serwist 9.0.0-preview.24 → 9.0.0-preview.25

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 (217) hide show
  1. package/dist/NavigationRoute.d.ts +1 -1
  2. package/dist/NavigationRoute.d.ts.map +1 -1
  3. package/dist/PrecacheRoute.d.ts.map +1 -1
  4. package/dist/RegExpRoute.d.ts +1 -1
  5. package/dist/RegExpRoute.d.ts.map +1 -1
  6. package/dist/Route.d.ts +1 -1
  7. package/dist/Route.d.ts.map +1 -1
  8. package/dist/Serwist.d.ts +38 -43
  9. package/dist/Serwist.d.ts.map +1 -1
  10. package/dist/chunks/printInstallDetails.js +1613 -0
  11. package/dist/chunks/resultingClientExists.js +1 -1
  12. package/dist/chunks/waitUntil.js +400 -1
  13. package/dist/copyResponse.d.ts +1 -1
  14. package/dist/copyResponse.d.ts.map +1 -1
  15. package/dist/disableDevLogs.d.ts +1 -1
  16. package/dist/index.d.ts +42 -10
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.internal.js +1 -2
  19. package/dist/index.js +1464 -8
  20. package/dist/index.legacy.d.ts +5 -3
  21. package/dist/index.legacy.d.ts.map +1 -1
  22. package/dist/index.legacy.js +168 -17
  23. package/dist/legacy/PrecacheController.d.ts +1 -1
  24. package/dist/legacy/PrecacheController.d.ts.map +1 -1
  25. package/dist/legacy/PrecacheRoute.d.ts.map +1 -1
  26. package/dist/legacy/Router.d.ts +1 -1
  27. package/dist/legacy/Router.d.ts.map +1 -1
  28. package/dist/legacy/constants.d.ts.map +1 -0
  29. package/dist/legacy/fallbacks.d.ts +1 -1
  30. package/dist/legacy/fallbacks.d.ts.map +1 -1
  31. package/dist/legacy/initializeGoogleAnalytics.d.ts +38 -0
  32. package/dist/legacy/initializeGoogleAnalytics.d.ts.map +1 -0
  33. package/dist/legacy/installSerwist.d.ts +69 -3
  34. package/dist/legacy/installSerwist.d.ts.map +1 -1
  35. package/dist/legacy/registerRoute.d.ts +1 -1
  36. package/dist/legacy/registerRoute.d.ts.map +1 -1
  37. package/dist/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.d.ts +3 -3
  38. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -0
  39. package/dist/{plugins/backgroundSync/Queue.d.ts → lib/backgroundSync/BackgroundSyncQueue.d.ts} +29 -13
  40. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +1 -0
  41. package/dist/{plugins/backgroundSync/QueueDb.d.ts → lib/backgroundSync/BackgroundSyncQueueDb.d.ts} +7 -7
  42. package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +1 -0
  43. package/dist/{plugins/backgroundSync/QueueStore.d.ts → lib/backgroundSync/BackgroundSyncQueueStore.d.ts} +7 -7
  44. package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +1 -0
  45. package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -0
  46. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -0
  47. package/dist/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.d.ts +1 -1
  48. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -0
  49. package/dist/lib/broadcastUpdate/constants.d.ts +5 -0
  50. package/dist/lib/broadcastUpdate/constants.d.ts.map +1 -0
  51. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -0
  52. package/dist/{plugins → lib}/broadcastUpdate/types.d.ts +3 -3
  53. package/dist/lib/broadcastUpdate/types.d.ts.map +1 -0
  54. package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +1 -0
  55. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -0
  56. package/dist/{plugins → lib}/expiration/CacheExpiration.d.ts +1 -1
  57. package/dist/lib/expiration/CacheExpiration.d.ts.map +1 -0
  58. package/dist/{plugins → lib}/expiration/ExpirationPlugin.d.ts +1 -1
  59. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -0
  60. package/dist/lib/expiration/models/CacheTimestampsModel.d.ts.map +1 -0
  61. package/dist/lib/googleAnalytics/constants.d.ts +10 -0
  62. package/dist/lib/googleAnalytics/constants.d.ts.map +1 -0
  63. package/dist/{plugins/googleAnalytics/initialize.d.ts → lib/googleAnalytics/initializeGoogleAnalytics.d.ts} +2 -2
  64. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -0
  65. package/dist/{plugins → lib}/precaching/PrecacheFallbackPlugin.d.ts +1 -1
  66. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -0
  67. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -0
  68. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -0
  69. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
  70. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -0
  71. package/dist/lib/strategies/CacheFirst.d.ts.map +1 -0
  72. package/dist/lib/strategies/CacheOnly.d.ts.map +1 -0
  73. package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -0
  74. package/dist/lib/strategies/NetworkOnly.d.ts.map +1 -0
  75. package/dist/{PrecacheStrategy.d.ts → lib/strategies/PrecacheOnly.d.ts} +7 -7
  76. package/dist/lib/strategies/PrecacheOnly.d.ts.map +1 -0
  77. package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +1 -0
  78. package/dist/{strategies → lib/strategies}/Strategy.d.ts +1 -1
  79. package/dist/lib/strategies/Strategy.d.ts.map +1 -0
  80. package/dist/{strategies → lib/strategies}/StrategyHandler.d.ts +1 -1
  81. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -0
  82. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +3 -0
  83. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -0
  84. package/dist/lib/strategies/utils/messages.d.ts.map +1 -0
  85. package/dist/navigationPreload.d.ts +3 -3
  86. package/dist/parseRoute.d.ts +1 -1
  87. package/dist/parseRoute.d.ts.map +1 -1
  88. package/dist/types.d.ts +12 -7
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +1 -1
  91. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -1
  92. package/dist/utils/assert.d.ts.map +1 -1
  93. package/package.json +7 -21
  94. package/src/NavigationRoute.ts +1 -1
  95. package/src/PrecacheRoute.ts +3 -3
  96. package/src/RegExpRoute.ts +2 -2
  97. package/src/Route.ts +2 -2
  98. package/src/Serwist.ts +69 -80
  99. package/src/cleanupOutdatedCaches.ts +1 -1
  100. package/src/disableDevLogs.ts +1 -1
  101. package/src/index.legacy.ts +16 -5
  102. package/src/index.ts +107 -14
  103. package/src/legacy/PrecacheController.ts +9 -9
  104. package/src/legacy/PrecacheFallbackPlugin.ts +1 -1
  105. package/src/legacy/PrecacheRoute.ts +3 -3
  106. package/src/legacy/Router.ts +5 -5
  107. package/src/legacy/fallbacks.ts +3 -3
  108. package/src/legacy/initializeGoogleAnalytics.ts +218 -0
  109. package/src/legacy/installSerwist.ts +156 -5
  110. package/src/legacy/registerRoute.ts +1 -1
  111. package/src/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.ts +6 -6
  112. package/src/{plugins/backgroundSync/Queue.ts → lib/backgroundSync/BackgroundSyncQueue.ts} +47 -26
  113. package/src/{plugins/backgroundSync/QueueDb.ts → lib/backgroundSync/BackgroundSyncQueueDb.ts} +16 -16
  114. package/src/{plugins/backgroundSync/QueueStore.ts → lib/backgroundSync/BackgroundSyncQueueStore.ts} +13 -13
  115. package/src/{plugins → lib}/backgroundSync/StorableRequest.ts +2 -2
  116. package/src/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.ts +14 -9
  117. package/src/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.ts +1 -1
  118. package/src/lib/broadcastUpdate/constants.ts +12 -0
  119. package/src/{plugins → lib}/broadcastUpdate/types.ts +3 -3
  120. package/src/{plugins → lib}/cacheableResponse/CacheableResponse.ts +5 -5
  121. package/src/{plugins → lib}/expiration/CacheExpiration.ts +7 -7
  122. package/src/{plugins → lib}/expiration/ExpirationPlugin.ts +10 -10
  123. package/src/lib/googleAnalytics/constants.ts +22 -0
  124. package/src/{plugins/googleAnalytics/initialize.ts → lib/googleAnalytics/initializeGoogleAnalytics.ts} +9 -9
  125. package/src/{strategies → lib/strategies}/CacheFirst.ts +4 -4
  126. package/src/{strategies → lib/strategies}/CacheOnly.ts +4 -4
  127. package/src/{strategies → lib/strategies}/NetworkFirst.ts +5 -5
  128. package/src/{strategies → lib/strategies}/NetworkOnly.ts +5 -5
  129. package/src/{PrecacheStrategy.ts → lib/strategies/PrecacheOnly.ts} +19 -15
  130. package/src/{strategies → lib/strategies}/StaleWhileRevalidate.ts +4 -4
  131. package/src/{strategies → lib/strategies}/Strategy.ts +5 -5
  132. package/src/{strategies → lib/strategies}/StrategyHandler.ts +11 -11
  133. package/src/{strategies → lib/strategies}/plugins/cacheOkAndOpaquePlugin.ts +1 -1
  134. package/src/{strategies → lib/strategies}/utils/messages.ts +2 -2
  135. package/src/models/messages/messages.ts +1 -1
  136. package/src/navigationPreload.ts +3 -3
  137. package/src/parseRoute.ts +3 -3
  138. package/src/registerQuotaErrorCallback.ts +1 -1
  139. package/src/types.ts +12 -7
  140. package/src/utils/PrecacheCacheKeyPlugin.ts +1 -1
  141. package/src/utils/assert.ts +1 -1
  142. package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
  143. package/src/utils/welcome.ts +1 -1
  144. package/dist/PrecacheStrategy.d.ts.map +0 -1
  145. package/dist/chunks/NetworkOnly.js +0 -599
  146. package/dist/chunks/PrecacheFallbackPlugin.js +0 -634
  147. package/dist/chunks/Serwist.js +0 -1034
  148. package/dist/chunks/registerQuotaErrorCallback.js +0 -17
  149. package/dist/chunks/timeout.js +0 -400
  150. package/dist/index.plugins.d.ts +0 -41
  151. package/dist/index.plugins.d.ts.map +0 -1
  152. package/dist/index.plugins.js +0 -669
  153. package/dist/index.strategies.d.ts +0 -22
  154. package/dist/index.strategies.d.ts.map +0 -1
  155. package/dist/index.strategies.js +0 -144
  156. package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
  157. package/dist/plugins/backgroundSync/Queue.d.ts.map +0 -1
  158. package/dist/plugins/backgroundSync/QueueDb.d.ts.map +0 -1
  159. package/dist/plugins/backgroundSync/QueueStore.d.ts.map +0 -1
  160. package/dist/plugins/backgroundSync/StorableRequest.d.ts.map +0 -1
  161. package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
  162. package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
  163. package/dist/plugins/broadcastUpdate/constants.d.ts +0 -5
  164. package/dist/plugins/broadcastUpdate/constants.d.ts.map +0 -1
  165. package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
  166. package/dist/plugins/broadcastUpdate/types.d.ts.map +0 -1
  167. package/dist/plugins/cacheableResponse/CacheableResponse.d.ts.map +0 -1
  168. package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
  169. package/dist/plugins/expiration/CacheExpiration.d.ts.map +0 -1
  170. package/dist/plugins/expiration/ExpirationPlugin.d.ts.map +0 -1
  171. package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts.map +0 -1
  172. package/dist/plugins/googleAnalytics/constants.d.ts.map +0 -1
  173. package/dist/plugins/googleAnalytics/initialize.d.ts.map +0 -1
  174. package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
  175. package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
  176. package/dist/plugins/rangeRequests/createPartialResponse.d.ts.map +0 -1
  177. package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
  178. package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
  179. package/dist/strategies/CacheFirst.d.ts.map +0 -1
  180. package/dist/strategies/CacheOnly.d.ts.map +0 -1
  181. package/dist/strategies/NetworkFirst.d.ts.map +0 -1
  182. package/dist/strategies/NetworkOnly.d.ts.map +0 -1
  183. package/dist/strategies/StaleWhileRevalidate.d.ts.map +0 -1
  184. package/dist/strategies/Strategy.d.ts.map +0 -1
  185. package/dist/strategies/StrategyHandler.d.ts.map +0 -1
  186. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +0 -3
  187. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +0 -1
  188. package/dist/strategies/utils/messages.d.ts.map +0 -1
  189. package/src/index.plugins.ts +0 -95
  190. package/src/index.strategies.ts +0 -26
  191. package/src/plugins/broadcastUpdate/constants.ts +0 -12
  192. package/dist/{plugins/googleAnalytics → legacy}/constants.d.ts +0 -0
  193. package/dist/{plugins → lib}/backgroundSync/StorableRequest.d.ts +0 -0
  194. package/dist/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.d.ts +0 -0
  195. package/dist/{plugins → lib}/broadcastUpdate/responsesAreSame.d.ts +0 -0
  196. package/dist/{plugins → lib}/cacheableResponse/CacheableResponse.d.ts +0 -0
  197. package/dist/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.d.ts +0 -0
  198. package/dist/{plugins → lib}/expiration/models/CacheTimestampsModel.d.ts +0 -0
  199. package/dist/{plugins → lib}/rangeRequests/RangeRequestsPlugin.d.ts +0 -0
  200. package/dist/{plugins → lib}/rangeRequests/createPartialResponse.d.ts +0 -0
  201. package/dist/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +0 -0
  202. package/dist/{plugins → lib}/rangeRequests/utils/parseRangeHeader.d.ts +0 -0
  203. package/dist/{strategies → lib/strategies}/CacheFirst.d.ts +0 -0
  204. package/dist/{strategies → lib/strategies}/CacheOnly.d.ts +0 -0
  205. package/dist/{strategies → lib/strategies}/NetworkFirst.d.ts +0 -0
  206. package/dist/{strategies → lib/strategies}/NetworkOnly.d.ts +0 -0
  207. package/dist/{strategies → lib/strategies}/StaleWhileRevalidate.d.ts +0 -0
  208. package/dist/{strategies → lib/strategies}/utils/messages.d.ts +0 -0
  209. package/src/{plugins/googleAnalytics → legacy}/constants.ts +0 -0
  210. package/src/{plugins → lib}/broadcastUpdate/responsesAreSame.ts +0 -0
  211. package/src/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.ts +0 -0
  212. package/src/{plugins → lib}/expiration/models/CacheTimestampsModel.ts +0 -0
  213. package/src/{plugins → lib}/precaching/PrecacheFallbackPlugin.ts +1 -1
  214. package/src/{plugins → lib}/rangeRequests/RangeRequestsPlugin.ts +0 -0
  215. package/src/{plugins → lib}/rangeRequests/createPartialResponse.ts +1 -1
  216. package/src/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.ts +1 -1
  217. package/src/{plugins → lib}/rangeRequests/utils/parseRangeHeader.ts +1 -1
