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
@@ -6,16 +6,16 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
+ import type { Route } from "../Route.js";
10
+ import type { HTTPMethod } from "../constants.js";
11
+ import { defaultMethod } from "../constants.js";
9
12
  import type { RouteHandler, RouteHandlerCallbackOptions, RouteHandlerObject, RouteMatchCallback, RouteMatchCallbackOptions } from "../types.js";
10
- import { assert } from "../utils/assert.js";
11
13
  import { SerwistError } from "../utils/SerwistError.js";
14
+ import { assert } from "../utils/assert.js";
12
15
  import { getFriendlyURL } from "../utils/getFriendlyURL.js";
13
16
  import { logger } from "../utils/logger.js";
14
- import type { Route } from "../Route.js";
15
- import type { HTTPMethod } from "../constants.js";
16
- import { defaultMethod } from "../constants.js";
17
- import { parseRoute } from "../parseRoute.js";
18
17
  import { normalizeHandler } from "../utils/normalizeHandler.js";
18
+ import { parseRoute } from "../utils/parseRoute.js";
19
19
 
20
20
  declare const self: ServiceWorkerGlobalScope;
21
21
 
@@ -1,12 +1,12 @@
1
- import { PrecacheFallbackPlugin } from "./PrecacheFallbackPlugin.js";
2
- import { Strategy } from "../strategies/Strategy.js";
1
+ import { Strategy } from "../lib/strategies/Strategy.js";
3
2
  import type { PrecacheRouteOptions, RuntimeCaching } from "../types.js";
4
3
  import type { PrecacheController } from "./PrecacheController.js";
4
+ import { PrecacheFallbackPlugin } from "./PrecacheFallbackPlugin.js";
5
+ import type { PrecacheFallbackEntry } from "./PrecacheFallbackPlugin.js";
5
6
  import { PrecacheRoute } from "./PrecacheRoute.js";
6
7
  import type { Router } from "./Router.js";
7
8
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
8
9
  import { getSingletonRouter } from "./singletonRouter.js";
9
- import type { PrecacheFallbackEntry } from "./PrecacheFallbackPlugin.js";
10
10
 
