serwist 9.5.7 → 9.5.8

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.
Files changed (242) hide show
  1. package/dist/chunks/Route-wAAof_Tq.d.ts +36 -0
  2. package/dist/chunks/Route-wAAof_Tq.d.ts.map +1 -0
  3. package/dist/chunks/cacheNames-DZwJpopB.d.ts +35 -0
  4. package/dist/chunks/cacheNames-DZwJpopB.d.ts.map +1 -0
  5. package/dist/chunks/index.internal-Dxj9Ni9X.js +65 -0
  6. package/dist/chunks/index.internal-Dxj9Ni9X.js.map +1 -0
  7. package/dist/chunks/printInstallDetails-c9A08ZVZ.js +2026 -0
  8. package/dist/chunks/printInstallDetails-c9A08ZVZ.js.map +1 -0
  9. package/dist/chunks/types-CKER0KBv.d.ts +786 -0
  10. package/dist/chunks/types-CKER0KBv.d.ts.map +1 -0
  11. package/dist/chunks/waitUntil-BHDx3Rgo.js +486 -0
  12. package/dist/chunks/waitUntil-BHDx3Rgo.js.map +1 -0
  13. package/dist/index.d.mts +1525 -0
  14. package/dist/index.d.mts.map +1 -0
  15. package/dist/index.internal.d.mts +337 -0
  16. package/dist/index.internal.d.mts.map +1 -0
  17. package/dist/index.internal.mjs +3 -0
  18. package/dist/index.legacy.d.mts +892 -0
  19. package/dist/index.legacy.d.mts.map +1 -0
  20. package/dist/index.legacy.mjs +1162 -0
  21. package/dist/index.legacy.mjs.map +1 -0
  22. package/dist/index.mjs +1847 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/package.json +16 -17
  25. package/dist/NavigationRoute.d.ts +0 -56
  26. package/dist/NavigationRoute.d.ts.map +0 -1
  27. package/dist/PrecacheRoute.d.ts +0 -16
  28. package/dist/PrecacheRoute.d.ts.map +0 -1
  29. package/dist/RegExpRoute.d.ts +0 -24
  30. package/dist/RegExpRoute.d.ts.map +0 -1
  31. package/dist/Route.d.ts +0 -33
  32. package/dist/Route.d.ts.map +0 -1
  33. package/dist/Serwist.d.ts +0 -299
  34. package/dist/Serwist.d.ts.map +0 -1
  35. package/dist/cacheNames.d.ts +0 -20
  36. package/dist/cacheNames.d.ts.map +0 -1
  37. package/dist/chunks/printInstallDetails.js +0 -1575
  38. package/dist/chunks/resultingClientExists.js +0 -32
  39. package/dist/chunks/waitUntil.js +0 -449
  40. package/dist/constants.d.ts +0 -15
  41. package/dist/constants.d.ts.map +0 -1
  42. package/dist/copyResponse.d.ts +0 -18
  43. package/dist/copyResponse.d.ts.map +0 -1
  44. package/dist/disableDevLogs.d.ts +0 -7
  45. package/dist/disableDevLogs.d.ts.map +0 -1
  46. package/dist/index.d.ts +0 -50
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.internal.d.ts +0 -18
  49. package/dist/index.internal.d.ts.map +0 -1
  50. package/dist/index.internal.js +0 -23
  51. package/dist/index.js +0 -1533
  52. package/dist/index.legacy.d.ts +0 -28
  53. package/dist/index.legacy.d.ts.map +0 -1
  54. package/dist/index.legacy.js +0 -790
  55. package/dist/legacy/PrecacheController.d.ts +0 -145
  56. package/dist/legacy/PrecacheController.d.ts.map +0 -1
  57. package/dist/legacy/PrecacheFallbackPlugin.d.ts +0 -61
  58. package/dist/legacy/PrecacheFallbackPlugin.d.ts.map +0 -1
  59. package/dist/legacy/PrecacheRoute.d.ts +0 -19
  60. package/dist/legacy/PrecacheRoute.d.ts.map +0 -1
  61. package/dist/legacy/Router.d.ts +0 -151
  62. package/dist/legacy/Router.d.ts.map +0 -1
  63. package/dist/legacy/addPlugins.d.ts +0 -9
  64. package/dist/legacy/addPlugins.d.ts.map +0 -1
  65. package/dist/legacy/addRoute.d.ts +0 -14
  66. package/dist/legacy/addRoute.d.ts.map +0 -1
  67. package/dist/legacy/constants.d.ts +0 -10
  68. package/dist/legacy/constants.d.ts.map +0 -1
  69. package/dist/legacy/createHandlerBoundToURL.d.ts +0 -17
  70. package/dist/legacy/createHandlerBoundToURL.d.ts.map +0 -1
  71. package/dist/legacy/fallbacks.d.ts +0 -59
  72. package/dist/legacy/fallbacks.d.ts.map +0 -1
  73. package/dist/legacy/getCacheKeyForURL.d.ts +0 -20
  74. package/dist/legacy/getCacheKeyForURL.d.ts.map +0 -1
  75. package/dist/legacy/handlePrecaching.d.ts +0 -54
  76. package/dist/legacy/handlePrecaching.d.ts.map +0 -1
  77. package/dist/legacy/initializeGoogleAnalytics.d.ts +0 -38
  78. package/dist/legacy/initializeGoogleAnalytics.d.ts.map +0 -1
  79. package/dist/legacy/installSerwist.d.ts +0 -81
  80. package/dist/legacy/installSerwist.d.ts.map +0 -1
  81. package/dist/legacy/matchPrecache.d.ts +0 -15
  82. package/dist/legacy/matchPrecache.d.ts.map +0 -1
  83. package/dist/legacy/precache.d.ts +0 -20
  84. package/dist/legacy/precache.d.ts.map +0 -1
  85. package/dist/legacy/precacheAndRoute.d.ts +0 -14
  86. package/dist/legacy/precacheAndRoute.d.ts.map +0 -1
  87. package/dist/legacy/registerRoute.d.ts +0 -16
  88. package/dist/legacy/registerRoute.d.ts.map +0 -1
  89. package/dist/legacy/registerRuntimeCaching.d.ts +0 -11
  90. package/dist/legacy/registerRuntimeCaching.d.ts.map +0 -1
  91. package/dist/legacy/setCatchHandler.d.ts +0 -10
  92. package/dist/legacy/setCatchHandler.d.ts.map +0 -1
  93. package/dist/legacy/setDefaultHandler.d.ts +0 -13
  94. package/dist/legacy/setDefaultHandler.d.ts.map +0 -1
  95. package/dist/legacy/singletonPrecacheController.d.ts +0 -34
  96. package/dist/legacy/singletonPrecacheController.d.ts.map +0 -1
  97. package/dist/legacy/singletonRouter.d.ts +0 -41
  98. package/dist/legacy/singletonRouter.d.ts.map +0 -1
  99. package/dist/legacy/unregisterRoute.d.ts +0 -9
  100. package/dist/legacy/unregisterRoute.d.ts.map +0 -1
  101. package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts +0 -16
  102. package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  103. package/dist/legacy/utils/getCacheKeyForURL.d.ts +0 -14
  104. package/dist/legacy/utils/getCacheKeyForURL.d.ts.map +0 -1
  105. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts +0 -23
  106. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
  107. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts +0 -182
  108. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +0 -1
  109. package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts +0 -90
  110. package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +0 -1
  111. package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts +0 -75
  112. package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +0 -1
  113. package/dist/lib/backgroundSync/StorableRequest.d.ts +0 -51
  114. package/dist/lib/backgroundSync/StorableRequest.d.ts.map +0 -1
  115. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts +0 -44
  116. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
  117. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts +0 -24
  118. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
  119. package/dist/lib/broadcastUpdate/constants.d.ts +0 -5
  120. package/dist/lib/broadcastUpdate/constants.d.ts.map +0 -1
  121. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts +0 -11
  122. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
  123. package/dist/lib/broadcastUpdate/types.d.ts +0 -35
  124. package/dist/lib/broadcastUpdate/types.d.ts.map +0 -1
  125. package/dist/lib/cacheableResponse/CacheableResponse.d.ts +0 -40
  126. package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +0 -1
  127. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts +0 -27
  128. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
  129. package/dist/lib/expiration/CacheExpiration.d.ts +0 -66
  130. package/dist/lib/expiration/CacheExpiration.d.ts.map +0 -1
  131. package/dist/lib/expiration/ExpirationPlugin.d.ts +0 -116
  132. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +0 -1
  133. package/dist/lib/expiration/models/CacheTimestampsModel.d.ts +0 -73
  134. package/dist/lib/expiration/models/CacheTimestampsModel.d.ts.map +0 -1
  135. package/dist/lib/googleAnalytics/constants.d.ts +0 -10
  136. package/dist/lib/googleAnalytics/constants.d.ts.map +0 -1
  137. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts +0 -30
  138. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +0 -1
  139. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts +0 -49
  140. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
  141. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts +0 -18
  142. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
  143. package/dist/lib/rangeRequests/createPartialResponse.d.ts +0 -18
  144. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +0 -1
  145. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +0 -14
  146. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
  147. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts +0 -12
  148. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
  149. package/dist/lib/strategies/CacheFirst.d.ts +0 -23
  150. package/dist/lib/strategies/CacheFirst.d.ts.map +0 -1
  151. package/dist/lib/strategies/CacheOnly.d.ts +0 -20
  152. package/dist/lib/strategies/CacheOnly.d.ts.map +0 -1
  153. package/dist/lib/strategies/NetworkFirst.d.ts +0 -61
  154. package/dist/lib/strategies/NetworkFirst.d.ts.map +0 -1
  155. package/dist/lib/strategies/NetworkOnly.d.ts +0 -32
  156. package/dist/lib/strategies/NetworkOnly.d.ts.map +0 -1
  157. package/dist/lib/strategies/PrecacheStrategy.d.ts +0 -69
  158. package/dist/lib/strategies/PrecacheStrategy.d.ts.map +0 -1
  159. package/dist/lib/strategies/StaleWhileRevalidate.d.ts +0 -35
  160. package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +0 -1
  161. package/dist/lib/strategies/Strategy.d.ts +0 -81
  162. package/dist/lib/strategies/Strategy.d.ts.map +0 -1
  163. package/dist/lib/strategies/StrategyHandler.d.ts +0 -190
  164. package/dist/lib/strategies/StrategyHandler.d.ts.map +0 -1
  165. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +0 -3
  166. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +0 -1
  167. package/dist/lib/strategies/utils/messages.d.ts +0 -5
  168. package/dist/lib/strategies/utils/messages.d.ts.map +0 -1
  169. package/dist/models/messages/messageGenerator.d.ts +0 -4
  170. package/dist/models/messages/messageGenerator.d.ts.map +0 -1
  171. package/dist/models/messages/messages.d.ts +0 -44
  172. package/dist/models/messages/messages.d.ts.map +0 -1
  173. package/dist/models/pluginEvents.d.ts +0 -10
  174. package/dist/models/pluginEvents.d.ts.map +0 -1
  175. package/dist/models/quotaErrorCallbacks.d.ts +0 -3
  176. package/dist/models/quotaErrorCallbacks.d.ts.map +0 -1
  177. package/dist/navigationPreload.d.ts +0 -24
  178. package/dist/navigationPreload.d.ts.map +0 -1
  179. package/dist/registerQuotaErrorCallback.d.ts +0 -8
  180. package/dist/registerQuotaErrorCallback.d.ts.map +0 -1
  181. package/dist/setCacheNameDetails.d.ts +0 -9
  182. package/dist/setCacheNameDetails.d.ts.map +0 -1
  183. package/dist/types.d.ts +0 -445
  184. package/dist/types.d.ts.map +0 -1
  185. package/dist/utils/Deferred.d.ts +0 -19
  186. package/dist/utils/Deferred.d.ts.map +0 -1
  187. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +0 -16
  188. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  189. package/dist/utils/PrecacheInstallReportPlugin.d.ts +0 -14
  190. package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +0 -1
  191. package/dist/utils/SerwistError.d.ts +0 -24
  192. package/dist/utils/SerwistError.d.ts.map +0 -1
  193. package/dist/utils/assert.d.ts +0 -11
  194. package/dist/utils/assert.d.ts.map +0 -1
  195. package/dist/utils/cacheMatchIgnoreParams.d.ts +0 -15
  196. package/dist/utils/cacheMatchIgnoreParams.d.ts.map +0 -1
  197. package/dist/utils/cacheNames.d.ts +0 -40
  198. package/dist/utils/cacheNames.d.ts.map +0 -1
  199. package/dist/utils/canConstructReadableStream.d.ts +0 -12
  200. package/dist/utils/canConstructReadableStream.d.ts.map +0 -1
  201. package/dist/utils/canConstructResponseFromBodyStream.d.ts +0 -11
  202. package/dist/utils/canConstructResponseFromBodyStream.d.ts.map +0 -1
  203. package/dist/utils/cleanupOutdatedCaches.d.ts +0 -6
  204. package/dist/utils/cleanupOutdatedCaches.d.ts.map +0 -1
  205. package/dist/utils/clientsClaim.d.ts +0 -6
  206. package/dist/utils/clientsClaim.d.ts.map +0 -1
  207. package/dist/utils/createCacheKey.d.ts +0 -16
  208. package/dist/utils/createCacheKey.d.ts.map +0 -1
  209. package/dist/utils/deleteOutdatedCaches.d.ts +0 -18
  210. package/dist/utils/deleteOutdatedCaches.d.ts.map +0 -1
  211. package/dist/utils/dontWaitFor.d.ts +0 -7
  212. package/dist/utils/dontWaitFor.d.ts.map +0 -1
  213. package/dist/utils/executeQuotaErrorCallbacks.d.ts +0 -8
  214. package/dist/utils/executeQuotaErrorCallbacks.d.ts.map +0 -1
  215. package/dist/utils/generateURLVariations.d.ts +0 -12
  216. package/dist/utils/generateURLVariations.d.ts.map +0 -1
  217. package/dist/utils/getFriendlyURL.d.ts +0 -3
  218. package/dist/utils/getFriendlyURL.d.ts.map +0 -1
  219. package/dist/utils/logger.d.ts +0 -24
  220. package/dist/utils/logger.d.ts.map +0 -1
  221. package/dist/utils/normalizeHandler.d.ts +0 -10
  222. package/dist/utils/normalizeHandler.d.ts.map +0 -1
  223. package/dist/utils/parsePrecacheOptions.d.ts +0 -26
  224. package/dist/utils/parsePrecacheOptions.d.ts.map +0 -1
  225. package/dist/utils/parseRoute.d.ts +0 -16
  226. package/dist/utils/parseRoute.d.ts.map +0 -1
  227. package/dist/utils/pluginUtils.d.ts +0 -5
  228. package/dist/utils/pluginUtils.d.ts.map +0 -1
  229. package/dist/utils/printCleanupDetails.d.ts +0 -6
  230. package/dist/utils/printCleanupDetails.d.ts.map +0 -1
  231. package/dist/utils/printInstallDetails.d.ts +0 -7
  232. package/dist/utils/printInstallDetails.d.ts.map +0 -1
  233. package/dist/utils/removeIgnoredSearchParams.d.ts +0 -12
  234. package/dist/utils/removeIgnoredSearchParams.d.ts.map +0 -1
  235. package/dist/utils/resultingClientExists.d.ts +0 -12
  236. package/dist/utils/resultingClientExists.d.ts.map +0 -1
  237. package/dist/utils/timeout.d.ts +0 -10
  238. package/dist/utils/timeout.d.ts.map +0 -1
  239. package/dist/utils/waitUntil.d.ts +0 -11
  240. package/dist/utils/waitUntil.d.ts.map +0 -1
  241. package/dist/utils/welcome.d.ts +0 -2
  242. package/dist/utils/welcome.d.ts.map +0 -1
