@serwist/core 8.4.4 → 9.0.0-preview.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 (117) hide show
  1. package/dist/_private/Deferred.d.ts +1 -0
  2. package/dist/_private/Deferred.d.ts.map +1 -0
  3. package/dist/_private/SerwistError.d.ts +1 -0
  4. package/dist/_private/SerwistError.d.ts.map +1 -0
  5. package/dist/_private/assert.d.ts +1 -0
  6. package/dist/_private/assert.d.ts.map +1 -0
  7. package/dist/_private/cacheMatchIgnoreParams.d.ts +1 -0
  8. package/dist/_private/cacheMatchIgnoreParams.d.ts.map +1 -0
  9. package/dist/_private/cacheNames.d.ts +1 -0
  10. package/dist/_private/cacheNames.d.ts.map +1 -0
  11. package/dist/_private/canConstructReadableStream.d.ts +1 -0
  12. package/dist/_private/canConstructReadableStream.d.ts.map +1 -0
  13. package/dist/_private/canConstructResponseFromBodyStream.d.ts +1 -0
  14. package/dist/_private/canConstructResponseFromBodyStream.d.ts.map +1 -0
  15. package/dist/_private/dontWaitFor.d.ts +1 -0
  16. package/dist/_private/dontWaitFor.d.ts.map +1 -0
  17. package/dist/_private/executeQuotaErrorCallbacks.d.ts +1 -0
  18. package/dist/_private/executeQuotaErrorCallbacks.d.ts.map +1 -0
  19. package/dist/_private/getFriendlyURL.d.ts +1 -0
  20. package/dist/_private/getFriendlyURL.d.ts.map +1 -0
  21. package/dist/_private/logger.d.ts +1 -0
  22. package/dist/_private/logger.d.ts.map +1 -0
  23. package/dist/_private/resultingClientExists.d.ts +1 -0
  24. package/dist/_private/resultingClientExists.d.ts.map +1 -0
  25. package/dist/_private/timeout.d.ts +1 -0
  26. package/dist/_private/timeout.d.ts.map +1 -0
  27. package/dist/_private/waitUntil.d.ts +1 -0
  28. package/dist/_private/waitUntil.d.ts.map +1 -0
  29. package/dist/cacheNames.d.ts +1 -0
  30. package/dist/cacheNames.d.ts.map +1 -0
  31. package/dist/{quotaErrorCallbacks.js → chunks/quotaErrorCallbacks.js} +9 -77
  32. package/dist/clientsClaim.d.ts +1 -0
  33. package/dist/clientsClaim.d.ts.map +1 -0
  34. package/dist/copyResponse.d.ts +1 -0
  35. package/dist/copyResponse.d.ts.map +1 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.internal.d.ts +1 -0
  39. package/dist/index.internal.d.ts.map +1 -0
  40. package/dist/index.internal.js +14 -123
  41. package/dist/index.js +5 -60
  42. package/dist/models/messages/messageGenerator.d.ts +1 -0
  43. package/dist/models/messages/messageGenerator.d.ts.map +1 -0
  44. package/dist/models/messages/messages.d.ts +1 -0
  45. package/dist/models/messages/messages.d.ts.map +1 -0
  46. package/dist/models/pluginEvents.d.ts +1 -0
  47. package/dist/models/pluginEvents.d.ts.map +1 -0
  48. package/dist/models/quotaErrorCallbacks.d.ts +1 -0
  49. package/dist/models/quotaErrorCallbacks.d.ts.map +1 -0
  50. package/dist/registerQuotaErrorCallback.d.ts +1 -0
  51. package/dist/registerQuotaErrorCallback.d.ts.map +1 -0
  52. package/dist/setCacheNameDetails.d.ts +1 -0
  53. package/dist/setCacheNameDetails.d.ts.map +1 -0
  54. package/dist/types.d.ts +1 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/utils/pluginUtils.d.ts +1 -0
  57. package/dist/utils/pluginUtils.d.ts.map +1 -0
  58. package/dist/utils/welcome.d.ts +1 -0
  59. package/dist/utils/welcome.d.ts.map +1 -0
  60. package/package.json +18 -22
  61. package/src/_private/Deferred.ts +33 -0
  62. package/src/_private/SerwistError.ts +42 -0
  63. package/src/_private/assert.ts +89 -0
  64. package/src/_private/cacheMatchIgnoreParams.ts +54 -0
  65. package/src/_private/cacheNames.ts +87 -0
  66. package/src/_private/canConstructReadableStream.ts +34 -0
  67. package/src/_private/canConstructResponseFromBodyStream.ts +37 -0
  68. package/src/_private/dontWaitFor.ts +16 -0
  69. package/src/_private/executeQuotaErrorCallbacks.ts +35 -0
  70. package/src/_private/getFriendlyURL.ts +16 -0
  71. package/src/_private/logger.ts +92 -0
  72. package/src/_private/resultingClientExists.ts +58 -0
  73. package/src/_private/timeout.ts +19 -0
  74. package/src/_private/waitUntil.ts +23 -0
  75. package/src/cacheNames.ts +41 -0
  76. package/src/clientsClaim.ts +20 -0
  77. package/src/copyResponse.ts +62 -0
  78. package/{dist/index.internal.d.cts → src/index.internal.ts} +19 -1
  79. package/{dist/index.d.cts → src/index.ts} +9 -0
  80. package/src/models/messages/messageGenerator.ts +28 -0
  81. package/src/models/messages/messages.ts +231 -0
  82. package/src/models/pluginEvents.ts +17 -0
  83. package/src/models/quotaErrorCallbacks.ts +13 -0
  84. package/src/registerQuotaErrorCallback.ts +36 -0
  85. package/src/setCacheNameDetails.ts +55 -0
  86. package/src/types.ts +315 -0
  87. package/src/utils/pluginUtils.ts +15 -0
  88. package/src/utils/welcome.ts +25 -0
  89. package/dist/_private/Deferred.d.cts +0 -18
  90. package/dist/_private/SerwistError.d.cts +0 -23
  91. package/dist/_private/assert.d.cts +0 -10
  92. package/dist/_private/cacheMatchIgnoreParams.d.cts +0 -14
  93. package/dist/_private/cacheNames.d.cts +0 -39
  94. package/dist/_private/canConstructReadableStream.d.cts +0 -11
  95. package/dist/_private/canConstructResponseFromBodyStream.d.cts +0 -10
  96. package/dist/_private/dontWaitFor.d.cts +0 -6
  97. package/dist/_private/executeQuotaErrorCallbacks.d.cts +0 -8
  98. package/dist/_private/getFriendlyURL.d.cts +0 -2
  99. package/dist/_private/logger.d.cts +0 -10
  100. package/dist/_private/resultingClientExists.d.cts +0 -11
  101. package/dist/_private/timeout.d.cts +0 -9
  102. package/dist/_private/waitUntil.d.cts +0 -11
  103. package/dist/cacheNames.d.cts +0 -20
  104. package/dist/clientsClaim.d.cts +0 -6
  105. package/dist/copyResponse.d.cts +0 -20
  106. package/dist/index.cjs +0 -153
  107. package/dist/index.internal.cjs +0 -243
  108. package/dist/models/messages/messageGenerator.d.cts +0 -1
  109. package/dist/models/messages/messages.d.cts +0 -8
  110. package/dist/models/pluginEvents.d.cts +0 -9
  111. package/dist/models/quotaErrorCallbacks.d.cts +0 -2
  112. package/dist/quotaErrorCallbacks.cjs +0 -432
  113. package/dist/registerQuotaErrorCallback.d.cts +0 -8
  114. package/dist/setCacheNameDetails.d.cts +0 -9
  115. package/dist/types.d.cts +0 -272
  116. package/dist/utils/pluginUtils.d.cts +0 -4
  117. package/dist/utils/welcome.d.cts +0 -1
