serwist 9.1.0-preview.0 → 10.0.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NavigationRoute.d.ts.map +1 -1
- package/dist/RegExpRoute.d.ts.map +1 -1
- package/dist/Route.d.ts.map +1 -1
- package/dist/Serwist.d.ts +75 -53
- package/dist/Serwist.d.ts.map +1 -1
- package/dist/cacheNames.d.ts.map +1 -1
- package/dist/chunks/waitUntil.js +49 -42
- package/dist/copyResponse.d.ts.map +1 -1
- package/dist/index.d.ts +11 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.internal.d.ts +16 -16
- package/dist/index.internal.d.ts.map +1 -1
- package/dist/index.internal.js +25 -3
- package/dist/index.js +1918 -248
- package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts +2 -2
- package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -1
- package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -1
- package/dist/lib/backgroundSync/index.d.ts +6 -0
- package/dist/lib/backgroundSync/index.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -1
- package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts +2 -2
- package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -1
- package/dist/lib/broadcastUpdate/index.d.ts +6 -0
- package/dist/lib/broadcastUpdate/index.d.ts.map +1 -0
- package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -1
- package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts +3 -3
- package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -1
- package/dist/lib/cacheableResponse/index.d.ts +4 -0
- package/dist/lib/cacheableResponse/index.d.ts.map +1 -0
- package/dist/{legacy/utils → lib/controllers/PrecacheController}/PrecacheCacheKeyPlugin.d.ts +4 -4
- package/dist/lib/controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/{legacy → lib/controllers/PrecacheController}/PrecacheController.d.ts +77 -64
- package/dist/lib/controllers/PrecacheController/PrecacheController.d.ts.map +1 -0
- package/dist/lib/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts +14 -0
- package/dist/lib/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts.map +1 -0
- package/dist/{PrecacheRoute.d.ts → lib/controllers/PrecacheController/PrecacheRoute.d.ts} +4 -5
- package/dist/lib/controllers/PrecacheController/PrecacheRoute.d.ts.map +1 -0
- package/dist/lib/{strategies → controllers/PrecacheController}/PrecacheStrategy.d.ts +6 -6
- package/dist/lib/controllers/PrecacheController/PrecacheStrategy.d.ts.map +1 -0
- package/dist/lib/controllers/PrecacheController/parsePrecacheOptions.d.ts +25 -0
- package/dist/lib/controllers/PrecacheController/parsePrecacheOptions.d.ts.map +1 -0
- package/dist/lib/controllers/RuntimeCacheController.d.ts +70 -0
- package/dist/lib/controllers/RuntimeCacheController.d.ts.map +1 -0
- package/dist/lib/controllers/index.d.ts +4 -0
- package/dist/lib/controllers/index.d.ts.map +1 -0
- package/dist/lib/expiration/ExpirationPlugin.d.ts +2 -2
- package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -1
- package/dist/lib/expiration/index.d.ts +4 -0
- package/dist/lib/expiration/index.d.ts.map +1 -0
- package/dist/lib/googleAnalytics/index.d.ts +3 -0
- package/dist/lib/googleAnalytics/index.d.ts.map +1 -0
- package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -1
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts +15 -9
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -1
- package/dist/lib/precaching/index.d.ts +3 -0
- package/dist/lib/precaching/index.d.ts.map +1 -0
- package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts +3 -3
- package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -1
- package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -1
- package/dist/lib/rangeRequests/index.d.ts +3 -0
- package/dist/lib/rangeRequests/index.d.ts.map +1 -0
- package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -1
- package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -1
- package/dist/lib/strategies/Strategy.d.ts +3 -3
- package/dist/lib/strategies/Strategy.d.ts.map +1 -1
- package/dist/lib/strategies/StrategyHandler.d.ts +4 -4
- package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
- package/dist/lib/strategies/index.d.ts +11 -0
- package/dist/lib/strategies/index.d.ts.map +1 -0
- package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +2 -2
- package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -1
- package/dist/navigationPreload.d.ts.map +1 -1
- package/dist/registerQuotaErrorCallback.d.ts.map +1 -1
- package/dist/setCacheNameDetails.d.ts +1 -1
- package/dist/setCacheNameDetails.d.ts.map +1 -1
- package/dist/types.d.ts +35 -64
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/SerwistError.d.ts +1 -1
- package/dist/utils/SerwistError.d.ts.map +1 -1
- package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -1
- package/dist/utils/createCacheKey.d.ts.map +1 -1
- package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -1
- package/dist/utils/getFriendlyURL.d.ts.map +1 -1
- package/dist/utils/normalizeHandler.d.ts.map +1 -1
- package/dist/utils/parseRoute.d.ts.map +1 -1
- package/dist/utils/pluginUtils.d.ts +2 -2
- package/dist/utils/pluginUtils.d.ts.map +1 -1
- package/dist/utils/printCleanupDetails.d.ts.map +1 -1
- package/dist/utils/printInstallDetails.d.ts.map +1 -1
- package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -1
- package/dist/utils/waitUntil.d.ts.map +1 -1
- package/package.json +29 -13
- package/src/NavigationRoute.ts +2 -2
- package/src/RegExpRoute.ts +2 -2
- package/src/Route.ts +2 -2
- package/src/Serwist.ts +170 -271
- package/src/cacheNames.ts +1 -1
- package/src/copyResponse.ts +2 -2
- package/src/index.internal.ts +16 -16
- package/src/index.ts +68 -93
- package/src/lib/backgroundSync/BackgroundSyncPlugin.ts +2 -2
- package/src/lib/backgroundSync/BackgroundSyncQueue.ts +4 -4
- package/src/lib/backgroundSync/BackgroundSyncQueueStore.ts +1 -1
- package/src/lib/backgroundSync/StorableRequest.ts +1 -1
- package/src/lib/backgroundSync/index.ts +5 -0
- package/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts +4 -4
- package/src/lib/broadcastUpdate/BroadcastUpdatePlugin.ts +2 -2
- package/src/lib/broadcastUpdate/index.ts +5 -0
- package/src/lib/broadcastUpdate/responsesAreSame.ts +2 -2
- package/src/lib/cacheableResponse/CacheableResponse.ts +4 -4
- package/src/lib/cacheableResponse/CacheableResponsePlugin.ts +3 -3
- package/src/lib/cacheableResponse/index.ts +3 -0
- package/src/{legacy/utils → lib/controllers/PrecacheController}/PrecacheCacheKeyPlugin.ts +5 -6
- package/src/lib/controllers/PrecacheController/PrecacheController.ts +328 -0
- package/src/{utils → lib/controllers/PrecacheController}/PrecacheInstallReportPlugin.ts +5 -5
- package/src/{PrecacheRoute.ts → lib/controllers/PrecacheController/PrecacheRoute.ts} +11 -12
- package/src/lib/{strategies → controllers/PrecacheController}/PrecacheStrategy.ts +13 -13
- package/src/lib/controllers/PrecacheController/parsePrecacheOptions.ts +46 -0
- package/src/lib/controllers/RuntimeCacheController.ts +119 -0
- package/src/lib/controllers/index.ts +3 -0
- package/src/lib/expiration/CacheExpiration.ts +3 -3
- package/src/lib/expiration/ExpirationPlugin.ts +8 -8
- package/src/lib/expiration/index.ts +3 -0
- package/src/lib/googleAnalytics/index.ts +2 -0
- package/src/lib/googleAnalytics/initializeGoogleAnalytics.ts +5 -5
- package/src/lib/precaching/PrecacheFallbackPlugin.ts +23 -12
- package/src/lib/precaching/index.ts +2 -0
- package/src/lib/rangeRequests/RangeRequestsPlugin.ts +3 -3
- package/src/lib/rangeRequests/createPartialResponse.ts +3 -3
- package/src/lib/rangeRequests/index.ts +2 -0
- package/src/lib/rangeRequests/utils/calculateEffectiveBoundaries.ts +2 -2
- package/src/lib/rangeRequests/utils/parseRangeHeader.ts +2 -2
- package/src/lib/strategies/CacheFirst.ts +3 -3
- package/src/lib/strategies/CacheOnly.ts +3 -3
- package/src/lib/strategies/NetworkFirst.ts +3 -3
- package/src/lib/strategies/NetworkOnly.ts +4 -4
- package/src/lib/strategies/StaleWhileRevalidate.ts +3 -3
- package/src/lib/strategies/Strategy.ts +7 -7
- package/src/lib/strategies/StrategyHandler.ts +18 -18
- package/src/lib/strategies/index.ts +10 -0
- package/src/lib/strategies/plugins/cacheOkAndOpaquePlugin.ts +2 -2
- package/src/lib/strategies/utils/messages.ts +2 -2
- package/src/models/messages/messages.ts +3 -3
- package/src/navigationPreload.ts +1 -1
- package/src/registerQuotaErrorCallback.ts +2 -2
- package/src/setCacheNameDetails.ts +4 -4
- package/src/types.ts +56 -68
- package/src/utils/SerwistError.ts +2 -2
- package/src/utils/cacheNames.ts +1 -1
- package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
- package/src/utils/pluginUtils.ts +2 -2
- package/dist/PrecacheRoute.d.ts.map +0 -1
- package/dist/chunks/printInstallDetails.js +0 -1601
- package/dist/chunks/resultingClientExists.js +0 -32
- package/dist/index.legacy.d.ts +0 -28
- package/dist/index.legacy.d.ts.map +0 -1
- package/dist/index.legacy.js +0 -790
- package/dist/legacy/PrecacheController.d.ts.map +0 -1
- package/dist/legacy/PrecacheFallbackPlugin.d.ts +0 -61
- package/dist/legacy/PrecacheFallbackPlugin.d.ts.map +0 -1
- package/dist/legacy/PrecacheRoute.d.ts +0 -19
- package/dist/legacy/PrecacheRoute.d.ts.map +0 -1
- package/dist/legacy/Router.d.ts +0 -151
- package/dist/legacy/Router.d.ts.map +0 -1
- package/dist/legacy/addPlugins.d.ts +0 -9
- package/dist/legacy/addPlugins.d.ts.map +0 -1
- package/dist/legacy/addRoute.d.ts +0 -14
- package/dist/legacy/addRoute.d.ts.map +0 -1
- package/dist/legacy/constants.d.ts +0 -10
- package/dist/legacy/constants.d.ts.map +0 -1
- package/dist/legacy/createHandlerBoundToURL.d.ts +0 -17
- package/dist/legacy/createHandlerBoundToURL.d.ts.map +0 -1
- package/dist/legacy/fallbacks.d.ts +0 -59
- package/dist/legacy/fallbacks.d.ts.map +0 -1
- package/dist/legacy/getCacheKeyForURL.d.ts +0 -20
- package/dist/legacy/getCacheKeyForURL.d.ts.map +0 -1
- package/dist/legacy/handlePrecaching.d.ts +0 -54
- package/dist/legacy/handlePrecaching.d.ts.map +0 -1
- package/dist/legacy/initializeGoogleAnalytics.d.ts +0 -38
- package/dist/legacy/initializeGoogleAnalytics.d.ts.map +0 -1
- package/dist/legacy/installSerwist.d.ts +0 -81
- package/dist/legacy/installSerwist.d.ts.map +0 -1
- package/dist/legacy/matchPrecache.d.ts +0 -15
- package/dist/legacy/matchPrecache.d.ts.map +0 -1
- package/dist/legacy/precache.d.ts +0 -20
- package/dist/legacy/precache.d.ts.map +0 -1
- package/dist/legacy/precacheAndRoute.d.ts +0 -14
- package/dist/legacy/precacheAndRoute.d.ts.map +0 -1
- package/dist/legacy/registerRoute.d.ts +0 -16
- package/dist/legacy/registerRoute.d.ts.map +0 -1
- package/dist/legacy/registerRuntimeCaching.d.ts +0 -11
- package/dist/legacy/registerRuntimeCaching.d.ts.map +0 -1
- package/dist/legacy/setCatchHandler.d.ts +0 -10
- package/dist/legacy/setCatchHandler.d.ts.map +0 -1
- package/dist/legacy/setDefaultHandler.d.ts +0 -13
- package/dist/legacy/setDefaultHandler.d.ts.map +0 -1
- package/dist/legacy/singletonPrecacheController.d.ts +0 -34
- package/dist/legacy/singletonPrecacheController.d.ts.map +0 -1
- package/dist/legacy/singletonRouter.d.ts +0 -41
- package/dist/legacy/singletonRouter.d.ts.map +0 -1
- package/dist/legacy/unregisterRoute.d.ts +0 -9
- package/dist/legacy/unregisterRoute.d.ts.map +0 -1
- package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
- package/dist/legacy/utils/getCacheKeyForURL.d.ts +0 -14
- package/dist/legacy/utils/getCacheKeyForURL.d.ts.map +0 -1
- package/dist/lib/strategies/PrecacheStrategy.d.ts.map +0 -1
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts +0 -16
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
- package/dist/utils/PrecacheInstallReportPlugin.d.ts +0 -14
- package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +0 -1
- package/dist/utils/parsePrecacheOptions.d.ts +0 -26
- package/dist/utils/parsePrecacheOptions.d.ts.map +0 -1
- package/src/index.legacy.ts +0 -62
- package/src/legacy/PrecacheController.ts +0 -337
- package/src/legacy/PrecacheFallbackPlugin.ts +0 -92
- package/src/legacy/PrecacheRoute.ts +0 -48
- package/src/legacy/Router.ts +0 -484
- package/src/legacy/addPlugins.ts +0 -21
- package/src/legacy/addRoute.ts +0 -27
- package/src/legacy/constants.ts +0 -22
- package/src/legacy/createHandlerBoundToURL.ts +0 -30
- package/src/legacy/fallbacks.ts +0 -94
- package/src/legacy/getCacheKeyForURL.ts +0 -32
- package/src/legacy/handlePrecaching.ts +0 -86
- package/src/legacy/initializeGoogleAnalytics.ts +0 -218
- package/src/legacy/installSerwist.ts +0 -170
- package/src/legacy/matchPrecache.ts +0 -27
- package/src/legacy/precache.ts +0 -33
- package/src/legacy/precacheAndRoute.ts +0 -27
- package/src/legacy/registerRoute.ts +0 -28
- package/src/legacy/registerRuntimeCaching.ts +0 -17
- package/src/legacy/setCatchHandler.ts +0 -21
- package/src/legacy/setDefaultHandler.ts +0 -24
- package/src/legacy/singletonPrecacheController.ts +0 -53
- package/src/legacy/singletonRouter.ts +0 -70
- package/src/legacy/unregisterRoute.ts +0 -13
- package/src/legacy/utils/getCacheKeyForURL.ts +0 -36
- package/src/utils/PrecacheCacheKeyPlugin.ts +0 -33
- package/src/utils/parsePrecacheOptions.ts +0 -47
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
|
|
2
2
|
import { NavigationRoute } from "./NavigationRoute.js";
|
|
3
|
-
import { PrecacheRoute } from "./PrecacheRoute.js";
|
|
4
3
|
import { RegExpRoute } from "./RegExpRoute.js";
|
|
5
4
|
import { Route } from "./Route.js";
|
|
6
5
|
import { Serwist, type SerwistOptions } from "./Serwist.js";
|
|
@@ -8,118 +7,94 @@ import { cacheNames } from "./cacheNames.js";
|
|
|
8
7
|
import type { HTTPMethod } from "./constants.js";
|
|
9
8
|
import { copyResponse } from "./copyResponse.js";
|
|
10
9
|
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
10
|
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
|
|
45
11
|
import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
|
|
46
12
|
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
47
13
|
|
|
14
|
+
// Background synchronizing
|
|
48
15
|
export {
|
|
49
|
-
// Core
|
|
50
|
-
Serwist,
|
|
51
|
-
cacheNames,
|
|
52
|
-
copyResponse,
|
|
53
|
-
disableDevLogs,
|
|
54
|
-
disableNavigationPreload,
|
|
55
|
-
enableNavigationPreload,
|
|
56
|
-
isNavigationPreloadSupported,
|
|
57
|
-
registerQuotaErrorCallback,
|
|
58
|
-
setCacheNameDetails,
|
|
59
|
-
// Caching strategies
|
|
60
|
-
CacheFirst,
|
|
61
|
-
CacheOnly,
|
|
62
|
-
NetworkFirst,
|
|
63
|
-
NetworkOnly,
|
|
64
|
-
PrecacheStrategy,
|
|
65
|
-
StaleWhileRevalidate,
|
|
66
|
-
Strategy,
|
|
67
|
-
StrategyHandler,
|
|
68
|
-
// Routing
|
|
69
|
-
NavigationRoute,
|
|
70
|
-
PrecacheRoute,
|
|
71
|
-
RegExpRoute,
|
|
72
|
-
Route,
|
|
73
|
-
// Background synchronizing
|
|
74
16
|
BackgroundSyncPlugin,
|
|
75
17
|
BackgroundSyncQueue,
|
|
76
18
|
BackgroundSyncQueueStore,
|
|
77
19
|
StorableRequest,
|
|
78
|
-
|
|
20
|
+
type BackgroundSyncQueueOptions,
|
|
21
|
+
type BackgroundSyncQueueEntry,
|
|
22
|
+
} from "#lib/backgroundSync/index.js";
|
|
23
|
+
|
|
24
|
+
// Broadcasting updates
|
|
25
|
+
export {
|
|
79
26
|
BroadcastCacheUpdate,
|
|
80
27
|
BroadcastUpdatePlugin,
|
|
81
28
|
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
82
29
|
responsesAreSame,
|
|
83
|
-
|
|
30
|
+
type BroadcastCacheUpdateOptions,
|
|
31
|
+
type BroadcastPayload,
|
|
32
|
+
type BroadcastPayloadGenerator,
|
|
33
|
+
type BroadcastMessage,
|
|
34
|
+
} from "#lib/broadcastUpdate/index.js";
|
|
35
|
+
|
|
36
|
+
// Setting cacheability criteria
|
|
37
|
+
export {
|
|
84
38
|
CacheableResponse,
|
|
85
39
|
CacheableResponsePlugin,
|
|
86
|
-
|
|
40
|
+
type CacheableResponseOptions,
|
|
41
|
+
} from "#lib/cacheableResponse/index.js";
|
|
42
|
+
|
|
43
|
+
// Controllers
|
|
44
|
+
export { PrecacheStrategy, PrecacheRoute, RuntimeCacheController } from "#lib/controllers/index.js";
|
|
45
|
+
|
|
46
|
+
// Expiring outdated responses
|
|
47
|
+
export {
|
|
87
48
|
CacheExpiration,
|
|
88
49
|
ExpirationPlugin,
|
|
89
|
-
|
|
50
|
+
type ExpirationPluginOptions,
|
|
51
|
+
} from "#lib/expiration/index.js";
|
|
52
|
+
|
|
53
|
+
// Google Analytics
|
|
54
|
+
export { initializeGoogleAnalytics, type GoogleAnalyticsInitializeOptions } from "#lib/googleAnalytics/index.js";
|
|
55
|
+
|
|
56
|
+
// Precaching
|
|
57
|
+
export {
|
|
90
58
|
PrecacheFallbackPlugin,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
59
|
+
type PrecacheFallbackEntry,
|
|
60
|
+
type PrecacheFallbackPluginOptions,
|
|
61
|
+
} from "#lib/precaching/index.js";
|
|
62
|
+
|
|
63
|
+
// Handling range requests
|
|
64
|
+
export {
|
|
94
65
|
createPartialResponse,
|
|
95
66
|
RangeRequestsPlugin,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
67
|
+
} from "#lib/rangeRequests/index.js";
|
|
68
|
+
|
|
69
|
+
// Built-in caching strategies
|
|
70
|
+
export {
|
|
71
|
+
CacheFirst,
|
|
72
|
+
CacheOnly,
|
|
73
|
+
NetworkFirst,
|
|
74
|
+
NetworkOnly,
|
|
75
|
+
StaleWhileRevalidate,
|
|
76
|
+
Strategy,
|
|
77
|
+
StrategyHandler,
|
|
78
|
+
type NetworkFirstOptions,
|
|
79
|
+
type NetworkOnlyOptions,
|
|
80
|
+
type StrategyOptions,
|
|
81
|
+
} from "#lib/strategies/index.js";
|
|
82
|
+
|
|
83
|
+
// Core
|
|
84
|
+
export {
|
|
85
|
+
Serwist,
|
|
86
|
+
cacheNames,
|
|
87
|
+
copyResponse,
|
|
88
|
+
disableDevLogs,
|
|
89
|
+
disableNavigationPreload,
|
|
90
|
+
enableNavigationPreload,
|
|
91
|
+
isNavigationPreloadSupported,
|
|
92
|
+
registerQuotaErrorCallback,
|
|
93
|
+
setCacheNameDetails,
|
|
105
94
|
// Routing
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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,
|
|
95
|
+
NavigationRoute,
|
|
96
|
+
RegExpRoute,
|
|
97
|
+
Route,
|
|
124
98
|
};
|
|
99
|
+
export type { HTTPMethod, SerwistOptions, NavigationRouteMatchOptions };
|
|
125
100
|
export type * from "./types.js";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { FetchDidFailCallbackParam,
|
|
9
|
+
import type { FetchDidFailCallbackParam, StrategyPlugin } from "../../types.js";
|
|
10
10
|
import type { BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
|
|
11
11
|
import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
|
|
|
14
14
|
* A class implementing the `fetchDidFail` lifecycle callback. This makes it
|
|
15
15
|
* easier to add failed requests to a {@linkcode BackgroundSyncQueue}.
|
|
16
16
|
*/
|
|
17
|
-
export class BackgroundSyncPlugin implements
|
|
17
|
+
export class BackgroundSyncPlugin implements StrategyPlugin {
|
|
18
18
|
private readonly _queue: BackgroundSyncQueue;
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SerwistError } from "../../utils/SerwistError.js";
|
|
2
1
|
/*
|
|
3
2
|
Copyright 2018 Google LLC
|
|
4
3
|
|
|
@@ -6,9 +5,10 @@ import { SerwistError } from "../../utils/SerwistError.js";
|
|
|
6
5
|
license that can be found in the LICENSE file or at
|
|
7
6
|
https://opensource.org/licenses/MIT.
|
|
8
7
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
11
|
+
import { logger } from "#utils/logger.js";
|
|
12
12
|
import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
|
|
13
13
|
import { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
|
|
14
14
|
import { StorableRequest } from "./StorableRequest.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
import { assert } from "
|
|
8
|
+
import { assert } from "#utils/assert.js";
|
|
9
9
|
import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
|
|
10
10
|
import { BackgroundSyncQueueDb } from "./BackgroundSyncQueueDb.js";
|
|
11
11
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
9
10
|
import type { MapLikeObject } from "../../types.js";
|
|
10
|
-
import { assert } from "../../utils/assert.js";
|
|
11
11
|
|
|
12
12
|
type SerializableProperties = "method" | "referrer" | "referrerPolicy" | "mode" | "credentials" | "cache" | "redirect" | "integrity" | "keepalive";
|
|
13
13
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BackgroundSyncPlugin } from "./BackgroundSyncPlugin.js";
|
|
2
|
+
export type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
|
|
3
|
+
export { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
|
|
4
|
+
export { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
|
|
5
|
+
export { StorableRequest } from "./StorableRequest.js";
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { assert } from "#utils/assert.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
11
|
+
import { resultingClientExists } from "#utils/resultingClientExists.js";
|
|
12
|
+
import { timeout } from "#utils/timeout.js";
|
|
9
13
|
import type { CacheDidUpdateCallbackParam } from "../../types.js";
|
|
10
|
-
import { assert } from "../../utils/assert.js";
|
|
11
|
-
import { logger } from "../../utils/logger.js";
|
|
12
|
-
import { resultingClientExists } from "../../utils/resultingClientExists.js";
|
|
13
|
-
import { timeout } from "../../utils/timeout.js";
|
|
14
14
|
import {
|
|
15
15
|
BROADCAST_UPDATE_DEFAULT_HEADERS,
|
|
16
16
|
BROADCAST_UPDATE_DEFAULT_NOTIFY,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { CacheDidUpdateCallbackParam,
|
|
9
|
+
import type { CacheDidUpdateCallbackParam, StrategyPlugin } from "../../types.js";
|
|
10
10
|
import { BroadcastCacheUpdate } from "./BroadcastCacheUpdate.js";
|
|
11
11
|
import type { BroadcastCacheUpdateOptions } from "./types.js";
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ import type { BroadcastCacheUpdateOptions } from "./types.js";
|
|
|
14
14
|
* A class implementing the `cacheDidUpdate` lifecycle callback. It will automatically
|
|
15
15
|
* broadcast a message whenever a cached response is updated.
|
|
16
16
|
*/
|
|
17
|
-
export class BroadcastUpdatePlugin implements
|
|
17
|
+
export class BroadcastUpdatePlugin implements StrategyPlugin {
|
|
18
18
|
private readonly _broadcastUpdate: BroadcastCacheUpdate;
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BroadcastCacheUpdate } from "./BroadcastCacheUpdate.js";
|
|
2
|
+
export { BroadcastUpdatePlugin } from "./BroadcastUpdatePlugin.js";
|
|
3
|
+
export { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./constants.js";
|
|
4
|
+
export { responsesAreSame } from "./responsesAreSame.js";
|
|
5
|
+
export type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./types.js";
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "
|
|
10
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
10
|
+
import { logger } from "#utils/logger.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Given two responses, compares several header values to see if they are
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SerwistError } from "
|
|
10
|
-
import { assert } from "
|
|
11
|
-
import { getFriendlyURL } from "
|
|
12
|
-
import { logger } from "
|
|
9
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
10
|
+
import { assert } from "#utils/assert.js";
|
|
11
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
12
|
+
import { logger } from "#utils/logger.js";
|
|
13
13
|
|
|
14
14
|
export interface CacheableResponseOptions {
|
|
15
15
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { StrategyPlugin } from "../../types.js";
|
|
10
10
|
import type { CacheableResponseOptions } from "./CacheableResponse.js";
|
|
11
11
|
import { CacheableResponse } from "./CacheableResponse.js";
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ import { CacheableResponse } from "./CacheableResponse.js";
|
|
|
15
15
|
* easier to add in cacheability checks to requests made via Serwist's built-in
|
|
16
16
|
* strategies.
|
|
17
17
|
*/
|
|
18
|
-
export class CacheableResponsePlugin implements
|
|
18
|
+
export class CacheableResponsePlugin implements StrategyPlugin {
|
|
19
19
|
private readonly _cacheableResponse: CacheableResponse;
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -36,7 +36,7 @@ export class CacheableResponsePlugin implements SerwistPlugin {
|
|
|
36
36
|
* @returns
|
|
37
37
|
* @private
|
|
38
38
|
*/
|
|
39
|
-
cacheWillUpdate:
|
|
39
|
+
cacheWillUpdate: StrategyPlugin["cacheWillUpdate"] = async ({ response }) => {
|
|
40
40
|
if (this._cacheableResponse.isResponseCacheable(response)) {
|
|
41
41
|
return response;
|
|
42
42
|
}
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
import type { PrecacheController } from "../PrecacheController.js";
|
|
8
|
+
import type { StrategyPlugin, StrategyPluginCallbackParam } from "../../../types.js";
|
|
9
|
+
import type { PrecacheController } from "./PrecacheController.js";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* A plugin, designed to be used with PrecacheController, to translate URLs into
|
|
@@ -15,17 +14,17 @@ import type { PrecacheController } from "../PrecacheController.js";
|
|
|
15
14
|
*
|
|
16
15
|
* @private
|
|
17
16
|
*/
|
|
18
|
-
export class PrecacheCacheKeyPlugin implements
|
|
17
|
+
export class PrecacheCacheKeyPlugin implements StrategyPlugin {
|
|
19
18
|
private readonly _precacheController: PrecacheController;
|
|
20
19
|
|
|
21
20
|
constructor({ precacheController }: { precacheController: PrecacheController }) {
|
|
22
21
|
this._precacheController = precacheController;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
cacheKeyWillBeUsed:
|
|
24
|
+
cacheKeyWillBeUsed: StrategyPlugin["cacheKeyWillBeUsed"] = async ({ request, params }: StrategyPluginCallbackParam["cacheKeyWillBeUsed"]) => {
|
|
26
25
|
// Params is type any, can't change right now.
|
|
27
26
|
/* eslint-disable */
|
|
28
|
-
const cacheKey = params?.cacheKey || this._precacheController.
|
|
27
|
+
const cacheKey = params?.cacheKey || this._precacheController.getPrecacheKeyForUrl(request.url);
|
|
29
28
|
/* eslint-enable */
|
|
30
29
|
|
|
31
30
|
return cacheKey ? new Request(cacheKey, { headers: request.headers }) : request;
|