@serwist/core 8.3.0 → 8.4.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.
package/dist/index.cjs CHANGED
@@ -95,8 +95,7 @@ var quotaErrorCallbacks = require('./quotaErrorCallbacks.cjs');
95
95
  * there's a quota error.
96
96
  *
97
97
  * @param callback
98
- */ // Can't change Function type
99
- // eslint-disable-next-line @typescript-eslint/ban-types
98
+ */ // biome-ignore lint/complexity/noBannedTypes: Can't change Function type
100
99
  function registerQuotaErrorCallback(callback) {
101
100
  if (process.env.NODE_ENV !== "production") {
102
101
  quotaErrorCallbacks.finalAssertExports.isType(callback, "function", {
@@ -118,29 +117,29 @@ function registerQuotaErrorCallback(callback) {
118
117
  * @param details
119
118
  */ function setCacheNameDetails(details) {
120
119
  if (process.env.NODE_ENV !== "production") {
121
- Object.keys(details).forEach((key)=>{
120
+ for (const key of Object.keys(details)){
122
121
  quotaErrorCallbacks.finalAssertExports.isType(details[key], "string", {
123
122
  moduleName: "@serwist/core",
124
123
  funcName: "setCacheNameDetails",
125
124
  paramName: `details.${key}`
126
125
  });
127
- });
128
- if (details["precache"]?.length === 0) {
126
+ }
127
+ if (details.precache?.length === 0) {
129
128
  throw new quotaErrorCallbacks.SerwistError("invalid-cache-name", {
130
129
  cacheNameId: "precache",
131
- value: details["precache"]
130
+ value: details.precache
132
131
  });
133
132
  }
134
- if (details["runtime"]?.length === 0) {
133
+ if (details.runtime?.length === 0) {
135
134
  throw new quotaErrorCallbacks.SerwistError("invalid-cache-name", {
136
135
  cacheNameId: "runtime",
137
- value: details["runtime"]
136
+ value: details.runtime
138
137
  });
139
138
  }
140
- if (details["googleAnalytics"]?.length === 0) {
139
+ if (details.googleAnalytics?.length === 0) {
141
140
  throw new quotaErrorCallbacks.SerwistError("invalid-cache-name", {
142
141
  cacheNameId: "googleAnalytics",
143
- value: details["googleAnalytics"]
142
+ value: details.googleAnalytics
144
143
  });
145
144
  }
146
145
  }
@@ -2,6 +2,33 @@
2
2
 
3
3
  var quotaErrorCallbacks = require('./quotaErrorCallbacks.cjs');
4
4
 
5
+ /*
6
+ Copyright 2018 Google LLC
7
+
8
+ Use of this source code is governed by an MIT-style
9
+ license that can be found in the LICENSE file or at
10
+ https://opensource.org/licenses/MIT.
11
+ */ /**
12
+ * The Deferred class composes Promises in a way that allows for them to be
13
+ * resolved or rejected from outside the constructor. In most cases promises
14
+ * should be used directly, but Deferreds can be necessary when the logic to
15
+ * resolve a promise must be separate.
16
+ *
17
+ * @private
18
+ */ class Deferred {
19
+ promise;
20
+ resolve;
21
+ reject;
22
+ /**
23
+ * Creates a promise and exposes its resolve and reject functions as methods.
24
+ */ constructor(){
25
+ this.promise = new Promise((resolve, reject)=>{
26
+ this.resolve = resolve;
27
+ this.reject = reject;
28
+ });
29
+ }
30
+ }
31
+
5
32
  /*
6
33
  Copyright 2020 Google LLC
7
34
  Use of this source code is governed by an MIT-style
@@ -76,33 +103,6 @@ var quotaErrorCallbacks = require('./quotaErrorCallbacks.cjs');
76
103
  return supportStatus;
77
104
  }
78
105
 
79
- /*
80
- Copyright 2018 Google LLC
81
-
82
- Use of this source code is governed by an MIT-style
83
- license that can be found in the LICENSE file or at
84
- https://opensource.org/licenses/MIT.
85
- */ /**
86
- * The Deferred class composes Promises in a way that allows for them to be
87
- * resolved or rejected from outside the constructor. In most cases promises
88
- * should be used directly, but Deferreds can be necessary when the logic to
89
- * resolve a promise must be separate.
90
- *
91
- * @private
92
- */ class Deferred {
93
- promise;
94
- resolve;
95
- reject;
96
- /**
97
- * Creates a promise and exposes its resolve and reject functions as methods.
98
- */ constructor(){
99
- this.promise = new Promise((resolve, reject)=>{
100
- this.resolve = resolve;
101
- this.reject = reject;
102
- });
103
- }
104
- }
105
-
106
106
  /*
107
107
  Copyright 2019 Google LLC
108
108
  Use of this source code is governed by an MIT-style
@@ -124,7 +124,7 @@ var quotaErrorCallbacks = require('./quotaErrorCallbacks.cjs');
124
124
  * @private
125
125
  */ async function executeQuotaErrorCallbacks() {
126
126
  if (process.env.NODE_ENV !== "production") {
127
- quotaErrorCallbacks.logger.log(`About to run ${quotaErrorCallbacks.quotaErrorCallbacks.size} ` + `callbacks to clean up caches.`);
127
+ quotaErrorCallbacks.logger.log(`About to run ${quotaErrorCallbacks.quotaErrorCallbacks.size} callbacks to clean up caches.`);
128
128
  }
129
129
  for (const callback of quotaErrorCallbacks.quotaErrorCallbacks){
130
130
  await callback();
@@ -184,7 +184,7 @@ const MAX_RETRY_TIME = 2000;
184
184
  type: "window"
185
185
  });
186
186
  const existingWindowIds = new Set(existingWindows.map((w)=>w.id));
187
- let resultingWindow;
187
+ let resultingWindow = undefined;
188
188
  const startTime = performance.now();
189
189
  // Only wait up to `MAX_RETRY_TIME` to find a matching client.
190
190
  while(performance.now() - startTime < MAX_RETRY_TIME){
@@ -195,10 +195,9 @@ const MAX_RETRY_TIME = 2000;
195
195
  if (resultingClientId) {
196
196
  // If we have a `resultingClientId`, we can match on that.
197
197
  return w.id === resultingClientId;
198
- } else {
199
- // Otherwise match on finding a window not in `existingWindowIds`.
200
- return !existingWindowIds.has(w.id);
201
198
  }
199
+ // Otherwise match on finding a window not in `existingWindowIds`.
200
+ return !existingWindowIds.has(w.id);
202
201
  });
203
202
  if (resultingWindow) {
204
203
  break;
@@ -1,15 +1,15 @@
1
+ import { Deferred } from "./_private/Deferred.js";
2
+ import { SerwistError } from "./_private/SerwistError.js";
1
3
  import { assert } from "./_private/assert.js";
2
4
  import { cacheMatchIgnoreParams } from "./_private/cacheMatchIgnoreParams.js";
3
5
  import { cacheNames as privateCacheNames } from "./_private/cacheNames.js";
4
6
  import { canConstructReadableStream } from "./_private/canConstructReadableStream.js";
5
7
  import { canConstructResponseFromBodyStream } from "./_private/canConstructResponseFromBodyStream.js";
6
- import { Deferred } from "./_private/Deferred.js";
7
8
  import { dontWaitFor } from "./_private/dontWaitFor.js";
8
9
  import { executeQuotaErrorCallbacks } from "./_private/executeQuotaErrorCallbacks.js";
9
10
  import { getFriendlyURL } from "./_private/getFriendlyURL.js";
10
11
  import { logger } from "./_private/logger.js";
11
12
  import { resultingClientExists } from "./_private/resultingClientExists.js";
12
- import { SerwistError } from "./_private/SerwistError.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, };
@@ -1,6 +1,33 @@
1
1
  import { l as logger, q as quotaErrorCallbacks } from './quotaErrorCallbacks.js';
2
2
  export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream, c as privateCacheNames } from './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 {
18
+ promise;
19
+ resolve;
20
+ reject;
21
+ /**
22
+ * Creates a promise and exposes its resolve and reject functions as methods.
23
+ */ constructor(){
24
+ this.promise = new Promise((resolve, reject)=>{
25
+ this.resolve = resolve;
26
+ this.reject = reject;
27
+ });
28
+ }
29
+ }
30
+
4
31
  /*
5
32
  Copyright 2020 Google LLC
6
33
  Use of this source code is governed by an MIT-style
@@ -75,33 +102,6 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
75
102
  return supportStatus;
76
103
  }
77
104
 
78
- /*
79
- Copyright 2018 Google LLC
80
-
81
- Use of this source code is governed by an MIT-style
82
- license that can be found in the LICENSE file or at
83
- https://opensource.org/licenses/MIT.
84
- */ /**
85
- * The Deferred class composes Promises in a way that allows for them to be
86
- * resolved or rejected from outside the constructor. In most cases promises
87
- * should be used directly, but Deferreds can be necessary when the logic to
88
- * resolve a promise must be separate.
89
- *
90
- * @private
91
- */ class Deferred {
92
- promise;
93
- resolve;
94
- reject;
95
- /**
96
- * Creates a promise and exposes its resolve and reject functions as methods.
97
- */ constructor(){
98
- this.promise = new Promise((resolve, reject)=>{
99
- this.resolve = resolve;
100
- this.reject = reject;
101
- });
102
- }
103
- }
104
-
105
105
  /*
106
106
  Copyright 2019 Google LLC
107
107
  Use of this source code is governed by an MIT-style
@@ -123,7 +123,7 @@ export { S as SerwistError, f as assert, a as canConstructResponseFromBodyStream
123
123
  * @private
124
124
  */ async function executeQuotaErrorCallbacks() {
125
125
  if (process.env.NODE_ENV !== "production") {
126
- logger.log(`About to run ${quotaErrorCallbacks.size} ` + `callbacks to clean up caches.`);
126
+ logger.log(`About to run ${quotaErrorCallbacks.size} callbacks to clean up caches.`);
127
127
  }
128
128
  for (const callback of quotaErrorCallbacks){
129
129
  await callback();
@@ -183,7 +183,7 @@ const MAX_RETRY_TIME = 2000;
183
183
  type: "window"
184
184
  });
185
185
  const existingWindowIds = new Set(existingWindows.map((w)=>w.id));
186
- let resultingWindow;
186
+ let resultingWindow = undefined;
187
187
  const startTime = performance.now();
188
188
  // Only wait up to `MAX_RETRY_TIME` to find a matching client.
189
189
  while(performance.now() - startTime < MAX_RETRY_TIME){
@@ -194,10 +194,9 @@ const MAX_RETRY_TIME = 2000;
194
194
  if (resultingClientId) {
195
195
  // If we have a `resultingClientId`, we can match on that.
196
196
  return w.id === resultingClientId;
197
- } else {
198
- // Otherwise match on finding a window not in `existingWindowIds`.
199
- return !existingWindowIds.has(w.id);
200
197
  }
198
+ // Otherwise match on finding a window not in `existingWindowIds`.
199
+ return !existingWindowIds.has(w.id);
201
200
  });
202
201
  if (resultingWindow) {
203
202
  break;
package/dist/index.js CHANGED
@@ -93,8 +93,7 @@ import { c as cacheNames$1, S as SerwistError, a as canConstructResponseFromBody
93
93
  * there's a quota error.
94
94
  *
95
95
  * @param callback
96
- */ // Can't change Function type
97
- // eslint-disable-next-line @typescript-eslint/ban-types
96
+ */ // biome-ignore lint/complexity/noBannedTypes: Can't change Function type
98
97
  function registerQuotaErrorCallback(callback) {
99
98
  if (process.env.NODE_ENV !== "production") {
100
99
  finalAssertExports.isType(callback, "function", {
@@ -116,29 +115,29 @@ function registerQuotaErrorCallback(callback) {
116
115
  * @param details
117
116
  */ function setCacheNameDetails(details) {
118
117
  if (process.env.NODE_ENV !== "production") {
119
- Object.keys(details).forEach((key)=>{
118
+ for (const key of Object.keys(details)){
120
119
  finalAssertExports.isType(details[key], "string", {
121
120
  moduleName: "@serwist/core",
122
121
  funcName: "setCacheNameDetails",
123
122
  paramName: `details.${key}`
124
123
  });
125
- });
126
- if (details["precache"]?.length === 0) {
124
+ }
125
+ if (details.precache?.length === 0) {
127
126
  throw new SerwistError("invalid-cache-name", {
128
127
  cacheNameId: "precache",
129
- value: details["precache"]
128
+ value: details.precache
130
129
  });
131
130
  }
132
- if (details["runtime"]?.length === 0) {
131
+ if (details.runtime?.length === 0) {
133
132
  throw new SerwistError("invalid-cache-name", {
134
133
  cacheNameId: "runtime",
135
- value: details["runtime"]
134
+ value: details.runtime
136
135
  });
137
136
  }
138
- if (details["googleAnalytics"]?.length === 0) {
137
+ if (details.googleAnalytics?.length === 0) {
139
138
  throw new SerwistError("invalid-cache-name", {
140
139
  cacheNameId: "googleAnalytics",
141
- value: details["googleAnalytics"]
140
+ value: details.googleAnalytics
142
141
  });
143
142
  }
144
143
  }
@@ -1,4 +1,4 @@
1
- export declare const enum pluginEvents {
1
+ export declare enum pluginEvents {
2
2
  CACHE_DID_UPDATE = "cacheDidUpdate",
3
3
  CACHE_KEY_WILL_BE_USED = "cacheKeyWillBeUsed",
4
4
  CACHE_WILL_UPDATE = "cacheWillUpdate",
@@ -1,4 +1,4 @@
1
- export declare const enum pluginEvents {
1
+ export declare enum pluginEvents {
2
2
  CACHE_DID_UPDATE = "cacheDidUpdate",
3
3
  CACHE_KEY_WILL_BE_USED = "cacheKeyWillBeUsed",
4
4
  CACHE_WILL_UPDATE = "cacheWillUpdate",
@@ -51,36 +51,6 @@ const cacheNames = {
51
51
  }
52
52
  };
53
53
 
54
- /*
55
- Copyright 2019 Google LLC
56
-
57
- Use of this source code is governed by an MIT-style
58
- license that can be found in the LICENSE file or at
59
- https://opensource.org/licenses/MIT.
60
- */ let supportStatus;
61
- /**
62
- * A utility function that determines whether the current browser supports
63
- * constructing a new `Response` from a `response.body` stream.
64
- *
65
- * @returns `true`, if the current browser can successfully construct
66
- * a `Response` from a `response.body` stream, `false` otherwise.
67
- * @private
68
- */ function canConstructResponseFromBodyStream() {
69
- if (supportStatus === undefined) {
70
- const testResponse = new Response("");
71
- if ("body" in testResponse) {
72
- try {
73
- new Response(testResponse.body);
74
- supportStatus = true;
75
- } catch (error) {
76
- supportStatus = false;
77
- }
78
- }
79
- supportStatus = false;
80
- }
81
- return supportStatus;
82
- }
83
-
84
54
  /*
85
55
  Copyright 2018 Google LLC
86
56
 
@@ -113,7 +83,7 @@ const cacheNames = {
113
83
  }
114
84
  const classNameStr = className ? `${className}.` : "";
115
85
  if (isReturnValueProblem) {
116
- return `The return value from ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
86
+ return `The return value from '${moduleName}.${classNameStr}${funcName}()' must be an instance of class ${expectedClassName}.`;
117
87
  }
118
88
  return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
119
89
  },
@@ -124,100 +94,100 @@ const cacheNames = {
124
94
  return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
125
95
  },
126
96
  "add-to-cache-list-unexpected-type": ({ entry })=>{
127
- return `An unexpected entry was passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' The entry ` + `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + `strings with one or more characters, objects with a url property or ` + `Request objects.`;
97
+ return `An unexpected entry was passed to '@serwist/precaching.PrecacheController.addToCacheList()' The entry '${JSON.stringify(entry)}' isn't supported. You must supply an array of strings with one or more characters, objects with a url property or Request objects.`;
128
98
  },
129
99
  "add-to-cache-list-conflicting-entries": ({ firstEntry, secondEntry })=>{
130
100
  if (!firstEntry || !secondEntry) {
131
- throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`);
101
+ throw new Error("Unexpected input to " + `'add-to-cache-list-duplicate-entries' error.`);
132
102
  }
133
- return `Two of the entries passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry} but different revision details. Serwist is ` + `unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
103
+ return `Two of the entries passed to '@serwist/precaching.PrecacheController.addToCacheList()' had the URL ${firstEntry} but different revision details. Serwist is unable to cache and version the asset correctly. Please remove one of the entries.`;
134
104
  },
135
105
  "plugin-error-request-will-fetch": ({ thrownErrorMessage })=>{
136
106
  if (!thrownErrorMessage) {
137
- throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);
107
+ throw new Error("Unexpected input to " + `'plugin-error-request-will-fetch', error.`);
138
108
  }
139
- return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownErrorMessage}'.`;
109
+ return `An error was thrown by a plugins 'requestWillFetch()' method. The thrown error message was: '${thrownErrorMessage}'.`;
140
110
  },
141
111
  "invalid-cache-name": ({ cacheNameId, value })=>{
142
112
  if (!cacheNameId) {
143
113
  throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
144
114
  }
145
- return `You must provide a name containing at least one character for ` + `setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + `'${JSON.stringify(value)}'`;
115
+ return `You must provide a name containing at least one character for setCacheDetails({${cacheNameId}: '...'}). Received a value of '${JSON.stringify(value)}'`;
146
116
  },
147
117
  "unregister-route-but-not-found-with-method": ({ method })=>{
148
118
  if (!method) {
149
- throw new Error(`Unexpected input to ` + `'unregister-route-but-not-found-with-method' error.`);
119
+ throw new Error("Unexpected input to " + `'unregister-route-but-not-found-with-method' error.`);
150
120
  }
151
- return `The route you're trying to unregister was not previously ` + `registered for the method type '${method}'.`;
121
+ return `The route you're trying to unregister was not previously registered for the method type '${method}'.`;
152
122
  },
153
123
  "unregister-route-route-not-registered": ()=>{
154
- return `The route you're trying to unregister was not previously ` + `registered.`;
124
+ return `The route you're trying to unregister was not previously ` + "registered.";
155
125
  },
156
126
  "queue-replay-failed": ({ name })=>{
157
127
  return `Replaying the background sync queue '${name}' failed.`;
158
128
  },
159
129
  "duplicate-queue-name": ({ name })=>{
160
- return `The Queue name '${name}' is already being used. ` + `All instances of backgroundSync.Queue must be given unique names.`;
130
+ return `The Queue name '${name}' is already being used. All instances of backgroundSync.Queue must be given unique names.`;
161
131
  },
162
132
  "expired-test-without-max-age": ({ methodName, paramName })=>{
163
133
  return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
164
134
  },
165
135
  "unsupported-route-type": ({ moduleName, className, funcName, paramName })=>{
166
- return `The supplied '${paramName}' parameter was an unsupported type. ` + `Please check the docs for ${moduleName}.${className}.${funcName} for ` + `valid input types.`;
136
+ return `The supplied '${paramName}' parameter was an unsupported type. Please check the docs for ${moduleName}.${className}.${funcName} for valid input types.`;
167
137
  },
168
138
  "not-array-of-class": ({ value, expectedClass, moduleName, className, funcName, paramName })=>{
169
- return `The supplied '${paramName}' parameter must be an array of ` + `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + `Please check the call to ${moduleName}.${className}.${funcName}() ` + `to fix the issue.`;
139
+ return `The supplied '${paramName}' parameter must be an array of '${expectedClass}' objects. Received '${JSON.stringify(value)},'. Please check the call to ${moduleName}.${className}.${funcName}() to fix the issue.`;
170
140
  },
171
141
  "max-entries-or-age-required": ({ moduleName, className, funcName })=>{
172
- return `You must define either config.maxEntries or config.maxAgeSeconds` + `in ${moduleName}.${className}.${funcName}`;
142
+ return `You must define either config.maxEntries or config.maxAgeSecondsin ${moduleName}.${className}.${funcName}`;
173
143
  },
174
144
  "statuses-or-headers-required": ({ moduleName, className, funcName })=>{
175
- return `You must define either config.statuses or config.headers` + `in ${moduleName}.${className}.${funcName}`;
145
+ return `You must define either config.statuses or config.headersin ${moduleName}.${className}.${funcName}`;
176
146
  },
177
147
  "invalid-string": ({ moduleName, funcName, paramName })=>{
178
148
  if (!paramName || !moduleName || !funcName) {
179
149
  throw new Error(`Unexpected input to 'invalid-string' error.`);
180
150
  }
181
- return `When using strings, the '${paramName}' parameter must start with ` + `'http' (for cross-origin matches) or '/' (for same-origin matches). ` + `Please see the docs for ${moduleName}.${funcName}() for ` + `more info.`;
151
+ return `When using strings, the '${paramName}' parameter must start with 'http' (for cross-origin matches) or '/' (for same-origin matches). Please see the docs for ${moduleName}.${funcName}() for more info.`;
182
152
  },
183
153
  "channel-name-required": ()=>{
184
- return `You must provide a channelName to construct a ` + `BroadcastCacheUpdate instance.`;
154
+ return "You must provide a channelName to construct a " + "BroadcastCacheUpdate instance.";
185
155
  },
186
156
  "invalid-responses-are-same-args": ()=>{
187
- return `The arguments passed into responsesAreSame() appear to be ` + `invalid. Please ensure valid Responses are used.`;
157
+ return "The arguments passed into responsesAreSame() appear to be " + "invalid. Please ensure valid Responses are used.";
188
158
  },
189
159
  "expire-custom-caches-only": ()=>{
190
- return `You must provide a 'cacheName' property when using the ` + `expiration plugin with a runtime caching strategy.`;
160
+ return `You must provide a 'cacheName' property when using the ` + "expiration plugin with a runtime caching strategy.";
191
161
  },
192
162
  "unit-must-be-bytes": ({ normalizedRangeHeader })=>{
193
163
  if (!normalizedRangeHeader) {
194
164
  throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
195
165
  }
196
- return `The 'unit' portion of the Range header must be set to 'bytes'. ` + `The Range header provided was "${normalizedRangeHeader}"`;
166
+ return `The 'unit' portion of the Range header must be set to 'bytes'. The Range header provided was "${normalizedRangeHeader}"`;
197
167
  },
198
168
  "single-range-only": ({ normalizedRangeHeader })=>{
199
169
  if (!normalizedRangeHeader) {
200
170
  throw new Error(`Unexpected input to 'single-range-only' error.`);
201
171
  }
202
- return `Multiple ranges are not supported. Please use a single start ` + `value, and optional end value. The Range header provided was ` + `"${normalizedRangeHeader}"`;
172
+ return `Multiple ranges are not supported. Please use a single start value, and optional end value. The Range header provided was "${normalizedRangeHeader}"`;
203
173
  },
204
174
  "invalid-range-values": ({ normalizedRangeHeader })=>{
205
175
  if (!normalizedRangeHeader) {
206
176
  throw new Error(`Unexpected input to 'invalid-range-values' error.`);
207
177
  }
208
- return `The Range header is missing both start and end values. At least ` + `one of those values is needed. The Range header provided was ` + `"${normalizedRangeHeader}"`;
178
+ return `The Range header is missing both start and end values. At least one of those values is needed. The Range header provided was "${normalizedRangeHeader}"`;
209
179
  },
210
180
  "no-range-header": ()=>{
211
- return `No Range header was found in the Request provided.`;
181
+ return "No Range header was found in the Request provided.";
212
182
  },
213
183
  "range-not-satisfiable": ({ size, start, end })=>{
214
184
  return `The start (${start}) and end (${end}) values in the Range are ` + `not satisfiable by the cached response, which is ${size} bytes.`;
215
185
  },
216
186
  "attempt-to-cache-non-get-request": ({ url, method })=>{
217
- return `Unable to cache '${url}' because it is a '${method}' request and ` + `only 'GET' requests can be cached.`;
187
+ return `Unable to cache '${url}' because it is a '${method}' request and only 'GET' requests can be cached.`;
218
188
  },
219
189
  "cache-put-with-no-response": ({ url })=>{
220
- return `There was an attempt to cache '${url}' but the response was not ` + `defined.`;
190
+ return `There was an attempt to cache '${url}' but the response was not defined.`;
221
191
  },
222
192
  "no-response": ({ url, error })=>{
223
193
  let message = `The strategy could not generate a response for '${url}'.`;
@@ -227,24 +197,24 @@ const cacheNames = {
227
197
  return message;
228
198
  },
229
199
  "bad-precaching-response": ({ url, status })=>{
230
- return `The precaching request for '${url}' failed` + (status ? ` with an HTTP status of ${status}.` : `.`);
200
+ return `The precaching request for '${url}' failed${status ? ` with an HTTP status of ${status}.` : "."}`;
231
201
  },
232
202
  "non-precached-url": ({ url })=>{
233
- return `createHandlerBoundToURL('${url}') was called, but that URL is ` + `not precached. Please pass in a URL that is precached instead.`;
203
+ return `createHandlerBoundToURL('${url}') was called, but that URL is not precached. Please pass in a URL that is precached instead.`;
234
204
  },
235
205
  "add-to-cache-list-conflicting-integrities": ({ url })=>{
236
- return `Two of the entries passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' had the URL ` + `${url} with different integrity values. Please remove one of them.`;
206
+ return `Two of the entries passed to '@serwist/precaching.PrecacheController.addToCacheList()' had the URL ${url} with different integrity values. Please remove one of them.`;
237
207
  },
238
208
  "missing-precache-entry": ({ cacheName, url })=>{
239
209
  return `Unable to find a precached response in ${cacheName} for ${url}.`;
240
210
  },
241
211
  "cross-origin-copy-response": ({ origin })=>{
242
- return `@serwist/core.copyResponse() can only be used with same-origin ` + `responses. It was passed a response with origin ${origin}.`;
212
+ return `@serwist/core.copyResponse() can only be used with same-origin responses. It was passed a response with origin ${origin}.`;
243
213
  },
244
214
  "opaque-streams-source": ({ type })=>{
245
- const message = `One of the @serwist/streams sources resulted in an ` + `'${type}' response.`;
215
+ const message = `One of the @serwist/streams sources resulted in an '${type}' response.`;
246
216
  if (type === "opaqueredirect") {
247
- return `${message} Please do not use a navigation request that results ` + `in a redirect as a source.`;
217
+ return `${message} Please do not use a navigation request that results in a redirect as a source.`;
248
218
  }
249
219
  return `${message} Please ensure your sources are CORS-enabled.`;
250
220
  }
@@ -291,6 +261,36 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
291
261
  }
292
262
  }
293
263
 
264
+ /*
265
+ Copyright 2019 Google LLC
266
+
267
+ Use of this source code is governed by an MIT-style
268
+ license that can be found in the LICENSE file or at
269
+ https://opensource.org/licenses/MIT.
270
+ */ let supportStatus;
271
+ /**
272
+ * A utility function that determines whether the current browser supports
273
+ * constructing a new `Response` from a `response.body` stream.
274
+ *
275
+ * @returns `true`, if the current browser can successfully construct
276
+ * a `Response` from a `response.body` stream, `false` otherwise.
277
+ * @private
278
+ */ function canConstructResponseFromBodyStream() {
279
+ if (supportStatus === undefined) {
280
+ const testResponse = new Response("");
281
+ if ("body" in testResponse) {
282
+ try {
283
+ new Response(testResponse.body);
284
+ supportStatus = true;
285
+ } catch (error) {
286
+ supportStatus = false;
287
+ }
288
+ }
289
+ supportStatus = false;
290
+ }
291
+ return supportStatus;
292
+ }
293
+
294
294
  /*
295
295
  * This method throws if the supplied value is not an array.
296
296
  * The destructed values are required to produce a meaningful error for users.
@@ -304,31 +304,31 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
304
304
  const hasMethod = (object, expectedMethod, details)=>{
305
305
  const type = typeof object[expectedMethod];
306
306
  if (type !== "function") {
307
- details["expectedMethod"] = expectedMethod;
307
+ details.expectedMethod = expectedMethod;
308
308
  throw new SerwistError("missing-a-method", details);
309
309
  }
310
310
  };
311
311
  const isType = (object, expectedType, details)=>{
312
+ // biome-ignore lint/suspicious/useValidTypeof: Know to not make a mistake...
312
313
  if (typeof object !== expectedType) {
313
- details["expectedType"] = expectedType;
314
+ details.expectedType = expectedType;
314
315
  throw new SerwistError("incorrect-type", details);
315
316
  }
316
317
  };
317
- const isInstance = (object, // Need the general type to do the check later.
318
- // eslint-disable-next-line @typescript-eslint/ban-types
318
+ const isInstance = (object, // biome-ignore lint/complexity/noBannedTypes: Need the general type to do the check later.
319
319
  expectedClass, details)=>{
320
320
  if (!(object instanceof expectedClass)) {
321
- details["expectedClassName"] = expectedClass.name;
321
+ details.expectedClassName = expectedClass.name;
322
322
  throw new SerwistError("incorrect-class", details);
323
323
  }
324
324
  };
325
325
  const isOneOf = (value, validValues, details)=>{
326
326
  if (!validValues.includes(value)) {
327
- details["validValueDescription"] = `Valid values are ${JSON.stringify(validValues)}.`;
327
+ details.validValueDescription = `Valid values are ${JSON.stringify(validValues)}.`;
328
328
  throw new SerwistError("invalid-value", details);
329
329
  }
330
330
  };
331
- const isArrayOfClass = (value, // Need general type to do check later.
331
+ const isArrayOfClass = (value, // biome-ignore lint/complexity/noBannedTypes: Need general type to do check later.
332
332
  expectedClass, details)=>{
333
333
  const error = new SerwistError("not-array-of-class", details);
334
334
  if (!Array.isArray(value)) {
@@ -363,14 +363,14 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
363
363
  }
364
364
  let inGroup = false;
365
365
  const methodToColorMap = {
366
- debug: `#7f8c8d`,
367
- log: `#2ecc71`,
368
- warn: `#f39c12`,
369
- error: `#c0392b`,
370
- groupCollapsed: `#3498db`,
366
+ debug: "#7f8c8d",
367
+ log: "#2ecc71",
368
+ warn: "#f39c12",
369
+ error: "#c0392b",
370
+ groupCollapsed: "#3498db",
371
371
  groupEnd: null
372
372
  };
373
- const print = function(method, args) {
373
+ const print = (method, args)=>{
374
374
  if (self.__WB_DISABLE_DEV_LOGS) {
375
375
  return;
376
376
  }
@@ -384,10 +384,10 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
384
384
  }
385
385
  const styles = [
386
386
  `background: ${methodToColorMap[method]}`,
387
- `border-radius: 0.5em`,
388
- `color: white`,
389
- `font-weight: bold`,
390
- `padding: 2px 0.5em`
387
+ "border-radius: 0.5em",
388
+ "color: white",
389
+ "font-weight: bold",
390
+ "padding: 2px 0.5em"
391
391
  ];
392
392
  // When in a group, the serwist prefix is not displayed.
393
393
  const logPrefix = inGroup ? [] : [
@@ -402,7 +402,7 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
402
402
  inGroup = false;
403
403
  }
404
404
  };
405
- // eslint-disable-next-line @typescript-eslint/ban-types
405
+ // biome-ignore lint/complexity/noBannedTypes: Unknown reason
406
406
  const api = {};
407
407
  const loggerMethods = Object.keys(methodToColorMap);
408
408
  for (const key of loggerMethods){
@@ -421,8 +421,7 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
421
421
  license that can be found in the LICENSE file or at
422
422
  https://opensource.org/licenses/MIT.
423
423
  */ // Callbacks to be executed whenever there's a quota error.
424
- // Can't change Function type right now.
425
- // eslint-disable-next-line @typescript-eslint/ban-types
424
+ // biome-ignore lint/complexity/noBannedTypes: Can't change Function type right now.
426
425
  const quotaErrorCallbacks = new Set();
427
426
 
428
427
  exports.SerwistError = SerwistError;
@@ -49,36 +49,6 @@ const cacheNames = {
49
49
  }
50
50
  };
51
51
 
52
- /*
53
- Copyright 2019 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
- */ let supportStatus;
59
- /**
60
- * A utility function that determines whether the current browser supports
61
- * constructing a new `Response` from a `response.body` stream.
62
- *
63
- * @returns `true`, if the current browser can successfully construct
64
- * a `Response` from a `response.body` stream, `false` otherwise.
65
- * @private
66
- */ function canConstructResponseFromBodyStream() {
67
- if (supportStatus === undefined) {
68
- const testResponse = new Response("");
69
- if ("body" in testResponse) {
70
- try {
71
- new Response(testResponse.body);
72
- supportStatus = true;
73
- } catch (error) {
74
- supportStatus = false;
75
- }
76
- }
77
- supportStatus = false;
78
- }
79
- return supportStatus;
80
- }
81
-
82
52
  /*
83
53
  Copyright 2018 Google LLC
84
54
 
@@ -111,7 +81,7 @@ const cacheNames = {
111
81
  }
112
82
  const classNameStr = className ? `${className}.` : "";
113
83
  if (isReturnValueProblem) {
114
- return `The return value from ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
84
+ return `The return value from '${moduleName}.${classNameStr}${funcName}()' must be an instance of class ${expectedClassName}.`;
115
85
  }
116
86
  return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
117
87
  },
@@ -122,100 +92,100 @@ const cacheNames = {
122
92
  return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
123
93
  },
124
94
  "add-to-cache-list-unexpected-type": ({ entry })=>{
125
- return `An unexpected entry was passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' The entry ` + `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + `strings with one or more characters, objects with a url property or ` + `Request objects.`;
95
+ return `An unexpected entry was passed to '@serwist/precaching.PrecacheController.addToCacheList()' The entry '${JSON.stringify(entry)}' isn't supported. You must supply an array of strings with one or more characters, objects with a url property or Request objects.`;
126
96
  },
127
97
  "add-to-cache-list-conflicting-entries": ({ firstEntry, secondEntry })=>{
128
98
  if (!firstEntry || !secondEntry) {
129
- throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`);
99
+ throw new Error("Unexpected input to " + `'add-to-cache-list-duplicate-entries' error.`);
130
100
  }
131
- return `Two of the entries passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry} but different revision details. Serwist is ` + `unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
101
+ return `Two of the entries passed to '@serwist/precaching.PrecacheController.addToCacheList()' had the URL ${firstEntry} but different revision details. Serwist is unable to cache and version the asset correctly. Please remove one of the entries.`;
132
102
  },
133
103
  "plugin-error-request-will-fetch": ({ thrownErrorMessage })=>{
134
104
  if (!thrownErrorMessage) {
135
- throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);
105
+ throw new Error("Unexpected input to " + `'plugin-error-request-will-fetch', error.`);
136
106
  }
137
- return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownErrorMessage}'.`;
107
+ return `An error was thrown by a plugins 'requestWillFetch()' method. The thrown error message was: '${thrownErrorMessage}'.`;
138
108
  },
139
109
  "invalid-cache-name": ({ cacheNameId, value })=>{
140
110
  if (!cacheNameId) {
141
111
  throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
142
112
  }
143
- return `You must provide a name containing at least one character for ` + `setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + `'${JSON.stringify(value)}'`;
113
+ return `You must provide a name containing at least one character for setCacheDetails({${cacheNameId}: '...'}). Received a value of '${JSON.stringify(value)}'`;
144
114
  },
145
115
  "unregister-route-but-not-found-with-method": ({ method })=>{
146
116
  if (!method) {
147
- throw new Error(`Unexpected input to ` + `'unregister-route-but-not-found-with-method' error.`);
117
+ throw new Error("Unexpected input to " + `'unregister-route-but-not-found-with-method' error.`);
148
118
  }
149
- return `The route you're trying to unregister was not previously ` + `registered for the method type '${method}'.`;
119
+ return `The route you're trying to unregister was not previously registered for the method type '${method}'.`;
150
120
  },
151
121
  "unregister-route-route-not-registered": ()=>{
152
- return `The route you're trying to unregister was not previously ` + `registered.`;
122
+ return `The route you're trying to unregister was not previously ` + "registered.";
153
123
  },
154
124
  "queue-replay-failed": ({ name })=>{
155
125
  return `Replaying the background sync queue '${name}' failed.`;
156
126
  },
157
127
  "duplicate-queue-name": ({ name })=>{
158
- return `The Queue name '${name}' is already being used. ` + `All instances of backgroundSync.Queue must be given unique names.`;
128
+ return `The Queue name '${name}' is already being used. All instances of backgroundSync.Queue must be given unique names.`;
159
129
  },
160
130
  "expired-test-without-max-age": ({ methodName, paramName })=>{
161
131
  return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
162
132
  },
163
133
  "unsupported-route-type": ({ moduleName, className, funcName, paramName })=>{
164
- return `The supplied '${paramName}' parameter was an unsupported type. ` + `Please check the docs for ${moduleName}.${className}.${funcName} for ` + `valid input types.`;
134
+ return `The supplied '${paramName}' parameter was an unsupported type. Please check the docs for ${moduleName}.${className}.${funcName} for valid input types.`;
165
135
  },
166
136
  "not-array-of-class": ({ value, expectedClass, moduleName, className, funcName, paramName })=>{
167
- return `The supplied '${paramName}' parameter must be an array of ` + `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + `Please check the call to ${moduleName}.${className}.${funcName}() ` + `to fix the issue.`;
137
+ return `The supplied '${paramName}' parameter must be an array of '${expectedClass}' objects. Received '${JSON.stringify(value)},'. Please check the call to ${moduleName}.${className}.${funcName}() to fix the issue.`;
168
138
  },
169
139
  "max-entries-or-age-required": ({ moduleName, className, funcName })=>{
170
- return `You must define either config.maxEntries or config.maxAgeSeconds` + `in ${moduleName}.${className}.${funcName}`;
140
+ return `You must define either config.maxEntries or config.maxAgeSecondsin ${moduleName}.${className}.${funcName}`;
171
141
  },
172
142
  "statuses-or-headers-required": ({ moduleName, className, funcName })=>{
173
- return `You must define either config.statuses or config.headers` + `in ${moduleName}.${className}.${funcName}`;
143
+ return `You must define either config.statuses or config.headersin ${moduleName}.${className}.${funcName}`;
174
144
  },
175
145
  "invalid-string": ({ moduleName, funcName, paramName })=>{
176
146
  if (!paramName || !moduleName || !funcName) {
177
147
  throw new Error(`Unexpected input to 'invalid-string' error.`);
178
148
  }
179
- return `When using strings, the '${paramName}' parameter must start with ` + `'http' (for cross-origin matches) or '/' (for same-origin matches). ` + `Please see the docs for ${moduleName}.${funcName}() for ` + `more info.`;
149
+ return `When using strings, the '${paramName}' parameter must start with 'http' (for cross-origin matches) or '/' (for same-origin matches). Please see the docs for ${moduleName}.${funcName}() for more info.`;
180
150
  },
181
151
  "channel-name-required": ()=>{
182
- return `You must provide a channelName to construct a ` + `BroadcastCacheUpdate instance.`;
152
+ return "You must provide a channelName to construct a " + "BroadcastCacheUpdate instance.";
183
153
  },
184
154
  "invalid-responses-are-same-args": ()=>{
185
- return `The arguments passed into responsesAreSame() appear to be ` + `invalid. Please ensure valid Responses are used.`;
155
+ return "The arguments passed into responsesAreSame() appear to be " + "invalid. Please ensure valid Responses are used.";
186
156
  },
187
157
  "expire-custom-caches-only": ()=>{
188
- return `You must provide a 'cacheName' property when using the ` + `expiration plugin with a runtime caching strategy.`;
158
+ return `You must provide a 'cacheName' property when using the ` + "expiration plugin with a runtime caching strategy.";
189
159
  },
190
160
  "unit-must-be-bytes": ({ normalizedRangeHeader })=>{
191
161
  if (!normalizedRangeHeader) {
192
162
  throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
193
163
  }
194
- return `The 'unit' portion of the Range header must be set to 'bytes'. ` + `The Range header provided was "${normalizedRangeHeader}"`;
164
+ return `The 'unit' portion of the Range header must be set to 'bytes'. The Range header provided was "${normalizedRangeHeader}"`;
195
165
  },
196
166
  "single-range-only": ({ normalizedRangeHeader })=>{
197
167
  if (!normalizedRangeHeader) {
198
168
  throw new Error(`Unexpected input to 'single-range-only' error.`);
199
169
  }
200
- return `Multiple ranges are not supported. Please use a single start ` + `value, and optional end value. The Range header provided was ` + `"${normalizedRangeHeader}"`;
170
+ return `Multiple ranges are not supported. Please use a single start value, and optional end value. The Range header provided was "${normalizedRangeHeader}"`;
201
171
  },
202
172
  "invalid-range-values": ({ normalizedRangeHeader })=>{
203
173
  if (!normalizedRangeHeader) {
204
174
  throw new Error(`Unexpected input to 'invalid-range-values' error.`);
205
175
  }
206
- return `The Range header is missing both start and end values. At least ` + `one of those values is needed. The Range header provided was ` + `"${normalizedRangeHeader}"`;
176
+ return `The Range header is missing both start and end values. At least one of those values is needed. The Range header provided was "${normalizedRangeHeader}"`;
207
177
  },
208
178
  "no-range-header": ()=>{
209
- return `No Range header was found in the Request provided.`;
179
+ return "No Range header was found in the Request provided.";
210
180
  },
211
181
  "range-not-satisfiable": ({ size, start, end })=>{
212
182
  return `The start (${start}) and end (${end}) values in the Range are ` + `not satisfiable by the cached response, which is ${size} bytes.`;
213
183
  },
214
184
  "attempt-to-cache-non-get-request": ({ url, method })=>{
215
- return `Unable to cache '${url}' because it is a '${method}' request and ` + `only 'GET' requests can be cached.`;
185
+ return `Unable to cache '${url}' because it is a '${method}' request and only 'GET' requests can be cached.`;
216
186
  },
217
187
  "cache-put-with-no-response": ({ url })=>{
218
- return `There was an attempt to cache '${url}' but the response was not ` + `defined.`;
188
+ return `There was an attempt to cache '${url}' but the response was not defined.`;
219
189
  },
220
190
  "no-response": ({ url, error })=>{
221
191
  let message = `The strategy could not generate a response for '${url}'.`;
@@ -225,24 +195,24 @@ const cacheNames = {
225
195
  return message;
226
196
  },
227
197
  "bad-precaching-response": ({ url, status })=>{
228
- return `The precaching request for '${url}' failed` + (status ? ` with an HTTP status of ${status}.` : `.`);
198
+ return `The precaching request for '${url}' failed${status ? ` with an HTTP status of ${status}.` : "."}`;
229
199
  },
230
200
  "non-precached-url": ({ url })=>{
231
- return `createHandlerBoundToURL('${url}') was called, but that URL is ` + `not precached. Please pass in a URL that is precached instead.`;
201
+ return `createHandlerBoundToURL('${url}') was called, but that URL is not precached. Please pass in a URL that is precached instead.`;
232
202
  },
233
203
  "add-to-cache-list-conflicting-integrities": ({ url })=>{
234
- return `Two of the entries passed to ` + `'@serwist/precaching.PrecacheController.addToCacheList()' had the URL ` + `${url} with different integrity values. Please remove one of them.`;
204
+ return `Two of the entries passed to '@serwist/precaching.PrecacheController.addToCacheList()' had the URL ${url} with different integrity values. Please remove one of them.`;
235
205
  },
236
206
  "missing-precache-entry": ({ cacheName, url })=>{
237
207
  return `Unable to find a precached response in ${cacheName} for ${url}.`;
238
208
  },
239
209
  "cross-origin-copy-response": ({ origin })=>{
240
- return `@serwist/core.copyResponse() can only be used with same-origin ` + `responses. It was passed a response with origin ${origin}.`;
210
+ return `@serwist/core.copyResponse() can only be used with same-origin responses. It was passed a response with origin ${origin}.`;
241
211
  },
242
212
  "opaque-streams-source": ({ type })=>{
243
- const message = `One of the @serwist/streams sources resulted in an ` + `'${type}' response.`;
213
+ const message = `One of the @serwist/streams sources resulted in an '${type}' response.`;
244
214
  if (type === "opaqueredirect") {
245
- return `${message} Please do not use a navigation request that results ` + `in a redirect as a source.`;
215
+ return `${message} Please do not use a navigation request that results in a redirect as a source.`;
246
216
  }
247
217
  return `${message} Please ensure your sources are CORS-enabled.`;
248
218
  }
@@ -289,6 +259,36 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
289
259
  }
290
260
  }
291
261
 
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() {
277
+ if (supportStatus === undefined) {
278
+ const testResponse = new Response("");
279
+ if ("body" in testResponse) {
280
+ try {
281
+ new Response(testResponse.body);
282
+ supportStatus = true;
283
+ } catch (error) {
284
+ supportStatus = false;
285
+ }
286
+ }
287
+ supportStatus = false;
288
+ }
289
+ return supportStatus;
290
+ }
291
+
292
292
  /*
293
293
  * This method throws if the supplied value is not an array.
294
294
  * The destructed values are required to produce a meaningful error for users.
@@ -302,31 +302,31 @@ const messageGenerator = process.env.NODE_ENV === "production" ? fallback : gene
302
302
  const hasMethod = (object, expectedMethod, details)=>{
303
303
  const type = typeof object[expectedMethod];
304
304
  if (type !== "function") {
305
- details["expectedMethod"] = expectedMethod;
305
+ details.expectedMethod = expectedMethod;
306
306
  throw new SerwistError("missing-a-method", details);
307
307
  }
308
308
  };
309
309
  const isType = (object, expectedType, details)=>{
310
+ // biome-ignore lint/suspicious/useValidTypeof: Know to not make a mistake...
310
311
  if (typeof object !== expectedType) {
311
- details["expectedType"] = expectedType;
312
+ details.expectedType = expectedType;
312
313
  throw new SerwistError("incorrect-type", details);
313
314
  }
314
315
  };
315
- const isInstance = (object, // Need the general type to do the check later.
316
- // eslint-disable-next-line @typescript-eslint/ban-types
316
+ const isInstance = (object, // biome-ignore lint/complexity/noBannedTypes: Need the general type to do the check later.
317
317
  expectedClass, details)=>{
318
318
  if (!(object instanceof expectedClass)) {
319
- details["expectedClassName"] = expectedClass.name;
319
+ details.expectedClassName = expectedClass.name;
320
320
  throw new SerwistError("incorrect-class", details);
321
321
  }
322
322
  };
323
323
  const isOneOf = (value, validValues, details)=>{
324
324
  if (!validValues.includes(value)) {
325
- details["validValueDescription"] = `Valid values are ${JSON.stringify(validValues)}.`;
325
+ details.validValueDescription = `Valid values are ${JSON.stringify(validValues)}.`;
326
326
  throw new SerwistError("invalid-value", details);
327
327
  }
328
328
  };
329
- const isArrayOfClass = (value, // Need general type to do check later.
329
+ const isArrayOfClass = (value, // biome-ignore lint/complexity/noBannedTypes: Need general type to do check later.
330
330
  expectedClass, details)=>{
331
331
  const error = new SerwistError("not-array-of-class", details);
332
332
  if (!Array.isArray(value)) {
@@ -361,14 +361,14 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
361
361
  }
362
362
  let inGroup = false;
363
363
  const methodToColorMap = {
364
- debug: `#7f8c8d`,
365
- log: `#2ecc71`,
366
- warn: `#f39c12`,
367
- error: `#c0392b`,
368
- groupCollapsed: `#3498db`,
364
+ debug: "#7f8c8d",
365
+ log: "#2ecc71",
366
+ warn: "#f39c12",
367
+ error: "#c0392b",
368
+ groupCollapsed: "#3498db",
369
369
  groupEnd: null
370
370
  };
371
- const print = function(method, args) {
371
+ const print = (method, args)=>{
372
372
  if (self.__WB_DISABLE_DEV_LOGS) {
373
373
  return;
374
374
  }
@@ -382,10 +382,10 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
382
382
  }
383
383
  const styles = [
384
384
  `background: ${methodToColorMap[method]}`,
385
- `border-radius: 0.5em`,
386
- `color: white`,
387
- `font-weight: bold`,
388
- `padding: 2px 0.5em`
385
+ "border-radius: 0.5em",
386
+ "color: white",
387
+ "font-weight: bold",
388
+ "padding: 2px 0.5em"
389
389
  ];
390
390
  // When in a group, the serwist prefix is not displayed.
391
391
  const logPrefix = inGroup ? [] : [
@@ -400,7 +400,7 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
400
400
  inGroup = false;
401
401
  }
402
402
  };
403
- // eslint-disable-next-line @typescript-eslint/ban-types
403
+ // biome-ignore lint/complexity/noBannedTypes: Unknown reason
404
404
  const api = {};
405
405
  const loggerMethods = Object.keys(methodToColorMap);
406
406
  for (const key of loggerMethods){
@@ -419,8 +419,7 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
419
419
  license that can be found in the LICENSE file or at
420
420
  https://opensource.org/licenses/MIT.
421
421
  */ // Callbacks to be executed whenever there's a quota error.
422
- // Can't change Function type right now.
423
- // eslint-disable-next-line @typescript-eslint/ban-types
422
+ // biome-ignore lint/complexity/noBannedTypes: Can't change Function type right now.
424
423
  const quotaErrorCallbacks = new Set();
425
424
 
426
425
  export { SerwistError as S, canConstructResponseFromBodyStream as a, cacheNames as c, finalAssertExports as f, logger as l, quotaErrorCallbacks as q };
package/dist/types.d.cts CHANGED
@@ -104,7 +104,7 @@ export interface HandlerWillStartCallbackParam {
104
104
  state?: PluginState;
105
105
  }
106
106
  export interface HandlerWillStartCallback {
107
- (param: HandlerWillStartCallbackParam): Promise<void | null | undefined>;
107
+ (param: HandlerWillStartCallbackParam): Promise<any>;
108
108
  }
109
109
  export interface CacheDidUpdateCallbackParam {
110
110
  /**
@@ -131,7 +131,7 @@ export interface CacheDidUpdateCallbackParam {
131
131
  state?: PluginState;
132
132
  }
133
133
  export interface CacheDidUpdateCallback {
134
- (param: CacheDidUpdateCallbackParam): Promise<void | null | undefined>;
134
+ (param: CacheDidUpdateCallbackParam): Promise<any>;
135
135
  }
136
136
  export interface CacheKeyWillBeUsedCallbackParam {
137
137
  mode: string;
@@ -150,7 +150,7 @@ export interface CacheWillUpdateCallbackParam {
150
150
  state?: PluginState;
151
151
  }
152
152
  export interface CacheWillUpdateCallback {
153
- (param: CacheWillUpdateCallbackParam): Promise<Response | void | null | undefined>;
153
+ (param: CacheWillUpdateCallbackParam): Promise<any>;
154
154
  }
155
155
  export interface CachedResponseWillBeUsedCallbackParam {
156
156
  /**
@@ -172,7 +172,7 @@ export interface CachedResponseWillBeUsedCallbackParam {
172
172
  state?: PluginState;
173
173
  }
174
174
  export interface CachedResponseWillBeUsedCallback {
175
- (param: CachedResponseWillBeUsedCallbackParam): Promise<Response | void | null | undefined>;
175
+ (param: CachedResponseWillBeUsedCallbackParam): Promise<any>;
176
176
  }
177
177
  export interface FetchDidFailCallbackParam {
178
178
  error: Error;
@@ -182,7 +182,7 @@ export interface FetchDidFailCallbackParam {
182
182
  state?: PluginState;
183
183
  }
184
184
  export interface FetchDidFailCallback {
185
- (param: FetchDidFailCallbackParam): Promise<void | null | undefined>;
185
+ (param: FetchDidFailCallbackParam): Promise<any>;
186
186
  }
187
187
  export interface FetchDidSucceedCallbackParam {
188
188
  request: Request;
@@ -226,7 +226,7 @@ export interface HandlerDidRespondCallbackParam {
226
226
  state?: PluginState;
227
227
  }
228
228
  export interface HandlerDidRespondCallback {
229
- (param: HandlerDidRespondCallbackParam): Promise<void | null | undefined>;
229
+ (param: HandlerDidRespondCallbackParam): Promise<any>;
230
230
  }
231
231
  export interface HandlerDidCompleteCallbackParam {
232
232
  request: Request;
@@ -236,7 +236,7 @@ export interface HandlerDidCompleteCallbackParam {
236
236
  state?: PluginState;
237
237
  }
238
238
  export interface HandlerDidCompleteCallback {
239
- (param: HandlerDidCompleteCallbackParam): Promise<void | null | undefined>;
239
+ (param: HandlerDidCompleteCallbackParam): Promise<any>;
240
240
  }
241
241
  /**
242
242
  * An object with optional lifecycle callback properties for the fetch and
package/dist/types.d.ts CHANGED
@@ -104,7 +104,7 @@ export interface HandlerWillStartCallbackParam {
104
104
  state?: PluginState;
105
105
  }
106
106
  export interface HandlerWillStartCallback {
107
- (param: HandlerWillStartCallbackParam): Promise<void | null | undefined>;
107
+ (param: HandlerWillStartCallbackParam): Promise<any>;
108
108
  }
109
109
  export interface CacheDidUpdateCallbackParam {
110
110
  /**
@@ -131,7 +131,7 @@ export interface CacheDidUpdateCallbackParam {
131
131
  state?: PluginState;
132
132
  }
133
133
  export interface CacheDidUpdateCallback {
134
- (param: CacheDidUpdateCallbackParam): Promise<void | null | undefined>;
134
+ (param: CacheDidUpdateCallbackParam): Promise<any>;
135
135
  }
136
136
  export interface CacheKeyWillBeUsedCallbackParam {
137
137
  mode: string;
@@ -150,7 +150,7 @@ export interface CacheWillUpdateCallbackParam {
150
150
  state?: PluginState;
151
151
  }
152
152
  export interface CacheWillUpdateCallback {
153
- (param: CacheWillUpdateCallbackParam): Promise<Response | void | null | undefined>;
153
+ (param: CacheWillUpdateCallbackParam): Promise<any>;
154
154
  }
155
155
  export interface CachedResponseWillBeUsedCallbackParam {
156
156
  /**
@@ -172,7 +172,7 @@ export interface CachedResponseWillBeUsedCallbackParam {
172
172
  state?: PluginState;
173
173
  }
174
174
  export interface CachedResponseWillBeUsedCallback {
175
- (param: CachedResponseWillBeUsedCallbackParam): Promise<Response | void | null | undefined>;
175
+ (param: CachedResponseWillBeUsedCallbackParam): Promise<any>;
176
176
  }
177
177
  export interface FetchDidFailCallbackParam {
178
178
  error: Error;
@@ -182,7 +182,7 @@ export interface FetchDidFailCallbackParam {
182
182
  state?: PluginState;
183
183
  }
184
184
  export interface FetchDidFailCallback {
185
- (param: FetchDidFailCallbackParam): Promise<void | null | undefined>;
185
+ (param: FetchDidFailCallbackParam): Promise<any>;
186
186
  }
187
187
  export interface FetchDidSucceedCallbackParam {
188
188
  request: Request;
@@ -226,7 +226,7 @@ export interface HandlerDidRespondCallbackParam {
226
226
  state?: PluginState;
227
227
  }
228
228
  export interface HandlerDidRespondCallback {
229
- (param: HandlerDidRespondCallbackParam): Promise<void | null | undefined>;
229
+ (param: HandlerDidRespondCallbackParam): Promise<any>;
230
230
  }
231
231
  export interface HandlerDidCompleteCallbackParam {
232
232
  request: Request;
@@ -236,7 +236,7 @@ export interface HandlerDidCompleteCallbackParam {
236
236
  state?: PluginState;
237
237
  }
238
238
  export interface HandlerDidCompleteCallback {
239
- (param: HandlerDidCompleteCallbackParam): Promise<void | null | undefined>;
239
+ (param: HandlerDidCompleteCallbackParam): Promise<any>;
240
240
  }
241
241
  /**
242
242
  * An object with optional lifecycle callback properties for the fetch and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/core",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
4
4
  "type": "module",
5
5
  "description": "This module is used by a number of the other Serwist modules to share common code.",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  "license": "MIT",
18
18
  "repository": "serwist/serwist",
19
19
  "bugs": "https://github.com/serwist/serwist/issues",
20
- "homepage": "https://serwist.vercel.app",
20
+ "homepage": "https://serwist.pages.dev",
21
21
  "main": "./dist/index.js",
22
22
  "module": "./dist/index.js",
23
23
  "types": "./dist/index.d.ts",
@@ -52,11 +52,12 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "rollup": "4.9.1",
55
- "@serwist/constants": "8.3.0"
55
+ "@serwist/constants": "8.4.1"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
59
- "lint": "eslint src --ext ts,tsx,js,jsx,cjs,mjs",
59
+ "dev": "rollup --config rollup.config.js --watch",
60
+ "lint": "biome lint ./src",
60
61
  "typecheck": "tsc"
61
62
  }
62
63
  }