@serwist/core 9.0.0-preview.9 → 9.0.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 (89) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +3 -11
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.internal.d.ts +1 -15
  5. package/dist/index.internal.d.ts.map +1 -1
  6. package/dist/index.internal.js +1 -120
  7. package/dist/index.js +2 -92
  8. package/package.json +9 -6
  9. package/src/index.internal.ts +4 -21
  10. package/src/index.ts +43 -13
  11. package/dist/_private/Deferred.d.ts +0 -19
  12. package/dist/_private/Deferred.d.ts.map +0 -1
  13. package/dist/_private/SerwistError.d.ts +0 -25
  14. package/dist/_private/SerwistError.d.ts.map +0 -1
  15. package/dist/_private/assert.d.ts +0 -11
  16. package/dist/_private/assert.d.ts.map +0 -1
  17. package/dist/_private/cacheMatchIgnoreParams.d.ts +0 -15
  18. package/dist/_private/cacheMatchIgnoreParams.d.ts.map +0 -1
  19. package/dist/_private/cacheNames.d.ts +0 -40
  20. package/dist/_private/cacheNames.d.ts.map +0 -1
  21. package/dist/_private/canConstructReadableStream.d.ts +0 -12
  22. package/dist/_private/canConstructReadableStream.d.ts.map +0 -1
  23. package/dist/_private/canConstructResponseFromBodyStream.d.ts +0 -11
  24. package/dist/_private/canConstructResponseFromBodyStream.d.ts.map +0 -1
  25. package/dist/_private/dontWaitFor.d.ts +0 -7
  26. package/dist/_private/dontWaitFor.d.ts.map +0 -1
  27. package/dist/_private/executeQuotaErrorCallbacks.d.ts +0 -9
  28. package/dist/_private/executeQuotaErrorCallbacks.d.ts.map +0 -1
  29. package/dist/_private/getFriendlyURL.d.ts +0 -3
  30. package/dist/_private/getFriendlyURL.d.ts.map +0 -1
  31. package/dist/_private/logger.d.ts +0 -24
  32. package/dist/_private/logger.d.ts.map +0 -1
  33. package/dist/_private/resultingClientExists.d.ts +0 -12
  34. package/dist/_private/resultingClientExists.d.ts.map +0 -1
  35. package/dist/_private/timeout.d.ts +0 -10
  36. package/dist/_private/timeout.d.ts.map +0 -1
  37. package/dist/_private/waitUntil.d.ts +0 -11
  38. package/dist/_private/waitUntil.d.ts.map +0 -1
  39. package/dist/cacheNames.d.ts +0 -21
  40. package/dist/cacheNames.d.ts.map +0 -1
  41. package/dist/chunks/quotaErrorCallbacks.js +0 -355
  42. package/dist/clientsClaim.d.ts +0 -7
  43. package/dist/clientsClaim.d.ts.map +0 -1
  44. package/dist/copyResponse.d.ts +0 -21
  45. package/dist/copyResponse.d.ts.map +0 -1
  46. package/dist/models/messages/messageGenerator.d.ts +0 -4
  47. package/dist/models/messages/messageGenerator.d.ts.map +0 -1
  48. package/dist/models/messages/messages.d.ts +0 -44
  49. package/dist/models/messages/messages.d.ts.map +0 -1
  50. package/dist/models/pluginEvents.d.ts +0 -10
  51. package/dist/models/pluginEvents.d.ts.map +0 -1
  52. package/dist/models/quotaErrorCallbacks.d.ts +0 -3
  53. package/dist/models/quotaErrorCallbacks.d.ts.map +0 -1
  54. package/dist/registerQuotaErrorCallback.d.ts +0 -9
  55. package/dist/registerQuotaErrorCallback.d.ts.map +0 -1
  56. package/dist/setCacheNameDetails.d.ts +0 -10
  57. package/dist/setCacheNameDetails.d.ts.map +0 -1
  58. package/dist/types.d.ts +0 -279
  59. package/dist/types.d.ts.map +0 -1
  60. package/dist/utils/pluginUtils.d.ts +0 -5
  61. package/dist/utils/pluginUtils.d.ts.map +0 -1
  62. package/dist/utils/welcome.d.ts +0 -2
  63. package/dist/utils/welcome.d.ts.map +0 -1
  64. package/src/_private/Deferred.ts +0 -33
  65. package/src/_private/SerwistError.ts +0 -43
  66. package/src/_private/assert.ts +0 -89
  67. package/src/_private/cacheMatchIgnoreParams.ts +0 -54
  68. package/src/_private/cacheNames.ts +0 -87
  69. package/src/_private/canConstructReadableStream.ts +0 -34
  70. package/src/_private/canConstructResponseFromBodyStream.ts +0 -37
  71. package/src/_private/dontWaitFor.ts +0 -16
  72. package/src/_private/executeQuotaErrorCallbacks.ts +0 -35
  73. package/src/_private/getFriendlyURL.ts +0 -16
  74. package/src/_private/logger.ts +0 -95
  75. package/src/_private/resultingClientExists.ts +0 -58
  76. package/src/_private/timeout.ts +0 -19
  77. package/src/_private/waitUntil.ts +0 -21
  78. package/src/cacheNames.ts +0 -41
  79. package/src/clientsClaim.ts +0 -20
  80. package/src/copyResponse.ts +0 -62
  81. package/src/models/messages/messageGenerator.ts +0 -29
  82. package/src/models/messages/messages.ts +0 -233
  83. package/src/models/pluginEvents.ts +0 -17
  84. package/src/models/quotaErrorCallbacks.ts +0 -13
  85. package/src/registerQuotaErrorCallback.ts +0 -36
  86. package/src/setCacheNameDetails.ts +0 -55
  87. package/src/types.ts +0 -322
  88. package/src/utils/pluginUtils.ts +0 -15
  89. package/src/utils/welcome.ts +0 -25
