serwist 10.0.0-preview.1 → 10.0.0-preview.11

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 (265) hide show
  1. package/dist/chunks/{resultingClientExists.js → waitUntil.js} +144 -144
  2. package/dist/index.d.ts +22 -50
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.internal.d.ts +16 -16
  5. package/dist/index.internal.d.ts.map +1 -1
  6. package/dist/index.internal.js +3 -3
  7. package/dist/index.js +1925 -1803
  8. package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncPlugin.d.ts +1 -1
  9. package/dist/lib/background-sync/BackgroundSyncPlugin.d.ts.map +1 -0
  10. package/dist/lib/background-sync/BackgroundSyncQueue.d.ts.map +1 -0
  11. package/dist/lib/background-sync/BackgroundSyncQueueDb.d.ts.map +1 -0
  12. package/dist/lib/background-sync/BackgroundSyncQueueStore.d.ts.map +1 -0
  13. package/dist/lib/{backgroundSync → background-sync}/StorableRequest.d.ts +1 -1
  14. package/dist/lib/background-sync/StorableRequest.d.ts.map +1 -0
  15. package/dist/lib/background-sync/index.d.ts +6 -0
  16. package/dist/lib/background-sync/index.d.ts.map +1 -0
  17. package/dist/lib/{broadcastUpdate → broadcast-update}/BroadcastCacheUpdate.d.ts +1 -1
  18. package/dist/lib/broadcast-update/BroadcastCacheUpdate.d.ts.map +1 -0
  19. package/dist/lib/{broadcastUpdate → broadcast-update}/BroadcastUpdatePlugin.d.ts +1 -1
  20. package/dist/lib/broadcast-update/BroadcastUpdatePlugin.d.ts.map +1 -0
  21. package/dist/lib/broadcast-update/constants.d.ts.map +1 -0
  22. package/dist/lib/broadcast-update/index.d.ts +6 -0
  23. package/dist/lib/broadcast-update/index.d.ts.map +1 -0
  24. package/dist/lib/broadcast-update/responsesAreSame.d.ts.map +1 -0
  25. package/dist/lib/{broadcastUpdate → broadcast-update}/types.d.ts +1 -1
  26. package/dist/lib/broadcast-update/types.d.ts.map +1 -0
  27. package/dist/{cacheNames.d.ts → lib/cache-name.d.ts} +1 -1
  28. package/dist/lib/cache-name.d.ts.map +1 -0
  29. package/dist/lib/cacheable-response/CacheableResponse.d.ts.map +1 -0
  30. package/dist/lib/{cacheableResponse → cacheable-response}/CacheableResponsePlugin.d.ts +1 -1
  31. package/dist/lib/cacheable-response/CacheableResponsePlugin.d.ts.map +1 -0
  32. package/dist/lib/cacheable-response/index.d.ts +4 -0
  33. package/dist/lib/cacheable-response/index.d.ts.map +1 -0
  34. package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
  35. package/dist/lib/constants.d.ts.map +1 -0
  36. package/dist/lib/core.d.ts +62 -0
  37. package/dist/lib/core.d.ts.map +1 -0
  38. package/dist/lib/expiration/ExpirationPlugin.d.ts +1 -1
  39. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -1
  40. package/dist/lib/expiration/index.d.ts +4 -0
  41. package/dist/lib/expiration/index.d.ts.map +1 -0
  42. package/dist/lib/extension.d.ts +30 -0
  43. package/dist/lib/extension.d.ts.map +1 -0
  44. package/dist/lib/extensions/google-analytics/constants.d.ts.map +1 -0
  45. package/dist/lib/extensions/google-analytics/extension.d.ts +79 -0
  46. package/dist/lib/extensions/google-analytics/extension.d.ts.map +1 -0
  47. package/dist/lib/extensions/google-analytics/index.d.ts +2 -0
  48. package/dist/lib/extensions/google-analytics/index.d.ts.map +1 -0
  49. package/dist/lib/extensions/google-analytics/initialize.d.ts +12 -0
  50. package/dist/lib/extensions/google-analytics/initialize.d.ts.map +1 -0
  51. package/dist/lib/extensions/index.d.ts +14 -0
  52. package/dist/lib/extensions/index.d.ts.map +1 -0
  53. package/dist/{controllers/PrecacheController/PrecacheController.d.ts → lib/extensions/precache/extension.d.ts} +19 -38
  54. package/dist/lib/extensions/precache/extension.d.ts.map +1 -0
  55. package/dist/{controllers/PrecacheController/parsePrecacheOptions.d.ts → lib/extensions/precache/options.d.ts} +6 -5
  56. package/dist/lib/extensions/precache/options.d.ts.map +1 -0
  57. package/dist/{controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts → lib/extensions/precache/plugin-cache-key.d.ts} +4 -4
  58. package/dist/lib/extensions/precache/plugin-cache-key.d.ts.map +1 -0
  59. package/dist/lib/{precaching/PrecacheFallbackPlugin.d.ts → extensions/precache/plugin-fallback.d.ts} +11 -11
  60. package/dist/lib/extensions/precache/plugin-fallback.d.ts.map +1 -0
  61. package/dist/{controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts → lib/extensions/precache/plugin-install-report.d.ts} +2 -2
  62. package/dist/lib/extensions/precache/plugin-install-report.d.ts.map +1 -0
  63. package/dist/lib/extensions/precache/route.d.ts +42 -0
  64. package/dist/lib/extensions/precache/route.d.ts.map +1 -0
  65. package/dist/{controllers/PrecacheController/PrecacheStrategy.d.ts → lib/extensions/precache/strategy.d.ts} +5 -5
  66. package/dist/lib/extensions/precache/strategy.d.ts.map +1 -0
  67. package/dist/{controllers/RuntimeCacheController.d.ts → lib/extensions/runtime-cache.d.ts} +16 -10
  68. package/dist/lib/extensions/runtime-cache.d.ts.map +1 -0
  69. package/dist/lib/functions/handlers.d.ts +60 -0
  70. package/dist/lib/functions/handlers.d.ts.map +1 -0
  71. package/dist/lib/functions/router.d.ts +60 -0
  72. package/dist/lib/functions/router.d.ts.map +1 -0
  73. package/dist/{navigationPreload.d.ts → lib/navigation-preload.d.ts} +1 -1
  74. package/dist/lib/navigation-preload.d.ts.map +1 -0
  75. package/dist/lib/{rangeRequests → range-requests}/RangeRequestsPlugin.d.ts +1 -1
  76. package/dist/lib/range-requests/RangeRequestsPlugin.d.ts.map +1 -0
  77. package/dist/lib/range-requests/createPartialResponse.d.ts.map +1 -0
  78. package/dist/lib/range-requests/index.d.ts +3 -0
  79. package/dist/lib/range-requests/index.d.ts.map +1 -0
  80. package/dist/lib/range-requests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
  81. package/dist/lib/range-requests/utils/parseRangeHeader.d.ts.map +1 -0
  82. package/dist/lib/route.d.ts +106 -0
  83. package/dist/lib/route.d.ts.map +1 -0
  84. package/dist/{Serwist.d.ts → lib/serwist.d.ts} +28 -41
  85. package/dist/lib/serwist.d.ts.map +1 -0
  86. package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -1
  87. package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +1 -1
  88. package/dist/lib/strategies/Strategy.d.ts +1 -1
  89. package/dist/lib/strategies/Strategy.d.ts.map +1 -1
  90. package/dist/lib/strategies/StrategyHandler.d.ts +1 -1
  91. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
  92. package/dist/lib/strategies/index.d.ts +11 -0
  93. package/dist/lib/strategies/index.d.ts.map +1 -0
  94. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +1 -1
  95. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -1
  96. package/dist/{types.d.ts → lib/types.d.ts} +15 -24
  97. package/dist/lib/types.d.ts.map +1 -0
  98. package/dist/{copyResponse.d.ts → lib/utils.d.ts} +22 -1
  99. package/dist/lib/utils.d.ts.map +1 -0
  100. package/dist/models/messages/messageGenerator.d.ts +1 -1
  101. package/dist/models/messages/messageGenerator.d.ts.map +1 -1
  102. package/dist/utils/SerwistError.d.ts +2 -2
  103. package/dist/utils/SerwistError.d.ts.map +1 -1
  104. package/dist/utils/assert.d.ts +1 -1
  105. package/dist/utils/assert.d.ts.map +1 -1
  106. package/dist/utils/cacheNames.d.ts.map +1 -1
  107. package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -1
  108. package/dist/utils/createCacheKey.d.ts +1 -1
  109. package/dist/utils/createCacheKey.d.ts.map +1 -1
  110. package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -1
  111. package/dist/utils/generateURLVariations.d.ts +1 -1
  112. package/dist/utils/generateURLVariations.d.ts.map +1 -1
  113. package/dist/utils/getFriendlyURL.d.ts.map +1 -1
  114. package/dist/utils/logger.d.ts +1 -1
  115. package/dist/utils/logger.d.ts.map +1 -1
  116. package/dist/utils/normalizeHandler.d.ts +1 -1
  117. package/dist/utils/normalizeHandler.d.ts.map +1 -1
  118. package/dist/utils/parseRoute.d.ts +3 -3
  119. package/dist/utils/parseRoute.d.ts.map +1 -1
  120. package/dist/utils/pluginUtils.d.ts +1 -1
  121. package/dist/utils/pluginUtils.d.ts.map +1 -1
  122. package/dist/utils/printCleanupDetails.d.ts.map +1 -1
  123. package/dist/utils/printInstallDetails.d.ts.map +1 -1
  124. package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -1
  125. package/dist/utils/waitUntil.d.ts.map +1 -1
  126. package/package.json +30 -6
  127. package/src/index.internal.ts +16 -16
  128. package/src/index.ts +100 -110
  129. package/src/lib/{backgroundSync → background-sync}/BackgroundSyncPlugin.ts +1 -1
  130. package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueue.ts +7 -7
  131. package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueueDb.ts +1 -1
  132. package/src/lib/{backgroundSync → background-sync}/BackgroundSyncQueueStore.ts +1 -3
  133. package/src/lib/{backgroundSync → background-sync}/StorableRequest.ts +2 -2
  134. package/src/lib/background-sync/index.ts +5 -0
  135. package/src/lib/{broadcastUpdate → broadcast-update}/BroadcastCacheUpdate.ts +5 -5
  136. package/src/lib/{broadcastUpdate → broadcast-update}/BroadcastUpdatePlugin.ts +1 -1
  137. package/src/lib/broadcast-update/index.ts +5 -0
  138. package/src/lib/{broadcastUpdate → broadcast-update}/responsesAreSame.ts +2 -2
  139. package/src/lib/{broadcastUpdate → broadcast-update}/types.ts +1 -1
  140. package/src/{cacheNames.ts → lib/cache-name.ts} +1 -1
  141. package/src/lib/{cacheableResponse → cacheable-response}/CacheableResponse.ts +4 -4
  142. package/src/lib/{cacheableResponse → cacheable-response}/CacheableResponsePlugin.ts +1 -1
  143. package/src/lib/cacheable-response/index.ts +3 -0
  144. package/src/lib/core.ts +128 -0
  145. package/src/lib/expiration/CacheExpiration.ts +3 -3
  146. package/src/lib/expiration/ExpirationPlugin.ts +9 -10
  147. package/src/lib/expiration/index.ts +3 -0
  148. package/src/lib/extension.ts +37 -0
  149. package/src/lib/{googleAnalytics/initializeGoogleAnalytics.ts → extensions/google-analytics/extension.ts} +43 -49
  150. package/src/lib/extensions/google-analytics/index.ts +0 -0
  151. package/src/lib/extensions/google-analytics/initialize.ts +48 -0
  152. package/src/lib/extensions/index.ts +13 -0
  153. package/src/{controllers/PrecacheController/PrecacheController.ts → lib/extensions/precache/extension.ts} +37 -56
  154. package/src/{controllers/PrecacheController/parsePrecacheOptions.ts → lib/extensions/precache/options.ts} +11 -8
  155. package/src/{controllers/PrecacheController/PrecacheCacheKeyPlugin.ts → lib/extensions/precache/plugin-cache-key.ts} +4 -4
  156. package/src/lib/{precaching/PrecacheFallbackPlugin.ts → extensions/precache/plugin-fallback.ts} +26 -16
  157. package/src/{controllers/PrecacheController/PrecacheInstallReportPlugin.ts → lib/extensions/precache/plugin-install-report.ts} +1 -1
  158. package/src/lib/extensions/precache/route.ts +72 -0
  159. package/src/{controllers/PrecacheController/PrecacheStrategy.ts → lib/extensions/precache/strategy.ts} +11 -11
  160. package/src/{controllers/RuntimeCacheController.ts → lib/extensions/runtime-cache.ts} +24 -17
  161. package/src/lib/functions/handlers.ts +149 -0
  162. package/src/lib/functions/router.ts +314 -0
  163. package/src/{navigationPreload.ts → lib/navigation-preload.ts} +1 -1
  164. package/src/lib/{rangeRequests → range-requests}/RangeRequestsPlugin.ts +1 -1
  165. package/src/lib/{rangeRequests → range-requests}/createPartialResponse.ts +3 -3
  166. package/src/lib/range-requests/index.ts +2 -0
  167. package/src/lib/{rangeRequests → range-requests}/utils/calculateEffectiveBoundaries.ts +2 -2
  168. package/src/lib/{rangeRequests → range-requests}/utils/parseRangeHeader.ts +2 -2
  169. package/src/lib/route.ts +234 -0
  170. package/src/lib/serwist.ts +443 -0
  171. package/src/lib/strategies/CacheFirst.ts +4 -4
  172. package/src/lib/strategies/CacheOnly.ts +3 -3
  173. package/src/lib/strategies/NetworkFirst.ts +6 -6
  174. package/src/lib/strategies/NetworkOnly.ts +5 -5
  175. package/src/lib/strategies/StaleWhileRevalidate.ts +5 -5
  176. package/src/lib/strategies/Strategy.ts +9 -9
  177. package/src/lib/strategies/StrategyHandler.ts +11 -11
  178. package/src/lib/strategies/index.ts +10 -0
  179. package/src/lib/strategies/plugins/cacheOkAndOpaquePlugin.ts +1 -1
  180. package/src/lib/strategies/utils/messages.ts +2 -2
  181. package/src/{types.ts → lib/types.ts} +17 -26
  182. package/src/lib/utils.ts +137 -0
  183. package/src/models/messages/messageGenerator.ts +1 -1
  184. package/src/models/messages/messages.ts +3 -3
  185. package/src/utils/SerwistError.ts +3 -3
  186. package/src/utils/assert.ts +1 -2
  187. package/src/utils/cacheNames.ts +0 -2
  188. package/src/utils/canConstructReadableStream.ts +1 -1
  189. package/src/utils/canConstructResponseFromBodyStream.ts +1 -1
  190. package/src/utils/createCacheKey.ts +1 -2
  191. package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
  192. package/src/utils/generateURLVariations.ts +1 -1
  193. package/src/utils/logger.ts +1 -1
  194. package/src/utils/normalizeHandler.ts +1 -1
  195. package/src/utils/parseRoute.ts +4 -5
  196. package/src/utils/pluginUtils.ts +1 -1
  197. package/src/utils/resultingClientExists.ts +1 -1
  198. package/dist/NavigationRoute.d.ts +0 -56
  199. package/dist/NavigationRoute.d.ts.map +0 -1
  200. package/dist/RegExpRoute.d.ts +0 -24
  201. package/dist/RegExpRoute.d.ts.map +0 -1
  202. package/dist/Route.d.ts +0 -33
  203. package/dist/Route.d.ts.map +0 -1
  204. package/dist/Serwist.d.ts.map +0 -1
  205. package/dist/cacheNames.d.ts.map +0 -1
  206. package/dist/constants.d.ts.map +0 -1
  207. package/dist/controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  208. package/dist/controllers/PrecacheController/PrecacheController.d.ts.map +0 -1
  209. package/dist/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts.map +0 -1
  210. package/dist/controllers/PrecacheController/PrecacheRoute.d.ts +0 -15
  211. package/dist/controllers/PrecacheController/PrecacheRoute.d.ts.map +0 -1
  212. package/dist/controllers/PrecacheController/PrecacheStrategy.d.ts.map +0 -1
  213. package/dist/controllers/PrecacheController/parsePrecacheOptions.d.ts.map +0 -1
  214. package/dist/controllers/RuntimeCacheController.d.ts.map +0 -1
  215. package/dist/copyResponse.d.ts.map +0 -1
  216. package/dist/disableDevLogs.d.ts +0 -7
  217. package/dist/disableDevLogs.d.ts.map +0 -1
  218. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
  219. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +0 -1
  220. package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +0 -1
  221. package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +0 -1
  222. package/dist/lib/backgroundSync/StorableRequest.d.ts.map +0 -1
  223. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
  224. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
  225. package/dist/lib/broadcastUpdate/constants.d.ts.map +0 -1
  226. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
  227. package/dist/lib/broadcastUpdate/types.d.ts.map +0 -1
  228. package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +0 -1
  229. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
  230. package/dist/lib/googleAnalytics/constants.d.ts.map +0 -1
  231. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts +0 -30
  232. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +0 -1
  233. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
  234. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
  235. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +0 -1
  236. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
  237. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
  238. package/dist/navigationPreload.d.ts.map +0 -1
  239. package/dist/registerQuotaErrorCallback.d.ts +0 -8
  240. package/dist/registerQuotaErrorCallback.d.ts.map +0 -1
  241. package/dist/setCacheNameDetails.d.ts +0 -9
  242. package/dist/setCacheNameDetails.d.ts.map +0 -1
  243. package/dist/types.d.ts.map +0 -1
  244. package/src/NavigationRoute.ts +0 -118
  245. package/src/RegExpRoute.ts +0 -74
  246. package/src/Route.ts +0 -67
  247. package/src/Serwist.ts +0 -762
  248. package/src/controllers/PrecacheController/PrecacheRoute.ts +0 -44
  249. package/src/copyResponse.ts +0 -58
  250. package/src/disableDevLogs.ts +0 -10
  251. package/src/registerQuotaErrorCallback.ts +0 -34
  252. package/src/setCacheNameDetails.ts +0 -53
  253. /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueue.d.ts +0 -0
  254. /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueueDb.d.ts +0 -0
  255. /package/dist/lib/{backgroundSync → background-sync}/BackgroundSyncQueueStore.d.ts +0 -0
  256. /package/dist/lib/{broadcastUpdate → broadcast-update}/constants.d.ts +0 -0
  257. /package/dist/lib/{broadcastUpdate → broadcast-update}/responsesAreSame.d.ts +0 -0
  258. /package/dist/lib/{cacheableResponse → cacheable-response}/CacheableResponse.d.ts +0 -0
  259. /package/dist/lib/{googleAnalytics → extensions/google-analytics}/constants.d.ts +0 -0
  260. /package/dist/lib/{rangeRequests → range-requests}/createPartialResponse.d.ts +0 -0
  261. /package/dist/lib/{rangeRequests → range-requests}/utils/calculateEffectiveBoundaries.d.ts +0 -0
  262. /package/dist/lib/{rangeRequests → range-requests}/utils/parseRangeHeader.d.ts +0 -0
  263. /package/src/lib/{broadcastUpdate → broadcast-update}/constants.ts +0 -0
  264. /package/src/{constants.ts → lib/constants.ts} +0 -0
  265. /package/src/lib/{googleAnalytics → extensions/google-analytics}/constants.ts +0 -0
