cicy-desktop 2.1.92 → 2.1.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cicy-desktop +48 -18
- package/package.json +6 -6
- package/src/main.js +19 -1
- package/src/utils/context-menu-options.js +8 -6
package/bin/cicy-desktop
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn, execSync } = require("child_process");
|
|
2
|
+
const { spawn, execSync, execFileSync } = require("child_process");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const os = require("os");
|
|
@@ -76,13 +76,50 @@ function globalElectronDir() {
|
|
|
76
76
|
} catch { return null; }
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// The per-platform Electron artifact (mirror zip name + the in-dist executable
|
|
80
|
+
// that path.txt must point at).
|
|
81
|
+
function electronArtifact() {
|
|
82
|
+
const plat = process.platform === "win32" ? "win32" : process.platform === "darwin" ? "darwin" : "linux";
|
|
83
|
+
const arch = process.arch === "arm64" ? "arm64" : "x64";
|
|
84
|
+
return {
|
|
85
|
+
zip: `electron-v${ELECTRON_VERSION}-${plat}-${arch}.zip`,
|
|
86
|
+
exe: process.platform === "win32" ? "electron.exe"
|
|
87
|
+
: process.platform === "darwin" ? "Electron.app/Contents/MacOS/Electron"
|
|
88
|
+
: "electron",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Provision the Electron binary INTO the bundled npx copy ourselves: download the
|
|
93
|
+
// platform zip from the mirror (R2) with curl, extract with the OS's own unzip,
|
|
94
|
+
// then write path.txt. We deliberately do NOT use electron's install.js /
|
|
95
|
+
// @electron/get: on Windows its bundled extract-zip only PARTIALLY unpacks
|
|
96
|
+
// electron 41 (leaves no path.txt → "Electron failed to install correctly") even
|
|
97
|
+
// though the downloaded zip is valid. curl + Expand-Archive/unzip is reliable,
|
|
98
|
+
// mirror-only (no GitHub), and writes a complete dist/.
|
|
99
|
+
function provisionElectronFromMirror(bundledDir) {
|
|
100
|
+
const { zip, exe } = electronArtifact();
|
|
101
|
+
const url = `${ELECTRON_MIRROR}v${ELECTRON_VERSION}/${zip}`;
|
|
102
|
+
const tmpZip = path.join(os.tmpdir(), `cicy-${zip}`);
|
|
103
|
+
const curl = isWindows ? "curl.exe" : "curl";
|
|
104
|
+
execFileSync(curl, ["-fL", "--retry", "5", "--retry-delay", "2", "--connect-timeout", "20", "-o", tmpZip, url], { stdio: "inherit" });
|
|
105
|
+
const distDir = path.join(bundledDir, "dist");
|
|
106
|
+
fs.rmSync(distDir, { recursive: true, force: true });
|
|
107
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
108
|
+
if (isWindows) {
|
|
109
|
+
execFileSync("powershell", ["-NoProfile", "-Command", `Expand-Archive -LiteralPath "${tmpZip}" -DestinationPath "${distDir}" -Force`], { stdio: "inherit" });
|
|
110
|
+
} else {
|
|
111
|
+
execFileSync("unzip", ["-o", "-q", tmpZip, "-d", distDir], { stdio: "inherit" });
|
|
112
|
+
try { fs.chmodSync(path.join(distDir, exe), 0o755); } catch {}
|
|
113
|
+
}
|
|
114
|
+
fs.writeFileSync(path.join(bundledDir, "path.txt"), exe);
|
|
115
|
+
try { fs.rmSync(tmpZip, { force: true }); } catch {}
|
|
116
|
+
}
|
|
117
|
+
|
|
79
118
|
// Make sure a USABLE electron exists before spawning the worker. A pre-existing
|
|
80
|
-
// GLOBAL electron is reused if present
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
// start first-try even when the install-time postinstall couldn't fetch the
|
|
85
|
-
// binary (GitHub blocked/slow). Runs once per process.
|
|
119
|
+
// GLOBAL electron is reused if present. Otherwise we provision the binary LOCALLY
|
|
120
|
+
// into the bundled npx copy straight from the R2 mirror — NO `npm i -g`, NO
|
|
121
|
+
// GitHub, NO @electron/get. This is what lets a single `npx cicy-desktop`
|
|
122
|
+
// self-provision electron and start first-try. Runs once per process.
|
|
86
123
|
let _electronEnsured = false;
|
|
87
124
|
function ensureElectron() {
|
|
88
125
|
if (_electronEnsured) return;
|
|
@@ -96,20 +133,13 @@ function ensureElectron() {
|
|
|
96
133
|
console.warn(`⚠️ electron package not resolvable under ${PACKAGE_ROOT}; cannot self-provision.`);
|
|
97
134
|
return;
|
|
98
135
|
}
|
|
99
|
-
// The electron package is installed but its binary wasn't downloaded. Fetch it
|
|
100
|
-
// INTO node_modules/electron from the mirror (R2) by invoking electron's own
|
|
101
|
-
// installer — @electron/get reads ELECTRON_MIRROR and pulls
|
|
102
|
-
// <mirror>v<version>/electron-v<version>-<platform>.zip. Local, no global.
|
|
103
136
|
console.log(`⚙️ Fetching Electron ${ELECTRON_VERSION} from mirror (one-time)…`);
|
|
104
137
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
env: { ...process.env, ELECTRON_MIRROR, npm_config_registry: NPM_REGISTRY },
|
|
109
|
-
});
|
|
138
|
+
provisionElectronFromMirror(bundledDir);
|
|
139
|
+
if (electronBinaryHealthy(bundledDir)) return;
|
|
140
|
+
console.warn(`⚠️ Electron provisioned but health check still failing.`);
|
|
110
141
|
} catch (e) {
|
|
111
|
-
console.warn(`⚠️ Electron
|
|
112
|
-
console.warn(` Retry: ELECTRON_MIRROR=${ELECTRON_MIRROR} node "${path.join(bundledDir, "install.js")}"`);
|
|
142
|
+
console.warn(`⚠️ Electron provision from mirror failed: ${e.message}`);
|
|
113
143
|
}
|
|
114
144
|
}
|
|
115
145
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cicy-desktop",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.94",
|
|
4
4
|
"description": "CiCy - AI-powered operating system browser",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -133,11 +133,11 @@
|
|
|
133
133
|
"//optionalDependencies": "Runtime Bundle v1 (主人指令): platform binaries delivered by `npm i -g cicy-desktop` itself — npm installs only the current-platform subpackage (os/cpu pinned in each), so first start seeds the runtime store with ZERO network, ZERO npx. Windows packages are named *-windows-* (npm spam filter 403s new names containing win32). cicy-msys2 added once published.",
|
|
134
134
|
"optionalDependencies": {
|
|
135
135
|
"electron": "41.0.3",
|
|
136
|
-
"cicy-code-darwin-x64": "2.3.
|
|
137
|
-
"cicy-code-darwin-arm64": "2.3.
|
|
138
|
-
"cicy-code-linux-x64": "2.3.
|
|
139
|
-
"cicy-code-linux-arm64": "2.3.
|
|
140
|
-
"cicy-code-windows-x64": "2.3.
|
|
136
|
+
"cicy-code-darwin-x64": "2.3.13",
|
|
137
|
+
"cicy-code-darwin-arm64": "2.3.13",
|
|
138
|
+
"cicy-code-linux-x64": "2.3.13",
|
|
139
|
+
"cicy-code-linux-arm64": "2.3.13",
|
|
140
|
+
"cicy-code-windows-x64": "2.3.13",
|
|
141
141
|
"cicy-mihomo-darwin-x64": "1.10.4",
|
|
142
142
|
"cicy-mihomo-darwin-arm64": "1.10.4",
|
|
143
143
|
"cicy-mihomo-linux-x64": "1.10.4",
|
package/src/main.js
CHANGED
|
@@ -20,7 +20,25 @@ const appUpdater = require("./app-updater");
|
|
|
20
20
|
// and guests fell back to the OS-native menu; this unifies them and adds 重新加载
|
|
21
21
|
// + 切换开发者工具 + 检查元素 everywhere (see utils/context-menu-options.js).
|
|
22
22
|
const { attachContextMenu } = require("./utils/context-menu-options");
|
|
23
|
-
electronApp.on("web-contents-created", (_e, wc) =>
|
|
23
|
+
electronApp.on("web-contents-created", (_e, wc) => {
|
|
24
|
+
attachContextMenu(wc);
|
|
25
|
+
// Ctrl/Cmd+C inside a <webview> guest: on Windows the application menu's
|
|
26
|
+
// role:"copy" accelerator doesn't reach the focused guest, so a selection
|
|
27
|
+
// couldn't be copied with the keyboard (right-click 复制 is fixed separately via
|
|
28
|
+
// attachContextMenu). Wire copy directly on the guest. COPY-ONLY and WITHOUT
|
|
29
|
+
// preventDefault, so the gotty terminal's Ctrl+C=SIGINT and any web app's own
|
|
30
|
+
// copy handler still fire; wc.copy() is a no-op when there's no selection.
|
|
31
|
+
try {
|
|
32
|
+
if (wc.getType && wc.getType() === "webview") {
|
|
33
|
+
wc.on("before-input-event", (_ev, input) => {
|
|
34
|
+
if (input.type === "keyDown" && (input.control || input.meta) &&
|
|
35
|
+
!input.alt && !input.shift && (input.key === "c" || input.key === "C")) {
|
|
36
|
+
try { wc.copy(); } catch (_) {}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
} catch (_) {}
|
|
41
|
+
});
|
|
24
42
|
|
|
25
43
|
// Setup Electron flags IMMEDIATELY after require
|
|
26
44
|
electronApp.commandLine.appendSwitch("ignore-certificate-errors");
|
|
@@ -58,17 +58,19 @@ const OPTIONS = {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
// Attach the menu to the host window
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
61
|
+
// Attach the menu to the host window, BrowserView tabs AND <webview> guests, so
|
|
62
|
+
// right-click → 复制/粘贴 works on EVERY surface. Webviews used to be excluded on
|
|
63
|
+
// the assumption they carry their own copy menu, but on Windows that left
|
|
64
|
+
// selections uncopyable: the app menu's Ctrl+C / role:"copy" doesn't reach the
|
|
65
|
+
// focused <webview> guest, and no own-menu filled the gap. Giving guests the ecm
|
|
66
|
+
// 复制/粘贴 menu fixes copy cross-platform. Idempotent via __cicyCtxMenu so the
|
|
67
|
+
// web-contents-created hook + the tab-browser's per-tab call never double-pop.
|
|
66
68
|
function attachContextMenu(wc) {
|
|
67
69
|
try {
|
|
68
70
|
if (!wc || (wc.isDestroyed && wc.isDestroyed())) return;
|
|
69
71
|
if (wc.__cicyCtxMenu) return;
|
|
70
72
|
const t = wc.getType && wc.getType();
|
|
71
|
-
if (t !== "window" && t !== "browserView") return; //
|
|
73
|
+
if (t !== "window" && t !== "browserView" && t !== "webview") return; // host + tabs + <webview>
|
|
72
74
|
wc.__cicyCtxMenu = true;
|
|
73
75
|
contextMenu({ ...OPTIONS, window: wc });
|
|
74
76
|
} catch (e) {}
|