@dsh-sup/dsh-core-win-x64 0.1.5-BETA.2 → 0.1.5-BETA.3
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/core.cjs +265 -138
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -225,7 +225,7 @@ var require_version = __commonJS({
|
|
|
225
225
|
var fs2 = require("node:fs");
|
|
226
226
|
var path2 = require("node:path");
|
|
227
227
|
function guardVersion() {
|
|
228
|
-
if (true) return String("0.1.5-BETA.
|
|
228
|
+
if (true) return String("0.1.5-BETA.3");
|
|
229
229
|
try {
|
|
230
230
|
return JSON.parse(fs2.readFileSync(path2.join(__dirname, "..", "..", "package.json"), "utf8")).version || "unknown";
|
|
231
231
|
} catch {
|
|
@@ -236,6 +236,64 @@ var require_version = __commonJS({
|
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
|
|
239
|
+
// src/platform/matrix.js
|
|
240
|
+
var require_matrix = __commonJS({
|
|
241
|
+
"src/platform/matrix.js"(exports2, module2) {
|
|
242
|
+
"use strict";
|
|
243
|
+
var SUPPORTED = [
|
|
244
|
+
{ platform: "linux", arch: "x64", osTag: "linux", npmTag: "linux-x64" },
|
|
245
|
+
{ platform: "darwin", arch: "arm64", osTag: "darwin", npmTag: "darwin-arm64" },
|
|
246
|
+
{ platform: "darwin", arch: "x64", osTag: "darwin", npmTag: "darwin-x64" },
|
|
247
|
+
{ platform: "win32", arch: "x64", osTag: "win", npmTag: "win-x64" }
|
|
248
|
+
];
|
|
249
|
+
var OS_TAG = { linux: "linux", darwin: "darwin", win32: "win" };
|
|
250
|
+
var FRP_OS = { linux: "linux", darwin: "darwin", win32: "windows" };
|
|
251
|
+
var FRP_ARCH = { x64: "amd64", arm64: "arm64" };
|
|
252
|
+
function osTag(platform) {
|
|
253
|
+
return OS_TAG[platform || process.platform] || null;
|
|
254
|
+
}
|
|
255
|
+
function current(platform, arch) {
|
|
256
|
+
const p = platform || process.platform;
|
|
257
|
+
const a = arch || process.arch;
|
|
258
|
+
return { platform: p, arch: a, osTag: OS_TAG[p] || null, npmTag: npmTag(p, a) };
|
|
259
|
+
}
|
|
260
|
+
function npmTag(platform, arch) {
|
|
261
|
+
const p = platform || process.platform;
|
|
262
|
+
const a = arch || process.arch;
|
|
263
|
+
const os2 = OS_TAG[p];
|
|
264
|
+
if (!os2 || a !== "x64" && a !== "arm64") {
|
|
265
|
+
throw new Error("\u4E0D\u652F\u6301\u7684\u5E73\u53F0\u7EC4\u5408: " + p + "/" + a + "\uFF08\u4EC5 linux/darwin/win32 \xD7 x64/arm64\uFF09");
|
|
266
|
+
}
|
|
267
|
+
return os2 + "-" + a;
|
|
268
|
+
}
|
|
269
|
+
function isSupported(platform, arch) {
|
|
270
|
+
const p = platform || process.platform;
|
|
271
|
+
const a = arch || process.arch;
|
|
272
|
+
return !!(OS_TAG[p] && (a === "x64" || a === "arm64"));
|
|
273
|
+
}
|
|
274
|
+
function frpTag(platform, arch) {
|
|
275
|
+
const p = platform || process.platform;
|
|
276
|
+
const a = arch || process.arch;
|
|
277
|
+
const os2 = FRP_OS[p];
|
|
278
|
+
const am = FRP_ARCH[a];
|
|
279
|
+
if (!os2 || !am) return null;
|
|
280
|
+
return { os: os2, arch: am, tag: os2 + "_" + am, exe: p === "win32" };
|
|
281
|
+
}
|
|
282
|
+
function supportsProcessGroup(platform) {
|
|
283
|
+
return (platform || process.platform) !== "win32";
|
|
284
|
+
}
|
|
285
|
+
module2.exports = {
|
|
286
|
+
SUPPORTED,
|
|
287
|
+
osTag,
|
|
288
|
+
current,
|
|
289
|
+
npmTag,
|
|
290
|
+
isSupported,
|
|
291
|
+
frpTag,
|
|
292
|
+
supportsProcessGroup
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
239
297
|
// src/platform/os/pidlookup.js
|
|
240
298
|
var require_pidlookup = __commonJS({
|
|
241
299
|
"src/platform/os/pidlookup.js"(exports2, module2) {
|
|
@@ -245,6 +303,56 @@ var require_pidlookup = __commonJS({
|
|
|
245
303
|
var isLinux = process.platform === "linux";
|
|
246
304
|
var isMac = process.platform === "darwin";
|
|
247
305
|
var isWindows = process.platform === "win32";
|
|
306
|
+
function parseProcNetTcpInodes(txt, port) {
|
|
307
|
+
const inodes = /* @__PURE__ */ new Set();
|
|
308
|
+
for (const lineRaw of String(txt || "").split("\n")) {
|
|
309
|
+
const cols = lineRaw.trim().split(/\s+/);
|
|
310
|
+
if (cols.length < 10) continue;
|
|
311
|
+
const local = cols[1];
|
|
312
|
+
const st = cols[3];
|
|
313
|
+
const inode = cols[9];
|
|
314
|
+
if (!local || !inode) continue;
|
|
315
|
+
const p = local.split(":")[1];
|
|
316
|
+
if (st === "0A" && p && parseInt(p, 16) === port) inodes.add("socket:[" + inode + "]");
|
|
317
|
+
}
|
|
318
|
+
return inodes;
|
|
319
|
+
}
|
|
320
|
+
function parseLsofPid(out) {
|
|
321
|
+
for (const line of String(out || "").split("\n")) {
|
|
322
|
+
const m = line.trim().split(/\s+/);
|
|
323
|
+
if (m.length >= 2 && /^\d+$/.test(m[1])) return Number(m[1]);
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
function parseNetstatPid(out, port) {
|
|
328
|
+
const want = String(port);
|
|
329
|
+
for (const line of String(out || "").split("\n")) {
|
|
330
|
+
const parts = line.trim().split(/\s+/);
|
|
331
|
+
if (parts.length >= 5 && (parts[0] === "TCP" || parts[0] === "TCPv6") && parts[3] === "LISTENING") {
|
|
332
|
+
const lp = parts[1];
|
|
333
|
+
const p = lp.slice(lp.lastIndexOf(":") + 1);
|
|
334
|
+
if (p === want) {
|
|
335
|
+
const pid = Number(parts[4]);
|
|
336
|
+
if (Number.isInteger(pid) && pid > 0) return pid;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
function parseSsPid(out) {
|
|
343
|
+
const m = out && /pid=(\d+)/.exec(String(out));
|
|
344
|
+
return m ? Number(m[1]) : null;
|
|
345
|
+
}
|
|
346
|
+
function parseWmicCommandLine(out) {
|
|
347
|
+
if (!out) return null;
|
|
348
|
+
const m = /CommandLine=([\s\S]*)/.exec(String(out));
|
|
349
|
+
const v = m ? m[1].trim() : "";
|
|
350
|
+
return v || null;
|
|
351
|
+
}
|
|
352
|
+
function parsePowerShellCommandLine(out) {
|
|
353
|
+
const v = out ? String(out).trim() : "";
|
|
354
|
+
return v || null;
|
|
355
|
+
}
|
|
248
356
|
function linuxListeningInodes(port) {
|
|
249
357
|
const inodes = /* @__PURE__ */ new Set();
|
|
250
358
|
for (const f of ["/proc/net/tcp", "/proc/net/tcp6"]) {
|
|
@@ -254,16 +362,7 @@ var require_pidlookup = __commonJS({
|
|
|
254
362
|
} catch {
|
|
255
363
|
continue;
|
|
256
364
|
}
|
|
257
|
-
for (const
|
|
258
|
-
const cols = lineRaw.trim().split(/\s+/);
|
|
259
|
-
if (cols.length < 10) continue;
|
|
260
|
-
const local = cols[1];
|
|
261
|
-
const st = cols[3];
|
|
262
|
-
const inode = cols[9];
|
|
263
|
-
if (!local || !inode) continue;
|
|
264
|
-
const p = local.split(":")[1];
|
|
265
|
-
if (st === "0A" && p && parseInt(p, 16) === port) inodes.add("socket:[" + inode + "]");
|
|
266
|
-
}
|
|
365
|
+
for (const x of parseProcNetTcpInodes(txt, port)) inodes.add(x);
|
|
267
366
|
}
|
|
268
367
|
return inodes;
|
|
269
368
|
}
|
|
@@ -297,10 +396,7 @@ var require_pidlookup = __commonJS({
|
|
|
297
396
|
try {
|
|
298
397
|
const out = ex2.runOut("lsof", ["-nP", "-iTCP:" + port, "-sTCP:LISTEN"], { timeoutMs: 3e3 });
|
|
299
398
|
if (!out) return null;
|
|
300
|
-
|
|
301
|
-
const m = line.trim().split(/\s+/);
|
|
302
|
-
if (m.length >= 2 && /^\d+$/.test(m[1])) return Number(m[1]);
|
|
303
|
-
}
|
|
399
|
+
return parseLsofPid(out);
|
|
304
400
|
} catch {
|
|
305
401
|
}
|
|
306
402
|
return null;
|
|
@@ -309,18 +405,7 @@ var require_pidlookup = __commonJS({
|
|
|
309
405
|
try {
|
|
310
406
|
const out = ex2.runOut("netstat", ["-ano"], { timeoutMs: 3e3 });
|
|
311
407
|
if (!out) return null;
|
|
312
|
-
|
|
313
|
-
for (const line of out.split("\n")) {
|
|
314
|
-
const parts = line.trim().split(/\s+/);
|
|
315
|
-
if (parts.length >= 5 && (parts[0] === "TCP" || parts[0] === "TCPv6") && parts[3] === "LISTENING") {
|
|
316
|
-
const lp = parts[1];
|
|
317
|
-
const p = lp.slice(lp.lastIndexOf(":") + 1);
|
|
318
|
-
if (p === want) {
|
|
319
|
-
const pid = Number(parts[4]);
|
|
320
|
-
if (Number.isInteger(pid) && pid > 0) return pid;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
408
|
+
return parseNetstatPid(out, port);
|
|
324
409
|
} catch {
|
|
325
410
|
}
|
|
326
411
|
return null;
|
|
@@ -330,8 +415,8 @@ var require_pidlookup = __commonJS({
|
|
|
330
415
|
for (const ssBin of candidates) {
|
|
331
416
|
try {
|
|
332
417
|
const out = ex2.runOut(ssBin, ["-tlnHp", "sport = :" + port], { timeoutMs: 3e3 });
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
418
|
+
const pid = parseSsPid(out);
|
|
419
|
+
if (pid !== null) return pid;
|
|
335
420
|
} catch {
|
|
336
421
|
}
|
|
337
422
|
}
|
|
@@ -375,15 +460,12 @@ var require_pidlookup = __commonJS({
|
|
|
375
460
|
}
|
|
376
461
|
if (isWindows) {
|
|
377
462
|
const out = ex2.runOut("wmic", ["process", "where", "ProcessId=" + pid, "get", "CommandLine", "/value"], { timeoutMs: 5e3 });
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const viaWmic = m ? m[1].trim() : "";
|
|
381
|
-
if (viaWmic) return viaWmic;
|
|
382
|
-
}
|
|
463
|
+
const viaWmic = parseWmicCommandLine(out);
|
|
464
|
+
if (viaWmic) return viaWmic;
|
|
383
465
|
{
|
|
384
466
|
const ps = "(Get-CimInstance Win32_Process -Filter 'ProcessId=" + pid + "').CommandLine";
|
|
385
467
|
const o = ex2.runOut("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], { timeoutMs: 5e3 });
|
|
386
|
-
return o
|
|
468
|
+
return parsePowerShellCommandLine(o);
|
|
387
469
|
}
|
|
388
470
|
}
|
|
389
471
|
return null;
|
|
@@ -439,7 +521,21 @@ var require_pidlookup = __commonJS({
|
|
|
439
521
|
function normCmdline(s) {
|
|
440
522
|
return String(s || "").replace(/\\/g, "/");
|
|
441
523
|
}
|
|
442
|
-
module2.exports = {
|
|
524
|
+
module2.exports = {
|
|
525
|
+
findListeningPid,
|
|
526
|
+
isAlive,
|
|
527
|
+
readCmdline,
|
|
528
|
+
normCmdline,
|
|
529
|
+
isDshCmdline,
|
|
530
|
+
pgrepList,
|
|
531
|
+
// 平台输出纯解析器(2026-09-13 抽出:使其可在任意宿主上穷举;生产代码直接调用,非平行实现)
|
|
532
|
+
parseProcNetTcpInodes,
|
|
533
|
+
parseLsofPid,
|
|
534
|
+
parseNetstatPid,
|
|
535
|
+
parseSsPid,
|
|
536
|
+
parseWmicCommandLine,
|
|
537
|
+
parsePowerShellCommandLine
|
|
538
|
+
};
|
|
443
539
|
}
|
|
444
540
|
});
|
|
445
541
|
|
|
@@ -868,13 +964,14 @@ var require_exec_path = __commonJS({
|
|
|
868
964
|
}
|
|
869
965
|
return null;
|
|
870
966
|
}
|
|
871
|
-
function standardDirs(platform, home) {
|
|
967
|
+
function standardDirs(platform, home, env) {
|
|
872
968
|
const pl = platform || process.platform;
|
|
873
969
|
const h = home || os2.homedir();
|
|
970
|
+
const e = env || process.env;
|
|
874
971
|
const dirs = [];
|
|
875
972
|
if (pl === "win32") {
|
|
876
|
-
if (
|
|
877
|
-
if (
|
|
973
|
+
if (e.APPDATA) dirs.push(path2.join(e.APPDATA, "npm"));
|
|
974
|
+
if (e.LOCALAPPDATA) dirs.push(path2.join(e.LOCALAPPDATA, "Programs", "dsh-supervisor"));
|
|
878
975
|
dirs.push(path2.join(h, ".local", "bin"));
|
|
879
976
|
} else {
|
|
880
977
|
dirs.push(path2.join(h, ".local", "bin"));
|
|
@@ -886,8 +983,9 @@ var require_exec_path = __commonJS({
|
|
|
886
983
|
}
|
|
887
984
|
return dirs;
|
|
888
985
|
}
|
|
889
|
-
function inPath(base, platform) {
|
|
890
|
-
const
|
|
986
|
+
function inPath(base, platform, env) {
|
|
987
|
+
const e = env || process.env;
|
|
988
|
+
const raw = e.PATH || e.Path || "";
|
|
891
989
|
for (const d of raw.split(path2.delimiter)) {
|
|
892
990
|
if (!d) continue;
|
|
893
991
|
const hit = firstExecutable(d, base, platform);
|
|
@@ -897,35 +995,42 @@ var require_exec_path = __commonJS({
|
|
|
897
995
|
}
|
|
898
996
|
function resolveExecutable(base, opts) {
|
|
899
997
|
const o = opts || {};
|
|
900
|
-
|
|
901
|
-
|
|
998
|
+
const pl = o.platform;
|
|
999
|
+
const env = o.env;
|
|
1000
|
+
const E = env || process.env;
|
|
1001
|
+
if (o.envVar && E[o.envVar]) {
|
|
1002
|
+
const v = E[o.envVar];
|
|
902
1003
|
try {
|
|
903
1004
|
if (fs2.statSync(v).isFile()) return v;
|
|
904
1005
|
} catch {
|
|
905
1006
|
}
|
|
906
1007
|
}
|
|
907
|
-
const inPathHit = inPath(base);
|
|
1008
|
+
const inPathHit = inPath(base, pl, env);
|
|
908
1009
|
if (inPathHit) return inPathHit;
|
|
909
|
-
for (const d of [...o.extraDirs || [], ...standardDirs()]) {
|
|
910
|
-
const hit = firstExecutable(d, base);
|
|
1010
|
+
for (const d of [...o.extraDirs || [], ...standardDirs(pl, void 0, env)]) {
|
|
1011
|
+
const hit = firstExecutable(d, base, pl);
|
|
911
1012
|
if (hit) return hit;
|
|
912
1013
|
}
|
|
913
1014
|
return null;
|
|
914
1015
|
}
|
|
915
1016
|
function npxBin(opts) {
|
|
916
|
-
const
|
|
1017
|
+
const o = opts || {};
|
|
1018
|
+
const pl = o.platform || process.platform;
|
|
1019
|
+
const env = o.env || process.env;
|
|
917
1020
|
if (pl !== "win32") return "npx";
|
|
918
|
-
const resolved = resolveExecutable("npx", { extraDirs: [
|
|
919
|
-
|
|
1021
|
+
const resolved = resolveExecutable("npx", { platform: pl, env, extraDirs: [
|
|
1022
|
+
env.APPDATA ? path2.join(env.APPDATA, "npm") : null
|
|
920
1023
|
].filter(Boolean) });
|
|
921
1024
|
if (resolved) return resolved;
|
|
922
1025
|
return "npx.cmd";
|
|
923
1026
|
}
|
|
924
1027
|
function npmBin(opts) {
|
|
925
|
-
const
|
|
1028
|
+
const o = opts || {};
|
|
1029
|
+
const pl = o.platform || process.platform;
|
|
1030
|
+
const env = o.env || process.env;
|
|
926
1031
|
if (pl !== "win32") return "npm";
|
|
927
|
-
const resolved = resolveExecutable("npm", { extraDirs: [
|
|
928
|
-
|
|
1032
|
+
const resolved = resolveExecutable("npm", { platform: pl, env, extraDirs: [
|
|
1033
|
+
env.APPDATA ? path2.join(env.APPDATA, "npm") : null
|
|
929
1034
|
].filter(Boolean) });
|
|
930
1035
|
if (resolved) return resolved;
|
|
931
1036
|
return "npm.cmd";
|
|
@@ -1174,53 +1279,54 @@ var require_notify = __commonJS({
|
|
|
1174
1279
|
"src/platform/os/notify.js"(exports2, module2) {
|
|
1175
1280
|
"use strict";
|
|
1176
1281
|
var { spawn } = require("node:child_process");
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1282
|
+
function appleScriptString(s) {
|
|
1283
|
+
return JSON.stringify(String(s));
|
|
1284
|
+
}
|
|
1285
|
+
function powerShellString(s) {
|
|
1286
|
+
return '"' + String(s).replace(/"/g, '""') + '"';
|
|
1287
|
+
}
|
|
1288
|
+
function notifyCommand(platform, title, body) {
|
|
1289
|
+
const pl = platform || process.platform;
|
|
1290
|
+
const t = String(title == null ? "" : title);
|
|
1291
|
+
const b = String(body == null ? "" : body);
|
|
1292
|
+
if (pl === "linux") {
|
|
1293
|
+
return { cmd: "notify-send", args: ["-a", "dsh-supervisor", t, b] };
|
|
1294
|
+
}
|
|
1295
|
+
if (pl === "darwin") {
|
|
1296
|
+
const script = "display notification " + appleScriptString(b) + " with title " + appleScriptString(t);
|
|
1297
|
+
return { cmd: "osascript", args: ["-e", script] };
|
|
1298
|
+
}
|
|
1299
|
+
if (pl === "win32") {
|
|
1300
|
+
const ps = [
|
|
1301
|
+
'[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null',
|
|
1302
|
+
'[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null',
|
|
1303
|
+
"$n = New-Object System.Windows.Forms.NotifyIcon",
|
|
1304
|
+
"$n.Icon = [System.Drawing.SystemIcons]::Information",
|
|
1305
|
+
"$n.Visible = $true",
|
|
1306
|
+
"$n.ShowBalloonTip(4000, " + powerShellString(t) + ", " + powerShellString(b) + ", [System.Windows.Forms.ToolTipIcon]::None)",
|
|
1307
|
+
"Start-Sleep -Milliseconds 4200",
|
|
1308
|
+
"$n.Dispose(); $n.Visible = $false"
|
|
1309
|
+
].join("; ");
|
|
1310
|
+
return { cmd: "powershell", args: ["-NoProfile", "-NonInteractive", "-Command", ps] };
|
|
1311
|
+
}
|
|
1312
|
+
return null;
|
|
1313
|
+
}
|
|
1180
1314
|
function notify(title, body, onError) {
|
|
1181
1315
|
try {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (isMac) {
|
|
1191
|
-
const script = "display notification " + JSON.stringify(String(body)) + " with title " + JSON.stringify(String(title));
|
|
1192
|
-
const c = spawn("osascript", ["-e", script], { stdio: "ignore" });
|
|
1193
|
-
c.on("error", () => {
|
|
1194
|
-
if (onError) onError();
|
|
1195
|
-
});
|
|
1196
|
-
c.unref();
|
|
1197
|
-
return true;
|
|
1198
|
-
}
|
|
1199
|
-
if (isWindows) {
|
|
1200
|
-
const ps = [
|
|
1201
|
-
'[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null',
|
|
1202
|
-
'[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null',
|
|
1203
|
-
"$n = New-Object System.Windows.Forms.NotifyIcon",
|
|
1204
|
-
"$n.Icon = [System.Drawing.SystemIcons]::Information",
|
|
1205
|
-
"$n.Visible = $true",
|
|
1206
|
-
"$n.ShowBalloonTip(4000, " + JSON.stringify(String(title)) + ", " + JSON.stringify(String(body)) + ", [System.Windows.Forms.ToolTipIcon]::None)",
|
|
1207
|
-
"Start-Sleep -Milliseconds 4200",
|
|
1208
|
-
"$n.Dispose(); $n.Visible = $false"
|
|
1209
|
-
].join("; ");
|
|
1210
|
-
const c = spawn("powershell", ["-NoProfile", "-NonInteractive", "-Command", ps], { stdio: "ignore" });
|
|
1211
|
-
c.on("error", () => {
|
|
1212
|
-
if (onError) onError();
|
|
1213
|
-
});
|
|
1214
|
-
c.unref();
|
|
1215
|
-
return true;
|
|
1216
|
-
}
|
|
1217
|
-
return false;
|
|
1316
|
+
const plan = notifyCommand(process.platform, title, body);
|
|
1317
|
+
if (!plan) return false;
|
|
1318
|
+
const c = spawn(plan.cmd, plan.args, { stdio: "ignore", detached: process.platform === "linux" });
|
|
1319
|
+
c.on("error", () => {
|
|
1320
|
+
if (onError) onError();
|
|
1321
|
+
});
|
|
1322
|
+
c.unref();
|
|
1323
|
+
return true;
|
|
1218
1324
|
} catch {
|
|
1219
1325
|
if (onError) onError();
|
|
1220
1326
|
return false;
|
|
1221
1327
|
}
|
|
1222
1328
|
}
|
|
1223
|
-
module2.exports = { notify };
|
|
1329
|
+
module2.exports = { notify, notifyCommand, appleScriptString, powerShellString };
|
|
1224
1330
|
}
|
|
1225
1331
|
});
|
|
1226
1332
|
|
|
@@ -1229,9 +1335,16 @@ var require_browser = __commonJS({
|
|
|
1229
1335
|
"src/platform/os/browser.js"(exports2, module2) {
|
|
1230
1336
|
"use strict";
|
|
1231
1337
|
var { spawn } = require("node:child_process");
|
|
1338
|
+
function openCommand(platform, url) {
|
|
1339
|
+
const pl = platform || process.platform;
|
|
1340
|
+
if (pl === "darwin") return { cmd: "open", args: [url] };
|
|
1341
|
+
if (pl === "win32") return { cmd: "cmd", args: ["/c", "start", "", url] };
|
|
1342
|
+
return { cmd: "xdg-open", args: [url] };
|
|
1343
|
+
}
|
|
1232
1344
|
function open(url) {
|
|
1233
1345
|
try {
|
|
1234
|
-
const
|
|
1346
|
+
const c = openCommand(process.platform, url);
|
|
1347
|
+
const p = spawn(c.cmd, c.args, { detached: true, stdio: "ignore" });
|
|
1235
1348
|
p.on("error", () => {
|
|
1236
1349
|
});
|
|
1237
1350
|
p.unref();
|
|
@@ -1258,6 +1371,37 @@ var require_browser = __commonJS({
|
|
|
1258
1371
|
child.unref();
|
|
1259
1372
|
return child;
|
|
1260
1373
|
}
|
|
1374
|
+
function isolatedPlan(platform, url, opts) {
|
|
1375
|
+
const o = opts || {};
|
|
1376
|
+
const antiArgs = o.antiArgs || [];
|
|
1377
|
+
const profileDir = o.profileDir;
|
|
1378
|
+
const pl = platform || process.platform;
|
|
1379
|
+
if (pl === "darwin") {
|
|
1380
|
+
return { kind: "single", bin: "open", args: ["-na", "Google Chrome", "--args", ...antiArgs], isolated: true, label: "Google Chrome" };
|
|
1381
|
+
}
|
|
1382
|
+
if (pl === "win32") {
|
|
1383
|
+
return {
|
|
1384
|
+
kind: "single",
|
|
1385
|
+
bin: "cmd",
|
|
1386
|
+
args: ["/c", "start", "", "chrome", "--incognito", "--user-data-dir=" + profileDir, url],
|
|
1387
|
+
isolated: true,
|
|
1388
|
+
label: "chrome"
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
return {
|
|
1392
|
+
kind: "chain",
|
|
1393
|
+
candidates: [
|
|
1394
|
+
{ bin: "microsoft-edge", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
|
|
1395
|
+
{ bin: "microsoft-edge-stable", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
|
|
1396
|
+
{ bin: "google-chrome", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
|
|
1397
|
+
{ bin: "chromium", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
|
|
1398
|
+
{ bin: "chromium-browser", args: antiArgs, isolated: true, watch: true, envKind: "anti" },
|
|
1399
|
+
{ bin: "firefox", args: ["--private-window", url], isolated: false, watch: true, envKind: "sys" },
|
|
1400
|
+
{ bin: "xdg-open", args: [url], isolated: false, watch: false, envKind: "sys" }
|
|
1401
|
+
// 兜底:无隔离
|
|
1402
|
+
]
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1261
1405
|
function launchIsolated(url, o) {
|
|
1262
1406
|
const opts = o || {};
|
|
1263
1407
|
const profileDir = opts.profileDir;
|
|
@@ -1266,31 +1410,20 @@ var require_browser = __commonJS({
|
|
|
1266
1410
|
const sysEnv = opts.sysEnv || process.env;
|
|
1267
1411
|
const onExit = opts.onExit;
|
|
1268
1412
|
try {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
return { ok: !!p, bin: p ? "chrome" : null, isolated: true };
|
|
1276
|
-
}
|
|
1277
|
-
const candidates = [
|
|
1278
|
-
{ bin: "microsoft-edge", args: antiArgs, env: antiEnv, isolated: true, watch: true },
|
|
1279
|
-
{ bin: "microsoft-edge-stable", args: antiArgs, env: antiEnv, isolated: true, watch: true },
|
|
1280
|
-
{ bin: "google-chrome", args: antiArgs, env: antiEnv, isolated: true, watch: true },
|
|
1281
|
-
{ bin: "chromium", args: antiArgs, env: antiEnv, isolated: true, watch: true },
|
|
1282
|
-
{ bin: "chromium-browser", args: antiArgs, env: antiEnv, isolated: true, watch: true },
|
|
1283
|
-
{ bin: "firefox", args: ["--private-window", url], env: sysEnv, isolated: false, watch: true },
|
|
1284
|
-
{ bin: "xdg-open", args: [url], env: sysEnv, isolated: false, watch: false }
|
|
1285
|
-
// 兜底:无隔离
|
|
1286
|
-
];
|
|
1413
|
+
const plan = isolatedPlan(process.platform, url, { profileDir, antiArgs });
|
|
1414
|
+
if (plan.kind === "single") {
|
|
1415
|
+
const env = plan.bin === "open" ? antiEnv : sysEnv;
|
|
1416
|
+
const p = _spawnDetached(plan.bin, plan.args, env, onExit);
|
|
1417
|
+
return { ok: !!p, bin: p ? plan.label : null, isolated: plan.isolated };
|
|
1418
|
+
}
|
|
1287
1419
|
let idx = 0;
|
|
1288
1420
|
const tryNext = () => {
|
|
1289
|
-
if (idx >= candidates.length) return { ok: false, bin: null, isolated: false };
|
|
1290
|
-
const c = candidates[idx++];
|
|
1421
|
+
if (idx >= plan.candidates.length) return { ok: false, bin: null, isolated: false };
|
|
1422
|
+
const c = plan.candidates[idx++];
|
|
1423
|
+
const env = c.envKind === "anti" ? antiEnv : sysEnv;
|
|
1291
1424
|
let child;
|
|
1292
1425
|
try {
|
|
1293
|
-
child = spawn(c.bin, c.args, { detached: true, stdio: "ignore", env:
|
|
1426
|
+
child = spawn(c.bin, c.args, { detached: true, stdio: "ignore", env: env || sysEnv });
|
|
1294
1427
|
} catch {
|
|
1295
1428
|
return tryNext();
|
|
1296
1429
|
}
|
|
@@ -1311,7 +1444,7 @@ var require_browser = __commonJS({
|
|
|
1311
1444
|
return { ok: false, bin: null, isolated: false };
|
|
1312
1445
|
}
|
|
1313
1446
|
}
|
|
1314
|
-
module2.exports = { open, launchIsolated };
|
|
1447
|
+
module2.exports = { open, launchIsolated, openCommand, isolatedPlan };
|
|
1315
1448
|
}
|
|
1316
1449
|
});
|
|
1317
1450
|
|
|
@@ -1359,7 +1492,7 @@ var require_desktop = __commonJS({
|
|
|
1359
1492
|
}
|
|
1360
1493
|
return {
|
|
1361
1494
|
platform: PLATFORM,
|
|
1362
|
-
available:
|
|
1495
|
+
available: sessionAvailable(),
|
|
1363
1496
|
reason: "session-scoped-by-launcher"
|
|
1364
1497
|
};
|
|
1365
1498
|
}
|
|
@@ -1462,6 +1595,9 @@ var require_autostart = __commonJS({
|
|
|
1462
1595
|
guiLabel: GUI_LABEL
|
|
1463
1596
|
};
|
|
1464
1597
|
}
|
|
1598
|
+
if (!isLinux && !isMac && !isWindows) {
|
|
1599
|
+
return { kind: "none", unit: "unsupported", on: false, gui: false };
|
|
1600
|
+
}
|
|
1465
1601
|
let unit = "unknown";
|
|
1466
1602
|
const en = ex2.runDetail("systemctl", ["--user", "is-enabled", "dsh-supervisor.service"]);
|
|
1467
1603
|
unit = String(en.stdout || en.stderr || "disabled").trim() || "disabled";
|
|
@@ -4693,6 +4829,7 @@ var require_dist = __commonJS({
|
|
|
4693
4829
|
var fs2 = require("node:fs");
|
|
4694
4830
|
var path2 = require("node:path");
|
|
4695
4831
|
var net = require("node:net");
|
|
4832
|
+
var matrix = require_matrix();
|
|
4696
4833
|
var { spawn } = require("node:child_process");
|
|
4697
4834
|
var { npmBin } = require_exec_path();
|
|
4698
4835
|
var registryContract = require_registry_contract();
|
|
@@ -4872,14 +5009,7 @@ var require_dist = __commonJS({
|
|
|
4872
5009
|
* 并如实上报(见该函数的 try/catch),不会让守卫崩溃。
|
|
4873
5010
|
*/
|
|
4874
5011
|
_platformTag() {
|
|
4875
|
-
|
|
4876
|
-
const archMap = { arm64: "arm64", x64: "x64" };
|
|
4877
|
-
const os2 = osMap[process.platform];
|
|
4878
|
-
const arch = archMap[process.arch];
|
|
4879
|
-
if (!os2 || !arch) {
|
|
4880
|
-
throw new Error("\u4E0D\u652F\u6301\u7684\u5E73\u53F0\u7EC4\u5408: " + process.platform + "/" + process.arch + "\uFF08\u4EC5 linux/darwin/win32 \xD7 x64/arm64\uFF09");
|
|
4881
|
-
}
|
|
4882
|
-
return os2 + "-" + arch;
|
|
5012
|
+
return matrix.npmTag();
|
|
4883
5013
|
}
|
|
4884
5014
|
/**
|
|
4885
5015
|
* 探测单个 registry 的可达性 + 延迟。
|
|
@@ -7358,20 +7488,14 @@ var require_frpmgr = __commonJS({
|
|
|
7358
7488
|
"use strict";
|
|
7359
7489
|
var fs2 = require("node:fs");
|
|
7360
7490
|
var path2 = require("node:path");
|
|
7491
|
+
var matrix = require_matrix();
|
|
7361
7492
|
var http2 = require("node:http");
|
|
7362
7493
|
var https = require("node:https");
|
|
7363
7494
|
var { spawn } = require("node:child_process");
|
|
7364
7495
|
var crypto = require("node:crypto");
|
|
7365
7496
|
var FRP_VERSION = "0.61.1";
|
|
7366
7497
|
function frpPlatformTag(platform, arch) {
|
|
7367
|
-
|
|
7368
|
-
const ar = arch || process.arch;
|
|
7369
|
-
const osMap = { linux: "linux", darwin: "darwin", win32: "windows" };
|
|
7370
|
-
const archMap = { x64: "amd64", arm64: "arm64" };
|
|
7371
|
-
const os2 = osMap[pl];
|
|
7372
|
-
const am = archMap[ar];
|
|
7373
|
-
if (!os2 || !am) return null;
|
|
7374
|
-
return { os: os2, arch: am, tag: os2 + "_" + am, exe: pl === "win32" };
|
|
7498
|
+
return matrix.frpTag(platform, arch);
|
|
7375
7499
|
}
|
|
7376
7500
|
var MIRROR_PREFIXES = [
|
|
7377
7501
|
"https://ghfast.top/",
|
|
@@ -7643,8 +7767,9 @@ var require_frpmgr = __commonJS({
|
|
|
7643
7767
|
}
|
|
7644
7768
|
};
|
|
7645
7769
|
if (!this.frpTag) {
|
|
7646
|
-
|
|
7647
|
-
|
|
7770
|
+
const cur = matrix.current();
|
|
7771
|
+
if (this.events) this.events.append("frpc_install_failed", { detail: "\u5F53\u524D\u5E73\u53F0\u65E0 frpc \u5B98\u65B9\u4EA7\u7269: " + cur.platform + "/" + cur.arch });
|
|
7772
|
+
return { ok: false, error: "\u5F53\u524D\u5E73\u53F0\u4E0D\u652F\u6301 FRP\uFF08" + cur.platform + "/" + cur.arch + "\uFF09\uFF0C\u4EC5 linux/darwin/win32 \xD7 x64/arm64" };
|
|
7648
7773
|
}
|
|
7649
7774
|
const asset = "frp_" + FRP_VERSION + "_" + this.frpTag.tag + ".tar.gz";
|
|
7650
7775
|
const urls = downloadUrls(asset);
|
|
@@ -10361,6 +10486,7 @@ var require_plugins = __commonJS({
|
|
|
10361
10486
|
var fs2 = require("node:fs");
|
|
10362
10487
|
var path2 = require("node:path");
|
|
10363
10488
|
var os2 = require("node:os");
|
|
10489
|
+
var matrix = require_matrix();
|
|
10364
10490
|
var { semverCompare } = require_dist();
|
|
10365
10491
|
var { dirSizeBytes } = require_fs_utils();
|
|
10366
10492
|
var PROTECTED = /* @__PURE__ */ new Set(["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app"]);
|
|
@@ -10728,7 +10854,7 @@ var require_plugins = __commonJS({
|
|
|
10728
10854
|
const killTree = (sig) => {
|
|
10729
10855
|
if (!child) return;
|
|
10730
10856
|
try {
|
|
10731
|
-
if (
|
|
10857
|
+
if (matrix.supportsProcessGroup() && child.pid) process.kill(-child.pid, sig);
|
|
10732
10858
|
else child.kill(sig);
|
|
10733
10859
|
} catch {
|
|
10734
10860
|
try {
|
|
@@ -17654,6 +17780,7 @@ var require_settings_view = __commonJS({
|
|
|
17654
17780
|
var { spawn } = require("node:child_process");
|
|
17655
17781
|
var { execFile } = require("node:child_process");
|
|
17656
17782
|
var ex2 = require_exec();
|
|
17783
|
+
var matrix = require_matrix();
|
|
17657
17784
|
var netInfo = require_netinfo();
|
|
17658
17785
|
var { EnvCatalog } = require_env_catalog();
|
|
17659
17786
|
var { semverCompare } = require_dist();
|
|
@@ -17793,8 +17920,7 @@ var require_settings_view = __commonJS({
|
|
|
17793
17920
|
guardCorePkg() {
|
|
17794
17921
|
const raw = this.config.corePackageName;
|
|
17795
17922
|
if (!raw) return null;
|
|
17796
|
-
|
|
17797
|
-
return String(raw).replace(/{os}/g, map[process.platform] || process.platform).replace(/{arch}/g, String(process.arch)) || null;
|
|
17923
|
+
return String(raw).replace(/{os}/g, matrix.osTag()).replace(/{arch}/g, matrix.current().arch) || null;
|
|
17798
17924
|
}
|
|
17799
17925
|
/** 守卫自更新(2026-09 收敛:npm 通道)——查 @dsh-sup/dsh-core-<os>-<arch> 全 tag 最高版本(全更新:
|
|
17800
17926
|
* BETA/RC/正式都算更新,任一更高即提示可更新),对本机 guardVersion 比较。 */
|
|
@@ -19487,6 +19613,7 @@ var require_supervisor = __commonJS({
|
|
|
19487
19613
|
var fs2 = require("node:fs");
|
|
19488
19614
|
var path2 = require("node:path");
|
|
19489
19615
|
var os2 = require("node:os");
|
|
19616
|
+
var matrix = require_matrix();
|
|
19490
19617
|
var pidlook = require_pidlookup();
|
|
19491
19618
|
var { DaemonLifecycle } = require_daemon_lifecycle();
|
|
19492
19619
|
var platform = require_os();
|
|
@@ -20399,7 +20526,7 @@ var require_supervisor = __commonJS({
|
|
|
20399
20526
|
if (!this.notifyEnabled) return;
|
|
20400
20527
|
platform.notify(title, body, () => {
|
|
20401
20528
|
this.notifyEnabled = false;
|
|
20402
|
-
this.logger.warn("\u684C\u9762\u901A\u77E5\u4E0D\u53EF\u7528\uFF08" +
|
|
20529
|
+
this.logger.warn("\u684C\u9762\u901A\u77E5\u4E0D\u53EF\u7528\uFF08" + matrix.osTag() + "\uFF09\uFF0C\u5DF2\u505C\u7528");
|
|
20403
20530
|
});
|
|
20404
20531
|
}
|
|
20405
20532
|
// ---- 升级流程挂钩(先停后装,消除运行中替换文件的混合版本窗口)----
|