dsh-unlag 1.9.39 → 1.9.41

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 +6 -1
  2. package/index.js +18 -14
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -559,7 +559,12 @@ window.__ModuleLoader__.load({
559
559
  function stillHeldBack() {
560
560
  const probe = new Event('beforeunload', { cancelable: true }); // ui-copy-ignore
561
561
  window.dispatchEvent(probe);
562
- return probe.defaultPrevented === true || probe.returnValue === false;
562
+ // A handler says no in three ways: cancelling the event, setting `returnValue` to false, or
563
+ // returning a message through `window.onbeforeunload` (the browser copies that message into
564
+ // `returnValue`). Missing the last one let a press start a navigation the page would then
565
+ // ask about over the page's own head.
566
+ const message = probe.returnValue;
567
+ return probe.defaultPrevented === true || message === false || (typeof message === 'string' && message !== '');
563
568
  }
564
569
 
565
570
  /**
package/index.js CHANGED
@@ -92,13 +92,18 @@ const MAX_DEFERRALS = 40
92
92
  const MAX_STARTUP_ROWS = 64
93
93
  const MAX_STARTUP_ROW_CHARS = 4096
94
94
  /**
95
- * The largest one startup script may be before a check refuses it. A real client bundle is far
96
- * below this; a body past it is either a mistake or an attempt to make a check read (and compile)
97
- * an unbounded amount of text inside the process that owns every running turn.
95
+ * The largest one startup script may be before a check refuses it. The app serves a whole profile as
96
+ * a few bundles, and those grow with every installed plugin: one profile's largest bundle measured
97
+ * 8.7 MB, which a smaller bound refused as if it were an attack and left the page unrebuildable.
98
+ * A body past this bound is a mistake or an attempt to make a check read (and compile) an unbounded
99
+ * amount of text inside the process that owns every running turn.
98
100
  */
99
- const MAX_SCRIPT_BYTES = 8 * 1024 * 1024
100
- /** The same bound for one whole startup list, so a list of large bodies cannot add up either. */
101
- const MAX_TOTAL_SCRIPT_BYTES = 32 * 1024 * 1024
101
+ const MAX_SCRIPT_BYTES = 64 * 1024 * 1024
102
+ /**
103
+ * The same bound for one whole startup list, so a list of large bodies cannot add up either. Only
104
+ * the compile happens under it: what a check keeps per body is the ids it names, never its text.
105
+ */
106
+ const MAX_TOTAL_SCRIPT_BYTES = 128 * 1024 * 1024
102
107
 
103
108
  /**
104
109
  * The most plugin ids one bundle address may name. A real startup list is far below this; a made-up
@@ -1534,12 +1539,11 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1534
1539
  if (required.length > 0 && missing.length > 0) {
1535
1540
  return { status: 'blocked', reason: 'register', detail: `${item.url} does not register ${missing.join(', ')}` }
1536
1541
  }
1537
- bodies.push({
1538
- url: item.url,
1539
- text,
1540
- ids: item.ids,
1541
- digest: createHash('sha256').update(bytes).digest('hex').slice(0, 16),
1542
- })
1542
+ // Only what the cross-checks below need from this body is kept; the text itself is let go here,
1543
+ // so a list of large scripts costs one script of memory rather than the whole list.
1544
+ const record = { url: item.url, ids: item.ids, registered, required: requiredIds(text) }
1545
+ record.digest = createHash('sha256').update(bytes).digest('hex').slice(0, 16)
1546
+ bodies.push(record)
1543
1547
  }
1544
1548
  /**
1545
1549
  * A body can read a plugin its own document does not list: the set changed after that document was
@@ -1548,10 +1552,10 @@ export async function verifyStartupRows(graph, fetchBody, rows, budgetMs = MAX_V
1548
1552
  * itself is that case, so the press is held rather than booting a page that dies half way.
1549
1553
  */
1550
1554
  const available = new Set(listed)
1551
- for (const body of bodies) for (const id of registeredIds(body.text)) available.add(id)
1555
+ for (const body of bodies) for (const id of body.registered) available.add(id)
1552
1556
  const absent = new Set()
1553
1557
  for (const body of bodies) {
1554
- for (const id of requiredIds(body.text)) {
1558
+ for (const id of body.required) {
1555
1559
  if (available.has(id) || !entries.has(id)) continue
1556
1560
  absent.add(id)
1557
1561
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlag",
3
- "version": "1.9.39",
3
+ "version": "1.9.41",
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",