@@ -16,3 +16,4 @@ declare class Deferred<T> {
16
16
  constructor();
17
17
  }
18
18
  export { Deferred };
19
+ //# sourceMappingURL=Deferred.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Deferred.d.ts","sourceRoot":"","sources":["../../src/_private/Deferred.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,cAAM,QAAQ,CAAC,CAAC;IACd,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAG,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAEhC;;OAEG;;CAOJ;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -21,3 +21,4 @@ declare class SerwistError extends Error {
21
21
  constructor(errorCode: string, details?: MapLikeObject);
22
22
  }
23
23
  export { SerwistError };
24
+ //# sourceMappingURL=SerwistError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SerwistError.d.ts","sourceRoot":"","sources":["../../src/_private/SerwistError.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;GAQG;AACH,cAAM,YAAa,SAAQ,KAAK;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;;;;OAOG;gBACS,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;CAQvD;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -8,3 +8,4 @@ declare const finalAssertExports: {
8
8
  isArrayOfClass: (value: any, expectedClass: Function, details: MapLikeObject) => void;
9
9
  } | null;
10
10
  export { finalAssertExports as assert };
11
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/_private/assert.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAmEjD,QAAA,MAAM,kBAAkB;wBArDG,aAAa,kBAAkB,MAAM,WAAW,aAAa;qBANhE,GAAG,EAAE,WAAW,aAAa;yBAuB3C,OAAO,iBAEA,QAAQ,WACd,aAAa;qBAQA,GAAG,eAAe,GAAG,EAAE,WAAW,aAAa;qBApB/C,OAAO,gBAAgB,MAAM,WAAW,aAAa;4BA4BpE,GAAG,iBAEK,QAAQ,WACd,aAAa;QAwBjB,CAAC;AAER,OAAO,EAAE,kBAAkB,IAAI,MAAM,EAAE,CAAC"}
@@ -12,3 +12,4 @@
12
12
  */
