devlog-ui 0.1.6 → 1.0.0
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 +10 -0
- package/dist/index.cjs +120 -30
- package/dist/index.d.ts +6 -0
- package/dist/index.js +512 -345
- package/dist/noop.cjs +1 -1
- package/dist/noop.d.ts +9 -0
- package/dist/noop.js +14 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (t, e, n) =>
|
|
4
|
-
const
|
|
1
|
+
var Fe = Object.defineProperty;
|
|
2
|
+
var He = (t, e, n) => e in t ? Fe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var p = (t, e, n) => He(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const le = {
|
|
5
5
|
debug: 0,
|
|
6
6
|
info: 1,
|
|
7
7
|
warn: 2,
|
|
@@ -10,35 +10,35 @@ const se = {
|
|
|
10
10
|
function w(t) {
|
|
11
11
|
return t !== null && typeof t == "object" && !Array.isArray(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function A(t, e) {
|
|
14
14
|
if (t === e) return !0;
|
|
15
15
|
if (typeof t != typeof e) return !1;
|
|
16
16
|
if (t === null || e === null) return t === e;
|
|
17
17
|
if (Array.isArray(t) && Array.isArray(e))
|
|
18
|
-
return t.length !== e.length ? !1 : t.every((n, o) =>
|
|
18
|
+
return t.length !== e.length ? !1 : t.every((n, o) => A(n, e[o]));
|
|
19
19
|
if (w(t) && w(e)) {
|
|
20
20
|
const n = Object.keys(t), o = Object.keys(e);
|
|
21
|
-
return n.length !== o.length ? !1 : n.every((r) =>
|
|
21
|
+
return n.length !== o.length ? !1 : n.every((r) => A(t[r], e[r]));
|
|
22
22
|
}
|
|
23
23
|
return !1;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ce(t) {
|
|
26
26
|
if (t === void 0) return "undefined";
|
|
27
27
|
if (t === null) return "null";
|
|
28
28
|
if (typeof t == "string") return `"${t}"`;
|
|
29
29
|
if (typeof t == "number" || typeof t == "boolean") return String(t);
|
|
30
30
|
if (Array.isArray(t))
|
|
31
|
-
return t.length === 0 ? "[]" : t.length <= 3 ? `[${t.map(
|
|
31
|
+
return t.length === 0 ? "[]" : t.length <= 3 ? `[${t.map(ce).join(", ")}]` : `[${t.length} items]`;
|
|
32
32
|
if (w(t)) {
|
|
33
33
|
const e = Object.keys(t);
|
|
34
|
-
return e.length === 0 ? "{}" : e.length <= 2 ? `{${e.map((n) => `${n}: ${
|
|
34
|
+
return e.length === 0 ? "{}" : e.length <= 2 ? `{${e.map((n) => `${n}: ${ce(t[n])}`).join(", ")}}` : `{${e.length} keys}`;
|
|
35
35
|
}
|
|
36
36
|
return String(t);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function ye(t, e, n = "", o = !1) {
|
|
39
39
|
const r = [];
|
|
40
40
|
if (!w(t) && !w(e))
|
|
41
|
-
return
|
|
41
|
+
return A(t, e) ? o && r.push({
|
|
42
42
|
path: n || "(root)",
|
|
43
43
|
type: "unchanged",
|
|
44
44
|
oldValue: t,
|
|
@@ -64,42 +64,42 @@ function ve(t, e, n = "", o = !1) {
|
|
|
64
64
|
newValue: e
|
|
65
65
|
}), r;
|
|
66
66
|
const s = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]);
|
|
67
|
-
for (const
|
|
68
|
-
const
|
|
67
|
+
for (const a of s) {
|
|
68
|
+
const l = n ? `${n}.${a}` : a, c = t[a], d = e[a], u = a in t, h = a in e;
|
|
69
69
|
!u && h ? r.push({
|
|
70
|
-
path:
|
|
70
|
+
path: l,
|
|
71
71
|
type: "added",
|
|
72
72
|
newValue: d
|
|
73
73
|
}) : u && !h ? r.push({
|
|
74
|
-
path:
|
|
74
|
+
path: l,
|
|
75
75
|
type: "removed",
|
|
76
|
-
oldValue:
|
|
77
|
-
}) : w(
|
|
78
|
-
path:
|
|
76
|
+
oldValue: c
|
|
77
|
+
}) : w(c) && w(d) ? r.push(...ye(c, d, l, o)) : Array.isArray(c) && Array.isArray(d) ? A(c, d) ? o && r.push({
|
|
78
|
+
path: l,
|
|
79
79
|
type: "unchanged",
|
|
80
|
-
oldValue:
|
|
80
|
+
oldValue: c,
|
|
81
81
|
newValue: d
|
|
82
82
|
}) : r.push({
|
|
83
|
-
path:
|
|
83
|
+
path: l,
|
|
84
84
|
type: "changed",
|
|
85
|
-
oldValue:
|
|
85
|
+
oldValue: c,
|
|
86
86
|
newValue: d
|
|
87
|
-
}) :
|
|
88
|
-
path:
|
|
87
|
+
}) : A(c, d) ? o && r.push({
|
|
88
|
+
path: l,
|
|
89
89
|
type: "unchanged",
|
|
90
|
-
oldValue:
|
|
90
|
+
oldValue: c,
|
|
91
91
|
newValue: d
|
|
92
92
|
}) : r.push({
|
|
93
|
-
path:
|
|
93
|
+
path: l,
|
|
94
94
|
type: "changed",
|
|
95
|
-
oldValue:
|
|
95
|
+
oldValue: c,
|
|
96
96
|
newValue: d
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
return r;
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
const n =
|
|
101
|
+
function de(t, e) {
|
|
102
|
+
const n = ye(t, e, "", !1), o = {
|
|
103
103
|
added: 0,
|
|
104
104
|
removed: 0,
|
|
105
105
|
changed: 0,
|
|
@@ -109,13 +109,13 @@ function ae(t, e) {
|
|
|
109
109
|
o[r.type]++;
|
|
110
110
|
return { changes: n, summary: o };
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function qt(t) {
|
|
113
113
|
return t.summary.added > 0 || t.summary.removed > 0 || t.summary.changed > 0;
|
|
114
114
|
}
|
|
115
|
-
const
|
|
116
|
-
function
|
|
115
|
+
const Oe = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
116
|
+
function ze() {
|
|
117
117
|
try {
|
|
118
|
-
if (typeof import.meta < "u" &&
|
|
118
|
+
if (typeof import.meta < "u" && Oe)
|
|
119
119
|
return !1;
|
|
120
120
|
const t = globalThis.process;
|
|
121
121
|
if (t?.env) {
|
|
@@ -129,13 +129,16 @@ function Ae() {
|
|
|
129
129
|
return !0;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
const
|
|
132
|
+
const Ne = {
|
|
133
133
|
maxLogs: 1e3,
|
|
134
134
|
persist: !1,
|
|
135
135
|
minLevel: "debug",
|
|
136
|
-
enabled:
|
|
136
|
+
enabled: ze(),
|
|
137
|
+
shortcutAction: "toggle",
|
|
138
|
+
showToggleButton: !0,
|
|
139
|
+
spanCollapsed: !1
|
|
137
140
|
};
|
|
138
|
-
function
|
|
141
|
+
function Pe() {
|
|
139
142
|
const t = "devlogger_session_id";
|
|
140
143
|
try {
|
|
141
144
|
const e = sessionStorage.getItem(t);
|
|
@@ -147,10 +150,10 @@ function He() {
|
|
|
147
150
|
return `session_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
|
-
function
|
|
153
|
+
function qe() {
|
|
151
154
|
return `log_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
152
155
|
}
|
|
153
|
-
function
|
|
156
|
+
function xe() {
|
|
154
157
|
try {
|
|
155
158
|
const t = new Error().stack;
|
|
156
159
|
if (!t)
|
|
@@ -165,7 +168,7 @@ function me() {
|
|
|
165
168
|
if (r)
|
|
166
169
|
return {
|
|
167
170
|
function: r[1] || void 0,
|
|
168
|
-
file:
|
|
171
|
+
file: ge(r[2] || "unknown"),
|
|
169
172
|
line: parseInt(r[3] || "0", 10),
|
|
170
173
|
column: parseInt(r[4] || "0", 10)
|
|
171
174
|
};
|
|
@@ -173,7 +176,7 @@ function me() {
|
|
|
173
176
|
if (s)
|
|
174
177
|
return {
|
|
175
178
|
function: s[1] || void 0,
|
|
176
|
-
file:
|
|
179
|
+
file: ge(s[2] || "unknown"),
|
|
177
180
|
line: parseInt(s[3] || "0", 10),
|
|
178
181
|
column: parseInt(s[4] || "0", 10)
|
|
179
182
|
};
|
|
@@ -183,12 +186,12 @@ function me() {
|
|
|
183
186
|
return { file: "unknown", line: 0 };
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
|
-
function
|
|
189
|
+
function ge(t) {
|
|
187
190
|
let e = t.replace(/^webpack:\/\/[^/]*\//, "").replace(/^\/@fs/, "").replace(/^file:\/\//, "").replace(/\?.*$/, "");
|
|
188
191
|
const n = e.split("/");
|
|
189
192
|
return n.length > 2 && (e = n.slice(-2).join("/")), e;
|
|
190
193
|
}
|
|
191
|
-
function
|
|
194
|
+
function Ue() {
|
|
192
195
|
return `span_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
193
196
|
}
|
|
194
197
|
class G {
|
|
@@ -197,13 +200,13 @@ class G {
|
|
|
197
200
|
p(this, "_event");
|
|
198
201
|
p(this, "_ended", !1);
|
|
199
202
|
this.logger = e, this._event = {
|
|
200
|
-
id:
|
|
203
|
+
id: Ue(),
|
|
201
204
|
name: n,
|
|
202
205
|
startTime: Date.now(),
|
|
203
206
|
status: "running",
|
|
204
207
|
parentId: r,
|
|
205
208
|
context: o,
|
|
206
|
-
source:
|
|
209
|
+
source: xe(),
|
|
207
210
|
sessionId: e.getSessionId()
|
|
208
211
|
}, e.notifySpan(this._event);
|
|
209
212
|
}
|
|
@@ -253,7 +256,7 @@ class G {
|
|
|
253
256
|
this._ended || (this._ended = !0, this._event.endTime = Date.now(), this._event.duration = this._event.endTime - this._event.startTime, this._event.status = e, this.logger.notifySpan(this._event));
|
|
254
257
|
}
|
|
255
258
|
}
|
|
256
|
-
class
|
|
259
|
+
class te {
|
|
257
260
|
constructor(e, n) {
|
|
258
261
|
p(this, "logger");
|
|
259
262
|
p(this, "context");
|
|
@@ -277,41 +280,41 @@ class ee {
|
|
|
277
280
|
}
|
|
278
281
|
/** Create a new context logger with merged context */
|
|
279
282
|
withContext(e) {
|
|
280
|
-
return new
|
|
283
|
+
return new te(this.logger, { ...this.context, ...e });
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
|
-
class
|
|
286
|
+
class Ve {
|
|
284
287
|
constructor() {
|
|
285
288
|
p(this, "logs", []);
|
|
286
289
|
p(this, "spans", /* @__PURE__ */ new Map());
|
|
287
290
|
p(this, "subscribers", /* @__PURE__ */ new Set());
|
|
288
291
|
p(this, "spanSubscribers", /* @__PURE__ */ new Set());
|
|
289
|
-
p(this, "config", { ...
|
|
292
|
+
p(this, "config", { ...Ne });
|
|
290
293
|
p(this, "sessionId");
|
|
291
294
|
p(this, "globalContext", {});
|
|
292
|
-
this.sessionId =
|
|
295
|
+
this.sessionId = Pe();
|
|
293
296
|
}
|
|
294
297
|
/**
|
|
295
298
|
* Core logging method - all public methods delegate to this
|
|
296
299
|
*/
|
|
297
300
|
log(e, n, o, r, s) {
|
|
298
301
|
try {
|
|
299
|
-
if (!this.config.enabled ||
|
|
302
|
+
if (!this.config.enabled || le[e] < le[this.config.minLevel])
|
|
300
303
|
return;
|
|
301
|
-
const
|
|
302
|
-
id:
|
|
304
|
+
const a = Object.keys(this.globalContext).length > 0 || r ? { ...this.globalContext, ...r } : void 0, l = {
|
|
305
|
+
id: qe(),
|
|
303
306
|
timestamp: Date.now(),
|
|
304
307
|
level: e,
|
|
305
308
|
message: String(n),
|
|
306
309
|
data: this.safeCloneData(o),
|
|
307
|
-
source:
|
|
310
|
+
source: xe(),
|
|
308
311
|
sessionId: this.sessionId,
|
|
309
|
-
context:
|
|
312
|
+
context: a,
|
|
310
313
|
spanId: s
|
|
311
314
|
};
|
|
312
|
-
this.store(
|
|
313
|
-
} catch (
|
|
314
|
-
typeof console < "u" && console.warn && console.warn("[DevLogger] Internal error:",
|
|
315
|
+
this.store(l), this.notify(l);
|
|
316
|
+
} catch (a) {
|
|
317
|
+
typeof console < "u" && console.warn && console.warn("[DevLogger] Internal error:", a);
|
|
315
318
|
}
|
|
316
319
|
}
|
|
317
320
|
/**
|
|
@@ -561,7 +564,7 @@ class Pe {
|
|
|
561
564
|
* Create a context-bound logger
|
|
562
565
|
*/
|
|
563
566
|
withContext(e) {
|
|
564
|
-
return new
|
|
567
|
+
return new te(this, e);
|
|
565
568
|
}
|
|
566
569
|
// ========== Export API ==========
|
|
567
570
|
/**
|
|
@@ -574,24 +577,24 @@ class Pe {
|
|
|
574
577
|
lastMs: o,
|
|
575
578
|
levels: r,
|
|
576
579
|
search: s,
|
|
577
|
-
pretty:
|
|
580
|
+
pretty: a = !0
|
|
578
581
|
} = e;
|
|
579
|
-
let
|
|
582
|
+
let l = [...this.logs];
|
|
580
583
|
if (o !== void 0 && o > 0) {
|
|
581
|
-
const
|
|
582
|
-
|
|
584
|
+
const c = Date.now() - o;
|
|
585
|
+
l = l.filter((d) => d.timestamp >= c);
|
|
583
586
|
}
|
|
584
587
|
if (r && r.length > 0) {
|
|
585
|
-
const
|
|
586
|
-
|
|
588
|
+
const c = new Set(r);
|
|
589
|
+
l = l.filter((d) => c.has(d.level));
|
|
587
590
|
}
|
|
588
591
|
if (s) {
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
(d) => d.message.toLowerCase().includes(
|
|
592
|
+
const c = s.toLowerCase();
|
|
593
|
+
l = l.filter(
|
|
594
|
+
(d) => d.message.toLowerCase().includes(c) || JSON.stringify(d.data).toLowerCase().includes(c)
|
|
592
595
|
);
|
|
593
596
|
}
|
|
594
|
-
return n === "text" ? this.formatLogsAsText(
|
|
597
|
+
return n === "text" ? this.formatLogsAsText(l) : a ? JSON.stringify(l, null, 2) : JSON.stringify(l);
|
|
595
598
|
} catch {
|
|
596
599
|
return "[]";
|
|
597
600
|
}
|
|
@@ -601,10 +604,10 @@ class Pe {
|
|
|
601
604
|
*/
|
|
602
605
|
formatLogsAsText(e) {
|
|
603
606
|
return e.map((n) => {
|
|
604
|
-
const o = new Date(n.timestamp).toISOString(), r = n.level.toUpperCase().padEnd(5), s = `${n.source.file}:${n.source.line}`,
|
|
607
|
+
const o = new Date(n.timestamp).toISOString(), r = n.level.toUpperCase().padEnd(5), s = `${n.source.file}:${n.source.line}`, a = n.context ? ` [${Object.entries(n.context).map(([d, u]) => `${d}=${u}`).join(", ")}]` : "", l = n.spanId ? ` (span: ${n.spanId})` : "", c = n.data.length > 0 ? `
|
|
605
608
|
Data: ${JSON.stringify(n.data)}` : "";
|
|
606
|
-
return `[${o}] ${r} ${n.message}${
|
|
607
|
-
Source: ${s}${
|
|
609
|
+
return `[${o}] ${r} ${n.message}${a}${l}
|
|
610
|
+
Source: ${s}${c}`;
|
|
608
611
|
}).join(`
|
|
609
612
|
|
|
610
613
|
`);
|
|
@@ -626,7 +629,7 @@ class Pe {
|
|
|
626
629
|
*/
|
|
627
630
|
diff(e, n, o, r = "info") {
|
|
628
631
|
try {
|
|
629
|
-
const s =
|
|
632
|
+
const s = de(n, o);
|
|
630
633
|
return this.log(r, e, [
|
|
631
634
|
{
|
|
632
635
|
__type: "Diff",
|
|
@@ -647,7 +650,7 @@ class Pe {
|
|
|
647
650
|
*/
|
|
648
651
|
computeDiff(e, n) {
|
|
649
652
|
try {
|
|
650
|
-
return
|
|
653
|
+
return de(e, n);
|
|
651
654
|
} catch {
|
|
652
655
|
return {
|
|
653
656
|
changes: [],
|
|
@@ -656,7 +659,7 @@ class Pe {
|
|
|
656
659
|
}
|
|
657
660
|
}
|
|
658
661
|
}
|
|
659
|
-
const f = new
|
|
662
|
+
const f = new Ve(), g = {
|
|
660
663
|
// Background
|
|
661
664
|
bgPrimary: "#1e1e1e",
|
|
662
665
|
bgSecondary: "#252526",
|
|
@@ -678,7 +681,7 @@ const f = new Pe(), g = {
|
|
|
678
681
|
// Interactive
|
|
679
682
|
buttonBg: "#0e639c",
|
|
680
683
|
buttonHover: "#1177bb"
|
|
681
|
-
},
|
|
684
|
+
}, je = `
|
|
682
685
|
:host {
|
|
683
686
|
--bg-primary: ${g.bgPrimary};
|
|
684
687
|
--bg-secondary: ${g.bgSecondary};
|
|
@@ -896,6 +899,90 @@ const f = new Pe(), g = {
|
|
|
896
899
|
padding-left: 10px;
|
|
897
900
|
}
|
|
898
901
|
|
|
902
|
+
.span-group {
|
|
903
|
+
border-bottom: 1px solid var(--border);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.span-header {
|
|
907
|
+
display: flex;
|
|
908
|
+
align-items: center;
|
|
909
|
+
gap: 8px;
|
|
910
|
+
padding: 8px 12px;
|
|
911
|
+
background: var(--bg-secondary);
|
|
912
|
+
cursor: pointer;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.span-header:hover {
|
|
916
|
+
background: var(--bg-hover);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.span-toggle {
|
|
920
|
+
background: transparent;
|
|
921
|
+
border: none;
|
|
922
|
+
color: var(--text-muted);
|
|
923
|
+
cursor: pointer;
|
|
924
|
+
padding: 2px;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
.span-toggle::before {
|
|
928
|
+
content: '▾';
|
|
929
|
+
display: inline-block;
|
|
930
|
+
transition: transform 0.15s ease;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
.span-group.collapsed .span-toggle::before {
|
|
934
|
+
transform: rotate(-90deg);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.span-title {
|
|
938
|
+
font-weight: 600;
|
|
939
|
+
font-size: 12px;
|
|
940
|
+
color: var(--text-primary);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
.span-status {
|
|
944
|
+
font-size: 10px;
|
|
945
|
+
text-transform: uppercase;
|
|
946
|
+
padding: 2px 6px;
|
|
947
|
+
border-radius: 3px;
|
|
948
|
+
color: var(--text-primary);
|
|
949
|
+
background: var(--bg-primary);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.span-status-running {
|
|
953
|
+
color: ${g.levelInfo};
|
|
954
|
+
background: rgba(55, 148, 255, 0.15);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
.span-status-success {
|
|
958
|
+
color: ${g.levelInfo};
|
|
959
|
+
background: rgba(55, 148, 255, 0.15);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.span-status-error {
|
|
963
|
+
color: ${g.levelError};
|
|
964
|
+
background: rgba(241, 76, 76, 0.15);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
.span-duration {
|
|
968
|
+
color: var(--text-muted);
|
|
969
|
+
font-size: 11px;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
.span-count {
|
|
973
|
+
margin-left: auto;
|
|
974
|
+
color: var(--text-secondary);
|
|
975
|
+
font-size: 11px;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
.span-logs {
|
|
979
|
+
padding-left: 4px;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
.span-group.collapsed .span-logs {
|
|
983
|
+
display: none;
|
|
984
|
+
}
|
|
985
|
+
|
|
899
986
|
.log-message {
|
|
900
987
|
color: var(--text-primary);
|
|
901
988
|
word-break: break-word;
|
|
@@ -1220,14 +1307,14 @@ const f = new Pe(), g = {
|
|
|
1220
1307
|
color: ${g.levelInfo};
|
|
1221
1308
|
}
|
|
1222
1309
|
`;
|
|
1223
|
-
function
|
|
1310
|
+
function We(t) {
|
|
1224
1311
|
const e = new Date(t), n = e.getHours().toString().padStart(2, "0"), o = e.getMinutes().toString().padStart(2, "0"), r = e.getSeconds().toString().padStart(2, "0"), s = e.getMilliseconds().toString().padStart(3, "0");
|
|
1225
1312
|
return `${n}:${o}:${r}.${s}`;
|
|
1226
1313
|
}
|
|
1227
|
-
function
|
|
1314
|
+
function ue(t) {
|
|
1228
1315
|
return t.file === "unknown" ? "unknown" : `${t.file}:${t.line}`;
|
|
1229
1316
|
}
|
|
1230
|
-
function
|
|
1317
|
+
function we(t) {
|
|
1231
1318
|
return t !== null && typeof t == "object" && t.__type === "Diff" && t.diff !== void 0;
|
|
1232
1319
|
}
|
|
1233
1320
|
function $(t) {
|
|
@@ -1243,23 +1330,23 @@ function $(t) {
|
|
|
1243
1330
|
}
|
|
1244
1331
|
return String(t);
|
|
1245
1332
|
}
|
|
1246
|
-
function
|
|
1333
|
+
function Ge(t) {
|
|
1247
1334
|
const e = `diff-${t.type}`, n = t.type === "added" ? "+" : t.type === "removed" ? "-" : t.type === "changed" ? "~" : " ";
|
|
1248
1335
|
let o = "";
|
|
1249
1336
|
return t.type === "added" ? o = $(t.newValue) : t.type === "removed" ? o = $(t.oldValue) : t.type === "changed" && (o = `${$(t.oldValue)} → ${$(t.newValue)}`), `<div class="diff-entry ${e}"><span class="diff-icon">${n}</span> <span class="diff-path">${t.path}</span>: <span class="diff-value">${o}</span></div>`;
|
|
1250
1337
|
}
|
|
1251
|
-
function
|
|
1338
|
+
function Je(t) {
|
|
1252
1339
|
const { diff: e } = t, { summary: n, changes: o } = e;
|
|
1253
1340
|
let r = '<div class="diff-container">';
|
|
1254
1341
|
if (r += '<div class="diff-summary">', n.added > 0 && (r += `<span class="diff-count diff-added">+${n.added}</span>`), n.removed > 0 && (r += `<span class="diff-count diff-removed">-${n.removed}</span>`), n.changed > 0 && (r += `<span class="diff-count diff-changed">~${n.changed}</span>`), n.added === 0 && n.removed === 0 && n.changed === 0 && (r += '<span class="diff-count diff-unchanged">No changes</span>'), r += "</div>", o.length > 0) {
|
|
1255
1342
|
r += '<div class="diff-changes">';
|
|
1256
1343
|
for (const s of o)
|
|
1257
|
-
r +=
|
|
1344
|
+
r += Ge(s);
|
|
1258
1345
|
r += "</div>";
|
|
1259
1346
|
}
|
|
1260
1347
|
return r += "</div>", r;
|
|
1261
1348
|
}
|
|
1262
|
-
function
|
|
1349
|
+
function Xe(t) {
|
|
1263
1350
|
if (t.length === 0)
|
|
1264
1351
|
return "";
|
|
1265
1352
|
try {
|
|
@@ -1269,30 +1356,30 @@ function We(t) {
|
|
|
1269
1356
|
return "[Unable to display data]";
|
|
1270
1357
|
}
|
|
1271
1358
|
}
|
|
1272
|
-
function
|
|
1273
|
-
return t.some(
|
|
1359
|
+
function Ye(t) {
|
|
1360
|
+
return t.some(we);
|
|
1274
1361
|
}
|
|
1275
1362
|
function M(t) {
|
|
1276
1363
|
const e = document.createElement("div");
|
|
1277
1364
|
return e.textContent = t, e.innerHTML;
|
|
1278
1365
|
}
|
|
1279
|
-
function
|
|
1366
|
+
function Ke(t) {
|
|
1280
1367
|
return !t || Object.keys(t).length === 0 ? "" : Object.entries(t).map(([e, n]) => `${e}=${n}`).join(" · ");
|
|
1281
1368
|
}
|
|
1282
|
-
function
|
|
1369
|
+
function J(t) {
|
|
1283
1370
|
const e = document.createElement("div");
|
|
1284
1371
|
e.className = `log-entry${t.spanId ? " log-entry-in-span" : ""}`, e.dataset.id = t.id, t.spanId && (e.dataset.spanId = t.spanId);
|
|
1285
|
-
const n = t.data.length > 0, o =
|
|
1372
|
+
const n = t.data.length > 0, o = Ye(t.data), r = t.context && Object.keys(t.context).length > 0, s = `data-${t.id}`, a = () => {
|
|
1286
1373
|
if (!n) return "";
|
|
1287
1374
|
if (o) {
|
|
1288
|
-
const
|
|
1289
|
-
if (
|
|
1375
|
+
const l = t.data.find(we);
|
|
1376
|
+
if (l)
|
|
1290
1377
|
return `
|
|
1291
1378
|
<div class="log-data log-data-diff">
|
|
1292
1379
|
<button class="log-data-toggle" data-target="${s}">
|
|
1293
1380
|
diff
|
|
1294
1381
|
</button>
|
|
1295
|
-
<div class="log-data-content" id="${s}">${
|
|
1382
|
+
<div class="log-data-content" id="${s}">${Je(l)}</div>
|
|
1296
1383
|
</div>
|
|
1297
1384
|
`;
|
|
1298
1385
|
}
|
|
@@ -1301,42 +1388,42 @@ function xe(t) {
|
|
|
1301
1388
|
<button class="log-data-toggle" data-target="${s}">
|
|
1302
1389
|
${t.data.length} item${t.data.length > 1 ? "s" : ""}
|
|
1303
1390
|
</button>
|
|
1304
|
-
<pre class="log-data-content" id="${s}">${M(
|
|
1391
|
+
<pre class="log-data-content" id="${s}">${M(Xe(t.data))}</pre>
|
|
1305
1392
|
</div>
|
|
1306
1393
|
`;
|
|
1307
1394
|
};
|
|
1308
1395
|
if (e.innerHTML = `
|
|
1309
1396
|
<div class="log-entry-header">
|
|
1310
1397
|
<span class="log-level log-level-${t.level}">${t.level}</span>
|
|
1311
|
-
<span class="log-time">${
|
|
1312
|
-
${r ? `<span class="log-context" title="Context">${M(
|
|
1313
|
-
<span class="log-source" title="${M(
|
|
1398
|
+
<span class="log-time">${We(t.timestamp)}</span>
|
|
1399
|
+
${r ? `<span class="log-context" title="Context">${M(Ke(t.context))}</span>` : ""}
|
|
1400
|
+
<span class="log-source" title="${M(ue(t.source))}">${M(ue(t.source))}</span>
|
|
1314
1401
|
</div>
|
|
1315
1402
|
<div class="log-message">${M(t.message)}</div>
|
|
1316
|
-
${
|
|
1403
|
+
${a()}
|
|
1317
1404
|
`, n) {
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
|
|
1405
|
+
const l = e.querySelector(".log-data-toggle"), c = e.querySelector(`#${s}`);
|
|
1406
|
+
l && c && l.addEventListener("click", () => {
|
|
1407
|
+
l.classList.toggle("expanded"), c.classList.toggle("visible");
|
|
1321
1408
|
});
|
|
1322
1409
|
}
|
|
1323
1410
|
return e;
|
|
1324
1411
|
}
|
|
1325
|
-
function
|
|
1412
|
+
function Qe() {
|
|
1326
1413
|
const t = document.createElement("div");
|
|
1327
1414
|
return t.className = "devlogger-empty", t.textContent = "No logs yet...", t;
|
|
1328
1415
|
}
|
|
1329
|
-
const
|
|
1330
|
-
function
|
|
1416
|
+
const Ze = "devlogger-sync";
|
|
1417
|
+
function et() {
|
|
1331
1418
|
return `sender_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
1332
1419
|
}
|
|
1333
|
-
class
|
|
1420
|
+
class tt {
|
|
1334
1421
|
constructor() {
|
|
1335
1422
|
p(this, "channel", null);
|
|
1336
1423
|
p(this, "handlers", /* @__PURE__ */ new Set());
|
|
1337
1424
|
p(this, "senderId");
|
|
1338
1425
|
p(this, "isConnected", !1);
|
|
1339
|
-
this.senderId =
|
|
1426
|
+
this.senderId = et(), this.connect();
|
|
1340
1427
|
}
|
|
1341
1428
|
/**
|
|
1342
1429
|
* Connect to the broadcast channel
|
|
@@ -1347,7 +1434,7 @@ class Qe {
|
|
|
1347
1434
|
console.warn("[DevLogger] BroadcastChannel not supported");
|
|
1348
1435
|
return;
|
|
1349
1436
|
}
|
|
1350
|
-
this.channel = new BroadcastChannel(
|
|
1437
|
+
this.channel = new BroadcastChannel(Ze), this.channel.onmessage = (e) => {
|
|
1351
1438
|
this.handleMessage(e.data);
|
|
1352
1439
|
}, this.channel.onmessageerror = () => {
|
|
1353
1440
|
console.warn("[DevLogger] Channel message error");
|
|
@@ -1438,36 +1525,36 @@ class Qe {
|
|
|
1438
1525
|
}
|
|
1439
1526
|
}
|
|
1440
1527
|
}
|
|
1441
|
-
const
|
|
1528
|
+
const z = new tt(), fe = 500, pe = 700;
|
|
1442
1529
|
let b = null;
|
|
1443
|
-
function
|
|
1530
|
+
function nt() {
|
|
1444
1531
|
try {
|
|
1445
1532
|
if (b && !b.closed)
|
|
1446
1533
|
return b.focus(), b;
|
|
1447
|
-
const t = Math.max(0, (screen.width -
|
|
1534
|
+
const t = Math.max(0, (screen.width - fe) / 2), e = Math.max(0, (screen.height - pe) / 2), n = rt();
|
|
1448
1535
|
return b = window.open(
|
|
1449
1536
|
"",
|
|
1450
1537
|
"devlogger-popout",
|
|
1451
|
-
`width=${
|
|
1538
|
+
`width=${fe},height=${pe},left=${t},top=${e},resizable=yes,scrollbars=yes`
|
|
1452
1539
|
), b ? (b.document.open(), b.document.write(n), b.document.close(), b.addEventListener("load", () => {
|
|
1453
1540
|
setTimeout(() => {
|
|
1454
|
-
|
|
1541
|
+
z.sendSyncResponse(f.getLogs());
|
|
1455
1542
|
}, 100);
|
|
1456
1543
|
}), b) : (console.warn("[DevLogger] Pop-out blocked by browser"), null);
|
|
1457
1544
|
} catch (t) {
|
|
1458
1545
|
return console.warn("[DevLogger] Failed to open pop-out:", t), null;
|
|
1459
1546
|
}
|
|
1460
1547
|
}
|
|
1461
|
-
function
|
|
1548
|
+
function he() {
|
|
1462
1549
|
try {
|
|
1463
1550
|
b && !b.closed && b.close(), b = null;
|
|
1464
1551
|
} catch {
|
|
1465
1552
|
}
|
|
1466
1553
|
}
|
|
1467
|
-
function
|
|
1554
|
+
function ot() {
|
|
1468
1555
|
return b !== null && !b.closed;
|
|
1469
1556
|
}
|
|
1470
|
-
function
|
|
1557
|
+
function rt() {
|
|
1471
1558
|
return `<!DOCTYPE html>
|
|
1472
1559
|
<html lang="en">
|
|
1473
1560
|
<head>
|
|
@@ -2532,14 +2619,14 @@ function tt() {
|
|
|
2532
2619
|
</body>
|
|
2533
2620
|
</html>`;
|
|
2534
2621
|
}
|
|
2535
|
-
function
|
|
2622
|
+
function N() {
|
|
2536
2623
|
return {
|
|
2537
2624
|
levels: /* @__PURE__ */ new Set(["debug", "info", "warn", "error"]),
|
|
2538
2625
|
search: "",
|
|
2539
2626
|
file: ""
|
|
2540
2627
|
};
|
|
2541
2628
|
}
|
|
2542
|
-
function
|
|
2629
|
+
function st(t, e) {
|
|
2543
2630
|
if (e.levels.size > 0 && !e.levels.has(t.level) || e.file && !t.source.file.toLowerCase().includes(e.file.toLowerCase()))
|
|
2544
2631
|
return !1;
|
|
2545
2632
|
if (e.search) {
|
|
@@ -2549,14 +2636,14 @@ function nt(t, e) {
|
|
|
2549
2636
|
}
|
|
2550
2637
|
return !0;
|
|
2551
2638
|
}
|
|
2552
|
-
function
|
|
2553
|
-
return t.filter((n) =>
|
|
2639
|
+
function V(t, e) {
|
|
2640
|
+
return t.filter((n) => st(n, e));
|
|
2554
2641
|
}
|
|
2555
|
-
function
|
|
2642
|
+
function ne(t) {
|
|
2556
2643
|
return !(t.levels.size === 4) || t.search !== "" || t.file !== "";
|
|
2557
2644
|
}
|
|
2558
|
-
function
|
|
2559
|
-
const o =
|
|
2645
|
+
function it(t, e, n) {
|
|
2646
|
+
const o = ne(t);
|
|
2560
2647
|
return `
|
|
2561
2648
|
<div class="filter-bar ${o ? "filter-active" : ""}">
|
|
2562
2649
|
<div class="filter-row">
|
|
@@ -2567,10 +2654,10 @@ function ot(t, e, n) {
|
|
|
2567
2654
|
<button class="filter-level-btn ${t.levels.has("error") ? "active" : ""}" data-level="error" title="Error">E</button>
|
|
2568
2655
|
</div>
|
|
2569
2656
|
<div class="filter-search">
|
|
2570
|
-
<input type="text" class="filter-input" placeholder="Search logs..." value="${
|
|
2657
|
+
<input type="text" class="filter-input" placeholder="Search logs..." value="${be(t.search)}" data-filter="search">
|
|
2571
2658
|
</div>
|
|
2572
2659
|
<div class="filter-file">
|
|
2573
|
-
<input type="text" class="filter-input filter-file-input" placeholder="Filter by file..." value="${
|
|
2660
|
+
<input type="text" class="filter-input filter-file-input" placeholder="Filter by file..." value="${be(t.file)}" data-filter="file">
|
|
2574
2661
|
</div>
|
|
2575
2662
|
${o ? '<button class="filter-clear-btn" title="Clear filters">✕</button>' : ""}
|
|
2576
2663
|
</div>
|
|
@@ -2578,11 +2665,24 @@ function ot(t, e, n) {
|
|
|
2578
2665
|
</div>
|
|
2579
2666
|
`;
|
|
2580
2667
|
}
|
|
2581
|
-
function
|
|
2668
|
+
function be(t) {
|
|
2582
2669
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2583
2670
|
}
|
|
2584
|
-
const
|
|
2585
|
-
function
|
|
2671
|
+
const Z = { key: "l", ctrlKey: !0, shiftKey: !0 };
|
|
2672
|
+
function oe() {
|
|
2673
|
+
return f.getConfig().shortcutAction === "popout" ? "popout" : "toggle";
|
|
2674
|
+
}
|
|
2675
|
+
function at() {
|
|
2676
|
+
return oe() === "popout" ? "Ctrl+Shift+L to open pop-out" : "Ctrl+Shift+L to toggle";
|
|
2677
|
+
}
|
|
2678
|
+
function lt(t) {
|
|
2679
|
+
const e = document.createElement("div");
|
|
2680
|
+
return e.textContent = t, e.innerHTML;
|
|
2681
|
+
}
|
|
2682
|
+
function Le(t) {
|
|
2683
|
+
return t.duration === void 0 ? "running" : `${Math.round(t.duration)}ms`;
|
|
2684
|
+
}
|
|
2685
|
+
function ve(t, e) {
|
|
2586
2686
|
const n = t.textContent;
|
|
2587
2687
|
t.textContent = e ? "✓" : "✗", t.disabled = !0, setTimeout(() => {
|
|
2588
2688
|
t.textContent = n, t.disabled = !1;
|
|
@@ -2599,70 +2699,72 @@ const i = {
|
|
|
2599
2699
|
toggleBtn: null,
|
|
2600
2700
|
badge: null,
|
|
2601
2701
|
unsubscribe: null,
|
|
2702
|
+
spanUnsubscribe: null,
|
|
2602
2703
|
channelUnsubscribe: null,
|
|
2603
|
-
filter:
|
|
2704
|
+
filter: N()
|
|
2604
2705
|
};
|
|
2605
|
-
function
|
|
2706
|
+
function ct(t) {
|
|
2606
2707
|
const e = document.createElement("style");
|
|
2607
|
-
e.textContent =
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
o.
|
|
2708
|
+
if (e.textContent = je, t.appendChild(e), f.getConfig().showToggleButton) {
|
|
2709
|
+
const s = document.createElement("button");
|
|
2710
|
+
s.className = "devlogger-toggle", s.innerHTML = "📋", s.title = oe() === "popout" ? "Toggle DevLogger" : "Toggle DevLogger (Ctrl+Shift+L)", s.addEventListener("click", () => F.toggle()), t.appendChild(s), i.toggleBtn = s;
|
|
2711
|
+
}
|
|
2712
|
+
const n = document.createElement("div");
|
|
2713
|
+
n.className = "devlogger-container hidden";
|
|
2714
|
+
const o = f.getLogs(), r = V(o, i.filter);
|
|
2715
|
+
n.innerHTML = `
|
|
2614
2716
|
<div class="devlogger-header">
|
|
2615
2717
|
<div class="devlogger-title">
|
|
2616
2718
|
DevLogger
|
|
2617
|
-
<span class="devlogger-badge">${
|
|
2719
|
+
<span class="devlogger-badge">${r.length}</span>
|
|
2618
2720
|
</div>
|
|
2619
2721
|
<div class="devlogger-actions">
|
|
2620
2722
|
<button class="devlogger-btn" data-action="copy-json" title="Copy as JSON">JSON</button>
|
|
2621
2723
|
<button class="devlogger-btn" data-action="copy-text" title="Copy as Text">TXT</button>
|
|
2622
2724
|
<button class="devlogger-btn" data-action="clear" title="Clear logs">Clear</button>
|
|
2623
2725
|
<button class="devlogger-btn devlogger-btn-primary" data-action="popout" title="Open in new window">Pop-out</button>
|
|
2624
|
-
<button class="devlogger-btn" data-action="close" title="Close
|
|
2726
|
+
<button class="devlogger-btn" data-action="close" title="Close">✕</button>
|
|
2625
2727
|
</div>
|
|
2626
2728
|
</div>
|
|
2627
2729
|
<div class="filter-bar-container"></div>
|
|
2628
2730
|
<div class="devlogger-logs"></div>
|
|
2629
2731
|
<div class="devlogger-footer">
|
|
2630
|
-
<span class="devlogger-log-count">${
|
|
2631
|
-
<span class="devlogger-shortcut"
|
|
2732
|
+
<span class="devlogger-log-count">${o.length} logs</span>
|
|
2733
|
+
<span class="devlogger-shortcut">${at()}</span>
|
|
2632
2734
|
</div>
|
|
2633
|
-
`, i.badge =
|
|
2634
|
-
|
|
2635
|
-
const l = a.currentTarget.dataset.action,
|
|
2735
|
+
`, i.badge = n.querySelector(".devlogger-badge"), i.logsList = n.querySelector(".devlogger-logs"), i.filterBar = n.querySelector(".filter-bar-container"), n.querySelectorAll("[data-action]").forEach((s) => {
|
|
2736
|
+
s.addEventListener("click", (a) => {
|
|
2737
|
+
const l = a.currentTarget.dataset.action, c = a.currentTarget;
|
|
2636
2738
|
switch (l) {
|
|
2637
2739
|
case "clear":
|
|
2638
|
-
f.clear(),
|
|
2740
|
+
f.clear(), z.sendClear(), y();
|
|
2639
2741
|
break;
|
|
2640
2742
|
case "popout":
|
|
2641
|
-
|
|
2743
|
+
F.popout();
|
|
2642
2744
|
break;
|
|
2643
2745
|
case "close":
|
|
2644
|
-
|
|
2746
|
+
F.close();
|
|
2645
2747
|
break;
|
|
2646
2748
|
case "copy-json":
|
|
2647
|
-
f.copyLogs({ format: "json" }).then((
|
|
2648
|
-
|
|
2749
|
+
f.copyLogs({ format: "json" }).then((d) => {
|
|
2750
|
+
ve(c, d);
|
|
2649
2751
|
});
|
|
2650
2752
|
break;
|
|
2651
2753
|
case "copy-text":
|
|
2652
|
-
f.copyLogs({ format: "text" }).then((
|
|
2653
|
-
|
|
2754
|
+
f.copyLogs({ format: "text" }).then((d) => {
|
|
2755
|
+
ve(c, d);
|
|
2654
2756
|
});
|
|
2655
2757
|
break;
|
|
2656
2758
|
}
|
|
2657
2759
|
});
|
|
2658
|
-
}), t.appendChild(
|
|
2760
|
+
}), t.appendChild(n), i.container = n, I(), y();
|
|
2659
2761
|
}
|
|
2660
2762
|
function I() {
|
|
2661
2763
|
if (!i.filterBar) return;
|
|
2662
|
-
const t = f.getLogs(), e =
|
|
2663
|
-
i.filterBar.innerHTML =
|
|
2764
|
+
const t = f.getLogs(), e = V(t, i.filter);
|
|
2765
|
+
i.filterBar.innerHTML = it(i.filter, t.length, e.length), dt();
|
|
2664
2766
|
}
|
|
2665
|
-
function
|
|
2767
|
+
function dt() {
|
|
2666
2768
|
if (!i.filterBar) return;
|
|
2667
2769
|
i.filterBar.querySelectorAll(".filter-level-btn").forEach((o) => {
|
|
2668
2770
|
o.addEventListener("click", (r) => {
|
|
@@ -2672,22 +2774,22 @@ function it() {
|
|
|
2672
2774
|
});
|
|
2673
2775
|
const t = i.filterBar.querySelector('[data-filter="search"]');
|
|
2674
2776
|
t && t.addEventListener("input", (o) => {
|
|
2675
|
-
i.filter.search = o.target.value,
|
|
2777
|
+
i.filter.search = o.target.value, ee(), y();
|
|
2676
2778
|
});
|
|
2677
2779
|
const e = i.filterBar.querySelector('[data-filter="file"]');
|
|
2678
2780
|
e && e.addEventListener("input", (o) => {
|
|
2679
|
-
i.filter.file = o.target.value,
|
|
2781
|
+
i.filter.file = o.target.value, ee(), y();
|
|
2680
2782
|
});
|
|
2681
2783
|
const n = i.filterBar.querySelector(".filter-clear-btn");
|
|
2682
2784
|
n && n.addEventListener("click", () => {
|
|
2683
|
-
i.filter =
|
|
2785
|
+
i.filter = N(), I(), y();
|
|
2684
2786
|
});
|
|
2685
2787
|
}
|
|
2686
2788
|
function y() {
|
|
2687
2789
|
if (!i.logsList) return;
|
|
2688
|
-
const t = f.getLogs(), e =
|
|
2790
|
+
const t = f.getLogs(), e = V(t, i.filter);
|
|
2689
2791
|
if (i.logsList.innerHTML = "", t.length === 0)
|
|
2690
|
-
i.logsList.appendChild(
|
|
2792
|
+
i.logsList.appendChild(Qe());
|
|
2691
2793
|
else if (e.length === 0) {
|
|
2692
2794
|
const n = document.createElement("div");
|
|
2693
2795
|
n.className = "devlogger-no-results", n.innerHTML = `
|
|
@@ -2695,58 +2797,121 @@ function y() {
|
|
|
2695
2797
|
<span class="devlogger-no-results-text">No logs match your filter</span>
|
|
2696
2798
|
`, i.logsList.appendChild(n);
|
|
2697
2799
|
} else {
|
|
2698
|
-
const n = document.createDocumentFragment();
|
|
2699
|
-
for (const
|
|
2700
|
-
|
|
2800
|
+
const n = document.createDocumentFragment(), o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
2801
|
+
for (const a of e) {
|
|
2802
|
+
if (!a.spanId) {
|
|
2803
|
+
n.appendChild(J(a));
|
|
2804
|
+
continue;
|
|
2805
|
+
}
|
|
2806
|
+
let l = o.get(a.spanId);
|
|
2807
|
+
if (!l) {
|
|
2808
|
+
const d = f.getSpan(a.spanId);
|
|
2809
|
+
l = Ce(a.spanId, d), o.set(a.spanId, l);
|
|
2810
|
+
const u = l.querySelector(".span-logs");
|
|
2811
|
+
u && r.set(a.spanId, u), n.appendChild(l);
|
|
2812
|
+
}
|
|
2813
|
+
const c = r.get(a.spanId);
|
|
2814
|
+
c && c.appendChild(J(a)), s.set(a.spanId, (s.get(a.spanId) ?? 0) + 1);
|
|
2815
|
+
}
|
|
2816
|
+
for (const [a, l] of s) {
|
|
2817
|
+
const d = o.get(a)?.querySelector(".span-count");
|
|
2818
|
+
d && (d.textContent = `${l} log${l === 1 ? "" : "s"}`);
|
|
2819
|
+
}
|
|
2701
2820
|
i.logsList.appendChild(n);
|
|
2702
2821
|
}
|
|
2703
|
-
|
|
2822
|
+
Se(e.length, t.length), re();
|
|
2704
2823
|
}
|
|
2705
|
-
function
|
|
2824
|
+
function gt(t) {
|
|
2706
2825
|
if (!i.logsList) return;
|
|
2707
|
-
const e = f.getLogs(), n =
|
|
2826
|
+
const e = f.getLogs(), n = V(e, i.filter);
|
|
2708
2827
|
if (n.some((r) => r.id === t.id)) {
|
|
2709
2828
|
const r = i.logsList.querySelector(".devlogger-empty, .devlogger-no-results");
|
|
2710
|
-
r && r.remove(),
|
|
2829
|
+
if (r && r.remove(), t.spanId) {
|
|
2830
|
+
let s = i.logsList.querySelector(`.span-group[data-span-id="${t.spanId}"]`);
|
|
2831
|
+
if (!s) {
|
|
2832
|
+
const l = f.getSpan(t.spanId);
|
|
2833
|
+
s = Ce(t.spanId, l), i.logsList.appendChild(s);
|
|
2834
|
+
}
|
|
2835
|
+
const a = s.querySelector(".span-logs");
|
|
2836
|
+
a && (a.appendChild(J(t)), ut(s, a));
|
|
2837
|
+
} else
|
|
2838
|
+
i.logsList.appendChild(J(t));
|
|
2711
2839
|
}
|
|
2712
|
-
|
|
2840
|
+
Se(n.length, e.length), ee(), re();
|
|
2713
2841
|
}
|
|
2714
|
-
function
|
|
2842
|
+
function Se(t, e) {
|
|
2715
2843
|
i.badge && (i.badge.textContent = String(t));
|
|
2716
2844
|
const n = i.container?.querySelector(".devlogger-log-count");
|
|
2717
|
-
n && (
|
|
2845
|
+
n && (ne(i.filter) ? n.textContent = `${t} of ${e} logs` : n.textContent = `${e} logs`);
|
|
2718
2846
|
}
|
|
2719
|
-
function
|
|
2847
|
+
function ee() {
|
|
2720
2848
|
if (!i.filterBar) return;
|
|
2721
|
-
const t = f.getLogs(), e =
|
|
2849
|
+
const t = f.getLogs(), e = V(t, i.filter), n = ne(i.filter), o = i.filterBar.querySelector(".filter-bar");
|
|
2722
2850
|
o && o.classList.toggle("filter-active", n);
|
|
2723
2851
|
let r = i.filterBar.querySelector(".filter-status");
|
|
2724
2852
|
if (n) {
|
|
2725
2853
|
r || (r = document.createElement("div"), r.className = "filter-status", o?.appendChild(r)), r.textContent = `Showing ${e.length} of ${t.length} logs`;
|
|
2726
2854
|
let s = i.filterBar.querySelector(".filter-clear-btn");
|
|
2727
2855
|
s || (s = document.createElement("button"), s.className = "filter-clear-btn", s.setAttribute("title", "Clear filters"), s.textContent = "✕", s.addEventListener("click", () => {
|
|
2728
|
-
i.filter =
|
|
2856
|
+
i.filter = N(), I(), y();
|
|
2729
2857
|
}), i.filterBar.querySelector(".filter-row")?.appendChild(s));
|
|
2730
2858
|
} else
|
|
2731
2859
|
r?.remove(), i.filterBar.querySelector(".filter-clear-btn")?.remove();
|
|
2732
2860
|
}
|
|
2733
|
-
function
|
|
2861
|
+
function re() {
|
|
2734
2862
|
i.logsList && i.visible && (i.logsList.scrollTop = i.logsList.scrollHeight);
|
|
2735
2863
|
}
|
|
2736
|
-
function
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2864
|
+
function ut(t, e) {
|
|
2865
|
+
const n = t.querySelector(".span-count");
|
|
2866
|
+
if (n) {
|
|
2867
|
+
const o = e.querySelectorAll(".log-entry").length;
|
|
2868
|
+
n.textContent = `${o} log${o === 1 ? "" : "s"}`;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
function Ce(t, e) {
|
|
2872
|
+
const n = document.createElement("div");
|
|
2873
|
+
n.className = "span-group", n.dataset.spanId = t;
|
|
2874
|
+
const o = e?.name ?? "Span", r = e?.status ?? "running", s = e ? Le(e) : "running", a = document.createElement("div");
|
|
2875
|
+
a.className = "span-header", a.innerHTML = `
|
|
2876
|
+
<button class="span-toggle" type="button" aria-label="Toggle span logs"></button>
|
|
2877
|
+
<span class="span-title">${lt(o)}</span>
|
|
2878
|
+
<span class="span-status span-status-${r}">${r}</span>
|
|
2879
|
+
<span class="span-duration">${s}</span>
|
|
2880
|
+
<span class="span-count">0 logs</span>
|
|
2881
|
+
`;
|
|
2882
|
+
const l = document.createElement("div");
|
|
2883
|
+
l.className = "span-logs", f.getConfig().spanCollapsed && n.classList.add("collapsed");
|
|
2884
|
+
const c = a.querySelector(".span-toggle"), d = () => {
|
|
2885
|
+
n.classList.toggle("collapsed");
|
|
2886
|
+
};
|
|
2887
|
+
return a.addEventListener("click", (u) => {
|
|
2888
|
+
u.target?.closest(".span-toggle") || d();
|
|
2889
|
+
}), c?.addEventListener("click", () => d()), n.appendChild(a), n.appendChild(l), n;
|
|
2890
|
+
}
|
|
2891
|
+
function ft(t) {
|
|
2892
|
+
const e = i.logsList?.querySelector(`.span-group[data-span-id="${t.id}"]`);
|
|
2893
|
+
if (!e) return;
|
|
2894
|
+
const n = e.querySelector(".span-title");
|
|
2895
|
+
n && (n.textContent = t.name);
|
|
2896
|
+
const o = e.querySelector(".span-status");
|
|
2897
|
+
o && (o.textContent = t.status, o.className = `span-status span-status-${t.status}`);
|
|
2898
|
+
const r = e.querySelector(".span-duration");
|
|
2899
|
+
r && (r.textContent = Le(t));
|
|
2900
|
+
}
|
|
2901
|
+
function me(t) {
|
|
2902
|
+
t.key.toLowerCase() === Z.key && t.ctrlKey === Z.ctrlKey && t.shiftKey === Z.shiftKey && (t.preventDefault(), oe() === "popout" ? F.popout() : F.toggle());
|
|
2903
|
+
}
|
|
2904
|
+
function pt(t) {
|
|
2740
2905
|
switch (t.type) {
|
|
2741
2906
|
case "CLEAR_LOGS":
|
|
2742
2907
|
f.clear(), y();
|
|
2743
2908
|
break;
|
|
2744
2909
|
case "SYNC_REQUEST":
|
|
2745
|
-
|
|
2910
|
+
z.sendSyncResponse(f.getLogs());
|
|
2746
2911
|
break;
|
|
2747
2912
|
}
|
|
2748
2913
|
}
|
|
2749
|
-
const
|
|
2914
|
+
const F = {
|
|
2750
2915
|
/**
|
|
2751
2916
|
* Initialize the overlay UI
|
|
2752
2917
|
*/
|
|
@@ -2757,9 +2922,11 @@ const j = {
|
|
|
2757
2922
|
const t = document.createElement("div");
|
|
2758
2923
|
t.id = "devlogger-host", document.body.appendChild(t), i.host = t;
|
|
2759
2924
|
const e = t.attachShadow({ mode: "open" });
|
|
2760
|
-
i.shadow = e,
|
|
2761
|
-
|
|
2762
|
-
}), i.
|
|
2925
|
+
i.shadow = e, ct(e), i.unsubscribe = f.subscribe((n) => {
|
|
2926
|
+
gt(n), z.sendLog(n);
|
|
2927
|
+
}), i.spanUnsubscribe = f.subscribeSpans((n) => {
|
|
2928
|
+
ft(n);
|
|
2929
|
+
}), i.channelUnsubscribe = z.subscribe(pt), document.addEventListener("keydown", me), i.initialized = !0;
|
|
2763
2930
|
} catch (t) {
|
|
2764
2931
|
console.warn("[DevLogger UI] Init error:", t);
|
|
2765
2932
|
}
|
|
@@ -2769,7 +2936,7 @@ const j = {
|
|
|
2769
2936
|
*/
|
|
2770
2937
|
open() {
|
|
2771
2938
|
try {
|
|
2772
|
-
i.initialized || this.init(), i.container && (i.container.classList.remove("hidden"), i.visible = !0,
|
|
2939
|
+
i.initialized || this.init(), i.container && (i.container.classList.remove("hidden"), i.visible = !0, re());
|
|
2773
2940
|
} catch {
|
|
2774
2941
|
}
|
|
2775
2942
|
},
|
|
@@ -2793,7 +2960,7 @@ const j = {
|
|
|
2793
2960
|
*/
|
|
2794
2961
|
popout() {
|
|
2795
2962
|
try {
|
|
2796
|
-
i.initialized || this.init(),
|
|
2963
|
+
i.initialized || this.init(), nt();
|
|
2797
2964
|
} catch (t) {
|
|
2798
2965
|
console.warn("[DevLogger] Failed to open pop-out:", t);
|
|
2799
2966
|
}
|
|
@@ -2802,13 +2969,13 @@ const j = {
|
|
|
2802
2969
|
* Close the pop-out window
|
|
2803
2970
|
*/
|
|
2804
2971
|
closePopout() {
|
|
2805
|
-
|
|
2972
|
+
he();
|
|
2806
2973
|
},
|
|
2807
2974
|
/**
|
|
2808
2975
|
* Check if pop-out window is open
|
|
2809
2976
|
*/
|
|
2810
2977
|
isPopoutOpen() {
|
|
2811
|
-
return
|
|
2978
|
+
return ot();
|
|
2812
2979
|
},
|
|
2813
2980
|
/**
|
|
2814
2981
|
* Set filter state
|
|
@@ -2830,7 +2997,7 @@ const j = {
|
|
|
2830
2997
|
*/
|
|
2831
2998
|
clearFilter() {
|
|
2832
2999
|
try {
|
|
2833
|
-
i.filter =
|
|
3000
|
+
i.filter = N(), I(), y();
|
|
2834
3001
|
} catch {
|
|
2835
3002
|
}
|
|
2836
3003
|
},
|
|
@@ -2839,7 +3006,7 @@ const j = {
|
|
|
2839
3006
|
*/
|
|
2840
3007
|
destroy() {
|
|
2841
3008
|
try {
|
|
2842
|
-
|
|
3009
|
+
he(), i.unsubscribe && (i.unsubscribe(), i.unsubscribe = null), i.spanUnsubscribe && (i.spanUnsubscribe(), i.spanUnsubscribe = null), i.channelUnsubscribe && (i.channelUnsubscribe(), i.channelUnsubscribe = null), document.removeEventListener("keydown", me), i.host && (i.host.remove(), i.host = null), i.initialized = !1, i.visible = !1, i.shadow = null, i.container = null, i.logsList = null, i.filterBar = null, i.toggleBtn = null, i.badge = null, i.spanUnsubscribe = null, i.filter = N();
|
|
2843
3010
|
} catch {
|
|
2844
3011
|
}
|
|
2845
3012
|
},
|
|
@@ -2855,21 +3022,21 @@ const j = {
|
|
|
2855
3022
|
isInitialized() {
|
|
2856
3023
|
return i.initialized;
|
|
2857
3024
|
}
|
|
2858
|
-
},
|
|
3025
|
+
}, ke = {
|
|
2859
3026
|
captureErrors: !0,
|
|
2860
3027
|
captureRejections: !0,
|
|
2861
3028
|
errorPrefix: "[Uncaught Error]",
|
|
2862
3029
|
rejectionPrefix: "[Unhandled Rejection]"
|
|
2863
3030
|
};
|
|
2864
|
-
let
|
|
2865
|
-
function
|
|
3031
|
+
let P = !1, L = { ...ke }, q = null, H = null;
|
|
3032
|
+
function ht(t, e, n, o, r) {
|
|
2866
3033
|
try {
|
|
2867
|
-
const s = r || (t instanceof ErrorEvent ? t.error : null),
|
|
2868
|
-
f.error(`${L.errorPrefix} ${
|
|
3034
|
+
const s = r || (t instanceof ErrorEvent ? t.error : null), a = s?.message || String(t), l = s?.stack;
|
|
3035
|
+
f.error(`${L.errorPrefix} ${a}`, {
|
|
2869
3036
|
source: e || "unknown",
|
|
2870
3037
|
line: n || 0,
|
|
2871
3038
|
column: o || 0,
|
|
2872
|
-
stack:
|
|
3039
|
+
stack: l,
|
|
2873
3040
|
originalError: s ? {
|
|
2874
3041
|
name: s.name,
|
|
2875
3042
|
message: s.message,
|
|
@@ -2878,14 +3045,14 @@ function at(t, e, n, o, r) {
|
|
|
2878
3045
|
});
|
|
2879
3046
|
} catch {
|
|
2880
3047
|
}
|
|
2881
|
-
if (
|
|
3048
|
+
if (q)
|
|
2882
3049
|
try {
|
|
2883
|
-
return
|
|
3050
|
+
return q(t, e, n, o, r) ?? !1;
|
|
2884
3051
|
} catch {
|
|
2885
3052
|
}
|
|
2886
3053
|
return !1;
|
|
2887
3054
|
}
|
|
2888
|
-
function
|
|
3055
|
+
function bt(t) {
|
|
2889
3056
|
try {
|
|
2890
3057
|
const e = t.reason;
|
|
2891
3058
|
let n, o = {};
|
|
@@ -2897,34 +3064,34 @@ function ct(t) {
|
|
|
2897
3064
|
} catch {
|
|
2898
3065
|
}
|
|
2899
3066
|
}
|
|
2900
|
-
function
|
|
2901
|
-
if (
|
|
3067
|
+
function vt(t = {}) {
|
|
3068
|
+
if (P) {
|
|
2902
3069
|
L = { ...L, ...t };
|
|
2903
3070
|
return;
|
|
2904
3071
|
}
|
|
2905
3072
|
try {
|
|
2906
3073
|
if (typeof window > "u")
|
|
2907
3074
|
return;
|
|
2908
|
-
L = { ...
|
|
3075
|
+
L = { ...ke, ...t }, q = window.onerror, L.captureErrors && (window.onerror = ht), L.captureRejections && (H = bt, window.addEventListener("unhandledrejection", H)), P = !0;
|
|
2909
3076
|
} catch {
|
|
2910
3077
|
}
|
|
2911
3078
|
}
|
|
2912
|
-
function
|
|
2913
|
-
if (
|
|
3079
|
+
function mt() {
|
|
3080
|
+
if (P)
|
|
2914
3081
|
try {
|
|
2915
3082
|
if (typeof window > "u")
|
|
2916
3083
|
return;
|
|
2917
|
-
window.onerror =
|
|
3084
|
+
window.onerror = q, H && window.removeEventListener("unhandledrejection", H), q = null, H = null, P = !1;
|
|
2918
3085
|
} catch {
|
|
2919
3086
|
}
|
|
2920
3087
|
}
|
|
2921
|
-
function
|
|
2922
|
-
return
|
|
3088
|
+
function yt() {
|
|
3089
|
+
return P;
|
|
2923
3090
|
}
|
|
2924
|
-
function
|
|
3091
|
+
function xt() {
|
|
2925
3092
|
return { ...L };
|
|
2926
3093
|
}
|
|
2927
|
-
const
|
|
3094
|
+
const Ut = {
|
|
2928
3095
|
/**
|
|
2929
3096
|
* Install global error handlers
|
|
2930
3097
|
*
|
|
@@ -2941,25 +3108,25 @@ const At = {
|
|
|
2941
3108
|
* });
|
|
2942
3109
|
* ```
|
|
2943
3110
|
*/
|
|
2944
|
-
install:
|
|
3111
|
+
install: vt,
|
|
2945
3112
|
/**
|
|
2946
3113
|
* Uninstall global error handlers and restore originals
|
|
2947
3114
|
*/
|
|
2948
|
-
uninstall:
|
|
3115
|
+
uninstall: mt,
|
|
2949
3116
|
/**
|
|
2950
3117
|
* Check if error capture is currently active
|
|
2951
3118
|
*/
|
|
2952
|
-
isActive:
|
|
3119
|
+
isActive: yt,
|
|
2953
3120
|
/**
|
|
2954
3121
|
* Get current configuration
|
|
2955
3122
|
*/
|
|
2956
|
-
getConfig:
|
|
2957
|
-
},
|
|
3123
|
+
getConfig: xt
|
|
3124
|
+
}, X = "devlogger_persisted_logs", se = "devlogger_session_active", $e = {
|
|
2958
3125
|
storage: "session",
|
|
2959
3126
|
maxPersisted: 500,
|
|
2960
3127
|
debounceMs: 100
|
|
2961
3128
|
};
|
|
2962
|
-
let R = !1, S = {
|
|
3129
|
+
let R = !1, S = { ...$e }, U = [], x = null, ie = !1, W = null;
|
|
2963
3130
|
function k() {
|
|
2964
3131
|
try {
|
|
2965
3132
|
return typeof window > "u" ? null : S.storage === "local" ? localStorage : sessionStorage;
|
|
@@ -2967,52 +3134,52 @@ function k() {
|
|
|
2967
3134
|
return null;
|
|
2968
3135
|
}
|
|
2969
3136
|
}
|
|
2970
|
-
function
|
|
3137
|
+
function wt() {
|
|
2971
3138
|
try {
|
|
2972
3139
|
const t = k();
|
|
2973
|
-
return t ? t.getItem(
|
|
3140
|
+
return t ? t.getItem(se) === "active" : !1;
|
|
2974
3141
|
} catch {
|
|
2975
3142
|
return !1;
|
|
2976
3143
|
}
|
|
2977
3144
|
}
|
|
2978
|
-
function
|
|
3145
|
+
function Lt() {
|
|
2979
3146
|
try {
|
|
2980
3147
|
const t = k();
|
|
2981
3148
|
if (!t) return;
|
|
2982
|
-
t.setItem(
|
|
3149
|
+
t.setItem(se, "active");
|
|
2983
3150
|
} catch {
|
|
2984
3151
|
}
|
|
2985
3152
|
}
|
|
2986
|
-
function
|
|
3153
|
+
function Ee() {
|
|
2987
3154
|
try {
|
|
2988
3155
|
const t = k();
|
|
2989
3156
|
if (!t) return;
|
|
2990
|
-
t.removeItem(
|
|
3157
|
+
t.removeItem(se);
|
|
2991
3158
|
} catch {
|
|
2992
3159
|
}
|
|
2993
3160
|
}
|
|
2994
|
-
function
|
|
3161
|
+
function Te(t) {
|
|
2995
3162
|
try {
|
|
2996
3163
|
const e = k();
|
|
2997
3164
|
if (!e) return;
|
|
2998
3165
|
const n = t.slice(-S.maxPersisted), o = JSON.stringify(n);
|
|
2999
|
-
e.setItem(
|
|
3166
|
+
e.setItem(X, o);
|
|
3000
3167
|
} catch (e) {
|
|
3001
3168
|
if (e instanceof DOMException && e.name === "QuotaExceededError")
|
|
3002
3169
|
try {
|
|
3003
3170
|
const n = k();
|
|
3004
3171
|
if (!n) return;
|
|
3005
3172
|
const o = t.slice(-Math.floor(S.maxPersisted / 2));
|
|
3006
|
-
n.setItem(
|
|
3173
|
+
n.setItem(X, JSON.stringify(o));
|
|
3007
3174
|
} catch {
|
|
3008
3175
|
}
|
|
3009
3176
|
}
|
|
3010
3177
|
}
|
|
3011
|
-
function
|
|
3178
|
+
function Ie() {
|
|
3012
3179
|
try {
|
|
3013
3180
|
const t = k();
|
|
3014
3181
|
if (!t) return [];
|
|
3015
|
-
const e = t.getItem(
|
|
3182
|
+
const e = t.getItem(X);
|
|
3016
3183
|
if (!e) return [];
|
|
3017
3184
|
const n = JSON.parse(e);
|
|
3018
3185
|
return Array.isArray(n) ? n.filter(
|
|
@@ -3022,31 +3189,31 @@ function $e() {
|
|
|
3022
3189
|
return [];
|
|
3023
3190
|
}
|
|
3024
3191
|
}
|
|
3025
|
-
function
|
|
3192
|
+
function St() {
|
|
3026
3193
|
try {
|
|
3027
3194
|
const t = k();
|
|
3028
3195
|
if (!t) return;
|
|
3029
|
-
t.removeItem(
|
|
3196
|
+
t.removeItem(X);
|
|
3030
3197
|
} catch {
|
|
3031
3198
|
}
|
|
3032
3199
|
}
|
|
3033
|
-
function
|
|
3034
|
-
|
|
3035
|
-
|
|
3200
|
+
function Ct(t) {
|
|
3201
|
+
U = t, x && clearTimeout(x), x = setTimeout(() => {
|
|
3202
|
+
Te(U), x = null;
|
|
3036
3203
|
}, S.debounceMs);
|
|
3037
3204
|
}
|
|
3038
|
-
function
|
|
3205
|
+
function Y() {
|
|
3039
3206
|
try {
|
|
3040
|
-
x && (clearTimeout(x), x = null),
|
|
3207
|
+
x && (clearTimeout(x), x = null), U.length > 0 && Te(U), Ee();
|
|
3041
3208
|
} catch {
|
|
3042
3209
|
}
|
|
3043
3210
|
}
|
|
3044
|
-
function
|
|
3211
|
+
function kt() {
|
|
3045
3212
|
if (!R) return;
|
|
3046
3213
|
const t = f.getLogs();
|
|
3047
|
-
|
|
3214
|
+
Ct([...t]);
|
|
3048
3215
|
}
|
|
3049
|
-
function
|
|
3216
|
+
function $t(t = {}) {
|
|
3050
3217
|
if (R) {
|
|
3051
3218
|
S = { ...S, ...t };
|
|
3052
3219
|
return;
|
|
@@ -3054,43 +3221,43 @@ function yt(t = {}) {
|
|
|
3054
3221
|
try {
|
|
3055
3222
|
if (typeof window > "u")
|
|
3056
3223
|
return;
|
|
3057
|
-
S = {
|
|
3224
|
+
S = { ...$e, ...t }, ie = wt(), Lt(), W = f.subscribe(kt), window.addEventListener("beforeunload", Y), window.addEventListener("pagehide", Y), R = !0;
|
|
3058
3225
|
} catch {
|
|
3059
3226
|
}
|
|
3060
3227
|
}
|
|
3061
|
-
function
|
|
3228
|
+
function Et() {
|
|
3062
3229
|
if (R)
|
|
3063
3230
|
try {
|
|
3064
3231
|
if (typeof window > "u")
|
|
3065
3232
|
return;
|
|
3066
|
-
x && (clearTimeout(x), x = null), W && (W(), W = null), window.removeEventListener("beforeunload",
|
|
3233
|
+
x && (clearTimeout(x), x = null), W && (W(), W = null), window.removeEventListener("beforeunload", Y), window.removeEventListener("pagehide", Y), Ee(), R = !1;
|
|
3067
3234
|
} catch {
|
|
3068
3235
|
}
|
|
3069
3236
|
}
|
|
3070
|
-
function
|
|
3071
|
-
return
|
|
3237
|
+
function Tt() {
|
|
3238
|
+
return ie;
|
|
3072
3239
|
}
|
|
3073
|
-
function
|
|
3074
|
-
return
|
|
3240
|
+
function It() {
|
|
3241
|
+
return Ie();
|
|
3075
3242
|
}
|
|
3076
|
-
function
|
|
3243
|
+
function Rt() {
|
|
3077
3244
|
try {
|
|
3078
|
-
const t =
|
|
3245
|
+
const t = Ie();
|
|
3079
3246
|
return t.length === 0 ? 0 : (f.importLogs(t), t.length);
|
|
3080
3247
|
} catch {
|
|
3081
3248
|
return 0;
|
|
3082
3249
|
}
|
|
3083
3250
|
}
|
|
3084
|
-
function
|
|
3085
|
-
|
|
3251
|
+
function Dt() {
|
|
3252
|
+
St(), U = [], ie = !1;
|
|
3086
3253
|
}
|
|
3087
|
-
function
|
|
3254
|
+
function _t() {
|
|
3088
3255
|
return R;
|
|
3089
3256
|
}
|
|
3090
|
-
function
|
|
3257
|
+
function Mt() {
|
|
3091
3258
|
return { ...S };
|
|
3092
3259
|
}
|
|
3093
|
-
const
|
|
3260
|
+
const Vt = {
|
|
3094
3261
|
/**
|
|
3095
3262
|
* Enable log persistence
|
|
3096
3263
|
*
|
|
@@ -3106,23 +3273,23 @@ const Ot = {
|
|
|
3106
3273
|
* });
|
|
3107
3274
|
* ```
|
|
3108
3275
|
*/
|
|
3109
|
-
enable:
|
|
3276
|
+
enable: $t,
|
|
3110
3277
|
/**
|
|
3111
3278
|
* Disable log persistence
|
|
3112
3279
|
*/
|
|
3113
|
-
disable:
|
|
3280
|
+
disable: Et,
|
|
3114
3281
|
/**
|
|
3115
3282
|
* Check if persistence is enabled
|
|
3116
3283
|
*/
|
|
3117
|
-
isActive:
|
|
3284
|
+
isActive: _t,
|
|
3118
3285
|
/**
|
|
3119
3286
|
* Check if the last session had a crash (unclean shutdown)
|
|
3120
3287
|
*/
|
|
3121
|
-
hadCrash:
|
|
3288
|
+
hadCrash: Tt,
|
|
3122
3289
|
/**
|
|
3123
3290
|
* Get persisted logs from previous session (without importing)
|
|
3124
3291
|
*/
|
|
3125
|
-
getPersistedLogs:
|
|
3292
|
+
getPersistedLogs: It,
|
|
3126
3293
|
/**
|
|
3127
3294
|
* Rehydrate logs from storage into the logger
|
|
3128
3295
|
* Call this at app startup to restore logs from previous session
|
|
@@ -3139,16 +3306,16 @@ const Ot = {
|
|
|
3139
3306
|
* }
|
|
3140
3307
|
* ```
|
|
3141
3308
|
*/
|
|
3142
|
-
rehydrate:
|
|
3309
|
+
rehydrate: Rt,
|
|
3143
3310
|
/**
|
|
3144
3311
|
* Clear all persisted logs
|
|
3145
3312
|
*/
|
|
3146
|
-
clear:
|
|
3313
|
+
clear: Dt,
|
|
3147
3314
|
/**
|
|
3148
3315
|
* Get current configuration
|
|
3149
3316
|
*/
|
|
3150
|
-
getConfig:
|
|
3151
|
-
},
|
|
3317
|
+
getConfig: Mt
|
|
3318
|
+
}, Re = {
|
|
3152
3319
|
captureFetch: !0,
|
|
3153
3320
|
captureXHR: !0,
|
|
3154
3321
|
includeHeaders: !1,
|
|
@@ -3158,8 +3325,8 @@ const Ot = {
|
|
|
3158
3325
|
ignorePatterns: [],
|
|
3159
3326
|
context: {}
|
|
3160
3327
|
};
|
|
3161
|
-
let E = null, O = null, T = null, B = !1, v = { ...
|
|
3162
|
-
function
|
|
3328
|
+
let E = null, O = null, T = null, B = !1, v = { ...Re };
|
|
3329
|
+
function De(t) {
|
|
3163
3330
|
for (const e of v.ignorePatterns)
|
|
3164
3331
|
if (typeof e == "string") {
|
|
3165
3332
|
if (t.includes(e)) return !0;
|
|
@@ -3167,7 +3334,7 @@ function Te(t) {
|
|
|
3167
3334
|
return !0;
|
|
3168
3335
|
return !1;
|
|
3169
3336
|
}
|
|
3170
|
-
function
|
|
3337
|
+
function _e(t) {
|
|
3171
3338
|
try {
|
|
3172
3339
|
const e = new URL(t, window.location.origin);
|
|
3173
3340
|
return {
|
|
@@ -3179,107 +3346,107 @@ function Ie(t) {
|
|
|
3179
3346
|
return { host: "unknown", path: t, full: t };
|
|
3180
3347
|
}
|
|
3181
3348
|
}
|
|
3182
|
-
function
|
|
3349
|
+
function Me(t, e) {
|
|
3183
3350
|
return t.length <= e ? t : t.slice(0, e) + "... (truncated)";
|
|
3184
3351
|
}
|
|
3185
|
-
function
|
|
3352
|
+
function K(t) {
|
|
3186
3353
|
try {
|
|
3187
3354
|
return JSON.parse(t);
|
|
3188
3355
|
} catch {
|
|
3189
3356
|
return t;
|
|
3190
3357
|
}
|
|
3191
3358
|
}
|
|
3192
|
-
function
|
|
3359
|
+
function Bt() {
|
|
3193
3360
|
return async function(e, n) {
|
|
3194
3361
|
const o = typeof e == "string" ? e : e instanceof URL ? e.href : e.url;
|
|
3195
|
-
if (
|
|
3362
|
+
if (De(o))
|
|
3196
3363
|
return E(e, n);
|
|
3197
|
-
const { host: r, path: s } =
|
|
3364
|
+
const { host: r, path: s } = _e(o), a = n?.method || "GET", l = `${a} ${s}`, c = f.span(l, {
|
|
3198
3365
|
...v.context,
|
|
3199
3366
|
type: "fetch",
|
|
3200
|
-
method:
|
|
3367
|
+
method: a,
|
|
3201
3368
|
host: r
|
|
3202
3369
|
});
|
|
3203
|
-
if (
|
|
3370
|
+
if (c.info(`Request started: ${o}`), v.includeHeaders && n?.headers && c.debug("Request headers", n.headers), v.includeBody && n?.body)
|
|
3204
3371
|
try {
|
|
3205
|
-
const u = typeof n.body == "string" ?
|
|
3206
|
-
|
|
3372
|
+
const u = typeof n.body == "string" ? K(n.body) : n.body;
|
|
3373
|
+
c.debug("Request body", u);
|
|
3207
3374
|
} catch {
|
|
3208
|
-
|
|
3375
|
+
c.debug("Request body", "[Unable to parse]");
|
|
3209
3376
|
}
|
|
3210
3377
|
const d = performance.now();
|
|
3211
3378
|
try {
|
|
3212
3379
|
const u = await E(e, n), h = Math.round(performance.now() - d);
|
|
3213
3380
|
if (u.ok) {
|
|
3214
|
-
if (
|
|
3381
|
+
if (c.info(`Response: ${u.status} ${u.statusText} (${h}ms)`), v.includeResponse)
|
|
3215
3382
|
try {
|
|
3216
|
-
const
|
|
3217
|
-
|
|
3383
|
+
const Q = await u.clone().text(), m = K(Me(Q, v.maxResponseLength));
|
|
3384
|
+
c.debug("Response body", m);
|
|
3218
3385
|
} catch {
|
|
3219
|
-
|
|
3386
|
+
c.debug("Response body", "[Unable to read]");
|
|
3220
3387
|
}
|
|
3221
|
-
|
|
3388
|
+
c.end();
|
|
3222
3389
|
} else
|
|
3223
|
-
|
|
3390
|
+
c.warn(`Response: ${u.status} ${u.statusText} (${h}ms)`), c.fail();
|
|
3224
3391
|
return u;
|
|
3225
3392
|
} catch (u) {
|
|
3226
3393
|
const h = Math.round(performance.now() - d);
|
|
3227
|
-
throw
|
|
3394
|
+
throw c.error(`Request failed after ${h}ms`, u), c.fail(), u;
|
|
3228
3395
|
}
|
|
3229
3396
|
};
|
|
3230
3397
|
}
|
|
3231
|
-
function
|
|
3398
|
+
function At() {
|
|
3232
3399
|
O = XMLHttpRequest.prototype.open, T = XMLHttpRequest.prototype.send, XMLHttpRequest.prototype.open = function(t, e, n = !0, o, r) {
|
|
3233
3400
|
const s = typeof e == "string" ? e : e.href;
|
|
3234
3401
|
return this.__networkCapture = {
|
|
3235
3402
|
method: t,
|
|
3236
3403
|
url: s,
|
|
3237
|
-
ignored:
|
|
3404
|
+
ignored: De(s)
|
|
3238
3405
|
}, O.call(this, t, e, n, o, r);
|
|
3239
3406
|
}, XMLHttpRequest.prototype.send = function(t) {
|
|
3240
3407
|
const e = this.__networkCapture;
|
|
3241
3408
|
if (!e || e.ignored)
|
|
3242
3409
|
return T.call(this, t);
|
|
3243
|
-
const { method: n, url: o } = e, { host: r, path: s } =
|
|
3410
|
+
const { method: n, url: o } = e, { host: r, path: s } = _e(o), a = `${n} ${s}`, l = f.span(a, {
|
|
3244
3411
|
...v.context,
|
|
3245
3412
|
type: "xhr",
|
|
3246
3413
|
method: n,
|
|
3247
3414
|
host: r
|
|
3248
3415
|
});
|
|
3249
|
-
if (
|
|
3416
|
+
if (l.info(`XHR Request started: ${o}`), v.includeBody && t)
|
|
3250
3417
|
try {
|
|
3251
|
-
const d = typeof t == "string" ?
|
|
3252
|
-
|
|
3418
|
+
const d = typeof t == "string" ? K(t) : t;
|
|
3419
|
+
l.debug("Request body", d);
|
|
3253
3420
|
} catch {
|
|
3254
|
-
|
|
3421
|
+
l.debug("Request body", "[Unable to parse]");
|
|
3255
3422
|
}
|
|
3256
|
-
const
|
|
3423
|
+
const c = performance.now();
|
|
3257
3424
|
return this.addEventListener("load", () => {
|
|
3258
|
-
const d = Math.round(performance.now() -
|
|
3425
|
+
const d = Math.round(performance.now() - c);
|
|
3259
3426
|
if (this.status >= 200 && this.status < 400) {
|
|
3260
|
-
if (
|
|
3261
|
-
const u =
|
|
3262
|
-
|
|
3427
|
+
if (l.info(`Response: ${this.status} ${this.statusText} (${d}ms)`), v.includeResponse && this.responseText) {
|
|
3428
|
+
const u = K(Me(this.responseText, v.maxResponseLength));
|
|
3429
|
+
l.debug("Response body", u);
|
|
3263
3430
|
}
|
|
3264
|
-
|
|
3431
|
+
l.end();
|
|
3265
3432
|
} else
|
|
3266
|
-
|
|
3433
|
+
l.warn(`Response: ${this.status} ${this.statusText} (${d}ms)`), l.fail();
|
|
3267
3434
|
}), this.addEventListener("error", () => {
|
|
3268
|
-
const d = Math.round(performance.now() -
|
|
3269
|
-
|
|
3435
|
+
const d = Math.round(performance.now() - c);
|
|
3436
|
+
l.error(`XHR Request failed after ${d}ms`), l.fail();
|
|
3270
3437
|
}), this.addEventListener("abort", () => {
|
|
3271
|
-
const d = Math.round(performance.now() -
|
|
3272
|
-
|
|
3438
|
+
const d = Math.round(performance.now() - c);
|
|
3439
|
+
l.warn(`XHR Request aborted after ${d}ms`), l.fail();
|
|
3273
3440
|
}), this.addEventListener("timeout", () => {
|
|
3274
|
-
const d = Math.round(performance.now() -
|
|
3275
|
-
|
|
3441
|
+
const d = Math.round(performance.now() - c);
|
|
3442
|
+
l.error(`XHR Request timeout after ${d}ms`), l.fail();
|
|
3276
3443
|
}), T.call(this, t);
|
|
3277
3444
|
};
|
|
3278
3445
|
}
|
|
3279
|
-
function
|
|
3446
|
+
function Ft() {
|
|
3280
3447
|
O && (XMLHttpRequest.prototype.open = O, O = null), T && (XMLHttpRequest.prototype.send = T, T = null);
|
|
3281
3448
|
}
|
|
3282
|
-
const
|
|
3449
|
+
const jt = {
|
|
3283
3450
|
/**
|
|
3284
3451
|
* Install network capture hooks
|
|
3285
3452
|
*/
|
|
@@ -3287,7 +3454,7 @@ const Ht = {
|
|
|
3287
3454
|
try {
|
|
3288
3455
|
if (B)
|
|
3289
3456
|
return;
|
|
3290
|
-
v = { ...
|
|
3457
|
+
v = { ...Re, ...t }, v.captureFetch && typeof globalThis.fetch == "function" && (E = globalThis.fetch, globalThis.fetch = Bt()), v.captureXHR && typeof XMLHttpRequest < "u" && At(), B = !0, f.debug("[NetworkCapture] Installed", {
|
|
3291
3458
|
fetch: v.captureFetch,
|
|
3292
3459
|
xhr: v.captureXHR
|
|
3293
3460
|
});
|
|
@@ -3302,7 +3469,7 @@ const Ht = {
|
|
|
3302
3469
|
try {
|
|
3303
3470
|
if (!B)
|
|
3304
3471
|
return;
|
|
3305
|
-
E && (globalThis.fetch = E, E = null),
|
|
3472
|
+
E && (globalThis.fetch = E, E = null), Ft(), B = !1, f.debug("[NetworkCapture] Uninstalled");
|
|
3306
3473
|
} catch (t) {
|
|
3307
3474
|
console.warn("[NetworkCapture] Uninstall error:", t);
|
|
3308
3475
|
}
|
|
@@ -3325,17 +3492,17 @@ const Ht = {
|
|
|
3325
3492
|
addIgnorePattern(t) {
|
|
3326
3493
|
v.ignorePatterns.push(t);
|
|
3327
3494
|
}
|
|
3328
|
-
},
|
|
3495
|
+
}, Ht = {
|
|
3329
3496
|
debug: "#6e6e6e",
|
|
3330
3497
|
info: "#3794ff",
|
|
3331
3498
|
warn: "#cca700",
|
|
3332
3499
|
error: "#f14c4c"
|
|
3333
|
-
},
|
|
3500
|
+
}, Ot = {
|
|
3334
3501
|
running: "#3794ff",
|
|
3335
3502
|
success: "#4caf50",
|
|
3336
3503
|
error: "#f14c4c"
|
|
3337
3504
|
};
|
|
3338
|
-
class
|
|
3505
|
+
class zt {
|
|
3339
3506
|
constructor(e) {
|
|
3340
3507
|
p(this, "container");
|
|
3341
3508
|
p(this, "config");
|
|
@@ -3443,8 +3610,8 @@ class Dt {
|
|
|
3443
3610
|
e.addEventListener("click", (n) => {
|
|
3444
3611
|
const o = n.currentTarget, r = parseInt(o.dataset.window || "60000", 10);
|
|
3445
3612
|
this.setTimeWindow(r), this.container.querySelectorAll("[data-window]").forEach((s) => {
|
|
3446
|
-
const
|
|
3447
|
-
|
|
3613
|
+
const a = s;
|
|
3614
|
+
a === o ? (a.style.background = "#0e639c", a.style.borderColor = "#0e639c", a.style.color = "white") : (a.style.background = "transparent", a.style.borderColor = "#3c3c3c", a.style.color = "#858585");
|
|
3448
3615
|
});
|
|
3449
3616
|
});
|
|
3450
3617
|
}), this.canvas && (this.canvas.addEventListener("mousemove", this.handleMouseMove.bind(this)), this.canvas.addEventListener("mouseleave", this.handleMouseLeave.bind(this))), this.startRefresh();
|
|
@@ -3467,44 +3634,44 @@ class Dt {
|
|
|
3467
3634
|
if (!this.canvas || !this.ctx) return;
|
|
3468
3635
|
const e = this.ctx, n = this.canvas.width, o = this.canvas.height, r = Date.now(), s = r - this.config.timeWindow;
|
|
3469
3636
|
e.fillStyle = "#1e1e1e", e.fillRect(0, 0, n, o), this.spanBounds.clear(), this.logBounds.clear(), this.drawTimeGrid(e, n, o, s, r);
|
|
3470
|
-
const
|
|
3471
|
-
this.config.showSpans && this.drawSpans(e,
|
|
3637
|
+
const a = f.getLogs().filter((c) => c.timestamp >= s), l = f.getSpans().filter((c) => c.startTime >= s || c.endTime && c.endTime >= s);
|
|
3638
|
+
this.config.showSpans && this.drawSpans(e, l, n, o, s, r), this.config.showLogs && this.drawLogs(e, a, n, o, s, r);
|
|
3472
3639
|
}
|
|
3473
3640
|
drawTimeGrid(e, n, o, r, s) {
|
|
3474
|
-
const
|
|
3641
|
+
const a = s - r, l = 6;
|
|
3475
3642
|
e.strokeStyle = "#333", e.lineWidth = 1, e.font = "10px SF Mono, monospace", e.fillStyle = "#666";
|
|
3476
|
-
for (let
|
|
3477
|
-
const d =
|
|
3643
|
+
for (let c = 0; c <= l; c++) {
|
|
3644
|
+
const d = c / l * n, u = r + a * c / l;
|
|
3478
3645
|
e.beginPath(), e.moveTo(d, 0), e.lineTo(d, o), e.stroke();
|
|
3479
3646
|
const h = new Date(u), C = `${h.getMinutes().toString().padStart(2, "0")}:${h.getSeconds().toString().padStart(2, "0")}`;
|
|
3480
3647
|
e.fillText(C, d + 2, o - 4);
|
|
3481
3648
|
}
|
|
3482
3649
|
}
|
|
3483
|
-
drawSpans(e, n, o, r, s,
|
|
3484
|
-
const
|
|
3650
|
+
drawSpans(e, n, o, r, s, a) {
|
|
3651
|
+
const l = a - s, c = 20, d = 4, u = 20, h = n.filter((m) => !m.parentId);
|
|
3485
3652
|
let C = u;
|
|
3486
|
-
const
|
|
3487
|
-
const
|
|
3488
|
-
e.fillStyle =
|
|
3489
|
-
const
|
|
3490
|
-
return e.fillText(
|
|
3491
|
-
x:
|
|
3492
|
-
y:
|
|
3493
|
-
w:
|
|
3494
|
-
h:
|
|
3495
|
-
}),
|
|
3653
|
+
const Q = (m, D, Nt = 0) => {
|
|
3654
|
+
const _ = (m.startTime - s) / l * o, Be = ((m.endTime || a) - s) / l * o, j = Math.max(Be - _, 2), ae = Ot[m.status];
|
|
3655
|
+
e.fillStyle = ae + "40", e.fillRect(_, D, j, c), e.strokeStyle = ae, e.lineWidth = 1, e.strokeRect(_, D, j, c), e.fillStyle = "#ccc", e.font = "10px SF Mono, monospace";
|
|
3656
|
+
const Ae = m.duration ? `${m.name} (${m.duration}ms)` : m.name;
|
|
3657
|
+
return e.fillText(Ae, _ + 4, D + 14, j - 8), this.spanBounds.set(m.id, {
|
|
3658
|
+
x: _,
|
|
3659
|
+
y: D,
|
|
3660
|
+
w: j,
|
|
3661
|
+
h: c
|
|
3662
|
+
}), D + c + d;
|
|
3496
3663
|
};
|
|
3497
3664
|
for (const m of h)
|
|
3498
|
-
C =
|
|
3665
|
+
C = Q(m, C);
|
|
3499
3666
|
}
|
|
3500
|
-
drawLogs(e, n, o, r, s,
|
|
3501
|
-
const
|
|
3667
|
+
drawLogs(e, n, o, r, s, a) {
|
|
3668
|
+
const l = a - s, c = 8, d = 30;
|
|
3502
3669
|
for (const u of n) {
|
|
3503
|
-
const h = (u.timestamp - s) /
|
|
3504
|
-
e.fillStyle = C, e.beginPath(), e.moveTo(h, r - d), e.lineTo(h -
|
|
3670
|
+
const h = (u.timestamp - s) / l * o, C = Ht[u.level];
|
|
3671
|
+
e.fillStyle = C, e.beginPath(), e.moveTo(h, r - d), e.lineTo(h - c / 2, r - d - c), e.lineTo(h + c / 2, r - d - c), e.closePath(), e.fill(), this.logBounds.set(u.id, {
|
|
3505
3672
|
x: h,
|
|
3506
|
-
y: r - d -
|
|
3507
|
-
r:
|
|
3673
|
+
y: r - d - c / 2,
|
|
3674
|
+
r: c
|
|
3508
3675
|
});
|
|
3509
3676
|
}
|
|
3510
3677
|
}
|
|
@@ -3512,8 +3679,8 @@ class Dt {
|
|
|
3512
3679
|
if (!this.canvas || !this.tooltip) return;
|
|
3513
3680
|
const n = this.canvas.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top;
|
|
3514
3681
|
for (const s of f.getSpans()) {
|
|
3515
|
-
const
|
|
3516
|
-
if (
|
|
3682
|
+
const a = this.spanBounds.get(s.id);
|
|
3683
|
+
if (a && o >= a.x && o <= a.x + a.w && r >= a.y && r <= a.y + a.h) {
|
|
3517
3684
|
this.showTooltip(e, `
|
|
3518
3685
|
<strong>${s.name}</strong><br>
|
|
3519
3686
|
Status: ${s.status}<br>
|
|
@@ -3524,8 +3691,8 @@ class Dt {
|
|
|
3524
3691
|
}
|
|
3525
3692
|
}
|
|
3526
3693
|
for (const s of f.getLogs()) {
|
|
3527
|
-
const
|
|
3528
|
-
if (
|
|
3694
|
+
const a = this.logBounds.get(s.id);
|
|
3695
|
+
if (a && Math.sqrt((o - a.x) ** 2 + (r - a.y) ** 2) <= a.r) {
|
|
3529
3696
|
this.showTooltip(e, `
|
|
3530
3697
|
<strong>[${s.level.toUpperCase()}]</strong> ${s.message}<br>
|
|
3531
3698
|
<small>${new Date(s.timestamp).toISOString()}</small>
|
|
@@ -3551,21 +3718,21 @@ class Dt {
|
|
|
3551
3718
|
this.stopRefresh(), this.container.innerHTML = "";
|
|
3552
3719
|
}
|
|
3553
3720
|
}
|
|
3554
|
-
function
|
|
3555
|
-
return new
|
|
3721
|
+
function Wt(t) {
|
|
3722
|
+
return new zt(t);
|
|
3556
3723
|
}
|
|
3557
|
-
const
|
|
3724
|
+
const Gt = "0.1.0";
|
|
3558
3725
|
export {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3726
|
+
F as DevLoggerUI,
|
|
3727
|
+
Ut as ErrorCapture,
|
|
3728
|
+
Vt as LogPersistence,
|
|
3729
|
+
jt as NetworkCapture,
|
|
3730
|
+
zt as Timeline,
|
|
3731
|
+
Gt as VERSION,
|
|
3732
|
+
ye as computeDiff,
|
|
3733
|
+
de as createDiffResult,
|
|
3734
|
+
Wt as createTimeline,
|
|
3735
|
+
ce as formatValue,
|
|
3736
|
+
qt as hasChanges,
|
|
3570
3737
|
f as logger
|
|
3571
3738
|
};
|