@logspace/sdk 1.0.2 → 1.0.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.
- package/logspace.esm.js +83 -1
- package/logspace.esm.js.map +1 -1
- package/logspace.iife.js +1 -1
- package/logspace.iife.js.map +1 -1
- package/logspace.umd.js +1 -1
- package/logspace.umd.js.map +1 -1
- package/package.json +5 -3
- package/shared/types.d.ts +99 -1
- package/README.md +0 -269
package/logspace.esm.js
CHANGED
|
@@ -27,6 +27,36 @@ function safeStringify(value) {
|
|
|
27
27
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
28
28
|
if (value === null) return "null";
|
|
29
29
|
if (value === void 0) return "undefined";
|
|
30
|
+
if (typeof FormData !== "undefined" && value instanceof FormData) {
|
|
31
|
+
const formDataObj = {};
|
|
32
|
+
value.forEach((val, key) => {
|
|
33
|
+
if (typeof Blob !== "undefined" && val instanceof Blob) {
|
|
34
|
+
const blobVal = val;
|
|
35
|
+
const fileInfo = typeof File !== "undefined" && val instanceof File ? `File(${val.name}, ${blobVal.size}b)` : `Blob(${blobVal.size}b)`;
|
|
36
|
+
if (formDataObj[key]) {
|
|
37
|
+
const existing = formDataObj[key];
|
|
38
|
+
formDataObj[key] = Array.isArray(existing) ? [...existing, fileInfo] : [existing, fileInfo];
|
|
39
|
+
} else {
|
|
40
|
+
formDataObj[key] = fileInfo;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
const strVal = String(val).length > 1e3 ? String(val).substring(0, 1e3) + "..." : String(val);
|
|
44
|
+
if (formDataObj[key]) {
|
|
45
|
+
const existing = formDataObj[key];
|
|
46
|
+
formDataObj[key] = Array.isArray(existing) ? [...existing, strVal] : [existing, strVal];
|
|
47
|
+
} else {
|
|
48
|
+
formDataObj[key] = strVal;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return JSON.stringify(formDataObj);
|
|
53
|
+
}
|
|
54
|
+
if (typeof Blob !== "undefined" && value instanceof Blob) {
|
|
55
|
+
if (value instanceof File) {
|
|
56
|
+
return `File(${value.name}, ${value.size}b, ${value.type})`;
|
|
57
|
+
}
|
|
58
|
+
return `Blob(${value.size}b, ${value.type})`;
|
|
59
|
+
}
|
|
30
60
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
31
61
|
return JSON.stringify(value, (key, val) => {
|
|
32
62
|
if (typeof val === "object" && val !== null) {
|
|
@@ -240,6 +270,7 @@ function createLogEntry(type, data, severity = "info") {
|
|
|
240
270
|
};
|
|
241
271
|
}
|
|
242
272
|
let originalConsole = null;
|
|
273
|
+
const timerMap = /* @__PURE__ */ new Map();
|
|
243
274
|
function shouldIgnoreMessage(args) {
|
|
244
275
|
if (!args || args.length === 0) return false;
|
|
245
276
|
for (const arg of args) {
|
|
@@ -275,7 +306,10 @@ const consoleCapture = {
|
|
|
275
306
|
info: console.info,
|
|
276
307
|
warn: console.warn,
|
|
277
308
|
error: console.error,
|
|
278
|
-
debug: console.debug
|
|
309
|
+
debug: console.debug,
|
|
310
|
+
time: console.time,
|
|
311
|
+
timeEnd: console.timeEnd,
|
|
312
|
+
timeLog: console.timeLog
|
|
279
313
|
};
|
|
280
314
|
levels.forEach((level) => {
|
|
281
315
|
console[level] = function(...args) {
|
|
@@ -303,6 +337,50 @@ const consoleCapture = {
|
|
|
303
337
|
handler2(log);
|
|
304
338
|
};
|
|
305
339
|
});
|
|
340
|
+
console.time = function(label = "default") {
|
|
341
|
+
originalConsole.time.call(console, label);
|
|
342
|
+
timerMap.set(label, performance.now());
|
|
343
|
+
};
|
|
344
|
+
console.timeLog = function(label = "default", ...args) {
|
|
345
|
+
originalConsole.timeLog.apply(console, [label, ...args]);
|
|
346
|
+
const startTime = timerMap.get(label);
|
|
347
|
+
if (startTime === void 0) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const duration = performance.now() - startTime;
|
|
351
|
+
const serializedArgs = args.map((arg) => safeStringify(arg));
|
|
352
|
+
const log = createLogEntry(
|
|
353
|
+
"console",
|
|
354
|
+
{
|
|
355
|
+
level: "timeLog",
|
|
356
|
+
args: [`${label}: ${duration.toFixed(3)}ms`, ...serializedArgs],
|
|
357
|
+
timerLabel: label,
|
|
358
|
+
duration
|
|
359
|
+
},
|
|
360
|
+
"info"
|
|
361
|
+
);
|
|
362
|
+
handler2(log);
|
|
363
|
+
};
|
|
364
|
+
console.timeEnd = function(label = "default") {
|
|
365
|
+
originalConsole.timeEnd.call(console, label);
|
|
366
|
+
const startTime = timerMap.get(label);
|
|
367
|
+
if (startTime === void 0) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const duration = performance.now() - startTime;
|
|
371
|
+
timerMap.delete(label);
|
|
372
|
+
const log = createLogEntry(
|
|
373
|
+
"console",
|
|
374
|
+
{
|
|
375
|
+
level: "timeEnd",
|
|
376
|
+
args: [`${label}: ${duration.toFixed(3)}ms`],
|
|
377
|
+
timerLabel: label,
|
|
378
|
+
duration
|
|
379
|
+
},
|
|
380
|
+
"info"
|
|
381
|
+
);
|
|
382
|
+
handler2(log);
|
|
383
|
+
};
|
|
306
384
|
},
|
|
307
385
|
uninstall() {
|
|
308
386
|
if (!isBrowser() || !originalConsole) return;
|
|
@@ -311,6 +389,10 @@ const consoleCapture = {
|
|
|
311
389
|
console.warn = originalConsole.warn;
|
|
312
390
|
console.error = originalConsole.error;
|
|
313
391
|
console.debug = originalConsole.debug;
|
|
392
|
+
console.time = originalConsole.time;
|
|
393
|
+
console.timeEnd = originalConsole.timeEnd;
|
|
394
|
+
console.timeLog = originalConsole.timeLog;
|
|
395
|
+
timerMap.clear();
|
|
314
396
|
originalConsole = null;
|
|
315
397
|
}
|
|
316
398
|
};
|