serwist 9.0.0-preview.24 → 9.0.0-preview.26

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 (232) hide show
  1. package/dist/NavigationRoute.d.ts +6 -7
  2. package/dist/NavigationRoute.d.ts.map +1 -1
  3. package/dist/PrecacheRoute.d.ts +2 -2
  4. package/dist/PrecacheRoute.d.ts.map +1 -1
  5. package/dist/RegExpRoute.d.ts +4 -4
  6. package/dist/RegExpRoute.d.ts.map +1 -1
  7. package/dist/Route.d.ts +10 -10
  8. package/dist/Route.d.ts.map +1 -1
  9. package/dist/Serwist.d.ts +39 -44
  10. package/dist/Serwist.d.ts.map +1 -1
  11. package/dist/chunks/printInstallDetails.js +1587 -0
  12. package/dist/chunks/resultingClientExists.js +1 -1
  13. package/dist/chunks/waitUntil.js +426 -1
  14. package/dist/copyResponse.d.ts +8 -10
  15. package/dist/copyResponse.d.ts.map +1 -1
  16. package/dist/disableDevLogs.d.ts +1 -1
  17. package/dist/index.d.ts +41 -12
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.internal.d.ts +3 -1
  20. package/dist/index.internal.d.ts.map +1 -1
  21. package/dist/index.internal.js +1 -2
  22. package/dist/index.js +1464 -8
  23. package/dist/index.legacy.d.ts +4 -8
  24. package/dist/index.legacy.d.ts.map +1 -1
  25. package/dist/index.legacy.js +166 -16
  26. package/dist/legacy/PrecacheController.d.ts +1 -1
  27. package/dist/legacy/PrecacheController.d.ts.map +1 -1
  28. package/dist/legacy/PrecacheRoute.d.ts.map +1 -1
  29. package/dist/legacy/Router.d.ts +1 -1
  30. package/dist/legacy/Router.d.ts.map +1 -1
  31. package/dist/legacy/constants.d.ts.map +1 -0
  32. package/dist/legacy/fallbacks.d.ts +1 -1
  33. package/dist/legacy/fallbacks.d.ts.map +1 -1
  34. package/dist/legacy/handlePrecaching.d.ts.map +1 -1
  35. package/dist/legacy/initializeGoogleAnalytics.d.ts +38 -0
  36. package/dist/legacy/initializeGoogleAnalytics.d.ts.map +1 -0
  37. package/dist/legacy/installSerwist.d.ts +69 -3
  38. package/dist/legacy/installSerwist.d.ts.map +1 -1
  39. package/dist/legacy/registerRoute.d.ts +1 -1
  40. package/dist/legacy/registerRoute.d.ts.map +1 -1
  41. package/dist/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.d.ts +3 -3
  42. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -0
  43. package/dist/{plugins/backgroundSync/Queue.d.ts → lib/backgroundSync/BackgroundSyncQueue.d.ts} +29 -13
  44. package/dist/lib/backgroundSync/BackgroundSyncQueue.d.ts.map +1 -0
  45. package/dist/{plugins/backgroundSync/QueueDb.d.ts → lib/backgroundSync/BackgroundSyncQueueDb.d.ts} +7 -7
  46. package/dist/lib/backgroundSync/BackgroundSyncQueueDb.d.ts.map +1 -0
  47. package/dist/{plugins/backgroundSync/QueueStore.d.ts → lib/backgroundSync/BackgroundSyncQueueStore.d.ts} +7 -7
  48. package/dist/lib/backgroundSync/BackgroundSyncQueueStore.d.ts.map +1 -0
  49. package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -0
  50. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -0
  51. package/dist/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.d.ts +1 -1
  52. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -0
  53. package/dist/lib/broadcastUpdate/constants.d.ts +5 -0
  54. package/dist/lib/broadcastUpdate/constants.d.ts.map +1 -0
  55. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -0
  56. package/dist/{plugins → lib}/broadcastUpdate/types.d.ts +3 -3
  57. package/dist/lib/broadcastUpdate/types.d.ts.map +1 -0
  58. package/dist/lib/cacheableResponse/CacheableResponse.d.ts.map +1 -0
  59. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -0
  60. package/dist/{plugins → lib}/expiration/CacheExpiration.d.ts +1 -1
  61. package/dist/lib/expiration/CacheExpiration.d.ts.map +1 -0
  62. package/dist/{plugins → lib}/expiration/ExpirationPlugin.d.ts +1 -1
  63. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -0
  64. package/dist/lib/expiration/models/CacheTimestampsModel.d.ts.map +1 -0
  65. package/dist/lib/googleAnalytics/constants.d.ts +10 -0
  66. package/dist/lib/googleAnalytics/constants.d.ts.map +1 -0
  67. package/dist/{plugins/googleAnalytics/initialize.d.ts → lib/googleAnalytics/initializeGoogleAnalytics.d.ts} +2 -2
  68. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -0
  69. package/dist/{plugins → lib}/precaching/PrecacheFallbackPlugin.d.ts +1 -1
  70. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -0
  71. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -0
  72. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -0
  73. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -0
  74. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -0
  75. package/dist/{strategies → lib/strategies}/CacheFirst.d.ts +1 -1
  76. package/dist/lib/strategies/CacheFirst.d.ts.map +1 -0
  77. package/dist/{strategies → lib/strategies}/CacheOnly.d.ts +2 -2
  78. package/dist/lib/strategies/CacheOnly.d.ts.map +1 -0
  79. package/dist/{strategies → lib/strategies}/NetworkFirst.d.ts +2 -2
  80. package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -0
  81. package/dist/{strategies → lib/strategies}/NetworkOnly.d.ts +2 -2
  82. package/dist/lib/strategies/NetworkOnly.d.ts.map +1 -0
  83. package/dist/{PrecacheStrategy.d.ts → lib/strategies/PrecacheStrategy.d.ts} +5 -5
  84. package/dist/lib/strategies/PrecacheStrategy.d.ts.map +1 -0
  85. package/dist/{strategies → lib/strategies}/StaleWhileRevalidate.d.ts +1 -1
  86. package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +1 -0
  87. package/dist/{strategies → lib/strategies}/Strategy.d.ts +15 -17
  88. package/dist/lib/strategies/Strategy.d.ts.map +1 -0
  89. package/dist/{strategies → lib/strategies}/StrategyHandler.d.ts +35 -41
  90. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -0
  91. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +3 -0
  92. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -0
  93. package/dist/lib/strategies/utils/messages.d.ts.map +1 -0
  94. package/dist/navigationPreload.d.ts +3 -3
  95. package/dist/types.d.ts +12 -7
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +1 -1
  98. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -1
  99. package/dist/utils/assert.d.ts.map +1 -1
  100. package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -0
  101. package/dist/utils/clientsClaim.d.ts.map +1 -0
  102. package/dist/{parseRoute.d.ts → utils/parseRoute.d.ts} +3 -3
  103. package/dist/utils/parseRoute.d.ts.map +1 -0
  104. package/package.json +7 -21
  105. package/src/NavigationRoute.ts +6 -7
  106. package/src/PrecacheRoute.ts +5 -5
  107. package/src/RegExpRoute.ts +5 -5
  108. package/src/Route.ts +11 -11
  109. package/src/Serwist.ts +73 -80
  110. package/src/copyResponse.ts +7 -9
  111. package/src/disableDevLogs.ts +1 -1
  112. package/src/index.internal.ts +4 -0
  113. package/src/index.legacy.ts +14 -18
  114. package/src/index.ts +105 -19
  115. package/src/legacy/PrecacheController.ts +8 -8
  116. package/src/legacy/PrecacheFallbackPlugin.ts +1 -1
  117. package/src/legacy/PrecacheRoute.ts +3 -3
  118. package/src/legacy/Router.ts +5 -5
  119. package/src/legacy/fallbacks.ts +3 -3
  120. package/src/legacy/handlePrecaching.ts +1 -1
  121. package/src/legacy/initializeGoogleAnalytics.ts +218 -0
  122. package/src/legacy/installSerwist.ts +156 -5
  123. package/src/legacy/registerRoute.ts +1 -1
  124. package/src/{plugins → lib}/backgroundSync/BackgroundSyncPlugin.ts +6 -6
  125. package/src/{plugins/backgroundSync/Queue.ts → lib/backgroundSync/BackgroundSyncQueue.ts} +47 -26
  126. package/src/{plugins/backgroundSync/QueueDb.ts → lib/backgroundSync/BackgroundSyncQueueDb.ts} +16 -16
  127. package/src/{plugins/backgroundSync/QueueStore.ts → lib/backgroundSync/BackgroundSyncQueueStore.ts} +13 -13
  128. package/src/{plugins → lib}/backgroundSync/StorableRequest.ts +2 -2
  129. package/src/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.ts +14 -9
  130. package/src/{plugins → lib}/broadcastUpdate/BroadcastUpdatePlugin.ts +1 -1
  131. package/src/lib/broadcastUpdate/constants.ts +12 -0
  132. package/src/{plugins → lib}/broadcastUpdate/types.ts +3 -3
  133. package/src/{plugins → lib}/cacheableResponse/CacheableResponse.ts +5 -5
  134. package/src/{plugins → lib}/expiration/CacheExpiration.ts +7 -7
  135. package/src/{plugins → lib}/expiration/ExpirationPlugin.ts +10 -10
  136. package/src/lib/googleAnalytics/constants.ts +22 -0
  137. package/src/{plugins/googleAnalytics/initialize.ts → lib/googleAnalytics/initializeGoogleAnalytics.ts} +9 -9
  138. package/src/{strategies → lib/strategies}/CacheFirst.ts +5 -5
  139. package/src/{strategies → lib/strategies}/CacheOnly.ts +6 -6
  140. package/src/{strategies → lib/strategies}/NetworkFirst.ts +7 -7
  141. package/src/{strategies → lib/strategies}/NetworkOnly.ts +7 -7
  142. package/src/{PrecacheStrategy.ts → lib/strategies/PrecacheStrategy.ts} +14 -10
  143. package/src/{strategies → lib/strategies}/StaleWhileRevalidate.ts +5 -5
  144. package/src/{strategies → lib/strategies}/Strategy.ts +19 -21
  145. package/src/{strategies → lib/strategies}/StrategyHandler.ts +45 -51
  146. package/src/{strategies → lib/strategies}/plugins/cacheOkAndOpaquePlugin.ts +1 -1
  147. package/src/{strategies → lib/strategies}/utils/messages.ts +2 -2
  148. package/src/models/messages/messages.ts +1 -1
  149. package/src/navigationPreload.ts +3 -3
  150. package/src/registerQuotaErrorCallback.ts +1 -1
  151. package/src/types.ts +12 -7
  152. package/src/utils/PrecacheCacheKeyPlugin.ts +1 -1
  153. package/src/utils/assert.ts +1 -1
  154. package/src/{cleanupOutdatedCaches.ts → utils/cleanupOutdatedCaches.ts} +3 -4
  155. package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
  156. package/src/{parseRoute.ts → utils/parseRoute.ts} +21 -23
  157. package/src/utils/welcome.ts +1 -1
  158. package/dist/PrecacheStrategy.d.ts.map +0 -1
  159. package/dist/chunks/NetworkOnly.js +0 -599
  160. package/dist/chunks/PrecacheFallbackPlugin.js +0 -634
  161. package/dist/chunks/Serwist.js +0 -1034
  162. package/dist/chunks/registerQuotaErrorCallback.js +0 -17
  163. package/dist/chunks/timeout.js +0 -400
  164. package/dist/cleanupOutdatedCaches.d.ts.map +0 -1
  165. package/dist/clientsClaim.d.ts.map +0 -1
  166. package/dist/index.plugins.d.ts +0 -41
  167. package/dist/index.plugins.d.ts.map +0 -1
  168. package/dist/index.plugins.js +0 -669
  169. package/dist/index.strategies.d.ts +0 -22
  170. package/dist/index.strategies.d.ts.map +0 -1
  171. package/dist/index.strategies.js +0 -144
  172. package/dist/parseRoute.d.ts.map +0 -1
  173. package/dist/plugins/backgroundSync/BackgroundSyncPlugin.d.ts.map +0 -1
  174. package/dist/plugins/backgroundSync/Queue.d.ts.map +0 -1
  175. package/dist/plugins/backgroundSync/QueueDb.d.ts.map +0 -1
  176. package/dist/plugins/backgroundSync/QueueStore.d.ts.map +0 -1
  177. package/dist/plugins/backgroundSync/StorableRequest.d.ts.map +0 -1
  178. package/dist/plugins/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +0 -1
  179. package/dist/plugins/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +0 -1
  180. package/dist/plugins/broadcastUpdate/constants.d.ts +0 -5
  181. package/dist/plugins/broadcastUpdate/constants.d.ts.map +0 -1
  182. package/dist/plugins/broadcastUpdate/responsesAreSame.d.ts.map +0 -1
  183. package/dist/plugins/broadcastUpdate/types.d.ts.map +0 -1
  184. package/dist/plugins/cacheableResponse/CacheableResponse.d.ts.map +0 -1
  185. package/dist/plugins/cacheableResponse/CacheableResponsePlugin.d.ts.map +0 -1
  186. package/dist/plugins/expiration/CacheExpiration.d.ts.map +0 -1
  187. package/dist/plugins/expiration/ExpirationPlugin.d.ts.map +0 -1
  188. package/dist/plugins/expiration/models/CacheTimestampsModel.d.ts.map +0 -1
  189. package/dist/plugins/googleAnalytics/constants.d.ts.map +0 -1
  190. package/dist/plugins/googleAnalytics/initialize.d.ts.map +0 -1
  191. package/dist/plugins/precaching/PrecacheFallbackPlugin.d.ts.map +0 -1
  192. package/dist/plugins/rangeRequests/RangeRequestsPlugin.d.ts.map +0 -1
  193. package/dist/plugins/rangeRequests/createPartialResponse.d.ts.map +0 -1
  194. package/dist/plugins/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +0 -1
  195. package/dist/plugins/rangeRequests/utils/parseRangeHeader.d.ts.map +0 -1
  196. package/dist/strategies/CacheFirst.d.ts.map +0 -1
  197. package/dist/strategies/CacheOnly.d.ts.map +0 -1
  198. package/dist/strategies/NetworkFirst.d.ts.map +0 -1
  199. package/dist/strategies/NetworkOnly.d.ts.map +0 -1
  200. package/dist/strategies/StaleWhileRevalidate.d.ts.map +0 -1
  201. package/dist/strategies/Strategy.d.ts.map +0 -1
  202. package/dist/strategies/StrategyHandler.d.ts.map +0 -1
  203. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +0 -3
  204. package/dist/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +0 -1
  205. package/dist/strategies/utils/messages.d.ts.map +0 -1
  206. package/src/index.plugins.ts +0 -95
  207. package/src/index.strategies.ts +0 -26
  208. package/src/plugins/broadcastUpdate/constants.ts +0 -12
  209. package/dist/{plugins/googleAnalytics → legacy}/constants.d.ts +0 -0
  210. package/dist/{plugins → lib}/backgroundSync/StorableRequest.d.ts +0 -0
  211. package/dist/{plugins → lib}/broadcastUpdate/BroadcastCacheUpdate.d.ts +0 -0
  212. package/dist/{plugins → lib}/broadcastUpdate/responsesAreSame.d.ts +0 -0
  213. package/dist/{plugins → lib}/cacheableResponse/CacheableResponse.d.ts +0 -0
  214. package/dist/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.d.ts +0 -0
  215. package/dist/{plugins → lib}/expiration/models/CacheTimestampsModel.d.ts +0 -0
  216. package/dist/{plugins → lib}/rangeRequests/RangeRequestsPlugin.d.ts +0 -0
  217. package/dist/{plugins → lib}/rangeRequests/createPartialResponse.d.ts +0 -0
  218. package/dist/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.d.ts +0 -0
  219. package/dist/{plugins → lib}/rangeRequests/utils/parseRangeHeader.d.ts +0 -0
  220. package/dist/{strategies → lib/strategies}/utils/messages.d.ts +0 -0
  221. package/dist/{cleanupOutdatedCaches.d.ts → utils/cleanupOutdatedCaches.d.ts} +0 -0
  222. package/dist/{clientsClaim.d.ts → utils/clientsClaim.d.ts} +0 -0
  223. package/src/{plugins/googleAnalytics → legacy}/constants.ts +0 -0
  224. package/src/{plugins → lib}/broadcastUpdate/responsesAreSame.ts +0 -0
  225. package/src/{plugins → lib}/cacheableResponse/CacheableResponsePlugin.ts +0 -0
  226. package/src/{plugins → lib}/expiration/models/CacheTimestampsModel.ts +0 -0
  227. package/src/{plugins → lib}/precaching/PrecacheFallbackPlugin.ts +1 -1
  228. package/src/{plugins → lib}/rangeRequests/RangeRequestsPlugin.ts +0 -0
  229. package/src/{plugins → lib}/rangeRequests/createPartialResponse.ts +1 -1
  230. package/src/{plugins → lib}/rangeRequests/utils/calculateEffectiveBoundaries.ts +1 -1
  231. package/src/{plugins → lib}/rangeRequests/utils/parseRangeHeader.ts +1 -1
  232. /package/src/{clientsClaim.ts → utils/clientsClaim.ts} +0 -0
