@serwist/sw 9.0.0-preview.17 → 9.0.0-preview.19
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/{Serwist.d.ts → abstractions/Serwist.d.ts} +6 -15
- package/dist/abstractions/Serwist.d.ts.map +1 -0
- package/dist/abstractions/disableDevLogs.d.ts.map +1 -0
- package/dist/{fallbacks.d.ts → abstractions/fallbacks.d.ts} +2 -2
- package/dist/abstractions/fallbacks.d.ts.map +1 -0
- package/dist/{handlePrecaching.d.ts → abstractions/handlePrecaching.d.ts} +1 -1
- package/dist/abstractions/handlePrecaching.d.ts.map +1 -0
- package/dist/abstractions/installSerwist.d.ts.map +1 -0
- package/dist/abstractions/navigationPreload.d.ts +20 -0
- package/dist/abstractions/navigationPreload.d.ts.map +1 -0
- package/dist/abstractions/registerRuntimeCaching.d.ts.map +1 -0
- package/dist/{types.d.ts → abstractions/types.d.ts} +1 -1
- package/dist/abstractions/types.d.ts.map +1 -0
- package/dist/chunks/NavigationRoute.js +54 -0
- package/dist/chunks/NetworkOnly.js +193 -0
- package/dist/chunks/PrecacheFallbackPlugin.js +573 -0
- package/dist/chunks/Strategy.js +410 -0
- package/dist/chunks/getOrCreatePrecacheController.js +429 -0
- package/dist/chunks/precacheAndRoute.js +112 -0
- package/dist/chunks/registerRoute.js +408 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -12
- package/dist/index.plugins.d.ts +40 -11
- package/dist/index.plugins.d.ts.map +1 -1
- package/dist/index.plugins.js +671 -5
- package/dist/index.precaching.d.ts +24 -0
- package/dist/index.precaching.d.ts.map +1 -0
- package/dist/index.precaching.js +24 -0
- package/dist/index.routing.d.ts +13 -0
- package/dist/index.routing.d.ts.map +1 -0
- package/dist/index.routing.js +21 -0
- package/dist/index.strategies.d.ts +19 -2
- package/dist/index.strategies.d.ts.map +1 -1
- package/dist/index.strategies.js +146 -1
- package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts +23 -0
- package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -0
- package/dist/plugins/backgroundSync/Queue.d.ts +166 -0
- package/dist/plugins/backgroundSync/Queue.d.ts.map +1 -0
- package/dist/plugins/backgroundSync/QueueDb.d.ts +90 -0
- package/dist/plugins/backgroundSync/QueueDb.d.ts.map +1 -0
- package/dist/plugins/backgroundSync/QueueStore.d.ts +75 -0
- package/dist/plugins/backgroundSync/QueueStore.d.ts.map +1 -0
- package/dist/plugins/backgroundSync/StorableRequest.d.ts +51 -0
- package/dist/plugins/backgroundSync/StorableRequest.d.ts.map +1 -0
- package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts +45 -0
- package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -0
- package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts +27 -0
- package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -0
- package/dist/plugins/broadcastUpdate/constants.d.ts +5 -0
- package/dist/plugins/broadcastUpdate/constants.d.ts.map +1 -0
- package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts +11 -0
- package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts.map +1 -0
- package/dist/plugins/broadcastUpdate/types.d.ts +34 -0
- package/dist/plugins/broadcastUpdate/types.d.ts.map +1 -0
- package/dist/plugins/cacheableResponse/CacheableResponse.d.ts +40 -0
- package/dist/plugins/cacheableResponse/CacheableResponse.d.ts.map +1 -0
- package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts +27 -0
- package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -0
- package/dist/plugins/expiration/CacheExpiration.d.ts +66 -0
- package/dist/plugins/expiration/CacheExpiration.d.ts.map +1 -0
- package/dist/plugins/expiration/ExpirationPlugin.d.ts +116 -0
- package/dist/plugins/expiration/ExpirationPlugin.d.ts.map +1 -0
- package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts +73 -0
- package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts.map +1 -0
- package/dist/plugins/googleAnalytics/constants.d.ts +10 -0
- package/dist/plugins/googleAnalytics/constants.d.ts.map +1 -0
- package/dist/plugins/googleAnalytics/initialize.d.ts +26 -0
- package/dist/plugins/googleAnalytics/initialize.d.ts.map +1 -0
- package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts +54 -0
- package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts.map +1 -0
- package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts +19 -0
- package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -0
- package/dist/plugins/rangeRequests/createPartialResponse.d.ts +18 -0
- package/dist/plugins/rangeRequests/createPartialResponse.d.ts.map +1 -0
- package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +14 -0
- package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
- package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts +12 -0
- package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -0
- package/dist/precaching/PrecacheController.d.ts +145 -0
- package/dist/precaching/PrecacheController.d.ts.map +1 -0
- package/dist/precaching/PrecacheRoute.d.ts +20 -0
- package/dist/precaching/PrecacheRoute.d.ts.map +1 -0
- package/dist/precaching/PrecacheStrategy.d.ts +68 -0
- package/dist/precaching/PrecacheStrategy.d.ts.map +1 -0
- package/dist/precaching/addPlugins.d.ts +8 -0
- package/dist/precaching/addPlugins.d.ts.map +1 -0
- package/dist/precaching/addRoute.d.ts +15 -0
- package/dist/precaching/addRoute.d.ts.map +1 -0
- package/dist/precaching/cleanupOutdatedCaches.d.ts +6 -0
- package/dist/precaching/cleanupOutdatedCaches.d.ts.map +1 -0
- package/dist/precaching/createHandlerBoundToURL.d.ts +17 -0
- package/dist/precaching/createHandlerBoundToURL.d.ts.map +1 -0
- package/dist/precaching/getCacheKeyForURL.d.ts +20 -0
- package/dist/precaching/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/precaching/matchPrecache.d.ts +14 -0
- package/dist/precaching/matchPrecache.d.ts.map +1 -0
- package/dist/precaching/precache.d.ts +19 -0
- package/dist/precaching/precache.d.ts.map +1 -0
- package/dist/precaching/precacheAndRoute.d.ts +14 -0
- package/dist/precaching/precacheAndRoute.d.ts.map +1 -0
- package/dist/precaching/types.d.ts +37 -0
- package/dist/precaching/types.d.ts.map +1 -0
- package/dist/precaching/utils/PrecacheCacheKeyPlugin.d.ts +17 -0
- package/dist/precaching/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/precaching/utils/PrecacheInstallReportPlugin.d.ts +15 -0
- package/dist/precaching/utils/PrecacheInstallReportPlugin.d.ts.map +1 -0
- package/dist/precaching/utils/createCacheKey.d.ts +16 -0
- package/dist/precaching/utils/createCacheKey.d.ts.map +1 -0
- package/dist/precaching/utils/deleteOutdatedCaches.d.ts +18 -0
- package/dist/precaching/utils/deleteOutdatedCaches.d.ts.map +1 -0
- package/dist/precaching/utils/generateURLVariations.d.ts +12 -0
- package/dist/precaching/utils/generateURLVariations.d.ts.map +1 -0
- package/dist/precaching/utils/getCacheKeyForURL.d.ts +14 -0
- package/dist/precaching/utils/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/precaching/utils/getOrCreatePrecacheController.d.ts +7 -0
- package/dist/precaching/utils/getOrCreatePrecacheController.d.ts.map +1 -0
- package/dist/precaching/utils/printCleanupDetails.d.ts +6 -0
- package/dist/precaching/utils/printCleanupDetails.d.ts.map +1 -0
- package/dist/precaching/utils/printInstallDetails.d.ts +7 -0
- package/dist/precaching/utils/printInstallDetails.d.ts.map +1 -0
- package/dist/precaching/utils/removeIgnoredSearchParams.d.ts +12 -0
- package/dist/precaching/utils/removeIgnoredSearchParams.d.ts.map +1 -0
- package/dist/routing/NavigationRoute.d.ts +57 -0
- package/dist/routing/NavigationRoute.d.ts.map +1 -0
- package/dist/routing/RegExpRoute.d.ts +24 -0
- package/dist/routing/RegExpRoute.d.ts.map +1 -0
- package/dist/routing/Route.d.ts +33 -0
- package/dist/routing/Route.d.ts.map +1 -0
- package/dist/routing/Router.d.ts +124 -0
- package/dist/routing/Router.d.ts.map +1 -0
- package/dist/routing/registerRoute.d.ts +15 -0
- package/dist/routing/registerRoute.d.ts.map +1 -0
- package/dist/routing/setCatchHandler.d.ts +9 -0
- package/dist/routing/setCatchHandler.d.ts.map +1 -0
- package/dist/routing/setDefaultHandler.d.ts +12 -0
- package/dist/routing/setDefaultHandler.d.ts.map +1 -0
- package/dist/routing/unregisterRoute.d.ts +8 -0
- package/dist/routing/unregisterRoute.d.ts.map +1 -0
- package/dist/routing/utils/constants.d.ts +15 -0
- package/dist/routing/utils/constants.d.ts.map +1 -0
- package/dist/routing/utils/getOrCreateDefaultRouter.d.ts +10 -0
- package/dist/routing/utils/getOrCreateDefaultRouter.d.ts.map +1 -0
- package/dist/routing/utils/normalizeHandler.d.ts +10 -0
- package/dist/routing/utils/normalizeHandler.d.ts.map +1 -0
- package/dist/routing/utils/parseRoute.d.ts +5 -0
- package/dist/routing/utils/parseRoute.d.ts.map +1 -0
- package/dist/strategies/CacheFirst.d.ts +23 -0
- package/dist/strategies/CacheFirst.d.ts.map +1 -0
- package/dist/strategies/CacheOnly.d.ts +20 -0
- package/dist/strategies/CacheOnly.d.ts.map +1 -0
- package/dist/strategies/NetworkFirst.d.ts +61 -0
- package/dist/strategies/NetworkFirst.d.ts.map +1 -0
- package/dist/strategies/NetworkOnly.d.ts +32 -0
- package/dist/strategies/NetworkOnly.d.ts.map +1 -0
- package/dist/strategies/StaleWhileRevalidate.d.ts +35 -0
- package/dist/strategies/StaleWhileRevalidate.d.ts.map +1 -0
- package/dist/strategies/Strategy.d.ts +83 -0
- package/dist/strategies/Strategy.d.ts.map +1 -0
- package/dist/strategies/StrategyHandler.d.ts +189 -0
- package/dist/strategies/StrategyHandler.d.ts.map +1 -0
- package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +3 -0
- package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -0
- package/dist/strategies/utils/messages.d.ts +5 -0
- package/dist/strategies/utils/messages.d.ts.map +1 -0
- package/package.json +22 -17
- package/src/{Serwist.ts → abstractions/Serwist.ts} +18 -21
- package/src/{fallbacks.ts → abstractions/fallbacks.ts} +5 -5
- package/src/{handlePrecaching.ts → abstractions/handlePrecaching.ts} +6 -3
- package/src/{installSerwist.ts → abstractions/installSerwist.ts} +2 -2
- package/src/abstractions/navigationPreload.ts +64 -0
- package/src/{registerRuntimeCaching.ts → abstractions/registerRuntimeCaching.ts} +1 -1
- package/src/{types.ts → abstractions/types.ts} +1 -1
- package/src/index.plugins.ts +65 -16
- package/src/index.precaching.ts +38 -0
- package/src/index.routing.ts +14 -0
- package/src/index.strategies.ts +22 -2
- package/src/index.ts +21 -9
- package/src/plugins/backgroundSync/BackgroundSyncPlugin.ts +39 -0
- package/src/plugins/backgroundSync/Queue.ts +438 -0
- package/src/plugins/backgroundSync/QueueDb.ts +176 -0
- package/src/plugins/backgroundSync/QueueStore.ts +161 -0
- package/src/plugins/backgroundSync/StorableRequest.ts +142 -0
- package/src/plugins/broadcastUpdate/BroadcastCacheUpdate.ts +159 -0
- package/src/plugins/broadcastUpdate/BroadcastUpdatePlugin.ts +43 -0
- package/src/plugins/broadcastUpdate/constants.ts +12 -0
- package/src/plugins/broadcastUpdate/responsesAreSame.ts +48 -0
- package/src/plugins/broadcastUpdate/types.ts +37 -0
- package/src/plugins/cacheableResponse/CacheableResponse.ts +141 -0
- package/src/plugins/cacheableResponse/CacheableResponsePlugin.ts +46 -0
- package/src/plugins/expiration/CacheExpiration.ts +192 -0
- package/src/plugins/expiration/ExpirationPlugin.ts +297 -0
- package/src/plugins/expiration/models/CacheTimestampsModel.ts +184 -0
- package/src/plugins/googleAnalytics/constants.ts +22 -0
- package/src/plugins/googleAnalytics/initialize.ts +200 -0
- package/src/plugins/precaching/PrecacheFallbackPlugin.ts +86 -0
- package/src/plugins/rangeRequests/RangeRequestsPlugin.ts +39 -0
- package/src/plugins/rangeRequests/createPartialResponse.ts +92 -0
- package/src/plugins/rangeRequests/utils/calculateEffectiveBoundaries.ts +58 -0
- package/src/plugins/rangeRequests/utils/parseRangeHeader.ts +54 -0
- package/src/precaching/PrecacheController.ts +332 -0
- package/src/precaching/PrecacheRoute.ts +50 -0
- package/src/precaching/PrecacheStrategy.ts +238 -0
- package/src/precaching/addPlugins.ts +21 -0
- package/src/precaching/addRoute.ts +30 -0
- package/src/precaching/cleanupOutdatedCaches.ts +33 -0
- package/src/precaching/createHandlerBoundToURL.ts +30 -0
- package/src/precaching/getCacheKeyForURL.ts +33 -0
- package/src/precaching/matchPrecache.ts +26 -0
- package/src/precaching/precache.ts +31 -0
- package/src/precaching/precacheAndRoute.ts +27 -0
- package/src/precaching/types.ts +46 -0
- package/src/precaching/utils/PrecacheCacheKeyPlugin.ts +36 -0
- package/src/precaching/utils/PrecacheInstallReportPlugin.ts +49 -0
- package/src/precaching/utils/createCacheKey.ts +68 -0
- package/src/precaching/utils/deleteOutdatedCaches.ts +40 -0
- package/src/precaching/utils/generateURLVariations.ts +55 -0
- package/src/precaching/utils/getCacheKeyForURL.ts +36 -0
- package/src/precaching/utils/getOrCreatePrecacheController.ts +22 -0
- package/src/precaching/utils/printCleanupDetails.ts +38 -0
- package/src/precaching/utils/printInstallDetails.ts +53 -0
- package/src/precaching/utils/removeIgnoredSearchParams.ts +29 -0
- package/src/routing/NavigationRoute.ts +119 -0
- package/src/routing/RegExpRoute.ts +74 -0
- package/src/routing/Route.ts +68 -0
- package/src/routing/Router.ts +432 -0
- package/src/routing/registerRoute.ts +33 -0
- package/src/routing/setCatchHandler.ts +22 -0
- package/src/routing/setDefaultHandler.ts +25 -0
- package/src/routing/unregisterRoute.ts +12 -0
- package/src/routing/utils/constants.ts +24 -0
- package/src/routing/utils/getOrCreateDefaultRouter.ts +29 -0
- package/src/routing/utils/normalizeHandler.ts +40 -0
- package/src/routing/utils/parseRoute.ts +67 -0
- package/src/strategies/CacheFirst.ts +87 -0
- package/src/strategies/CacheOnly.ts +58 -0
- package/src/strategies/NetworkFirst.ts +228 -0
- package/src/strategies/NetworkOnly.ts +96 -0
- package/src/strategies/StaleWhileRevalidate.ts +109 -0
- package/src/strategies/Strategy.ts +202 -0
- package/src/strategies/StrategyHandler.ts +557 -0
- package/src/strategies/plugins/cacheOkAndOpaquePlugin.ts +26 -0
- package/src/strategies/utils/messages.ts +20 -0
- package/dist/Serwist.d.ts.map +0 -1
- package/dist/disableDevLogs.d.ts.map +0 -1
- package/dist/fallbacks.d.ts.map +0 -1
- package/dist/handlePrecaching.d.ts.map +0 -1
- package/dist/installSerwist.d.ts.map +0 -1
- package/dist/registerRuntimeCaching.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{disableDevLogs.d.ts → abstractions/disableDevLogs.d.ts} +0 -0
- /package/dist/{installSerwist.d.ts → abstractions/installSerwist.d.ts} +0 -0
- /package/dist/{registerRuntimeCaching.d.ts → abstractions/registerRuntimeCaching.d.ts} +0 -0
- /package/src/{disableDevLogs.ts → abstractions/disableDevLogs.ts} +0 -0
package/src/index.plugins.ts
CHANGED
|
@@ -1,46 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { BackgroundSyncPlugin } from "./plugins/backgroundSync/BackgroundSyncPlugin.js";
|
|
2
|
+
import type { QueueEntry as BackgroundSyncQueueEntry, QueueOptions as BackgroundSyncQueueOptions } from "./plugins/backgroundSync/Queue.js";
|
|
3
|
+
import { Queue as BackgroundSyncQueue } from "./plugins/backgroundSync/Queue.js";
|
|
4
|
+
import { QueueStore as BackgroundSyncQueueStore } from "./plugins/backgroundSync/QueueStore.js";
|
|
5
|
+
import { StorableRequest } from "./plugins/backgroundSync/StorableRequest.js";
|
|
6
|
+
import { BroadcastCacheUpdate } from "./plugins/broadcastUpdate/BroadcastCacheUpdate.js";
|
|
7
|
+
import { BroadcastUpdatePlugin } from "./plugins/broadcastUpdate/BroadcastUpdatePlugin.js";
|
|
4
8
|
import {
|
|
5
|
-
BroadcastCacheUpdate,
|
|
6
|
-
BroadcastUpdatePlugin,
|
|
7
9
|
CACHE_UPDATED_MESSAGE_META as BROADCAST_UPDATE_MESSAGE_META,
|
|
8
10
|
CACHE_UPDATED_MESSAGE_TYPE as BROADCAST_UPDATE_MESSAGE_TYPE,
|
|
9
11
|
defaultHeadersToCheck as BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
10
|
-
|
|
11
|
-
} from "
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
12
|
+
} from "./plugins/broadcastUpdate/constants.js";
|
|
13
|
+
import { responsesAreSame } from "./plugins/broadcastUpdate/responsesAreSame.js";
|
|
14
|
+
import type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./plugins/broadcastUpdate/types.js";
|
|
15
|
+
import type { CacheableResponseOptions } from "./plugins/cacheableResponse/CacheableResponse.js";
|
|
16
|
+
import { CacheableResponse } from "./plugins/cacheableResponse/CacheableResponse.js";
|
|
17
|
+
import { CacheableResponsePlugin } from "./plugins/cacheableResponse/CacheableResponsePlugin.js";
|
|
18
|
+
import { CacheExpiration } from "./plugins/expiration/CacheExpiration.js";
|
|
19
|
+
import type { ExpirationPluginOptions } from "./plugins/expiration/ExpirationPlugin.js";
|
|
20
|
+
import { ExpirationPlugin } from "./plugins/expiration/ExpirationPlugin.js";
|
|
21
|
+
import type { GoogleAnalyticsInitializeOptions } from "./plugins/googleAnalytics/initialize.js";
|
|
22
|
+
import { initialize as initializeGoogleAnalytics } from "./plugins/googleAnalytics/initialize.js";
|
|
23
|
+
import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./plugins/precaching/PrecacheFallbackPlugin.js";
|
|
24
|
+
import { PrecacheFallbackPlugin } from "./plugins/precaching/PrecacheFallbackPlugin.js";
|
|
25
|
+
import { RangeRequestsPlugin } from "./plugins/rangeRequests/RangeRequestsPlugin.js";
|
|
26
|
+
import { createPartialResponse } from "./plugins/rangeRequests/createPartialResponse.js";
|
|
27
|
+
|
|
28
|
+
// See https://github.com/GoogleChrome/workbox/issues/2946
|
|
29
|
+
interface SyncManager {
|
|
30
|
+
getTags(): Promise<string[]>;
|
|
31
|
+
register(tag: string): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare global {
|
|
35
|
+
interface ServiceWorkerRegistration {
|
|
36
|
+
readonly sync: SyncManager;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SyncEvent extends ExtendableEvent {
|
|
40
|
+
readonly lastChance: boolean;
|
|
41
|
+
readonly tag: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface ServiceWorkerGlobalScopeEventMap {
|
|
45
|
+
sync: SyncEvent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
17
48
|
|
|
18
49
|
export {
|
|
50
|
+
// Background synchronization
|
|
19
51
|
BackgroundSyncPlugin,
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
BackgroundSyncQueue,
|
|
53
|
+
BackgroundSyncQueueStore,
|
|
22
54
|
StorableRequest,
|
|
55
|
+
// Update broadcasting
|
|
23
56
|
BroadcastCacheUpdate,
|
|
24
57
|
BroadcastUpdatePlugin,
|
|
25
58
|
responsesAreSame,
|
|
26
59
|
BROADCAST_UPDATE_MESSAGE_META,
|
|
27
60
|
BROADCAST_UPDATE_MESSAGE_TYPE,
|
|
28
61
|
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
62
|
+
// Cacheable responses
|
|
29
63
|
CacheableResponse,
|
|
30
64
|
CacheableResponsePlugin,
|
|
65
|
+
// Expiration
|
|
31
66
|
CacheExpiration,
|
|
32
67
|
ExpirationPlugin,
|
|
68
|
+
// Precaching
|
|
69
|
+
PrecacheFallbackPlugin,
|
|
70
|
+
// Range requests
|
|
33
71
|
createPartialResponse,
|
|
34
72
|
RangeRequestsPlugin,
|
|
73
|
+
// Google Analytics
|
|
74
|
+
initializeGoogleAnalytics,
|
|
35
75
|
};
|
|
36
76
|
|
|
37
77
|
export type {
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
// Background synchronization
|
|
79
|
+
BackgroundSyncQueueOptions,
|
|
80
|
+
BackgroundSyncQueueEntry,
|
|
81
|
+
// Update broadcasting
|
|
40
82
|
BroadcastCacheUpdateOptions,
|
|
41
83
|
BroadcastPayload,
|
|
42
84
|
BroadcastPayloadGenerator,
|
|
43
85
|
BroadcastMessage,
|
|
86
|
+
// Cacheable responses
|
|
44
87
|
CacheableResponseOptions,
|
|
88
|
+
// Expiration
|
|
45
89
|
ExpirationPluginOptions,
|
|
90
|
+
// Precaching
|
|
91
|
+
PrecacheFallbackEntry,
|
|
92
|
+
PrecacheFallbackPluginOptions,
|
|
93
|
+
// Google Analytics
|
|
94
|
+
GoogleAnalyticsInitializeOptions,
|
|
46
95
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PrecacheController } from "./precaching/PrecacheController.js";
|
|
2
|
+
import { PrecacheRoute } from "./precaching/PrecacheRoute.js";
|
|
3
|
+
import { PrecacheStrategy } from "./precaching/PrecacheStrategy.js";
|
|
4
|
+
import { addPlugins } from "./precaching/addPlugins.js";
|
|
5
|
+
import { addRoute } from "./precaching/addRoute.js";
|
|
6
|
+
import { cleanupOutdatedCaches } from "./precaching/cleanupOutdatedCaches.js";
|
|
7
|
+
import { createHandlerBoundToURL } from "./precaching/createHandlerBoundToURL.js";
|
|
8
|
+
import { getCacheKeyForURL } from "./precaching/getCacheKeyForURL.js";
|
|
9
|
+
import { matchPrecache } from "./precaching/matchPrecache.js";
|
|
10
|
+
import { precache } from "./precaching/precache.js";
|
|
11
|
+
import { precacheAndRoute } from "./precaching/precacheAndRoute.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Most consumers of this module will want to use the
|
|
15
|
+
* `@serwist/sw/precaching.precacheAndRoute`
|
|
16
|
+
* method to add assets to the cache and respond to network requests with these
|
|
17
|
+
* cached assets.
|
|
18
|
+
*
|
|
19
|
+
* If you require more control over caching and routing, you can use the
|
|
20
|
+
* `@serwist/precaching.PrecacheController`
|
|
21
|
+
* interface.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
addPlugins,
|
|
26
|
+
addRoute,
|
|
27
|
+
cleanupOutdatedCaches,
|
|
28
|
+
createHandlerBoundToURL,
|
|
29
|
+
getCacheKeyForURL,
|
|
30
|
+
matchPrecache,
|
|
31
|
+
precache,
|
|
32
|
+
precacheAndRoute,
|
|
33
|
+
PrecacheController,
|
|
34
|
+
PrecacheRoute,
|
|
35
|
+
PrecacheStrategy,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type * from "./precaching/types.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NavigationRouteMatchOptions } from "./routing/NavigationRoute.js";
|
|
2
|
+
import { NavigationRoute } from "./routing/NavigationRoute.js";
|
|
3
|
+
import { RegExpRoute } from "./routing/RegExpRoute.js";
|
|
4
|
+
import { Route } from "./routing/Route.js";
|
|
5
|
+
import { Router } from "./routing/Router.js";
|
|
6
|
+
import { registerRoute } from "./routing/registerRoute.js";
|
|
7
|
+
import { setCatchHandler } from "./routing/setCatchHandler.js";
|
|
8
|
+
import { setDefaultHandler } from "./routing/setDefaultHandler.js";
|
|
9
|
+
import { unregisterRoute } from "./routing/unregisterRoute.js";
|
|
10
|
+
import type { HTTPMethod } from "./routing/utils/constants.js";
|
|
11
|
+
|
|
12
|
+
export { NavigationRoute, RegExpRoute, registerRoute, Route, Router, setCatchHandler, setDefaultHandler, unregisterRoute };
|
|
13
|
+
|
|
14
|
+
export type { HTTPMethod, NavigationRouteMatchOptions };
|
package/src/index.strategies.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { CacheFirst } from "./strategies/CacheFirst.js";
|
|
2
|
+
import { CacheOnly } from "./strategies/CacheOnly.js";
|
|
3
|
+
import type { NetworkFirstOptions } from "./strategies/NetworkFirst.js";
|
|
4
|
+
import { NetworkFirst } from "./strategies/NetworkFirst.js";
|
|
5
|
+
import type { NetworkOnlyOptions } from "./strategies/NetworkOnly.js";
|
|
6
|
+
import { NetworkOnly } from "./strategies/NetworkOnly.js";
|
|
7
|
+
import { StaleWhileRevalidate } from "./strategies/StaleWhileRevalidate.js";
|
|
8
|
+
import type { StrategyOptions } from "./strategies/Strategy.js";
|
|
9
|
+
import { Strategy } from "./strategies/Strategy.js";
|
|
10
|
+
import { StrategyHandler } from "./strategies/StrategyHandler.js";
|
|
3
11
|
|
|
12
|
+
// See https://github.com/GoogleChrome/workbox/issues/2946
|
|
13
|
+
declare global {
|
|
14
|
+
interface FetchEvent {
|
|
15
|
+
// See https://github.com/GoogleChrome/workbox/issues/2974
|
|
16
|
+
readonly preloadResponse: Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* There are common caching strategies that most service workers will need
|
|
22
|
+
* and use. This module provides simple implementations of these strategies.
|
|
23
|
+
*/
|
|
4
24
|
export { CacheFirst, CacheOnly, NetworkFirst, NetworkOnly, StaleWhileRevalidate, Strategy, StrategyHandler };
|
|
5
25
|
|
|
6
26
|
export type { NetworkFirstOptions, NetworkOnlyOptions, StrategyOptions };
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import { Serwist, type
|
|
2
|
-
import { disableDevLogs } from "./disableDevLogs.js";
|
|
3
|
-
import type { FallbackEntry, FallbackMatcher, FallbacksOptions } from "./fallbacks.js";
|
|
4
|
-
import { fallbacks } from "./fallbacks.js";
|
|
5
|
-
import { type HandlePrecachingOptions, handlePrecaching } from "./handlePrecaching.js";
|
|
6
|
-
import { type InstallSerwistOptions, installSerwist } from "./installSerwist.js";
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import { Serwist, type SerwistInstallOptions, type SerwistOptions } from "./abstractions/Serwist.js";
|
|
2
|
+
import { disableDevLogs } from "./abstractions/disableDevLogs.js";
|
|
3
|
+
import type { FallbackEntry, FallbackMatcher, FallbacksOptions } from "./abstractions/fallbacks.js";
|
|
4
|
+
import { fallbacks } from "./abstractions/fallbacks.js";
|
|
5
|
+
import { type HandlePrecachingOptions, handlePrecaching } from "./abstractions/handlePrecaching.js";
|
|
6
|
+
import { type InstallSerwistOptions, installSerwist } from "./abstractions/installSerwist.js";
|
|
7
|
+
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./abstractions/navigationPreload.js";
|
|
8
|
+
import { registerRuntimeCaching } from "./abstractions/registerRuntimeCaching.js";
|
|
9
|
+
import type { RuntimeCaching } from "./abstractions/types.js";
|
|
9
10
|
|
|
10
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
disableDevLogs,
|
|
13
|
+
fallbacks,
|
|
14
|
+
handlePrecaching,
|
|
15
|
+
installSerwist,
|
|
16
|
+
Serwist,
|
|
17
|
+
registerRuntimeCaching,
|
|
18
|
+
// Navigation preloading
|
|
19
|
+
disableNavigationPreload,
|
|
20
|
+
enableNavigationPreload,
|
|
21
|
+
isNavigationPreloadSupported,
|
|
22
|
+
};
|
|
11
23
|
export type {
|
|
12
24
|
FallbackEntry,
|
|
13
25
|
FallbackMatcher,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2018 Google LLC
|
|
3
|
+
|
|
4
|
+
Use of this source code is governed by an MIT-style
|
|
5
|
+
license that can be found in the LICENSE file or at
|
|
6
|
+
https://opensource.org/licenses/MIT.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { FetchDidFailCallbackParam, SerwistPlugin } from "@serwist/core";
|
|
10
|
+
|
|
11
|
+
import type { QueueOptions } from "./Queue.js";
|
|
12
|
+
import { Queue } from "./Queue.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A class implementing the `fetchDidFail` lifecycle callback. This makes it
|
|
16
|
+
* easier to add failed requests to a background sync Queue.
|
|
17
|
+
*/
|
|
18
|
+
export class BackgroundSyncPlugin implements SerwistPlugin {
|
|
19
|
+
private readonly _queue: Queue;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param name See the `@serwist/sw/plugins.BackgroundSyncQueue`
|
|
23
|
+
* documentation for parameter details.
|
|
24
|
+
* @param options See the `@serwist/sw/plugins.BackgroundSyncQueue`
|
|
25
|
+
* documentation for parameter details.
|
|
26
|
+
* @see https://serwist.pages.dev/docs/background-sync/queue
|
|
27
|
+
*/
|
|
28
|
+
constructor(name: string, options?: QueueOptions) {
|
|
29
|
+
this._queue = new Queue(name, options);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param options
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
async fetchDidFail({ request }: FetchDidFailCallbackParam) {
|
|
37
|
+
await this._queue.pushRequest({ request });
|
|
38
|
+
}
|
|
39
|
+
}
|