13
13
  declare function cacheMatchIgnoreParams(cache: Cache, request: Request, ignoreParams: string[], matchOptions?: CacheQueryOptions): Promise<Response | undefined>;
14
14
  export { cacheMatchIgnoreParams };
15
+ //# sourceMappingURL=cacheMatchIgnoreParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheMatchIgnoreParams.d.ts","sourceRoot":"","sources":["../../src/_private/cacheMatchIgnoreParams.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,iBAAe,sBAAsB,CACnC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,CAAC,EAAE,iBAAiB,GAC/B,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAmB/B;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -37,3 +37,4 @@ export declare const cacheNames: {
37
37
  getRuntimeName: (userCacheName?: string) => string;
38
38
  getSuffix: () => string;
39
39
  };
40
+ //# sourceMappingURL=cacheNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheNames.d.ts","sourceRoot":"","sources":["../../src/_private/cacheNames.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAoBpG,eAAO,MAAM,UAAU;6BACI,uBAAuB,KAAG,IAAI;6CAQd,MAAM,KAAG,MAAM;sCAGtB,MAAM,KAAG,MAAM;qBAGlC,MAAM;qCAGY,MAAM,KAAG,MAAM;qBAGjC,MAAM;CAGtB,CAAC"}
@@ -9,3 +9,4 @@
9
9
  */
10
10
  declare function canConstructReadableStream(): boolean;
11
11
  export { canConstructReadableStream };
12
+ //# sourceMappingURL=canConstructReadableStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canConstructReadableStream.d.ts","sourceRoot":"","sources":["../../src/_private/canConstructReadableStream.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,iBAAS,0BAA0B,IAAI,OAAO,CAY7C;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -8,3 +8,4 @@
8
8
  */
9
9
  declare function canConstructResponseFromBodyStream(): boolean;
10
10
  export { canConstructResponseFromBodyStream };
11
+ //# sourceMappingURL=canConstructResponseFromBodyStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canConstructResponseFromBodyStream.d.ts","sourceRoot":"","sources":["../../src/_private/canConstructResponseFromBodyStream.ts"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,iBAAS,kCAAkC,IAAI,OAAO,CAgBrD;AAED,OAAO,EAAE,kCAAkC,EAAE,CAAC"}
@@ -4,3 +4,4 @@
4
4
  * @private
5
5
  **/
6
6
  export declare function dontWaitFor(promise: Promise<any>): void;
