@voltro/devtools 0.84.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -89
  3. package/dist/Devtools.js +327 -0
  4. package/dist/capsuleClearance.js +42 -0
  5. package/dist/capsulePlacement.js +66 -0
  6. package/dist/components/boundary.js +47 -0
  7. package/dist/components/dockMenu.js +121 -0
  8. package/dist/components/icons.js +236 -0
  9. package/dist/components/primitives.js +75 -0
  10. package/dist/console/Capsule.js +169 -0
  11. package/dist/console/Console.js +508 -0
  12. package/dist/console/InspectRefusals.js +89 -0
  13. package/dist/console/searchIndex.js +63 -0
  14. package/dist/console/sources.js +106 -0
  15. package/dist/consoleBridge.js +76 -0
  16. package/dist/externalWindow.js +9 -0
  17. package/dist/index.js +3 -4382
  18. package/dist/inspectAuth.js +16 -0
  19. package/dist/inspectFetch.js +46 -0
  20. package/dist/inspectRefusal.js +45 -0
  21. package/dist/inspectStream.js +88 -0
  22. package/dist/logsBus.js +22 -0
  23. package/dist/panels/desktop.js +101 -0
  24. package/dist/panels/indexes.js +233 -0
  25. package/dist/panels/logs.js +55 -0
  26. package/dist/panels/mutations.js +81 -0
  27. package/dist/panels/pwa.js +171 -0
  28. package/dist/panels/routes.js +69 -0
  29. package/dist/panels/runtimes.js +67 -0
  30. package/dist/panels/stores.js +125 -0
  31. package/dist/panels/subscriptions.js +117 -0
  32. package/dist/panels/traces.js +160 -0
  33. package/dist/panels/webhooks.js +248 -0
  34. package/dist/panels/workflows.js +478 -0
  35. package/dist/pushPage.js +36 -0
  36. package/dist/shadowHost.js +77 -0
  37. package/dist/strings.js +332 -0
  38. package/dist/styles.css +20 -0
  39. package/dist/useCapsuleClearance.js +85 -0
  40. package/dist/useDevStatuses.js +6 -0
  41. package/dist/useDock.js +181 -0
  42. package/dist/useDocumentVisible.js +5 -0
  43. package/dist/useLiveCacheEntries.js +19 -0
  44. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,4382 +1,3 @@
