serwist 9.0.2 → 9.0.3

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 (127) hide show
  1. package/dist/NavigationRoute.d.ts +2 -2
  2. package/dist/PrecacheRoute.d.ts +2 -3
  3. package/dist/PrecacheRoute.d.ts.map +1 -1
  4. package/dist/RegExpRoute.d.ts +2 -2
  5. package/dist/Route.d.ts +4 -4
  6. package/dist/Serwist.d.ts +19 -19
  7. package/dist/chunks/printInstallDetails.js +6 -10
  8. package/dist/copyResponse.d.ts.map +1 -1
  9. package/dist/legacy/PrecacheController.d.ts +1 -1
  10. package/dist/legacy/PrecacheFallbackPlugin.d.ts +6 -7
  11. package/dist/legacy/PrecacheFallbackPlugin.d.ts.map +1 -1
  12. package/dist/legacy/PrecacheRoute.d.ts +3 -3
  13. package/dist/legacy/Router.d.ts +23 -23
  14. package/dist/legacy/addRoute.d.ts +6 -8
  15. package/dist/legacy/addRoute.d.ts.map +1 -1
  16. package/dist/legacy/createHandlerBoundToURL.d.ts +5 -6
  17. package/dist/legacy/createHandlerBoundToURL.d.ts.map +1 -1
  18. package/dist/legacy/fallbacks.d.ts +3 -3
  19. package/dist/legacy/handlePrecaching.d.ts +3 -3
  20. package/dist/legacy/initializeGoogleAnalytics.d.ts +1 -1
  21. package/dist/legacy/installSerwist.d.ts +4 -4
  22. package/dist/legacy/matchPrecache.d.ts +4 -4
  23. package/dist/legacy/matchPrecache.d.ts.map +1 -1
  24. package/dist/legacy/precache.d.ts +2 -2
  25. package/dist/legacy/precache.d.ts.map +1 -1
  26. package/dist/legacy/precacheAndRoute.d.ts +3 -4
  27. package/dist/legacy/precacheAndRoute.d.ts.map +1 -1
  28. package/dist/legacy/registerRoute.d.ts +6 -6
  29. package/dist/legacy/registerRoute.d.ts.map +1 -1
  30. package/dist/legacy/registerRuntimeCaching.d.ts +1 -1
  31. package/dist/legacy/setCatchHandler.d.ts +2 -2
  32. package/dist/legacy/setDefaultHandler.d.ts +3 -3
  33. package/dist/legacy/singletonPrecacheController.d.ts +7 -7
  34. package/dist/legacy/singletonRouter.d.ts +9 -9
  35. package/dist/legacy/unregisterRoute.d.ts +1 -1
  36. package/dist/legacy/unregisterRoute.d.ts.map +1 -1
  37. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts +3 -3
  38. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts +1 -1
  39. package/dist/lib/backgroundSync/StorableRequest.d.ts +1 -1
  40. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts +1 -2
  41. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -1
  42. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts +4 -7
  43. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -1
  44. package/dist/lib/broadcastUpdate/types.d.ts +2 -1
  45. package/dist/lib/broadcastUpdate/types.d.ts.map +1 -1
  46. package/dist/lib/cacheableResponse/CacheableResponse.d.ts +6 -6
  47. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts +2 -2
  48. package/dist/lib/expiration/CacheExpiration.d.ts +2 -2
  49. package/dist/lib/expiration/ExpirationPlugin.d.ts +11 -11
  50. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -1
  51. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts +4 -4
  52. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts +3 -4
  53. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -1
  54. package/dist/lib/rangeRequests/createPartialResponse.d.ts +7 -7
  55. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -1
  56. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts +2 -2
  57. package/dist/lib/strategies/CacheFirst.d.ts +1 -1
  58. package/dist/lib/strategies/CacheOnly.d.ts +1 -1
  59. package/dist/lib/strategies/NetworkFirst.d.ts +1 -1
  60. package/dist/lib/strategies/NetworkOnly.d.ts +1 -1
  61. package/dist/lib/strategies/PrecacheStrategy.d.ts +3 -3
  62. package/dist/lib/strategies/PrecacheStrategy.d.ts.map +1 -1
  63. package/dist/lib/strategies/StaleWhileRevalidate.d.ts +1 -1
  64. package/dist/lib/strategies/Strategy.d.ts +7 -7
  65. package/dist/lib/strategies/StrategyHandler.d.ts +12 -13
  66. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
  67. package/dist/types.d.ts +37 -36
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/utils/cacheNames.d.ts +1 -1
  70. package/dist/utils/cacheNames.d.ts.map +1 -1
  71. package/dist/utils/canConstructResponseFromBodyStream.d.ts +2 -2
  72. package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -1
  73. package/dist/utils/executeQuotaErrorCallbacks.d.ts.map +1 -1
  74. package/dist/utils/parseRoute.d.ts +8 -8
  75. package/dist/utils/waitUntil.d.ts.map +1 -1
  76. package/package.json +5 -5
  77. package/src/NavigationRoute.ts +2 -2
  78. package/src/PrecacheRoute.ts +2 -3
  79. package/src/RegExpRoute.ts +2 -2
  80. package/src/Route.ts +4 -4
  81. package/src/Serwist.ts +19 -19
  82. package/src/legacy/PrecacheController.ts +1 -1
  83. package/src/legacy/PrecacheFallbackPlugin.ts +6 -7
  84. package/src/legacy/PrecacheRoute.ts +3 -3
  85. package/src/legacy/Router.ts +23 -23
  86. package/src/legacy/addRoute.ts +6 -8
  87. package/src/legacy/createHandlerBoundToURL.ts +6 -6
  88. package/src/legacy/fallbacks.ts +3 -3
  89. package/src/legacy/handlePrecaching.ts +3 -3
  90. package/src/legacy/initializeGoogleAnalytics.ts +1 -1
  91. package/src/legacy/installSerwist.ts +4 -4
  92. package/src/legacy/matchPrecache.ts +5 -4
  93. package/src/legacy/precache.ts +4 -2
  94. package/src/legacy/precacheAndRoute.ts +3 -4
  95. package/src/legacy/registerRoute.ts +8 -7
  96. package/src/legacy/registerRuntimeCaching.ts +1 -1
  97. package/src/legacy/setCatchHandler.ts +2 -2
  98. package/src/legacy/setDefaultHandler.ts +3 -3
  99. package/src/legacy/singletonPrecacheController.ts +7 -7
  100. package/src/legacy/singletonRouter.ts +9 -9
  101. package/src/legacy/unregisterRoute.ts +2 -1
  102. package/src/lib/backgroundSync/BackgroundSyncPlugin.ts +3 -3
  103. package/src/lib/backgroundSync/BackgroundSyncQueue.ts +1 -1
  104. package/src/lib/backgroundSync/StorableRequest.ts +1 -1
  105. package/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts +1 -2
  106. package/src/lib/broadcastUpdate/BroadcastUpdatePlugin.ts +4 -7
  107. package/src/lib/broadcastUpdate/types.ts +2 -1
  108. package/src/lib/cacheableResponse/CacheableResponse.ts +6 -6
  109. package/src/lib/cacheableResponse/CacheableResponsePlugin.ts +2 -2
  110. package/src/lib/expiration/CacheExpiration.ts +2 -2
  111. package/src/lib/expiration/ExpirationPlugin.ts +12 -11
  112. package/src/lib/precaching/PrecacheFallbackPlugin.ts +4 -4
  113. package/src/lib/rangeRequests/RangeRequestsPlugin.ts +3 -4
  114. package/src/lib/rangeRequests/createPartialResponse.ts +7 -7
  115. package/src/lib/rangeRequests/utils/parseRangeHeader.ts +2 -2
  116. package/src/lib/strategies/CacheFirst.ts +1 -1
  117. package/src/lib/strategies/CacheOnly.ts +1 -1
  118. package/src/lib/strategies/NetworkFirst.ts +1 -1
  119. package/src/lib/strategies/NetworkOnly.ts +1 -1
  120. package/src/lib/strategies/PrecacheStrategy.ts +4 -3
  121. package/src/lib/strategies/StaleWhileRevalidate.ts +1 -1
  122. package/src/lib/strategies/Strategy.ts +7 -7
  123. package/src/lib/strategies/StrategyHandler.ts +21 -25
  124. package/src/types.ts +39 -36
  125. package/src/utils/cacheNames.ts +2 -1
  126. package/src/utils/canConstructResponseFromBodyStream.ts +2 -2
  127. package/src/utils/parseRoute.ts +8 -8
