serwist 9.2.3 → 9.3.1

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 (77) hide show
  1. package/dist/PrecacheRoute.d.ts.map +1 -1
  2. package/dist/RegExpRoute.d.ts +1 -1
  3. package/dist/RegExpRoute.d.ts.map +1 -1
  4. package/dist/Serwist.d.ts +2 -4
  5. package/dist/Serwist.d.ts.map +1 -1
  6. package/dist/chunks/printInstallDetails.js +1113 -1113
  7. package/dist/chunks/waitUntil.js +83 -83
  8. package/dist/index.d.ts +9 -9
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.internal.d.ts +2 -2
  11. package/dist/index.internal.d.ts.map +1 -1
  12. package/dist/index.internal.js +1 -1
  13. package/dist/index.js +1319 -1319
  14. package/dist/index.legacy.d.ts +5 -5
  15. package/dist/index.legacy.d.ts.map +1 -1
  16. package/dist/index.legacy.js +30 -31
  17. package/dist/legacy/PrecacheController.d.ts +1 -2
  18. package/dist/legacy/PrecacheController.d.ts.map +1 -1
  19. package/dist/legacy/PrecacheRoute.d.ts.map +1 -1
  20. package/dist/legacy/Router.d.ts +1 -1
  21. package/dist/legacy/Router.d.ts.map +1 -1
  22. package/dist/legacy/fallbacks.d.ts.map +1 -1
  23. package/dist/legacy/handlePrecaching.d.ts.map +1 -1
  24. package/dist/legacy/initializeGoogleAnalytics.d.ts.map +1 -1
  25. package/dist/legacy/installSerwist.d.ts +2 -2
  26. package/dist/legacy/installSerwist.d.ts.map +1 -1
  27. package/dist/legacy/registerRoute.d.ts +1 -1
  28. package/dist/legacy/registerRoute.d.ts.map +1 -1
  29. package/dist/legacy/registerRuntimeCaching.d.ts.map +1 -1
  30. package/dist/lib/googleAnalytics/initializeGoogleAnalytics.d.ts.map +1 -1
  31. package/dist/lib/strategies/NetworkFirst.d.ts.map +1 -1
  32. package/dist/lib/strategies/PrecacheStrategy.d.ts.map +1 -1
  33. package/dist/lib/strategies/StaleWhileRevalidate.d.ts.map +1 -1
  34. package/dist/lib/strategies/StrategyHandler.d.ts.map +1 -1
  35. package/dist/setCacheNameDetails.d.ts.map +1 -1
  36. package/dist/utils/createCacheKey.d.ts.map +1 -1
  37. package/dist/utils/parseRoute.d.ts +1 -1
  38. package/dist/utils/parseRoute.d.ts.map +1 -1
  39. package/package.json +4 -4
  40. package/src/PrecacheRoute.ts +1 -2
  41. package/src/RegExpRoute.ts +1 -1
  42. package/src/Serwist.ts +12 -10
  43. package/src/copyResponse.ts +1 -1
  44. package/src/index.internal.ts +2 -2
  45. package/src/index.legacy.ts +5 -5
  46. package/src/index.ts +9 -9
  47. package/src/legacy/PrecacheController.ts +3 -4
  48. package/src/legacy/PrecacheRoute.ts +1 -2
  49. package/src/legacy/Router.ts +2 -2
  50. package/src/legacy/fallbacks.ts +1 -3
  51. package/src/legacy/handlePrecaching.ts +1 -1
  52. package/src/legacy/initializeGoogleAnalytics.ts +2 -2
  53. package/src/legacy/installSerwist.ts +3 -3
  54. package/src/legacy/matchPrecache.ts +1 -1
  55. package/src/legacy/precache.ts +1 -1
  56. package/src/legacy/registerRoute.ts +4 -3
  57. package/src/legacy/registerRuntimeCaching.ts +1 -2
  58. package/src/lib/backgroundSync/BackgroundSyncQueue.ts +1 -1
  59. package/src/lib/broadcastUpdate/responsesAreSame.ts +1 -1
  60. package/src/lib/cacheableResponse/CacheableResponse.ts +1 -1
  61. package/src/lib/expiration/CacheExpiration.ts +1 -1
  62. package/src/lib/expiration/ExpirationPlugin.ts +2 -2
  63. package/src/lib/googleAnalytics/initializeGoogleAnalytics.ts +2 -2
  64. package/src/lib/rangeRequests/createPartialResponse.ts +1 -1
  65. package/src/lib/rangeRequests/utils/calculateEffectiveBoundaries.ts +1 -1
  66. package/src/lib/rangeRequests/utils/parseRangeHeader.ts +1 -1
  67. package/src/lib/strategies/CacheFirst.ts +1 -1
  68. package/src/lib/strategies/CacheOnly.ts +1 -1
  69. package/src/lib/strategies/NetworkFirst.ts +2 -2
  70. package/src/lib/strategies/NetworkOnly.ts +1 -1
  71. package/src/lib/strategies/PrecacheStrategy.ts +2 -2
  72. package/src/lib/strategies/StaleWhileRevalidate.ts +2 -2
  73. package/src/lib/strategies/Strategy.ts +1 -1
  74. package/src/lib/strategies/StrategyHandler.ts +3 -3
  75. package/src/setCacheNameDetails.ts +1 -1
  76. package/src/utils/createCacheKey.ts +1 -2
  77. package/src/utils/parseRoute.ts +2 -2
