dsh-unlag 1.9.38 → 1.9.40
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/client.js +6 -1
- package/index.js +19 -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
|
-
|
|
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
|
@@ -192,6 +192,16 @@ function settingsOf(config) {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* One log line, whatever the message. An address, a plugin id or an error can carry a line break,
|
|
197
|
+
* and a forged line in a file that is read as evidence is worse than a missing one; a message can
|
|
198
|
+
* also be arbitrarily long, and the log is one line per event.
|
|
199
|
+
*/
|
|
200
|
+
export function oneLine(value, limit = 2000) {
|
|
201
|
+
const text = String(value ?? '').replace(/[\r\n\u2028\u2029]+/gu, ' ')
|
|
202
|
+
return text.length > limit ? `${text.slice(0, limit)}\u2026` : text
|
|
203
|
+
}
|
|
204
|
+
|
|
195
205
|
function log(line) {
|
|
196
206
|
try {
|
|
197
207
|
const target = logTarget()
|
|
@@ -205,7 +215,7 @@ function log(line) {
|
|
|
205
215
|
/* a missing or unreadable log is created by the append below */
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
|
-
appendFileSync(target, `${new Date().toISOString()} ${line}\n`)
|
|
218
|
+
appendFileSync(target, `${new Date().toISOString()} ${oneLine(line)}\n`)
|
|
209
219
|
} catch {}
|
|
210
220
|
}
|
|
211
221
|
|
|
@@ -1369,7 +1379,10 @@ function releaseBundleShim(shim) {
|
|
|
1369
1379
|
}
|
|
1370
1380
|
// The mark belongs to this wrapper only; a mark left by a newer one stays on the route.
|
|
1371
1381
|
if (shim.route[SHIM_MARK] === shim.wrapped) delete shim.route[SHIM_MARK]
|
|
1372
|
-
} catch {
|
|
1382
|
+
} catch (error) {
|
|
1383
|
+
// A route left wrapped here would answer pages from a context that is going away.
|
|
1384
|
+
log(`cannot unwrap the bundle route: ${oneLine(error?.message ?? error)}`)
|
|
1385
|
+
}
|
|
1373
1386
|
}
|
|
1374
1387
|
|
|
1375
1388
|
/**
|
|
@@ -1572,7 +1585,10 @@ export async function readStartupScript(clientModules, url) {
|
|
|
1572
1585
|
try {
|
|
1573
1586
|
const answer = await currentBundleAnswer(clientModules, 'GET', url)
|
|
1574
1587
|
if (answer !== null) return { status: 200, arrayBuffer: async () => answer.body }
|
|
1575
|
-
} catch {
|
|
1588
|
+
} catch (error) {
|
|
1589
|
+
// The fallback is still the right answer; the failure itself must not vanish.
|
|
1590
|
+
log(`cannot answer ${oneLine(url)} at the revision the app serves now: ${oneLine(error?.message ?? error)}; asking the app's own route`)
|
|
1591
|
+
}
|
|
1576
1592
|
return fetchBundleAt(clientModules, url, 'GET')
|
|
1577
1593
|
}
|
|
1578
1594
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.40",
|
|
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",
|