serwist 9.0.0-preview.24
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/NavigationRoute.d.ts +57 -0
- package/dist/NavigationRoute.d.ts.map +1 -0
- package/dist/PrecacheRoute.d.ts +17 -0
- package/dist/PrecacheRoute.d.ts.map +1 -0
- package/dist/PrecacheStrategy.d.ts +66 -0
- package/dist/PrecacheStrategy.d.ts.map +1 -0
- package/dist/RegExpRoute.d.ts +24 -0
- package/dist/RegExpRoute.d.ts.map +1 -0
- package/dist/Route.d.ts +33 -0
- package/dist/Route.d.ts.map +1 -0
- package/dist/Serwist.d.ts +331 -0
- package/dist/Serwist.d.ts.map +1 -0
- package/dist/cacheNames.d.ts +20 -0
- package/dist/cacheNames.d.ts.map +1 -0
- package/dist/chunks/NetworkOnly.js +599 -0
- package/dist/chunks/PrecacheFallbackPlugin.js +634 -0
- package/dist/chunks/Serwist.js +1034 -0
- package/dist/chunks/registerQuotaErrorCallback.js +17 -0
- package/dist/chunks/resultingClientExists.js +32 -0
- package/dist/chunks/timeout.js +400 -0
- package/dist/chunks/waitUntil.js +24 -0
- package/dist/cleanupOutdatedCaches.d.ts +6 -0
- package/dist/cleanupOutdatedCaches.d.ts.map +1 -0
- package/dist/clientsClaim.d.ts +6 -0
- package/dist/clientsClaim.d.ts.map +1 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/copyResponse.d.ts +20 -0
- package/dist/copyResponse.d.ts.map +1 -0
- package/dist/disableDevLogs.d.ts +7 -0
- package/dist/disableDevLogs.d.ts.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.internal.d.ts +16 -0
- package/dist/index.internal.d.ts.map +1 -0
- package/dist/index.internal.js +24 -0
- package/dist/index.js +27 -0
- package/dist/index.legacy.d.ts +32 -0
- package/dist/index.legacy.d.ts.map +1 -0
- package/dist/index.legacy.js +640 -0
- package/dist/index.plugins.d.ts +41 -0
- package/dist/index.plugins.d.ts.map +1 -0
- package/dist/index.plugins.js +669 -0
- package/dist/index.strategies.d.ts +22 -0
- package/dist/index.strategies.d.ts.map +1 -0
- package/dist/index.strategies.js +144 -0
- package/dist/legacy/PrecacheController.d.ts +146 -0
- package/dist/legacy/PrecacheController.d.ts.map +1 -0
- package/dist/legacy/PrecacheFallbackPlugin.d.ts +62 -0
- package/dist/legacy/PrecacheFallbackPlugin.d.ts.map +1 -0
- package/dist/legacy/PrecacheRoute.d.ts +19 -0
- package/dist/legacy/PrecacheRoute.d.ts.map +1 -0
- package/dist/legacy/Router.d.ts +151 -0
- package/dist/legacy/Router.d.ts.map +1 -0
- package/dist/legacy/addPlugins.d.ts +9 -0
- package/dist/legacy/addPlugins.d.ts.map +1 -0
- package/dist/legacy/addRoute.d.ts +16 -0
- package/dist/legacy/addRoute.d.ts.map +1 -0
- package/dist/legacy/createHandlerBoundToURL.d.ts +18 -0
- package/dist/legacy/createHandlerBoundToURL.d.ts.map +1 -0
- package/dist/legacy/fallbacks.d.ts +59 -0
- package/dist/legacy/fallbacks.d.ts.map +1 -0
- package/dist/legacy/getCacheKeyForURL.d.ts +20 -0
- package/dist/legacy/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/legacy/handlePrecaching.d.ts +54 -0
- package/dist/legacy/handlePrecaching.d.ts.map +1 -0
- package/dist/legacy/installSerwist.d.ts +15 -0
- package/dist/legacy/installSerwist.d.ts.map +1 -0
- package/dist/legacy/matchPrecache.d.ts +15 -0
- package/dist/legacy/matchPrecache.d.ts.map +1 -0
- package/dist/legacy/precache.d.ts +20 -0
- package/dist/legacy/precache.d.ts.map +1 -0
- package/dist/legacy/precacheAndRoute.d.ts +15 -0
- package/dist/legacy/precacheAndRoute.d.ts.map +1 -0
- package/dist/legacy/registerRoute.d.ts +16 -0
- package/dist/legacy/registerRoute.d.ts.map +1 -0
- package/dist/legacy/registerRuntimeCaching.d.ts +11 -0
- package/dist/legacy/registerRuntimeCaching.d.ts.map +1 -0
- package/dist/legacy/setCatchHandler.d.ts +10 -0
- package/dist/legacy/setCatchHandler.d.ts.map +1 -0
- package/dist/legacy/setDefaultHandler.d.ts +13 -0
- package/dist/legacy/setDefaultHandler.d.ts.map +1 -0
- package/dist/legacy/singletonPrecacheController.d.ts +34 -0
- package/dist/legacy/singletonPrecacheController.d.ts.map +1 -0
- package/dist/legacy/singletonRouter.d.ts +41 -0
- package/dist/legacy/singletonRouter.d.ts.map +1 -0
- package/dist/legacy/unregisterRoute.d.ts +9 -0
- package/dist/legacy/unregisterRoute.d.ts.map +1 -0
- package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts +16 -0
- package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/legacy/utils/getCacheKeyForURL.d.ts +14 -0
- package/dist/legacy/utils/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/models/messages/messageGenerator.d.ts +4 -0
- package/dist/models/messages/messageGenerator.d.ts.map +1 -0
- package/dist/models/messages/messages.d.ts +44 -0
- package/dist/models/messages/messages.d.ts.map +1 -0
- package/dist/models/pluginEvents.d.ts +10 -0
- package/dist/models/pluginEvents.d.ts.map +1 -0
- package/dist/models/quotaErrorCallbacks.d.ts +3 -0
- package/dist/models/quotaErrorCallbacks.d.ts.map +1 -0
- package/dist/navigationPreload.d.ts +24 -0
- package/dist/navigationPreload.d.ts.map +1 -0
- package/dist/parseRoute.d.ts +16 -0
- package/dist/parseRoute.d.ts.map +1 -0
- 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 +30 -0
- package/dist/plugins/googleAnalytics/initialize.d.ts.map +1 -0
- package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts +53 -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/registerQuotaErrorCallback.d.ts +8 -0
- package/dist/registerQuotaErrorCallback.d.ts.map +1 -0
- package/dist/setCacheNameDetails.d.ts +9 -0
- package/dist/setCacheNameDetails.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/dist/types.d.ts +317 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/Deferred.d.ts +19 -0
- package/dist/utils/Deferred.d.ts.map +1 -0
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts +16 -0
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/utils/PrecacheInstallReportPlugin.d.ts +14 -0
- package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +1 -0
- package/dist/utils/SerwistError.d.ts +24 -0
- package/dist/utils/SerwistError.d.ts.map +1 -0
- package/dist/utils/assert.d.ts +11 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/cacheMatchIgnoreParams.d.ts +15 -0
- package/dist/utils/cacheMatchIgnoreParams.d.ts.map +1 -0
- package/dist/utils/cacheNames.d.ts +40 -0
- package/dist/utils/cacheNames.d.ts.map +1 -0
- package/dist/utils/canConstructReadableStream.d.ts +12 -0
- package/dist/utils/canConstructReadableStream.d.ts.map +1 -0
- package/dist/utils/canConstructResponseFromBodyStream.d.ts +11 -0
- package/dist/utils/canConstructResponseFromBodyStream.d.ts.map +1 -0
- package/dist/utils/createCacheKey.d.ts +16 -0
- package/dist/utils/createCacheKey.d.ts.map +1 -0
- package/dist/utils/deleteOutdatedCaches.d.ts +18 -0
- package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -0
- package/dist/utils/dontWaitFor.d.ts +7 -0
- package/dist/utils/dontWaitFor.d.ts.map +1 -0
- package/dist/utils/executeQuotaErrorCallbacks.d.ts +8 -0
- package/dist/utils/executeQuotaErrorCallbacks.d.ts.map +1 -0
- package/dist/utils/generateURLVariations.d.ts +12 -0
- package/dist/utils/generateURLVariations.d.ts.map +1 -0
- package/dist/utils/getFriendlyURL.d.ts +3 -0
- package/dist/utils/getFriendlyURL.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/normalizeHandler.d.ts +10 -0
- package/dist/utils/normalizeHandler.d.ts.map +1 -0
- package/dist/utils/pluginUtils.d.ts +5 -0
- package/dist/utils/pluginUtils.d.ts.map +1 -0
- package/dist/utils/printCleanupDetails.d.ts +6 -0
- package/dist/utils/printCleanupDetails.d.ts.map +1 -0
- package/dist/utils/printInstallDetails.d.ts +7 -0
- package/dist/utils/printInstallDetails.d.ts.map +1 -0
- package/dist/utils/removeIgnoredSearchParams.d.ts +12 -0
- package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -0
- package/dist/utils/resultingClientExists.d.ts +12 -0
- package/dist/utils/resultingClientExists.d.ts.map +1 -0
- package/dist/utils/timeout.d.ts +10 -0
- package/dist/utils/timeout.d.ts.map +1 -0
- package/dist/utils/waitUntil.d.ts +11 -0
- package/dist/utils/waitUntil.d.ts.map +1 -0
- package/dist/utils/welcome.d.ts +2 -0
- package/dist/utils/welcome.d.ts.map +1 -0
- package/package.json +85 -0
- package/src/NavigationRoute.ts +119 -0
- package/src/PrecacheRoute.ts +46 -0
- package/src/PrecacheStrategy.ts +239 -0
- package/src/RegExpRoute.ts +74 -0
- package/src/Route.ts +67 -0
- package/src/Serwist.ts +920 -0
- package/src/cacheNames.ts +39 -0
- package/src/cleanupOutdatedCaches.ts +32 -0
- package/src/clientsClaim.ts +18 -0
- package/src/constants.ts +24 -0
- package/src/copyResponse.ts +60 -0
- package/src/disableDevLogs.ts +10 -0
- package/src/index.internal.ts +33 -0
- package/src/index.legacy.ts +66 -0
- package/src/index.plugins.ts +95 -0
- package/src/index.strategies.ts +26 -0
- package/src/index.ts +39 -0
- package/src/legacy/PrecacheController.ts +337 -0
- package/src/legacy/PrecacheFallbackPlugin.ts +93 -0
- package/src/legacy/PrecacheRoute.ts +48 -0
- package/src/legacy/Router.ts +484 -0
- package/src/legacy/addPlugins.ts +21 -0
- package/src/legacy/addRoute.ts +29 -0
- package/src/legacy/createHandlerBoundToURL.ts +30 -0
- package/src/legacy/fallbacks.ts +94 -0
- package/src/legacy/getCacheKeyForURL.ts +32 -0
- package/src/legacy/handlePrecaching.ts +86 -0
- package/src/legacy/installSerwist.ts +19 -0
- package/src/legacy/matchPrecache.ts +26 -0
- package/src/legacy/precache.ts +31 -0
- package/src/legacy/precacheAndRoute.ts +28 -0
- package/src/legacy/registerRoute.ts +27 -0
- package/src/legacy/registerRuntimeCaching.ts +17 -0
- package/src/legacy/setCatchHandler.ts +21 -0
- package/src/legacy/setDefaultHandler.ts +24 -0
- package/src/legacy/singletonPrecacheController.ts +53 -0
- package/src/legacy/singletonRouter.ts +70 -0
- package/src/legacy/unregisterRoute.ts +12 -0
- package/src/legacy/utils/PrecacheCacheKeyPlugin.ts +33 -0
- package/src/legacy/utils/getCacheKeyForURL.ts +36 -0
- package/src/models/messages/messageGenerator.ts +29 -0
- package/src/models/messages/messages.ts +233 -0
- package/src/models/pluginEvents.ts +17 -0
- package/src/models/quotaErrorCallbacks.ts +13 -0
- package/src/navigationPreload.ts +68 -0
- package/src/parseRoute.ts +78 -0
- package/src/plugins/backgroundSync/BackgroundSyncPlugin.ts +38 -0
- package/src/plugins/backgroundSync/Queue.ts +440 -0
- package/src/plugins/backgroundSync/QueueDb.ts +176 -0
- package/src/plugins/backgroundSync/QueueStore.ts +160 -0
- package/src/plugins/backgroundSync/StorableRequest.ts +142 -0
- package/src/plugins/broadcastUpdate/BroadcastCacheUpdate.ts +161 -0
- package/src/plugins/broadcastUpdate/BroadcastUpdatePlugin.ts +42 -0
- package/src/plugins/broadcastUpdate/constants.ts +12 -0
- package/src/plugins/broadcastUpdate/responsesAreSame.ts +49 -0
- package/src/plugins/broadcastUpdate/types.ts +37 -0
- package/src/plugins/cacheableResponse/CacheableResponse.ts +144 -0
- package/src/plugins/cacheableResponse/CacheableResponsePlugin.ts +45 -0
- package/src/plugins/expiration/CacheExpiration.ts +193 -0
- package/src/plugins/expiration/ExpirationPlugin.ts +300 -0
- package/src/plugins/expiration/models/CacheTimestampsModel.ts +184 -0
- package/src/plugins/googleAnalytics/constants.ts +22 -0
- package/src/plugins/googleAnalytics/initialize.ts +209 -0
- package/src/plugins/precaching/PrecacheFallbackPlugin.ts +83 -0
- package/src/plugins/rangeRequests/RangeRequestsPlugin.ts +38 -0
- package/src/plugins/rangeRequests/createPartialResponse.ts +93 -0
- package/src/plugins/rangeRequests/utils/calculateEffectiveBoundaries.ts +59 -0
- package/src/plugins/rangeRequests/utils/parseRangeHeader.ts +55 -0
- package/src/registerQuotaErrorCallback.ts +34 -0
- package/src/setCacheNameDetails.ts +53 -0
- package/src/strategies/CacheFirst.ts +88 -0
- package/src/strategies/CacheOnly.ts +59 -0
- package/src/strategies/NetworkFirst.ts +229 -0
- package/src/strategies/NetworkOnly.ts +98 -0
- package/src/strategies/StaleWhileRevalidate.ts +110 -0
- package/src/strategies/Strategy.ts +204 -0
- package/src/strategies/StrategyHandler.ts +554 -0
- package/src/strategies/plugins/cacheOkAndOpaquePlugin.ts +26 -0
- package/src/strategies/utils/messages.ts +21 -0
- package/src/types.ts +358 -0
- package/src/utils/Deferred.ts +33 -0
- package/src/utils/PrecacheCacheKeyPlugin.ts +33 -0
- package/src/utils/PrecacheInstallReportPlugin.ts +47 -0
- package/src/utils/SerwistError.ts +41 -0
- package/src/utils/assert.ts +89 -0
- package/src/utils/cacheMatchIgnoreParams.ts +54 -0
- package/src/utils/cacheNames.ts +87 -0
- package/src/utils/canConstructReadableStream.ts +34 -0
- package/src/utils/canConstructResponseFromBodyStream.ts +37 -0
- package/src/utils/createCacheKey.ts +68 -0
- package/src/utils/deleteOutdatedCaches.ts +40 -0
- package/src/utils/dontWaitFor.ts +16 -0
- package/src/utils/executeQuotaErrorCallbacks.ts +33 -0
- package/src/utils/generateURLVariations.ts +55 -0
- package/src/utils/getFriendlyURL.ts +16 -0
- package/src/utils/logger.ts +95 -0
- package/src/utils/normalizeHandler.ts +40 -0
- package/src/utils/pluginUtils.ts +15 -0
- package/src/utils/printCleanupDetails.ts +38 -0
- package/src/utils/printInstallDetails.ts +53 -0
- package/src/utils/removeIgnoredSearchParams.ts +29 -0
- package/src/utils/resultingClientExists.ts +58 -0
- package/src/utils/timeout.ts +19 -0
- package/src/utils/waitUntil.ts +21 -0
- package/src/utils/welcome.ts +19 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
interface CacheExpirationConfig {
|
|
2
|
+
/**
|
|
3
|
+
* The maximum number of entries to cache. Entries used the least will
|
|
4
|
+
* be removed as the maximum is reached.
|
|
5
|
+
*/
|
|
6
|
+
maxEntries?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The maximum age of an entry before it's treated as stale and removed.
|
|
9
|
+
*/
|
|
10
|
+
maxAgeSeconds?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters)
|
|
13
|
+
* that will be used when calling `delete()` on the cache.
|
|
14
|
+
*/
|
|
15
|
+
matchOptions?: CacheQueryOptions;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Allows you to expires cached responses based on age or maximum number of entries.
|
|
19
|
+
* @see https://serwist.pages.dev/docs/expiration/cache-expiration
|
|
20
|
+
*/
|
|
21
|
+
export declare class CacheExpiration {
|
|
22
|
+
private _isRunning;
|
|
23
|
+
private _rerunRequested;
|
|
24
|
+
private readonly _maxEntries?;
|
|
25
|
+
private readonly _maxAgeSeconds?;
|
|
26
|
+
private readonly _matchOptions?;
|
|
27
|
+
private readonly _cacheName;
|
|
28
|
+
private readonly _timestampModel;
|
|
29
|
+
/**
|
|
30
|
+
* To construct a new CacheExpiration instance you must provide at least
|
|
31
|
+
* one of the `config` properties.
|
|
32
|
+
*
|
|
33
|
+
* @param cacheName Name of the cache to apply restrictions to.
|
|
34
|
+
* @param config
|
|
35
|
+
*/
|
|
36
|
+
constructor(cacheName: string, config?: CacheExpirationConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Expires entries for the given cache and given criteria.
|
|
39
|
+
*/
|
|
40
|
+
expireEntries(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Updates the timestamp for the given URL, allowing it to be correctly
|
|
43
|
+
* tracked by the class.
|
|
44
|
+
*
|
|
45
|
+
* @param url
|
|
46
|
+
*/
|
|
47
|
+
updateTimestamp(url: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a URL has expired or not before it's used.
|
|
50
|
+
*
|
|
51
|
+
* This looks the timestamp up in IndexedDB and can be slow.
|
|
52
|
+
*
|
|
53
|
+
* Note: This method does not remove an expired entry, call
|
|
54
|
+
* `expireEntries()` to remove such entries instead.
|
|
55
|
+
*
|
|
56
|
+
* @param url
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
isURLExpired(url: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Removes the IndexedDB used to keep track of cache expiration metadata.
|
|
62
|
+
*/
|
|
63
|
+
delete(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=CacheExpiration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheExpiration.d.ts","sourceRoot":"","sources":["../../../src/plugins/expiration/CacheExpiration.ts"],"names":[],"mappings":"AAaA,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAoB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IAEvD;;;;;;OAMG;gBACS,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,qBAA0B;IA2CjE;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CpC;;;;;OAKG;IACG,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAajD;;;;;;;;;;OAUG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAejD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAM9B"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { CacheDidUpdateCallbackParam, CachedResponseWillBeUsedCallbackParam, SerwistPlugin } from "../../types.js";
|
|
2
|
+
export interface ExpirationPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The maximum number of entries to cache. Entries used the least will be removed
|
|
5
|
+
* as the maximum is reached.
|
|
6
|
+
*/
|
|
7
|
+
maxEntries?: number;
|
|
8
|
+
/**
|
|
9
|
+
* The maximum number of seconds before an entry is treated as stale and removed.
|
|
10
|
+
*/
|
|
11
|
+
maxAgeSeconds?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether `maxAgeSeconds` should be calculated from when an
|
|
14
|
+
* entry was last fetched or when it was last used.
|
|
15
|
+
*
|
|
16
|
+
* @default "last-fetched"
|
|
17
|
+
*/
|
|
18
|
+
maxAgeFrom?: "last-fetched" | "last-used";
|
|
19
|
+
/**
|
|
20
|
+
* The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters)
|
|
21
|
+
* that will be used when calling `delete()` on the cache.
|
|
22
|
+
*/
|
|
23
|
+
matchOptions?: CacheQueryOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to opt this cache into automatic deletion if the available storage quota has been exceeded.
|
|
26
|
+
*/
|
|
27
|
+
purgeOnQuotaError?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This plugin can be used in a `serwist/strategies` Strategy to regularly enforce a
|
|
31
|
+
* limit on the age and/or the number of cached requests.
|
|
32
|
+
*
|
|
33
|
+
* It can only be used with Strategy instances that have a custom `cacheName` property set.
|
|
34
|
+
* In other words, it can't be used to expire entries in strategies that use the default runtime
|
|
35
|
+
* cache name.
|
|
36
|
+
*
|
|
37
|
+
* Whenever a cached response is used or updated, this plugin will look
|
|
38
|
+
* at the associated cache and remove any old or extra responses.
|
|
39
|
+
*
|
|
40
|
+
* When using `maxAgeSeconds`, responses may be used *once* after expiring
|
|
41
|
+
* because the expiration clean up will not have occurred until *after* the
|
|
42
|
+
* cached response has been used. If the response has a "Date" header, then a lightweight expiration
|
|
43
|
+
* check is performed, and the response will not be used immediately.
|
|
44
|
+
*
|
|
45
|
+
* When using `maxEntries`, the least recently requested entry will be removed
|
|
46
|
+
* from the cache.
|
|
47
|
+
*
|
|
48
|
+
* @see https://serwist.pages.dev/docs/expiration/expiration-plugin
|
|
49
|
+
*/
|
|
50
|
+
export declare class ExpirationPlugin implements SerwistPlugin {
|
|
51
|
+
private readonly _config;
|
|
52
|
+
private _cacheExpirations;
|
|
53
|
+
/**
|
|
54
|
+
* @param config
|
|
55
|
+
*/
|
|
56
|
+
constructor(config?: ExpirationPluginOptions);
|
|
57
|
+
/**
|
|
58
|
+
* A simple helper method to return a CacheExpiration instance for a given
|
|
59
|
+
* cache name.
|
|
60
|
+
*
|
|
61
|
+
* @param cacheName
|
|
62
|
+
* @returns
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private _getCacheExpiration;
|
|
66
|
+
/**
|
|
67
|
+
* A "lifecycle" callback that will be triggered automatically by the
|
|
68
|
+
* `serwist/strategies` handlers when a `Response` is about to be returned
|
|
69
|
+
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to
|
|
70
|
+
* the handler. It allows the `Response` to be inspected for freshness and
|
|
71
|
+
* prevents it from being used if the `Response`'s `Date` header value is
|
|
72
|
+
* older than the configured `maxAgeSeconds`.
|
|
73
|
+
*
|
|
74
|
+
* @param options
|
|
75
|
+
* @returns `cachedResponse` if it is fresh and `null` if it is stale or
|
|
76
|
+
* not available.
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
cachedResponseWillBeUsed({ event, cacheName, request, cachedResponse }: CachedResponseWillBeUsedCallbackParam): Response | null;
|
|
80
|
+
/**
|
|
81
|
+
* @param cachedResponse
|
|
82
|
+
* @returns
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
private _isResponseDateFresh;
|
|
86
|
+
/**
|
|
87
|
+
* Extracts the `Date` header and parse it into an useful value.
|
|
88
|
+
*
|
|
89
|
+
* @param cachedResponse
|
|
90
|
+
* @returns
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
private _getDateHeaderTimestamp;
|
|
94
|
+
/**
|
|
95
|
+
* A "lifecycle" callback that will be triggered automatically by the
|
|
96
|
+
* `serwist/strategies` handlers when an entry is added to a cache.
|
|
97
|
+
*
|
|
98
|
+
* @param options
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
cacheDidUpdate({ cacheName, request }: CacheDidUpdateCallbackParam): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Deletes the underlying `Cache` instance associated with this instance and the metadata
|
|
104
|
+
* from IndexedDB used to keep track of expiration details for each `Cache` instance.
|
|
105
|
+
*
|
|
106
|
+
* When using cache expiration, calling this method is preferable to calling
|
|
107
|
+
* `caches.delete()` directly, since this will ensure that the IndexedDB
|
|
108
|
+
* metadata is also cleanly removed and that open IndexedDB instances are deleted.
|
|
109
|
+
*
|
|
110
|
+
* Note that if you're *not* using cache expiration for a given cache, calling
|
|
111
|
+
* `caches.delete()` and passing in the cache's name should be sufficient.
|
|
112
|
+
* There is no Serwist-specific method needed for cleanup in that case.
|
|
113
|
+
*/
|
|
114
|
+
deleteCacheAndMetadata(): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=ExpirationPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpirationPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/expiration/ExpirationPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,qCAAqC,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASxH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IAC1C;;;OAGG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,iBAAiB,CAA+B;IAExD;;OAEG;gBACS,MAAM,GAAE,uBAA4B;IAkDhD;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;;;;;;;;OAYG;IACH,wBAAwB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,qCAAqC;IAqC7G;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAwB5B;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAkB/B;;;;;;OAMG;IACG,cAAc,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,2BAA2B;IAqBxE;;;;;;;;;;;OAWG;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;CAW9C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the timestamp model.
|
|
3
|
+
*
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare class CacheTimestampsModel {
|
|
7
|
+
private readonly _cacheName;
|
|
8
|
+
private _db;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param cacheName
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
constructor(cacheName: string);
|
|
16
|
+
/**
|
|
17
|
+
* Takes a URL and returns an ID that will be unique in the object store.
|
|
18
|
+
*
|
|
19
|
+
* @param url
|
|
20
|
+
* @returns
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
private _getId;
|
|
24
|
+
/**
|
|
25
|
+
* Performs an upgrade of indexedDB.
|
|
26
|
+
*
|
|
27
|
+
* @param db
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
private _upgradeDb;
|
|
32
|
+
/**
|
|
33
|
+
* Performs an upgrade of indexedDB and deletes deprecated DBs.
|
|
34
|
+
*
|
|
35
|
+
* @param db
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
private _upgradeDbAndDeleteOldDbs;
|
|
40
|
+
/**
|
|
41
|
+
* @param url
|
|
42
|
+
* @param timestamp
|
|
43
|
+
*
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
setTimestamp(url: string, timestamp: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the timestamp stored for a given URL.
|
|
49
|
+
*
|
|
50
|
+
* @param url
|
|
51
|
+
* @returns
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
getTimestamp(url: string): Promise<number | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Iterates through all the entries in the object store (from newest to
|
|
57
|
+
* oldest) and removes entries once either `maxCount` is reached or the
|
|
58
|
+
* entry's timestamp is less than `minTimestamp`.
|
|
59
|
+
*
|
|
60
|
+
* @param minTimestamp
|
|
61
|
+
* @param maxCount
|
|
62
|
+
* @returns
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
expireEntries(minTimestamp: number, maxCount?: number): Promise<string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns an open connection to the database.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private getDb;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=CacheTimestampsModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheTimestampsModel.d.ts","sourceRoot":"","sources":["../../../../src/plugins/expiration/models/CacheTimestampsModel.ts"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,GAAG,CAA4C;IAEvD;;;;;OAKG;gBACS,SAAS,EAAE,MAAM;IAI7B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM;IAId;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAYlB;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;;;;OAKG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjE;;;;;;OAMG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAM5D;;;;;;;;;OASG;IACG,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyB/E;;;;OAIG;YACW,KAAK;CAQpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const QUEUE_NAME = "serwist-google-analytics";
|
|
2
|
+
export declare const MAX_RETENTION_TIME: number;
|
|
3
|
+
export declare const GOOGLE_ANALYTICS_HOST = "www.google-analytics.com";
|
|
4
|
+
export declare const GTM_HOST = "www.googletagmanager.com";
|
|
5
|
+
export declare const ANALYTICS_JS_PATH = "/analytics.js";
|
|
6
|
+
export declare const GTAG_JS_PATH = "/gtag/js";
|
|
7
|
+
export declare const GTM_JS_PATH = "/gtm.js";
|
|
8
|
+
export declare const COLLECT_DEFAULT_PATH = "/collect";
|
|
9
|
+
export declare const COLLECT_PATHS_REGEX: RegExp;
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/plugins/googleAnalytics/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,6BAA6B,CAAC;AACrD,eAAO,MAAM,kBAAkB,QAAU,CAAC;AAC1C,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAChE,eAAO,MAAM,QAAQ,6BAA6B,CAAC;AACnD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AACjD,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAM/C,eAAO,MAAM,mBAAmB,QAAuB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Serwist } from "../../Serwist.js";
|
|
2
|
+
export interface GoogleAnalyticsInitializeOptions {
|
|
3
|
+
serwist: Serwist;
|
|
4
|
+
/**
|
|
5
|
+
* The cache name to store and retrieve analytics.js. Defaults to Serwist's default cache names.
|
|
6
|
+
*/
|
|
7
|
+
cacheName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
|
|
10
|
+
* expressed as key/value pairs, to be added to replayed Google Analytics
|
|
11
|
+
* requests. This can be used to, e.g., set a custom dimension indicating
|
|
12
|
+
* that the request was replayed.
|
|
13
|
+
*/
|
|
14
|
+
parameterOverrides?: {
|
|
15
|
+
[paramName: string]: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A function that allows you to modify the hit parameters prior to replaying
|
|
19
|
+
* the hit. The function is invoked with the original hit's URLSearchParams
|
|
20
|
+
* object as its only argument.
|
|
21
|
+
*/
|
|
22
|
+
hitFilter?: (params: URLSearchParams) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize Serwist's offline Google Analytics v3 support.
|
|
26
|
+
*
|
|
27
|
+
* @param options
|
|
28
|
+
*/
|
|
29
|
+
export declare const initialize: ({ serwist, cacheName, ...options }: GoogleAnalyticsInitializeOptions) => void;
|
|
30
|
+
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/plugins/googleAnalytics/initialize.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACrD;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAC/C;AAyID;;;;GAIG;AACH,eAAO,MAAM,UAAU,uCAAwC,gCAAgC,KAAG,IAkBjG,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { HandlerDidErrorCallbackParam, SerwistPlugin } from "../../types.js";
|
|
2
|
+
import type { Serwist } from "../../Serwist.js";
|
|
3
|
+
export interface PrecacheFallbackEntry {
|
|
4
|
+
/**
|
|
5
|
+
* A function that checks whether the fallback entry can be used
|
|
6
|
+
* for a request.
|
|
7
|
+
*/
|
|
8
|
+
matcher: (param: HandlerDidErrorCallbackParam) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A precached URL to be used as a fallback.
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PrecacheFallbackPluginOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Precached URLs to be used as the fallback
|
|
17
|
+
* if the associated strategy can't generate a response.
|
|
18
|
+
*/
|
|
19
|
+
fallbackUrls: (string | PrecacheFallbackEntry)[];
|
|
20
|
+
/**
|
|
21
|
+
* Your `Serwist` instance.
|
|
22
|
+
*/
|
|
23
|
+
serwist: Serwist;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `PrecacheFallbackPlugin` allows you to specify offline fallbacks
|
|
27
|
+
* to be used when a given strategy is unable to generate a response.
|
|
28
|
+
*
|
|
29
|
+
* It does this by intercepting the `handlerDidError` plugin callback
|
|
30
|
+
* and returning a precached response, taking the expected revision parameter
|
|
31
|
+
* into account automatically.
|
|
32
|
+
*
|
|
33
|
+
* Unless you explicitly pass in a `PrecacheController` instance to the
|
|
34
|
+
* constructor, the default instance will be used. Generally speaking, most
|
|
35
|
+
* developers will end up using the default.
|
|
36
|
+
*/
|
|
37
|
+
export declare class PrecacheFallbackPlugin implements SerwistPlugin {
|
|
38
|
+
private readonly _fallbackUrls;
|
|
39
|
+
private readonly _serwist;
|
|
40
|
+
/**
|
|
41
|
+
* Constructs a new `PrecacheFallbackPlugin` with the associated `fallbackUrls`.
|
|
42
|
+
*
|
|
43
|
+
* @param config
|
|
44
|
+
*/
|
|
45
|
+
constructor({ fallbackUrls, serwist }: PrecacheFallbackPluginOptions);
|
|
46
|
+
/**
|
|
47
|
+
* @returns The precache response for one of the fallback URLs, or `undefined` if
|
|
48
|
+
* nothing satisfies the conditions.
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
handlerDidError(param: HandlerDidErrorCallbackParam): Promise<Response | undefined>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=PrecacheFallbackPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrecacheFallbackPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/precaching/PrecacheFallbackPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,OAAO,CAAC;IAC1D;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,YAAY,EAAE,CAAC,MAAM,GAAG,qBAAqB,CAAC,EAAE,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAC1D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC;;;;OAIG;gBACS,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,6BAA6B;IAKpE;;;;OAIG;IACG,eAAe,CAAC,KAAK,EAAE,4BAA4B;CAgB1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SerwistPlugin } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The range request plugin makes it easy for a request with a 'Range' header to
|
|
4
|
+
* be fulfilled by a cached response.
|
|
5
|
+
*
|
|
6
|
+
* It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
|
|
7
|
+
* and returning the appropriate subset of the cached response body.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RangeRequestsPlugin implements SerwistPlugin {
|
|
10
|
+
/**
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns If request contains a 'Range' header, then a
|
|
13
|
+
* new response with status 206 whose body is a subset of `cachedResponse` is
|
|
14
|
+
* returned. Otherwise, `cachedResponse` is returned as-is.
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
cachedResponseWillBeUsed: SerwistPlugin["cachedResponseWillBeUsed"];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=RangeRequestsPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeRequestsPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/rangeRequests/RangeRequestsPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD;;;;;;OAMG;IACH,wBAAwB,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAUjE;CACH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a `Request` and `Response` objects as input, this will return a
|
|
3
|
+
* promise for a new `Response`.
|
|
4
|
+
*
|
|
5
|
+
* If the original `Response` already contains partial content (i.e. it has
|
|
6
|
+
* a status of 206), then this assumes it already fulfills the `Range:`
|
|
7
|
+
* requirements, and will return it as-is.
|
|
8
|
+
*
|
|
9
|
+
* @param request A request, which should contain a Range:
|
|
10
|
+
* header.
|
|
11
|
+
* @param originalResponse A response.
|
|
12
|
+
* @returns Either a `206 Partial Content` response, with
|
|
13
|
+
* the response body set to the slice of content specified by the request's
|
|
14
|
+
* `Range:` header, or a `416 Range Not Satisfiable` response if the
|
|
15
|
+
* conditions of the `Range:` header can't be met.
|
|
16
|
+
*/
|
|
17
|
+
export declare const createPartialResponse: (request: Request, originalResponse: Response) => Promise<Response>;
|
|
18
|
+
//# sourceMappingURL=createPartialResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPartialResponse.d.ts","sourceRoot":"","sources":["../../../src/plugins/rangeRequests/createPartialResponse.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,YAAmB,OAAO,oBAAoB,QAAQ,KAAG,QAAQ,QAAQ,CA8D1G,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param blob A source blob.
|
|
3
|
+
* @param start The offset to use as the start of the
|
|
4
|
+
* slice.
|
|
5
|
+
* @param end The offset to use as the end of the slice.
|
|
6
|
+
* @returns An object with `start` and `end` properties, reflecting
|
|
7
|
+
* the effective boundaries to use given the size of the blob.
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export declare const calculateEffectiveBoundaries: (blob: Blob, start?: number, end?: number) => {
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=calculateEffectiveBoundaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateEffectiveBoundaries.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rangeRequests/utils/calculateEffectiveBoundaries.ts"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,SAAU,IAAI,UAAU,MAAM,QAAQ,MAAM;WAAY,MAAM;SAAO,MAAM;CAsCnH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param rangeHeader A Range: header value.
|
|
3
|
+
* @returns An object with `start` and `end` properties, reflecting
|
|
4
|
+
* the parsed value of the Range: header. If either the `start` or `end` are
|
|
5
|
+
* omitted, then `null` will be returned.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseRangeHeader: (rangeHeader: string) => {
|
|
9
|
+
start?: number;
|
|
10
|
+
end?: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=parseRangeHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseRangeHeader.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rangeRequests/utils/parseRangeHeader.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,gBACd,MAAM,KAClB;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CAgCd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a function to the set of quotaErrorCallbacks that will be executed if
|
|
3
|
+
* there's a quota error.
|
|
4
|
+
*
|
|
5
|
+
* @param callback
|
|
6
|
+
*/
|
|
7
|
+
export declare const registerQuotaErrorCallback: (callback: Function) => void;
|
|
8
|
+
//# sourceMappingURL=registerQuotaErrorCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerQuotaErrorCallback.d.ts","sourceRoot":"","sources":["../src/registerQuotaErrorCallback.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AAEH,eAAO,MAAM,0BAA0B,aAAc,QAAQ,KAAG,IAc/D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PartialCacheNameDetails } from "./utils/cacheNames.js";
|
|
2
|
+
/**
|
|
3
|
+
* Modifies the default cache names used by Serwist packages.
|
|
4
|
+
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
|
|
5
|
+
*
|
|
6
|
+
* @param details
|
|
7
|
+
*/
|
|
8
|
+
export declare const setCacheNameDetails: (details: PartialCacheNameDetails) => void;
|
|
9
|
+
//# sourceMappingURL=setCacheNameDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setCacheNameDetails.d.ts","sourceRoot":"","sources":["../src/setCacheNameDetails.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGrE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,uBAAuB,KAAG,IAiCtE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Strategy } from "./Strategy.js";
|
|
2
|
+
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
3
|
+
/**
|
|
4
|
+
* An implementation of the [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache_first_falling_back_to_network)
|
|
5
|
+
* request strategy.
|
|
6
|
+
*
|
|
7
|
+
* A cache first strategy is useful for assets that have been revisioned,
|
|
8
|
+
* such as URLs like `/styles/example.a8f5f1.css`, since they
|
|
9
|
+
* can be cached for long periods of time.
|
|
10
|
+
*
|
|
11
|
+
* If the network request fails, and there is no cache match, this will throw
|
|
12
|
+
* a `SerwistError` exception.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CacheFirst extends Strategy {
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @param request A request to run this strategy for.
|
|
18
|
+
* @param handler The event that triggered the request.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
_handle(request: Request, handler: StrategyHandler): Promise<Response>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=CacheFirst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFirst.d.ts","sourceRoot":"","sources":["../../src/strategies/CacheFirst.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;;;;GAUG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACtC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD7E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Strategy } from "./Strategy.js";
|
|
2
|
+
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
3
|
+
/**
|
|
4
|
+
* An implementation of the [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-only)
|
|
5
|
+
* request strategy.
|
|
6
|
+
*
|
|
7
|
+
* This class is useful if you want to take advantage of any Serwist plugin.
|
|
8
|
+
*
|
|
9
|
+
* If there is no cache match, this will throw a `SerwistError` exception.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CacheOnly extends Strategy {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
* @param request A request to run this strategy for.
|
|
15
|
+
* @param handler The event that triggered the request.
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
_handle(request: Request, handler: StrategyHandler): Promise<Response>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=CacheOnly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheOnly.d.ts","sourceRoot":"","sources":["../../src/strategies/CacheOnly.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,QAAQ;IACrC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA4B7E"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { StrategyOptions } from "./Strategy.js";
|
|
2
|
+
import { Strategy } from "./Strategy.js";
|
|
3
|
+
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
4
|
+
export interface NetworkFirstOptions extends StrategyOptions {
|
|
5
|
+
/**
|
|
6
|
+
* If set, any network requests that fail to respond within the timeout will fallback to the cache.
|
|
7
|
+
*/
|
|
8
|
+
networkTimeoutSeconds?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache)
|
|
12
|
+
* request strategy.
|
|
13
|
+
*
|
|
14
|
+
* By default, this strategy will cache responses with a 200 status code as
|
|
15
|
+
* well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
|
|
16
|
+
* Opaque responses are are cross-origin requests where the response doesn't
|
|
17
|
+
* support [CORS](https://enable-cors.org/).
|
|
18
|
+
*
|
|
19
|
+
* If the network request fails, and there is no cache match, this will throw
|
|
20
|
+
* a `SerwistError` exception.
|
|
21
|
+
*/
|
|
22
|
+
export declare class NetworkFirst extends Strategy {
|
|
23
|
+
private readonly _networkTimeoutSeconds;
|
|
24
|
+
/**
|
|
25
|
+
* @param options
|
|
26
|
+
* This option can be used to combat
|
|
27
|
+
* "[lie-fi](https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi)"
|
|
28
|
+
* scenarios.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options?: NetworkFirstOptions);
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @param request A request to run this strategy for.
|
|
34
|
+
* @param handler The event that triggered the request.
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
_handle(request: Request, handler: StrategyHandler): Promise<Response>;
|
|
38
|
+
/**
|
|
39
|
+
* @param options
|
|
40
|
+
* @returns
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private _getTimeoutPromise;
|
|
44
|
+
/**
|
|
45
|
+
* @param options
|
|
46
|
+
* @param options.timeoutId
|
|
47
|
+
* @param options.request
|
|
48
|
+
* @param options.logs A reference to the logs Array.
|
|
49
|
+
* @param options.event
|
|
50
|
+
* @returns
|
|
51
|
+
*
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
_getNetworkPromise({ timeoutId, request, logs, handler, }: {
|
|
55
|
+
request: Request;
|
|
56
|
+
logs: any[];
|
|
57
|
+
timeoutId?: number;
|
|
58
|
+
handler: StrategyHandler;
|
|
59
|
+
}): Promise<Response | undefined>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=NetworkFirst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkFirst.d.ts","sourceRoot":"","sources":["../../src/strategies/NetworkFirst.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAChD;;;;;OAKG;gBACS,OAAO,GAAE,mBAAwB;IAsB7C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgE5E;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;;;;;;;OASG;IACG,kBAAkB,CAAC,EACvB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,eAAe,CAAC;KAC1B,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;CAqClC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { StrategyOptions } from "./Strategy.js";
|
|
2
|
+
import { Strategy } from "./Strategy.js";
|
|
3
|
+
import type { StrategyHandler } from "./StrategyHandler.js";
|
|
4
|
+
export interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
|
|
5
|
+
/**
|
|
6
|
+
* If set, any network requests that fail to respond within the timeout will result in a network error.
|
|
7
|
+
*/
|
|
8
|
+
networkTimeoutSeconds?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
|
|
12
|
+
* request strategy.
|
|
13
|
+
*
|
|
14
|
+
* This class is useful if you want to take advantage of any Serwist plugin.
|
|
15
|
+
*
|
|
16
|
+
* If the network request fails, this will throw a `SerwistError` exception.
|
|
17
|
+
*/
|
|
18
|
+
export declare class NetworkOnly extends Strategy {
|
|
19
|
+
private readonly _networkTimeoutSeconds;
|
|
20
|
+
/**
|
|
21
|
+
* @param options
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: NetworkOnlyOptions);
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @param request A request to run this strategy for.
|
|
27
|
+
* @param handler The event that triggered the request.
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
_handle(request: Request, handler: StrategyHandler): Promise<Response>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=NetworkOnly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkOnly.d.ts","sourceRoot":"","sources":["../../src/strategies/NetworkOnly.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,cAAc,CAAC;IAC7F;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,QAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;OAEG;gBACS,OAAO,GAAE,kBAAuB;IAM5C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA+C7E"}
|