@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 +0 -8
- package/dist/index.mjs +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
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);
|