@@ -0,0 +1,1525 @@
1
+ import { $ as StrategyOptions, A as MaybePromise, B as RouteHandler, C as HandlerWillStartCallback, D as ManualHandlerCallback, E as InstallResult, F as RequestRule, G as RouteMatchCallbackOptions, H as RouteHandlerCallbackOptions, I as RequestRuleCondition, J as SerwistPlugin, K as RuntimeCaching, L as RequestRuleSource, M as PrecacheEntry, N as PrecacheOptions, O as ManualHandlerCallbackOptions, P as PrecacheRouteOptions, Q as Strategy, R as RequestWillFetchCallback, S as HandlerWillRespondCallbackParam, T as InstallEvent, U as RouteHandlerObject, V as RouteHandlerCallback, W as RouteMatchCallback, X as UrlManipulation, Y as SerwistPluginCallbackParam, Z as PrecacheStrategy, _ as HandlerDidErrorCallback, a as CacheWillUpdateCallback, b as HandlerDidRespondCallbackParam, c as CachedResponseWillBeUsedCallbackParam, d as FetchDidFailCallbackParam, et as StrategyHandler, f as FetchDidSucceedCallback, g as HandlerDidCompleteCallbackParam, h as HandlerDidCompleteCallback, i as CacheKeyWillBeUsedCallbackParam, j as PluginState, k as MapLikeObject, l as CleanupResult, m as HandlerCallbackOptions, n as CacheDidUpdateCallbackParam, o as CacheWillUpdateCallbackParam, p as FetchDidSucceedCallbackParam, q as SerwistGlobalConfig, r as CacheKeyWillBeUsedCallback, s as CachedResponseWillBeUsedCallback, t as CacheDidUpdateCallback, tt as HTTPMethod, u as FetchDidFailCallback, v as HandlerDidErrorCallbackParam, w as HandlerWillStartCallbackParam, x as HandlerWillRespondCallback, y as HandlerDidRespondCallback, z as RequestWillFetchCallbackParam } from "./chunks/types-CKER0KBv.js";
2
+ import { t as Route } from "./chunks/Route-wAAof_Tq.js";
3
+ import { t as PartialCacheNameDetails } from "./chunks/cacheNames-DZwJpopB.js";
4
+
5
+ //#region src/cacheNames.d.ts
6
+ /**
7
+ * Get the current cache names and prefix/suffix used by Serwist.
8
+ *
9
+ * `cacheNames.precache` is used for precached assets,
10
+ * `cacheNames.googleAnalytics` is used by `@serwist/google-analytics` to
11
+ * store `analytics.js`, and `cacheNames.runtime` is used for everything else.
12
+ *
13
+ * `cacheNames.prefix` can be used to retrieve just the current prefix value.
14
+ * `cacheNames.suffix` can be used to retrieve just the current suffix value.
15
+ *
16
+ * @returns An object with `precache`, `runtime`, `prefix`, and `googleAnalytics` properties.
17
+ */
18
+ declare const cacheNames: {
19
+ readonly googleAnalytics: string;
20
+ readonly precache: string;
21
+ readonly prefix: string;
22
+ readonly runtime: string;
23
+ readonly suffix: string;
24
+ };
25
+ //#endregion
26
+ //#region src/copyResponse.d.ts
27
+ /**
28
+ * Allows developers to copy a response and modify its `headers`, `status`,
29
+ * or `statusText` values (the [valid options](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#options)
30
+ * when constructing a `Response` object).
31
+ * To modify these values, pass a function as the second argument. That
32
+ * function will be invoked with the options of the initial `Response` object.
33
+ * The return value of this function will be used as the options for the new `Response` object.
34
+ * To change the values either modify the passed parameter(s) and return it or return a totally
35
+ * new object.
36
+ *
37
+ * This method is intentionally limited to same-origin responses, regardless of
38
+ * whether CORS was used or not.
39
+ *
40
+ * @param response The initial response.
41
+ * @param modifier The function used to modify the options of the `Response` object.
42
+ */
43
+ declare const copyResponse: (response: Response, modifier?: (responseInit: ResponseInit) => ResponseInit) => Promise<Response>;
44
+ //#endregion
45
+ //#region src/disableDevLogs.d.ts
46
+ /**
47
+ * Disables Serwist's logging in development mode.
48
+ *
49
+ * @see https://serwist.pages.dev/docs/serwist/core/disable-dev-logs
50
+ */
51
+ declare const disableDevLogs$1: () => void;
52
+ //#endregion
53
+ //#region src/lib/backgroundSync/BackgroundSyncQueue.d.ts
54
+ interface SyncManager {
55
+ getTags(): Promise<string[]>;
56
+ register(tag: string): Promise<void>;
57
+ }
58
+ declare global {
59
+ interface ServiceWorkerRegistration {
60
+ readonly sync: SyncManager;
61
+ }
62
+ interface SyncEvent extends ExtendableEvent {
63
+ readonly lastChance: boolean;
64
+ readonly tag: string;
65
+ }
66
+ interface ServiceWorkerGlobalScopeEventMap {
67
+ sync: SyncEvent;
68
+ }
69
+ }
70
+ interface OnSyncCallbackOptions {
71
+ queue: BackgroundSyncQueue;
72
+ }
73
+ type OnSyncCallback = (options: OnSyncCallbackOptions) => void | Promise<void>;
74
+ interface BackgroundSyncQueueOptions {
75
+ /**
76
+ * If `true`, instead of attempting to use background sync events, always attempt
77
+ * to replay queued request at service worker startup. Most folks will not need
78
+ * this, unless you explicitly target a runtime like Electron that exposes the
79
+ * interfaces for background sync, but does not have a working implementation.
80
+ *
81
+ * @default false
82
+ */
83
+ forceSyncFallback?: boolean;
84
+ /**
85
+ * The amount of time (in minutes) a request may be retried. After this amount
86
+ * of time has passed, the request will be deleted from the queue.
87
+ *
88
+ * @default 60 * 24 * 7
89
+ */
90
+ maxRetentionTime?: number;
91
+ /**
92
+ * A function that gets invoked whenever the 'sync' event fires. The function
93
+ * is invoked with an object containing the `queue` property (referencing this
94
+ * instance), and you can use the callback to customize the replay behavior of
95
+ * the queue. When not set the `replayRequests()` method is called. Note: if the
96
+ * replay fails after a sync event, make sure you throw an error, so the browser
97
+ * knows to retry the sync event later.
98
+ */
99
+ onSync?: OnSyncCallback;
100
+ }
101
+ interface BackgroundSyncQueueEntry {
102
+ /**
103
+ * The request to store in the queue.
104
+ */
105
+ request: Request;
106
+ /**
107
+ * The timestamp (Epoch time in milliseconds) when the request was first added
108
+ * to the queue. This is used along with `maxRetentionTime` to remove outdated
109
+ * requests. In general you don't need to set this value, as it's automatically
110
+ * set for you (defaulting to `Date.now()`), but you can update it if you don't
111
+ * want particular requests to expire.
112
+ */
113
+ timestamp?: number;
114
+ /**
115
+ * Any metadata you want associated with the stored request. When requests are
116
+ * replayed you'll have access to this metadata object in case you need to modify
117
+ * the request beforehand.
118
+ */
119
+ metadata?: Record<string, unknown>;
120
+ }
121
+ /**
122
+ * A class to manage storing failed requests in IndexedDB and retrying them
123
+ * later. All parts of the storing and replaying process are observable via
124
+ * callbacks.
125
+ */
126
+ declare class BackgroundSyncQueue {
127
+ private readonly _name;
128
+ private readonly _onSync;
129
+ private readonly _maxRetentionTime;
130
+ private readonly _queueStore;
131
+ private readonly _forceSyncFallback;
132
+ private _syncInProgress;
133
+ private _requestsAddedDuringSync;
134
+ /**
135
+ * Creates an instance of Queue with the given options
136
+ *
137
+ * @param name The unique name for this queue. This name must be
138
+ * unique as it's used to register sync events and store requests
139
+ * in IndexedDB specific to this instance. An error will be thrown if
140
+ * a duplicate name is detected.
141
+ * @param options
142
+ */
143
+ constructor(name: string, {
144
+ forceSyncFallback,
145
+ onSync,
146
+ maxRetentionTime
147
+ }?: BackgroundSyncQueueOptions);
148
+ /**
149
+ * @returns
150
+ */
151
+ get name(): string;
152
+ /**
153
+ * Stores the passed request in IndexedDB (with its timestamp and any
154
+ * metadata) at the end of the queue.
155
+ *
156
+ * @param entry
157
+ */
158
+ pushRequest(entry: BackgroundSyncQueueEntry): Promise<void>;
159
+ /**
160
+ * Stores the passed request in IndexedDB (with its timestamp and any
161
+ * metadata) at the beginning of the queue.
162
+ *
163
+ * @param entry
164
+ */
165
+ unshiftRequest(entry: BackgroundSyncQueueEntry): Promise<void>;
166
+ /**
167
+ * Removes and returns the last request in the queue (along with its
168
+ * timestamp and any metadata).
169
+ *
170
+ * @returns
171
+ */
172
+ popRequest(): Promise<BackgroundSyncQueueEntry | undefined>;
173
+ /**
174
+ * Removes and returns the first request in the queue (along with its
175
+ * timestamp and any metadata).
176
+ *
177
+ * @returns
178
+ */
179
+ shiftRequest(): Promise<BackgroundSyncQueueEntry | undefined>;
180
+ /**
181
+ * Returns all the entries that have not expired (per `maxRetentionTime`).
182
+ * Any expired entries are removed from the queue.
183
+ *
184
+ * @returns
185
+ */
186
+ getAll(): Promise<BackgroundSyncQueueEntry[]>;
187
+ /**
188
+ * Returns the number of entries present in the queue.
189
+ * Note that expired entries (per `maxRetentionTime`) are also included in this count.
190
+ *
191
+ * @returns
192
+ */
193
+ size(): Promise<number>;
194
+ /**
195
+ * Adds the entry to the QueueStore and registers for a sync event.
196
+ *
197
+ * @param entry
198
+ * @param operation
199
+ * @private
200
+ */
201
+ _addRequest({
202
+ request,
203
+ metadata,
204
+ timestamp
205
+ }: BackgroundSyncQueueEntry, operation: "push" | "unshift"): Promise<void>;
206
+ /**
207
+ * Removes and returns the first or last (depending on `operation`) entry
208
+ * from the {@linkcode BackgroundSyncQueueStore} that's not older than the `maxRetentionTime`.
209
+ *
210
+ * @param operation
211
+ * @returns
212
+ * @private
213
+ */
214
+ _removeRequest(operation: "pop" | "shift"): Promise<BackgroundSyncQueueEntry | undefined>;
215
+ /**
216
+ * Loops through each request in the queue and attempts to re-fetch it.
217
+ * If any request fails to re-fetch, it's put back in the same position in
218
+ * the queue (which registers a retry for the next sync event).
219
+ */
220
+ replayRequests(): Promise<void>;
221
+ /**
222
+ * Registers a sync event with a tag unique to this instance.
223
+ */
224
+ registerSync(): Promise<void>;
225
+ /**
226
+ * In sync-supporting browsers, this adds a listener for the sync event.
227
+ * In non-sync-supporting browsers, or if _forceSyncFallback is true, this
228
+ * will retry the queue on service worker startup.
229
+ *
230
+ * @private
231
+ */
232
+ private _addSyncListener;
233
+ /**
234
+ * Returns the set of queue names. This is primarily used to reset the list
235
+ * of queue names in tests.
236
+ *
237
+ * @returns
238
+ * @private
239
+ */
240
+ static get _queueNames(): Set<string>;
241
+ }
242
+ //#endregion
243
+ //#region src/lib/backgroundSync/BackgroundSyncPlugin.d.ts
244
+ /**
245
+ * A class implementing the `fetchDidFail` lifecycle callback. This makes it
246
+ * easier to add failed requests to a {@linkcode BackgroundSyncQueue}.
247
+ */
248
+ declare class BackgroundSyncPlugin implements SerwistPlugin {
249
+ private readonly _queue;
250
+ /**
251
+ * @param name See the {@linkcode BackgroundSyncQueue}
252
+ * documentation for parameter details.
253
+ * @param options See the {@linkcode BackgroundSyncQueue}
254
+ * documentation for parameter details.
255
+ * @see https://serwist.pages.dev/docs/serwist/core/background-sync-queue
256
+ */
257
+ constructor(name: string, options?: BackgroundSyncQueueOptions);
258
+ /**
259
+ * @param options
260
+ * @private
261
+ */
262
+ fetchDidFail({
263
+ request
264
+ }: FetchDidFailCallbackParam): Promise<void>;
265
+ }
266
+ //#endregion
267
+ //#region src/lib/backgroundSync/StorableRequest.d.ts
268
+ interface RequestData extends MapLikeObject {
269
+ url: string;
270
+ headers: MapLikeObject;
271
+ body?: ArrayBuffer;
272
+ }
273
+ /**
274
+ * A class to make it easier to serialize and de-serialize requests so they
275
+ * can be stored in IndexedDB.
276
+ *
277
+ * Most developers will not need to access this class directly;
278
+ * it is exposed for advanced use cases.
279
+ */
280
+ declare class StorableRequest {
281
+ private readonly _requestData;
282
+ /**
283
+ * Converts a Request object to a plain object that can be structured
284
+ * cloned or stringified to JSON.
285
+ *
286
+ * @param request
287
+ * @returns
288
+ */
289
+ static fromRequest(request: Request): Promise<StorableRequest>;
290
+ /**
291
+ * Accepts an object of request data that can be used to construct a
292
+ * `Request` object but can also be stored in IndexedDB.
293
+ *
294
+ * @param requestData An object of request data that includes the `url` plus any relevant property of
295
+ * [`requestInit`](https://fetch.spec.whatwg.org/#requestinit).
296
+ */
297
+ constructor(requestData: RequestData);
298
+ /**
299
+ * Returns a deep clone of the instance's `requestData` object.
300
+ *
301
+ * @returns
302
+ */
303
+ toObject(): RequestData;
304
+ /**
305
+ * Converts this instance to a Request.
306
+ *
307
+ * @returns
308
+ */
309
+ toRequest(): Request;
310
+ /**
311
+ * Creates and returns a deep clone of the instance.
312
+ *
313
+ * @returns
314
+ */
315
+ clone(): StorableRequest;
316
+ }
317
+ //#endregion
318
+ //#region src/lib/backgroundSync/BackgroundSyncQueueDb.d.ts
319
+ interface UnidentifiedQueueStoreEntry {
320
+ requestData: RequestData;
321
+ timestamp: number;
322
+ id?: number;
323
+ queueName?: string;
324
+ metadata?: Record<string, unknown>;
325
+ }
326
+ interface BackgroundSyncQueueStoreEntry extends UnidentifiedQueueStoreEntry {
327
+ id: number;
328
+ }
329
+ //#endregion
330
+ //#region src/lib/backgroundSync/BackgroundSyncQueueStore.d.ts
331
+ /**
332
+ * A class to manage storing requests from a Queue in IndexedDB,
333
+ * indexed by their queue name for easier access.
334
+ *
335
+ * Most developers will not need to access this class directly;
336
+ * it is exposed for advanced use cases.
337
+ */
338
+ declare class BackgroundSyncQueueStore {
339
+ private readonly _queueName;
340
+ private readonly _queueDb;
341
+ /**
342
+ * Associates this instance with a Queue instance, so entries added can be
343
+ * identified by their queue name.
344
+ *
345
+ * @param queueName
346
+ */
347
+ constructor(queueName: string);
348
+ /**
349
+ * Append an entry last in the queue.
350
+ *
351
+ * @param entry
352
+ */
353
+ pushEntry(entry: UnidentifiedQueueStoreEntry): Promise<void>;
354
+ /**
355
+ * Prepend an entry first in the queue.
356
+ *
357
+ * @param entry
358
+ */
359
+ unshiftEntry(entry: UnidentifiedQueueStoreEntry): Promise<void>;
360
+ /**
361
+ * Removes and returns the last entry in the queue matching the `queueName`.
362
+ *
363
+ * @returns
364
+ */
365
+ popEntry(): Promise<BackgroundSyncQueueStoreEntry | undefined>;
366
+ /**
367
+ * Removes and returns the first entry in the queue matching the `queueName`.
368
+ *
369
+ * @returns
370
+ */
371
+ shiftEntry(): Promise<BackgroundSyncQueueStoreEntry | undefined>;
372
+ /**
373
+ * Returns all entries in the store matching the `queueName`.
374
+ *
375
+ * @returns
376
+ */
377
+ getAll(): Promise<BackgroundSyncQueueStoreEntry[]>;
378
+ /**
379
+ * Returns the number of entries in the store matching the `queueName`.
380
+ *
381
+ * @returns
382
+ */
383
+ size(): Promise<number>;
384
+ /**
385
+ * Deletes the entry for the given ID.
386
+ *
387
+ * WARNING: this method does not ensure the deleted entry belongs to this
388
+ * queue (i.e. matches the `queueName`). But this limitation is acceptable
389
+ * as this class is not publicly exposed. An additional check would make
390
+ * this method slower than it needs to be.
391
+ *
392
+ * @param id
393
+ */
394
+ deleteEntry(id: number): Promise<void>;
395
+ /**
396
+ * Removes and returns the first or last entry in the queue (based on the
397
+ * `direction` argument) matching the `queueName`.
398
+ *
399
+ * @returns
400
+ * @private
401
+ */
402
+ _removeEntry(entry?: BackgroundSyncQueueStoreEntry): Promise<BackgroundSyncQueueStoreEntry | undefined>;
403
+ }
404
+ //#endregion
405
+ //#region src/lib/broadcastUpdate/constants.d.ts
406
+ declare const BROADCAST_UPDATE_MESSAGE_TYPE = "CACHE_UPDATED";
407
+ declare const BROADCAST_UPDATE_MESSAGE_META = "serwist-broadcast-update";
408
+ declare const BROADCAST_UPDATE_DEFAULT_HEADERS: string[];
409
+ //#endregion
410
+ //#region src/lib/broadcastUpdate/types.d.ts
411
+ interface BroadcastCacheUpdateOptions {
412
+ /**
413
+ * A list of headers that will be used to determine whether the responses
414
+ * differ.
415
+ *
416
+ * @default
417
+ * ['content-length', 'etag', 'last-modified']`
418
+ */
419
+ headersToCheck?: string[];
420
+ /**
421
+ * A function whose return value
422
+ * will be used as the `payload` field in any cache update messages sent
423
+ * to the window clients.
424
+ * @param options
425
+ * @returns
426
+ */
427
+ generatePayload?: (options: CacheDidUpdateCallbackParam) => Record<string, any>;
428
+ /**
429
+ * If `true` (the default) then all open clients will receive a message. If `false`,
430
+ * then only the client that make the original request will be notified of the update.
431
+ *
432
+ * @default true
433
+ */
434
+ notifyAllClients?: boolean;
435
+ }
436
+ type BroadcastPayload = Record<string, any>;
437
+ type BroadcastPayloadGenerator = (options: CacheDidUpdateCallbackParam) => BroadcastPayload;
438
+ interface BroadcastMessage {
439
+ type: typeof BROADCAST_UPDATE_MESSAGE_TYPE;
440
+ meta: typeof BROADCAST_UPDATE_MESSAGE_META;
441
+ payload: BroadcastPayload;
442
+ }
443
+ //#endregion
444
+ //#region src/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts
445
+ /**
446
+ * A class that uses the `postMessage()` API to inform any open windows/tabs when
447
+ * a cached response has been updated.
448
+ *
449
+ * For efficiency's sake, the underlying response bodies are not compared;
450
+ * only specific response headers are checked.
451
+ */
452
+ declare class BroadcastCacheUpdate {
453
+ private readonly _headersToCheck;
454
+ private readonly _generatePayload;
455
+ private readonly _notifyAllClients;
456
+ /**
457
+ * Construct an instance of `BroadcastCacheUpdate`.
458
+ *
459
+ * @param options
460
+ */
461
+ constructor({
462
+ generatePayload,
463
+ headersToCheck,
464
+ notifyAllClients
465
+ }?: BroadcastCacheUpdateOptions);
466
+ /**
467
+ * Compares two responses and sends a message (via `postMessage()`) to all window clients if the
468
+ * responses differ. Neither of the Responses can be opaque.
469
+ *
470
+ * The message that's posted has the following format (where `payload` can
471
+ * be customized via the `generatePayload` option the instance is created
472
+ * with):
473
+ *
474
+ * ```
475
+ * {
476
+ * type: 'CACHE_UPDATED',
477
+ * meta: 'workbox-broadcast-update',
478
+ * payload: {
479
+ * cacheName: 'the-cache-name',
480
+ * updatedURL: 'https://example.com/'
481
+ * }
482
+ * }
483
+ * ```
484
+ *
485
+ * @param options
486
+ * @returns Resolves once the update is sent.
487
+ */
488
+ notifyIfUpdated(options: CacheDidUpdateCallbackParam): Promise<void>;
489
+ }
490
+ //#endregion
491
+ //#region src/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts
492
+ /**
493
+ * A class implementing the `cacheDidUpdate` lifecycle callback. It will automatically
494
+ * broadcast a message whenever a cached response is updated.
495
+ */
496
+ declare class BroadcastUpdatePlugin implements SerwistPlugin {
497
+ private readonly _broadcastUpdate;
498
+ /**
499
+ * Construct a {@linkcode BroadcastCacheUpdate} instance with
500
+ * the passed options and calls its {@linkcode BroadcastCacheUpdate.notifyIfUpdated}
501
+ * method whenever the plugin's {@linkcode BroadcastUpdatePlugin.cacheDidUpdate} callback
502
+ * is invoked.
503
+ *
504
+ * @param options
505
+ */
506
+ constructor(options?: BroadcastCacheUpdateOptions);
507
+ /**
508
+ * @private
509
+ * @param options The input object to this function.
510
+ */
511
+ cacheDidUpdate(options: CacheDidUpdateCallbackParam): void;
512
+ }
513
+ //#endregion
514
+ //#region src/lib/broadcastUpdate/responsesAreSame.d.ts
515
+ /**
516
+ * Given two responses, compares several header values to see if they are
517
+ * the same or not.
518
+ *
519
+ * @param firstResponse The first response.
520
+ * @param secondResponse The second response.
521
+ * @param headersToCheck A list of headers to check.
522
+ * @returns
523
+ */
524
+ declare const responsesAreSame: (firstResponse: Response, secondResponse: Response, headersToCheck: string[]) => boolean;
525
+ //#endregion
526
+ //#region src/lib/cacheableResponse/CacheableResponse.d.ts
527
+ interface CacheableResponseOptions {
528
+ /**
529
+ * One or more HTTP status codes that a response can have to be considered cacheable.
530
+ */
531
+ statuses?: number[];
532
+ /**
533
+ * A mapping of header names and expected values that a response can have and be
534
+ * considered cacheable. If multiple headers are provided, only one needs to be present.
535
+ */
536
+ headers?: HeadersInit;
537
+ }
538
+ /**
539
+ * Allows you to set up rules determining what status codes and/or headers need
540
+ * to be present in order for a [response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
541
+ * to be considered cacheable.
542
+ */
543
+ declare class CacheableResponse {
544
+ private readonly _statuses?;
545
+ private readonly _headers?;
546
+ /**
547
+ * To construct a new `CacheableResponse` instance you must provide at least
548
+ * one of the `config` properties.
549
+ *
550
+ * If both `statuses` and `headers` are specified, then both conditions must
551
+ * be met for the response to be considered cacheable.
552
+ *
553
+ * @param config
554
+ */
555
+ constructor(config?: CacheableResponseOptions);
556
+ /**
557
+ * Checks a response to see whether it's cacheable or not.
558
+ *
559
+ * @param response The response whose cacheability is being
560
+ * checked.
561
+ * @returns `true` if the response is cacheable, and `false`
562
+ * otherwise.
563
+ */
564
+ isResponseCacheable(response: Response): boolean;
565
+ }
566
+ //#endregion
567
+ //#region src/lib/cacheableResponse/CacheableResponsePlugin.d.ts
568
+ /**
569
+ * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it
570
+ * easier to add in cacheability checks to requests made via Serwist's built-in
571
+ * strategies.
572
+ */
573
+ declare class CacheableResponsePlugin implements SerwistPlugin {
574
+ private readonly _cacheableResponse;
575
+ /**
576
+ * To construct a new `CacheableResponsePlugin` instance you must provide at
577
+ * least one of the `config` properties.
578
+ *
579
+ * If both `statuses` and `headers` are specified, then both conditions must
580
+ * be met for the response to be considered cacheable.
581
+ *
582
+ * @param config
583
+ */
584
+ constructor(config: CacheableResponseOptions);
585
+ /**
586
+ * @param options
587
+ * @returns
588
+ * @private
589
+ */
590
+ cacheWillUpdate: SerwistPlugin["cacheWillUpdate"];
591
+ }
592
+ //#endregion
593
+ //#region src/lib/expiration/CacheExpiration.d.ts
594
+ interface CacheExpirationConfig {
595
+ /**
596
+ * The maximum number of entries to cache. Entries used least recently will
597
+ * be removed as the maximum is reached.
598
+ */
599
+ maxEntries?: number;
600
+ /**
601
+ * The maximum age of an entry before it's treated as stale and removed.
602
+ */
603
+ maxAgeSeconds?: number;
604
+ /**
605
+ * The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters)
606
+ * that will be used when calling `delete()` on the cache.
607
+ */
608
+ matchOptions?: CacheQueryOptions;
609
+ }
610
+ /**
611
+ * Allows you to expires cached responses based on age or maximum number of entries.
612
+ * @see https://serwist.pages.dev/docs/serwist/core/cache-expiration
613
+ */
614
+ declare class CacheExpiration {
615
+ private _isRunning;
616
+ private _rerunRequested;
617
+ private readonly _maxEntries?;
618
+ private readonly _maxAgeSeconds?;
619
+ private readonly _matchOptions?;
620
+ private readonly _cacheName;
621
+ private readonly _timestampModel;
622
+ /**
623
+ * To construct a new `CacheExpiration` instance you must provide at least
624
+ * one of the `config` properties.
625
+ *
626
+ * @param cacheName Name of the cache to apply restrictions to.
627
+ * @param config
628
+ */
629
+ constructor(cacheName: string, config?: CacheExpirationConfig);
630
+ /**
631
+ * Expires entries for the given cache and given criteria.
632
+ */
633
+ expireEntries(): Promise<void>;
634
+ /**
635
+ * Updates the timestamp for the given URL, allowing it to be correctly
636
+ * tracked by the class.
637
+ *
638
+ * @param url
639
+ */
640
+ updateTimestamp(url: string): Promise<void>;
641
+ /**
642
+ * Checks if a URL has expired or not before it's used.
643
+ *
644
+ * This looks the timestamp up in IndexedDB and can be slow.
645
+ *
646
+ * Note: This method does not remove an expired entry, call
647
+ * `expireEntries()` to remove such entries instead.
648
+ *
649
+ * @param url
650
+ * @returns
651
+ */
652
+ isURLExpired(url: string): Promise<boolean>;
653
+ /**
654
+ * Removes the IndexedDB used to keep track of cache expiration metadata.
655
+ */
656
+ delete(): Promise<void>;
657
+ }
658
+ //#endregion
659
+ //#region src/lib/expiration/ExpirationPlugin.d.ts
660
+ interface ExpirationPluginOptions {
661
+ /**
662
+ * The maximum number of entries to cache. Entries used (if `maxAgeFrom` is
663
+ * `"last-used"`) or fetched from the network (if `maxAgeFrom` is `"last-fetched"`)
664
+ * least recently will be removed as the maximum is reached.
665
+ */
666
+ maxEntries?: number;
667
+ /**
668
+ * The maximum number of seconds before an entry is treated as stale and removed.
669
+ */
670
+ maxAgeSeconds?: number;
671
+ /**
672
+ * Determines whether `maxAgeSeconds` should be calculated from when an
673
+ * entry was last fetched or when it was last used.
674
+ *
675
+ * @default "last-fetched"
676
+ */
677
+ maxAgeFrom?: "last-fetched" | "last-used";
678
+ /**
679
+ * The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters)
680
+ * that will be used when calling `delete()` on the cache.
681
+ */
682
+ matchOptions?: CacheQueryOptions;
683
+ /**
684
+ * Whether to opt this cache into automatic deletion if the available storage quota has been exceeded.
685
+ */
686
+ purgeOnQuotaError?: boolean;
687
+ }
688
+ /**
689
+ * This plugin can be used in a {@linkcode Strategy} to regularly enforce a
690
+ * limit on the age and/or the number of cached requests.
691
+ *
692
+ * It can only be used with {@linkcode Strategy} instances that have a custom `cacheName` property set.
693
+ * In other words, it can't be used to expire entries in strategies that use the default runtime
694
+ * cache name.
695
+ *
696
+ * Whenever a cached response is used or updated, this plugin will look
697
+ * at the associated cache and remove any old or extra responses.
698
+ *
699
+ * When using `maxAgeSeconds`, responses may be used *once* after expiring
700
+ * because the expiration clean up will not have occurred until *after* the
701
+ * cached response has been used. If the response has a "Date" header, then a lightweight expiration
702
+ * check is performed, and the response will not be used immediately.
703
+ *
704
+ * When using `maxEntries`, the least recently requested entry will be removed
705
+ * from the cache.
706
+ *
707
+ * @see https://serwist.pages.dev/docs/serwist/runtime-caching/plugins/expiration-plugin
708
+ */
709
+ declare class ExpirationPlugin implements SerwistPlugin {
710
+ private readonly _config;
711
+ private _cacheExpirations;
712
+ /**
713
+ * @param config
714
+ */
715
+ constructor(config?: ExpirationPluginOptions);
716
+ /**
717
+ * A simple helper method to return a CacheExpiration instance for a given
718
+ * cache name.
719
+ *
720
+ * @param cacheName
721
+ * @returns
722
+ * @private
723
+ */
724
+ private _getCacheExpiration;
725
+ /**
726
+ * A lifecycle callback that will be triggered automatically when a
727
+ * response is about to be returned from a [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
728
+ * It allows the response to be inspected for freshness and
729
+ * prevents it from being used if the response's `Date` header value is
730
+ * older than the configured `maxAgeSeconds`.
731
+ *
732
+ * @param options
733
+ * @returns `cachedResponse` if it is fresh and `null` if it is stale or
734
+ * not available.
735
+ * @private
736
+ */
737
+ cachedResponseWillBeUsed({
738
+ event,
739
+ cacheName,
740
+ request,
741
+ cachedResponse
742
+ }: CachedResponseWillBeUsedCallbackParam): Response | null;
743
+ /**
744
+ * @param cachedResponse
745
+ * @returns
746
+ * @private
747
+ */
748
+ private _isResponseDateFresh;
749
+ /**
750
+ * Extracts the `Date` header and parse it into an useful value.
751
+ *
752
+ * @param cachedResponse
753
+ * @returns
754
+ * @private
755
+ */
756
+ private _getDateHeaderTimestamp;
757
+ /**
758
+ * A lifecycle callback that will be triggered automatically when an entry is added
759
+ * to a cache.
760
+ *
761
+ * @param options
762
+ * @private
763
+ */
764
+ cacheDidUpdate({
765
+ cacheName,
766
+ request
767
+ }: CacheDidUpdateCallbackParam): Promise<void>;
768
+ /**
769
+ * Deletes the underlying `Cache` instance associated with this instance and the metadata
770
+ * from IndexedDB used to keep track of expiration details for each `Cache` instance.
771
+ *
772
+ * When using cache expiration, calling this method is preferable to calling
773
+ * `caches.delete()` directly, since this will ensure that the IndexedDB
774
+ * metadata is also cleanly removed and that open IndexedDB instances are deleted.
775
+ *
776
+ * Note that if you're *not* using cache expiration for a given cache, calling
777
+ * `caches.delete()` and passing in the cache's name should be sufficient.
778
+ * There is no Serwist-specific method needed for cleanup in that case.
779
+ */
780
+ deleteCacheAndMetadata(): Promise<void>;
781
+ }
782
+ //#endregion
783
+ //#region src/lib/precaching/PrecacheFallbackPlugin.d.ts
784
+ interface PrecacheFallbackEntry {
785
+ /**
786
+ * A precached URL to be used as a fallback.
787
+ */
788
+ url: string;
789
+ /**
790
+ * A function that checks whether the fallback entry can be used
791
+ * for a request.
792
+ */
793
+ matcher: (param: HandlerDidErrorCallbackParam) => boolean;
794
+ }
795
+ interface PrecacheFallbackPluginOptions {
796
+ /**
797
+ * Precached URLs to be used as the fallback
798
+ * if the associated strategy can't generate a response.
799
+ */
800
+ fallbackUrls: (string | PrecacheFallbackEntry)[];
801
+ /**
802
+ * A {@linkcode Serwist} instance.
803
+ */
804
+ serwist: Serwist;
805
+ }
806
+ /**
807
+ * Allows you to specify offline fallbacks to be used when a given strategy
808
+ * is unable to generate a response.
809
+ *
810
+ * It does this by intercepting the `handlerDidError` plugin callback
811
+ * and returning a precached response, taking the expected revision parameter
812
+ * into account automatically.
813
+ */
814
+ declare class PrecacheFallbackPlugin implements SerwistPlugin {
815
+ private readonly _fallbackUrls;
816
+ private readonly _serwist;
817
+ /**
818
+ * Constructs a new instance with the associated `fallbackUrls`.
819
+ *
820
+ * @param config
821
+ */
822
+ constructor({
823
+ fallbackUrls,
824
+ serwist
825
+ }: PrecacheFallbackPluginOptions);
826
+ /**
827
+ * @returns The precache response for one of the fallback URLs, or `undefined` if
828
+ * nothing satisfies the conditions.
829
+ * @private
830
+ */
831
+ handlerDidError(param: HandlerDidErrorCallbackParam): Promise<Response | undefined>;
832
+ }
833
+ //#endregion
834
+ //#region src/Serwist.d.ts
835
+ interface FallbackEntry extends PrecacheFallbackEntry {}
836
+ interface FallbacksOptions {
837
+ /**
838
+ * A list of fallback entries.
839
+ */
840
+ entries: FallbackEntry[];
841
+ }
842
+ interface SerwistOptions {
843
+ /**
844
+ * A list of URLs that should be cached.
845
+ */
846
+ precacheEntries?: (PrecacheEntry | string)[];
847
+ /**
848
+ * Options to customize how Serwist precaches the URLs in the precache list.
849
+ */
850
+ precacheOptions?: PrecacheOptions;
851
+ /**
852
+ * Forces the waiting service worker to become the active one.
853
+ *
854
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting
855
+ */
856
+ skipWaiting?: boolean;
857
+ /**
858
+ * Imports external scripts. They are executed in the order they
859
+ * are passed.
860
+ *
861
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
862
+ */
863
+ importScripts?: string[];
864
+ /**
865
+ * Enables navigation preloading if it is supported.
866
+ *
867
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload
868
+ */
869
+ navigationPreload?: boolean;
870
+ /**
871
+ * Modifies the prefix of the default cache names used by Serwist packages.
872
+ */
873
+ cacheId?: string | undefined;
874
+ /**
875
+ * Claims any currently available clients once the service worker
876
+ * becomes active. This is normally used in conjunction with `skipWaiting()`.
877
+ *
878
+ * @default false
879
+ */
880
+ clientsClaim?: boolean;
881
+ /**
882
+ * A list of caching strategies.
883
+ */
884
+ runtimeCaching?: RuntimeCaching[];
885
+ /**
886
+ * Request rules that define how certain resources should be fetched
887
+ * before the service worker starts up.
888
+ *
889
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/InstallEvent/addRoutes
890
+ * @experimental
891
+ */
892
+ requestRules?: RequestRule | RequestRule[];
893
+ /**
894
+ * Your configuration for {@linkcode initializeGoogleAnalytics}. This plugin is
895
+ * only initialized when this option is not `undefined` or `false`.
896
+ */
897
+ offlineAnalyticsConfig?: Omit<GoogleAnalyticsInitializeOptions, "serwist"> | boolean;
898
+ /**
899
+ * Disables Serwist's logging in development mode.
900
+ *
901
+ * @default false
902
+ */
903
+ disableDevLogs?: boolean;
904
+ /**
905
+ * Precaches routes so that they can be used as a fallback when
906
+ * a {@linkcode Strategy} fails to generate a response.
907
+ *
908
+ * Note: This option mutates `runtimeCaching`. It also expects the URLs
909
+ * defined in `entries` to have been precached beforehand.
910
+ */
911
+ fallbacks?: FallbacksOptions;
912
+ }
913
+ /**
914
+ * A class that helps bootstrap the service worker.
915
+ *
916
+ * @see https://serwist.pages.dev/docs/serwist/core/serwist
917
+ */
918
+ declare class Serwist {
919
+ private readonly _urlsToCacheKeys;
920
+ private readonly _urlsToCacheModes;
921
+ private readonly _cacheKeysToIntegrities;
922
+ private _concurrentPrecaching;
923
+ private readonly _precacheStrategy;
924
+ private readonly _routes;
925
+ private readonly _defaultHandlerMap;
926
+ private _catchHandler?;
927
+ private _requestRules?;
928
+ constructor({
929
+ precacheEntries,
930
+ precacheOptions,
931
+ skipWaiting,
932
+ importScripts,
933
+ navigationPreload,
934
+ cacheId,
935
+ clientsClaim,
936
+ runtimeCaching,
937
+ offlineAnalyticsConfig,
938
+ disableDevLogs,
939
+ fallbacks,
940
+ requestRules
941
+ }?: SerwistOptions);
942
+ /**
943
+ * The strategy used to precache assets and respond to `fetch` events.
944
+ */
945
+ get precacheStrategy(): Strategy;
946
+ /**
947
+ * A `Map` of HTTP method name (`'GET'`, etc.) to an array of all corresponding registered {@linkcode Route}
948
+ * instances.
949
+ */
950
+ get routes(): Map<HTTPMethod, Route[]>;
951
+ /**
952
+ * Adds Serwist's event listeners for you. Before calling it, add your own listeners should you need to.
953
+ */
954
+ addEventListeners(): void;
955
+ /**
956
+ * Adds items to the precache list, removing duplicates and ensuring the information is valid.
957
+ *
958
+ * @param entries Array of entries to precache.
959
+ */
960
+ addToPrecacheList(entries: (PrecacheEntry | string)[]): void;
961
+ /**
962
+ * Precaches new and updated assets. Call this method from the service worker's
963
+ * `install` event.
964
+ *
965
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
966
+ * to call it yourself in your event handlers.
967
+ *
968
+ * @param event
969
+ * @returns
970
+ */
971
+ handleInstall(event: InstallEvent): Promise<InstallResult>;
972
+ /**
973
+ * Registers request rules using the experimental `InstallEvent.addRoutes()` API.
974
+ * These rules allow bypassing the service worker for specific requests to improve performance.
975
+ *
976
+ * @param event The event object of an `install` event handler.
977
+ * @throws {Error} When the route rules are invalid
978
+ */
979
+ registerRequestRules(event: InstallEvent): Promise<void>;
980
+ /**
981
+ * Deletes assets that are no longer present in the current precache manifest.
982
+ * Call this method from the service worker's `activate` event.
983
+ *
984
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
985
+ * to call it yourself in your event handlers.
986
+ *
987
+ * @param event
988
+ * @returns
989
+ */
990
+ handleActivate(event: ExtendableEvent): Promise<CleanupResult>;
991
+ /**
992
+ * Gets a `Response` from an appropriate `Route`'s handler. Call this method
993
+ * from the service worker's `fetch` event.
994
+ * @param event
995
+ */
996
+ handleFetch(event: FetchEvent): void;
997
+ /**
998
+ * Caches new URLs on demand. Call this method from the service worker's
999
+ * `message` event. To trigger the handler, send a message of type `"CACHE_URLS"`
1000
+ * alongside a list of URLs that should be cached as `urlsToCache`.
1001
+ * @param event
1002
+ */
1003
+ handleCache(event: ExtendableMessageEvent): void;
1004
+ /**
1005
+ * Define a default handler that's called when no routes explicitly
1006
+ * match the incoming request.
1007
+ *
1008
+ * Each HTTP method (`'GET'`, `'POST'`, etc.) gets its own default handler.
1009
+ *
1010
+ * Without a default handler, unmatched requests will go against the
1011
+ * network as if there were no service worker present.
1012
+ *
1013
+ * @param handler A callback function that returns a `Promise` resulting in a `Response`.
1014
+ * @param method The HTTP method to associate with this default handler. Each method
1015
+ * has its own default. Defaults to `'GET'`.
1016
+ */
1017
+ setDefaultHandler(handler: RouteHandler, method?: HTTPMethod): void;
1018
+ /**
1019
+ * If a {@linkcode Route} throws an error while handling a request, this handler
1020
+ * will be called and given a chance to provide a response.
1021
+ *
1022
+ * @param handler A callback function that returns a `Promise` resulting
1023
+ * in a `Response`.
1024
+ */
1025
+ setCatchHandler(handler: RouteHandler): void;
1026
+ /**
1027
+ * Registers a `RegExp`, string, or function with a caching
1028
+ * strategy to the router.
1029
+ *
1030
+ * @param capture If the capture param is a {@linkcode Route} object, all other arguments will be ignored.
1031
+ * @param handler A callback function that returns a `Promise` resulting in a `Response`.
1032
+ * This parameter is required if `capture` is not a {@linkcode Route} object.
1033
+ * @param method The HTTP method to match the route against. Defaults to `'GET'`.
1034
+ * @returns The generated {@linkcode Route} object.
1035
+ */
1036
+ registerCapture<T extends RegExp | string | RouteMatchCallback | Route>(capture: T, handler?: T extends Route ? never : RouteHandler, method?: T extends Route ? never : HTTPMethod): Route;
1037
+ /**
1038
+ * Registers a {@linkcode Route} with the router.
1039
+ *
1040
+ * @param route The {@linkcode Route} to register.
1041
+ */
1042
+ registerRoute(route: Route): void;
1043
+ /**
1044
+ * Unregisters a route from the router.
1045
+ *
1046
+ * @param route The {@linkcode Route} object to unregister.
1047
+ */
1048
+ unregisterRoute(route: Route): void;
1049
+ /**
1050
+ * Returns a mapping of a precached URL to the corresponding cache key, taking
1051
+ * into account the revision information for the URL.
1052
+ *
1053
+ * @returns A URL to cache key mapping.
1054
+ */
1055
+ getUrlsToPrecacheKeys(): Map<string, string>;
1056
+ /**
1057
+ * Returns a list of all the URLs that have been precached by the current
1058
+ * service worker.
1059
+ *
1060
+ * @returns The precached URLs.
1061
+ */
1062
+ getPrecachedUrls(): string[];
1063
+ /**
1064
+ * Returns the cache key used for storing a given URL. If that URL is
1065
+ * unversioned, like "/index.html", then the cache key will be the original
1066
+ * URL with a search parameter appended to it.
1067
+ *
1068
+ * @param url A URL whose cache key you want to look up.
1069
+ * @returns The versioned URL that corresponds to a cache key
1070
+ * for the original URL, or undefined if that URL isn't precached.
1071
+ */
1072
+ getPrecacheKeyForUrl(url: string): string | undefined;
1073
+ /**
1074
+ * @param url A cache key whose SRI you want to look up.
1075
+ * @returns The subresource integrity associated with the cache key,
1076
+ * or undefined if it's not set.
1077
+ */
1078
+ getIntegrityForPrecacheKey(cacheKey: string): string | undefined;
1079
+ /**
1080
+ * This acts as a drop-in replacement for
1081
+ * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
1082
+ * with the following differences:
1083
+ *
1084
+ * - It knows what the name of the precache is, and only checks in that cache.
1085
+ * - It allows you to pass in an "original" URL without versioning parameters,
1086
+ * and it will automatically look up the correct cache key for the currently
1087
+ * active revision of that URL.
1088
+ *
1089
+ * E.g., `matchPrecache('index.html')` will find the correct precached
1090
+ * response for the currently active service worker, even if the actual cache
1091
+ * key is `'/index.html?__WB_REVISION__=1234abcd'`.
1092
+ *
1093
+ * @param request The key (without revisioning parameters)
1094
+ * to look up in the precache.
1095
+ * @returns
1096
+ */
1097
+ matchPrecache(request: string | Request): Promise<Response | undefined>;
1098
+ /**
1099
+ * Returns a function that looks up `url` in the precache (taking into
1100
+ * account revision information), and returns the corresponding `Response`.
1101
+ *
1102
+ * @param url The precached URL which will be used to lookup the response.
1103
+ * @return
1104
+ */
1105
+ createHandlerBoundToUrl(url: string): RouteHandlerCallback;
1106
+ /**
1107
+ * Applies the routing rules to a `FetchEvent` object to get a response from an
1108
+ * appropriate route.
1109
+ *
1110
+ * @param options
1111
+ * @returns A promise is returned if a registered route can handle the request.
1112
+ * If there is no matching route and there's no default handler, `undefined`
1113
+ * is returned.
1114
+ */
1115
+ handleRequest({
1116
+ request,
1117
+ event
1118
+ }: {
1119
+ /**
1120
+ * The request to handle.
1121
+ */
1122
+ request: Request;
1123
+ /**
1124
+ * The event that triggered the request.
1125
+ */
1126
+ event: ExtendableEvent;
1127
+ }): Promise<Response> | undefined;
1128
+ /**
1129
+ * Checks a request and URL (and optionally an event) against the list of
1130
+ * registered routes, and if there's a match, returns the corresponding
1131
+ * route along with any params generated by the match.
1132
+ *
1133
+ * @param options
1134
+ * @returns An object with `route` and `params` properties. They are populated
1135
+ * if a matching route was found or `undefined` otherwise.
1136
+ */
1137
+ findMatchingRoute({
1138
+ url,
1139
+ sameOrigin,
1140
+ request,
1141
+ event
1142
+ }: RouteMatchCallbackOptions): {
1143
+ route?: Route;
1144
+ params?: RouteHandlerCallbackOptions["params"];
1145
+ };
1146
+ }
1147
+ //#endregion
1148
+ //#region src/lib/googleAnalytics/initializeGoogleAnalytics.d.ts
1149
+ interface GoogleAnalyticsInitializeOptions {
1150
+ serwist: Serwist;
1151
+ /**
1152
+ * The cache name to store and retrieve analytics.js. Defaults to Serwist's default cache names.
1153
+ */
1154
+ cacheName?: string;
1155
+ /**
1156
+ * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
1157
+ * expressed as key/value pairs, to be added to replayed Google Analytics
1158
+ * requests. This can be used to, e.g., set a custom dimension indicating
1159
+ * that the request was replayed.
1160
+ */
1161
+ parameterOverrides?: {
1162
+ [paramName: string]: string;
1163
+ };
1164
+ /**
1165
+ * A function that allows you to modify the hit parameters prior to replaying
1166
+ * the hit. The function is invoked with the original hit's URLSearchParams
1167
+ * object as its only argument.
1168
+ */
1169
+ hitFilter?: (params: URLSearchParams) => void;
1170
+ }
1171
+ /**
1172
+ * Initialize Serwist's offline Google Analytics v3 support.
1173
+ *
1174
+ * @param options
1175
+ */
1176
+ declare const initializeGoogleAnalytics: ({
1177
+ serwist,
1178
+ cacheName,
1179
+ ...options
1180
+ }: GoogleAnalyticsInitializeOptions) => void;
1181
+ //#endregion
1182
+ //#region src/lib/rangeRequests/createPartialResponse.d.ts
1183
+ /**
1184
+ * Given a request and a response, this will return a
1185
+ * promise that resolves to a partial response.
1186
+ *
1187
+ * If the original response already contains partial content (i.e. it has
1188
+ * a status of 206), then this assumes it already fulfills the `Range`
1189
+ * requirements, and will return it as-is.
1190
+ *
1191
+ * @param request A request, which should contain a `Range`
1192
+ * header.
1193
+ * @param originalResponse A response.
1194
+ * @returns Either a `206 Partial Content` response, with
1195
+ * the response body set to the slice of content specified by the request's
1196
+ * `Range` header, or a `416 Range Not Satisfiable` response if the
1197
+ * conditions of the `Range` header can't be met.
1198
+ */
1199
+ declare const createPartialResponse: (request: Request, originalResponse: Response) => Promise<Response>;
1200
+ //#endregion
1201
+ //#region src/lib/rangeRequests/RangeRequestsPlugin.d.ts
1202
+ /**
1203
+ * Makes it easy for a request with a `Range` header to be fulfilled by a cached response.
1204
+ *
1205
+ * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
1206
+ * and returning the appropriate subset of the cached response body.
1207
+ */
1208
+ declare class RangeRequestsPlugin implements SerwistPlugin {
1209
+ /**
1210
+ * @param options
1211
+ * @returns If request contains a `Range` header, then a
1212
+ * partial response whose body is a subset of `cachedResponse` is
1213
+ * returned. Otherwise, `cachedResponse` is returned as-is.
1214
+ * @private
1215
+ */
1216
+ cachedResponseWillBeUsed: SerwistPlugin["cachedResponseWillBeUsed"];
1217
+ }
1218
+ //#endregion
1219
+ //#region src/lib/strategies/CacheFirst.d.ts
1220
+ /**
1221
+ * An implementation of the [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache_first_falling_back_to_network)
1222
+ * request strategy.
1223
+ *
1224
+ * A cache first strategy is useful for assets that have been revisioned,
1225
+ * such as URLs like "/styles/example.a8f5f1.css", since they
1226
+ * can be cached for long periods of time.
1227
+ *
1228
+ * If the network request fails, and there is no cache match, this will throw
1229
+ * a {@linkcode SerwistError} exception.
1230
+ */
1231
+ declare class CacheFirst extends Strategy {
1232
+ /**
1233
+ * @private
1234
+ * @param request A request to run this strategy for.
1235
+ * @param handler The event that triggered the request.
1236
+ * @returns
1237
+ */
1238
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
1239
+ }
1240
+ //#endregion
1241
+ //#region src/lib/strategies/CacheOnly.d.ts
1242
+ /**
1243
+ * An implementation of the [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache_only)
1244
+ * request strategy.
1245
+ *
1246
+ * This class is useful if you already have your own precaching step.
1247
+ *
1248
+ * If there is no cache match, this will throw a {@linkcode SerwistError} exception.
1249
+ */
1250
+ declare class CacheOnly extends Strategy {
1251
+ /**
1252
+ * @private
1253
+ * @param request A request to run this strategy for.
1254
+ * @param handler The event that triggered the request.
1255
+ * @returns
1256
+ */
1257
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
1258
+ }
1259
+ //#endregion
1260
+ //#region src/lib/strategies/NetworkFirst.d.ts
1261
+ interface NetworkFirstOptions extends StrategyOptions {
1262
+ /**
1263
+ * If set, any network requests that fail to respond within the timeout will fallback to the cache.
1264
+ */
1265
+ networkTimeoutSeconds?: number;
1266
+ }
1267
+ /**
1268
+ * An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network_first_falling_back_to_cache)
1269
+ * request strategy.
1270
+ *
1271
+ * By default, this strategy will cache responses with a 200 status code as
1272
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque_responses).
1273
+ * Opaque responses are are cross-origin requests where the response doesn't
1274
+ * support [CORS](https://enable-cors.org/).
1275
+ *
1276
+ * If the network request fails, and there is no cache match, this will throw
1277
+ * a {@linkcode SerwistError} exception.
1278
+ */
1279
+ declare class NetworkFirst extends Strategy {
1280
+ private readonly _networkTimeoutSeconds;
1281
+ /**
1282
+ * @param options
1283
+ * This option can be used to combat
1284
+ * "[lie-fi](https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi)"
1285
+ * scenarios.
1286
+ */
1287
+ constructor(options?: NetworkFirstOptions);
1288
+ /**
1289
+ * @private
1290
+ * @param request A request to run this strategy for.
1291
+ * @param handler The event that triggered the request.
1292
+ * @returns
1293
+ */
1294
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
1295
+ /**
1296
+ * @param options
1297
+ * @returns
1298
+ * @private
1299
+ */
1300
+ private _getTimeoutPromise;
1301
+ /**
1302
+ * @param options
1303
+ * @param options.timeoutId
1304
+ * @param options.request
1305
+ * @param options.logs A reference to the logs Array.
1306
+ * @param options.event
1307
+ * @returns
1308
+ *
1309
+ * @private
1310
+ */
1311
+ _getNetworkPromise({
1312
+ timeoutId,
1313
+ request,
1314
+ logs,
1315
+ handler
1316
+ }: {
1317
+ request: Request;
1318
+ logs: any[];
1319
+ timeoutId?: number;
1320
+ handler: StrategyHandler;
1321
+ }): Promise<Response | undefined>;
1322
+ }
1323
+ //#endregion
1324
+ //#region src/lib/strategies/NetworkOnly.d.ts
1325
+ interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
1326
+ /**
1327
+ * If set, any network requests that fail to respond within the timeout will result in a network error.
1328
+ */
1329
+ networkTimeoutSeconds?: number;
1330
+ }
1331
+ /**
1332
+ * An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network_only)
1333
+ * request strategy.
1334
+ *
1335
+ * This class is useful if you require specific requests to only be fulfilled from the network.
1336
+ *
1337
+ * If the network request fails, this will throw a {@linkcode SerwistError} exception.
1338
+ */
1339
+ declare class NetworkOnly extends Strategy {
1340
+ private readonly _networkTimeoutSeconds;
1341
+ /**
1342
+ * @param options
1343
+ */
1344
+ constructor(options?: NetworkOnlyOptions);
1345
+ /**
1346
+ * @private
1347
+ * @param request A request to run this strategy for.
1348
+ * @param handler The event that triggered the request.
1349
+ * @returns
1350
+ */
1351
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
1352
+ }
1353
+ //#endregion
1354
+ //#region src/lib/strategies/StaleWhileRevalidate.d.ts
1355
+ /**
1356
+ * An implementation of the
1357
+ * [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale_while_revalidate)
1358
+ * request strategy.
1359
+ *
1360
+ * Resources are requested from both the cache and the network in parallel.
1361
+ * The strategy will respond with the cached version if available, otherwise
1362
+ * wait for the network response. The cache is updated with the network response
1363
+ * with each successful request.
1364
+ *
1365
+ * By default, this strategy will cache responses with a 200 status code as
1366
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
1367
+ * Opaque responses are cross-origin requests where the response doesn't
1368
+ * support [CORS](https://enable-cors.org/).
1369
+ *
1370
+ * If the network request fails, and there is no cache match, this will throw
1371
+ * a {@linkcode SerwistError} exception.
1372
+ */
1373
+ declare class StaleWhileRevalidate extends Strategy {
1374
+ /**
1375
+ * @param options
1376
+ */
1377
+ constructor(options?: StrategyOptions);
1378
+ /**
1379
+ * @private
1380
+ * @param request A request to run this strategy for.
1381
+ * @param handler The event that triggered the request.
1382
+ * @returns
1383
+ */
1384
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
1385
+ }
1386
+ //#endregion
1387
+ //#region src/NavigationRoute.d.ts
1388
+ interface NavigationRouteMatchOptions {
1389
+ /**
1390
+ * If any of these patterns
1391
+ * match the URL's pathname and search parameter, the route will handle the
1392
+ * request (assuming the denylist doesn't match).
1393
+ *
1394
+ * @default [/./]
1395
+ */
1396
+ allowlist?: RegExp[];
1397
+ /**
1398
+ * If any of these patterns match, the route will not handle the request (even if a allowlist RegExp matches).
1399
+ */
1400
+ denylist?: RegExp[];
1401
+ }
1402
+ /**
1403
+ * A class that makes it easy to create a {@linkcode Route} object that matches navigation requests.
1404
+ *
1405
+ * It will only match incoming requests whose [`mode`](https://fetch.spec.whatwg.org/#concept-request-mode) is set to `"navigate"`.
1406
+ *
1407
+ * You can optionally only apply this route to a subset of navigation requests
1408
+ * by using one or both of the `denylist` and `allowlist` parameters.
1409
+ */
1410
+ declare class NavigationRoute extends Route {
1411
+ private readonly _allowlist;
1412
+ private readonly _denylist;
1413
+ /**
1414
+ * If both `denylist` and `allowlist` are provided, `denylist` will
1415
+ * take precedence.
1416
+ *
1417
+ * The regular expressions in `allowlist` and `denylist`
1418
+ * are matched against the concatenated
1419
+ * [`pathname`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname)
1420
+ * and [`search`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search)
1421
+ * portions of the requested URL.
1422
+ *
1423
+ * *Note*: These RegExps may be evaluated against every destination URL during
1424
+ * a navigation. Avoid using
1425
+ * [complex RegExps](https://github.com/GoogleChrome/workbox/issues/3077),
1426
+ * or else your users may see delays when navigating your site.
1427
+ *
1428
+ * @param handler A callback function that returns a `Promise` resulting in a `Response`.
1429
+ * @param options
1430
+ */
1431
+ constructor(handler: RouteHandler, {
1432
+ allowlist,
1433
+ denylist
1434
+ }?: NavigationRouteMatchOptions);
1435
+ /**
1436
+ * Routes match handler.
1437
+ *
1438
+ * @param options
1439
+ * @returns
1440
+ * @private
1441
+ */
1442
+ private _match;
1443
+ }
1444
+ //#endregion
1445
+ //#region src/navigationPreload.d.ts
1446
+ /**
1447
+ * Checks whether the current browser supports
1448
+ * navigation preloading.
1449
+ *
1450
+ * @returns
1451
+ * @see https://serwist.pages.dev/docs/serwist/core/is-navigation-preload-supported
1452
+ */
1453
+ declare const isNavigationPreloadSupported: () => boolean;
1454
+ /**
1455
+ * If the browser supports navigation preloading, then this will enable it.
1456
+ *
1457
+ * @param headerValue Optional. Allows developers to override the value of
1458
+ * the `Service-Worker-Navigation-Preload` header which will be sent to the
1459
+ * server when making the navigation request.
1460
+ * @see https://serwist.pages.dev/docs/serwist/core/enable-navigation-preload
1461
+ */
1462
+ declare const enableNavigationPreload: (headerValue?: string) => void;
1463
+ /**
1464
+ * If the browser supports navigation preloading, then this will disable it.
1465
+ *
1466
+ * @see https://serwist.pages.dev/docs/serwist/core/disable-navigation-preload
1467
+ */
1468
+ declare const disableNavigationPreload: () => void;
1469
+ //#endregion
1470
+ //#region src/PrecacheRoute.d.ts
1471
+ /**
1472
+ * A subclass of {@linkcode Route} that takes a {@linkcode Serwist} instance and uses it to match
1473
+ * incoming requests and handle fetching responses from the precache.
1474
+ */
1475
+ declare class PrecacheRoute extends Route {
1476
+ /**
1477
+ * @param serwist A {@linkcode Serwist} instance.
1478
+ * @param options Options to control how requests are matched
1479
+ * against the list of precached URLs.
1480
+ */
1481
+ constructor(serwist: Serwist, options?: PrecacheRouteOptions);
1482
+ }
1483
+ //#endregion
1484
+ //#region src/RegExpRoute.d.ts
1485
+ /**
1486
+ * A class that makes it easy to create a {@linkcode Route} object with a regular expression.
1487
+ *
1488
+ * For same-origin requests the `RegExp` only needs to match part of the URL. For
1489
+ * requests against third-party servers, you must define a `RegExp` that matches
1490
+ * the start of the URL.
1491
+ */
1492
+ declare class RegExpRoute extends Route {
1493
+ /**
1494
+ * If the regular expression contains
1495
+ * [capture groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references),
1496
+ * the captured values will be passed to the `params` argument.
1497
+ *
1498
+ * @param regExp The regular expression to match against URLs.
1499
+ * @param handler A callback function that returns a `Promise` resulting in a `Response`.
1500
+ * @param method The HTTP method to match the {@linkcode Route} against. Defaults to `GET`.
1501
+ * against.
1502
+ */
1503
+ constructor(regExp: RegExp, handler: RouteHandler, method?: HTTPMethod);
1504
+ }
1505
+ //#endregion
1506
+ //#region src/registerQuotaErrorCallback.d.ts
1507
+ /**
1508
+ * Adds a function to the set of quotaErrorCallbacks that will be executed if
1509
+ * there's a quota error.
1510
+ *
1511
+ * @param callback
1512
+ */
1513
+ declare const registerQuotaErrorCallback: (callback: Function) => void;
1514
+ //#endregion
1515
+ //#region src/setCacheNameDetails.d.ts
1516
+ /**
1517
+ * Modifies the default cache names used by Serwist packages.
1518
+ * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
1519
+ *
1520
+ * @param details
1521
+ */
1522
+ declare const setCacheNameDetails: (details: PartialCacheNameDetails) => void;
1523
+ //#endregion
1524
+ export { BROADCAST_UPDATE_DEFAULT_HEADERS, BackgroundSyncPlugin, BackgroundSyncQueue, type BackgroundSyncQueueEntry, type BackgroundSyncQueueOptions, BackgroundSyncQueueStore, BroadcastCacheUpdate, type BroadcastCacheUpdateOptions, type BroadcastMessage, type BroadcastPayload, type BroadcastPayloadGenerator, BroadcastUpdatePlugin, CacheDidUpdateCallback, CacheDidUpdateCallbackParam, CacheExpiration, CacheFirst, CacheKeyWillBeUsedCallback, CacheKeyWillBeUsedCallbackParam, CacheOnly, CacheWillUpdateCallback, CacheWillUpdateCallbackParam, CacheableResponse, type CacheableResponseOptions, CacheableResponsePlugin, CachedResponseWillBeUsedCallback, CachedResponseWillBeUsedCallbackParam, CleanupResult, ExpirationPlugin, type ExpirationPluginOptions, FetchDidFailCallback, FetchDidFailCallbackParam, FetchDidSucceedCallback, FetchDidSucceedCallbackParam, type GoogleAnalyticsInitializeOptions, type HTTPMethod, HandlerCallbackOptions, HandlerDidCompleteCallback, HandlerDidCompleteCallbackParam, HandlerDidErrorCallback, HandlerDidErrorCallbackParam, HandlerDidRespondCallback, HandlerDidRespondCallbackParam, HandlerWillRespondCallback, HandlerWillRespondCallbackParam, HandlerWillStartCallback, HandlerWillStartCallbackParam, InstallEvent, InstallResult, ManualHandlerCallback, ManualHandlerCallbackOptions, MapLikeObject, NavigationRoute, type NavigationRouteMatchOptions, NetworkFirst, type NetworkFirstOptions, NetworkOnly, type NetworkOnlyOptions, PluginState, PrecacheEntry, type PrecacheFallbackEntry, PrecacheFallbackPlugin, type PrecacheFallbackPluginOptions, PrecacheOptions, PrecacheRoute, PrecacheRouteOptions, PrecacheStrategy, MaybePromise as PromiseOrNot, RangeRequestsPlugin, RegExpRoute, RequestRule, RequestRuleCondition, RequestRuleSource, RequestWillFetchCallback, RequestWillFetchCallbackParam, Route, RouteHandler, RouteHandlerCallback, RouteHandlerCallbackOptions, RouteHandlerObject, RouteMatchCallback, RouteMatchCallbackOptions, RuntimeCaching, Serwist, SerwistGlobalConfig, type SerwistOptions, SerwistPlugin, SerwistPluginCallbackParam, StaleWhileRevalidate, StorableRequest, Strategy, StrategyHandler, type StrategyOptions, UrlManipulation, cacheNames, copyResponse, createPartialResponse, disableDevLogs$1 as disableDevLogs, disableNavigationPreload, enableNavigationPreload, initializeGoogleAnalytics, isNavigationPreloadSupported, registerQuotaErrorCallback, responsesAreSame, setCacheNameDetails };
1525
+ //# sourceMappingURL=index.d.mts.map