11
11
  export interface FallbackEntry extends PrecacheFallbackEntry {
12
12
  /**
@@ -1,6 +1,6 @@
1
1
  import { NavigationRoute } from "../NavigationRoute.js";
2
- import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "../cleanupOutdatedCaches.js";
3
2
  import type { PrecacheEntry, PrecacheRouteOptions } from "../types.js";
3
+ import { cleanupOutdatedCaches as cleanupOutdatedCachesImpl } from "../utils/cleanupOutdatedCaches.js";
4
4
  import type { PrecacheController } from "./PrecacheController.js";
5
5
  import { PrecacheRoute } from "./PrecacheRoute.js";
6
6
  import type { Router } from "./Router.js";
@@ -0,0 +1,218 @@
1
+ /*
2
+ Copyright 2018 Google LLC
3
+
4
+ Use of this source code is governed by an MIT-style
5
+ license that can be found in the LICENSE file or at
6
+ https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ import { Route } from "../Route.js";
10
+ import { BackgroundSyncPlugin } from "../lib/backgroundSync/BackgroundSyncPlugin.js";
11
+ import type { BackgroundSyncQueue, BackgroundSyncQueueEntry } from "../lib/backgroundSync/BackgroundSyncQueue.js";
12
+ import { NetworkFirst } from "../lib/strategies/NetworkFirst.js";
13
+ import { NetworkOnly } from "../lib/strategies/NetworkOnly.js";
14
+ import type { RouteMatchCallbackOptions } from "../types.js";
15
+ import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
16
+ import { getFriendlyURL } from "../utils/getFriendlyURL.js";
17
+ import { logger } from "../utils/logger.js";
18
+ import { Router } from "./Router.js";
19
+ import {
20
+ ANALYTICS_JS_PATH,
21
+ COLLECT_PATHS_REGEX,
22
+ GOOGLE_ANALYTICS_HOST,
23
+ GTAG_JS_PATH,
24
+ GTM_HOST,
25
+ GTM_JS_PATH,
26
+ MAX_RETENTION_TIME,
27
+ QUEUE_NAME,
28
+ } from "./constants.js";
29
+ import { getSingletonRouter } from "./singletonRouter.js";
30
+
31
+ /**
32
+ * @deprecated
33
+ */
34
+ export interface GoogleAnalyticsInitializeOptions {
35
+ /**
36
+ * An optional `Router` instance. If not provided, the singleton `Router`
37
+ * will be used.
38
+ */
39
+ router?: Router;
40
+ /**
41
+ * The cache name to store and retrieve analytics.js. Defaults to Serwist's default cache names.
42
+ */
43
+ cacheName?: string;
44
+ /**
45
+ * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
46
+ * expressed as key/value pairs, to be added to replayed Google Analytics
47
+ * requests. This can be used to, e.g., set a custom dimension indicating
48
+ * that the request was replayed.
49
+ */
50
+ parameterOverrides?: { [paramName: string]: string };
51
+ /**
52
+ * A function that allows you to modify the hit parameters prior to replaying
53
+ * the hit. The function is invoked with the original hit's URLSearchParams
54
+ * object as its only argument.
55
+ */
56
+ hitFilter?: (params: URLSearchParams) => void;
57
+ }
58
+
59
+ /**
60
+ * Creates the requestWillDequeue callback to be used with the background
61
+ * sync plugin. The callback takes the failed request and adds the
62
+ * `qt` param based on the current time, as well as applies any other
63
+ * user-defined hit modifications.
64
+ *
65
+ * @param config
66
+ * @returns The requestWillDequeue callback function.
67
+ * @private
68
+ */
69
+ const createOnSyncCallback = (config: Pick<GoogleAnalyticsInitializeOptions, "parameterOverrides" | "hitFilter">) => {
70
+ return async ({ queue }: { queue: BackgroundSyncQueue }) => {
71
+ let entry: BackgroundSyncQueueEntry | undefined = undefined;
72
+ while ((entry = await queue.shiftRequest())) {
73
+ const { request, timestamp } = entry;
74
+ const url = new URL(request.url);
75
+
76
+ try {
77
+ // Measurement protocol requests can set their payload parameters in
78
+ // either the URL query string (for GET requests) or the POST body.
79
+ const params = request.method === "POST" ? new URLSearchParams(await request.clone().text()) : url.searchParams;
80
+
81
+ // Calculate the qt param, accounting for the fact that an existing
82
+ // qt param may be present and should be updated rather than replaced.
83
+ const originalHitTime = timestamp! - (Number(params.get("qt")) || 0);
84
+ const queueTime = Date.now() - originalHitTime;
85
+
86
+ // Set the qt param prior to applying hitFilter or parameterOverrides.
87
+ params.set("qt", String(queueTime));
88
+
89
+ // Apply `parameterOverrides`, if set.
90
+ if (config.parameterOverrides) {
91
+ for (const param of Object.keys(config.parameterOverrides)) {
92
+ const value = config.parameterOverrides[param];
93
+ params.set(param, value);
94
+ }
95
+ }
96
+
97
+ // Apply `hitFilter`, if set.
98
+ if (typeof config.hitFilter === "function") {
99
+ config.hitFilter.call(null, params);
100
+ }
101
+
102
+ // Retry the fetch. Ignore URL search params from the URL as they're
103
+ // now in the post body.
104
+ await fetch(
105
+ new Request(url.origin + url.pathname, {
106
+ body: params.toString(),
107
+ method: "POST",
108
+ mode: "cors",
109
+ credentials: "omit",
110
+ headers: { "Content-Type": "text/plain" },
111
+ }),
112
+ );
113
+
114
+ if (process.env.NODE_ENV !== "production") {
115
+ logger.log(`Request for '${getFriendlyURL(url.href)}' has been replayed`);
116
+ }
117
+ } catch (err) {
118
+ await queue.unshiftRequest(entry);
119
+
120
+ if (process.env.NODE_ENV !== "production") {
121
+ logger.log(`Request for '${getFriendlyURL(url.href)}' failed to replay, putting it back in the queue.`);
122
+ }
123
+ throw err;
124
+ }
125
+ }
126
+ if (process.env.NODE_ENV !== "production") {
127
+ logger.log("All Google Analytics request successfully replayed; " + "the queue is now empty!");
128
+ }
129
+ };
130
+ };
131
+
132
+ /**
133
+ * Creates GET and POST routes to catch failed Measurement Protocol hits.
134
+ *
135
+ * @param bgSyncPlugin
136
+ * @returns The created routes.
137
+ * @private
138
+ */
139
+ const createCollectRoutes = (bgSyncPlugin: BackgroundSyncPlugin) => {
140
+ const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
141
+
142
+ const handler = new NetworkOnly({
143
+ plugins: [bgSyncPlugin],
144
+ });
145
+
146
+ return [new Route(match, handler, "GET"), new Route(match, handler, "POST")];
147
+ };
148
+
149
+ /**
150
+ * Creates a route with a network first strategy for the analytics.js script.
151
+ *
152
+ * @param cacheName
153
+ * @returns The created route.
154
+ * @private
155
+ */
156
+ const createAnalyticsJsRoute = (cacheName: string) => {
157
+ const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
158
+
159
+ const handler = new NetworkFirst({ cacheName });
160
+
161
+ return new Route(match, handler, "GET");
162
+ };
163
+
164
+ /**
165
+ * Creates a route with a network first strategy for the gtag.js script.
166
+ *
167
+ * @param cacheName
168
+ * @returns The created route.
169
+ * @private
170
+ */
171
+ const createGtagJsRoute = (cacheName: string) => {
172
+ const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
173
+
174
+ const handler = new NetworkFirst({ cacheName });
175
+
176
+ return new Route(match, handler, "GET");
177
+ };
178
+
179
+ /**
180
+ * Creates a route with a network first strategy for the gtm.js script.
181
+ *
182
+ * @param cacheName
183
+ * @returns The created route.
184
+ * @private
185
+ */
186
+ const createGtmJsRoute = (cacheName: string) => {
187
+ const match = ({ url }: RouteMatchCallbackOptions) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
188
+
189
+ const handler = new NetworkFirst({ cacheName });
190
+
191
+ return new Route(match, handler, "GET");
192
+ };
193
+
194
+ /**
195
+ * Initialize Serwist's offline Google Analytics v3 support.
196
+ *
197
+ * @param options
198
+ * @deprecated Use `serwist.initializeGoogleAnalytics` instead.
199
+ */
200
+ export const initializeGoogleAnalytics = ({ router = getSingletonRouter(), cacheName, ...options }: GoogleAnalyticsInitializeOptions = {}): void => {
201
+ const resolvedCacheName = privateCacheNames.getGoogleAnalyticsName(cacheName);
202
+
203
+ const bgSyncPlugin = new BackgroundSyncPlugin(QUEUE_NAME, {
204
+ maxRetentionTime: MAX_RETENTION_TIME,
205
+ onSync: createOnSyncCallback(options),
206
+ });
207
+
208
+ const routes = [
209
+ createGtmJsRoute(resolvedCacheName),
210
+ createAnalyticsJsRoute(resolvedCacheName),
211
+ createGtagJsRoute(resolvedCacheName),
212
+ ...createCollectRoutes(bgSyncPlugin),
213
+ ];
214
+
215
+ for (const route of routes) {
216
+ router.registerRoute(route);
217
+ }
218
+ };
@@ -1,11 +1,88 @@
1
- import { Serwist, type SerwistOptions } from "../Serwist.js";
1
+ import { disableDevLogs as disableDevLogsImpl } from "../disableDevLogs.js";
2
+ import { enableNavigationPreload } from "../navigationPreload.js";
3
+ import { setCacheNameDetails } from "../setCacheNameDetails.js";
4
+ import type { RuntimeCaching } from "../types.js";
5
+ import { clientsClaim as clientsClaimImpl } from "../utils/clientsClaim.js";
6
+ import type { PrecacheController } from "./PrecacheController.js";
7
+ import type { Router } from "./Router.js";
8
+ import type { FallbacksOptions } from "./fallbacks.js";
9
+ import { fallbacks as fallbacksImpl } from "./fallbacks.js";
10
+ import { type HandlePrecachingOptions, handlePrecaching } from "./handlePrecaching.js";
11
+ import { initializeGoogleAnalytics } from "./initializeGoogleAnalytics.js";
12
+ import type { GoogleAnalyticsInitializeOptions } from "./initializeGoogleAnalytics.js";
13
+ import { registerRuntimeCaching } from "./registerRuntimeCaching.js";
14
+ import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
15
+ import { getSingletonRouter } from "./singletonRouter.js";
16
+
17
+ declare const self: ServiceWorkerGlobalScope;
2
18
 
3
19
  /**
4
20
  * Options for `installSerwist`.
5
21
  *
6
22
  * @deprecated
7
23
  */
8
- export type InstallSerwistOptions = SerwistOptions;
24
+ export interface InstallSerwistOptions extends Omit<HandlePrecachingOptions, "precacheController" | "router"> {
25
+ /**
26
+ * An optional `PrecacheController` instance. If not provided, the singleton
27
+ * `PrecacheController` will be used.
28
+ */
29
+ precacheController?: PrecacheController;
30
+ /**
31
+ * An optional `Router` instance. If not provided, the singleton `Router`
32
+ * will be used.
33
+ */
34
+ router?: Router;
35
+ /**
36
+ * Forces the waiting service worker to become the active one.
37
+ *
38
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/skipWaiting
39
+ */
40
+ skipWaiting?: boolean;
41
+ /**
42
+ * Imports external scripts. They are executed in the order they
43
+ * are passed.
44
+ *
45
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
46
+ */
47
+ importScripts?: string[];
48
+ /**
49
+ * Enables navigation preloading if it is supported.
50
+ *
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/navigationPreload
52
+ */
53
+ navigationPreload?: boolean;
54
+ /**
55
+ * Modifies the prefix of the default cache names used by Serwist packages.
56
+ */
57
+ cacheId?: string | undefined;
58
+ /**
59
+ * Claims any currently available clients once the service worker
60
+ * becomes active. This is normally used in conjunction with `skipWaiting()`.
61
+ *
62
+ * @default false
63
+ */
64
+ clientsClaim?: boolean;
65
+ /**
66
+ * A list of caching strategies.
67
+ */
68
+ runtimeCaching?: RuntimeCaching[];
69
+ /**
70
+ * Your configuration for `@serwist/google-analytics`. This plugin is
71
+ * only initialized when this option is not `undefined` or `false`.
72
+ */
73
+ offlineAnalyticsConfig?: GoogleAnalyticsInitializeOptions | boolean;
74
+ /**
75
+ * Disables Serwist's logging in development mode.
76
+ *
77
+ * @default false
78
+ */
79
+ disableDevLogs?: boolean;
80
+ /**
81
+ * Precaches routes so that they can be used as a fallback when
82
+ * a Strategy fails to generate a response.
83
+ */
84
+ fallbacks?: Pick<FallbacksOptions, "entries">;
85
+ }
9
86
 
10
87
  /**
11
88
  * Abstracts away the core APIs of Serwist.
@@ -13,7 +90,81 @@ export type InstallSerwistOptions = SerwistOptions;
13
90
  * @param options - `installSerwist` options.
14
91
  * @deprecated
15
92
  */
16
- export const installSerwist = (options: InstallSerwistOptions): void => {
17
- const serwist = new Serwist(options);
18
- serwist.addEventListeners();
93
+ export const installSerwist = ({
94
+ precacheController = getSingletonPrecacheController(),
95
+ router = getSingletonRouter(),
96
+ precacheEntries,
97
+ precacheOptions,
98
+ cleanupOutdatedCaches,
99
+ navigateFallback,
100
+ navigateFallbackAllowlist,
101
+ navigateFallbackDenylist,
102
+ skipWaiting,
103
+ importScripts,
104
+ navigationPreload = false,
105
+ cacheId,
106
+ clientsClaim = false,
107
+ runtimeCaching,
108
+ offlineAnalyticsConfig,
109
+ disableDevLogs = false,
110
+ fallbacks,
111
+ }: InstallSerwistOptions): void => {
112
+ if (!!importScripts && importScripts.length > 0) self.importScripts(...importScripts);
113
+
114
+ if (navigationPreload) enableNavigationPreload();
115
+
116
+ if (cacheId !== undefined) {
117
+ setCacheNameDetails({
118
+ prefix: cacheId,
119
+ });
120
+ }
121
+
122
+ if (skipWaiting) {
123
+ self.skipWaiting();
124
+ } else {
125
+ self.addEventListener("message", (event) => {
126
+ if (event.data && event.data.type === "SKIP_WAITING") {
127
+ self.skipWaiting();
128
+ }
129
+ });
130
+ }
131
+
132
+ if (clientsClaim) clientsClaimImpl();
133
+
134
+ handlePrecaching({
135
+ precacheController,
136
+ router,
137
+ precacheEntries,
138
+ precacheOptions,
139
+ cleanupOutdatedCaches,
140
+ navigateFallback,
141
+ navigateFallbackAllowlist,
142
+ navigateFallbackDenylist,
143
+ });
144
+
145
+ if (runtimeCaching !== undefined) {
146
+ if (fallbacks !== undefined) {
147
+ runtimeCaching = fallbacksImpl({
148
+ precacheController,
149
+ router,
150
+ runtimeCaching,
151
+ entries: fallbacks.entries,
152
+ precacheOptions,
153
+ });
154
+ }
155
+ registerRuntimeCaching(...runtimeCaching);
156
+ }
157
+
158
+ if (offlineAnalyticsConfig !== undefined) {
159
+ if (typeof offlineAnalyticsConfig === "boolean") {
160
+ offlineAnalyticsConfig && initializeGoogleAnalytics({ router });
161
+ } else {
162
+ initializeGoogleAnalytics({
163
+ ...offlineAnalyticsConfig,
164
+ router,
165
+ });
166
+ }
167
+ }
168
+
169
+ if (disableDevLogs) disableDevLogsImpl();
19
170
  };
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteHandler, RouteMatchCallback } from "../types.js";
10
9
  import type { Route } from "../Route.js";
11
10
  import type { HTTPMethod } from "../constants.js";
11
+ import type { RouteHandler, RouteMatchCallback } from "../types.js";
12
12
  import { getSingletonRouter } from "./singletonRouter.js";
13
13
 
14
14
  /**
@@ -7,25 +7,25 @@
7
7
  */
8
8
 
9
9
  import type { FetchDidFailCallbackParam, SerwistPlugin } from "../../types.js";
10
- import type { QueueOptions } from "./Queue.js";
11
- import { Queue } from "./Queue.js";
10
+ import type { BackgroundSyncQueueOptions } from "./BackgroundSyncQueue.js";
11
+ import { BackgroundSyncQueue } from "./BackgroundSyncQueue.js";
12
12
 
13
13
  /**
14
14
  * A class implementing the `fetchDidFail` lifecycle callback. This makes it
15
15
  * easier to add failed requests to a background sync Queue.
16
16
  */
17
17
  export class BackgroundSyncPlugin implements SerwistPlugin {
18
- private readonly _queue: Queue;
18
+ private readonly _queue: BackgroundSyncQueue;
19
19
 
20
20
  /**
21
21
  * @param name See the `serwist/plugins.BackgroundSyncQueue`
22
22
  * documentation for parameter details.
23
23
  * @param options See the `serwist/plugins.BackgroundSyncQueue`
24
24
  * documentation for parameter details.
25
- * @see https://serwist.pages.dev/docs/background-sync/queue
25
+ * @see https://serwist.pages.dev/docs/core/background-sync-queue
26
26
  */
27
- constructor(name: string, options?: QueueOptions) {
28
- this._queue = new Queue(name, options);
27
+ constructor(name: string, options?: BackgroundSyncQueueOptions) {
28
+ this._queue = new BackgroundSyncQueue(name, options);
29
29
  }
30
30
 
31
31
  /**
@@ -1,3 +1,4 @@
1
+ import { SerwistError } from "../../utils/SerwistError.js";
1
2
  /*
2
3
  Copyright 2018 Google LLC
3
4
 
@@ -6,23 +7,43 @@
6
7
  https://opensource.org/licenses/MIT.
7
8
  */
8
9
  import { assert } from "../../utils/assert.js";
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
10
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
11
11
  import { logger } from "../../utils/logger.js";
12
- import type { QueueStoreEntry, UnidentifiedQueueStoreEntry } from "./QueueDb.js";
13
- import { QueueStore } from "./QueueStore.js";
12
+ import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
13
+ import { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
14
14
  import { StorableRequest } from "./StorableRequest.js";
15
15
 
16
+ // See https://github.com/GoogleChrome/workbox/issues/2946
17
+ interface SyncManager {
18
+ getTags(): Promise<string[]>;
19
+ register(tag: string): Promise<void>;
20
+ }
21
+
22
+ declare global {
23
+ interface ServiceWorkerRegistration {
24
+ readonly sync: SyncManager;
25
+ }
26
+
27
+ interface SyncEvent extends ExtendableEvent {
28
+ readonly lastChance: boolean;
29
+ readonly tag: string;
30
+ }
31
+
32
+ interface ServiceWorkerGlobalScopeEventMap {
33
+ sync: SyncEvent;
34
+ }
35
+ }
36
+
16
37
  // Give TypeScript the correct global.
17
- declare let self: ServiceWorkerGlobalScope;
38
+ declare const self: ServiceWorkerGlobalScope;
18
39
 
19
40
  interface OnSyncCallbackOptions {
20
- queue: Queue;
41
+ queue: BackgroundSyncQueue;
21
42
  }
22
43
 
23
44
  type OnSyncCallback = (options: OnSyncCallbackOptions) => void | Promise<void>;
24
45
 
25
- export interface QueueOptions {
46
+ export interface BackgroundSyncQueueOptions {
26
47
  /**
27
48
  * If `true`, instead of attempting to use background sync events, always attempt
28
49
  * to replay queued request at service worker startup. Most folks will not need
@@ -50,7 +71,7 @@ export interface QueueOptions {
50
71
  onSync?: OnSyncCallback;
51
72
  }
52
73
 
53
- export interface QueueEntry {
74
+ export interface BackgroundSyncQueueEntry {
54
75
  /**
55
76
  * The request to store in the queue.
56
77
  */
@@ -85,8 +106,8 @@ const queueNames = new Set<string>();
85
106
  * @returns
86
107
  * @private
87
108
  */
88
- const convertEntry = (queueStoreEntry: UnidentifiedQueueStoreEntry): QueueEntry => {
89
- const queueEntry: QueueEntry = {
109
+ const convertEntry = (queueStoreEntry: UnidentifiedQueueStoreEntry): BackgroundSyncQueueEntry => {
110
+ const queueEntry: BackgroundSyncQueueEntry = {
90
111
  request: new StorableRequest(queueStoreEntry.requestData).toRequest(),
91
112
  timestamp: queueStoreEntry.timestamp,
92
113
  };
@@ -101,11 +122,11 @@ const convertEntry = (queueStoreEntry: UnidentifiedQueueStoreEntry): QueueEntry
101
122
  * later. All parts of the storing and replaying process are observable via
102
123
  * callbacks.
103
124
  */
104
- export class Queue {
125
+ export class BackgroundSyncQueue {
105
126
  private readonly _name: string;
106
127
  private readonly _onSync: OnSyncCallback;
107
128
  private readonly _maxRetentionTime: number;
108
- private readonly _queueStore: QueueStore;
129
+ private readonly _queueStore: BackgroundSyncQueueStore;
109
130
  private readonly _forceSyncFallback: boolean;
110
131
  private _syncInProgress = false;
111
132
  private _requestsAddedDuringSync = false;
@@ -119,7 +140,7 @@ export class Queue {
119
140
  * a duplicate name is detected.
120
141
  * @param options
121
142
  */
122
- constructor(name: string, { forceSyncFallback, onSync, maxRetentionTime }: QueueOptions = {}) {
143
+ constructor(name: string, { forceSyncFallback, onSync, maxRetentionTime }: BackgroundSyncQueueOptions = {}) {
123
144
  // Ensure the store name is not already being used
124
145
  if (queueNames.has(name)) {
125
146
  throw new SerwistError("duplicate-queue-name", { name });
@@ -130,7 +151,7 @@ export class Queue {
130
151
  this._onSync = onSync || this.replayRequests;
131
152
  this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;
132
153
  this._forceSyncFallback = Boolean(forceSyncFallback);
133
- this._queueStore = new QueueStore(this._name);
154
+ this._queueStore = new BackgroundSyncQueueStore(this._name);
134
155
 
135
156
  this._addSyncListener();
136
157
  }
@@ -148,16 +169,16 @@ export class Queue {
148
169
  *
149
170
  * @param entry
150
171
  */
151
- async pushRequest(entry: QueueEntry): Promise<void> {
172
+ async pushRequest(entry: BackgroundSyncQueueEntry): Promise<void> {
152
173
  if (process.env.NODE_ENV !== "production") {
153
174
  assert!.isType(entry, "object", {
154
- moduleName: "serwist/plugins",
175
+ moduleName: "serwist",
155
176
  className: "BackgroundSyncQueue",
156
177
  funcName: "pushRequest",
157
178
  paramName: "entry",
158
179
  });
159
180
  assert!.isInstance(entry.request, Request, {
160
- moduleName: "serwist/plugins",
181
+ moduleName: "serwist",
161
182
  className: "BackgroundSyncQueue",
162
183
  funcName: "pushRequest",
163
184
  paramName: "entry.request",
@@ -173,16 +194,16 @@ export class Queue {
173
194
  *
174
195
  * @param entry
175
196
  */
176
- async unshiftRequest(entry: QueueEntry): Promise<void> {
197
+ async unshiftRequest(entry: BackgroundSyncQueueEntry): Promise<void> {
177
198
  if (process.env.NODE_ENV !== "production") {
178
199
  assert!.isType(entry, "object", {
179
- moduleName: "serwist/plugins",
200
+ moduleName: "serwist",
180
201
  className: "BackgroundSyncQueue",
181
202
  funcName: "unshiftRequest",
182
203
  paramName: "entry",
183
204
  });
184
205
  assert!.isInstance(entry.request, Request, {
185
- moduleName: "serwist/plugins",
206
+ moduleName: "serwist",
186
207
  className: "BackgroundSyncQueue",
187
208
  funcName: "unshiftRequest",
188
209
  paramName: "entry.request",
@@ -198,7 +219,7 @@ export class Queue {
198
219
  *
199
220
  * @returns
200
221
  */
201
- async popRequest(): Promise<QueueEntry | undefined> {
222
+ async popRequest(): Promise<BackgroundSyncQueueEntry | undefined> {
202
223
  return this._removeRequest("pop");
203
224
  }
204
225
 
@@ -208,7 +229,7 @@ export class Queue {
208
229
  *
209
230
  * @returns
210
231
  */
211
- async shiftRequest(): Promise<QueueEntry | undefined> {
232
+ async shiftRequest(): Promise<BackgroundSyncQueueEntry | undefined> {
212
233
  return this._removeRequest("shift");
213
234
  }
214
235
 
@@ -218,7 +239,7 @@ export class Queue {
218
239
  *
219
240
  * @returns
220
241
  */
221
- async getAll(): Promise<QueueEntry[]> {
242
+ async getAll(): Promise<BackgroundSyncQueueEntry[]> {
222
243
  const allEntries = await this._queueStore.getAll();
223
244
  const now = Date.now();
224
245
 
@@ -254,7 +275,7 @@ export class Queue {
254
275
  * @param operation
255
276
  * @private
256
277
  */
257
- async _addRequest({ request, metadata, timestamp = Date.now() }: QueueEntry, operation: "push" | "unshift"): Promise<void> {
278
+ async _addRequest({ request, metadata, timestamp = Date.now() }: BackgroundSyncQueueEntry, operation: "push" | "unshift"): Promise<void> {
258
279
  const storableRequest = await StorableRequest.fromRequest(request.clone());
259
280
  const entry: UnidentifiedQueueStoreEntry = {
260
281
  requestData: storableRequest.toObject(),
@@ -297,9 +318,9 @@ export class Queue {
297
318
  * @returns
298
319
  * @private
299
320
  */
300
- async _removeRequest(operation: "pop" | "shift"): Promise<QueueEntry | undefined> {
321
+ async _removeRequest(operation: "pop" | "shift"): Promise<BackgroundSyncQueueEntry | undefined> {
301
322
  const now = Date.now();
302
- let entry: QueueStoreEntry | undefined;
323
+ let entry: BackgroundSyncQueueStoreEntry | undefined;
303
324
  switch (operation) {
304
325
  case "pop":
305
326
  entry = await this._queueStore.popEntry();
@@ -329,7 +350,7 @@ export class Queue {
329
350
  * the queue (which registers a retry for the next sync event).
330
351
  */
331
352
  async replayRequests(): Promise<void> {
332
- let entry: QueueEntry | undefined = undefined;
353
+ let entry: BackgroundSyncQueueEntry | undefined = undefined;
333
354
  while ((entry = await this.shiftRequest())) {
334
355
  try {
335
356
  await fetch(entry.request.clone());