@ovineko/spa-guard 0.0.2-alpha-1 → 0.0.4

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 (67) hide show
  1. package/README.md +22 -173
  2. package/dist/ForceRetryError-BWLv3UVK.d.mts +6 -0
  3. package/dist/_internal.d.ts +149 -20
  4. package/dist/_internal.js +113 -170
  5. package/dist/chunk-CfYAbeIz.mjs +13 -0
  6. package/dist/common/index.d.ts +29 -9
  7. package/dist/common/index.js +47 -83
  8. package/dist/errorDispatchers-Cl_pa0DT.mjs +105 -0
  9. package/dist/i18n/index.d.ts +2 -21
  10. package/dist/i18n/index.js +344 -341
  11. package/dist/index-DL8CfPXg.d.mts +26 -0
  12. package/dist/index-rPxPv6iu.d.mts +16 -0
  13. package/dist/logger-Cp1Eyk6S.mjs +534 -0
  14. package/dist/retryOrchestrator-DNGIHV2M.mjs +758 -0
  15. package/dist/retryOrchestrator-mn9XcIVu.d.mts +257 -0
  16. package/dist/runtime/debug/index.d.ts +6 -4
  17. package/dist/runtime/debug/index.js +218 -238
  18. package/dist/runtime/index.d.ts +66 -8
  19. package/dist/runtime/index.js +279 -367
  20. package/dist/schema/index.d.ts +2 -13
  21. package/dist/schema/index.js +1 -0
  22. package/dist/schema/parse.d.ts +6 -2
  23. package/dist/schema/parse.js +29 -44
  24. package/dist/spinner-BbZVKZ-6.mjs +60 -0
  25. package/dist/spinner-X23gI09z.d.mts +37 -0
  26. package/dist/state-I20jENMD.mjs +93 -0
  27. package/dist/types-DrN8pgyc.d.mts +107 -0
  28. package/package.json +1 -4
  29. package/dist/chunk-3UJ67DPX.js +0 -98
  30. package/dist/chunk-GE63YJOT.js +0 -865
  31. package/dist/chunk-MLKGABMK.js +0 -9
  32. package/dist/chunk-PERG4557.js +0 -74
  33. package/dist/chunk-VZ2DLGXX.js +0 -111
  34. package/dist/chunk-XIFXSNSD.js +0 -678
  35. package/dist/common/checkVersion.d.ts +0 -5
  36. package/dist/common/constants.d.ts +0 -14
  37. package/dist/common/errors/BeaconError.d.ts +0 -12
  38. package/dist/common/errors/ForceRetryError.d.ts +0 -5
  39. package/dist/common/events/index.d.ts +0 -2
  40. package/dist/common/events/internal.d.ts +0 -13
  41. package/dist/common/events/types.d.ts +0 -104
  42. package/dist/common/fallbackRendering.d.ts +0 -23
  43. package/dist/common/fallbackState.d.ts +0 -3
  44. package/dist/common/handleErrorWithSpaGuard.d.ts +0 -18
  45. package/dist/common/html.generated.d.ts +0 -3
  46. package/dist/common/i18n.d.ts +0 -23
  47. package/dist/common/isChunkError.d.ts +0 -1
  48. package/dist/common/isStaticAssetError.d.ts +0 -3
  49. package/dist/common/lastReloadTime.d.ts +0 -17
  50. package/dist/common/listen/index.d.ts +0 -1
  51. package/dist/common/listen/internal.d.ts +0 -2
  52. package/dist/common/log.d.ts +0 -1
  53. package/dist/common/logger.d.ts +0 -30
  54. package/dist/common/options.d.ts +0 -182
  55. package/dist/common/parseVersion.d.ts +0 -9
  56. package/dist/common/retryImport.d.ts +0 -43
  57. package/dist/common/retryOrchestrator.d.ts +0 -35
  58. package/dist/common/retryState.d.ts +0 -11
  59. package/dist/common/sendBeacon.d.ts +0 -2
  60. package/dist/common/serializeError.d.ts +0 -1
  61. package/dist/common/shouldIgnore.d.ts +0 -13
  62. package/dist/common/spinner.d.ts +0 -8
  63. package/dist/common/staticAssetRecovery.d.ts +0 -2
  64. package/dist/i18n/translations.d.ts +0 -2
  65. package/dist/runtime/debug/errorDispatchers.d.ts +0 -63
  66. package/dist/runtime/recommendedSetup.d.ts +0 -36
  67. package/dist/runtime/state.d.ts +0 -20