@@ -29,15 +29,15 @@ interface CacheURLsMessageData {
29
29
  }
30
30
 
31
31
  /**
32
- * `Router` can be used to process a `FetchEvent` using one or more `Route`(s), responding with a `Response`
32
+ * A class that can be used to process a `fetch` event using one or more route(s), responding with a response
33
33
  * if a matching route exists.
34
34
  *
35
- * If no `Route` matches given a `Request`, the `Router` will use the default handler if one is defined.
35
+ * If no route matches given a request, the router will use the default handler if one is defined.
36
36
  *
37
- * Should the matching Route throw an error, the Router will use the catch handler if one is defined to
38
- * gracefully deal with issues and respond with a `Request`.
37
+ * Should the matching route throw an error, the router will use the catch handler if one is defined to
38
+ * gracefully deal with issues and respond with a response.
39
39
  *
40
- * If a `Request` matches multiple routes, the earliest registered route will be used to respond to the `Request`.
40
+ * If a request matches multiple routes, the earliest registered route will be used to respond to the it.
41
41
  * @deprecated
42
42
  */
43
43
  export class Router {
@@ -56,16 +56,16 @@ export class Router {
56
56
  }
57
57
 
58
58
  /**
59
- * @returns routes A `Map` of HTTP method name (`'GET'`, etc.) to an array of all the corresponding `Route`
60
- * instances that are registered.
59
+ * @returns routes A `Map` of HTTP method name (`'GET'`, etc.) to an array of all
60
+ * the corresponding {@linkcode Route} instances that are registered.
61
61
  */
62
62
  get routes(): Map<HTTPMethod, Route[]> {
63
63
  return this._routes;
64
64
  }
65
65
 
66
66
  /**
67
- * Adds a `fetch` event listener to respond to events when a `Route` matches
68
- * the event's request. Effectively no-op if `addFEtchListener` has been
67
+ * Adds a `fetch` event listener to respond to events when a route matches
68
+ * the event's request. Effectively no-op if `addFetchListener` has been
69
69
  * called, but `removeFetchListener` has not.
70
70
  */
71
71
  addFetchListener(): void {
@@ -161,8 +161,8 @@ export class Router {
161
161
  }
162
162
 
163
163
  /**
164
- * Apply the routing rules to a `FetchEvent` object to get a `Response` from an
165
- * appropriate `Route`'s handler.
164
+ * Apply the routing rules to a `fetch` event to get a response from an
165
+ * appropriate route.
166
166
  *
167
167
  * @param options
168
168
  * @returns A promise is returned if a registered route can handle the request.
@@ -367,7 +367,7 @@ export class Router {
367
367
  }
368
368
 
369
369
  /**
370
- * Define a default `handler` that's called when no routes explicitly
370
+ * Define a default handler that's called when no routes explicitly
371
371
  * match the incoming request.
372
372
  *
373
373
  * Each HTTP method (`'GET'`, `'POST'`, etc.) gets its own default handler.
@@ -375,7 +375,7 @@ export class Router {
375
375
  * Without a default handler, unmatched requests will go against the
376
376
  * network as if there were no service worker present.
377
377
  *
378
- * @param handler A callback function that returns a `Promise` resulting in a `Response`.
378
+ * @param handler A callback function that returns a promise resulting in a response.
379
379
  * @param method The HTTP method to associate with this default handler. Each method
380
380
  * has its own default. Defaults to `'GET'`.
381
381
  */
@@ -396,13 +396,13 @@ export class Router {
396
396
 
397
397
  /**
398
398
  * Registers a `RegExp`, string, or function with a caching
399
- * strategy to the `Router`.
399
+ * strategy to the router.
400
400
  *
401
- * @param capture If the capture param is a `Route`, all other arguments will be ignored.
402
- * @param handler A callback function that returns a `Promise` resulting in a `Response`.
403
- * This parameter is required if `capture` is not a `Route` object.
404
- * @param method The HTTP method to match the Route against. Defaults to `'GET'`.
405
- * @returns The generated `Route`.
401
+ * @param capture If the capture param is a {@linkcode Route} object, all other arguments will be ignored.
402
+ * @param handler A callback function that returns a promise resulting in a response.
403
+ * This parameter is required if `capture` is not a {@linkcode Route} object.
404
+ * @param method The HTTP method to match the route against. Defaults to `'GET'`.
405
+ * @returns The generated {@linkcode Route} object.
406
406
  */
407
407
  registerCapture(capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route {
408
408
  const route = parseRoute(capture, handler, method);
@@ -411,9 +411,9 @@ export class Router {
411
411
  }
412
412
 
413
413
  /**
414
- * Registers a `Route` with the router.
414
+ * Registers a route with the router.
415
415
  *
416
- * @param route The `Route` to register.
416
+ * @param route The route to register.
417
417
  */
418
418
  registerRoute(route: Route): void {
419
419
  if (process.env.NODE_ENV !== "production") {
@@ -463,9 +463,9 @@ export class Router {
463
463
  }
464
464
 
465
465
  /**
466
- * Unregisters a `Route` with the `Router`.
466
+ * Unregisters a route from the router.
467
467
  *
468
- * @param route The `Route` to unregister.
468
+ * @param route The route to unregister.
469
469
  */
470
470
  unregisterRoute(route: Route): void {
471
471
  if (!this._routes.has(route.method)) {
@@ -11,16 +11,14 @@ import { registerRoute } from "./registerRoute.js";
11
11
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
12
12
 
13
13
  /**
14
- * Add a `fetch` listener to the service worker that will
15
- * respond to
16
- * [network requests](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests)
17
- * with precached assets.
14
+ * Add a `fetch` listener that will
15
+ * respond to [network requests](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests)
16
+ * with precached assets to the service worker.
18
17
  *
19
- * Requests for assets that aren't precached, the `FetchEvent` will not be
20
- * responded to, allowing the event to fall through to other `fetch` event
21
- * listeners.
18
+ * As for requests for assets that aren't precached, the `fetch` event will not be
19
+ * responded to, allowing the event to fall through to other `fetch` event listeners.
22
20
  *
23
- * @param options See `serwist.PrecacheRouteOptions`.
21
+ * @param options See {@linkcode PrecacheRouteOptions}.
24
22
  * @deprecated
25
23
  */
26
24
  export const addRoute = (options?: PrecacheRouteOptions): void => {
@@ -7,18 +7,18 @@
7
7
  */
8
8
 
9
9
  import type { RouteHandlerCallback } from "../types.js";
10
+ import type { PrecacheController } from "./PrecacheController.js";
10
11
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
11
12
 
12
13
  /**
13
- * Helper function that calls `PrecacheController#createHandlerBoundToURL`
14
- * on the default `PrecacheController` instance.
14
+ * Helper function that calls {@linkcode PrecacheController.createHandlerBoundToURL}
15
+ * on the default {@linkcode PrecacheController} instance.
15
16
  *
16
- * If you are creating your own `PrecacheController`, then call the
17
- * `PrecacheController#createHandlerBoundToURL` on that instance,
17
+ * If you are creating your own {@linkcode PrecacheController}, then call the
18
+ * {@linkcode PrecacheController.createHandlerBoundToURL} function on that instance
18
19
  * instead of using this function.
19
20
  *
20
- * @param url The precached URL which will be used to lookup the
21
- * `Response`.
21
+ * @param url The precached URL which will be used to look up the response.
22
22
  * @param fallbackToNetwork Whether to attempt to get the
23
23
  * response from the network if there's a precache miss.
24
24
  * @return
@@ -29,12 +29,12 @@ export interface FallbacksOptions {
29
29
 
30
30
  export interface FallbacksOptions {
31
31
  /**
32
- * An optional `PrecacheController` instance. If not provided, the singleton
33
- * `PrecacheController` will be used.
32
+ * An optional {@linkcode PrecacheController} instance. If not provided, the singleton
33
+ * {@linkcode PrecacheController} will be used.
34
34
  */
35
35
  precacheController?: PrecacheController;
36
36
  /**
37
- * An optional `Router` instance. If not provided, the singleton `Router`
37
+ * An optional {@linkcode Router} instance. If not provided, the singleton {@linkcode Router}
38
38
  * will be used.
39
39
  */
40
40
  router?: Router;
@@ -13,12 +13,12 @@ import { getSingletonRouter } from "./singletonRouter.js";
13
13
  */
14
14
  export interface HandlePrecachingOptions {
15
15
  /**
16
- * An optional `PrecacheController` instance. If not provided, the singleton
17
- * `PrecacheController` will be used.
16
+ * An optional {@linkcode PrecacheController} instance. If not provided, the singleton
17
+ * {@linkcode PrecacheController} will be used.
18
18
  */
19
19
  precacheController?: PrecacheController;
20
20
  /**
21
- * An optional `Router` instance. If not provided, the singleton `Router`
21
+ * An optional {@linkcode Router} instance. If not provided, the singleton {@linkcode Router}
22
22
  * will be used.
23
23
  */
24
24
  router?: Router;
@@ -33,7 +33,7 @@ import { getSingletonRouter } from "./singletonRouter.js";
33
33
  */
34
34
  export interface GoogleAnalyticsInitializeOptions {
35
35
  /**
36
- * An optional `Router` instance. If not provided, the singleton `Router`
36
+ * An optional {@linkcode Router} instance. If not provided, the singleton {@linkcode Router}
37
37
  * will be used.
38
38
  */
39
39
  router?: Router;
@@ -17,18 +17,18 @@ import { getSingletonRouter } from "./singletonRouter.js";
17
17
  declare const self: ServiceWorkerGlobalScope;
18
18
 
19
19
  /**
20
- * Options for `installSerwist`.
20
+ * Options for {@linkcode installSerwist}.
21
21
  *
22
22
  * @deprecated
23
23
  */
24
24
  export interface InstallSerwistOptions extends Omit<HandlePrecachingOptions, "precacheController" | "router"> {
25
25
  /**
26
- * An optional `PrecacheController` instance. If not provided, the singleton
27
- * `PrecacheController` will be used.
26
+ * An optional {@linkcode PrecacheController} instance. If not provided, the singleton
27
+ * {@linkcode PrecacheController} will be used.
28
28
  */
29
29
  precacheController?: PrecacheController;
30
30
  /**
31
- * An optional `Router` instance. If not provided, the singleton `Router`
31
+ * An optional {@linkcode Router} instance. If not provided, the singleton {@linkcode Router}
32
32
  * will be used.
33
33
  */
34
34
  router?: Router;
@@ -7,13 +7,14 @@
7
7
  */
8
8
 
9
9
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
10
+ import type { PrecacheController } from "./PrecacheController.js";
10
11
 
11
12
  /**
12
- * Helper function that calls `PrecacheController#matchPrecache`
13
- * on the default `PrecacheController` instance.
13
+ * Helper function that calls {@linkcode PrecacheController.matchPrecache}
14
+ * on the default {@linkcode PrecacheController} instance.
14
15
  *
15
- * If you are creating your own `PrecacheController`, then call
16
- * `PrecacheController#matchPrecache` on that instance,
16
+ * If you are creating your own {@linkcode PrecacheController}, then call
17
+ * the {@linkcode PrecacheController.matchPrecache} function on that instance
17
18
  * instead of using this function.
18
19
  *
19
20
  * @param request The key (without revisioning parameters)
@@ -8,6 +8,8 @@
8
8
 
9
9
  import type { PrecacheEntry } from "../types.js";
10
10
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
11
+ import type { addRoute } from "./addRoute.js";
12
+ import type { precacheAndRoute } from "./precacheAndRoute.js";
11
13
 
12
14
  /**
13
15
  * Adds items to the precache list, removing any duplicates and
@@ -18,10 +20,10 @@ import { getSingletonPrecacheController } from "./singletonPrecacheController.js
18
20
  *
19
21
  * Please note: This method **will not** serve any of the cached files for you.
20
22
  * It only precaches files. To respond to a network request you call
21
- * `serwist/legacy.addRoute`.
23
+ * {@linkcode addRoute}.
22
24
  *
23
25
  * If you have a single array of files to precache, you can just call
24
- * `serwist/legacy.precacheAndRoute`.
26
+ * {@linkcode precacheAndRoute}.
25
27
  *
26
28
  * @param entries Array of entries to precache.
27
29
  * @deprecated
@@ -12,14 +12,13 @@ import { precache } from "./precache.js";
12
12
 
13
13
  /**
14
14
  * This method will add entries to the precache list and add a route to
15
- * respond to fetch events.
15
+ * respond to `fetch` events.
16
16
  *
17
17
  * This is a convenience method that will call
18
- * `serwist/legacy.precache` and
19
- * `serwist/legacy.addRoute` in a single call.
18
+ * {@linkcode precache} and {@linkcode addRoute} in a single call.
20
19
  *
21
20
  * @param entries Array of entries to precache.
22
- * @param options See the `serwist.PrecacheRouteOptions` options.
21
+ * @param options See the {@linkcode PrecacheRouteOptions} options.
23
22
  * @deprecated
24
23
  */
25
24
  export const precacheAndRoute = (entries: (PrecacheEntry | string)[], options?: PrecacheRouteOptions): void => {
@@ -5,21 +5,22 @@
5
5
  license that can be found in the LICENSE file or at
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
-
8
+ import type { Router } from "./Router.js";
9
9
  import type { Route } from "../Route.js";
10
10
  import type { HTTPMethod } from "../constants.js";
11
11
  import type { RouteHandler, RouteMatchCallback } from "../types.js";
12
+ import type { unregisterRoute } from "./unregisterRoute.js";
12
13
  import { getSingletonRouter } from "./singletonRouter.js";
13
14
 
14
15
  /**
15
16
  * Registers a `RegExp`, string, or function with a caching
16
- * strategy to a singleton `Router` instance.
17
+ * strategy to a singleton {@linkcode Router} instance.
17
18
  *
18
- * @param capture If the capture param is a `Route`, all other arguments will be ignored.
19
- * @param handler A callback function that returns a `Promise` resulting in a `Response`.
20
- * This parameter is required if `capture` is not a `Route` object.
21
- * @param method The HTTP method to match the `Route` against. Defaults to `'GET'`.
22
- * @returns The generated `Route`, which can then be provided to `unregisterRoute` if needed.
19
+ * @param capture If the capture param is a {@linkcode Route}, all other arguments will be ignored.
20
+ * @param handler A callback function that returns a promise resulting in a response.
21
+ * This parameter is required if `capture` is not a {@linkcode Route} object.
22
+ * @param method The HTTP method to match the route against. Defaults to `'GET'`.
23
+ * @returns The generated {@linkcode Route} object, which can then be provided to {@linkcode unregisterRoute} if needed.
23
24
  * @deprecated
24
25
  */
25
26
  export const registerRoute = (capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route => {
@@ -4,7 +4,7 @@ import type { RuntimeCaching } from "../types.js";
4
4
 
5
5
  /**
6
6
  * Registers caching strategies to a singleton Router instance. It is a simple
7
- * syntatic sugar for `serwist/legacy.registerRoute`.
7
+ * syntatic sugar for {@linkcode registerRoute}.
8
8
  *
9
9
  * @param runtimeCachingList
10
10
  * @returns
@@ -10,10 +10,10 @@ import type { RouteHandler } from "../types.js";
10
10
  import { getSingletonRouter } from "./singletonRouter.js";
11
11
 
12
12
  /**
13
- * If a `Route` throws an error while handling a request, this `handler`
13
+ * If a route throws an error while handling a request, this handler
14
14
  * will be called and given a chance to provide a response.
15
15
  *
16
- * @param handler A callback function that returns a Promise resulting in a Response.
16
+ * @param handler A callback function that returns a promise resulting in a response.
17
17
  * @deprecated
18
18
  */
19
19
  export const setCatchHandler = (handler: RouteHandler): void => {
@@ -10,13 +10,13 @@ import type { RouteHandler } from "../types.js";
10
10
  import { getSingletonRouter } from "./singletonRouter.js";
11
11
 
12
12
  /**
13
- * Defines a default `handler` that's called when no routes explicitly
13
+ * Defines a default handler that's called when no routes explicitly
14
14
  * match the incoming request.
15
15
  *
16
- * Without a default `handler`, unmatched requests will go against the
16
+ * Without a default handler, unmatched requests will go against the
17
17
  * network as if there were no service worker present.
18
18
  *
19
- * @param handler A callback function that returns a Promise resulting in a Response.
19
+ * @param handler A callback function that returns a promise resulting in a response.
20
20
  * @deprecated
21
21
  */
22
22
  export const setDefaultHandler = (handler: RouteHandler): void => {
@@ -11,12 +11,12 @@ import { PrecacheController } from "./PrecacheController.js";
11
11
  let defaultPrecacheController: PrecacheController | undefined = undefined;
12
12
 
13
13
  /**
14
- * Creates a new, singleton `PrecacheController` if one does not exist. If one does
14
+ * Creates a new, singleton {@linkcode PrecacheController} if one does not exist. If one does
15
15
  * already exist, that instance is returned. This instance is used by Serwist's
16
- * `PrecacheController`-dependent functions and classes unless you provide a different
17
- * `Router` to them.
16
+ * {@linkcode PrecacheController}-dependent functions and classes unless you provide a different
17
+ * {@linkcode PrecacheController} to them.
18
18
  *
19
- * @returns The singleton `PrecacheController`.
19
+ * @returns The singleton {@linkcode PrecacheController}.
20
20
  * @deprecated
21
21
  */
22
22
  export const getSingletonPrecacheController = (): PrecacheController => {
@@ -27,8 +27,8 @@ export const getSingletonPrecacheController = (): PrecacheController => {
27
27
  };
28
28
 
29
29
  /**
30
- * Changes the singleton `PrecacheController` to a different instance. This is meant for when you do not
31
- * want to pass your own `PrecacheController` to every one of Serwist's `PrecacheController`-dependent
30
+ * Changes the singleton {@linkcode PrecacheController} to a different instance. This is meant for when you do not
31
+ * want to pass your own {@linkcode PrecacheController} to every one of Serwist's {@linkcode PrecacheController}-dependent
32
32
  * functions and classes.
33
33
  *
34
34
  * It is highly recommended that you call this before anything else, if you plan on doing so.
@@ -44,7 +44,7 @@ export const getSingletonPrecacheController = (): PrecacheController => {
44
44
  * // Do something with your controller...
45
45
  * ```
46
46
  * @param router
47
- * @returns The new singleton `PrecacheController`.
47
+ * @returns The new singleton {@linkcode PrecacheController}.
48
48
  * @deprecated
49
49
  */
50
50
  export const setSingletonPrecacheController = (precacheController: PrecacheController): PrecacheController => {
@@ -11,12 +11,12 @@ import { Router } from "./Router.js";
11
11
  let defaultRouter: Router | undefined = undefined;
12
12
 
13
13
  /**
14
- * Creates a new, singleton `Router` if one does not exist. If one does
14
+ * Creates a new, singleton {@linkcode Router} if one does not exist. If one does
15
15
  * already exist, that instance is returned. This instance is used by
16
- * Serwist's `Router`-dependent functions and classes unless you provide
17
- * a different `Router` to them.
16
+ * Serwist's {@linkcode Router}-dependent functions and classes unless you provide
17
+ * a different {@linkcode Router} to them.
18
18
  *
19
- * @returns The singleton `Router`.
19
+ * @returns The singleton {@linkcode Router}.
20
20
  * @deprecated
21
21
  */
22
22
  export const getSingletonRouter = (): Router => {
@@ -31,10 +31,10 @@ export const getSingletonRouter = (): Router => {
31
31
  };
32
32
 
33
33
  /**
34
- * Changes the singleton `Router` to a different instance. This is meant for when you do not
35
- * want to pass your own `Router` to every one of Serwist's `Router`-dependent functions and classes.
36
- * If this or `getSingletonRouter` has been called before, it removes the listeners of the
37
- * previous singleton `Router`. It also adds those of the new one, so you need not do that yourself.
34
+ * Changes the singleton {@linkcode Router} to a different instance. This is meant for when you do not
35
+ * want to pass your own {@linkcode Router} to every one of Serwist's {@linkcode Router}-dependent functions and classes.
36
+ * If this or {@linkcode getSingletonRouter} has been called before, it removes the listeners of the
37
+ * previous singleton {@linkcode Router}. It also adds those of the new one, so you need not do that yourself.
38
38
  *
39
39
  * It is highly recommended that you call this before anything else, if you plan on doing so.
40
40
  *
@@ -55,7 +55,7 @@ export const getSingletonRouter = (): Router => {
55
55
  * );
56
56
  * ```
57
57
  * @param router
58
- * @returns The new singleton `Router`.
58
+ * @returns The new singleton {@linkcode Router}.
59
59
  * @deprecated
60
60
  */
61
61
  export const setSingletonRouter = (router: Router): Router => {
@@ -1,8 +1,9 @@
1
1
  import type { Route } from "../Route.js";
2
+ import type { Router } from "./Router.js";
2
3
  import { getSingletonRouter } from "./singletonRouter.js";
3
4
 
4
5
  /**
5
- * Unregisters a route from the singleton `Router` instance.
6
+ * Unregisters a route from the singleton {@linkcode Router} instance.
6
7
  *
7
8
  * @param route The route to unregister.
8
9
  * @deprecated
@@ -12,15 +12,15 @@ import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
12
12
 
13
13
  /**
14
14
  * A class implementing the `fetchDidFail` lifecycle callback. This makes it
15
- * easier to add failed requests to a background sync Queue.
15
+ * easier to add failed requests to a {@linkcode BackgroundSyncQueue}.
16
16
  */
17
17
  export class BackgroundSyncPlugin implements SerwistPlugin {
18
18
  private readonly _queue: BackgroundSyncQueue;
19
19
 
20
20
  /**
21
- * @param name See the `serwist/plugins.BackgroundSyncQueue`
21
+ * @param name See the {@linkcode BackgroundSyncQueue}
22
22
  * documentation for parameter details.
23
- * @param options See the `serwist/plugins.BackgroundSyncQueue`
23
+ * @param options See the {@linkcode BackgroundSyncQueue}
24
24
  * documentation for parameter details.
25
25
  * @see https://serwist.pages.dev/docs/core/background-sync-queue
26
26
  */
@@ -312,7 +312,7 @@ export class BackgroundSyncQueue {
312
312
 
313
313
  /**
314
314
  * Removes and returns the first or last (depending on `operation`) entry
315
- * from the QueueStore that's not older than the `maxRetentionTime`.
315
+ * from the {@linkcode BackgroundSyncQueueStore} that's not older than the `maxRetentionTime`.
316
316
  *
317
317
  * @param operation
318
318
  * @returns
@@ -77,7 +77,7 @@ export class StorableRequest {
77
77
 
78
78
  /**
79
79
  * Accepts an object of request data that can be used to construct a
80
- * `Request` but can also be stored in IndexedDB.
80
+ * `Request` object but can also be stored in IndexedDB.
81
81
  *
82
82
  * @param requestData An object of request data that includes the `url` plus any relevant property of
83
83
  * [`requestInit`](https://fetch.spec.whatwg.org/#requestinit).
@@ -54,8 +54,7 @@ export class BroadcastCacheUpdate {
54
54
  private readonly _notifyAllClients: boolean;
55
55
 
56
56
  /**
57
- * Construct a BroadcastCacheUpdate instance with a specific `channelName` to
58
- * broadcast messages on
57
+ * Construct an instance of `BroadcastCacheUpdate`.
59
58
  *
60
59
  * @param options
61
60
  */
@@ -18,9 +18,10 @@ export class BroadcastUpdatePlugin implements SerwistPlugin {
18
18
  private readonly _broadcastUpdate: BroadcastCacheUpdate;
19
19
 
20
20
  /**
21
- * Construct a `serwist.BroadcastCacheUpdate` instance with
22
- * the passed options and calls its `notifyIfUpdated` method whenever the
23
- * plugin's `cacheDidUpdate` callback is invoked.
21
+ * Construct a {@linkcode BroadcastCacheUpdate} instance with
22
+ * the passed options and calls its {@linkcode BroadcastCacheUpdate.notifyIfUpdated}
23
+ * method whenever the plugin's {@linkcode BroadcastUpdatePlugin.cacheDidUpdate} callback
24
+ * is invoked.
24
25
  *
25
26
  * @param options
26
27
  */
@@ -29,10 +30,6 @@ export class BroadcastUpdatePlugin implements SerwistPlugin {
29
30
  }
30
31
 
31
32
  /**
32
- * A "lifecycle" callback that will be triggered automatically by
33
- * `@serwist/build.RuntimeCaching` handlers when an entry is
34
- * added to a cache.
35
- *
36
33
  * @private
37
34
  * @param options The input object to this function.
38
35
  */
@@ -6,7 +6,8 @@ export interface BroadcastCacheUpdateOptions {
6
6
  * A list of headers that will be used to determine whether the responses
7
7
  * differ.
8
8
  *
9
- * @default ['content-length', 'etag', 'last-modified']
9
+ * @default
10
+ * ['content-length', 'etag', 'last-modified']`
10
11
  */
11
12
  headersToCheck?: string[];
12
13
  /**
@@ -13,11 +13,11 @@ import { logger } from "../../utils/logger.js";
13
13
 
14
14
  export interface CacheableResponseOptions {
15
15
  /**
16
- * One or more status codes that a `Response` can have to be considered cacheable.
16
+ * One or more HTTP status codes that a response can have to be considered cacheable.
17
17
  */
18
18
  statuses?: number[];
19
19
  /**
20
- * A mapping of header names and expected values that a `Response` can have and be
20
+ * A mapping of header names and expected values that a response can have and be
21
21
  * considered cacheable. If multiple headers are provided, only one needs to be present.
22
22
  */
23
23
  headers?: HeadersInit;
@@ -25,7 +25,7 @@ export interface CacheableResponseOptions {
25
25
 
26
26
  /**
27
27
  * Allows you to set up rules determining what status codes and/or headers need
28
- * to be present in order for a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
28
+ * to be present in order for a [response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
29
29
  * to be considered cacheable.
30
30
  */
31
31
  export class CacheableResponse {
@@ -33,11 +33,11 @@ export class CacheableResponse {
33
33
  private readonly _headers?: Headers;
34
34
 
35
35
  /**
36
- * To construct a new CacheableResponse instance you must provide at least
36
+ * To construct a new `CacheableResponse` instance you must provide at least
37
37
  * one of the `config` properties.
38
38
  *
39
39
  * If both `statuses` and `headers` are specified, then both conditions must
40
- * be met for the `Response` to be considered cacheable.
40
+ * be met for the response to be considered cacheable.
41
41
  *
42
42
  * @param config
43
43
  */
@@ -81,7 +81,7 @@ export class CacheableResponse {
81
81
  *
82
82
  * @param response The response whose cacheability is being
83
83
  * checked.
84
- * @returns `true` if the `Response` is cacheable, and `false`
84
+ * @returns `true` if the response is cacheable, and `false`
85
85
  * otherwise.
86
86
  */
87
87
  isResponseCacheable(response: Response): boolean {
@@ -19,11 +19,11 @@ export class CacheableResponsePlugin implements SerwistPlugin {
19
19
  private readonly _cacheableResponse: CacheableResponse;
20
20
 
21
21
  /**
22
- * To construct a new CacheableResponsePlugin instance you must provide at
22
+ * To construct a new `CacheableResponsePlugin` instance you must provide at
23
23
  * least one of the `config` properties.
24
24
  *
25
25
  * If both `statuses` and `headers` are specified, then both conditions must
26
- * be met for the `Response` to be considered cacheable.
26
+ * be met for the response to be considered cacheable.
27
27
  *
28
28
  * @param config
29
29
  */
@@ -13,7 +13,7 @@ import { CacheTimestampsModel } from "./models/CacheTimestampsModel.js";
13
13
 
14
14
  interface CacheExpirationConfig {
15
15
  /**
16
- * The maximum number of entries to cache. Entries used the least will
16
+ * The maximum number of entries to cache. Entries used least recently will
17
17
  * be removed as the maximum is reached.
18
18
  */
19
19
  maxEntries?: number;
@@ -42,7 +42,7 @@ export class CacheExpiration {
42
42
  private readonly _timestampModel: CacheTimestampsModel;
43
43
 
44
44
  /**
45
- * To construct a new CacheExpiration instance you must provide at least
45
+ * To construct a new `CacheExpiration` instance you must provide at least
46
46
  * one of the `config` properties.
47
47
  *
48
48
  * @param cacheName Name of the cache to apply restrictions to.