7
+ //# sourceMappingURL=dontWaitFor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dontWaitFor.d.ts","sourceRoot":"","sources":["../../src/_private/dontWaitFor.ts"],"names":[],"mappings":"AAOA;;;;IAII;AACJ,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAGvD"}
@@ -6,3 +6,4 @@
6
6
  */
7
7
  declare function executeQuotaErrorCallbacks(): Promise<void>;
8
8
  export { executeQuotaErrorCallbacks };
9
+ //# sourceMappingURL=executeQuotaErrorCallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeQuotaErrorCallbacks.d.ts","sourceRoot":"","sources":["../../src/_private/executeQuotaErrorCallbacks.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,iBAAe,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAezD;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,2 +1,3 @@
1
1
  declare const getFriendlyURL: (url: URL | string) => string;
2
2
  export { getFriendlyURL };
3
+ //# sourceMappingURL=getFriendlyURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFriendlyURL.d.ts","sourceRoot":"","sources":["../../src/_private/getFriendlyURL.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,cAAc,QAAS,GAAG,GAAG,MAAM,KAAG,MAK3C,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -8,3 +8,4 @@ declare global {
8
8
  }
9
9
  declare const logger: Console;
10
10
  export { logger };
11
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/_private/logger.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB,qBAAqB,EAAE,OAAO,CAAC;KAChC;IAED,UAAU,MAAM;QACd,qBAAqB,EAAE,OAAO,CAAC;KAChC;CACF;AAID,QAAA,MAAM,MAAM,SAqEA,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -9,3 +9,4 @@
9
9
  * @private
10
10
  */
11
11
  export declare function resultingClientExists(resultingClientId?: string): Promise<Client | undefined>;
12
+ //# sourceMappingURL=resultingClientExists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultingClientExists.d.ts","sourceRoot":"","sources":["../../src/_private/resultingClientExists.ts"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiCnG"}
@@ -7,3 +7,4 @@
7
7
  * @private
8
8
  */
9
9
  export declare function timeout(ms: number): Promise<unknown>;
10
+ //# sourceMappingURL=timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../src/_private/timeout.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AAEH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpD"}
@@ -9,3 +9,4 @@
9
9
  */
10
10
  declare function waitUntil(event: ExtendableEvent, asyncFn: () => Promise<any>): Promise<any>;
11
11
  export { waitUntil };
12
+ //# sourceMappingURL=waitUntil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../src/_private/waitUntil.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAIpF;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -18,3 +18,4 @@ declare const cacheNames: {
18
18
  readonly suffix: string;
19
19
  };
20
20
  export { cacheNames };
