dsh-unlag 1.9.0 → 1.9.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.
Files changed (3) hide show
  1. package/client.js +15 -7
  2. package/index.js +19 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -27,11 +27,16 @@ window.__ModuleLoader__.load({
27
27
  return false;
28
28
  }
29
29
 
30
- /** The notice for one copy key, naming the reason when a readiness check stopped the press. */
31
- function noticeFor(key) {
30
+ /**
31
+ * The notice for one copy key, naming the reason when a readiness check stopped the press.
32
+ * A press that already replaced the plugins did its work even when the page was left alone, and
33
+ * is said so: the update is live either way, and only the new document was skipped.
34
+ */
35
+ function noticeFor(key, applied = false) {
32
36
  if (key !== 'blocked' || holdReason === null) return COPY[key];
33
37
  const why = REASONS[holdReason] ?? REASONS.list;
34
- return zh ? `暂时无法重建:${why}。稍后再点一次。` : `Cannot rebuild yet: ${why}. Press again shortly.`;
38
+ if (applied) return zh ? `插件已更新,页面未重开:${why}。` : `Plugins updated; the page stayed: ${why}.`;
39
+ return zh ? `暂时无法重建:${why}。` : `Cannot rebuild yet: ${why}.`;
35
40
  }
36
41
 
37
42
  // Desktop shell only: the macOS and Windows desktop build owns the page and the running
@@ -517,13 +522,14 @@ window.__ModuleLoader__.load({
517
522
  if (Number.isFinite(previous) && Date.now() - previous < 3000) return; // ui-copy-ignore
518
523
  setPending(true);
519
524
  setNotice(null);
520
- const stop = (key) => {
525
+ const stop = (key, applied = false) => {
521
526
  setPending(false);
522
- setNotice(noticeFor(key));
527
+ setNotice(noticeFor(key, applied));
523
528
  };
524
529
  const settings = await readSettings();
525
530
  const replace = settings === null ? false : settings.plugins;
526
531
  const rebuild = settings === null ? true : settings.page;
532
+ let replaced = false;
527
533
  // Both switches off: a press does nothing at all.
528
534
  if (!replace && !rebuild) {
529
535
  setPending(false);
@@ -548,6 +554,7 @@ window.__ModuleLoader__.load({
548
554
  report('plugin-held', key);
549
555
  return stop(key);
550
556
  }
557
+ replaced = status === 'done';
551
558
  }
552
559
  if (!rebuild) {
553
560
  setPending(false);
@@ -557,8 +564,9 @@ window.__ModuleLoader__.load({
557
564
  const reason = await prepareInterface();
558
565
  if (reason !== null) {
559
566
  // The log keeps the exact check that refused, so a held press can be explained later.
560
- report('held', reason === 'blocked' && holdReason !== null ? `blocked:${holdReason}` : reason);
561
- return stop(reason);
567
+ const gate = reason === 'blocked' && holdReason !== null ? `blocked:${holdReason}` : reason;
568
+ report('held', replaced ? `applied:${gate}` : gate);
569
+ return stop(reason, replaced);
562
570
  }
563
571
  report('rebuild');
564
572
  reloadFreshPage();
package/index.js CHANGED
@@ -1174,15 +1174,32 @@ export async function verifyStartupRows(graph, fetchBody, rows) {
1174
1174
  }
1175
1175
  }
1176
1176
 
1177
+ /**
1178
+ * Read one startup script the way the document itself would get it.
1179
+ *
1180
+ * The route answers a script from an older generation at the revision that still holds it, so a
1181
+ * document booting from the shell's frozen list comes up instead of 404. Reading the address
1182
+ * directly would see that same 404 and refuse a rebuild the button can actually carry out, so the
1183
+ * answer is taken through the same mapping and only falls back to the raw address when the mapping
1184
+ * has nothing to say.
1185
+ */
1186
+ export async function readStartupScript(clientModules, url) {
1187
+ try {
1188
+ const answer = await currentBundleAnswer(clientModules, 'GET', url)
1189
+ if (answer !== null) return { status: 200, arrayBuffer: async () => answer.body }
1190
+ } catch {}
1191
+ return fetchBundleAt(clientModules, url, 'GET')
1192
+ }
1193
+
1177
1194
  /** Ask the same question of the plugin table the plugin itself talks to. */
1178
- async function verifyStartup(clientModules, rows) {
1195
+ export async function verifyStartup(clientModules, rows) {
1179
1196
  let graph = null
1180
1197
  try {
1181
1198
  graph = clientModules.graph()
1182
1199
  } catch (error) {
1183
1200
  return { status: 'blocked', reason: 'list', detail: String(error?.message ?? error) }
1184
1201
  }
1185
- return verifyStartupRows(graph, (url) => fetchBundleAt(clientModules, url, 'GET'), rows)
1202
+ return verifyStartupRows(graph, (url) => readStartupScript(clientModules, url), rows)
1186
1203
  }
1187
1204
 
1188
1205
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "type": "module",
5
5
  "description": "A press applies plugin edits right away and brings a laggy interface back; automatic reloading stays off unless you turn it on, so the press is the only trigger, and nothing restarts.",
6
6
  "license": "MIT",