@ultimat3/pwa 21.0.0 → 22.0.0
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 +15 -0
- package/package.json +3 -3
- package/src/index.ts +1 -8
- package/src/strategies.ts +7 -2
package/README.md
CHANGED
|
@@ -81,6 +81,21 @@ gate. `CAPABILITY_SW_MARKERS` is checked against the emitted `sw.js` in both dir
|
|
|
81
81
|
here that the generator does not honour is a failing test rather than an installed app announcing a
|
|
82
82
|
capability nothing implements.
|
|
83
83
|
|
|
84
|
+
## Error classes
|
|
85
|
+
|
|
86
|
+
Every error class `src/index.ts` exports, for `instanceof` inside one process. Across a wire or
|
|
87
|
+
a job boundary the class is gone and the `code` is what survives — match on that.
|
|
88
|
+
|
|
89
|
+
| Class | Code | Declared in |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `BuildIdMissingError` | `X_BUILD_ID_MISSING` | `src/errors.ts` |
|
|
92
|
+
| `NotImplementedError` | `X_NOT_IMPLEMENTED` | `src/errors.ts` |
|
|
93
|
+
| `PwaIconMissingError` | `X_PWA_ICON_MISSING` | `src/errors.ts` |
|
|
94
|
+
| `PwaManifestInvalidError` | `X_PWA_MANIFEST_INVALID` | `src/errors.ts` |
|
|
95
|
+
| `PwaNoOfflineFallbackError` | `X_PWA_NO_OFFLINE_FALLBACK` | `src/errors.ts` |
|
|
96
|
+
| `PwaStrategyExhaustedError` | `X_PWA_STRATEGY_EXHAUSTED` | `src/errors.ts` |
|
|
97
|
+
| `SwScopeInvalidError` | `X_SW_SCOPE_INVALID` | `src/errors.ts` |
|
|
98
|
+
|
|
84
99
|
## Public API
|
|
85
100
|
|
|
86
101
|
| Export | Owns |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/pwa",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "Generated service worker, web manifest, icons, push and version-skew handling.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "bun test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ultimat3/core": "
|
|
36
|
-
"@ultimat3/seo": "
|
|
35
|
+
"@ultimat3/core": "22.0.0",
|
|
36
|
+
"@ultimat3/seo": "22.0.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ export {
|
|
|
17
17
|
export type { Capability, CapabilityFlags, ResolvedCapabilities } from './capabilities';
|
|
18
18
|
export {
|
|
19
19
|
CAPABILITIES,
|
|
20
|
-
CAPABILITY_MANIFEST_KEYS,
|
|
21
20
|
CAPABILITY_SW_MARKERS,
|
|
22
21
|
enabledCapabilities,
|
|
23
22
|
isEnabled,
|
|
@@ -57,7 +56,6 @@ export {
|
|
|
57
56
|
maskableSafeZone,
|
|
58
57
|
planIcons,
|
|
59
58
|
requireSourceIcon,
|
|
60
|
-
SPLASH_MATRIX,
|
|
61
59
|
} from './icons';
|
|
62
60
|
export type {
|
|
63
61
|
BeforeInstallPromptEventLike,
|
|
@@ -68,7 +66,7 @@ export type {
|
|
|
68
66
|
IosGuidance,
|
|
69
67
|
ReadSignal,
|
|
70
68
|
} from './install';
|
|
71
|
-
export { createInstallController, iosInstallGuidance
|
|
69
|
+
export { createInstallController, iosInstallGuidance } from './install';
|
|
72
70
|
export type {
|
|
73
71
|
DisplayMode,
|
|
74
72
|
FileHandler,
|
|
@@ -90,7 +88,6 @@ export type { PrecacheAsset, PrecacheEntry, PrecacheInput, PrecacheManifest } fr
|
|
|
90
88
|
export {
|
|
91
89
|
buildPrecacheManifest,
|
|
92
90
|
DEFAULT_PRECACHE_WARN_BYTES,
|
|
93
|
-
serializePrecacheManifest,
|
|
94
91
|
} from './precache';
|
|
95
92
|
export type {
|
|
96
93
|
PushPayload,
|
|
@@ -105,7 +102,6 @@ export type {
|
|
|
105
102
|
export {
|
|
106
103
|
pushSource,
|
|
107
104
|
renderPushPayload,
|
|
108
|
-
serializePushMessage,
|
|
109
105
|
subscribeSource,
|
|
110
106
|
subscriptionState,
|
|
111
107
|
} from './push';
|
|
@@ -123,10 +119,7 @@ export {
|
|
|
123
119
|
MODE_STRATEGY,
|
|
124
120
|
networkFirst,
|
|
125
121
|
networkOnly,
|
|
126
|
-
STRATEGY_FN_NAMES,
|
|
127
|
-
STRATEGY_FNS,
|
|
128
122
|
STRATEGY_NAMES,
|
|
129
|
-
STRATEGY_SOURCE,
|
|
130
123
|
staleWhileRevalidate,
|
|
131
124
|
strategyFor,
|
|
132
125
|
} from './strategies';
|
package/src/strategies.ts
CHANGED
|
@@ -80,6 +80,8 @@ export interface StrategyEnv {
|
|
|
80
80
|
/** The named cache this strategy reads and writes. */
|
|
81
81
|
open(cacheName: string): Promise<StrategyCache>;
|
|
82
82
|
fetch(request: Request): Promise<Response>;
|
|
83
|
+
/** The fetch event's `waitUntil`, when there is one — background work must be handed to it. */
|
|
84
|
+
wait?(work: Promise<unknown>): void;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
export interface StrategyCache {
|
|
@@ -139,7 +141,10 @@ export async function staleWhileRevalidate(
|
|
|
139
141
|
.catch(async () => (hit !== undefined ? hit : fallbackOrThrow(options)));
|
|
140
142
|
|
|
141
143
|
if (hit !== undefined) {
|
|
142
|
-
|
|
144
|
+
// The refresh is handed to the event's `waitUntil` NOW, before the cached answer returns:
|
|
145
|
+
// taken after `respondWith` settled, a browser refuses the extension (`InvalidStateError`) and
|
|
146
|
+
// may kill the worker mid-refresh. `later` also swallows its rejection, as `.catch` did.
|
|
147
|
+
env.wait?.(refresh.catch(() => undefined));
|
|
143
148
|
return hit;
|
|
144
149
|
}
|
|
145
150
|
return refresh;
|
|
@@ -215,7 +220,7 @@ export const STRATEGY_SOURCE = Object.freeze<Record<StrategyName, string>>({
|
|
|
215
220
|
const c=await openCache(cn);const hit=await c.match(req);
|
|
216
221
|
const refresh=fetch(req).then((r)=>{if(r.ok)later(wait,c.put(req,r.clone()));return r})
|
|
217
222
|
.catch(()=>hit||(fb?fb():Response.error()));
|
|
218
|
-
if(hit){refresh
|
|
223
|
+
if(hit){later(wait,refresh);return hit}
|
|
219
224
|
return refresh
|
|
220
225
|
}`,
|
|
221
226
|
'network-only': `async function networkOnly(req,cn,fb,wait){
|