@@ -6,16 +6,15 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { Route } from "../Route.js";
10
9
  import { BackgroundSyncPlugin } from "../lib/backgroundSync/BackgroundSyncPlugin.js";
11
10
  import type { BackgroundSyncQueue, BackgroundSyncQueueEntry } from "../lib/backgroundSync/BackgroundSyncQueue.js";
12
11
  import { NetworkFirst } from "../lib/strategies/NetworkFirst.js";
13
12
  import { NetworkOnly } from "../lib/strategies/NetworkOnly.js";
13
+ import { Route } from "../Route.js";
14
14
  import type { RouteMatchCallbackOptions } from "../types.js";
15
15
  import { cacheNames as privateCacheNames } from "../utils/cacheNames.js";
16
16
  import { getFriendlyURL } from "../utils/getFriendlyURL.js";
17
17
  import { logger } from "../utils/logger.js";
18
- import type { Router } from "./Router.js";
19
18
  import {
20
19
  ANALYTICS_JS_PATH,
21
20
  COLLECT_PATHS_REGEX,
@@ -26,6 +25,7 @@ import {
26
25
  MAX_RETENTION_TIME,
27
26
  QUEUE_NAME,
28
27
  } from "./constants.js";
28
+ import type { Router } from "./Router.js";
29
29
  import { getSingletonRouter } from "./singletonRouter.js";
30
30
 
31
31
  /**
@@ -3,13 +3,13 @@ import { enableNavigationPreload } from "../navigationPreload.js";
3
3
  import { setCacheNameDetails } from "../setCacheNameDetails.js";
4
4
  import type { RuntimeCaching } from "../types.js";
5
5
  import { clientsClaim as clientsClaimImpl } from "../utils/clientsClaim.js";
6
- import type { PrecacheController } from "./PrecacheController.js";
7
- import type { Router } from "./Router.js";
8
6
  import type { FallbacksOptions } from "./fallbacks.js";
9
7
  import { fallbacks as fallbacksImpl } from "./fallbacks.js";
10
8
  import { type HandlePrecachingOptions, handlePrecaching } from "./handlePrecaching.js";
11
- import { initializeGoogleAnalytics } from "./initializeGoogleAnalytics.js";
12
9
  import type { GoogleAnalyticsInitializeOptions } from "./initializeGoogleAnalytics.js";
10
+ import { initializeGoogleAnalytics } from "./initializeGoogleAnalytics.js";
11
+ import type { PrecacheController } from "./PrecacheController.js";
12
+ import type { Router } from "./Router.js";
13
13
  import { registerRuntimeCaching } from "./registerRuntimeCaching.js";
14
14
  import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
15
15
  import { getSingletonRouter } from "./singletonRouter.js";
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
10
9
  import type { PrecacheController } from "./PrecacheController.js";
10
+ import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
11
11
 
12
12
  /**
13
13
  * Helper function that calls {@linkcode PrecacheController.matchPrecache}
@@ -7,9 +7,9 @@
7
7
  */
8
8
 
9
9
  import type { PrecacheEntry } from "../types.js";
10
- import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
11
10
  import type { addRoute } from "./addRoute.js";
12
11
  import type { precacheAndRoute } from "./precacheAndRoute.js";
12
+ import { getSingletonPrecacheController } from "./singletonPrecacheController.js";
13
13
 
14
14
  /**
15
15
  * Adds items to the precache list, removing any duplicates and
@@ -5,12 +5,13 @@
5
5
  license that can be found in the LICENSE file or at
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
- import type { Router } from "./Router.js";
9
- import type { Route } from "../Route.js";
8
+
10
9
  import type { HTTPMethod } from "../constants.js";
10
+ import type { Route } from "../Route.js";
11
11
  import type { RouteHandler, RouteMatchCallback } from "../types.js";
12
- import type { unregisterRoute } from "./unregisterRoute.js";
12
+ import type { Router } from "./Router.js";
13
13
  import { getSingletonRouter } from "./singletonRouter.js";
14
+ import type { unregisterRoute } from "./unregisterRoute.js";
14
15
 
15
16
  /**
16
17
  * Registers a `RegExp`, string, or function with a caching
@@ -1,6 +1,5 @@
1
- import { registerRoute } from "./registerRoute.js";
2
-
3
1
  import type { RuntimeCaching } from "../types.js";
2
+ import { registerRoute } from "./registerRoute.js";
4
3
 
5
4
  /**
6
5
  * Registers caching strategies to a singleton Router instance. It is a simple
@@ -1,4 +1,3 @@
1
- import { SerwistError } from "../../utils/SerwistError.js";
2
1
  /*
3
2
  Copyright 2018 Google LLC
4
3
 
@@ -9,6 +8,7 @@ import { SerwistError } from "../../utils/SerwistError.js";
9
8
  import { assert } from "../../utils/assert.js";
10
9
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import type { BackgroundSyncQueueStoreEntry, UnidentifiedQueueStoreEntry } from "./BackgroundSyncQueueDb.js";
13
13
  import { BackgroundSyncQueueStore } from "./BackgroundSyncQueueStore.js";
14
14
  import { StorableRequest } from "./StorableRequest.js";
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { logger } from "../../utils/logger.js";
10
+ import { SerwistError } from "../../utils/SerwistError.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
9
  import { assert } from "../../utils/assert.js";
11
10
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
12
11
  import { logger } from "../../utils/logger.js";
12
+ import { SerwistError } from "../../utils/SerwistError.js";
13
13
 
14
14
  export interface CacheableResponseOptions {
15
15
  /**
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { CacheTimestampsModel } from "./models/CacheTimestampsModel.js";
13
13
 
14
14
  interface CacheExpirationConfig {
@@ -8,13 +8,13 @@
8
8
 
9
9
  import { registerQuotaErrorCallback } from "../../registerQuotaErrorCallback.js";
10
10
  import type { CacheDidUpdateCallbackParam, CachedResponseWillBeUsedCallbackParam, SerwistPlugin } from "../../types.js";
11
- import { SerwistError } from "../../utils/SerwistError.js";
12
11
  import { assert } from "../../utils/assert.js";
13
12
  import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
14
13
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
15
14
  import { logger } from "../../utils/logger.js";
16
- import { CacheExpiration } from "./CacheExpiration.js";
15
+ import { SerwistError } from "../../utils/SerwistError.js";
17
16
  import type { Strategy } from "../strategies/Strategy.js";
17
+ import { CacheExpiration } from "./CacheExpiration.js";
18
18
 
19
19
  export interface ExpirationPluginOptions {
20
20
  /**
@@ -6,10 +6,10 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { Route } from "../../Route.js";
10
- import type { Serwist } from "../../Serwist.js";
11
9
  import { NetworkFirst } from "../../lib/strategies/NetworkFirst.js";
12
10
  import { NetworkOnly } from "../../lib/strategies/NetworkOnly.js";
11
+ import { Route } from "../../Route.js";
12
+ import type { Serwist } from "../../Serwist.js";
13
13
  import type { RouteMatchCallbackOptions } from "../../types.js";
14
14
  import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
15
15
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { calculateEffectiveBoundaries } from "./utils/calculateEffectiveBoundaries.js";
13
13
  import { parseRangeHeader } from "./utils/parseRangeHeader.js";
14
14
 
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../../utils/SerwistError.js";
10
9
  import { assert } from "../../../utils/assert.js";
10
+ import { SerwistError } from "../../../utils/SerwistError.js";
11
11
 
12
12
  /**
13
13
  * @param blob A source blob.
@@ -6,8 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../../utils/SerwistError.js";
10
9
  import { assert } from "../../../utils/assert.js";
10
+ import { SerwistError } from "../../../utils/SerwistError.js";
11
11
 
12
12
  /**
13
13
  * @param rangeHeader A `Range` header value.
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { Strategy } from "./Strategy.js";
13
13
  import type { StrategyHandler } from "./StrategyHandler.js";
14
14
  import { messages } from "./utils/messages.js";
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { Strategy } from "./Strategy.js";
13
13
  import type { StrategyHandler } from "./StrategyHandler.js";
14
14
  import { messages } from "./utils/messages.js";
@@ -6,13 +6,13 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
+ import { cacheOkAndOpaquePlugin } from "./plugins/cacheOkAndOpaquePlugin.js";
12
13
  import type { StrategyOptions } from "./Strategy.js";
13
14
  import { Strategy } from "./Strategy.js";
14
15
  import type { StrategyHandler } from "./StrategyHandler.js";
15
- import { cacheOkAndOpaquePlugin } from "./plugins/cacheOkAndOpaquePlugin.js";
16
16
  import { messages } from "./utils/messages.js";
17
17
 
18
18
  export interface NetworkFirstOptions extends StrategyOptions {
@@ -6,9 +6,9 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { timeout } from "../../utils/timeout.js";
13
13
  import type { StrategyOptions } from "./Strategy.js";
14
14
  import { Strategy } from "./Strategy.js";
@@ -7,12 +7,12 @@
7
7
  */
8
8
 
9
9
  import { copyResponse } from "../../copyResponse.js";
10
+ import type { Serwist } from "../../Serwist.js";
10
11
  import type { SerwistPlugin } from "../../types.js";
11
- import { SerwistError } from "../../utils/SerwistError.js";
12
12
  import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
13
13
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
14
14
  import { logger } from "../../utils/logger.js";
15
- import type { Serwist } from "../../Serwist.js";
15
+ import { SerwistError } from "../../utils/SerwistError.js";
16
16
  import type { StrategyOptions } from "./Strategy.js";
17
17
  import { Strategy } from "./Strategy.js";
18
18
  import type { StrategyHandler } from "./StrategyHandler.js";
@@ -6,13 +6,13 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "../../utils/SerwistError.js";
10
9
  import { assert } from "../../utils/assert.js";
11
10
  import { logger } from "../../utils/logger.js";
11
+ import { SerwistError } from "../../utils/SerwistError.js";
12
+ import { cacheOkAndOpaquePlugin } from "./plugins/cacheOkAndOpaquePlugin.js";
12
13
  import type { StrategyOptions } from "./Strategy.js";
13
14
  import { Strategy } from "./Strategy.js";
14
15
  import type { StrategyHandler } from "./StrategyHandler.js";
15
- import { cacheOkAndOpaquePlugin } from "./plugins/cacheOkAndOpaquePlugin.js";
16
16
  import { messages } from "./utils/messages.js";
17
17
 
18
18
  /**
@@ -7,10 +7,10 @@
7
7
  */
8
8
 
9
9
  import type { HandlerCallbackOptions, RouteHandlerObject, SerwistPlugin } from "../../types.js";
10
- import { SerwistError } from "../../utils/SerwistError.js";
11
10
  import { cacheNames as privateCacheNames } from "../../utils/cacheNames.js";
12
11
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
13
12
  import { logger } from "../../utils/logger.js";
13
+ import { SerwistError } from "../../utils/SerwistError.js";
14
14
  import { StrategyHandler } from "./StrategyHandler.js";
15
15
 
16
16
  export interface StrategyOptions {
@@ -6,17 +6,17 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
+ import type { Route } from "../../Route.js";
9
10
  import type { HandlerCallbackOptions, MapLikeObject, SerwistPlugin, SerwistPluginCallbackParam } from "../../types.js";
10
- import { Deferred } from "../../utils/Deferred.js";
11
- import { SerwistError } from "../../utils/SerwistError.js";
12
11
  import { assert } from "../../utils/assert.js";
13
12
  import { cacheMatchIgnoreParams } from "../../utils/cacheMatchIgnoreParams.js";
13
+ import { Deferred } from "../../utils/Deferred.js";
14
14
  import { executeQuotaErrorCallbacks } from "../../utils/executeQuotaErrorCallbacks.js";
15
15
  import { getFriendlyURL } from "../../utils/getFriendlyURL.js";
16
16
  import { logger } from "../../utils/logger.js";
17
+ import { SerwistError } from "../../utils/SerwistError.js";
17
18
  import { timeout } from "../../utils/timeout.js";
18
19
  import type { Strategy } from "./Strategy.js";
19
- import type { Route } from "../../Route.js";
20
20
 
21
21
  function toRequest(input: RequestInfo) {
22
22
  return typeof input === "string" ? new Request(input) : input;
@@ -6,10 +6,10 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "./utils/SerwistError.js";
10
9
  import { assert } from "./utils/assert.js";
11
10
  import type { PartialCacheNameDetails } from "./utils/cacheNames.js";
12
11
  import { cacheNames } from "./utils/cacheNames.js";
12
+ import { SerwistError } from "./utils/SerwistError.js";
13
13
 
14
14
  /**
15
15
  * Modifies the default cache names used by Serwist packages.
@@ -6,9 +6,8 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { SerwistError } from "./SerwistError.js";
10
-
11
9
  import type { PrecacheEntry } from "../types.js";
10
+ import { SerwistError } from "./SerwistError.js";
12
11
 
13
12
  interface CacheKey {
14
13
  cacheKey: string;
@@ -1,9 +1,9 @@
1
+ import type { HTTPMethod } from "../constants.js";
1
2
  import { RegExpRoute } from "../RegExpRoute.js";
2
3
  import { Route } from "../Route.js";
3
- import type { HTTPMethod } from "../constants.js";
4
4
  import type { RouteHandler, RouteMatchCallback } from "../types.js";
5
- import { SerwistError } from "./SerwistError.js";
6
5
  import { logger } from "./logger.js";
6
+ import { SerwistError } from "./SerwistError.js";
7
7
 
8
8
  /**
9
9
  * Parses a `RegExp`, string, or function with a caching strategy into a {@linkcode Route}. This is for