serwist 9.0.0-preview.24 → 9.0.0-preview.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/dist/NavigationRoute.d.ts +6 -7
- package/dist/NavigationRoute.d.ts.map +1 -1
- package/dist/PrecacheRoute.d.ts +2 -2
- package/dist/PrecacheRoute.d.ts.map +1 -1
- package/dist/RegExpRoute.d.ts +4 -4
- package/dist/RegExpRoute.d.ts.map +1 -1
- package/dist/Route.d.ts +10 -10
- package/dist/Route.d.ts.map +1 -1
- package/dist/Serwist.d.ts +39 -44
- package/dist/Serwist.d.ts.map +1 -1
- package/dist/chunks/printInstallDetails.js +1587 -0
- package/dist/chunks/resultingClientExists.js +1 -1
- package/dist/chunks/waitUntil.js +426 -1
- package/dist/copyResponse.d.ts +8 -10
- package/dist/copyResponse.d.ts.map +1 -1
- package/dist/disableDevLogs.d.ts +1 -1
- package/dist/index.d.ts +41 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.internal.d.ts +3 -1
- package/dist/index.internal.d.ts.map +1 -1
- package/dist/index.internal.js +1 -2
- package/dist/index.js +1464 -8
- package/dist/index.legacy.d.ts +4 -8
- package/dist/index.legacy.d.ts.map +1 -1
- package/dist/index.legacy.js +166 -16
- package/dist/legacy/PrecacheController.d.ts +1 -1
- package/dist/legacy/PrecacheController.d.ts.map +1 -1
- package/dist/legacy/PrecacheRoute.d.ts.map +1 -1
- package/dist/legacy/Router.d.ts +1 -1
- package/dist/legacy/Router.d.ts.map +1 -1
- package/dist/legacy/constants.d.ts.map +1 -0
- package/dist/legacy/fallbacks.d.ts +1 -1
- package/dist/legacy/fallbacks.d.ts.map +1 -1
- package/dist/legacy/handlePrecaching.d.ts.map +1 -1
- package/dist/legacy/initializeGoogleAnalytics.d.ts +38 -0
- package/dist/legacy/initializeGoogleAnalytics.d.ts.map +1 -0
- package/dist/legacy/installSerwist.d.ts +69 -3
- package/dist/legacy/installSerwist.d.ts.map +1 -1
- package/dist/legacy/registerRoute.d.ts +1 -1
- package/dist/legacy/registerRoute.d.ts.map +1 -1
- package/dist/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.d.ts +3 -3
- package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -0
- package/dist/{plugins/backgroundSync/Queue.d.ts → lib/backgroundSync/BackgroundSyncQueue.d.ts} +29 -13
- package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +1 -0
- package/dist/{plugins/backgroundSync/QueueDb.d.ts → lib/backgroundSync/BackgroundSyncQueueDb.d.ts} +7 -7
- package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +1 -0
- package/dist/{plugins/backgroundSync/QueueStore.d.ts → lib/backgroundSync/BackgroundSyncQueueStore.d.ts} +7 -7
- package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +1 -0
- package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -0
- package/dist/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.d.ts +1 -1
- package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/constants.d.ts +5 -0
- package/dist/lib/broadcastUpdate/constants.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -0
- package/dist/{plugins → lib}/broadcastUpdate/types.d.ts +3 -3
- package/dist/lib/broadcastUpdate/types.d.ts.map +1 -0
- package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +1 -0
- package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -0
- package/dist/{plugins → lib}/expiration/CacheExpiration.d.ts +1 -1
- package/dist/lib/expiration/CacheExpiration.d.ts.map +1 -0
- package/dist/{plugins → lib}/expiration/ExpirationPlugin.d.ts +1 -1
- package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -0
- package/dist/lib/expiration/models/CacheTimestampsModel.d.ts.map +1 -0
- package/dist/lib/googleAnalytics/constants.d.ts +10 -0
- package/dist/lib/googleAnalytics/constants.d.ts.map +1 -0
- package/dist/{plugins/googleAnalytics/initialize.d.ts → lib/googleAnalytics/initializeGoogleAnalytics.d.ts} +2 -2
- package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -0
- package/dist/{plugins → lib}/precaching/PrecacheFallbackPlugin.d.ts +1 -1
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -0
- package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -0
- package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -0
- package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
- package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/CacheFirst.d.ts +1 -1
- package/dist/lib/strategies/CacheFirst.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/CacheOnly.d.ts +2 -2
- package/dist/lib/strategies/CacheOnly.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/NetworkFirst.d.ts +2 -2
- package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/NetworkOnly.d.ts +2 -2
- package/dist/lib/strategies/NetworkOnly.d.ts.map +1 -0
- package/dist/{PrecacheStrategy.d.ts → lib/strategies/PrecacheStrategy.d.ts} +5 -5
- package/dist/lib/strategies/PrecacheStrategy.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/StaleWhileRevalidate.d.ts +1 -1
- package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/Strategy.d.ts +15 -17
- package/dist/lib/strategies/Strategy.d.ts.map +1 -0
- package/dist/{strategies → lib/strategies}/StrategyHandler.d.ts +35 -41
- package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -0
- package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +3 -0
- package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -0
- package/dist/lib/strategies/utils/messages.d.ts.map +1 -0
- package/dist/navigationPreload.d.ts +3 -3
- package/dist/types.d.ts +12 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts +1 -1
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -1
- package/dist/utils/assert.d.ts.map +1 -1
- package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -0
- package/dist/utils/clientsClaim.d.ts.map +1 -0
- package/dist/{parseRoute.d.ts → utils/parseRoute.d.ts} +3 -3
- package/dist/utils/parseRoute.d.ts.map +1 -0
- package/package.json +7 -21
- package/src/NavigationRoute.ts +6 -7
- package/src/PrecacheRoute.ts +5 -5
- package/src/RegExpRoute.ts +5 -5
- package/src/Route.ts +11 -11
- package/src/Serwist.ts +73 -80
- package/src/copyResponse.ts +7 -9
- package/src/disableDevLogs.ts +1 -1
- package/src/index.internal.ts +4 -0
- package/src/index.legacy.ts +14 -18
- package/src/index.ts +105 -19
- package/src/legacy/PrecacheController.ts +8 -8
- package/src/legacy/PrecacheFallbackPlugin.ts +1 -1
- package/src/legacy/PrecacheRoute.ts +3 -3
- package/src/legacy/Router.ts +5 -5
- package/src/legacy/fallbacks.ts +3 -3
- package/src/legacy/handlePrecaching.ts +1 -1
- package/src/legacy/initializeGoogleAnalytics.ts +218 -0
- package/src/legacy/installSerwist.ts +156 -5
- package/src/legacy/registerRoute.ts +1 -1
- package/src/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.ts +6 -6
- package/src/{plugins/backgroundSync/Queue.ts → lib/backgroundSync/BackgroundSyncQueue.ts} +47 -26
- package/src/{plugins/backgroundSync/QueueDb.ts → lib/backgroundSync/BackgroundSyncQueueDb.ts} +16 -16
- package/src/{plugins/backgroundSync/QueueStore.ts → lib/backgroundSync/BackgroundSyncQueueStore.ts} +13 -13
- package/src/{plugins → lib}/backgroundSync/StorableRequest.ts +2 -2
- package/src/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.ts +14 -9
- package/src/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.ts +1 -1
- package/src/lib/broadcastUpdate/constants.ts +12 -0
- package/src/{plugins → lib}/broadcastUpdate/types.ts +3 -3
- package/src/{plugins → lib}/cacheableResponse/CacheableResponse.ts +5 -5
- package/src/{plugins → lib}/expiration/CacheExpiration.ts +7 -7
- package/src/{plugins → lib}/expiration/ExpirationPlugin.ts +10 -10
- package/src/lib/googleAnalytics/constants.ts +22 -0
- package/src/{plugins/googleAnalytics/initialize.ts → lib/googleAnalytics/initializeGoogleAnalytics.ts} +9 -9
- package/src/{strategies → lib/strategies}/CacheFirst.ts +5 -5
- package/src/{strategies → lib/strategies}/CacheOnly.ts +6 -6
- package/src/{strategies → lib/strategies}/NetworkFirst.ts +7 -7
- package/src/{strategies → lib/strategies}/NetworkOnly.ts +7 -7
- package/src/{PrecacheStrategy.ts → lib/strategies/PrecacheStrategy.ts} +14 -10
- package/src/{strategies → lib/strategies}/StaleWhileRevalidate.ts +5 -5
- package/src/{strategies → lib/strategies}/Strategy.ts +19 -21
- package/src/{strategies → lib/strategies}/StrategyHandler.ts +45 -51
- package/src/{strategies → lib/strategies}/plugins/cacheOkAndOpaquePlugin.ts +1 -1
- package/src/{strategies → lib/strategies}/utils/messages.ts +2 -2
- package/src/models/messages/messages.ts +1 -1
- package/src/navigationPreload.ts +3 -3
- package/src/registerQuotaErrorCallback.ts +1 -1
- package/src/types.ts +12 -7
- package/src/utils/PrecacheCacheKeyPlugin.ts +1 -1
- package/src/utils/assert.ts +1 -1
- package/src/{cleanupOutdatedCaches.ts → utils/cleanupOutdatedCaches.ts} +3 -4
- package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
- package/src/{parseRoute.ts → utils/parseRoute.ts} +21 -23
- package/src/utils/welcome.ts +1 -1
- package/dist/PrecacheStrategy.d.ts.map +0 -1
- package/dist/chunks/NetworkOnly.js +0 -599
- package/dist/chunks/PrecacheFallbackPlugin.js +0 -634
- package/dist/chunks/Serwist.js +0 -1034
- package/dist/chunks/registerQuotaErrorCallback.js +0 -17
- package/dist/chunks/timeout.js +0 -400
- package/dist/cleanupOutdatedCaches.d.ts.map +0 -1
- package/dist/clientsClaim.d.ts.map +0 -1
- package/dist/index.plugins.d.ts +0 -41
- package/dist/index.plugins.d.ts.map +0 -1
- package/dist/index.plugins.js +0 -669
- package/dist/index.strategies.d.ts +0 -22
- package/dist/index.strategies.d.ts.map +0 -1
- package/dist/index.strategies.js +0 -144
- package/dist/parseRoute.d.ts.map +0 -1
- package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
- package/dist/plugins/backgroundSync/Queue.d.ts.map +0 -1
- package/dist/plugins/backgroundSync/QueueDb.d.ts.map +0 -1
- package/dist/plugins/backgroundSync/QueueStore.d.ts.map +0 -1
- package/dist/plugins/backgroundSync/StorableRequest.d.ts.map +0 -1
- package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
- package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
- package/dist/plugins/broadcastUpdate/constants.d.ts +0 -5
- package/dist/plugins/broadcastUpdate/constants.d.ts.map +0 -1
- package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
- package/dist/plugins/broadcastUpdate/types.d.ts.map +0 -1
- package/dist/plugins/cacheableResponse/CacheableResponse.d.ts.map +0 -1
- package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
- package/dist/plugins/expiration/CacheExpiration.d.ts.map +0 -1
- package/dist/plugins/expiration/ExpirationPlugin.d.ts.map +0 -1
- package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts.map +0 -1
- package/dist/plugins/googleAnalytics/constants.d.ts.map +0 -1
- package/dist/plugins/googleAnalytics/initialize.d.ts.map +0 -1
- package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
- package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
- package/dist/plugins/rangeRequests/createPartialResponse.d.ts.map +0 -1
- package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
- package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
- package/dist/strategies/CacheFirst.d.ts.map +0 -1
- package/dist/strategies/CacheOnly.d.ts.map +0 -1
- package/dist/strategies/NetworkFirst.d.ts.map +0 -1
- package/dist/strategies/NetworkOnly.d.ts.map +0 -1
- package/dist/strategies/StaleWhileRevalidate.d.ts.map +0 -1
- package/dist/strategies/Strategy.d.ts.map +0 -1
- package/dist/strategies/StrategyHandler.d.ts.map +0 -1
- package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +0 -3
- package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +0 -1
- package/dist/strategies/utils/messages.d.ts.map +0 -1
- package/src/index.plugins.ts +0 -95
- package/src/index.strategies.ts +0 -26
- package/src/plugins/broadcastUpdate/constants.ts +0 -12
- package/dist/{plugins/googleAnalytics → legacy}/constants.d.ts +0 -0
- package/dist/{plugins → lib}/backgroundSync/StorableRequest.d.ts +0 -0
- package/dist/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.d.ts +0 -0
- package/dist/{plugins → lib}/broadcastUpdate/responsesAreSame.d.ts +0 -0
- package/dist/{plugins → lib}/cacheableResponse/CacheableResponse.d.ts +0 -0
- package/dist/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.d.ts +0 -0
- package/dist/{plugins → lib}/expiration/models/CacheTimestampsModel.d.ts +0 -0
- package/dist/{plugins → lib}/rangeRequests/RangeRequestsPlugin.d.ts +0 -0
- package/dist/{plugins → lib}/rangeRequests/createPartialResponse.d.ts +0 -0
- package/dist/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +0 -0
- package/dist/{plugins → lib}/rangeRequests/utils/parseRangeHeader.d.ts +0 -0
- package/dist/{strategies → lib/strategies}/utils/messages.d.ts +0 -0
- package/dist/{cleanupOutdatedCaches.d.ts → utils/cleanupOutdatedCaches.d.ts} +0 -0
- package/dist/{clientsClaim.d.ts → utils/clientsClaim.d.ts} +0 -0
- package/src/{plugins/googleAnalytics → legacy}/constants.ts +0 -0
- package/src/{plugins → lib}/broadcastUpdate/responsesAreSame.ts +0 -0
- package/src/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.ts +0 -0
- package/src/{plugins → lib}/expiration/models/CacheTimestampsModel.ts +0 -0
- package/src/{plugins → lib}/precaching/PrecacheFallbackPlugin.ts +1 -1
- package/src/{plugins → lib}/rangeRequests/RangeRequestsPlugin.ts +0 -0
- package/src/{plugins → lib}/rangeRequests/createPartialResponse.ts +1 -1
- package/src/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.ts +1 -1
- package/src/{plugins → lib}/rangeRequests/utils/parseRangeHeader.ts +1 -1
- /package/src/{clientsClaim.ts → utils/clientsClaim.ts} +0 -0
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
10
|
+
import { assert } from "../../utils/assert.js";
|
|
11
|
+
import { logger } from "../../utils/logger.js";
|
|
12
12
|
import type { StrategyOptions } from "./Strategy.js";
|
|
13
13
|
import { Strategy } from "./Strategy.js";
|
|
14
14
|
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
@@ -23,11 +23,11 @@ export interface NetworkFirstOptions extends StrategyOptions {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#
|
|
26
|
+
* An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network_first_falling_back_to_cache)
|
|
27
27
|
* request strategy.
|
|
28
28
|
*
|
|
29
29
|
* By default, this strategy will cache responses with a 200 status code as
|
|
30
|
-
* well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#
|
|
30
|
+
* well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque_responses).
|
|
31
31
|
* Opaque responses are are cross-origin requests where the response doesn't
|
|
32
32
|
* support [CORS](https://enable-cors.org/).
|
|
33
33
|
*
|
|
@@ -55,7 +55,7 @@ export class NetworkFirst extends Strategy {
|
|
|
55
55
|
if (process.env.NODE_ENV !== "production") {
|
|
56
56
|
if (this._networkTimeoutSeconds) {
|
|
57
57
|
assert!.isType(this._networkTimeoutSeconds, "number", {
|
|
58
|
-
moduleName: "serwist
|
|
58
|
+
moduleName: "serwist",
|
|
59
59
|
className: this.constructor.name,
|
|
60
60
|
funcName: "constructor",
|
|
61
61
|
paramName: "networkTimeoutSeconds",
|
|
@@ -75,7 +75,7 @@ export class NetworkFirst extends Strategy {
|
|
|
75
75
|
|
|
76
76
|
if (process.env.NODE_ENV !== "production") {
|
|
77
77
|
assert!.isInstance(request, Request, {
|
|
78
|
-
moduleName: "serwist
|
|
78
|
+
moduleName: "serwist",
|
|
79
79
|
className: this.constructor.name,
|
|
80
80
|
funcName: "handle",
|
|
81
81
|
paramName: "makeRequest",
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { logger } from "
|
|
12
|
-
import { timeout } from "
|
|
9
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
10
|
+
import { assert } from "../../utils/assert.js";
|
|
11
|
+
import { logger } from "../../utils/logger.js";
|
|
12
|
+
import { timeout } from "../../utils/timeout.js";
|
|
13
13
|
import type { StrategyOptions } from "./Strategy.js";
|
|
14
14
|
import { Strategy } from "./Strategy.js";
|
|
15
15
|
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
@@ -23,10 +23,10 @@ export interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" |
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#
|
|
26
|
+
* An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network_only)
|
|
27
27
|
* request strategy.
|
|
28
28
|
*
|
|
29
|
-
* This class is useful if you
|
|
29
|
+
* This class is useful if you require specific requests to only be fulfilled from the network.
|
|
30
30
|
*
|
|
31
31
|
* If the network request fails, this will throw a `SerwistError` exception.
|
|
32
32
|
*/
|
|
@@ -51,7 +51,7 @@ export class NetworkOnly extends Strategy {
|
|
|
51
51
|
async _handle(request: Request, handler: StrategyHandler): Promise<Response> {
|
|
52
52
|
if (process.env.NODE_ENV !== "production") {
|
|
53
53
|
assert!.isInstance(request, Request, {
|
|
54
|
-
moduleName: "serwist
|
|
54
|
+
moduleName: "serwist",
|
|
55
55
|
className: this.constructor.name,
|
|
56
56
|
funcName: "_handle",
|
|
57
57
|
paramName: "request",
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { SerwistError } from "
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import type { StrategyOptions } from "./
|
|
16
|
-
import { Strategy } from "./
|
|
17
|
-
import type { StrategyHandler } from "./
|
|
9
|
+
import { copyResponse } from "../../copyResponse.js";
|
|
10
|
+
import type { SerwistPlugin } from "../../types.js";
|
|
11
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
12
|
+
import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
|
|
13
|
+
import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
|
|
14
|
+
import { logger } from "../../utils/logger.js";
|
|
15
|
+
import type { StrategyOptions } from "./Strategy.js";
|
|
16
|
+
import { Strategy } from "./Strategy.js";
|
|
17
|
+
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
18
18
|
|
|
19
19
|
interface PrecacheStrategyOptions extends StrategyOptions {
|
|
20
20
|
/**
|
|
@@ -29,7 +29,7 @@ interface PrecacheStrategyOptions extends StrategyOptions {
|
|
|
29
29
|
* specifically designed to both cache and fetch precached assets.
|
|
30
30
|
*
|
|
31
31
|
* Note: an instance of this class is created automatically when creating a
|
|
32
|
-
* `
|
|
32
|
+
* `Serwist` instance; it's generally not necessary to create this yourself.
|
|
33
33
|
*/
|
|
34
34
|
export class PrecacheStrategy extends Strategy {
|
|
35
35
|
private readonly _fallbackToNetwork: boolean;
|
|
@@ -55,6 +55,7 @@ export class PrecacheStrategy extends Strategy {
|
|
|
55
55
|
*/
|
|
56
56
|
constructor(options: PrecacheStrategyOptions = {}) {
|
|
57
57
|
options.cacheName = privateCacheNames.getPrecacheName(options.cacheName);
|
|
58
|
+
|
|
58
59
|
super(options);
|
|
59
60
|
|
|
60
61
|
this._fallbackToNetwork = options.fallbackToNetwork === false ? false : true;
|
|
@@ -74,6 +75,7 @@ export class PrecacheStrategy extends Strategy {
|
|
|
74
75
|
*/
|
|
75
76
|
async _handle(request: Request, handler: StrategyHandler): Promise<Response> {
|
|
76
77
|
const response = await handler.cacheMatch(request);
|
|
78
|
+
|
|
77
79
|
if (response) {
|
|
78
80
|
return response;
|
|
79
81
|
}
|
|
@@ -91,6 +93,7 @@ export class PrecacheStrategy extends Strategy {
|
|
|
91
93
|
|
|
92
94
|
async _handleFetch(request: Request, handler: StrategyHandler): Promise<Response> {
|
|
93
95
|
let response: Response | undefined = undefined;
|
|
96
|
+
|
|
94
97
|
const params = (handler.params || {}) as {
|
|
95
98
|
cacheKey?: string;
|
|
96
99
|
integrity?: string;
|
|
@@ -169,6 +172,7 @@ export class PrecacheStrategy extends Strategy {
|
|
|
169
172
|
// Make sure we defer cachePut() until after we know the response
|
|
170
173
|
// should be cached; see https://github.com/GoogleChrome/workbox/issues/2737
|
|
171
174
|
const wasCached = await handler.cachePut(request, response.clone());
|
|
175
|
+
|
|
172
176
|
if (!wasCached) {
|
|
173
177
|
// Throwing here will lead to the `install` handler failing, which
|
|
174
178
|
// we want to do if *any* of the responses aren't safe to cache.
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
10
|
+
import { assert } from "../../utils/assert.js";
|
|
11
|
+
import { logger } from "../../utils/logger.js";
|
|
12
12
|
import type { StrategyOptions } from "./Strategy.js";
|
|
13
13
|
import { Strategy } from "./Strategy.js";
|
|
14
14
|
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
@@ -17,7 +17,7 @@ import { messages } from "./utils/messages.js";
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* An implementation of the
|
|
20
|
-
* [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#
|
|
20
|
+
* [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale_while_revalidate)
|
|
21
21
|
* request strategy.
|
|
22
22
|
*
|
|
23
23
|
* Resources are requested from both the cache and the network in parallel.
|
|
@@ -58,7 +58,7 @@ export class StaleWhileRevalidate extends Strategy {
|
|
|
58
58
|
|
|
59
59
|
if (process.env.NODE_ENV !== "production") {
|
|
60
60
|
assert!.isInstance(request, Request, {
|
|
61
|
-
moduleName: "serwist
|
|
61
|
+
moduleName: "serwist",
|
|
62
62
|
className: this.constructor.name,
|
|
63
63
|
funcName: "handle",
|
|
64
64
|
paramName: "request",
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { HandlerCallbackOptions, RouteHandlerObject, SerwistPlugin } from "
|
|
10
|
-
import { SerwistError } from "
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
9
|
+
import type { HandlerCallbackOptions, RouteHandlerObject, SerwistPlugin } from "../../types.js";
|
|
10
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
11
|
+
import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
|
|
12
|
+
import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
|
|
13
|
+
import { logger } from "../../utils/logger.js";
|
|
14
14
|
import { StrategyHandler } from "./StrategyHandler.js";
|
|
15
15
|
|
|
16
16
|
export interface StrategyOptions {
|
|
@@ -19,27 +19,26 @@ export interface StrategyOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
cacheName?: string;
|
|
21
21
|
/**
|
|
22
|
-
* [Plugins](https://
|
|
23
|
-
* to use in conjunction with this caching strategy.
|
|
22
|
+
* [Plugins](https://serwist.pages.dev/docs/serwist/runtime-caching/plugins) to use in conjunction with this caching strategy.
|
|
24
23
|
*/
|
|
25
24
|
plugins?: SerwistPlugin[];
|
|
26
25
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Options passed to [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796) `fetch()` calls made by
|
|
27
|
+
* this strategy.
|
|
29
28
|
*/
|
|
30
29
|
fetchOptions?: RequestInit;
|
|
31
30
|
/**
|
|
32
31
|
* The [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
|
33
|
-
*
|
|
32
|
+
* passed to any `cache.match()` or `cache.put()` call made by this strategy.
|
|
34
33
|
*/
|
|
35
34
|
matchOptions?: CacheQueryOptions;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* fetch options and plugins are used (per the current strategy instance).
|
|
38
|
+
* Abstract class for implementing runtime caching strategies.
|
|
39
|
+
*
|
|
40
|
+
* Custom strategies should extend this class and leverage `StrategyHandler`, which will ensure all relevant cache options,
|
|
41
|
+
* fetch options, and plugins are used (per the current strategy instance), to perform all fetching and caching logic.
|
|
43
42
|
*/
|
|
44
43
|
export abstract class Strategy implements RouteHandlerObject {
|
|
45
44
|
cacheName: string;
|
|
@@ -67,7 +66,7 @@ export abstract class Strategy implements RouteHandlerObject {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
|
-
*
|
|
69
|
+
* Performs a request strategy and returns a `Promise` that will resolve with
|
|
71
70
|
* a `Response`, invoking all relevant plugin callbacks.
|
|
72
71
|
*
|
|
73
72
|
* When a strategy instance is registered with a `Route`, this method is automatically
|
|
@@ -88,12 +87,11 @@ export abstract class Strategy implements RouteHandlerObject {
|
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
/**
|
|
91
|
-
* Similar to `
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* `event.waitUntil()` as part of performing the strategy have completed.
|
|
90
|
+
* Similar to `handle()`, but instead of just returning a `Promise` that
|
|
91
|
+
* resolves to a `Response`, it will return an tuple of `[response, done]` promises,
|
|
92
|
+
* where `response` is equivalent to what `handle()` returns, and `done` is a
|
|
93
|
+
* `Promise` that will resolve once all promises added to `event.waitUntil()` as a part
|
|
94
|
+
* of performing the strategy have completed.
|
|
97
95
|
*
|
|
98
96
|
* You can await the `done` promise to ensure any extra work performed by
|
|
99
97
|
* the strategy (usually caching responses) completes successfully.
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { HandlerCallbackOptions, MapLikeObject, SerwistPlugin, SerwistPluginCallbackParam } from "
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { cacheMatchIgnoreParams } from "
|
|
14
|
-
import { executeQuotaErrorCallbacks } from "
|
|
15
|
-
import { getFriendlyURL } from "
|
|
16
|
-
import { logger } from "
|
|
17
|
-
import { timeout } from "
|
|
9
|
+
import type { HandlerCallbackOptions, MapLikeObject, SerwistPlugin, SerwistPluginCallbackParam } from "../../types.js";
|
|
10
|
+
import { Deferred } from "../../utils/Deferred.js";
|
|
11
|
+
import { SerwistError } from "../../utils/SerwistError.js";
|
|
12
|
+
import { assert } from "../../utils/assert.js";
|
|
13
|
+
import { cacheMatchIgnoreParams } from "../../utils/cacheMatchIgnoreParams.js";
|
|
14
|
+
import { executeQuotaErrorCallbacks } from "../../utils/executeQuotaErrorCallbacks.js";
|
|
15
|
+
import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
|
|
16
|
+
import { logger } from "../../utils/logger.js";
|
|
17
|
+
import { timeout } from "../../utils/timeout.js";
|
|
18
18
|
import type { Strategy } from "./Strategy.js";
|
|
19
19
|
|
|
20
20
|
function toRequest(input: RequestInfo) {
|
|
@@ -22,9 +22,9 @@ function toRequest(input: RequestInfo) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* A class created every time a Strategy instance
|
|
25
|
+
* A class created every time a `Strategy` instance calls `Strategy.handle` or
|
|
26
26
|
* `Strategy.handleAll` that wraps all fetch and cache actions around plugin callbacks
|
|
27
|
-
* and keeps track of when the strategy is "done" (i.e. all added `event.waitUntil()` promises
|
|
27
|
+
* and keeps track of when the strategy is "done" (i.e. when all added `event.waitUntil()` promises
|
|
28
28
|
* have resolved).
|
|
29
29
|
*/
|
|
30
30
|
export class StrategyHandler {
|
|
@@ -33,23 +33,23 @@ export class StrategyHandler {
|
|
|
33
33
|
*/
|
|
34
34
|
public event: ExtendableEvent;
|
|
35
35
|
/**
|
|
36
|
-
* The request the strategy is
|
|
36
|
+
* The request the strategy is processing (passed to the strategy's
|
|
37
37
|
* `handle()` or `handleAll()` method).
|
|
38
38
|
*/
|
|
39
39
|
public request: Request;
|
|
40
40
|
/**
|
|
41
41
|
* A `URL` instance of `request.url` (if passed to the strategy's
|
|
42
42
|
* `handle()` or `handleAll()` method).
|
|
43
|
-
* Note: the `url` param will be present if the strategy
|
|
43
|
+
* Note: the `url` param will be present if the strategy is invoked
|
|
44
44
|
* from a `Route` object.
|
|
45
45
|
*/
|
|
46
46
|
public url?: URL;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Some additional params (if passed to the strategy's
|
|
49
49
|
* `handle()` or `handleAll()` method).
|
|
50
|
-
* Note: the `
|
|
51
|
-
* from a `Route` object and
|
|
52
|
-
*
|
|
50
|
+
* Note: the `params` param will be present if the strategy is invoked
|
|
51
|
+
* from a `Route` object and that route's matcher returned a truthy value
|
|
52
|
+
* (it will be that value).
|
|
53
53
|
*/
|
|
54
54
|
public params?: string[] | MapLikeObject;
|
|
55
55
|
|
|
@@ -78,13 +78,13 @@ export class StrategyHandler {
|
|
|
78
78
|
) {
|
|
79
79
|
if (process.env.NODE_ENV !== "production") {
|
|
80
80
|
assert!.isInstance(options.event, ExtendableEvent, {
|
|
81
|
-
moduleName: "serwist
|
|
81
|
+
moduleName: "serwist",
|
|
82
82
|
className: "StrategyHandler",
|
|
83
83
|
funcName: "constructor",
|
|
84
84
|
paramName: "options.event",
|
|
85
85
|
});
|
|
86
86
|
assert!.isInstance(options.request, Request, {
|
|
87
|
-
moduleName: "serwist
|
|
87
|
+
moduleName: "serwist",
|
|
88
88
|
className: "StrategyHandler",
|
|
89
89
|
funcName: "constructor",
|
|
90
90
|
paramName: "options.request",
|
|
@@ -114,8 +114,8 @@ export class StrategyHandler {
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Fetches a given request (and invokes any applicable plugin callback
|
|
117
|
-
* methods)
|
|
118
|
-
* `plugins`
|
|
117
|
+
* methods), taking the `fetchOptions` (for non-navigation requests) and
|
|
118
|
+
* `plugins` provided to the `Strategy` object into account.
|
|
119
119
|
*
|
|
120
120
|
* The following plugin lifecycle methods are invoked when using this method:
|
|
121
121
|
* - `requestWillFetch()`
|
|
@@ -199,11 +199,10 @@ export class StrategyHandler {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
|
-
* Calls `this.fetch()` and (in the background)
|
|
203
|
-
* the response generated by `this.fetch()`.
|
|
202
|
+
* Calls `this.fetch()` and (in the background) caches the generated response.
|
|
204
203
|
*
|
|
205
204
|
* The call to `this.cachePut()` automatically invokes `this.waitUntil()`,
|
|
206
|
-
* so you do not have to
|
|
205
|
+
* so you do not have to call `waitUntil()` yourself.
|
|
207
206
|
*
|
|
208
207
|
* @param input The request or URL to fetch and cache.
|
|
209
208
|
* @returns
|
|
@@ -219,14 +218,14 @@ export class StrategyHandler {
|
|
|
219
218
|
|
|
220
219
|
/**
|
|
221
220
|
* Matches a request from the cache (and invokes any applicable plugin
|
|
222
|
-
* callback
|
|
223
|
-
*
|
|
221
|
+
* callback method) using the `cacheName`, `matchOptions`, and `plugins`
|
|
222
|
+
* provided to the `Strategy` object.
|
|
224
223
|
*
|
|
225
|
-
* The following
|
|
226
|
-
* - cacheKeyWillByUsed
|
|
227
|
-
* - cachedResponseWillByUsed
|
|
224
|
+
* The following lifecycle methods are invoked when using this method:
|
|
225
|
+
* - `cacheKeyWillByUsed`
|
|
226
|
+
* - `cachedResponseWillByUsed`
|
|
228
227
|
*
|
|
229
|
-
* @param key The Request or URL to use as the cache key.
|
|
228
|
+
* @param key The `Request` or `URL` object to use as the cache key.
|
|
230
229
|
* @returns A matching response, if found.
|
|
231
230
|
*/
|
|
232
231
|
async cacheMatch(key: RequestInfo): Promise<Response | undefined> {
|
|
@@ -261,14 +260,14 @@ export class StrategyHandler {
|
|
|
261
260
|
}
|
|
262
261
|
|
|
263
262
|
/**
|
|
264
|
-
* Puts a request/response pair
|
|
265
|
-
* plugin callback
|
|
266
|
-
* the
|
|
263
|
+
* Puts a request/response pair into the cache (and invokes any applicable
|
|
264
|
+
* plugin callback method) using the `cacheName` and `plugins` provided to
|
|
265
|
+
* the `Strategy` object.
|
|
267
266
|
*
|
|
268
267
|
* The following plugin lifecycle methods are invoked when using this method:
|
|
269
|
-
* - cacheKeyWillByUsed
|
|
270
|
-
* - cacheWillUpdate
|
|
271
|
-
* - cacheDidUpdate
|
|
268
|
+
* - `cacheKeyWillByUsed`
|
|
269
|
+
* - `cacheWillUpdate`
|
|
270
|
+
* - `cacheDidUpdate`
|
|
272
271
|
*
|
|
273
272
|
* @param key The request or URL to use as the cache key.
|
|
274
273
|
* @param response The response to cache.
|
|
@@ -370,11 +369,11 @@ export class StrategyHandler {
|
|
|
370
369
|
}
|
|
371
370
|
|
|
372
371
|
/**
|
|
373
|
-
* Checks the
|
|
374
|
-
*
|
|
372
|
+
* Checks the `plugins` provided to the `Strategy` object for `cacheKeyWillBeUsed`
|
|
373
|
+
* callbacks and executes found callbacks in sequence. The final `Request`
|
|
375
374
|
* object returned by the last plugin is treated as the cache key for cache
|
|
376
375
|
* reads and/or writes. If no `cacheKeyWillBeUsed` plugin callbacks have
|
|
377
|
-
* been registered, the passed request is returned unmodified
|
|
376
|
+
* been registered, the passed request is returned unmodified.
|
|
378
377
|
*
|
|
379
378
|
* @param request
|
|
380
379
|
* @param mode
|
|
@@ -402,7 +401,7 @@ export class StrategyHandler {
|
|
|
402
401
|
}
|
|
403
402
|
|
|
404
403
|
/**
|
|
405
|
-
* Returns true if the strategy has at least one plugin with the given
|
|
404
|
+
* Returns `true` if the strategy has at least one plugin with the given
|
|
406
405
|
* callback.
|
|
407
406
|
*
|
|
408
407
|
* @param name The name of the callback to check for.
|
|
@@ -419,8 +418,7 @@ export class StrategyHandler {
|
|
|
419
418
|
|
|
420
419
|
/**
|
|
421
420
|
* Runs all plugin callbacks matching the given name, in order, passing the
|
|
422
|
-
* given param object
|
|
423
|
-
* argument.
|
|
421
|
+
* given param object as the only argument.
|
|
424
422
|
*
|
|
425
423
|
* Note: since this method runs all plugins, it's not suitable for cases
|
|
426
424
|
* where the return value of a callback needs to be applied prior to calling
|
|
@@ -439,10 +437,7 @@ export class StrategyHandler {
|
|
|
439
437
|
}
|
|
440
438
|
|
|
441
439
|
/**
|
|
442
|
-
* Accepts a callback and returns an iterable of matching plugin callbacks
|
|
443
|
-
* where each callback is wrapped with the current handler state (i.e. when
|
|
444
|
-
* you call each callback, whatever object parameter you pass it will
|
|
445
|
-
* be merged with the plugin's current state).
|
|
440
|
+
* Accepts a callback name and returns an iterable of matching plugin callbacks.
|
|
446
441
|
*
|
|
447
442
|
* @param name The name fo the callback to run
|
|
448
443
|
* @returns
|
|
@@ -482,12 +477,11 @@ export class StrategyHandler {
|
|
|
482
477
|
|
|
483
478
|
/**
|
|
484
479
|
* Returns a promise that resolves once all promises passed to
|
|
485
|
-
* `
|
|
480
|
+
* `this.waitUntil()` have settled.
|
|
486
481
|
*
|
|
487
482
|
* Note: any work done after `doneWaiting()` settles should be manually
|
|
488
|
-
* passed to an event's `waitUntil()` method (not this
|
|
489
|
-
*
|
|
490
|
-
* prior to your work completing.
|
|
483
|
+
* passed to an event's `waitUntil()` method (not `this.waitUntil()`), otherwise
|
|
484
|
+
* the service worker thread may be killed prior to your work completing.
|
|
491
485
|
*/
|
|
492
486
|
async doneWaiting(): Promise<void> {
|
|
493
487
|
let promise: Promise<any> | undefined = undefined;
|
|
@@ -498,7 +492,7 @@ export class StrategyHandler {
|
|
|
498
492
|
|
|
499
493
|
/**
|
|
500
494
|
* Stops running the strategy and immediately resolves any pending
|
|
501
|
-
* `waitUntil()`
|
|
495
|
+
* `waitUntil()` promise.
|
|
502
496
|
*/
|
|
503
497
|
destroy(): void {
|
|
504
498
|
this._handlerDeferred.resolve(null);
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { getFriendlyURL } from "
|
|
10
|
-
import { logger } from "
|
|
9
|
+
import { getFriendlyURL } from "../../../utils/getFriendlyURL.js";
|
|
10
|
+
import { logger } from "../../../utils/logger.js";
|
|
11
11
|
|
|
12
12
|
export const messages = {
|
|
13
13
|
strategyStart: (strategyName: string, request: Request): string => `Using ${strategyName} to respond to '${getFriendlyURL(request.url)}'`,
|
|
@@ -112,7 +112,7 @@ export const messages = {
|
|
|
112
112
|
},
|
|
113
113
|
|
|
114
114
|
"duplicate-queue-name": ({ name }) => {
|
|
115
|
-
return `The
|
|
115
|
+
return `The queue name '${name}' is already being used. All instances of 'serwist.BackgroundSyncQueue' must be given unique names.`;
|
|
116
116
|
},
|
|
117
117
|
|
|
118
118
|
"expired-test-without-max-age": ({ methodName, paramName }) => {
|
package/src/navigationPreload.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const self: ServiceWorkerGlobalScope;
|
|
|
7
7
|
* navigation preloading.
|
|
8
8
|
*
|
|
9
9
|
* @returns
|
|
10
|
-
* @see https://serwist.pages.dev/docs/
|
|
10
|
+
* @see https://serwist.pages.dev/docs/serwist/core/is-navigation-preload-supported
|
|
11
11
|
*/
|
|
12
12
|
export const isNavigationPreloadSupported = (): boolean => {
|
|
13
13
|
return Boolean(self.registration?.navigationPreload);
|
|
@@ -19,7 +19,7 @@ export const isNavigationPreloadSupported = (): boolean => {
|
|
|
19
19
|
* @param headerValue Optional. Allows developers to override the value of
|
|
20
20
|
* the `Service-Worker-Navigation-Preload` header which will be sent to the
|
|
21
21
|
* server when making the navigation request.
|
|
22
|
-
* @see https://serwist.pages.dev/docs/
|
|
22
|
+
* @see https://serwist.pages.dev/docs/serwist/core/enable-navigation-preload
|
|
23
23
|
*/
|
|
24
24
|
export const enableNavigationPreload = (headerValue?: string): void => {
|
|
25
25
|
if (isNavigationPreloadSupported()) {
|
|
@@ -47,7 +47,7 @@ export const enableNavigationPreload = (headerValue?: string): void => {
|
|
|
47
47
|
/**
|
|
48
48
|
* If the browser supports navigation preloading, then this will disable it.
|
|
49
49
|
*
|
|
50
|
-
* @see https://serwist.pages.dev/docs/
|
|
50
|
+
* @see https://serwist.pages.dev/docs/serwist/core/disable-navigation-preload
|
|
51
51
|
*/
|
|
52
52
|
export const disableNavigationPreload = (): void => {
|
|
53
53
|
if (isNavigationPreloadSupported()) {
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { quotaErrorCallbacks } from "./models/quotaErrorCallbacks.js";
|
|
9
10
|
import { assert } from "./utils/assert.js";
|
|
10
11
|
import { logger } from "./utils/logger.js";
|
|
11
|
-
import { quotaErrorCallbacks } from "./models/quotaErrorCallbacks.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Adds a function to the set of quotaErrorCallbacks that will be executed if
|
package/src/types.ts
CHANGED
|
@@ -335,22 +335,27 @@ export declare interface PrecacheEntry {
|
|
|
335
335
|
|
|
336
336
|
export interface PrecacheRouteOptions {
|
|
337
337
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
338
|
+
* Tells Serwist to check the precache for an entry whose URL is the request URL appended
|
|
339
|
+
* with the specified value. Only applies if the request URL ends with "/".
|
|
340
|
+
*
|
|
341
|
+
* @default "index.html"
|
|
340
342
|
*/
|
|
341
343
|
directoryIndex?: string | null;
|
|
342
344
|
/**
|
|
343
|
-
* An array of RegExp
|
|
345
|
+
* An array of `RegExp` objects matching search params that should be removed when looking
|
|
346
|
+
* for a precache match.
|
|
344
347
|
*/
|
|
345
348
|
ignoreURLParametersMatching?: RegExp[];
|
|
346
349
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
350
|
+
* Tells Serwist to check the precache for an entry whose URL is the request URL appended
|
|
351
|
+
* with ".html".
|
|
352
|
+
*
|
|
353
|
+
* @default true
|
|
349
354
|
*/
|
|
350
355
|
cleanURLs?: boolean;
|
|
351
356
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
357
|
+
* A function that should take a URL and return an array of alternative URLs that should
|
|
358
|
+
* be checked for precache matches.
|
|
354
359
|
*/
|
|
355
360
|
urlManipulation?: UrlManipulation;
|
|
356
361
|
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { SerwistPlugin, SerwistPluginCallbackParam } from "../types.js";
|
|
10
9
|
import type { Serwist } from "../Serwist.js";
|
|
10
|
+
import type { SerwistPlugin, SerwistPluginCallbackParam } from "../types.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* A plugin, designed to be used with PrecacheController, to translate URLs into
|
package/src/utils/assert.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "./SerwistError.js";
|
|
10
9
|
import type { MapLikeObject } from "../types.js";
|
|
10
|
+
import { SerwistError } from "./SerwistError.js";
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* This method throws if the supplied value is not an array.
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { deleteOutdatedCaches } from "./utils/deleteOutdatedCaches.js";
|
|
9
|
+
import { cacheNames as privateCacheNames } from "./cacheNames.js";
|
|
10
|
+
import { deleteOutdatedCaches } from "./deleteOutdatedCaches.js";
|
|
11
|
+
import { logger } from "./logger.js";
|
|
13
12
|
|
|
14
13
|
declare const self: ServiceWorkerGlobalScope;
|
|
15
14
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { logger } from "./logger.js";
|
|
10
9
|
import { quotaErrorCallbacks } from "../models/quotaErrorCallbacks.js";
|
|
10
|
+
import { logger } from "./logger.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Runs all of the callback functions, one at a time sequentially, in the order
|