dsh-unlag 1.9.78 → 1.9.80

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 +14 -1
  2. package/index.js +18 -2
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -72,6 +72,14 @@ window.__ModuleLoader__.load({
72
72
  }
73
73
  }
74
74
 
75
+ function stampClear() {
76
+ try {
77
+ window.sessionStorage.removeItem(STAMP_KEY);
78
+ } catch {
79
+ // Pacing is the only thing this stamp feeds: a store that refuses the clear costs nothing.
80
+ }
81
+ }
82
+
75
83
  function stampWrite() {
76
84
  try {
77
85
  window.sessionStorage.setItem(STAMP_KEY, String(Date.now()));
@@ -860,7 +868,6 @@ window.__ModuleLoader__.load({
860
868
  report('replaced');
861
869
  return stop(replaced ? 'replaced' : 'done');
862
870
  }
863
- stampWrite();
864
871
  const reason = await prepareInterface();
865
872
  if (reason !== null) {
866
873
  // The log keeps the exact check that refused, so a held press can be explained later.
@@ -868,6 +875,9 @@ window.__ModuleLoader__.load({
868
875
  report('held', replaced ? `applied:${gate}` : gate);
869
876
  return stop(reason, replaced);
870
877
  }
878
+ // Written only now, when the document really is about to go: a press that was held changed
879
+ // nothing, so the next press must not be turned away as if this one had been answered.
880
+ stampWrite();
871
881
  report('rebuild');
872
882
  navigated = true;
873
883
  reloadFreshPage();
@@ -885,6 +895,9 @@ window.__ModuleLoader__.load({
885
895
  // Still here after asking for a rebuild: the page held the navigation. Say what
886
896
  // happened and take the press back, so the button is never left unresponsive.
887
897
  report('held', 'navigation');
898
+ // The document stayed, so no press was answered: clear the pacing stamp this press
899
+ // wrote, or the next press inside three seconds would be told it is already applying.
900
+ stampClear();
888
901
  setPending(false);
889
902
  // Only a press that really replaced the plugins may say so: a page-only press that
890
903
  // held the navigation changed no code.
package/index.js CHANGED
@@ -1144,7 +1144,13 @@ async function currentBundleAnswer(clientModules, method, url, deadline = Date.n
1144
1144
  }
1145
1145
  }
1146
1146
  }
1147
- return (await regroupedBundleAnswer(clientModules, graph, request, deadline)) ?? survivingBundleAnswer(clientModules, graph, request, deadline)
1147
+ const regrouped = await regroupedBundleAnswer(clientModules, graph, request, deadline)
1148
+ if (regrouped !== null) return regrouped
1149
+ // What is left is the last resort: the set itself is gone and the body is a stand-in that
1150
+ // registers nothing. The check passes, and the answer says so, because a page booting that row
1151
+ // comes up without the plugin rather than failing.
1152
+ const surviving = await survivingBundleAnswer(clientModules, graph, request, deadline)
1153
+ return surviving === null ? null : { ...surviving, standIn: true }
1148
1154
  }
1149
1155
 
1150
1156
  /** Answer one stale request over the plain request/response route an app registers. */
@@ -1663,6 +1669,7 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1663
1669
  const bodies = []
1664
1670
  const began = Date.now()
1665
1671
  let totalBytes = 0
1672
+ let standInRows = 0
1666
1673
  for (const item of wanted) {
1667
1674
  if (Date.now() - began > budgetMs) {
1668
1675
  return { status: 'blocked', reason: 'slow', detail: 'the startup list took longer than this check waits' }
@@ -1688,6 +1695,9 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1688
1695
  if (!readable || response === null || response === undefined || status !== 200) {
1689
1696
  return { status: 'blocked', reason: 'missing', detail: `${item.url} answers ${readable ? String(status ?? 'nothing') : 'nothing readable'}` }
1690
1697
  }
1698
+ try {
1699
+ if (response?.standIn === true) standInRows += 1
1700
+ } catch {}
1691
1701
  let bytes = null
1692
1702
  try {
1693
1703
  bytes = Buffer.from(await response.arrayBuffer())
@@ -1742,6 +1752,7 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1742
1752
  revision: typeof graph?.rev === 'string' ? graph.rev : null,
1743
1753
  scripts: bodies.map((body) => ({ url: body.url, digest: body.digest, ids: body.ids })),
1744
1754
  ...(leftOut.size > 0 ? { leftOut: [...leftOut] } : {}),
1755
+ ...(standInRows > 0 ? { standInRows } : {}),
1745
1756
  }
1746
1757
  }
1747
1758
 
@@ -1757,7 +1768,9 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1757
1768
  export async function readStartupScript(clientModules, url) {
1758
1769
  try {
1759
1770
  const answer = await currentBundleAnswer(clientModules, 'GET', url)
1760
- if (answer !== null) return { status: 200, arrayBuffer: async () => answer.body }
1771
+ // `standIn` rides along: these bytes stand in for a plugin the set no longer has, and the check
1772
+ // says so when it passes, so the log can tell that from a body the app really serves.
1773
+ if (answer !== null) return { status: 200, standIn: answer.standIn === true, arrayBuffer: async () => answer.body }
1761
1774
  } catch (error) {
1762
1775
  // The fallback is still the right answer; the failure itself must not vanish.
1763
1776
  log(`cannot answer ${oneLine(url)} at the revision the app serves now: ${oneLine(error?.message ?? error)}; asking the app's own route`)
@@ -1892,6 +1905,9 @@ function serveButton(ctx, controller, config) {
1892
1905
  if (verdict?.status !== 'ok') {
1893
1906
  log(`a startup check refused the page: ${String(verdict?.reason ?? 'list')} (${String(verdict?.detail ?? 'no detail')})`)
1894
1907
  }
1908
+ if (typeof verdict?.standInRows === 'number' && verdict.standInRows > 0) {
1909
+ log(`a startup check passed with ${String(verdict.standInRows)} row(s) answered by a stand-in script`)
1910
+ }
1895
1911
  if (Array.isArray(verdict?.leftOut) && verdict.leftOut.length > 0) {
1896
1912
  log(`a startup row names a plugin this app no longer serves: ${verdict.leftOut.join(', ')}; the page comes up without it`)
1897
1913
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.78",
3
+ "version": "1.9.80",
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",