batchkit-devtools 0.3.6 → 0.4.1

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.
@@ -1,1065 +0,0 @@
1
- import { delegateEvents as ne, template as _, style as o, insert as g, createComponent as k, effect as B, memo as N, setAttribute as te, setStyleProperty as he, addEventListener as De, className as we, render as je } from "solid-js/web";
2
- import { createRoot as Me, createSignal as J, createMemo as _e, For as de, Show as L, onMount as Le } from "solid-js";
3
- import { __setDevtoolsHook as Ne } from "batchkit";
4
- let Fe = 0;
5
- function Ue(i) {
6
- if (!i) return;
7
- const e = i.split(`
8
- `);
9
- for (const s of e)
10
- if (s.includes("batch") && !s.includes("batchkit") && !s.includes("node_modules")) {
11
- const r = s.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
12
- if (r) return r[1];
13
- }
14
- for (const s of e.slice(2))
15
- if (!s.includes("batchkit") && !s.includes("node_modules")) {
16
- const r = s.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
17
- if (r) return r[1];
18
- }
19
- }
20
- function Ke() {
21
- const [i, e] = J({
22
- batchers: /* @__PURE__ */ new Map(),
23
- events: [],
24
- batches: /* @__PURE__ */ new Map(),
25
- selectedBatcher: null,
26
- isOpen: !1,
27
- config: {}
28
- }), s = /* @__PURE__ */ new Set();
29
- function r() {
30
- const a = i();
31
- for (const p of s)
32
- p(a);
33
- }
34
- function t(a) {
35
- e((p) => {
36
- const d = new Map(p.batchers);
37
- return d.set(a.name, a), { ...p, batchers: d };
38
- }), r();
39
- }
40
- function n(a, p) {
41
- const d = { ...p, batcherName: a };
42
- e((C) => {
43
- const T = [...C.events, d], $ = new Map(C.batches);
44
- if (d.type === "schedule") {
45
- const S = {
46
- batchId: d.batchId,
47
- batcherName: a,
48
- keys: [],
49
- status: "scheduled",
50
- scheduledAt: d.timestamp
51
- };
52
- $.set(d.batchId, S);
53
- }
54
- if (d.type === "dispatch") {
55
- const S = $.get(d.batchId);
56
- S && $.set(d.batchId, {
57
- ...S,
58
- keys: d.keys,
59
- status: "dispatching",
60
- dispatchedAt: d.timestamp
61
- });
62
- }
63
- if (d.type === "resolve") {
64
- const S = $.get(d.batchId);
65
- S && $.set(d.batchId, {
66
- ...S,
67
- status: "resolved",
68
- completedAt: d.timestamp,
69
- duration: d.duration
70
- });
71
- }
72
- if (d.type === "error") {
73
- const S = $.get(d.batchId);
74
- S && $.set(d.batchId, {
75
- ...S,
76
- status: "error",
77
- completedAt: d.timestamp,
78
- error: d.error
79
- });
80
- }
81
- if (d.type === "abort") {
82
- const S = $.get(d.batchId);
83
- S && $.set(d.batchId, {
84
- ...S,
85
- status: "aborted",
86
- completedAt: d.timestamp
87
- });
88
- }
89
- return { ...C, events: T, batches: $ };
90
- }), r();
91
- }
92
- function l(a) {
93
- return s.add(a), a(i()), () => s.delete(a);
94
- }
95
- function u() {
96
- return i();
97
- }
98
- function v() {
99
- e((a) => ({
100
- ...a,
101
- events: [],
102
- batches: /* @__PURE__ */ new Map()
103
- })), r();
104
- }
105
- function f() {
106
- e((a) => ({ ...a, isOpen: !0 })), r();
107
- }
108
- function h() {
109
- e((a) => ({ ...a, isOpen: !1 })), r();
110
- }
111
- function b() {
112
- e((a) => ({ ...a, isOpen: !a.isOpen })), r();
113
- }
114
- return Ne({
115
- onBatcherCreated({ fn: a, name: p, stack: d }) {
116
- const C = !p, T = p ?? `unnamed-${++Fe}`, $ = a.toString().slice(0, 500), S = Ue(d);
117
- return t({
118
- name: T,
119
- registeredAt: performance.now(),
120
- isUnnamed: C,
121
- fnSource: $,
122
- location: S
123
- }), (O) => {
124
- n(T, O);
125
- };
126
- }
127
- }), {
128
- subscribe: l,
129
- getStore: u,
130
- clear: v,
131
- open: f,
132
- close: h,
133
- toggle: b,
134
- _setStore: e,
135
- _store: i
136
- };
137
- }
138
- let z = null;
139
- function He() {
140
- if (typeof window > "u")
141
- throw new Error("DevTools can only be used in browser environment");
142
- return z || (z = Me(() => Ke())), z;
143
- }
144
- function Y() {
145
- if (!z)
146
- throw new Error(
147
- "DevTools registry not initialized. Call initRegistry() first."
148
- );
149
- return z;
150
- }
151
- function ke() {
152
- const i = Y();
153
- if (i._store)
154
- return i._store;
155
- const [e, s] = J(i.getStore());
156
- return i.subscribe(s), e;
157
- }
158
- function Pe(i) {
159
- var e;
160
- z && ((e = z._setStore) == null || e.call(z, (s) => ({
161
- ...s,
162
- selectedBatcher: i
163
- })));
164
- }
165
- function Ge(i) {
166
- var e;
167
- z && ((e = z._setStore) == null || e.call(z, (s) => ({
168
- ...s,
169
- config: { ...s.config, ...i }
170
- })));
171
- }
172
- var Xe = /* @__PURE__ */ _("<div>"), We = /* @__PURE__ */ _("<div><div></div><div><span> gets</span><span> batches"), Ye = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batchers yet</div><div style=font-size:11px;color:#57534e>Call batch() to see it here");
173
- const qe = {
174
- flex: "1",
175
- "overflow-y": "auto"
176
- }, Ce = {
177
- padding: "8px 12px",
178
- cursor: "pointer",
179
- "border-bottom": "1px solid #292524",
180
- "border-left": "2px solid transparent"
181
- }, Je = {
182
- ...Ce,
183
- background: "#1c1917",
184
- "border-left-color": "#a8a29e"
185
- }, ze = {
186
- "font-size": "13px",
187
- color: "#d6d3d1",
188
- "margin-bottom": "2px"
189
- }, Ze = {
190
- ...ze,
191
- color: "#78716c",
192
- "font-style": "italic"
193
- }, Qe = {
194
- "font-size": "11px",
195
- color: "#78716c"
196
- }, ge = {
197
- display: "inline-flex",
198
- "align-items": "center",
199
- gap: "4px",
200
- "margin-right": "8px"
201
- }, Ve = {
202
- display: "flex",
203
- "flex-direction": "column",
204
- "align-items": "center",
205
- "justify-content": "center",
206
- height: "100%",
207
- color: "#57534e",
208
- "text-align": "center",
209
- padding: "24px 12px"
210
- }, et = (i) => {
211
- const e = _e(() => Array.from(i.batchers.values())), s = (t) => {
212
- const n = i.events.filter((v) => v.batcherName === t), l = n.filter((v) => v.type === "get").length, u = n.filter((v) => v.type === "resolve").length;
213
- return {
214
- gets: l,
215
- batches: u
216
- };
217
- }, r = (t) => {
218
- i.selectedBatcher === t ? i.onSelect(null) : i.onSelect(t);
219
- };
220
- return (() => {
221
- var t = Xe();
222
- return o(t, qe), g(t, k(de, {
223
- get each() {
224
- return e();
225
- },
226
- children: (n) => {
227
- const l = () => s(n.name), u = () => i.selectedBatcher === n.name;
228
- return (() => {
229
- var v = We(), f = v.firstChild, h = f.nextSibling, b = h.firstChild, y = b.firstChild, a = b.nextSibling, p = a.firstChild;
230
- return v.$$click = () => r(n.name), g(f, () => n.name), o(h, Qe), g(b, () => l().gets, y), g(a, () => l().batches, p), B((d) => {
231
- var C = u() ? Je : Ce, T = n.isUnnamed ? Ze : ze, $ = ge, S = ge;
232
- return d.e = o(v, C, d.e), d.t = o(f, T, d.t), d.a = o(b, $, d.a), d.o = o(a, S, d.o), d;
233
- }, {
234
- e: void 0,
235
- t: void 0,
236
- a: void 0,
237
- o: void 0
238
- }), v;
239
- })();
240
- }
241
- }), null), g(t, (() => {
242
- var n = N(() => e().length === 0);
243
- return () => n() && (() => {
244
- var l = Ye(), u = l.firstChild;
245
- return u.nextSibling, o(l, Ve), l;
246
- })();
247
- })(), null), t;
248
- })();
249
- };
250
- ne(["click"]);
251
- var tt = /* @__PURE__ */ _("<div>"), nt = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batches yet</div><div style=font-size:11px;color:#57534e>Batches appear as requests are processed"), rt = /* @__PURE__ */ _("<div><div></div><div></div><div></div><div>");
252
- const ot = {
253
- display: "flex",
254
- "flex-direction": "column",
255
- gap: "1px"
256
- }, it = {
257
- display: "flex",
258
- "align-items": "center",
259
- gap: "12px",
260
- padding: "6px 8px",
261
- background: "#1c1917",
262
- "font-size": "11px"
263
- }, st = {
264
- "font-size": "11px",
265
- color: "#78716c",
266
- "min-width": "80px"
267
- }, H = {
268
- padding: "2px 6px",
269
- "font-size": "10px",
270
- "font-weight": "500",
271
- "text-transform": "uppercase",
272
- "letter-spacing": "0.3px"
273
- }, lt = {
274
- scheduled: {
275
- ...H,
276
- background: "#422006",
277
- color: "#fbbf24"
278
- },
279
- dispatching: {
280
- ...H,
281
- background: "#1e3a5f",
282
- color: "#60a5fa"
283
- },
284
- resolved: {
285
- ...H,
286
- background: "#14532d",
287
- color: "#4ade80"
288
- },
289
- error: {
290
- ...H,
291
- background: "#450a0a",
292
- color: "#f87171"
293
- },
294
- aborted: {
295
- ...H,
296
- background: "#292524",
297
- color: "#a8a29e"
298
- }
299
- }, ct = {
300
- flex: "1",
301
- "font-size": "11px",
302
- color: "#a8a29e",
303
- "white-space": "nowrap",
304
- overflow: "hidden",
305
- "text-overflow": "ellipsis"
306
- }, at = {
307
- "font-size": "11px",
308
- color: "#57534e",
309
- "min-width": "50px",
310
- "text-align": "right"
311
- }, dt = {
312
- display: "flex",
313
- "flex-direction": "column",
314
- "align-items": "center",
315
- "justify-content": "center",
316
- height: "100%",
317
- color: "#57534e",
318
- "text-align": "center",
319
- padding: "32px"
320
- }, ut = (i) => {
321
- const e = (t) => t === void 0 ? "-" : t < 1 ? "<1ms" : t < 1e3 ? `${Math.round(t)}ms` : `${(t / 1e3).toFixed(2)}s`, s = (t) => {
322
- if (t.length === 0) return "-";
323
- const n = t.slice(0, 3).map((l) => String(l)).join(", ");
324
- return t.length > 3 ? `${n} +${t.length - 3}` : n;
325
- }, r = () => [...i.batches].sort((t, n) => n.scheduledAt - t.scheduledAt);
326
- return (() => {
327
- var t = tt();
328
- return o(t, ot), g(t, k(L, {
329
- get when() {
330
- return r().length > 0;
331
- },
332
- get fallback() {
333
- return (() => {
334
- var n = nt(), l = n.firstChild;
335
- return l.nextSibling, o(n, dt), n;
336
- })();
337
- },
338
- get children() {
339
- return k(de, {
340
- get each() {
341
- return r();
342
- },
343
- children: (n) => (() => {
344
- var l = rt(), u = l.firstChild, v = u.nextSibling, f = v.nextSibling, h = f.nextSibling;
345
- return o(l, it), o(u, st), g(u, () => n.batchId), g(v, () => n.status), o(f, ct), g(f, () => s(n.keys)), o(h, at), g(h, () => e(n.duration)), B((b) => {
346
- var y = lt[n.status] || H, a = n.keys.map(String).join(", ");
347
- return b.e = o(v, y, b.e), a !== b.t && te(f, "title", b.t = a), b;
348
- }, {
349
- e: void 0,
350
- t: void 0
351
- }), l;
352
- })()
353
- });
354
- }
355
- })), t;
356
- })();
357
- };
358
- var ft = /* @__PURE__ */ _("<div>"), vt = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No events</div><div style=font-size:11px;color:#57534e>Events appear as batchers process requests"), ht = /* @__PURE__ */ _("<div><span></span><span></span><span>");
359
- const gt = {
360
- display: "flex",
361
- "flex-direction": "column",
362
- gap: "1px",
363
- "font-size": "11px"
364
- }, mt = {
365
- display: "flex",
366
- gap: "12px",
367
- padding: "4px 8px",
368
- background: "#1c1917"
369
- }, bt = {
370
- color: "#57534e",
371
- "min-width": "60px"
372
- }, pt = {
373
- "min-width": "60px",
374
- "font-weight": "500"
375
- }, xt = {
376
- get: "#60a5fa",
377
- dedup: "#c084fc",
378
- schedule: "#fbbf24",
379
- dispatch: "#22d3ee",
380
- resolve: "#4ade80",
381
- error: "#f87171",
382
- abort: "#a8a29e"
383
- }, yt = {
384
- color: "#78716c",
385
- flex: "1",
386
- "white-space": "nowrap",
387
- overflow: "hidden",
388
- "text-overflow": "ellipsis"
389
- }, St = {
390
- display: "flex",
391
- "flex-direction": "column",
392
- "align-items": "center",
393
- "justify-content": "center",
394
- height: "100%",
395
- color: "#57534e",
396
- "text-align": "center",
397
- padding: "32px"
398
- }, $t = (i) => {
399
- const e = (t) => (t / 1e3).toFixed(3) + "s", s = (t) => {
400
- switch (t.type) {
401
- case "get":
402
- return `key: ${String(t.key)}`;
403
- case "dedup":
404
- return `key: ${String(t.key)} (dedup)`;
405
- case "schedule":
406
- return `batch: ${t.batchId}, size: ${t.size}`;
407
- case "dispatch":
408
- return `batch: ${t.batchId}, keys: [${t.keys.map(String).join(", ")}]`;
409
- case "resolve":
410
- return `batch: ${t.batchId}, ${t.duration.toFixed(1)}ms`;
411
- case "error":
412
- return `batch: ${t.batchId}, ${t.error.message}`;
413
- case "abort":
414
- return `batch: ${t.batchId}`;
415
- default:
416
- return "";
417
- }
418
- }, r = () => [...i.events].reverse();
419
- return (() => {
420
- var t = ft();
421
- return o(t, gt), g(t, k(L, {
422
- get when() {
423
- return r().length > 0;
424
- },
425
- get fallback() {
426
- return (() => {
427
- var n = vt(), l = n.firstChild;
428
- return l.nextSibling, o(n, St), n;
429
- })();
430
- },
431
- get children() {
432
- return k(de, {
433
- get each() {
434
- return r();
435
- },
436
- children: (n) => (() => {
437
- var l = ht(), u = l.firstChild, v = u.nextSibling, f = v.nextSibling;
438
- return o(l, mt), o(u, bt), g(u, () => e(n.timestamp)), g(v, () => n.type), o(f, yt), g(f, () => s(n)), B((h) => o(v, {
439
- ...pt,
440
- color: xt[n.type]
441
- }, h)), l;
442
- })()
443
- });
444
- }
445
- })), t;
446
- })();
447
- };
448
- var wt = /* @__PURE__ */ _("<div><div><div>Gets</div><div></div></div><div><div>Batches</div><div></div></div><div><div>Deduped</div><div><span>(<!>%)</span></div></div><div><div>Avg Size</div><div></div></div><div><div>Avg Time</div><div><span>ms</span></div></div><div><div>Err / Abort</div><div><span></span><span style=color:#57534e> / </span><span>");
449
- const _t = {
450
- display: "grid",
451
- "grid-template-columns": "repeat(auto-fit, minmax(120px, 1fr))",
452
- gap: "1px",
453
- background: "#292524"
454
- }, F = {
455
- padding: "12px",
456
- background: "#1c1917"
457
- }, U = {
458
- "font-size": "11px",
459
- "text-transform": "uppercase",
460
- "letter-spacing": "0.5px",
461
- color: "#78716c",
462
- "margin-bottom": "4px"
463
- }, K = {
464
- "font-size": "20px",
465
- "font-weight": "500",
466
- color: "#f5f5f4"
467
- }, me = {
468
- "font-size": "11px",
469
- color: "#57534e",
470
- "margin-left": "2px"
471
- }, kt = (i) => {
472
- const e = _e(() => {
473
- const s = i.events, r = i.batches, t = s.filter((a) => a.type === "get").length, n = s.filter((a) => a.type === "dedup").length, l = r.filter((a) => a.status === "resolved"), u = l.length, v = u > 0 ? l.reduce((a, p) => a + p.keys.length, 0) / u : 0, f = u > 0 ? l.reduce((a, p) => a + (p.duration || 0), 0) / u : 0, h = r.filter((a) => a.status === "error").length, b = r.filter((a) => a.status === "aborted").length, y = t > 0 ? n / t * 100 : 0;
474
- return {
475
- totalGets: t,
476
- totalBatches: u,
477
- dedupedKeys: n,
478
- avgBatchSize: v,
479
- avgDuration: f,
480
- errors: h,
481
- aborts: b,
482
- dedupRate: y
483
- };
484
- });
485
- return (() => {
486
- var s = wt(), r = s.firstChild, t = r.firstChild, n = t.nextSibling, l = r.nextSibling, u = l.firstChild, v = u.nextSibling, f = l.nextSibling, h = f.firstChild, b = h.nextSibling, y = b.firstChild, a = y.firstChild, p = a.nextSibling;
487
- p.nextSibling;
488
- var d = f.nextSibling, C = d.firstChild, T = C.nextSibling, $ = d.nextSibling, S = $.firstChild, O = S.nextSibling, Z = O.firstChild, x = $.nextSibling, w = x.firstChild, E = w.nextSibling, I = E.firstChild, D = I.nextSibling, R = D.nextSibling;
489
- return o(s, _t), g(n, () => e().totalGets), g(v, () => e().totalBatches), g(b, () => e().dedupedKeys, y), g(y, () => e().dedupRate.toFixed(0), p), g(T, () => e().avgBatchSize.toFixed(1)), g(O, () => e().avgDuration.toFixed(0), Z), g(I, () => e().errors), g(R, () => e().aborts), B((c) => {
490
- var P = F, A = U, j = K, G = F, X = U, W = K, Q = F, M = U, m = K, V = me, re = F, oe = U, ie = K, se = F, le = U, ce = K, Ae = me, Oe = F, Ee = U, Re = K, fe = e().errors > 0 ? "#f87171" : "#f5f5f4", ve = e().aborts > 0 ? "#fbbf24" : "#f5f5f4";
491
- return c.e = o(r, P, c.e), c.t = o(t, A, c.t), c.a = o(n, j, c.a), c.o = o(l, G, c.o), c.i = o(u, X, c.i), c.n = o(v, W, c.n), c.s = o(f, Q, c.s), c.h = o(h, M, c.h), c.r = o(b, m, c.r), c.d = o(y, V, c.d), c.l = o(d, re, c.l), c.u = o(C, oe, c.u), c.c = o(T, ie, c.c), c.w = o($, se, c.w), c.m = o(S, le, c.m), c.f = o(O, ce, c.f), c.y = o(Z, Ae, c.y), c.g = o(x, Oe, c.g), c.p = o(w, Ee, c.p), c.b = o(E, Re, c.b), fe !== c.T && he(I, "color", c.T = fe), ve !== c.A && he(R, "color", c.A = ve), c;
492
- }, {
493
- e: void 0,
494
- t: void 0,
495
- a: void 0,
496
- o: void 0,
497
- i: void 0,
498
- n: void 0,
499
- s: void 0,
500
- h: void 0,
501
- r: void 0,
502
- d: void 0,
503
- l: void 0,
504
- u: void 0,
505
- c: void 0,
506
- w: void 0,
507
- m: void 0,
508
- f: void 0,
509
- y: void 0,
510
- g: void 0,
511
- p: void 0,
512
- b: void 0,
513
- T: void 0,
514
- A: void 0
515
- }), s;
516
- })();
517
- };
518
- var ae = /* @__PURE__ */ _("<div>"), Ct = /* @__PURE__ */ _("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batcher selected</div><div style=font-size:11px;color:#57534e>Click a batcher to see its trace info"), zt = /* @__PURE__ */ _("<div><div>Function</div><div>"), Tt = /* @__PURE__ */ _('<div style="height:auto;padding:24px 0"><div style=font-size:11px;color:#57534e>No trace metadata available'), Bt = /* @__PURE__ */ _("<span style=color:#78716c;font-weight:normal;font-style:italic> (unnamed)"), It = /* @__PURE__ */ _("<div><div>Location"), At = /* @__PURE__ */ _("<a> ↗");
519
- function Ot(i) {
520
- let e = i;
521
- const s = i.match(/^https?:\/\/[^/]+(.*)$/);
522
- s && (e = s[1]), e = e.split("?")[0];
523
- const r = e.match(/^(.+?):(\d+)(?::(\d+))?$/);
524
- return r ? {
525
- path: r[1],
526
- line: parseInt(r[2], 10),
527
- column: r[3] ? parseInt(r[3], 10) : void 0
528
- } : {
529
- path: e
530
- };
531
- }
532
- function Et(i, e) {
533
- const s = Ot(i);
534
- if (!s) return null;
535
- let {
536
- path: r,
537
- line: t,
538
- column: n
539
- } = s;
540
- if (r.startsWith("/") && !r.startsWith("//") && e.projectRoot)
541
- r = e.projectRoot + r;
542
- else if (!r.startsWith("/"))
543
- if (e.projectRoot)
544
- r = e.projectRoot + "/" + r;
545
- else
546
- return null;
547
- const l = e.editor ?? "vscode", v = {
548
- vscode: "vscode://file",
549
- cursor: "cursor://file",
550
- webstorm: "webstorm://open?file=",
551
- idea: "idea://open?file="
552
- }[l];
553
- if (!v) return null;
554
- if (l === "webstorm" || l === "idea") {
555
- let h = `${v}${encodeURIComponent(r)}`;
556
- return t !== void 0 && (h += `&line=${t}`, n !== void 0 && (h += `&column=${n}`)), h;
557
- }
558
- let f = `${v}${r}`;
559
- return t !== void 0 && (f += `:${t}`, n !== void 0 && (f += `:${n}`)), f;
560
- }
561
- const Rt = {
562
- padding: "12px",
563
- height: "100%",
564
- "overflow-y": "auto"
565
- }, be = {
566
- display: "flex",
567
- "flex-direction": "column",
568
- "align-items": "center",
569
- "justify-content": "center",
570
- height: "100%",
571
- color: "#57534e",
572
- "text-align": "center"
573
- }, pe = {
574
- "margin-bottom": "16px"
575
- }, xe = {
576
- color: "#78716c",
577
- "margin-bottom": "6px",
578
- "font-size": "10px",
579
- "text-transform": "uppercase",
580
- "letter-spacing": "0.5px"
581
- }, ue = {
582
- background: "#1c1917",
583
- padding: "8px 10px",
584
- "font-size": "11px",
585
- color: "#d6d3d1",
586
- border: "1px solid #292524"
587
- }, Dt = {
588
- ...ue,
589
- display: "block",
590
- color: "#93c5fd",
591
- "text-decoration": "none",
592
- cursor: "pointer"
593
- }, jt = {
594
- "text-decoration": "underline"
595
- }, Mt = {
596
- ...ue,
597
- "white-space": "pre-wrap",
598
- "word-break": "break-all",
599
- "max-height": "300px",
600
- "overflow-y": "auto",
601
- "font-family": "ui-monospace, monospace"
602
- }, Lt = {
603
- "font-size": "14px",
604
- "font-weight": "600",
605
- color: "#f5f5f4",
606
- "margin-bottom": "16px"
607
- }, Nt = (i) => {
608
- const e = ke(), s = () => e().config;
609
- return (() => {
610
- var r = ae();
611
- return o(r, Rt), g(r, k(L, {
612
- get when() {
613
- return i.batcher;
614
- },
615
- get fallback() {
616
- return (() => {
617
- var t = Ct(), n = t.firstChild;
618
- return n.nextSibling, B((l) => o(t, be, l)), t;
619
- })();
620
- },
621
- children: (t) => [(() => {
622
- var n = ae();
623
- return o(n, Lt), g(n, () => t().name, null), g(n, (() => {
624
- var l = N(() => !!t().isUnnamed);
625
- return () => l() && Bt();
626
- })(), null), n;
627
- })(), k(L, {
628
- get when() {
629
- return t().location;
630
- },
631
- children: (n) => {
632
- const l = () => Et(n(), s());
633
- return (() => {
634
- var u = It(), v = u.firstChild;
635
- return g(u, k(L, {
636
- get when() {
637
- return l();
638
- },
639
- get fallback() {
640
- return (() => {
641
- var f = ae();
642
- return g(f, n), B((h) => o(f, ue, h)), f;
643
- })();
644
- },
645
- children: (f) => (() => {
646
- var h = At(), b = h.firstChild;
647
- return h.$$mouseout = (y) => y.currentTarget.style.textDecoration = "none", h.$$mouseover = (y) => Object.assign(y.currentTarget.style, jt), g(h, n, b), B((y) => {
648
- var a = f(), p = Dt;
649
- return a !== y.e && te(h, "href", y.e = a), y.t = o(h, p, y.t), y;
650
- }, {
651
- e: void 0,
652
- t: void 0
653
- }), h;
654
- })()
655
- }), null), B((f) => {
656
- var h = pe, b = xe;
657
- return f.e = o(u, h, f.e), f.t = o(v, b, f.t), f;
658
- }, {
659
- e: void 0,
660
- t: void 0
661
- }), u;
662
- })();
663
- }
664
- }), k(L, {
665
- get when() {
666
- return t().fnSource;
667
- },
668
- get children() {
669
- var n = zt(), l = n.firstChild, u = l.nextSibling;
670
- return g(u, () => t().fnSource), B((v) => {
671
- var f = pe, h = xe, b = Mt;
672
- return v.e = o(n, f, v.e), v.t = o(l, h, v.t), v.a = o(u, b, v.a), v;
673
- }, {
674
- e: void 0,
675
- t: void 0,
676
- a: void 0
677
- }), n;
678
- }
679
- }), k(L, {
680
- get when() {
681
- return N(() => !t().location)() && !t().fnSource;
682
- },
683
- get children() {
684
- var n = Tt();
685
- return n.firstChild, B((l) => o(n, {
686
- ...be
687
- }, l)), n;
688
- }
689
- })]
690
- })), r;
691
- })();
692
- };
693
- ne(["mouseover", "mouseout"]);
694
- var Ft = /* @__PURE__ */ _("<button>");
695
- const Te = {
696
- position: "fixed",
697
- bottom: "16px",
698
- right: "16px",
699
- width: "40px",
700
- height: "40px",
701
- border: "1px solid #44403c",
702
- background: "#1c1917",
703
- color: "#a8a29e",
704
- cursor: "pointer",
705
- display: "flex",
706
- "align-items": "center",
707
- "justify-content": "center",
708
- "z-index": "99999",
709
- "font-family": "ui-monospace, monospace"
710
- }, Ut = {
711
- ...Te,
712
- background: "#292524",
713
- color: "#f5f5f4",
714
- "border-color": "#57534e"
715
- }, Kt = (i) => {
716
- const e = () => ({
717
- ...i.isOpen ? Ut : Te,
718
- ...i.style
719
- });
720
- return (() => {
721
- var s = Ft();
722
- return De(s, "click", i.onClick, !0), g(s, () => i.isOpen ? "[×]" : "[=]"), B((r) => {
723
- var t = i.class, n = e(), l = i.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools", u = i.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools";
724
- return t !== r.e && we(s, r.e = t), r.t = o(s, n, r.t), l !== r.a && te(s, "title", r.a = l), u !== r.o && te(s, "aria-label", r.o = u), r;
725
- }, {
726
- e: void 0,
727
- t: void 0,
728
- a: void 0,
729
- o: void 0
730
- }), s;
731
- })();
732
- };
733
- ne(["click"]);
734
- var Ht = /* @__PURE__ */ _("<div><div></div><div><div><span style=color:#78716c>[=]</span>Devtools</div><button>Clear</button></div><div><div><div>Batchers</div></div><div><div><button>Timeline</button><button>Events</button><button>Stats</button><button>Trace</button></div><div>");
735
- const Be = "batchkit-devtools", Pt = 650, Gt = 350, ye = 200, Se = 1200, Xt = "0.2s";
736
- function Ie() {
737
- try {
738
- const i = localStorage.getItem(Be);
739
- return i ? JSON.parse(i) : {};
740
- } catch {
741
- return {};
742
- }
743
- }
744
- function $e(i) {
745
- try {
746
- const e = Ie();
747
- localStorage.setItem(Be, JSON.stringify({
748
- ...e,
749
- ...i
750
- }));
751
- } catch {
752
- }
753
- }
754
- function Wt(i, e, s) {
755
- const r = {
756
- position: "fixed",
757
- background: "#0c0a09",
758
- "border-color": "#44403c",
759
- "border-style": "solid",
760
- "border-width": "0",
761
- display: "flex",
762
- "flex-direction": "column",
763
- overflow: "hidden",
764
- "z-index": "99998",
765
- "font-family": "ui-monospace, monospace",
766
- color: "#d6d3d1",
767
- transition: s ? "none" : `transform ${Xt} ease-out`,
768
- "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
769
- };
770
- switch (i) {
771
- case "right":
772
- return {
773
- ...r,
774
- top: "0",
775
- right: "0",
776
- width: `${e}px`,
777
- height: "100vh",
778
- "border-left-width": "1px"
779
- };
780
- case "left":
781
- return {
782
- ...r,
783
- top: "0",
784
- left: "0",
785
- width: `${e}px`,
786
- height: "100vh",
787
- "border-right-width": "1px"
788
- };
789
- case "bottom":
790
- return {
791
- ...r,
792
- bottom: "0",
793
- left: "0",
794
- right: "0",
795
- width: "100%",
796
- height: `${e}px`,
797
- "border-top-width": "1px"
798
- };
799
- }
800
- }
801
- function Yt(i) {
802
- const e = {
803
- position: "absolute",
804
- background: "transparent",
805
- "z-index": "99999"
806
- };
807
- switch (i) {
808
- case "right":
809
- return {
810
- ...e,
811
- left: "0",
812
- top: "0",
813
- bottom: "0",
814
- width: "6px",
815
- cursor: "ew-resize"
816
- };
817
- case "left":
818
- return {
819
- ...e,
820
- right: "0",
821
- top: "0",
822
- bottom: "0",
823
- width: "6px",
824
- cursor: "ew-resize"
825
- };
826
- case "bottom":
827
- return {
828
- ...e,
829
- top: "0",
830
- left: "0",
831
- right: "0",
832
- height: "6px",
833
- cursor: "ns-resize"
834
- };
835
- }
836
- }
837
- function qt(i, e) {
838
- if (e) return "translate(0, 0)";
839
- switch (i) {
840
- case "right":
841
- return "translateX(100%)";
842
- case "left":
843
- return "translateX(-100%)";
844
- case "bottom":
845
- return "translateY(100%)";
846
- }
847
- }
848
- const Jt = {
849
- display: "flex",
850
- "align-items": "center",
851
- "justify-content": "space-between",
852
- padding: "8px 12px",
853
- background: "#1c1917",
854
- "border-bottom": "1px solid #44403c",
855
- "flex-shrink": "0",
856
- "user-select": "none"
857
- }, Zt = {
858
- "font-size": "11px",
859
- "font-weight": "500",
860
- color: "#a8a29e",
861
- display: "flex",
862
- "align-items": "center",
863
- gap: "8px",
864
- "text-transform": "uppercase",
865
- "letter-spacing": "0.5px"
866
- }, Qt = {
867
- padding: "4px 8px",
868
- border: "1px solid #44403c",
869
- background: "#1c1917",
870
- color: "#78716c",
871
- "font-size": "11px",
872
- "font-family": "ui-monospace, monospace",
873
- cursor: "pointer"
874
- }, Vt = {
875
- display: "flex",
876
- flex: "1",
877
- "min-height": "0"
878
- }, en = {
879
- width: "160px",
880
- "border-right": "1px solid #44403c",
881
- display: "flex",
882
- "flex-direction": "column",
883
- background: "#0c0a09",
884
- "flex-shrink": "0",
885
- "user-select": "none"
886
- }, tn = {
887
- padding: "8px 12px",
888
- "font-size": "11px",
889
- "font-weight": "500",
890
- "text-transform": "uppercase",
891
- "letter-spacing": "0.5px",
892
- color: "#78716c",
893
- "border-bottom": "1px solid #292524"
894
- }, nn = {
895
- flex: "1",
896
- display: "flex",
897
- "flex-direction": "column",
898
- "min-width": "0"
899
- }, rn = {
900
- display: "flex",
901
- "border-bottom": "1px solid #44403c",
902
- background: "#1c1917",
903
- "flex-shrink": "0",
904
- "user-select": "none"
905
- }, q = {
906
- padding: "8px 12px",
907
- "font-size": "11px",
908
- "font-weight": "500",
909
- color: "#78716c",
910
- cursor: "pointer",
911
- "border-bottom": "1px solid transparent",
912
- "margin-bottom": "-1px",
913
- background: "transparent",
914
- border: "none",
915
- "font-family": "ui-monospace, monospace"
916
- }, ee = {
917
- ...q,
918
- color: "#f5f5f4",
919
- "border-bottom": "1px solid #f5f5f4"
920
- }, on = {
921
- flex: "1",
922
- overflow: "auto",
923
- padding: "12px",
924
- background: "#0c0a09"
925
- }, sn = (i) => {
926
- const e = ke(), [s, r] = J("timeline"), [t, n] = J(!1), l = () => i.position ?? "right", u = () => l() === "bottom", v = () => u() ? Gt : Pt, [f, h] = J(v());
927
- Le(() => {
928
- const x = Ie();
929
- x.isOpen !== void 0 ? x.isOpen && Y().open() : i.defaultOpen && Y().open();
930
- const w = u() ? x.height : x.width;
931
- w && w >= ye && w <= Se && h(w);
932
- });
933
- const b = () => {
934
- Y().toggle(), $e({
935
- isOpen: !e().isOpen
936
- });
937
- }, y = (x) => {
938
- x.preventDefault(), n(!0);
939
- const w = u() ? x.clientY : x.clientX, E = f(), I = l(), D = (c) => {
940
- const P = u() ? c.clientY : c.clientX;
941
- let A = w - P;
942
- I === "left" && (A = -A), I === "bottom" && (A = A);
943
- const j = Math.min(Se, Math.max(ye, E + A));
944
- h(j);
945
- }, R = () => {
946
- n(!1), document.removeEventListener("mousemove", D), document.removeEventListener("mouseup", R), document.body.style.cursor = "", document.body.style.userSelect = "", $e(u() ? {
947
- height: f()
948
- } : {
949
- width: f()
950
- });
951
- };
952
- document.addEventListener("mousemove", D), document.addEventListener("mouseup", R), document.body.style.cursor = u() ? "ns-resize" : "ew-resize", document.body.style.userSelect = "none";
953
- }, a = () => {
954
- Y().clear();
955
- }, p = () => e().selectedBatcher, d = () => e().batchers, C = () => e().events, T = () => e().batches, $ = () => {
956
- const x = p();
957
- return x ? d().get(x) ?? null : null;
958
- }, S = () => {
959
- const x = p();
960
- return x ? C().filter((w) => w.batcherName === x) : C();
961
- }, O = () => {
962
- const x = p();
963
- return x ? Array.from(T().values()).filter((w) => w.batcherName === x) : Array.from(T().values());
964
- }, Z = () => ({
965
- ...Wt(l(), f(), t()),
966
- transform: qt(l(), e().isOpen),
967
- ...i.panelStyle
968
- });
969
- return [k(Kt, {
970
- get isOpen() {
971
- return e().isOpen;
972
- },
973
- onClick: b,
974
- get style() {
975
- return i.buttonStyle;
976
- },
977
- get class() {
978
- return i.buttonClass;
979
- }
980
- }), (() => {
981
- var x = Ht(), w = x.firstChild, E = w.nextSibling, I = E.firstChild;
982
- I.firstChild;
983
- var D = I.nextSibling, R = E.nextSibling, c = R.firstChild, P = c.firstChild, A = c.nextSibling, j = A.firstChild, G = j.firstChild, X = G.nextSibling, W = X.nextSibling, Q = W.nextSibling, M = j.nextSibling;
984
- return w.$$mouseout = (m) => m.currentTarget.style.background = "transparent", w.$$mouseover = (m) => m.currentTarget.style.background = "#44403c", w.$$mousedown = y, o(E, Jt), o(I, Zt), D.$$click = a, o(D, Qt), o(R, Vt), o(c, en), o(P, tn), g(c, k(et, {
985
- get batchers() {
986
- return d();
987
- },
988
- get events() {
989
- return C();
990
- },
991
- get selectedBatcher() {
992
- return p();
993
- },
994
- onSelect: Pe
995
- }), null), o(A, nn), o(j, rn), G.$$click = () => r("timeline"), X.$$click = () => r("events"), W.$$click = () => r("stats"), Q.$$click = () => r("trace"), o(M, on), g(M, (() => {
996
- var m = N(() => s() === "timeline");
997
- return () => m() && k(ut, {
998
- get batches() {
999
- return O();
1000
- }
1001
- });
1002
- })(), null), g(M, (() => {
1003
- var m = N(() => s() === "events");
1004
- return () => m() && k($t, {
1005
- get events() {
1006
- return S();
1007
- }
1008
- });
1009
- })(), null), g(M, (() => {
1010
- var m = N(() => s() === "stats");
1011
- return () => m() && k(kt, {
1012
- get events() {
1013
- return S();
1014
- },
1015
- get batches() {
1016
- return O();
1017
- }
1018
- });
1019
- })(), null), g(M, (() => {
1020
- var m = N(() => s() === "trace");
1021
- return () => m() && k(Nt, {
1022
- get batcher() {
1023
- return $();
1024
- }
1025
- });
1026
- })(), null), B((m) => {
1027
- var V = i.panelClass, re = Z(), oe = Yt(l()), ie = s() === "timeline" ? ee : q, se = s() === "events" ? ee : q, le = s() === "stats" ? ee : q, ce = s() === "trace" ? ee : q;
1028
- return V !== m.e && we(x, m.e = V), m.t = o(x, re, m.t), m.a = o(w, oe, m.a), m.o = o(G, ie, m.o), m.i = o(X, se, m.i), m.n = o(W, le, m.n), m.s = o(Q, ce, m.s), m;
1029
- }, {
1030
- e: void 0,
1031
- t: void 0,
1032
- a: void 0,
1033
- o: void 0,
1034
- i: void 0,
1035
- n: void 0,
1036
- s: void 0
1037
- }), x;
1038
- })()];
1039
- };
1040
- ne(["mousedown", "mouseover", "mouseout", "click"]);
1041
- function dn(i, e) {
1042
- if (typeof window > "u")
1043
- return () => {
1044
- };
1045
- He(), (e != null && e.projectRoot || e != null && e.editor) && Ge({
1046
- projectRoot: e.projectRoot,
1047
- editor: e.editor
1048
- });
1049
- const s = {
1050
- position: e == null ? void 0 : e.position,
1051
- defaultOpen: e == null ? void 0 : e.defaultOpen,
1052
- buttonStyle: e == null ? void 0 : e.buttonStyle,
1053
- buttonClass: e == null ? void 0 : e.buttonClass,
1054
- panelStyle: e == null ? void 0 : e.panelStyle,
1055
- panelClass: e == null ? void 0 : e.panelClass
1056
- };
1057
- return je(() => sn(s), i);
1058
- }
1059
- export {
1060
- Ge as c,
1061
- Y as g,
1062
- He as i,
1063
- dn as m,
1064
- ke as u
1065
- };