-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,651 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[target.'cfg(target_os = "linux")'] | ||
rustflags = ["-C", "link-arg=-nostartfiles", "-C", "target-feature=-crt-static"] | ||
|
||
[target.aarch64-unknown-linux-gnu] | ||
linker = "aarch64-linux-gnu-gcc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
target | ||
Cargo.lock | ||
.cargo | ||
.github | ||
npm | ||
.eslintrc | ||
.prettierignore | ||
rustfmt.toml | ||
yarn.lock | ||
*.node | ||
.yarn | ||
__test__ | ||
renovate.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
edition = "2021" | ||
name = "rubick-native" | ||
version = "0.0.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
rdev = { version = "0.5", features = ["serialize", "unstable_grab"] } | ||
clipboard-files = "0.1" | ||
copypasta = "0.10" | ||
enigo = "0.1" | ||
napi = { version = "2", features = ["async"] } | ||
napi-derive = "2" | ||
serde_json = "1" | ||
lnk_parser = "0.4" | ||
parselnk = "0.1" | ||
pelite = "0.10" | ||
base64 = "0.21" | ||
tokio = { version = "1", features = ["full"] } | ||
|
||
[build-dependencies] | ||
napi-build = "2" | ||
|
||
[profile.release] | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate napi_build; | ||
|
||
fn main() { | ||
napi_build::setup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getClipboardContent as gcbc } from "addon" | ||
|
||
interface ClipboardContentText { | ||
type: "text", | ||
content: string | ||
} | ||
|
||
interface ClipboardContentFile { | ||
type: "file", | ||
content: string[] | ||
} | ||
|
||
export type ClipboardContent = ClipboardContentText | ClipboardContentFile | null | ||
|
||
export const getClipboardContent = (): ClipboardContent => { | ||
const c = gcbc() | ||
if (c?.type === 'text') { | ||
return { | ||
type: "text", | ||
content: c.content.at(0) | ||
} | ||
} else { | ||
return c as ClipboardContent | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// import { arch, platform, homedir } from "os" | ||
// import { onClipboardChange } from "../../addon" | ||
// import got from "got" | ||
// import { Extract } from "unzip-stream" | ||
// import { access, mkdir, constants } from "fs/promises" | ||
// import { join } from "path" | ||
// import { execaCommand } from "execa" | ||
// const getKey = (stdout: string, key: string) => stdout.split(`"${key}": `).at(1)?.split(`,\r\n`).at(0)! | ||
// import { asyncFolderWalker } from "async-folder-walker" | ||
|
||
// // 启动剪切板程序 | ||
// export default async () => { | ||
// let latestNum = 0 | ||
// const repoURL = "https://ghproxy.com/https://github.com/Slackadays/Clipboard" | ||
// let a = arch() | ||
// let p: string = platform() | ||
// // 确保目录存在 | ||
// const dirPath = join(homedir(), "cb") | ||
// try { | ||
// await access(dirPath, constants.O_DIRECTORY) | ||
// } catch { | ||
// await mkdir(dirPath) | ||
// } | ||
// // cb 路径 | ||
// const cbPath = join(dirPath, 'bin', p === "win32" ? "cb.exe" : "cb") | ||
// // 同步剪切板内容 | ||
// const execCB = async () => { | ||
// const stdout = (await execaCommand(cbPath + " info", { env: { "CLIPBOARD_SILENT": "true" } })).stdout | ||
// // 最新缓存 | ||
// latestNum = Number(getKey(stdout, "totalEntries")) - 1 | ||
// return stdout | ||
// } | ||
// try { | ||
// await access(cbPath) | ||
// } catch { | ||
// switch (a) { | ||
// case "arm64": | ||
// break; | ||
// case "x64": | ||
// a = "amd64" | ||
// break; | ||
// default: | ||
// throw new Error("Not Support Your Sys Arch") | ||
// } | ||
// switch (p) { | ||
// case "freebsd": | ||
// case "linux": | ||
// case "netbsd": | ||
// case "openbsd": | ||
// break; | ||
// case "win32": | ||
// p = "windows" | ||
// break; | ||
// case "darwin": | ||
// p = "macos" | ||
// break; | ||
// default: | ||
// throw new Error("Not Support Your Sys Arch") | ||
// } | ||
// const latest = (await fetch(repoURL + "/releases/latest")).url.split("/").pop() | ||
// const durl = repoURL + `/releases/download/${latest}/clipboard-${p}-${p === "macos" ? 'arm64-amd64' : a}.zip` | ||
// got.stream(durl).pipe(Extract({ path: dirPath })) | ||
// } finally { | ||
// // 剪切板历史路径 | ||
// const basePath = join(getKey(await execCB(), "path").replaceAll('"', ''), "data") | ||
// // 剪切板监听 | ||
// onClipboardChange(execCB) | ||
// return { | ||
// latest: () => { | ||
// const latestPath = join(basePath, latestNum.toString()) | ||
// const walker = asyncFolderWalker(latestPath, { maxDepth: 0 }) | ||
// return walker | ||
// } | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/got": "^9.6.12", | ||
"@types/node": "^20.7.1", | ||
"@types/unzip-stream": "^0.3.2" | ||
}, | ||
"dependencies": { | ||
"async-folder-walker": "^2.2.1", | ||
"execa": "^8.0.1", | ||
"got": "^13.0.0", | ||
"unzip-stream": "^0.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { activeWindow } from "@miniben90/x-win" | ||
import { lstat } from "fs/promises" | ||
import { homedir } from "os" | ||
import { join } from "path" | ||
|
||
// 获取活动的文件夹路径 | ||
export const getFolderOpenPath = async () => { | ||
if (process.platform === 'darwin') { | ||
const { execa } = await import("execa") | ||
const res = await execa('osascript', ['-e', ` | ||
tell app "Finder" | ||
try | ||
POSIX path of (insertion location as alias) | ||
on error | ||
POSIX path of (path to desktop folder as alias) | ||
end try | ||
end tell | ||
`]) | ||
return res.stdout; | ||
} | ||
|
||
if (process.platform === 'win32') { | ||
const win = activeWindow() | ||
if (win.info.execName === 'explorer') { | ||
const base = homedir() | ||
let path: string | ||
switch (win.title) { | ||
case 'Home': | ||
case '主文件夹': | ||
path = base | ||
break; | ||
|
||
case 'Downloads': | ||
case '下载': | ||
path = join(base, 'Downloads') | ||
break; | ||
|
||
case 'Documents': | ||
case '文档': | ||
path = join(base, 'Documents') | ||
break; | ||
|
||
case 'Desktop': | ||
case '桌面': | ||
path = join(base, 'Desktop') | ||
break; | ||
|
||
case 'Videos': | ||
case '视频': | ||
path = join(base, 'Videos') | ||
break; | ||
|
||
case 'Pictures': | ||
case '图片': | ||
path = join(base, 'Pictures') | ||
break; | ||
|
||
case 'Music': | ||
case '音乐': | ||
path = join(base, 'Music') | ||
break; | ||
|
||
case 'Links': | ||
case '链接': | ||
path = join(base, 'Music') | ||
break; | ||
|
||
default: | ||
path = win.title | ||
break; | ||
} | ||
try { | ||
const s = await lstat(path) | ||
if (s.isDirectory()) { | ||
return path | ||
} | ||
} catch { | ||
return null | ||
} | ||
} | ||
} | ||
|
||
// todo linux | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { activeWindow as getActiveWin, openWindows as getOpenWin } from "@miniben90/x-win" | ||
export * from "./clipboard" | ||
export * from "./folder" | ||
export * from "./simulation" | ||
export * from "./monitor" | ||
export * from './sysapp' |
Oops, something went wrong.