dsh-unlag 1.9.77 → 1.9.79
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 +27 -5
- 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()));
|
|
@@ -100,15 +108,23 @@ window.__ModuleLoader__.load({
|
|
|
100
108
|
*/
|
|
101
109
|
const HOST_BASE = '/dsh-unlag'; // ui-copy-ignore
|
|
102
110
|
|
|
103
|
-
async function readSettings() {
|
|
111
|
+
async function readSettings(attempt = 0) {
|
|
112
|
+
const again = async () => {
|
|
113
|
+
if (attempt >= 1) return null;
|
|
114
|
+
await new Promise((resolve) => setTimeout(resolve, 250)); // ui-copy-ignore
|
|
115
|
+
return readSettings(attempt + 1);
|
|
116
|
+
};
|
|
104
117
|
try {
|
|
118
|
+
// The answer can be missing for a moment while the plugin set is recomposed, which reads
|
|
119
|
+
// exactly like a press with nothing switched on. One more ask costs a fraction of a second
|
|
120
|
+
// and turns that into the press the person meant; a second miss is still reported as such.
|
|
105
121
|
const response = await withTimeout(fetch(`${HOST_BASE}/state`, { cache: 'no-store', credentials: 'same-origin' }));
|
|
106
|
-
if (!response.ok) return
|
|
122
|
+
if (!response.ok) return again();
|
|
107
123
|
const data = await withTimeout(response.json());
|
|
108
|
-
if (data === null || typeof data !== 'object') return
|
|
124
|
+
if (data === null || typeof data !== 'object') return again();
|
|
109
125
|
return { plugins: data.plugins !== false, page: data.page !== false };
|
|
110
126
|
} catch {
|
|
111
|
-
return
|
|
127
|
+
return again();
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
|
|
@@ -852,7 +868,6 @@ window.__ModuleLoader__.load({
|
|
|
852
868
|
report('replaced');
|
|
853
869
|
return stop(replaced ? 'replaced' : 'done');
|
|
854
870
|
}
|
|
855
|
-
stampWrite();
|
|
856
871
|
const reason = await prepareInterface();
|
|
857
872
|
if (reason !== null) {
|
|
858
873
|
// The log keeps the exact check that refused, so a held press can be explained later.
|
|
@@ -860,6 +875,9 @@ window.__ModuleLoader__.load({
|
|
|
860
875
|
report('held', replaced ? `applied:${gate}` : gate);
|
|
861
876
|
return stop(reason, replaced);
|
|
862
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();
|
|
863
881
|
report('rebuild');
|
|
864
882
|
navigated = true;
|
|
865
883
|
reloadFreshPage();
|
|
@@ -877,6 +895,9 @@ window.__ModuleLoader__.load({
|
|
|
877
895
|
// Still here after asking for a rebuild: the page held the navigation. Say what
|
|
878
896
|
// happened and take the press back, so the button is never left unresponsive.
|
|
879
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();
|
|
880
901
|
setPending(false);
|
|
881
902
|
// Only a press that really replaced the plugins may say so: a page-only press that
|
|
882
903
|
// held the navigation changed no code.
|
|
@@ -918,6 +939,7 @@ window.__ModuleLoader__.load({
|
|
|
918
939
|
*/
|
|
919
940
|
const PROBE = {
|
|
920
941
|
prepareInterface,
|
|
942
|
+
readSettings,
|
|
921
943
|
startupLooksServable,
|
|
922
944
|
startupHoldReason: () => holdReason,
|
|
923
945
|
noticeFor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.79",
|
|
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",
|