@ovineko/spa-guard 0.0.1-alpha-25 → 0.0.1-alpha-26
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/README.md +76 -0
- package/dist/runtime/index.js +4 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @ovineko/spa-guard
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ovineko/spa-guard)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
Core runtime for spa-guard — chunk load error handling, version checking, spinner, i18n, and event schema for SPAs.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @ovineko/spa-guard
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Call `recommendedSetup` once when your app boots. It dismisses the loading spinner, starts version checking, and returns a cleanup function.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { recommendedSetup } from "@ovineko/spa-guard/runtime";
|
|
20
|
+
|
|
21
|
+
const cleanup = recommendedSetup();
|
|
22
|
+
// optionally call cleanup() to stop background checks
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Disable version checking:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const cleanup = recommendedSetup({ versionCheck: false });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
### `@ovineko/spa-guard` (common)
|
|
34
|
+
|
|
35
|
+
- `listen` — subscribe to spa-guard events
|
|
36
|
+
- `events` — event type constants
|
|
37
|
+
- `options` — runtime options helpers
|
|
38
|
+
- `disableDefaultRetry` / `enableDefaultRetry` / `isDefaultRetryEnabled` — control default retry behaviour
|
|
39
|
+
- `BeaconError` — error class for beacon failures
|
|
40
|
+
- `ForceRetryError` — error class to force a retry
|
|
41
|
+
|
|
42
|
+
### `@ovineko/spa-guard/runtime`
|
|
43
|
+
|
|
44
|
+
- `recommendedSetup(options?)` — enable recommended runtime features; returns cleanup function
|
|
45
|
+
- `RecommendedSetupOptions` — `{ versionCheck?: boolean }`
|
|
46
|
+
- `startVersionCheck` / `stopVersionCheck` — manual version check control
|
|
47
|
+
- `getState` / `subscribeToState` — runtime state access
|
|
48
|
+
- `SpaGuardState` — state type
|
|
49
|
+
- `showSpinner` / `dismissSpinner` / `getSpinnerHtml` — spinner helpers
|
|
50
|
+
- `setTranslations` — override i18n strings
|
|
51
|
+
- `ForceRetryError`
|
|
52
|
+
|
|
53
|
+
### `@ovineko/spa-guard/schema`
|
|
54
|
+
|
|
55
|
+
Schemas for spa-guard configuration.
|
|
56
|
+
|
|
57
|
+
### `@ovineko/spa-guard/i18n`
|
|
58
|
+
|
|
59
|
+
Built-in translation strings.
|
|
60
|
+
|
|
61
|
+
### `@ovineko/spa-guard/runtime/debug`
|
|
62
|
+
|
|
63
|
+
Debug helpers for testing error scenarios.
|
|
64
|
+
|
|
65
|
+
## Related packages
|
|
66
|
+
|
|
67
|
+
- [@ovineko/spa-guard-react](../react/README.md) — `lazyWithRetry` and React error boundary
|
|
68
|
+
- [@ovineko/spa-guard-react-router](../react-router/README.md) — React Router error boundary
|
|
69
|
+
- [@ovineko/spa-guard-vite](../vite/README.md) — Vite plugin (injects runtime script)
|
|
70
|
+
- [@ovineko/spa-guard-node](../node/README.md) — Node.js cache and builder API
|
|
71
|
+
- [@ovineko/spa-guard-fastify](../fastify/README.md) — Fastify plugin
|
|
72
|
+
- [@ovineko/spa-guard-eslint](../eslint/README.md) — ESLint rules
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
package/dist/runtime/index.js
CHANGED
|
@@ -33,7 +33,10 @@ if (globalThis.window && !globalThis.window[versionCheckStateWindowKey]) {
|
|
|
33
33
|
globalThis.window[versionCheckStateWindowKey] = createInitialState();
|
|
34
34
|
}
|
|
35
35
|
var getState2 = () => {
|
|
36
|
-
|
|
36
|
+
if (globalThis.window === void 0) {
|
|
37
|
+
return createInitialState();
|
|
38
|
+
}
|
|
39
|
+
return globalThis.window[versionCheckStateWindowKey] ?? (globalThis.window[versionCheckStateWindowKey] = createInitialState());
|
|
37
40
|
};
|
|
38
41
|
var fetchJsonVersion = async () => {
|
|
39
42
|
const endpoint = getOptions().checkVersion?.endpoint;
|