@@ -6,13 +6,13 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteMatchCallback, RouteMatchCallbackOptions } from "./types.js";
10
- import { getFriendlyURL } from "./utils/getFriendlyURL.js";
11
- import { logger } from "./utils/logger.js";
12
9
  import { Route } from "./Route.js";
13
10
  import type { Serwist } from "./Serwist.js";
11
+ import type { RouteMatchCallback, RouteMatchCallbackOptions } from "./types.js";
14
12
  import type { PrecacheRouteOptions } from "./types.js";
15
13
  import { generateURLVariations } from "./utils/generateURLVariations.js";
14
+ import { getFriendlyURL } from "./utils/getFriendlyURL.js";
15
+ import { logger } from "./utils/logger.js";
16
16
 
17
17
  /**
18
18
  * A subclass of `Route` that takes a `serwist.Serwist` instance and uses it to match
@@ -6,11 +6,11 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
+ import { Route } from "./Route.js";
10
+ import type { HTTPMethod } from "./constants.js";
9
11
  import type { RouteHandler, RouteMatchCallback, RouteMatchCallbackOptions } from "./types.js";
10
12
  import { assert } from "./utils/assert.js";
11
13
  import { logger } from "./utils/logger.js";
12
- import { Route } from "./Route.js";
13
- import type { HTTPMethod } from "./constants.js";
14
14
 
15
15
  /**
16
16
  * `RegExpRoute` makes it easy to create a regular expression based on a `Route`.
package/src/Route.ts CHANGED
@@ -6,10 +6,10 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteHandler, RouteHandlerObject, RouteMatchCallback } from "./types.js";
10
- import { assert } from "./utils/assert.js";
11
9
  import type { HTTPMethod } from "./constants.js";
12
10
  import { defaultMethod, validMethods } from "./constants.js";
11
+ import type { RouteHandler, RouteHandlerObject, RouteMatchCallback } from "./types.js";
12
+ import { assert } from "./utils/assert.js";
13
13
  import { normalizeHandler } from "./utils/normalizeHandler.js";
14
14
 
15
15
  /**
package/src/Serwist.ts CHANGED
@@ -1,41 +1,41 @@
1
- import type {
2
- RouteHandler,
3
- RouteHandlerCallback,
4
- RouteHandlerCallbackOptions,
5
- RouteHandlerObject,
6
- RouteMatchCallback,
7
- RouteMatchCallbackOptions,
8
- SerwistPlugin,
9
- } from "./types.js";
10
- import { clientsClaim as clientsClaimImpl } from "./clientsClaim.js";
11
- import { setCacheNameDetails } from "./setCacheNameDetails.js";
12
- import { assert } from "./utils/assert.js";
13
- import { SerwistError } from "./utils/SerwistError.js";
14
- import { getFriendlyURL } from "./utils/getFriendlyURL.js";
15
- import { logger } from "./utils/logger.js";
16
- import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
17
- import { waitUntil } from "./utils/waitUntil.js";
18
1
  import { parallel } from "@serwist/utils";
19
2
  import { NavigationRoute } from "./NavigationRoute.js";
20
3
  import { PrecacheRoute } from "./PrecacheRoute.js";
21
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
22
4
  import type { Route } from "./Route.js";
23
5
  import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "./cleanupOutdatedCaches.js";
6
+ import { clientsClaim as clientsClaimImpl } from "./clientsClaim.js";
24
7
  import { type HTTPMethod, defaultMethod } from "./constants.js";
25
8
  import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
9
+ import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
10
+ import { type PrecacheFallbackEntry, PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
11
+ import { PrecacheOnly } from "./lib/strategies/PrecacheOnly.js";
12
+ import { Strategy } from "./lib/strategies/Strategy.js";
26
13
  import { enableNavigationPreload } from "./navigationPreload.js";
27
14
  import { parseRoute } from "./parseRoute.js";
28
- import { type GoogleAnalyticsInitializeOptions, initialize } from "./plugins/googleAnalytics/initialize.js";
29
- import { type PrecacheFallbackEntry, PrecacheFallbackPlugin } from "./plugins/precaching/PrecacheFallbackPlugin.js";
30
- import { Strategy } from "./strategies/Strategy.js";
15
+ import { setCacheNameDetails } from "./setCacheNameDetails.js";
16
+ import type {
17
+ RouteHandler,
18
+ RouteHandlerCallback,
19
+ RouteHandlerCallbackOptions,
20
+ RouteHandlerObject,
21
+ RouteMatchCallback,
22
+ RouteMatchCallbackOptions,
23
+ SerwistPlugin,
24
+ } from "./types.js";
31
25
  import type { PrecacheRouteOptions, RuntimeCaching } from "./types.js";
32
26
  import type { CleanupResult, InstallResult, PrecacheEntry } from "./types.js";
33
27
  import { PrecacheCacheKeyPlugin } from "./utils/PrecacheCacheKeyPlugin.js";
34
28
  import { PrecacheInstallReportPlugin } from "./utils/PrecacheInstallReportPlugin.js";
29
+ import { SerwistError } from "./utils/SerwistError.js";
30
+ import { assert } from "./utils/assert.js";
31
+ import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
35
32
  import { createCacheKey } from "./utils/createCacheKey.js";
33
+ import { getFriendlyURL } from "./utils/getFriendlyURL.js";
34
+ import { logger } from "./utils/logger.js";
36
35
  import { normalizeHandler } from "./utils/normalizeHandler.js";
37
36
  import { printCleanupDetails } from "./utils/printCleanupDetails.js";
38
37
  import { printInstallDetails } from "./utils/printInstallDetails.js";
38
+ import { waitUntil } from "./utils/waitUntil.js";
39
39
 
40
40
  declare const self: ServiceWorkerGlobalScope;
41
41
 
@@ -50,26 +50,26 @@ export interface FallbacksOptions {
50
50
 
51
51
  export interface PrecacheOptions extends PrecacheRouteOptions {
52
52
  /**
53
- * The cache to use for precaching.
53
+ * The cache used for precaching.
54
54
  */
