serwist 9.1.0-preview.0 → 10.0.0-preview.2

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 (239) hide show
  1. package/dist/NavigationRoute.d.ts.map +1 -1
  2. package/dist/RegExpRoute.d.ts.map +1 -1
  3. package/dist/Route.d.ts.map +1 -1
  4. package/dist/Serwist.d.ts +75 -53
  5. package/dist/Serwist.d.ts.map +1 -1
  6. package/dist/cacheNames.d.ts.map +1 -1
  7. package/dist/chunks/waitUntil.js +49 -42
  8. package/dist/copyResponse.d.ts.map +1 -1
  9. package/dist/index.d.ts +11 -36
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.internal.d.ts +16 -16
  12. package/dist/index.internal.d.ts.map +1 -1
  13. package/dist/index.internal.js +25 -3
  14. package/dist/index.js +1918 -248
  15. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts +2 -2
  16. package/dist/lib/backgroundSync/BackgroundSyncPlugin.d.ts.map +1 -1
  17. package/dist/lib/backgroundSync/StorableRequest.d.ts.map +1 -1
  18. package/dist/lib/backgroundSync/index.d.ts +6 -0
  19. package/dist/lib/backgroundSync/index.d.ts.map +1 -0
  20. package/dist/lib/broadcastUpdate/BroadcastCacheUpdate.d.ts.map +1 -1
  21. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts +2 -2
  22. package/dist/lib/broadcastUpdate/BroadcastUpdatePlugin.d.ts.map +1 -1
  23. package/dist/lib/broadcastUpdate/index.d.ts +6 -0
  24. package/dist/lib/broadcastUpdate/index.d.ts.map +1 -0
  25. package/dist/lib/broadcastUpdate/responsesAreSame.d.ts.map +1 -1
  26. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts +3 -3
  27. package/dist/lib/cacheableResponse/CacheableResponsePlugin.d.ts.map +1 -1
  28. package/dist/lib/cacheableResponse/index.d.ts +4 -0
  29. package/dist/lib/cacheableResponse/index.d.ts.map +1 -0
  30. package/dist/{legacy/utils → lib/controllers/PrecacheController}/PrecacheCacheKeyPlugin.d.ts +4 -4
  31. package/dist/lib/controllers/PrecacheController/PrecacheCacheKeyPlugin.d.ts.map +1 -0
  32. package/dist/{legacy → lib/controllers/PrecacheController}/PrecacheController.d.ts +77 -64
  33. package/dist/lib/controllers/PrecacheController/PrecacheController.d.ts.map +1 -0
  34. package/dist/lib/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts +14 -0
  35. package/dist/lib/controllers/PrecacheController/PrecacheInstallReportPlugin.d.ts.map +1 -0
  36. package/dist/{PrecacheRoute.d.ts → lib/controllers/PrecacheController/PrecacheRoute.d.ts} +4 -5
  37. package/dist/lib/controllers/PrecacheController/PrecacheRoute.d.ts.map +1 -0
  38. package/dist/lib/{strategies → controllers/PrecacheController}/PrecacheStrategy.d.ts +6 -6
  39. package/dist/lib/controllers/PrecacheController/PrecacheStrategy.d.ts.map +1 -0
  40. package/dist/lib/controllers/PrecacheController/parsePrecacheOptions.d.ts +25 -0
  41. package/dist/lib/controllers/PrecacheController/parsePrecacheOptions.d.ts.map +1 -0
  42. package/dist/lib/controllers/RuntimeCacheController.d.ts +70 -0
  43. package/dist/lib/controllers/RuntimeCacheController.d.ts.map +1 -0
  44. package/dist/lib/controllers/index.d.ts +4 -0
  45. package/dist/lib/controllers/index.d.ts.map +1 -0
  46. package/dist/lib/expiration/ExpirationPlugin.d.ts +2 -2
  47. package/dist/lib/expiration/ExpirationPlugin.d.ts.map +1 -1
  48. package/dist/lib/expiration/index.d.ts +4 -0
  49. package/dist/lib/expiration/index.d.ts.map +1 -0
  50. package/dist/lib/googleAnalytics/index.d.ts +3 -0
  51. package/dist/lib/googleAnalytics/index.d.ts.map +1 -0
  52. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -1
  53. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts +15 -9
  54. package/dist/lib/precaching/PrecacheFallbackPlugin.d.ts.map +1 -1
  55. package/dist/lib/precaching/index.d.ts +3 -0
  56. package/dist/lib/precaching/index.d.ts.map +1 -0
  57. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts +3 -3
  58. package/dist/lib/rangeRequests/RangeRequestsPlugin.d.ts.map +1 -1
  59. package/dist/lib/rangeRequests/createPartialResponse.d.ts.map +1 -1
  60. package/dist/lib/rangeRequests/index.d.ts +3 -0
  61. package/dist/lib/rangeRequests/index.d.ts.map +1 -0
  62. package/dist/lib/rangeRequests/utils/calculateEffectiveBoundaries.d.ts.map +1 -1
  63. package/dist/lib/rangeRequests/utils/parseRangeHeader.d.ts.map +1 -1
  64. package/dist/lib/strategies/Strategy.d.ts +3 -3
  65. package/dist/lib/strategies/Strategy.d.ts.map +1 -1
  66. package/dist/lib/strategies/StrategyHandler.d.ts +4 -4
  67. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
  68. package/dist/lib/strategies/index.d.ts +11 -0
  69. package/dist/lib/strategies/index.d.ts.map +1 -0
  70. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts +2 -2
  71. package/dist/lib/strategies/plugins/cacheOkAndOpaquePlugin.d.ts.map +1 -1
  72. package/dist/navigationPreload.d.ts.map +1 -1
  73. package/dist/registerQuotaErrorCallback.d.ts.map +1 -1
  74. package/dist/setCacheNameDetails.d.ts +1 -1
  75. package/dist/setCacheNameDetails.d.ts.map +1 -1
  76. package/dist/types.d.ts +35 -64
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/utils/SerwistError.d.ts +1 -1
  79. package/dist/utils/SerwistError.d.ts.map +1 -1
  80. package/dist/utils/cleanupOutdatedCaches.d.ts.map +1 -1
  81. package/dist/utils/createCacheKey.d.ts.map +1 -1
  82. package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -1
  83. package/dist/utils/getFriendlyURL.d.ts.map +1 -1
  84. package/dist/utils/normalizeHandler.d.ts.map +1 -1
  85. package/dist/utils/parseRoute.d.ts.map +1 -1
  86. package/dist/utils/pluginUtils.d.ts +2 -2
  87. package/dist/utils/pluginUtils.d.ts.map +1 -1
  88. package/dist/utils/printCleanupDetails.d.ts.map +1 -1
  89. package/dist/utils/printInstallDetails.d.ts.map +1 -1
  90. package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -1
  91. package/dist/utils/waitUntil.d.ts.map +1 -1
  92. package/package.json +29 -13
  93. package/src/NavigationRoute.ts +2 -2
  94. package/src/RegExpRoute.ts +2 -2
  95. package/src/Route.ts +2 -2
  96. package/src/Serwist.ts +170 -271
  97. package/src/cacheNames.ts +1 -1
  98. package/src/copyResponse.ts +2 -2
  99. package/src/index.internal.ts +16 -16
  100. package/src/index.ts +68 -93
  101. package/src/lib/backgroundSync/BackgroundSyncPlugin.ts +2 -2
  102. package/src/lib/backgroundSync/BackgroundSyncQueue.ts +4 -4
  103. package/src/lib/backgroundSync/BackgroundSyncQueueStore.ts +1 -1
  104. package/src/lib/backgroundSync/StorableRequest.ts +1 -1
  105. package/src/lib/backgroundSync/index.ts +5 -0
  106. package/src/lib/broadcastUpdate/BroadcastCacheUpdate.ts +4 -4
  107. package/src/lib/broadcastUpdate/BroadcastUpdatePlugin.ts +2 -2
  108. package/src/lib/broadcastUpdate/index.ts +5 -0
  109. package/src/lib/broadcastUpdate/responsesAreSame.ts +2 -2
  110. package/src/lib/cacheableResponse/CacheableResponse.ts +4 -4
  111. package/src/lib/cacheableResponse/CacheableResponsePlugin.ts +3 -3
  112. package/src/lib/cacheableResponse/index.ts +3 -0
  113. package/src/{legacy/utils → lib/controllers/PrecacheController}/PrecacheCacheKeyPlugin.ts +5 -6
  114. package/src/lib/controllers/PrecacheController/PrecacheController.ts +328 -0
  115. package/src/{utils → lib/controllers/PrecacheController}/PrecacheInstallReportPlugin.ts +5 -5
  116. package/src/{PrecacheRoute.ts → lib/controllers/PrecacheController/PrecacheRoute.ts} +11 -12
  117. package/src/lib/{strategies → controllers/PrecacheController}/PrecacheStrategy.ts +13 -13
  118. package/src/lib/controllers/PrecacheController/parsePrecacheOptions.ts +46 -0
  119. package/src/lib/controllers/RuntimeCacheController.ts +119 -0
  120. package/src/lib/controllers/index.ts +3 -0
  121. package/src/lib/expiration/CacheExpiration.ts +3 -3
  122. package/src/lib/expiration/ExpirationPlugin.ts +8 -8
  123. package/src/lib/expiration/index.ts +3 -0
  124. package/src/lib/googleAnalytics/index.ts +2 -0
  125. package/src/lib/googleAnalytics/initializeGoogleAnalytics.ts +5 -5
  126. package/src/lib/precaching/PrecacheFallbackPlugin.ts +23 -12
  127. package/src/lib/precaching/index.ts +2 -0
  128. package/src/lib/rangeRequests/RangeRequestsPlugin.ts +3 -3
  129. package/src/lib/rangeRequests/createPartialResponse.ts +3 -3
  130. package/src/lib/rangeRequests/index.ts +2 -0
  131. package/src/lib/rangeRequests/utils/calculateEffectiveBoundaries.ts +2 -2
  132. package/src/lib/rangeRequests/utils/parseRangeHeader.ts +2 -2
  133. package/src/lib/strategies/CacheFirst.ts +3 -3
  134. package/src/lib/strategies/CacheOnly.ts +3 -3
  135. package/src/lib/strategies/NetworkFirst.ts +3 -3
  136. package/src/lib/strategies/NetworkOnly.ts +4 -4
  137. package/src/lib/strategies/StaleWhileRevalidate.ts +3 -3
  138. package/src/lib/strategies/Strategy.ts +7 -7
  139. package/src/lib/strategies/StrategyHandler.ts +18 -18
  140. package/src/lib/strategies/index.ts +10 -0
  141. package/src/lib/strategies/plugins/cacheOkAndOpaquePlugin.ts +2 -2
  142. package/src/lib/strategies/utils/messages.ts +2 -2
  143. package/src/models/messages/messages.ts +3 -3
  144. package/src/navigationPreload.ts +1 -1
  145. package/src/registerQuotaErrorCallback.ts +2 -2
  146. package/src/setCacheNameDetails.ts +4 -4
  147. package/src/types.ts +56 -68
  148. package/src/utils/SerwistError.ts +2 -2
  149. package/src/utils/cacheNames.ts +1 -1
  150. package/src/utils/executeQuotaErrorCallbacks.ts +1 -1
  151. package/src/utils/pluginUtils.ts +2 -2
  152. package/dist/PrecacheRoute.d.ts.map +0 -1
  153. package/dist/chunks/printInstallDetails.js +0 -1601
  154. package/dist/chunks/resultingClientExists.js +0 -32
  155. package/dist/index.legacy.d.ts +0 -28
  156. package/dist/index.legacy.d.ts.map +0 -1
  157. package/dist/index.legacy.js +0 -790
  158. package/dist/legacy/PrecacheController.d.ts.map +0 -1
  159. package/dist/legacy/PrecacheFallbackPlugin.d.ts +0 -61
  160. package/dist/legacy/PrecacheFallbackPlugin.d.ts.map +0 -1
  161. package/dist/legacy/PrecacheRoute.d.ts +0 -19
  162. package/dist/legacy/PrecacheRoute.d.ts.map +0 -1
  163. package/dist/legacy/Router.d.ts +0 -151
  164. package/dist/legacy/Router.d.ts.map +0 -1
  165. package/dist/legacy/addPlugins.d.ts +0 -9
  166. package/dist/legacy/addPlugins.d.ts.map +0 -1
  167. package/dist/legacy/addRoute.d.ts +0 -14
  168. package/dist/legacy/addRoute.d.ts.map +0 -1
  169. package/dist/legacy/constants.d.ts +0 -10
  170. package/dist/legacy/constants.d.ts.map +0 -1
  171. package/dist/legacy/createHandlerBoundToURL.d.ts +0 -17
  172. package/dist/legacy/createHandlerBoundToURL.d.ts.map +0 -1
  173. package/dist/legacy/fallbacks.d.ts +0 -59
  174. package/dist/legacy/fallbacks.d.ts.map +0 -1
  175. package/dist/legacy/getCacheKeyForURL.d.ts +0 -20
  176. package/dist/legacy/getCacheKeyForURL.d.ts.map +0 -1
  177. package/dist/legacy/handlePrecaching.d.ts +0 -54
  178. package/dist/legacy/handlePrecaching.d.ts.map +0 -1
  179. package/dist/legacy/initializeGoogleAnalytics.d.ts +0 -38
  180. package/dist/legacy/initializeGoogleAnalytics.d.ts.map +0 -1
  181. package/dist/legacy/installSerwist.d.ts +0 -81
  182. package/dist/legacy/installSerwist.d.ts.map +0 -1
  183. package/dist/legacy/matchPrecache.d.ts +0 -15
  184. package/dist/legacy/matchPrecache.d.ts.map +0 -1
  185. package/dist/legacy/precache.d.ts +0 -20
  186. package/dist/legacy/precache.d.ts.map +0 -1
  187. package/dist/legacy/precacheAndRoute.d.ts +0 -14
  188. package/dist/legacy/precacheAndRoute.d.ts.map +0 -1
  189. package/dist/legacy/registerRoute.d.ts +0 -16
  190. package/dist/legacy/registerRoute.d.ts.map +0 -1
  191. package/dist/legacy/registerRuntimeCaching.d.ts +0 -11
  192. package/dist/legacy/registerRuntimeCaching.d.ts.map +0 -1
  193. package/dist/legacy/setCatchHandler.d.ts +0 -10
  194. package/dist/legacy/setCatchHandler.d.ts.map +0 -1
  195. package/dist/legacy/setDefaultHandler.d.ts +0 -13
  196. package/dist/legacy/setDefaultHandler.d.ts.map +0 -1
  197. package/dist/legacy/singletonPrecacheController.d.ts +0 -34
  198. package/dist/legacy/singletonPrecacheController.d.ts.map +0 -1
  199. package/dist/legacy/singletonRouter.d.ts +0 -41
  200. package/dist/legacy/singletonRouter.d.ts.map +0 -1
  201. package/dist/legacy/unregisterRoute.d.ts +0 -9
  202. package/dist/legacy/unregisterRoute.d.ts.map +0 -1
  203. package/dist/legacy/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  204. package/dist/legacy/utils/getCacheKeyForURL.d.ts +0 -14
  205. package/dist/legacy/utils/getCacheKeyForURL.d.ts.map +0 -1
  206. package/dist/lib/strategies/PrecacheStrategy.d.ts.map +0 -1
  207. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +0 -16
  208. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  209. package/dist/utils/PrecacheInstallReportPlugin.d.ts +0 -14
  210. package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +0 -1
  211. package/dist/utils/parsePrecacheOptions.d.ts +0 -26
  212. package/dist/utils/parsePrecacheOptions.d.ts.map +0 -1
  213. package/src/index.legacy.ts +0 -62
  214. package/src/legacy/PrecacheController.ts +0 -337
  215. package/src/legacy/PrecacheFallbackPlugin.ts +0 -92
  216. package/src/legacy/PrecacheRoute.ts +0 -48
  217. package/src/legacy/Router.ts +0 -484
  218. package/src/legacy/addPlugins.ts +0 -21
  219. package/src/legacy/addRoute.ts +0 -27
  220. package/src/legacy/constants.ts +0 -22
  221. package/src/legacy/createHandlerBoundToURL.ts +0 -30
  222. package/src/legacy/fallbacks.ts +0 -94
  223. package/src/legacy/getCacheKeyForURL.ts +0 -32
  224. package/src/legacy/handlePrecaching.ts +0 -86
  225. package/src/legacy/initializeGoogleAnalytics.ts +0 -218
  226. package/src/legacy/installSerwist.ts +0 -170
  227. package/src/legacy/matchPrecache.ts +0 -27
  228. package/src/legacy/precache.ts +0 -33
  229. package/src/legacy/precacheAndRoute.ts +0 -27
  230. package/src/legacy/registerRoute.ts +0 -28
  231. package/src/legacy/registerRuntimeCaching.ts +0 -17
  232. package/src/legacy/setCatchHandler.ts +0 -21
  233. package/src/legacy/setDefaultHandler.ts +0 -24
  234. package/src/legacy/singletonPrecacheController.ts +0 -53
  235. package/src/legacy/singletonRouter.ts +0 -70
  236. package/src/legacy/unregisterRoute.ts +0 -13
  237. package/src/legacy/utils/getCacheKeyForURL.ts +0 -36
  238. package/src/utils/PrecacheCacheKeyPlugin.ts +0 -33
  239. package/src/utils/parsePrecacheOptions.ts +0 -47
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { NavigationRouteMatchOptions } from "./NavigationRoute.js";
2
2
  import { NavigationRoute } from "./NavigationRoute.js";
