@ziztechnology/dial-library 0.0.7 → 0.0.8

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/README.md CHANGED
@@ -13,14 +13,6 @@
13
13
  npm install @ziztechnology/dial-library
14
14
  ```
15
15
 
16
- ```bash
17
- pnpm add @ziztechnology/dial-library
18
- ```
19
-
20
- ```bash
21
- yarn add @ziztechnology/dial-library
22
- ```
23
-
24
16
  SDK 是 ESM 包,并自带 TypeScript 类型。
25
17
 
26
18
  ## 快速开始
package/dist/index.mjs CHANGED
@@ -1,5 +1,22 @@
1
1
  import { Gunzip } from "fflate";
2
+ const resolveLogIntervalMs = (intervalMs = void 0) => typeof intervalMs === "number" && Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : 300;
3
+ //#endregion
2
4
  //#region src/helper/debugger.ts
5
+ const logIntervalMs = resolveLogIntervalMs();
6
+ const lastLoggedAtByType = /* @__PURE__ */ new Map();
7
+ const createLogTypeKey = (moduleName, scope, phase) => JSON.stringify([
8
+ moduleName,
9
+ scope,
10
+ phase
11
+ ]);
12
+ const shouldLog = (moduleName, scope, phase) => {
13
+ const key = createLogTypeKey(moduleName, scope, phase);
14
+ const now = Date.now();
15
+ const lastLoggedAt = lastLoggedAtByType.get(key);
16
+ if (lastLoggedAt !== void 0 && now >= lastLoggedAt && now - lastLoggedAt < logIntervalMs) return false;
17
+ lastLoggedAtByType.set(key, now);
18
+ return true;
19
+ };
3
20
  const stringifyDebugData = (data) => {
4
21
  const seen = /* @__PURE__ */ new WeakSet();
5
22
  return JSON.stringify(data, (_key, value) => {
@@ -18,6 +35,7 @@ const stringifyDebugData = (data) => {
18
35
  }) ?? String(data);
19
36
  };
20
37
  const dialSdkDebugWarn = (moduleName, scope, phase, data) => {
38
+ if (!shouldLog(moduleName, scope, phase)) return;
21
39
  const message = `[DIAL_SDK_DEBUG - ${moduleName}] ${scope}: ${phase}`;
22
40
  try {
23
41
  if (data === void 0) console.warn(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziztechnology/dial-library",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "description": "Tooony 表盘工具函数、方法",
6
6
  "files": [