batchkit-devtools 0.3.5 → 0.3.6

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