3
- import { PrecacheRoute } from "./PrecacheRoute.js";
4
3
  import { RegExpRoute } from "./RegExpRoute.js";
5
4
  import { Route } from "./Route.js";
6
5
  import { Serwist, type SerwistOptions } from "./Serwist.js";
@@ -8,118 +7,94 @@ import { cacheNames } from "./cacheNames.js";
8
7
  import type { HTTPMethod } from "./constants.js";
9
8
  import { copyResponse } from "./copyResponse.js";
10
9
  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
10
  import { disableNavigationPreload, enableNavigationPreload, isNavigationPreloadSupported } from "./navigationPreload.js";
45
11
  import { registerQuotaErrorCallback } from "./registerQuotaErrorCallback.js";
46
12
  import { setCacheNameDetails } from "./setCacheNameDetails.js";
47
13
 
14
+ // Background synchronizing
48
15
  export {
49
- // Core
50
- Serwist,
51
- cacheNames,
52
- copyResponse,
53
- disableDevLogs,
54
- disableNavigationPreload,
55
- enableNavigationPreload,
56
- isNavigationPreloadSupported,
57
- registerQuotaErrorCallback,
58
- setCacheNameDetails,
59
- // Caching strategies
60
- CacheFirst,
61
- CacheOnly,
62
- NetworkFirst,
63
- NetworkOnly,
64
- PrecacheStrategy,
65
- StaleWhileRevalidate,
66
- Strategy,
67
- StrategyHandler,
68
- // Routing
69
- NavigationRoute,
70
- PrecacheRoute,
71
- RegExpRoute,
72
- Route,
73
- // Background synchronizing
74
16
  BackgroundSyncPlugin,
75
17
  BackgroundSyncQueue,
76
18
  BackgroundSyncQueueStore,
77
19
  StorableRequest,
78
- // Broadcasting updates
20
+ type BackgroundSyncQueueOptions,
21
+ type BackgroundSyncQueueEntry,
22
+ } from "#lib/backgroundSync/index.js";
23
+
24
+ // Broadcasting updates
25
+ export {
79
26
  BroadcastCacheUpdate,
80
27
  BroadcastUpdatePlugin,
81
28
  BROADCAST_UPDATE_DEFAULT_HEADERS,
82
29
  responsesAreSame,
83
- // Setting cacheability criteria
30
+ type BroadcastCacheUpdateOptions,
31
+ type BroadcastPayload,
32
+ type BroadcastPayloadGenerator,
33
+ type BroadcastMessage,
34
+ } from "#lib/broadcastUpdate/index.js";
35
+
36
+ // Setting cacheability criteria
37
+ export {
84
38
  CacheableResponse,
85
39
  CacheableResponsePlugin,
86
- // Expiring outdated responses
40
+ type CacheableResponseOptions,
41
+ } from "#lib/cacheableResponse/index.js";
42
+
43
+ // Controllers
44
+ export { PrecacheStrategy, PrecacheRoute, RuntimeCacheController } from "#lib/controllers/index.js";
45
+
46
+ // Expiring outdated responses
47
+ export {
87
48
  CacheExpiration,
88
49
  ExpirationPlugin,
89
- // Precaching
50
+ type ExpirationPluginOptions,
51
+ } from "#lib/expiration/index.js";
52
+
53
+ // Google Analytics
54
+ export { initializeGoogleAnalytics, type GoogleAnalyticsInitializeOptions } from "#lib/googleAnalytics/index.js";
55
+
56
+ // Precaching
57
+ export {
90
58
  PrecacheFallbackPlugin,
91
- // Google Analytics
92
- initializeGoogleAnalytics,
93
- // Handling range requests
59
+ type PrecacheFallbackEntry,
60
+ type PrecacheFallbackPluginOptions,
61
+ } from "#lib/precaching/index.js";
62
+
63
+ // Handling range requests
64
+ export {
94
65
  createPartialResponse,
95
66
  RangeRequestsPlugin,
96
- };
97
- export type {
98
- // Core
99
- HTTPMethod,
100
- SerwistOptions,
101
- // Caching strategies
102
- NetworkFirstOptions,
103
- NetworkOnlyOptions,
104
- StrategyOptions,
67
+ } from "#lib/rangeRequests/index.js";
68
+
69
+ // Built-in caching strategies
70
+ export {
71
+ CacheFirst,
72
+ CacheOnly,
73
+ NetworkFirst,
74
+ NetworkOnly,
75
+ StaleWhileRevalidate,
76
+ Strategy,
77
+ StrategyHandler,
78
+ type NetworkFirstOptions,
79
+ type NetworkOnlyOptions,
80
+ type StrategyOptions,
81
+ } from "#lib/strategies/index.js";
82
+
83
+ // Core
84
+ export {
85
+ Serwist,
86
+ cacheNames,
87
+ copyResponse,
88
+ disableDevLogs,
89
+ disableNavigationPreload,
90
+ enableNavigationPreload,
91
+ isNavigationPreloadSupported,
92
+ registerQuotaErrorCallback,
93
+ setCacheNameDetails,
105
94
  // 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,
95
+ NavigationRoute,
96
+ RegExpRoute,
97
+ Route,
124
98
  };
