serwist 9.1.1 → 10.0.0-preview.10
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/chunks/waitUntil.js +141 -134
- package/dist/index.d.ts +22 -49
- 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 +2231 -452
- package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncPlugin.d.ts +2 -2
- package/dist/lib/background-sync/BackgroundSyncPlugin.d.ts.map +1 -0
- package/dist/lib/background-sync/BackgroundSyncQueue.d.ts.map +1 -0
- package/dist/lib/background-sync/BackgroundSyncQueueDb.d.ts.map +1 -0
- package/dist/lib/background-sync/BackgroundSyncQueueStore.d.ts.map +1 -0
- package/dist/lib/{backgroundSync → background-sync}/StorableRequest.d.ts +1 -1
- package/dist/lib/background-sync/StorableRequest.d.ts.map +1 -0
- package/dist/lib/background-sync/index.d.ts +6 -0
- package/dist/lib/background-sync/index.d.ts.map +1 -0
- package/dist/lib/{broadcastUpdate → broadcast-update}/BroadcastCacheUpdate.d.ts +1 -1
- package/dist/lib/broadcast-update/BroadcastCacheUpdate.d.ts.map +1 -0
- package/dist/lib/{broadcastUpdate → broadcast-update}/BroadcastUpdatePlugin.d.ts +2 -2
- package/dist/lib/broadcast-update/BroadcastUpdatePlugin.d.ts.map +1 -0
- package/dist/lib/broadcast-update/constants.d.ts.map +1 -0
- package/dist/lib/broadcast-update/index.d.ts +6 -0
- package/dist/lib/broadcast-update/index.d.ts.map +1 -0
- package/dist/lib/broadcast-update/responsesAreSame.d.ts.map +1 -0
- package/dist/lib/{broadcastUpdate → broadcast-update}/types.d.ts +1 -1
- package/dist/lib/broadcast-update/types.d.ts.map +1 -0
- package/dist/{cacheNames.d.ts → lib/cache-name.d.ts} +1 -1
- package/dist/lib/cache-name.d.ts.map +1 -0
- package/dist/lib/cacheable-response/CacheableResponse.d.ts.map +1 -0
- package/dist/lib/{cacheableResponse → cacheable-response}/CacheableResponsePlugin.d.ts +3 -3
- package/dist/lib/cacheable-response/CacheableResponsePlugin.d.ts.map +1 -0
- package/dist/lib/cacheable-response/index.d.ts +4 -0
- package/dist/lib/cacheable-response/index.d.ts.map +1 -0
- package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/core.d.ts +62 -0
- package/dist/lib/core.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/extension.d.ts +30 -0
- package/dist/lib/extension.d.ts.map +1 -0
- package/dist/lib/extensions/google-analytics/constants.d.ts.map +1 -0
- package/dist/lib/extensions/google-analytics/extension.d.ts +79 -0
- package/dist/lib/extensions/google-analytics/extension.d.ts.map +1 -0
- package/dist/lib/extensions/google-analytics/index.d.ts +2 -0
- package/dist/lib/extensions/google-analytics/index.d.ts.map +1 -0
- package/dist/lib/extensions/google-analytics/initialize.d.ts +12 -0
- package/dist/lib/extensions/google-analytics/initialize.d.ts.map +1 -0
- package/dist/lib/extensions/index.d.ts +14 -0
- package/dist/lib/extensions/index.d.ts.map +1 -0
- package/dist/{legacy/PrecacheController.d.ts → lib/extensions/precache/extension.d.ts} +56 -66
- package/dist/lib/extensions/precache/extension.d.ts.map +1 -0
- package/dist/lib/extensions/precache/options.d.ts +26 -0
- package/dist/lib/extensions/precache/options.d.ts.map +1 -0
- package/dist/lib/extensions/precache/plugin-cache-key.d.ts +16 -0
- package/dist/lib/extensions/precache/plugin-cache-key.d.ts.map +1 -0
- package/dist/lib/{precaching/PrecacheFallbackPlugin.d.ts → extensions/precache/plugin-fallback.d.ts} +4 -4
- package/dist/lib/extensions/precache/plugin-fallback.d.ts.map +1 -0
- package/dist/lib/extensions/precache/plugin-install-report.d.ts +14 -0
- package/dist/lib/extensions/precache/plugin-install-report.d.ts.map +1 -0
- package/dist/lib/extensions/precache/route.d.ts +42 -0
- package/dist/lib/extensions/precache/route.d.ts.map +1 -0
- package/dist/lib/{strategies/PrecacheStrategy.d.ts → extensions/precache/strategy.d.ts} +7 -7
- package/dist/lib/extensions/precache/strategy.d.ts.map +1 -0
- package/dist/lib/extensions/runtime-cache.d.ts +71 -0
- package/dist/lib/extensions/runtime-cache.d.ts.map +1 -0
- package/dist/lib/functions/handlers.d.ts +60 -0
- package/dist/lib/functions/handlers.d.ts.map +1 -0
- package/dist/lib/functions/router.d.ts +60 -0
- package/dist/lib/functions/router.d.ts.map +1 -0
- package/dist/{navigationPreload.d.ts → lib/navigation-preload.d.ts} +1 -1
- package/dist/lib/navigation-preload.d.ts.map +1 -0
- package/dist/lib/{rangeRequests → range-requests}/RangeRequestsPlugin.d.ts +3 -3
- package/dist/lib/range-requests/RangeRequestsPlugin.d.ts.map +1 -0
- package/dist/lib/range-requests/createPartialResponse.d.ts.map +1 -0
- package/dist/lib/range-requests/index.d.ts +3 -0
- package/dist/lib/range-requests/index.d.ts.map +1 -0
- package/dist/lib/range-requests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
- package/dist/lib/range-requests/utils/parseRangeHeader.d.ts.map +1 -0
- package/dist/lib/route.d.ts +106 -0
- package/dist/lib/route.d.ts.map +1 -0
- package/dist/{Serwist.d.ts → lib/serwist.d.ts} +71 -62
- package/dist/lib/serwist.d.ts.map +1 -0
- package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -1
- package/dist/lib/strategies/StaleWhileRevalidate.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/{types.d.ts → lib/types.d.ts} +7 -65
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/{copyResponse.d.ts → lib/utils.d.ts} +22 -1
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/models/messages/messageGenerator.d.ts +1 -1
- package/dist/models/messages/messageGenerator.d.ts.map +1 -1
- package/dist/utils/SerwistError.d.ts +2 -2
- package/dist/utils/SerwistError.d.ts.map +1 -1
- package/dist/utils/assert.d.ts +1 -1
- package/dist/utils/assert.d.ts.map +1 -1
- package/dist/utils/createCacheKey.d.ts +1 -1
- package/dist/utils/createCacheKey.d.ts.map +1 -1
- package/dist/utils/generateURLVariations.d.ts +1 -1
- package/dist/utils/generateURLVariations.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/normalizeHandler.d.ts +1 -1
- package/dist/utils/normalizeHandler.d.ts.map +1 -1
- package/dist/utils/parseRoute.d.ts +3 -3
- 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/package.json +28 -11
- package/src/index.internal.ts +16 -16
- package/src/index.ts +100 -107
- package/src/lib/{backgroundSync → background-sync}/BackgroundSyncPlugin.ts +2 -2
- package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueue.ts +4 -4
- package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueueStore.ts +1 -1
- package/src/lib/{backgroundSync → background-sync}/StorableRequest.ts +2 -2
- package/src/lib/background-sync/index.ts +5 -0
- package/src/lib/{broadcastUpdate → broadcast-update}/BroadcastCacheUpdate.ts +5 -5
- package/src/lib/{broadcastUpdate → broadcast-update}/BroadcastUpdatePlugin.ts +2 -2
- package/src/lib/broadcast-update/index.ts +5 -0
- package/src/lib/{broadcastUpdate → broadcast-update}/responsesAreSame.ts +2 -2
- package/src/lib/{broadcastUpdate → broadcast-update}/types.ts +1 -1
- package/src/{cacheNames.ts → lib/cache-name.ts} +1 -1
- package/src/lib/{cacheableResponse → cacheable-response}/CacheableResponse.ts +4 -4
- package/src/lib/{cacheableResponse → cacheable-response}/CacheableResponsePlugin.ts +3 -3
- package/src/lib/cacheable-response/index.ts +3 -0
- package/src/lib/core.ts +128 -0
- package/src/lib/expiration/CacheExpiration.ts +3 -3
- package/src/lib/expiration/ExpirationPlugin.ts +9 -10
- package/src/lib/expiration/index.ts +3 -0
- package/src/lib/extension.ts +37 -0
- package/src/lib/{googleAnalytics/initializeGoogleAnalytics.ts → extensions/google-analytics/extension.ts} +42 -48
- package/src/lib/extensions/google-analytics/index.ts +0 -0
- package/src/lib/extensions/google-analytics/initialize.ts +48 -0
- package/src/lib/extensions/index.ts +13 -0
- package/src/lib/extensions/precache/extension.ts +306 -0
- package/src/lib/extensions/precache/options.ts +49 -0
- package/src/{legacy/utils/PrecacheCacheKeyPlugin.ts → lib/extensions/precache/plugin-cache-key.ts} +7 -8
- package/src/lib/{precaching/PrecacheFallbackPlugin.ts → extensions/precache/plugin-fallback.ts} +19 -8
- package/src/{utils/PrecacheInstallReportPlugin.ts → lib/extensions/precache/plugin-install-report.ts} +5 -5
- package/src/lib/extensions/precache/route.ts +72 -0
- package/src/lib/{strategies/PrecacheStrategy.ts → extensions/precache/strategy.ts} +12 -12
- package/src/lib/extensions/runtime-cache.ts +126 -0
- package/src/lib/functions/handlers.ts +149 -0
- package/src/lib/functions/router.ts +314 -0
- package/src/{navigationPreload.ts → lib/navigation-preload.ts} +1 -1
- package/src/lib/{rangeRequests → range-requests}/RangeRequestsPlugin.ts +3 -3
- package/src/lib/{rangeRequests → range-requests}/createPartialResponse.ts +3 -3
- package/src/lib/range-requests/index.ts +2 -0
- package/src/lib/{rangeRequests → range-requests}/utils/calculateEffectiveBoundaries.ts +2 -2
- package/src/lib/{rangeRequests → range-requests}/utils/parseRangeHeader.ts +2 -2
- package/src/lib/route.ts +234 -0
- package/src/lib/serwist.ts +443 -0
- package/src/lib/strategies/CacheFirst.ts +3 -3
- package/src/lib/strategies/CacheOnly.ts +3 -3
- package/src/lib/strategies/NetworkFirst.ts +4 -4
- package/src/lib/strategies/NetworkOnly.ts +4 -4
- package/src/lib/strategies/StaleWhileRevalidate.ts +4 -4
- 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/{types.ts → lib/types.ts} +17 -70
- package/src/lib/utils.ts +137 -0
- package/src/models/messages/messageGenerator.ts +1 -1
- package/src/models/messages/messages.ts +3 -3
- package/src/utils/SerwistError.ts +3 -3
- package/src/utils/assert.ts +1 -1
- package/src/utils/createCacheKey.ts +1 -2
- package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
- package/src/utils/generateURLVariations.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/src/utils/normalizeHandler.ts +1 -1
- package/src/utils/parseRoute.ts +4 -5
- package/src/utils/pluginUtils.ts +2 -2
- package/dist/NavigationRoute.d.ts +0 -56
- package/dist/NavigationRoute.d.ts.map +0 -1
- package/dist/PrecacheRoute.d.ts +0 -16
- package/dist/PrecacheRoute.d.ts.map +0 -1
- package/dist/RegExpRoute.d.ts +0 -24
- package/dist/RegExpRoute.d.ts.map +0 -1
- package/dist/Route.d.ts +0 -33
- package/dist/Route.d.ts.map +0 -1
- package/dist/Serwist.d.ts.map +0 -1
- package/dist/cacheNames.d.ts.map +0 -1
- package/dist/chunks/printInstallDetails.js +0 -1601
- package/dist/chunks/resultingClientExists.js +0 -32
- package/dist/constants.d.ts.map +0 -1
- package/dist/copyResponse.d.ts.map +0 -1
- package/dist/disableDevLogs.d.ts +0 -7
- package/dist/disableDevLogs.d.ts.map +0 -1
- 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.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 +0 -16
- 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/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
- package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +0 -1
- package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +0 -1
- package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +0 -1
- package/dist/lib/backgroundSync/StorableRequest.d.ts.map +0 -1
- package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
- package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
- package/dist/lib/broadcastUpdate/constants.d.ts.map +0 -1
- package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
- package/dist/lib/broadcastUpdate/types.d.ts.map +0 -1
- package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +0 -1
- package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
- package/dist/lib/googleAnalytics/constants.d.ts +0 -10
- package/dist/lib/googleAnalytics/constants.d.ts.map +0 -1
- package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts +0 -30
- package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +0 -1
- package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
- package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
- package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +0 -1
- package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
- package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
- package/dist/lib/strategies/PrecacheStrategy.d.ts.map +0 -1
- package/dist/navigationPreload.d.ts.map +0 -1
- package/dist/registerQuotaErrorCallback.d.ts +0 -8
- package/dist/registerQuotaErrorCallback.d.ts.map +0 -1
- package/dist/setCacheNameDetails.d.ts +0 -9
- package/dist/setCacheNameDetails.d.ts.map +0 -1
- package/dist/types.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/NavigationRoute.ts +0 -118
- package/src/PrecacheRoute.ts +0 -45
- package/src/RegExpRoute.ts +0 -74
- package/src/Route.ts +0 -67
- package/src/Serwist.ts +0 -867
- package/src/copyResponse.ts +0 -58
- package/src/disableDevLogs.ts +0 -10
- 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/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/lib/googleAnalytics/constants.ts +0 -22
- package/src/registerQuotaErrorCallback.ts +0 -34
- package/src/setCacheNameDetails.ts +0 -53
- package/src/utils/PrecacheCacheKeyPlugin.ts +0 -33
- package/src/utils/parsePrecacheOptions.ts +0 -47
- /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueue.d.ts +0 -0
- /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueueDb.d.ts +0 -0
- /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueueStore.d.ts +0 -0
- /package/dist/lib/{broadcastUpdate → broadcast-update}/constants.d.ts +0 -0
- /package/dist/lib/{broadcastUpdate → broadcast-update}/responsesAreSame.d.ts +0 -0
- /package/dist/lib/{cacheableResponse → cacheable-response}/CacheableResponse.d.ts +0 -0
- /package/dist/{legacy → lib/extensions/google-analytics}/constants.d.ts +0 -0
- /package/dist/lib/{rangeRequests → range-requests}/createPartialResponse.d.ts +0 -0
- /package/dist/lib/{rangeRequests → range-requests}/utils/calculateEffectiveBoundaries.d.ts +0 -0
- /package/dist/lib/{rangeRequests → range-requests}/utils/parseRangeHeader.d.ts +0 -0
- /package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueueDb.ts +0 -0
- /package/src/lib/{broadcastUpdate → broadcast-update}/constants.ts +0 -0
- /package/src/{constants.ts → lib/constants.ts} +0 -0
- /package/src/{legacy → lib/extensions/google-analytics}/constants.ts +0 -0
package/dist/chunks/waitUntil.js
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
+
const _cacheNameDetails = {
|
|
2
|
+
googleAnalytics: "googleAnalytics",
|
|
3
|
+
precache: "precache-v2",
|
|
4
|
+
prefix: "serwist",
|
|
5
|
+
runtime: "runtime",
|
|
6
|
+
suffix: typeof registration !== "undefined" ? registration.scope : ""
|
|
7
|
+
};
|
|
8
|
+
const _createCacheName = (cacheName)=>{
|
|
9
|
+
return [
|
|
10
|
+
_cacheNameDetails.prefix,
|
|
11
|
+
cacheName,
|
|
12
|
+
_cacheNameDetails.suffix
|
|
13
|
+
].filter((value)=>value && value.length > 0).join("-");
|
|
14
|
+
};
|
|
15
|
+
const eachCacheNameDetail = (fn)=>{
|
|
16
|
+
for (const key of Object.keys(_cacheNameDetails)){
|
|
17
|
+
fn(key);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const cacheNames = {
|
|
21
|
+
updateDetails: (details)=>{
|
|
22
|
+
eachCacheNameDetail((key)=>{
|
|
23
|
+
const detail = details[key];
|
|
24
|
+
if (typeof detail === "string") {
|
|
25
|
+
_cacheNameDetails[key] = detail;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
getGoogleAnalyticsName: (userCacheName)=>{
|
|
30
|
+
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
|
|
31
|
+
},
|
|
32
|
+
getPrecacheName: (userCacheName)=>{
|
|
33
|
+
return userCacheName || _createCacheName(_cacheNameDetails.precache);
|
|
34
|
+
},
|
|
35
|
+
getPrefix: ()=>{
|
|
36
|
+
return _cacheNameDetails.prefix;
|
|
37
|
+
},
|
|
38
|
+
getRuntimeName: (userCacheName)=>{
|
|
39
|
+
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
|
|
40
|
+
},
|
|
41
|
+
getSuffix: ()=>{
|
|
42
|
+
return _cacheNameDetails.suffix;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const logger = process.env.NODE_ENV === "production" || typeof self === "undefined" || import.meta.env?.SSR ? null : (()=>{
|
|
47
|
+
if (!("__WB_DISABLE_DEV_LOGS" in globalThis)) {
|
|
48
|
+
self.__WB_DISABLE_DEV_LOGS = false;
|
|
49
|
+
}
|
|
50
|
+
let inGroup = false;
|
|
51
|
+
const methodToColorMap = {
|
|
52
|
+
debug: "#7f8c8d",
|
|
53
|
+
log: "#2ecc71",
|
|
54
|
+
warn: "#f39c12",
|
|
55
|
+
error: "#c0392b",
|
|
56
|
+
groupCollapsed: "#3498db",
|
|
57
|
+
groupEnd: null
|
|
58
|
+
};
|
|
59
|
+
const print = (method, args)=>{
|
|
60
|
+
if (self.__WB_DISABLE_DEV_LOGS) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (method === "groupCollapsed") {
|
|
64
|
+
if (typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
65
|
+
console[method](...args);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const styles = [
|
|
70
|
+
`background: ${methodToColorMap[method]}`,
|
|
71
|
+
"border-radius: 0.5em",
|
|
72
|
+
"color: white",
|
|
73
|
+
"font-weight: bold",
|
|
74
|
+
"padding: 2px 0.5em"
|
|
75
|
+
];
|
|
76
|
+
const logPrefix = inGroup ? [] : [
|
|
77
|
+
"%cserwist",
|
|
78
|
+
styles.join(";")
|
|
79
|
+
];
|
|
80
|
+
console[method](...logPrefix, ...args);
|
|
81
|
+
if (method === "groupCollapsed") {
|
|
82
|
+
inGroup = true;
|
|
83
|
+
}
|
|
84
|
+
if (method === "groupEnd") {
|
|
85
|
+
inGroup = false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const loggerMethods = Object.keys(methodToColorMap);
|
|
89
|
+
return loggerMethods.reduce((api, method)=>{
|
|
90
|
+
api[method] = (...args)=>{
|
|
91
|
+
print(method, args);
|
|
92
|
+
};
|
|
93
|
+
return api;
|
|
94
|
+
}, {});
|
|
95
|
+
})();
|
|
96
|
+
|
|
1
97
|
const messages = {
|
|
2
98
|
"invalid-value": ({ paramName, validValueDescription, value })=>{
|
|
3
99
|
if (!paramName || !validValueDescription) {
|
|
@@ -35,13 +131,13 @@ const messages = {
|
|
|
35
131
|
return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
|
|
36
132
|
},
|
|
37
133
|
"add-to-cache-list-unexpected-type": ({ entry })=>{
|
|
38
|
-
return `An unexpected entry was passed to 'serwist.Serwist.
|
|
134
|
+
return `An unexpected entry was passed to 'serwist.Serwist.precache.addToCacheList()' The entry '${JSON.stringify(entry)}' isn't supported. You must supply an array of strings with one or more characters, objects with a url property or Request objects.`;
|
|
39
135
|
},
|
|
40
136
|
"add-to-cache-list-conflicting-entries": ({ firstEntry, secondEntry })=>{
|
|
41
137
|
if (!firstEntry || !secondEntry) {
|
|
42
138
|
throw new Error("Unexpected input to " + `'add-to-cache-list-duplicate-entries' error.`);
|
|
43
139
|
}
|
|
44
|
-
return `Two of the entries passed to 'serwist.Serwist.
|
|
140
|
+
return `Two of the entries passed to 'serwist.Serwist.precache.addToCacheList()' had the URL ${firstEntry} but different revision details. Serwist is unable to cache and version the asset correctly. Please remove one of the entries.`;
|
|
45
141
|
},
|
|
46
142
|
"plugin-error-request-will-fetch": ({ thrownErrorMessage })=>{
|
|
47
143
|
if (!thrownErrorMessage) {
|
|
@@ -144,7 +240,7 @@ const messages = {
|
|
|
144
240
|
return `'createHandlerBoundToURL("${url}")' was called, but that URL is not precached. Please pass in a URL that is precached instead.`;
|
|
145
241
|
},
|
|
146
242
|
"add-to-cache-list-conflicting-integrities": ({ url })=>{
|
|
147
|
-
return `Two of the entries passed to 'serwist.Serwist.
|
|
243
|
+
return `Two of the entries passed to 'serwist.Serwist.precache.addToCacheList()' had the URL ${url} with different integrity values. Please remove one of them.`;
|
|
148
244
|
},
|
|
149
245
|
"missing-precache-entry": ({ cacheName, url })=>{
|
|
150
246
|
return `Unable to find a precached response in ${cacheName} for ${url}.`;
|
|
@@ -237,119 +333,15 @@ const finalAssertExports = process.env.NODE_ENV === "production" ? null : {
|
|
|
237
333
|
isArrayOfClass
|
|
238
334
|
};
|
|
239
335
|
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
let inGroup = false;
|
|
245
|
-
const methodToColorMap = {
|
|
246
|
-
debug: "#7f8c8d",
|
|
247
|
-
log: "#2ecc71",
|
|
248
|
-
warn: "#f39c12",
|
|
249
|
-
error: "#c0392b",
|
|
250
|
-
groupCollapsed: "#3498db",
|
|
251
|
-
groupEnd: null
|
|
252
|
-
};
|
|
253
|
-
const print = (method, args)=>{
|
|
254
|
-
if (self.__WB_DISABLE_DEV_LOGS) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (method === "groupCollapsed") {
|
|
258
|
-
if (typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
259
|
-
console[method](...args);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
const styles = [
|
|
264
|
-
`background: ${methodToColorMap[method]}`,
|
|
265
|
-
"border-radius: 0.5em",
|
|
266
|
-
"color: white",
|
|
267
|
-
"font-weight: bold",
|
|
268
|
-
"padding: 2px 0.5em"
|
|
269
|
-
];
|
|
270
|
-
const logPrefix = inGroup ? [] : [
|
|
271
|
-
"%cserwist",
|
|
272
|
-
styles.join(";")
|
|
273
|
-
];
|
|
274
|
-
console[method](...logPrefix, ...args);
|
|
275
|
-
if (method === "groupCollapsed") {
|
|
276
|
-
inGroup = true;
|
|
277
|
-
}
|
|
278
|
-
if (method === "groupEnd") {
|
|
279
|
-
inGroup = false;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
const loggerMethods = Object.keys(methodToColorMap);
|
|
283
|
-
return loggerMethods.reduce((api, method)=>{
|
|
284
|
-
api[method] = (...args)=>{
|
|
285
|
-
print(method, args);
|
|
286
|
-
};
|
|
287
|
-
return api;
|
|
288
|
-
}, {});
|
|
289
|
-
})();
|
|
336
|
+
const clientsClaim = ()=>{
|
|
337
|
+
self.addEventListener("activate", ()=>self.clients.claim());
|
|
338
|
+
};
|
|
290
339
|
|
|
291
340
|
const getFriendlyURL = (url)=>{
|
|
292
341
|
const urlObj = new URL(String(url), location.href);
|
|
293
342
|
return urlObj.href.replace(new RegExp(`^${location.origin}`), "");
|
|
294
343
|
};
|
|
295
344
|
|
|
296
|
-
const _cacheNameDetails = {
|
|
297
|
-
googleAnalytics: "googleAnalytics",
|
|
298
|
-
precache: "precache-v2",
|
|
299
|
-
prefix: "serwist",
|
|
300
|
-
runtime: "runtime",
|
|
301
|
-
suffix: typeof registration !== "undefined" ? registration.scope : ""
|
|
302
|
-
};
|
|
303
|
-
const _createCacheName = (cacheName)=>{
|
|
304
|
-
return [
|
|
305
|
-
_cacheNameDetails.prefix,
|
|
306
|
-
cacheName,
|
|
307
|
-
_cacheNameDetails.suffix
|
|
308
|
-
].filter((value)=>value && value.length > 0).join("-");
|
|
309
|
-
};
|
|
310
|
-
const eachCacheNameDetail = (fn)=>{
|
|
311
|
-
for (const key of Object.keys(_cacheNameDetails)){
|
|
312
|
-
fn(key);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
const cacheNames = {
|
|
316
|
-
updateDetails: (details)=>{
|
|
317
|
-
eachCacheNameDetail((key)=>{
|
|
318
|
-
const detail = details[key];
|
|
319
|
-
if (typeof detail === "string") {
|
|
320
|
-
_cacheNameDetails[key] = detail;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
},
|
|
324
|
-
getGoogleAnalyticsName: (userCacheName)=>{
|
|
325
|
-
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
|
|
326
|
-
},
|
|
327
|
-
getPrecacheName: (userCacheName)=>{
|
|
328
|
-
return userCacheName || _createCacheName(_cacheNameDetails.precache);
|
|
329
|
-
},
|
|
330
|
-
getPrefix: ()=>{
|
|
331
|
-
return _cacheNameDetails.prefix;
|
|
332
|
-
},
|
|
333
|
-
getRuntimeName: (userCacheName)=>{
|
|
334
|
-
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
|
|
335
|
-
},
|
|
336
|
-
getSuffix: ()=>{
|
|
337
|
-
return _cacheNameDetails.suffix;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
class Deferred {
|
|
342
|
-
promise;
|
|
343
|
-
resolve;
|
|
344
|
-
reject;
|
|
345
|
-
constructor(){
|
|
346
|
-
this.promise = new Promise((resolve, reject)=>{
|
|
347
|
-
this.resolve = resolve;
|
|
348
|
-
this.reject = reject;
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
345
|
function stripParams(fullURL, ignoreParams) {
|
|
354
346
|
const strippedURL = new URL(fullURL);
|
|
355
347
|
for (const param of ignoreParams){
|
|
@@ -376,6 +368,18 @@ async function cacheMatchIgnoreParams(cache, request, ignoreParams, matchOptions
|
|
|
376
368
|
return;
|
|
377
369
|
}
|
|
378
370
|
|
|
371
|
+
class Deferred {
|
|
372
|
+
promise;
|
|
373
|
+
resolve;
|
|
374
|
+
reject;
|
|
375
|
+
constructor(){
|
|
376
|
+
this.promise = new Promise((resolve, reject)=>{
|
|
377
|
+
this.resolve = resolve;
|
|
378
|
+
this.reject = reject;
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
379
383
|
const quotaErrorCallbacks = new Set();
|
|
380
384
|
|
|
381
385
|
const executeQuotaErrorCallbacks = async ()=>{
|
|
@@ -414,31 +418,34 @@ function canConstructResponseFromBodyStream() {
|
|
|
414
418
|
return supportStatus;
|
|
415
419
|
}
|
|
416
420
|
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
421
|
+
const MAX_RETRY_TIME = 2000;
|
|
422
|
+
async function resultingClientExists(resultingClientId) {
|
|
423
|
+
if (!resultingClientId) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
let existingWindows = await self.clients.matchAll({
|
|
427
|
+
type: "window"
|
|
422
428
|
});
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
429
|
+
const existingWindowIds = new Set(existingWindows.map((w)=>w.id));
|
|
430
|
+
let resultingWindow;
|
|
431
|
+
const startTime = performance.now();
|
|
432
|
+
while(performance.now() - startTime < MAX_RETRY_TIME){
|
|
433
|
+
existingWindows = await self.clients.matchAll({
|
|
434
|
+
type: "window"
|
|
435
|
+
});
|
|
436
|
+
resultingWindow = existingWindows.find((w)=>{
|
|
437
|
+
if (resultingClientId) {
|
|
438
|
+
return w.id === resultingClientId;
|
|
434
439
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
440
|
+
return !existingWindowIds.has(w.id);
|
|
441
|
+
});
|
|
442
|
+
if (resultingWindow) {
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
await timeout(100);
|
|
446
|
+
}
|
|
447
|
+
return resultingWindow;
|
|
448
|
+
}
|
|
442
449
|
|
|
443
450
|
const waitUntil = (event, asyncFn)=>{
|
|
444
451
|
const returnPromise = asyncFn();
|
|
@@ -446,4 +453,4 @@ const waitUntil = (event, asyncFn)=>{
|
|
|
446
453
|
return returnPromise;
|
|
447
454
|
};
|
|
448
455
|
|
|
449
|
-
export { Deferred as D, SerwistError as S,
|
|
456
|
+
export { Deferred as D, SerwistError as S, cacheMatchIgnoreParams as a, canConstructResponseFromBodyStream as b, cacheNames as c, clientsClaim as d, executeQuotaErrorCallbacks as e, finalAssertExports as f, getFriendlyURL as g, logger as l, quotaErrorCallbacks as q, resultingClientExists as r, timeout as t, waitUntil as w };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Route } from "
|
|
6
|
-
import { Serwist, type SerwistOptions } from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import { CacheableResponsePlugin } from "./lib/cacheableResponse/CacheableResponsePlugin.js";
|
|
24
|
-
import { CacheExpiration } from "./lib/expiration/CacheExpiration.js";
|
|
25
|
-
import type { ExpirationPluginOptions } from "./lib/expiration/ExpirationPlugin.js";
|
|
26
|
-
import { ExpirationPlugin } from "./lib/expiration/ExpirationPlugin.js";
|
|
27
|
-
import { initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
28
|
-
import type { GoogleAnalyticsInitializeOptions } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
|
|
29
|
-
import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
30
|
-
import { PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
|
|
31
|
-
import { RangeRequestsPlugin } from "./lib/rangeRequests/RangeRequestsPlugin.js";
|
|
32
|
-
import { createPartialResponse } from "./lib/rangeRequests/createPartialResponse.js";
|
|
33
|
-
import { CacheFirst } from "./lib/strategies/CacheFirst.js";
|
|
34
|
-
import { CacheOnly } from "./lib/strategies/CacheOnly.js";
|
|
35
|
-
import type { NetworkFirstOptions } from "./lib/strategies/NetworkFirst.js";
|
|
36
|
-
import { NetworkFirst } from "./lib/strategies/NetworkFirst.js";
|
|
37
|
-
import type { NetworkOnlyOptions } from "./lib/strategies/NetworkOnly.js";
|
|
38
|
-
import { NetworkOnly } from "./lib/strategies/NetworkOnly.js";
|
|
39
|
-
import { PrecacheStrategy } from "./lib/strategies/PrecacheStrategy.js";
|
|
40
|
-
import { StaleWhileRevalidate } from "./lib/strategies/StaleWhileRevalidate.js";
|
|
41
|
-
import type { StrategyOptions } from "./lib/strategies/Strategy.js";
|
|
42
|
-
import { Strategy } from "./lib/strategies/Strategy.js";
|
|
43
|
-
import { StrategyHandler } from "./lib/strategies/StrategyHandler.js";
|
|
44
|
-
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
|
|
45
|
-
import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
|
|
46
|
-
import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
47
|
-
export { Serwist, cacheNames, copyResponse, disableDevLogs, disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported, registerQuotaErrorCallback, setCacheNameDetails, CacheFirst, CacheOnly, NetworkFirst, NetworkOnly, PrecacheStrategy, StaleWhileRevalidate, Strategy, StrategyHandler, NavigationRoute, PrecacheRoute, RegExpRoute, Route, BackgroundSyncPlugin, BackgroundSyncQueue, BackgroundSyncQueueStore, StorableRequest, BroadcastCacheUpdate, BroadcastUpdatePlugin, BROADCAST_UPDATE_DEFAULT_HEADERS, responsesAreSame, CacheableResponse, CacheableResponsePlugin, CacheExpiration, ExpirationPlugin, PrecacheFallbackPlugin, initializeGoogleAnalytics, createPartialResponse, RangeRequestsPlugin, };
|
|
48
|
-
export type { HTTPMethod, SerwistOptions, NetworkFirstOptions, NetworkOnlyOptions, StrategyOptions, NavigationRouteMatchOptions, BackgroundSyncQueueOptions, BackgroundSyncQueueEntry, BroadcastCacheUpdateOptions, BroadcastPayload, BroadcastPayloadGenerator, BroadcastMessage, CacheableResponseOptions, ExpirationPluginOptions, PrecacheFallbackEntry, PrecacheFallbackPluginOptions, GoogleAnalyticsInitializeOptions, };
|
|
49
|
-
export type * from "./types.js";
|
|
1
|
+
import { cacheNames } from "#lib/cache-name.js";
|
|
2
|
+
import type { HTTPMethod } from "#lib/constants.js";
|
|
3
|
+
import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "#lib/navigation-preload.js";
|
|
4
|
+
import type { NavigationRouteMatchOptions } from "#lib/route.js";
|
|
5
|
+
import { NavigationRoute, RegExpRoute, Route } from "#lib/route.js";
|
|
6
|
+
import { Serwist, type SerwistOptions } from "#lib/serwist.js";
|
|
7
|
+
import { copyResponse, disableDevLogs, registerQuotaErrorCallback, setCacheNameDetails } from "#lib/utils.js";
|
|
8
|
+
export { BackgroundSyncPlugin, BackgroundSyncQueue, type BackgroundSyncQueueEntry, type BackgroundSyncQueueOptions, BackgroundSyncQueueStore, StorableRequest, } from "#lib/background-sync/index.js";
|
|
9
|
+
export { BROADCAST_UPDATE_DEFAULT_HEADERS, BroadcastCacheUpdate, type BroadcastCacheUpdateOptions, type BroadcastMessage, type BroadcastPayload, type BroadcastPayloadGenerator, BroadcastUpdatePlugin, responsesAreSame, } from "#lib/broadcast-update/index.js";
|
|
10
|
+
export { CacheableResponse, type CacheableResponseOptions, CacheableResponsePlugin, } from "#lib/cacheable-response/index.js";
|
|
11
|
+
export { CacheExpiration, ExpirationPlugin, type ExpirationPluginOptions, } from "#lib/expiration/index.js";
|
|
12
|
+
export { GoogleAnalytics, type GoogleAnalyticsInitializeOptions, type GoogleAnalyticsOptions, initializeGoogleAnalytics, type PrecacheFallbackEntry, PrecacheFallbackPlugin, type PrecacheFallbackPluginOptions, PrecacheRoute, PrecacheStrategy, RuntimeCache, type RuntimeCacheOptions, } from "#lib/extensions/index.js";
|
|
13
|
+
export { createPartialResponse, RangeRequestsPlugin, } from "#lib/range-requests/index.js";
|
|
14
|
+
export { CacheFirst, CacheOnly, NetworkFirst, type NetworkFirstOptions, NetworkOnly, type NetworkOnlyOptions, StaleWhileRevalidate, Strategy, StrategyHandler, type StrategyOptions, } from "#lib/strategies/index.js";
|
|
15
|
+
export { Serwist, cacheNames, copyResponse, disableDevLogs, disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported, registerQuotaErrorCallback, setCacheNameDetails, NavigationRoute, RegExpRoute, Route, };
|
|
16
|
+
export type { Serwist as SerwistState, SerwistOptions as CreateSerwistOptions } from "#lib/core.js";
|
|
17
|
+
export { createSerwist } from "#lib/core.js";
|
|
18
|
+
export type * from "#lib/extension.js";
|
|
19
|
+
export { addEventListeners, createActivateHandler, createCacheHandler, createFetchHandler, createInstallHandler, iterateExtensions, setCatchHandler, setDefaultHandler, } from "#lib/functions/handlers.js";
|
|
20
|
+
export { findMatchingRoute, handleRequest, registerCapture, registerRoute, unregisterRoute } from "#lib/functions/router.js";
|
|
21
|
+
export type { HTTPMethod, SerwistOptions, NavigationRouteMatchOptions };
|
|
22
|
+
export type * from "#lib/types.js";
|
|
50
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC7H,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG9G,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,wBAAwB,EACxB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,gCAAgC,EAChC,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,eAAe,EACf,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,yBAAyB,EACzB,KAAK,qBAAqB,EAC1B,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,KAAK,mBAAmB,EACxB,WAAW,EACX,KAAK,kBAAkB,EACvB,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,KAAK,eAAe,GACrB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,OAAO,EACP,UAAU,EACV,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EAEnB,eAAe,EACf,WAAW,EACX,KAAK,GACN,CAAC;AAIF,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,mBAAmB,mBAAmB,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE7H,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC;AACxE,mBAAmB,eAAe,CAAC"}
|
package/dist/index.internal.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { timeout } from "
|
|
16
|
-
import { waitUntil } from "
|
|
1
|
+
import { assert } from "#utils/assert.js";
|
|
2
|
+
import { cacheMatchIgnoreParams } from "#utils/cacheMatchIgnoreParams.js";
|
|
3
|
+
import { cacheNames as privateCacheNames } from "#utils/cacheNames.js";
|
|
4
|
+
import { canConstructReadableStream } from "#utils/canConstructReadableStream.js";
|
|
5
|
+
import { canConstructResponseFromBodyStream } from "#utils/canConstructResponseFromBodyStream.js";
|
|
6
|
+
import { cleanupOutdatedCaches } from "#utils/cleanupOutdatedCaches.js";
|
|
7
|
+
import { clientsClaim } from "#utils/clientsClaim.js";
|
|
8
|
+
import { Deferred } from "#utils/Deferred.js";
|
|
9
|
+
import { dontWaitFor } from "#utils/dontWaitFor.js";
|
|
10
|
+
import { executeQuotaErrorCallbacks } from "#utils/executeQuotaErrorCallbacks.js";
|
|
11
|
+
import { getFriendlyURL } from "#utils/getFriendlyURL.js";
|
|
12
|
+
import { logger } from "#utils/logger.js";
|
|
13
|
+
import { resultingClientExists } from "#utils/resultingClientExists.js";
|
|
14
|
+
import { SerwistError } from "#utils/SerwistError.js";
|
|
15
|
+
import { timeout } from "#utils/timeout.js";
|
|
16
|
+
import { waitUntil } from "#utils/waitUntil.js";
|
|
17
17
|
export { Deferred, SerwistError, assert, cleanupOutdatedCaches, clientsClaim, cacheMatchIgnoreParams, privateCacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, };
|
|
18
18
|
//# sourceMappingURL=index.internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,kCAAkC,EAClC,WAAW,EACX,0BAA0B,EAC1B,cAAc,EACd,MAAM,EACN,qBAAqB,EACrB,OAAO,EACP,SAAS,GACV,CAAC"}
|
package/dist/index.internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export { r as resultingClientExists } from './chunks/
|
|
1
|
+
import { c as cacheNames, l as logger } from './chunks/waitUntil.js';
|
|
2
|
+
export { D as Deferred, S as SerwistError, f as assert, a as cacheMatchIgnoreParams, b as canConstructResponseFromBodyStream, d as clientsClaim, e as executeQuotaErrorCallbacks, g as getFriendlyURL, r as resultingClientExists, t as timeout, w as waitUntil } from './chunks/waitUntil.js';
|
|
3
3
|
|
|
4
4
|
let supportStatus;
|
|
5
5
|
function canConstructReadableStream() {
|
|
@@ -16,8 +16,30 @@ function canConstructReadableStream() {
|
|
|
16
16
|
return supportStatus;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const SUBSTRING_TO_FIND = "-precache-";
|
|
20
|
+
const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND)=>{
|
|
21
|
+
const cacheNames = await self.caches.keys();
|
|
22
|
+
const cacheNamesToDelete = cacheNames.filter((cacheName)=>{
|
|
23
|
+
return cacheName.includes(substringToFind) && cacheName.includes(self.registration.scope) && cacheName !== currentPrecacheName;
|
|
24
|
+
});
|
|
25
|
+
await Promise.all(cacheNamesToDelete.map((cacheName)=>self.caches.delete(cacheName)));
|
|
26
|
+
return cacheNamesToDelete;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const cleanupOutdatedCaches = (cacheName)=>{
|
|
30
|
+
self.addEventListener("activate", (event)=>{
|
|
31
|
+
event.waitUntil(deleteOutdatedCaches(cacheNames.getPrecacheName(cacheName)).then((cachesDeleted)=>{
|
|
32
|
+
if (process.env.NODE_ENV !== "production") {
|
|
33
|
+
if (cachesDeleted.length > 0) {
|
|
34
|
+
logger.log("The following out-of-date precaches were cleaned up automatically:", cachesDeleted);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
19
41
|
function dontWaitFor(promise) {
|
|
20
42
|
void promise.then(()=>{});
|
|
21
43
|
}
|
|
22
44
|
|
|
23
|
-
export { canConstructReadableStream, dontWaitFor };
|
|
45
|
+
export { canConstructReadableStream, cleanupOutdatedCaches, dontWaitFor, logger, cacheNames as privateCacheNames };
|