55
55
  cacheName?: string;
56
- }
57
-
58
- export interface SerwistOptions {
59
- /**
60
- * A list of URLs that should be cached.
61
- */
62
- precacheEntries?: (PrecacheEntry | string)[];
63
- /**
64
- * Options to customize how Serwist precaches the URLs in the precache list.
65
- */
66
- precacheOptions?: PrecacheOptions;
67
56
  /**
68
57
  * Whether outdated caches should be removed.
69
58
  *
70
59
  * @default false
71
60
  */
72
61
  cleanupOutdatedCaches?: boolean;
62
+ /**
63
+ * The number of precache requests that should be made concurrently.
64
+ *
65
+ * @default 10
66
+ */
67
+ concurrency?: number;
68
+ /**
69
+ * Whether to attempt to get the response from the network if there's
70
+ * a precache miss.
71
+ */
72
+ fallbackToNetwork?: boolean;
73
73
  /**
74
74
  * An URL that should point to a HTML file with which navigation requests for URLs that aren't
75
75
  * precached will be fulfilled.
@@ -89,17 +89,17 @@ export interface SerwistOptions {
89
89
  * events for precached assets.
90
90
  */
91
91
  plugins?: SerwistPlugin[];
92
+ }
93
+
94
+ export interface SerwistOptions {
92
95
  /**
93
- * Whether to attempt to get the response from the network if there's
94
- * a precache miss.
96
+ * A list of URLs that should be cached.
95
97
  */
96
- fallbackToNetwork?: boolean;
98
+ precacheEntries?: (PrecacheEntry | string)[];
97
99
  /**
98
- * The number of precache requests that should be made concurrently.
99
- *
100
- * @default 1
100
+ * Options to customize how Serwist precaches the URLs in the precache list.
101
101
  */
102
- concurrentPrecaching?: number;
102
+ precacheOptions?: PrecacheOptions;
103
103
  /**
104
104
  * Forces the waiting service worker to become the active one.
105
105
  *
@@ -132,12 +132,10 @@ export interface SerwistOptions {
132
132
  clientsClaim?: boolean;
133
133
  /**
134
134
  * A list of caching strategies.
135
- *
136
- * @see https://serwist.pages.dev/docs/sw/runtime-caching
137
135
  */
138
136
  runtimeCaching?: RuntimeCaching[];
139
137
  /**
140
- * Your configuration for `@serwist/google-analytics`. This plugin is
138
+ * Your configuration for `initializeGoogleAnalytics`. This plugin is
141
139
  * only initialized when this option is not `undefined` or `false`.
142
140
  */
143
141
  offlineAnalyticsConfig?: Omit<GoogleAnalyticsInitializeOptions, "serwist"> | boolean;
@@ -149,12 +147,10 @@ export interface SerwistOptions {
149
147
  disableDevLogs?: boolean;
150
148
  /**
151
149
  * Precaches routes so that they can be used as a fallback when
152
- * a Strategy fails to generate a response.
150
+ * a `Strategy` fails to generate a response.
153
151
  *
154
- * Note: This option mutates `runtimeCaching`. It also precaches the URLs
155
- * defined in `entries`, so you must NOT precache any of them beforehand.
156
- *
157
- * @see https://serwist.pages.dev/docs/sw/abstractions/fallbacks
152
+ * Note: This option mutates `runtimeCaching`. It also expects the URLs
153
+ * defined in `entries` to have been precached beforehand.
158
154
  */
159
155
  fallbacks?: FallbacksOptions;
160
156
  }
@@ -170,6 +166,8 @@ interface CacheURLsMessageData {
170
166
 
171
167
  /**
172
168
  * A class that helps bootstrap the service worker.
169
+ *
170
+ * @see https://serwist.pages.dev/docs/serwist/core/serwist
173
171
  */
174
172
  export class Serwist {
175
173
  private readonly _urlsToCacheKeys: Map<string, string> = new Map();
@@ -184,13 +182,6 @@ export class Serwist {
184
182
  constructor({
185
183
  precacheEntries,
186
184
  precacheOptions,
187
- cleanupOutdatedCaches,
188
- navigateFallback,
189
- navigateFallbackAllowlist,
190
- navigateFallbackDenylist,
191
- plugins = [],
192
- fallbackToNetwork = true,
193
- concurrentPrecaching = 1,
194
185
  skipWaiting = false,
195
186
  importScripts,
196
187
  navigationPreload = false,
@@ -201,11 +192,11 @@ export class Serwist {
201
192
  disableDevLogs = false,
202
193
  fallbacks,
203
194
  }: SerwistOptions = {}) {
204
- this._concurrentPrecaching = concurrentPrecaching;
205
- this._precacheStrategy = new PrecacheStrategy({
195
+ this._concurrentPrecaching = precacheOptions?.concurrency ?? 10;
196
+ this._precacheStrategy = new PrecacheOnly({
206
197
  cacheName: privateCacheNames.getPrecacheName(precacheOptions?.cacheName),
207
- plugins: [...plugins, new PrecacheCacheKeyPlugin({ precacheController: this })],
208
- fallbackToNetwork,
198
+ plugins: [...(precacheOptions?.plugins ?? []), new PrecacheCacheKeyPlugin({ precacheController: this })],
199
+ fallbackToNetwork: precacheOptions?.fallbackToNetwork,
209
200
  });
210
201
  this._routes = new Map();
211
202
  this._defaultHandlerMap = new Map();
@@ -237,35 +228,36 @@ export class Serwist {
237
228
 
238
229
  if (clientsClaim) clientsClaimImpl();
239
230
 
240
- this.registerRoute(new PrecacheRoute(this, precacheOptions));
241
-
242
231
  if (!!precacheEntries && precacheEntries.length > 0) {
243
232
  this.addToPrecacheList(precacheEntries);
244
233
  }
245
234
 
246
- if (cleanupOutdatedCaches) {
235
+ if (precacheOptions?.cleanupOutdatedCaches) {
247
236
  cleanupOutdatedCachesImpl(precacheOptions?.cacheName);
248
237
  }
249
238
 
250
- if (navigateFallback) {
239
+ this.registerRoute(new PrecacheRoute(this, precacheOptions));
240
+
241
+ if (precacheOptions?.navigateFallback) {
251
242
  this.registerRoute(
252
- new NavigationRoute(this.createHandlerBoundToUrl(navigateFallback), {
253
- allowlist: navigateFallbackAllowlist,
254
- denylist: navigateFallbackDenylist,
243
+ new NavigationRoute(this.createHandlerBoundToUrl(precacheOptions?.navigateFallback), {
244
+ allowlist: precacheOptions?.navigateFallbackAllowlist,
245
+ denylist: precacheOptions?.navigateFallbackDenylist,
255
246
  }),
256
247
  );
257
248
  }
258
249
 
259
250
  if (offlineAnalyticsConfig !== undefined) {
260
251
  if (typeof offlineAnalyticsConfig === "boolean") {
261
- offlineAnalyticsConfig && initialize({ serwist: this });
252
+ offlineAnalyticsConfig && initializeGoogleAnalytics({ serwist: this });
262
253
  } else {
263
- initialize({
254
+ initializeGoogleAnalytics({
264
255
  ...offlineAnalyticsConfig,
265
256
  serwist: this,
266
257
  });
267
258
  }
268
259
  }
260
+
269
261
  if (runtimeCaching !== undefined) {
270
262
  if (fallbacks !== undefined) {
271
263
  const fallbackPlugin = new PrecacheFallbackPlugin({
@@ -292,23 +284,21 @@ export class Serwist {
292
284
  }
293
285
 
294
286
  /**
295
- * The strategy created by this controller and
296
- * used to cache assets and respond to fetch events.
287
+ * The strategy used to precache assets and respond to fetch events.
297
288
  */
298
289
  get precacheStrategy(): Strategy {
299
290
  return this._precacheStrategy;
300
291
  }
301
292
  /**
302
- * A `Map` of HTTP method name (`'GET'`, etc.) to an array of all the corresponding `Route`
303
- * instances that are registered.
293
+ * A `Map` of HTTP method name (`'GET'`, etc.) to an array of all corresponding registered `Route`
294
+ * instances.
304
295
  */
305
296
  get routes(): Map<HTTPMethod, Route[]> {
306
297
  return this._routes;
307
298
  }
308
299
 
309
300
  /**
310
- * This function adds Serwist's event listeners for you. Before calling it, add your own listeners
311
- * should you need to.
301
+ * Adds Serwist's event listeners for you. Before calling it, add your own listeners should you need to.
312
302
  */
313
303
  addEventListeners() {
314
304
  self.addEventListener("install", this.handleInstall);
@@ -318,8 +308,7 @@ export class Serwist {
318
308
  }
319
309
 
320
310
  /**
321
- * This method will add items to the precache list, removing duplicates
322
- * and ensuring the information is valid.
311
+ * Adds items to the precache list, removing duplicates and ensuring the information is valid.
323
312
  *
324
313
  * @param entries Array of entries to precache.
325
314
  */
@@ -535,7 +524,7 @@ export class Serwist {
535
524
 
536
525
  /**
537
526
  * Registers a `RegExp`, string, or function with a caching
538
- * strategy to the `Router`.
527
+ * strategy to the router.
539
528
  *
540
529
  * @param capture If the capture param is a `Route`, all other arguments will be ignored.
541
530
  * @param handler A callback function that returns a `Promise` resulting in a `Response`.
@@ -602,7 +591,7 @@ export class Serwist {
602
591
  }
603
592
 
604
593
  /**
605
- * Unregisters a `Route` with the `Router`.
594
+ * Unregisters a `Route` with the router.
606
595
  *
607
596
  * @param route The `Route` to unregister.
608
597
  */
@@ -643,7 +632,7 @@ export class Serwist {
643
632
 
644
633
  /**
645
634
  * Returns the cache key used for storing a given URL. If that URL is
646
- * unversioned, like `/index.html', then the cache key will be the original
635
+ * unversioned, like "/index.html", then the cache key will be the original
647
636
  * URL with a search parameter appended to it.
648
637
  *
649
638
  * @param url A URL whose cache key you want to look up.
@@ -713,7 +702,7 @@ export class Serwist {
713
702
  }
714
703
 
715
704
  /**
716
- * Apply the routing rules to a `FetchEvent` object to get a `Response` from an
705
+ * Applies the routing rules to a `FetchEvent` object to get a `Response` from an
717
706
  * appropriate `Route`'s handler.
718
707
  *
719
708
  * @param options
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { logger } from "./utils/logger.js";
10
9
  import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
10
+ import { logger } from "./utils/logger.js";
11
11
 
12
12
  import { deleteOutdatedCaches } from "./utils/deleteOutdatedCaches.js";
13
13
 
@@ -3,7 +3,7 @@ declare const self: ServiceWorkerGlobalScope;
3
3
  /**
4
4
  * Disables Serwist's logging in development mode.
5
5
  *
6
- * @see https://serwist.pages.dev/docs/sw/abstractions/disable-dev-logs
6
+ * @see https://serwist.pages.dev/docs/serwist/core/disable-dev-logs
7
7
  */
8
8
  export const disableDevLogs = (): void => {
9
9
  self.__WB_DISABLE_DEV_LOGS = true;
@@ -1,5 +1,4 @@
1
1
  import { NavigationRoute } from "./NavigationRoute.js";
2
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
3
2
  import { RegExpRoute } from "./RegExpRoute.js";
4
3
  import { Route } from "./Route.js";
5
4
  import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
@@ -15,6 +14,8 @@ import type { FallbackEntry, FallbacksOptions } from "./legacy/fallbacks.js";
15
14
  import { fallbacks } from "./legacy/fallbacks.js";
16
15
  import { getCacheKeyForURL } from "./legacy/getCacheKeyForURL.js";
17
16
  import { type HandlePrecachingOptions, handlePrecaching } from "./legacy/handlePrecaching.js";
17
+ import type { GoogleAnalyticsInitializeOptions } from "./legacy/initializeGoogleAnalytics.js";
18
+ import { initializeGoogleAnalytics } from "./legacy/initializeGoogleAnalytics.js";
18
19
  import { type InstallSerwistOptions, installSerwist } from "./legacy/installSerwist.js";
19
20
  import { matchPrecache } from "./legacy/matchPrecache.js";
20
21
  import { precache } from "./legacy/precache.js";
@@ -26,6 +27,7 @@ import { setDefaultHandler } from "./legacy/setDefaultHandler.js";
26
27
  import { getSingletonPrecacheController, setSingletonPrecacheController } from "./legacy/singletonPrecacheController.js";
27
28
  import { getSingletonRouter, setSingletonRouter } from "./legacy/singletonRouter.js";
28
29
  import { unregisterRoute } from "./legacy/unregisterRoute.js";
30
+ import { PrecacheOnly } from "./lib/strategies/PrecacheOnly.js";
29
31
  import { parseRoute } from "./parseRoute.js";
30
32
 
31
33
  export {
@@ -33,7 +35,7 @@ export {
33
35
  // can re-export them without having to import both the normal and legacy
34
36
  // import paths.
35
37
  NavigationRoute,
36
- PrecacheStrategy,
38
+ PrecacheOnly,
37
39
  RegExpRoute,
38
40
  Route,
39
41
  cleanupOutdatedCaches,
@@ -42,8 +44,10 @@ export {
42
44
  addPlugins,
43
45
  addRoute,
44
46
  createHandlerBoundToURL,
45
- getCacheKeyForURL,
46
47
  fallbacks,
48
+ getCacheKeyForURL,
49
+ initializeGoogleAnalytics,
50
+ installSerwist,
47
51
  matchPrecache,
48
52
  precache,
49
53
  precacheAndRoute,
@@ -53,7 +57,6 @@ export {
53
57
  getSingletonPrecacheController,
54
58
  setSingletonPrecacheController,
55
59
  handlePrecaching,
56
- installSerwist,
57
60
  registerRuntimeCaching,
58
61
  registerRoute,
59
62
  Router,
@@ -63,4 +66,12 @@ export {
63
66
  setSingletonRouter,
64
67
  unregisterRoute,
65
68
  };
66
- export type { HandlePrecachingOptions, InstallSerwistOptions, FallbackEntry, FallbacksOptions, PrecacheFallbackEntry, PrecacheFallbackPluginOptions };
69
+ export type {
70
+ HandlePrecachingOptions,
71
+ GoogleAnalyticsInitializeOptions,
72
+ InstallSerwistOptions,
73
+ FallbackEntry,
74
+ FallbacksOptions,
75
+ PrecacheFallbackEntry,
76
+ PrecacheFallbackPluginOptions,
77
+ };
package/src/index.ts CHANGED
@@ -1,23 +1,56 @@
1
- import type { HTTPMethod } from "./constants.js";
1
+ import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
2
+ import { NavigationRoute } from "./NavigationRoute.js";
3
+ import { PrecacheRoute } from "./PrecacheRoute.js";
4
+ import { RegExpRoute } from "./RegExpRoute.js";
5
+ import { Route } from "./Route.js";
6
+ import { Serwist, type SerwistOptions } from "./Serwist.js";
2
7
  import { cacheNames } from "./cacheNames.js";
3
8
  import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
4
9
  import { clientsClaim } from "./clientsClaim.js";
10
+ import type { HTTPMethod } from "./constants.js";
5
11
  import { copyResponse } from "./copyResponse.js";
6
12
  import { disableDevLogs } from "./disableDevLogs.js";
13
+ import { BackgroundSyncPlugin } from "./lib/backgroundSync/BackgroundSyncPlugin.js";
14
+ import type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./lib/backgroundSync/BackgroundSyncQueue.js";
15
+ import { BackgroundSyncQueue } from "./lib/backgroundSync/BackgroundSyncQueue.js";
16
+ import { BackgroundSyncQueueStore } from "./lib/backgroundSync/BackgroundSyncQueueStore.js";
17
+ import { StorableRequest } from "./lib/backgroundSync/StorableRequest.js";
18
+ import { BroadcastCacheUpdate } from "./lib/broadcastUpdate/BroadcastCacheUpdate.js";
19
+ import { BroadcastUpdatePlugin } from "./lib/broadcastUpdate/BroadcastUpdatePlugin.js";
20
+ import { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./lib/broadcastUpdate/constants.js";
21
+ import { responsesAreSame } from "./lib/broadcastUpdate/responsesAreSame.js";
22
+ import type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./lib/broadcastUpdate/types.js";
23
+ import { CacheableResponse } from "./lib/cacheableResponse/CacheableResponse.js";
24
+ import type { CacheableResponseOptions } from "./lib/cacheableResponse/CacheableResponse.js";
25
+ import { CacheableResponsePlugin } from "./lib/cacheableResponse/CacheableResponsePlugin.js";
26
+ import { CacheExpiration } from "./lib/expiration/CacheExpiration.js";
27
+ import type { ExpirationPluginOptions } from "./lib/expiration/ExpirationPlugin.js";
28
+ import { ExpirationPlugin } from "./lib/expiration/ExpirationPlugin.js";
29
+ import { initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
30
+ import type { GoogleAnalyticsInitializeOptions } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
31
+ import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./lib/precaching/PrecacheFallbackPlugin.js";
32
+ import { PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
33
+ import { RangeRequestsPlugin } from "./lib/rangeRequests/RangeRequestsPlugin.js";
34
+ import { createPartialResponse } from "./lib/rangeRequests/createPartialResponse.js";
35
+ import { CacheFirst } from "./lib/strategies/CacheFirst.js";
36
+ import { CacheOnly } from "./lib/strategies/CacheOnly.js";
37
+ import type { NetworkFirstOptions } from "./lib/strategies/NetworkFirst.js";
38
+ import { NetworkFirst } from "./lib/strategies/NetworkFirst.js";
39
+ import type { NetworkOnlyOptions } from "./lib/strategies/NetworkOnly.js";
40
+ import { NetworkOnly } from "./lib/strategies/NetworkOnly.js";
41
+ import { PrecacheOnly } from "./lib/strategies/PrecacheOnly.js";
42
+ import { StaleWhileRevalidate } from "./lib/strategies/StaleWhileRevalidate.js";
43
+ import type { StrategyOptions } from "./lib/strategies/Strategy.js";
44
+ import { Strategy } from "./lib/strategies/Strategy.js";
45
+ import { StrategyHandler } from "./lib/strategies/StrategyHandler.js";
7
46
  import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
8
- import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
9
- import { NavigationRoute } from "./NavigationRoute.js";
10
47
  import { parseRoute } from "./parseRoute.js";
11
- import { PrecacheRoute } from "./PrecacheRoute.js";
12
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
13
- import { RegExpRoute } from "./RegExpRoute.js";
14
48
  import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
15
- import { Route } from "./Route.js";
16
- import { Serwist, type SerwistOptions } from "./Serwist.js";
17
49
  import { setCacheNameDetails } from "./setCacheNameDetails.js";
18
50
 
19
51
  export {
20
- NavigationRoute,
52
+ // Core
53
+ Serwist,
21
54
  cacheNames,
22
55
  cleanupOutdatedCaches,
23
56
  clientsClaim,
@@ -26,14 +59,74 @@ export {
26
59
  disableNavigationPreload,
27
60
  enableNavigationPreload,
28
61
  isNavigationPreloadSupported,
29
- parseRoute,
62
+ // Caching strategies
63
+ CacheFirst,
64
+ CacheOnly,
65
+ NetworkFirst,
66
+ NetworkOnly,
67
+ PrecacheOnly,
68
+ StaleWhileRevalidate,
69
+ Strategy,
70
+ StrategyHandler,
71
+ // Routing
72
+ NavigationRoute,
30
73
  PrecacheRoute,
31
- PrecacheStrategy,
32
74
  RegExpRoute,
33
- registerQuotaErrorCallback,
34
75
  Route,
35
- Serwist,
76
+ parseRoute,
77
+ // Background synchronizing
78
+ BackgroundSyncPlugin,
79
+ BackgroundSyncQueue,
80
+ BackgroundSyncQueueStore,
81
+ StorableRequest,
82
+ // Broadcasting updates
83
+ BroadcastCacheUpdate,
84
+ BroadcastUpdatePlugin,
85
+ BROADCAST_UPDATE_DEFAULT_HEADERS,
86
+ responsesAreSame,
87
+ // Setting cacheability criteria
88
+ CacheableResponse,
89
+ CacheableResponsePlugin,
90
+ // Expiring outdated responses
91
+ CacheExpiration,
92
+ ExpirationPlugin,
93
+ // Precaching
94
+ PrecacheFallbackPlugin,
95
+ // Google Analytics
96
+ initializeGoogleAnalytics,
97
+ // Handling range requests
98
+ createPartialResponse,
99
+ RangeRequestsPlugin,
100
+ // Misc
101
+ registerQuotaErrorCallback,
36
102
  setCacheNameDetails,
37
103
  };
38
- export type { HTTPMethod, NavigationRouteMatchOptions, SerwistOptions };
104
+ export type {
105
+ // Core
106
+ HTTPMethod,
107
+ SerwistOptions,
108
+ // Caching strategies
109
+ NetworkFirstOptions,
110
+ NetworkOnlyOptions,
111
+ StrategyOptions,
112
+ // Routing
113
+ NavigationRouteMatchOptions,
114
+ // Background synchronizing
115
+ BackgroundSyncQueueOptions,
116
+ BackgroundSyncQueueEntry,
117
+ // Broadcasting updates
118
+ BroadcastCacheUpdateOptions,
119
+ BroadcastPayload,
120
+ BroadcastPayloadGenerator,
121
+ BroadcastMessage,
122
+ // Setting cacheability criteria
123
+ CacheableResponseOptions,
124
+ // Expiring outdated responses
125
+ ExpirationPluginOptions,
126
+ // Precaching
127
+ PrecacheFallbackEntry,
128
+ PrecacheFallbackPluginOptions,
129
+ // Google Analytics
130
+ GoogleAnalyticsInitializeOptions,
131
+ };
39
132
  export type * from "./types.js";
@@ -6,20 +6,20 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteHandlerCallback, SerwistPlugin } from "../types.js";
10
- import { assert } from "../utils/assert.js";
11
- import { SerwistError } from "../utils/SerwistError.js";
12
- import { logger } from "../utils/logger.js";
13
- import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
14
- import { waitUntil } from "../utils/waitUntil.js";
15
9
  import { parallel } from "@serwist/utils";
16
- import { PrecacheStrategy } from "../PrecacheStrategy.js";
17
- import type { Strategy } from "../strategies/Strategy.js";
10
+ import { PrecacheOnly } from "../lib/strategies/PrecacheOnly.js";
11
+ import type { Strategy } from "../lib/strategies/Strategy.js";
12
+ import type { RouteHandlerCallback, SerwistPlugin } from "../types.js";
18
13
  import type { CleanupResult, InstallResult, PrecacheEntry } from "../types.js";
19
14
  import { PrecacheInstallReportPlugin } from "../utils/PrecacheInstallReportPlugin.js";
15
+ import { SerwistError } from "../utils/SerwistError.js";
16
+ import { assert } from "../utils/assert.js";
17
+ import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
20
18
  import { createCacheKey } from "../utils/createCacheKey.js";
19
+ import { logger } from "../utils/logger.js";
21
20
  import { printCleanupDetails } from "../utils/printCleanupDetails.js";
22
21
  import { printInstallDetails } from "../utils/printInstallDetails.js";
22
+ import { waitUntil } from "../utils/waitUntil.js";
23
23
  import { PrecacheCacheKeyPlugin } from "./utils/PrecacheCacheKeyPlugin.js";
24
24
 
25
25
  // Give TypeScript the correct global.
@@ -67,7 +67,7 @@ export class PrecacheController {
67
67
  */
68
68
  constructor({ cacheName, plugins = [], fallbackToNetwork = true, concurrentPrecaching = 1 }: PrecacheControllerOptions = {}) {
69
69
  this._concurrentPrecaching = concurrentPrecaching;
70
- this._strategy = new PrecacheStrategy({
70
+ this._strategy = new PrecacheOnly({
71
71
  cacheName: privateCacheNames.getPrecacheName(cacheName),
72
72
  plugins: [...plugins, new PrecacheCacheKeyPlugin({ precacheController: this })],
73
73
  fallbackToNetwork,
@@ -52,7 +52,7 @@ export interface PrecacheFallbackPluginOptions {
52
52
  * Unless you explicitly pass in a `PrecacheController` instance to the
53
53
  * constructor, the default instance will be used. Generally speaking, most
54
54
  * developers will end up using the default.
55
- *
55
+ *
56
56
  * @deprecated
57
57
  */
58
58
  export class PrecacheFallbackPlugin implements SerwistPlugin {
@@ -6,12 +6,12 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteMatchCallback, RouteMatchCallbackOptions } from "../types.js";
10
- import { getFriendlyURL } from "../utils/getFriendlyURL.js";
11
- import { logger } from "../utils/logger.js";
12
9
  import { Route } from "../Route.js";
10
+ import type { RouteMatchCallback, RouteMatchCallbackOptions } from "../types.js";
13
11
  import type { PrecacheRouteOptions } from "../types.js";
14
12
  import { generateURLVariations } from "../utils/generateURLVariations.js";
13
+ import { getFriendlyURL } from "../utils/getFriendlyURL.js";
14
+ import { logger } from "../utils/logger.js";
15
15
  import type { PrecacheController } from "./PrecacheController.js";
16
16
 
17
17
  /**