99
+ export type { HTTPMethod, SerwistOptions, NavigationRouteMatchOptions };
125
100
  export type * from "./types.js";
@@ -6,7 +6,7 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { FetchDidFailCallbackParam, SerwistPlugin } from "../../types.js";
9
+ import type { FetchDidFailCallbackParam, StrategyPlugin } from "../../types.js";
10
10
  import type { BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
11
11
  import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
12
12
 
@@ -14,7 +14,7 @@ import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
14
14
  * A class implementing the `fetchDidFail` lifecycle callback. This makes it
15
15
  * easier to add failed requests to a {@linkcode BackgroundSyncQueue}.
16
16
  */
17
- export class BackgroundSyncPlugin implements SerwistPlugin {
17
+ export class BackgroundSyncPlugin implements StrategyPlugin {
18
18
  private readonly _queue: BackgroundSyncQueue;
19
19
 
20
20
  /**
@@ -1,4 +1,3 @@
1
- import { SerwistError } from "../../utils/SerwistError.js";
2
1
  /*
3
2
  Copyright 2018 Google LLC
4
3
 
@@ -6,9 +5,10 @@ import { SerwistError } from "../../utils/SerwistError.js";
6
5
  license that can be found in the LICENSE file or at
7
6
  https://opensource.org/licenses/MIT.
8
7
  */
9
- import { assert } from "../../utils/assert.js";
10
- import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
11
- import { logger } from "../../utils/logger.js";
8
+ import { SerwistError } from "#utils/SerwistError.js";
9
+ import { assert } from "#utils/assert.js";
10
+ import { getFriendlyURL } from "#utils/getFriendlyURL.js";
11
+ import { logger } from "#utils/logger.js";
12
12
  import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
13
13
  import { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
14
14
  import { StorableRequest } from "./StorableRequest.js";
@@ -5,7 +5,7 @@
5
5
  license that can be found in the LICENSE file or at
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
- import { assert } from "../../utils/assert.js";
8
+ import { assert } from "#utils/assert.js";
9
9
  import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
10
10
  import { BackgroundSyncQueueDb } from "./BackgroundSyncQueueDb.js";
11
11
 
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
+ import { assert } from "#utils/assert.js";
9
10
  import type { MapLikeObject } from "../../types.js";
10
- import { assert } from "../../utils/assert.js";
11
11
 
12
12
  type SerializableProperties = "method" | "referrer" | "referrerPolicy" | "mode" | "credentials" | "cache" | "redirect" | "integrity" | "keepalive";
13
13
 
@@ -0,0 +1,5 @@
1
+ export { BackgroundSyncPlugin } from "./BackgroundSyncPlugin.js";
2
+ export type { BackgroundSyncQueueEntry, BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
3
+ export { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
4
+ export { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
5
+ export { StorableRequest } from "./StorableRequest.js";
@@ -6,11 +6,11 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
+ import { assert } from "#utils/assert.js";
10
+ import { logger } from "#utils/logger.js";
11
+ import { resultingClientExists } from "#utils/resultingClientExists.js";
12
+ import { timeout } from "#utils/timeout.js";
9
13
  import type { CacheDidUpdateCallbackParam } from "../../types.js";
10
- import { assert } from "../../utils/assert.js";
11
- import { logger } from "../../utils/logger.js";
12
- import { resultingClientExists } from "../../utils/resultingClientExists.js";
13
- import { timeout } from "../../utils/timeout.js";
14
14
  import {
15
15
  BROADCAST_UPDATE_DEFAULT_HEADERS,
16
16
  BROADCAST_UPDATE_DEFAULT_NOTIFY,
@@ -6,7 +6,7 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { CacheDidUpdateCallbackParam, SerwistPlugin } from "../../types.js";
9
+ import type { CacheDidUpdateCallbackParam, StrategyPlugin } from "../../types.js";
10
10
  import { BroadcastCacheUpdate } from "./BroadcastCacheUpdate.js";
11
11
  import type { BroadcastCacheUpdateOptions } from "./types.js";
12
12
 
@@ -14,7 +14,7 @@ import type { BroadcastCacheUpdateOptions } from "./types.js";
14
14
  * A class implementing the `cacheDidUpdate` lifecycle callback. It will automatically
15
15
  * broadcast a message whenever a cached response is updated.
16
16
  */
17
- export class BroadcastUpdatePlugin implements SerwistPlugin {
17
+ export class BroadcastUpdatePlugin implements StrategyPlugin {
18
18
  private readonly _broadcastUpdate: BroadcastCacheUpdate;
19
19
 
20
20
  /**
@@ -0,0 +1,5 @@
1
+ export { BroadcastCacheUpdate } from "./BroadcastCacheUpdate.js";
2
+ export { BroadcastUpdatePlugin } from "./BroadcastUpdatePlugin.js";
3
+ export { BROADCAST_UPDATE_DEFAULT_HEADERS } from "./constants.js";
4
+ export { responsesAreSame } from "./responsesAreSame.js";
5
+ export type { BroadcastCacheUpdateOptions, BroadcastMessage, BroadcastPayload, BroadcastPayloadGenerator } from "./types.js";
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
- import { logger } from "../../utils/logger.js";
9
+ import { SerwistError } from "#utils/SerwistError.js";
10
+ import { logger } from "#utils/logger.js";
11
11
 
12
12
  /**
13
13
  * Given two responses, compares several header values to see if they are
@@ -6,10 +6,10 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
- import { assert } from "../../utils/assert.js";
11
- import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
12
- import { logger } from "../../utils/logger.js";
9
+ import { SerwistError } from "#utils/SerwistError.js";
10
+ import { assert } from "#utils/assert.js";
11
+ import { getFriendlyURL } from "#utils/getFriendlyURL.js";
12
+ import { logger } from "#utils/logger.js";
13
13
 
14
14
  export interface CacheableResponseOptions {
15
15
  /**
@@ -6,7 +6,7 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { SerwistPlugin } from "../../types.js";
9
+ import type { StrategyPlugin } from "../../types.js";
10
10
  import type { CacheableResponseOptions } from "./CacheableResponse.js";
11
11
  import { CacheableResponse } from "./CacheableResponse.js";
12
12
 
@@ -15,7 +15,7 @@ import { CacheableResponse } from "./CacheableResponse.js";
15
15
  * easier to add in cacheability checks to requests made via Serwist's built-in
16
16
  * strategies.
17
17
  */
18
- export class CacheableResponsePlugin implements SerwistPlugin {
18
+ export class CacheableResponsePlugin implements StrategyPlugin {
19
19
  private readonly _cacheableResponse: CacheableResponse;
20
20
 
21
21
  /**
@@ -36,7 +36,7 @@ export class CacheableResponsePlugin implements SerwistPlugin {
36
36
  * @returns
37
37
  * @private
38
38
  */
39
- cacheWillUpdate: SerwistPlugin["cacheWillUpdate"] = async ({ response }) => {
39
+ cacheWillUpdate: StrategyPlugin["cacheWillUpdate"] = async ({ response }) => {
40
40
  if (this._cacheableResponse.isResponseCacheable(response)) {
41
41
  return response;
42
42
  }
@@ -0,0 +1,3 @@
1
+ export { CacheableResponse } from "./CacheableResponse.js";
2
+ export type { CacheableResponseOptions } from "./CacheableResponse.js";
3
+ export { CacheableResponsePlugin } from "./CacheableResponsePlugin.js";
@@ -5,9 +5,8 @@
5
5
  license that can be found in the LICENSE file or at
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
-
9
- import type { SerwistPlugin, SerwistPluginCallbackParam } from "../../types.js";
10
- import type { PrecacheController } from "../PrecacheController.js";
8
+ import type { StrategyPlugin, StrategyPluginCallbackParam } from "../../../types.js";
9
+ import type { PrecacheController } from "./PrecacheController.js";
11
10
 
12
11
  /**
13
12
  * A plugin, designed to be used with PrecacheController, to translate URLs into
@@ -15,17 +14,17 @@ import type { PrecacheController } from "../PrecacheController.js";
15
14
  *
16
15
  * @private
17
16
  */
18
- export class PrecacheCacheKeyPlugin implements SerwistPlugin {
17
+ export class PrecacheCacheKeyPlugin implements StrategyPlugin {
19
18
  private readonly _precacheController: PrecacheController;
20
19
 
21
20
  constructor({ precacheController }: { precacheController: PrecacheController }) {
22
21
  this._precacheController = precacheController;
23
22
  }
24
23
 
25
- cacheKeyWillBeUsed: SerwistPlugin["cacheKeyWillBeUsed"] = async ({ request, params }: SerwistPluginCallbackParam["cacheKeyWillBeUsed"]) => {
24
+ cacheKeyWillBeUsed: StrategyPlugin["cacheKeyWillBeUsed"] = async ({ request, params }: StrategyPluginCallbackParam["cacheKeyWillBeUsed"]) => {
26
25
  // Params is type any, can't change right now.
27
26
  /* eslint-disable */
28
- const cacheKey = params?.cacheKey || this._precacheController.getCacheKeyForURL(request.url);
27
+ const cacheKey = params?.cacheKey || this._precacheController.getPrecacheKeyForUrl(request.url);
29
28
  /* eslint-enable */
30
29
 
31
30
  return cacheKey ? new Request(cacheKey, { headers: request.headers }) : request;