@@ -1,386 +1,298 @@
1
- import {
2
- dismissSpinner,
3
- extractVersionFromHtml,
4
- getSpinnerHtml,
5
- showSpinner
6
- } from "../chunk-3UJ67DPX.js";
7
- import {
8
- getState,
9
- subscribeToState
10
- } from "../chunk-VZ2DLGXX.js";
11
- import {
12
- ForceRetryError,
13
- getLogger,
14
- getOptions,
15
- getRetryAttemptFromUrl,
16
- getRetrySnapshot,
17
- markRetryHealthyBoot,
18
- setTranslations,
19
- versionCheckStateWindowKey
20
- } from "../chunk-GE63YJOT.js";
21
- import "../chunk-MLKGABMK.js";
22
-
23
- // src/common/checkVersion.ts
24
- var createInitialState = () => ({
25
- blurHandler: null,
26
- checkInProgress: false,
27
- focusHandler: null,
28
- lastCheckTimestamp: null,
29
- lastKnownVersion: null,
30
- runEpoch: 0,
31
- versionCheckInterval: null,
32
- versionCheckTimeout: null,
33
- visibilityHandler: null
1
+ import { C as setTranslations, D as getLogger, L as versionCheckStateWindowKey, g as getOptions, l as ForceRetryError, n as markRetryHealthyBoot, p as getRetryAttemptFromUrl, t as getRetrySnapshot } from "../retryOrchestrator-DNGIHV2M.mjs";
2
+ import { i as getSpinnerHtml, o as showSpinner, r as dismissSpinner, s as extractVersionFromHtml } from "../spinner-BbZVKZ-6.mjs";
3
+ import { n as subscribeToState, t as getState } from "../state-I20jENMD.mjs";
4
+ //#region src/common/checkVersion.ts
5
+ const createInitialState = () => ({
6
+ blurHandler: null,
7
+ checkInProgress: false,
8
+ focusHandler: null,
9
+ lastCheckTimestamp: null,
10
+ lastKnownVersion: null,
11
+ runEpoch: 0,
12
+ versionCheckInterval: null,
13
+ versionCheckTimeout: null,
14
+ visibilityHandler: null
34
15
  });
35
- if (globalThis.window && !globalThis.window[versionCheckStateWindowKey]) {
36
- globalThis.window[versionCheckStateWindowKey] = createInitialState();
37
- }
38
- var getState2 = () => {
39
- if (globalThis.window === void 0) {
40
- return createInitialState();
41
- }
42
- return globalThis.window[versionCheckStateWindowKey] ?? (globalThis.window[versionCheckStateWindowKey] = createInitialState());
16
+ if (globalThis.window && !globalThis.window[versionCheckStateWindowKey]) globalThis.window[versionCheckStateWindowKey] = createInitialState();
17
+ const getState$2 = () => {
18
+ if (globalThis.window === void 0) return createInitialState();
19
+ return globalThis.window[versionCheckStateWindowKey] ?? (globalThis.window[versionCheckStateWindowKey] = createInitialState());
43
20
  };
44
- var FETCH_TIMEOUT_MS = 3e4;
45
- var fetchJsonVersion = async () => {
46
- const endpoint = getOptions().checkVersion?.endpoint;
47
- if (!endpoint) {
48
- getLogger()?.versionCheckRequiresEndpoint();
49
- return null;
50
- }
51
- const controller = new AbortController();
52
- const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
53
- try {
54
- const response = await fetch(endpoint, {
55
- cache: getOptions().checkVersion?.cache ?? "no-store",
56
- headers: { Accept: "application/json" },
57
- signal: controller.signal
58
- });
59
- if (!response.ok) {
60
- getLogger()?.versionCheckHttpError(response.status);
61
- return null;
62
- }
63
- const data = await response.json();
64
- if (typeof data !== "object" || data === null) {
65
- return null;
66
- }
67
- return "version" in data && typeof data.version === "string" ? data.version : null;
68
- } finally {
69
- clearTimeout(timeoutId);
70
- }
21
+ const FETCH_TIMEOUT_MS = 3e4;
22
+ const fetchJsonVersion = async () => {
23
+ const endpoint = getOptions().checkVersion?.endpoint;
24
+ if (!endpoint) {
25
+ getLogger()?.versionCheckRequiresEndpoint();
26
+ return null;
27
+ }
28
+ const controller = new AbortController();
29
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
30
+ try {
31
+ const response = await fetch(endpoint, {
32
+ cache: getOptions().checkVersion?.cache ?? "no-store",
33
+ headers: { Accept: "application/json" },
34
+ signal: controller.signal
35
+ });
36
+ if (!response.ok) {
37
+ getLogger()?.versionCheckHttpError(response.status);
38
+ return null;
39
+ }
40
+ const data = await response.json();
41
+ if (typeof data !== "object" || data === null) return null;
42
+ return "version" in data && typeof data.version === "string" ? data.version : null;
43
+ } finally {
44
+ clearTimeout(timeoutId);
45
+ }
71
46
  };
72
- var fetchHtmlVersion = async () => {
73
- const url = new URL(globalThis.location.href);
74
- url.search = "";
75
- url.hash = "";
76
- const controller = new AbortController();
77
- const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
78
- try {
79
- const response = await fetch(url.toString(), {
80
- cache: getOptions().checkVersion?.cache ?? "no-store",
81
- headers: { Accept: "text/html" },
82
- signal: controller.signal
83
- });
84
- if (!response.ok) {
85
- getLogger()?.versionCheckHttpError(response.status);
86
- return null;
87
- }
88
- const html = await response.text();
89
- const version = extractVersionFromHtml(html);
90
- if (!version) {
91
- getLogger()?.versionCheckParseError();
92
- return null;
93
- }
94
- return version;
95
- } finally {
96
- clearTimeout(timeoutId);
97
- }
47
+ const fetchHtmlVersion = async () => {
48
+ const url = new URL(globalThis.location.href);
49
+ url.search = "";
50
+ url.hash = "";
51
+ const controller = new AbortController();
52
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
53
+ try {
54
+ const response = await fetch(url.toString(), {
55
+ cache: getOptions().checkVersion?.cache ?? "no-store",
56
+ headers: { Accept: "text/html" },
57
+ signal: controller.signal
58
+ });
59
+ if (!response.ok) {
60
+ getLogger()?.versionCheckHttpError(response.status);
61
+ return null;
62
+ }
63
+ const version = extractVersionFromHtml(await response.text());
64
+ if (!version) {
65
+ getLogger()?.versionCheckParseError();
66
+ return null;
67
+ }
68
+ return version;
69
+ } finally {
70
+ clearTimeout(timeoutId);
71
+ }
98
72
  };
99
- var fetchRemoteVersion = async (mode) => {
100
- return mode === "json" ? fetchJsonVersion() : fetchHtmlVersion();
73
+ const fetchRemoteVersion = async (mode) => {
74
+ return mode === "json" ? fetchJsonVersion() : fetchHtmlVersion();
101
75
  };
102
- var onVersionChange = (oldVersion, latestVersion) => {
103
- if (globalThis.window !== void 0) {
104
- globalThis.dispatchEvent(
105
- new CustomEvent("spa-guard:version-change", {
106
- detail: { latestVersion, oldVersion }
107
- })
108
- );
109
- }
110
- getLogger()?.versionChangeDetected(oldVersion, latestVersion);
111
- if (getOptions().checkVersion?.onUpdate !== "event") {
112
- globalThis.location.reload();
113
- }
76
+ const onVersionChange = (oldVersion, latestVersion) => {
77
+ if (globalThis.window !== void 0) globalThis.dispatchEvent(new CustomEvent("spa-guard:version-change", { detail: {
78
+ latestVersion,
79
+ oldVersion
80
+ } }));
81
+ getLogger()?.versionChangeDetected(oldVersion, latestVersion);
82
+ if (getOptions().checkVersion?.onUpdate !== "event") globalThis.location.reload();
114
83
  };
115
- var checkVersionOnce = async (mode) => {
116
- const s = getState2();
117
- if (s.checkInProgress) {
118
- return;
119
- }
120
- s.checkInProgress = true;
121
- const epochAtStart = s.runEpoch;
122
- try {
123
- const remoteVersion = await fetchRemoteVersion(mode);
124
- if (epochAtStart !== s.runEpoch) {
125
- return;
126
- }
127
- if (remoteVersion && remoteVersion !== s.lastKnownVersion) {
128
- const oldVersion = s.lastKnownVersion;
129
- s.lastKnownVersion = remoteVersion;
130
- onVersionChange(oldVersion, remoteVersion);
131
- }
132
- } catch (error) {
133
- getLogger()?.versionCheckFailed(error);
134
- } finally {
135
- if (epochAtStart === s.runEpoch) {
136
- s.checkInProgress = false;
137
- }
138
- }
84
+ const checkVersionOnce = async (mode) => {
85
+ const s = getState$2();
86
+ if (s.checkInProgress) return;
87
+ s.checkInProgress = true;
88
+ const epochAtStart = s.runEpoch;
89
+ try {
90
+ const remoteVersion = await fetchRemoteVersion(mode);
91
+ if (epochAtStart !== s.runEpoch) return;
92
+ if (remoteVersion && remoteVersion !== s.lastKnownVersion) {
93
+ const oldVersion = s.lastKnownVersion;
94
+ s.lastKnownVersion = remoteVersion;
95
+ onVersionChange(oldVersion, remoteVersion);
96
+ }
97
+ } catch (error) {
98
+ getLogger()?.versionCheckFailed(error);
99
+ } finally {
100
+ if (epochAtStart === s.runEpoch) s.checkInProgress = false;
101
+ }
139
102
  };
140
- var startPolling = (mode, interval) => {
141
- const s = getState2();
142
- clearTimers();
143
- s.versionCheckInterval = setInterval(async () => {
144
- s.lastCheckTimestamp = Date.now();
145
- await checkVersionOnce(mode);
146
- }, interval);
103
+ const startPolling = (mode, interval) => {
104
+ const s = getState$2();
105
+ clearTimers();
106
+ s.versionCheckInterval = setInterval(async () => {
107
+ s.lastCheckTimestamp = Date.now();
108
+ await checkVersionOnce(mode);
109
+ }, interval);
147
110
  };
148
- var clearTimers = () => {
149
- const s = getState2();
150
- if (s.versionCheckInterval !== null) {
151
- clearInterval(s.versionCheckInterval);
152
- s.versionCheckInterval = null;
153
- }
154
- if (s.versionCheckTimeout !== null) {
155
- clearTimeout(s.versionCheckTimeout);
156
- s.versionCheckTimeout = null;
157
- }
111
+ const clearTimers = () => {
112
+ const s = getState$2();
113
+ if (s.versionCheckInterval !== null) {
114
+ clearInterval(s.versionCheckInterval);
115
+ s.versionCheckInterval = null;
116
+ }
117
+ if (s.versionCheckTimeout !== null) {
118
+ clearTimeout(s.versionCheckTimeout);
119
+ s.versionCheckTimeout = null;
120
+ }
158
121
  };
159
- var handleVisibilityHidden = () => {
160
- clearTimers();
161
- getLogger()?.versionCheckPaused();
122
+ const handleVisibilityHidden = () => {
123
+ clearTimers();
124
+ getLogger()?.versionCheckPaused();
162
125
  };
163
- var handleResume = (mode, interval) => {
164
- if (document.visibilityState !== "visible" || !document.hasFocus()) {
165
- return;
166
- }
167
- const s = getState2();
168
- if (s.versionCheckInterval !== null || s.versionCheckTimeout !== null) {
169
- return;
170
- }
171
- const elapsed = Date.now() - (s.lastCheckTimestamp ?? 0);
172
- if (elapsed >= interval) {
173
- getLogger()?.versionCheckResumedImmediate();
174
- s.lastCheckTimestamp = Date.now();
175
- void checkVersionOnce(mode);
176
- startPolling(mode, interval);
177
- return;
178
- }
179
- getLogger()?.versionCheckResumed();
180
- const remaining = interval - elapsed;
181
- s.versionCheckTimeout = setTimeout(() => {
182
- s.versionCheckTimeout = null;
183
- s.lastCheckTimestamp = Date.now();
184
- void checkVersionOnce(mode);
185
- startPolling(mode, interval);
186
- }, remaining);
126
+ const handleResume = (mode, interval) => {
127
+ if (document.visibilityState !== "visible" || !document.hasFocus()) return;
128
+ const s = getState$2();
129
+ if (s.versionCheckInterval !== null || s.versionCheckTimeout !== null) return;
130
+ const elapsed = Date.now() - (s.lastCheckTimestamp ?? 0);
131
+ if (elapsed >= interval) {
132
+ getLogger()?.versionCheckResumedImmediate();
133
+ s.lastCheckTimestamp = Date.now();
134
+ checkVersionOnce(mode);
135
+ startPolling(mode, interval);
136
+ return;
137
+ }
138
+ getLogger()?.versionCheckResumed();
139
+ const remaining = interval - elapsed;
140
+ s.versionCheckTimeout = setTimeout(() => {
141
+ s.versionCheckTimeout = null;
142
+ s.lastCheckTimestamp = Date.now();
143
+ checkVersionOnce(mode);
144
+ startPolling(mode, interval);
145
+ }, remaining);
187
146
  };
188
- var startVersionCheck = () => {
189
- if (globalThis.window === void 0) {
190
- return;
191
- }
192
- const options = getOptions();
193
- if (!options.version) {
194
- getLogger()?.versionCheckDisabled();
195
- return;
196
- }
197
- const s = getState2();
198
- if (s.versionCheckInterval !== null || s.visibilityHandler !== null) {
199
- getLogger()?.versionCheckAlreadyRunning();
200
- return;
201
- }
202
- s.runEpoch++;
203
- s.lastKnownVersion = options.version;
204
- const interval = options.checkVersion?.interval ?? 3e5;
205
- const mode = options.checkVersion?.mode ?? "html";
206
- getLogger()?.versionCheckStarted(mode, interval, s.lastKnownVersion);
207
- const isTabVisible = document.visibilityState === "visible";
208
- const isWindowFocused = document.hasFocus();
209
- if (isTabVisible && isWindowFocused) {
210
- s.lastCheckTimestamp = Date.now();
211
- startPolling(mode, interval);
212
- } else {
213
- s.lastCheckTimestamp = 0;
214
- getLogger()?.versionCheckPaused();
215
- }
216
- s.visibilityHandler = () => {
217
- if (document.visibilityState === "hidden") {
218
- handleVisibilityHidden();
219
- } else {
220
- handleResume(mode, interval);
221
- }
222
- };
223
- s.focusHandler = () => {
224
- handleResume(mode, interval);
225
- };
226
- s.blurHandler = () => {
227
- handleVisibilityHidden();
228
- };
229
- document.addEventListener("visibilitychange", s.visibilityHandler);
230
- globalThis.addEventListener("focus", s.focusHandler);
231
- globalThis.addEventListener("blur", s.blurHandler);
147
+ const startVersionCheck = () => {
148
+ if (globalThis.window === void 0) return;
149
+ const options = getOptions();
150
+ if (!options.version) {
151
+ getLogger()?.versionCheckDisabled();
152
+ return;
153
+ }
154
+ const s = getState$2();
155
+ if (s.versionCheckInterval !== null || s.visibilityHandler !== null) {
156
+ getLogger()?.versionCheckAlreadyRunning();
157
+ return;
158
+ }
159
+ s.runEpoch++;
160
+ s.lastKnownVersion = options.version;
161
+ const interval = options.checkVersion?.interval ?? 3e5;
162
+ const mode = options.checkVersion?.mode ?? "html";
163
+ getLogger()?.versionCheckStarted(mode, interval, s.lastKnownVersion);
164
+ const isTabVisible = document.visibilityState === "visible";
165
+ const isWindowFocused = document.hasFocus();
166
+ if (isTabVisible && isWindowFocused) {
167
+ s.lastCheckTimestamp = Date.now();
168
+ startPolling(mode, interval);
169
+ } else {
170
+ s.lastCheckTimestamp = 0;
171
+ getLogger()?.versionCheckPaused();
172
+ }
173
+ s.visibilityHandler = () => {
174
+ if (document.visibilityState === "hidden") handleVisibilityHidden();
175
+ else handleResume(mode, interval);
176
+ };
177
+ s.focusHandler = () => {
178
+ handleResume(mode, interval);
179
+ };
180
+ s.blurHandler = () => {
181
+ handleVisibilityHidden();
182
+ };
183
+ document.addEventListener("visibilitychange", s.visibilityHandler);
184
+ globalThis.addEventListener("focus", s.focusHandler);
185
+ globalThis.addEventListener("blur", s.blurHandler);
232
186
  };
233
- var stopVersionCheck = () => {
234
- if (globalThis.window === void 0) {
235
- return;
236
- }
237
- const s = getState2();
238
- s.runEpoch++;
239
- s.checkInProgress = false;
240
- const wasRunning = s.versionCheckInterval !== null || s.versionCheckTimeout !== null || s.visibilityHandler !== null;
241
- clearTimers();
242
- if (s.visibilityHandler !== null) {
243
- document.removeEventListener("visibilitychange", s.visibilityHandler);
244
- s.visibilityHandler = null;
245
- }
246
- if (s.focusHandler !== null) {
247
- globalThis.removeEventListener("focus", s.focusHandler);
248
- s.focusHandler = null;
249
- }
250
- if (s.blurHandler !== null) {
251
- globalThis.removeEventListener("blur", s.blurHandler);
252
- s.blurHandler = null;
253
- }
254
- if (wasRunning) {
255
- getLogger()?.versionCheckStopped();
256
- }
187
+ const stopVersionCheck = () => {
188
+ if (globalThis.window === void 0) return;
189
+ const s = getState$2();
190
+ s.runEpoch++;
191
+ s.checkInProgress = false;
192
+ const wasRunning = s.versionCheckInterval !== null || s.versionCheckTimeout !== null || s.visibilityHandler !== null;
193
+ clearTimers();
194
+ if (s.visibilityHandler !== null) {
195
+ document.removeEventListener("visibilitychange", s.visibilityHandler);
196
+ s.visibilityHandler = null;
197
+ }
198
+ if (s.focusHandler !== null) {
199
+ globalThis.removeEventListener("focus", s.focusHandler);
200
+ s.focusHandler = null;
201
+ }
202
+ if (s.blurHandler !== null) {
203
+ globalThis.removeEventListener("blur", s.blurHandler);
204
+ s.blurHandler = null;
205
+ }
206
+ if (wasRunning) getLogger()?.versionCheckStopped();
257
207
  };
258
-
259
- // src/runtime/recommendedSetup.ts
260
- var AUTO_HEALTHY_BOOT_BUFFER_MS = 1e3;
261
- var MIN_HEALTHY_BOOT_GRACE_MS = 5e3;
262
- var setupStateWindowKey = "__spa_guard_runtime_recommended_setup_state__";
263
- var createFreshState = () => ({
264
- cleanup: () => {
265
- },
266
- initialized: false,
267
- timer: null,
268
- versionCheckEnabled: false
208
+ //#endregion
209
+ //#region src/runtime/recommendedSetup.ts
210
+ const AUTO_HEALTHY_BOOT_BUFFER_MS = 1e3;
211
+ const MIN_HEALTHY_BOOT_GRACE_MS = 5e3;
212
+ const setupStateWindowKey = "__spa_guard_runtime_recommended_setup_state__";
213
+ const createFreshState = () => ({
214
+ cleanup: () => {},
215
+ initialized: false,
216
+ timer: null,
217
+ versionCheckEnabled: false
269
218
  });
270
- var getState3 = () => {
271
- if (globalThis.window === void 0) {
272
- return createFreshState();
273
- }
274
- const w = globalThis.window;
275
- if (!w[setupStateWindowKey]) {
276
- w[setupStateWindowKey] = createFreshState();
277
- }
278
- return w[setupStateWindowKey];
219
+ const getState$1 = () => {
220
+ if (globalThis.window === void 0) return createFreshState();
221
+ const w = globalThis.window;
222
+ if (!w[setupStateWindowKey]) w[setupStateWindowKey] = createFreshState();
223
+ return w[setupStateWindowKey];
279
224
  };
280
- var resolveOptions = (overrides) => {
281
- const healthyBoot = overrides?.healthyBoot;
282
- const versionCheck = overrides?.versionCheck ?? true;
283
- const computedGraceMs = computeAutoHealthyBootGraceMs();
284
- if (healthyBoot === false || healthyBoot === "off") {
285
- return {
286
- healthyBootGraceMs: computedGraceMs,
287
- healthyBootMode: "off",
288
- versionCheck
289
- };
290
- }
291
- if (healthyBoot === "manual") {
292
- return {
293
- healthyBootGraceMs: computedGraceMs,
294
- healthyBootMode: "manual",
295
- versionCheck
296
- };
297
- }
298
- if (healthyBoot && typeof healthyBoot === "object") {
299
- return {
300
- healthyBootGraceMs: Math.max(computedGraceMs, healthyBoot.graceMs ?? computedGraceMs),
301
- healthyBootMode: "auto",
302
- versionCheck
303
- };
304
- }
305
- return {
306
- healthyBootGraceMs: computedGraceMs,
307
- healthyBootMode: "auto",
308
- versionCheck
309
- };
225
+ const resolveOptions = (overrides) => {
226
+ const healthyBoot = overrides?.healthyBoot;
227
+ const versionCheck = overrides?.versionCheck ?? true;
228
+ const computedGraceMs = computeAutoHealthyBootGraceMs();
229
+ if (healthyBoot === false || healthyBoot === "off") return {
230
+ healthyBootGraceMs: computedGraceMs,
231
+ healthyBootMode: "off",
232
+ versionCheck
233
+ };
234
+ if (healthyBoot === "manual") return {
235
+ healthyBootGraceMs: computedGraceMs,
236
+ healthyBootMode: "manual",
237
+ versionCheck
238
+ };
239
+ if (healthyBoot && typeof healthyBoot === "object") return {
240
+ healthyBootGraceMs: Math.max(computedGraceMs, healthyBoot.graceMs ?? computedGraceMs),
241
+ healthyBootMode: "auto",
242
+ versionCheck
243
+ };
244
+ return {
245
+ healthyBootGraceMs: computedGraceMs,
246
+ healthyBootMode: "auto",
247
+ versionCheck
248
+ };
310
249
  };
311
- var computeAutoHealthyBootGraceMs = () => {
312
- const options = getOptions();
313
- const reloadDelays = options.reloadDelays ?? [1e3, 2e3, 5e3];
314
- const lazyRetryDelays = options.lazyRetry?.retryDelays ?? [1e3, 2e3];
315
- const maxReloadDelay = Math.max(...reloadDelays, 0);
316
- const lazyRetryTotalDelay = lazyRetryDelays.reduce((acc, delay) => acc + delay, 0);
317
- return Math.max(
318
- MIN_HEALTHY_BOOT_GRACE_MS,
319
- maxReloadDelay + AUTO_HEALTHY_BOOT_BUFFER_MS,
320
- lazyRetryTotalDelay + AUTO_HEALTHY_BOOT_BUFFER_MS
321
- );
250
+ const computeAutoHealthyBootGraceMs = () => {
251
+ const options = getOptions();
252
+ const reloadDelays = options.reloadDelays ?? [
253
+ 1e3,
254
+ 2e3,
255
+ 5e3
256
+ ];
257
+ const lazyRetryDelays = options.lazyRetry?.retryDelays ?? [1e3, 2e3];
258
+ const maxReloadDelay = Math.max(...reloadDelays, 0);
259
+ const lazyRetryTotalDelay = lazyRetryDelays.reduce((acc, delay) => acc + delay, 0);
260
+ return Math.max(MIN_HEALTHY_BOOT_GRACE_MS, maxReloadDelay + AUTO_HEALTHY_BOOT_BUFFER_MS, lazyRetryTotalDelay + AUTO_HEALTHY_BOOT_BUFFER_MS);
322
261
  };
323
- var scheduleAutoHealthyBoot = (graceMs) => {
324
- if (globalThis.window === void 0) {
325
- return null;
326
- }
327
- if (getRetryAttemptFromUrl() === null) {
328
- return null;
329
- }
330
- return setTimeout(() => {
331
- if (getRetryAttemptFromUrl() === null) {
332
- return;
333
- }
334
- const snapshot = getRetrySnapshot();
335
- if (snapshot.phase !== "idle") {
336
- return;
337
- }
338
- markRetryHealthyBoot();
339
- }, graceMs);
262
+ const scheduleAutoHealthyBoot = (graceMs) => {
263
+ if (globalThis.window === void 0) return null;
264
+ if (getRetryAttemptFromUrl() === null) return null;
265
+ return setTimeout(() => {
266
+ if (getRetryAttemptFromUrl() === null) return;
267
+ if (getRetrySnapshot().phase !== "idle") return;
268
+ markRetryHealthyBoot();
269
+ }, graceMs);
340
270
  };
341
- var recommendedSetup = (overrides) => {
342
- const state = getState3();
343
- if (state.initialized) {
344
- return state.cleanup;
345
- }
346
- dismissSpinner();
347
- const options = resolveOptions(overrides);
348
- if (options.versionCheck) {
349
- startVersionCheck();
350
- }
351
- const timer = options.healthyBootMode === "auto" ? scheduleAutoHealthyBoot(options.healthyBootGraceMs) : null;
352
- const cleanup = () => {
353
- const currentState = getState3();
354
- if (!currentState.initialized) {
355
- return;
356
- }
357
- if (currentState.timer !== null) {
358
- clearTimeout(currentState.timer);
359
- }
360
- if (currentState.versionCheckEnabled) {
361
- stopVersionCheck();
362
- }
363
- if (globalThis.window !== void 0) {
364
- globalThis.window[setupStateWindowKey] = createFreshState();
365
- }
366
- };
367
- Object.assign(state, {
368
- cleanup,
369
- initialized: true,
370
- timer,
371
- versionCheckEnabled: options.versionCheck
372
- });
373
- return cleanup;
374
- };
375
- export {
376
- ForceRetryError,
377
- dismissSpinner,
378
- getSpinnerHtml,
379
- getState,
380
- recommendedSetup,
381
- setTranslations,
382
- showSpinner,
383
- startVersionCheck,
384
- stopVersionCheck,
385
- subscribeToState
271
+ /**
272
+ * Enable recommended runtime features with sensible defaults.
273
+ * Returns a cleanup function that tears down all started features.
274
+ */
275
+ const recommendedSetup = (overrides) => {
276
+ const state = getState$1();
277
+ if (state.initialized) return state.cleanup;
278
+ dismissSpinner();
279
+ const options = resolveOptions(overrides);
280
+ if (options.versionCheck) startVersionCheck();
281
+ const timer = options.healthyBootMode === "auto" ? scheduleAutoHealthyBoot(options.healthyBootGraceMs) : null;
282
+ const cleanup = () => {
283
+ const currentState = getState$1();
284
+ if (!currentState.initialized) return;
285
+ if (currentState.timer !== null) clearTimeout(currentState.timer);
286
+ if (currentState.versionCheckEnabled) stopVersionCheck();
287
+ if (globalThis.window !== void 0) globalThis.window[setupStateWindowKey] = createFreshState();
288
+ };
289
+ Object.assign(state, {
290
+ cleanup,
291
+ initialized: true,
292
+ timer,
293
+ versionCheckEnabled: options.versionCheck
294
+ });
295
+ return cleanup;
386
296
  };
297
+ //#endregion
298
+ export { ForceRetryError, dismissSpinner, getSpinnerHtml, getState, recommendedSetup, setTranslations, showSpinner, startVersionCheck, stopVersionCheck, subscribeToState };