dsh-auto-open-web 0.1.27 → 0.1.29
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/lib/index.js +43 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -194,7 +194,7 @@ function openAppWindow(exe, url, browser, job) {
|
|
|
194
194
|
console.error(`[auto-open-web] app window spawn failed: ${error.message}`);
|
|
195
195
|
});
|
|
196
196
|
child.on('exit', (code) => {
|
|
197
|
-
if (code === 0 &&
|
|
197
|
+
if (code === 0 && exitOnCloseActive()) {
|
|
198
198
|
console.log('[auto-open-web] app window closed; exiting DSH (exitOnWindowClose)');
|
|
199
199
|
process.exit(0);
|
|
200
200
|
}
|
|
@@ -236,7 +236,7 @@ function spawnHostWindow(exe, url, iconPath) {
|
|
|
236
236
|
console.error(`[auto-open-web] host window spawn failed: ${error.message}`);
|
|
237
237
|
});
|
|
238
238
|
child.on('exit', (code) => {
|
|
239
|
-
if (code === 0 &&
|
|
239
|
+
if (code === 0 && exitOnCloseActive()) {
|
|
240
240
|
console.log('[auto-open-web] host window closed; exiting DSH (exitOnWindowClose)');
|
|
241
241
|
process.exit(0);
|
|
242
242
|
}
|
|
@@ -463,6 +463,18 @@ async function ensureIconFile(server) {
|
|
|
463
463
|
*/
|
|
464
464
|
let exitWatcherEnabled = false;
|
|
465
465
|
|
|
466
|
+
/**
|
|
467
|
+
* 关窗退出的**实时判定**(由 apply 注入)。
|
|
468
|
+
*
|
|
469
|
+
* 为什么不能只靠 `exitWatcherEnabled` 快照:dsh 0.1.7 起 volatile 字段的改动
|
|
470
|
+
* **不重跑 apply** —— loader 对 volatile 字段视作"相等"(`deepEqual(..., true)`),
|
|
471
|
+
* 只调 `updateVolatile(ref, source)` **就地改配置对象**再 emit
|
|
472
|
+
* `loader/volatile-update`。于是 apply 时快照下来的布尔值永远是旧值,
|
|
473
|
+
* 用户打开"窗口关闭时退出 DSH"后关窗不会退出(设置"没生效")。
|
|
474
|
+
* 这里改为在**判定时刻**读活配置(rc 线仍以 settings 已合并的 state 为准)。
|
|
475
|
+
*/
|
|
476
|
+
let exitOnCloseActive = () => false;
|
|
477
|
+
|
|
466
478
|
/** 测试钩子:纯函数导出,生产代码不依赖。 */
|
|
467
479
|
export const internals = {
|
|
468
480
|
resolveBrowserExe: platform.resolveBrowserExe,
|
|
@@ -510,7 +522,7 @@ export function apply(ctx, config) {
|
|
|
510
522
|
: base;
|
|
511
523
|
};
|
|
512
524
|
|
|
513
|
-
// ---- 配置状态:行配置为种子;settings 命名空间持久化(
|
|
525
|
+
// ---- 配置状态:行配置为种子;settings 命名空间持久化(rc 线由设置卡片写入) ----
|
|
514
526
|
const settingsSvc = ctx.get('settings');
|
|
515
527
|
let scope = null;
|
|
516
528
|
let writable = false;
|
|
@@ -539,6 +551,34 @@ export function apply(ctx, config) {
|
|
|
539
551
|
}
|
|
540
552
|
syncExitWatcher(); // 启动时的最终生效值(settings 已合并或行配置)
|
|
541
553
|
|
|
554
|
+
// 关窗退出的实时判定(见 exitOnCloseActive 的说明):
|
|
555
|
+
// · rc 线:settings 已合并进 state,由 scope.watch 维护;
|
|
556
|
+
// · 新版:settings.register 不存在,配置由宿主**就地更新** —— 判定时刻现读。
|
|
557
|
+
// 读活配置的口径与官方一致(见 dsh-experimental-speech-to-text / dsh-llm-deepseek):
|
|
558
|
+
// 条目上的 `ctx.fiber.entry.options.config` 是 loader 用 updateVolatile 维护的那份;
|
|
559
|
+
// apply 的 config 形参在 volatile 更新后可能仍是旧对象,故只作兜底。
|
|
560
|
+
const liveConfig = () => {
|
|
561
|
+
try {
|
|
562
|
+
const entry = ctx.fiber !== undefined && ctx.fiber !== null ? ctx.fiber.entry : undefined;
|
|
563
|
+
const fromEntry = entry !== undefined && entry !== null && entry.options !== undefined ? entry.options.config : undefined;
|
|
564
|
+
return fromEntry !== undefined && fromEntry !== null ? fromEntry : config;
|
|
565
|
+
} catch (error) {
|
|
566
|
+
return config;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
const currentState = () => normalizeState(liveConfig());
|
|
570
|
+
exitOnCloseActive = () => (scope !== null ? state.exitOnWindowClose === true : currentState().exitOnWindowClose === true);
|
|
571
|
+
|
|
572
|
+
// 新版(0.1.7+)volatile 字段改动不重跑 apply:监听官方事件把 state 刷新,
|
|
573
|
+
// 让"浏览/测试"等辅助路由与退出判定都看得见新值。
|
|
574
|
+
if (typeof ctx.on === 'function') {
|
|
575
|
+
ctx.on('loader/volatile-update', () => {
|
|
576
|
+
state = currentState();
|
|
577
|
+
syncExitWatcher();
|
|
578
|
+
console.log(`[auto-open-web] volatile config updated (exitOnWindowClose=${String(state.exitOnWindowClose)}, appWindow=${String(state.appWindow)}, windowKind=${state.windowKind})`);
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
|
|
542
582
|
// ---- 卡片辅助 API(浏览/测试;设置读写走官方 settings 域) ----
|
|
543
583
|
// 设置卡片经客户端 settingsScope(settings 域)读写本命名空间,不再自建
|
|
544
584
|
// config 路由;这里只保留官方通道无法覆盖的能力。
|
package/package.json
CHANGED