@serwist/sw 9.0.0-preview.17 → 9.0.0-preview.18

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 (251) hide show
  1. package/dist/{Serwist.d.ts → abstractions/Serwist.d.ts} +6 -15
  2. package/dist/abstractions/Serwist.d.ts.map +1 -0
  3. package/dist/abstractions/disableDevLogs.d.ts.map +1 -0
  4. package/dist/{fallbacks.d.ts → abstractions/fallbacks.d.ts} +2 -2
  5. package/dist/abstractions/fallbacks.d.ts.map +1 -0
  6. package/dist/{handlePrecaching.d.ts → abstractions/handlePrecaching.d.ts} +1 -1
  7. package/dist/abstractions/handlePrecaching.d.ts.map +1 -0
  8. package/dist/abstractions/installSerwist.d.ts.map +1 -0
  9. package/dist/abstractions/registerRuntimeCaching.d.ts.map +1 -0
  10. package/dist/{types.d.ts → abstractions/types.d.ts} +1 -1
  11. package/dist/abstractions/types.d.ts.map +1 -0
  12. package/dist/chunks/NavigationRoute.js +54 -0
  13. package/dist/chunks/NetworkOnly.js +193 -0
  14. package/dist/chunks/PrecacheFallbackPlugin.js +573 -0
  15. package/dist/chunks/Strategy.js +410 -0
  16. package/dist/chunks/getOrCreatePrecacheController.js +429 -0
  17. package/dist/chunks/precacheAndRoute.js +112 -0
  18. package/dist/chunks/registerRoute.js +408 -0
  19. package/dist/index.d.ts +8 -8
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +11 -9
  22. package/dist/index.plugins.d.ts +40 -11
  23. package/dist/index.plugins.d.ts.map +1 -1
  24. package/dist/index.plugins.js +671 -5
  25. package/dist/index.precaching.d.ts +24 -0
  26. package/dist/index.precaching.d.ts.map +1 -0
  27. package/dist/index.precaching.js +24 -0
  28. package/dist/index.routing.d.ts +13 -0
  29. package/dist/index.routing.d.ts.map +1 -0
  30. package/dist/index.routing.js +21 -0
  31. package/dist/index.strategies.d.ts +19 -2
  32. package/dist/index.strategies.d.ts.map +1 -1
  33. package/dist/index.strategies.js +146 -1
  34. package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts +23 -0
  35. package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -0
  36. package/dist/plugins/backgroundSync/Queue.d.ts +166 -0
  37. package/dist/plugins/backgroundSync/Queue.d.ts.map +1 -0
  38. package/dist/plugins/backgroundSync/QueueDb.d.ts +90 -0
  39. package/dist/plugins/backgroundSync/QueueDb.d.ts.map +1 -0
  40. package/dist/plugins/backgroundSync/QueueStore.d.ts +75 -0
  41. package/dist/plugins/backgroundSync/QueueStore.d.ts.map +1 -0
  42. package/dist/plugins/backgroundSync/StorableRequest.d.ts +51 -0
  43. package/dist/plugins/backgroundSync/StorableRequest.d.ts.map +1 -0
  44. package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts +45 -0
  45. package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -0
  46. package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts +27 -0
  47. package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -0
  48. package/dist/plugins/broadcastUpdate/constants.d.ts +5 -0
  49. package/dist/plugins/broadcastUpdate/constants.d.ts.map +1 -0
  50. package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts +11 -0
  51. package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts.map +1 -0
  52. package/dist/plugins/broadcastUpdate/types.d.ts +34 -0
  53. package/dist/plugins/broadcastUpdate/types.d.ts.map +1 -0
  54. package/dist/plugins/cacheableResponse/CacheableResponse.d.ts +40 -0
  55. package/dist/plugins/cacheableResponse/CacheableResponse.d.ts.map +1 -0
  56. package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts +27 -0
  57. package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -0
  58. package/dist/plugins/expiration/CacheExpiration.d.ts +66 -0
  59. package/dist/plugins/expiration/CacheExpiration.d.ts.map +1 -0
  60. package/dist/plugins/expiration/ExpirationPlugin.d.ts +116 -0
  61. package/dist/plugins/expiration/ExpirationPlugin.d.ts.map +1 -0
  62. package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts +73 -0
  63. package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts.map +1 -0
  64. package/dist/plugins/googleAnalytics/constants.d.ts +10 -0
  65. package/dist/plugins/googleAnalytics/constants.d.ts.map +1 -0
  66. package/dist/plugins/googleAnalytics/initialize.d.ts +26 -0
  67. package/dist/plugins/googleAnalytics/initialize.d.ts.map +1 -0
  68. package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts +54 -0
  69. package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts.map +1 -0
  70. package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts +19 -0
  71. package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -0
  72. package/dist/plugins/rangeRequests/createPartialResponse.d.ts +18 -0
  73. package/dist/plugins/rangeRequests/createPartialResponse.d.ts.map +1 -0
  74. package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +14 -0
  75. package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
  76. package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts +12 -0
  77. package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -0
  78. package/dist/precaching/PrecacheController.d.ts +145 -0
  79. package/dist/precaching/PrecacheController.d.ts.map +1 -0
  80. package/dist/precaching/PrecacheRoute.d.ts +20 -0
  81. package/dist/precaching/PrecacheRoute.d.ts.map +1 -0
  82. package/dist/precaching/PrecacheStrategy.d.ts +68 -0
  83. package/dist/precaching/PrecacheStrategy.d.ts.map +1 -0
  84. package/dist/precaching/addPlugins.d.ts +8 -0
  85. package/dist/precaching/addPlugins.d.ts.map +1 -0
  86. package/dist/precaching/addRoute.d.ts +15 -0
  87. package/dist/precaching/addRoute.d.ts.map +1 -0
  88. package/dist/precaching/cleanupOutdatedCaches.d.ts +6 -0
  89. package/dist/precaching/cleanupOutdatedCaches.d.ts.map +1 -0
  90. package/dist/precaching/createHandlerBoundToURL.d.ts +17 -0
  91. package/dist/precaching/createHandlerBoundToURL.d.ts.map +1 -0
  92. package/dist/precaching/getCacheKeyForURL.d.ts +20 -0
  93. package/dist/precaching/getCacheKeyForURL.d.ts.map +1 -0
  94. package/dist/precaching/matchPrecache.d.ts +14 -0
  95. package/dist/precaching/matchPrecache.d.ts.map +1 -0
  96. package/dist/precaching/precache.d.ts +19 -0
  97. package/dist/precaching/precache.d.ts.map +1 -0
  98. package/dist/precaching/precacheAndRoute.d.ts +14 -0
  99. package/dist/precaching/precacheAndRoute.d.ts.map +1 -0
  100. package/dist/precaching/types.d.ts +37 -0
  101. package/dist/precaching/types.d.ts.map +1 -0
  102. package/dist/precaching/utils/PrecacheCacheKeyPlugin.d.ts +17 -0
  103. package/dist/precaching/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
  104. package/dist/precaching/utils/PrecacheInstallReportPlugin.d.ts +15 -0
  105. package/dist/precaching/utils/PrecacheInstallReportPlugin.d.ts.map +1 -0
  106. package/dist/precaching/utils/createCacheKey.d.ts +16 -0
  107. package/dist/precaching/utils/createCacheKey.d.ts.map +1 -0
  108. package/dist/precaching/utils/deleteOutdatedCaches.d.ts +18 -0
  109. package/dist/precaching/utils/deleteOutdatedCaches.d.ts.map +1 -0
  110. package/dist/precaching/utils/generateURLVariations.d.ts +12 -0
  111. package/dist/precaching/utils/generateURLVariations.d.ts.map +1 -0
  112. package/dist/precaching/utils/getCacheKeyForURL.d.ts +14 -0
  113. package/dist/precaching/utils/getCacheKeyForURL.d.ts.map +1 -0
  114. package/dist/precaching/utils/getOrCreatePrecacheController.d.ts +7 -0
  115. package/dist/precaching/utils/getOrCreatePrecacheController.d.ts.map +1 -0
  116. package/dist/precaching/utils/printCleanupDetails.d.ts +6 -0
  117. package/dist/precaching/utils/printCleanupDetails.d.ts.map +1 -0
  118. package/dist/precaching/utils/printInstallDetails.d.ts +7 -0
  119. package/dist/precaching/utils/printInstallDetails.d.ts.map +1 -0
  120. package/dist/precaching/utils/removeIgnoredSearchParams.d.ts +12 -0
  121. package/dist/precaching/utils/removeIgnoredSearchParams.d.ts.map +1 -0
  122. package/dist/routing/NavigationRoute.d.ts +57 -0
  123. package/dist/routing/NavigationRoute.d.ts.map +1 -0
  124. package/dist/routing/RegExpRoute.d.ts +24 -0
  125. package/dist/routing/RegExpRoute.d.ts.map +1 -0
  126. package/dist/routing/Route.d.ts +33 -0
  127. package/dist/routing/Route.d.ts.map +1 -0
  128. package/dist/routing/Router.d.ts +124 -0
  129. package/dist/routing/Router.d.ts.map +1 -0
  130. package/dist/routing/registerRoute.d.ts +15 -0
  131. package/dist/routing/registerRoute.d.ts.map +1 -0
  132. package/dist/routing/setCatchHandler.d.ts +9 -0
  133. package/dist/routing/setCatchHandler.d.ts.map +1 -0
  134. package/dist/routing/setDefaultHandler.d.ts +12 -0
  135. package/dist/routing/setDefaultHandler.d.ts.map +1 -0
  136. package/dist/routing/unregisterRoute.d.ts +8 -0
  137. package/dist/routing/unregisterRoute.d.ts.map +1 -0
  138. package/dist/routing/utils/constants.d.ts +15 -0
  139. package/dist/routing/utils/constants.d.ts.map +1 -0
  140. package/dist/routing/utils/getOrCreateDefaultRouter.d.ts +10 -0
  141. package/dist/routing/utils/getOrCreateDefaultRouter.d.ts.map +1 -0
  142. package/dist/routing/utils/normalizeHandler.d.ts +10 -0
  143. package/dist/routing/utils/normalizeHandler.d.ts.map +1 -0
  144. package/dist/routing/utils/parseRoute.d.ts +5 -0
  145. package/dist/routing/utils/parseRoute.d.ts.map +1 -0
  146. package/dist/strategies/CacheFirst.d.ts +23 -0
  147. package/dist/strategies/CacheFirst.d.ts.map +1 -0
  148. package/dist/strategies/CacheOnly.d.ts +20 -0
  149. package/dist/strategies/CacheOnly.d.ts.map +1 -0
  150. package/dist/strategies/NetworkFirst.d.ts +61 -0
  151. package/dist/strategies/NetworkFirst.d.ts.map +1 -0
  152. package/dist/strategies/NetworkOnly.d.ts +32 -0
  153. package/dist/strategies/NetworkOnly.d.ts.map +1 -0
  154. package/dist/strategies/StaleWhileRevalidate.d.ts +35 -0
  155. package/dist/strategies/StaleWhileRevalidate.d.ts.map +1 -0
  156. package/dist/strategies/Strategy.d.ts +83 -0
  157. package/dist/strategies/Strategy.d.ts.map +1 -0
  158. package/dist/strategies/StrategyHandler.d.ts +189 -0
  159. package/dist/strategies/StrategyHandler.d.ts.map +1 -0
  160. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +3 -0
  161. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -0
  162. package/dist/strategies/utils/messages.d.ts +5 -0
  163. package/dist/strategies/utils/messages.d.ts.map +1 -0
  164. package/package.json +20 -14
  165. package/src/{Serwist.ts → abstractions/Serwist.ts} +16 -19
  166. package/src/{fallbacks.ts → abstractions/fallbacks.ts} +5 -5
  167. package/src/{handlePrecaching.ts → abstractions/handlePrecaching.ts} +6 -3
  168. package/src/{installSerwist.ts → abstractions/installSerwist.ts} +2 -2
  169. package/src/{registerRuntimeCaching.ts → abstractions/registerRuntimeCaching.ts} +1 -1
  170. package/src/{types.ts → abstractions/types.ts} +1 -1
  171. package/src/index.plugins.ts +65 -16
  172. package/src/index.precaching.ts +38 -0
  173. package/src/index.routing.ts +14 -0
  174. package/src/index.strategies.ts +22 -2
  175. package/src/index.ts +8 -8
  176. package/src/plugins/backgroundSync/BackgroundSyncPlugin.ts +39 -0
  177. package/src/plugins/backgroundSync/Queue.ts +438 -0
  178. package/src/plugins/backgroundSync/QueueDb.ts +176 -0
  179. package/src/plugins/backgroundSync/QueueStore.ts +161 -0
  180. package/src/plugins/backgroundSync/StorableRequest.ts +142 -0
  181. package/src/plugins/broadcastUpdate/BroadcastCacheUpdate.ts +159 -0
  182. package/src/plugins/broadcastUpdate/BroadcastUpdatePlugin.ts +43 -0
  183. package/src/plugins/broadcastUpdate/constants.ts +12 -0
  184. package/src/plugins/broadcastUpdate/responsesAreSame.ts +48 -0
  185. package/src/plugins/broadcastUpdate/types.ts +37 -0
  186. package/src/plugins/cacheableResponse/CacheableResponse.ts +141 -0
  187. package/src/plugins/cacheableResponse/CacheableResponsePlugin.ts +46 -0
  188. package/src/plugins/expiration/CacheExpiration.ts +192 -0
  189. package/src/plugins/expiration/ExpirationPlugin.ts +297 -0
  190. package/src/plugins/expiration/models/CacheTimestampsModel.ts +184 -0
  191. package/src/plugins/googleAnalytics/constants.ts +22 -0
  192. package/src/plugins/googleAnalytics/initialize.ts +200 -0
  193. package/src/plugins/precaching/PrecacheFallbackPlugin.ts +86 -0
  194. package/src/plugins/rangeRequests/RangeRequestsPlugin.ts +39 -0
  195. package/src/plugins/rangeRequests/createPartialResponse.ts +92 -0
  196. package/src/plugins/rangeRequests/utils/calculateEffectiveBoundaries.ts +58 -0
  197. package/src/plugins/rangeRequests/utils/parseRangeHeader.ts +54 -0
  198. package/src/precaching/PrecacheController.ts +332 -0
  199. package/src/precaching/PrecacheRoute.ts +50 -0
  200. package/src/precaching/PrecacheStrategy.ts +238 -0
  201. package/src/precaching/addPlugins.ts +21 -0
  202. package/src/precaching/addRoute.ts +30 -0
  203. package/src/precaching/cleanupOutdatedCaches.ts +33 -0
  204. package/src/precaching/createHandlerBoundToURL.ts +30 -0
  205. package/src/precaching/getCacheKeyForURL.ts +33 -0
  206. package/src/precaching/matchPrecache.ts +26 -0
  207. package/src/precaching/precache.ts +31 -0
  208. package/src/precaching/precacheAndRoute.ts +27 -0
  209. package/src/precaching/types.ts +46 -0
  210. package/src/precaching/utils/PrecacheCacheKeyPlugin.ts +36 -0
  211. package/src/precaching/utils/PrecacheInstallReportPlugin.ts +49 -0
  212. package/src/precaching/utils/createCacheKey.ts +68 -0
  213. package/src/precaching/utils/deleteOutdatedCaches.ts +40 -0
  214. package/src/precaching/utils/generateURLVariations.ts +55 -0
  215. package/src/precaching/utils/getCacheKeyForURL.ts +36 -0
  216. package/src/precaching/utils/getOrCreatePrecacheController.ts +22 -0
  217. package/src/precaching/utils/printCleanupDetails.ts +38 -0
  218. package/src/precaching/utils/printInstallDetails.ts +53 -0
  219. package/src/precaching/utils/removeIgnoredSearchParams.ts +29 -0
  220. package/src/routing/NavigationRoute.ts +119 -0
  221. package/src/routing/RegExpRoute.ts +74 -0
  222. package/src/routing/Route.ts +68 -0
  223. package/src/routing/Router.ts +432 -0
  224. package/src/routing/registerRoute.ts +33 -0
  225. package/src/routing/setCatchHandler.ts +22 -0
  226. package/src/routing/setDefaultHandler.ts +25 -0
  227. package/src/routing/unregisterRoute.ts +12 -0
  228. package/src/routing/utils/constants.ts +24 -0
  229. package/src/routing/utils/getOrCreateDefaultRouter.ts +29 -0
  230. package/src/routing/utils/normalizeHandler.ts +40 -0
  231. package/src/routing/utils/parseRoute.ts +67 -0
  232. package/src/strategies/CacheFirst.ts +87 -0
  233. package/src/strategies/CacheOnly.ts +58 -0
  234. package/src/strategies/NetworkFirst.ts +228 -0
  235. package/src/strategies/NetworkOnly.ts +96 -0
  236. package/src/strategies/StaleWhileRevalidate.ts +109 -0
  237. package/src/strategies/Strategy.ts +202 -0
  238. package/src/strategies/StrategyHandler.ts +557 -0
  239. package/src/strategies/plugins/cacheOkAndOpaquePlugin.ts +26 -0
  240. package/src/strategies/utils/messages.ts +20 -0
  241. package/dist/Serwist.d.ts.map +0 -1
  242. package/dist/disableDevLogs.d.ts.map +0 -1
  243. package/dist/fallbacks.d.ts.map +0 -1
  244. package/dist/handlePrecaching.d.ts.map +0 -1
  245. package/dist/installSerwist.d.ts.map +0 -1
  246. package/dist/registerRuntimeCaching.d.ts.map +0 -1
  247. package/dist/types.d.ts.map +0 -1
  248. /package/dist/{disableDevLogs.d.ts → abstractions/disableDevLogs.d.ts} +0 -0
  249. /package/dist/{installSerwist.d.ts → abstractions/installSerwist.d.ts} +0 -0
  250. /package/dist/{registerRuntimeCaching.d.ts → abstractions/registerRuntimeCaching.d.ts} +0 -0
  251. /package/src/{disableDevLogs.ts → abstractions/disableDevLogs.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ /**
3
+ * The range request plugin makes it easy for a request with a 'Range' header to
4
+ * be fulfilled by a cached response.
5
+ *
6
+ * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
7
+ * and returning the appropriate subset of the cached response body.
8
+ */
9
+ export declare class RangeRequestsPlugin implements SerwistPlugin {
10
+ /**
11
+ * @param options
12
+ * @returns If request contains a 'Range' header, then a
13
+ * new response with status 206 whose body is a subset of `cachedResponse` is
14
+ * returned. Otherwise, `cachedResponse` is returned as-is.
15
+ * @private
16
+ */
17
+ cachedResponseWillBeUsed: SerwistPlugin["cachedResponseWillBeUsed"];
18
+ }
19
+ //# sourceMappingURL=RangeRequestsPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RangeRequestsPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/rangeRequests/RangeRequestsPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD;;;;;;OAMG;IACH,wBAAwB,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAUjE;CACH"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Given a `Request` and `Response` objects as input, this will return a
3
+ * promise for a new `Response`.
4
+ *
5
+ * If the original `Response` already contains partial content (i.e. it has
6
+ * a status of 206), then this assumes it already fulfills the `Range:`
7
+ * requirements, and will return it as-is.
8
+ *
9
+ * @param request A request, which should contain a Range:
10
+ * header.
11
+ * @param originalResponse A response.
12
+ * @returns Either a `206 Partial Content` response, with
13
+ * the response body set to the slice of content specified by the request's
14
+ * `Range:` header, or a `416 Range Not Satisfiable` response if the
15
+ * conditions of the `Range:` header can't be met.
16
+ */
17
+ export declare const createPartialResponse: (request: Request, originalResponse: Response) => Promise<Response>;
18
+ //# sourceMappingURL=createPartialResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPartialResponse.d.ts","sourceRoot":"","sources":["../../../src/plugins/rangeRequests/createPartialResponse.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,YAAmB,OAAO,oBAAoB,QAAQ,KAAG,QAAQ,QAAQ,CA8D1G,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @param blob A source blob.
3
+ * @param start The offset to use as the start of the
4
+ * slice.
5
+ * @param end The offset to use as the end of the slice.
6
+ * @returns An object with `start` and `end` properties, reflecting
7
+ * the effective boundaries to use given the size of the blob.
8
+ * @private
9
+ */
10
+ export declare const calculateEffectiveBoundaries: (blob: Blob, start?: number, end?: number) => {
11
+ start: number;
12
+ end: number;
13
+ };
14
+ //# sourceMappingURL=calculateEffectiveBoundaries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateEffectiveBoundaries.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rangeRequests/utils/calculateEffectiveBoundaries.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,SAAU,IAAI,UAAU,MAAM,QAAQ,MAAM;WAAY,MAAM;SAAO,MAAM;CAsCnH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @param rangeHeader A Range: header value.
3
+ * @returns An object with `start` and `end` properties, reflecting
4
+ * the parsed value of the Range: header. If either the `start` or `end` are
5
+ * omitted, then `null` will be returned.
6
+ * @private
7
+ */
8
+ export declare const parseRangeHeader: (rangeHeader: string) => {
9
+ start?: number;
10
+ end?: number;
11
+ };
12
+ //# sourceMappingURL=parseRangeHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseRangeHeader.d.ts","sourceRoot":"","sources":["../../../../src/plugins/rangeRequests/utils/parseRangeHeader.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,gBACd,MAAM,KAClB;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CAgCd,CAAC"}
@@ -0,0 +1,145 @@
1
+ import type { RouteHandlerCallback, SerwistPlugin } from "@serwist/core";
2
+ import type { Strategy } from "../strategies/Strategy.js";
3
+ import type { CleanupResult, InstallResult, PrecacheEntry } from "./types.js";
4
+ interface PrecacheControllerOptions {
5
+ /**
6
+ * The cache to use for precaching.
7
+ */
8
+ cacheName?: string;
9
+ /**
10
+ * Plugins to use when precaching as well as responding to fetch
11
+ * events for precached assets.
12
+ */
13
+ plugins?: SerwistPlugin[];
14
+ /**
15
+ * Whether to attempt to get the response from the network if there's
16
+ * a precache miss.
17
+ */
18
+ fallbackToNetwork?: boolean;
19
+ /**
20
+ * A number of how many precache requests should be made concurrently.
21
+ *
22
+ * @default 1
23
+ */
24
+ concurrentPrecaching?: number;
25
+ }
26
+ /**
27
+ * Performs efficient precaching of assets.
28
+ */
29
+ export declare class PrecacheController {
30
+ private _installAndActiveListenersAdded?;
31
+ private _concurrentPrecaching;
32
+ private readonly _strategy;
33
+ private readonly _urlsToCacheKeys;
34
+ private readonly _urlsToCacheModes;
35
+ private readonly _cacheKeysToIntegrities;
36
+ /**
37
+ * Create a new PrecacheController.
38
+ *
39
+ * @param options
40
+ */
41
+ constructor({ cacheName, plugins, fallbackToNetwork, concurrentPrecaching }?: PrecacheControllerOptions);
42
+ /**
43
+ * The strategy created by this controller and
44
+ * used to cache assets and respond to fetch events.
45
+ */
46
+ get strategy(): Strategy;
47
+ /**
48
+ * Adds items to the precache list, removing any duplicates and
49
+ * stores the files in the precache cache when the service
50
+ * worker installs.
51
+ *
52
+ * This method can be called multiple times.
53
+ *
54
+ * @param entries Array of entries to precache.
55
+ */
56
+ precache(entries: (PrecacheEntry | string)[]): void;
57
+ /**
58
+ * This method will add items to the precache list, removing duplicates
59
+ * and ensuring the information is valid.
60
+ *
61
+ * @param entries Array of entries to precache.
62
+ */
63
+ addToCacheList(entries: (PrecacheEntry | string)[]): void;
64
+ /**
65
+ * Precaches new and updated assets. Call this method from the service worker
66
+ * install event.
67
+ *
68
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
69
+ * to call it yourself in your event handlers.
70
+ *
71
+ * @param event
72
+ * @returns
73
+ */
74
+ install(event: ExtendableEvent): Promise<InstallResult>;
75
+ /**
76
+ * Deletes assets that are no longer present in the current precache manifest.
77
+ * Call this method from the service worker activate event.
78
+ *
79
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
80
+ * to call it yourself in your event handlers.
81
+ *
82
+ * @param event
83
+ * @returns
84
+ */
85
+ activate(event: ExtendableEvent): Promise<CleanupResult>;
86
+ /**
87
+ * Returns a mapping of a precached URL to the corresponding cache key, taking
88
+ * into account the revision information for the URL.
89
+ *
90
+ * @returns A URL to cache key mapping.
91
+ */
92
+ getURLsToCacheKeys(): Map<string, string>;
93
+ /**
94
+ * Returns a list of all the URLs that have been precached by the current
95
+ * service worker.
96
+ *
97
+ * @returns The precached URLs.
98
+ */
99
+ getCachedURLs(): string[];
100
+ /**
101
+ * Returns the cache key used for storing a given URL. If that URL is
102
+ * unversioned, like `/index.html', then the cache key will be the original
103
+ * URL with a search parameter appended to it.
104
+ *
105
+ * @param url A URL whose cache key you want to look up.
106
+ * @returns The versioned URL that corresponds to a cache key
107
+ * for the original URL, or undefined if that URL isn't precached.
108
+ */
109
+ getCacheKeyForURL(url: string): string | undefined;
110
+ /**
111
+ * @param url A cache key whose SRI you want to look up.
112
+ * @returns The subresource integrity associated with the cache key,
113
+ * or undefined if it's not set.
114
+ */
115
+ getIntegrityForCacheKey(cacheKey: string): string | undefined;
116
+ /**
117
+ * This acts as a drop-in replacement for
118
+ * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
119
+ * with the following differences:
120
+ *
121
+ * - It knows what the name of the precache is, and only checks in that cache.
122
+ * - It allows you to pass in an "original" URL without versioning parameters,
123
+ * and it will automatically look up the correct cache key for the currently
124
+ * active revision of that URL.
125
+ *
126
+ * E.g., `matchPrecache('index.html')` will find the correct precached
127
+ * response for the currently active service worker, even if the actual cache
128
+ * key is `'/index.html?__WB_REVISION__=1234abcd'`.
129
+ *
130
+ * @param request The key (without revisioning parameters)
131
+ * to look up in the precache.
132
+ * @returns
133
+ */
134
+ matchPrecache(request: string | Request): Promise<Response | undefined>;
135
+ /**
136
+ * Returns a function that looks up `url` in the precache (taking into
137
+ * account revision information), and returns the corresponding `Response`.
138
+ *
139
+ * @param url The precached URL which will be used to lookup the response.
140
+ * @return
141
+ */
142
+ createHandlerBoundToURL(url: string): RouteHandlerCallback;
143
+ }
144
+ export {};
145
+ //# sourceMappingURL=PrecacheController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheController.d.ts","sourceRoot":"","sources":["../../src/precaching/PrecacheController.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAU9E,UAAU,yBAAyB;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,+BAA+B,CAAC,CAAU;IAClD,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkC;IACnE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6G;IAC/I,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAkC;IAE1E;;;;OAIG;gBACS,EAAE,SAAS,EAAE,OAAY,EAAE,iBAAwB,EAAE,oBAAwB,EAAE,GAAE,yBAA8B;IAY3H;;;OAGG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI;IAUnD;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI;IAwDzD;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAmCvD;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAuBxD;;;;;OAKG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;;OAKG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKlD;;;;OAIG;IACH,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7D;;;;;;;;;;;;;;;;;OAiBG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAU7E;;;;;;OAMG;IACH,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB;CAY3D"}
@@ -0,0 +1,20 @@
1
+ import { Route } from "../routing/Route.js";
2
+ import type { PrecacheController } from "./PrecacheController.js";
3
+ import type { PrecacheRouteOptions } from "./types.js";
4
+ /**
5
+ * A subclass of `@serwist/routing.Route` that takes a
6
+ * `@serwist/precaching.PrecacheController`
7
+ * instance and uses it to match incoming requests and handle fetching
8
+ * responses from the precache.
9
+ */
10
+ declare class PrecacheRoute extends Route {
11
+ /**
12
+ * @param precacheController A `PrecacheController`
13
+ * instance used to both match requests and respond to fetch events.
14
+ * @param options Options to control how requests are matched
15
+ * against the list of precached URLs.
16
+ */
17
+ constructor(precacheController: PrecacheController, options?: PrecacheRouteOptions);
18
+ }
19
+ export { PrecacheRoute };
20
+ //# sourceMappingURL=PrecacheRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheRoute.d.ts","sourceRoot":"","sources":["../../src/precaching/PrecacheRoute.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;GAKG;AACH,cAAM,aAAc,SAAQ,KAAK;IAC/B;;;;;OAKG;gBACS,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAkBnF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ import type { StrategyOptions } from "../strategies/Strategy.js";
3
+ import { Strategy } from "../strategies/Strategy.js";
4
+ import type { StrategyHandler } from "../strategies/StrategyHandler.js";
5
+ interface PrecacheStrategyOptions extends StrategyOptions {
6
+ /**
7
+ * Whether to attempt to get the response from the network
8
+ * if there's a precache miss.
9
+ */
10
+ fallbackToNetwork?: boolean;
11
+ }
12
+ /**
13
+ * A `@serwist/strategies.Strategy` implementation
14
+ * specifically designed to work with
15
+ * `@serwist/precaching.PrecacheController`
16
+ * to both cache and fetch precached assets.
17
+ *
18
+ * Note: an instance of this class is created automatically when creating a
19
+ * `PrecacheController`; it's generally not necessary to create this yourself.
20
+ */
21
+ export declare class PrecacheStrategy extends Strategy {
22
+ private readonly _fallbackToNetwork;
23
+ static readonly defaultPrecacheCacheabilityPlugin: SerwistPlugin;
24
+ static readonly copyRedirectedCacheableResponsesPlugin: SerwistPlugin;
25
+ /**
26
+ * @param options
27
+ */
28
+ constructor(options?: PrecacheStrategyOptions);
29
+ /**
30
+ * @private
31
+ * @param request A request to run this strategy for.
32
+ * @param handler The event that triggered the request.
33
+ * @returns
34
+ */
35
+ _handle(request: Request, handler: StrategyHandler): Promise<Response>;
36
+ _handleFetch(request: Request, handler: StrategyHandler): Promise<Response>;
37
+ _handleInstall(request: Request, handler: StrategyHandler): Promise<Response>;
38
+ /**
39
+ * This method is complex, as there a number of things to account for:
40
+ *
41
+ * The `plugins` array can be set at construction, and/or it might be added to
42
+ * to at any time before the strategy is used.
43
+ *
44
+ * At the time the strategy is used (i.e. during an `install` event), there
45
+ * needs to be at least one plugin that implements `cacheWillUpdate` in the
46
+ * array, other than `copyRedirectedCacheableResponsesPlugin`.
47
+ *
48
+ * - If this method is called and there are no suitable `cacheWillUpdate`
49
+ * plugins, we need to add `defaultPrecacheCacheabilityPlugin`.
50
+ *
51
+ * - If this method is called and there is exactly one `cacheWillUpdate`, then
52
+ * we don't have to do anything (this might be a previously added
53
+ * `defaultPrecacheCacheabilityPlugin`, or it might be a custom plugin).
54
+ *
55
+ * - If this method is called and there is more than one `cacheWillUpdate`,
56
+ * then we need to check if one is `defaultPrecacheCacheabilityPlugin`. If so,
57
+ * we need to remove it. (This situation is unlikely, but it could happen if
58
+ * the strategy is used multiple times, the first without a `cacheWillUpdate`,
59
+ * and then later on after manually adding a custom `cacheWillUpdate`.)
60
+ *
61
+ * See https://github.com/GoogleChrome/workbox/issues/2737 for more context.
62
+ *
63
+ * @private
64
+ */
65
+ _useDefaultCacheabilityPluginIfNeeded(): void;
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=PrecacheStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheStrategy.d.ts","sourceRoot":"","sources":["../../src/precaching/PrecacheStrategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,UAAU,uBAAwB,SAAQ,eAAe;IACvD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC5C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAU;IAE7C,MAAM,CAAC,QAAQ,CAAC,iCAAiC,EAAE,aAAa,CAQ9D;IAEF,MAAM,CAAC,QAAQ,CAAC,sCAAsC,EAAE,aAAa,CAInE;IAEF;;OAEG;gBACS,OAAO,GAAE,uBAA4B;IAajD;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBtE,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAwE3E,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoBnF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,qCAAqC,IAAI,IAAI;CA4B9C"}
@@ -0,0 +1,8 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ /**
3
+ * Adds plugins to the precaching strategy.
4
+ *
5
+ * @param plugins
6
+ */
7
+ export declare const addPlugins: (plugins: SerwistPlugin[]) => void;
8
+ //# sourceMappingURL=addPlugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addPlugins.d.ts","sourceRoot":"","sources":["../../src/precaching/addPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD;;;;GAIG;AACH,eAAO,MAAM,UAAU,YAAa,aAAa,EAAE,KAAG,IAGrD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { PrecacheRouteOptions } from "./types.js";
2
+ /**
3
+ * Add a `fetch` listener to the service worker that will
4
+ * respond to
5
+ * [network requests](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests)
6
+ * with precached assets.
7
+ *
8
+ * Requests for assets that aren't precached, the `FetchEvent` will not be
9
+ * responded to, allowing the event to fall through to other `fetch` event
10
+ * listeners.
11
+ *
12
+ * @param options See the `@serwist/precaching.PrecacheRoute` options.
13
+ */
14
+ export declare const addRoute: (options?: PrecacheRouteOptions) => void;
15
+ //# sourceMappingURL=addRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addRoute.d.ts","sourceRoot":"","sources":["../../src/precaching/addRoute.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,aAAc,oBAAoB,KAAG,IAKzD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Adds an `activate` event listener which will clean up incompatible
3
+ * precaches that were created by older versions of Serwist.
4
+ */
5
+ export declare const cleanupOutdatedCaches: () => void;
6
+ //# sourceMappingURL=cleanupOutdatedCaches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupOutdatedCaches.d.ts","sourceRoot":"","sources":["../../src/precaching/cleanupOutdatedCaches.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAcxC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { RouteHandlerCallback } from "@serwist/core";
2
+ /**
3
+ * Helper function that calls `PrecacheController#createHandlerBoundToURL`
4
+ * on the default `PrecacheController` instance.
5
+ *
6
+ * If you are creating your own `PrecacheController`, then call the
7
+ * `PrecacheController#createHandlerBoundToURL` on that instance,
8
+ * instead of using this function.
9
+ *
10
+ * @param url The precached URL which will be used to lookup the
11
+ * `Response`.
12
+ * @param fallbackToNetwork Whether to attempt to get the
13
+ * response from the network if there's a precache miss.
14
+ * @return
15
+ */
16
+ export declare const createHandlerBoundToURL: (url: string) => RouteHandlerCallback;
17
+ //# sourceMappingURL=createHandlerBoundToURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHandlerBoundToURL.d.ts","sourceRoot":"","sources":["../../src/precaching/createHandlerBoundToURL.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,QAAS,MAAM,KAAG,oBAGrD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Takes in a URL, and returns the corresponding URL that could be used to
3
+ * lookup the entry in the precache.
4
+ *
5
+ * If a relative URL is provided, the location of the service worker file will
6
+ * be used as the base.
7
+ *
8
+ * For precached entries without revision information, the cache key will be the
9
+ * same as the original URL.
10
+ *
11
+ * For precached entries with revision information, the cache key will be the
12
+ * original URL with the addition of a query parameter used for keeping track of
13
+ * the revision info.
14
+ *
15
+ * @param url The URL whose cache key to look up.
16
+ * @returns The cache key that corresponds to that URL.
17
+ */
18
+ declare function getCacheKeyForURL(url: string): string | undefined;
19
+ export { getCacheKeyForURL };
20
+ //# sourceMappingURL=getCacheKeyForURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCacheKeyForURL.d.ts","sourceRoot":"","sources":["../../src/precaching/getCacheKeyForURL.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1D;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Helper function that calls `PrecacheController#matchPrecache`
3
+ * on the default `PrecacheController` instance.
4
+ *
5
+ * If you are creating your own `PrecacheController`, then call
6
+ * `PrecacheController#matchPrecache` on that instance,
7
+ * instead of using this function.
8
+ *
9
+ * @param request The key (without revisioning parameters)
10
+ * to look up in the precache.
11
+ * @returns
12
+ */
13
+ export declare const matchPrecache: (request: string | Request) => Promise<Response | undefined>;
14
+ //# sourceMappingURL=matchPrecache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchPrecache.d.ts","sourceRoot":"","sources":["../../src/precaching/matchPrecache.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,YAAa,MAAM,GAAG,OAAO,KAAG,QAAQ,QAAQ,GAAG,SAAS,CAGrF,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { PrecacheEntry } from "./types.js";
2
+ /**
3
+ * Adds items to the precache list, removing any duplicates and
4
+ * stores the files in the precache cache when the service
5
+ * worker installs.
6
+ *
7
+ * This method can be called multiple times.
8
+ *
9
+ * Please note: This method **will not** serve any of the cached files for you.
10
+ * It only precaches files. To respond to a network request you call
11
+ * `@serwist/precaching.addRoute`.
12
+ *
13
+ * If you have a single array of files to precache, you can just call
14
+ * `@serwist/precaching.precacheAndRoute`.
15
+ *
16
+ * @param entries Array of entries to precache.
17
+ */
18
+ export declare const precache: (entries: (PrecacheEntry | string)[]) => void;
19
+ //# sourceMappingURL=precache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precache.d.ts","sourceRoot":"","sources":["../../src/precaching/precache.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,YAAa,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,KAAG,IAG9D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PrecacheEntry, PrecacheRouteOptions } from "./types.js";
2
+ /**
3
+ * This method will add entries to the precache list and add a route to
4
+ * respond to fetch events.
5
+ *
6
+ * This is a convenience method that will call
7
+ * `@serwist/precaching.precache` and
8
+ * `@serwist/precaching.addRoute` in a single call.
9
+ *
10
+ * @param entries Array of entries to precache.
11
+ * @param options See the `@serwist/precaching.PrecacheRoute` options.
12
+ */
13
+ export declare const precacheAndRoute: (entries: (PrecacheEntry | string)[], options?: PrecacheRouteOptions) => void;
14
+ //# sourceMappingURL=precacheAndRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precacheAndRoute.d.ts","sourceRoot":"","sources":["../../src/precaching/precacheAndRoute.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,YAAa,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,YAAY,oBAAoB,KAAG,IAGtG,CAAC"}
@@ -0,0 +1,37 @@
1
+ export interface InstallResult {
2
+ updatedURLs: string[];
3
+ notUpdatedURLs: string[];
4
+ }
5
+ export interface CleanupResult {
6
+ deletedCacheRequests: string[];
7
+ }
8
+ export declare interface PrecacheEntry {
9
+ integrity?: string;
10
+ url: string;
11
+ revision?: string | null;
12
+ }
13
+ export interface PrecacheRouteOptions {
14
+ /**
15
+ * The `directoryIndex` will check cache entries for a URL ending with '/'
16
+ * to see if there is a hit when appending the `directoryIndex` value.
17
+ */
18
+ directoryIndex?: string | null;
19
+ /**
20
+ * An array of RegExp's to remove search params when looking for a cache match.
21
+ */
22
+ ignoreURLParametersMatching?: RegExp[];
23
+ /**
24
+ * The `cleanURLs` option will check the cache for the URL with a `.html` added
25
+ * to the end of the end.
26
+ */
27
+ cleanURLs?: boolean;
28
+ /**
29
+ * This is a function that should take a URL and return an array of
30
+ * alternative URLs that should be checked for precache matches.
31
+ */
32
+ urlManipulation?: UrlManipulation;
33
+ }
34
+ export type UrlManipulation = ({ url }: {
35
+ url: URL;
36
+ }) => URL[];
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/precaching/types.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,KAAK,GAAG,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ import type { PrecacheController } from "../PrecacheController.js";
3
+ /**
4
+ * A plugin, designed to be used with PrecacheController, to translate URLs into
5
+ * the corresponding cache key, based on the current revision info.
6
+ *
7
+ * @private
8
+ */
9
+ declare class PrecacheCacheKeyPlugin implements SerwistPlugin {
10
+ private readonly _precacheController;
11
+ constructor({ precacheController }: {
12
+ precacheController: PrecacheController;
13
+ });
14
+ cacheKeyWillBeUsed: SerwistPlugin["cacheKeyWillBeUsed"];
15
+ }
16
+ export { PrecacheCacheKeyPlugin };
17
+ //# sourceMappingURL=PrecacheCacheKeyPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheCacheKeyPlugin.d.ts","sourceRoot":"","sources":["../../../src/precaching/utils/PrecacheCacheKeyPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;GAKG;AACH,cAAM,sBAAuB,YAAW,aAAa;IACnD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;gBAE7C,EAAE,kBAAkB,EAAE,EAAE;QAAE,kBAAkB,EAAE,kBAAkB,CAAA;KAAE;IAI9E,kBAAkB,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAOrD;CACH;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ /**
3
+ * A plugin, designed to be used with PrecacheController, to determine the
4
+ * of assets that were updated (or not updated) during the install event.
5
+ *
6
+ * @private
7
+ */
8
+ declare class PrecacheInstallReportPlugin implements SerwistPlugin {
9
+ updatedURLs: string[];
10
+ notUpdatedURLs: string[];
11
+ handlerWillStart: SerwistPlugin["handlerWillStart"];
12
+ cachedResponseWillBeUsed: SerwistPlugin["cachedResponseWillBeUsed"];
13
+ }
14
+ export { PrecacheInstallReportPlugin };
15
+ //# sourceMappingURL=PrecacheInstallReportPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheInstallReportPlugin.d.ts","sourceRoot":"","sources":["../../../src/precaching/utils/PrecacheInstallReportPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,eAAe,CAAC;AAE/E;;;;;GAKG;AACH,cAAM,2BAA4B,YAAW,aAAa;IACxD,WAAW,EAAE,MAAM,EAAE,CAAM;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAM;IAE9B,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAKjD;IAEF,wBAAwB,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAkBjE;CACH;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { PrecacheEntry } from "../types.js";
2
+ interface CacheKey {
3
+ cacheKey: string;
4
+ url: string;
5
+ }
6
+ /**
7
+ * Converts a manifest entry into a versioned URL suitable for precaching.
8
+ *
9
+ * @param entry
10
+ * @returns A URL with versioning info.
11
+ *
12
+ * @private
13
+ */
14
+ export declare function createCacheKey(entry: PrecacheEntry | string): CacheKey;
15
+ export {};
16
+ //# sourceMappingURL=createCacheKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCacheKey.d.ts","sourceRoot":"","sources":["../../../src/precaching/utils/createCacheKey.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,UAAU,QAAQ;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAKD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,QAAQ,CAuCtE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Cleans up incompatible precaches that were created by older versions of
3
+ * Serwist, by a service worker registered under the current scope.
4
+ *
5
+ * This is meant to be called as part of the `activate` event.
6
+ *
7
+ * This should be safe to use as long as you don't include `substringToFind`
8
+ * (defaulting to `-precache-`) in your non-precache cache names.
9
+ *
10
+ * @param currentPrecacheName The cache name currently in use for
11
+ * precaching. This cache won't be deleted.
12
+ * @param substringToFind Cache names which include this
13
+ * substring will be deleted (excluding `currentPrecacheName`).
14
+ * @returns A list of all the cache names that were deleted.
15
+ * @private
16
+ */
17
+ export declare const deleteOutdatedCaches: (currentPrecacheName: string, substringToFind?: string) => Promise<string[]>;
18
+ //# sourceMappingURL=deleteOutdatedCaches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteOutdatedCaches.d.ts","sourceRoot":"","sources":["../../../src/precaching/utils/deleteOutdatedCaches.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,wBAA+B,MAAM,oBAAmB,MAAM,KAAuB,QAAQ,MAAM,EAAE,CAUrI,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { PrecacheRouteOptions } from "../types.js";
2
+ /**
3
+ * Generator function that yields possible variations on the original URL to
4
+ * check, one at a time.
5
+ *
6
+ * @param url
7
+ * @param options
8
+ *
9
+ * @private
10
+ */
11
+ export declare function generateURLVariations(url: string, { ignoreURLParametersMatching, directoryIndex, cleanURLs, urlManipulation, }?: PrecacheRouteOptions): Generator<string, void, unknown>;
12
+ //# sourceMappingURL=generateURLVariations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateURLVariations.d.ts","sourceRoot":"","sources":["../../../src/precaching/utils/generateURLVariations.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;;;;GAQG;AACH,wBAAiB,qBAAqB,CACpC,GAAG,EAAE,MAAM,EACX,EACE,2BAAmD,EACnD,cAA6B,EAC7B,SAAgB,EAChB,eAAe,GAChB,GAAE,oBAAyB,GAC3B,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CA0BlC"}