1
- import { Component as e, createContext as t, useCallback as n, useContext as r, useEffect as i, useId as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l, useSyncExternalStore as u } from "react";
2
- import { addSink as d } from "@voltro/logger";
3
- import { getRouteSnapshot as f, getStatuses as p, subscribeConsoleCalls as m, subscribeRouteSnapshot as h, subscribeStatuses as g, useAppUpdate as _, useInstallPrompt as v, useOfflineStatus as y } from "@voltro/web";
4
- import { clearStoreHistory as b, definedStores as x, getMutations as S, readPairing as C, storeHistory as w, subscribeMutations as T, subscribeStoreHistory as ee, travelToStoreState as E, useConnectionStatus as D, useFrameworkRuntimes as O, usePlatform as k, useShellExtension as te, useWorkflow as A } from "@voltro/client";
5
- import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
6
- import { createPortal as ne } from "react-dom";
7
- //#region src/consoleBridge.ts
8
- var P = (e) => e === "warn" || e === "error", F = (e) => {
9
- if (typeof e == "string") return e;
10
- if (e instanceof Error) return `${e.name}: ${e.message}`;
11
- if (e === void 0) return "undefined";
12
- if (typeof e == "function") return `[function ${e.name || "anonymous"}]`;
13
- if (typeof e == "symbol" || typeof e == "bigint") return String(e);
14
- try {
15
- let t = JSON.stringify(e);
16
- return t === void 0 ? String(e) : t.length > 500 ? `${t.slice(0, 499)}…` : t;
17
- } catch {
18
- return String(e);
19
- }
20
- }, I = (e, t, n = /* @__PURE__ */ new Date()) => {
21
- let r = t.find((e) => e instanceof Error), i = {};
22
- return t.forEach((e, t) => {
23
- typeof e != "string" && !(e instanceof Error) && typeof e == "object" && e && (i[`arg${t}`] = e);
24
- }), {
25
- ts: n,
26
- level: e,
27
- scope: `console.${e}`,
28
- message: t.map(F).join(" "),
29
- fields: i,
30
- ...r === void 0 ? {} : { cause: r }
31
- };
32
- }, L = (e, t, n = /* @__PURE__ */ new Date()) => {
33
- let r = t instanceof Error ? t : void 0;
34
- return {
35
- ts: n,
36
- level: "error",
37
- scope: e,
38
- message: t instanceof Error ? `${t.name}: ${t.message}` : `${e === "window.error" ? "Uncaught" : "Unhandled rejection"}: ${F(t)}`,
39
- fields: {},
40
- ...r === void 0 ? {} : { cause: r }
41
- };
42
- }, R = Symbol.for("voltro.devtools.consoleBridge"), z = (e, t = m) => {
43
- let n = globalThis, r = n[R];
44
- if (r !== void 0) return r;
45
- let i = [], a = !1, o = () => {
46
- a = !1;
47
- let t = i;
48
- i = [];
49
- for (let n of t) n.claimed || e(n.record);
50
- }, s = (e) => {
51
- i.push({
52
- record: e,
53
- claimed: !1
54
- }), a || (a = !0, queueMicrotask(o));
55
- }, c = (e) => {
56
- if (e.message !== "") {
57
- for (let t of i) if (!t.claimed && t.record.level === e.level && t.record.message.includes(e.message)) {
58
- t.claimed = !0;
59
- break;
60
- }
61
- }
62
- }, l = t((e) => {
63
- if (P(e.level)) try {
64
- s(I(e.level, e.args, new Date(e.ts)));
65
- } catch {}
66
- }), u = (t) => {
67
- e(L("window.error", t.error ?? t.message));
68
- }, d = (t) => {
69
- e(L("unhandledrejection", t.reason));
70
- }, f = typeof window < "u";
71
- f && (window.addEventListener("error", u), window.addEventListener("unhandledrejection", d));
72
- let p = {
73
- noteLoggerRecord: c,
74
- dispose: () => {
75
- l(), f && (window.removeEventListener("error", u), window.removeEventListener("unhandledrejection", d)), delete n[R];
76
- }
77
- };
78
- return n[R] = p, p;
79
- }, B = 500, re = [], V = /* @__PURE__ */ new Set(), ie = [], ae = () => {
80
- ie = re.slice();
81
- }, oe = () => {
82
- ae();
83
- for (let e of V) try {
84
- e();
85
- } catch {}
86
- }, se = typeof window < "u" ? z(ce) : null;
87
- d((e) => {
88
- se?.noteLoggerRecord(e), ce(e);
89
- });
90
- function ce(e) {
91
- re.unshift(e), re.length > B && (re.length = B), oe();
92
- }
93
- var le = () => ie, ue = (e) => (V.add(e), () => {
94
- V.delete(e);
95
- }), H = (e) => ({ className: t }) => /* @__PURE__ */ M("svg", {
96
- viewBox: "0 0 24 24",
97
- fill: "none",
98
- stroke: "currentColor",
99
- strokeWidth: "1.6",
100
- strokeLinecap: "round",
101
- strokeLinejoin: "round",
102
- className: t ?? "vdt:w-4 vdt:h-4",
103
- "aria-hidden": "true",
104
- children: e
105
- }), de = ({ className: e }) => {
106
- let t = a(), n = `vdtBoltFront-${t}`, r = `vdtBoltBack-${t}`;
107
- return /* @__PURE__ */ N("svg", {
108
- viewBox: "0 0 48 48",
109
- fill: "none",
110
- className: e,
111
- "aria-hidden": "true",
112
- children: [
113
- /* @__PURE__ */ N("defs", { children: [/* @__PURE__ */ N("linearGradient", {
114
- id: n,
115
- x1: "13",
116
- y1: "5",
117
- x2: "33",
118
- y2: "43",
119
- gradientUnits: "userSpaceOnUse",
120
- children: [/* @__PURE__ */ M("stop", { stopColor: "#C4A6FF" }), /* @__PURE__ */ M("stop", {
121
- offset: "1",
122
- stopColor: "#9D5BFF"
123
- })]
124
- }), /* @__PURE__ */ N("linearGradient", {
125
- id: r,
126
- x1: "22",
127
- y1: "5",
128
- x2: "35",
129
- y2: "43",
130
- gradientUnits: "userSpaceOnUse",
131
- children: [/* @__PURE__ */ M("stop", { stopColor: "#9D5BFF" }), /* @__PURE__ */ M("stop", {
132
- offset: "1",
133
- stopColor: "#7C3AED"
134
- })]
135
- })] }),
136
- /* @__PURE__ */ M("path", {
137
- d: "M28 5 13 27 22 26 20 43Z",
138
- fill: `url(#${n})`
139
- }),
140
- /* @__PURE__ */ M("path", {
141
- d: "M28 5 20 43 35 21 26 22Z",
142
- fill: `url(#${r})`
143
- })
144
- ]
145
- });
146
- }, fe = H(/* @__PURE__ */ M("polyline", { points: "6 9 12 15 18 9" })), pe = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("line", {
147
- x1: "18",
148
- y1: "6",
149
- x2: "6",
150
- y2: "18"
151
- }), /* @__PURE__ */ M("line", {
152
- x1: "6",
153
- y1: "6",
154
- x2: "18",
155
- y2: "18"
156
- })] })), me = H(/* @__PURE__ */ M("polyline", { points: "22 12 18 12 15 21 9 3 6 12 2 12" })), he = H(/* @__PURE__ */ N(j, { children: [
157
- /* @__PURE__ */ M("ellipse", {
158
- cx: "12",
159
- cy: "5",
160
- rx: "9",
161
- ry: "3"
162
- }),
163
- /* @__PURE__ */ M("path", { d: "M3 5 v6 c0 1.66 4 3 9 3 s9 -1.34 9 -3 V5" }),
164
- /* @__PURE__ */ M("path", { d: "M3 11 v6 c0 1.66 4 3 9 3 s9 -1.34 9 -3 v-6" })
165
- ] })), ge = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("circle", {
166
- cx: "12",
167
- cy: "12",
168
- r: "10"
169
- }), /* @__PURE__ */ M("polygon", { points: "16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76" })] })), _e = H(/* @__PURE__ */ N(j, { children: [
170
- /* @__PURE__ */ M("path", { d: "M12 22 v-5" }),
171
- /* @__PURE__ */ M("path", { d: "M9 8 V2" }),
172
- /* @__PURE__ */ M("path", { d: "M15 8 V2" }),
173
- /* @__PURE__ */ M("path", { d: "M18 8 v4 a6 6 0 0 1 -12 0 V8 z" })
174
- ] })), ve = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("polyline", { points: "17 11 12 6 7 11" }), /* @__PURE__ */ M("polyline", { points: "17 17 12 22 7 17" })] })), ye = H(/* @__PURE__ */ N(j, { children: [
175
- /* @__PURE__ */ M("polyline", { points: "3 6 5 6 21 6" }),
176
- /* @__PURE__ */ M("path", { d: "M19 6 l-1 14 c-.05 1.1 -.96 2 -2 2 H8 c-1.04 0 -1.95 -.9 -2 -2 L5 6" }),
177
- /* @__PURE__ */ M("path", { d: "M10 11 v6" }),
178
- /* @__PURE__ */ M("path", { d: "M14 11 v6" })
179
- ] })), be = H(/* @__PURE__ */ N(j, { children: [
180
- /* @__PURE__ */ M("path", { d: "M18 16.98 h-5.99 c-1.1 0 -1.95 .94 -2.48 1.9 A4 4 0 0 1 2 17 c0 -1.42 .76 -2.66 1.9 -3.34" }),
181
- /* @__PURE__ */ M("path", { d: "M6 17 l3.13 -5.78 c.53 -.97 .43 -2.22 -.26 -3.07 A4 4 0 1 1 17 7" }),
182
- /* @__PURE__ */ M("path", { d: "M16 6.78 a4 4 0 1 1 5 6.31 c-.84 .6 -1.36 1.59 -1.36 2.61" })
183
- ] })), xe = H(/* @__PURE__ */ N(j, { children: [
184
- /* @__PURE__ */ M("rect", {
185
- x: "3",
186
- y: "3",
187
- width: "6",
188
- height: "6",
189
- rx: "1"
190
- }),
191
- /* @__PURE__ */ M("rect", {
192
- x: "15",
193
- y: "15",
194
- width: "6",
195
- height: "6",
196
- rx: "1"
197
- }),
198
- /* @__PURE__ */ M("path", { d: "M9 6h3a3 3 0 0 1 3 3v3" }),
199
- /* @__PURE__ */ M("path", { d: "M15 18h-3a3 3 0 0 1-3-3v-3" })
200
- ] })), Se = H(/* @__PURE__ */ N(j, { children: [
201
- /* @__PURE__ */ M("line", {
202
- x1: "6",
203
- y1: "3",
204
- x2: "6",
205
- y2: "15"
206
- }),
207
- /* @__PURE__ */ M("circle", {
208
- cx: "18",
209
- cy: "6",
210
- r: "3"
211
- }),
212
- /* @__PURE__ */ M("circle", {
213
- cx: "6",
214
- cy: "18",
215
- r: "3"
216
- }),
217
- /* @__PURE__ */ M("path", { d: "M18 9 a9 9 0 0 1 -9 9" })
218
- ] })), Ce = H(/* @__PURE__ */ M("path", { d: "m13 2-9 12h7l-1 8 10-12h-7l1-8z" })), we = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("circle", {
219
- cx: "11",
220
- cy: "11",
221
- r: "7"
222
- }), /* @__PURE__ */ M("path", { d: "m20 20-3.5-3.5" })] })), Te = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("path", { d: "M4 12h12M12 6l6 6-6 6" }), /* @__PURE__ */ M("path", { d: "M4 4v16" })] })), Ee = H(/* @__PURE__ */ N(j, { children: [
223
- /* @__PURE__ */ M("path", { d: "M4 6h16M4 12h10M4 18h6" }),
224
- /* @__PURE__ */ M("circle", {
225
- cx: "18",
226
- cy: "17",
227
- r: "3"
228
- }),
229
- /* @__PURE__ */ M("path", { d: "m20.5 19.5 2 2" })
230
- ] })), De = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("path", { d: "M5 4h14v16H5z" }), /* @__PURE__ */ M("path", { d: "M8 8h8M8 12h8M8 16h5" })] })), Oe = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
231
- x: "3",
232
- y: "4",
233
- width: "18",
234
- height: "12",
235
- rx: "2"
236
- }), /* @__PURE__ */ M("path", { d: "M8 20h8M12 16v4" })] })), ke = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
237
- x: "3",
238
- y: "4",
239
- width: "18",
240
- height: "16",
241
- rx: "2"
242
- }), /* @__PURE__ */ M("path", { d: "M3 14h18" })] })), Ae = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
243
- x: "3",
244
- y: "4",
245
- width: "18",
246
- height: "16",
247
- rx: "2"
248
- }), /* @__PURE__ */ M("path", { d: "M3 10h18" })] })), je = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
249
- x: "3",
250
- y: "4",
251
- width: "18",
252
- height: "16",
253
- rx: "2"
254
- }), /* @__PURE__ */ M("path", { d: "M9 4v16" })] })), Me = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
255
- x: "3",
256
- y: "4",
257
- width: "18",
258
- height: "16",
259
- rx: "2"
260
- }), /* @__PURE__ */ M("path", { d: "M15 4v16" })] })), Ne = H(/* @__PURE__ */ N(j, { children: [
261
- /* @__PURE__ */ M("path", { d: "M14 4h6v6" }),
262
- /* @__PURE__ */ M("path", { d: "M20 4l-8 8" }),
263
- /* @__PURE__ */ M("path", { d: "M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4" })
264
- ] })), Pe = H(/* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("rect", {
265
- x: "7",
266
- y: "8",
267
- width: "14",
268
- height: "12",
269
- rx: "2"
270
- }), /* @__PURE__ */ M("path", { d: "M3 14V6a2 2 0 0 1 2-2h8" })] })), Fe = H(/* @__PURE__ */ N(j, { children: [
271
- /* @__PURE__ */ M("circle", {
272
- cx: "9",
273
- cy: "6",
274
- r: "1",
275
- fill: "currentColor"
276
- }),
277
- /* @__PURE__ */ M("circle", {
278
- cx: "15",
279
- cy: "6",
280
- r: "1",
281
- fill: "currentColor"
282
- }),
283
- /* @__PURE__ */ M("circle", {
284
- cx: "9",
285
- cy: "12",
286
- r: "1",
287
- fill: "currentColor"
288
- }),
289
- /* @__PURE__ */ M("circle", {
290
- cx: "15",
291
- cy: "12",
292
- r: "1",
293
- fill: "currentColor"
294
- }),
295
- /* @__PURE__ */ M("circle", {
296
- cx: "9",
297
- cy: "18",
298
- r: "1",
299
- fill: "currentColor"
300
- }),
301
- /* @__PURE__ */ M("circle", {
302
- cx: "15",
303
- cy: "18",
304
- r: "1",
305
- fill: "currentColor"
306
- })
307
- ] })), Ie = ({ className: e }) => /* @__PURE__ */ N("svg", {
308
- viewBox: "0 0 24 24",
309
- fill: "none",
310
- className: e,
311
- "aria-hidden": "true",
312
- children: [/* @__PURE__ */ M("circle", {
313
- cx: "12",
314
- cy: "12",
315
- r: "9",
316
- stroke: "currentColor",
317
- strokeOpacity: "0.2",
318
- strokeWidth: "2.5"
319
- }), /* @__PURE__ */ M("path", {
320
- d: "M21 12 a9 9 0 0 0 -9 -9",
321
- stroke: "currentColor",
322
- strokeWidth: "2.5",
323
- strokeLinecap: "round"
324
- })]
325
- }), Le = {
326
- shell: {
327
- brand: "Voltro Devtools",
328
- brandWord: "Voltro",
329
- kicker: "Devtools",
330
- openLabel: "Open Voltro Devtools",
331
- openTitle: "Open Voltro Devtools (Alt+V) · drag to move",
332
- closeTitle: "Close (Alt+V)",
333
- searchPlaceholder: "Search subscriptions, mutations, actions, traces, logs…",
334
- searchLabel: "Search",
335
- dockMenuTitle: "Dock position",
336
- dockBottom: "Dock to bottom",
337
- dockTop: "Dock to top",
338
- dockLeft: "Dock to left",
339
- dockRight: "Dock to right",
340
- dockWindow: "Floating window",
341
- dockExternal: "Own browser window",
342
- externalBlocked: "The browser blocked the console window — allow pop-ups for this page, or click the capsule to try again.",
343
- pushPage: "Push the page",
344
- pushPageHint: "Lays the page out beside the console, dialogs included. 100vw and media queries still see the full window.",
345
- resizeLabel: "Resize",
346
- moveTitle: "Drag to move",
347
- scopeAll: "All",
348
- connected: "connected",
349
- recovering: "reconnecting",
350
- degraded: "degraded",
351
- offline: "offline",
352
- live: "live",
353
- pending: "pending",
354
- retainedSelection: "Saved selection — no longer in the recent feed. Select another entry to release it.",
355
- pendingInvocations: (e) => `Show pending calls (${e})`,
356
- emptyPending: "No pending calls.",
357
- emptyPendingHint: "All captured calls have settled. Turn off the pending filter to see their results.",
358
- failed: "failed",
359
- errorsWord: (e) => e === 1 ? "error" : "errors",
360
- warningsWord: (e) => e === 1 ? "warning" : "warnings",
361
- results: (e) => `${e} result${e === 1 ? "" : "s"}`,
362
- noResults: "Nothing matches.",
363
- noResultsHint: "Search matches names, inputs, messages and error text. Quote a phrase to match it whole.",
364
- emptyAll: "Nothing captured yet.",
365
- emptyAllHint: "Subscriptions, mutations, actions, traces and logs appear here as the app produces them.",
366
- emptySubscriptions: "No live subscriptions.",
367
- emptySubscriptionsHint: "Mount a `useSubscription` hook and its cache entry appears here.",
368
- emptyMutations: "No mutations yet.",
369
- emptyMutationsHint: "Every `useMutation` call lands here with its input, result and timing.",
370
- emptyActions: "No actions yet.",
371
- emptyActionsHint: "Every `useAction` call lands here with its input, result and timing.",
372
- emptyTraces: "No traces yet.",
373
- emptyTracesHint: "Spans arrive from the api while the console is open.",
374
- emptyLogs: "No log records yet.",
375
- emptyLogsHint: "Records from `@voltro/logger` in this page land here.",
376
- selectHint: "Select a row to see its detail.",
377
- hintNavigate: "navigate",
378
- hintOpen: "open",
379
- hintToggle: "toggle",
380
- hintDock: "dock",
381
- crashTitle: "The devtools overlay hit an error. The page is unaffected.",
382
- crashReset: "Reset overlay"
383
- },
384
- inspect: {
385
- refusedTitle: (e, t) => `The inspect surface of \`${e}\` refused the devtools (HTTP ${t}).`,
386
- unreachableTitle: (e) => `The inspect surface of \`${e}\` could not be read.`,
387
- unreachableHint: "The browser gave no status. An api on another origin looks exactly like this when it refuses the request — the browser hides the reason. The api answers a cross-origin read only for a page on `localhost`, so from a deployed host that path cannot work with or without a token. Read it through the web server instead: drop `apis.<name>.url` and point `VOLTRO_API_ORIGIN_<NAME>` at the api, so the overlay fetches `/_voltro/api/<name>` on this origin. The web server lends the api's credential only to its own machine, to a session signed in with `VOLTRO_DASHBOARD_TOKEN`, or to a client network listed in `VOLTRO_INSPECT_TRUSTED_CLIENTS` (behind the proxies in `VOLTRO_TRUSTED_PROXIES`).",
388
- fixLabel: "Fix:",
389
- paused: "Inspect reads for this api are paused until you reopen the console.",
390
- tokenLabel: "Devtools token (VOLTRO_DASHBOARD_TOKEN)",
391
- signIn: "Sign in",
392
- signInFailed: (e) => `Sign-in refused: ${e}`
393
- },
394
- tabs: {
395
- subscriptions: "Subs",
396
- mutations: "Mutations",
397
- actions: "Actions",
398
- stores: "Stores",
399
- indexes: "Indexes",
400
- webhooks: "Webhooks",
401
- traces: "Traces",
402
- routes: "Routes",
403
- runtimes: "Runtimes",
404
- logs: "Logs",
405
- workflows: "Workflows",
406
- pwa: "PWA",
407
- desktop: "Desktop"
408
- },
409
- pwa: {
410
- loading: "Reading the worker…",
411
- unsupported: "No service worker support in this browser — the PWA surface is off here.",
412
- refresh: "Refresh",
413
- worker: "Service worker",
414
- scope: "scope",
415
- script: "script",
416
- backgroundSync: "background sync",
417
- update: "Update",
418
- checkNow: "Check now",
419
- forceUpdate: "Force update",
420
- currentBuild: "current build",
421
- waitingBuild: "waiting build",
422
- online: "online",
423
- precache: "Caches",
424
- noCaches: "No voltro-* cache yet — the worker precaches at install.",
425
- entries: (e) => e === 1 ? "1 entry" : `${e} entries`,
426
- installAndPush: "Install + push",
427
- install: "Install",
428
- installed: "installed",
429
- installPrompt: "install prompt",
430
- pushPermission: "push permission",
431
- pushSubscription: "push subscription",
432
- yes: "yes",
433
- no: "no",
434
- none: "—",
435
- unknown: "?"
436
- },
437
- desktop: {
438
- notDesktop: "Not a desktop shell — this is a browser tab; the desktop surface is off here.",
439
- refresh: "Refresh",
440
- shell: "Shell",
441
- kind: "kind",
442
- os: "os",
443
- theme: "theme",
444
- window: "window",
445
- appVersion: "app version",
446
- updater: "Updater",
447
- updaterPort: "update channel",
448
- checkNow: "Check now",
449
- waitingVersion: "available version",
450
- localStack: "Local Stack",
451
- sidecarPort: "sidecar port",
452
- apiUrl: "api url",
453
- apiName: "api name",
454
- capabilities: "Capabilities",
455
- noCapabilities: "No capability reports true — the adapter fills in what the shell has.",
456
- yes: "yes",
457
- no: "no",
458
- none: "—",
459
- unknown: "?"
460
- },
461
- workflows: {
462
- noApi: "No api processes connected — workflows discover from `*.workflow.tsx`.",
463
- noDefinitions: "This api registers no workflows.",
464
- noRuns: "No runs yet — start one above, or call `useWorkflow()` from the page.",
465
- runsUnavailable: "The run list is unavailable — the api refused the workflow built-ins (check access or the api log).",
466
- runs: (e) => `Runs (${e})`,
467
- runsBadge: (e) => `${e} runs`,
468
- runningBadge: (e) => `${e} running`,
469
- child: "child",
470
- start: "Start",
471
- starting: "Starting…",
472
- workflowLabel: "Workflow",
473
- payloadLabel: "Payload (JSON)",
474
- payloadHint: "Prefilled from the last run of this workflow; edit and start.",
475
- invalidJson: (e) => `Payload is not valid JSON: ${e}`,
476
- started: (e, t) => `Started · ${e} · ${t}`,
477
- startFailed: (e) => `Start refused: ${e}`,
478
- steps: (e) => `Steps (${e})`,
479
- noSteps: "No steps recorded yet.",
480
- events: (e) => `Events (${e})`,
481
- attempt: (e) => `attempt ${e}`,
482
- input: "Input",
483
- output: "Output",
484
- error: "Error",
485
- trace: "trace",
486
- cancel: "Cancel run",
487
- cancelResult: (e) => `Cancel · ${e}`,
488
- awaiting: "awaiting signal",
489
- signalName: "Signal",
490
- signalPayload: "Signal payload (JSON)",
491
- sendSignal: "Send signal",
492
- signalSent: (e) => `Signal \`${e}\` sent.`,
493
- actionFailed: (e, t) => `${e} refused: ${t}`
494
- },
495
- subscriptions: {
496
- emptyTitle: "No active subscriptions.",
497
- emptyHint: "Mount a `useSubscription` hook to see live cache state here.",
498
- timelineTitle: "Client recovery timeline"
499
- },
500
- indexes: {
501
- noApis: "No APIs mounted in this app.",
502
- unreachableTitle: "Couldn't reach any api's `/_voltro/inspect/subscriptions` endpoint.",
503
- unreachableHint: "Is `voltro dev` running? `/_voltro/inspect/*` requires `VOLTRO_INSPECT_TOKEN`; `voltro dev` mints one per project and its proxy sends it for you. Under `voltro start` / `voltro serve` you must set it yourself, or pass `<VoltroDevtools inspectToken>`.",
504
- offline: "offline",
505
- tables: "Tables",
506
- subscriptionsSection: "Subscriptions",
507
- subsBadge: (e) => `${e} subs`,
508
- live: "live",
509
- poll: "poll",
510
- via: "via",
511
- clients: (e) => e === 1 ? "client" : "clients"
512
- },
513
- webhooks: {
514
- empty: "No api processes connected — webhooks discover from `*.webhook.tsx`.",
515
- outgoing: (e) => `Outgoing events (${e})`,
516
- incoming: (e) => `Incoming routes (${e})`,
517
- targets: (e) => `Active targets (${e})`,
518
- deliveries: (e) => `Recent deliveries (${e})`,
519
- signed: "signed",
520
- unsigned: "unsigned",
521
- active: "active",
522
- paused: "paused",
523
- attempt: (e) => `attempt ${e}`
524
- },
525
- mutations: {
526
- emptyTitle: "No mutations yet.",
527
- emptyHint: "Calling `mutate(input)` from any `useMutation()` hook will land a row here. Newest-first; capped at 100 entries.",
528
- clearTitle: "Clear mutation history",
529
- clear: "Clear",
530
- recent: (e) => `Recent (${e})`
531
- },
532
- logs: {
533
- filters: "Filters",
534
- clearTitle: "Clear log history",
535
- clear: "Clear",
536
- searchPlaceholder: "Filter messages, scope, fields…",
537
- emptyNone: "No log records yet.",
538
- emptyNoMatch: "No records match the current filters.",
539
- emptyHint: "Every `createLogger().info(...)` / `Effect.log*` call lands here (capped at 500, newest-first).",
540
- tail: "Tail"
541
- },
542
- routes: {
543
- currentRoute: "Current Route",
544
- loaderData: "Loader Data",
545
- collapse: "collapse",
546
- expand: "expand",
547
- noLoaderTitle: "No loader data for this route.",
548
- noLoaderHint: (e) => /* @__PURE__ */ N(j, { children: [
549
- "Pages with an exported `loader` see their resolved data here. UI-only apps (no ",
550
- e,
551
- ") don't surface loader state at all."
552
- ] })
553
- },
554
- runtimes: {
555
- emptyTitle: "No APIs mounted in this app.",
556
- emptyHint: "UI-only apps (no `apis` in app.config.ts) don't open any runtimes.",
557
- live: "live"
558
- },
559
- traces: {
560
- includeBackground: "Show background traces",
561
- duration: "Duration",
562
- lastDelivery: "Last delivery",
563
- attributes: "Recorded attributes",
564
- noAttributes: "No attributes were recorded for this span.",
565
- sqlWithoutCaller: "Only database spans were captured. No calling request or action was recorded in this trace.",
566
- missingParents: "Parent spans are missing from this capture. The calling operation and full duration may be unavailable.",
567
- noApi: "No API connected. Traces appear once a `useMutation` / `useSubscription` call runs.",
568
- noneCaptured: (e) => `${e} — no traces captured yet. Trigger an action.`,
569
- proxiedTitle: "Traces aren't fetchable from this browser — the API is reached over a proxied socket, so there's no direct inspect origin for this panel.",
570
- proxiedHint: (e) => /* @__PURE__ */ N(j, { children: [
571
- "They're still recorded server-side. Use ",
572
- e,
573
- " or open the app's",
574
- " ",
575
- "Traces page in the cloud dashboard."
576
- ] }),
577
- ok: "ok",
578
- error: "error",
579
- sub: "sub",
580
- delivery: (e) => e === 1 ? "delivery" : "deliveries",
581
- spans: (e) => `${e} ${e === 1 ? "span" : "spans"}`
582
- }
583
- }, Re = t(Le), ze = (e, t) => ({
584
- shell: {
585
- ...e.shell,
586
- ...t.shell
587
- },
588
- inspect: {
589
- ...e.inspect,
590
- ...t.inspect
591
- },
592
- tabs: {
593
- ...e.tabs,
594
- ...t.tabs
595
- },
596
- subscriptions: {
597
- ...e.subscriptions,
598
- ...t.subscriptions
599
- },
600
- indexes: {
601
- ...e.indexes,
602
- ...t.indexes
603
- },
604
- webhooks: {
605
- ...e.webhooks,
606
- ...t.webhooks
607
- },
608
- mutations: {
609
- ...e.mutations,
610
- ...t.mutations
611
- },
612
- logs: {
613
- ...e.logs,
614
- ...t.logs
615
- },
616
- routes: {
617
- ...e.routes,
618
- ...t.routes
619
- },
620
- runtimes: {
621
- ...e.runtimes,
622
- ...t.runtimes
623
- },
624
- traces: {
625
- ...e.traces,
626
- ...t.traces
627
- },
628
- workflows: {
629
- ...e.workflows,
630
- ...t.workflows
631
- },
632
- pwa: {
633
- ...e.pwa,
634
- ...t.pwa
635
- },
636
- desktop: {
637
- ...e.desktop,
638
- ...t.desktop
639
- }
640
- });
641
- function Be(e) {
642
- let t = r(Re), n = s(() => ze(t, e.strings), [t, e.strings]);
643
- return /* @__PURE__ */ M(Re.Provider, {
644
- value: n,
645
- children: e.children
646
- });
647
- }
648
- var U = (e) => {
649
- let t = r(Re);
650
- return s(() => e ? ze(t, e) : t, [t, e]);
651
- }, Ve = {
652
- default: "vdt:bg-muted vdt:text-foreground vdt:hover:bg-muted/80",
653
- ghost: "vdt:bg-transparent vdt:text-foreground vdt:hover:bg-muted/50",
654
- outline: "vdt:bg-transparent vdt:text-foreground vdt:border vdt:border-border vdt:hover:border-border-strong",
655
- accent: "vdt:bg-accent vdt:text-accent-foreground vdt:hover:bg-accent-dim",
656
- danger: "vdt:bg-danger/15 vdt:text-danger vdt:hover:bg-danger/25"
657
- }, He = {
658
- sm: "vdt:text-xs vdt:px-2 vdt:py-1 vdt:rounded-sm",
659
- md: "vdt:text-sm vdt:px-3 vdt:py-1.5 vdt:rounded-md"
660
- }, W = ({ variant: e = "default", size: t = "md", onClick: n, disabled: r, children: i, className: a, title: o }) => /* @__PURE__ */ M("button", {
661
- onClick: n,
662
- disabled: r,
663
- title: o,
664
- className: [
665
- "vdt:inline-flex vdt:items-center vdt:gap-1.5 vdt:font-medium vdt:transition-colors",
666
- "vdt:disabled:opacity-40 vdt:disabled:cursor-not-allowed",
667
- Ve[e],
668
- He[t],
669
- a ?? ""
670
- ].join(" "),
671
- children: i
672
- }), Ue = {
673
- neutral: "vdt:bg-muted vdt:text-foreground-muted vdt:border vdt:border-border",
674
- success: "vdt:bg-success/15 vdt:text-success vdt:border vdt:border-success/30",
675
- warning: "vdt:bg-warning/15 vdt:text-warning vdt:border vdt:border-warning/30",
676
- danger: "vdt:bg-danger/15 vdt:text-danger vdt:border vdt:border-danger/30",
677
- info: "vdt:bg-info/15 vdt:text-info vdt:border vdt:border-info/30",
678
- accent: "vdt:bg-accent/15 vdt:text-accent vdt:border vdt:border-accent/30"
679
- }, G = ({ tone: e = "neutral", children: t, className: n }) => /* @__PURE__ */ M("span", {
680
- className: [
681
- "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:px-1.5 vdt:py-0.5",
682
- "vdt:rounded-sm vdt:text-[10px] vdt:font-medium vdt:uppercase vdt:tracking-wider",
683
- Ue[e],
684
- n ?? ""
685
- ].join(" "),
686
- children: t
687
- }), K = ({ children: e, className: t }) => /* @__PURE__ */ M("div", {
688
- className: ["vdt:bg-background-elevated vdt:border vdt:border-border vdt:rounded-md", t ?? ""].join(" "),
689
- children: e
690
- }), We = ({ children: e, className: t }) => /* @__PURE__ */ M("div", {
691
- className: ["vdt-card-body", t ?? ""].join(" "),
692
- children: e
693
- }), q = ({ children: e, right: t, Icon: n }) => /* @__PURE__ */ N("div", {
694
- className: "vdt:flex vdt:items-center vdt:justify-between vdt:px-3 vdt:py-2 vdt:border-b vdt:border-border",
695
- children: [/* @__PURE__ */ N("div", {
696
- className: "vdt:flex vdt:items-center vdt:gap-1.5",
697
- children: [n ? /* @__PURE__ */ M(n, { className: "vdt:w-3 vdt:h-3 vdt:text-foreground-muted" }) : null, /* @__PURE__ */ M("span", {
698
- className: "vdt:text-[10px] vdt:font-semibold vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted",
699
- children: e
700
- })]
701
- }), t ?? null]
702
- }), J = ({ entries: e }) => /* @__PURE__ */ M("dl", {
703
- className: "vdt:grid vdt:grid-cols-[auto_1fr] vdt:gap-x-3 vdt:gap-y-1 vdt:px-3 vdt:py-2 vdt:text-xs",
704
- children: e.map((e) => /* @__PURE__ */ N("div", {
705
- className: "vdt:contents",
706
- children: [/* @__PURE__ */ M("dt", {
707
- className: "vdt:text-foreground-muted vdt:font-medium",
708
- children: e.key
709
- }), /* @__PURE__ */ M("dd", {
710
- className: "vdt:font-mono vdt:text-foreground vdt:break-all",
711
- children: e.value
712
- })]
713
- }, e.key))
714
- }), Y = ({ children: e }) => /* @__PURE__ */ M("div", {
715
- className: "vdt:flex vdt:items-center vdt:justify-center vdt:py-12 vdt:px-6 vdt:text-center",
716
- children: /* @__PURE__ */ M("div", {
717
- className: "vdt:text-xs vdt:text-foreground-subtle vdt:max-w-xs",
718
- children: e
719
- })
720
- }), Ge = 500, Ke = (e) => {
721
- let t = "";
722
- for (let n of e) t += `${n.key}|${n.subscriberCount}|${n.snapshot.revision}|${n.snapshot.pendingPatches}|${n.snapshot.error === void 0 ? "0" : "1"}|${n.hasFiber ? "1" : "0"}|${n.evicting ? "1" : "0"};`;
723
- return t;
724
- }, qe = (e) => {
725
- let [t, n] = l(() => e ? e.peekAll() : []), r = c(Ke(t));
726
- return i(() => {
727
- if (!e) return;
728
- let t = () => {
729
- let t = e.peekAll(), i = Ke(t);
730
- i !== r.current && (r.current = i, n(t));
731
- }, i = setInterval(t, Ge);
732
- return t(), () => clearInterval(i);
733
- }, [e]), t;
734
- }, Je = () => {
735
- let e = O();
736
- return e.names.map((t) => ({
737
- name: t,
738
- entries: e.get(t).cache.peekAll()
739
- }));
740
- }, Ye = () => {
741
- let e = O();
742
- return qe((e.names[0] ? e.get(e.names[0]) : null)?.cache ?? null), Je();
743
- }, Xe = (e) => {
744
- if (e instanceof Error) {
745
- let t = e._tag;
746
- return `${typeof t == "string" ? t : e.name}: ${e.message}`;
747
- }
748
- if (typeof e == "object" && e) {
749
- let { _tag: t, message: n } = e;
750
- if (typeof t == "string") return typeof n == "string" && n !== "" ? `${t}: ${n}` : t;
751
- try {
752
- return JSON.stringify(e);
753
- } catch {
754
- return String(e);
755
- }
756
- }
757
- return String(e);
758
- }, Ze = (e) => {
759
- try {
760
- let t = JSON.parse(e);
761
- if (Array.isArray(t)) {
762
- let [e, ...n] = t;
763
- return n.length === 0 || n.length === 1 && (n[0] === void 0 || JSON.stringify(n[0]) === "{}") ? String(e) : `${String(e)}(${n.map((e) => JSON.stringify(e)).join(", ")})`;
764
- }
765
- } catch {}
766
- return e;
767
- }, Qe = ({ entry: e }) => /* @__PURE__ */ N("div", {
768
- className: "vdt:bg-background/60",
769
- children: [/* @__PURE__ */ M(J, { entries: [
770
- {
771
- key: "tag",
772
- value: e.tag ?? "—"
773
- },
774
- {
775
- key: "source",
776
- value: e.source ?? "—"
777
- },
778
- {
779
- key: "subscribers",
780
- value: String(e.subscriberCount)
781
- },
782
- {
783
- key: "fiber",
784
- value: e.hasFiber ? "running" : e.evicting ? "evicting" : "idle"
785
- },
786
- {
787
- key: "recovery",
788
- value: e.recovery.phase
789
- },
790
- {
791
- key: "recoveryAttempt",
792
- value: String(e.recovery.attempt)
793
- },
794
- {
795
- key: "basePreserved",
796
- value: String(e.recovery.basePreserved)
797
- },
798
- {
799
- key: "lastTransportFailureAt",
800
- value: e.recovery.lastTransportFailureAt ? new Date(e.recovery.lastTransportFailureAt).toISOString() : "—"
801
- },
802
- {
803
- key: "lastReissueAt",
804
- value: e.recovery.lastReissueAt ? new Date(e.recovery.lastReissueAt).toISOString() : "—"
805
- },
806
- {
807
- key: "lastDeliveryAt",
808
- value: e.recovery.lastDeliveryAt ? new Date(e.recovery.lastDeliveryAt).toISOString() : "—"
809
- },
810
- {
811
- key: "revision",
812
- value: e.snapshot.revision >= 0 ? String(e.snapshot.revision) : "—"
813
- },
814
- {
815
- key: "emittedAt",
816
- value: e.snapshot.emittedAt ? new Date(e.snapshot.emittedAt).toISOString() : "—"
817
- },
818
- {
819
- key: "pendingPatches",
820
- value: String(e.snapshot.pendingPatches)
821
- },
822
- {
823
- key: "error",
824
- value: e.snapshot.error === void 0 ? "—" : Xe(e.snapshot.error)
825
- }
826
- ] }), /* @__PURE__ */ N("details", {
827
- className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
828
- children: [/* @__PURE__ */ M("summary", {
829
- className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
830
- children: "Data"
831
- }), /* @__PURE__ */ M("pre", {
832
- className: "vdt:mt-2 vdt:text-[11px] vdt:text-foreground vdt:max-h-64 vdt:overflow-auto vdt:font-mono",
833
- children: (() => {
834
- try {
835
- return JSON.stringify(e.snapshot.data, null, 2);
836
- } catch {
837
- return String(e.snapshot.data);
838
- }
839
- })()
840
- })]
841
- })]
842
- }), $e = () => Ye().reduce((e, t) => e + t.entries.length, 0), et = (e) => e === "compiling" || e === "loading" || e === "reconnecting", tt = () => u(ue, le, le), nt = ({ name: e }) => {
843
- let t = D(e).status;
844
- return /* @__PURE__ */ N("span", {
845
- className: "vdt-chip",
846
- "data-status": t,
847
- children: [/* @__PURE__ */ M("span", {
848
- className: `vdt-dot vdt-dot-${t === "connected" ? "ok" : t === "recovering" ? "warn" : "err"}`,
849
- "aria-hidden": "true"
850
- }), /* @__PURE__ */ M("b", { children: e })]
851
- });
852
- }, rt = 260, it = "cubic-bezier(0.2, 0.8, 0.2, 1)", at = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, ot = (e, t) => {
853
- let r = c(null), a = c(null), s = c(null), l = c(e), u = n((e) => {
854
- r.current = e, t && (t.current = e);
855
- }, [t]);
856
- return i(() => {
857
- let e = r.current;
858
- if (e === null || typeof ResizeObserver > "u") return;
859
- a.current = e.offsetWidth;
860
- let t = new ResizeObserver(() => {
861
- a.current = e.offsetWidth;
862
- });
863
- return t.observe(e), () => t.disconnect();
864
- }, []), o(() => {
865
- if (l.current === e) return;
866
- l.current = e;
867
- let t = r.current;
868
- if (t === null || typeof t.animate != "function" || at()) return;
869
- let n = s.current === null ? a.current : t.offsetWidth;
870
- s.current?.cancel(), s.current = null;
871
- let i = t.offsetWidth;
872
- if (n === null || n === i) return;
873
- t.setAttribute("data-morphing", "true");
874
- let o = t.animate([{ width: `${n}px` }, { width: `${i}px` }], {
875
- duration: rt,
876
- easing: it
877
- });
878
- s.current = o;
879
- let c = () => {
880
- s.current === o && (s.current = null, t.removeAttribute("data-morphing"));
881
- };
882
- o.addEventListener("finish", c), o.addEventListener("cancel", c);
883
- }, [e]), u;
884
- }, st = ({ status: e, onOpen: t, buttonRef: n, style: r, dragging: i = !1, onPointerDown: a }) => {
885
- let o = U().shell, s = O(), c = $e(), l = u(T, S, S), d = tt(), f = l.filter((e) => e.status === "pending").length, p = l.filter((e) => e.status === "error").length, m = d.filter((e) => e.level === "error" || e.level === "fatal").length, h = d.filter((e) => e.level === "warn").length, g = e !== null, _ = e?.kind ?? "idle", v = e === null ? "" : et(_) ? e.label.replace(/[…\.\s]+$/, "") : e.label, y = g ? `${_}:${v}` : "chips", b = ot(y, n);
886
- return /* @__PURE__ */ N("button", {
887
- ref: b,
888
- type: "button",
889
- className: "vdt-capsule",
890
- "data-busy": g ? "true" : "false",
891
- "data-kind": _,
892
- "data-dragging": i ? "true" : void 0,
893
- style: r,
894
- onClick: t,
895
- onPointerDown: a,
896
- title: o.openTitle,
897
- "aria-label": o.openLabel,
898
- children: [
899
- /* @__PURE__ */ M("span", {
900
- className: "vdt-capsule-halo vdt-capsule-aura",
901
- "aria-hidden": "true"
902
- }),
903
- /* @__PURE__ */ M("span", {
904
- className: "vdt-capsule-halo",
905
- "aria-hidden": "true"
906
- }),
907
- g ? /* @__PURE__ */ M(Ie, { className: "vdt-capsule-mark vdt-spinner" }) : /* @__PURE__ */ M(de, { className: "vdt-capsule-mark" }),
908
- g ? /* @__PURE__ */ N("span", {
909
- className: "vdt-capsule-status",
910
- children: [v, et(_) ? /* @__PURE__ */ N("span", {
911
- className: "vdt-dots",
912
- "aria-hidden": "true",
913
- children: [
914
- /* @__PURE__ */ M("span", {}),
915
- /* @__PURE__ */ M("span", {}),
916
- /* @__PURE__ */ M("span", {})
917
- ]
918
- }) : null]
919
- }, y) : /* @__PURE__ */ N("span", {
920
- className: "vdt-capsule-chips",
921
- children: [
922
- s.names.map((e) => /* @__PURE__ */ M(nt, { name: e }, e)),
923
- /* @__PURE__ */ N("span", {
924
- className: "vdt-chip",
925
- "data-chip": "live",
926
- children: [
927
- /* @__PURE__ */ M("b", { children: c }),
928
- " ",
929
- o.live
930
- ]
931
- }),
932
- f > 0 ? /* @__PURE__ */ N("span", {
933
- className: "vdt-chip vdt-chip-info",
934
- "data-chip": "pending",
935
- children: [
936
- /* @__PURE__ */ M("span", {
937
- className: "vdt-dot vdt-dot-info",
938
- "aria-hidden": "true"
939
- }),
940
- /* @__PURE__ */ M("b", { children: f }),
941
- " ",
942
- o.pending
943
- ]
944
- }) : null,
945
- p > 0 ? /* @__PURE__ */ N("span", {
946
- className: "vdt-chip vdt-chip-err",
947
- "data-chip": "failed",
948
- children: [
949
- /* @__PURE__ */ M("span", {
950
- className: "vdt-dot vdt-dot-err",
951
- "aria-hidden": "true"
952
- }),
953
- /* @__PURE__ */ M("b", { children: p }),
954
- " ",
955
- o.failed
956
- ]
957
- }) : null,
958
- m > 0 ? /* @__PURE__ */ N("span", {
959
- className: "vdt-chip vdt-chip-err",
960
- "data-chip": "errors",
961
- children: [
962
- /* @__PURE__ */ M("b", { children: m }),
963
- " ",
964
- o.errorsWord(m)
965
- ]
966
- }) : null,
967
- m === 0 && h > 0 ? /* @__PURE__ */ N("span", {
968
- className: "vdt-chip vdt-chip-warn",
969
- "data-chip": "warnings",
970
- children: [
971
- /* @__PURE__ */ M("b", { children: h }),
972
- " ",
973
- o.warningsWord(h)
974
- ]
975
- }) : null
976
- ]
977
- })
978
- ]
979
- });
980
- }, ct = {
981
- x: .5,
982
- y: 1
983
- }, lt = [
984
- {
985
- x: 0,
986
- y: 0
987
- },
988
- {
989
- x: .5,
990
- y: 0
991
- },
992
- {
993
- x: 1,
994
- y: 0
995
- },
996
- {
997
- x: 0,
998
- y: .5
999
- },
1000
- {
1001
- x: 1,
1002
- y: .5
1003
- },
1004
- {
1005
- x: 0,
1006
- y: 1
1007
- },
1008
- {
1009
- x: .5,
1010
- y: 1
1011
- },
1012
- {
1013
- x: 1,
1014
- y: 1
1015
- }
1016
- ], ut = (e) => Math.min(1, Math.max(0, e)), dt = (e, t) => ({
1017
- x: Math.max(0, t.width - 36 - e.w),
1018
- y: Math.max(0, t.height - 36 - e.h)
1019
- }), ft = (e, t) => e.x === t.x && e.y === t.y, pt = (e, t, n) => {
1020
- let r = dt(t, n), i = null, a = 48;
1021
- for (let t of lt) {
1022
- let n = Math.hypot((e.x - t.x) * r.x, (e.y - t.y) * r.y);
1023
- n <= a && (i = t, a = n);
1024
- }
1025
- return i === null ? e : {
1026
- x: r.x > 0 ? i.x : e.x,
1027
- y: r.y > 0 ? i.y : e.y
1028
- };
1029
- }, mt = (e, t, n, r, i) => {
1030
- let a = dt(t, n);
1031
- return pt({
1032
- x: a.x > 0 ? ut((e.x * a.x + r) / a.x) : e.x,
1033
- y: a.y > 0 ? ut((e.y * a.y + i) / a.y) : e.y
1034
- }, t, n);
1035
- }, ht = (e) => typeof e == "number" && Number.isFinite(e), gt = (e) => {
1036
- if (typeof e != "object" || !e) return ct;
1037
- let t = e;
1038
- return {
1039
- x: ht(t.x) ? ut(t.x) : ct.x,
1040
- y: ht(t.y) ? ut(t.y) : ct.y
1041
- };
1042
- }, _t = [
1043
- "bottom",
1044
- "top",
1045
- "left",
1046
- "right",
1047
- "window",
1048
- "external"
1049
- ], vt = [
1050
- "bottom",
1051
- "top",
1052
- "left",
1053
- "right"
1054
- ], yt = (e) => typeof e == "string" && _t.includes(e), bt = (e) => e !== "window" && e !== "external", xt = {
1055
- bottom: 240,
1056
- top: 240,
1057
- left: 320,
1058
- right: 320
1059
- }, St = {
1060
- w: 480,
1061
- h: 320
1062
- }, Ct = 64, wt = {
1063
- dock: "bottom",
1064
- sizes: {
1065
- bottom: 400,
1066
- top: 400,
1067
- left: 460,
1068
- right: 460
1069
- },
1070
- window: {
1071
- x: 80,
1072
- y: 80,
1073
- w: 860,
1074
- h: 560
1075
- },
1076
- push: !1,
1077
- capsule: ct
1078
- }, Tt = "voltro:devtools:dock", Et = (e) => typeof e == "number" && Number.isFinite(e), Dt = (e, t) => {
1079
- let n = {
1080
- ...wt,
1081
- dock: t
1082
- };
1083
- if (typeof e != "object" || !e) return n;
1084
- let r = e, i = typeof r.sizes == "object" && r.sizes !== null ? r.sizes : {}, a = { ...wt.sizes };
1085
- for (let e of vt) {
1086
- let t = i[e];
1087
- Et(t) && t >= xt[e] && (a[e] = Math.round(t));
1088
- }
1089
- let o = typeof r.window == "object" && r.window !== null ? r.window : {}, s = {
1090
- x: Et(o.x) ? Math.round(o.x) : n.window.x,
1091
- y: Et(o.y) ? Math.round(o.y) : n.window.y,
1092
- w: Et(o.w) && o.w >= St.w ? Math.round(o.w) : n.window.w,
1093
- h: Et(o.h) && o.h >= St.h ? Math.round(o.h) : n.window.h
1094
- };
1095
- return {
1096
- dock: yt(r.dock) ? r.dock : t,
1097
- sizes: a,
1098
- window: s,
1099
- push: r.push === !0,
1100
- capsule: gt(r.capsule)
1101
- };
1102
- }, Ot = (e) => {
1103
- if (typeof window > "u") return {
1104
- ...wt,
1105
- dock: e
1106
- };
1107
- try {
1108
- let t = window.localStorage.getItem(Tt);
1109
- return t === null ? {
1110
- ...wt,
1111
- dock: e
1112
- } : Dt(JSON.parse(t), e);
1113
- } catch {
1114
- return {
1115
- ...wt,
1116
- dock: e
1117
- };
1118
- }
1119
- }, kt = (e) => {
1120
- if (!(typeof window > "u")) try {
1121
- window.localStorage.setItem(Tt, JSON.stringify(e));
1122
- } catch {}
1123
- }, At = () => typeof window > "u" ? {
1124
- width: 1440,
1125
- height: 900
1126
- } : {
1127
- width: window.innerWidth,
1128
- height: window.innerHeight
1129
- }, jt = (e, t, n = At()) => {
1130
- let r = e === "left" || e === "right" ? n.width : n.height, i = Math.max(xt[e], r - Ct);
1131
- return Math.round(Math.min(i, Math.max(xt[e], t)));
1132
- }, Mt = (e, t = At()) => {
1133
- let n = Math.max(120, t.width - 16), r = Math.max(120, t.height - 16), i = Math.round(Math.min(Math.max(Math.min(St.w, n), e.w), n)), a = Math.round(Math.min(Math.max(Math.min(St.h, r), e.h), r));
1134
- return {
1135
- x: Math.round(Math.min(Math.max(8, e.x), Math.max(8, t.width - i - 8))),
1136
- y: Math.round(Math.min(Math.max(8, e.y), Math.max(8, t.height - a - 8))),
1137
- w: i,
1138
- h: a
1139
- };
1140
- }, Nt = (e, t) => {
1141
- let n = { ...e.sizes }, r = !1;
1142
- for (let e of vt) {
1143
- let i = jt(e, n[e], t);
1144
- i !== n[e] && (n[e] = i, r = !0);
1145
- }
1146
- let i = Mt(e.window, t), a = i.x !== e.window.x || i.y !== e.window.y || i.w !== e.window.w || i.h !== e.window.h;
1147
- return !r && !a ? e : {
1148
- ...e,
1149
- sizes: n,
1150
- window: i
1151
- };
1152
- }, Pt = (e) => (window.addEventListener("resize", e), () => window.removeEventListener("resize", e)), Ft = {
1153
- width: 0,
1154
- height: 0
1155
- }, It = () => {
1156
- let e = window.innerWidth, t = window.innerHeight;
1157
- return (Ft.width !== e || Ft.height !== t) && (Ft = {
1158
- width: e,
1159
- height: t
1160
- }), Ft;
1161
- }, Lt = {
1162
- width: 1440,
1163
- height: 900
1164
- }, Rt = () => Lt, zt = () => u(Pt, It, Rt), Bt = (e = "bottom") => {
1165
- let [t, r] = l(() => Ot(e));
1166
- i(() => {
1167
- if (typeof window > "u") return;
1168
- let t = (t) => {
1169
- if (t.key === Tt && t.newValue !== null) try {
1170
- r(Dt(JSON.parse(t.newValue), e));
1171
- } catch {}
1172
- };
1173
- return window.addEventListener("storage", t), () => window.removeEventListener("storage", t);
1174
- }, [e]);
1175
- let a = n((e) => {
1176
- r((t) => {
1177
- let n = e(t);
1178
- return kt(n), n;
1179
- });
1180
- }, []);
1181
- return [t, {
1182
- setDock: n((e) => a((t) => t.dock === e ? t : {
1183
- ...t,
1184
- dock: e
1185
- }), [a]),
1186
- setEdgeSize: n((e, t) => a((n) => {
1187
- let r = jt(e, t);
1188
- return n.sizes[e] === r ? n : {
1189
- ...n,
1190
- sizes: {
1191
- ...n.sizes,
1192
- [e]: r
1193
- }
1194
- };
1195
- }), [a]),
1196
- setWindowRect: n((e) => a((t) => ({
1197
- ...t,
1198
- window: Mt(e)
1199
- })), [a]),
1200
- setPush: n((e) => a((t) => t.push === e ? t : {
1201
- ...t,
1202
- push: e
1203
- }), [a]),
1204
- setCapsule: n((e) => a((t) => ft(t.capsule, e) ? t : {
1205
- ...t,
1206
- capsule: e
1207
- }), [a])
1208
- }];
1209
- }, Vt = (e) => {
1210
- switch (e) {
1211
- case "ArrowDown": return "bottom";
1212
- case "ArrowUp": return "top";
1213
- case "ArrowLeft": return "left";
1214
- case "ArrowRight": return "right";
1215
- default: return null;
1216
- }
1217
- }, Ht = {
1218
- bottom: ke,
1219
- top: Ae,
1220
- left: je,
1221
- right: Me,
1222
- window: Pe,
1223
- external: Ne
1224
- }, Ut = ({ dock: e, push: t, onDock: n, onPush: r }) => {
1225
- let a = U().shell, [o, s] = l(!1), u = c(null), d = {
1226
- bottom: a.dockBottom,
1227
- top: a.dockTop,
1228
- left: a.dockLeft,
1229
- right: a.dockRight,
1230
- window: a.dockWindow,
1231
- external: a.dockExternal
1232
- };
1233
- i(() => {
1234
- if (!o) return;
1235
- let e = u.current?.ownerDocument ?? document, t = (e) => {
1236
- u.current !== null && !e.composedPath().includes(u.current) && s(!1);
1237
- }, n = (e) => {
1238
- e.key === "Escape" && s(!1);
1239
- };
1240
- return e.addEventListener("mousedown", t), e.addEventListener("keydown", n), () => {
1241
- e.removeEventListener("mousedown", t), e.removeEventListener("keydown", n);
1242
- };
1243
- }, [o]);
1244
- let f = c([]);
1245
- i(() => {
1246
- if (!o) return;
1247
- let t = _t.indexOf(e);
1248
- f.current[t === -1 ? 0 : t]?.focus();
1249
- }, [o, e]);
1250
- let p = (e) => {
1251
- let t = f.current.filter((e) => e !== null);
1252
- if (t.length === 0) return;
1253
- let n = t.findIndex((t) => t === e.target), r = null;
1254
- switch (e.key) {
1255
- case "ArrowRight":
1256
- case "ArrowDown":
1257
- r = (n + 1) % t.length;
1258
- break;
1259
- case "ArrowLeft":
1260
- case "ArrowUp":
1261
- r = (n - 1 + t.length) % t.length;
1262
- break;
1263
- case "Home":
1264
- r = 0;
1265
- break;
1266
- case "End":
1267
- r = t.length - 1;
1268
- break;
1269
- default: return;
1270
- }
1271
- e.preventDefault(), t[r]?.focus();
1272
- }, m = Ht[e];
1273
- return /* @__PURE__ */ N("div", {
1274
- ref: u,
1275
- className: "vdt-dockmenu",
1276
- children: [/* @__PURE__ */ M("button", {
1277
- type: "button",
1278
- className: `vdt-iconbtn${o ? " vdt-iconbtn-on" : ""}`,
1279
- title: a.dockMenuTitle,
1280
- "aria-label": a.dockMenuTitle,
1281
- "aria-haspopup": "menu",
1282
- "aria-expanded": o,
1283
- onClick: () => s((e) => !e),
1284
- children: /* @__PURE__ */ M(m, { className: "vdt:w-4 vdt:h-4" })
1285
- }), o ? /* @__PURE__ */ N("div", {
1286
- role: "menu",
1287
- "aria-label": a.dockMenuTitle,
1288
- className: "vdt-dockmenu-pop",
1289
- children: [/* @__PURE__ */ M("div", {
1290
- className: "vdt-dockmenu-row",
1291
- onKeyDown: p,
1292
- children: _t.map((t, r) => {
1293
- let i = Ht[t], a = t === e;
1294
- return /* @__PURE__ */ M("button", {
1295
- ref: (e) => {
1296
- f.current[r] = e;
1297
- },
1298
- type: "button",
1299
- role: "menuitemradio",
1300
- "aria-checked": a,
1301
- "aria-label": d[t],
1302
- title: d[t],
1303
- className: `vdt-dockmenu-item${a ? " vdt-dockmenu-item-on" : ""}`,
1304
- onClick: () => {
1305
- n(t), s(!1);
1306
- },
1307
- children: /* @__PURE__ */ M(i, { className: "vdt:w-4 vdt:h-4" })
1308
- }, t);
1309
- })
1310
- }), /* @__PURE__ */ N("label", {
1311
- className: `vdt-dockmenu-push${bt(e) ? "" : " vdt-dockmenu-push-off"}`,
1312
- children: [/* @__PURE__ */ M("input", {
1313
- type: "checkbox",
1314
- role: "menuitemcheckbox",
1315
- "aria-checked": t,
1316
- checked: t,
1317
- disabled: !bt(e),
1318
- onChange: (e) => r(e.target.checked)
1319
- }), /* @__PURE__ */ N("span", { children: [/* @__PURE__ */ M("span", {
1320
- className: "vdt-dockmenu-push-label",
1321
- children: a.pushPage
1322
- }), /* @__PURE__ */ M("span", {
1323
- className: "vdt-dockmenu-push-hint",
1324
- children: a.pushPageHint
1325
- })] })]
1326
- })]
1327
- }) : null]
1328
- });
1329
- }, Wt = 2e3, Gt = 6e4, X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Set(), qt = [], Jt = () => {
1330
- qt = Array.from(X.values());
1331
- for (let e of Kt) e();
1332
- }, Yt = (e) => {
1333
- let t = e.indexOf("/_voltro/inspect");
1334
- return t === -1 ? e : e.slice(0, t);
1335
- }, Xt = (e) => X.get(e), Zt = (e, t = Date.now()) => {
1336
- if (X.has(e)) return !1;
1337
- let n = Z.get(e);
1338
- return n === void 0 || t >= n.retryAt;
1339
- }, Qt = (e) => {
1340
- Z.delete(e.baseUrl), X.set(e.baseUrl, e), Jt();
1341
- }, $t = (e, t, n = Date.now()) => {
1342
- let r = (Z.get(e)?.count ?? 0) + 1;
1343
- if (t && r >= 3) {
1344
- Qt({
1345
- baseUrl: e,
1346
- status: 0
1347
- });
1348
- return;
1349
- }
1350
- Z.set(e, {
1351
- count: r,
1352
- retryAt: n + Math.min(Gt, Wt * 2 ** r)
1353
- });
1354
- }, en = (e) => {
1355
- Z.delete(e);
1356
- }, tn = () => {
1357
- Z.clear(), X.size !== 0 && (X.clear(), Jt());
1358
- }, nn = (e) => e === 401 || e === 403, rn = async (e, t) => {
1359
- let n = await t.json().catch(() => null), r = (e) => {
1360
- let t = typeof n == "object" && n ? n[e] : void 0;
1361
- return typeof t == "string" && t !== "" ? t : void 0;
1362
- }, i = typeof n == "object" && !!n && n.locked === !0, a = r("error"), o = r("reason"), s = r("fix"), c = r("login");
1363
- return {
1364
- baseUrl: e,
1365
- status: t.status,
1366
- ...a === void 0 ? {} : { error: a },
1367
- ...o === void 0 ? {} : { reason: o },
1368
- ...s === void 0 ? {} : { fix: s },
1369
- ...i ? { locked: !0 } : {},
1370
- ...c === void 0 ? {} : { login: c }
1371
- };
1372
- }, an = (e) => (Kt.add(e), () => {
1373
- Kt.delete(e);
1374
- }), on = () => u(an, () => qt, () => qt), sn = (e) => {
1375
- if (e.login !== void 0) try {
1376
- return new URL(e.login, new URL(e.baseUrl, window.location.href)).href;
1377
- } catch {
1378
- return;
1379
- }
1380
- }, cn = ({ url: e }) => {
1381
- let t = U().inspect, [n, r] = l(""), [i, a] = l(null), o = async (t) => {
1382
- t.preventDefault(), a(null);
1383
- try {
1384
- let t = await fetch(e, {
1385
- method: "POST",
1386
- credentials: "same-origin",
1387
- headers: { "content-type": "application/json" },
1388
- body: JSON.stringify({ token: n })
1389
- });
1390
- if (t.ok) {
1391
- r(""), tn();
1392
- return;
1393
- }
1394
- let i = await t.json().catch(() => null), o = typeof i == "object" && i && typeof i.reason == "string" ? i.reason : `HTTP ${t.status}`;
1395
- a(o);
1396
- } catch (e) {
1397
- a(e instanceof Error ? e.message : String(e));
1398
- }
1399
- };
1400
- return /* @__PURE__ */ N("form", {
1401
- className: "vdt-refusal-signin",
1402
- onSubmit: (e) => {
1403
- o(e);
1404
- },
1405
- children: [
1406
- /* @__PURE__ */ N("label", { children: [/* @__PURE__ */ M("span", { children: t.tokenLabel }), /* @__PURE__ */ M("input", {
1407
- type: "password",
1408
- autoComplete: "off",
1409
- value: n,
1410
- onChange: (e) => r(e.target.value)
1411
- })] }),
1412
- /* @__PURE__ */ M("button", {
1413
- type: "submit",
1414
- disabled: n === "",
1415
- children: t.signIn
1416
- }),
1417
- i === null ? null : /* @__PURE__ */ M("span", {
1418
- className: "vdt-refusal-failed",
1419
- children: t.signInFailed(i)
1420
- })
1421
- ]
1422
- });
1423
- }, ln = () => {
1424
- let e = on(), t = O(), n = U().inspect;
1425
- if (e.length === 0) return null;
1426
- let r = (e) => t.names.find((n) => t.get(n).inspectBaseUrl === e) ?? e;
1427
- return /* @__PURE__ */ M("div", {
1428
- className: "vdt-refusals",
1429
- role: "status",
1430
- children: e.map((e) => {
1431
- let t = e.locked === !0 ? sn(e) : void 0;
1432
- return /* @__PURE__ */ N("div", {
1433
- className: "vdt-refusal",
1434
- children: [
1435
- /* @__PURE__ */ M("strong", { children: e.status === 0 ? n.unreachableTitle(r(e.baseUrl)) : n.refusedTitle(r(e.baseUrl), e.status) }),
1436
- e.status === 0 ? /* @__PURE__ */ M("p", { children: n.unreachableHint }) : /* @__PURE__ */ M("p", { children: [e.error, e.reason].filter((e) => e !== void 0).join(" — ") }),
1437
- e.fix === void 0 ? null : /* @__PURE__ */ N("p", { children: [
1438
- /* @__PURE__ */ M("span", {
1439
- className: "vdt-refusal-label",
1440
- children: n.fixLabel
1441
- }),
1442
- " ",
1443
- e.fix
1444
- ] }),
1445
- t === void 0 ? null : /* @__PURE__ */ M(cn, { url: t }),
1446
- /* @__PURE__ */ M("p", {
1447
- className: "vdt-refusal-paused",
1448
- children: n.paused
1449
- })
1450
- ]
1451
- }, e.baseUrl);
1452
- })
1453
- });
1454
- }, un = t(null);
1455
- function dn(e) {
1456
- return /* @__PURE__ */ M(un.Provider, {
1457
- value: e.token,
1458
- children: e.children
1459
- });
1460
- }
1461
- var Q = () => r(un), fn = (e, t) => {
1462
- let n = { ...t ?? {} };
1463
- return e !== null && e !== "" && (n.authorization = `Bearer ${e}`), n;
1464
- }, pn = (e) => e !== void 0 && e !== "" ? e : null, mn = (e) => typeof e == "object" && !!e && "data" in e, hn = (e) => mn(e) ? e.data : null, gn = async (e, t, n) => {
1465
- let r = await fetch(e, {
1466
- method: "POST",
1467
- headers: fn(t, {
1468
- accept: "application/json",
1469
- "content-type": "application/json"
1470
- }),
1471
- body: JSON.stringify(n ?? {})
1472
- }), i = await r.json().catch(() => null);
1473
- if (!r.ok) {
1474
- let e = typeof i == "object" && i ? i : void 0, t = typeof e?.message == "string" ? e.message : typeof e?.error == "string" ? e.error : `HTTP ${r.status}`;
1475
- throw Error(t);
1476
- }
1477
- let a = hn(i);
1478
- if (a === null) throw Error("the api answered without an observation");
1479
- return a;
1480
- }, _n = (e, t) => {
1481
- let n = `${e}\u0000${t ?? ""}`, r = vn.get(n);
1482
- if (r !== void 0) return r;
1483
- let i = yn(e, t).finally(() => {
1484
- vn.delete(n);
1485
- });
1486
- return vn.set(n, i), i;
1487
- }, vn = /* @__PURE__ */ new Map(), yn = async (e, t) => {
1488
- let n = Yt(e);
1489
- if (!Zt(n)) return null;
1490
- let r;
1491
- try {
1492
- r = await fetch(e, { headers: fn(t, { accept: "application/json" }) });
1493
- } catch {
1494
- return $t(n, !0), null;
1495
- }
1496
- if (nn(r.status)) return Qt(await rn(n, r)), null;
1497
- if (!r.ok) return $t(n, !1), null;
1498
- en(n);
1499
- try {
1500
- return hn(await r.json());
1501
- } catch {
1502
- return null;
1503
- }
1504
- }, bn = (e) => typeof document > "u" ? () => {} : (document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e)), xn = () => typeof document > "u" || !document.hidden, Sn = () => !0, $ = () => u(bn, xn, Sn), Cn = 5e3, wn = async (e, t) => {
1505
- if (e === "") return null;
1506
- let n = await _n(`${e}/_voltro/inspect/subscriptions`, t);
1507
- return n !== null && Array.isArray(n.subscriptions) ? n : null;
1508
- }, Tn = (e) => {
1509
- let t = O(), n = $(), r = Q(), a = t.names, o = e && n, [s, c] = l(() => a.map((e) => ({
1510
- name: e,
1511
- response: null,
1512
- live: !1
1513
- })));
1514
- return i(() => {
1515
- if (!o) return;
1516
- let e = !1, n = (t, n) => {
1517
- e || c((e) => e.map((e) => e.name === t ? {
1518
- ...e,
1519
- ...n
1520
- } : e));
1521
- }, i = a.map((i) => {
1522
- let a = t.get(i).inspectBaseUrl;
1523
- if (a === "") return { teardown: () => {} };
1524
- let o = null, s = null, c, l = () => {
1525
- s !== null && clearInterval(s), s = null;
1526
- }, u = () => Xt(a) !== void 0, d = () => {
1527
- if (s !== null || u()) return;
1528
- let e = async () => {
1529
- let e = await wn(a, r);
1530
- e !== null && n(i, {
1531
- response: e,
1532
- live: !1
1533
- }), u() && (l(), o?.close());
1534
- };
1535
- e(), s = setInterval(() => {
1536
- e();
1537
- }, Cn);
1538
- };
1539
- return wn(a, r).then((e) => {
1540
- e !== null && n(i, { response: e }), u() && (l(), o?.close());
1541
- }), c = setTimeout(() => {
1542
- if (!(u() || e)) try {
1543
- o = new EventSource(`${a}/_voltro/inspect/stream`), o.addEventListener("subscriptions", (e) => {
1544
- try {
1545
- let t = JSON.parse(e.data).payload;
1546
- t && typeof t == "object" && n(i, {
1547
- response: t,
1548
- live: !0
1549
- });
1550
- } catch {}
1551
- }), o.addEventListener("open", () => {
1552
- n(i, { live: !0 }), l();
1553
- }), o.addEventListener("error", () => {
1554
- n(i, { live: !1 }), d();
1555
- });
1556
- } catch {
1557
- d();
1558
- }
1559
- }, 0), { teardown: () => {
1560
- clearTimeout(c), o?.close(), l();
1561
- } };
1562
- });
1563
- return () => {
1564
- e = !0;
1565
- for (let e of i) e.teardown();
1566
- };
1567
- }, [
1568
- o,
1569
- t,
1570
- a,
1571
- r
1572
- ]), s;
1573
- }, En = (e) => {
1574
- if (typeof e != "object" || !e) return !1;
1575
- let t = e;
1576
- if (Array.isArray(t.and)) return t.and.some(En);
1577
- if (Array.isArray(t.or)) return t.or.some(En);
1578
- let n = t.op;
1579
- return n === "gt" || n === "gte" || n === "lt" || n === "lte";
1580
- }, Dn = (e) => {
1581
- if (typeof e != "object" || !e) return !1;
1582
- let t = e;
1583
- if (Array.isArray(t.and)) return t.and.some(Dn);
1584
- if (Array.isArray(t.or)) return t.or.some(Dn);
1585
- let n = t.op;
1586
- return n === "eq" || n === "in";
1587
- }, On = (e) => e.usingIndex !== void 0 && e.usingIndex.fields.every((t) => e.conjunctiveColumns.includes(t)) ? "tuple" : Dn(e.predicate) ? "column" : En(e.predicate) ? "range" : "unindexed", kn = (e) => e === "tuple" ? "success" : e === "column" ? "info" : e === "range" ? "neutral" : "warning", An = (e) => e === "tuple" ? "tuple" : e === "column" ? "column" : e === "range" ? "range" : "UNINDEXED", jn = (e) => e == null ? "null" : typeof e == "string" ? `'${e}'` : Array.isArray(e) ? `[${e.map(jn).join(", ")}]` : String(e), Mn = (e) => e.op === "isNull" ? `${e.column} IS NULL` : e.op === "isNotNull" ? `${e.column} IS NOT NULL` : `${e.column} ${e.op} ${jn(e.value)}`, Nn = (e, t = 0) => {
1588
- if (typeof e != "object" || !e) return String(e);
1589
- let n = e;
1590
- if (Array.isArray(n.and)) return n.and.map((e) => Nn(e, t + 1)).join(" AND ");
1591
- if (Array.isArray(n.or)) {
1592
- let e = n.or.map((e) => Nn(e, t + 1)).join(" OR ");
1593
- return t > 0 ? `(${e})` : e;
1594
- }
1595
- return typeof n.column == "string" && typeof n.op == "string" ? Mn(n) : JSON.stringify(e);
1596
- }, Pn = () => {
1597
- let e = Tn(!0), t = U().indexes, n = e.filter((e) => e.response !== null).length;
1598
- return e.length === 0 ? /* @__PURE__ */ M(Y, { children: t.noApis }) : n === 0 ? /* @__PURE__ */ N(Y, { children: [t.unreachableTitle, /* @__PURE__ */ M("div", {
1599
- className: "vdt:mt-1 vdt:text-foreground-subtle",
1600
- children: t.unreachableHint
1601
- })] }) : /* @__PURE__ */ M("div", {
1602
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
1603
- children: e.map(({ name: e, response: n, live: r }) => n === null ? /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
1604
- Icon: me,
1605
- children: e
1606
- }), /* @__PURE__ */ M(We, {
1607
- className: "vdt:text-xs vdt:text-foreground-subtle",
1608
- children: t.offline
1609
- })] }, e) : /* @__PURE__ */ M(Fn, {
1610
- apiName: e,
1611
- response: n,
1612
- live: r
1613
- }, e))
1614
- });
1615
- }, Fn = ({ apiName: e, response: t, live: n }) => {
1616
- let r = U().indexes, i = [...t.subscriptions].sort((e, t) => t.subscriberCount - e.subscriberCount);
1617
- return /* @__PURE__ */ N(K, { children: [
1618
- /* @__PURE__ */ M(q, {
1619
- Icon: me,
1620
- right: /* @__PURE__ */ N("div", {
1621
- className: "vdt:flex vdt:items-center vdt:gap-1",
1622
- children: [/* @__PURE__ */ M(G, {
1623
- tone: "info",
1624
- children: r.subsBadge(t.subscriptions.length)
1625
- }), /* @__PURE__ */ M(G, {
1626
- tone: n ? "success" : "neutral",
1627
- children: n ? r.live : r.poll
1628
- })]
1629
- }),
1630
- children: e
1631
- }),
1632
- t.matcherStats.length > 0 && /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("div", {
1633
- className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
1634
- children: r.tables
1635
- }), /* @__PURE__ */ M("div", {
1636
- className: "vdt:flex vdt:flex-col vdt:gap-1",
1637
- children: t.matcherStats.map((e) => /* @__PURE__ */ N("div", {
1638
- className: "vdt:flex vdt:items-baseline vdt:gap-3 vdt:text-xs",
1639
- children: [
1640
- /* @__PURE__ */ M("span", {
1641
- className: "vdt:font-mono vdt:text-foreground",
1642
- children: e.tableName
1643
- }),
1644
- /* @__PURE__ */ N("span", {
1645
- className: "vdt:text-foreground-subtle",
1646
- children: [e.tupleRouted + e.columnBucketed + e.rangeBucketed + e.unindexedFallback, " subs"]
1647
- }),
1648
- e.tupleRouted > 0 && /* @__PURE__ */ M(G, {
1649
- tone: "success",
1650
- children: `${e.tupleRouted} tuple`
1651
- }),
1652
- e.columnBucketed > 0 && /* @__PURE__ */ M(G, {
1653
- tone: "info",
1654
- children: `${e.columnBucketed} column`
1655
- }),
1656
- e.rangeBucketed > 0 && /* @__PURE__ */ M(G, {
1657
- tone: "neutral",
1658
- children: `${e.rangeBucketed} range`
1659
- }),
1660
- e.unindexedFallback > 0 && /* @__PURE__ */ M(G, {
1661
- tone: "warning",
1662
- children: `${e.unindexedFallback} unindexed`
1663
- }),
1664
- e.distinctTupleKeys > 0 && /* @__PURE__ */ N("span", {
1665
- className: "vdt:text-foreground-subtle",
1666
- children: [e.distinctTupleKeys, " tuple keys"]
1667
- })
1668
- ]
1669
- }, e.tableName))
1670
- })] }),
1671
- i.length > 0 && /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("div", {
1672
- className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
1673
- children: r.subscriptionsSection
1674
- }), /* @__PURE__ */ M("div", {
1675
- className: "vdt:flex vdt:flex-col vdt:gap-2",
1676
- children: i.map((e) => /* @__PURE__ */ M(In, { sub: e }, e.fingerprint))
1677
- })] })
1678
- ] });
1679
- }, In = ({ sub: e }) => {
1680
- let t = U().indexes, n = On(e);
1681
- return /* @__PURE__ */ N("div", {
1682
- className: "vdt:flex vdt:flex-col vdt:gap-0.5 vdt:px-2 vdt:py-1 vdt:rounded-sm vdt:bg-muted/40",
1683
- children: [/* @__PURE__ */ N("div", {
1684
- className: "vdt:flex vdt:items-baseline vdt:gap-2 vdt:text-xs",
1685
- children: [
1686
- /* @__PURE__ */ M("span", {
1687
- className: "vdt:font-mono vdt:text-foreground",
1688
- children: e.table
1689
- }),
1690
- /* @__PURE__ */ M(G, {
1691
- tone: kn(n),
1692
- children: An(n)
1693
- }),
1694
- e.usingIndex && /* @__PURE__ */ N("span", {
1695
- className: "vdt:text-foreground-subtle",
1696
- children: [
1697
- t.via,
1698
- " ",
1699
- /* @__PURE__ */ M("span", {
1700
- className: "vdt:font-mono",
1701
- children: e.usingIndex.name
1702
- })
1703
- ]
1704
- }),
1705
- /* @__PURE__ */ N("span", {
1706
- className: "vdt:text-foreground-subtle vdt:ml-auto",
1707
- children: [
1708
- e.subscriberCount,
1709
- " ",
1710
- t.clients(e.subscriberCount)
1711
- ]
1712
- })
1713
- ]
1714
- }), /* @__PURE__ */ M("div", {
1715
- className: "vdt:text-[11px] vdt:font-mono vdt:text-foreground-subtle vdt:break-all",
1716
- children: Nn(e.predicate)
1717
- })]
1718
- });
1719
- }, Ln = (e) => {
1720
- let t = Tn(e), n = 0;
1721
- for (let e of t) n += e.response?.subscriptions.length ?? 0;
1722
- return n;
1723
- }, Rn = {
1724
- outgoing: [],
1725
- incoming: [],
1726
- targets: [],
1727
- deliveries: []
1728
- }, zn = 4e3, Bn = async (e, t) => {
1729
- if (e === "") return null;
1730
- let n = await _n(`${e}/_voltro/inspect/webhooks`, t);
1731
- return n !== null && Array.isArray(n.outgoing) && Array.isArray(n.incoming) ? n : null;
1732
- }, Vn = (e, t = !0) => {
1733
- let n = $(), r = Q(), a = t && n && e !== "", [o, s] = l(Rn);
1734
- return i(() => {
1735
- if (!a) return;
1736
- let t = !1, n = async () => {
1737
- let n = await Bn(e, r);
1738
- t || n === null || s(n);
1739
- };
1740
- n();
1741
- let i = setInterval(n, zn);
1742
- return () => {
1743
- t = !0, clearInterval(i);
1744
- };
1745
- }, [
1746
- e,
1747
- a,
1748
- r
1749
- ]), o;
1750
- }, Hn = {
1751
- pending: "neutral",
1752
- inFlight: "info",
1753
- succeeded: "success",
1754
- failed: "danger",
1755
- retryScheduled: "warning"
1756
- }, Un = (e) => {
1757
- let t = new Date(e), n = (e) => e < 10 ? `0${e}` : String(e);
1758
- return `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
1759
- }, Wn = (e) => {
1760
- let t = O(), n = $(), r = Q(), a = t.names.join(","), [o, s] = l(0), c = e && n;
1761
- return i(() => {
1762
- if (!c) {
1763
- s(0);
1764
- return;
1765
- }
1766
- let e = a === "" ? [] : a.split(",").map((e) => t.get(e).inspectBaseUrl).filter((e) => e !== "");
1767
- if (e.length === 0) {
1768
- s(0);
1769
- return;
1770
- }
1771
- let n = !1, i = async () => {
1772
- let t = await Promise.all(e.map((e) => Bn(e, r)));
1773
- n || s(t.reduce((e, t) => e + (t === null ? 0 : t.outgoing.length + t.incoming.length + t.targets.length), 0));
1774
- };
1775
- i();
1776
- let o = setInterval(i, zn);
1777
- return () => {
1778
- n = !0, clearInterval(o);
1779
- };
1780
- }, [
1781
- t,
1782
- a,
1783
- c,
1784
- r
1785
- ]), o;
1786
- }, Gn = ({ apiName: e, baseUrl: t }) => {
1787
- let n = Vn(t), r = U().webhooks;
1788
- return n.outgoing.length + n.incoming.length + n.targets.length + n.deliveries.length > 0 ? /* @__PURE__ */ M("div", {
1789
- className: "vdt:space-y-4",
1790
- children: /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
1791
- Icon: be,
1792
- children: e
1793
- }), /* @__PURE__ */ N(We, { children: [
1794
- n.outgoing.length > 0 ? /* @__PURE__ */ N("div", {
1795
- className: "vdt:mb-4",
1796
- children: [/* @__PURE__ */ M("div", {
1797
- className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1798
- children: r.outgoing(n.outgoing.length)
1799
- }), /* @__PURE__ */ M("div", {
1800
- className: "vdt:space-y-1",
1801
- children: n.outgoing.map((e) => /* @__PURE__ */ N("div", {
1802
- className: "vdt-record-row vdt:text-sm",
1803
- children: [
1804
- /* @__PURE__ */ M("code", {
1805
- className: "vdt:text-foreground vdt:font-mono",
1806
- children: e.id
1807
- }),
1808
- /* @__PURE__ */ N(G, {
1809
- tone: "neutral",
1810
- children: ["v", e.version]
1811
- }),
1812
- e.description ? /* @__PURE__ */ M("span", {
1813
- className: "vdt-record-description vdt:text-foreground-muted vdt:text-xs",
1814
- children: e.description
1815
- }) : null
1816
- ]
1817
- }, e.id))
1818
- })]
1819
- }) : null,
1820
- n.incoming.length > 0 ? /* @__PURE__ */ N("div", {
1821
- className: "vdt:mb-4",
1822
- children: [/* @__PURE__ */ M("div", {
1823
- className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1824
- children: r.incoming(n.incoming.length)
1825
- }), /* @__PURE__ */ M("div", {
1826
- className: "vdt:space-y-1",
1827
- children: n.incoming.map((e) => /* @__PURE__ */ N("div", {
1828
- className: "vdt-record-row vdt:text-sm",
1829
- children: [
1830
- /* @__PURE__ */ M("code", {
1831
- className: "vdt:text-foreground vdt:font-mono",
1832
- children: e.path
1833
- }),
1834
- e.provider ? /* @__PURE__ */ M(G, {
1835
- tone: "info",
1836
- children: e.provider
1837
- }) : null,
1838
- e.signatureConfigured ? /* @__PURE__ */ M(G, {
1839
- tone: "success",
1840
- children: r.signed
1841
- }) : /* @__PURE__ */ M(G, {
1842
- tone: "warning",
1843
- children: r.unsigned
1844
- })
1845
- ]
1846
- }, e.id))
1847
- })]
1848
- }) : null,
1849
- n.targets.length > 0 ? /* @__PURE__ */ N("div", {
1850
- className: "vdt:mb-4",
1851
- children: [/* @__PURE__ */ M("div", {
1852
- className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1853
- children: r.targets(n.targets.length)
1854
- }), /* @__PURE__ */ M("div", {
1855
- className: "vdt:space-y-1",
1856
- children: n.targets.map((e) => {
1857
- let t = n.outgoing.find((t) => t.id === e.event)?.version ?? e.payloadVersion, i = e.payloadVersion === t ? "current" : e.payloadVersion < t ? "behind" : "ahead";
1858
- return /* @__PURE__ */ N("div", {
1859
- className: "vdt-record-row vdt:text-sm",
1860
- children: [
1861
- /* @__PURE__ */ M("code", {
1862
- className: "vdt:text-foreground vdt:font-mono",
1863
- children: e.event
1864
- }),
1865
- /* @__PURE__ */ M("span", {
1866
- className: "vdt:text-foreground-muted",
1867
- children: "→"
1868
- }),
1869
- /* @__PURE__ */ M("span", {
1870
- className: "vdt:text-foreground vdt:text-xs vdt:truncate vdt:max-w-72",
1871
- children: e.url
1872
- }),
1873
- e.active ? /* @__PURE__ */ M(G, {
1874
- tone: "success",
1875
- children: r.active
1876
- }) : /* @__PURE__ */ M(G, {
1877
- tone: "warning",
1878
- children: r.paused
1879
- }),
1880
- i === "current" ? /* @__PURE__ */ N(G, {
1881
- tone: "neutral",
1882
- children: ["v", e.payloadVersion]
1883
- }) : i === "behind" ? /* @__PURE__ */ N(G, {
1884
- tone: "warning",
1885
- children: [
1886
- "v",
1887
- e.payloadVersion,
1888
- " ← current v",
1889
- t
1890
- ]
1891
- }) : /* @__PURE__ */ N(G, {
1892
- tone: "danger",
1893
- children: [
1894
- "v",
1895
- e.payloadVersion,
1896
- " → ahead of v",
1897
- t
1898
- ]
1899
- })
1900
- ]
1901
- }, e.id);
1902
- })
1903
- })]
1904
- }) : null,
1905
- n.deliveries.length > 0 ? /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ M("div", {
1906
- className: "vdt:text-foreground-muted vdt:text-xs vdt:uppercase vdt:tracking-wider vdt:mb-2",
1907
- children: r.deliveries(n.deliveries.length)
1908
- }), /* @__PURE__ */ M("div", {
1909
- className: "vdt:space-y-0.5 vdt:font-mono vdt:text-xs",
1910
- children: n.deliveries.map((e) => /* @__PURE__ */ N("div", {
1911
- className: "vdt:flex vdt:items-center vdt:gap-2",
1912
- children: [
1913
- /* @__PURE__ */ M("span", {
1914
- className: "vdt:text-foreground-subtle",
1915
- children: Un(e.scheduledAt)
1916
- }),
1917
- /* @__PURE__ */ M("span", {
1918
- className: "vdt:text-foreground vdt:min-w-32 vdt:truncate",
1919
- children: e.event
1920
- }),
1921
- /* @__PURE__ */ M(G, {
1922
- tone: Hn[e.status],
1923
- children: e.status
1924
- }),
1925
- e.responseStatus === null ? null : /* @__PURE__ */ M("span", {
1926
- className: "vdt:text-foreground-muted",
1927
- children: e.responseStatus
1928
- }),
1929
- e.latencyMs === null ? null : /* @__PURE__ */ N("span", {
1930
- className: "vdt:text-foreground-subtle",
1931
- children: [e.latencyMs, "ms"]
1932
- }),
1933
- /* @__PURE__ */ M("span", {
1934
- className: "vdt:text-foreground-subtle",
1935
- children: r.attempt(e.attempt)
1936
- }),
1937
- e.errorMessage ? /* @__PURE__ */ M("span", {
1938
- className: "vdt:text-danger vdt:truncate vdt:max-w-64",
1939
- children: e.errorMessage
1940
- }) : null
1941
- ]
1942
- }, e.id))
1943
- })] }) : null
1944
- ] })] })
1945
- }) : null;
1946
- }, Kn = () => {
1947
- let e = O(), t = U().webhooks;
1948
- return e.names.length === 0 ? /* @__PURE__ */ M(Y, { children: t.empty }) : /* @__PURE__ */ M("div", {
1949
- className: "vdt:space-y-4 vdt:p-3",
1950
- children: e.names.map((t) => {
1951
- let n = e.get(t);
1952
- return /* @__PURE__ */ M(Gn, {
1953
- apiName: t,
1954
- baseUrl: n.inspectBaseUrl
1955
- }, t);
1956
- })
1957
- });
1958
- }, qn = (e, t) => {
1959
- let n = `${e}/_voltro/inspect/stream?channels=${encodeURIComponent(t.channels.join(","))}`, r = !1, i = !1, a = 0, o, s, c = async () => {
1960
- if (r) return;
1961
- if (Xt(e) !== void 0) {
1962
- i = !0;
1963
- return;
1964
- }
1965
- o = new AbortController();
1966
- let l;
1967
- try {
1968
- let s = await fetch(n, {
1969
- headers: fn(t.token, { accept: "text/event-stream" }),
1970
- signal: o.signal
1971
- });
1972
- if (nn(s.status)) throw Qt(await rn(e, s)), i = !0, Error(`inspect stream refused (HTTP ${s.status})`);
1973
- if (!s.ok || s.body === null) throw Error(`inspect stream HTTP ${s.status}`);
1974
- if (r) {
1975
- await s.body.cancel();
1976
- return;
1977
- }
1978
- a = 0, l = s.body.getReader();
1979
- let c = new TextDecoder(), u = "";
1980
- for (; !r;) {
1981
- let { done: e, value: n } = await l.read();
1982
- if (e) break;
1983
- if (u = (u + c.decode(n, { stream: !0 })).replace(/\r\n/g, "\n"), u.length > 1048576) throw Error("inspect stream event exceeds the size limit");
1984
- let r;
1985
- for (; (r = u.indexOf("\n\n")) !== -1;) {
1986
- let e = u.slice(0, r);
1987
- u = u.slice(r + 2);
1988
- let n = e.split("\n").filter((e) => e.startsWith("data:")).map((e) => e.slice(5).replace(/^ /, "")).join("\n");
1989
- if (n === "") continue;
1990
- let i;
1991
- try {
1992
- i = JSON.parse(n);
1993
- } catch {
1994
- continue;
1995
- }
1996
- typeof i == "object" && i && typeof i.channel == "string" && t.onEvent(i);
1997
- }
1998
- }
1999
- if (!r) throw Error("inspect stream disconnected");
2000
- } catch (e) {
2001
- r || t.onError?.(e instanceof Error ? e : Error(String(e)));
2002
- } finally {
2003
- await l?.cancel().catch(() => void 0), l?.releaseLock(), o.abort();
2004
- }
2005
- if (!r && !i) {
2006
- let e = Math.min(3e4, 1e3 * 2 ** a);
2007
- a = Math.min(a + 1, 5), s = setTimeout(() => {
2008
- c();
2009
- }, e);
2010
- }
2011
- };
2012
- return s = setTimeout(() => {
2013
- c();
2014
- }, 0), { close: () => {
2015
- r = !0, clearTimeout(s), o?.abort();
2016
- } };
2017
- }, Jn = (e, t, n, r = 250) => {
2018
- let [a, o] = l(0), s = t.join(",");
2019
- return i(() => {
2020
- if (!n || e === "") return;
2021
- let t = new Set(s.split(",")), i, a = !1, c = qn(e, {
2022
- channels: s.split(","),
2023
- token: null,
2024
- onEvent: (e) => {
2025
- !a && t.has(e.channel) && i === void 0 && (i = setTimeout(() => {
2026
- i = void 0, a || o((e) => e + 1);
2027
- }, r));
2028
- }
2029
- });
2030
- return () => {
2031
- a = !0, clearTimeout(i), c.close();
2032
- };
2033
- }, [
2034
- e,
2035
- s,
2036
- n,
2037
- r
2038
- ]), a;
2039
- }, Yn = {
2040
- queued: "neutral",
2041
- running: "info",
2042
- succeeded: "success",
2043
- failed: "danger",
2044
- cancelled: "warning",
2045
- paused: "accent",
2046
- suspended: "accent"
2047
- }, Xn = {
2048
- running: "info",
2049
- succeeded: "success",
2050
- failed: "danger"
2051
- }, Zn = 50, Qn = 1e4, $n = (e) => e == null ? "—" : e < 1e3 ? `${Math.round(e)}ms` : e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 2 : 1)}s` : `${Math.floor(e / 6e4)}m ${Math.floor(e % 6e4 / 1e3)}s`, er = (e) => {
2052
- let t = new Date(e), n = (e) => e < 10 ? `0${e}` : String(e);
2053
- return `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
2054
- }, tr = (e) => {
2055
- try {
2056
- return JSON.stringify(e, null, 2);
2057
- } catch {
2058
- return String(e);
2059
- }
2060
- }, nr = (e) => e === "running" || e === "queued", rr = (e, t) => e.durationMs ?? (nr(e.status) ? t - new Date(e.startedAt).getTime() : null), ir = (e) => {
2061
- let t = /* @__PURE__ */ new Set();
2062
- for (let n of e) {
2063
- let e = n.payload?.signalName;
2064
- typeof e == "string" && (n.eventType === "signal-awaited" && t.add(e), n.eventType === "signal-received" && t.delete(e));
2065
- }
2066
- return [...t];
2067
- }, ar = async (e, t) => {
2068
- if (e === "") return null;
2069
- let n = await _n(`${e}/_voltro/inspect/workflows/runs?limit=${Zn}`, t);
2070
- return n !== null && Array.isArray(n.runs) ? n.runs : null;
2071
- }, or = (e) => {
2072
- let t = $(), n = Q(), r = t && e !== "", a = Jn(e, ["workflowRuns"], r), [o, s] = l([]), [c, u] = l(!1);
2073
- return i(() => {
2074
- if (!r) return;
2075
- let t = !1, i = async () => {
2076
- let r = await ar(e, n);
2077
- if (!t) {
2078
- if (r === null) {
2079
- u(!0);
2080
- return;
2081
- }
2082
- u(!1), s(r);
2083
- }
2084
- };
2085
- i();
2086
- let a = setInterval(i, Qn);
2087
- return () => {
2088
- t = !0, clearInterval(a);
2089
- };
2090
- }, [
2091
- e,
2092
- r,
2093
- n,
2094
- a
2095
- ]), {
2096
- runs: o,
2097
- failed: c
2098
- };
2099
- }, sr = (e, t) => {
2100
- let n = $(), r = Q(), a = Jn(e, ["workflowSteps", "workflowEvents"], n && e !== ""), [o, s] = l([]), [c, u] = l([]);
2101
- return i(() => {
2102
- if (!n || e === "") return;
2103
- let i = !1, a = `${e}/_voltro/inspect/workflows/runs/${encodeURIComponent(t)}`, o = async () => {
2104
- let [e, t] = await Promise.all([_n(`${a}/steps`, r), _n(`${a}/events`, r)]);
2105
- i || (e !== null && Array.isArray(e.steps) && s(e.steps), t !== null && Array.isArray(t.events) && u(t.events));
2106
- };
2107
- o();
2108
- let c = setInterval(o, Qn);
2109
- return () => {
2110
- i = !0, clearInterval(c);
2111
- };
2112
- }, [
2113
- e,
2114
- t,
2115
- n,
2116
- r,
2117
- a
2118
- ]), {
2119
- steps: o,
2120
- events: c
2121
- };
2122
- }, cr = (e) => {
2123
- let t = O(), n = $(), r = Q(), a = t.names.join(","), [o, s] = l(0), c = e && n, u = Jn(a === "" ? "" : t.get(a.split(",")[0]).inspectBaseUrl ?? "", ["workflowRuns"], c);
2124
- return i(() => {
2125
- if (!c) {
2126
- s(0);
2127
- return;
2128
- }
2129
- let e = a === "" ? [] : a.split(",").map((e) => t.get(e).inspectBaseUrl).filter((e) => e !== "");
2130
- if (e.length === 0) {
2131
- s(0);
2132
- return;
2133
- }
2134
- let n = !1, i = async () => {
2135
- let t = await Promise.all(e.map((e) => ar(e, r)));
2136
- n || s(t.reduce((e, t) => e + (t === null ? 0 : t.filter((e) => nr(e.status)).length), 0));
2137
- };
2138
- i();
2139
- let o = setInterval(i, Qn);
2140
- return () => {
2141
- n = !0, clearInterval(o);
2142
- };
2143
- }, [
2144
- t,
2145
- a,
2146
- c,
2147
- r,
2148
- u
2149
- ]), o;
2150
- }, lr = () => {
2151
- let e = O(), t = U().workflows;
2152
- return e.names.length === 0 ? /* @__PURE__ */ M(Y, { children: t.noApi }) : /* @__PURE__ */ M("div", {
2153
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
2154
- children: e.names.map((e) => /* @__PURE__ */ M(ur, { apiName: e }, e))
2155
- });
2156
- }, ur = ({ apiName: e }) => {
2157
- let t = O(), n = U().workflows, r = t.get(e), a = r.inspectBaseUrl, o = s(() => Object.entries(r.descriptors).filter(([, e]) => e.kind === "workflow").map(([e]) => e).sort(), [r.descriptors]), { runs: c, failed: u } = or(a), d = c.filter((e) => nr(e.status)).length, [f, p] = l(null), [m, h] = l(() => Date.now());
2158
- return i(() => {
2159
- if (d === 0) return;
2160
- let e = setInterval(() => h(Date.now()), 1e3);
2161
- return () => clearInterval(e);
2162
- }, [d]), /* @__PURE__ */ N(K, { children: [
2163
- /* @__PURE__ */ M(q, {
2164
- Icon: xe,
2165
- right: d > 0 ? /* @__PURE__ */ M(G, {
2166
- tone: "info",
2167
- children: n.runningBadge(d)
2168
- }) : /* @__PURE__ */ M(G, {
2169
- tone: "neutral",
2170
- children: n.runsBadge(c.length)
2171
- }),
2172
- children: e
2173
- }),
2174
- /* @__PURE__ */ M(dr, {
2175
- apiName: e,
2176
- definitions: o,
2177
- runs: c
2178
- }),
2179
- /* @__PURE__ */ N("div", {
2180
- className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
2181
- children: [/* @__PURE__ */ M("div", {
2182
- className: "vdt:text-foreground-muted vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:mb-1.5",
2183
- children: n.runs(c.length)
2184
- }), u ? /* @__PURE__ */ M("div", {
2185
- className: "vdt:text-xs vdt:text-danger",
2186
- children: n.runsUnavailable
2187
- }) : c.length === 0 ? /* @__PURE__ */ M("div", {
2188
- className: "vdt:text-xs vdt:text-foreground-subtle",
2189
- children: o.length === 0 ? n.noDefinitions : n.noRuns
2190
- }) : /* @__PURE__ */ M("div", {
2191
- className: "vdt:flex vdt:flex-col vdt:gap-0.5",
2192
- children: c.map((e) => /* @__PURE__ */ N("div", {
2193
- "data-run-id": e.id,
2194
- "data-run-status": e.status,
2195
- children: [/* @__PURE__ */ N("button", {
2196
- type: "button",
2197
- "aria-expanded": f === e.id,
2198
- onClick: () => p(f === e.id ? null : e.id),
2199
- className: "vdt:w-full vdt:flex vdt:items-center vdt:gap-2 vdt:text-left vdt:text-xs vdt:px-1.5 vdt:py-1 vdt:rounded-sm vdt:hover:bg-muted",
2200
- children: [
2201
- /* @__PURE__ */ M("span", {
2202
- className: "vdt:text-foreground-subtle vdt:w-2",
2203
- children: f === e.id ? "▾" : "▸"
2204
- }),
2205
- /* @__PURE__ */ M(G, {
2206
- tone: Yn[e.status] ?? "neutral",
2207
- children: e.status
2208
- }),
2209
- /* @__PURE__ */ M("code", {
2210
- className: "vdt:font-mono vdt:text-foreground vdt:truncate",
2211
- children: e.tag
2212
- }),
2213
- e.parentExecutionId === null ? null : /* @__PURE__ */ M(G, {
2214
- tone: "neutral",
2215
- children: n.child
2216
- }),
2217
- e.errorMessage === null ? null : /* @__PURE__ */ N("span", {
2218
- className: "vdt:text-danger vdt:truncate vdt:font-mono vdt:text-[11px]",
2219
- children: [e.errorTag === null ? "" : `${e.errorTag} · `, e.errorMessage]
2220
- }),
2221
- /* @__PURE__ */ M("span", {
2222
- className: "vdt:ml-auto vdt:tabular-nums vdt:text-foreground-muted vdt:whitespace-nowrap",
2223
- children: $n(rr(e, m))
2224
- }),
2225
- /* @__PURE__ */ M("span", {
2226
- className: "vdt:tabular-nums vdt:text-foreground-subtle vdt:whitespace-nowrap",
2227
- children: er(e.startedAt)
2228
- })
2229
- ]
2230
- }), f === e.id ? /* @__PURE__ */ M(fr, {
2231
- baseUrl: a,
2232
- run: e
2233
- }) : null]
2234
- }, e.id))
2235
- })]
2236
- })
2237
- ] });
2238
- }, dr = ({ apiName: e, definitions: t, runs: n }) => {
2239
- let r = U().workflows, [a, o] = l(t[0] ?? "");
2240
- i(() => {
2241
- a === "" && t.length > 0 && o(t[0]);
2242
- }, [t, a]);
2243
- let c = s(() => {
2244
- let e = n.find((e) => e.tag === a);
2245
- return e === void 0 ? "{}" : tr(e.payload);
2246
- }, [n, a]), [u, d] = l(c), [f, p] = l(!1);
2247
- i(() => {
2248
- f || d(c);
2249
- }, [c, f]);
2250
- let [m, h] = l(null), g = A(e, a === "" ? "__voltro.devtools.none" : a);
2251
- if (t.length === 0) return null;
2252
- let _ = async () => {
2253
- let e;
2254
- try {
2255
- e = u.trim() === "" ? {} : JSON.parse(u);
2256
- } catch (e) {
2257
- h({
2258
- tone: "danger",
2259
- text: r.invalidJson(e instanceof Error ? e.message : String(e))
2260
- });
2261
- return;
2262
- }
2263
- h(null);
2264
- try {
2265
- let t = await g.start(e);
2266
- h({
2267
- tone: "success",
2268
- text: r.started(t.executionId ?? t.id, t.status)
2269
- }), p(!1);
2270
- } catch (e) {
2271
- h({
2272
- tone: "danger",
2273
- text: r.startFailed(e instanceof Error ? e.message : String(e))
2274
- });
2275
- }
2276
- };
2277
- return /* @__PURE__ */ N("div", {
2278
- className: "vdt:px-3 vdt:py-2 vdt:flex vdt:flex-col vdt:gap-1.5",
2279
- children: [
2280
- /* @__PURE__ */ N("div", {
2281
- className: "vdt:flex vdt:items-center vdt:gap-2",
2282
- children: [
2283
- /* @__PURE__ */ M("span", {
2284
- className: "vdt:text-foreground-muted vdt:text-[10px] vdt:uppercase vdt:tracking-wider",
2285
- children: r.start
2286
- }),
2287
- /* @__PURE__ */ M("select", {
2288
- "aria-label": r.workflowLabel,
2289
- value: a,
2290
- onChange: (e) => {
2291
- o(e.target.value), p(!1), h(null);
2292
- },
2293
- className: "vdt:text-xs vdt:font-mono vdt:bg-background vdt:border vdt:border-border vdt:rounded-sm vdt:px-1.5 vdt:py-0.5 vdt:text-foreground",
2294
- children: t.map((e) => /* @__PURE__ */ M("option", {
2295
- value: e,
2296
- children: e
2297
- }, e))
2298
- }),
2299
- /* @__PURE__ */ M("span", { className: "vdt:sp" }),
2300
- /* @__PURE__ */ M(W, {
2301
- onClick: () => {
2302
- _();
2303
- },
2304
- disabled: g.pending || a === "",
2305
- children: g.pending ? r.starting : r.start
2306
- })
2307
- ]
2308
- }),
2309
- /* @__PURE__ */ M("textarea", {
2310
- "aria-label": r.payloadLabel,
2311
- value: u,
2312
- onChange: (e) => {
2313
- d(e.target.value), p(!0);
2314
- },
2315
- spellCheck: !1,
2316
- rows: Math.min(8, Math.max(2, u.split("\n").length)),
2317
- className: "vdt:w-full vdt:text-[11px] vdt:font-mono vdt:bg-background vdt:border vdt:border-border vdt:rounded-sm vdt:px-2 vdt:py-1 vdt:text-foreground vdt:resize-y"
2318
- }),
2319
- /* @__PURE__ */ M("div", {
2320
- className: "vdt:text-[10px] vdt:text-foreground-subtle",
2321
- children: r.payloadHint
2322
- }),
2323
- m === null ? null : /* @__PURE__ */ M("div", {
2324
- role: m.tone === "danger" ? "alert" : "status",
2325
- className: `vdt:text-xs ${m.tone === "danger" ? "vdt:text-danger" : "vdt:text-success"}`,
2326
- children: m.text
2327
- })
2328
- ]
2329
- });
2330
- }, fr = ({ baseUrl: e, run: t }) => {
2331
- let n = U().workflows, r = Q(), { steps: a, events: o } = sr(e, t.id), c = s(() => ir(o), [o]), [u, d] = l(""), [f, p] = l("{}"), [m, h] = l(!1), [g, _] = l(null);
2332
- i(() => {
2333
- u === "" && c.length > 0 && d(c[0]);
2334
- }, [c, u]);
2335
- let [v, y] = l(null), b = t.status === "running" || t.status === "queued" || t.status === "suspended", x = `${e}/_voltro/inspect/workflows/runs/${encodeURIComponent(t.id)}`, S = async (e, t) => {
2336
- _(null), h(!0);
2337
- try {
2338
- _({
2339
- tone: "success",
2340
- text: await t()
2341
- });
2342
- } catch (t) {
2343
- _({
2344
- tone: "danger",
2345
- text: n.actionFailed(e, t instanceof Error ? t.message : String(t))
2346
- });
2347
- } finally {
2348
- h(!1);
2349
- }
2350
- }, C = () => S(n.cancel, async () => {
2351
- let e = await gn(`${x}/cancel`, r, {});
2352
- return n.cancelResult(typeof e.kind == "string" ? e.kind : e.cancelled === !0 ? "confirmed" : "submitted");
2353
- }), w = () => S(n.sendSignal, async () => {
2354
- let e;
2355
- try {
2356
- e = f.trim() === "" ? void 0 : JSON.parse(f);
2357
- } catch (e) {
2358
- throw Error(n.invalidJson(e instanceof Error ? e.message : String(e)));
2359
- }
2360
- return await gn(`${x}/signal`, r, e === void 0 ? { signalName: u } : {
2361
- signalName: u,
2362
- payload: e
2363
- }), n.signalSent(u);
2364
- });
2365
- return /* @__PURE__ */ N("div", {
2366
- className: "vdt:ml-4 vdt:pl-2 vdt:border-l vdt:border-border vdt:py-1 vdt:flex vdt:flex-col vdt:gap-2 vdt:text-xs",
2367
- children: [
2368
- /* @__PURE__ */ N("div", {
2369
- className: "vdt:grid vdt:grid-cols-1 vdt:sm:grid-cols-2 vdt:gap-2",
2370
- children: [/* @__PURE__ */ M(pr, {
2371
- label: n.payloadLabel,
2372
- value: t.payload
2373
- }), /* @__PURE__ */ M(pr, {
2374
- label: t.status === "failed" ? n.error : n.output,
2375
- value: t.status === "failed" ? {
2376
- tag: t.errorTag,
2377
- message: t.errorMessage
2378
- } : t.output
2379
- })]
2380
- }),
2381
- /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ M("div", {
2382
- className: "vdt:text-foreground-muted vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:mb-1",
2383
- children: n.steps(a.length)
2384
- }), a.length === 0 ? /* @__PURE__ */ M("div", {
2385
- className: "vdt:text-foreground-subtle",
2386
- children: n.noSteps
2387
- }) : /* @__PURE__ */ M("div", {
2388
- className: "vdt:flex vdt:flex-col vdt:gap-0.5",
2389
- children: a.map((e) => /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ N("button", {
2390
- type: "button",
2391
- onClick: () => y(v === e.id ? null : e.id),
2392
- className: "vdt:w-full vdt:flex vdt:items-center vdt:gap-2 vdt:text-left vdt:px-1 vdt:py-0.5 vdt:rounded-sm vdt:hover:bg-muted",
2393
- children: [
2394
- /* @__PURE__ */ M(G, {
2395
- tone: Xn[e.status] ?? "info",
2396
- children: e.status
2397
- }),
2398
- /* @__PURE__ */ M("code", {
2399
- className: "vdt:font-mono vdt:text-foreground",
2400
- children: e.stepName
2401
- }),
2402
- e.attempt > 1 ? /* @__PURE__ */ M("span", {
2403
- className: "vdt:text-warning",
2404
- children: n.attempt(e.attempt)
2405
- }) : null,
2406
- e.errorMessage === null ? null : /* @__PURE__ */ M("span", {
2407
- className: "vdt:text-danger vdt:truncate vdt:font-mono vdt:text-[11px]",
2408
- children: e.errorMessage
2409
- }),
2410
- /* @__PURE__ */ M("span", {
2411
- className: "vdt:ml-auto vdt:tabular-nums vdt:text-foreground-muted",
2412
- children: $n(e.durationMs)
2413
- })
2414
- ]
2415
- }), v === e.id ? /* @__PURE__ */ N("div", {
2416
- className: "vdt:ml-3 vdt:grid vdt:grid-cols-1 vdt:sm:grid-cols-2 vdt:gap-2 vdt:py-1",
2417
- children: [/* @__PURE__ */ M(pr, {
2418
- label: n.input,
2419
- value: e.input
2420
- }), /* @__PURE__ */ M(pr, {
2421
- label: e.status === "failed" ? n.error : n.output,
2422
- value: e.status === "failed" ? e.errorCause ?? {
2423
- tag: e.errorTag,
2424
- message: e.errorMessage
2425
- } : e.output
2426
- })]
2427
- }) : null] }, e.id))
2428
- })] }),
2429
- o.length > 0 ? /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ M("div", {
2430
- className: "vdt:text-foreground-muted vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:mb-1",
2431
- children: n.events(o.length)
2432
- }), /* @__PURE__ */ M("div", {
2433
- className: "vdt:flex vdt:flex-wrap vdt:gap-1",
2434
- children: o.map((e) => /* @__PURE__ */ N("span", {
2435
- title: er(e.occurredAt),
2436
- className: "vdt:inline-flex vdt:items-center vdt:gap-1 vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted vdt:border vdt:border-border vdt:rounded-sm vdt:px-1",
2437
- children: [e.eventType, e.stepName === null ? "" : ` · ${e.stepName}`]
2438
- }, e.id))
2439
- })] }) : null,
2440
- /* @__PURE__ */ N("div", {
2441
- className: "vdt:flex vdt:flex-wrap vdt:items-center vdt:gap-2",
2442
- children: [
2443
- b ? /* @__PURE__ */ M(W, {
2444
- onClick: () => {
2445
- C();
2446
- },
2447
- disabled: m,
2448
- children: n.cancel
2449
- }) : null,
2450
- c.length > 0 && t.status === "running" ? /* @__PURE__ */ N(j, { children: [
2451
- /* @__PURE__ */ M("span", {
2452
- className: "vdt:text-foreground-muted",
2453
- children: n.awaiting
2454
- }),
2455
- /* @__PURE__ */ M("select", {
2456
- "aria-label": n.signalName,
2457
- value: u,
2458
- onChange: (e) => d(e.target.value),
2459
- className: "vdt:text-xs vdt:font-mono vdt:bg-background vdt:border vdt:border-border vdt:rounded-sm vdt:px-1.5 vdt:py-0.5 vdt:text-foreground",
2460
- children: c.map((e) => /* @__PURE__ */ M("option", {
2461
- value: e,
2462
- children: e
2463
- }, e))
2464
- }),
2465
- /* @__PURE__ */ M("input", {
2466
- "aria-label": n.signalPayload,
2467
- value: f,
2468
- onChange: (e) => p(e.target.value),
2469
- spellCheck: !1,
2470
- className: "vdt:text-[11px] vdt:font-mono vdt:bg-background vdt:border vdt:border-border vdt:rounded-sm vdt:px-1.5 vdt:py-0.5 vdt:text-foreground vdt:min-w-32"
2471
- }),
2472
- /* @__PURE__ */ M(W, {
2473
- onClick: () => {
2474
- w();
2475
- },
2476
- disabled: m || u === "",
2477
- children: n.sendSignal
2478
- })
2479
- ] }) : null,
2480
- t.traceId === null ? null : /* @__PURE__ */ N("span", {
2481
- className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-subtle",
2482
- children: [
2483
- n.trace,
2484
- " · ",
2485
- t.traceId
2486
- ]
2487
- })
2488
- ]
2489
- }),
2490
- g === null ? null : /* @__PURE__ */ M("div", {
2491
- role: g.tone === "danger" ? "alert" : "status",
2492
- className: g.tone === "danger" ? "vdt:text-danger" : "vdt:text-success",
2493
- children: g.text
2494
- })
2495
- ]
2496
- });
2497
- }, pr = ({ label: e, value: t }) => /* @__PURE__ */ N("div", {
2498
- className: "vdt:min-w-0",
2499
- children: [/* @__PURE__ */ M("div", {
2500
- className: "vdt:text-foreground-muted vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:mb-0.5",
2501
- children: e
2502
- }), t == null ? /* @__PURE__ */ M("div", {
2503
- className: "vdt:text-foreground-subtle",
2504
- children: "—"
2505
- }) : /* @__PURE__ */ M("pre", {
2506
- className: "vdt:overflow-x-auto vdt:text-[11px] vdt:font-mono vdt:p-1.5 vdt:rounded-sm vdt:bg-background vdt:border vdt:border-border vdt:text-foreground vdt:whitespace-pre-wrap vdt:break-all",
2507
- children: tr(t)
2508
- })]
2509
- }), mr = (e) => {
2510
- try {
2511
- return JSON.stringify(e, null, 2);
2512
- } catch {
2513
- return String(e);
2514
- }
2515
- }, hr = () => u(h, f, f), gr = () => {
2516
- let [e, t] = l(() => typeof window > "u" ? "/" : window.location.pathname);
2517
- return i(() => {
2518
- if (typeof window > "u") return;
2519
- let e = () => t(window.location.pathname);
2520
- window.addEventListener("popstate", e);
2521
- let n = setInterval(e, 1e3);
2522
- return () => {
2523
- window.removeEventListener("popstate", e), clearInterval(n);
2524
- };
2525
- }, []), e;
2526
- }, _r = () => {
2527
- let e = hr(), t = gr(), n = U().routes, [r, i] = l(!0), a = e.pathname === "/" && Object.keys(e.params).length === 0 && e.loaderData === void 0 && t !== "/" ? t : e.pathname, o = Object.entries(e.params).map(([e, t]) => ({
2528
- key: e,
2529
- value: String(t)
2530
- }));
2531
- return /* @__PURE__ */ N("div", {
2532
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
2533
- children: [/* @__PURE__ */ N(K, { children: [
2534
- /* @__PURE__ */ M(q, {
2535
- Icon: ge,
2536
- children: n.currentRoute
2537
- }),
2538
- /* @__PURE__ */ M(J, { entries: [{
2539
- key: "pathname",
2540
- value: a
2541
- }, {
2542
- key: "params",
2543
- value: o.length === 0 ? "—" : ""
2544
- }] }),
2545
- o.length > 0 ? /* @__PURE__ */ M("div", {
2546
- className: "vdt:px-3 vdt:pb-3",
2547
- children: /* @__PURE__ */ M(J, { entries: o })
2548
- }) : null
2549
- ] }), /* @__PURE__ */ N(K, { children: [
2550
- /* @__PURE__ */ M(q, {
2551
- Icon: ge,
2552
- children: n.loaderData
2553
- }),
2554
- /* @__PURE__ */ M("button", {
2555
- onClick: () => i((e) => !e),
2556
- className: "vdt:px-3 vdt:py-1.5 vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:hover:text-foreground",
2557
- children: r ? n.collapse : n.expand
2558
- }),
2559
- r ? e.loaderData === void 0 ? /* @__PURE__ */ N(Y, { children: [n.noLoaderTitle, /* @__PURE__ */ M("div", {
2560
- className: "vdt:mt-1 vdt:text-foreground-subtle",
2561
- children: n.noLoaderHint(/* @__PURE__ */ M("code", { children: "<Router>" }))
2562
- })] }) : /* @__PURE__ */ M("pre", {
2563
- className: "vdt:px-3 vdt:pb-3 vdt:text-[11px] vdt:max-h-80 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
2564
- children: mr(e.loaderData)
2565
- }) : null
2566
- ] })]
2567
- });
2568
- }, vr = (e) => {
2569
- let t = 0, n = 0, r = 0, i = 0, a = 0;
2570
- for (let o of Object.values(e)) o.kind === "query" && (t += 1), o.kind === "mutation" && (n += 1), o.kind === "action" && (r += 1), o.kind === "stream" && (i += 1), o.kind === "workflow" && (a += 1);
2571
- return {
2572
- queries: t,
2573
- mutations: n,
2574
- actions: r,
2575
- streams: i,
2576
- workflows: a
2577
- };
2578
- }, yr = () => {
2579
- let e = O(), t = U().runtimes, n = e.names;
2580
- return n.length === 0 ? /* @__PURE__ */ N(Y, { children: [t.emptyTitle, /* @__PURE__ */ M("div", {
2581
- className: "vdt:mt-1 vdt:text-foreground-subtle",
2582
- children: t.emptyHint
2583
- })] }) : /* @__PURE__ */ M("div", {
2584
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
2585
- children: n.map((n) => {
2586
- let r = e.get(n), i = vr(r.descriptors);
2587
- return /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2588
- Icon: _e,
2589
- right: /* @__PURE__ */ M(G, {
2590
- tone: "success",
2591
- children: t.live
2592
- }),
2593
- children: n
2594
- }), /* @__PURE__ */ M(J, { entries: [
2595
- {
2596
- key: "queries",
2597
- value: String(i.queries)
2598
- },
2599
- {
2600
- key: "mutations",
2601
- value: String(i.mutations)
2602
- },
2603
- {
2604
- key: "actions",
2605
- value: String(i.actions)
2606
- },
2607
- {
2608
- key: "streams",
2609
- value: String(i.streams)
2610
- },
2611
- {
2612
- key: "workflows",
2613
- value: String(i.workflows)
2614
- },
2615
- {
2616
- key: "cacheSize",
2617
- value: String(r.cache.size())
2618
- },
2619
- {
2620
- key: "descriptors",
2621
- value: String(Object.keys(r.descriptors).length)
2622
- }
2623
- ] })] }, n);
2624
- })
2625
- });
2626
- }, br = (e, t) => ({
2627
- supported: t,
2628
- scope: e?.scope ?? null,
2629
- scriptUrl: e?.active?.scriptURL ?? e?.waiting?.scriptURL ?? e?.installing?.scriptURL ?? null,
2630
- installing: e?.installing?.state ?? null,
2631
- waiting: e?.waiting?.state ?? null,
2632
- active: e?.active?.state ?? null,
2633
- backgroundSync: e != null && "sync" in e && e.sync !== void 0
2634
- }), xr = (e) => e.filter((e) => e.startsWith("voltro-")).sort(), Sr = (e) => {
2635
- try {
2636
- return new URL(e).host;
2637
- } catch {
2638
- return "(unparseable endpoint)";
2639
- }
2640
- }, Cr = async () => {
2641
- let e = typeof navigator > "u" ? void 0 : navigator, t = e?.serviceWorker !== void 0, n = t ? await e.serviceWorker.getRegistration().catch(() => void 0) : void 0, r = br(n ?? null, t), i = globalThis.caches, a = i ? xr(await i.keys().catch(() => [])) : [], o = [];
2642
- for (let e of a) {
2643
- let t = i ? await i.open(e).then((e) => e.keys()).then((e) => e.length).catch(() => 0) : 0;
2644
- o.push({
2645
- name: e,
2646
- entries: t
2647
- });
2648
- }
2649
- let s = globalThis.Notification, c = null;
2650
- if (n?.pushManager) {
2651
- let e = await n.pushManager.getSubscription().catch(() => null);
2652
- c = e ? Sr(e.endpoint) : null;
2653
- }
2654
- return {
2655
- worker: r,
2656
- caches: o,
2657
- pushPermission: s?.permission ?? null,
2658
- pushEndpointHost: c
2659
- };
2660
- }, wr = (e) => e === "activated" ? "success" : e === null ? "neutral" : "warning", Tr = () => {
2661
- let e = U().pwa, t = _(), r = v(), a = y(), o = k(), [s, c] = l(null), u = n(() => {
2662
- Cr().then(c);
2663
- }, []);
2664
- if (i(() => {
2665
- u();
2666
- let e = typeof navigator > "u" ? void 0 : navigator;
2667
- return e?.serviceWorker?.addEventListener?.("controllerchange", u), () => {
2668
- e?.serviceWorker?.removeEventListener?.("controllerchange", u);
2669
- };
2670
- }, [u]), s === null) return /* @__PURE__ */ M(Y, { children: e.loading });
2671
- if (!s.worker.supported) return /* @__PURE__ */ M(Y, { children: e.unsupported });
2672
- let d = s.worker;
2673
- return /* @__PURE__ */ N("div", {
2674
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
2675
- children: [
2676
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2677
- Icon: _e,
2678
- right: /* @__PURE__ */ M(W, {
2679
- size: "sm",
2680
- onClick: u,
2681
- children: e.refresh
2682
- }),
2683
- children: e.worker
2684
- }), /* @__PURE__ */ M(J, { entries: [
2685
- {
2686
- key: e.scope,
2687
- value: d.scope ?? e.none
2688
- },
2689
- {
2690
- key: e.script,
2691
- value: d.scriptUrl ?? e.none
2692
- },
2693
- {
2694
- key: "installing",
2695
- value: /* @__PURE__ */ M(G, {
2696
- tone: wr(d.installing),
2697
- children: d.installing ?? e.none
2698
- })
2699
- },
2700
- {
2701
- key: "waiting",
2702
- value: /* @__PURE__ */ M(G, {
2703
- tone: wr(d.waiting),
2704
- children: d.waiting ?? e.none
2705
- })
2706
- },
2707
- {
2708
- key: "active",
2709
- value: /* @__PURE__ */ M(G, {
2710
- tone: wr(d.active),
2711
- children: d.active ?? e.none
2712
- })
2713
- },
2714
- {
2715
- key: e.backgroundSync,
2716
- value: d.backgroundSync ? e.yes : e.no
2717
- }
2718
- ] })] }),
2719
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2720
- right: /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(W, {
2721
- size: "sm",
2722
- onClick: () => {
2723
- t.check();
2724
- },
2725
- children: e.checkNow
2726
- }), /* @__PURE__ */ M(W, {
2727
- size: "sm",
2728
- variant: "accent",
2729
- disabled: !t.updateAvailable,
2730
- onClick: () => {
2731
- t.apply({ force: !0 });
2732
- },
2733
- children: e.forceUpdate
2734
- })] }),
2735
- children: e.update
2736
- }), /* @__PURE__ */ M(J, { entries: [
2737
- {
2738
- key: e.currentBuild,
2739
- value: o.platform.appVersion ?? e.unknown
2740
- },
2741
- {
2742
- key: e.waitingBuild,
2743
- value: t.updateAvailable ? t.version ?? e.unknown : e.none
2744
- },
2745
- {
2746
- key: e.online,
2747
- value: a.online ? e.yes : e.no
2748
- }
2749
- ] })] }),
2750
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, { children: e.precache }), s.caches.length === 0 ? /* @__PURE__ */ M("div", {
2751
- className: "vdt:px-3 vdt:py-2 vdt:text-xs vdt:text-foreground-subtle",
2752
- children: e.noCaches
2753
- }) : /* @__PURE__ */ M(J, { entries: s.caches.map((t) => ({
2754
- key: t.name,
2755
- value: e.entries(t.entries)
2756
- })) })] }),
2757
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2758
- right: r.canInstall ? /* @__PURE__ */ M(W, {
2759
- size: "sm",
2760
- onClick: () => {
2761
- r.install();
2762
- },
2763
- children: e.install
2764
- }) : void 0,
2765
- children: e.installAndPush
2766
- }), /* @__PURE__ */ M(J, { entries: [
2767
- {
2768
- key: e.installed,
2769
- value: r.installed ? e.yes : e.no
2770
- },
2771
- {
2772
- key: e.installPrompt,
2773
- value: r.platform
2774
- },
2775
- {
2776
- key: e.pushPermission,
2777
- value: s.pushPermission ?? e.unknown
2778
- },
2779
- {
2780
- key: e.pushSubscription,
2781
- value: s.pushEndpointHost ?? e.none
2782
- }
2783
- ] })] })
2784
- ]
2785
- });
2786
- }, Er = (e) => Object.entries(e ?? {}).filter(([, e]) => e === !0).map(([e]) => e).sort(), Dr = (e) => [e.fullscreen ? "fullscreen" : e.maximized ? "maximized" : "windowed", e.focused ? "focused" : "unfocused"].join(", "), Or = () => {
2787
- let e = U().desktop, t = k(), r = te("desktop"), [a, o] = l(0), [s, c] = l(null), [u, d] = l(null), f = n(() => o((e) => e + 1), []);
2788
- if (i(() => {
2789
- if (!r) return;
2790
- let e = r.window.subscribe(f), t = r.os.onThemeChange(f);
2791
- return () => {
2792
- e(), t();
2793
- };
2794
- }, [r, f]), i(() => {
2795
- let e = t.storage("local");
2796
- if (e === null) {
2797
- d(null);
2798
- return;
2799
- }
2800
- C(e).then(d);
2801
- }, [t, a]), !r) return /* @__PURE__ */ M(Y, { children: e.notDesktop });
2802
- let p = Er(t.capabilities);
2803
- return /* @__PURE__ */ N("div", {
2804
- className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
2805
- children: [
2806
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2807
- Icon: Oe,
2808
- right: /* @__PURE__ */ M(W, {
2809
- size: "sm",
2810
- onClick: f,
2811
- children: e.refresh
2812
- }),
2813
- children: e.shell
2814
- }), /* @__PURE__ */ M(J, { entries: [
2815
- {
2816
- key: e.kind,
2817
- value: /* @__PURE__ */ M(G, {
2818
- tone: "info",
2819
- children: r.kind
2820
- })
2821
- },
2822
- {
2823
- key: e.os,
2824
- value: `${r.os.platform} ${r.os.arch} ${r.os.version}`
2825
- },
2826
- {
2827
- key: e.theme,
2828
- value: r.os.theme()
2829
- },
2830
- {
2831
- key: e.window,
2832
- value: Dr(r.window.read())
2833
- },
2834
- {
2835
- key: e.appVersion,
2836
- value: t.platform.appVersion ?? e.unknown
2837
- }
2838
- ] })] }),
2839
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, {
2840
- right: t.updates ? /* @__PURE__ */ M(W, {
2841
- size: "sm",
2842
- onClick: () => {
2843
- t.updates.check().then(c);
2844
- },
2845
- children: e.checkNow
2846
- }) : void 0,
2847
- children: e.updater
2848
- }), /* @__PURE__ */ M(J, { entries: [{
2849
- key: e.updaterPort,
2850
- value: t.updates ? e.yes : e.no
2851
- }, {
2852
- key: e.waitingVersion,
2853
- value: s?.version ?? e.none
2854
- }] })] }),
2855
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, { children: e.localStack }), /* @__PURE__ */ M(J, { entries: [
2856
- {
2857
- key: e.sidecarPort,
2858
- value: r.sidecar === void 0 ? e.no : e.yes
2859
- },
2860
- {
2861
- key: e.apiUrl,
2862
- value: u?.api ?? e.none
2863
- },
2864
- {
2865
- key: e.apiName,
2866
- value: u?.name ?? e.none
2867
- }
2868
- ] })] }),
2869
- /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ M(q, { children: e.capabilities }), p.length === 0 ? /* @__PURE__ */ M("div", {
2870
- className: "vdt:px-3 vdt:py-2 vdt:text-xs vdt:text-foreground-subtle",
2871
- children: e.noCapabilities
2872
- }) : /* @__PURE__ */ M("div", {
2873
- className: "vdt:flex vdt:flex-wrap vdt:gap-1 vdt:px-3 vdt:py-2",
2874
- children: p.map((e) => /* @__PURE__ */ M(G, {
2875
- tone: "neutral",
2876
- children: e
2877
- }, e))
2878
- })] })
2879
- ]
2880
- });
2881
- }, kr = () => u(ee, w, w), Ar = (e, t = 90) => {
2882
- let n;
2883
- try {
2884
- n = JSON.stringify(e) ?? String(e);
2885
- } catch {
2886
- n = String(e);
2887
- }
2888
- return n.length > t ? `${n.slice(0, t)}…` : n;
2889
- }, jr = (e, t) => typeof e != "object" || typeof t != "object" || e === null || t === null ? [] : [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])].filter((n) => !Object.is(e[n], t[n])), Mr = ({ label: e, state: t }) => {
2890
- let [n, r] = l(!1);
2891
- return /* @__PURE__ */ N("div", {
2892
- className: "vdt:border-t vdt:border-border",
2893
- children: [/* @__PURE__ */ N("button", {
2894
- type: "button",
2895
- className: "vdt:flex vdt:w-full vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-2 vdt:text-left vdt:hover:bg-muted",
2896
- onClick: () => r((e) => !e),
2897
- children: [/* @__PURE__ */ M(G, {
2898
- tone: "neutral",
2899
- children: e
2900
- }), /* @__PURE__ */ M("span", {
2901
- className: "vdt:truncate vdt:font-mono vdt:text-[11px] vdt:text-foreground-muted",
2902
- children: Ar(t)
2903
- })]
2904
- }), n ? /* @__PURE__ */ M(J, { entries: Object.entries(t).map(([e, t]) => ({
2905
- key: e,
2906
- value: Ar(t, 200)
2907
- })) }) : null]
2908
- });
2909
- }, Nr = () => {
2910
- let e = kr(), [t, n] = l(null), r = x(), i = t ?? e.length;
2911
- return /* @__PURE__ */ N(j, { children: [
2912
- /* @__PURE__ */ N(q, {
2913
- Icon: he,
2914
- right: /* @__PURE__ */ N(W, {
2915
- onClick: () => {
2916
- b(), n(null);
2917
- },
2918
- children: [/* @__PURE__ */ M(ye, {}), "Clear"]
2919
- }),
2920
- children: [
2921
- "Stores (",
2922
- r.length,
2923
- ")"
2924
- ]
2925
- }),
2926
- r.length === 0 ? /* @__PURE__ */ M(Y, { children: "No stores defined. `defineStore(name, () => state)` in a *.store.ts file." }) : r.map((e) => /* @__PURE__ */ N(K, { children: [
2927
- /* @__PURE__ */ M(q, { children: e.name }),
2928
- /* @__PURE__ */ M(Mr, {
2929
- label: "global",
2930
- state: e.get()
2931
- }),
2932
- e.keys().map((t) => /* @__PURE__ */ M(Mr, {
2933
- label: t,
2934
- state: e.get(t)
2935
- }, t))
2936
- ] }, e.name)),
2937
- /* @__PURE__ */ N(q, {
2938
- Icon: ve,
2939
- right: /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(W, {
2940
- onClick: () => {
2941
- i <= 0 || E(i - 1, "before") && n(i - 1);
2942
- },
2943
- disabled: i <= 0,
2944
- children: "◀ Back"
2945
- }), /* @__PURE__ */ M(W, {
2946
- onClick: () => {
2947
- t === null || i >= e.length || E(i, "after") && n(i + 1);
2948
- },
2949
- disabled: t === null || i >= e.length,
2950
- children: "Forward ▶"
2951
- })] }),
2952
- children: [
2953
- "Writes (",
2954
- e.length,
2955
- ")",
2956
- t === null ? "" : ` — travelled to ${i}/${e.length}`
2957
- ]
2958
- }),
2959
- e.length === 0 ? /* @__PURE__ */ M(Y, { children: "No writes yet. Every `set()` lands here, labelled if you pass one." }) : [...e].reverse().map((n, r) => {
2960
- let a = e.length - 1 - r, o = jr(n.prev, n.next);
2961
- return /* @__PURE__ */ N(K, { children: [/* @__PURE__ */ N("div", {
2962
- className: "vdt:flex vdt:items-center vdt:gap-2 vdt:px-3 vdt:py-2",
2963
- children: [
2964
- /* @__PURE__ */ M(G, {
2965
- tone: n.isUndo === !0 ? "warning" : "neutral",
2966
- children: n.store
2967
- }),
2968
- n.key === void 0 ? null : /* @__PURE__ */ M(G, {
2969
- tone: "neutral",
2970
- children: n.key
2971
- }),
2972
- n.label === void 0 ? null : /* @__PURE__ */ M("span", {
2973
- className: "vdt:truncate vdt:font-mono vdt:text-[11px] vdt:text-foreground-muted",
2974
- children: n.label
2975
- }),
2976
- t !== null && a === i ? /* @__PURE__ */ M(G, {
2977
- tone: "info",
2978
- children: "here"
2979
- }) : null
2980
- ]
2981
- }), /* @__PURE__ */ M(J, { entries: [
2982
- {
2983
- key: "changed",
2984
- value: o.length > 0 ? o.join(", ") : "(no field diff)"
2985
- },
2986
- {
2987
- key: "before",
2988
- value: Ar(n.prev)
2989
- },
2990
- {
2991
- key: "after",
2992
- value: Ar(n.next)
2993
- }
2994
- ] })] }, `${n.at}-${a}`);
2995
- })
2996
- ] });
2997
- }, Pr = (e) => typeof e == "number" ? e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s` : "—", Fr = (e) => {
2998
- try {
2999
- return JSON.stringify(e, null, 2);
3000
- } catch {
3001
- return String(e);
3002
- }
3003
- }, Ir = ({ mutation: e }) => /* @__PURE__ */ N("div", {
3004
- className: "vdt:bg-background/60",
3005
- children: [
3006
- /* @__PURE__ */ M(J, { entries: [
3007
- {
3008
- key: "id",
3009
- value: e.id
3010
- },
3011
- {
3012
- key: "api",
3013
- value: e.apiName
3014
- },
3015
- {
3016
- key: "tag",
3017
- value: e.tag
3018
- },
3019
- {
3020
- key: "status",
3021
- value: e.status
3022
- },
3023
- {
3024
- key: "startedAt",
3025
- value: new Date(e.startedAt).toISOString()
3026
- },
3027
- {
3028
- key: "settledAt",
3029
- value: e.settledAt ? new Date(e.settledAt).toISOString() : "—"
3030
- },
3031
- {
3032
- key: "duration",
3033
- value: Pr(e.durationMs)
3034
- }
3035
- ] }),
3036
- /* @__PURE__ */ N("details", {
3037
- className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
3038
- open: !0,
3039
- children: [/* @__PURE__ */ M("summary", {
3040
- className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
3041
- children: "Input"
3042
- }), /* @__PURE__ */ M("pre", {
3043
- className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
3044
- children: Fr(e.input)
3045
- })]
3046
- }),
3047
- e.status === "success" ? /* @__PURE__ */ N("details", {
3048
- className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
3049
- open: !0,
3050
- children: [/* @__PURE__ */ M("summary", {
3051
- className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
3052
- children: "Output"
3053
- }), /* @__PURE__ */ M("pre", {
3054
- className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
3055
- children: Fr(e.output)
3056
- })]
3057
- }) : null,
3058
- e.status === "error" ? /* @__PURE__ */ N("details", {
3059
- className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
3060
- open: !0,
3061
- children: [/* @__PURE__ */ M("summary", {
3062
- className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-danger vdt:cursor-pointer",
3063
- children: "Error"
3064
- }), /* @__PURE__ */ M("pre", {
3065
- className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
3066
- children: e.error instanceof Error ? `${e.error.name}: ${e.error.message}\n\n${e.error.stack ?? ""}` : Fr(e.error)
3067
- })]
3068
- }) : null
3069
- ]
3070
- }), Lr = {
3071
- trace: "vdt:text-foreground-subtle",
3072
- debug: "vdt:text-info",
3073
- info: "vdt:text-foreground",
3074
- warn: "vdt:text-warning",
3075
- error: "vdt:text-danger",
3076
- fatal: "vdt:text-danger vdt:font-bold"
3077
- }, Rr = (e) => {
3078
- if (Object.keys(e).length === 0) return "";
3079
- try {
3080
- return JSON.stringify(e, null, 2);
3081
- } catch {
3082
- return String(e);
3083
- }
3084
- }, zr = (e) => {
3085
- let t = (e) => e < 10 ? `0${e}` : String(e);
3086
- return `${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${((e) => e < 100 ? e < 10 ? `00${e}` : `0${e}` : String(e))(e.getMilliseconds())}`;
3087
- }, Br = ({ record: e }) => {
3088
- let t = Rr(e.fields);
3089
- return /* @__PURE__ */ N("div", {
3090
- className: "vdt:bg-background/60 vdt:px-3 vdt:py-2 vdt:flex vdt:flex-col vdt:gap-2",
3091
- children: [
3092
- /* @__PURE__ */ N("div", {
3093
- className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted",
3094
- children: [
3095
- zr(e.ts),
3096
- e.scope ? ` · ${e.scope}` : "",
3097
- " · ",
3098
- e.level
3099
- ]
3100
- }),
3101
- /* @__PURE__ */ M("div", {
3102
- className: ["vdt:text-xs vdt:break-words", Lr[e.level]].join(" "),
3103
- children: e.message
3104
- }),
3105
- e.fiberId ? /* @__PURE__ */ N("div", {
3106
- className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted",
3107
- children: ["fiber: ", e.fiberId]
3108
- }) : null,
3109
- t ? /* @__PURE__ */ M("pre", {
3110
- className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
3111
- children: t
3112
- }) : null,
3113
- e.cause === void 0 ? null : /* @__PURE__ */ M("pre", {
3114
- className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
3115
- children: e.cause instanceof Error ? e.cause.stack ?? `${e.cause.name}: ${e.cause.message}` : String(e.cause)
3116
- })
3117
- ]
3118
- });
3119
- }, Vr = 4e3, Hr = async (e, t, n = !1) => {
3120
- if (e === "") return null;
3121
- let r = await _n(`${e}/_voltro/inspect/traces${n ? "?includeBackground=1" : ""}`, t);
3122
- return r !== null && Array.isArray(r.traces) ? r : null;
3123
- }, Ur = [], Wr = (e, t = !1) => {
3124
- let n = O(), r = $(), a = Q(), o = n.names.join(","), [s, c] = l(Ur), u = e && r;
3125
- return i(() => {
3126
- if (!u) {
3127
- c(Ur);
3128
- return;
3129
- }
3130
- let e = o === "" ? [] : o.split(",").map((e) => ({
3131
- name: e,
3132
- baseUrl: n.get(e).inspectBaseUrl
3133
- })).filter((e) => e.baseUrl !== "");
3134
- if (e.length === 0) {
3135
- c(Ur);
3136
- return;
3137
- }
3138
- let r = !1, i = async () => {
3139
- let n = await Promise.all(e.map((e) => Hr(e.baseUrl, a, t)));
3140
- if (r) return;
3141
- let i = [];
3142
- n.forEach((t, n) => {
3143
- if (t !== null) for (let r of t.traces) i.push({
3144
- apiName: e[n].name,
3145
- trace: r
3146
- });
3147
- }), c(i);
3148
- };
3149
- i();
3150
- let s = setInterval(i, Vr);
3151
- return () => {
3152
- r = !0, clearInterval(s);
3153
- };
3154
- }, [
3155
- n,
3156
- o,
3157
- u,
3158
- a,
3159
- t
3160
- ]), s;
3161
- }, Gr = (e) => e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(2)}s`, Kr = (e) => {
3162
- let t = new Map(e.map((e) => [e.spanId, e])), n = /* @__PURE__ */ new Map(), r = (e, i) => {
3163
- if (n.has(e.spanId)) return n.get(e.spanId);
3164
- if (i > 64 || e.parentSpanId === null) return n.set(e.spanId, 0), 0;
3165
- let a = t.get(e.parentSpanId), o = a ? r(a, i + 1) + 1 : 0;
3166
- return n.set(e.spanId, o), o;
3167
- };
3168
- for (let t of e) r(t, 0);
3169
- return n;
3170
- }, qr = (e) => {
3171
- if (typeof e == "string") return e;
3172
- try {
3173
- return JSON.stringify(e, null, 2) ?? String(e);
3174
- } catch {
3175
- return String(e);
3176
- }
3177
- }, Jr = ({ trace: e }) => {
3178
- let t = U().traces, n = Kr(e.spans), r = new Set(e.spans.map((e) => e.spanId)), i = e.spans.some((e) => e.parentSpanId !== null && !r.has(e.parentSpanId)), a = e.spans.length > 0 && e.spans.every((e) => e.name.startsWith("sql.")), o = e.durationMs > 0 ? e.durationMs : 1;
3179
- return /* @__PURE__ */ N("div", {
3180
- className: "vdt-trace-detail",
3181
- children: [
3182
- /* @__PURE__ */ N("div", {
3183
- className: "vdt-trace-summary",
3184
- children: [/* @__PURE__ */ M("span", { children: t.spans(e.spanCount) }), e.kind === "subscription" ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ N("span", { children: [
3185
- e.deliveryCount ?? 0,
3186
- " ",
3187
- t.delivery(e.deliveryCount ?? 0)
3188
- ] }), e.lastDeliveryMs === void 0 ? null : /* @__PURE__ */ N("span", { children: [
3189
- t.lastDelivery,
3190
- ": ",
3191
- /* @__PURE__ */ M("strong", { children: Gr(e.lastDeliveryMs) })
3192
- ] })] }) : /* @__PURE__ */ N("span", { children: [
3193
- t.duration,
3194
- ": ",
3195
- /* @__PURE__ */ M("strong", { children: Gr(e.durationMs) })
3196
- ] })]
3197
- }),
3198
- /* @__PURE__ */ N("code", {
3199
- className: "vdt-trace-id",
3200
- children: ["trace ", e.traceId]
3201
- }),
3202
- i || a ? /* @__PURE__ */ M("p", {
3203
- className: "vdt-trace-context",
3204
- children: i ? t.missingParents : t.sqlWithoutCaller
3205
- }) : null,
3206
- e.spans.map((r) => {
3207
- let i = Math.min(n.get(r.spanId) ?? 0, 8), a = Math.max(0, Math.min(100, (r.startMs - e.startMs) / o * 100)), s = Math.max(0, Math.min(100 - a, Math.max(1.5, r.durationMs / o * 100))), c = Object.entries(r.attributes);
3208
- return /* @__PURE__ */ N("details", {
3209
- className: "vdt-trace-span",
3210
- open: r.status === "error",
3211
- "data-status": r.status,
3212
- children: [/* @__PURE__ */ N("summary", {
3213
- className: "vdt-trace-span-head",
3214
- style: { paddingLeft: 8 + i * 8 },
3215
- children: [
3216
- /* @__PURE__ */ N("span", {
3217
- className: "vdt-trace-span-label",
3218
- children: [/* @__PURE__ */ M(fe, { className: "vdt-trace-chevron" }), /* @__PURE__ */ M("code", {
3219
- className: "vdt-trace-span-name",
3220
- children: r.name
3221
- })]
3222
- }),
3223
- /* @__PURE__ */ M("span", {
3224
- className: "vdt-trace-span-duration",
3225
- children: Gr(r.durationMs)
3226
- }),
3227
- /* @__PURE__ */ M("span", {
3228
- className: "vdt-trace-span-bar",
3229
- "aria-hidden": "true",
3230
- children: /* @__PURE__ */ M("span", { style: {
3231
- left: `${a}%`,
3232
- width: `${s}%`
3233
- } })
3234
- })
3235
- ]
3236
- }), /* @__PURE__ */ N("div", {
3237
- className: "vdt-trace-span-body",
3238
- children: [
3239
- /* @__PURE__ */ N("div", {
3240
- className: "vdt-trace-span-meta",
3241
- children: [
3242
- /* @__PURE__ */ M("span", { children: r.kind }),
3243
- /* @__PURE__ */ M("span", { children: r.status }),
3244
- /* @__PURE__ */ M("code", { children: r.spanId })
3245
- ]
3246
- }),
3247
- r.statusMessage ? /* @__PURE__ */ M("p", {
3248
- className: "vdt-trace-span-message",
3249
- children: r.statusMessage
3250
- }) : null,
3251
- c.length > 0 ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("div", {
3252
- className: "vdt-trace-attributes-label",
3253
- children: t.attributes
3254
- }), /* @__PURE__ */ M("dl", {
3255
- className: "vdt-trace-attributes",
3256
- children: c.map(([e, t]) => /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ M("dt", { children: e }), /* @__PURE__ */ M("dd", { children: /* @__PURE__ */ M("pre", { children: qr(t) }) })] }, e))
3257
- })] }) : /* @__PURE__ */ M("p", {
3258
- className: "vdt-trace-no-attributes",
3259
- children: t.noAttributes
3260
- })
3261
- ]
3262
- })]
3263
- }, r.spanId);
3264
- })
3265
- ]
3266
- });
3267
- }, Yr = [
3268
- "all",
3269
- "subscription",
3270
- "mutation",
3271
- "action",
3272
- "trace",
3273
- "log"
3274
- ], Xr = [
3275
- "workflows",
3276
- "stores",
3277
- "indexes",
3278
- "webhooks",
3279
- "routes",
3280
- "runtimes",
3281
- "pwa",
3282
- "desktop"
3283
- ], Zr = [...Yr, ...Xr], Qr = (e) => Yr.includes(e), $r = (e) => {
3284
- let t = [], n = /"([^"]*)"|(\S+)/g, r;
3285
- for (; (r = n.exec(e)) !== null;) {
3286
- let e = (r[1] ?? r[2] ?? "").toLowerCase();
3287
- e !== "" && t.push(e);
3288
- }
3289
- return t;
3290
- }, ei = (e, t) => t.every((t) => e.includes(t)), ti = {
3291
- subscription: 0,
3292
- mutation: 1,
3293
- action: 1,
3294
- trace: 1,
3295
- log: 1
3296
- }, ni = (e) => (e.source === "mutation" || e.source === "action") && e.status === "pending", ri = (e, t, n) => {
3297
- let r = $r(t), i = n === "all" ? e : e.filter((e) => e.source === n);
3298
- return [...r.length === 0 ? i : i.filter((e) => ei(e.haystack, r))].sort((e, t) => {
3299
- let n = Number(ni(t)) - Number(ni(e));
3300
- if (n !== 0) return n;
3301
- let r = ti[e.source] - ti[t.source];
3302
- return r === 0 ? t.at - e.at : r;
3303
- });
3304
- }, ii = (e) => {
3305
- let t = {
3306
- subscription: 0,
3307
- mutation: 0,
3308
- action: 0,
3309
- trace: 0,
3310
- log: 0
3311
- };
3312
- for (let n of e) t[n.source]++;
3313
- return t;
3314
- }, ai = (e, t = 400) => {
3315
- let n;
3316
- try {
3317
- n = JSON.stringify(e) ?? String(e);
3318
- } catch {
3319
- n = String(e);
3320
- }
3321
- return n.length > t ? n.slice(0, t) : n;
3322
- }, oi = (e, t, n) => {
3323
- if (e.length === 0) return null;
3324
- let r = t === null ? -1 : e.indexOf(t);
3325
- return r === -1 ? n === 1 ? e[0] : e[e.length - 1] : e[(r + n + e.length) % e.length];
3326
- }, si = (e) => e.recovery.phase === "stuck" || e.snapshot.error ? "err" : e.recovery.phase !== "steady" || e.snapshot.pendingPatches > 0 ? "warn" : e.snapshot.revision >= 0 ? "ok" : e.hasFiber ? "info" : "idle", ci = (e, t) => {
3327
- let n = Ze(t.key), r = [];
3328
- t.subscriberCount > 0 && r.push(`${t.subscriberCount} sub${t.subscriberCount === 1 ? "" : "s"}`), t.snapshot.revision >= 0 && r.push(`r${t.snapshot.revision}`), t.snapshot.pendingPatches > 0 && r.push(`+${t.snapshot.pendingPatches} pending`), t.evicting && r.push("evicting");
3329
- let i = t.snapshot.error ? "error" : t.recovery.phase === "steady" ? void 0 : t.recovery.phase;
3330
- return {
3331
- id: `sub:${e}:${t.key}`,
3332
- source: "subscription",
3333
- apiName: e,
3334
- name: n,
3335
- summary: r.join(" · "),
3336
- ...i === void 0 ? {} : { status: i },
3337
- tone: si(t),
3338
- at: 0,
3339
- haystack: `${e} ${t.key} ${t.tag ?? ""} ${t.source ?? ""} ${i ?? ""}`.toLowerCase(),
3340
- detail: {
3341
- source: "subscription",
3342
- apiName: e,
3343
- entry: t
3344
- }
3345
- };
3346
- }, li = (e) => e.status === "pending" ? "info" : e.status === "success" ? "ok" : "err", ui = (e) => e.status === "error" ? e.error instanceof Error && e.error.name !== "Error" ? e.error.name : "error" : e.status, di = (e) => {
3347
- let t = e.kind === "action" ? "action" : "mutation", n = ai(e.input, 160), r = e.status === "error" ? e.error instanceof Error ? `${e.error.name} ${e.error.message}` : ai(e.error, 200) : "";
3348
- return {
3349
- id: `mut:${e.id}`,
3350
- source: t,
3351
- apiName: e.apiName,
3352
- name: e.tag,
3353
- summary: n,
3354
- status: ui(e),
3355
- tone: li(e),
3356
- at: e.startedAt,
3357
- haystack: `${t} ${e.apiName} ${e.tag} ${e.status} ${n} ${r}`.toLowerCase(),
3358
- detail: {
3359
- source: t,
3360
- mutation: e
3361
- }
3362
- };
3363
- }, fi = (e) => {
3364
- switch (e.level) {
3365
- case "error":
3366
- case "fatal": return "err";
3367
- case "warn": return "warn";
3368
- case "info": return "info";
3369
- default: return "idle";
3370
- }
3371
- }, pi = (e, t) => ({
3372
- id: `log:${e.ts.getTime()}:${t}`,
3373
- source: "log",
3374
- name: e.scope ?? "log",
3375
- summary: e.message,
3376
- status: e.level,
3377
- tone: fi(e),
3378
- at: e.ts.getTime(),
3379
- haystack: `${e.scope ?? ""} ${e.level} ${e.message} ${ai(e.fields, 300)}`.toLowerCase(),
3380
- detail: {
3381
- source: "log",
3382
- record: e
3383
- }
3384
- }), mi = (e, t, n = Le.traces) => {
3385
- let r = t.spans.map((e) => e.attributes["db.operation.name"] ?? e.attributes["db.operation"]).find((e) => typeof e == "string"), i = t.spans.filter((e) => e.name !== t.rootName).slice(0, 3).map((e) => e.name).join(" → "), a = t.kind === "subscription" ? `${t.deliveryCount ?? 0} ${n.delivery(t.deliveryCount ?? 0)}` : [
3386
- Gr(t.durationMs),
3387
- n.spans(t.spanCount),
3388
- r ?? i
3389
- ].filter(Boolean).join(" · "), o = t.spans.filter((e) => e.status === "error").map((e) => `${e.name} ${e.statusMessage ?? ""}`).join(" ");
3390
- return {
3391
- id: `trace:${e}:${t.traceId}`,
3392
- source: "trace",
3393
- apiName: e,
3394
- name: t.rootName,
3395
- summary: a,
3396
- status: t.hasError ? "error" : "ok",
3397
- tone: t.hasError ? "err" : "ok",
3398
- at: t.startMs,
3399
- haystack: `${e} ${t.rootName} ${t.traceId} ${t.spans.map((e) => e.name).join(" ")} ${o}`.toLowerCase(),
3400
- detail: {
3401
- source: "trace",
3402
- apiName: e,
3403
- trace: t
3404
- }
3405
- };
3406
- }, hi = () => u(T, S, S), gi = () => u(ue, le, le), _i = (e, t = !1) => {
3407
- let n = U().traces, r = Ye(), i = hi(), a = gi(), o = Wr(e, t);
3408
- return s(() => {
3409
- let e = [];
3410
- for (let t of r) for (let n of t.entries) e.push(ci(t.name, n));
3411
- for (let t of i) e.push(di(t));
3412
- for (let t of o) e.push(mi(t.apiName, t.trace, n));
3413
- return a.forEach((t, n) => e.push(pi(t, n))), e;
3414
- }, [
3415
- r,
3416
- i,
3417
- a,
3418
- o,
3419
- n
3420
- ]);
3421
- }, vi = {
3422
- all: null,
3423
- subscription: me,
3424
- mutation: Te,
3425
- action: Ce,
3426
- trace: Se,
3427
- log: De,
3428
- workflows: xe,
3429
- stores: he,
3430
- indexes: Ee,
3431
- webhooks: be,
3432
- routes: ge,
3433
- runtimes: Oe,
3434
- pwa: Oe,
3435
- desktop: Oe
3436
- }, yi = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent) ? {
3437
- search: "⌘K",
3438
- alt: "⌥",
3439
- shift: "⇧"
3440
- } : {
3441
- search: "Ctrl K",
3442
- alt: "Alt",
3443
- shift: "Shift"
3444
- }, bi = (e, t, n) => {
3445
- if (n.trim() !== "") return {
3446
- title: e.noResults,
3447
- hint: e.noResultsHint
3448
- };
3449
- switch (t) {
3450
- case "subscription": return {
3451
- title: e.emptySubscriptions,
3452
- hint: e.emptySubscriptionsHint
3453
- };
3454
- case "mutation": return {
3455
- title: e.emptyMutations,
3456
- hint: e.emptyMutationsHint
3457
- };
3458
- case "action": return {
3459
- title: e.emptyActions,
3460
- hint: e.emptyActionsHint
3461
- };
3462
- case "trace": return {
3463
- title: e.emptyTraces,
3464
- hint: e.emptyTracesHint
3465
- };
3466
- case "log": return {
3467
- title: e.emptyLogs,
3468
- hint: e.emptyLogsHint
3469
- };
3470
- default: return {
3471
- title: e.emptyAll,
3472
- hint: e.emptyAllHint
3473
- };
3474
- }
3475
- }, xi = (e) => {
3476
- let t = new Date(e), n = (e) => e < 10 ? `0${e}` : String(e);
3477
- return `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
3478
- }, Si = ({ item: e, selected: t, onSelect: n }) => {
3479
- let r = c(null);
3480
- return i(() => {
3481
- t && r.current !== null && typeof r.current.scrollIntoView == "function" && r.current.scrollIntoView({ block: "nearest" });
3482
- }, [t]), /* @__PURE__ */ N("button", {
3483
- ref: r,
3484
- type: "button",
3485
- role: "option",
3486
- "aria-selected": t,
3487
- "data-source": e.source,
3488
- className: `vdt-row${t ? " vdt-row-sel" : ""}`,
3489
- onClick: n,
3490
- children: [
3491
- /* @__PURE__ */ M("span", {
3492
- className: `vdt-dot vdt-dot-${e.tone}`,
3493
- "aria-hidden": "true"
3494
- }),
3495
- /* @__PURE__ */ M("span", {
3496
- className: "vdt-row-src",
3497
- children: e.source
3498
- }),
3499
- /* @__PURE__ */ N("span", {
3500
- className: "vdt-row-main",
3501
- children: [/* @__PURE__ */ M("code", {
3502
- className: "vdt-row-name",
3503
- children: e.name
3504
- }), /* @__PURE__ */ M("span", {
3505
- className: "vdt-row-summary",
3506
- children: e.summary
3507
- })]
3508
- }),
3509
- /* @__PURE__ */ N("span", {
3510
- className: "vdt-row-meta",
3511
- children: [
3512
- e.apiName === void 0 ? null : /* @__PURE__ */ M("span", {
3513
- className: "vdt-row-api",
3514
- children: e.apiName
3515
- }),
3516
- e.status === void 0 ? null : /* @__PURE__ */ M("span", {
3517
- className: `vdt-tag vdt-tag-${e.tone}`,
3518
- children: e.status
3519
- }),
3520
- e.at > 0 ? /* @__PURE__ */ M("span", {
3521
- className: "vdt-row-time",
3522
- children: xi(e.at)
3523
- }) : null
3524
- ]
3525
- })
3526
- ]
3527
- });
3528
- }, Ci = ({ item: e, retained: t }) => {
3529
- let n = e.detail, r = U().shell;
3530
- return /* @__PURE__ */ N("div", {
3531
- className: "vdt-detail",
3532
- children: [/* @__PURE__ */ N("div", {
3533
- className: "vdt-detail-head",
3534
- children: [
3535
- /* @__PURE__ */ M("span", {
3536
- className: `vdt-dot vdt-dot-${e.tone}`,
3537
- "aria-hidden": "true"
3538
- }),
3539
- /* @__PURE__ */ M("span", {
3540
- className: "vdt-row-src",
3541
- children: e.source
3542
- }),
3543
- /* @__PURE__ */ M("code", {
3544
- className: "vdt-detail-name",
3545
- children: e.name
3546
- }),
3547
- e.status === void 0 ? null : /* @__PURE__ */ M("span", {
3548
- className: `vdt-tag vdt-tag-${e.tone}`,
3549
- children: e.status
3550
- }),
3551
- /* @__PURE__ */ M("span", { className: "vdt-sp" }),
3552
- e.apiName === void 0 ? null : /* @__PURE__ */ M("span", {
3553
- className: "vdt-row-api",
3554
- children: e.apiName
3555
- }),
3556
- e.at > 0 ? /* @__PURE__ */ M("span", {
3557
- className: "vdt-row-time",
3558
- children: xi(e.at)
3559
- }) : null
3560
- ]
3561
- }), /* @__PURE__ */ N("div", {
3562
- className: "vdt-detail-body",
3563
- children: [
3564
- t ? /* @__PURE__ */ M("p", {
3565
- className: "vdt:px-3 vdt:py-2 vdt:text-xs vdt:text-foreground-muted",
3566
- role: "status",
3567
- children: r.retainedSelection
3568
- }) : null,
3569
- n.source === "subscription" ? /* @__PURE__ */ M(Qe, { entry: n.entry }) : null,
3570
- n.source === "mutation" || n.source === "action" ? /* @__PURE__ */ M(Ir, { mutation: n.mutation }) : null,
3571
- n.source === "trace" ? /* @__PURE__ */ M(Jr, { trace: n.trace }) : null,
3572
- n.source === "log" ? /* @__PURE__ */ M(Br, { record: n.record }) : null
3573
- ]
3574
- })]
3575
- });
3576
- }, wi = ({ name: e }) => {
3577
- let t = U().shell, n = D(e).status, r = n === "connected" ? "ok" : n === "recovering" ? "warn" : "err", i = n === "connected" ? t.connected : n === "recovering" ? t.recovering : n === "degraded" ? t.degraded : t.offline;
3578
- return /* @__PURE__ */ N("span", {
3579
- className: "vdt-chip",
3580
- "data-status": n,
3581
- children: [
3582
- /* @__PURE__ */ M("span", {
3583
- className: `vdt-dot vdt-dot-${r}`,
3584
- "aria-hidden": "true"
3585
- }),
3586
- /* @__PURE__ */ M("b", { children: e }),
3587
- /* @__PURE__ */ M("span", { children: i })
3588
- ]
3589
- });
3590
- }, Ti = () => u(h, () => f().pathname ?? "", () => ""), Ei = (e) => {
3591
- let t = e.detail;
3592
- switch (t.source) {
3593
- case "subscription": return t.entry;
3594
- case "mutation":
3595
- case "action": return t.mutation;
3596
- case "trace": return t.trace;
3597
- case "log": return t.record;
3598
- }
3599
- }, Di = ({ dock: e, push: t, onDock: n, onPush: r, onClose: a, scope: o, onScope: c, searchRef: u, onHeaderPointerDown: d }) => {
3600
- let f = U(), p = f.shell, m = f.tabs, h = O(), [g, _] = l(!1), v = _i(!0, g), y = Ln(!0), b = Wn(!0), x = cr(!0), S = Ti(), [C, w] = l(""), [T, ee] = l(!1), [E, D] = l(null), k = E?.id ?? null;
3601
- i(() => {
3602
- if (E === null || E.source === "subscription") return;
3603
- let e = v.find((e) => e.id === E.id);
3604
- e !== void 0 && Ei(e) !== Ei(E) && D(e);
3605
- }, [v, E]);
3606
- let te = Qr(o), A = s(() => ii(v), [v]), ne = s(() => v.filter((e) => e.source === "trace" && e.tone === "err").length, [v]), P = s(() => v.filter(ni).length, [v]), F = E === null ? null : v.find((e) => e.id === E.id) ?? null, I = E !== null && E.source !== "subscription" && F === null, L = s(() => {
3607
- let e = F ?? (I ? E : null);
3608
- return e !== null && ri([e], C, o).length > 0 ? e : null;
3609
- }, [
3610
- F,
3611
- I,
3612
- E,
3613
- C,
3614
- o
3615
- ]), R = s(() => {
3616
- let e = I && L !== null ? [...v, L] : v;
3617
- return ri(T ? e.filter(ni) : e, C, o);
3618
- }, [
3619
- v,
3620
- C,
3621
- o,
3622
- T,
3623
- I,
3624
- L
3625
- ]), z = s(() => T && C.trim() === "" ? {
3626
- title: p.emptyPending,
3627
- hint: p.emptyPendingHint
3628
- } : bi(p, o, C), [
3629
- p,
3630
- o,
3631
- C,
3632
- T
3633
- ]), B = (e) => {
3634
- D(e === null ? null : R.find((t) => t.id === e) ?? null);
3635
- }, re = (e) => {
3636
- switch (e) {
3637
- case "all": return v.length;
3638
- case "subscription": return A.subscription;
3639
- case "mutation": return A.mutation;
3640
- case "action": return A.action;
3641
- case "trace": return A.trace;
3642
- case "log": return A.log;
3643
- case "indexes": return y;
3644
- case "webhooks": return b;
3645
- case "workflows": return x;
3646
- default: return null;
3647
- }
3648
- }, V = (e) => {
3649
- switch (e) {
3650
- case "all": return p.scopeAll;
3651
- case "subscription": return m.subscriptions;
3652
- case "mutation": return m.mutations;
3653
- case "action": return m.actions;
3654
- case "trace": return m.traces;
3655
- case "log": return m.logs;
3656
- case "workflows": return m.workflows;
3657
- case "stores": return m.stores;
3658
- case "indexes": return m.indexes;
3659
- case "webhooks": return m.webhooks;
3660
- case "routes": return m.routes;
3661
- case "runtimes": return m.runtimes;
3662
- case "pwa": return m.pwa;
3663
- case "desktop": return m.desktop;
3664
- }
3665
- };
3666
- return /* @__PURE__ */ N(j, { children: [
3667
- /* @__PURE__ */ N("header", {
3668
- className: "vdt-bar",
3669
- onPointerDown: d,
3670
- children: [
3671
- e === "window" ? /* @__PURE__ */ M("span", {
3672
- className: "vdt-win-handle",
3673
- title: p.moveTitle,
3674
- "aria-hidden": "true",
3675
- children: /* @__PURE__ */ M(Fe, { className: "vdt:w-4 vdt:h-4" })
3676
- }) : null,
3677
- /* @__PURE__ */ M(de, { className: "vdt-bar-mark" }),
3678
- te ? /* @__PURE__ */ N("label", {
3679
- className: "vdt-search",
3680
- children: [
3681
- /* @__PURE__ */ M(we, { className: "vdt:w-3.5 vdt:h-3.5" }),
3682
- /* @__PURE__ */ M("input", {
3683
- ref: u,
3684
- type: "search",
3685
- value: C,
3686
- onChange: (e) => w(e.target.value),
3687
- onKeyDown: (e) => {
3688
- e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), B(oi(R.map((e) => e.id), k, e.key === "ArrowDown" ? 1 : -1))) : e.key === "Escape" ? C === "" ? a() : (e.preventDefault(), w("")) : e.key === "Enter" && L === null && R.length > 0 && B(R[0].id);
3689
- },
3690
- placeholder: p.searchPlaceholder,
3691
- "aria-label": p.searchLabel,
3692
- autoComplete: "off",
3693
- spellCheck: !1
3694
- }),
3695
- /* @__PURE__ */ M("kbd", {
3696
- className: "vdt-kbd",
3697
- children: yi.search
3698
- })
3699
- ]
3700
- }) : /* @__PURE__ */ N("span", {
3701
- className: "vdt-bar-title",
3702
- children: [/* @__PURE__ */ M("span", {
3703
- className: "vdt-bar-brand",
3704
- children: p.brandWord
3705
- }), /* @__PURE__ */ M("span", {
3706
- className: "vdt-bar-kicker",
3707
- children: p.kicker
3708
- })]
3709
- }),
3710
- /* @__PURE__ */ M("div", {
3711
- role: "tablist",
3712
- "aria-label": p.brand,
3713
- className: "vdt-scopes",
3714
- children: Zr.map((e, t) => {
3715
- let n = vi[e], r = re(e), i = e === o;
3716
- return /* @__PURE__ */ N("button", {
3717
- type: "button",
3718
- role: "tab",
3719
- "aria-label": r !== null && r > 0 ? `${V(e)} (${r})` : V(e),
3720
- "aria-selected": i,
3721
- "data-scope": e,
3722
- className: `vdt-scope${i ? " vdt-scope-on" : ""}${t === Yr.length ? " vdt-scope-sep" : ""}`,
3723
- onClick: () => {
3724
- c(e), B(null), ee(!1), Qr(e) && requestAnimationFrame(() => {
3725
- let e = u.current;
3726
- e !== null && e.getRootNode().activeElement !== e && e.focus();
3727
- });
3728
- },
3729
- children: [
3730
- n ? /* @__PURE__ */ M(n, { className: "vdt:w-3.5 vdt:h-3.5" }) : null,
3731
- /* @__PURE__ */ M("span", {
3732
- className: "vdt-scope-label",
3733
- children: V(e)
3734
- }),
3735
- r !== null && r > 0 ? /* @__PURE__ */ M("span", {
3736
- className: `vdt-badge${i ? " vdt-badge-acc" : ""}${e === "trace" && ne > 0 ? " vdt-badge-err" : ""}`,
3737
- children: r
3738
- }) : null
3739
- ]
3740
- }, e);
3741
- })
3742
- }),
3743
- /* @__PURE__ */ M("span", { className: "vdt-sp" }),
3744
- /* @__PURE__ */ M(Ut, {
3745
- dock: e,
3746
- push: t,
3747
- onDock: n,
3748
- onPush: r
3749
- }),
3750
- /* @__PURE__ */ M("button", {
3751
- type: "button",
3752
- className: "vdt-iconbtn",
3753
- title: p.closeTitle,
3754
- "aria-label": p.closeTitle,
3755
- onClick: a,
3756
- children: /* @__PURE__ */ M(pe, { className: "vdt:w-4 vdt:h-4" })
3757
- })
3758
- ]
3759
- }),
3760
- /* @__PURE__ */ M(ln, {}),
3761
- te ? /* @__PURE__ */ N("div", {
3762
- className: "vdt-body",
3763
- "data-empty": R.length === 0 && L === null ? "true" : "false",
3764
- children: [/* @__PURE__ */ M("div", {
3765
- role: "listbox",
3766
- "aria-label": p.results(R.length),
3767
- tabIndex: 0,
3768
- className: "vdt-results",
3769
- onKeyDown: (e) => {
3770
- e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), B(oi(R.map((e) => e.id), k, e.key === "ArrowDown" ? 1 : -1))) : e.key === "Escape" && a();
3771
- },
3772
- children: R.length === 0 ? /* @__PURE__ */ N("div", {
3773
- className: "vdt-empty",
3774
- children: [/* @__PURE__ */ M("div", {
3775
- className: "vdt-empty-title",
3776
- children: z.title
3777
- }), /* @__PURE__ */ M("div", {
3778
- className: "vdt-empty-hint",
3779
- children: z.hint
3780
- })]
3781
- }) : R.map((e) => /* @__PURE__ */ M(Si, {
3782
- item: e,
3783
- selected: e.id === k,
3784
- onSelect: () => B(e.id === k ? null : e.id)
3785
- }, e.id))
3786
- }), /* @__PURE__ */ M("aside", {
3787
- className: "vdt-side",
3788
- "aria-live": "polite",
3789
- children: L === null ? /* @__PURE__ */ M("div", {
3790
- className: "vdt-empty vdt-empty-side",
3791
- children: /* @__PURE__ */ M("div", {
3792
- className: "vdt-empty-hint",
3793
- children: p.selectHint
3794
- })
3795
- }) : /* @__PURE__ */ M(Ci, {
3796
- item: L,
3797
- retained: I
3798
- })
3799
- })]
3800
- }) : /* @__PURE__ */ N("div", {
3801
- className: "vdt-body vdt-body-panel",
3802
- children: [
3803
- o === "workflows" ? /* @__PURE__ */ M(lr, {}) : null,
3804
- o === "stores" ? /* @__PURE__ */ M(Nr, {}) : null,
3805
- o === "indexes" ? /* @__PURE__ */ M(Pn, {}) : null,
3806
- o === "webhooks" ? /* @__PURE__ */ M(Kn, {}) : null,
3807
- o === "routes" ? /* @__PURE__ */ M(_r, {}) : null,
3808
- o === "runtimes" ? /* @__PURE__ */ M(yr, {}) : null,
3809
- o === "pwa" ? /* @__PURE__ */ M(Tr, {}) : null,
3810
- o === "desktop" ? /* @__PURE__ */ M(Or, {}) : null
3811
- ]
3812
- }),
3813
- /* @__PURE__ */ N("footer", {
3814
- className: "vdt-foot",
3815
- children: [
3816
- o === "trace" ? /* @__PURE__ */ M("button", {
3817
- type: "button",
3818
- className: "vdt-chip vdt-background-filter",
3819
- "aria-pressed": g,
3820
- onClick: () => _(!g),
3821
- children: f.traces.includeBackground
3822
- }) : null,
3823
- P > 0 || T ? /* @__PURE__ */ N("button", {
3824
- type: "button",
3825
- className: "vdt-chip vdt-chip-info vdt-pending-filter",
3826
- "data-chip": "pending",
3827
- "aria-label": p.pendingInvocations(P),
3828
- "aria-pressed": T,
3829
- onClick: () => {
3830
- ee(!T), c("all"), w(""), B(null);
3831
- },
3832
- children: [
3833
- /* @__PURE__ */ M("span", {
3834
- className: "vdt-dot vdt-dot-info",
3835
- "aria-hidden": "true"
3836
- }),
3837
- /* @__PURE__ */ M("b", { children: P }),
3838
- " ",
3839
- p.pending
3840
- ]
3841
- }) : null,
3842
- h.names.map((e) => /* @__PURE__ */ M(wi, { name: e }, e)),
3843
- S === "" ? null : /* @__PURE__ */ M("span", {
3844
- className: "vdt-foot-route",
3845
- children: /* @__PURE__ */ M("code", { children: S })
3846
- }),
3847
- /* @__PURE__ */ M("span", { className: "vdt-sp" }),
3848
- /* @__PURE__ */ N("span", {
3849
- className: "vdt-hints",
3850
- children: [
3851
- /* @__PURE__ */ N("span", { children: [
3852
- /* @__PURE__ */ M("kbd", {
3853
- className: "vdt-kbd",
3854
- children: "↑↓"
3855
- }),
3856
- " ",
3857
- p.hintNavigate
3858
- ] }),
3859
- /* @__PURE__ */ N("span", { children: [
3860
- /* @__PURE__ */ M("kbd", {
3861
- className: "vdt-kbd",
3862
- children: "↵"
3863
- }),
3864
- " ",
3865
- p.hintOpen
3866
- ] }),
3867
- /* @__PURE__ */ N("span", { children: [
3868
- /* @__PURE__ */ M("kbd", {
3869
- className: "vdt-kbd",
3870
- children: yi.alt
3871
- }),
3872
- "+",
3873
- /* @__PURE__ */ M("kbd", {
3874
- className: "vdt-kbd",
3875
- children: "V"
3876
- }),
3877
- " ",
3878
- p.hintToggle
3879
- ] }),
3880
- /* @__PURE__ */ N("span", { children: [
3881
- /* @__PURE__ */ M("kbd", {
3882
- className: "vdt-kbd",
3883
- children: yi.alt
3884
- }),
3885
- "+",
3886
- /* @__PURE__ */ M("kbd", {
3887
- className: "vdt-kbd",
3888
- children: yi.shift
3889
- }),
3890
- "+",
3891
- /* @__PURE__ */ M("kbd", {
3892
- className: "vdt-kbd",
3893
- children: "←↑↓→"
3894
- }),
3895
- " ",
3896
- p.hintDock
3897
- ] })
3898
- ]
3899
- })
3900
- ]
3901
- })
3902
- ] });
3903
- }, Oi = ({ error: e, onReset: t }) => {
3904
- let n = U().shell;
3905
- return /* @__PURE__ */ N("div", {
3906
- role: "alert",
3907
- className: "vdt-crash",
3908
- children: [
3909
- /* @__PURE__ */ M("div", {
3910
- className: "vdt-crash-title",
3911
- children: n.crashTitle
3912
- }),
3913
- /* @__PURE__ */ N("pre", {
3914
- className: "vdt-crash-message",
3915
- children: [
3916
- e.name,
3917
- ": ",
3918
- e.message
3919
- ]
3920
- }),
3921
- /* @__PURE__ */ M("button", {
3922
- type: "button",
3923
- className: "vdt-crash-reset",
3924
- onClick: t,
3925
- children: n.crashReset
3926
- })
3927
- ]
3928
- });
3929
- }, ki = class extends e {
3930
- state = { error: null };
3931
- static getDerivedStateFromError(e) {
3932
- return { error: e };
3933
- }
3934
- componentDidCatch(e, t) {
3935
- this.props.onError?.(e, t);
3936
- }
3937
- render() {
3938
- return this.state.error === null ? this.props.children : /* @__PURE__ */ M(Oi, {
3939
- error: this.state.error,
3940
- onReset: () => this.setState({ error: null })
3941
- });
3942
- }
3943
- }, Ai = /vdt/, ji = (e, t) => {
3944
- for (let n of Array.from(e)) {
3945
- if (n instanceof CSSStyleRule) {
3946
- (Ai.test(n.selectorText) || Array.from(n.style).some((e) => e.startsWith("--vdt-"))) && t.push(n.cssText);
3947
- continue;
3948
- }
3949
- if (n instanceof CSSKeyframesRule) {
3950
- n.name.startsWith("vdt-") && t.push(n.cssText);
3951
- continue;
3952
- }
3953
- if (n instanceof CSSGroupingRule || n instanceof CSSLayerBlockRule) {
3954
- let e = [];
3955
- if (ji(n.cssRules, e), e.length === 0) continue;
3956
- let r = n.cssText, i = r.slice(0, r.indexOf("{")).trim();
3957
- t.push(`${i} {\n${e.join("\n")}\n}`);
3958
- continue;
3959
- }
3960
- n.constructor.name === "CSSPropertyRule" && Ai.test(n.cssText) && t.push(n.cssText), n.constructor.name === "CSSLayerStatementRule" && t.push(n.cssText);
3961
- }
3962
- }, Mi = (e) => {
3963
- let t = [], n = (e) => {
3964
- for (let r of Array.from(e)) r.constructor.name === "CSSPropertyRule" && /@property\s+--(tw|vdt)-/.test(r.cssText) ? t.push(r.cssText) : (r instanceof CSSGroupingRule || r instanceof CSSLayerBlockRule) && n(r.cssRules);
3965
- };
3966
- for (let t of Array.from(e.styleSheets)) {
3967
- let e;
3968
- try {
3969
- e = t.cssRules;
3970
- } catch {
3971
- continue;
3972
- }
3973
- n(e);
3974
- }
3975
- return t.join("\n");
3976
- }, Ni = (e) => {
3977
- let t = [];
3978
- for (let n of Array.from(e.styleSheets)) {
3979
- let e;
3980
- try {
3981
- e = n.cssRules;
3982
- } catch {
3983
- continue;
3984
- }
3985
- ji(e, t);
3986
- }
3987
- return t.join("\n");
3988
- }, Pi = (e, t) => {
3989
- let n = e.ownerDocument.defaultView?.CSSStyleSheet;
3990
- if (n !== void 0 && "replaceSync" in n.prototype && "adoptedStyleSheets" in e) {
3991
- let r = new n();
3992
- r.replaceSync(t), e.adoptedStyleSheets = [r];
3993
- return;
3994
- }
3995
- let r = e.querySelector("style[data-vdt]");
3996
- r === null && (r = e.ownerDocument.createElement("style"), r.setAttribute("data-vdt", ""), e.prepend(r)), r.textContent = t;
3997
- }, Fi = ({ children: e, target: t }) => {
3998
- let [n, r] = l(null);
3999
- return o(() => {
4000
- let e = document, n = t ?? e, i = n.createElement("div");
4001
- i.className = "vdt-root", i.setAttribute("data-voltro-devtools", ""), n.documentElement.append(i);
4002
- let a = i.attachShadow({ mode: "open" }), o = n.createElement("div");
4003
- o.setAttribute("data-vdt-mount", ""), a.append(o);
4004
- let s = n === e ? null : n.createElement("style");
4005
- s !== null && (s.setAttribute("data-vdt-properties", ""), n.head.append(s));
4006
- let c = "", l = () => {
4007
- if (s !== null) {
4008
- let t = Mi(e);
4009
- s.textContent !== t && (s.textContent = t);
4010
- }
4011
- let t = Ni(e);
4012
- t !== c && (c = t, Pi(a, t));
4013
- };
4014
- l();
4015
- let u = typeof MutationObserver > "u" ? null : new MutationObserver(() => l());
4016
- return u?.observe(e.head, {
4017
- childList: !0,
4018
- subtree: !0,
4019
- characterData: !0
4020
- }), r(o), () => {
4021
- u?.disconnect(), i.remove(), s?.remove(), r(null);
4022
- };
4023
- }, [t]), n === null ? null : ne(e, n);
4024
- }, Ii = () => u(g, p, p), Li = ["overflow"], Ri = [
4025
- "position",
4026
- "top",
4027
- "right",
4028
- "bottom",
4029
- "left",
4030
- "overflow",
4031
- "contain"
4032
- ], zi = (e, t) => t.map((t) => [
4033
- t,
4034
- e.getPropertyValue(t),
4035
- e.getPropertyPriority(t)
4036
- ]), Bi = (e, t) => {
4037
- for (let [n, r, i] of t) r === "" ? e.removeProperty(n) : e.setProperty(n, r, i);
4038
- }, Vi = (e, t, n = document) => {
4039
- let r = n.documentElement, i = n.body, a = n.defaultView, o = zi(r.style, Li), s = zi(i.style, Ri), c = a?.scrollX ?? 0, l = a?.scrollY ?? 0;
4040
- r.style.setProperty("overflow", "hidden"), i.style.setProperty("position", "fixed");
4041
- for (let e of [
4042
- "top",
4043
- "right",
4044
- "bottom",
4045
- "left"
4046
- ]) i.style.setProperty(e, "0px");
4047
- return i.style.setProperty(e, `${t}px`), i.style.setProperty("overflow", "auto"), i.style.setProperty("contain", "layout paint"), i.scrollTop = l, i.scrollLeft = c, {
4048
- resize: (t) => {
4049
- i.style.setProperty(e, `${t}px`);
4050
- },
4051
- release: () => {
4052
- let e = i.scrollTop, t = i.scrollLeft;
4053
- Bi(i.style, s), Bi(r.style, o), a?.scrollTo(t, e);
4054
- }
4055
- };
4056
- }, Hi = (e, t) => {
4057
- let n = window.open("", `voltro-devtools-${Date.now().toString(36)}`, `popup,width=${Math.round(e.w)},height=${Math.round(e.h)}`);
4058
- if (n === null) return null;
4059
- let r = n.document;
4060
- return r.title = t, r.documentElement.style.setProperty("color-scheme", "dark"), r.documentElement.style.setProperty("background", "#100c19"), r.body.style.setProperty("margin", "0"), n;
4061
- }, Ui = "voltro:devtools:open", Wi = (e) => {
4062
- if (typeof window > "u") return e;
4063
- try {
4064
- let t = window.localStorage.getItem(Ui);
4065
- return t === null ? e : t === "1";
4066
- } catch {
4067
- return e;
4068
- }
4069
- }, Gi = (e) => {
4070
- if (!(typeof window > "u")) try {
4071
- window.localStorage.setItem(Ui, e ? "1" : "0");
4072
- } catch {}
4073
- }, Ki = ({ initialIsOpen: e = !1, initialDock: t = "bottom", strings: n, inspectToken: r } = {}) => {
4074
- let i = pn(r);
4075
- return /* @__PURE__ */ M(dn, {
4076
- token: i,
4077
- children: /* @__PURE__ */ M(Be, {
4078
- strings: n ?? {},
4079
- children: /* @__PURE__ */ M(ea, {
4080
- initialIsOpen: e,
4081
- initialDock: t
4082
- })
4083
- })
4084
- });
4085
- }, qi = (e) => {
4086
- switch (e.dock) {
4087
- case "bottom":
4088
- case "top": return { height: e.sizes[e.dock] };
4089
- case "left":
4090
- case "right": return { width: e.sizes[e.dock] };
4091
- case "window": return {
4092
- left: e.window.x,
4093
- top: e.window.y,
4094
- width: e.window.w,
4095
- height: e.window.h
4096
- };
4097
- case "external": return {};
4098
- }
4099
- }, Ji = (e, t) => {
4100
- let n = {
4101
- "--vdt-capsule-x": e.x,
4102
- "--vdt-capsule-y": e.y
4103
- };
4104
- return t !== void 0 && (n.width = t.w, n.height = t.h), n;
4105
- }, Yi = (e, t, n, r) => {
4106
- switch (e) {
4107
- case "bottom": return t - r;
4108
- case "top": return t + r;
4109
- case "left": return t + n;
4110
- case "right": return t - n;
4111
- }
4112
- }, Xi = (e) => {
4113
- console.error("[voltro devtools] the overlay hit an error and was contained:", e);
4114
- }, Zi = (e) => {
4115
- let t = document.body.style;
4116
- e !== null && t.setProperty("cursor", e), t.setProperty("user-select", "none"), t.setProperty("-webkit-user-select", "none");
4117
- }, Qi = () => {
4118
- let e = document.body.style;
4119
- e.removeProperty("cursor"), e.removeProperty("user-select"), e.removeProperty("-webkit-user-select");
4120
- }, $i = (e) => e instanceof Element && e.closest("button, input, a, [role=\"menu\"], [role=\"tablist\"], label") !== null, ea = ({ initialIsOpen: e, initialDock: t }) => {
4121
- let r = U().shell, [a, o] = Bt(t), [u, d] = l(() => Wi(e) && a.dock !== "external"), [f, p] = l("all"), m = c(null), [h, g] = l(0), _ = Ii(), v = _.length > 0 ? _[_.length - 1] : null;
4122
- i(() => {
4123
- Gi(u);
4124
- }, [u]), i(() => {
4125
- u || tn();
4126
- }, [u]);
4127
- let { dock: y, push: b } = a, { setDock: x, setEdgeSize: S, setWindowRect: C, setPush: w, setCapsule: T } = o, ee = zt(), E = s(() => Nt(a, ee), [a, ee]), [D, O] = l(u);
4128
- u && !D && O(!0);
4129
- let k = D && !u, te = c(null);
4130
- i(() => {
4131
- if (!k) return;
4132
- let e = te.current?.getAnimations?.() ?? [];
4133
- if (e.length === 0) {
4134
- O(!1);
4135
- return;
4136
- }
4137
- let t = !1, n = () => {
4138
- t || O(!1);
4139
- };
4140
- return Promise.all(e.map((e) => e.finished)).then(n, n), () => {
4141
- t = !0;
4142
- };
4143
- }, [k]);
4144
- let A = c(null), ne = c(!1);
4145
- i(() => {
4146
- if (D) {
4147
- ne.current = !0;
4148
- return;
4149
- }
4150
- ne.current && A.current?.focus();
4151
- }, [D]);
4152
- let [P, F] = l(null), I = u && y === "external";
4153
- i(() => {
4154
- if (!I || typeof window > "u") return;
4155
- let e = Hi(a.window, r.brand);
4156
- if (e === null) {
4157
- console.warn(`[voltro devtools] ${r.externalBlocked}`), d(!1);
4158
- return;
4159
- }
4160
- F(e), e.focus();
4161
- let t = window.setInterval(() => {
4162
- e.closed && d(!1);
4163
- }, 400), n = () => {
4164
- e.close();
4165
- };
4166
- return window.addEventListener("pagehide", n), () => {
4167
- window.clearInterval(t), window.removeEventListener("pagehide", n), F(null), e.close();
4168
- };
4169
- }, [I]), i(() => {
4170
- if (typeof window > "u") return;
4171
- let e = (e, t, n) => e.code === t || e.key.toLowerCase() === n, t = (t) => {
4172
- if (t.altKey && !t.shiftKey && !t.metaKey && !t.ctrlKey && e(t, "KeyV", "v")) {
4173
- t.preventDefault(), d((e) => !e);
4174
- return;
4175
- }
4176
- if ((t.metaKey || t.ctrlKey) && !t.altKey && e(t, "KeyK", "k")) {
4177
- t.preventDefault(), d(!0), p((e) => e === "stores" || e === "indexes" || e === "webhooks" || e === "routes" || e === "runtimes" || e === "pwa" || e === "desktop" ? "all" : e), g((e) => e + 1);
4178
- return;
4179
- }
4180
- if (t.altKey && t.shiftKey) {
4181
- let e = Vt(t.key);
4182
- e !== null && (t.preventDefault(), d(!0), x(e));
4183
- }
4184
- }, n = P === null ? [window] : [window, P];
4185
- for (let e of n) e.addEventListener("keydown", t);
4186
- return () => {
4187
- for (let e of n) e.removeEventListener("keydown", t);
4188
- };
4189
- }, [x, P]), i(() => {
4190
- if (!u) return;
4191
- let e = requestAnimationFrame(() => m.current?.focus());
4192
- return () => cancelAnimationFrame(e);
4193
- }, [
4194
- u,
4195
- h,
4196
- P
4197
- ]);
4198
- let L = D && b && bt(y) ? y : null, R = c(null);
4199
- i(() => {
4200
- if (typeof document > "u" || L === null) return;
4201
- let e = Vi(L, E.sizes[L]);
4202
- return R.current = e, () => {
4203
- R.current = null, e.release();
4204
- };
4205
- }, [L]);
4206
- let z = L === null ? null : E.sizes[L];
4207
- i(() => {
4208
- z !== null && R.current?.resize(z);
4209
- }, [z]);
4210
- let B = n((e) => {
4211
- if (!bt(y)) return;
4212
- e.preventDefault();
4213
- let t = y, n = {
4214
- x: e.clientX,
4215
- y: e.clientY,
4216
- size: E.sizes[t]
4217
- }, r = (e) => {
4218
- S(t, jt(t, Yi(t, n.size, e.clientX - n.x, e.clientY - n.y)));
4219
- }, i = () => {
4220
- window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i), window.removeEventListener("pointercancel", i), Qi();
4221
- };
4222
- window.addEventListener("pointermove", r), window.addEventListener("pointerup", i), window.addEventListener("pointercancel", i), Zi(t === "left" || t === "right" ? "col-resize" : "row-resize");
4223
- }, [
4224
- y,
4225
- E.sizes,
4226
- S
4227
- ]), re = n((e) => {
4228
- if (y !== "window" || $i(e.target)) return;
4229
- e.preventDefault();
4230
- let t = {
4231
- x: e.clientX,
4232
- y: e.clientY,
4233
- rect: E.window
4234
- }, n = (e) => {
4235
- C(Mt({
4236
- ...t.rect,
4237
- x: t.rect.x + (e.clientX - t.x),
4238
- y: t.rect.y + (e.clientY - t.y)
4239
- }));
4240
- }, r = () => {
4241
- window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), Qi();
4242
- };
4243
- window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r), Zi(null);
4244
- }, [
4245
- y,
4246
- E.window,
4247
- C
4248
- ]), V = n((e) => {
4249
- if (y !== "window") return;
4250
- e.preventDefault();
4251
- let t = {
4252
- x: e.clientX,
4253
- y: e.clientY,
4254
- rect: E.window
4255
- }, n = (e) => {
4256
- C(Mt({
4257
- ...t.rect,
4258
- w: t.rect.w + (e.clientX - t.x),
4259
- h: t.rect.h + (e.clientY - t.y)
4260
- }));
4261
- }, r = () => {
4262
- window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), Qi();
4263
- };
4264
- window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r), Zi("nwse-resize");
4265
- }, [
4266
- y,
4267
- E.window,
4268
- C
4269
- ]), [ie, ae] = l(null), oe = c(!1), se = n((e) => {
4270
- if (e.button !== 0) return;
4271
- let t = e.currentTarget.getBoundingClientRect(), n = {
4272
- x: e.clientX,
4273
- y: e.clientY,
4274
- placement: a.capsule,
4275
- size: {
4276
- w: t.width,
4277
- h: t.height
4278
- }
4279
- }, r = !1, i = (e) => {
4280
- let t = e.clientX - n.x, i = e.clientY - n.y;
4281
- if (!r) {
4282
- if (Math.hypot(t, i) < 4) return;
4283
- r = !0, oe.current = !0, ae(n.size), Zi("grabbing");
4284
- }
4285
- T(mt(n.placement, n.size, {
4286
- width: window.innerWidth,
4287
- height: window.innerHeight
4288
- }, t, i));
4289
- }, o = () => {
4290
- window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", o), r && (ae(null), Qi(), setTimeout(() => {
4291
- oe.current = !1;
4292
- }, 0));
4293
- };
4294
- window.addEventListener("pointermove", i), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", o);
4295
- }, [a.capsule, T]), ce = n(() => d(!1), []), le = n(() => {
4296
- if (oe.current) {
4297
- oe.current = !1;
4298
- return;
4299
- }
4300
- d(!0);
4301
- }, []), ue = y === "external", H = D ? /* @__PURE__ */ N("section", {
4302
- ref: te,
4303
- className: "vdt-console",
4304
- role: "dialog",
4305
- "aria-label": r.brand,
4306
- "data-dock": y,
4307
- "data-closing": k ? "true" : void 0,
4308
- inert: k,
4309
- style: qi(E),
4310
- children: [
4311
- bt(y) ? /* @__PURE__ */ M("div", {
4312
- className: "vdt-grip",
4313
- role: "separator",
4314
- "aria-label": r.resizeLabel,
4315
- "aria-orientation": y === "left" || y === "right" ? "vertical" : "horizontal",
4316
- onPointerDown: B
4317
- }) : null,
4318
- /* @__PURE__ */ M(ki, {
4319
- onError: Xi,
4320
- children: /* @__PURE__ */ M(Di, {
4321
- dock: y,
4322
- push: b,
4323
- onDock: x,
4324
- onPush: w,
4325
- onClose: ce,
4326
- scope: f,
4327
- onScope: p,
4328
- searchRef: m,
4329
- onHeaderPointerDown: y === "window" ? re : void 0
4330
- })
4331
- }),
4332
- y === "window" ? /* @__PURE__ */ M("div", {
4333
- className: "vdt-win-resize",
4334
- role: "separator",
4335
- "aria-label": r.resizeLabel,
4336
- onPointerDown: V
4337
- }) : null
4338
- ]
4339
- }) : null;
4340
- return /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M(Fi, { children: /* @__PURE__ */ M("div", {
4341
- className: "vdt-host",
4342
- "data-open": u ? "true" : "false",
4343
- "data-dock": y,
4344
- "data-push": L === null ? "false" : "true",
4345
- children: /* @__PURE__ */ M("div", {
4346
- className: "vdt-scope",
4347
- children: D ? ue ? null : H : /* @__PURE__ */ N(ki, {
4348
- onError: Xi,
4349
- children: [ie === null ? null : /* @__PURE__ */ M("div", {
4350
- className: "vdt-capsule-slots",
4351
- "aria-hidden": "true",
4352
- children: lt.map((e) => /* @__PURE__ */ M("span", {
4353
- className: "vdt-capsule-slot",
4354
- "data-active": ft(e, a.capsule) ? "true" : void 0,
4355
- style: Ji(e, ie)
4356
- }, `${e.x}:${e.y}`))
4357
- }), /* @__PURE__ */ M(st, {
4358
- status: v,
4359
- onOpen: le,
4360
- buttonRef: A,
4361
- style: Ji(a.capsule),
4362
- dragging: ie !== null,
4363
- onPointerDown: se
4364
- })]
4365
- })
4366
- })
4367
- }) }), ue && P !== null ? /* @__PURE__ */ M(Fi, {
4368
- target: P.document,
4369
- children: /* @__PURE__ */ M("div", {
4370
- className: "vdt-host",
4371
- "data-open": "true",
4372
- "data-dock": "external",
4373
- "data-push": "false",
4374
- children: /* @__PURE__ */ M("div", {
4375
- className: "vdt-scope",
4376
- children: H
4377
- })
4378
- })
4379
- }) : null] });
4380
- };
4381
- //#endregion
4382
- export { Be as DevtoolsStringsProvider, Ki as VoltroDevtools, Le as defaultDevtoolsStrings, U as useDevtoolsStrings };
1
+ import { DevtoolsStringsProvider as e, defaultDevtoolsStrings as t, useDevtoolsStrings as n } from "./strings.js";
2
+ import { VoltroDevtools as r } from "./Devtools.js";
3
+ export { e as DevtoolsStringsProvider, r as VoltroDevtools, t as defaultDevtoolsStrings, n as useDevtoolsStrings };