@archbase/tools 3.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 +423 -0
- package/dist/archbase-tools-3.0.0.tgz +0 -0
- package/dist/index.js +2088 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2088 @@
|
|
|
1
|
+
import { jsxs as n, jsx as r, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import W, { useState as F, useEffect as L, useRef as M, Component as Q } from "react";
|
|
3
|
+
import X from "react-dom";
|
|
4
|
+
import { useHotkeys as Z } from "@mantine/hooks";
|
|
5
|
+
import { Group as H, Text as U, Badge as $, Button as G, Select as q, Accordion as A, JsonInput as ee } from "@mantine/core";
|
|
6
|
+
import { IconDatabase as V, IconRefresh as te, IconEye as re, IconSettings as oe } from "@tabler/icons-react";
|
|
7
|
+
class j {
|
|
8
|
+
static instance;
|
|
9
|
+
enabled = !0;
|
|
10
|
+
logLevel = "debug";
|
|
11
|
+
prefix = "[Archbase]";
|
|
12
|
+
constructor() {
|
|
13
|
+
}
|
|
14
|
+
static getInstance() {
|
|
15
|
+
return j.instance || (j.instance = new j()), j.instance;
|
|
16
|
+
}
|
|
17
|
+
setEnabled(t) {
|
|
18
|
+
return this.enabled = t, this;
|
|
19
|
+
}
|
|
20
|
+
setLogLevel(t) {
|
|
21
|
+
return this.logLevel = t, this;
|
|
22
|
+
}
|
|
23
|
+
setPrefix(t) {
|
|
24
|
+
return this.prefix = t, this;
|
|
25
|
+
}
|
|
26
|
+
shouldLog(t) {
|
|
27
|
+
if (!this.enabled)
|
|
28
|
+
return !1;
|
|
29
|
+
const o = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
30
|
+
return o[t] >= o[this.logLevel];
|
|
31
|
+
}
|
|
32
|
+
debug(t, ...o) {
|
|
33
|
+
this.shouldLog("debug") && console.log(
|
|
34
|
+
`%c${this.prefix} [DEBUG]`,
|
|
35
|
+
"color: #9CA3AF; font-weight: bold",
|
|
36
|
+
t,
|
|
37
|
+
...o
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
info(t, ...o) {
|
|
41
|
+
this.shouldLog("info") && console.log(
|
|
42
|
+
`%c${this.prefix} [INFO]`,
|
|
43
|
+
"color: #3B82F6; font-weight: bold",
|
|
44
|
+
t,
|
|
45
|
+
...o
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
warn(t, ...o) {
|
|
49
|
+
this.shouldLog("warn") && console.warn(
|
|
50
|
+
`%c${this.prefix} [WARN]`,
|
|
51
|
+
"color: #F59E0B; font-weight: bold",
|
|
52
|
+
t,
|
|
53
|
+
...o
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
error(t, o, ...s) {
|
|
57
|
+
this.shouldLog("error") && (console.error(
|
|
58
|
+
`%c${this.prefix} [ERROR]`,
|
|
59
|
+
"color: #EF4444; font-weight: bold",
|
|
60
|
+
t,
|
|
61
|
+
o,
|
|
62
|
+
...s
|
|
63
|
+
), o?.stack && console.error(o.stack));
|
|
64
|
+
}
|
|
65
|
+
group(t, o) {
|
|
66
|
+
this.enabled && (console.group(`%c${this.prefix} ${t}`, "font-weight: bold"), o(), console.groupEnd());
|
|
67
|
+
}
|
|
68
|
+
time(t) {
|
|
69
|
+
this.enabled && console.time(`${this.prefix} ${t}`);
|
|
70
|
+
}
|
|
71
|
+
timeEnd(t) {
|
|
72
|
+
this.enabled && console.timeEnd(`${this.prefix} ${t}`);
|
|
73
|
+
}
|
|
74
|
+
table(t, o) {
|
|
75
|
+
this.enabled && (console.log(`%c${this.prefix} [TABLE]`, "color: #8B5CF6; font-weight: bold"), console.table(t, o));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const ue = j.getInstance(), he = ({
|
|
79
|
+
enabled: l = process.env.NODE_ENV === "development",
|
|
80
|
+
position: t = "bottom-right",
|
|
81
|
+
maxEntries: o = 100
|
|
82
|
+
}) => {
|
|
83
|
+
const [s, p] = F(!1), [g, f] = F([]), [x, y] = F(""), [S, C] = F("all");
|
|
84
|
+
if (L(() => {
|
|
85
|
+
if (!l)
|
|
86
|
+
return;
|
|
87
|
+
const m = (z) => {
|
|
88
|
+
f((u) => [z.detail, ...u].slice(0, o));
|
|
89
|
+
};
|
|
90
|
+
return window.addEventListener("archbase-debug", m), () => {
|
|
91
|
+
window.removeEventListener("archbase-debug", m);
|
|
92
|
+
};
|
|
93
|
+
}, [l, o]), !l)
|
|
94
|
+
return null;
|
|
95
|
+
const k = g.filter((m) => {
|
|
96
|
+
const z = x === "" || m.message.toLowerCase().includes(x.toLowerCase()) || m.component?.toLowerCase().includes(x.toLowerCase()), u = S === "all" || m.type === S;
|
|
97
|
+
return z && u;
|
|
98
|
+
}), a = /* @__PURE__ */ n(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
style: {
|
|
102
|
+
position: "fixed",
|
|
103
|
+
...{
|
|
104
|
+
"top-right": { top: 20, right: 20 },
|
|
105
|
+
"top-left": { top: 20, left: 20 },
|
|
106
|
+
"bottom-right": { bottom: 20, right: 20 },
|
|
107
|
+
"bottom-left": { bottom: 20, left: 20 }
|
|
108
|
+
}[t],
|
|
109
|
+
width: s ? "400px" : "50px",
|
|
110
|
+
height: s ? "500px" : "50px",
|
|
111
|
+
backgroundColor: "rgba(0, 0, 0, 0.9)",
|
|
112
|
+
border: "1px solid #333",
|
|
113
|
+
borderRadius: "8px",
|
|
114
|
+
color: "white",
|
|
115
|
+
fontFamily: "monospace",
|
|
116
|
+
fontSize: "12px",
|
|
117
|
+
zIndex: 999999,
|
|
118
|
+
transition: "all 0.3s ease",
|
|
119
|
+
overflow: "hidden"
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ n(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
style: {
|
|
126
|
+
padding: "10px",
|
|
127
|
+
borderBottom: s ? "1px solid #333" : "none",
|
|
128
|
+
cursor: "pointer",
|
|
129
|
+
display: "flex",
|
|
130
|
+
justifyContent: "space-between",
|
|
131
|
+
alignItems: "center"
|
|
132
|
+
},
|
|
133
|
+
onClick: () => p(!s),
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ r("span", { children: s ? "🐛 Debug Panel" : "🐛" }),
|
|
136
|
+
s && /* @__PURE__ */ n("span", { children: [
|
|
137
|
+
k.length,
|
|
138
|
+
" entries"
|
|
139
|
+
] })
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
s && /* @__PURE__ */ n(_, { children: [
|
|
144
|
+
/* @__PURE__ */ n("div", { style: { padding: "10px", borderBottom: "1px solid #333" }, children: [
|
|
145
|
+
/* @__PURE__ */ r(
|
|
146
|
+
"input",
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
placeholder: "Filter...",
|
|
150
|
+
value: x,
|
|
151
|
+
onChange: (m) => y(m.target.value),
|
|
152
|
+
style: {
|
|
153
|
+
width: "100%",
|
|
154
|
+
padding: "5px",
|
|
155
|
+
backgroundColor: "#222",
|
|
156
|
+
border: "1px solid #444",
|
|
157
|
+
borderRadius: "4px",
|
|
158
|
+
color: "white",
|
|
159
|
+
marginBottom: "5px"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ n(
|
|
164
|
+
"select",
|
|
165
|
+
{
|
|
166
|
+
value: S,
|
|
167
|
+
onChange: (m) => C(m.target.value),
|
|
168
|
+
style: {
|
|
169
|
+
width: "100%",
|
|
170
|
+
padding: "5px",
|
|
171
|
+
backgroundColor: "#222",
|
|
172
|
+
border: "1px solid #444",
|
|
173
|
+
borderRadius: "4px",
|
|
174
|
+
color: "white"
|
|
175
|
+
},
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ r("option", { value: "all", children: "All Types" }),
|
|
178
|
+
/* @__PURE__ */ r("option", { value: "render", children: "Render" }),
|
|
179
|
+
/* @__PURE__ */ r("option", { value: "state", children: "State" }),
|
|
180
|
+
/* @__PURE__ */ r("option", { value: "props", children: "Props" }),
|
|
181
|
+
/* @__PURE__ */ r("option", { value: "api", children: "API" }),
|
|
182
|
+
/* @__PURE__ */ r("option", { value: "performance", children: "Performance" })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ r(
|
|
188
|
+
"div",
|
|
189
|
+
{
|
|
190
|
+
style: {
|
|
191
|
+
height: "calc(100% - 120px)",
|
|
192
|
+
overflowY: "auto",
|
|
193
|
+
padding: "10px"
|
|
194
|
+
},
|
|
195
|
+
children: k.map((m) => /* @__PURE__ */ n(
|
|
196
|
+
"div",
|
|
197
|
+
{
|
|
198
|
+
style: {
|
|
199
|
+
marginBottom: "10px",
|
|
200
|
+
padding: "8px",
|
|
201
|
+
backgroundColor: "#111",
|
|
202
|
+
borderRadius: "4px",
|
|
203
|
+
border: "1px solid #222"
|
|
204
|
+
},
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "5px" }, children: [
|
|
207
|
+
/* @__PURE__ */ n("span", { style: { color: ne(m.type) }, children: [
|
|
208
|
+
"[",
|
|
209
|
+
m.type.toUpperCase(),
|
|
210
|
+
"]"
|
|
211
|
+
] }),
|
|
212
|
+
/* @__PURE__ */ r("span", { style: { color: "#666" }, children: new Date(m.timestamp).toLocaleTimeString() })
|
|
213
|
+
] }),
|
|
214
|
+
m.component && /* @__PURE__ */ r("div", { style: { color: "#888", fontSize: "11px", marginBottom: "3px" }, children: m.component }),
|
|
215
|
+
/* @__PURE__ */ r("div", { children: m.message }),
|
|
216
|
+
m.duration && /* @__PURE__ */ n("div", { style: { color: "#FFD700", fontSize: "11px", marginTop: "3px" }, children: [
|
|
217
|
+
"Duration: ",
|
|
218
|
+
m.duration,
|
|
219
|
+
"ms"
|
|
220
|
+
] }),
|
|
221
|
+
m.data && /* @__PURE__ */ n("details", { style: { marginTop: "5px" }, children: [
|
|
222
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", color: "#888" }, children: "Data" }),
|
|
223
|
+
/* @__PURE__ */ r("pre", { style: { fontSize: "10px", overflow: "auto" }, children: JSON.stringify(m.data, null, 2) })
|
|
224
|
+
] })
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
m.id
|
|
228
|
+
))
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
] })
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
return X.createPortal(a, document.body);
|
|
236
|
+
};
|
|
237
|
+
function ne(l) {
|
|
238
|
+
return {
|
|
239
|
+
render: "#4CAF50",
|
|
240
|
+
state: "#2196F3",
|
|
241
|
+
props: "#FF9800",
|
|
242
|
+
api: "#9C27B0",
|
|
243
|
+
performance: "#F44336"
|
|
244
|
+
}[l] || "#888";
|
|
245
|
+
}
|
|
246
|
+
function I(l) {
|
|
247
|
+
if (process.env.NODE_ENV !== "development")
|
|
248
|
+
return;
|
|
249
|
+
const t = {
|
|
250
|
+
...l,
|
|
251
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
252
|
+
timestamp: Date.now()
|
|
253
|
+
};
|
|
254
|
+
window.dispatchEvent(new CustomEvent("archbase-debug", { detail: t }));
|
|
255
|
+
}
|
|
256
|
+
class J {
|
|
257
|
+
static instance;
|
|
258
|
+
marks = /* @__PURE__ */ new Map();
|
|
259
|
+
measures = /* @__PURE__ */ new Map();
|
|
260
|
+
constructor() {
|
|
261
|
+
}
|
|
262
|
+
static getInstance() {
|
|
263
|
+
return J.instance || (J.instance = new J()), J.instance;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Start measuring performance
|
|
267
|
+
*/
|
|
268
|
+
start(t) {
|
|
269
|
+
this.marks.set(t, performance.now());
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* End measurement and return duration
|
|
273
|
+
*/
|
|
274
|
+
end(t) {
|
|
275
|
+
const o = this.marks.get(t);
|
|
276
|
+
if (!o)
|
|
277
|
+
return console.warn(`No start mark found for label: ${t}`), null;
|
|
278
|
+
const s = performance.now() - o;
|
|
279
|
+
return this.marks.delete(t), this.measures.has(t) || this.measures.set(t, []), this.measures.get(t).push(s), s;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get statistics for a label
|
|
283
|
+
*/
|
|
284
|
+
getStats(t) {
|
|
285
|
+
const o = this.measures.get(t);
|
|
286
|
+
if (!o || o.length === 0)
|
|
287
|
+
return null;
|
|
288
|
+
const s = [...o].sort((C, k) => C - k), p = o.length, g = o.reduce((C, k) => C + k, 0), f = g / p, x = s[0] || 0, y = s[p - 1] || 0, S = p % 2 === 0 ? ((s[p / 2 - 1] || 0) + (s[p / 2] || 0)) / 2 : s[Math.floor(p / 2)] || 0;
|
|
289
|
+
return { count: p, total: g, average: f, min: x, max: y, median: S };
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Clear all measurements
|
|
293
|
+
*/
|
|
294
|
+
clear(t) {
|
|
295
|
+
t ? (this.measures.delete(t), this.marks.delete(t)) : (this.measures.clear(), this.marks.clear());
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Get all statistics
|
|
299
|
+
*/
|
|
300
|
+
getAllStats() {
|
|
301
|
+
const t = /* @__PURE__ */ new Map();
|
|
302
|
+
for (const [o] of this.measures) {
|
|
303
|
+
const s = this.getStats(o);
|
|
304
|
+
s && t.set(o, s);
|
|
305
|
+
}
|
|
306
|
+
return t;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Print performance report to console
|
|
310
|
+
*/
|
|
311
|
+
report() {
|
|
312
|
+
console.group("🚀 Performance Report");
|
|
313
|
+
const t = this.getAllStats();
|
|
314
|
+
for (const [o, s] of t)
|
|
315
|
+
s && (console.log(`%c${o}`, "font-weight: bold"), console.table({
|
|
316
|
+
Calls: s.count,
|
|
317
|
+
"Total (ms)": s.total.toFixed(2),
|
|
318
|
+
"Average (ms)": s.average.toFixed(2),
|
|
319
|
+
"Min (ms)": s.min.toFixed(2),
|
|
320
|
+
"Max (ms)": s.max.toFixed(2),
|
|
321
|
+
"Median (ms)": s.median.toFixed(2)
|
|
322
|
+
}));
|
|
323
|
+
console.groupEnd();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const K = J.getInstance();
|
|
327
|
+
function ge(l, t) {
|
|
328
|
+
const o = M(0), s = M([]), p = M(0);
|
|
329
|
+
L(() => {
|
|
330
|
+
o.current++;
|
|
331
|
+
const f = performance.now() - p.current;
|
|
332
|
+
p.current > 0 && (s.current.push(f), s.current.length > 10 && s.current.shift(), K.start(`${l}_render`), K.end(`${l}_render`), I({
|
|
333
|
+
type: "render",
|
|
334
|
+
component: l,
|
|
335
|
+
message: `Rendered in ${f.toFixed(2)}ms (count: ${o.current})`,
|
|
336
|
+
duration: f,
|
|
337
|
+
data: { props: t, renderCount: o.current }
|
|
338
|
+
})), p.current = performance.now();
|
|
339
|
+
});
|
|
340
|
+
const g = s.current.length > 0 ? s.current.reduce((f, x) => f + x, 0) / s.current.length : 0;
|
|
341
|
+
return {
|
|
342
|
+
componentName: l,
|
|
343
|
+
renderCount: o.current,
|
|
344
|
+
lastRenderTime: s.current[s.current.length - 1] || 0,
|
|
345
|
+
averageRenderTime: g,
|
|
346
|
+
props: t
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function fe(l, t) {
|
|
350
|
+
const o = M(null);
|
|
351
|
+
L(() => {
|
|
352
|
+
if (o.current) {
|
|
353
|
+
const s = {};
|
|
354
|
+
Object.keys(t).forEach((p) => {
|
|
355
|
+
o.current[p] !== t[p] && (s[p] = {
|
|
356
|
+
from: o.current[p],
|
|
357
|
+
to: t[p]
|
|
358
|
+
});
|
|
359
|
+
}), Object.keys(o.current).forEach((p) => {
|
|
360
|
+
p in t || (s[p] = {
|
|
361
|
+
from: o.current[p],
|
|
362
|
+
to: void 0
|
|
363
|
+
});
|
|
364
|
+
}), Object.keys(s).length > 0 && I({
|
|
365
|
+
type: "props",
|
|
366
|
+
component: l,
|
|
367
|
+
message: `Props changed: ${Object.keys(s).join(", ")}`,
|
|
368
|
+
data: s
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
o.current = { ...t };
|
|
372
|
+
}, [t, l]);
|
|
373
|
+
}
|
|
374
|
+
const me = ({
|
|
375
|
+
prefix: l = "",
|
|
376
|
+
onItemClick: t,
|
|
377
|
+
showSize: o = !0
|
|
378
|
+
}) => {
|
|
379
|
+
const [s, p] = F([]), [g, f] = F(""), [x, y] = F(null), S = () => {
|
|
380
|
+
const u = [];
|
|
381
|
+
for (let D = 0; D < localStorage.length; D++) {
|
|
382
|
+
const E = localStorage.key(D);
|
|
383
|
+
if (E && (!l || E.startsWith(l))) {
|
|
384
|
+
const b = localStorage.getItem(E) || "";
|
|
385
|
+
let w = "string";
|
|
386
|
+
try {
|
|
387
|
+
const e = JSON.parse(b);
|
|
388
|
+
Array.isArray(e) ? w = "array" : typeof e == "object" && e !== null ? w = "object" : typeof e == "number" ? w = "number" : typeof e == "boolean" && (w = "boolean");
|
|
389
|
+
} catch {
|
|
390
|
+
}
|
|
391
|
+
u.push({
|
|
392
|
+
key: E,
|
|
393
|
+
value: b,
|
|
394
|
+
size: new Blob([b]).size,
|
|
395
|
+
type: w
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
u.sort((D, E) => D.key.localeCompare(E.key)), p(u);
|
|
400
|
+
};
|
|
401
|
+
L(() => {
|
|
402
|
+
S();
|
|
403
|
+
const u = () => S();
|
|
404
|
+
return window.addEventListener("storage", u), () => {
|
|
405
|
+
window.removeEventListener("storage", u);
|
|
406
|
+
};
|
|
407
|
+
}, [l]);
|
|
408
|
+
const C = (u) => {
|
|
409
|
+
window.confirm(`Delete localStorage item "${u}"?`) && (localStorage.removeItem(u), S());
|
|
410
|
+
}, k = () => {
|
|
411
|
+
if (window.confirm("Clear all localStorage items? This cannot be undone.")) {
|
|
412
|
+
if (l) {
|
|
413
|
+
const u = [];
|
|
414
|
+
for (let D = 0; D < localStorage.length; D++) {
|
|
415
|
+
const E = localStorage.key(D);
|
|
416
|
+
E && E.startsWith(l) && u.push(E);
|
|
417
|
+
}
|
|
418
|
+
u.forEach((D) => localStorage.removeItem(D));
|
|
419
|
+
} else
|
|
420
|
+
localStorage.clear();
|
|
421
|
+
S();
|
|
422
|
+
}
|
|
423
|
+
}, R = () => {
|
|
424
|
+
const u = {};
|
|
425
|
+
s.forEach((w) => {
|
|
426
|
+
try {
|
|
427
|
+
u[w.key] = JSON.parse(w.value);
|
|
428
|
+
} catch {
|
|
429
|
+
u[w.key] = w.value;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
const D = new Blob([JSON.stringify(u, null, 2)], { type: "application/json" }), E = URL.createObjectURL(D), b = document.createElement("a");
|
|
433
|
+
b.href = E, b.download = `localStorage_${(/* @__PURE__ */ new Date()).toISOString()}.json`, b.click(), URL.revokeObjectURL(E);
|
|
434
|
+
}, a = s.filter(
|
|
435
|
+
(u) => u.key.toLowerCase().includes(g.toLowerCase()) || u.value.toLowerCase().includes(g.toLowerCase())
|
|
436
|
+
), m = s.reduce((u, D) => u + D.size, 0), z = {
|
|
437
|
+
string: "#4CAF50",
|
|
438
|
+
object: "#2196F3",
|
|
439
|
+
array: "#FF9800",
|
|
440
|
+
number: "#9C27B0",
|
|
441
|
+
boolean: "#F44336"
|
|
442
|
+
};
|
|
443
|
+
return /* @__PURE__ */ n("div", { style: {
|
|
444
|
+
fontFamily: "monospace",
|
|
445
|
+
fontSize: "12px",
|
|
446
|
+
backgroundColor: "#1e1e1e",
|
|
447
|
+
color: "#d4d4d4",
|
|
448
|
+
padding: "10px",
|
|
449
|
+
borderRadius: "8px",
|
|
450
|
+
maxHeight: "600px",
|
|
451
|
+
overflow: "hidden",
|
|
452
|
+
display: "flex",
|
|
453
|
+
flexDirection: "column"
|
|
454
|
+
}, children: [
|
|
455
|
+
/* @__PURE__ */ n("div", { style: { marginBottom: "10px" }, children: [
|
|
456
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 10px 0" }, children: [
|
|
457
|
+
"📦 LocalStorage Viewer",
|
|
458
|
+
o && /* @__PURE__ */ n("span", { style: { fontSize: "10px", color: "#888", marginLeft: "10px" }, children: [
|
|
459
|
+
"Total: ",
|
|
460
|
+
(m / 1024).toFixed(2),
|
|
461
|
+
" KB"
|
|
462
|
+
] })
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [
|
|
465
|
+
/* @__PURE__ */ r(
|
|
466
|
+
"input",
|
|
467
|
+
{
|
|
468
|
+
type: "text",
|
|
469
|
+
placeholder: "Filter keys or values...",
|
|
470
|
+
value: g,
|
|
471
|
+
onChange: (u) => f(u.target.value),
|
|
472
|
+
style: {
|
|
473
|
+
flex: 1,
|
|
474
|
+
padding: "5px",
|
|
475
|
+
backgroundColor: "#2d2d2d",
|
|
476
|
+
border: "1px solid #3e3e3e",
|
|
477
|
+
borderRadius: "4px",
|
|
478
|
+
color: "#d4d4d4"
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
),
|
|
482
|
+
/* @__PURE__ */ r(
|
|
483
|
+
"button",
|
|
484
|
+
{
|
|
485
|
+
onClick: R,
|
|
486
|
+
style: {
|
|
487
|
+
padding: "5px 10px",
|
|
488
|
+
backgroundColor: "#0e639c",
|
|
489
|
+
border: "none",
|
|
490
|
+
borderRadius: "4px",
|
|
491
|
+
color: "white",
|
|
492
|
+
cursor: "pointer"
|
|
493
|
+
},
|
|
494
|
+
children: "Export"
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ n(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
onClick: k,
|
|
501
|
+
style: {
|
|
502
|
+
padding: "5px 10px",
|
|
503
|
+
backgroundColor: "#a1260d",
|
|
504
|
+
border: "none",
|
|
505
|
+
borderRadius: "4px",
|
|
506
|
+
color: "white",
|
|
507
|
+
cursor: "pointer"
|
|
508
|
+
},
|
|
509
|
+
children: [
|
|
510
|
+
"Clear ",
|
|
511
|
+
l ? "Prefix" : "All"
|
|
512
|
+
]
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
] })
|
|
516
|
+
] }),
|
|
517
|
+
/* @__PURE__ */ r("div", { style: { flex: 1, overflow: "auto" }, children: a.length === 0 ? /* @__PURE__ */ r("div", { style: { textAlign: "center", color: "#888", padding: "20px" }, children: "No items found" }) : /* @__PURE__ */ n("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
518
|
+
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */ n("tr", { style: { borderBottom: "1px solid #3e3e3e" }, children: [
|
|
519
|
+
/* @__PURE__ */ r("th", { style: { textAlign: "left", padding: "5px" }, children: "Key" }),
|
|
520
|
+
/* @__PURE__ */ r("th", { style: { textAlign: "left", padding: "5px", width: "60px" }, children: "Type" }),
|
|
521
|
+
o && /* @__PURE__ */ r("th", { style: { textAlign: "right", padding: "5px", width: "80px" }, children: "Size" }),
|
|
522
|
+
/* @__PURE__ */ r("th", { style: { width: "60px" } })
|
|
523
|
+
] }) }),
|
|
524
|
+
/* @__PURE__ */ r("tbody", { children: a.map((u) => /* @__PURE__ */ n(W.Fragment, { children: [
|
|
525
|
+
/* @__PURE__ */ n(
|
|
526
|
+
"tr",
|
|
527
|
+
{
|
|
528
|
+
style: {
|
|
529
|
+
borderBottom: "1px solid #2d2d2d",
|
|
530
|
+
cursor: "pointer",
|
|
531
|
+
backgroundColor: x === u.key ? "#2d2d2d" : "transparent"
|
|
532
|
+
},
|
|
533
|
+
onClick: () => {
|
|
534
|
+
if (y(x === u.key ? null : u.key), t)
|
|
535
|
+
try {
|
|
536
|
+
t(u.key, JSON.parse(u.value));
|
|
537
|
+
} catch {
|
|
538
|
+
t(u.key, u.value);
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
children: [
|
|
542
|
+
/* @__PURE__ */ r("td", { style: { padding: "5px", wordBreak: "break-all" }, children: u.key }),
|
|
543
|
+
/* @__PURE__ */ r("td", { style: { padding: "5px" }, children: /* @__PURE__ */ r("span", { style: { color: z[u.type], fontSize: "10px" }, children: u.type }) }),
|
|
544
|
+
o && /* @__PURE__ */ n("td", { style: { padding: "5px", textAlign: "right", color: "#888" }, children: [
|
|
545
|
+
(u.size / 1024).toFixed(2),
|
|
546
|
+
" KB"
|
|
547
|
+
] }),
|
|
548
|
+
/* @__PURE__ */ r("td", { style: { padding: "5px" }, children: /* @__PURE__ */ r(
|
|
549
|
+
"button",
|
|
550
|
+
{
|
|
551
|
+
onClick: (D) => {
|
|
552
|
+
D.stopPropagation(), C(u.key);
|
|
553
|
+
},
|
|
554
|
+
style: {
|
|
555
|
+
padding: "2px 6px",
|
|
556
|
+
backgroundColor: "#a1260d",
|
|
557
|
+
border: "none",
|
|
558
|
+
borderRadius: "3px",
|
|
559
|
+
color: "white",
|
|
560
|
+
cursor: "pointer",
|
|
561
|
+
fontSize: "10px"
|
|
562
|
+
},
|
|
563
|
+
children: "Delete"
|
|
564
|
+
}
|
|
565
|
+
) })
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
x === u.key && /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: o ? 4 : 3, style: { padding: "10px", backgroundColor: "#252526" }, children: /* @__PURE__ */ r("pre", { style: {
|
|
570
|
+
margin: 0,
|
|
571
|
+
whiteSpace: "pre-wrap",
|
|
572
|
+
wordBreak: "break-all",
|
|
573
|
+
maxHeight: "200px",
|
|
574
|
+
overflow: "auto"
|
|
575
|
+
}, children: (() => {
|
|
576
|
+
try {
|
|
577
|
+
return JSON.stringify(JSON.parse(u.value), null, 2);
|
|
578
|
+
} catch {
|
|
579
|
+
return u.value;
|
|
580
|
+
}
|
|
581
|
+
})() }) }) })
|
|
582
|
+
] }, u.key)) })
|
|
583
|
+
] }) })
|
|
584
|
+
] });
|
|
585
|
+
}, xe = ({
|
|
586
|
+
filterUrls: l = [],
|
|
587
|
+
excludeUrls: t = [],
|
|
588
|
+
maxRequests: o = 50
|
|
589
|
+
}) => {
|
|
590
|
+
const [s, p] = F([]), [g, f] = F(null), [x, y] = F(""), [S, C] = F("all");
|
|
591
|
+
L(() => {
|
|
592
|
+
const a = window.fetch, m = /* @__PURE__ */ new Map();
|
|
593
|
+
return window.fetch = async function(...z) {
|
|
594
|
+
const [u, D] = z, E = typeof u == "string" ? u : u.url, b = D?.method || "GET";
|
|
595
|
+
if (l.length > 0 && !l.some((i) => E.includes(i)))
|
|
596
|
+
return a.apply(this, z);
|
|
597
|
+
if (t.some((i) => E.includes(i)))
|
|
598
|
+
return a.apply(this, z);
|
|
599
|
+
const w = Math.random().toString(36).substr(2, 9), e = performance.now(), c = {
|
|
600
|
+
id: w,
|
|
601
|
+
method: b,
|
|
602
|
+
url: E,
|
|
603
|
+
timestamp: Date.now(),
|
|
604
|
+
requestHeaders: D?.headers,
|
|
605
|
+
requestBody: D?.body
|
|
606
|
+
};
|
|
607
|
+
m.set(w, c), p((i) => [c, ...i].slice(0, o));
|
|
608
|
+
try {
|
|
609
|
+
const i = await a.apply(this, z), h = performance.now() - e, d = i.clone();
|
|
610
|
+
let v, B = 0;
|
|
611
|
+
try {
|
|
612
|
+
const T = await d.text();
|
|
613
|
+
B = new Blob([T]).size;
|
|
614
|
+
try {
|
|
615
|
+
v = JSON.parse(T);
|
|
616
|
+
} catch {
|
|
617
|
+
v = T;
|
|
618
|
+
}
|
|
619
|
+
} catch {
|
|
620
|
+
v = "Unable to read response body";
|
|
621
|
+
}
|
|
622
|
+
const O = {
|
|
623
|
+
...c,
|
|
624
|
+
status: i.status,
|
|
625
|
+
statusText: i.statusText,
|
|
626
|
+
duration: h,
|
|
627
|
+
size: B,
|
|
628
|
+
responseHeaders: Object.fromEntries(i.headers.entries()),
|
|
629
|
+
responseBody: v
|
|
630
|
+
};
|
|
631
|
+
return p(
|
|
632
|
+
(T) => T.map((P) => P.id === w ? O : P)
|
|
633
|
+
), I({
|
|
634
|
+
type: "api",
|
|
635
|
+
message: `${b} ${E} - ${i.status} (${h.toFixed(0)}ms)`,
|
|
636
|
+
data: {
|
|
637
|
+
request: O,
|
|
638
|
+
response: v
|
|
639
|
+
},
|
|
640
|
+
duration: h
|
|
641
|
+
}), i;
|
|
642
|
+
} catch (i) {
|
|
643
|
+
const h = performance.now() - e, d = {
|
|
644
|
+
...c,
|
|
645
|
+
duration: h,
|
|
646
|
+
error: i instanceof Error ? i.message : "Unknown error"
|
|
647
|
+
};
|
|
648
|
+
throw p(
|
|
649
|
+
(v) => v.map((B) => B.id === w ? d : B)
|
|
650
|
+
), I({
|
|
651
|
+
type: "api",
|
|
652
|
+
message: `${b} ${E} - ERROR`,
|
|
653
|
+
data: {
|
|
654
|
+
request: d,
|
|
655
|
+
error: i instanceof Error ? i.message : "Unknown error"
|
|
656
|
+
}
|
|
657
|
+
}), i;
|
|
658
|
+
} finally {
|
|
659
|
+
m.delete(w);
|
|
660
|
+
}
|
|
661
|
+
}, () => {
|
|
662
|
+
window.fetch = a;
|
|
663
|
+
};
|
|
664
|
+
}, [l, t, o]);
|
|
665
|
+
const k = s.filter((a) => {
|
|
666
|
+
const m = x === "" || a.url.toLowerCase().includes(x.toLowerCase()) || a.method.toLowerCase().includes(x.toLowerCase()), z = S === "all" || S === "success" && a.status && a.status >= 200 && a.status < 400 || S === "error" && (a.error || a.status && a.status >= 400);
|
|
667
|
+
return m && z;
|
|
668
|
+
}), R = (a, m) => m ? "#F44336" : a ? a >= 200 && a < 300 ? "#4CAF50" : a >= 300 && a < 400 ? "#2196F3" : "#F44336" : "#FFA500";
|
|
669
|
+
return /* @__PURE__ */ n("div", { style: {
|
|
670
|
+
fontFamily: "monospace",
|
|
671
|
+
fontSize: "12px",
|
|
672
|
+
backgroundColor: "#1e1e1e",
|
|
673
|
+
color: "#d4d4d4",
|
|
674
|
+
borderRadius: "8px",
|
|
675
|
+
overflow: "hidden",
|
|
676
|
+
display: "flex",
|
|
677
|
+
flexDirection: "column",
|
|
678
|
+
height: "100%"
|
|
679
|
+
}, children: [
|
|
680
|
+
/* @__PURE__ */ n("div", { style: { padding: "10px", borderBottom: "1px solid #3e3e3e" }, children: [
|
|
681
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 10px 0" }, children: [
|
|
682
|
+
"🌐 Network Monitor",
|
|
683
|
+
/* @__PURE__ */ n("span", { style: { fontSize: "10px", color: "#888", marginLeft: "10px" }, children: [
|
|
684
|
+
k.length,
|
|
685
|
+
" requests"
|
|
686
|
+
] })
|
|
687
|
+
] }),
|
|
688
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "10px" }, children: [
|
|
689
|
+
/* @__PURE__ */ r(
|
|
690
|
+
"input",
|
|
691
|
+
{
|
|
692
|
+
type: "text",
|
|
693
|
+
placeholder: "Filter URLs...",
|
|
694
|
+
value: x,
|
|
695
|
+
onChange: (a) => y(a.target.value),
|
|
696
|
+
style: {
|
|
697
|
+
flex: 1,
|
|
698
|
+
padding: "5px",
|
|
699
|
+
backgroundColor: "#2d2d2d",
|
|
700
|
+
border: "1px solid #3e3e3e",
|
|
701
|
+
borderRadius: "4px",
|
|
702
|
+
color: "#d4d4d4"
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
),
|
|
706
|
+
/* @__PURE__ */ n(
|
|
707
|
+
"select",
|
|
708
|
+
{
|
|
709
|
+
value: S,
|
|
710
|
+
onChange: (a) => C(a.target.value),
|
|
711
|
+
style: {
|
|
712
|
+
padding: "5px",
|
|
713
|
+
backgroundColor: "#2d2d2d",
|
|
714
|
+
border: "1px solid #3e3e3e",
|
|
715
|
+
borderRadius: "4px",
|
|
716
|
+
color: "#d4d4d4"
|
|
717
|
+
},
|
|
718
|
+
children: [
|
|
719
|
+
/* @__PURE__ */ r("option", { value: "all", children: "All" }),
|
|
720
|
+
/* @__PURE__ */ r("option", { value: "success", children: "Success" }),
|
|
721
|
+
/* @__PURE__ */ r("option", { value: "error", children: "Error" })
|
|
722
|
+
]
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
] })
|
|
726
|
+
] }),
|
|
727
|
+
/* @__PURE__ */ r("div", { style: { flex: 1, overflow: "auto" }, children: k.map((a) => /* @__PURE__ */ n(
|
|
728
|
+
"div",
|
|
729
|
+
{
|
|
730
|
+
style: {
|
|
731
|
+
borderBottom: "1px solid #2d2d2d",
|
|
732
|
+
cursor: "pointer",
|
|
733
|
+
backgroundColor: g === a.id ? "#2d2d2d" : "transparent"
|
|
734
|
+
},
|
|
735
|
+
onClick: () => f(g === a.id ? null : a.id),
|
|
736
|
+
children: [
|
|
737
|
+
/* @__PURE__ */ n("div", { style: { padding: "8px", display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
738
|
+
/* @__PURE__ */ r("span", { style: {
|
|
739
|
+
color: R(a.status, a.error),
|
|
740
|
+
fontWeight: "bold",
|
|
741
|
+
minWidth: "50px"
|
|
742
|
+
}, children: a.method }),
|
|
743
|
+
/* @__PURE__ */ r("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: a.url }),
|
|
744
|
+
/* @__PURE__ */ r("span", { style: { color: R(a.status, a.error), minWidth: "40px" }, children: a.error ? "ERR" : a.status || "..." }),
|
|
745
|
+
a.duration && /* @__PURE__ */ n("span", { style: { color: "#888", minWidth: "60px", textAlign: "right" }, children: [
|
|
746
|
+
a.duration.toFixed(0),
|
|
747
|
+
"ms"
|
|
748
|
+
] }),
|
|
749
|
+
a.size && /* @__PURE__ */ n("span", { style: { color: "#888", minWidth: "60px", textAlign: "right" }, children: [
|
|
750
|
+
(a.size / 1024).toFixed(1),
|
|
751
|
+
"KB"
|
|
752
|
+
] })
|
|
753
|
+
] }),
|
|
754
|
+
g === a.id && /* @__PURE__ */ n("div", { style: { padding: "10px", backgroundColor: "#252526" }, children: [
|
|
755
|
+
/* @__PURE__ */ n("details", { children: [
|
|
756
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "5px" }, children: "Request Headers" }),
|
|
757
|
+
/* @__PURE__ */ r("pre", { style: { fontSize: "10px", margin: "5px 0" }, children: JSON.stringify(a.requestHeaders || {}, null, 2) })
|
|
758
|
+
] }),
|
|
759
|
+
a.requestBody && /* @__PURE__ */ n("details", { children: [
|
|
760
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "5px" }, children: "Request Body" }),
|
|
761
|
+
/* @__PURE__ */ r("pre", { style: { fontSize: "10px", margin: "5px 0", maxHeight: "200px", overflow: "auto" }, children: typeof a.requestBody == "string" ? a.requestBody : JSON.stringify(a.requestBody, null, 2) })
|
|
762
|
+
] }),
|
|
763
|
+
a.responseHeaders && /* @__PURE__ */ n("details", { children: [
|
|
764
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "5px" }, children: "Response Headers" }),
|
|
765
|
+
/* @__PURE__ */ r("pre", { style: { fontSize: "10px", margin: "5px 0" }, children: JSON.stringify(a.responseHeaders, null, 2) })
|
|
766
|
+
] }),
|
|
767
|
+
a.responseBody && /* @__PURE__ */ n("details", { open: !0, children: [
|
|
768
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "5px" }, children: "Response Body" }),
|
|
769
|
+
/* @__PURE__ */ r("pre", { style: { fontSize: "10px", margin: "5px 0", maxHeight: "300px", overflow: "auto" }, children: typeof a.responseBody == "string" ? a.responseBody : JSON.stringify(a.responseBody, null, 2) })
|
|
770
|
+
] }),
|
|
771
|
+
a.error && /* @__PURE__ */ n("div", { style: { color: "#F44336", marginTop: "10px" }, children: [
|
|
772
|
+
"Error: ",
|
|
773
|
+
a.error
|
|
774
|
+
] })
|
|
775
|
+
] })
|
|
776
|
+
]
|
|
777
|
+
},
|
|
778
|
+
a.id
|
|
779
|
+
)) })
|
|
780
|
+
] });
|
|
781
|
+
}, ye = ({
|
|
782
|
+
stores: l = [],
|
|
783
|
+
maxSnapshots: t = 50
|
|
784
|
+
}) => {
|
|
785
|
+
const [o, s] = F([]), [p, g] = F(null), [f, x] = F(""), [y, S] = F(!0), [C, k] = F(!1), [R, a] = F([null, null]);
|
|
786
|
+
L(() => {
|
|
787
|
+
if (!y)
|
|
788
|
+
return;
|
|
789
|
+
const e = [];
|
|
790
|
+
return l.forEach((c) => {
|
|
791
|
+
if (c.subscribe) {
|
|
792
|
+
const i = c.subscribe(() => {
|
|
793
|
+
const h = {
|
|
794
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
795
|
+
timestamp: Date.now(),
|
|
796
|
+
name: c.name,
|
|
797
|
+
state: c.getState(),
|
|
798
|
+
type: c.type
|
|
799
|
+
};
|
|
800
|
+
s((d) => [h, ...d].slice(0, t)), I({
|
|
801
|
+
type: "state",
|
|
802
|
+
message: `State updated: ${c.name}`,
|
|
803
|
+
data: h.state
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
e.push(i);
|
|
807
|
+
}
|
|
808
|
+
}), () => {
|
|
809
|
+
e.forEach((c) => c());
|
|
810
|
+
};
|
|
811
|
+
}, [l, y, t]);
|
|
812
|
+
const m = () => {
|
|
813
|
+
l.forEach((e) => {
|
|
814
|
+
const c = {
|
|
815
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
816
|
+
timestamp: Date.now(),
|
|
817
|
+
name: e.name,
|
|
818
|
+
state: e.getState(),
|
|
819
|
+
type: e.type
|
|
820
|
+
};
|
|
821
|
+
s((i) => [c, ...i].slice(0, t));
|
|
822
|
+
});
|
|
823
|
+
}, z = () => {
|
|
824
|
+
const e = o.map((d) => ({
|
|
825
|
+
...d,
|
|
826
|
+
timestampFormatted: new Date(d.timestamp).toISOString()
|
|
827
|
+
})), c = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), i = URL.createObjectURL(c), h = document.createElement("a");
|
|
828
|
+
h.href = i, h.download = `state_snapshots_${(/* @__PURE__ */ new Date()).toISOString()}.json`, h.click(), URL.revokeObjectURL(i);
|
|
829
|
+
}, u = (e) => {
|
|
830
|
+
const c = e.target.files?.[0];
|
|
831
|
+
if (!c)
|
|
832
|
+
return;
|
|
833
|
+
const i = new FileReader();
|
|
834
|
+
i.onload = (h) => {
|
|
835
|
+
try {
|
|
836
|
+
const d = JSON.parse(h.target?.result);
|
|
837
|
+
s(d);
|
|
838
|
+
} catch (d) {
|
|
839
|
+
console.error("Failed to import snapshots:", d);
|
|
840
|
+
}
|
|
841
|
+
}, i.readAsText(c);
|
|
842
|
+
}, D = () => {
|
|
843
|
+
window.confirm("Clear all snapshots?") && (s([]), g(null), a([null, null]));
|
|
844
|
+
}, E = o.filter(
|
|
845
|
+
(e) => f === "" || e.name.toLowerCase().includes(f.toLowerCase()) || JSON.stringify(e.state).toLowerCase().includes(f.toLowerCase())
|
|
846
|
+
), b = (e, c, i = "") => {
|
|
847
|
+
const h = {};
|
|
848
|
+
return Object.keys(c).forEach((d) => {
|
|
849
|
+
const v = i ? `${i}.${d}` : d;
|
|
850
|
+
if (!(d in e))
|
|
851
|
+
h[v] = { type: "added", value: c[d] };
|
|
852
|
+
else if (typeof c[d] == "object" && c[d] !== null && typeof e[d] == "object" && e[d] !== null) {
|
|
853
|
+
const B = b(e[d], c[d], v);
|
|
854
|
+
Object.assign(h, B);
|
|
855
|
+
} else
|
|
856
|
+
e[d] !== c[d] && (h[v] = { type: "modified", from: e[d], to: c[d] });
|
|
857
|
+
}), Object.keys(e).forEach((d) => {
|
|
858
|
+
const v = i ? `${i}.${d}` : d;
|
|
859
|
+
d in c || (h[v] = { type: "deleted", value: e[d] });
|
|
860
|
+
}), h;
|
|
861
|
+
}, w = {
|
|
862
|
+
redux: "#764ABC",
|
|
863
|
+
zustand: "#FF6B6B",
|
|
864
|
+
context: "#61DAFB",
|
|
865
|
+
custom: "#4CAF50"
|
|
866
|
+
};
|
|
867
|
+
return /* @__PURE__ */ n("div", { style: {
|
|
868
|
+
fontFamily: "monospace",
|
|
869
|
+
fontSize: "12px",
|
|
870
|
+
backgroundColor: "#1e1e1e",
|
|
871
|
+
color: "#d4d4d4",
|
|
872
|
+
borderRadius: "8px",
|
|
873
|
+
overflow: "hidden",
|
|
874
|
+
display: "flex",
|
|
875
|
+
flexDirection: "column",
|
|
876
|
+
height: "100%"
|
|
877
|
+
}, children: [
|
|
878
|
+
/* @__PURE__ */ n("div", { style: { padding: "10px", borderBottom: "1px solid #3e3e3e" }, children: [
|
|
879
|
+
/* @__PURE__ */ n("h3", { style: { margin: "0 0 10px 0" }, children: [
|
|
880
|
+
"🔍 State Inspector",
|
|
881
|
+
/* @__PURE__ */ n("span", { style: { fontSize: "10px", color: "#888", marginLeft: "10px" }, children: [
|
|
882
|
+
E.length,
|
|
883
|
+
" snapshots"
|
|
884
|
+
] })
|
|
885
|
+
] }),
|
|
886
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "10px", marginBottom: "10px" }, children: [
|
|
887
|
+
/* @__PURE__ */ r(
|
|
888
|
+
"input",
|
|
889
|
+
{
|
|
890
|
+
type: "text",
|
|
891
|
+
placeholder: "Filter snapshots...",
|
|
892
|
+
value: f,
|
|
893
|
+
onChange: (e) => x(e.target.value),
|
|
894
|
+
style: {
|
|
895
|
+
flex: 1,
|
|
896
|
+
padding: "5px",
|
|
897
|
+
backgroundColor: "#2d2d2d",
|
|
898
|
+
border: "1px solid #3e3e3e",
|
|
899
|
+
borderRadius: "4px",
|
|
900
|
+
color: "#d4d4d4"
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
),
|
|
904
|
+
/* @__PURE__ */ r(
|
|
905
|
+
"button",
|
|
906
|
+
{
|
|
907
|
+
onClick: () => S(!y),
|
|
908
|
+
style: {
|
|
909
|
+
padding: "5px 10px",
|
|
910
|
+
backgroundColor: y ? "#4CAF50" : "#666",
|
|
911
|
+
border: "none",
|
|
912
|
+
borderRadius: "4px",
|
|
913
|
+
color: "white",
|
|
914
|
+
cursor: "pointer"
|
|
915
|
+
},
|
|
916
|
+
children: y ? "Auto" : "Manual"
|
|
917
|
+
}
|
|
918
|
+
),
|
|
919
|
+
/* @__PURE__ */ r(
|
|
920
|
+
"button",
|
|
921
|
+
{
|
|
922
|
+
onClick: () => k(!C),
|
|
923
|
+
style: {
|
|
924
|
+
padding: "5px 10px",
|
|
925
|
+
backgroundColor: C ? "#2196F3" : "#666",
|
|
926
|
+
border: "none",
|
|
927
|
+
borderRadius: "4px",
|
|
928
|
+
color: "white",
|
|
929
|
+
cursor: "pointer"
|
|
930
|
+
},
|
|
931
|
+
children: "Compare"
|
|
932
|
+
}
|
|
933
|
+
)
|
|
934
|
+
] }),
|
|
935
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "10px" }, children: [
|
|
936
|
+
/* @__PURE__ */ r(
|
|
937
|
+
"button",
|
|
938
|
+
{
|
|
939
|
+
onClick: m,
|
|
940
|
+
style: {
|
|
941
|
+
flex: 1,
|
|
942
|
+
padding: "5px",
|
|
943
|
+
backgroundColor: "#0e639c",
|
|
944
|
+
border: "none",
|
|
945
|
+
borderRadius: "4px",
|
|
946
|
+
color: "white",
|
|
947
|
+
cursor: "pointer"
|
|
948
|
+
},
|
|
949
|
+
children: "Capture"
|
|
950
|
+
}
|
|
951
|
+
),
|
|
952
|
+
/* @__PURE__ */ r(
|
|
953
|
+
"button",
|
|
954
|
+
{
|
|
955
|
+
onClick: z,
|
|
956
|
+
style: {
|
|
957
|
+
flex: 1,
|
|
958
|
+
padding: "5px",
|
|
959
|
+
backgroundColor: "#16825d",
|
|
960
|
+
border: "none",
|
|
961
|
+
borderRadius: "4px",
|
|
962
|
+
color: "white",
|
|
963
|
+
cursor: "pointer"
|
|
964
|
+
},
|
|
965
|
+
children: "Export"
|
|
966
|
+
}
|
|
967
|
+
),
|
|
968
|
+
/* @__PURE__ */ n("label", { style: {
|
|
969
|
+
flex: 1,
|
|
970
|
+
padding: "5px",
|
|
971
|
+
backgroundColor: "#f48771",
|
|
972
|
+
border: "none",
|
|
973
|
+
borderRadius: "4px",
|
|
974
|
+
color: "white",
|
|
975
|
+
cursor: "pointer",
|
|
976
|
+
textAlign: "center"
|
|
977
|
+
}, children: [
|
|
978
|
+
"Import",
|
|
979
|
+
/* @__PURE__ */ r(
|
|
980
|
+
"input",
|
|
981
|
+
{
|
|
982
|
+
type: "file",
|
|
983
|
+
accept: ".json",
|
|
984
|
+
onChange: u,
|
|
985
|
+
style: { display: "none" }
|
|
986
|
+
}
|
|
987
|
+
)
|
|
988
|
+
] }),
|
|
989
|
+
/* @__PURE__ */ r(
|
|
990
|
+
"button",
|
|
991
|
+
{
|
|
992
|
+
onClick: D,
|
|
993
|
+
style: {
|
|
994
|
+
flex: 1,
|
|
995
|
+
padding: "5px",
|
|
996
|
+
backgroundColor: "#a1260d",
|
|
997
|
+
border: "none",
|
|
998
|
+
borderRadius: "4px",
|
|
999
|
+
color: "white",
|
|
1000
|
+
cursor: "pointer"
|
|
1001
|
+
},
|
|
1002
|
+
children: "Clear"
|
|
1003
|
+
}
|
|
1004
|
+
)
|
|
1005
|
+
] })
|
|
1006
|
+
] }),
|
|
1007
|
+
/* @__PURE__ */ n("div", { style: { flex: 1, display: "flex", overflow: "hidden" }, children: [
|
|
1008
|
+
/* @__PURE__ */ r("div", { style: { width: "300px", borderRight: "1px solid #3e3e3e", overflow: "auto" }, children: E.map((e, c) => /* @__PURE__ */ n(
|
|
1009
|
+
"div",
|
|
1010
|
+
{
|
|
1011
|
+
style: {
|
|
1012
|
+
padding: "8px",
|
|
1013
|
+
borderBottom: "1px solid #2d2d2d",
|
|
1014
|
+
cursor: "pointer",
|
|
1015
|
+
backgroundColor: C && R[0] === e.id || C && R[1] === e.id || p === e.id ? "#2d2d2d" : "transparent"
|
|
1016
|
+
},
|
|
1017
|
+
onClick: () => {
|
|
1018
|
+
C ? a((i) => i[0] ? !i[1] && i[0] !== e.id ? [i[0], e.id] : [e.id, null] : [e.id, null]) : g(e.id);
|
|
1019
|
+
},
|
|
1020
|
+
children: [
|
|
1021
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
1022
|
+
/* @__PURE__ */ r("span", { style: {
|
|
1023
|
+
color: w[e.type],
|
|
1024
|
+
fontWeight: "bold"
|
|
1025
|
+
}, children: e.name }),
|
|
1026
|
+
/* @__PURE__ */ n("span", { style: { fontSize: "10px", color: "#888" }, children: [
|
|
1027
|
+
"#",
|
|
1028
|
+
c + 1
|
|
1029
|
+
] })
|
|
1030
|
+
] }),
|
|
1031
|
+
/* @__PURE__ */ r("div", { style: { fontSize: "10px", color: "#666", marginTop: "2px" }, children: new Date(e.timestamp).toLocaleTimeString() }),
|
|
1032
|
+
C && (R[0] === e.id || R[1] === e.id) && /* @__PURE__ */ r("div", { style: { fontSize: "10px", color: "#2196F3", marginTop: "2px" }, children: R[0] === e.id ? "Compare A" : "Compare B" })
|
|
1033
|
+
]
|
|
1034
|
+
},
|
|
1035
|
+
e.id
|
|
1036
|
+
)) }),
|
|
1037
|
+
/* @__PURE__ */ r("div", { style: { flex: 1, overflow: "auto", padding: "10px" }, children: C && R[0] && R[1] ? /* @__PURE__ */ n("div", { children: [
|
|
1038
|
+
/* @__PURE__ */ r("h4", { style: { margin: "0 0 10px 0" }, children: "State Diff" }),
|
|
1039
|
+
(() => {
|
|
1040
|
+
const e = o.find((h) => h.id === R[0]), c = o.find((h) => h.id === R[1]);
|
|
1041
|
+
if (!e || !c)
|
|
1042
|
+
return null;
|
|
1043
|
+
const i = b(e.state, c.state);
|
|
1044
|
+
return /* @__PURE__ */ r("pre", { style: {
|
|
1045
|
+
fontSize: "11px",
|
|
1046
|
+
backgroundColor: "#252526",
|
|
1047
|
+
padding: "10px",
|
|
1048
|
+
borderRadius: "4px",
|
|
1049
|
+
overflow: "auto"
|
|
1050
|
+
}, children: Object.entries(i).map(([h, d]) => /* @__PURE__ */ n("div", { style: { marginBottom: "5px" }, children: [
|
|
1051
|
+
/* @__PURE__ */ n("span", { style: { color: "#888" }, children: [
|
|
1052
|
+
h,
|
|
1053
|
+
": "
|
|
1054
|
+
] }),
|
|
1055
|
+
d.type === "added" && /* @__PURE__ */ n("span", { style: { color: "#4CAF50" }, children: [
|
|
1056
|
+
"+ ",
|
|
1057
|
+
JSON.stringify(d.value)
|
|
1058
|
+
] }),
|
|
1059
|
+
d.type === "deleted" && /* @__PURE__ */ n("span", { style: { color: "#F44336" }, children: [
|
|
1060
|
+
"- ",
|
|
1061
|
+
JSON.stringify(d.value)
|
|
1062
|
+
] }),
|
|
1063
|
+
d.type === "modified" && /* @__PURE__ */ n("span", { children: [
|
|
1064
|
+
/* @__PURE__ */ n("span", { style: { color: "#F44336" }, children: [
|
|
1065
|
+
"- ",
|
|
1066
|
+
JSON.stringify(d.from)
|
|
1067
|
+
] }),
|
|
1068
|
+
" → ",
|
|
1069
|
+
/* @__PURE__ */ n("span", { style: { color: "#4CAF50" }, children: [
|
|
1070
|
+
"+ ",
|
|
1071
|
+
JSON.stringify(d.to)
|
|
1072
|
+
] })
|
|
1073
|
+
] })
|
|
1074
|
+
] }, h)) });
|
|
1075
|
+
})()
|
|
1076
|
+
] }) : p ? /* @__PURE__ */ n("div", { children: [
|
|
1077
|
+
/* @__PURE__ */ r("h4", { style: { margin: "0 0 10px 0" }, children: "State Details" }),
|
|
1078
|
+
/* @__PURE__ */ r("pre", { style: {
|
|
1079
|
+
fontSize: "11px",
|
|
1080
|
+
backgroundColor: "#252526",
|
|
1081
|
+
padding: "10px",
|
|
1082
|
+
borderRadius: "4px",
|
|
1083
|
+
overflow: "auto"
|
|
1084
|
+
}, children: JSON.stringify(
|
|
1085
|
+
o.find((e) => e.id === p)?.state,
|
|
1086
|
+
null,
|
|
1087
|
+
2
|
|
1088
|
+
) })
|
|
1089
|
+
] }) : /* @__PURE__ */ r("div", { style: { textAlign: "center", color: "#888", marginTop: "50px" }, children: C ? "Select two snapshots to compare" : "Select a snapshot to view details" }) })
|
|
1090
|
+
] })
|
|
1091
|
+
] });
|
|
1092
|
+
};
|
|
1093
|
+
class be extends Q {
|
|
1094
|
+
constructor(t) {
|
|
1095
|
+
super(t), this.state = {
|
|
1096
|
+
hasError: !1,
|
|
1097
|
+
error: null,
|
|
1098
|
+
errorInfo: null,
|
|
1099
|
+
errorHistory: []
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
static getDerivedStateFromError(t) {
|
|
1103
|
+
return { hasError: !0, error: t };
|
|
1104
|
+
}
|
|
1105
|
+
componentDidCatch(t, o) {
|
|
1106
|
+
this.setState((s) => ({
|
|
1107
|
+
errorInfo: o,
|
|
1108
|
+
errorHistory: [
|
|
1109
|
+
...s.errorHistory,
|
|
1110
|
+
{ error: t, errorInfo: o, timestamp: Date.now() }
|
|
1111
|
+
].slice(-10)
|
|
1112
|
+
// Keep last 10 errors
|
|
1113
|
+
})), this.props.logToConsole !== !1 && (console.group("🚨 React Error Boundary"), console.error("Error:", t), console.error("Component Stack:", o.componentStack), console.groupEnd()), I({
|
|
1114
|
+
type: "performance",
|
|
1115
|
+
message: `Error in component: ${t.message}`,
|
|
1116
|
+
data: {
|
|
1117
|
+
error: {
|
|
1118
|
+
name: t.name,
|
|
1119
|
+
message: t.message,
|
|
1120
|
+
stack: t.stack
|
|
1121
|
+
},
|
|
1122
|
+
componentStack: o.componentStack
|
|
1123
|
+
}
|
|
1124
|
+
}), this.props.onError && this.props.onError(t, o);
|
|
1125
|
+
}
|
|
1126
|
+
handleRetry = () => {
|
|
1127
|
+
this.setState({
|
|
1128
|
+
hasError: !1,
|
|
1129
|
+
error: null,
|
|
1130
|
+
errorInfo: null
|
|
1131
|
+
});
|
|
1132
|
+
};
|
|
1133
|
+
handleClearHistory = () => {
|
|
1134
|
+
this.setState({ errorHistory: [] });
|
|
1135
|
+
};
|
|
1136
|
+
render() {
|
|
1137
|
+
return this.state.hasError && this.state.error && this.state.errorInfo ? this.props.fallback ? this.props.fallback(this.state.error, this.state.errorInfo) : /* @__PURE__ */ r(
|
|
1138
|
+
se,
|
|
1139
|
+
{
|
|
1140
|
+
error: this.state.error,
|
|
1141
|
+
errorInfo: this.state.errorInfo,
|
|
1142
|
+
errorHistory: this.state.errorHistory,
|
|
1143
|
+
showStack: this.props.showStack,
|
|
1144
|
+
onRetry: this.handleRetry,
|
|
1145
|
+
onClearHistory: this.handleClearHistory
|
|
1146
|
+
}
|
|
1147
|
+
) : this.props.children;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const se = ({
|
|
1151
|
+
error: l,
|
|
1152
|
+
errorInfo: t,
|
|
1153
|
+
errorHistory: o,
|
|
1154
|
+
showStack: s = process.env.NODE_ENV === "development",
|
|
1155
|
+
onRetry: p,
|
|
1156
|
+
onClearHistory: g
|
|
1157
|
+
}) => {
|
|
1158
|
+
const [f, x] = W.useState(!1), [y, S] = W.useState(!1), C = () => {
|
|
1159
|
+
const k = `
|
|
1160
|
+
Error: ${l.message}
|
|
1161
|
+
Stack: ${l.stack}
|
|
1162
|
+
Component Stack: ${t.componentStack}
|
|
1163
|
+
`.trim();
|
|
1164
|
+
navigator.clipboard.writeText(k).then(() => {
|
|
1165
|
+
alert("Error information copied to clipboard");
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
return /* @__PURE__ */ n("div", { style: {
|
|
1169
|
+
padding: "20px",
|
|
1170
|
+
margin: "20px",
|
|
1171
|
+
border: "2px solid #F44336",
|
|
1172
|
+
borderRadius: "8px",
|
|
1173
|
+
backgroundColor: "#FFEBEE",
|
|
1174
|
+
fontFamily: "monospace",
|
|
1175
|
+
fontSize: "14px"
|
|
1176
|
+
}, children: [
|
|
1177
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", marginBottom: "15px" }, children: [
|
|
1178
|
+
/* @__PURE__ */ r("span", { style: { fontSize: "24px", marginRight: "10px" }, children: "💥" }),
|
|
1179
|
+
/* @__PURE__ */ r("h2", { style: { margin: 0, color: "#D32F2F" }, children: "Something went wrong" })
|
|
1180
|
+
] }),
|
|
1181
|
+
/* @__PURE__ */ n("div", { style: { marginBottom: "15px" }, children: [
|
|
1182
|
+
/* @__PURE__ */ r("strong", { children: "Error:" }),
|
|
1183
|
+
" ",
|
|
1184
|
+
l.message
|
|
1185
|
+
] }),
|
|
1186
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "10px", marginBottom: "15px" }, children: [
|
|
1187
|
+
/* @__PURE__ */ r(
|
|
1188
|
+
"button",
|
|
1189
|
+
{
|
|
1190
|
+
onClick: p,
|
|
1191
|
+
style: {
|
|
1192
|
+
padding: "8px 16px",
|
|
1193
|
+
backgroundColor: "#4CAF50",
|
|
1194
|
+
border: "none",
|
|
1195
|
+
borderRadius: "4px",
|
|
1196
|
+
color: "white",
|
|
1197
|
+
cursor: "pointer"
|
|
1198
|
+
},
|
|
1199
|
+
children: "Try Again"
|
|
1200
|
+
}
|
|
1201
|
+
),
|
|
1202
|
+
/* @__PURE__ */ n(
|
|
1203
|
+
"button",
|
|
1204
|
+
{
|
|
1205
|
+
onClick: () => x(!f),
|
|
1206
|
+
style: {
|
|
1207
|
+
padding: "8px 16px",
|
|
1208
|
+
backgroundColor: "#2196F3",
|
|
1209
|
+
border: "none",
|
|
1210
|
+
borderRadius: "4px",
|
|
1211
|
+
color: "white",
|
|
1212
|
+
cursor: "pointer"
|
|
1213
|
+
},
|
|
1214
|
+
children: [
|
|
1215
|
+
f ? "Hide" : "Show",
|
|
1216
|
+
" Details"
|
|
1217
|
+
]
|
|
1218
|
+
}
|
|
1219
|
+
),
|
|
1220
|
+
/* @__PURE__ */ r(
|
|
1221
|
+
"button",
|
|
1222
|
+
{
|
|
1223
|
+
onClick: C,
|
|
1224
|
+
style: {
|
|
1225
|
+
padding: "8px 16px",
|
|
1226
|
+
backgroundColor: "#FF9800",
|
|
1227
|
+
border: "none",
|
|
1228
|
+
borderRadius: "4px",
|
|
1229
|
+
color: "white",
|
|
1230
|
+
cursor: "pointer"
|
|
1231
|
+
},
|
|
1232
|
+
children: "Copy Error"
|
|
1233
|
+
}
|
|
1234
|
+
),
|
|
1235
|
+
o.length > 0 && /* @__PURE__ */ n(
|
|
1236
|
+
"button",
|
|
1237
|
+
{
|
|
1238
|
+
onClick: () => S(!y),
|
|
1239
|
+
style: {
|
|
1240
|
+
padding: "8px 16px",
|
|
1241
|
+
backgroundColor: "#9C27B0",
|
|
1242
|
+
border: "none",
|
|
1243
|
+
borderRadius: "4px",
|
|
1244
|
+
color: "white",
|
|
1245
|
+
cursor: "pointer"
|
|
1246
|
+
},
|
|
1247
|
+
children: [
|
|
1248
|
+
"History (",
|
|
1249
|
+
o.length,
|
|
1250
|
+
")"
|
|
1251
|
+
]
|
|
1252
|
+
}
|
|
1253
|
+
)
|
|
1254
|
+
] }),
|
|
1255
|
+
f && s && /* @__PURE__ */ n("details", { style: { marginBottom: "15px" }, children: [
|
|
1256
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "10px" }, children: "Stack Trace" }),
|
|
1257
|
+
/* @__PURE__ */ r("pre", { style: {
|
|
1258
|
+
backgroundColor: "#F5F5F5",
|
|
1259
|
+
padding: "10px",
|
|
1260
|
+
borderRadius: "4px",
|
|
1261
|
+
overflow: "auto",
|
|
1262
|
+
fontSize: "12px",
|
|
1263
|
+
border: "1px solid #E0E0E0"
|
|
1264
|
+
}, children: l.stack })
|
|
1265
|
+
] }),
|
|
1266
|
+
f && /* @__PURE__ */ n("details", { style: { marginBottom: "15px" }, children: [
|
|
1267
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", marginBottom: "10px" }, children: "Component Stack" }),
|
|
1268
|
+
/* @__PURE__ */ r("pre", { style: {
|
|
1269
|
+
backgroundColor: "#F5F5F5",
|
|
1270
|
+
padding: "10px",
|
|
1271
|
+
borderRadius: "4px",
|
|
1272
|
+
overflow: "auto",
|
|
1273
|
+
fontSize: "12px",
|
|
1274
|
+
border: "1px solid #E0E0E0"
|
|
1275
|
+
}, children: t.componentStack })
|
|
1276
|
+
] }),
|
|
1277
|
+
y && o.length > 0 && /* @__PURE__ */ n("details", { open: !0, children: [
|
|
1278
|
+
/* @__PURE__ */ n("summary", { style: { cursor: "pointer", marginBottom: "10px" }, children: [
|
|
1279
|
+
"Error History",
|
|
1280
|
+
/* @__PURE__ */ r(
|
|
1281
|
+
"button",
|
|
1282
|
+
{
|
|
1283
|
+
onClick: (k) => {
|
|
1284
|
+
k.stopPropagation(), g();
|
|
1285
|
+
},
|
|
1286
|
+
style: {
|
|
1287
|
+
marginLeft: "10px",
|
|
1288
|
+
padding: "2px 6px",
|
|
1289
|
+
backgroundColor: "#F44336",
|
|
1290
|
+
border: "none",
|
|
1291
|
+
borderRadius: "3px",
|
|
1292
|
+
color: "white",
|
|
1293
|
+
cursor: "pointer",
|
|
1294
|
+
fontSize: "11px"
|
|
1295
|
+
},
|
|
1296
|
+
children: "Clear"
|
|
1297
|
+
}
|
|
1298
|
+
)
|
|
1299
|
+
] }),
|
|
1300
|
+
/* @__PURE__ */ r("div", { style: {
|
|
1301
|
+
backgroundColor: "#F5F5F5",
|
|
1302
|
+
padding: "10px",
|
|
1303
|
+
borderRadius: "4px",
|
|
1304
|
+
border: "1px solid #E0E0E0",
|
|
1305
|
+
maxHeight: "300px",
|
|
1306
|
+
overflow: "auto"
|
|
1307
|
+
}, children: o.map((k, R) => /* @__PURE__ */ n("div", { style: {
|
|
1308
|
+
padding: "8px",
|
|
1309
|
+
marginBottom: "8px",
|
|
1310
|
+
backgroundColor: "white",
|
|
1311
|
+
borderRadius: "4px",
|
|
1312
|
+
border: "1px solid #E0E0E0"
|
|
1313
|
+
}, children: [
|
|
1314
|
+
/* @__PURE__ */ r("div", { style: { fontSize: "12px", color: "#666", marginBottom: "5px" }, children: new Date(k.timestamp).toLocaleString() }),
|
|
1315
|
+
/* @__PURE__ */ r("div", { style: { fontWeight: "bold", marginBottom: "5px" }, children: k.error.message }),
|
|
1316
|
+
/* @__PURE__ */ n("details", { children: [
|
|
1317
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", fontSize: "12px" }, children: "Stack Trace" }),
|
|
1318
|
+
/* @__PURE__ */ r("pre", { style: {
|
|
1319
|
+
fontSize: "10px",
|
|
1320
|
+
margin: "5px 0",
|
|
1321
|
+
overflow: "auto",
|
|
1322
|
+
maxHeight: "100px"
|
|
1323
|
+
}, children: k.error.stack })
|
|
1324
|
+
] })
|
|
1325
|
+
] }, R)) })
|
|
1326
|
+
] }),
|
|
1327
|
+
/* @__PURE__ */ r("div", { style: {
|
|
1328
|
+
fontSize: "12px",
|
|
1329
|
+
color: "#666",
|
|
1330
|
+
fontStyle: "italic",
|
|
1331
|
+
marginTop: "15px"
|
|
1332
|
+
}, children: "💡 Tip: Check the browser console for more detailed error information" })
|
|
1333
|
+
] });
|
|
1334
|
+
};
|
|
1335
|
+
class N {
|
|
1336
|
+
static instance;
|
|
1337
|
+
snapshots = [];
|
|
1338
|
+
intervalId = null;
|
|
1339
|
+
isMonitoring = !1;
|
|
1340
|
+
maxSnapshots = 100;
|
|
1341
|
+
growthThreshold = 1.5;
|
|
1342
|
+
// 50% growth threshold
|
|
1343
|
+
criticalThreshold = 0.9;
|
|
1344
|
+
// 90% of heap limit
|
|
1345
|
+
constructor() {
|
|
1346
|
+
}
|
|
1347
|
+
static getInstance() {
|
|
1348
|
+
return N.instance || (N.instance = new N()), N.instance;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Start monitoring memory usage
|
|
1352
|
+
*/
|
|
1353
|
+
startMonitoring(t = 5e3) {
|
|
1354
|
+
this.isMonitoring || (this.isMonitoring = !0, this.takeSnapshot(), this.intervalId = window.setInterval(() => {
|
|
1355
|
+
this.takeSnapshot(), this.analyzeMemoryPatterns();
|
|
1356
|
+
}, t), I({
|
|
1357
|
+
type: "performance",
|
|
1358
|
+
message: "Memory leak detection started",
|
|
1359
|
+
data: { interval: t }
|
|
1360
|
+
}));
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Stop monitoring
|
|
1364
|
+
*/
|
|
1365
|
+
stopMonitoring() {
|
|
1366
|
+
this.isMonitoring && (this.isMonitoring = !1, this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), I({
|
|
1367
|
+
type: "performance",
|
|
1368
|
+
message: "Memory leak detection stopped",
|
|
1369
|
+
data: { totalSnapshots: this.snapshots.length }
|
|
1370
|
+
}));
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Take a memory snapshot
|
|
1374
|
+
*/
|
|
1375
|
+
takeSnapshot() {
|
|
1376
|
+
if (!this.isMemoryAPIAvailable())
|
|
1377
|
+
return console.warn("Memory API not available in this browser"), null;
|
|
1378
|
+
const t = performance.memory, o = process?.memoryUsage?.() || {}, s = {
|
|
1379
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
1380
|
+
timestamp: Date.now(),
|
|
1381
|
+
heapUsed: o.heapUsed || 0,
|
|
1382
|
+
heapTotal: o.heapTotal || 0,
|
|
1383
|
+
external: o.external || 0,
|
|
1384
|
+
jsHeapSizeLimit: t?.jsHeapSizeLimit || 0,
|
|
1385
|
+
totalJSHeapSize: t?.totalJSHeapSize || 0,
|
|
1386
|
+
usedJSHeapSize: t?.usedJSHeapSize || 0
|
|
1387
|
+
};
|
|
1388
|
+
return this.snapshots.push(s), this.snapshots.length > this.maxSnapshots && this.snapshots.shift(), s;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Analyze memory patterns for potential leaks
|
|
1392
|
+
*/
|
|
1393
|
+
analyzeMemoryPatterns() {
|
|
1394
|
+
if (this.snapshots.length < 5)
|
|
1395
|
+
return [];
|
|
1396
|
+
const t = [], o = this.snapshots.slice(-10), s = this.checkMemoryGrowth(o);
|
|
1397
|
+
s && t.push(s);
|
|
1398
|
+
const p = this.checkHeapLimit(o);
|
|
1399
|
+
p && t.push(p);
|
|
1400
|
+
const g = this.checkExternalGrowth(o);
|
|
1401
|
+
return g && t.push(g), t.filter((f) => f.severity === "high").forEach((f) => {
|
|
1402
|
+
I({
|
|
1403
|
+
type: "performance",
|
|
1404
|
+
message: `Memory leak suspected: ${f.message}`,
|
|
1405
|
+
data: f
|
|
1406
|
+
});
|
|
1407
|
+
}), t;
|
|
1408
|
+
}
|
|
1409
|
+
checkMemoryGrowth(t) {
|
|
1410
|
+
const o = t.map((f) => f.usedJSHeapSize || f.heapUsed), s = o[0], p = o[o.length - 1];
|
|
1411
|
+
if (!s || !p || s === 0 || p === 0)
|
|
1412
|
+
return null;
|
|
1413
|
+
const g = p / s;
|
|
1414
|
+
return g > this.growthThreshold ? {
|
|
1415
|
+
type: "memory-growth",
|
|
1416
|
+
severity: g > 2 ? "high" : g > 1.75 ? "medium" : "low",
|
|
1417
|
+
message: `Memory usage increased by ${((g - 1) * 100).toFixed(1)}%`,
|
|
1418
|
+
trend: o,
|
|
1419
|
+
recommendation: "Check for memory leaks in event listeners, timers, or retained DOM references"
|
|
1420
|
+
} : null;
|
|
1421
|
+
}
|
|
1422
|
+
checkHeapLimit(t) {
|
|
1423
|
+
const o = t[t.length - 1];
|
|
1424
|
+
if (!o || o.jsHeapSizeLimit === 0 || o.usedJSHeapSize === 0)
|
|
1425
|
+
return null;
|
|
1426
|
+
const s = o.usedJSHeapSize / o.jsHeapSizeLimit;
|
|
1427
|
+
return s > this.criticalThreshold ? {
|
|
1428
|
+
type: "heap-limit",
|
|
1429
|
+
severity: "high",
|
|
1430
|
+
message: `Heap usage at ${(s * 100).toFixed(1)}% of limit`,
|
|
1431
|
+
trend: t.map((p) => p.usedJSHeapSize),
|
|
1432
|
+
recommendation: "Consider force garbage collection or reducing memory usage"
|
|
1433
|
+
} : null;
|
|
1434
|
+
}
|
|
1435
|
+
checkExternalGrowth(t) {
|
|
1436
|
+
const o = t.map((f) => f.external).filter((f) => f > 0);
|
|
1437
|
+
if (o.length < 2)
|
|
1438
|
+
return null;
|
|
1439
|
+
const s = o[0], p = o[o.length - 1];
|
|
1440
|
+
if (!s || !p)
|
|
1441
|
+
return null;
|
|
1442
|
+
const g = p / s;
|
|
1443
|
+
return g > this.growthThreshold ? {
|
|
1444
|
+
type: "external-growth",
|
|
1445
|
+
severity: g > 2 ? "high" : "medium",
|
|
1446
|
+
message: `External memory usage increased by ${((g - 1) * 100).toFixed(1)}%`,
|
|
1447
|
+
trend: o,
|
|
1448
|
+
recommendation: "Check for growing buffers, file handles, or external resources"
|
|
1449
|
+
} : null;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Force garbage collection (Chrome DevTools only)
|
|
1453
|
+
*/
|
|
1454
|
+
forceGarbageCollection() {
|
|
1455
|
+
return typeof window.gc == "function" ? (window.gc(), this.takeSnapshot(), I({
|
|
1456
|
+
type: "performance",
|
|
1457
|
+
message: "Garbage collection forced",
|
|
1458
|
+
data: { timestamp: Date.now() }
|
|
1459
|
+
}), !0) : !1;
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Get memory usage statistics
|
|
1463
|
+
*/
|
|
1464
|
+
getMemoryStats() {
|
|
1465
|
+
if (this.snapshots.length === 0)
|
|
1466
|
+
return {
|
|
1467
|
+
current: null,
|
|
1468
|
+
peak: null,
|
|
1469
|
+
average: 0,
|
|
1470
|
+
growth: 0,
|
|
1471
|
+
suspicions: []
|
|
1472
|
+
};
|
|
1473
|
+
const t = this.snapshots[this.snapshots.length - 1] || null, o = this.snapshots.reduce(
|
|
1474
|
+
(y, S) => (S.usedJSHeapSize || S.heapUsed) > (y?.usedJSHeapSize || y?.heapUsed || 0) ? S : y
|
|
1475
|
+
) || null, s = this.snapshots.map((y) => y.usedJSHeapSize || y.heapUsed), p = s.reduce((y, S) => y + S, 0) / s.length, g = s[0] || 0, f = s[s.length - 1] || 0, x = g > 0 ? (f - g) / g * 100 : 0;
|
|
1476
|
+
return {
|
|
1477
|
+
current: t,
|
|
1478
|
+
peak: o,
|
|
1479
|
+
average: p,
|
|
1480
|
+
growth: x,
|
|
1481
|
+
suspicions: this.analyzeMemoryPatterns()
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Get all snapshots
|
|
1486
|
+
*/
|
|
1487
|
+
getSnapshots() {
|
|
1488
|
+
return [...this.snapshots];
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Clear all snapshots
|
|
1492
|
+
*/
|
|
1493
|
+
clearSnapshots() {
|
|
1494
|
+
this.snapshots = [];
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Export memory data
|
|
1498
|
+
*/
|
|
1499
|
+
exportData() {
|
|
1500
|
+
const t = this.getMemoryStats();
|
|
1501
|
+
return JSON.stringify({
|
|
1502
|
+
snapshots: this.snapshots,
|
|
1503
|
+
stats: t,
|
|
1504
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1505
|
+
}, null, 2);
|
|
1506
|
+
}
|
|
1507
|
+
isMemoryAPIAvailable() {
|
|
1508
|
+
return typeof performance < "u" && (performance.memory || typeof process < "u" && process.memoryUsage);
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Check if monitoring is active
|
|
1512
|
+
*/
|
|
1513
|
+
isActive() {
|
|
1514
|
+
return this.isMonitoring;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
const we = N.getInstance(), ve = ({
|
|
1518
|
+
dataSources: l = [],
|
|
1519
|
+
autoDiscover: t = !0,
|
|
1520
|
+
hotkey: o = "ctrl+shift+D",
|
|
1521
|
+
visible: s = !1,
|
|
1522
|
+
position: p = "top-right",
|
|
1523
|
+
maxOperations: g = 50
|
|
1524
|
+
}) => {
|
|
1525
|
+
const [f, x] = F(s), [y, S] = F([]), [C, k] = F(""), [R, a] = F(0), [m, z] = F([]), u = M([]);
|
|
1526
|
+
Z([[o, () => x(!f)]]), L(() => {
|
|
1527
|
+
if (!t || process.env.NODE_ENV !== "development")
|
|
1528
|
+
return;
|
|
1529
|
+
const e = [];
|
|
1530
|
+
typeof window < "u" && ((i, h = "window") => {
|
|
1531
|
+
!i || typeof i != "object" || Object.keys(i).forEach((d) => {
|
|
1532
|
+
try {
|
|
1533
|
+
const v = i[d];
|
|
1534
|
+
v && typeof v == "object" && (v.constructor?.name?.includes("DataSource") || v._isArchbaseDataSource || v.name && typeof v.getCurrentRecord == "function") && e.push({
|
|
1535
|
+
name: `${h}.${d}`,
|
|
1536
|
+
dataSource: v
|
|
1537
|
+
});
|
|
1538
|
+
} catch {
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
})(window), z([...l, ...e]);
|
|
1542
|
+
}, [l, t, R]), L(() => {
|
|
1543
|
+
const e = (i) => {
|
|
1544
|
+
const h = {
|
|
1545
|
+
...i,
|
|
1546
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
1547
|
+
timestamp: Date.now()
|
|
1548
|
+
};
|
|
1549
|
+
u.current = [h, ...u.current].slice(0, g), S([...u.current]), I({
|
|
1550
|
+
type: "state",
|
|
1551
|
+
message: `DataSource ${i.operation}`,
|
|
1552
|
+
data: i.details
|
|
1553
|
+
});
|
|
1554
|
+
}, c = [];
|
|
1555
|
+
return m.forEach(({ name: i, dataSource: h }) => {
|
|
1556
|
+
if (h)
|
|
1557
|
+
try {
|
|
1558
|
+
if (typeof h.addListener == "function") {
|
|
1559
|
+
const v = () => {
|
|
1560
|
+
e({
|
|
1561
|
+
operation: "State Changed",
|
|
1562
|
+
details: {
|
|
1563
|
+
name: i,
|
|
1564
|
+
currentRecord: h.getCurrentRecord?.(),
|
|
1565
|
+
recordCount: h.getRecordCount?.(),
|
|
1566
|
+
state: h.getState?.()
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
h.addListener(v), c.push(() => h.removeListener?.(v));
|
|
1571
|
+
}
|
|
1572
|
+
["post", "edit", "delete", "cancel", "append", "insert"].forEach((v) => {
|
|
1573
|
+
if (typeof h[v] == "function") {
|
|
1574
|
+
const B = h[v];
|
|
1575
|
+
h[v] = function(...O) {
|
|
1576
|
+
const T = performance.now(), P = B.apply(this, O), Y = performance.now() - T;
|
|
1577
|
+
return e({
|
|
1578
|
+
operation: v,
|
|
1579
|
+
details: { name: i, arguments: O },
|
|
1580
|
+
duration: Y
|
|
1581
|
+
}), P;
|
|
1582
|
+
}, c.push(() => {
|
|
1583
|
+
h[v] = B;
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
} catch (d) {
|
|
1588
|
+
console.warn("Failed to monitor DataSource:", i, d);
|
|
1589
|
+
}
|
|
1590
|
+
}), () => {
|
|
1591
|
+
c.forEach((i) => i());
|
|
1592
|
+
};
|
|
1593
|
+
}, [m, g]);
|
|
1594
|
+
const D = (e) => {
|
|
1595
|
+
try {
|
|
1596
|
+
const c = e._isArchbaseDataSourceV2 ? "v2" : e._isArchbaseDataSource ? "v1" : "unknown";
|
|
1597
|
+
return {
|
|
1598
|
+
recordCount: e.getRecordCount?.() || 0,
|
|
1599
|
+
currentRecordIndex: e.getRecordCount?.() || -1,
|
|
1600
|
+
totalRecords: e.getRecordCount?.() || 0,
|
|
1601
|
+
state: e.getState?.() || "unknown",
|
|
1602
|
+
isActive: e.isActive?.() || !1,
|
|
1603
|
+
isBrowsing: e.isBrowsing?.() || !1,
|
|
1604
|
+
isInserting: e.isInserting?.() || !1,
|
|
1605
|
+
isEditing: e.isEditing?.() || !1,
|
|
1606
|
+
isDeleting: e.isDeleting?.() || !1,
|
|
1607
|
+
hasChanges: e.hasChanges?.() || !1,
|
|
1608
|
+
version: c
|
|
1609
|
+
};
|
|
1610
|
+
} catch {
|
|
1611
|
+
return {
|
|
1612
|
+
recordCount: 0,
|
|
1613
|
+
currentRecordIndex: -1,
|
|
1614
|
+
totalRecords: 0,
|
|
1615
|
+
state: "error",
|
|
1616
|
+
isActive: !1,
|
|
1617
|
+
isBrowsing: !1,
|
|
1618
|
+
isInserting: !1,
|
|
1619
|
+
isEditing: !1,
|
|
1620
|
+
isDeleting: !1,
|
|
1621
|
+
hasChanges: !1,
|
|
1622
|
+
version: "unknown"
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
}, E = (e) => ({
|
|
1626
|
+
browsing: "blue",
|
|
1627
|
+
editing: "orange",
|
|
1628
|
+
inserting: "green",
|
|
1629
|
+
deleting: "red",
|
|
1630
|
+
inactive: "gray",
|
|
1631
|
+
error: "red"
|
|
1632
|
+
})[e.toLowerCase()] || "gray", b = (e) => ({
|
|
1633
|
+
v1: "blue",
|
|
1634
|
+
v2: "green",
|
|
1635
|
+
unknown: "gray"
|
|
1636
|
+
})[e] || "gray", w = {
|
|
1637
|
+
"top-left": { top: 20, left: 20 },
|
|
1638
|
+
"top-right": { top: 20, right: 20 },
|
|
1639
|
+
"bottom-left": { bottom: 20, left: 20 },
|
|
1640
|
+
"bottom-right": { bottom: 20, right: 20 }
|
|
1641
|
+
};
|
|
1642
|
+
return f ? /* @__PURE__ */ n(
|
|
1643
|
+
"div",
|
|
1644
|
+
{
|
|
1645
|
+
style: {
|
|
1646
|
+
position: "fixed",
|
|
1647
|
+
...w[p],
|
|
1648
|
+
width: "600px",
|
|
1649
|
+
height: "700px",
|
|
1650
|
+
backgroundColor: "#1e1e1e",
|
|
1651
|
+
color: "#d4d4d4",
|
|
1652
|
+
border: "1px solid #3e3e3e",
|
|
1653
|
+
borderRadius: "8px",
|
|
1654
|
+
zIndex: 999999,
|
|
1655
|
+
display: "flex",
|
|
1656
|
+
flexDirection: "column",
|
|
1657
|
+
fontFamily: "monospace",
|
|
1658
|
+
fontSize: "12px"
|
|
1659
|
+
},
|
|
1660
|
+
children: [
|
|
1661
|
+
/* @__PURE__ */ n("div", { style: {
|
|
1662
|
+
padding: "12px",
|
|
1663
|
+
borderBottom: "1px solid #3e3e3e",
|
|
1664
|
+
display: "flex",
|
|
1665
|
+
justifyContent: "space-between",
|
|
1666
|
+
alignItems: "center"
|
|
1667
|
+
}, children: [
|
|
1668
|
+
/* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1669
|
+
/* @__PURE__ */ r(V, { size: 16 }),
|
|
1670
|
+
/* @__PURE__ */ r(U, { size: "sm", fw: 500, children: "DataSource Inspector" }),
|
|
1671
|
+
/* @__PURE__ */ n($, { size: "xs", color: "blue", children: [
|
|
1672
|
+
m.length,
|
|
1673
|
+
" sources"
|
|
1674
|
+
] })
|
|
1675
|
+
] }),
|
|
1676
|
+
/* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1677
|
+
/* @__PURE__ */ r(
|
|
1678
|
+
G,
|
|
1679
|
+
{
|
|
1680
|
+
size: "xs",
|
|
1681
|
+
variant: "subtle",
|
|
1682
|
+
onClick: () => a((e) => e + 1),
|
|
1683
|
+
children: /* @__PURE__ */ r(te, { size: 12 })
|
|
1684
|
+
}
|
|
1685
|
+
),
|
|
1686
|
+
/* @__PURE__ */ r(
|
|
1687
|
+
G,
|
|
1688
|
+
{
|
|
1689
|
+
size: "xs",
|
|
1690
|
+
variant: "subtle",
|
|
1691
|
+
onClick: () => x(!1),
|
|
1692
|
+
children: "×"
|
|
1693
|
+
}
|
|
1694
|
+
)
|
|
1695
|
+
] })
|
|
1696
|
+
] }),
|
|
1697
|
+
/* @__PURE__ */ r("div", { style: { padding: "12px", borderBottom: "1px solid #3e3e3e" }, children: /* @__PURE__ */ r(
|
|
1698
|
+
q,
|
|
1699
|
+
{
|
|
1700
|
+
size: "xs",
|
|
1701
|
+
placeholder: "Select DataSource to inspect",
|
|
1702
|
+
value: C,
|
|
1703
|
+
onChange: (e) => k(e || ""),
|
|
1704
|
+
data: m.map((e) => ({
|
|
1705
|
+
value: e.name,
|
|
1706
|
+
label: e.name
|
|
1707
|
+
}))
|
|
1708
|
+
}
|
|
1709
|
+
) }),
|
|
1710
|
+
/* @__PURE__ */ r("div", { style: { flex: 1, overflow: "auto" }, children: /* @__PURE__ */ n(A, { multiple: !0, defaultValue: ["stats", "operations"], children: [
|
|
1711
|
+
/* @__PURE__ */ n(A.Item, { value: "stats", children: [
|
|
1712
|
+
/* @__PURE__ */ r(A.Control, { children: /* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1713
|
+
/* @__PURE__ */ r(re, { size: 14 }),
|
|
1714
|
+
"Current State"
|
|
1715
|
+
] }) }),
|
|
1716
|
+
/* @__PURE__ */ r(A.Panel, { children: C ? (() => {
|
|
1717
|
+
const e = m.find((i) => i.name === C)?.dataSource;
|
|
1718
|
+
if (!e)
|
|
1719
|
+
return /* @__PURE__ */ r(U, { size: "xs", c: "dimmed", children: "DataSource not found" });
|
|
1720
|
+
const c = D(e);
|
|
1721
|
+
return /* @__PURE__ */ n("div", { style: { fontSize: "11px" }, children: [
|
|
1722
|
+
/* @__PURE__ */ n(H, { gap: "xs", mb: "xs", children: [
|
|
1723
|
+
/* @__PURE__ */ r($, { size: "xs", color: b(c.version), children: c.version.toUpperCase() }),
|
|
1724
|
+
/* @__PURE__ */ r($, { size: "xs", color: E(c.state), children: c.state }),
|
|
1725
|
+
c.hasChanges && /* @__PURE__ */ r($, { size: "xs", color: "yellow", children: "Modified" })
|
|
1726
|
+
] }),
|
|
1727
|
+
/* @__PURE__ */ n("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "8px" }, children: [
|
|
1728
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1729
|
+
"Records: ",
|
|
1730
|
+
c.recordCount
|
|
1731
|
+
] }),
|
|
1732
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1733
|
+
"Current: ",
|
|
1734
|
+
c.currentRecordIndex
|
|
1735
|
+
] }),
|
|
1736
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1737
|
+
"Active: ",
|
|
1738
|
+
c.isActive ? "Yes" : "No"
|
|
1739
|
+
] }),
|
|
1740
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1741
|
+
"Browsing: ",
|
|
1742
|
+
c.isBrowsing ? "Yes" : "No"
|
|
1743
|
+
] }),
|
|
1744
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1745
|
+
"Editing: ",
|
|
1746
|
+
c.isEditing ? "Yes" : "No"
|
|
1747
|
+
] }),
|
|
1748
|
+
/* @__PURE__ */ n("div", { children: [
|
|
1749
|
+
"Inserting: ",
|
|
1750
|
+
c.isInserting ? "Yes" : "No"
|
|
1751
|
+
] })
|
|
1752
|
+
] }),
|
|
1753
|
+
/* @__PURE__ */ n("details", { style: { marginTop: "8px" }, children: [
|
|
1754
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer" }, children: "Current Record" }),
|
|
1755
|
+
/* @__PURE__ */ r(
|
|
1756
|
+
ee,
|
|
1757
|
+
{
|
|
1758
|
+
size: "xs",
|
|
1759
|
+
value: JSON.stringify(e.getCurrentRecord?.() || {}, null, 2),
|
|
1760
|
+
readOnly: !0,
|
|
1761
|
+
autosize: !0,
|
|
1762
|
+
minRows: 3,
|
|
1763
|
+
maxRows: 10,
|
|
1764
|
+
styles: {
|
|
1765
|
+
input: { fontSize: "10px", fontFamily: "monospace" }
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
)
|
|
1769
|
+
] })
|
|
1770
|
+
] });
|
|
1771
|
+
})() : /* @__PURE__ */ r(U, { size: "xs", c: "dimmed", children: "Select a DataSource to view stats" }) })
|
|
1772
|
+
] }),
|
|
1773
|
+
/* @__PURE__ */ n(A.Item, { value: "operations", children: [
|
|
1774
|
+
/* @__PURE__ */ r(A.Control, { children: /* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1775
|
+
/* @__PURE__ */ r(oe, { size: 14 }),
|
|
1776
|
+
"Recent Operations (",
|
|
1777
|
+
y.length,
|
|
1778
|
+
")"
|
|
1779
|
+
] }) }),
|
|
1780
|
+
/* @__PURE__ */ r(A.Panel, { children: /* @__PURE__ */ r("div", { style: { maxHeight: "300px", overflow: "auto" }, children: y.length === 0 ? /* @__PURE__ */ r(U, { size: "xs", c: "dimmed", children: "No operations recorded yet" }) : y.map((e) => /* @__PURE__ */ n(
|
|
1781
|
+
"div",
|
|
1782
|
+
{
|
|
1783
|
+
style: {
|
|
1784
|
+
padding: "6px 8px",
|
|
1785
|
+
marginBottom: "4px",
|
|
1786
|
+
backgroundColor: "#2d2d2d",
|
|
1787
|
+
borderRadius: "4px",
|
|
1788
|
+
fontSize: "10px"
|
|
1789
|
+
},
|
|
1790
|
+
children: [
|
|
1791
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "2px" }, children: [
|
|
1792
|
+
/* @__PURE__ */ r("span", { style: { fontWeight: "bold" }, children: e.operation }),
|
|
1793
|
+
/* @__PURE__ */ r("span", { style: { color: "#888" }, children: new Date(e.timestamp).toLocaleTimeString() })
|
|
1794
|
+
] }),
|
|
1795
|
+
e.duration && /* @__PURE__ */ n("div", { style: { color: "#FFD700", fontSize: "9px" }, children: [
|
|
1796
|
+
"Duration: ",
|
|
1797
|
+
e.duration.toFixed(2),
|
|
1798
|
+
"ms"
|
|
1799
|
+
] }),
|
|
1800
|
+
/* @__PURE__ */ n("details", { children: [
|
|
1801
|
+
/* @__PURE__ */ r("summary", { style: { cursor: "pointer", fontSize: "9px", color: "#888" }, children: "Details" }),
|
|
1802
|
+
/* @__PURE__ */ r("pre", { style: {
|
|
1803
|
+
fontSize: "9px",
|
|
1804
|
+
margin: "2px 0",
|
|
1805
|
+
overflow: "auto",
|
|
1806
|
+
maxHeight: "80px"
|
|
1807
|
+
}, children: JSON.stringify(e.details, null, 2) })
|
|
1808
|
+
] })
|
|
1809
|
+
]
|
|
1810
|
+
},
|
|
1811
|
+
e.id
|
|
1812
|
+
)) }) })
|
|
1813
|
+
] }),
|
|
1814
|
+
/* @__PURE__ */ n(A.Item, { value: "overview", children: [
|
|
1815
|
+
/* @__PURE__ */ r(A.Control, { children: /* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1816
|
+
/* @__PURE__ */ r(V, { size: 14 }),
|
|
1817
|
+
"All DataSources (",
|
|
1818
|
+
m.length,
|
|
1819
|
+
")"
|
|
1820
|
+
] }) }),
|
|
1821
|
+
/* @__PURE__ */ r(A.Panel, { children: /* @__PURE__ */ r("div", { style: { fontSize: "10px" }, children: m.map(({ name: e, dataSource: c }) => {
|
|
1822
|
+
const i = D(c);
|
|
1823
|
+
return /* @__PURE__ */ n(
|
|
1824
|
+
"div",
|
|
1825
|
+
{
|
|
1826
|
+
style: {
|
|
1827
|
+
padding: "4px 6px",
|
|
1828
|
+
marginBottom: "3px",
|
|
1829
|
+
backgroundColor: C === e ? "#2d2d2d" : "transparent",
|
|
1830
|
+
borderRadius: "3px",
|
|
1831
|
+
cursor: "pointer"
|
|
1832
|
+
},
|
|
1833
|
+
onClick: () => k(e),
|
|
1834
|
+
children: [
|
|
1835
|
+
/* @__PURE__ */ r("div", { style: { fontWeight: "bold", marginBottom: "2px" }, children: e }),
|
|
1836
|
+
/* @__PURE__ */ n(H, { gap: "xs", children: [
|
|
1837
|
+
/* @__PURE__ */ r($, { size: "xs", color: b(i.version), children: i.version }),
|
|
1838
|
+
/* @__PURE__ */ r($, { size: "xs", color: E(i.state), children: i.state }),
|
|
1839
|
+
/* @__PURE__ */ n("span", { style: { color: "#888" }, children: [
|
|
1840
|
+
i.recordCount,
|
|
1841
|
+
" records"
|
|
1842
|
+
] })
|
|
1843
|
+
] })
|
|
1844
|
+
]
|
|
1845
|
+
},
|
|
1846
|
+
e
|
|
1847
|
+
);
|
|
1848
|
+
}) }) })
|
|
1849
|
+
] })
|
|
1850
|
+
] }) })
|
|
1851
|
+
]
|
|
1852
|
+
}
|
|
1853
|
+
) : /* @__PURE__ */ n(
|
|
1854
|
+
"div",
|
|
1855
|
+
{
|
|
1856
|
+
style: {
|
|
1857
|
+
position: "fixed",
|
|
1858
|
+
...w[p],
|
|
1859
|
+
zIndex: 999999,
|
|
1860
|
+
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
|
1861
|
+
color: "white",
|
|
1862
|
+
padding: "8px 12px",
|
|
1863
|
+
borderRadius: "4px",
|
|
1864
|
+
cursor: "pointer",
|
|
1865
|
+
fontSize: "12px",
|
|
1866
|
+
fontFamily: "monospace"
|
|
1867
|
+
},
|
|
1868
|
+
onClick: () => x(!0),
|
|
1869
|
+
children: [
|
|
1870
|
+
/* @__PURE__ */ r(V, { size: 16 }),
|
|
1871
|
+
" DataSource Debug (",
|
|
1872
|
+
m.length,
|
|
1873
|
+
")"
|
|
1874
|
+
]
|
|
1875
|
+
}
|
|
1876
|
+
);
|
|
1877
|
+
};
|
|
1878
|
+
function Se(l, t, o = {}) {
|
|
1879
|
+
const {
|
|
1880
|
+
logOperations: s = !0,
|
|
1881
|
+
monitorState: p = !0,
|
|
1882
|
+
trackPerformance: g = !0,
|
|
1883
|
+
maxHistory: f = 100
|
|
1884
|
+
} = o, [x, y] = F([]), [S, C] = F(null), k = M([]), R = M(/* @__PURE__ */ new Map()), a = (b) => {
|
|
1885
|
+
const w = {
|
|
1886
|
+
...b,
|
|
1887
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
1888
|
+
timestamp: Date.now()
|
|
1889
|
+
};
|
|
1890
|
+
k.current = [w, ...k.current].slice(0, f), y([...k.current]), s && I({
|
|
1891
|
+
type: "state",
|
|
1892
|
+
message: `DataSource ${t}: ${b.operation}`,
|
|
1893
|
+
data: {
|
|
1894
|
+
operation: b.operation,
|
|
1895
|
+
args: b.args,
|
|
1896
|
+
duration: b.duration,
|
|
1897
|
+
result: b.result,
|
|
1898
|
+
error: b.error
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
}, m = () => {
|
|
1902
|
+
if (!(!p || !l))
|
|
1903
|
+
try {
|
|
1904
|
+
const b = {
|
|
1905
|
+
recordCount: l.getRecordCount?.(),
|
|
1906
|
+
currentRecord: l.getCurrentRecord?.(),
|
|
1907
|
+
recNo: l.getRecNo?.(),
|
|
1908
|
+
state: l.getState?.(),
|
|
1909
|
+
isActive: l.isActive?.(),
|
|
1910
|
+
isBrowsing: l.isBrowsing?.(),
|
|
1911
|
+
isEditing: l.isEditing?.(),
|
|
1912
|
+
isInserting: l.isInserting?.(),
|
|
1913
|
+
hasChanges: l.hasChanges?.(),
|
|
1914
|
+
version: l._isArchbaseDataSourceV2 ? "v2" : l._isArchbaseDataSource ? "v1" : "unknown"
|
|
1915
|
+
};
|
|
1916
|
+
C(b);
|
|
1917
|
+
} catch (b) {
|
|
1918
|
+
console.warn("Failed to update DataSource state:", b);
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
L(() => {
|
|
1922
|
+
if (!l)
|
|
1923
|
+
return;
|
|
1924
|
+
const b = [];
|
|
1925
|
+
if (p && typeof l.addListener == "function") {
|
|
1926
|
+
const w = () => {
|
|
1927
|
+
m(), a({
|
|
1928
|
+
operation: "stateChanged",
|
|
1929
|
+
args: []
|
|
1930
|
+
});
|
|
1931
|
+
};
|
|
1932
|
+
l.addListener(w), b.push(() => {
|
|
1933
|
+
typeof l.removeListener == "function" && l.removeListener(w);
|
|
1934
|
+
}), m();
|
|
1935
|
+
}
|
|
1936
|
+
return (s || g) && ([
|
|
1937
|
+
"post",
|
|
1938
|
+
"edit",
|
|
1939
|
+
"delete",
|
|
1940
|
+
"cancel",
|
|
1941
|
+
"append",
|
|
1942
|
+
"insert",
|
|
1943
|
+
"remove",
|
|
1944
|
+
"first",
|
|
1945
|
+
"last",
|
|
1946
|
+
"next",
|
|
1947
|
+
"prior",
|
|
1948
|
+
"gotoRecNo",
|
|
1949
|
+
"locate",
|
|
1950
|
+
"applyFilter",
|
|
1951
|
+
"clearFilter",
|
|
1952
|
+
"sort",
|
|
1953
|
+
"refresh"
|
|
1954
|
+
].forEach((e) => {
|
|
1955
|
+
if (typeof l[e] == "function") {
|
|
1956
|
+
const c = l[e];
|
|
1957
|
+
R.current.set(e, c), l[e] = function(...i) {
|
|
1958
|
+
const h = g ? performance.now() : 0;
|
|
1959
|
+
let d, v;
|
|
1960
|
+
try {
|
|
1961
|
+
if (d = c.apply(this, i), d && typeof d.then == "function")
|
|
1962
|
+
d.then((B) => {
|
|
1963
|
+
const O = g ? performance.now() - h : void 0;
|
|
1964
|
+
a({
|
|
1965
|
+
operation: e,
|
|
1966
|
+
args: i,
|
|
1967
|
+
duration: O,
|
|
1968
|
+
result: B
|
|
1969
|
+
});
|
|
1970
|
+
}).catch((B) => {
|
|
1971
|
+
const O = g ? performance.now() - h : void 0;
|
|
1972
|
+
a({
|
|
1973
|
+
operation: e,
|
|
1974
|
+
args: i,
|
|
1975
|
+
duration: O,
|
|
1976
|
+
error: B
|
|
1977
|
+
});
|
|
1978
|
+
});
|
|
1979
|
+
else {
|
|
1980
|
+
const B = g ? performance.now() - h : void 0;
|
|
1981
|
+
a({
|
|
1982
|
+
operation: e,
|
|
1983
|
+
args: i,
|
|
1984
|
+
duration: B,
|
|
1985
|
+
result: d
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
} catch (B) {
|
|
1989
|
+
v = B;
|
|
1990
|
+
const O = g ? performance.now() - h : void 0;
|
|
1991
|
+
throw a({
|
|
1992
|
+
operation: e,
|
|
1993
|
+
args: i,
|
|
1994
|
+
duration: O,
|
|
1995
|
+
error: v
|
|
1996
|
+
}), B;
|
|
1997
|
+
}
|
|
1998
|
+
return d;
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
}), b.push(() => {
|
|
2002
|
+
l && R.current.forEach((e, c) => {
|
|
2003
|
+
l[c] && (l[c] = e);
|
|
2004
|
+
}), R.current.clear();
|
|
2005
|
+
})), () => {
|
|
2006
|
+
b.forEach((w) => w());
|
|
2007
|
+
};
|
|
2008
|
+
}, [l, t, s, p, g, f]);
|
|
2009
|
+
const z = () => {
|
|
2010
|
+
const b = x.reduce((w, e) => (w[e.operation] || (w[e.operation] = []), e.duration !== void 0 && w[e.operation].push(e.duration), w), {});
|
|
2011
|
+
return Object.entries(b).map(([w, e]) => {
|
|
2012
|
+
const c = e.reduce((d, v) => d + v, 0) / e.length, i = Math.min(...e), h = Math.max(...e);
|
|
2013
|
+
return {
|
|
2014
|
+
method: w,
|
|
2015
|
+
count: e.length,
|
|
2016
|
+
avgDuration: c,
|
|
2017
|
+
minDuration: i,
|
|
2018
|
+
maxDuration: h,
|
|
2019
|
+
totalDuration: e.reduce((d, v) => d + v, 0)
|
|
2020
|
+
};
|
|
2021
|
+
});
|
|
2022
|
+
}, u = (b) => b ? x.filter((w) => w.operation === b) : x, D = () => {
|
|
2023
|
+
k.current = [], y([]);
|
|
2024
|
+
}, E = () => ({
|
|
2025
|
+
dataSourceName: t,
|
|
2026
|
+
currentState: S,
|
|
2027
|
+
operations: x,
|
|
2028
|
+
performanceStats: z(),
|
|
2029
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2030
|
+
});
|
|
2031
|
+
return {
|
|
2032
|
+
operations: x,
|
|
2033
|
+
currentState: S,
|
|
2034
|
+
performanceStats: z(),
|
|
2035
|
+
getOperationHistory: u,
|
|
2036
|
+
clearHistory: D,
|
|
2037
|
+
exportDebugData: E
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
function Ce() {
|
|
2041
|
+
const [l, t] = F([]);
|
|
2042
|
+
return {
|
|
2043
|
+
dataSources: l,
|
|
2044
|
+
registerDataSource: (x, y, S) => {
|
|
2045
|
+
t((C) => C.find((R) => R.name === x) ? C.map(
|
|
2046
|
+
(R) => R.name === x ? { ...R, dataSource: y } : R
|
|
2047
|
+
) : [...C, {
|
|
2048
|
+
name: x,
|
|
2049
|
+
dataSource: y,
|
|
2050
|
+
debugHook: {}
|
|
2051
|
+
// Will be populated by the hook
|
|
2052
|
+
}]);
|
|
2053
|
+
},
|
|
2054
|
+
unregisterDataSource: (x) => {
|
|
2055
|
+
t((y) => y.filter((S) => S.name !== x));
|
|
2056
|
+
},
|
|
2057
|
+
getDataSource: (x) => l.find((y) => y.name === x),
|
|
2058
|
+
getAllDataSources: () => l,
|
|
2059
|
+
exportAllDebugData: () => ({
|
|
2060
|
+
dataSources: l.map((x) => ({
|
|
2061
|
+
name: x.name,
|
|
2062
|
+
debugData: x.debugHook
|
|
2063
|
+
})),
|
|
2064
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2065
|
+
})
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
const ke = "3.0.0";
|
|
2069
|
+
export {
|
|
2070
|
+
j as ArchbaseConsoleLogger,
|
|
2071
|
+
ve as ArchbaseDataSourceInspector,
|
|
2072
|
+
he as ArchbaseDebugPanel,
|
|
2073
|
+
be as ArchbaseErrorBoundary,
|
|
2074
|
+
me as ArchbaseLocalStorageViewer,
|
|
2075
|
+
N as ArchbaseMemoryLeakDetector,
|
|
2076
|
+
xe as ArchbaseNetworkMonitor,
|
|
2077
|
+
J as ArchbasePerformanceMonitor,
|
|
2078
|
+
ye as ArchbaseStateInspector,
|
|
2079
|
+
ke as ArchbaseToolsVersion,
|
|
2080
|
+
I as emitDebugInfo,
|
|
2081
|
+
ue as logger,
|
|
2082
|
+
we as memoryLeakDetector,
|
|
2083
|
+
K as performanceMonitor,
|
|
2084
|
+
Se as useArchbaseDataSourceDebug,
|
|
2085
|
+
Ce as useArchbaseDataSourceRegistry,
|
|
2086
|
+
ge as useArchbaseRenderTracker,
|
|
2087
|
+
fe as useArchbaseWhyDidYouRender
|
|
2088
|
+
};
|