cicy-desktop 2.1.290 → 2.1.291
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/package.json
CHANGED
|
@@ -1081,6 +1081,13 @@ async function status(port = 8008) {
|
|
|
1081
1081
|
// downloads and exit-100. A second caller just attaches to the in-flight run.
|
|
1082
1082
|
let _bootstrapInFlight = null;
|
|
1083
1083
|
let _bootstrapBeat = 0; // 上次进度事件时间 —— 心跳,用于判定 in-flight 是否卡死
|
|
1084
|
+
// 所有跟随同一次安装的进度订阅者 + 最近事件缓存:守护循环先起的安装没有 UI,用户随后点
|
|
1085
|
+
// 「安装」打开抽屉时,把已发生的步骤回放给它,之后的事件也同时推给它,而不是只有一句
|
|
1086
|
+
// 「正在跟随同一进度…」。
|
|
1087
|
+
const _bootstrapListeners = new Set();
|
|
1088
|
+
let _bootstrapRecent = [];
|
|
1089
|
+
let _bootstrapT0 = 0;
|
|
1090
|
+
const BOOTSTRAP_RECENT_MAX = 60;
|
|
1084
1091
|
// 没有任何进度事件超过这个时长 = wedged(`wsl --import` 静默最久 ~1-4 分钟,留足余量)。
|
|
1085
1092
|
const BOOTSTRAP_STALL_MS = 6 * 60 * 1000;
|
|
1086
1093
|
|
|
@@ -1092,7 +1099,11 @@ async function bootstrap(opts = {}) {
|
|
|
1092
1099
|
// 丢弃它、重起一次;否则正常并发跟随同一进度。
|
|
1093
1100
|
const stalled = Date.now() - _bootstrapBeat > BOOTSTRAP_STALL_MS;
|
|
1094
1101
|
if (!stalled) {
|
|
1095
|
-
|
|
1102
|
+
if (opts.onProgress) {
|
|
1103
|
+
try { opts.onProgress({ phase: "install-docker", status: "running", message: `安装已在进行中(${Math.round((Date.now() - _bootstrapT0) / 1000)}s 前开始),正在跟随同一进度…` }); } catch {}
|
|
1104
|
+
for (const ev of _bootstrapRecent) { try { opts.onProgress(ev); } catch {} }
|
|
1105
|
+
_bootstrapListeners.add(opts.onProgress);
|
|
1106
|
+
}
|
|
1096
1107
|
return _bootstrapInFlight;
|
|
1097
1108
|
}
|
|
1098
1109
|
log.warn(`[bootstrap] in-flight 卡死(${Math.round((Date.now() - _bootstrapBeat) / 1000)}s 无进度)→ 丢弃僵死的,重起一次`);
|
|
@@ -1101,9 +1112,16 @@ async function bootstrap(opts = {}) {
|
|
|
1101
1112
|
}
|
|
1102
1113
|
// 包一层 onProgress:每来一个事件就刷新心跳,卡死检测才准。
|
|
1103
1114
|
_bootstrapBeat = Date.now();
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1115
|
+
_bootstrapT0 = Date.now();
|
|
1116
|
+
_bootstrapListeners.clear();
|
|
1117
|
+
_bootstrapRecent = [];
|
|
1118
|
+
if (opts.onProgress) _bootstrapListeners.add(opts.onProgress);
|
|
1119
|
+
const wrapped = { ...opts, onProgress: (ev) => {
|
|
1120
|
+
_bootstrapBeat = Date.now();
|
|
1121
|
+
_bootstrapRecent.push(ev); if (_bootstrapRecent.length > BOOTSTRAP_RECENT_MAX) _bootstrapRecent.shift();
|
|
1122
|
+
for (const fn of _bootstrapListeners) { try { fn(ev); } catch {} }
|
|
1123
|
+
} };
|
|
1124
|
+
_bootstrapInFlight = _bootstrap(wrapped).finally(() => { _bootstrapInFlight = null; _bootstrapListeners.clear(); });
|
|
1107
1125
|
return _bootstrapInFlight;
|
|
1108
1126
|
}
|
|
1109
1127
|
|
|
@@ -30,3 +30,9 @@ test("keepalive logon task degrades to LeastPrivilege / HKCU Run when not elevat
|
|
|
30
30
|
assert.match(src, /writeKeepaliveFiles\(\{ runLevel: "LeastPrivilege" \}\)/);
|
|
31
31
|
assert.match(src, /CurrentVersion\\\\Run/);
|
|
32
32
|
});
|
|
33
|
+
|
|
34
|
+
test("a second bootstrap caller gets the in-flight run's progress (replay + live)", () => {
|
|
35
|
+
const src = read("src/sidecar/wsl-docker.js");
|
|
36
|
+
assert.match(src, /for \(const ev of _bootstrapRecent\) \{ try \{ opts\.onProgress\(ev\); \} catch \{\} \}\n\s+_bootstrapListeners\.add\(opts\.onProgress\);/);
|
|
37
|
+
assert.match(src, /for \(const fn of _bootstrapListeners\) \{ try \{ fn\(ev\); \} catch \{\} \}/);
|
|
38
|
+
});
|