21
+ //# sourceMappingURL=cacheNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cacheNames.d.ts","sourceRoot":"","sources":["../src/cacheNames.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,UAAU;;;;;;CAgBf,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,10 +1,4 @@
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
- */ const _cacheNameDetails = {
1
+ const _cacheNameDetails = {
8
2
  googleAnalytics: "googleAnalytics",
9
3
  precache: "precache-v2",
10
4
  prefix: "serwist",
@@ -49,13 +43,7 @@ const cacheNames = {
49
43
  }
50
44
  };
51
45
 
52
- /*
53
- Copyright 2018 Google LLC
54
-
55
- Use of this source code is governed by an MIT-style
56
- license that can be found in the LICENSE file or at
57
- https://opensource.org/licenses/MIT.
58
- */ const messages = {
46
+ const messages = {
59
47
  "invalid-value": ({ paramName, validValueDescription, value })=>{
60
48
  if (!paramName || !validValueDescription) {
61
49
  throw new Error(`Unexpected input to 'invalid-value' error.`);
@@ -234,24 +222,9 @@ const generatorFunction = (code, details = {})=>{
234
222
  };
235
223
  const messageGenerator = process.env.NODE_ENV === "production" ? fallback : generatorFunction;
236
224
 
237
- /**
238
- * Serwist errors should be thrown with this class.
239
- * This allows use to ensure the type easily in tests,
240
- * helps developers identify errors from Serwist
241
- * easily and allows use to optimise error
242
- * messages correctly.
243
- *
244
- * @private
245
- */ class SerwistError extends Error {
225
+ class SerwistError extends Error {
246
226
  details;
247
- /**
248
- *
249
- * @param errorCode The error code that
250
- * identifies this particular error.
251
- * @param details Any relevant arguments
252
- * that will help developers identify issues should
253
- * be added as a key on the context object.
254
- */ constructor(errorCode, details){
227
+ constructor(errorCode, details){
255
228
  const message = messageGenerator(errorCode, details);
256
229
  super(message);
257
230
  this.name = errorCode;
@@ -259,21 +232,8 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
259
232
  }
260
233
  }
261
234
 
262
- /*
263
- Copyright 2019 Google LLC
264
-
265
- Use of this source code is governed by an MIT-style
266
- license that can be found in the LICENSE file or at
267
- https://opensource.org/licenses/MIT.
268
- */ let supportStatus;
269
- /**
270
- * A utility function that determines whether the current browser supports
271
- * constructing a new `Response` from a `response.body` stream.
272
- *
273
- * @returns `true`, if the current browser can successfully construct
274
- * a `Response` from a `response.body` stream, `false` otherwise.
275
- * @private
276
- */ function canConstructResponseFromBodyStream() {
235
+ let supportStatus;
236
+ function canConstructResponseFromBodyStream() {
277
237
  if (supportStatus === undefined) {
278
238
  const testResponse = new Response("");
279
239
  if ("body" in testResponse) {
@@ -289,12 +249,7 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
289
249
  return supportStatus;
290
250
  }
291
251
 
292
- /*
293
- * This method throws if the supplied value is not an array.
294
- * The destructed values are required to produce a meaningful error for users.
295
- * The destructed and restructured object is so it's clear what is
296
- * needed.
297
- */ const isArray = (value, details)=>{
252
+ const isArray = (value, details)=>{
298
253
  if (!Array.isArray(value)) {
299
254
  throw new SerwistError("not-an-array", details);
300
255
  }
@@ -307,14 +262,12 @@ const hasMethod = (object, expectedMethod, details)=>{
307
262
  }
308
263
  };
309
264
  const isType = (object, expectedType, details)=>{
310
- // biome-ignore lint/suspicious/useValidTypeof: Know to not make a mistake...
311
265
  if (typeof object !== expectedType) {
312
266
  details.expectedType = expectedType;
313
267
  throw new SerwistError("incorrect-type", details);
314
268
  }
315
269
  };
316
- const isInstance = (object, // biome-ignore lint/complexity/noBannedTypes: Need the general type to do the check later.
317
- expectedClass, details)=>{
270
+ const isInstance = (object, expectedClass, details)=>{
318
271
  if (!(object instanceof expectedClass)) {
319
272
  details.expectedClassName = expectedClass.name;
320
273
  throw new SerwistError("incorrect-class", details);
@@ -326,8 +279,7 @@ const isOneOf = (value, validValues, details)=>{
326
279
  throw new SerwistError("invalid-value", details);
327
280
  }
328
281
  };
329
- const isArrayOfClass = (value, // biome-ignore lint/complexity/noBannedTypes: Need general type to do check later.
330
- expectedClass, details)=>{
282
+ const isArrayOfClass = (value, expectedClass, details)=>{
331
283
  const error = new SerwistError("not-array-of-class", details);
332
284
  if (!Array.isArray(value)) {
333
285
  throw error;
@@ -347,15 +299,7 @@ const finalAssertExports = process.env.NODE_ENV === "production" ? null : {
347
299
  isArrayOfClass
348
300
  };
349
301
 
350
- /*
351
- Copyright 2019 Google LLC
352
- Use of this source code is governed by an MIT-style
353
- license that can be found in the LICENSE file or at
354
- https://opensource.org/licenses/MIT.
355
- */ // logger is used inside of both service workers and the window global scope.
356
302
  const logger = process.env.NODE_ENV === "production" ? null : (()=>{
357
- // Don't overwrite this value if it's already set.
358
- // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
359
303
  if (!("__WB_DISABLE_DEV_LOGS" in globalThis)) {
360
304
  self.__WB_DISABLE_DEV_LOGS = false;
361
305
  }
@@ -373,8 +317,6 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
373
317
  return;
374
318
  }
375
319
  if (method === "groupCollapsed") {
376
- // Safari doesn't print all console.groupCollapsed() arguments:
377
- // https://bugs.webkit.org/show_bug.cgi?id=182754
378
320
  if (typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
379
321
  console[method](...args);
380
322
  return;
@@ -387,7 +329,6 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
387
329
  "font-weight: bold",
388
330
  "padding: 2px 0.5em"
389
331
  ];
390
- // When in a group, the serwist prefix is not displayed.
391
332
  const logPrefix = inGroup ? [] : [
392
333
  "%cserwist",
393
334
  styles.join(";")
@@ -400,7 +341,6 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
400
341
  inGroup = false;
401
342
  }
402
343
  };
403
- // biome-ignore lint/complexity/noBannedTypes: Unknown reason
404
344
  const api = {};
405
345
  const loggerMethods = Object.keys(methodToColorMap);
406
346
  for (const key of loggerMethods){
@@ -412,14 +352,6 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
412
352
  return api;
413
353
  })();
414
354
 
415
- /*
416
- Copyright 2018 Google LLC
417
-
418
- Use of this source code is governed by an MIT-style
419
- license that can be found in the LICENSE file or at
420
- https://opensource.org/licenses/MIT.
421
- */ // Callbacks to be executed whenever there's a quota error.
422
- // biome-ignore lint/complexity/noBannedTypes: Can't change Function type right now.
423
355
  const quotaErrorCallbacks = new Set();
424
356
 
425
357
  export { SerwistError as S, canConstructResponseFromBodyStream as a, cacheNames as c, finalAssertExports as f, logger as l, quotaErrorCallbacks as q };
@@ -4,3 +4,4 @@
4
4
  */
5
5
  declare function clientsClaim(): void;
6
6
  export { clientsClaim };
7
+ //# sourceMappingURL=clientsClaim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientsClaim.d.ts","sourceRoot":"","sources":["../src/clientsClaim.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,iBAAS,YAAY,IAAI,IAAI,CAE5B;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -18,3 +18,4 @@
18
18
  */
19
19
  declare function copyResponse(response: Response, modifier?: (responseInit: ResponseInit) => ResponseInit): Promise<Response>;
20
20
  export { copyResponse };
21
+ //# sourceMappingURL=copyResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyResponse.d.ts","sourceRoot":"","sources":["../src/copyResponse.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAe,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8B1H;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ import { setCacheNameDetails } from "./setCacheNameDetails.js";
9
9
  */
10
10
  export { cacheNames, clientsClaim, copyResponse, registerQuotaErrorCallback, setCacheNameDetails };
11
11
  export * from "./types.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,CAAC;AAEnG,cAAc,YAAY,CAAC"}
@@ -13,3 +13,4 @@ import { resultingClientExists } from "./_private/resultingClientExists.js";
13
13
  import { timeout } from "./_private/timeout.js";
14
14
  import { waitUntil } from "./_private/waitUntil.js";
15
15
  export { assert, cacheMatchIgnoreParams, canConstructReadableStream, canConstructResponseFromBodyStream, Deferred, dontWaitFor, executeQuotaErrorCallbacks, getFriendlyURL, logger, privateCacheNames, resultingClientExists, SerwistError, timeout, waitUntil, };
16
+ //# sourceMappingURL=index.internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,kCAAkC,EAClC,QAAQ,EACR,WAAW,EACX,0BAA0B,EAC1B,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,SAAS,GACV,CAAC"}
@@ -1,26 +1,11 @@
1
- import { l as logger, q as quotaErrorCallbacks } from './quotaErrorCallbacks.js';
2
- export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream, c as privateCacheNames } from './quotaErrorCallbacks.js';
1
+ import { l as logger, q as quotaErrorCallbacks } from './chunks/quotaErrorCallbacks.js';
2
+ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream, c as privateCacheNames } from './chunks/quotaErrorCallbacks.js';
3
3
 
4
- /*
5
- Copyright 2018 Google LLC
6
-
7
- Use of this source code is governed by an MIT-style
8
- license that can be found in the LICENSE file or at
9
- https://opensource.org/licenses/MIT.
10
- */ /**
11
- * The Deferred class composes Promises in a way that allows for them to be
12
- * resolved or rejected from outside the constructor. In most cases promises
13
- * should be used directly, but Deferreds can be necessary when the logic to
14
- * resolve a promise must be separate.
15
- *
16
- * @private
17
- */ class Deferred {
4
+ class Deferred {
18
5
  promise;
19
6
  resolve;
20
7
  reject;
21
- /**
22
- * Creates a promise and exposes its resolve and reject functions as methods.
23
- */ constructor(){
8
+ constructor(){
24
9
  this.promise = new Promise((resolve, reject)=>{
25
10
  this.resolve = resolve;
26
11
  this.reject = reject;
@@ -28,36 +13,18 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
28
13
  }
29
14
  }
30
15
 
31
- /*
32
- Copyright 2020 Google LLC
33
- Use of this source code is governed by an MIT-style
34
- license that can be found in the LICENSE file or at
35
- https://opensource.org/licenses/MIT.
36
- */ function stripParams(fullURL, ignoreParams) {
16
+ function stripParams(fullURL, ignoreParams) {
37
17
  const strippedURL = new URL(fullURL);
38
18
  for (const param of ignoreParams){
39
19
  strippedURL.searchParams.delete(param);
40
20
  }
41
21
  return strippedURL.href;
42
22
  }
43
- /**
44
- * Matches an item in the cache, ignoring specific URL params. This is similar
45
- * to the `ignoreSearch` option, but it allows you to ignore just specific
46
- * params (while continuing to match on the others).
47
- *
48
- * @private
49
- * @param cache
50
- * @param request
51
- * @param matchOptions
52
- * @param ignoreParams
53
- * @returns
54
- */ async function cacheMatchIgnoreParams(cache, request, ignoreParams, matchOptions) {
23
+ async function cacheMatchIgnoreParams(cache, request, ignoreParams, matchOptions) {
55
24
  const strippedRequestURL = stripParams(request.url, ignoreParams);
56
- // If the request doesn't include any ignored params, match as normal.
57
25
  if (request.url === strippedRequestURL) {
58
26
  return cache.match(request, matchOptions);
59
27
  }
60
- // Otherwise, match by comparing keys
61
28
  const keysOptions = {
62
29
  ...matchOptions,
63
30
  ignoreSearch: true
@@ -72,24 +39,9 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
72
39
  return;
73
40
  }
74
41
 
75
- /*
76
- Copyright 2019 Google LLC
77
-
78
- Use of this source code is governed by an MIT-style
79
- license that can be found in the LICENSE file or at
80
- https://opensource.org/licenses/MIT.
81
- */ let supportStatus;
82
- /**
83
- * A utility function that determines whether the current browser supports
84
- * constructing a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
85
- * object.
86
- *
87
- * @returns `true`, if the current browser can successfully construct a `ReadableStream`, `false` otherwise.
88
- *
89
- * @private
90
- */ function canConstructReadableStream() {
42
+ let supportStatus;
43
+ function canConstructReadableStream() {
91
44
  if (supportStatus === undefined) {
92
- // See https://github.com/GoogleChrome/workbox/issues/1473
93
45
  try {
94
46
  new ReadableStream({
95
47
  start () {}
@@ -102,26 +54,11 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
102
54
  return supportStatus;
103
55
  }
104
56
 
105
- /*
106
- Copyright 2019 Google LLC
107
- Use of this source code is governed by an MIT-style
108
- license that can be found in the LICENSE file or at
109
- https://opensource.org/licenses/MIT.
110
- */ /**
111
- * A helper function that prevents a promise from being flagged as unused.
112
- *
113
- * @private
114
- **/ function dontWaitFor(promise) {
115
- // Effective no-op.
57
+ function dontWaitFor(promise) {
116
58
  void promise.then(()=>{});
117
59
  }
118
60
 
119
- /**
120
- * Runs all of the callback functions, one at a time sequentially, in the order
121
- * in which they were registered.
122
- *
123
- * @private
124
- */ async function executeQuotaErrorCallbacks() {
61
+ async function executeQuotaErrorCallbacks() {
125
62
  if (process.env.NODE_ENV !== "production") {
126
63
  logger.log(`About to run ${quotaErrorCallbacks.size} callbacks to clean up caches.`);
127
64
  }
@@ -136,46 +73,17 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
136
73
  }
137
74
  }
138
75
 
139
- /*
140
- Copyright 2018 Google LLC
141
-
142
- Use of this source code is governed by an MIT-style
143
- license that can be found in the LICENSE file or at
144
- https://opensource.org/licenses/MIT.
145
- */ const getFriendlyURL = (url)=>{
76
+ const getFriendlyURL = (url)=>{
146
77
  const urlObj = new URL(String(url), location.href);
147
- // See https://github.com/GoogleChrome/workbox/issues/2323
148
- // We want to include everything, except for the origin if it's same-origin.
149
78
  return urlObj.href.replace(new RegExp(`^${location.origin}`), "");
150
79
  };
151
80
 
152
- /*
153
- Copyright 2019 Google LLC
154
- Use of this source code is governed by an MIT-style
155
- license that can be found in the LICENSE file or at
156
- https://opensource.org/licenses/MIT.
157
- */ /**
158
- * Returns a promise that resolves and the passed number of milliseconds.
159
- * This utility is an async/await-friendly version of `setTimeout`.
160
- *
161
- * @param ms
162
- * @returns
163
- * @private
164
- */ function timeout(ms) {
81
+ function timeout(ms) {
165
82
  return new Promise((resolve)=>setTimeout(resolve, ms));
166
83
  }
167
84
 
168
85
  const MAX_RETRY_TIME = 2000;
169
- /**
170
- * Returns a promise that resolves to a window client matching the passed
171
- * `resultingClientId`. For browsers that don't support `resultingClientId`
172
- * or if waiting for the resulting client to apper takes too long, resolve to
173
- * `undefined`.
174
- *
175
- * @param resultingClientId
176
- * @returns
177
- * @private
178
- */ async function resultingClientExists(resultingClientId) {
86
+ async function resultingClientExists(resultingClientId) {
179
87
  if (!resultingClientId) {
180
88
  return;
181
89
  }
@@ -185,42 +93,25 @@ const MAX_RETRY_TIME = 2000;
185
93
  const existingWindowIds = new Set(existingWindows.map((w)=>w.id));
186
94
  let resultingWindow = undefined;
187
95
  const startTime = performance.now();
188
- // Only wait up to `MAX_RETRY_TIME` to find a matching client.
189
96
  while(performance.now() - startTime < MAX_RETRY_TIME){
190
97
  existingWindows = await self.clients.matchAll({
191
98
  type: "window"
192
99
  });
193
100
  resultingWindow = existingWindows.find((w)=>{
194
101
  if (resultingClientId) {
195
- // If we have a `resultingClientId`, we can match on that.
196
102
  return w.id === resultingClientId;
197
103
  }
198
- // Otherwise match on finding a window not in `existingWindowIds`.
199
104
  return !existingWindowIds.has(w.id);
200
105
  });
201
106
  if (resultingWindow) {
202
107
  break;
203
108
  }
204
- // Sleep for 100ms and retry.
205
109
  await timeout(100);
206
110
  }
207
111
  return resultingWindow;
208
112
  }
209
113
 
210
- /*
211
- Copyright 2020 Google LLC
212
- Use of this source code is governed by an MIT-style
213
- license that can be found in the LICENSE file or at
214
- https://opensource.org/licenses/MIT.
215
- */ /**
216
- * A utility method that makes it easier to use `event.waitUntil` with
217
- * async functions and return the result.
218
- *
219
- * @param event
220
- * @param asyncFn
221
- * @returns
222
- * @private
223
- */ function waitUntil(event, asyncFn) {
114
+ function waitUntil(event, asyncFn) {
224
115
  const returnPromise = asyncFn();
225
116
  event.waitUntil(returnPromise);
226
117
  return returnPromise;