@@ -1,12 +0,0 @@
1
- /**
2
- * Returns a promise that resolves to a window client matching the passed
3
- * `resultingClientId`. For browsers that don't support `resultingClientId`
4
- * or if waiting for the resulting client to apper takes too long, resolve to
5
- * `undefined`.
6
- *
7
- * @param resultingClientId
8
- * @returns
9
- * @private
10
- */
11
- export declare function resultingClientExists(resultingClientId?: string): Promise<Client | undefined>;
12
- //# sourceMappingURL=resultingClientExists.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Returns a promise that resolves and the passed number of milliseconds.
3
- * This utility is an async/await-friendly version of `setTimeout`.
4
- *
5
- * @param ms
6
- * @returns
7
- * @private
8
- */
9
- export declare function timeout(ms: number): Promise<unknown>;
10
- //# sourceMappingURL=timeout.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
1
- /**
2
- * A utility method that makes it easier to use `event.waitUntil` with
3
- * async functions and return the result.
4
- *
5
- * @param event
6
- * @param asyncFn
7
- * @returns
8
- * @private
9
- */
10
- export declare const waitUntil: <T = any>(event: ExtendableEvent, asyncFn: () => Promise<T>) => Promise<T>;
11
- //# sourceMappingURL=waitUntil.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../src/_private/waitUntil.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,mBAAoB,eAAe,0CAIxD,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Get the current cache names and prefix/suffix used by Workbox.
3
- *
4
- * `cacheNames.precache` is used for precached assets,
5
- * `cacheNames.googleAnalytics` is used by `@serwist/google-analytics` to
6
- * store `analytics.js`, and `cacheNames.runtime` is used for everything else.
7
- *
8
- * `cacheNames.prefix` can be used to retrieve just the current prefix value.
9
- * `cacheNames.suffix` can be used to retrieve just the current suffix value.
10
- *
11
- * @returns An object with `precache`, `runtime`, `prefix`, and `googleAnalytics` properties.
12
- */
13
- declare const cacheNames: {
14
- readonly googleAnalytics: string;
15
- readonly precache: string;
16
- readonly prefix: string;
17
- readonly runtime: string;
18
- readonly suffix: string;
19
- };
20
- export { cacheNames };
21
- //# sourceMappingURL=cacheNames.d.ts.map
@@ -1 +0,0 @@
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,355 +0,0 @@
1
- const _cacheNameDetails = {
2
- googleAnalytics: "googleAnalytics",
3
- precache: "precache-v2",
4
- prefix: "serwist",
5
- runtime: "runtime",
6
- suffix: typeof registration !== "undefined" ? registration.scope : ""
7
- };
8
- const _createCacheName = (cacheName)=>{
9
- return [
10
- _cacheNameDetails.prefix,
11
- cacheName,
12
- _cacheNameDetails.suffix
13
- ].filter((value)=>value && value.length > 0).join("-");
14
- };
15
- const eachCacheNameDetail = (fn)=>{
16
- for (const key of Object.keys(_cacheNameDetails)){
17
- fn(key);
18
- }
19
- };
20
- const cacheNames = {
21
- updateDetails: (details)=>{
22
- eachCacheNameDetail((key)=>{
23
- const detail = details[key];
24
- if (typeof detail === "string") {
25
- _cacheNameDetails[key] = detail;
26
- }
27
- });
28
- },
29
- getGoogleAnalyticsName: (userCacheName)=>{
30
- return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
31
- },
32
- getPrecacheName: (userCacheName)=>{
33
- return userCacheName || _createCacheName(_cacheNameDetails.precache);
34
- },
35
- getPrefix: ()=>{
36
- return _cacheNameDetails.prefix;
37
- },
38
- getRuntimeName: (userCacheName)=>{
39
- return userCacheName || _createCacheName(_cacheNameDetails.runtime);
40
- },
41
- getSuffix: ()=>{
42
- return _cacheNameDetails.suffix;
43
- }
44
- };
45
-
46
- const messages = {
47
- "invalid-value": ({ paramName, validValueDescription, value })=>{
48
- if (!paramName || !validValueDescription) {
49
- throw new Error(`Unexpected input to 'invalid-value' error.`);
50
- }
51
- return `The '${paramName}' parameter was given a value with an ` + `unexpected value. ${validValueDescription} Received a value of ` + `${JSON.stringify(value)}.`;
52
- },
53
- "not-an-array": ({ moduleName, className, funcName, paramName })=>{
54
- if (!moduleName || !className || !funcName || !paramName) {
55
- throw new Error(`Unexpected input to 'not-an-array' error.`);
56
- }
57
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className}.${funcName}()' must be an array.`;
58
- },
59
- "incorrect-type": ({ expectedType, paramName, moduleName, className, funcName })=>{
60
- if (!expectedType || !paramName || !moduleName || !funcName) {
61
- throw new Error(`Unexpected input to 'incorrect-type' error.`);
62
- }
63
- const classNameStr = className ? `${className}.` : "";
64
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}` + `${funcName}()' must be of type ${expectedType}.`;
65
- },
66
- "incorrect-class": ({ expectedClassName, paramName, moduleName, className, funcName, isReturnValueProblem })=>{
67
- if (!expectedClassName || !moduleName || !funcName) {
68
- throw new Error(`Unexpected input to 'incorrect-class' error.`);
69
- }
70
- const classNameStr = className ? `${className}.` : "";
71
- if (isReturnValueProblem) {
72
- return `The return value from '${moduleName}.${classNameStr}${funcName}()' must be an instance of class ${expectedClassName}.`;
73
- }
74
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
75
- },
76
- "missing-a-method": ({ expectedMethod, paramName, moduleName, className, funcName })=>{
77
- if (!expectedMethod || !paramName || !moduleName || !className || !funcName) {
78
- throw new Error(`Unexpected input to 'missing-a-method' error.`);
79
- }
80
- return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
81
- },
82
- "add-to-cache-list-unexpected-type": ({ entry })=>{
83
- 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.`;
84
- },
85
- "add-to-cache-list-conflicting-entries": ({ firstEntry, secondEntry })=>{
86
- if (!firstEntry || !secondEntry) {
87
- throw new Error("Unexpected input to " + `'add-to-cache-list-duplicate-entries' error.`);
88
- }
89
- 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.`;
90
- },
91
- "plugin-error-request-will-fetch": ({ thrownErrorMessage })=>{
92
- if (!thrownErrorMessage) {
93
- throw new Error("Unexpected input to " + `'plugin-error-request-will-fetch', error.`);
94
- }
95
- return `An error was thrown by a plugin's 'requestWillFetch()' method. The thrown error message was: '${thrownErrorMessage}'.`;
96
- },
97
- "invalid-cache-name": ({ cacheNameId, value })=>{
98
- if (!cacheNameId) {
99
- throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
100
- }
101
- return `You must provide a name containing at least one character for setCacheDetails({${cacheNameId}: '...'}). Received a value of '${JSON.stringify(value)}'`;
102
- },
103
- "unregister-route-but-not-found-with-method": ({ method })=>{
104
- if (!method) {
105
- throw new Error("Unexpected input to " + `'unregister-route-but-not-found-with-method' error.`);
106
- }
107
- return `The route you're trying to unregister was not previously registered for the method type '${method}'.`;
108
- },
109
- "unregister-route-route-not-registered": ()=>{
110
- return `The route you're trying to unregister was not previously ` + "registered.";
111
- },
112
- "queue-replay-failed": ({ name })=>{
113
- return `Replaying the background sync queue '${name}' failed.`;
114
- },
115
- "duplicate-queue-name": ({ name })=>{
116
- return `The Queue name '${name}' is already being used. All instances of backgroundSync.Queue must be given unique names.`;
117
- },
118
- "expired-test-without-max-age": ({ methodName, paramName })=>{
119
- return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
120
- },
121
- "unsupported-route-type": ({ moduleName, className, funcName, paramName })=>{
122
- return `The supplied '${paramName}' parameter was an unsupported type. Please check the docs for ${moduleName}.${className}.${funcName} for valid input types.`;
123
- },
124
- "not-array-of-class": ({ value, expectedClass, moduleName, className, funcName, paramName })=>{
125
- 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.`;
126
- },
127
- "max-entries-or-age-required": ({ moduleName, className, funcName })=>{
128
- return `You must define either config.maxEntries or config.maxAgeSecondsin ${moduleName}.${className}.${funcName}`;
129
- },
130
- "statuses-or-headers-required": ({ moduleName, className, funcName })=>{
131
- return `You must define either config.statuses or config.headersin ${moduleName}.${className}.${funcName}`;
132
- },
133
- "invalid-string": ({ moduleName, funcName, paramName })=>{
134
- if (!paramName || !moduleName || !funcName) {
135
- throw new Error(`Unexpected input to 'invalid-string' error.`);
136
- }
137
- 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.`;
138
- },
139
- "channel-name-required": ()=>{
140
- return "You must provide a channelName to construct a " + "BroadcastCacheUpdate instance.";
141
- },
142
- "invalid-responses-are-same-args": ()=>{
143
- return "The arguments passed into responsesAreSame() appear to be " + "invalid. Please ensure valid Responses are used.";
144
- },
145
- "expire-custom-caches-only": ()=>{
146
- return `You must provide a 'cacheName' property when using the ` + "expiration plugin with a runtime caching strategy.";
147
- },
148
- "unit-must-be-bytes": ({ normalizedRangeHeader })=>{
149
- if (!normalizedRangeHeader) {
150
- throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
151
- }
152
- return `The 'unit' portion of the Range header must be set to 'bytes'. The Range header provided was "${normalizedRangeHeader}"`;
153
- },
154
- "single-range-only": ({ normalizedRangeHeader })=>{
155
- if (!normalizedRangeHeader) {
156
- throw new Error(`Unexpected input to 'single-range-only' error.`);
157
- }
158
- return `Multiple ranges are not supported. Please use a single start value, and optional end value. The Range header provided was "${normalizedRangeHeader}"`;
159
- },
160
- "invalid-range-values": ({ normalizedRangeHeader })=>{
161
- if (!normalizedRangeHeader) {
162
- throw new Error(`Unexpected input to 'invalid-range-values' error.`);
163
- }
164
- 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}"`;
165
- },
166
- "no-range-header": ()=>{
167
- return "No Range header was found in the Request provided.";
168
- },
169
- "range-not-satisfiable": ({ size, start, end })=>{
170
- return `The start (${start}) and end (${end}) values in the Range are ` + `not satisfiable by the cached response, which is ${size} bytes.`;
171
- },
172
- "attempt-to-cache-non-get-request": ({ url, method })=>{
173
- return `Unable to cache '${url}' because it is a '${method}' request and only 'GET' requests can be cached.`;
174
- },
175
- "cache-put-with-no-response": ({ url })=>{
176
- return `There was an attempt to cache '${url}' but the response was not defined.`;
177
- },
178
- "no-response": ({ url, error })=>{
179
- let message = `The strategy could not generate a response for '${url}'.`;
180
- if (error) {
181
- message += ` The underlying error is ${error}.`;
182
- }
183
- return message;
184
- },
185
- "bad-precaching-response": ({ url, status })=>{
186
- return `The precaching request for '${url}' failed${status ? ` with an HTTP status of ${status}.` : "."}`;
187
- },
188
- "non-precached-url": ({ url })=>{
189
- return `createHandlerBoundToURL('${url}') was called, but that URL is not precached. Please pass in a URL that is precached instead.`;
190
- },
191
- "add-to-cache-list-conflicting-integrities": ({ url })=>{
192
- return `Two of the entries passed to '@serwist/precaching.PrecacheController.addToCacheList()' had the URL ${url} with different integrity values. Please remove one of them.`;
193
- },
194
- "missing-precache-entry": ({ cacheName, url })=>{
195
- return `Unable to find a precached response in ${cacheName} for ${url}.`;
196
- },
197
- "cross-origin-copy-response": ({ origin })=>{
198
- return `@serwist/core.copyResponse() can only be used with same-origin responses. It was passed a response with origin ${origin}.`;
199
- },
200
- "opaque-streams-source": ({ type })=>{
201
- const message = `One of the @serwist/streams sources resulted in an '${type}' response.`;
202
- if (type === "opaqueredirect") {
203
- return `${message} Please do not use a navigation request that results in a redirect as a source.`;
204
- }
205
- return `${message} Please ensure your sources are CORS-enabled.`;
206
- }
207
- };
208
-
209
- const fallback = (code, ...args)=>{
210
- let msg = code;
211
- if (args.length > 0) {
212
- msg += ` :: ${JSON.stringify(args)}`;
213
- }
214
- return msg;
215
- };
216
- const generatorFunction = (code, details = {})=>{
217
- const message = messages[code];
218
- if (!message) {
219
- throw new Error(`Unable to find message for code '${code}'.`);
220
- }
221
- return message(details);
222
- };
223
- const messageGenerator = process.env.NODE_ENV === "production" ? fallback : generatorFunction;
224
-
225
- class SerwistError extends Error {
226
- details;
227
- constructor(errorCode, details){
228
- const message = messageGenerator(errorCode, details);
229
- super(message);
230
- this.name = errorCode;
231
- this.details = details;
232
- }
233
- }
234
-
235
- let supportStatus;
236
- function canConstructResponseFromBodyStream() {
237
- if (supportStatus === undefined) {
238
- const testResponse = new Response("");
239
- if ("body" in testResponse) {
240
- try {
241
- new Response(testResponse.body);
242
- supportStatus = true;
243
- } catch (error) {
244
- supportStatus = false;
245
- }
246
- }
247
- supportStatus = false;
248
- }
249
- return supportStatus;
250
- }
251
-
252
- const isArray = (value, details)=>{
253
- if (!Array.isArray(value)) {
254
- throw new SerwistError("not-an-array", details);
255
- }
256
- };
257
- const hasMethod = (object, expectedMethod, details)=>{
258
- const type = typeof object[expectedMethod];
259
- if (type !== "function") {
260
- details.expectedMethod = expectedMethod;
261
- throw new SerwistError("missing-a-method", details);
262
- }
263
- };
264
- const isType = (object, expectedType, details)=>{
265
- if (typeof object !== expectedType) {
266
- details.expectedType = expectedType;
267
- throw new SerwistError("incorrect-type", details);
268
- }
269
- };
270
- const isInstance = (object, expectedClass, details)=>{
271
- if (!(object instanceof expectedClass)) {
272
- details.expectedClassName = expectedClass.name;
273
- throw new SerwistError("incorrect-class", details);
274
- }
275
- };
276
- const isOneOf = (value, validValues, details)=>{
277
- if (!validValues.includes(value)) {
278
- details.validValueDescription = `Valid values are ${JSON.stringify(validValues)}.`;
279
- throw new SerwistError("invalid-value", details);
280
- }
281
- };
282
- const isArrayOfClass = (value, expectedClass, details)=>{
283
- const error = new SerwistError("not-array-of-class", details);
284
- if (!Array.isArray(value)) {
285
- throw error;
286
- }
287
- for (const item of value){
288
- if (!(item instanceof expectedClass)) {
289
- throw error;
290
- }
291
- }
292
- };
293
- const finalAssertExports = process.env.NODE_ENV === "production" ? null : {
294
- hasMethod,
295
- isArray,
296
- isInstance,
297
- isOneOf,
298
- isType,
299
- isArrayOfClass
300
- };
301
-
302
- const logger = process.env.NODE_ENV === "production" ? null : (()=>{
303
- if (!("__WB_DISABLE_DEV_LOGS" in globalThis)) {
304
- self.__WB_DISABLE_DEV_LOGS = false;
305
- }
306
- let inGroup = false;
307
- const methodToColorMap = {
308
- debug: "#7f8c8d",
309
- log: "#2ecc71",
310
- warn: "#f39c12",
311
- error: "#c0392b",
312
- groupCollapsed: "#3498db",
313
- groupEnd: null
314
- };
315
- const print = (method, args)=>{
316
- if (self.__WB_DISABLE_DEV_LOGS) {
317
- return;
318
- }
319
- if (method === "groupCollapsed") {
320
- if (typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
321
- console[method](...args);
322
- return;
323
- }
324
- }
325
- const styles = [
326
- `background: ${methodToColorMap[method]}`,
327
- "border-radius: 0.5em",
328
- "color: white",
329
- "font-weight: bold",
330
- "padding: 2px 0.5em"
331
- ];
332
- const logPrefix = inGroup ? [] : [
333
- "%cserwist",
334
- styles.join(";")
335
- ];
336
- console[method](...logPrefix, ...args);
337
- if (method === "groupCollapsed") {
338
- inGroup = true;
339
- }
340
- if (method === "groupEnd") {
341
- inGroup = false;
342
- }
343
- };
344
- const loggerMethods = Object.keys(methodToColorMap);
345
- return loggerMethods.reduce((api, method)=>{
346
- api[method] = (...args)=>{
347
- print(method, args);
348
- };
349
- return api;
350
- }, {});
351
- })();
352
-
353
- const quotaErrorCallbacks = new Set();
354
-
355
- export { SerwistError as S, canConstructResponseFromBodyStream as a, cacheNames as c, finalAssertExports as f, logger as l, quotaErrorCallbacks as q };
@@ -1,7 +0,0 @@
1
- /**
2
- * Claims any currently available clients once the service worker
3
- * becomes active. This is normally used in conjunction with `skipWaiting()`.
4
- */
5
- declare function clientsClaim(): void;
6
- export { clientsClaim };
7
- //# sourceMappingURL=clientsClaim.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Allows developers to copy a response and modify its `headers`, `status`,
3
- * or `statusText` values (the values settable via a
4
- * [`ResponseInit`](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#Syntax)
5
- * object in the constructor).
6
- * To modify these values, pass a function as the second argument. That
7
- * function will be invoked with a single object with the response properties
8
- * `{headers, status, statusText}`. The return value of this function will
9
- * be used as the `ResponseInit` for the new `Response`. To change the values
10
- * either modify the passed parameter(s) and return it, or return a totally
11
- * new object.
12
- *
13
- * This method is intentionally limited to same-origin responses, regardless of
14
- * whether CORS was used or not.
15
- *
16
- * @param response
17
- * @param modifier
18
- */
19
- declare function copyResponse(response: Response, modifier?: (responseInit: ResponseInit) => ResponseInit): Promise<Response>;
20
- export { copyResponse };
21
- //# sourceMappingURL=copyResponse.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,4 +0,0 @@
1
- import type { MapLikeObject } from "../../types.js";
2
- import { type MessageKey } from "./messages.js";
3
- export declare const messageGenerator: ((code: string, ...args: any[]) => string) | ((code: MessageKey, details?: MapLikeObject) => string);
4
- //# sourceMappingURL=messageGenerator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageGenerator.d.ts","sourceRoot":"","sources":["../../../src/models/messages/messageGenerator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,eAAe,CAAC;AAmB1D,eAAO,MAAM,gBAAgB,UAjBL,MAAM,WAAW,GAAG,EAAE,uBAQb,UAAU,YAAW,aAAa,YASiC,CAAC"}
@@ -1,44 +0,0 @@
1
- interface LoggableObject {
2
- [key: string]: string | number;
3
- }
4
- export declare const messages: {
5
- "invalid-value": ({ paramName, validValueDescription, value }: LoggableObject) => string;
6
- "not-an-array": ({ moduleName, className, funcName, paramName }: LoggableObject) => string;
7
- "incorrect-type": ({ expectedType, paramName, moduleName, className, funcName }: LoggableObject) => string;
8
- "incorrect-class": ({ expectedClassName, paramName, moduleName, className, funcName, isReturnValueProblem }: LoggableObject) => string;
9
- "missing-a-method": ({ expectedMethod, paramName, moduleName, className, funcName }: LoggableObject) => string;
10
- "add-to-cache-list-unexpected-type": ({ entry }: LoggableObject) => string;
11
- "add-to-cache-list-conflicting-entries": ({ firstEntry, secondEntry }: LoggableObject) => string;
12
- "plugin-error-request-will-fetch": ({ thrownErrorMessage }: LoggableObject) => string;
13
- "invalid-cache-name": ({ cacheNameId, value }: LoggableObject) => string;
14
- "unregister-route-but-not-found-with-method": ({ method }: LoggableObject) => string;
15
- "unregister-route-route-not-registered": () => string;
16
- "queue-replay-failed": ({ name }: LoggableObject) => string;
17
- "duplicate-queue-name": ({ name }: LoggableObject) => string;
18
- "expired-test-without-max-age": ({ methodName, paramName }: LoggableObject) => string;
19
- "unsupported-route-type": ({ moduleName, className, funcName, paramName }: LoggableObject) => string;
20
- "not-array-of-class": ({ value, expectedClass, moduleName, className, funcName, paramName }: LoggableObject) => string;
21
- "max-entries-or-age-required": ({ moduleName, className, funcName }: LoggableObject) => string;
22
- "statuses-or-headers-required": ({ moduleName, className, funcName }: LoggableObject) => string;
23
- "invalid-string": ({ moduleName, funcName, paramName }: LoggableObject) => string;
24
- "channel-name-required": () => string;
25
- "invalid-responses-are-same-args": () => string;
26
- "expire-custom-caches-only": () => string;
27
- "unit-must-be-bytes": ({ normalizedRangeHeader }: LoggableObject) => string;
28
- "single-range-only": ({ normalizedRangeHeader }: LoggableObject) => string;
29
- "invalid-range-values": ({ normalizedRangeHeader }: LoggableObject) => string;
30
- "no-range-header": () => string;
31
- "range-not-satisfiable": ({ size, start, end }: LoggableObject) => string;
32
- "attempt-to-cache-non-get-request": ({ url, method }: LoggableObject) => string;
33
- "cache-put-with-no-response": ({ url }: LoggableObject) => string;
34
- "no-response": ({ url, error }: LoggableObject) => string;
35
- "bad-precaching-response": ({ url, status }: LoggableObject) => string;
36
- "non-precached-url": ({ url }: LoggableObject) => string;
37
- "add-to-cache-list-conflicting-integrities": ({ url }: LoggableObject) => string;
38
- "missing-precache-entry": ({ cacheName, url }: LoggableObject) => string;
39
- "cross-origin-copy-response": ({ origin }: LoggableObject) => string;
40
- "opaque-streams-source": ({ type }: LoggableObject) => string;
41
- };
42
- export type MessageKey = keyof typeof messages;
43
- export {};
44
- //# sourceMappingURL=messages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/models/messages/messages.ts"],"names":[],"mappings":"AAQA,UAAU,cAAc;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAKD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuNC,CAAC;AAEvB,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,QAAQ,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare enum pluginEvents {
2
- CACHE_DID_UPDATE = "cacheDidUpdate",
3
- CACHE_KEY_WILL_BE_USED = "cacheKeyWillBeUsed",
4
- CACHE_WILL_UPDATE = "cacheWillUpdate",
5
- CACHED_RESPONSE_WILL_BE_USED = "cachedResponseWillBeUsed",
6
- FETCH_DID_FAIL = "fetchDidFail",
7
- FETCH_DID_SUCCEED = "fetchDidSucceed",
8
- REQUEST_WILL_FETCH = "requestWillFetch"
9
- }
10
- //# sourceMappingURL=pluginEvents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pluginEvents.d.ts","sourceRoot":"","sources":["../../src/models/pluginEvents.ts"],"names":[],"mappings":"AAQA,oBAAY,YAAY;IACtB,gBAAgB,mBAAmB;IACnC,sBAAsB,uBAAuB;IAC7C,iBAAiB,oBAAoB;IACrC,4BAA4B,6BAA6B;IACzD,cAAc,iBAAiB;IAC/B,iBAAiB,oBAAoB;IACrC,kBAAkB,qBAAqB;CACxC"}
@@ -1,3 +0,0 @@
1
- declare const quotaErrorCallbacks: Set<Function>;
2
- export { quotaErrorCallbacks };
3
- //# sourceMappingURL=quotaErrorCallbacks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"quotaErrorCallbacks.d.ts","sourceRoot":"","sources":["../../src/models/quotaErrorCallbacks.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,mBAAmB,EAAE,GAAG,CAAC,QAAQ,CAAa,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Adds a function to the set of quotaErrorCallbacks that will be executed if
3
- * there's a quota error.
4
- *
5
- * @param callback
6
- */
7
- declare function registerQuotaErrorCallback(callback: Function): void;
8
- export { registerQuotaErrorCallback };
9
- //# sourceMappingURL=registerQuotaErrorCallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerQuotaErrorCallback.d.ts","sourceRoot":"","sources":["../src/registerQuotaErrorCallback.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AAEH,iBAAS,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAc5D;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,10 +0,0 @@
1
- import type { PartialCacheNameDetails } from "./_private/cacheNames.js";
2
- /**
3
- * Modifies the default cache names used by Serwist packages.
4
- * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
5
- *
6
- * @param details
7
- */
8
- declare function setCacheNameDetails(details: PartialCacheNameDetails): void;
9
- export { setCacheNameDetails };
10
- //# sourceMappingURL=setCacheNameDetails.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setCacheNameDetails.d.ts","sourceRoot":"","sources":["../src/setCacheNameDetails.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGxE;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAiCnE;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}