dsh-unlag 1.9.17 → 1.9.19
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 +18 -3
- package/index.js +11 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -117,18 +117,33 @@ window.__ModuleLoader__.load({
|
|
|
117
117
|
* before rebuilding looks exactly like one that never happened, and the page itself is gone by
|
|
118
118
|
* the time anyone reads it.
|
|
119
119
|
*/
|
|
120
|
-
function report(event, gate) {
|
|
120
|
+
function report(event, gate, attempt = 0) {
|
|
121
121
|
const page = String(window?.__DSH_BOOT__?.rev ?? '').replace(/[^a-z0-9]/gu, '').slice(0, 24);
|
|
122
122
|
const named = gate === undefined ? `event=${event}` : `event=${event}&gate=${encodeURIComponent(gate)}`;
|
|
123
123
|
const query = page === '' ? named : `${named}&rev=${page}`;
|
|
124
|
+
/**
|
|
125
|
+
* The route belongs to the instance this press is replacing. Its answer can land while the old
|
|
126
|
+
* one is gone and the new one is not listening yet, and a lost line is a press nobody can
|
|
127
|
+
* account for later. Two more tries cost nothing and keep the record.
|
|
128
|
+
*/
|
|
129
|
+
const again = () => {
|
|
130
|
+
if (attempt >= 2) return;
|
|
131
|
+
setTimeout(() => report(event, gate, attempt + 1), attempt === 0 ? 300 : 900);
|
|
132
|
+
};
|
|
124
133
|
try {
|
|
125
134
|
fetch(`${HOST_BASE}/report?${query}`, {
|
|
126
135
|
method: 'POST', // ui-copy-ignore
|
|
127
136
|
credentials: 'same-origin',
|
|
128
137
|
headers: { 'x-dsh-unlag': '1' }, // ui-copy-ignore
|
|
129
138
|
keepalive: true, // ui-copy-ignore
|
|
130
|
-
})
|
|
131
|
-
|
|
139
|
+
})
|
|
140
|
+
.then((response) => {
|
|
141
|
+
if (!response?.ok) again();
|
|
142
|
+
})
|
|
143
|
+
.catch(again);
|
|
144
|
+
} catch {
|
|
145
|
+
again();
|
|
146
|
+
}
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
/** Ask the running app to replace changed plugins now; a running turn is reported, never cut. */
|
package/index.js
CHANGED
|
@@ -1532,9 +1532,17 @@ function serveButton(ctx, controller, config) {
|
|
|
1532
1532
|
// Which generation of the page came up. A rebuild that lands on older bytes then says so.
|
|
1533
1533
|
const pageRev = (params.get('rev') ?? '').replace(/[^a-z0-9]/gu, '').slice(0, 24)
|
|
1534
1534
|
const from = pageRev === '' ? '' : ` (page ${pageRev})`
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1535
|
+
/**
|
|
1536
|
+
* Every outcome the page reports is written down. A press whose line was missing left the
|
|
1537
|
+
* log unable to say what happened; an outcome with no line of its own (a failed
|
|
1538
|
+
* replacement, a press when both switches are off) says so in its own words.
|
|
1539
|
+
*/
|
|
1540
|
+
const named = event.replace(/[^a-z-]/gu, '').slice(0, 24)
|
|
1541
|
+
if (named === 'mounted') log(`interface rebuilt; the page runs the plugins as served now${from}`)
|
|
1542
|
+
else if (named === 'rebuild') log('rebuild allowed: the page re-enters on the served modules')
|
|
1543
|
+
else if (named === 'held') log(`rebuild held back: ${gate === '' ? 'unknown' : gate}`)
|
|
1544
|
+
else if (named === '') log('a press reported nothing')
|
|
1545
|
+
else log(`a press ended: ${named}${gate === '' ? '' : ` (${gate})`}${from}`)
|
|
1538
1546
|
sendJson(res, 200, { status: 'done' })
|
|
1539
1547
|
} catch (error) {
|
|
1540
1548
|
log(`cannot record a press report: ${error?.message ?? error}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.19",
|
|
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",
|