@serwist/core 9.0.0-preview.1 → 9.0.0-preview.3

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.
@@ -6,6 +6,12 @@ declare global {
6
6
  __WB_DISABLE_DEV_LOGS: boolean;
7
7
  }
8
8
  }
9
- declare const logger: Console;
10
- export { logger };
9
+ export declare const logger: {
10
+ error: (...args: any[]) => void;
11
+ debug: (...args: any[]) => void;
12
+ log: (...args: any[]) => void;
13
+ warn: (...args: any[]) => void;
14
+ groupCollapsed: (...args: any[]) => void;
15
+ groupEnd: (...args: any[]) => void;
16
+ };
11
17
  //# 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;AAID,QAAA,MAAM,MAAM,SAqEA,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,CAAC"}
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,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"}
@@ -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
- for (const key of loggerMethods){
347
- const method = key;
345
+ return loggerMethods.reduce((api, method)=>{
348
346
  api[method] = (...args)=>{
349
347
  print(method, args);
350
348
  };
351
- }
352
- return api;
349
+ return api;
350
+ }, {});
353
351
  })();
354
352
 
355
353
  const quotaErrorCallbacks = new Set();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Claim any currently available clients once the service worker
2
+ * Claims any currently available clients once the service worker
3
3
  * becomes active. This is normally used in conjunction with `skipWaiting()`.
4
4
  */
5
5
  declare function clientsClaim(): void;
@@ -1,6 +1,6 @@
1
1
  import type { PartialCacheNameDetails } from "./_private/cacheNames.js";
2
2
  /**
3
- * Modifies the default cache names used by the Serwist packages.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/core",
3
- "version": "9.0.0-preview.1",
3
+ "version": "9.0.0-preview.3",
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.20240203",
43
- "@serwist/constants": "9.0.0-preview.1"
42
+ "typescript": "5.4.0-dev.20240206",
43
+ "@serwist/constants": "9.0.0-preview.3"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "typescript": ">=5.0.0"
@@ -16,11 +16,9 @@ declare global {
16
16
  }
17
17
  }
18
18
 
19
- type LoggerMethods = "debug" | "log" | "warn" | "error" | "groupCollapsed" | "groupEnd";
20
-
21
- const logger = (
19
+ export const logger =
22
20
  process.env.NODE_ENV === "production"
23
- ? null
21
+ ? null!
24
22
  : (() => {
25
23
  // Don't overwrite this value if it's already set.
26
24
  // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
@@ -30,7 +28,7 @@ const logger = (
30
28
 
31
29
  let inGroup = false;
32
30
 
33
- const methodToColorMap: { [methodName: string]: string | null } = {
31
+ const methodToColorMap = {
34
32
  debug: "#7f8c8d", // Gray
35
33
  log: "#2ecc71", // Green
36
34
  warn: "#f39c12", // Yellow
@@ -39,6 +37,8 @@ const logger = (
39
37
  groupEnd: null, // No colored prefix on groupEnd
40
38
  };
41
39
 
40
+ type LoggerMethods = keyof typeof methodToColorMap;
41
+
42
42
  const print = (method: LoggerMethods, args: any[]) => {
43
43
  if (self.__WB_DISABLE_DEV_LOGS) {
44
44
  return;
@@ -73,20 +73,16 @@ const logger = (
73
73
  inGroup = false;
74
74
  }
75
75
  };
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
76
 
92
- export { logger };
77
+ const loggerMethods = Object.keys(methodToColorMap) as LoggerMethods[];
78
+
79
+ return loggerMethods.reduce(
80
+ (api, method) => {
81
+ api[method] = (...args: any[]) => {
82
+ print(method, args);
83
+ };
84
+ return api;
85
+ },
86
+ {} as { [method in LoggerMethods]: (...args: any[]) => void },
87
+ );
88
+ })();
@@ -10,7 +10,7 @@
10
10
  declare let self: ServiceWorkerGlobalScope;
11
11
 
12
12
  /**
13
- * Claim any currently available clients once the service worker
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 {
@@ -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 the Serwist packages.
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