@serwist/core 9.0.0-preview.9 → 9.0.0

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
package/dist/types.d.ts DELETED
@@ -1,279 +0,0 @@
1
- export type PromiseOrNot<T> = T | Promise<T>;
2
- export interface MapLikeObject {
3
- [key: string]: any;
4
- }
5
- /**
6
- * Using a plain `MapLikeObject` for now, but could extend/restrict this
7
- * in the future.
8
- */
9
- export type PluginState = MapLikeObject;
10
- /**
11
- * Options passed to a `RouteMatchCallback` function.
12
- */
13
- export interface RouteMatchCallbackOptions {
14
- event: ExtendableEvent;
15
- request: Request;
16
- sameOrigin: boolean;
17
- url: URL;
18
- }
19
- /**
20
- * The "match" callback is used to determine if a `Route` should apply for a
21
- * particular URL and request. When matching occurs in response to a fetch
22
- * event from the client, the `event` object is also supplied. However, since
23
- * the match callback can be invoked outside of a fetch event, matching logic
24
- * should not assume the `event` object will always be available.
25
- * If the match callback returns a truthy value, the matching route's
26
- * `RouteHandlerCallback` will be invoked immediately. If the value returned
27
- * is a non-empty array or object, that value will be set on the handler's
28
- * `options.params` argument.
29
- */
30
- export interface RouteMatchCallback {
31
- (options: RouteMatchCallbackOptions): any;
32
- }
33
- /**
34
- * Options passed to a `RouteHandlerCallback` function.
35
- */
36
- export declare interface RouteHandlerCallbackOptions {
37
- /**
38
- * The event associated with the request.
39
- */
40
- event: ExtendableEvent;
41
- /**
42
- * A request to run this strategy for.
43
- */
44
- request: Request;
45
- url: URL;
46
- /**
47
- * The return value from `@serwist/routing`'s `matchCallback` (if applicable).
48
- */
49
- params?: string[] | MapLikeObject;
50
- }
51
- /**
52
- * Options passed to a `ManualHandlerCallback` function.
53
- */
54
- export interface ManualHandlerCallbackOptions {
55
- /**
56
- * The event associated with the request.
57
- */
58
- event: ExtendableEvent;
59
- /**
60
- * A request to run this strategy for.
61
- */
62
- request: Request | string;
63
- }
64
- export type HandlerCallbackOptions = RouteHandlerCallbackOptions | ManualHandlerCallbackOptions;
65
- /**
66
- * The "handler" callback is invoked whenever a `Router` matches a URL/Request
67
- * to a `Route` via its `RouteMatchCallback`. This handler callback should
68
- * return a `Promise` that resolves with a `Response`.
69
- *
70
- * If a non-empty array or object is returned by the `RouteMatchCallback` it
71
- * will be passed in as this handler's `options.params` argument.
72
- */
73
- export interface RouteHandlerCallback {
74
- (options: RouteHandlerCallbackOptions): Promise<Response>;
75
- }
76
- /**
77
- * The "handler" callback is invoked whenever a `Router` matches a URL/Request
78
- * to a `Route` via its `RouteMatchCallback`. This handler callback should
79
- * return a `Promise` that resolves with a `Response`.
80
- *
81
- * If a non-empty array or object is returned by the `RouteMatchCallback` it
82
- * will be passed in as this handler's `options.params` argument.
83
- */
84
- export interface ManualHandlerCallback {
85
- (options: ManualHandlerCallbackOptions): Promise<Response>;
86
- }
87
- /**
88
- * An object with a `handle` method of type `RouteHandlerCallback`.
89
- *
90
- * A `Route` object can be created with either an `RouteHandlerCallback`
91
- * function or this `RouteHandler` object. The benefit of the `RouteHandler`
92
- * is it can be extended (as is done by the `@serwist/strategies` package).
93
- */
94
- export interface RouteHandlerObject {
95
- handle: RouteHandlerCallback;
96
- }
97
- /**
98
- * Either a `RouteHandlerCallback` or a `RouteHandlerObject`.
99
- * Most APIs in `@serwist/routing` that accept route handlers take either.
100
- */
101
- export type RouteHandler = RouteHandlerCallback | RouteHandlerObject;
102
- export interface HandlerWillStartCallbackParam {
103
- request: Request;
104
- event: ExtendableEvent;
105
- state?: PluginState;
106
- }
107
- export interface HandlerWillStartCallback {
108
- (param: HandlerWillStartCallbackParam): Promise<any>;
109
- }
110
- export interface CacheDidUpdateCallbackParam {
111
- /**
112
- * Name of the cache the responses belong to. This is included in the
113
- * broadcast message.
114
- */
115
- cacheName: string;
116
- /**
117
- * Possibly updated response to compare.
118
- */
119
- newResponse: Response;
120
- /**
121
- * The `Request` object for the cached entry.
122
- */
123
- request: Request;
124
- /**
125
- * The event that triggered this possible cache update.
126
- */
127
- event: ExtendableEvent;
128
- /**
129
- * Cached response to compare.
130
- */
131
- oldResponse?: Response | null;
132
- state?: PluginState;
133
- }
134
- export interface CacheDidUpdateCallback {
135
- (param: CacheDidUpdateCallbackParam): PromiseOrNot<any>;
136
- }
137
- export interface CacheKeyWillBeUsedCallbackParam {
138
- mode: string;
139
- request: Request;
140
- event: ExtendableEvent;
141
- params?: any;
142
- state?: PluginState;
143
- }
144
- export interface CacheKeyWillBeUsedCallback {
145
- (param: CacheKeyWillBeUsedCallbackParam): PromiseOrNot<Request | string>;
146
- }
147
- export interface CacheWillUpdateCallbackParam {
148
- request: Request;
149
- response: Response;
150
- event: ExtendableEvent;
151
- state?: PluginState;
152
- }
153
- export interface CacheWillUpdateCallback {
154
- (param: CacheWillUpdateCallbackParam): PromiseOrNot<any>;
155
- }
156
- export interface CachedResponseWillBeUsedCallbackParam {
157
- /**
158
- * Name of the cache the response is in.
159
- */
160
- cacheName: string;
161
- /**
162
- * The original request, which may or may not
163
- * contain a Range: header.
164
- */
165
- request: Request;
166
- /**
167
- * The complete cached `Response` object that's been read
168
- * from a cache and whose freshness should be checked.
169
- */
170
- cachedResponse?: Response;
171
- event: ExtendableEvent;
172
- matchOptions?: CacheQueryOptions;
173
- state?: PluginState;
174
- }
175
- export interface CachedResponseWillBeUsedCallback {
176
- (param: CachedResponseWillBeUsedCallbackParam): PromiseOrNot<any>;
177
- }
178
- export interface FetchDidFailCallbackParam {
179
- error: Error;
180
- originalRequest: Request;
181
- request: Request;
182
- event: ExtendableEvent;
183
- state?: PluginState;
184
- }
185
- export interface FetchDidFailCallback {
186
- (param: FetchDidFailCallbackParam): PromiseOrNot<any>;
187
- }
188
- export interface FetchDidSucceedCallbackParam {
189
- request: Request;
190
- response: Response;
191
- event: ExtendableEvent;
192
- state?: PluginState;
193
- }
194
- export interface FetchDidSucceedCallback {
195
- (param: FetchDidSucceedCallbackParam): PromiseOrNot<Response>;
196
- }
197
- export interface RequestWillFetchCallbackParam {
198
- request: Request;
199
- event: ExtendableEvent;
200
- state?: PluginState;
201
- }
202
- export interface RequestWillFetchCallback {
203
- (param: RequestWillFetchCallbackParam): PromiseOrNot<Request>;
204
- }
205
- export interface HandlerWillRespondCallbackParam {
206
- request: Request;
207
- response: Response;
208
- event: ExtendableEvent;
209
- state?: PluginState;
210
- }
211
- export interface HandlerWillRespondCallback {
212
- (param: HandlerWillRespondCallbackParam): PromiseOrNot<Response>;
213
- }
214
- export interface HandlerDidErrorCallbackParam {
215
- request: Request;
216
- event: ExtendableEvent;
217
- error: Error;
218
- state?: PluginState;
219
- }
220
- export interface HandlerDidErrorCallback {
221
- (param: HandlerDidErrorCallbackParam): PromiseOrNot<Response | undefined>;
222
- }
223
- export interface HandlerDidRespondCallbackParam {
224
- request: Request;
225
- event: ExtendableEvent;
226
- response?: Response;
227
- state?: PluginState;
228
- }
229
- export interface HandlerDidRespondCallback {
230
- (param: HandlerDidRespondCallbackParam): PromiseOrNot<any>;
231
- }
232
- export interface HandlerDidCompleteCallbackParam {
233
- request: Request;
234
- error?: Error;
235
- event: ExtendableEvent;
236
- response?: Response;
237
- state?: PluginState;
238
- }
239
- export interface HandlerDidCompleteCallback {
240
- (param: HandlerDidCompleteCallbackParam): PromiseOrNot<any>;
241
- }
242
- /**
243
- * An object with optional lifecycle callback properties for the fetch and
244
- * cache operations.
245
- */
246
- export declare interface SerwistPlugin {
247
- cacheDidUpdate?: CacheDidUpdateCallback;
248
- cachedResponseWillBeUsed?: CachedResponseWillBeUsedCallback;
249
- cacheKeyWillBeUsed?: CacheKeyWillBeUsedCallback;
250
- cacheWillUpdate?: CacheWillUpdateCallback;
251
- fetchDidFail?: FetchDidFailCallback;
252
- fetchDidSucceed?: FetchDidSucceedCallback;
253
- handlerDidComplete?: HandlerDidCompleteCallback;
254
- handlerDidError?: HandlerDidErrorCallback;
255
- handlerDidRespond?: HandlerDidRespondCallback;
256
- handlerWillRespond?: HandlerWillRespondCallback;
257
- handlerWillStart?: HandlerWillStartCallback;
258
- requestWillFetch?: RequestWillFetchCallback;
259
- }
260
- export interface SerwistPluginCallbackParam {
261
- cacheDidUpdate: CacheDidUpdateCallbackParam;
262
- cachedResponseWillBeUsed: CachedResponseWillBeUsedCallbackParam;
263
- cacheKeyWillBeUsed: CacheKeyWillBeUsedCallbackParam;
264
- cacheWillUpdate: CacheWillUpdateCallbackParam;
265
- fetchDidFail: FetchDidFailCallbackParam;
266
- fetchDidSucceed: FetchDidSucceedCallbackParam;
267
- handlerDidComplete: HandlerDidCompleteCallbackParam;
268
- handlerDidError: HandlerDidErrorCallbackParam;
269
- handlerDidRespond: HandlerDidRespondCallbackParam;
270
- handlerWillRespond: HandlerWillRespondCallbackParam;
271
- handlerWillStart: HandlerWillStartCallbackParam;
272
- requestWillFetch: RequestWillFetchCallbackParam;
273
- }
274
- export interface SerwistGlobalConfig {
275
- __WB_DISABLE_DEV_LOGS: boolean;
276
- __WB_FORCE_RUNTIME_CACHING: boolean;
277
- __WB_CONCURRENT_PRECACHING: number;
278
- }
279
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,WAAW,aAA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Ae,CAAC,EAAE,uBAAuB,CAAC;IAC1C,kBAAkB,CAAC,EAAE,0BAA0B,CAAC;IAChD,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IAC9C,kBAAkB,CAAC,EAAE,0BAA0B,CAAC;IAChD,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,2BAA2B,CAAC;IAC5C,wBAAwB,EAAE,qCAAqC,CAAC;IAChE,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,eAAe,EAAE,4BAA4B,CAAC;IAC9C,YAAY,EAAE,yBAAyB,CAAC;IACxC,eAAe,EAAE,4BAA4B,CAAC;IAC9C,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,eAAe,EAAE,4BAA4B,CAAC;IAC9C,iBAAiB,EAAE,8BAA8B,CAAC;IAClD,kBAAkB,EAAE,+BAA+B,CAAC;IACpD,gBAAgB,EAAE,6BAA6B,CAAC;IAChD,gBAAgB,EAAE,6BAA6B,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,0BAA0B,EAAE,OAAO,CAAC;IACpC,0BAA0B,EAAE,MAAM,CAAC;CACpC"}
@@ -1,5 +0,0 @@
1
- import type { SerwistPlugin } from "../types.js";
2
- export declare const pluginUtils: {
3
- filter: (plugins: SerwistPlugin[], callbackName: string) => SerwistPlugin[];
4
- };
5
- //# sourceMappingURL=pluginUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pluginUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pluginUtils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,eAAO,MAAM,WAAW;sBACJ,aAAa,EAAE,gBAAgB,MAAM,KAAG,aAAa,EAAE;CAG1E,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=welcome.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"welcome.d.ts","sourceRoot":"","sources":["../../src/utils/welcome.ts"],"names":[],"mappings":""}
@@ -1,33 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- /**
10
- * The Deferred class composes Promises in a way that allows for them to be
11
- * resolved or rejected from outside the constructor. In most cases promises
12
- * should be used directly, but Deferreds can be necessary when the logic to
13
- * resolve a promise must be separate.
14
- *
15
- * @private
16
- */
17
- class Deferred<T> {
18
- promise: Promise<T>;
19
- resolve!: (value: T) => void;
20
- reject!: (reason?: any) => void;
21
-
22
- /**
23
- * Creates a promise and exposes its resolve and reject functions as methods.
24
- */
25
- constructor() {
26
- this.promise = new Promise((resolve, reject) => {
27
- this.resolve = resolve;
28
- this.reject = reject;
29
- });
30
- }
31
- }
32
-
33
- export { Deferred };
@@ -1,43 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import { messageGenerator } from "../models/messages/messageGenerator.js";
10
- import type { MessageKey } from "../models/messages/messages.js";
11
- import type { MapLikeObject } from "../types.js";
12
-
13
- /**
14
- * Serwist errors should be thrown with this class.
15
- * This allows use to ensure the type easily in tests,
16
- * helps developers identify errors from Serwist
17
- * easily and allows use to optimise error
18
- * messages correctly.
19
- *
20
- * @private
21
- */
22
- class SerwistError extends Error {
23
- details?: MapLikeObject;
24
-
25
- /**
26
- *
27
- * @param errorCode The error code that
28
- * identifies this particular error.
29
- * @param details Any relevant arguments
30
- * that will help developers identify issues should
31
- * be added as a key on the context object.
32
- */
33
- constructor(errorCode: MessageKey, details?: MapLikeObject) {
34
- const message = messageGenerator(errorCode, details);
35
-
36
- super(message);
37
-
38
- this.name = errorCode;
39
- this.details = details;
40
- }
41
- }
42
-
43
- export { SerwistError };
@@ -1,89 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import { SerwistError } from "../_private/SerwistError.js";
10
- import type { MapLikeObject } from "../types.js";
11
-
12
- /*
13
- * This method throws if the supplied value is not an array.
14
- * The destructed values are required to produce a meaningful error for users.
15
- * The destructed and restructured object is so it's clear what is
16
- * needed.
17
- */
18
- const isArray = (value: any[], details: MapLikeObject) => {
19
- if (!Array.isArray(value)) {
20
- throw new SerwistError("not-an-array", details);
21
- }
22
- };
23
-
24
- const hasMethod = (object: MapLikeObject, expectedMethod: string, details: MapLikeObject) => {
25
- const type = typeof object[expectedMethod];
26
- if (type !== "function") {
27
- details.expectedMethod = expectedMethod;
28
- throw new SerwistError("missing-a-method", details);
29
- }
30
- };
31
-
32
- const isType = (object: unknown, expectedType: string, details: MapLikeObject) => {
33
- // biome-ignore lint/suspicious/useValidTypeof: Know to not make a mistake...
34
- if (typeof object !== expectedType) {
35
- details.expectedType = expectedType;
36
- throw new SerwistError("incorrect-type", details);
37
- }
38
- };
39
-
40
- const isInstance = (
41
- object: unknown,
42
- // biome-ignore lint/complexity/noBannedTypes: Need the general type to do the check later.
43
- expectedClass: Function,
44
- details: MapLikeObject,
45
- ) => {
46
- if (!(object instanceof expectedClass)) {
47
- details.expectedClassName = expectedClass.name;
48
- throw new SerwistError("incorrect-class", details);
49
- }
50
- };
51
-
52
- const isOneOf = (value: any, validValues: any[], details: MapLikeObject) => {
53
- if (!validValues.includes(value)) {
54
- details.validValueDescription = `Valid values are ${JSON.stringify(validValues)}.`;
55
- throw new SerwistError("invalid-value", details);
56
- }
57
- };
58
-
59
- const isArrayOfClass = (
60
- value: any,
61
- // biome-ignore lint/complexity/noBannedTypes: Need general type to do check later.
62
- expectedClass: Function,
63
- details: MapLikeObject,
64
- ) => {
65
- const error = new SerwistError("not-array-of-class", details);
66
- if (!Array.isArray(value)) {
67
- throw error;
68
- }
69
-
70
- for (const item of value) {
71
- if (!(item instanceof expectedClass)) {
72
- throw error;
73
- }
74
- }
75
- };
76
-
77
- const finalAssertExports =
78
- process.env.NODE_ENV === "production"
79
- ? null
80
- : {
81
- hasMethod,
82
- isArray,
83
- isInstance,
84
- isOneOf,
85
- isType,
86
- isArrayOfClass,
87
- };
88
-
89
- export { finalAssertExports as assert };
@@ -1,54 +0,0 @@
1
- /*
2
- Copyright 2020 Google LLC
3
- Use of this source code is governed by an MIT-style
4
- license that can be found in the LICENSE file or at
5
- https://opensource.org/licenses/MIT.
6
- */
7
-
8
- function stripParams(fullURL: string, ignoreParams: string[]) {
9
- const strippedURL = new URL(fullURL);
10
- for (const param of ignoreParams) {
11
- strippedURL.searchParams.delete(param);
12
- }
13
- return strippedURL.href;
14
- }
15
-
16
- /**
17
- * Matches an item in the cache, ignoring specific URL params. This is similar
18
- * to the `ignoreSearch` option, but it allows you to ignore just specific
19
- * params (while continuing to match on the others).
20
- *
21
- * @private
22
- * @param cache
23
- * @param request
24
- * @param matchOptions
25
- * @param ignoreParams
26
- * @returns
27
- */
28
- async function cacheMatchIgnoreParams(
29
- cache: Cache,
30
- request: Request,
31
- ignoreParams: string[],
32
- matchOptions?: CacheQueryOptions,
33
- ): Promise<Response | undefined> {
34
- const strippedRequestURL = stripParams(request.url, ignoreParams);
35
-
36
- // If the request doesn't include any ignored params, match as normal.
37
- if (request.url === strippedRequestURL) {
38
- return cache.match(request, matchOptions);
39
- }
40
-
41
- // Otherwise, match by comparing keys
42
- const keysOptions = { ...matchOptions, ignoreSearch: true };
43
- const cacheKeys = await cache.keys(request, keysOptions);
44
-
45
- for (const cacheKey of cacheKeys) {
46
- const strippedCacheKeyURL = stripParams(cacheKey.url, ignoreParams);
47
- if (strippedRequestURL === strippedCacheKeyURL) {
48
- return cache.match(cacheKey, matchOptions);
49
- }
50
- }
51
- return;
52
- }
53
-
54
- export { cacheMatchIgnoreParams };
@@ -1,87 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- declare let registration: ServiceWorkerRegistration | undefined;
10
-
11
- export interface CacheNameDetails {
12
- googleAnalytics: string;
13
- precache: string;
14
- prefix: string;
15
- runtime: string;
16
- suffix: string;
17
- }
18
-
19
- export interface PartialCacheNameDetails {
20
- /**
21
- * The string to add to the beginning of the precache and runtime cache names.
22
- */
23
- prefix?: string;
24
- /**
25
- * The string to add to the end of the precache and runtime cache names.
26
- */
27
- suffix?: string;
28
- /**
29
- * The cache name to use for precache caching.
30
- */
31
- precache?: string;
32
- /**
33
- * The cache name to use for runtime caching.
34
- */
35
- runtime?: string;
36
- /**
37
- * The cache name to use for `@serwist/google-analytics` caching.
38
- */
39
- googleAnalytics?: string;
40
- [propName: string]: string | undefined;
41
- }
42
-
43
- export type CacheNameDetailsProp = "googleAnalytics" | "precache" | "prefix" | "runtime" | "suffix";
44
-
45
- const _cacheNameDetails: CacheNameDetails = {
46
- googleAnalytics: "googleAnalytics",
47
- precache: "precache-v2",
48
- prefix: "serwist",
49
- runtime: "runtime",
50
- suffix: typeof registration !== "undefined" ? registration.scope : "",
51
- };
52
-
53
- const _createCacheName = (cacheName: string): string => {
54
- return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter((value) => value && value.length > 0).join("-");
55
- };
56
-
57
- const eachCacheNameDetail = (fn: (key: CacheNameDetailsProp) => void): void => {
58
- for (const key of Object.keys(_cacheNameDetails)) {
59
- fn(key as CacheNameDetailsProp);
60
- }
61
- };
62
-
63
- export const cacheNames = {
64
- updateDetails: (details: PartialCacheNameDetails): void => {
65
- eachCacheNameDetail((key: CacheNameDetailsProp): void => {
66
- const detail = details[key];
67
- if (typeof detail === "string") {
68
- _cacheNameDetails[key] = detail;
69
- }
70
- });
71
- },
72
- getGoogleAnalyticsName: (userCacheName?: string): string => {
73
- return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
74
- },
75
- getPrecacheName: (userCacheName?: string): string => {
76
- return userCacheName || _createCacheName(_cacheNameDetails.precache);
77
- },
78
- getPrefix: (): string => {
79
- return _cacheNameDetails.prefix;
80
- },
81
- getRuntimeName: (userCacheName?: string): string => {
82
- return userCacheName || _createCacheName(_cacheNameDetails.runtime);
83
- },
84
- getSuffix: (): string => {
85
- return _cacheNameDetails.suffix;
86
- },
87
- };
@@ -1,34 +0,0 @@
1
- /*
2
- Copyright 2019 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- let supportStatus: boolean | undefined;
10
-
11
- /**
12
- * A utility function that determines whether the current browser supports
13
- * constructing a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
14
- * object.
15
- *
16
- * @returns `true`, if the current browser can successfully construct a `ReadableStream`, `false` otherwise.
17
- *
18
- * @private
19
- */
20
- function canConstructReadableStream(): boolean {
21
- if (supportStatus === undefined) {
22
- // See https://github.com/GoogleChrome/workbox/issues/1473
23
- try {
24
- new ReadableStream({ start() {} });
25
- supportStatus = true;
26
- } catch (error) {
27
- supportStatus = false;
28
- }
29
- }
30
-
31
- return supportStatus;
32
- }
33
-
34
- export { canConstructReadableStream };
@@ -1,37 +0,0 @@
1
- /*
2
- Copyright 2019 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- let supportStatus: boolean | undefined;
10
-
11
- /**
12
- * A utility function that determines whether the current browser supports
13
- * constructing a new `Response` from a `response.body` stream.
14
- *
15
- * @returns `true`, if the current browser can successfully construct
16
- * a `Response` from a `response.body` stream, `false` otherwise.
17
- * @private
18
- */
19
- function canConstructResponseFromBodyStream(): boolean {
20
- if (supportStatus === undefined) {
21
- const testResponse = new Response("");
22
-
23
- if ("body" in testResponse) {
24
- try {
25
- new Response(testResponse.body);
26
- supportStatus = true;
27
- } catch (error) {
28
- supportStatus = false;
29
- }
30
- }
31
- supportStatus = false;
32
- }
33
-
34
- return supportStatus;
35
- }
36
-
37
- export { canConstructResponseFromBodyStream };