@serwist/core 9.0.0-preview.1 → 9.0.0-preview.10
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/_private/SerwistError.d.ts +2 -1
- package/dist/_private/SerwistError.d.ts.map +1 -1
- package/dist/_private/logger.d.ts +15 -2
- package/dist/_private/logger.d.ts.map +1 -1
- package/dist/_private/waitUntil.d.ts +1 -2
- package/dist/_private/waitUntil.d.ts.map +1 -1
- package/dist/chunks/quotaErrorCallbacks.js +4 -6
- package/dist/clientsClaim.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.internal.js +2 -2
- package/dist/models/messages/messageGenerator.d.ts +3 -1
- package/dist/models/messages/messageGenerator.d.ts.map +1 -1
- package/dist/models/messages/messages.d.ts +39 -4
- package/dist/models/messages/messages.d.ts.map +1 -1
- package/dist/setCacheNameDetails.d.ts +1 -1
- package/dist/types.d.ts +17 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/_private/SerwistError.ts +2 -1
- package/src/_private/logger.ts +24 -21
- package/src/_private/waitUntil.ts +2 -4
- package/src/clientsClaim.ts +1 -1
- package/src/index.ts +1 -1
- package/src/models/messages/messageGenerator.ts +3 -2
- package/src/models/messages/messages.ts +5 -3
- package/src/setCacheNameDetails.ts +1 -1
- package/src/types.ts +18 -11
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageKey } from "../models/messages/messages.js";
|
|
1
2
|
import type { MapLikeObject } from "../types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Serwist errors should be thrown with this class.
|
|
@@ -18,7 +19,7 @@ declare class SerwistError extends Error {
|
|
|
18
19
|
* that will help developers identify issues should
|
|
19
20
|
* be added as a key on the context object.
|
|
20
21
|
*/
|
|
21
|
-
constructor(errorCode:
|
|
22
|
+
constructor(errorCode: MessageKey, details?: MapLikeObject);
|
|
22
23
|
}
|
|
23
24
|
export { SerwistError };
|
|
24
25
|
//# sourceMappingURL=SerwistError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerwistError.d.ts","sourceRoot":"","sources":["../../src/_private/SerwistError.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;GAQG;AACH,cAAM,YAAa,SAAQ,KAAK;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;;;;OAOG;gBACS,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"SerwistError.d.ts","sourceRoot":"","sources":["../../src/_private/SerwistError.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;GAQG;AACH,cAAM,YAAa,SAAQ,KAAK;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;;;;OAOG;gBACS,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,aAAa;CAQ3D;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -6,6 +6,19 @@ declare global {
|
|
|
6
6
|
__WB_DISABLE_DEV_LOGS: boolean;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The logger used by Serwist inside of both service workers and the window global scope.
|
|
11
|
+
*
|
|
12
|
+
* Note: This is forcibly `null` in production mode to reduce bundle size. Do check whether
|
|
13
|
+
* you are currently in development mode (by using `process.env.NODE_ENV !== "production"`)
|
|
14
|
+
* before using it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const logger: {
|
|
17
|
+
error: (...args: any[]) => void;
|
|
18
|
+
debug: (...args: any[]) => void;
|
|
19
|
+
log: (...args: any[]) => void;
|
|
20
|
+
warn: (...args: any[]) => void;
|
|
21
|
+
groupCollapsed: (...args: any[]) => void;
|
|
22
|
+
groupEnd: (...args: any[]) => void;
|
|
23
|
+
};
|
|
11
24
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/_private/logger.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB,qBAAqB,EAAE,OAAO,CAAC;KAChC;IAED,UAAU,MAAM;QACd,qBAAqB,EAAE,OAAO,CAAC;KAChC;CACF;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/_private/logger.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB,qBAAqB,EAAE,OAAO,CAAC;KAChC;IAED,UAAU,MAAM;QACd,qBAAqB,EAAE,OAAO,CAAC;KAChC;CACF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;qBAmEoC,GAAG,EAAE,KAAK,IAAI;qBAAd,GAAG,EAAE,KAAK,IAAI;mBAAd,GAAG,EAAE,KAAK,IAAI;oBAAd,GAAG,EAAE,KAAK,IAAI;8BAAd,GAAG,EAAE,KAAK,IAAI;wBAAd,GAAG,EAAE,KAAK,IAAI;CAE3D,CAAC"}
|
|
@@ -7,6 +7,5 @@
|
|
|
7
7
|
* @returns
|
|
8
8
|
* @private
|
|
9
9
|
*/
|
|
10
|
-
declare
|
|
11
|
-
export { waitUntil };
|
|
10
|
+
export declare const waitUntil: <T = any>(event: ExtendableEvent, asyncFn: () => Promise<T>) => Promise<T>;
|
|
12
11
|
//# sourceMappingURL=waitUntil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../src/_private/waitUntil.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,
|
|
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"}
|
|
@@ -92,7 +92,7 @@ const messages = {
|
|
|
92
92
|
if (!thrownErrorMessage) {
|
|
93
93
|
throw new Error("Unexpected input to " + `'plugin-error-request-will-fetch', error.`);
|
|
94
94
|
}
|
|
95
|
-
return `An error was thrown by a
|
|
95
|
+
return `An error was thrown by a plugin's 'requestWillFetch()' method. The thrown error message was: '${thrownErrorMessage}'.`;
|
|
96
96
|
},
|
|
97
97
|
"invalid-cache-name": ({ cacheNameId, value })=>{
|
|
98
98
|
if (!cacheNameId) {
|
|
@@ -341,15 +341,13 @@ const logger = process.env.NODE_ENV === "production" ? null : (()=>{
|
|
|
341
341
|
inGroup = false;
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
|
-
const api = {};
|
|
345
344
|
const loggerMethods = Object.keys(methodToColorMap);
|
|
346
|
-
|
|
347
|
-
const method = key;
|
|
345
|
+
return loggerMethods.reduce((api, method)=>{
|
|
348
346
|
api[method] = (...args)=>{
|
|
349
347
|
print(method, args);
|
|
350
348
|
};
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
return api;
|
|
350
|
+
}, {});
|
|
353
351
|
})();
|
|
354
352
|
|
|
355
353
|
const quotaErrorCallbacks = new Set();
|
package/dist/clientsClaim.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ import { setCacheNameDetails } from "./setCacheNameDetails.js";
|
|
|
8
8
|
* setting default values that need to be shared (like cache names).
|
|
9
9
|
*/
|
|
10
10
|
export { cacheNames, clientsClaim, copyResponse, registerQuotaErrorCallback, setCacheNameDetails };
|
|
11
|
-
export * from "./types.js";
|
|
11
|
+
export type * from "./types.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,CAAC;AAEnG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,CAAC;AAEnG,mBAAmB,YAAY,CAAC"}
|
package/dist/index.internal.js
CHANGED
|
@@ -111,10 +111,10 @@ async function resultingClientExists(resultingClientId) {
|
|
|
111
111
|
return resultingWindow;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
const waitUntil = (event, asyncFn)=>{
|
|
115
115
|
const returnPromise = asyncFn();
|
|
116
116
|
event.waitUntil(returnPromise);
|
|
117
117
|
return returnPromise;
|
|
118
|
-
}
|
|
118
|
+
};
|
|
119
119
|
|
|
120
120
|
export { Deferred, cacheMatchIgnoreParams, canConstructReadableStream, dontWaitFor, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil };
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
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);
|
|
2
4
|
//# sourceMappingURL=messageGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageGenerator.d.ts","sourceRoot":"","sources":["../../../src/models/messages/messageGenerator.ts"],"names":[],"mappings":"
|
|
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,9 +1,44 @@
|
|
|
1
1
|
interface LoggableObject {
|
|
2
2
|
[key: string]: string | number;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
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;
|
|
8
43
|
export {};
|
|
9
44
|
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import type { PartialCacheNameDetails } from "./_private/cacheNames.js";
|
|
2
2
|
/**
|
|
3
|
-
* Modifies the default cache names used by
|
|
3
|
+
* Modifies the default cache names used by Serwist packages.
|
|
4
4
|
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
|
|
5
5
|
*
|
|
6
6
|
* @param details
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type PromiseOrNot<T> = T | Promise<T>;
|
|
1
2
|
export interface MapLikeObject {
|
|
2
3
|
[key: string]: any;
|
|
3
4
|
}
|
|
@@ -131,7 +132,7 @@ export interface CacheDidUpdateCallbackParam {
|
|
|
131
132
|
state?: PluginState;
|
|
132
133
|
}
|
|
133
134
|
export interface CacheDidUpdateCallback {
|
|
134
|
-
(param: CacheDidUpdateCallbackParam):
|
|
135
|
+
(param: CacheDidUpdateCallbackParam): PromiseOrNot<any>;
|
|
135
136
|
}
|
|
136
137
|
export interface CacheKeyWillBeUsedCallbackParam {
|
|
137
138
|
mode: string;
|
|
@@ -141,7 +142,7 @@ export interface CacheKeyWillBeUsedCallbackParam {
|
|
|
141
142
|
state?: PluginState;
|
|
142
143
|
}
|
|
143
144
|
export interface CacheKeyWillBeUsedCallback {
|
|
144
|
-
(param: CacheKeyWillBeUsedCallbackParam):
|
|
145
|
+
(param: CacheKeyWillBeUsedCallbackParam): PromiseOrNot<Request | string>;
|
|
145
146
|
}
|
|
146
147
|
export interface CacheWillUpdateCallbackParam {
|
|
147
148
|
request: Request;
|
|
@@ -150,7 +151,7 @@ export interface CacheWillUpdateCallbackParam {
|
|
|
150
151
|
state?: PluginState;
|
|
151
152
|
}
|
|
152
153
|
export interface CacheWillUpdateCallback {
|
|
153
|
-
(param: CacheWillUpdateCallbackParam):
|
|
154
|
+
(param: CacheWillUpdateCallbackParam): PromiseOrNot<any>;
|
|
154
155
|
}
|
|
155
156
|
export interface CachedResponseWillBeUsedCallbackParam {
|
|
156
157
|
/**
|
|
@@ -172,7 +173,7 @@ export interface CachedResponseWillBeUsedCallbackParam {
|
|
|
172
173
|
state?: PluginState;
|
|
173
174
|
}
|
|
174
175
|
export interface CachedResponseWillBeUsedCallback {
|
|
175
|
-
(param: CachedResponseWillBeUsedCallbackParam):
|
|
176
|
+
(param: CachedResponseWillBeUsedCallbackParam): PromiseOrNot<any>;
|
|
176
177
|
}
|
|
177
178
|
export interface FetchDidFailCallbackParam {
|
|
178
179
|
error: Error;
|
|
@@ -182,7 +183,7 @@ export interface FetchDidFailCallbackParam {
|
|
|
182
183
|
state?: PluginState;
|
|
183
184
|
}
|
|
184
185
|
export interface FetchDidFailCallback {
|
|
185
|
-
(param: FetchDidFailCallbackParam):
|
|
186
|
+
(param: FetchDidFailCallbackParam): PromiseOrNot<any>;
|
|
186
187
|
}
|
|
187
188
|
export interface FetchDidSucceedCallbackParam {
|
|
188
189
|
request: Request;
|
|
@@ -191,7 +192,7 @@ export interface FetchDidSucceedCallbackParam {
|
|
|
191
192
|
state?: PluginState;
|
|
192
193
|
}
|
|
193
194
|
export interface FetchDidSucceedCallback {
|
|
194
|
-
(param: FetchDidSucceedCallbackParam):
|
|
195
|
+
(param: FetchDidSucceedCallbackParam): PromiseOrNot<Response>;
|
|
195
196
|
}
|
|
196
197
|
export interface RequestWillFetchCallbackParam {
|
|
197
198
|
request: Request;
|
|
@@ -199,7 +200,7 @@ export interface RequestWillFetchCallbackParam {
|
|
|
199
200
|
state?: PluginState;
|
|
200
201
|
}
|
|
201
202
|
export interface RequestWillFetchCallback {
|
|
202
|
-
(param: RequestWillFetchCallbackParam):
|
|
203
|
+
(param: RequestWillFetchCallbackParam): PromiseOrNot<Request>;
|
|
203
204
|
}
|
|
204
205
|
export interface HandlerWillRespondCallbackParam {
|
|
205
206
|
request: Request;
|
|
@@ -208,7 +209,7 @@ export interface HandlerWillRespondCallbackParam {
|
|
|
208
209
|
state?: PluginState;
|
|
209
210
|
}
|
|
210
211
|
export interface HandlerWillRespondCallback {
|
|
211
|
-
(param: HandlerWillRespondCallbackParam):
|
|
212
|
+
(param: HandlerWillRespondCallbackParam): PromiseOrNot<Response>;
|
|
212
213
|
}
|
|
213
214
|
export interface HandlerDidErrorCallbackParam {
|
|
214
215
|
request: Request;
|
|
@@ -217,7 +218,7 @@ export interface HandlerDidErrorCallbackParam {
|
|
|
217
218
|
state?: PluginState;
|
|
218
219
|
}
|
|
219
220
|
export interface HandlerDidErrorCallback {
|
|
220
|
-
(param: HandlerDidErrorCallbackParam):
|
|
221
|
+
(param: HandlerDidErrorCallbackParam): PromiseOrNot<Response | undefined>;
|
|
221
222
|
}
|
|
222
223
|
export interface HandlerDidRespondCallbackParam {
|
|
223
224
|
request: Request;
|
|
@@ -226,7 +227,7 @@ export interface HandlerDidRespondCallbackParam {
|
|
|
226
227
|
state?: PluginState;
|
|
227
228
|
}
|
|
228
229
|
export interface HandlerDidRespondCallback {
|
|
229
|
-
(param: HandlerDidRespondCallbackParam):
|
|
230
|
+
(param: HandlerDidRespondCallbackParam): PromiseOrNot<any>;
|
|
230
231
|
}
|
|
231
232
|
export interface HandlerDidCompleteCallbackParam {
|
|
232
233
|
request: Request;
|
|
@@ -236,7 +237,7 @@ export interface HandlerDidCompleteCallbackParam {
|
|
|
236
237
|
state?: PluginState;
|
|
237
238
|
}
|
|
238
239
|
export interface HandlerDidCompleteCallback {
|
|
239
|
-
(param: HandlerDidCompleteCallbackParam):
|
|
240
|
+
(param: HandlerDidCompleteCallbackParam): PromiseOrNot<any>;
|
|
240
241
|
}
|
|
241
242
|
/**
|
|
242
243
|
* An object with optional lifecycle callback properties for the fetch and
|
|
@@ -270,4 +271,9 @@ export interface SerwistPluginCallbackParam {
|
|
|
270
271
|
handlerWillStart: HandlerWillStartCallbackParam;
|
|
271
272
|
requestWillFetch: RequestWillFetchCallbackParam;
|
|
272
273
|
}
|
|
274
|
+
export interface SerwistGlobalConfig {
|
|
275
|
+
__WB_DISABLE_DEV_LOGS: boolean;
|
|
276
|
+
__WB_FORCE_RUNTIME_CACHING: boolean;
|
|
277
|
+
__WB_CONCURRENT_PRECACHING: number;
|
|
278
|
+
}
|
|
273
279
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,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AAC;IAC1C,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,eAAe,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/core",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.10",
|
|
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": [
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"rollup": "4.9.6",
|
|
42
|
-
"typescript": "5.4.0-dev.
|
|
43
|
-
"@serwist/constants": "9.0.0-preview.
|
|
42
|
+
"typescript": "5.4.0-dev.20240206",
|
|
43
|
+
"@serwist/constants": "9.0.0-preview.10"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"typescript": ">=5.0.0"
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { messageGenerator } from "../models/messages/messageGenerator.js";
|
|
10
|
+
import type { MessageKey } from "../models/messages/messages.js";
|
|
10
11
|
import type { MapLikeObject } from "../types.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -29,7 +30,7 @@ class SerwistError extends Error {
|
|
|
29
30
|
* that will help developers identify issues should
|
|
30
31
|
* be added as a key on the context object.
|
|
31
32
|
*/
|
|
32
|
-
constructor(errorCode:
|
|
33
|
+
constructor(errorCode: MessageKey, details?: MapLikeObject) {
|
|
33
34
|
const message = messageGenerator(errorCode, details);
|
|
34
35
|
|
|
35
36
|
super(message);
|
package/src/_private/logger.ts
CHANGED
|
@@ -16,11 +16,16 @@ declare global {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The logger used by Serwist inside of both service workers and the window global scope.
|
|
21
|
+
*
|
|
22
|
+
* Note: This is forcibly `null` in production mode to reduce bundle size. Do check whether
|
|
23
|
+
* you are currently in development mode (by using `process.env.NODE_ENV !== "production"`)
|
|
24
|
+
* before using it.
|
|
25
|
+
*/
|
|
26
|
+
export const logger =
|
|
22
27
|
process.env.NODE_ENV === "production"
|
|
23
|
-
? null
|
|
28
|
+
? null!
|
|
24
29
|
: (() => {
|
|
25
30
|
// Don't overwrite this value if it's already set.
|
|
26
31
|
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
|
|
@@ -30,7 +35,7 @@ const logger = (
|
|
|
30
35
|
|
|
31
36
|
let inGroup = false;
|
|
32
37
|
|
|
33
|
-
const methodToColorMap
|
|
38
|
+
const methodToColorMap = {
|
|
34
39
|
debug: "#7f8c8d", // Gray
|
|
35
40
|
log: "#2ecc71", // Green
|
|
36
41
|
warn: "#f39c12", // Yellow
|
|
@@ -39,6 +44,8 @@ const logger = (
|
|
|
39
44
|
groupEnd: null, // No colored prefix on groupEnd
|
|
40
45
|
};
|
|
41
46
|
|
|
47
|
+
type LoggerMethods = keyof typeof methodToColorMap;
|
|
48
|
+
|
|
42
49
|
const print = (method: LoggerMethods, args: any[]) => {
|
|
43
50
|
if (self.__WB_DISABLE_DEV_LOGS) {
|
|
44
51
|
return;
|
|
@@ -73,20 +80,16 @@ const logger = (
|
|
|
73
80
|
inGroup = false;
|
|
74
81
|
}
|
|
75
82
|
};
|
|
76
|
-
// biome-ignore lint/complexity/noBannedTypes: Unknown reason
|
|
77
|
-
const api: { [methodName: string]: Function } = {};
|
|
78
|
-
const loggerMethods = Object.keys(methodToColorMap);
|
|
79
|
-
|
|
80
|
-
for (const key of loggerMethods) {
|
|
81
|
-
const method = key as LoggerMethods;
|
|
82
|
-
|
|
83
|
-
api[method] = (...args: any[]) => {
|
|
84
|
-
print(method, args);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return api as unknown;
|
|
89
|
-
})()
|
|
90
|
-
) as Console;
|
|
91
83
|
|
|
92
|
-
|
|
84
|
+
const loggerMethods = Object.keys(methodToColorMap) as LoggerMethods[];
|
|
85
|
+
|
|
86
|
+
return loggerMethods.reduce(
|
|
87
|
+
(api, method) => {
|
|
88
|
+
api[method] = (...args: any[]) => {
|
|
89
|
+
print(method, args);
|
|
90
|
+
};
|
|
91
|
+
return api;
|
|
92
|
+
},
|
|
93
|
+
{} as { [method in LoggerMethods]: (...args: any[]) => void },
|
|
94
|
+
);
|
|
95
|
+
})();
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* @returns
|
|
15
15
|
* @private
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
export const waitUntil = <T = any>(event: ExtendableEvent, asyncFn: () => Promise<T>): Promise<T> => {
|
|
18
18
|
const returnPromise = asyncFn();
|
|
19
19
|
event.waitUntil(returnPromise);
|
|
20
20
|
return returnPromise;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { waitUntil };
|
|
21
|
+
};
|
package/src/clientsClaim.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
declare let self: ServiceWorkerGlobalScope;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Claims any currently available clients once the service worker
|
|
14
14
|
* becomes active. This is normally used in conjunction with `skipWaiting()`.
|
|
15
15
|
*/
|
|
16
16
|
function clientsClaim(): void {
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import type { MapLikeObject } from "../../types.js";
|
|
10
|
+
import { type MessageKey, messages } from "./messages.js";
|
|
10
11
|
|
|
11
12
|
const fallback = (code: string, ...args: any[]) => {
|
|
12
13
|
let msg = code;
|
|
@@ -16,7 +17,7 @@ const fallback = (code: string, ...args: any[]) => {
|
|
|
16
17
|
return msg;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const generatorFunction = (code:
|
|
20
|
+
const generatorFunction = (code: MessageKey, details: MapLikeObject = {}) => {
|
|
20
21
|
const message = messages[code];
|
|
21
22
|
if (!message) {
|
|
22
23
|
throw new Error(`Unable to find message for code '${code}'.`);
|
|
@@ -13,7 +13,7 @@ interface MessageMap {
|
|
|
13
13
|
[messageID: string]: (param: LoggableObject) => string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const messages
|
|
16
|
+
export const messages = {
|
|
17
17
|
"invalid-value": ({ paramName, validValueDescription, value }) => {
|
|
18
18
|
if (!paramName || !validValueDescription) {
|
|
19
19
|
throw new Error(`Unexpected input to 'invalid-value' error.`);
|
|
@@ -82,7 +82,7 @@ export const messages: MessageMap = {
|
|
|
82
82
|
throw new Error("Unexpected input to " + `'plugin-error-request-will-fetch', error.`);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
return `An error was thrown by a
|
|
85
|
+
return `An error was thrown by a plugin's 'requestWillFetch()' method. The thrown error message was: '${thrownErrorMessage}'.`;
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
"invalid-cache-name": ({ cacheNameId, value }) => {
|
|
@@ -228,4 +228,6 @@ export const messages: MessageMap = {
|
|
|
228
228
|
}
|
|
229
229
|
return `${message} Please ensure your sources are CORS-enabled.`;
|
|
230
230
|
},
|
|
231
|
-
};
|
|
231
|
+
} satisfies MessageMap;
|
|
232
|
+
|
|
233
|
+
export type MessageKey = keyof typeof messages;
|
|
@@ -12,7 +12,7 @@ import type { PartialCacheNameDetails } from "./_private/cacheNames.js";
|
|
|
12
12
|
import { cacheNames } from "./_private/cacheNames.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Modifies the default cache names used by
|
|
15
|
+
* Modifies the default cache names used by Serwist packages.
|
|
16
16
|
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
|
|
17
17
|
*
|
|
18
18
|
* @param details
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
export type PromiseOrNot<T> = T | Promise<T>;
|
|
8
9
|
|
|
9
10
|
export interface MapLikeObject {
|
|
10
11
|
[key: string]: any;
|
|
@@ -152,7 +153,7 @@ export interface CacheDidUpdateCallbackParam {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
export interface CacheDidUpdateCallback {
|
|
155
|
-
(param: CacheDidUpdateCallbackParam):
|
|
156
|
+
(param: CacheDidUpdateCallbackParam): PromiseOrNot<any>;
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
export interface CacheKeyWillBeUsedCallbackParam {
|
|
@@ -164,7 +165,7 @@ export interface CacheKeyWillBeUsedCallbackParam {
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
export interface CacheKeyWillBeUsedCallback {
|
|
167
|
-
(param: CacheKeyWillBeUsedCallbackParam):
|
|
168
|
+
(param: CacheKeyWillBeUsedCallbackParam): PromiseOrNot<Request | string>;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
export interface CacheWillUpdateCallbackParam {
|
|
@@ -175,7 +176,7 @@ export interface CacheWillUpdateCallbackParam {
|
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
export interface CacheWillUpdateCallback {
|
|
178
|
-
(param: CacheWillUpdateCallbackParam):
|
|
179
|
+
(param: CacheWillUpdateCallbackParam): PromiseOrNot<any>;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export interface CachedResponseWillBeUsedCallbackParam {
|
|
@@ -199,7 +200,7 @@ export interface CachedResponseWillBeUsedCallbackParam {
|
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
export interface CachedResponseWillBeUsedCallback {
|
|
202
|
-
(param: CachedResponseWillBeUsedCallbackParam):
|
|
203
|
+
(param: CachedResponseWillBeUsedCallbackParam): PromiseOrNot<any>;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
export interface FetchDidFailCallbackParam {
|
|
@@ -211,7 +212,7 @@ export interface FetchDidFailCallbackParam {
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
export interface FetchDidFailCallback {
|
|
214
|
-
(param: FetchDidFailCallbackParam):
|
|
215
|
+
(param: FetchDidFailCallbackParam): PromiseOrNot<any>;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
export interface FetchDidSucceedCallbackParam {
|
|
@@ -222,7 +223,7 @@ export interface FetchDidSucceedCallbackParam {
|
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
export interface FetchDidSucceedCallback {
|
|
225
|
-
(param: FetchDidSucceedCallbackParam):
|
|
226
|
+
(param: FetchDidSucceedCallbackParam): PromiseOrNot<Response>;
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
export interface RequestWillFetchCallbackParam {
|
|
@@ -232,7 +233,7 @@ export interface RequestWillFetchCallbackParam {
|
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
export interface RequestWillFetchCallback {
|
|
235
|
-
(param: RequestWillFetchCallbackParam):
|
|
236
|
+
(param: RequestWillFetchCallbackParam): PromiseOrNot<Request>;
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
export interface HandlerWillRespondCallbackParam {
|
|
@@ -243,7 +244,7 @@ export interface HandlerWillRespondCallbackParam {
|
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
export interface HandlerWillRespondCallback {
|
|
246
|
-
(param: HandlerWillRespondCallbackParam):
|
|
247
|
+
(param: HandlerWillRespondCallbackParam): PromiseOrNot<Response>;
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
export interface HandlerDidErrorCallbackParam {
|
|
@@ -254,7 +255,7 @@ export interface HandlerDidErrorCallbackParam {
|
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
export interface HandlerDidErrorCallback {
|
|
257
|
-
(param: HandlerDidErrorCallbackParam):
|
|
258
|
+
(param: HandlerDidErrorCallbackParam): PromiseOrNot<Response | undefined>;
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
export interface HandlerDidRespondCallbackParam {
|
|
@@ -265,7 +266,7 @@ export interface HandlerDidRespondCallbackParam {
|
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
export interface HandlerDidRespondCallback {
|
|
268
|
-
(param: HandlerDidRespondCallbackParam):
|
|
269
|
+
(param: HandlerDidRespondCallbackParam): PromiseOrNot<any>;
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
export interface HandlerDidCompleteCallbackParam {
|
|
@@ -277,7 +278,7 @@ export interface HandlerDidCompleteCallbackParam {
|
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
export interface HandlerDidCompleteCallback {
|
|
280
|
-
(param: HandlerDidCompleteCallbackParam):
|
|
281
|
+
(param: HandlerDidCompleteCallbackParam): PromiseOrNot<any>;
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
/**
|
|
@@ -313,3 +314,9 @@ export interface SerwistPluginCallbackParam {
|
|
|
313
314
|
handlerWillStart: HandlerWillStartCallbackParam;
|
|
314
315
|
requestWillFetch: RequestWillFetchCallbackParam;
|
|
315
316
|
}
|
|
317
|
+
|
|
318
|
+
export interface SerwistGlobalConfig {
|
|
319
|
+
__WB_DISABLE_DEV_LOGS: boolean;
|
|
320
|
+
__WB_FORCE_RUNTIME_CACHING: boolean;
|
|
321
|
+
__WB_CONCURRENT_PRECACHING: number;
|
|
322
|
+
}
|