serwist 10.0.0-preview.1 → 10.0.0-preview.3
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/dist/NavigationRoute.d.ts.map +1 -1
- package/dist/RegExpRoute.d.ts.map +1 -1
- package/dist/Route.d.ts.map +1 -1
- package/dist/Serwist.d.ts +5 -5
- package/dist/Serwist.d.ts.map +1 -1
- package/dist/chunks/{resultingClientExists.js → waitUntil.js} +117 -117
- package/dist/copyResponse.d.ts.map +1 -1
- package/dist/index.d.ts +11 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.internal.d.ts +16 -16
- package/dist/index.internal.d.ts.map +1 -1
- package/dist/index.internal.js +2 -2
- package/dist/index.js +1400 -1387
- package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -1
- package/dist/lib/backgroundSync/index.d.ts +6 -0
- package/dist/lib/backgroundSync/index.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -1
- package/dist/lib/broadcastUpdate/index.d.ts +6 -0
- package/dist/lib/broadcastUpdate/index.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -1
- package/dist/lib/cacheableResponse/index.d.ts +4 -0
- package/dist/lib/cacheableResponse/index.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/PrecacheCacheKeyPlugin.d.ts +1 -1
- package/dist/lib/controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/PrecacheController.d.ts +9 -5
- package/dist/lib/controllers/PrecacheController/PrecacheController.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/PrecacheInstallReportPlugin.d.ts +1 -1
- package/dist/lib/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/PrecacheRoute.d.ts +1 -1
- package/dist/lib/controllers/PrecacheController/PrecacheRoute.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/PrecacheStrategy.d.ts +4 -4
- package/dist/lib/controllers/PrecacheController/PrecacheStrategy.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/PrecacheController/parsePrecacheOptions.d.ts +3 -3
- package/dist/lib/controllers/PrecacheController/parsePrecacheOptions.d.ts.map +1 -0
- package/dist/{controllers → lib/controllers}/RuntimeCacheController.d.ts +10 -5
- package/dist/lib/controllers/RuntimeCacheController.d.ts.map +1 -0
- package/dist/lib/controllers/index.d.ts +4 -0
- package/dist/lib/controllers/index.d.ts.map +1 -0
- package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -1
- package/dist/lib/expiration/index.d.ts +4 -0
- package/dist/lib/expiration/index.d.ts.map +1 -0
- package/dist/lib/googleAnalytics/index.d.ts +3 -0
- package/dist/lib/googleAnalytics/index.d.ts.map +1 -0
- package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -1
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts +12 -6
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -1
- package/dist/lib/precaching/index.d.ts +3 -0
- package/dist/lib/precaching/index.d.ts.map +1 -0
- package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -1
- package/dist/lib/rangeRequests/index.d.ts +3 -0
- package/dist/lib/rangeRequests/index.d.ts.map +1 -0
- package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -1
- package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -1
- package/dist/lib/strategies/Strategy.d.ts.map +1 -1
- package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
- package/dist/lib/strategies/index.d.ts +11 -0
- package/dist/lib/strategies/index.d.ts.map +1 -0
- package/dist/navigationPreload.d.ts.map +1 -1
- package/dist/registerQuotaErrorCallback.d.ts.map +1 -1
- package/dist/setCacheNameDetails.d.ts +1 -1
- package/dist/setCacheNameDetails.d.ts.map +1 -1
- package/dist/types.d.ts +24 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/SerwistError.d.ts +1 -1
- package/dist/utils/SerwistError.d.ts.map +1 -1
- package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -1
- package/dist/utils/createCacheKey.d.ts.map +1 -1
- package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -1
- package/dist/utils/getFriendlyURL.d.ts.map +1 -1
- package/dist/utils/normalizeHandler.d.ts.map +1 -1
- package/dist/utils/parseRoute.d.ts.map +1 -1
- package/dist/utils/printCleanupDetails.d.ts.map +1 -1
- package/dist/utils/printInstallDetails.d.ts.map +1 -1
- package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -1
- package/dist/utils/waitUntil.d.ts.map +1 -1
- package/package.json +28 -5
- package/src/NavigationRoute.ts +2 -2
- package/src/RegExpRoute.ts +2 -2
- package/src/Route.ts +2 -2
- package/src/Serwist.ts +23 -19
- package/src/cacheNames.ts +1 -1
- package/src/copyResponse.ts +2 -2
- package/src/index.internal.ts +16 -16
- package/src/index.ts +68 -96
- package/src/lib/backgroundSync/BackgroundSyncQueue.ts +4 -4
- package/src/lib/backgroundSync/BackgroundSyncQueueStore.ts +1 -1
- package/src/lib/backgroundSync/StorableRequest.ts +1 -1
- package/src/lib/backgroundSync/index.ts +5 -0
- package/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts +4 -4
- package/src/lib/broadcastUpdate/index.ts +5 -0
- package/src/lib/broadcastUpdate/responsesAreSame.ts +2 -2
- package/src/lib/cacheableResponse/CacheableResponse.ts +4 -4
- package/src/lib/cacheableResponse/index.ts +3 -0
- package/src/{controllers → lib/controllers}/PrecacheController/PrecacheCacheKeyPlugin.ts +1 -1
- package/src/{controllers → lib/controllers}/PrecacheController/PrecacheController.ts +19 -16
- package/src/{controllers → lib/controllers}/PrecacheController/PrecacheInstallReportPlugin.ts +1 -1
- package/src/{controllers → lib/controllers}/PrecacheController/PrecacheRoute.ts +5 -5
- package/src/{controllers → lib/controllers}/PrecacheController/PrecacheStrategy.ts +10 -10
- package/src/{controllers → lib/controllers}/PrecacheController/parsePrecacheOptions.ts +3 -3
- package/src/{controllers → lib/controllers}/RuntimeCacheController.ts +6 -6
- package/src/lib/controllers/index.ts +3 -0
- package/src/lib/expiration/CacheExpiration.ts +3 -3
- package/src/lib/expiration/ExpirationPlugin.ts +6 -6
- package/src/lib/expiration/index.ts +3 -0
- package/src/lib/googleAnalytics/index.ts +2 -0
- package/src/lib/googleAnalytics/initializeGoogleAnalytics.ts +5 -5
- package/src/lib/precaching/PrecacheFallbackPlugin.ts +18 -7
- package/src/lib/precaching/index.ts +2 -0
- package/src/lib/rangeRequests/createPartialResponse.ts +3 -3
- package/src/lib/rangeRequests/index.ts +2 -0
- package/src/lib/rangeRequests/utils/calculateEffectiveBoundaries.ts +2 -2
- package/src/lib/rangeRequests/utils/parseRangeHeader.ts +2 -2
- package/src/lib/strategies/CacheFirst.ts +3 -3
- package/src/lib/strategies/CacheOnly.ts +3 -3
- package/src/lib/strategies/NetworkFirst.ts +3 -3
- package/src/lib/strategies/NetworkOnly.ts +4 -4
- package/src/lib/strategies/StaleWhileRevalidate.ts +3 -3
- package/src/lib/strategies/Strategy.ts +4 -4
- package/src/lib/strategies/StrategyHandler.ts +9 -9
- package/src/lib/strategies/index.ts +10 -0
- package/src/lib/strategies/utils/messages.ts +2 -2
- package/src/models/messages/messages.ts +3 -3
- package/src/navigationPreload.ts +1 -1
- package/src/registerQuotaErrorCallback.ts +2 -2
- package/src/setCacheNameDetails.ts +4 -4
- package/src/types.ts +36 -5
- package/src/utils/SerwistError.ts +2 -2
- package/src/utils/cacheNames.ts +1 -1
- package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
- package/dist/controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts.map +0 -1
- package/dist/controllers/PrecacheController/PrecacheController.d.ts.map +0 -1
- package/dist/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts.map +0 -1
- package/dist/controllers/PrecacheController/PrecacheRoute.d.ts.map +0 -1
- package/dist/controllers/PrecacheController/PrecacheStrategy.d.ts.map +0 -1
- package/dist/controllers/PrecacheController/parsePrecacheOptions.d.ts.map +0 -1
- package/dist/controllers/RuntimeCacheController.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serwist",
|
|
3
|
-
"version": "10.0.0-preview.
|
|
3
|
+
"version": "10.0.0-preview.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Swiss Army knife for service workers.",
|
|
6
6
|
"files": [
|
|
@@ -30,6 +30,28 @@
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
+
"imports": {
|
|
34
|
+
"#lib/*.js": {
|
|
35
|
+
"local": "./src/lib/*.ts",
|
|
36
|
+
"types": "./dist/lib/*.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"#index": {
|
|
39
|
+
"local": "./src/index.ts",
|
|
40
|
+
"types": "./dist/index.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"#index.internal": {
|
|
43
|
+
"local": "./src/index.internal.ts",
|
|
44
|
+
"types": "./dist/index.internal.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"#models/*.js": {
|
|
47
|
+
"local": "./src/models/*.ts",
|
|
48
|
+
"types": "./dist/models/*.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"#utils/*.js": {
|
|
51
|
+
"local": "./src/utils/*.ts",
|
|
52
|
+
"types": "./dist/utils/*.d.ts"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
33
55
|
"exports": {
|
|
34
56
|
".": {
|
|
35
57
|
"types": "./dist/index.d.ts",
|
|
@@ -43,12 +65,12 @@
|
|
|
43
65
|
},
|
|
44
66
|
"dependencies": {
|
|
45
67
|
"idb": "8.0.2",
|
|
46
|
-
"@serwist/utils": "10.0.0-preview.
|
|
68
|
+
"@serwist/utils": "10.0.0-preview.3"
|
|
47
69
|
},
|
|
48
70
|
"devDependencies": {
|
|
49
|
-
"rollup": "4.
|
|
50
|
-
"typescript": "5.
|
|
51
|
-
"@serwist/configs": "10.0.0-preview.
|
|
71
|
+
"rollup": "4.40.0",
|
|
72
|
+
"typescript": "5.8.3",
|
|
73
|
+
"@serwist/configs": "10.0.0-preview.3"
|
|
52
74
|
},
|
|
53
75
|
"peerDependencies": {
|
|
54
76
|
"typescript": ">=5.0.0"
|
|
@@ -62,6 +84,7 @@
|
|
|
62
84
|
"build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
|
|
63
85
|
"dev": "rollup --config rollup.config.js --watch",
|
|
64
86
|
"lint": "biome lint ./src",
|
|
87
|
+
"qcheck": "biome check ./src",
|
|
65
88
|
"typecheck": "tsc"
|
|
66
89
|
}
|
|
67
90
|
}
|
package/src/NavigationRoute.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
9
11
|
import { Route } from "./Route.js";
|
|
10
12
|
import type { RouteHandler, RouteMatchCallbackOptions } from "./types.js";
|
|
11
|
-
import { assert } from "./utils/assert.js";
|
|
12
|
-
import { logger } from "./utils/logger.js";
|
|
13
13
|
|
|
14
14
|
export interface NavigationRouteMatchOptions {
|
|
15
15
|
/**
|
package/src/RegExpRoute.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
9
11
|
import { Route } from "./Route.js";
|
|
10
12
|
import type { HTTPMethod } from "./constants.js";
|
|
11
13
|
import type { RouteHandler, RouteMatchCallback, RouteMatchCallbackOptions } from "./types.js";
|
|
12
|
-
import { assert } from "./utils/assert.js";
|
|
13
|
-
import { logger } from "./utils/logger.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A class that makes it easy to create a {@linkcode Route} object with a regular expression.
|
package/src/Route.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { normalizeHandler } from "#utils/normalizeHandler.js";
|
|
9
11
|
import type { HTTPMethod } from "./constants.js";
|
|
10
12
|
import { defaultMethod, validMethods } from "./constants.js";
|
|
11
13
|
import type { RouteHandler, RouteHandlerObject, RouteMatchCallback } from "./types.js";
|
|
12
|
-
import { assert } from "./utils/assert.js";
|
|
13
|
-
import { normalizeHandler } from "./utils/normalizeHandler.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A `Route` consists of a pair of callback functions, `match` and `handler`.
|
package/src/Serwist.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import { PrecacheController, type PrecacheOptions } from "#lib/controllers/PrecacheController/PrecacheController.js";
|
|
2
|
+
import { RuntimeCacheController } from "#lib/controllers/RuntimeCacheController.js";
|
|
3
|
+
import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "#lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
4
|
+
import type { PrecacheFallbackEntry } from "#lib/precaching/PrecacheFallbackPlugin.js";
|
|
5
|
+
import type { Strategy } from "#lib/strategies/Strategy.js";
|
|
6
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
7
|
+
import { assert } from "#utils/assert.js";
|
|
8
|
+
import { clientsClaim as clientsClaimImpl } from "#utils/clientsClaim.js";
|
|
9
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
11
|
+
import { normalizeHandler } from "#utils/normalizeHandler.js";
|
|
12
|
+
import { parseRoute } from "#utils/parseRoute.js";
|
|
13
|
+
import { waitUntil } from "#utils/waitUntil.js";
|
|
1
14
|
import type { Route } from "./Route.js";
|
|
2
15
|
import { type HTTPMethod, defaultMethod } from "./constants.js";
|
|
3
16
|
import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
|
|
4
|
-
import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
5
|
-
import type { PrecacheFallbackEntry } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
6
|
-
import type { Strategy } from "./lib/strategies/Strategy.js";
|
|
7
17
|
import { enableNavigationPreload } from "./navigationPreload.js";
|
|
8
18
|
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
9
19
|
import type {
|
|
10
20
|
Controller,
|
|
21
|
+
ControllerParam,
|
|
11
22
|
PrecacheEntry,
|
|
12
23
|
RouteHandler,
|
|
13
24
|
RouteHandlerCallback,
|
|
@@ -17,16 +28,6 @@ import type {
|
|
|
17
28
|
RouteMatchCallbackOptions,
|
|
18
29
|
RuntimeCaching,
|
|
19
30
|
} from "./types.js";
|
|
20
|
-
import { SerwistError } from "./utils/SerwistError.js";
|
|
21
|
-
import { assert } from "./utils/assert.js";
|
|
22
|
-
import { clientsClaim as clientsClaimImpl } from "./utils/clientsClaim.js";
|
|
23
|
-
import { getFriendlyURL } from "./utils/getFriendlyURL.js";
|
|
24
|
-
import { logger } from "./utils/logger.js";
|
|
25
|
-
import { normalizeHandler } from "./utils/normalizeHandler.js";
|
|
26
|
-
import { parseRoute } from "./utils/parseRoute.js";
|
|
27
|
-
import { waitUntil } from "./utils/waitUntil.js";
|
|
28
|
-
import { PrecacheController, type PrecacheOptions } from "./controllers/PrecacheController/PrecacheController.js";
|
|
29
|
-
import { RuntimeCacheController } from "./controllers/RuntimeCacheController.js";
|
|
30
31
|
|
|
31
32
|
declare const self: ServiceWorkerGlobalScope;
|
|
32
33
|
|
|
@@ -179,7 +180,7 @@ export class Serwist {
|
|
|
179
180
|
|
|
180
181
|
this._precacheController = new PrecacheController(precacheEntries ?? [], precacheOptions);
|
|
181
182
|
|
|
182
|
-
// TODO(ducanhgh): remove in
|
|
183
|
+
// TODO(ducanhgh): remove in v11.
|
|
183
184
|
// Fallback for legacy users who have not migrated from `runtimeCaching` to the Controller pattern.
|
|
184
185
|
if (runtimeCaching) {
|
|
185
186
|
if (!this._controllers?.some((controller) => controller instanceof RuntimeCacheController)) {
|
|
@@ -203,7 +204,7 @@ export class Serwist {
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
for (const callback of this.iterateControllers("init")) {
|
|
206
|
-
callback(this);
|
|
207
|
+
callback({ serwist: this });
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
if (disableDevLogs) disableDevLogsImpl();
|
|
@@ -220,7 +221,10 @@ export class Serwist {
|
|
|
220
221
|
|
|
221
222
|
for (const controller of this._controllers) {
|
|
222
223
|
if (typeof controller[name] === "function") {
|
|
223
|
-
|
|
224
|
+
const callback = (param: ControllerParam[C]) => {
|
|
225
|
+
controller[name]!(param as any);
|
|
226
|
+
};
|
|
227
|
+
yield callback as NonNullable<Controller[C]>;
|
|
224
228
|
}
|
|
225
229
|
}
|
|
226
230
|
}
|
|
@@ -270,7 +274,7 @@ export class Serwist {
|
|
|
270
274
|
handleInstall(event: ExtendableEvent): Promise<void> {
|
|
271
275
|
return waitUntil(event, async () => {
|
|
272
276
|
for (const callback of this.iterateControllers("install")) {
|
|
273
|
-
await callback(event, this);
|
|
277
|
+
await callback({ event, serwist: this });
|
|
274
278
|
}
|
|
275
279
|
});
|
|
276
280
|
}
|
|
@@ -288,7 +292,7 @@ export class Serwist {
|
|
|
288
292
|
handleActivate(event: ExtendableEvent): Promise<void> {
|
|
289
293
|
return waitUntil(event, async () => {
|
|
290
294
|
for (const callback of this.iterateControllers("activate")) {
|
|
291
|
-
await callback(event, this);
|
|
295
|
+
await callback({ event, serwist: this });
|
|
292
296
|
}
|
|
293
297
|
});
|
|
294
298
|
}
|
|
@@ -672,7 +676,7 @@ export class Serwist {
|
|
|
672
676
|
/**
|
|
673
677
|
* Adds items to the precache list, removing duplicates and ensuring the information is valid.
|
|
674
678
|
*
|
|
675
|
-
* @deprecated Use `serwist.precache.
|
|
679
|
+
* @deprecated Use `serwist.precache.addToCacheList` instead.
|
|
676
680
|
* @param entries Array of entries to precache.
|
|
677
681
|
*/
|
|
678
682
|
addToPrecacheList(entries: (PrecacheEntry | string)[]): void {
|
package/src/cacheNames.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { cacheNames as privateCacheNames } from "
|
|
9
|
+
import { cacheNames as privateCacheNames } from "#utils/cacheNames.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Get the current cache names and prefix/suffix used by Serwist.
|
package/src/copyResponse.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "
|
|
10
|
-
import { canConstructResponseFromBodyStream } from "
|
|
9
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
10
|
+
import { canConstructResponseFromBodyStream } from "#utils/canConstructResponseFromBodyStream.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Allows developers to copy a response and modify its `headers`, `status`,
|
package/src/index.internal.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Deferred } from "
|
|
2
|
-
import { SerwistError } from "
|
|
3
|
-
import { assert } from "
|
|
4
|
-
import { cacheMatchIgnoreParams } from "
|
|
5
|
-
import { cacheNames as privateCacheNames } from "
|
|
6
|
-
import { canConstructReadableStream } from "
|
|
7
|
-
import { canConstructResponseFromBodyStream } from "
|
|
8
|
-
import { cleanupOutdatedCaches } from "
|
|
9
|
-
import { clientsClaim } from "
|
|
10
|
-
import { dontWaitFor } from "
|
|
11
|
-
import { executeQuotaErrorCallbacks } from "
|
|
12
|
-
import { getFriendlyURL } from "
|
|
13
|
-
import { logger } from "
|
|
14
|
-
import { resultingClientExists } from "
|
|
15
|
-
import { timeout } from "
|
|
16
|
-
import { waitUntil } from "
|
|
1
|
+
import { Deferred } from "#utils/Deferred.js";
|
|
2
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
3
|
+
import { assert } from "#utils/assert.js";
|
|
4
|
+
import { cacheMatchIgnoreParams } from "#utils/cacheMatchIgnoreParams.js";
|
|
5
|
+
import { cacheNames as privateCacheNames } from "#utils/cacheNames.js";
|
|
6
|
+
import { canConstructReadableStream } from "#utils/canConstructReadableStream.js";
|
|
7
|
+
import { canConstructResponseFromBodyStream } from "#utils/canConstructResponseFromBodyStream.js";
|
|
8
|
+
import { cleanupOutdatedCaches } from "#utils/cleanupOutdatedCaches.js";
|
|
9
|
+
import { clientsClaim } from "#utils/clientsClaim.js";
|
|
10
|
+
import { dontWaitFor } from "#utils/dontWaitFor.js";
|
|
11
|
+
import { executeQuotaErrorCallbacks } from "#utils/executeQuotaErrorCallbacks.js";
|
|
12
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
13
|
+
import { logger } from "#utils/logger.js";
|
|
14
|
+
import { resultingClientExists } from "#utils/resultingClientExists.js";
|
|
15
|
+
import { timeout } from "#utils/timeout.js";
|
|
16
|
+
import { waitUntil } from "#utils/waitUntil.js";
|
|
17
17
|
|
|
18
18
|
// Serwist's internal functions, classes, variables, and more. Feel free to use them,
|
|
19
19
|
// but they are not documented. Note: they do follow semver.
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { PrecacheStrategy } from "./controllers/PrecacheController/PrecacheStrategy.js";
|
|
2
|
-
import { PrecacheRoute } from "./controllers/PrecacheController/PrecacheRoute.js";
|
|
3
|
-
import { RuntimeCacheController } from "./controllers/RuntimeCacheController.js";
|
|
4
1
|
import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
|
|
5
2
|
import { NavigationRoute } from "./NavigationRoute.js";
|
|
6
3
|
import { RegExpRoute } from "./RegExpRoute.js";
|
|
@@ -10,119 +7,94 @@ import { cacheNames } from "./cacheNames.js";
|
|
|
10
7
|
import type { HTTPMethod } from "./constants.js";
|
|
11
8
|
import { copyResponse } from "./copyResponse.js";
|
|
12
9
|
import { disableDevLogs } from "./disableDevLogs.js";
|
|
13
|
-
import { BackgroundSyncPlugin } from "./lib/backgroundSync/BackgroundSyncPlugin.js";
|
|
14
|
-
import type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./lib/backgroundSync/BackgroundSyncQueue.js";
|
|
15
|
-
import { BackgroundSyncQueue } from "./lib/backgroundSync/BackgroundSyncQueue.js";
|
|
16
|
-
import { BackgroundSyncQueueStore } from "./lib/backgroundSync/BackgroundSyncQueueStore.js";
|
|
17
|
-
import { StorableRequest } from "./lib/backgroundSync/StorableRequest.js";
|
|
18
|
-
import { BroadcastCacheUpdate } from "./lib/broadcastUpdate/BroadcastCacheUpdate.js";
|
|
19
|
-
import { BroadcastUpdatePlugin } from "./lib/broadcastUpdate/BroadcastUpdatePlugin.js";
|
|
20
|
-
import { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./lib/broadcastUpdate/constants.js";
|
|
21
|
-
import { responsesAreSame } from "./lib/broadcastUpdate/responsesAreSame.js";
|
|
22
|
-
import type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./lib/broadcastUpdate/types.js";
|
|
23
|
-
import { CacheableResponse } from "./lib/cacheableResponse/CacheableResponse.js";
|
|
24
|
-
import type { CacheableResponseOptions } from "./lib/cacheableResponse/CacheableResponse.js";
|
|
25
|
-
import { CacheableResponsePlugin } from "./lib/cacheableResponse/CacheableResponsePlugin.js";
|
|
26
|
-
import { CacheExpiration } from "./lib/expiration/CacheExpiration.js";
|
|
27
|
-
import type { ExpirationPluginOptions } from "./lib/expiration/ExpirationPlugin.js";
|
|
28
|
-
import { ExpirationPlugin } from "./lib/expiration/ExpirationPlugin.js";
|
|
29
|
-
import { initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
30
|
-
import type { GoogleAnalyticsInitializeOptions } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
31
|
-
import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
32
|
-
import { PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
33
|
-
import { RangeRequestsPlugin } from "./lib/rangeRequests/RangeRequestsPlugin.js";
|
|
34
|
-
import { createPartialResponse } from "./lib/rangeRequests/createPartialResponse.js";
|
|
35
|
-
import { CacheFirst } from "./lib/strategies/CacheFirst.js";
|
|
36
|
-
import { CacheOnly } from "./lib/strategies/CacheOnly.js";
|
|
37
|
-
import type { NetworkFirstOptions } from "./lib/strategies/NetworkFirst.js";
|
|
38
|
-
import { NetworkFirst } from "./lib/strategies/NetworkFirst.js";
|
|
39
|
-
import type { NetworkOnlyOptions } from "./lib/strategies/NetworkOnly.js";
|
|
40
|
-
import { NetworkOnly } from "./lib/strategies/NetworkOnly.js";
|
|
41
|
-
import { StaleWhileRevalidate } from "./lib/strategies/StaleWhileRevalidate.js";
|
|
42
|
-
import type { StrategyOptions } from "./lib/strategies/Strategy.js";
|
|
43
|
-
import { Strategy } from "./lib/strategies/Strategy.js";
|
|
44
|
-
import { StrategyHandler } from "./lib/strategies/StrategyHandler.js";
|
|
45
10
|
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
|
|
46
11
|
import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
|
|
47
12
|
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
48
13
|
|
|
14
|
+
// Background synchronizing
|
|
49
15
|
export {
|
|
50
|
-
// Core
|
|
51
|
-
Serwist,
|
|
52
|
-
cacheNames,
|
|
53
|
-
copyResponse,
|
|
54
|
-
disableDevLogs,
|
|
55
|
-
disableNavigationPreload,
|
|
56
|
-
enableNavigationPreload,
|
|
57
|
-
isNavigationPreloadSupported,
|
|
58
|
-
registerQuotaErrorCallback,
|
|
59
|
-
setCacheNameDetails,
|
|
60
|
-
// Controllers
|
|
61
|
-
RuntimeCacheController,
|
|
62
|
-
// Caching strategies
|
|
63
|
-
CacheFirst,
|
|
64
|
-
CacheOnly,
|
|
65
|
-
NetworkFirst,
|
|
66
|
-
NetworkOnly,
|
|
67
|
-
PrecacheStrategy,
|
|
68
|
-
StaleWhileRevalidate,
|
|
69
|
-
Strategy,
|
|
70
|
-
StrategyHandler,
|
|
71
|
-
// Routing
|
|
72
|
-
NavigationRoute,
|
|
73
|
-
PrecacheRoute,
|
|
74
|
-
RegExpRoute,
|
|
75
|
-
Route,
|
|
76
|
-
// Background synchronizing
|
|
77
16
|
BackgroundSyncPlugin,
|
|
78
17
|
BackgroundSyncQueue,
|
|
79
18
|
BackgroundSyncQueueStore,
|
|
80
19
|
StorableRequest,
|
|
81
|
-
|
|
20
|
+
type BackgroundSyncQueueOptions,
|
|
21
|
+
type BackgroundSyncQueueEntry,
|
|
22
|
+
} from "#lib/backgroundSync/index.js";
|
|
23
|
+
|
|
24
|
+
// Broadcasting updates
|
|
25
|
+
export {
|
|
82
26
|
BroadcastCacheUpdate,
|
|
83
27
|
BroadcastUpdatePlugin,
|
|
84
28
|
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
85
29
|
responsesAreSame,
|
|
86
|
-
|
|
30
|
+
type BroadcastCacheUpdateOptions,
|
|
31
|
+
type BroadcastPayload,
|
|
32
|
+
type BroadcastPayloadGenerator,
|
|
33
|
+
type BroadcastMessage,
|
|
34
|
+
} from "#lib/broadcastUpdate/index.js";
|
|
35
|
+
|
|
36
|
+
// Setting cacheability criteria
|
|
37
|
+
export {
|
|
87
38
|
CacheableResponse,
|
|
88
39
|
CacheableResponsePlugin,
|
|
89
|
-
|
|
40
|
+
type CacheableResponseOptions,
|
|
41
|
+
} from "#lib/cacheableResponse/index.js";
|
|
42
|
+
|
|
43
|
+
// Controllers
|
|
44
|
+
export { PrecacheStrategy, PrecacheRoute, RuntimeCacheController } from "#lib/controllers/index.js";
|
|
45
|
+
|
|
46
|
+
// Expiring outdated responses
|
|
47
|
+
export {
|
|
90
48
|
CacheExpiration,
|
|
91
49
|
ExpirationPlugin,
|
|
92
|
-
|
|
50
|
+
type ExpirationPluginOptions,
|
|
51
|
+
} from "#lib/expiration/index.js";
|
|
52
|
+
|
|
53
|
+
// Google Analytics
|
|
54
|
+
export { initializeGoogleAnalytics, type GoogleAnalyticsInitializeOptions } from "#lib/googleAnalytics/index.js";
|
|
55
|
+
|
|
56
|
+
// Precaching
|
|
57
|
+
export {
|
|
93
58
|
PrecacheFallbackPlugin,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
59
|
+
type PrecacheFallbackEntry,
|
|
60
|
+
type PrecacheFallbackPluginOptions,
|
|
61
|
+
} from "#lib/precaching/index.js";
|
|
62
|
+
|
|
63
|
+
// Handling range requests
|
|
64
|
+
export {
|
|
97
65
|
createPartialResponse,
|
|
98
66
|
RangeRequestsPlugin,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
67
|
+
} from "#lib/rangeRequests/index.js";
|
|
68
|
+
|
|
69
|
+
// Built-in caching strategies
|
|
70
|
+
export {
|
|
71
|
+
CacheFirst,
|
|
72
|
+
CacheOnly,
|
|
73
|
+
NetworkFirst,
|
|
74
|
+
NetworkOnly,
|
|
75
|
+
StaleWhileRevalidate,
|
|
76
|
+
Strategy,
|
|
77
|
+
StrategyHandler,
|
|
78
|
+
type NetworkFirstOptions,
|
|
79
|
+
type NetworkOnlyOptions,
|
|
80
|
+
type StrategyOptions,
|
|
81
|
+
} from "#lib/strategies/index.js";
|
|
82
|
+
|
|
83
|
+
// Core
|
|
84
|
+
export {
|
|
85
|
+
Serwist,
|
|
86
|
+
cacheNames,
|
|
87
|
+
copyResponse,
|
|
88
|
+
disableDevLogs,
|
|
89
|
+
disableNavigationPreload,
|
|
90
|
+
enableNavigationPreload,
|
|
91
|
+
isNavigationPreloadSupported,
|
|
92
|
+
registerQuotaErrorCallback,
|
|
93
|
+
setCacheNameDetails,
|
|
108
94
|
// Routing
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
BackgroundSyncQueueEntry,
|
|
113
|
-
// Broadcasting updates
|
|
114
|
-
BroadcastCacheUpdateOptions,
|
|
115
|
-
BroadcastPayload,
|
|
116
|
-
BroadcastPayloadGenerator,
|
|
117
|
-
BroadcastMessage,
|
|
118
|
-
// Setting cacheability criteria
|
|
119
|
-
CacheableResponseOptions,
|
|
120
|
-
// Expiring outdated responses
|
|
121
|
-
ExpirationPluginOptions,
|
|
122
|
-
// Precaching
|
|
123
|
-
PrecacheFallbackEntry,
|
|
124
|
-
PrecacheFallbackPluginOptions,
|
|
125
|
-
// Google Analytics
|
|
126
|
-
GoogleAnalyticsInitializeOptions,
|
|
95
|
+
NavigationRoute,
|
|
96
|
+
RegExpRoute,
|
|
97
|
+
Route,
|
|
127
98
|
};
|
|
99
|
+
export type { HTTPMethod, SerwistOptions, NavigationRouteMatchOptions };
|
|
128
100
|
export type * from "./types.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SerwistError } from "../../utils/SerwistError.js";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2018 Google LLC
|
|
4
3
|
|
|
@@ -6,9 +5,10 @@ import { SerwistError } from "../../utils/SerwistError.js";
|
|
|
6
5
|
license that can be found in the LICENSE file or at
|
|
7
6
|
https://opensource.org/licenses/MIT.
|
|
8
7
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
11
|
+
import { logger } from "#utils/logger.js";
|
|
12
12
|
import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
|
|
13
13
|
import { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
|
|
14
14
|
import { StorableRequest } from "./StorableRequest.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
import { assert } from "
|
|
8
|
+
import { assert } from "#utils/assert.js";
|
|
9
9
|
import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
|
|
10
10
|
import { BackgroundSyncQueueDb } from "./BackgroundSyncQueueDb.js";
|
|
11
11
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
9
10
|
import type { MapLikeObject } from "../../types.js";
|
|
10
|
-
import { assert } from "../../utils/assert.js";
|
|
11
11
|
|
|
12
12
|
type SerializableProperties = "method" | "referrer" | "referrerPolicy" | "mode" | "credentials" | "cache" | "redirect" | "integrity" | "keepalive";
|
|
13
13
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BackgroundSyncPlugin } from "./BackgroundSyncPlugin.js";
|
|
2
|
+
export type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
|
|
3
|
+
export { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
|
|
4
|
+
export { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
|
|
5
|
+
export { StorableRequest } from "./StorableRequest.js";
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
11
|
+
import { resultingClientExists } from "#utils/resultingClientExists.js";
|
|
12
|
+
import { timeout } from "#utils/timeout.js";
|
|
9
13
|
import type { CacheDidUpdateCallbackParam } from "../../types.js";
|
|
10
|
-
import { assert } from "../../utils/assert.js";
|
|
11
|
-
import { logger } from "../../utils/logger.js";
|
|
12
|
-
import { resultingClientExists } from "../../utils/resultingClientExists.js";
|
|
13
|
-
import { timeout } from "../../utils/timeout.js";
|
|
14
14
|
import {
|
|
15
15
|
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
16
16
|
BROADCAST_UPDATE_DEFAULT_NOTIFY,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BroadcastCacheUpdate } from "./BroadcastCacheUpdate.js";
|
|
2
|
+
export { BroadcastUpdatePlugin } from "./BroadcastUpdatePlugin.js";
|
|
3
|
+
export { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./constants.js";
|
|
4
|
+
export { responsesAreSame } from "./responsesAreSame.js";
|
|
5
|
+
export type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./types.js";
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "
|
|
10
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Given two responses, compares several header values to see if they are
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "
|
|
10
|
-
import { assert } from "
|
|
11
|
-
import { getFriendlyURL } from "
|
|
12
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
10
|
+
import { assert } from "#utils/assert.js";
|
|
11
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
12
|
+
import { logger } from "#utils/logger.js";
|
|
13
13
|
|
|
14
14
|
export interface CacheableResponseOptions {
|
|
15
15
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
import type { StrategyPlugin, StrategyPluginCallbackParam } from "../../../types.js";
|
|
8
9
|
import type { PrecacheController } from "./PrecacheController.js";
|
|
9
|
-
import type { StrategyPlugin, StrategyPluginCallbackParam } from "../../types.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A plugin, designed to be used with PrecacheController, to translate URLs into
|