batchkit-devtools 0.3.5 → 0.3.7

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.
@@ -0,0 +1,1065 @@
1
+ import { delegateEvents as ne, template as _, style as o, insert as g, createComponent as k, effect as B, memo as L, setAttribute as te, setStyleProperty as ge, addEventListener as Re, className as _e, render as De } from "solid-js/web";
2
+ import { createRoot as je, createSignal as Z, createMemo as ke, For as de, Show as N, onMount as Me } from "solid-js";
3
+ import { __setDevtoolsHook as Ne } from "batchkit";
4
+ let Le = 0;
5
+ function Fe(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 Ue() {
21
+ const [i, e] = Z({
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 y = {
46
+ batchId: d.batchId,
47
+ batcherName: a,
48
+ keys: [],
49
+ status: "scheduled",
50
+ scheduledAt: d.timestamp
51
+ };
52
+ $.set(d.batchId, y);
53
+ }
54
+ if (d.type === "dispatch") {
55
+ const y = $.get(d.batchId);
56
+ y && $.set(d.batchId, {
57
+ ...y,
58
+ keys: d.keys,
59
+ status: "dispatching",
60
+ dispatchedAt: d.timestamp
61
+ });
62
+ }
63
+ if (d.type === "resolve") {
64
+ const y = $.get(d.batchId);
65
+ y && $.set(d.batchId, {
66
+ ...y,
67
+ status: "resolved",
68
+ completedAt: d.timestamp,
69
+ duration: d.duration
70
+ });
71
+ }
72
+ if (d.type === "error") {
73
+ const y = $.get(d.batchId);
74
+ y && $.set(d.batchId, {
75
+ ...y,
76
+ status: "error",
77
+ completedAt: d.timestamp,
78
+ error: d.error
79
+ });
80
+ }
81
+ if (d.type === "abort") {
82
+ const y = $.get(d.batchId);
83
+ y && $.set(d.batchId, {
84
+ ...y,
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 f() {
99
+ e((a) => ({
100
+ ...a,
101
+ events: [],
102
+ batches: /* @__PURE__ */ new Map()
103
+ })), r();
104
+ }
105
+ function v() {
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-${++Le}`, $ = a.toString().slice(0, 500), y = Fe(d);
117
+ return t({
118
+ name: T,
119
+ registeredAt: performance.now(),
120
+ isUnnamed: C,
121
+ fnSource: $,
122
+ location: y
123
+ }), (E) => {
124
+ n(T, E);
125
+ };
126
+ }
127
+ }), {
128
+ subscribe: l,
129
+ getStore: u,
130
+ clear: f,
131
+ open: v,
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 = je(() => Ue())), 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 Ce() {
152
+ const i = Y();
153
+ if (i._store)
154
+ return i._store;
155
+ const [e, s] = Z(i.getStore());
156
+ return i.subscribe(s), e;
157
+ }
158
+ function Ke(i) {
159
+ var e;
160
+ z && ((e = z._setStore) == null || e.call(z, (s) => ({
161
+ ...s,
162
+ selectedBatcher: i
163
+ })));
164
+ }
165
+ function Pe(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>"), Ge = /* @__PURE__ */ _("<div><div></div><div><span> gets</span><span> batches"), We = /* @__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 Ye = {
174
+ flex: "1",
175
+ "overflow-y": "auto"
176
+ }, ze = {
177
+ padding: "8px 12px",
178
+ cursor: "pointer",
179
+ "border-bottom": "1px solid #292524",
180
+ "border-left": "2px solid transparent"
181
+ }, qe = {
182
+ ...ze,
183
+ background: "#1c1917",
184
+ "border-left-color": "#a8a29e"
185
+ }, Te = {
186
+ "font-size": "13px",
187
+ color: "#d6d3d1",
188
+ "margin-bottom": "2px"
189
+ }, Ze = {
190
+ ...Te,
191
+ color: "#78716c",
192
+ "font-style": "italic"
193
+ }, Je = {
194
+ "font-size": "11px",
195
+ color: "#78716c"
196
+ }, me = {
197
+ display: "inline-flex",
198
+ "align-items": "center",
199
+ gap: "4px",
200
+ "margin-right": "8px"
201
+ }, Qe = {
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
+ }, Ve = (i) => {
211
+ const e = ke(() => Array.from(i.batchers.values())), s = (t) => {
212
+ const n = i.events.filter((f) => f.batcherName === t), l = n.filter((f) => f.type === "get").length, u = n.filter((f) => f.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, Ye), 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 f = Ge(), v = f.firstChild, h = v.nextSibling, b = h.firstChild, x = b.firstChild, a = b.nextSibling, p = a.firstChild;
230
+ return f.$$click = () => r(n.name), g(v, () => n.name), o(h, Je), g(b, () => l().gets, x), g(a, () => l().batches, p), B((d) => {
231
+ var C = u() ? qe : ze, T = n.isUnnamed ? Ze : Te, $ = me, y = me;
232
+ return d.e = o(f, C, d.e), d.t = o(v, T, d.t), d.a = o(b, $, d.a), d.o = o(a, y, d.o), d;
233
+ }, {
234
+ e: void 0,
235
+ t: void 0,
236
+ a: void 0,
237
+ o: void 0
238
+ }), f;
239
+ })();
240
+ }
241
+ }), null), g(t, (() => {
242
+ var n = L(() => e().length === 0);
243
+ return () => n() && (() => {
244
+ var l = We(), u = l.firstChild;
245
+ return u.nextSibling, o(l, Qe), l;
246
+ })();
247
+ })(), null), t;
248
+ })();
249
+ };
250
+ ne(["click"]);
251
+ var et = /* @__PURE__ */ _("<div>"), tt = /* @__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"), nt = /* @__PURE__ */ _("<div><div></div><div></div><div></div><div>");
252
+ const rt = {
253
+ display: "flex",
254
+ "flex-direction": "column",
255
+ gap: "1px"
256
+ }, ot = {
257
+ display: "flex",
258
+ "align-items": "center",
259
+ gap: "12px",
260
+ padding: "6px 8px",
261
+ background: "#1c1917",
262
+ "font-size": "11px"
263
+ }, it = {
264
+ "font-size": "11px",
265
+ color: "#78716c",
266
+ "min-width": "80px"
267
+ }, K = {
268
+ padding: "2px 6px",
269
+ "font-size": "10px",
270
+ "font-weight": "500",
271
+ "text-transform": "uppercase",
272
+ "letter-spacing": "0.3px"
273
+ }, st = {
274
+ scheduled: {
275
+ ...K,
276
+ background: "#422006",
277
+ color: "#fbbf24"
278
+ },
279
+ dispatching: {
280
+ ...K,
281
+ background: "#1e3a5f",
282
+ color: "#60a5fa"
283
+ },
284
+ resolved: {
285
+ ...K,
286
+ background: "#14532d",
287
+ color: "#4ade80"
288
+ },
289
+ error: {
290
+ ...K,
291
+ background: "#450a0a",
292
+ color: "#f87171"
293
+ },
294
+ aborted: {
295
+ ...K,
296
+ background: "#292524",
297
+ color: "#a8a29e"
298
+ }
299
+ }, lt = {
300
+ flex: "1",
301
+ "font-size": "11px",
302
+ color: "#a8a29e",
303
+ "white-space": "nowrap",
304
+ overflow: "hidden",
305
+ "text-overflow": "ellipsis"
306
+ }, ct = {
307
+ "font-size": "11px",
308
+ color: "#57534e",
309
+ "min-width": "50px",
310
+ "text-align": "right"
311
+ }, at = {
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
+ }, dt = (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 = et();
328
+ return o(t, rt), g(t, k(N, {
329
+ get when() {
330
+ return r().length > 0;
331
+ },
332
+ get fallback() {
333
+ return (() => {
334
+ var n = tt(), l = n.firstChild;
335
+ return l.nextSibling, o(n, at), n;
336
+ })();
337
+ },
338
+ get children() {
339
+ return k(de, {
340
+ get each() {
341
+ return r();
342
+ },
343
+ children: (n) => (() => {
344
+ var l = nt(), u = l.firstChild, f = u.nextSibling, v = f.nextSibling, h = v.nextSibling;
345
+ return o(l, ot), o(u, it), g(u, () => n.batchId), g(f, () => n.status), o(v, lt), g(v, () => s(n.keys)), o(h, ct), g(h, () => e(n.duration)), B((b) => {
346
+ var x = st[n.status] || K, a = n.keys.map(String).join(", ");
347
+ return b.e = o(f, x, b.e), a !== b.t && te(v, "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 ut = /* @__PURE__ */ _("<div>"), ft = /* @__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"), vt = /* @__PURE__ */ _("<div><span></span><span></span><span>");
359
+ const ht = {
360
+ display: "flex",
361
+ "flex-direction": "column",
362
+ gap: "1px",
363
+ "font-size": "11px"
364
+ }, gt = {
365
+ display: "flex",
366
+ gap: "12px",
367
+ padding: "4px 8px",
368
+ background: "#1c1917"
369
+ }, mt = {
370
+ color: "#57534e",
371
+ "min-width": "60px"
372
+ }, bt = {
373
+ "min-width": "60px",
374
+ "font-weight": "500"
375
+ }, pt = {
376
+ get: "#60a5fa",
377
+ dedup: "#c084fc",
378
+ schedule: "#fbbf24",
379
+ dispatch: "#22d3ee",
380
+ resolve: "#4ade80",
381
+ error: "#f87171",
382
+ abort: "#a8a29e"
383
+ }, xt = {
384
+ color: "#78716c",
385
+ flex: "1",
386
+ "white-space": "nowrap",
387
+ overflow: "hidden",
388
+ "text-overflow": "ellipsis"
389
+ }, yt = {
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
+ }, St = (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 = ut();
421
+ return o(t, ht), g(t, k(N, {
422
+ get when() {
423
+ return r().length > 0;
424
+ },
425
+ get fallback() {
426
+ return (() => {
427
+ var n = ft(), l = n.firstChild;
428
+ return l.nextSibling, o(n, yt), n;
429
+ })();
430
+ },
431
+ get children() {
432
+ return k(de, {
433
+ get each() {
434
+ return r();
435
+ },
436
+ children: (n) => (() => {
437
+ var l = vt(), u = l.firstChild, f = u.nextSibling, v = f.nextSibling;
438
+ return o(l, gt), o(u, mt), g(u, () => e(n.timestamp)), g(f, () => n.type), o(v, xt), g(v, () => s(n)), B((h) => o(f, {
439
+ ...bt,
440
+ color: pt[n.type]
441
+ }, h)), l;
442
+ })()
443
+ });
444
+ }
445
+ })), t;
446
+ })();
447
+ };
448
+ var $t = /* @__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 wt = {
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
+ }, H = {
464
+ "font-size": "20px",
465
+ "font-weight": "500",
466
+ color: "#f5f5f4"
467
+ }, be = {
468
+ "font-size": "11px",
469
+ color: "#57534e",
470
+ "margin-left": "2px"
471
+ }, _t = (i) => {
472
+ const e = ke(() => {
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, f = u > 0 ? l.reduce((a, p) => a + p.keys.length, 0) / u : 0, v = 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, x = t > 0 ? n / t * 100 : 0;
474
+ return {
475
+ totalGets: t,
476
+ totalBatches: u,
477
+ dedupedKeys: n,
478
+ avgBatchSize: f,
479
+ avgDuration: v,
480
+ errors: h,
481
+ aborts: b,
482
+ dedupRate: x
483
+ };
484
+ });
485
+ return (() => {
486
+ var s = $t(), r = s.firstChild, t = r.firstChild, n = t.nextSibling, l = r.nextSibling, u = l.firstChild, f = u.nextSibling, v = l.nextSibling, h = v.firstChild, b = h.nextSibling, x = b.firstChild, a = x.firstChild, p = a.nextSibling;
487
+ p.nextSibling;
488
+ var d = v.nextSibling, C = d.firstChild, T = C.nextSibling, $ = d.nextSibling, y = $.firstChild, E = y.nextSibling, J = E.firstChild, S = $.nextSibling, w = S.firstChild, O = w.nextSibling, I = O.firstChild, D = I.nextSibling, R = D.nextSibling;
489
+ return o(s, wt), g(n, () => e().totalGets), g(f, () => e().totalBatches), g(b, () => e().dedupedKeys, x), g(x, () => e().dedupRate.toFixed(0), p), g(T, () => e().avgBatchSize.toFixed(1)), g(E, () => e().avgDuration.toFixed(0), J), g(I, () => e().errors), g(R, () => e().aborts), B((c) => {
490
+ var P = F, A = U, j = H, X = F, G = U, W = H, Q = F, M = U, m = H, V = be, re = F, oe = U, ie = H, se = F, le = U, ce = H, Ie = be, Ae = F, Ee = U, Oe = H, ve = e().errors > 0 ? "#f87171" : "#f5f5f4", he = 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, X, c.o), c.i = o(u, G, c.i), c.n = o(f, W, c.n), c.s = o(v, Q, c.s), c.h = o(h, M, c.h), c.r = o(b, m, c.r), c.d = o(x, 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(y, le, c.m), c.f = o(E, ce, c.f), c.y = o(J, Ie, c.y), c.g = o(S, Ae, c.g), c.p = o(w, Ee, c.p), c.b = o(O, Oe, c.b), ve !== c.T && ge(I, "color", c.T = ve), he !== c.A && ge(R, "color", c.A = he), 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>"), kt = /* @__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"), Ct = /* @__PURE__ */ _("<div><div>Function</div><div>"), zt = /* @__PURE__ */ _('<div style="height:auto;padding:24px 0"><div style=font-size:11px;color:#57534e>No trace metadata available'), Tt = /* @__PURE__ */ _("<span style=color:#78716c;font-weight:normal;font-style:italic> (unnamed)"), Bt = /* @__PURE__ */ _("<div><div>Location"), It = /* @__PURE__ */ _("<a> ↗");
519
+ function At(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 = At(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", f = {
548
+ vscode: "vscode://file",
549
+ cursor: "cursor://file",
550
+ webstorm: "webstorm://open?file=",
551
+ idea: "idea://open?file="
552
+ }[l];
553
+ if (!f) return null;
554
+ if (l === "webstorm" || l === "idea") {
555
+ let h = `${f}${encodeURIComponent(r)}`;
556
+ return t !== void 0 && (h += `&line=${t}`, n !== void 0 && (h += `&column=${n}`)), h;
557
+ }
558
+ let v = `${f}${r}`;
559
+ return t !== void 0 && (v += `:${t}`, n !== void 0 && (v += `:${n}`)), v;
560
+ }
561
+ const Ot = {
562
+ padding: "12px",
563
+ height: "100%",
564
+ "overflow-y": "auto"
565
+ }, pe = {
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
+ }, xe = {
574
+ "margin-bottom": "16px"
575
+ }, ye = {
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
+ }, Rt = {
588
+ ...ue,
589
+ display: "block",
590
+ color: "#93c5fd",
591
+ "text-decoration": "none",
592
+ cursor: "pointer"
593
+ }, Dt = {
594
+ "text-decoration": "underline"
595
+ }, jt = {
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
+ }, Mt = {
603
+ "font-size": "14px",
604
+ "font-weight": "600",
605
+ color: "#f5f5f4",
606
+ "margin-bottom": "16px"
607
+ }, Nt = (i) => {
608
+ const e = Ce(), s = () => e().config;
609
+ return (() => {
610
+ var r = ae();
611
+ return o(r, Ot), g(r, k(N, {
612
+ get when() {
613
+ return i.batcher;
614
+ },
615
+ get fallback() {
616
+ return (() => {
617
+ var t = kt(), n = t.firstChild;
618
+ return n.nextSibling, B((l) => o(t, pe, l)), t;
619
+ })();
620
+ },
621
+ children: (t) => [(() => {
622
+ var n = ae();
623
+ return o(n, Mt), g(n, () => t().name, null), g(n, (() => {
624
+ var l = L(() => !!t().isUnnamed);
625
+ return () => l() && Tt();
626
+ })(), null), n;
627
+ })(), k(N, {
628
+ get when() {
629
+ return t().location;
630
+ },
631
+ children: (n) => {
632
+ const l = () => Et(n(), s());
633
+ return (() => {
634
+ var u = Bt(), f = u.firstChild;
635
+ return g(u, k(N, {
636
+ get when() {
637
+ return l();
638
+ },
639
+ get fallback() {
640
+ return (() => {
641
+ var v = ae();
642
+ return g(v, n), B((h) => o(v, ue, h)), v;
643
+ })();
644
+ },
645
+ children: (v) => (() => {
646
+ var h = It(), b = h.firstChild;
647
+ return h.$$mouseout = (x) => x.currentTarget.style.textDecoration = "none", h.$$mouseover = (x) => Object.assign(x.currentTarget.style, Dt), g(h, n, b), B((x) => {
648
+ var a = v(), p = Rt;
649
+ return a !== x.e && te(h, "href", x.e = a), x.t = o(h, p, x.t), x;
650
+ }, {
651
+ e: void 0,
652
+ t: void 0
653
+ }), h;
654
+ })()
655
+ }), null), B((v) => {
656
+ var h = xe, b = ye;
657
+ return v.e = o(u, h, v.e), v.t = o(f, b, v.t), v;
658
+ }, {
659
+ e: void 0,
660
+ t: void 0
661
+ }), u;
662
+ })();
663
+ }
664
+ }), k(N, {
665
+ get when() {
666
+ return t().fnSource;
667
+ },
668
+ get children() {
669
+ var n = Ct(), l = n.firstChild, u = l.nextSibling;
670
+ return g(u, () => t().fnSource), B((f) => {
671
+ var v = xe, h = ye, b = jt;
672
+ return f.e = o(n, v, f.e), f.t = o(l, h, f.t), f.a = o(u, b, f.a), f;
673
+ }, {
674
+ e: void 0,
675
+ t: void 0,
676
+ a: void 0
677
+ }), n;
678
+ }
679
+ }), k(N, {
680
+ get when() {
681
+ return L(() => !t().location)() && !t().fnSource;
682
+ },
683
+ get children() {
684
+ var n = zt();
685
+ return n.firstChild, B((l) => o(n, {
686
+ ...pe
687
+ }, l)), n;
688
+ }
689
+ })]
690
+ })), r;
691
+ })();
692
+ };
693
+ ne(["mouseover", "mouseout"]);
694
+ var Lt = /* @__PURE__ */ _("<button>");
695
+ const Be = {
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
+ }, Ft = {
711
+ ...Be,
712
+ background: "#292524",
713
+ color: "#f5f5f4",
714
+ "border-color": "#57534e"
715
+ }, Ut = (i) => {
716
+ const e = () => ({
717
+ ...i.isOpen ? Ft : Be,
718
+ ...i.style
719
+ });
720
+ return (() => {
721
+ var s = Lt();
722
+ return Re(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 && _e(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 fe = "__batchkit_devtools_", Kt = 650, Pt = 350, Se = 200, $e = 1200, Xt = "0.2s";
736
+ function Gt(i) {
737
+ try {
738
+ const e = localStorage.getItem(fe + i);
739
+ return e === null ? void 0 : e === "true";
740
+ } catch {
741
+ return;
742
+ }
743
+ }
744
+ function Wt(i) {
745
+ try {
746
+ const e = localStorage.getItem(fe + i);
747
+ if (e === null) return;
748
+ const s = parseInt(e, 10);
749
+ return isNaN(s) ? void 0 : s;
750
+ } catch {
751
+ return;
752
+ }
753
+ }
754
+ function we(i, e) {
755
+ try {
756
+ localStorage.setItem(fe + i, String(e));
757
+ } catch {
758
+ }
759
+ }
760
+ function Yt(i, e, s) {
761
+ const r = {
762
+ position: "fixed",
763
+ background: "#0c0a09",
764
+ "border-color": "#44403c",
765
+ "border-style": "solid",
766
+ "border-width": "0",
767
+ display: "flex",
768
+ "flex-direction": "column",
769
+ overflow: "hidden",
770
+ "z-index": "99998",
771
+ "font-family": "ui-monospace, monospace",
772
+ color: "#d6d3d1",
773
+ transition: s ? "none" : `transform ${Xt} ease-out`,
774
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
775
+ };
776
+ switch (i) {
777
+ case "right":
778
+ return {
779
+ ...r,
780
+ top: "0",
781
+ right: "0",
782
+ width: `${e}px`,
783
+ height: "100vh",
784
+ "border-left-width": "1px"
785
+ };
786
+ case "left":
787
+ return {
788
+ ...r,
789
+ top: "0",
790
+ left: "0",
791
+ width: `${e}px`,
792
+ height: "100vh",
793
+ "border-right-width": "1px"
794
+ };
795
+ case "bottom":
796
+ return {
797
+ ...r,
798
+ bottom: "0",
799
+ left: "0",
800
+ right: "0",
801
+ width: "100%",
802
+ height: `${e}px`,
803
+ "border-top-width": "1px"
804
+ };
805
+ }
806
+ }
807
+ function qt(i) {
808
+ const e = {
809
+ position: "absolute",
810
+ background: "transparent",
811
+ "z-index": "99999"
812
+ };
813
+ switch (i) {
814
+ case "right":
815
+ return {
816
+ ...e,
817
+ left: "0",
818
+ top: "0",
819
+ bottom: "0",
820
+ width: "6px",
821
+ cursor: "ew-resize"
822
+ };
823
+ case "left":
824
+ return {
825
+ ...e,
826
+ right: "0",
827
+ top: "0",
828
+ bottom: "0",
829
+ width: "6px",
830
+ cursor: "ew-resize"
831
+ };
832
+ case "bottom":
833
+ return {
834
+ ...e,
835
+ top: "0",
836
+ left: "0",
837
+ right: "0",
838
+ height: "6px",
839
+ cursor: "ns-resize"
840
+ };
841
+ }
842
+ }
843
+ function Zt(i, e) {
844
+ if (e) return "translate(0, 0)";
845
+ switch (i) {
846
+ case "right":
847
+ return "translateX(100%)";
848
+ case "left":
849
+ return "translateX(-100%)";
850
+ case "bottom":
851
+ return "translateY(100%)";
852
+ }
853
+ }
854
+ const Jt = {
855
+ display: "flex",
856
+ "align-items": "center",
857
+ "justify-content": "space-between",
858
+ padding: "8px 12px",
859
+ background: "#1c1917",
860
+ "border-bottom": "1px solid #44403c",
861
+ "flex-shrink": "0",
862
+ "user-select": "none"
863
+ }, Qt = {
864
+ "font-size": "11px",
865
+ "font-weight": "500",
866
+ color: "#a8a29e",
867
+ display: "flex",
868
+ "align-items": "center",
869
+ gap: "8px",
870
+ "text-transform": "uppercase",
871
+ "letter-spacing": "0.5px"
872
+ }, Vt = {
873
+ padding: "4px 8px",
874
+ border: "1px solid #44403c",
875
+ background: "#1c1917",
876
+ color: "#78716c",
877
+ "font-size": "11px",
878
+ "font-family": "ui-monospace, monospace",
879
+ cursor: "pointer"
880
+ }, en = {
881
+ display: "flex",
882
+ flex: "1",
883
+ "min-height": "0"
884
+ }, tn = {
885
+ width: "160px",
886
+ "border-right": "1px solid #44403c",
887
+ display: "flex",
888
+ "flex-direction": "column",
889
+ background: "#0c0a09",
890
+ "flex-shrink": "0",
891
+ "user-select": "none"
892
+ }, nn = {
893
+ padding: "8px 12px",
894
+ "font-size": "11px",
895
+ "font-weight": "500",
896
+ "text-transform": "uppercase",
897
+ "letter-spacing": "0.5px",
898
+ color: "#78716c",
899
+ "border-bottom": "1px solid #292524"
900
+ }, rn = {
901
+ flex: "1",
902
+ display: "flex",
903
+ "flex-direction": "column",
904
+ "min-width": "0"
905
+ }, on = {
906
+ display: "flex",
907
+ "border-bottom": "1px solid #44403c",
908
+ background: "#1c1917",
909
+ "flex-shrink": "0",
910
+ "user-select": "none"
911
+ }, q = {
912
+ padding: "8px 12px",
913
+ "font-size": "11px",
914
+ "font-weight": "500",
915
+ color: "#78716c",
916
+ cursor: "pointer",
917
+ "border-bottom": "1px solid transparent",
918
+ "margin-bottom": "-1px",
919
+ background: "transparent",
920
+ border: "none",
921
+ "font-family": "ui-monospace, monospace"
922
+ }, ee = {
923
+ ...q,
924
+ color: "#f5f5f4",
925
+ "border-bottom": "1px solid #f5f5f4"
926
+ }, sn = {
927
+ flex: "1",
928
+ overflow: "auto",
929
+ padding: "12px",
930
+ background: "#0c0a09"
931
+ }, ln = (i) => {
932
+ const e = Ce(), [s, r] = Z("timeline"), [t, n] = Z(!1), l = () => i.position ?? "right", u = () => l() === "bottom", f = () => u() ? Pt : Kt, [v, h] = Z(f());
933
+ Me(() => {
934
+ const S = Gt("isOpen");
935
+ S !== void 0 ? S && Y().open() : i.defaultOpen && Y().open();
936
+ const w = Wt("panelSize");
937
+ w && w >= Se && w <= $e && h(w);
938
+ });
939
+ const b = () => {
940
+ Y().toggle(), we("isOpen", e().isOpen);
941
+ }, x = (S) => {
942
+ S.preventDefault(), n(!0);
943
+ const w = u() ? S.clientY : S.clientX, O = v(), I = l(), D = (c) => {
944
+ const P = u() ? c.clientY : c.clientX;
945
+ let A = w - P;
946
+ I === "left" && (A = -A), I === "bottom" && (A = A);
947
+ const j = Math.min($e, Math.max(Se, O + A));
948
+ h(j);
949
+ }, R = () => {
950
+ n(!1), document.removeEventListener("mousemove", D), document.removeEventListener("mouseup", R), document.body.style.cursor = "", document.body.style.userSelect = "", we("panelSize", v());
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 S = p();
957
+ return S ? d().get(S) ?? null : null;
958
+ }, y = () => {
959
+ const S = p();
960
+ return S ? C().filter((w) => w.batcherName === S) : C();
961
+ }, E = () => {
962
+ const S = p();
963
+ return S ? Array.from(T().values()).filter((w) => w.batcherName === S) : Array.from(T().values());
964
+ }, J = () => ({
965
+ ...Yt(l(), v(), t()),
966
+ transform: Zt(l(), e().isOpen),
967
+ ...i.panelStyle
968
+ });
969
+ return [k(Ut, {
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 S = Ht(), w = S.firstChild, O = w.nextSibling, I = O.firstChild;
982
+ I.firstChild;
983
+ var D = I.nextSibling, R = O.nextSibling, c = R.firstChild, P = c.firstChild, A = c.nextSibling, j = A.firstChild, X = j.firstChild, G = X.nextSibling, W = G.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 = x, o(O, Jt), o(I, Qt), D.$$click = a, o(D, Vt), o(R, en), o(c, tn), o(P, nn), g(c, k(Ve, {
985
+ get batchers() {
986
+ return d();
987
+ },
988
+ get events() {
989
+ return C();
990
+ },
991
+ get selectedBatcher() {
992
+ return p();
993
+ },
994
+ onSelect: Ke
995
+ }), null), o(A, rn), o(j, on), X.$$click = () => r("timeline"), G.$$click = () => r("events"), W.$$click = () => r("stats"), Q.$$click = () => r("trace"), o(M, sn), g(M, (() => {
996
+ var m = L(() => s() === "timeline");
997
+ return () => m() && k(dt, {
998
+ get batches() {
999
+ return E();
1000
+ }
1001
+ });
1002
+ })(), null), g(M, (() => {
1003
+ var m = L(() => s() === "events");
1004
+ return () => m() && k(St, {
1005
+ get events() {
1006
+ return y();
1007
+ }
1008
+ });
1009
+ })(), null), g(M, (() => {
1010
+ var m = L(() => s() === "stats");
1011
+ return () => m() && k(_t, {
1012
+ get events() {
1013
+ return y();
1014
+ },
1015
+ get batches() {
1016
+ return E();
1017
+ }
1018
+ });
1019
+ })(), null), g(M, (() => {
1020
+ var m = L(() => s() === "trace");
1021
+ return () => m() && k(Nt, {
1022
+ get batcher() {
1023
+ return $();
1024
+ }
1025
+ });
1026
+ })(), null), B((m) => {
1027
+ var V = i.panelClass, re = J(), oe = qt(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 && _e(S, m.e = V), m.t = o(S, re, m.t), m.a = o(w, oe, m.a), m.o = o(X, ie, m.o), m.i = o(G, 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
+ }), S;
1038
+ })()];
1039
+ };
1040
+ ne(["mousedown", "mouseover", "mouseout", "click"]);
1041
+ function un(i, e) {
1042
+ if (typeof window > "u")
1043
+ return () => {
1044
+ };
1045
+ He(), (e != null && e.projectRoot || e != null && e.editor) && Pe({
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 De(() => ln(s), i);
1058
+ }
1059
+ export {
1060
+ Pe as c,
1061
+ Y as g,
1062
+ He as i,
1063
+ un as m,
1064
+ Ce as u
1065
+ };