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
package/src/Serwist.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import { parallel } from "@serwist/utils";
|
|
2
|
+
import { NavigationRoute } from "./NavigationRoute.js";
|
|
3
|
+
import { PrecacheRoute } from "./PrecacheRoute.js";
|
|
4
|
+
import type { Route } from "./Route.js";
|
|
5
|
+
import { type HTTPMethod, defaultMethod } from "./constants.js";
|
|
6
|
+
import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
|
|
7
|
+
import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
8
|
+
import { type PrecacheFallbackEntry, PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
9
|
+
import { PrecacheStrategy } from "./lib/strategies/PrecacheStrategy.js";
|
|
10
|
+
import { Strategy } from "./lib/strategies/Strategy.js";
|
|
11
|
+
import { enableNavigationPreload } from "./navigationPreload.js";
|
|
12
|
+
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
1
13
|
import type {
|
|
2
14
|
RouteHandler,
|
|
3
15
|
RouteHandlerCallback,
|
|
@@ -7,35 +19,23 @@ import type {
|
|
|
7
19
|
RouteMatchCallbackOptions,
|
|
8
20
|
SerwistPlugin,
|
|
9
21
|
} from "./types.js";
|
|
10
|
-
import { clientsClaim as clientsClaimImpl } from "./clientsClaim.js";
|
|
11
|
-
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
12
|
-
import { assert } from "./utils/assert.js";
|
|
13
|
-
import { SerwistError } from "./utils/SerwistError.js";
|
|
14
|
-
import { getFriendlyURL } from "./utils/getFriendlyURL.js";
|
|
15
|
-
import { logger } from "./utils/logger.js";
|
|
16
|
-
import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
|
|
17
|
-
import { waitUntil } from "./utils/waitUntil.js";
|
|
18
|
-
import { parallel } from "@serwist/utils";
|
|
19
|
-
import { NavigationRoute } from "./NavigationRoute.js";
|
|
20
|
-
import { PrecacheRoute } from "./PrecacheRoute.js";
|
|
21
|
-
import { PrecacheStrategy } from "./PrecacheStrategy.js";
|
|
22
|
-
import type { Route } from "./Route.js";
|
|
23
|
-
import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "./cleanupOutdatedCaches.js";
|
|
24
|
-
import { type HTTPMethod, defaultMethod } from "./constants.js";
|
|
25
|
-
import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
|
|
26
|
-
import { enableNavigationPreload } from "./navigationPreload.js";
|
|
27
|
-
import { parseRoute } from "./parseRoute.js";
|
|
28
|
-
import { type GoogleAnalyticsInitializeOptions, initialize } from "./plugins/googleAnalytics/initialize.js";
|
|
29
|
-
import { type PrecacheFallbackEntry, PrecacheFallbackPlugin } from "./plugins/precaching/PrecacheFallbackPlugin.js";
|
|
30
|
-
import { Strategy } from "./strategies/Strategy.js";
|
|
31
22
|
import type { PrecacheRouteOptions, RuntimeCaching } from "./types.js";
|
|
32
23
|
import type { CleanupResult, InstallResult, PrecacheEntry } from "./types.js";
|
|
33
24
|
import { PrecacheCacheKeyPlugin } from "./utils/PrecacheCacheKeyPlugin.js";
|
|
34
25
|
import { PrecacheInstallReportPlugin } from "./utils/PrecacheInstallReportPlugin.js";
|
|
26
|
+
import { SerwistError } from "./utils/SerwistError.js";
|
|
27
|
+
import { assert } from "./utils/assert.js";
|
|
28
|
+
import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
|
|
29
|
+
import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "./utils/cleanupOutdatedCaches.js";
|
|
30
|
+
import { clientsClaim as clientsClaimImpl } from "./utils/clientsClaim.js";
|
|
35
31
|
import { createCacheKey } from "./utils/createCacheKey.js";
|
|
32
|
+
import { getFriendlyURL } from "./utils/getFriendlyURL.js";
|
|
33
|
+
import { logger } from "./utils/logger.js";
|
|
36
34
|
import { normalizeHandler } from "./utils/normalizeHandler.js";
|
|
35
|
+
import { parseRoute } from "./utils/parseRoute.js";
|
|
37
36
|
import { printCleanupDetails } from "./utils/printCleanupDetails.js";
|
|
38
37
|
import { printInstallDetails } from "./utils/printInstallDetails.js";
|
|
38
|
+
import { waitUntil } from "./utils/waitUntil.js";
|
|
39
39
|
|
|
40
40
|
declare const self: ServiceWorkerGlobalScope;
|
|
41
41
|
|
|
@@ -50,26 +50,26 @@ export interface FallbacksOptions {
|
|
|
50
50
|
|
|
51
51
|
export interface PrecacheOptions extends PrecacheRouteOptions {
|
|
52
52
|
/**
|
|
53
|
-
* The cache
|
|
53
|
+
* The cache used for precaching.
|
|
54
54
|
*/
|
|
55
55
|
cacheName?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface SerwistOptions {
|
|
59
|
-
/**
|
|
60
|
-
* A list of URLs that should be cached.
|
|
61
|
-
*/
|
|
62
|
-
precacheEntries?: (PrecacheEntry | string)[];
|
|
63
|
-
/**
|
|
64
|
-
* Options to customize how Serwist precaches the URLs in the precache list.
|
|
65
|
-
*/
|
|
66
|
-
precacheOptions?: PrecacheOptions;
|
|
67
56
|
/**
|
|
68
57
|
* Whether outdated caches should be removed.
|
|
69
58
|
*
|
|
70
59
|
* @default false
|
|
71
60
|
*/
|
|
72
61
|
cleanupOutdatedCaches?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The number of precache requests that should be made concurrently.
|
|
64
|
+
*
|
|
65
|
+
* @default 10
|
|
66
|
+
*/
|
|
67
|
+
concurrency?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to attempt to get the response from the network if there's
|
|
70
|
+
* a precache miss.
|
|
71
|
+
*/
|
|
72
|
+
fallbackToNetwork?: boolean;
|
|
73
73
|
/**
|
|
74
74
|
* An URL that should point to a HTML file with which navigation requests for URLs that aren't
|
|
75
75
|
* precached will be fulfilled.
|
|
@@ -89,17 +89,17 @@ export interface SerwistOptions {
|
|
|
89
89
|
* events for precached assets.
|
|
90
90
|
*/
|
|
91
91
|
plugins?: SerwistPlugin[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface SerwistOptions {
|
|
92
95
|
/**
|
|
93
|
-
*
|
|
94
|
-
* a precache miss.
|
|
96
|
+
* A list of URLs that should be cached.
|
|
95
97
|
*/
|
|
96
|
-
|
|
98
|
+
precacheEntries?: (PrecacheEntry | string)[];
|
|
97
99
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @default 1
|
|
100
|
+
* Options to customize how Serwist precaches the URLs in the precache list.
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
precacheOptions?: PrecacheOptions;
|
|
103
103
|
/**
|
|
104
104
|
* Forces the waiting service worker to become the active one.
|
|
105
105
|
*
|
|
@@ -132,12 +132,10 @@ export interface SerwistOptions {
|
|
|
132
132
|
clientsClaim?: boolean;
|
|
133
133
|
/**
|
|
134
134
|
* A list of caching strategies.
|
|
135
|
-
*
|
|
136
|
-
* @see https://serwist.pages.dev/docs/sw/runtime-caching
|
|
137
135
|
*/
|
|
138
136
|
runtimeCaching?: RuntimeCaching[];
|
|
139
137
|
/**
|
|
140
|
-
* Your configuration for
|
|
138
|
+
* Your configuration for `initializeGoogleAnalytics`. This plugin is
|
|
141
139
|
* only initialized when this option is not `undefined` or `false`.
|
|
142
140
|
*/
|
|
143
141
|
offlineAnalyticsConfig?: Omit<GoogleAnalyticsInitializeOptions, "serwist"> | boolean;
|
|
@@ -149,12 +147,10 @@ export interface SerwistOptions {
|
|
|
149
147
|
disableDevLogs?: boolean;
|
|
150
148
|
/**
|
|
151
149
|
* Precaches routes so that they can be used as a fallback when
|
|
152
|
-
* a Strategy fails to generate a response.
|
|
150
|
+
* a `Strategy` fails to generate a response.
|
|
153
151
|
*
|
|
154
|
-
* Note: This option mutates `runtimeCaching`. It also
|
|
155
|
-
* defined in `entries
|
|
156
|
-
*
|
|
157
|
-
* @see https://serwist.pages.dev/docs/sw/abstractions/fallbacks
|
|
152
|
+
* Note: This option mutates `runtimeCaching`. It also expects the URLs
|
|
153
|
+
* defined in `entries` to have been precached beforehand.
|
|
158
154
|
*/
|
|
159
155
|
fallbacks?: FallbacksOptions;
|
|
160
156
|
}
|
|
@@ -170,6 +166,8 @@ interface CacheURLsMessageData {
|
|
|
170
166
|
|
|
171
167
|
/**
|
|
172
168
|
* A class that helps bootstrap the service worker.
|
|
169
|
+
*
|
|
170
|
+
* @see https://serwist.pages.dev/docs/serwist/core/serwist
|
|
173
171
|
*/
|
|
174
172
|
export class Serwist {
|
|
175
173
|
private readonly _urlsToCacheKeys: Map<string, string> = new Map();
|
|
@@ -184,13 +182,6 @@ export class Serwist {
|
|
|
184
182
|
constructor({
|
|
185
183
|
precacheEntries,
|
|
186
184
|
precacheOptions,
|
|
187
|
-
cleanupOutdatedCaches,
|
|
188
|
-
navigateFallback,
|
|
189
|
-
navigateFallbackAllowlist,
|
|
190
|
-
navigateFallbackDenylist,
|
|
191
|
-
plugins = [],
|
|
192
|
-
fallbackToNetwork = true,
|
|
193
|
-
concurrentPrecaching = 1,
|
|
194
185
|
skipWaiting = false,
|
|
195
186
|
importScripts,
|
|
196
187
|
navigationPreload = false,
|
|
@@ -201,11 +192,11 @@ export class Serwist {
|
|
|
201
192
|
disableDevLogs = false,
|
|
202
193
|
fallbacks,
|
|
203
194
|
}: SerwistOptions = {}) {
|
|
204
|
-
this._concurrentPrecaching =
|
|
195
|
+
this._concurrentPrecaching = precacheOptions?.concurrency ?? 10;
|
|
205
196
|
this._precacheStrategy = new PrecacheStrategy({
|
|
206
197
|
cacheName: privateCacheNames.getPrecacheName(precacheOptions?.cacheName),
|
|
207
|
-
plugins: [...plugins, new PrecacheCacheKeyPlugin({ precacheController: this })],
|
|
208
|
-
fallbackToNetwork,
|
|
198
|
+
plugins: [...(precacheOptions?.plugins ?? []), new PrecacheCacheKeyPlugin({ precacheController: this })],
|
|
199
|
+
fallbackToNetwork: precacheOptions?.fallbackToNetwork,
|
|
209
200
|
});
|
|
210
201
|
this._routes = new Map();
|
|
211
202
|
this._defaultHandlerMap = new Map();
|
|
@@ -237,35 +228,36 @@ export class Serwist {
|
|
|
237
228
|
|
|
238
229
|
if (clientsClaim) clientsClaimImpl();
|
|
239
230
|
|
|
240
|
-
this.registerRoute(new PrecacheRoute(this, precacheOptions));
|
|
241
|
-
|
|
242
231
|
if (!!precacheEntries && precacheEntries.length > 0) {
|
|
243
232
|
this.addToPrecacheList(precacheEntries);
|
|
244
233
|
}
|
|
245
234
|
|
|
246
|
-
if (cleanupOutdatedCaches) {
|
|
235
|
+
if (precacheOptions?.cleanupOutdatedCaches) {
|
|
247
236
|
cleanupOutdatedCachesImpl(precacheOptions?.cacheName);
|
|
248
237
|
}
|
|
249
238
|
|
|
250
|
-
|
|
239
|
+
this.registerRoute(new PrecacheRoute(this, precacheOptions));
|
|
240
|
+
|
|
241
|
+
if (precacheOptions?.navigateFallback) {
|
|
251
242
|
this.registerRoute(
|
|
252
|
-
new NavigationRoute(this.createHandlerBoundToUrl(navigateFallback), {
|
|
253
|
-
allowlist: navigateFallbackAllowlist,
|
|
254
|
-
denylist: navigateFallbackDenylist,
|
|
243
|
+
new NavigationRoute(this.createHandlerBoundToUrl(precacheOptions?.navigateFallback), {
|
|
244
|
+
allowlist: precacheOptions?.navigateFallbackAllowlist,
|
|
245
|
+
denylist: precacheOptions?.navigateFallbackDenylist,
|
|
255
246
|
}),
|
|
256
247
|
);
|
|
257
248
|
}
|
|
258
249
|
|
|
259
250
|
if (offlineAnalyticsConfig !== undefined) {
|
|
260
251
|
if (typeof offlineAnalyticsConfig === "boolean") {
|
|
261
|
-
offlineAnalyticsConfig &&
|
|
252
|
+
offlineAnalyticsConfig && initializeGoogleAnalytics({ serwist: this });
|
|
262
253
|
} else {
|
|
263
|
-
|
|
254
|
+
initializeGoogleAnalytics({
|
|
264
255
|
...offlineAnalyticsConfig,
|
|
265
256
|
serwist: this,
|
|
266
257
|
});
|
|
267
258
|
}
|
|
268
259
|
}
|
|
260
|
+
|
|
269
261
|
if (runtimeCaching !== undefined) {
|
|
270
262
|
if (fallbacks !== undefined) {
|
|
271
263
|
const fallbackPlugin = new PrecacheFallbackPlugin({
|
|
@@ -292,23 +284,21 @@ export class Serwist {
|
|
|
292
284
|
}
|
|
293
285
|
|
|
294
286
|
/**
|
|
295
|
-
* The strategy
|
|
296
|
-
* used to cache assets and respond to fetch events.
|
|
287
|
+
* The strategy used to precache assets and respond to fetch events.
|
|
297
288
|
*/
|
|
298
289
|
get precacheStrategy(): Strategy {
|
|
299
290
|
return this._precacheStrategy;
|
|
300
291
|
}
|
|
301
292
|
/**
|
|
302
|
-
* A `Map` of HTTP method name (`'GET'`, etc.) to an array of all
|
|
303
|
-
* instances
|
|
293
|
+
* A `Map` of HTTP method name (`'GET'`, etc.) to an array of all corresponding registered `Route`
|
|
294
|
+
* instances.
|
|
304
295
|
*/
|
|
305
296
|
get routes(): Map<HTTPMethod, Route[]> {
|
|
306
297
|
return this._routes;
|
|
307
298
|
}
|
|
308
299
|
|
|
309
300
|
/**
|
|
310
|
-
*
|
|
311
|
-
* should you need to.
|
|
301
|
+
* Adds Serwist's event listeners for you. Before calling it, add your own listeners should you need to.
|
|
312
302
|
*/
|
|
313
303
|
addEventListeners() {
|
|
314
304
|
self.addEventListener("install", this.handleInstall);
|
|
@@ -318,8 +308,7 @@ export class Serwist {
|
|
|
318
308
|
}
|
|
319
309
|
|
|
320
310
|
/**
|
|
321
|
-
*
|
|
322
|
-
* and ensuring the information is valid.
|
|
311
|
+
* Adds items to the precache list, removing duplicates and ensuring the information is valid.
|
|
323
312
|
*
|
|
324
313
|
* @param entries Array of entries to precache.
|
|
325
314
|
*/
|
|
@@ -535,7 +524,7 @@ export class Serwist {
|
|
|
535
524
|
|
|
536
525
|
/**
|
|
537
526
|
* Registers a `RegExp`, string, or function with a caching
|
|
538
|
-
* strategy to the
|
|
527
|
+
* strategy to the router.
|
|
539
528
|
*
|
|
540
529
|
* @param capture If the capture param is a `Route`, all other arguments will be ignored.
|
|
541
530
|
* @param handler A callback function that returns a `Promise` resulting in a `Response`.
|
|
@@ -543,7 +532,11 @@ export class Serwist {
|
|
|
543
532
|
* @param method The HTTP method to match the Route against. Defaults to `'GET'`.
|
|
544
533
|
* @returns The generated `Route`.
|
|
545
534
|
*/
|
|
546
|
-
registerCapture
|
|
535
|
+
registerCapture<T extends RegExp | string | RouteMatchCallback | Route>(
|
|
536
|
+
capture: T,
|
|
537
|
+
handler?: T extends Route ? never : RouteHandler,
|
|
538
|
+
method?: T extends Route ? never : HTTPMethod,
|
|
539
|
+
): Route {
|
|
547
540
|
const route = parseRoute(capture, handler, method);
|
|
548
541
|
this.registerRoute(route);
|
|
549
542
|
return route;
|
|
@@ -602,7 +595,7 @@ export class Serwist {
|
|
|
602
595
|
}
|
|
603
596
|
|
|
604
597
|
/**
|
|
605
|
-
* Unregisters a `Route` with the
|
|
598
|
+
* Unregisters a `Route` with the router.
|
|
606
599
|
*
|
|
607
600
|
* @param route The `Route` to unregister.
|
|
608
601
|
*/
|
|
@@ -643,7 +636,7 @@ export class Serwist {
|
|
|
643
636
|
|
|
644
637
|
/**
|
|
645
638
|
* Returns the cache key used for storing a given URL. If that URL is
|
|
646
|
-
* unversioned, like
|
|
639
|
+
* unversioned, like "/index.html", then the cache key will be the original
|
|
647
640
|
* URL with a search parameter appended to it.
|
|
648
641
|
*
|
|
649
642
|
* @param url A URL whose cache key you want to look up.
|
|
@@ -713,7 +706,7 @@ export class Serwist {
|
|
|
713
706
|
}
|
|
714
707
|
|
|
715
708
|
/**
|
|
716
|
-
*
|
|
709
|
+
* Applies the routing rules to a `FetchEvent` object to get a `Response` from an
|
|
717
710
|
* appropriate `Route`'s handler.
|
|
718
711
|
*
|
|
719
712
|
* @param options
|
package/src/copyResponse.ts
CHANGED
|
@@ -11,21 +11,19 @@ import { canConstructResponseFromBodyStream } from "./utils/canConstructResponse
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Allows developers to copy a response and modify its `headers`, `status`,
|
|
14
|
-
* or `statusText` values (the
|
|
15
|
-
*
|
|
16
|
-
* object in the constructor).
|
|
14
|
+
* or `statusText` values (the [valid options](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#options)
|
|
15
|
+
* when constructing a `Response` object).
|
|
17
16
|
* To modify these values, pass a function as the second argument. That
|
|
18
|
-
* function will be invoked with
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* either modify the passed parameter(s) and return it, or return a totally
|
|
17
|
+
* function will be invoked with the options of the initial `Response` object.
|
|
18
|
+
* The return value of this function will be used as the options for the new `Response` object.
|
|
19
|
+
* To change the values either modify the passed parameter(s) and return it or return a totally
|
|
22
20
|
* new object.
|
|
23
21
|
*
|
|
24
22
|
* This method is intentionally limited to same-origin responses, regardless of
|
|
25
23
|
* whether CORS was used or not.
|
|
26
24
|
*
|
|
27
|
-
* @param response
|
|
28
|
-
* @param modifier
|
|
25
|
+
* @param response The initial response.
|
|
26
|
+
* @param modifier The function used to modify the options of the `Response` object.
|
|
29
27
|
*/
|
|
30
28
|
export const copyResponse = async (response: Response, modifier?: (responseInit: ResponseInit) => ResponseInit): Promise<Response> => {
|
|
31
29
|
let origin = null;
|
package/src/disableDevLogs.ts
CHANGED
|
@@ -3,7 +3,7 @@ declare const self: ServiceWorkerGlobalScope;
|
|
|
3
3
|
/**
|
|
4
4
|
* Disables Serwist's logging in development mode.
|
|
5
5
|
*
|
|
6
|
-
* @see https://serwist.pages.dev/docs/
|
|
6
|
+
* @see https://serwist.pages.dev/docs/serwist/core/disable-dev-logs
|
|
7
7
|
*/
|
|
8
8
|
export const disableDevLogs = (): void => {
|
|
9
9
|
self.__WB_DISABLE_DEV_LOGS = true;
|
package/src/index.internal.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { cacheMatchIgnoreParams } from "./utils/cacheMatchIgnoreParams.js";
|
|
|
5
5
|
import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
|
|
6
6
|
import { canConstructReadableStream } from "./utils/canConstructReadableStream.js";
|
|
7
7
|
import { canConstructResponseFromBodyStream } from "./utils/canConstructResponseFromBodyStream.js";
|
|
8
|
+
import { cleanupOutdatedCaches } from "./utils/cleanupOutdatedCaches.js";
|
|
9
|
+
import { clientsClaim } from "./utils/clientsClaim.js";
|
|
8
10
|
import { dontWaitFor } from "./utils/dontWaitFor.js";
|
|
9
11
|
import { executeQuotaErrorCallbacks } from "./utils/executeQuotaErrorCallbacks.js";
|
|
10
12
|
import { getFriendlyURL } from "./utils/getFriendlyURL.js";
|
|
@@ -19,6 +21,8 @@ export {
|
|
|
19
21
|
Deferred,
|
|
20
22
|
SerwistError,
|
|
21
23
|
assert,
|
|
24
|
+
cleanupOutdatedCaches,
|
|
25
|
+
clientsClaim,
|
|
22
26
|
cacheMatchIgnoreParams,
|
|
23
27
|
privateCacheNames,
|
|
24
28
|
canConstructReadableStream,
|
package/src/index.legacy.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { NavigationRoute } from "./NavigationRoute.js";
|
|
2
|
-
import { PrecacheStrategy } from "./PrecacheStrategy.js";
|
|
3
|
-
import { RegExpRoute } from "./RegExpRoute.js";
|
|
4
|
-
import { Route } from "./Route.js";
|
|
5
|
-
import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
|
|
6
1
|
import { PrecacheController } from "./legacy/PrecacheController.js";
|
|
7
2
|
import { PrecacheFallbackPlugin } from "./legacy/PrecacheFallbackPlugin.js";
|
|
8
3
|
import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./legacy/PrecacheFallbackPlugin.js";
|
|
@@ -15,6 +10,8 @@ import type { FallbackEntry, FallbacksOptions } from "./legacy/fallbacks.js";
|
|
|
15
10
|
import { fallbacks } from "./legacy/fallbacks.js";
|
|
16
11
|
import { getCacheKeyForURL } from "./legacy/getCacheKeyForURL.js";
|
|
17
12
|
import { type HandlePrecachingOptions, handlePrecaching } from "./legacy/handlePrecaching.js";
|
|
13
|
+
import type { GoogleAnalyticsInitializeOptions } from "./legacy/initializeGoogleAnalytics.js";
|
|
14
|
+
import { initializeGoogleAnalytics } from "./legacy/initializeGoogleAnalytics.js";
|
|
18
15
|
import { type InstallSerwistOptions, installSerwist } from "./legacy/installSerwist.js";
|
|
19
16
|
import { matchPrecache } from "./legacy/matchPrecache.js";
|
|
20
17
|
import { precache } from "./legacy/precache.js";
|
|
@@ -26,24 +23,16 @@ import { setDefaultHandler } from "./legacy/setDefaultHandler.js";
|
|
|
26
23
|
import { getSingletonPrecacheController, setSingletonPrecacheController } from "./legacy/singletonPrecacheController.js";
|
|
27
24
|
import { getSingletonRouter, setSingletonRouter } from "./legacy/singletonRouter.js";
|
|
28
25
|
import { unregisterRoute } from "./legacy/unregisterRoute.js";
|
|
29
|
-
import { parseRoute } from "./parseRoute.js";
|
|
30
26
|
|
|
31
27
|
export {
|
|
32
|
-
// These are not deprecated, but we export them so legacy packages
|
|
33
|
-
// can re-export them without having to import both the normal and legacy
|
|
34
|
-
// import paths.
|
|
35
|
-
NavigationRoute,
|
|
36
|
-
PrecacheStrategy,
|
|
37
|
-
RegExpRoute,
|
|
38
|
-
Route,
|
|
39
|
-
cleanupOutdatedCaches,
|
|
40
|
-
parseRoute,
|
|
41
28
|
// Actual deprecated modules start here
|
|
42
29
|
addPlugins,
|
|
43
30
|
addRoute,
|
|
44
31
|
createHandlerBoundToURL,
|
|
45
|
-
getCacheKeyForURL,
|
|
46
32
|
fallbacks,
|
|
33
|
+
getCacheKeyForURL,
|
|
34
|
+
initializeGoogleAnalytics,
|
|
35
|
+
installSerwist,
|
|
47
36
|
matchPrecache,
|
|
48
37
|
precache,
|
|
49
38
|
precacheAndRoute,
|
|
@@ -53,7 +42,6 @@ export {
|
|
|
53
42
|
getSingletonPrecacheController,
|
|
54
43
|
setSingletonPrecacheController,
|
|
55
44
|
handlePrecaching,
|
|
56
|
-
installSerwist,
|
|
57
45
|
registerRuntimeCaching,
|
|
58
46
|
registerRoute,
|
|
59
47
|
Router,
|
|
@@ -63,4 +51,12 @@ export {
|
|
|
63
51
|
setSingletonRouter,
|
|
64
52
|
unregisterRoute,
|
|
65
53
|
};
|
|
66
|
-
export type {
|
|
54
|
+
export type {
|
|
55
|
+
HandlePrecachingOptions,
|
|
56
|
+
GoogleAnalyticsInitializeOptions,
|
|
57
|
+
InstallSerwistOptions,
|
|
58
|
+
FallbackEntry,
|
|
59
|
+
FallbacksOptions,
|
|
60
|
+
PrecacheFallbackEntry,
|
|
61
|
+
PrecacheFallbackPluginOptions,
|
|
62
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,39 +1,125 @@
|
|
|
1
|
-
import type { HTTPMethod } from "./constants.js";
|
|
2
|
-
import { cacheNames } from "./cacheNames.js";
|
|
3
|
-
import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
|
|
4
|
-
import { clientsClaim } from "./clientsClaim.js";
|
|
5
|
-
import { copyResponse } from "./copyResponse.js";
|
|
6
|
-
import { disableDevLogs } from "./disableDevLogs.js";
|
|
7
|
-
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
|
|
8
1
|
import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
|
|
9
2
|
import { NavigationRoute } from "./NavigationRoute.js";
|
|
10
|
-
import { parseRoute } from "./parseRoute.js";
|
|
11
3
|
import { PrecacheRoute } from "./PrecacheRoute.js";
|
|
12
|
-
import { PrecacheStrategy } from "./PrecacheStrategy.js";
|
|
13
4
|
import { RegExpRoute } from "./RegExpRoute.js";
|
|
14
|
-
import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
|
|
15
5
|
import { Route } from "./Route.js";
|
|
16
6
|
import { Serwist, type SerwistOptions } from "./Serwist.js";
|
|
7
|
+
import { cacheNames } from "./cacheNames.js";
|
|
8
|
+
import type { HTTPMethod } from "./constants.js";
|
|
9
|
+
import { copyResponse } from "./copyResponse.js";
|
|
10
|
+
import { disableDevLogs } from "./disableDevLogs.js";
|
|
11
|
+
import { BackgroundSyncPlugin } from "./lib/backgroundSync/BackgroundSyncPlugin.js";
|
|
12
|
+
import type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./lib/backgroundSync/BackgroundSyncQueue.js";
|
|
13
|
+
import { BackgroundSyncQueue } from "./lib/backgroundSync/BackgroundSyncQueue.js";
|
|
14
|
+
import { BackgroundSyncQueueStore } from "./lib/backgroundSync/BackgroundSyncQueueStore.js";
|
|
15
|
+
import { StorableRequest } from "./lib/backgroundSync/StorableRequest.js";
|
|
16
|
+
import { BroadcastCacheUpdate } from "./lib/broadcastUpdate/BroadcastCacheUpdate.js";
|
|
17
|
+
import { BroadcastUpdatePlugin } from "./lib/broadcastUpdate/BroadcastUpdatePlugin.js";
|
|
18
|
+
import { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./lib/broadcastUpdate/constants.js";
|
|
19
|
+
import { responsesAreSame } from "./lib/broadcastUpdate/responsesAreSame.js";
|
|
20
|
+
import type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./lib/broadcastUpdate/types.js";
|
|
21
|
+
import { CacheableResponse } from "./lib/cacheableResponse/CacheableResponse.js";
|
|
22
|
+
import type { CacheableResponseOptions } from "./lib/cacheableResponse/CacheableResponse.js";
|
|
23
|
+
import { CacheableResponsePlugin } from "./lib/cacheableResponse/CacheableResponsePlugin.js";
|
|
24
|
+
import { CacheExpiration } from "./lib/expiration/CacheExpiration.js";
|
|
25
|
+
import type { ExpirationPluginOptions } from "./lib/expiration/ExpirationPlugin.js";
|
|
26
|
+
import { ExpirationPlugin } from "./lib/expiration/ExpirationPlugin.js";
|
|
27
|
+
import { initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
28
|
+
import type { GoogleAnalyticsInitializeOptions } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
29
|
+
import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
30
|
+
import { PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
31
|
+
import { RangeRequestsPlugin } from "./lib/rangeRequests/RangeRequestsPlugin.js";
|
|
32
|
+
import { createPartialResponse } from "./lib/rangeRequests/createPartialResponse.js";
|
|
33
|
+
import { CacheFirst } from "./lib/strategies/CacheFirst.js";
|
|
34
|
+
import { CacheOnly } from "./lib/strategies/CacheOnly.js";
|
|
35
|
+
import type { NetworkFirstOptions } from "./lib/strategies/NetworkFirst.js";
|
|
36
|
+
import { NetworkFirst } from "./lib/strategies/NetworkFirst.js";
|
|
37
|
+
import type { NetworkOnlyOptions } from "./lib/strategies/NetworkOnly.js";
|
|
38
|
+
import { NetworkOnly } from "./lib/strategies/NetworkOnly.js";
|
|
39
|
+
import { PrecacheStrategy } from "./lib/strategies/PrecacheStrategy.js";
|
|
40
|
+
import { StaleWhileRevalidate } from "./lib/strategies/StaleWhileRevalidate.js";
|
|
41
|
+
import type { StrategyOptions } from "./lib/strategies/Strategy.js";
|
|
42
|
+
import { Strategy } from "./lib/strategies/Strategy.js";
|
|
43
|
+
import { StrategyHandler } from "./lib/strategies/StrategyHandler.js";
|
|
44
|
+
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
|
|
45
|
+
import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
|
|
17
46
|
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
18
47
|
|
|
19
48
|
export {
|
|
20
|
-
|
|
49
|
+
// Core
|
|
50
|
+
Serwist,
|
|
21
51
|
cacheNames,
|
|
22
|
-
cleanupOutdatedCaches,
|
|
23
|
-
clientsClaim,
|
|
24
52
|
copyResponse,
|
|
25
53
|
disableDevLogs,
|
|
26
54
|
disableNavigationPreload,
|
|
27
55
|
enableNavigationPreload,
|
|
28
56
|
isNavigationPreloadSupported,
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
registerQuotaErrorCallback,
|
|
58
|
+
setCacheNameDetails,
|
|
59
|
+
// Caching strategies
|
|
60
|
+
CacheFirst,
|
|
61
|
+
CacheOnly,
|
|
62
|
+
NetworkFirst,
|
|
63
|
+
NetworkOnly,
|
|
31
64
|
PrecacheStrategy,
|
|
65
|
+
StaleWhileRevalidate,
|
|
66
|
+
Strategy,
|
|
67
|
+
StrategyHandler,
|
|
68
|
+
// Routing
|
|
69
|
+
NavigationRoute,
|
|
70
|
+
PrecacheRoute,
|
|
32
71
|
RegExpRoute,
|
|
33
|
-
registerQuotaErrorCallback,
|
|
34
72
|
Route,
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
// Background synchronizing
|
|
74
|
+
BackgroundSyncPlugin,
|
|
75
|
+
BackgroundSyncQueue,
|
|
76
|
+
BackgroundSyncQueueStore,
|
|
77
|
+
StorableRequest,
|
|
78
|
+
// Broadcasting updates
|
|
79
|
+
BroadcastCacheUpdate,
|
|
80
|
+
BroadcastUpdatePlugin,
|
|
81
|
+
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
82
|
+
responsesAreSame,
|
|
83
|
+
// Setting cacheability criteria
|
|
84
|
+
CacheableResponse,
|
|
85
|
+
CacheableResponsePlugin,
|
|
86
|
+
// Expiring outdated responses
|
|
87
|
+
CacheExpiration,
|
|
88
|
+
ExpirationPlugin,
|
|
89
|
+
// Precaching
|
|
90
|
+
PrecacheFallbackPlugin,
|
|
91
|
+
// Google Analytics
|
|
92
|
+
initializeGoogleAnalytics,
|
|
93
|
+
// Handling range requests
|
|
94
|
+
createPartialResponse,
|
|
95
|
+
RangeRequestsPlugin,
|
|
96
|
+
};
|
|
97
|
+
export type {
|
|
98
|
+
// Core
|
|
99
|
+
HTTPMethod,
|
|
100
|
+
SerwistOptions,
|
|
101
|
+
// Caching strategies
|
|
102
|
+
NetworkFirstOptions,
|
|
103
|
+
NetworkOnlyOptions,
|
|
104
|
+
StrategyOptions,
|
|
105
|
+
// Routing
|
|
106
|
+
NavigationRouteMatchOptions,
|
|
107
|
+
// Background synchronizing
|
|
108
|
+
BackgroundSyncQueueOptions,
|
|
109
|
+
BackgroundSyncQueueEntry,
|
|
110
|
+
// Broadcasting updates
|
|
111
|
+
BroadcastCacheUpdateOptions,
|
|
112
|
+
BroadcastPayload,
|
|
113
|
+
BroadcastPayloadGenerator,
|
|
114
|
+
BroadcastMessage,
|
|
115
|
+
// Setting cacheability criteria
|
|
116
|
+
CacheableResponseOptions,
|
|
117
|
+
// Expiring outdated responses
|
|
118
|
+
ExpirationPluginOptions,
|
|
119
|
+
// Precaching
|
|
120
|
+
PrecacheFallbackEntry,
|
|
121
|
+
PrecacheFallbackPluginOptions,
|
|
122
|
+
// Google Analytics
|
|
123
|
+
GoogleAnalyticsInitializeOptions,
|
|
37
124
|
};
|
|
38
|
-
export type { HTTPMethod, NavigationRouteMatchOptions, SerwistOptions };
|
|
39
125
|
export type * from "./types.js";
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { RouteHandlerCallback, SerwistPlugin } from "../types.js";
|
|
10
|
-
import { assert } from "../utils/assert.js";
|
|
11
|
-
import { SerwistError } from "../utils/SerwistError.js";
|
|
12
|
-
import { logger } from "../utils/logger.js";
|
|
13
|
-
import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
|
|
14
|
-
import { waitUntil } from "../utils/waitUntil.js";
|
|
15
9
|
import { parallel } from "@serwist/utils";
|
|
16
|
-
import { PrecacheStrategy } from "../PrecacheStrategy.js";
|
|
17
|
-
import type { Strategy } from "../strategies/Strategy.js";
|
|
10
|
+
import { PrecacheStrategy } from "../lib/strategies/PrecacheStrategy.js";
|
|
11
|
+
import type { Strategy } from "../lib/strategies/Strategy.js";
|
|
12
|
+
import type { RouteHandlerCallback, SerwistPlugin } from "../types.js";
|
|
18
13
|
import type { CleanupResult, InstallResult, PrecacheEntry } from "../types.js";
|
|
19
14
|
import { PrecacheInstallReportPlugin } from "../utils/PrecacheInstallReportPlugin.js";
|
|
15
|
+
import { SerwistError } from "../utils/SerwistError.js";
|
|
16
|
+
import { assert } from "../utils/assert.js";
|
|
17
|
+
import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
|
|
20
18
|
import { createCacheKey } from "../utils/createCacheKey.js";
|
|
19
|
+
import { logger } from "../utils/logger.js";
|
|
21
20
|
import { printCleanupDetails } from "../utils/printCleanupDetails.js";
|
|
22
21
|
import { printInstallDetails } from "../utils/printInstallDetails.js";
|
|
22
|
+
import { waitUntil } from "../utils/waitUntil.js";
|
|
23
23
|
import { PrecacheCacheKeyPlugin } from "./utils/PrecacheCacheKeyPlugin.js";
|
|
24
24
|
|
|
25
25
|
// Give TypeScript the correct global.
|
|
@@ -52,7 +52,7 @@ export interface PrecacheFallbackPluginOptions {
|
|
|
52
52
|
* Unless you explicitly pass in a `PrecacheController` instance to the
|
|
53
53
|
* constructor, the default instance will be used. Generally speaking, most
|
|
54
54
|
* developers will end up using the default.
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
56
|
* @deprecated
|
|
57
57
|
*/
|
|
58
58
|
export class PrecacheFallbackPlugin implements SerwistPlugin {
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { RouteMatchCallback, RouteMatchCallbackOptions } from "../types.js";
|
|
10
|
-
import { getFriendlyURL } from "../utils/getFriendlyURL.js";
|
|
11
|
-
import { logger } from "../utils/logger.js";
|
|
12
9
|
import { Route } from "../Route.js";
|
|
10
|
+
import type { RouteMatchCallback, RouteMatchCallbackOptions } from "../types.js";
|
|
13
11
|
import type { PrecacheRouteOptions } from "../types.js";
|
|
14
12
|
import { generateURLVariations } from "../utils/generateURLVariations.js";
|
|
13
|
+
import { getFriendlyURL } from "../utils/getFriendlyURL.js";
|
|
14
|
+
import { logger } from "../utils/logger.js";
|
|
15
15
|
import type { PrecacheController } from "./PrecacheController.js";
|
|
16
16
|
|
|
17
17
|
/**
|