dsh-unlag 1.9.55 → 1.9.57

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 +24 -2
  2. package/index.js +22 -3
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -432,6 +432,22 @@ window.__ModuleLoader__.load({
432
432
  }
433
433
  }
434
434
 
435
+ /**
436
+ * The stamp written when the plugin code was last loaded. A replacement that was applied
437
+ * without changing which bundles are served keeps the startup list's revision, so the graph
438
+ * alone cannot tell a lost answer from a failed press; the code stamp can.
439
+ */
440
+ async function hostCodeStamp() {
441
+ try {
442
+ const response = await withTimeout(fetch(`${HOST_BASE}/state`, { cache: 'no-store', credentials: 'same-origin' }));
443
+ if (!response.ok) return null;
444
+ const data = await withTimeout(response.json());
445
+ return typeof data?.code === 'string' ? data.code : null;
446
+ } catch {
447
+ return null;
448
+ }
449
+ }
450
+
435
451
  /** Whether a plugin no longer in the running set still has its script answered. */
436
452
  async function hostShimAnswersGone() {
437
453
  try {
@@ -683,13 +699,19 @@ window.__ModuleLoader__.load({
683
699
  */
684
700
  const before = await hostBootGraph();
685
701
  const revBefore = typeof before?.rev === 'string' ? before.rev : null;
702
+ const codeBefore = await hostCodeStamp();
686
703
  let status = await withTimeout(replacePlugins()).catch(() => 'failed');
687
- if (status === 'failed' && revBefore !== null) {
704
+ if (status === 'failed' && (revBefore !== null || codeBefore !== null)) {
688
705
  for (const wait of [400, 900, 1800]) { // ui-copy-ignore
689
706
  await new Promise((resolve) => setTimeout(resolve, wait));
690
707
  const after = await hostBootGraph();
691
708
  const revNow = typeof after?.rev === 'string' ? after.rev : null;
692
- if (revNow !== null && revNow !== revBefore) {
709
+ if (revNow !== null && revBefore !== null && revNow !== revBefore) {
710
+ status = 'done';
711
+ break;
712
+ }
713
+ const codeNow = await hostCodeStamp();
714
+ if (codeNow !== null && codeBefore !== null && codeNow !== codeBefore) {
693
715
  status = 'done';
694
716
  break;
695
717
  }
package/index.js CHANGED
@@ -200,15 +200,34 @@ export const Config = {
200
200
  },
201
201
  }
202
202
 
203
+ /** Switches already reported, so a settings form read repeatedly writes one line, not many. */
204
+ const STRANGE_SWITCHES = new Set()
205
+ /**
206
+ * One switch. Absent means the default; a boolean means itself; anything else — a hand-edited
207
+ * string, a number, a list — is not a yes and is read as off, with one line saying so. A row that
208
+ * says "off" must not swap plugin code because the value happened to be the word "no".
209
+ */
210
+ function booleanSwitch(config, key, fallback) {
211
+ const value = config?.[key]
212
+ if (value === undefined || value === null) return fallback
213
+ if (typeof value === 'boolean') return value
214
+ const seen = `${key}=${oneLine(value, 40)}`
215
+ if (!STRANGE_SWITCHES.has(seen) && STRANGE_SWITCHES.size < 32) {
216
+ STRANGE_SWITCHES.add(seen)
217
+ log(`a switch that is not a boolean was read as off: ${seen}`)
218
+ }
219
+ return false
220
+ }
221
+
203
222
  /**
204
223
  * The three switches from any config shape. The press switches default on; automatic reloading
205
224
  * defaults off, and the undocumented `plugins: 'off'` from older configs keeps meaning off.
206
225
  */
207
226
  function settingsOf(config) {
208
227
  return {
209
- reloadPlugins: config?.reloadPlugins !== false,
210
- reloadInterface: config?.reloadInterface !== false,
211
- autoReload: config?.plugins === 'off' ? false : config?.autoReload === true,
228
+ reloadPlugins: booleanSwitch(config, 'reloadPlugins', true),
229
+ reloadInterface: booleanSwitch(config, 'reloadInterface', true),
230
+ autoReload: config?.plugins === 'off' ? false : booleanSwitch(config, 'autoReload', false),
212
231
  }
213
232
  }
214
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.55",
3
+ "version": "1.9.57",
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",