package/src/Serwist.ts CHANGED
@@ -1,3 +1,15 @@
1
+ import { parallel } from "@serwist/utils";
2
+ import { NavigationRoute } from "./NavigationRoute.js";
3
+ import { PrecacheRoute } from "./PrecacheRoute.js";
4
+ import type { Route } from "./Route.js";
5
+ import { type HTTPMethod, defaultMethod } from "./constants.js";
6
+ import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
7
+ import { type GoogleAnalyticsInitializeOptions, initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
8
+ import { type PrecacheFallbackEntry, PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
9
+ import { PrecacheStrategy } from "./lib/strategies/PrecacheStrategy.js";
10
+ import { Strategy } from "./lib/strategies/Strategy.js";
11
+ import { enableNavigationPreload } from "./navigationPreload.js";
12
+ import { setCacheNameDetails } from "./setCacheNameDetails.js";
1
13
  import type {
2
14
  RouteHandler,
3
15
  RouteHandlerCallback,
@@ -7,35 +19,23 @@ import type {
7
19
  RouteMatchCallbackOptions,
8
20
  SerwistPlugin,
9
21
  } 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
- import { parallel } from "@serwist/utils";
19
- import { NavigationRoute } from "./NavigationRoute.js";
20
- import { PrecacheRoute } from "./PrecacheRoute.js";
21
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
22
- import type { Route } from "./Route.js";
23
- import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "./cleanupOutdatedCaches.js";
24
- import { type HTTPMethod, defaultMethod } from "./constants.js";
25
- import { disableDevLogs as disableDevLogsImpl } from "./disableDevLogs.js";
26
- import { enableNavigationPreload } from "./navigationPreload.js";
27
- 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";
31
22
  import type { PrecacheRouteOptions, RuntimeCaching } from "./types.js";
32
23
  import type { CleanupResult, InstallResult, PrecacheEntry } from "./types.js";
33
24
  import { PrecacheCacheKeyPlugin } from "./utils/PrecacheCacheKeyPlugin.js";
34
25
  import { PrecacheInstallReportPlugin } from "./utils/PrecacheInstallReportPlugin.js";
26
+ import { SerwistError } from "./utils/SerwistError.js";
27
+ import { assert } from "./utils/assert.js";
28
+ import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
29
+ import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "./utils/cleanupOutdatedCaches.js";
30
+ import { clientsClaim as clientsClaimImpl } from "./utils/clientsClaim.js";
35
31
  import { createCacheKey } from "./utils/createCacheKey.js";
32
+ import { getFriendlyURL } from "./utils/getFriendlyURL.js";
33
+ import { logger } from "./utils/logger.js";
36
34
  import { normalizeHandler } from "./utils/normalizeHandler.js";
35
+ import { parseRoute } from "./utils/parseRoute.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;
195
+ this._concurrentPrecaching = precacheOptions?.concurrency ?? 10;
205
196
  this._precacheStrategy = new PrecacheStrategy({
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`.
@@ -543,7 +532,11 @@ export class Serwist {
543
532
  * @param method The HTTP method to match the Route against. Defaults to `'GET'`.
544
533
  * @returns The generated `Route`.
545
534
  */
546
- registerCapture(capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route {
535
+ registerCapture<T extends RegExp | string | RouteMatchCallback | Route>(
536
+ capture: T,
537
+ handler?: T extends Route ? never : RouteHandler,
538
+ method?: T extends Route ? never : HTTPMethod,
539
+ ): Route {
547
540
  const route = parseRoute(capture, handler, method);
548
541
  this.registerRoute(route);
549
542
  return route;
@@ -602,7 +595,7 @@ export class Serwist {
602
595
  }
603
596
 
604
597
  /**
605
- * Unregisters a `Route` with the `Router`.
598
+ * Unregisters a `Route` with the router.
606
599
  *
607
600
  * @param route The `Route` to unregister.
608
601
  */
@@ -643,7 +636,7 @@ export class Serwist {
643
636
 
644
637
  /**
645
638
  * 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
639
+ * unversioned, like "/index.html", then the cache key will be the original
647
640
  * URL with a search parameter appended to it.
648
641
  *
649
642
  * @param url A URL whose cache key you want to look up.
@@ -713,7 +706,7 @@ export class Serwist {
713
706
  }
714
707
 
715
708
  /**
716
- * Apply the routing rules to a `FetchEvent` object to get a `Response` from an
709
+ * Applies the routing rules to a `FetchEvent` object to get a `Response` from an
717
710
  * appropriate `Route`'s handler.
718
711
  *
719
712
  * @param options
@@ -11,21 +11,19 @@ import { canConstructResponseFromBodyStream } from "./utils/canConstructResponse
11
11
 
12
12
  /**
13
13
  * Allows developers to copy a response and modify its `headers`, `status`,
14
- * or `statusText` values (the values settable via a
15
- * [`ResponseInit`](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#Syntax)
16
- * object in the constructor).
14
+ * or `statusText` values (the [valid options](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#options)
15
+ * when constructing a `Response` object).
17
16
  * To modify these values, pass a function as the second argument. That
18
- * function will be invoked with a single object with the response properties
19
- * `{headers, status, statusText}`. The return value of this function will
20
- * be used as the `ResponseInit` for the new `Response`. To change the values
21
- * either modify the passed parameter(s) and return it, or return a totally
17
+ * function will be invoked with the options of the initial `Response` object.
18
+ * The return value of this function will be used as the options for the new `Response` object.
19
+ * To change the values either modify the passed parameter(s) and return it or return a totally
22
20
  * new object.
23
21
  *
24
22
  * This method is intentionally limited to same-origin responses, regardless of
25
23
  * whether CORS was used or not.
26
24
  *
27
- * @param response
28
- * @param modifier
25
+ * @param response The initial response.
26
+ * @param modifier The function used to modify the options of the `Response` object.
29
27
  */
30
28
  export const copyResponse = async (response: Response, modifier?: (responseInit: ResponseInit) => ResponseInit): Promise<Response> => {
31
29
  let origin = null;
@@ -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;
@@ -5,6 +5,8 @@ import { cacheMatchIgnoreParams } from "./utils/cacheMatchIgnoreParams.js";
5
5
  import { cacheNames as privateCacheNames } from "./utils/cacheNames.js";
6
6
  import { canConstructReadableStream } from "./utils/canConstructReadableStream.js";
7
7
  import { canConstructResponseFromBodyStream } from "./utils/canConstructResponseFromBodyStream.js";
8
+ import { cleanupOutdatedCaches } from "./utils/cleanupOutdatedCaches.js";
9
+ import { clientsClaim } from "./utils/clientsClaim.js";
8
10
  import { dontWaitFor } from "./utils/dontWaitFor.js";
9
11
  import { executeQuotaErrorCallbacks } from "./utils/executeQuotaErrorCallbacks.js";
10
12
  import { getFriendlyURL } from "./utils/getFriendlyURL.js";
@@ -19,6 +21,8 @@ export {
19
21
  Deferred,
20
22
  SerwistError,
21
23
  assert,
24
+ cleanupOutdatedCaches,
25
+ clientsClaim,
22
26
  cacheMatchIgnoreParams,
23
27
  privateCacheNames,
24
28
  canConstructReadableStream,
@@ -1,8 +1,3 @@
1
- import { NavigationRoute } from "./NavigationRoute.js";
2
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
3
- import { RegExpRoute } from "./RegExpRoute.js";
4
- import { Route } from "./Route.js";
5
- import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
6
1
  import { PrecacheController } from "./legacy/PrecacheController.js";
7
2
  import { PrecacheFallbackPlugin } from "./legacy/PrecacheFallbackPlugin.js";
8
3
  import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./legacy/PrecacheFallbackPlugin.js";
@@ -15,6 +10,8 @@ import type { FallbackEntry, FallbacksOptions } from "./legacy/fallbacks.js";
15
10
  import { fallbacks } from "./legacy/fallbacks.js";
16
11
  import { getCacheKeyForURL } from "./legacy/getCacheKeyForURL.js";
17
12
  import { type HandlePrecachingOptions, handlePrecaching } from "./legacy/handlePrecaching.js";
13
+ import type { GoogleAnalyticsInitializeOptions } from "./legacy/initializeGoogleAnalytics.js";
14
+ import { initializeGoogleAnalytics } from "./legacy/initializeGoogleAnalytics.js";
18
15
  import { type InstallSerwistOptions, installSerwist } from "./legacy/installSerwist.js";
19
16
  import { matchPrecache } from "./legacy/matchPrecache.js";
20
17
  import { precache } from "./legacy/precache.js";
@@ -26,24 +23,16 @@ import { setDefaultHandler } from "./legacy/setDefaultHandler.js";
26
23
  import { getSingletonPrecacheController, setSingletonPrecacheController } from "./legacy/singletonPrecacheController.js";
27
24
  import { getSingletonRouter, setSingletonRouter } from "./legacy/singletonRouter.js";
28
25
  import { unregisterRoute } from "./legacy/unregisterRoute.js";
29
- import { parseRoute } from "./parseRoute.js";
30
26
 
31
27
  export {
32
- // These are not deprecated, but we export them so legacy packages
33
- // can re-export them without having to import both the normal and legacy
34
- // import paths.
35
- NavigationRoute,
36
- PrecacheStrategy,
37
- RegExpRoute,
38
- Route,
39
- cleanupOutdatedCaches,
40
- parseRoute,
41
28
  // Actual deprecated modules start here
42
29
  addPlugins,
43
30
  addRoute,
44
31
  createHandlerBoundToURL,
45
- getCacheKeyForURL,
46
32
  fallbacks,
33
+ getCacheKeyForURL,
34
+ initializeGoogleAnalytics,
35
+ installSerwist,
47
36
  matchPrecache,
48
37
  precache,
49
38
  precacheAndRoute,
@@ -53,7 +42,6 @@ export {
53
42
  getSingletonPrecacheController,
54
43
  setSingletonPrecacheController,
55
44
  handlePrecaching,
56
- installSerwist,
57
45
  registerRuntimeCaching,
58
46
  registerRoute,
59
47
  Router,
@@ -63,4 +51,12 @@ export {
63
51
  setSingletonRouter,
64
52
  unregisterRoute,
65
53
  };
66
- export type { HandlePrecachingOptions, InstallSerwistOptions, FallbackEntry, FallbacksOptions, PrecacheFallbackEntry, PrecacheFallbackPluginOptions };
54
+ export type {
55
+ HandlePrecachingOptions,
56
+ GoogleAnalyticsInitializeOptions,
57
+ InstallSerwistOptions,
58
+ FallbackEntry,
59
+ FallbacksOptions,
60
+ PrecacheFallbackEntry,
61
+ PrecacheFallbackPluginOptions,
62
+ };
package/src/index.ts CHANGED
@@ -1,39 +1,125 @@
1
- import type { HTTPMethod } from "./constants.js";
2
- import { cacheNames } from "./cacheNames.js";
3
- import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
4
- import { clientsClaim } from "./clientsClaim.js";
5
- import { copyResponse } from "./copyResponse.js";
6
- import { disableDevLogs } from "./disableDevLogs.js";
7
- import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
8
1
  import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
9
2
  import { NavigationRoute } from "./NavigationRoute.js";
10
- import { parseRoute } from "./parseRoute.js";
11
3
  import { PrecacheRoute } from "./PrecacheRoute.js";
12
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
13
4
  import { RegExpRoute } from "./RegExpRoute.js";
14
- import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
15
5
  import { Route } from "./Route.js";
16
6
  import { Serwist, type SerwistOptions } from "./Serwist.js";
7
+ import { cacheNames } from "./cacheNames.js";
8
+ import type { HTTPMethod } from "./constants.js";
9
+ import { copyResponse } from "./copyResponse.js";
10
+ import { disableDevLogs } from "./disableDevLogs.js";
11
+ import { BackgroundSyncPlugin } from "./lib/backgroundSync/BackgroundSyncPlugin.js";
12
+ import type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./lib/backgroundSync/BackgroundSyncQueue.js";
13
+ import { BackgroundSyncQueue } from "./lib/backgroundSync/BackgroundSyncQueue.js";
14
+ import { BackgroundSyncQueueStore } from "./lib/backgroundSync/BackgroundSyncQueueStore.js";
15
+ import { StorableRequest } from "./lib/backgroundSync/StorableRequest.js";
16
+ import { BroadcastCacheUpdate } from "./lib/broadcastUpdate/BroadcastCacheUpdate.js";
17
+ import { BroadcastUpdatePlugin } from "./lib/broadcastUpdate/BroadcastUpdatePlugin.js";
18
+ import { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./lib/broadcastUpdate/constants.js";
19
+ import { responsesAreSame } from "./lib/broadcastUpdate/responsesAreSame.js";
20
+ import type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./lib/broadcastUpdate/types.js";
21
+ import { CacheableResponse } from "./lib/cacheableResponse/CacheableResponse.js";
22
+ import type { CacheableResponseOptions } from "./lib/cacheableResponse/CacheableResponse.js";
23
+ import { CacheableResponsePlugin } from "./lib/cacheableResponse/CacheableResponsePlugin.js";
24
+ import { CacheExpiration } from "./lib/expiration/CacheExpiration.js";
25
+ import type { ExpirationPluginOptions } from "./lib/expiration/ExpirationPlugin.js";
26
+ import { ExpirationPlugin } from "./lib/expiration/ExpirationPlugin.js";
27
+ import { initializeGoogleAnalytics } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
28
+ import type { GoogleAnalyticsInitializeOptions } from "./lib/googleAnalytics/initializeGoogleAnalytics.js";
29
+ import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./lib/precaching/PrecacheFallbackPlugin.js";
30
+ import { PrecacheFallbackPlugin } from "./lib/precaching/PrecacheFallbackPlugin.js";
31
+ import { RangeRequestsPlugin } from "./lib/rangeRequests/RangeRequestsPlugin.js";
32
+ import { createPartialResponse } from "./lib/rangeRequests/createPartialResponse.js";
33
+ import { CacheFirst } from "./lib/strategies/CacheFirst.js";
34
+ import { CacheOnly } from "./lib/strategies/CacheOnly.js";
35
+ import type { NetworkFirstOptions } from "./lib/strategies/NetworkFirst.js";
36
+ import { NetworkFirst } from "./lib/strategies/NetworkFirst.js";
37
+ import type { NetworkOnlyOptions } from "./lib/strategies/NetworkOnly.js";
38
+ import { NetworkOnly } from "./lib/strategies/NetworkOnly.js";
39
+ import { PrecacheStrategy } from "./lib/strategies/PrecacheStrategy.js";
40
+ import { StaleWhileRevalidate } from "./lib/strategies/StaleWhileRevalidate.js";
41
+ import type { StrategyOptions } from "./lib/strategies/Strategy.js";
42
+ import { Strategy } from "./lib/strategies/Strategy.js";
43
+ import { StrategyHandler } from "./lib/strategies/StrategyHandler.js";
44
+ import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
45
+ import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
17
46
  import { setCacheNameDetails } from "./setCacheNameDetails.js";
18
47
 
19
48
  export {
20
- NavigationRoute,
49
+ // Core
50
+ Serwist,
21
51
  cacheNames,
22
- cleanupOutdatedCaches,
23
- clientsClaim,
24
52
  copyResponse,
25
53
  disableDevLogs,
26
54
  disableNavigationPreload,
27
55
  enableNavigationPreload,
28
56
  isNavigationPreloadSupported,
29
- parseRoute,
30
- PrecacheRoute,
57
+ registerQuotaErrorCallback,
58
+ setCacheNameDetails,
59
+ // Caching strategies
60
+ CacheFirst,
61
+ CacheOnly,
62
+ NetworkFirst,
63
+ NetworkOnly,
31
64
  PrecacheStrategy,
65
+ StaleWhileRevalidate,
66
+ Strategy,
67
+ StrategyHandler,
68
+ // Routing
69
+ NavigationRoute,
70
+ PrecacheRoute,
32
71
  RegExpRoute,
33
- registerQuotaErrorCallback,
34
72
  Route,
35
- Serwist,
36
- setCacheNameDetails,
73
+ // Background synchronizing
74
+ BackgroundSyncPlugin,
75
+ BackgroundSyncQueue,
76
+ BackgroundSyncQueueStore,
77
+ StorableRequest,
78
+ // Broadcasting updates
79
+ BroadcastCacheUpdate,
80
+ BroadcastUpdatePlugin,
81
+ BROADCAST_UPDATE_DEFAULT_HEADERS,
82
+ responsesAreSame,
83
+ // Setting cacheability criteria
84
+ CacheableResponse,
85
+ CacheableResponsePlugin,
86
+ // Expiring outdated responses
87
+ CacheExpiration,
88
+ ExpirationPlugin,
89
+ // Precaching
90
+ PrecacheFallbackPlugin,
91
+ // Google Analytics
92
+ initializeGoogleAnalytics,
93
+ // Handling range requests
94
+ createPartialResponse,
95
+ RangeRequestsPlugin,
96
+ };
97
+ export type {
98
+ // Core
99
+ HTTPMethod,
100
+ SerwistOptions,
101
+ // Caching strategies
102
+ NetworkFirstOptions,
103
+ NetworkOnlyOptions,
104
+ StrategyOptions,
105
+ // Routing
106
+ NavigationRouteMatchOptions,
107
+ // Background synchronizing
108
+ BackgroundSyncQueueOptions,
109
+ BackgroundSyncQueueEntry,
110
+ // Broadcasting updates
111
+ BroadcastCacheUpdateOptions,
112
+ BroadcastPayload,
113
+ BroadcastPayloadGenerator,
114
+ BroadcastMessage,
115
+ // Setting cacheability criteria
116
+ CacheableResponseOptions,
117
+ // Expiring outdated responses
118
+ ExpirationPluginOptions,
119
+ // Precaching
120
+ PrecacheFallbackEntry,
121
+ PrecacheFallbackPluginOptions,
122
+ // Google Analytics
123
+ GoogleAnalyticsInitializeOptions,
37
124
  };
38
- export type { HTTPMethod, NavigationRouteMatchOptions, SerwistOptions };
39
125
  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 { PrecacheStrategy } from "../lib/strategies/PrecacheStrategy.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.
@@ -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
  /**