package/src/Serwist.ts DELETED
@@ -1,762 +0,0 @@
1
- import type { Route } from "./Route.js";
2
- import { type HTTPMethod, defaultMethod } from "./constants.js";
3
- import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
4
- import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
5
- import type { PrecacheFallbackEntry } from "./lib/precaching/PrecacheFallbackPlugin.js";
6
- import type { Strategy } from "./lib/strategies/Strategy.js";
7
- import { enableNavigationPreload } from "./navigationPreload.js";
8
- import { setCacheNameDetails } from "./setCacheNameDetails.js";
9
- import type {
10
- Controller,
11
- PrecacheEntry,
12
- RouteHandler,
13
- RouteHandlerCallback,
14
- RouteHandlerCallbackOptions,
15
- RouteHandlerObject,
16
- RouteMatchCallback,
17
- RouteMatchCallbackOptions,
18
- RuntimeCaching,
19
- } from "./types.js";
20
- import { SerwistError } from "./utils/SerwistError.js";
21
- import { assert } from "./utils/assert.js";
22
- import { clientsClaim as clientsClaimImpl } from "./utils/clientsClaim.js";
23
- import { getFriendlyURL } from "./utils/getFriendlyURL.js";
24
- import { logger } from "./utils/logger.js";
25
- import { normalizeHandler } from "./utils/normalizeHandler.js";
26
- import { parseRoute } from "./utils/parseRoute.js";
27
- import { waitUntil } from "./utils/waitUntil.js";
28
- import { PrecacheController, type PrecacheOptions } from "./controllers/PrecacheController/PrecacheController.js";
29
- import { RuntimeCacheController } from "./controllers/RuntimeCacheController.js";
30
-
31
- declare const self: ServiceWorkerGlobalScope;
32
-
33
- export interface FallbackEntry extends PrecacheFallbackEntry {}
34
-
35
- export interface FallbacksOptions {
36
- /**
37
- * A list of fallback entries.
38
- */
39
- entries: FallbackEntry[];
40
- }
41
-
42
- export interface SerwistOptions {
43
- /**
44
- * A list of URLs that should be cached.
45
- */
46
- precacheEntries?: (PrecacheEntry | string)[];
47
- /**
48
- * Options to customize how Serwist precaches the URLs in the precache list.
49
- */
50
- precacheOptions?: PrecacheOptions;
51
- /**
52
- * A list of controllers that run throughout Serwist's lifecycle.
53
- */
54
- controllers?: Controller[];
55
- /**
56
- * Forces the waiting service worker to become the active one.
57
- *
58
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting
59
- */
60
- skipWaiting?: boolean;
61
- /**
62
- * Imports external scripts. They are executed in the order they
63
- * are passed.
64
- *
65
- * @see https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
66
- */
67
- importScripts?: string[];
68
- /**
69
- * Enables navigation preloading if it is supported.
70
- *
71
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload
72
- */
73
- navigationPreload?: boolean;
74
- /**
75
- * Modifies the prefix of the default cache names used by Serwist packages.
76
- */
77
- cacheId?: string | undefined;
78
- /**
79
- * Claims any currently available clients once the service worker
80
- * becomes active. This is normally used in conjunction with `skipWaiting()`.
81
- *
82
- * @default false
83
- */
84
- clientsClaim?: boolean;
85
- /**
86
- * A list of caching strategies.
87
- *
88
- * @deprecated Use {@linkcode RuntimeCacheController} instead.
89
- */
90
- runtimeCaching?: RuntimeCaching[];
91
- /**
92
- * Your configuration for {@linkcode initializeGoogleAnalytics}. This plugin is
93
- * only initialized when this option is not `undefined` or `false`.
94
- */
95
- offlineAnalyticsConfig?: Omit<GoogleAnalyticsInitializeOptions, "serwist"> | boolean;
96
- /**
97
- * Disables Serwist's logging in development mode.
98
- *
99
- * @default false
100
- */
101
- disableDevLogs?: boolean;
102
- /**
103
- * Precaches routes so that they can be used as a fallback when
104
- * a {@linkcode Strategy} fails to generate a response.
105
- *
106
- * Note: This option mutates `runtimeCaching`. It also expects the URLs
107
- * defined in `entries` to have been precached beforehand.
108
- *
109
- * @deprecated Use {@linkcode RuntimeCacheController} instead.
110
- */
111
- fallbacks?: FallbacksOptions;
112
- }
113
-
114
- type RequestArgs = string | [string, RequestInit?];
115
-
116
- interface CacheURLsMessageData {
117
- type: string;
118
- payload: {
119
- urlsToCache: RequestArgs[];
120
- };
121
- }
122
-
123
- /**
124
- * A class that helps bootstrap the service worker.
125
- *
126
- * @see https://serwist.pages.dev/docs/serwist/core/serwist
127
- */
128
- export class Serwist {
129
- private readonly _routes: Map<HTTPMethod, Route[]>;
130
- private readonly _defaultHandlerMap: Map<HTTPMethod, RouteHandlerObject>;
131
- private readonly _precacheController: PrecacheController;
132
- private readonly _controllers: Controller[];
133
- private _catchHandler?: RouteHandlerObject;
134
-
135
- constructor({
136
- precacheEntries,
137
- precacheOptions,
138
- controllers = [],
139
- skipWaiting = false,
140
- importScripts,
141
- navigationPreload = false,
142
- cacheId,
143
- clientsClaim = false,
144
- runtimeCaching,
145
- offlineAnalyticsConfig,
146
- disableDevLogs = false,
147
- fallbacks,
148
- }: SerwistOptions = {}) {
149
- this._routes = new Map();
150
- this._defaultHandlerMap = new Map();
151
- this._controllers = controllers;
152
-
153
- this.handleInstall = this.handleInstall.bind(this);
154
- this.handleActivate = this.handleActivate.bind(this);
155
- this.handleFetch = this.handleFetch.bind(this);
156
- this.handleCache = this.handleCache.bind(this);
157
-
158
- if (!!importScripts && importScripts.length > 0) self.importScripts(...importScripts);
159
-
160
- if (navigationPreload) enableNavigationPreload();
161
-
162
- if (cacheId !== undefined) {
163
- setCacheNameDetails({
164
- prefix: cacheId,
165
- });
166
- }
167
-
168
- if (skipWaiting) {
169
- self.skipWaiting();
170
- } else {
171
- self.addEventListener("message", (event) => {
172
- if (event.data && event.data.type === "SKIP_WAITING") {
173
- self.skipWaiting();
174
- }
175
- });
176
- }
177
-
178
- if (clientsClaim) clientsClaimImpl();
179
-
180
- this._precacheController = new PrecacheController(precacheEntries ?? [], precacheOptions);
181
-
182
- // TODO(ducanhgh): remove in v10.
183
- // Fallback for legacy users who have not migrated from `runtimeCaching` to the Controller pattern.
184
- if (runtimeCaching) {
185
- if (!this._controllers?.some((controller) => controller instanceof RuntimeCacheController)) {
186
- this._controllers.unshift(new RuntimeCacheController(runtimeCaching, { fallbacks }));
187
- } else if (process.env.NODE_ENV !== "production") {
188
- logger.warn("You have migrated to the Controller pattern, so setting `runtimeCaching` is a no-op.");
189
- }
190
- }
191
-
192
- this._controllers.unshift(this._precacheController);
193
-
194
- if (offlineAnalyticsConfig !== undefined) {
195
- if (typeof offlineAnalyticsConfig === "boolean") {
196
- offlineAnalyticsConfig && initializeGoogleAnalytics({ serwist: this });
197
- } else {
198
- initializeGoogleAnalytics({
199
- ...offlineAnalyticsConfig,
200
- serwist: this,
201
- });
202
- }
203
- }
204
-
205
- for (const callback of this.iterateControllers("init")) {
206
- callback(this);
207
- }
208
-
209
- if (disableDevLogs) disableDevLogsImpl();
210
- }
211
-
212
- /**
213
- * Accepts a callback name and returns an iterable of matching plugin callbacks.
214
- *
215
- * @param name The name fo the callback to run
216
- * @returns
217
- */
218
- *iterateControllers<C extends keyof Controller>(name: C): Generator<NonNullable<Controller[C]>> {
219
- if (!this._controllers) return;
220
-
221
- for (const controller of this._controllers) {
222
- if (typeof controller[name] === "function") {
223
- yield controller[name];
224
- }
225
- }
226
- }
227
-
228
- /**
229
- * The `PrecacheController` used to handle precaching.
230
- */
231
- get precache(): PrecacheController {
232
- return this._precacheController;
233
- }
234
-
235
- /**
236
- * The strategy used to precache assets and respond to `fetch` events.
237
- */
238
- get precacheStrategy(): Strategy {
239
- return this._precacheController.strategy;
240
- }
241
-
242
- /**
243
- * A `Map` of HTTP method name (`'GET'`, etc.) to an array of all corresponding registered {@linkcode Route}
244
- * instances.
245
- */
246
- get routes(): Map<HTTPMethod, Route[]> {
247
- return this._routes;
248
- }
249
-
250
- /**
251
- * Adds Serwist's event listeners. Before calling it, add your own listeners should you need to.
252
- */
253
- addEventListeners() {
254
- self.addEventListener("install", this.handleInstall);
255
- self.addEventListener("activate", this.handleActivate);
256
- self.addEventListener("fetch", this.handleFetch);
257
- self.addEventListener("message", this.handleCache);
258
- }
259
-
260
- /**
261
- * Precaches new and updated assets. Call this method from the service worker's
262
- * `install` event.
263
- *
264
- * Note: this method calls `event.waitUntil()` for you, so you do not need
265
- * to call it yourself in your event handlers.
266
- *
267
- * @param event
268
- * @returns
269
- */
270
- handleInstall(event: ExtendableEvent): Promise<void> {
271
- return waitUntil(event, async () => {
272
- for (const callback of this.iterateControllers("install")) {
273
- await callback(event, this);
274
- }
275
- });
276
- }
277
-
278
- /**
279
- * Deletes assets that are no longer present in the current precache manifest.
280
- * Call this method from the service worker's `activate` event.
281
- *
282
- * Note: this method calls `event.waitUntil()` for you, so you do not need
283
- * to call it yourself in your event handlers.
284
- *
285
- * @param event
286
- * @returns
287
- */
288
- handleActivate(event: ExtendableEvent): Promise<void> {
289
- return waitUntil(event, async () => {
290
- for (const callback of this.iterateControllers("activate")) {
291
- await callback(event, this);
292
- }
293
- });
294
- }
295
-
296
- /**
297
- * Gets a `Response` from an appropriate `Route`'s handler. Call this method
298
- * from the service worker's `fetch` event.
299
- * @param event
300
- */
301
- handleFetch(event: FetchEvent) {
302
- const { request } = event;
303
- const responsePromise = this.handleRequest({ request, event });
304
- if (responsePromise) {
305
- event.respondWith(responsePromise);
306
- }
307
- }
308
-
309
- /**
310
- * Caches new URLs on demand. Call this method from the service worker's
311
- * `message` event. To trigger the handler, send a message of type `"CACHE_URLS"`
312
- * alongside a list of URLs that should be cached as `urlsToCache`.
313
- * @param event
314
- */
315
- handleCache(event: ExtendableMessageEvent) {
316
- if (event.data && event.data.type === "CACHE_URLS") {
317
- const { payload }: CacheURLsMessageData = event.data;
318
-
319
- if (process.env.NODE_ENV !== "production") {
320
- logger.debug("Caching URLs from the window", payload.urlsToCache);
321
- }
322
-
323
- const requestPromises = Promise.all(
324
- payload.urlsToCache.map((entry: string | [string, RequestInit?]) => {
325
- let request: Request;
326
- if (typeof entry === "string") {
327
- request = new Request(entry);
328
- } else {
329
- request = new Request(...entry);
330
- }
331
- return this.handleRequest({ request, event });
332
- }),
333
- );
334
-
335
- event.waitUntil(requestPromises);
336
-
337
- // If a MessageChannel was used, reply to the message on success.
338
- if (event.ports?.[0]) {
339
- void requestPromises.then(() => event.ports[0].postMessage(true));
340
- }
341
- }
342
- }
343
-
344
- /**
345
- * Define a default handler that's called when no routes explicitly
346
- * match the incoming request.
347
- *
348
- * Each HTTP method (`'GET'`, `'POST'`, etc.) gets its own default handler.
349
- *
350
- * Without a default handler, unmatched requests will go against the
351
- * network as if there were no service worker present.
352
- *
353
- * @param handler A callback function that returns a `Promise` resulting in a `Response`.
354
- * @param method The HTTP method to associate with this default handler. Each method
355
- * has its own default. Defaults to `'GET'`.
356
- */
357
- setDefaultHandler(handler: RouteHandler, method: HTTPMethod = defaultMethod): void {
358
- this._defaultHandlerMap.set(method, normalizeHandler(handler));
359
- }
360
-
361
- /**
362
- * If a {@linkcode Route} throws an error while handling a request, this handler
363
- * will be called and given a chance to provide a response.
364
- *
365
- * @param handler A callback function that returns a `Promise` resulting
366
- * in a `Response`.
367
- */
368
- setCatchHandler(handler: RouteHandler): void {
369
- this._catchHandler = normalizeHandler(handler);
370
- }
371
-
372
- /**
373
- * Registers a `RegExp`, string, or function with a caching
374
- * strategy to the router.
375
- *
376
- * @param capture If the capture param is a {@linkcode Route} object, all other arguments will be ignored.
377
- * @param handler A callback function that returns a `Promise` resulting in a `Response`.
378
- * This parameter is required if `capture` is not a {@linkcode Route} object.
379
- * @param method The HTTP method to match the route against. Defaults to `'GET'`.
380
- * @returns The generated {@linkcode Route} object.
381
- */
382
- registerCapture<T extends RegExp | string | RouteMatchCallback | Route>(
383
- capture: T,
384
- handler?: T extends Route ? never : RouteHandler,
385
- method?: T extends Route ? never : HTTPMethod,
386
- ): Route {
387
- const route = parseRoute(capture, handler, method);
388
- this.registerRoute(route);
389
- return route;
390
- }
391
-
392
- /**
393
- * Registers a {@linkcode Route} with the router.
394
- *
395
- * @param route The {@linkcode Route} to register.
396
- */
397
- registerRoute(route: Route): void {
398
- if (process.env.NODE_ENV !== "production") {
399
- assert!.isType(route, "object", {
400
- moduleName: "serwist",
401
- className: "Serwist",
402
- funcName: "registerRoute",
403
- paramName: "route",
404
- });
405
-
406
- assert!.hasMethod(route, "match", {
407
- moduleName: "serwist",
408
- className: "Serwist",
409
- funcName: "registerRoute",
410
- paramName: "route",
411
- });
412
-
413
- assert!.isType(route.handler, "object", {
414
- moduleName: "serwist",
415
- className: "Serwist",
416
- funcName: "registerRoute",
417
- paramName: "route",
418
- });
419
-
420
- assert!.hasMethod(route.handler, "handle", {
421
- moduleName: "serwist",
422
- className: "Serwist",
423
- funcName: "registerRoute",
424
- paramName: "route.handler",
425
- });
426
-
427
- assert!.isType(route.method, "string", {
428
- moduleName: "serwist",
429
- className: "Serwist",
430
- funcName: "registerRoute",
431
- paramName: "route.method",
432
- });
433
- }
434
-
435
- if (!this._routes.has(route.method)) {
436
- this._routes.set(route.method, []);
437
- }
438
-
439
- // Give precedence to all of the earlier routes by adding this additional
440
- // route to the end of the array.
441
- this._routes.get(route.method)!.push(route);
442
- }
443
-
444
- /**
445
- * Unregisters a route from the router.
446
- *
447
- * @param route The {@linkcode Route} object to unregister.
448
- */
449
- unregisterRoute(route: Route): void {
450
- if (!this._routes.has(route.method)) {
451
- throw new SerwistError("unregister-route-but-not-found-with-method", {
452
- method: route.method,
453
- });
454
- }
455
-
456
- const routeIndex = this._routes.get(route.method)!.indexOf(route);
457
- if (routeIndex > -1) {
458
- this._routes.get(route.method)!.splice(routeIndex, 1);
459
- } else {
460
- throw new SerwistError("unregister-route-route-not-registered");
461
- }
462
- }
463
-
464
- /**
465
- * Applies the routing rules to a `FetchEvent` object to get a response from an
466
- * appropriate route.
467
- *
468
- * @param options
469
- * @returns A promise is returned if a registered route can handle the request.
470
- * If there is no matching route and there's no default handler, `undefined`
471
- * is returned.
472
- */
473
- handleRequest({
474
- request,
475
- event,
476
- }: {
477
- /**
478
- * The request to handle.
479
- */
480
- request: Request;
481
- /**
482
- * The event that triggered the request.
483
- */
484
- event: ExtendableEvent;
485
- }): Promise<Response> | undefined {
486
- if (process.env.NODE_ENV !== "production") {
487
- assert!.isInstance(request, Request, {
488
- moduleName: "serwist",
489
- className: "Serwist",
490
- funcName: "handleRequest",
491
- paramName: "options.request",
492
- });
493
- }
494
-
495
- const url = new URL(request.url, location.href);
496
- if (!url.protocol.startsWith("http")) {
497
- if (process.env.NODE_ENV !== "production") {
498
- logger.debug("Router only supports URLs that start with 'http'.");
499
- }
500
- return;
501
- }
502
-
503
- const sameOrigin = url.origin === location.origin;
504
- const { params, route } = this.findMatchingRoute({
505
- event,
506
- request,
507
- sameOrigin,
508
- url,
509
- });
510
- let handler = route?.handler;
511
-
512
- const debugMessages = [];
513
- if (process.env.NODE_ENV !== "production") {
514
- if (handler) {
515
- debugMessages.push(["Found a route to handle this request:", route]);
516
-
517
- if (params) {
518
- debugMessages.push([`Passing the following params to the route's handler:`, params]);
519
- }
520
- }
521
- }
522
-
523
- // If we don't have a handler because there was no matching route, then
524
- // fall back to defaultHandler if that's defined.
525
- const method = request.method as HTTPMethod;
526
- if (!handler && this._defaultHandlerMap.has(method)) {
527
- if (process.env.NODE_ENV !== "production") {
528
- debugMessages.push(`Failed to find a matching route. Falling back to the default handler for ${method}.`);
529
- }
530
- handler = this._defaultHandlerMap.get(method);
531
- }
532
-
533
- if (!handler) {
534
- if (process.env.NODE_ENV !== "production") {
535
- // No handler so Serwist will do nothing. If logs is set of debug
536
- // i.e. verbose, we should print out this information.
537
- logger.debug(`No route found for: ${getFriendlyURL(url)}`);
538
- }
539
- return;
540
- }
541
-
542
- if (process.env.NODE_ENV !== "production") {
543
- // We have a handler, meaning Serwist is going to handle the route.
544
- // print the routing details to the console.
545
- logger.groupCollapsed(`Router is responding to: ${getFriendlyURL(url)}`);
546
-
547
- for (const msg of debugMessages) {
548
- if (Array.isArray(msg)) {
549
- logger.log(...msg);
550
- } else {
551
- logger.log(msg);
552
- }
553
- }
554
-
555
- logger.groupEnd();
556
- }
557
-
558
- // Wrap in try and catch in case the handle method throws a synchronous
559
- // error. It should still callback to the catch handler.
560
- let responsePromise: Promise<Response>;
561
- try {
562
- responsePromise = handler.handle({ url, request, event, params });
563
- } catch (err) {
564
- responsePromise = Promise.reject(err);
565
- }
566
-
567
- // Get route's catch handler, if it exists
568
- const catchHandler = route?.catchHandler;
569
-
570
- if (responsePromise instanceof Promise && (this._catchHandler || catchHandler)) {
571
- responsePromise = responsePromise.catch(async (err) => {
572
- // If there's a route catch handler, process that first
573
- if (catchHandler) {
574
- if (process.env.NODE_ENV !== "production") {
575
- // Still include URL here as it will be async from the console group
576
- // and may not make sense without the URL
577
- logger.groupCollapsed(`Error thrown when responding to: ${getFriendlyURL(url)}. Falling back to route's Catch Handler.`);
578
- logger.error("Error thrown by:", route);
579
- logger.error(err);
580
- logger.groupEnd();
581
- }
582
-
583
- try {
584
- return await catchHandler.handle({ url, request, event, params });
585
- } catch (catchErr) {
586
- if (catchErr instanceof Error) {
587
- err = catchErr;
588
- }
589
- }
590
- }
591
-
592
- if (this._catchHandler) {
593
- if (process.env.NODE_ENV !== "production") {
594
- // Still include URL here as it will be async from the console group
595
- // and may not make sense without the URL
596
- logger.groupCollapsed(`Error thrown when responding to: ${getFriendlyURL(url)}. Falling back to global Catch Handler.`);
597
- logger.error("Error thrown by:", route);
598
- logger.error(err);
599
- logger.groupEnd();
600
- }
601
- return this._catchHandler.handle({ url, request, event });
602
- }
603
-
604
- throw err;
605
- });
606
- }
607
-
608
- return responsePromise;
609
- }
610
-
611
- /**
612
- * Checks a request and URL (and optionally an event) against the list of
613
- * registered routes, and if there's a match, returns the corresponding
614
- * route along with any params generated by the match.
615
- *
616
- * @param options
617
- * @returns An object with `route` and `params` properties. They are populated
618
- * if a matching route was found or `undefined` otherwise.
619
- */
620
- findMatchingRoute({ url, sameOrigin, request, event }: RouteMatchCallbackOptions): {
621
- route?: Route;
622
- params?: RouteHandlerCallbackOptions["params"];
623
- } {
624
- const routes = this._routes.get(request.method as HTTPMethod) || [];
625
- for (const route of routes) {
626
- let params: Promise<any> | undefined;
627
- // route.match returns type any, not possible to change right now.
628
- const matchResult = route.match({ url, sameOrigin, request, event });
629
- if (matchResult) {
630
- if (process.env.NODE_ENV !== "production") {
631
- // Warn developers that using an async matchCallback is almost always
632
- // not the right thing to do.
633
- if (matchResult instanceof Promise) {
634
- logger.warn(
635
- `While routing ${getFriendlyURL(
636
- url,
637
- )}, an async matchCallback function was used. Please convert the following route to use a synchronous matchCallback function:`,
638
- route,
639
- );
640
- }
641
- }
642
-
643
- // See https://github.com/GoogleChrome/workbox/issues/2079
644
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
645
- params = matchResult;
646
- if (Array.isArray(params) && params.length === 0) {
647
- // Instead of passing an empty array in as params, use undefined.
648
- params = undefined;
649
- } else if (
650
- matchResult.constructor === Object && // eslint-disable-line
651
- Object.keys(matchResult).length === 0
652
- ) {
653
- // Instead of passing an empty object in as params, use undefined.
654
- params = undefined;
655
- } else if (typeof matchResult === "boolean") {
656
- // For the boolean value true (rather than just something truth-y),
657
- // don't set params.
658
- // See https://github.com/GoogleChrome/workbox/pull/2134#issuecomment-513924353
659
- params = undefined;
660
- }
661
-
662
- // Return early if have a match.
663
- return { route, params };
664
- }
665
- }
666
- // If no match was found above, return and empty object.
667
- return {};
668
- }
669
-
670
- // The following are deprecated methods:
671
-
672
- /**
673
- * Adds items to the precache list, removing duplicates and ensuring the information is valid.
674
- *
675
- * @deprecated Use `serwist.precache.addToPrecacheList` instead.
676
- * @param entries Array of entries to precache.
677
- */
678
- addToPrecacheList(entries: (PrecacheEntry | string)[]): void {
679
- this._precacheController.addToCacheList(entries);
680
- }
681
-
682
- /**
683
- * Returns a mapping of a precached URL to the corresponding cache key, taking
684
- * into account the revision information for the URL.
685
- *
686
- * @deprecated Use `serwist.precache.getUrlsToPrecacheKeys` instead.
687
- * @returns A URL to cache key mapping.
688
- */
689
- getUrlsToPrecacheKeys(): Map<string, string> {
690
- return this.precache.getUrlsToPrecacheKeys();
691
- }
692
-
693
- /**
694
- * Returns a list of all the URLs that have been precached by the current
695
- * service worker.
696
- *
697
- * @deprecated Use `serwist.precache.getPrecachedUrls` instead.
698
- * @returns The precached URLs.
699
- */
700
- getPrecachedUrls(): string[] {
701
- return this.precache.getPrecachedUrls();
702
- }
703
-
704
- /**
705
- * Returns the cache key used for storing a given URL. If that URL is
706
- * unversioned, like "/index.html", then the cache key will be the original
707
- * URL with a search parameter appended to it.
708
- *
709
- * @deprecated Use `serwist.precache.getPrecacheKeyForUrl` instead.
710
- * @param url A URL whose cache key you want to look up.
711
- * @returns The versioned URL that corresponds to a cache key
712
- * for the original URL, or undefined if that URL isn't precached.
713
- */
714
- getPrecacheKeyForUrl(url: string): string | undefined {
715
- return this.precache.getPrecacheKeyForUrl(url);
716
- }
717
-
718
- /**
719
- * @deprecated Use `serwist.precache.getIntegrityForPrecacheKey` instead.
720
- * @param url A cache key whose SRI you want to look up.
721
- * @returns The subresource integrity associated with the cache key,
722
- * or undefined if it's not set.
723
- */
724
- getIntegrityForPrecacheKey(cacheKey: string): string | undefined {
725
- return this.precache.getIntegrityForPrecacheKey(cacheKey);
726
- }
727
-
728
- /**
729
- * This acts as a drop-in replacement for
730
- * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
731
- * with the following differences:
732
- *
733
- * - It knows what the name of the precache is, and only checks in that cache.
734
- * - It allows you to pass in an "original" URL without versioning parameters,
735
- * and it will automatically look up the correct cache key for the currently
736
- * active revision of that URL.
737
- *
738
- * E.g., `matchPrecache('index.html')` will find the correct precached
739
- * response for the currently active service worker, even if the actual cache
740
- * key is `'/index.html?__WB_REVISION__=1234abcd'`.
741
- *
742
- * @deprecated Use `serwist.precache.matchPrecache` instead.
743
- * @param request The key (without revisioning parameters)
744
- * to look up in the precache.
745
- * @returns
746
- */
747
- matchPrecache(request: string | Request): Promise<Response | undefined> {
748
- return this.precache.matchPrecache(request);
749
- }
750
-
751
- /**
752
- * Returns a function that looks up `url` in the precache (taking into
753
- * account revision information), and returns the corresponding `Response`.
754
- *
755
- * @deprecated Use `serwist.precache.createHandlerBoundToUrl` instead.
756
- * @param url The precached URL which will be used to lookup the response.
757
- * @return
758
- */
759
- createHandlerBoundToUrl(url: string): RouteHandlerCallback {
760
- return this.precache.createHandlerBoundToUrl(url);
761
- }
762
- }