@cloud411716/fancy-webnovel 4.7.0 → 4.7.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.7.0",
3
+ "version": "4.7.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -19,6 +19,10 @@ const { spawn } = require('child_process');
19
19
  const crypto = require('crypto');
20
20
  const { parseArgs, ensureDir, readJson, writeJsonAtomic, printJson, fail, log } = require('./lib.cjs');
21
21
 
22
+ // 启动参数版本:更新过 Chrome flags 后,旧的常驻 Chrome 不能继续复用,
23
+ // 否则用户会一直看到旧行为(更新提示 / xdg-open 弹窗)。
24
+ const LAUNCH_VERSION = 2;
25
+
22
26
  function getVersion(port, timeout = 1500) {
23
27
  return new Promise((resolve) => {
24
28
  const req = http.get({ host: '127.0.0.1', port, path: '/json/version', timeout }, (res) => {
@@ -132,7 +136,8 @@ async function main() {
132
136
  if (existing && Number(existing.port) > 0) {
133
137
  const version = await getVersion(Number(existing.port));
134
138
  const existingMode = existing.mode || 'headed';
135
- if (version.ok && existingMode === mode) {
139
+ const sameLaunch = Number(existing.launch_version) === LAUNCH_VERSION;
140
+ if (version.ok && existingMode === mode && sameLaunch) {
136
141
  const port = Number(existing.port);
137
142
  printJson({
138
143
  ok: true,
@@ -146,7 +151,8 @@ async function main() {
146
151
  return;
147
152
  }
148
153
  if (version.ok) {
149
- log('[chrome] mode switch ' + existingMode + ' -> ' + mode + ', closing old browser');
154
+ log('[chrome] restarting old browser (mode ' + existingMode + ' -> ' + mode
155
+ + ', launch ' + (existing.launch_version || 0) + ' -> ' + LAUNCH_VERSION + ')');
150
156
  await closeChrome(Number(existing.port));
151
157
  }
152
158
  }
@@ -198,6 +204,7 @@ async function main() {
198
204
  port,
199
205
  profile,
200
206
  mode,
207
+ launch_version: LAUNCH_VERSION,
201
208
  started_at: new Date().toISOString(),
202
209
  }, 0o600);
203
210