@voltro/devtools 0.85.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 +666 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -33
  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
@@ -0,0 +1,16 @@
1
+ import { createContext as e, useContext as t } from "react";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ //#region src/inspectAuth.tsx
4
+ var r = e(null);
5
+ function i(e) {
6
+ return /* @__PURE__ */ n(r.Provider, {
7
+ value: e.token,
8
+ children: e.children
9
+ });
10
+ }
11
+ var a = () => t(r), o = (e, t) => {
12
+ let n = { ...t ?? {} };
13
+ return e !== null && e !== "" && (n.authorization = `Bearer ${e}`), n;
14
+ }, s = (e) => e !== void 0 && e !== "" ? e : null;
15
+ //#endregion
16
+ export { i as InspectTokenProvider, o as inspectHeaders, s as resolveInspectToken, a as useInspectToken };
@@ -0,0 +1,46 @@
1
+ import { inspectBaseOf as e, isRefusalStatus as t, mayAskInspect as n, noteInspectFailure as r, noteInspectRefusal as i, noteInspectSuccess as a, readInspectRefusal as o } from "./inspectRefusal.js";
2
+ import { inspectHeaders as s } from "./inspectAuth.js";
3
+ //#region src/inspectFetch.ts
4
+ var c = (e) => typeof e == "object" && !!e && "data" in e, l = (e) => c(e) ? e.data : null, u = async (e, t, n) => {
5
+ let r = await fetch(e, {
6
+ method: "POST",
7
+ headers: s(t, {
8
+ accept: "application/json",
9
+ "content-type": "application/json"
10
+ }),
11
+ body: JSON.stringify(n ?? {})
12
+ }), i = await r.json().catch(() => null);
13
+ if (!r.ok) {
14
+ 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}`;
15
+ throw Error(t);
16
+ }
17
+ let a = l(i);
18
+ if (a === null) throw Error("the api answered without an observation");
19
+ return a;
20
+ }, d = (e, t) => {
21
+ let n = `${e}\u0000${t ?? ""}`, r = f.get(n);
22
+ if (r !== void 0) return r;
23
+ let i = p(e, t).finally(() => {
24
+ f.delete(n);
25
+ });
26
+ return f.set(n, i), i;
27
+ }, f = /* @__PURE__ */ new Map(), p = async (c, u) => {
28
+ let d = e(c);
29
+ if (!n(d)) return null;
30
+ let f;
31
+ try {
32
+ f = await fetch(c, { headers: s(u, { accept: "application/json" }) });
33
+ } catch {
34
+ return r(d, !0), null;
35
+ }
36
+ if (t(f.status)) return i(await o(d, f)), null;
37
+ if (!f.ok) return r(d, !1), null;
38
+ a(d);
39
+ try {
40
+ return l(await f.json());
41
+ } catch {
42
+ return null;
43
+ }
44
+ };
45
+ //#endregion
46
+ export { d as fetchInspect, u as postInspect, l as readInspectData };
@@ -0,0 +1,45 @@
1
+ import { useSyncExternalStore as e } from "react";
2
+ var t = 2e3, n = 6e4, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = [], s = () => {
3
+ o = Array.from(r.values());
4
+ for (let e of a) e();
5
+ }, c = (e) => {
6
+ let t = e.indexOf("/_voltro/inspect");
7
+ return t === -1 ? e : e.slice(0, t);
8
+ }, l = (e) => r.get(e), u = (e, t = Date.now()) => {
9
+ if (r.has(e)) return !1;
10
+ let n = i.get(e);
11
+ return n === void 0 || t >= n.retryAt;
12
+ }, d = (e) => {
13
+ i.delete(e.baseUrl), r.set(e.baseUrl, e), s();
14
+ }, f = (e, r, a = Date.now()) => {
15
+ let o = (i.get(e)?.count ?? 0) + 1;
16
+ r && o >= 3 ? d({
17
+ baseUrl: e,
18
+ status: 0
19
+ }) : i.set(e, {
20
+ count: o,
21
+ retryAt: a + Math.min(n, t * 2 ** o)
22
+ });
23
+ }, p = (e) => {
24
+ i.delete(e);
25
+ }, m = () => {
26
+ i.clear(), r.size !== 0 && (r.clear(), s());
27
+ }, h = (e) => e === 401 || e === 403, g = async (e, t) => {
28
+ let n = await t.json().catch(() => null), r = (e) => {
29
+ let t = typeof n == "object" && n ? n[e] : void 0;
30
+ return typeof t == "string" && t !== "" ? t : void 0;
31
+ }, i = typeof n == "object" && !!n && n.locked === !0, a = r("error"), o = r("reason"), s = r("fix"), c = r("login");
32
+ return {
33
+ baseUrl: e,
34
+ status: t.status,
35
+ ...a === void 0 ? {} : { error: a },
36
+ ...o === void 0 ? {} : { reason: o },
37
+ ...s === void 0 ? {} : { fix: s },
38
+ ...i ? { locked: !0 } : {},
39
+ ...c === void 0 ? {} : { login: c }
40
+ };
41
+ }, _ = (e) => (a.add(e), () => {
42
+ a.delete(e);
43
+ }), v = () => e(_, () => o, () => o);
44
+ //#endregion
45
+ export { m as clearInspectRefusals, c as inspectBaseOf, l as inspectRefusalFor, h as isRefusalStatus, u as mayAskInspect, f as noteInspectFailure, d as noteInspectRefusal, p as noteInspectSuccess, g as readInspectRefusal, v as useInspectRefusals };
@@ -0,0 +1,88 @@
1
+ import { inspectRefusalFor as e, isRefusalStatus as t, noteInspectRefusal as n, readInspectRefusal as r } from "./inspectRefusal.js";
2
+ import { inspectHeaders as i } from "./inspectAuth.js";
3
+ import { useEffect as a, useState as o } from "react";
4
+ //#region src/inspectStream.ts
5
+ var s = (a, o) => {
6
+ let s = `${a}/_voltro/inspect/stream?channels=${encodeURIComponent(o.channels.join(","))}`, c = !1, l = !1, u = 0, d, f, p = async () => {
7
+ if (c) return;
8
+ if (e(a) !== void 0) {
9
+ l = !0;
10
+ return;
11
+ }
12
+ d = new AbortController();
13
+ let m;
14
+ try {
15
+ let e = await fetch(s, {
16
+ headers: i(o.token, { accept: "text/event-stream" }),
17
+ signal: d.signal
18
+ });
19
+ if (t(e.status)) throw n(await r(a, e)), l = !0, Error(`inspect stream refused (HTTP ${e.status})`);
20
+ if (!e.ok || e.body === null) throw Error(`inspect stream HTTP ${e.status}`);
21
+ if (c) {
22
+ await e.body.cancel();
23
+ return;
24
+ }
25
+ u = 0, m = e.body.getReader();
26
+ let f = new TextDecoder(), p = "";
27
+ for (; !c;) {
28
+ let { done: e, value: t } = await m.read();
29
+ if (e) break;
30
+ if (p = (p + f.decode(t, { stream: !0 })).replace(/\r\n/g, "\n"), p.length > 1048576) throw Error("inspect stream event exceeds the size limit");
31
+ let n;
32
+ for (; (n = p.indexOf("\n\n")) !== -1;) {
33
+ let e = p.slice(0, n);
34
+ p = p.slice(n + 2);
35
+ let t = e.split("\n").filter((e) => e.startsWith("data:")).map((e) => e.slice(5).replace(/^ /, "")).join("\n");
36
+ if (t === "") continue;
37
+ let r;
38
+ try {
39
+ r = JSON.parse(t);
40
+ } catch {
41
+ continue;
42
+ }
43
+ typeof r == "object" && r && typeof r.channel == "string" && o.onEvent(r);
44
+ }
45
+ }
46
+ if (!c) throw Error("inspect stream disconnected");
47
+ } catch (e) {
48
+ c || o.onError?.(e instanceof Error ? e : Error(String(e)));
49
+ } finally {
50
+ await m?.cancel().catch(() => void 0), m?.releaseLock(), d.abort();
51
+ }
52
+ if (!c && !l) {
53
+ let e = Math.min(3e4, 1e3 * 2 ** u);
54
+ u = Math.min(u + 1, 5), f = setTimeout(() => {
55
+ p();
56
+ }, e);
57
+ }
58
+ };
59
+ return f = setTimeout(() => {
60
+ p();
61
+ }, 0), { close: () => {
62
+ c = !0, clearTimeout(f), d?.abort();
63
+ } };
64
+ }, c = (e, t, n, r = 250) => {
65
+ let [i, c] = o(0), l = t.join(",");
66
+ return a(() => {
67
+ if (!n || e === "") return;
68
+ let t = new Set(l.split(",")), i, a = !1, o = s(e, {
69
+ channels: l.split(","),
70
+ token: null,
71
+ onEvent: (e) => {
72
+ !a && t.has(e.channel) && i === void 0 && (i = setTimeout(() => {
73
+ i = void 0, a || c((e) => e + 1);
74
+ }, r));
75
+ }
76
+ });
77
+ return () => {
78
+ a = !0, clearTimeout(i), o.close();
79
+ };
80
+ }, [
81
+ e,
82
+ l,
83
+ n,
84
+ r
85
+ ]), i;
86
+ };
87
+ //#endregion
88
+ export { s as openInspectStream, c as useInspectChangeEpoch };
@@ -0,0 +1,22 @@
1
+ import { installConsoleBridge as e } from "./consoleBridge.js";
2
+ import { addSink as t } from "@voltro/logger";
3
+ //#region src/logsBus.ts
4
+ var n = 500, r = [], i = /* @__PURE__ */ new Set(), a = [], o = () => {
5
+ a = r.slice();
6
+ }, s = () => {
7
+ o();
8
+ for (let e of i) try {
9
+ e();
10
+ } catch {}
11
+ }, c = typeof window < "u" ? e(l) : null;
12
+ t((e) => {
13
+ c?.noteLoggerRecord(e), l(e);
14
+ });
15
+ function l(e) {
16
+ r.unshift(e), r.length > n && (r.length = n), s();
17
+ }
18
+ var u = () => a, d = (e) => (i.add(e), () => {
19
+ i.delete(e);
20
+ });
21
+ //#endregion
22
+ export { u as getLogs, l as pushLog, d as subscribeLogs };
@@ -0,0 +1,101 @@
1
+ import { Monitor as e } from "../components/icons.js";
2
+ import { useDevtoolsStrings as t } from "../strings.js";
3
+ import { Badge as n, Button as r, Card as i, Empty as a, KeyValue as o, SectionTitle as s } from "../components/primitives.js";
4
+ import { useCallback as c, useEffect as l, useState as u } from "react";
5
+ import { readPairing as d, usePlatform as f, useShellExtension as p } from "@voltro/client";
6
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
+ //#region src/panels/desktop.tsx
8
+ var g = (e) => Object.entries(e ?? {}).filter(([, e]) => e === !0).map(([e]) => e).sort(), _ = (e) => [e.fullscreen ? "fullscreen" : e.maximized ? "maximized" : "windowed", e.focused ? "focused" : "unfocused"].join(", "), v = () => {
9
+ let v = t().desktop, y = f(), b = p("desktop"), [x, S] = u(0), [C, w] = u(null), [T, E] = u(null), D = c(() => S((e) => e + 1), []);
10
+ if (l(() => {
11
+ if (!b) return;
12
+ let e = b.window.subscribe(D), t = b.os.onThemeChange(D);
13
+ return () => {
14
+ e(), t();
15
+ };
16
+ }, [b, D]), l(() => {
17
+ let e = y.storage("local");
18
+ e === null ? E(null) : d(e).then(E);
19
+ }, [y, x]), !b) return /* @__PURE__ */ m(a, { children: v.notDesktop });
20
+ let O = g(y.capabilities);
21
+ return /* @__PURE__ */ h("div", {
22
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
23
+ children: [
24
+ /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(s, {
25
+ Icon: e,
26
+ right: /* @__PURE__ */ m(r, {
27
+ size: "sm",
28
+ onClick: D,
29
+ children: v.refresh
30
+ }),
31
+ children: v.shell
32
+ }), /* @__PURE__ */ m(o, { entries: [
33
+ {
34
+ key: v.kind,
35
+ value: /* @__PURE__ */ m(n, {
36
+ tone: "info",
37
+ children: b.kind
38
+ })
39
+ },
40
+ {
41
+ key: v.os,
42
+ value: `${b.os.platform} ${b.os.arch} ${b.os.version}`
43
+ },
44
+ {
45
+ key: v.theme,
46
+ value: b.os.theme()
47
+ },
48
+ {
49
+ key: v.window,
50
+ value: _(b.window.read())
51
+ },
52
+ {
53
+ key: v.appVersion,
54
+ value: y.platform.appVersion ?? v.unknown
55
+ }
56
+ ] })] }),
57
+ /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(s, {
58
+ right: y.updates ? /* @__PURE__ */ m(r, {
59
+ size: "sm",
60
+ onClick: () => {
61
+ y.updates.check().then(w);
62
+ },
63
+ children: v.checkNow
64
+ }) : void 0,
65
+ children: v.updater
66
+ }), /* @__PURE__ */ m(o, { entries: [{
67
+ key: v.updaterPort,
68
+ value: y.updates ? v.yes : v.no
69
+ }, {
70
+ key: v.waitingVersion,
71
+ value: C?.version ?? v.none
72
+ }] })] }),
73
+ /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(s, { children: v.localStack }), /* @__PURE__ */ m(o, { entries: [
74
+ {
75
+ key: v.sidecarPort,
76
+ value: b.sidecar === void 0 ? v.no : v.yes
77
+ },
78
+ {
79
+ key: v.apiUrl,
80
+ value: T?.api ?? v.none
81
+ },
82
+ {
83
+ key: v.apiName,
84
+ value: T?.name ?? v.none
85
+ }
86
+ ] })] }),
87
+ /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(s, { children: v.capabilities }), O.length === 0 ? /* @__PURE__ */ m("div", {
88
+ className: "vdt:px-3 vdt:py-2 vdt:text-xs vdt:text-foreground-subtle",
89
+ children: v.noCapabilities
90
+ }) : /* @__PURE__ */ m("div", {
91
+ className: "vdt:flex vdt:flex-wrap vdt:gap-1 vdt:px-3 vdt:py-2",
92
+ children: O.map((e) => /* @__PURE__ */ m(n, {
93
+ tone: "neutral",
94
+ children: e
95
+ }, e))
96
+ })] })
97
+ ]
98
+ });
99
+ };
100
+ //#endregion
101
+ export { v as DesktopPanel, _ as describeWindow, g as enabledCapabilities };
@@ -0,0 +1,233 @@
1
+ import { Activity as e } from "../components/icons.js";
2
+ import { useDevtoolsStrings as t } from "../strings.js";
3
+ import { Badge as n, Card as r, CardBody as i, Empty as a, SectionTitle as o } from "../components/primitives.js";
4
+ import { inspectRefusalFor as s } from "../inspectRefusal.js";
5
+ import { useInspectToken as c } from "../inspectAuth.js";
6
+ import { fetchInspect as l } from "../inspectFetch.js";
7
+ import { useDocumentVisible as u } from "../useDocumentVisible.js";
8
+ import { useEffect as d, useState as f } from "react";
9
+ import { useFrameworkRuntimes as p } from "@voltro/client";
10
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
11
+ //#region src/panels/indexes.tsx
12
+ var _ = 5e3, v = async (e, t) => {
13
+ if (e === "") return null;
14
+ let n = await l(`${e}/_voltro/inspect/subscriptions`, t);
15
+ return n !== null && Array.isArray(n.subscriptions) ? n : null;
16
+ }, y = (e) => {
17
+ let t = p(), n = u(), r = c(), i = t.names, a = e && n, [o, l] = f(() => i.map((e) => ({
18
+ name: e,
19
+ response: null,
20
+ live: !1
21
+ })));
22
+ return d(() => {
23
+ if (!a) return;
24
+ let e = !1, n = (t, n) => {
25
+ e || l((e) => e.map((e) => e.name === t ? {
26
+ ...e,
27
+ ...n
28
+ } : e));
29
+ }, o = i.map((i) => {
30
+ let a = t.get(i).inspectBaseUrl;
31
+ if (a === "") return { teardown: () => {} };
32
+ let o = null, c = null, l, u = () => {
33
+ c !== null && clearInterval(c), c = null;
34
+ }, d = () => s(a) !== void 0, f = () => {
35
+ if (c !== null || d()) return;
36
+ let e = async () => {
37
+ let e = await v(a, r);
38
+ e !== null && n(i, {
39
+ response: e,
40
+ live: !1
41
+ }), d() && (u(), o?.close());
42
+ };
43
+ e(), c = setInterval(() => {
44
+ e();
45
+ }, _);
46
+ };
47
+ return v(a, r).then((e) => {
48
+ e !== null && n(i, { response: e }), d() && (u(), o?.close());
49
+ }), l = setTimeout(() => {
50
+ if (!(d() || e)) try {
51
+ o = new EventSource(`${a}/_voltro/inspect/stream`), o.addEventListener("subscriptions", (e) => {
52
+ try {
53
+ let t = JSON.parse(e.data).payload;
54
+ t && typeof t == "object" && n(i, {
55
+ response: t,
56
+ live: !0
57
+ });
58
+ } catch {}
59
+ }), o.addEventListener("open", () => {
60
+ n(i, { live: !0 }), u();
61
+ }), o.addEventListener("error", () => {
62
+ n(i, { live: !1 }), f();
63
+ });
64
+ } catch {
65
+ f();
66
+ }
67
+ }, 0), { teardown: () => {
68
+ clearTimeout(l), o?.close(), u();
69
+ } };
70
+ });
71
+ return () => {
72
+ e = !0;
73
+ for (let e of o) e.teardown();
74
+ };
75
+ }, [
76
+ a,
77
+ t,
78
+ i,
79
+ r
80
+ ]), o;
81
+ }, b = (e) => {
82
+ if (typeof e != "object" || !e) return !1;
83
+ let t = e;
84
+ if (Array.isArray(t.and)) return t.and.some(b);
85
+ if (Array.isArray(t.or)) return t.or.some(b);
86
+ let n = t.op;
87
+ return n === "gt" || n === "gte" || n === "lt" || n === "lte";
88
+ }, x = (e) => {
89
+ if (typeof e != "object" || !e) return !1;
90
+ let t = e;
91
+ if (Array.isArray(t.and)) return t.and.some(x);
92
+ if (Array.isArray(t.or)) return t.or.some(x);
93
+ let n = t.op;
94
+ return n === "eq" || n === "in";
95
+ }, S = (e) => e.usingIndex !== void 0 && e.usingIndex.fields.every((t) => e.conjunctiveColumns.includes(t)) ? "tuple" : x(e.predicate) ? "column" : b(e.predicate) ? "range" : "unindexed", C = (e) => e === "tuple" ? "success" : e === "column" ? "info" : e === "range" ? "neutral" : "warning", w = (e) => e === "tuple" ? "tuple" : e === "column" ? "column" : e === "range" ? "range" : "UNINDEXED", T = (e) => e == null ? "null" : typeof e == "string" ? `'${e}'` : Array.isArray(e) ? `[${e.map(T).join(", ")}]` : String(e), E = (e) => e.op === "isNull" ? `${e.column} IS NULL` : e.op === "isNotNull" ? `${e.column} IS NOT NULL` : `${e.column} ${e.op} ${T(e.value)}`, D = (e, t = 0) => {
96
+ if (typeof e != "object" || !e) return String(e);
97
+ let n = e;
98
+ if (Array.isArray(n.and)) return n.and.map((e) => D(e, t + 1)).join(" AND ");
99
+ if (Array.isArray(n.or)) {
100
+ let e = n.or.map((e) => D(e, t + 1)).join(" OR ");
101
+ return t > 0 ? `(${e})` : e;
102
+ }
103
+ return typeof n.column == "string" && typeof n.op == "string" ? E(n) : JSON.stringify(e);
104
+ }, O = () => {
105
+ let n = y(!0), s = t().indexes, c = n.filter((e) => e.response !== null).length;
106
+ return n.length === 0 ? /* @__PURE__ */ h(a, { children: s.noApis }) : c === 0 ? /* @__PURE__ */ g(a, { children: [s.unreachableTitle, /* @__PURE__ */ h("div", {
107
+ className: "vdt:mt-1 vdt:text-foreground-subtle",
108
+ children: s.unreachableHint
109
+ })] }) : /* @__PURE__ */ h("div", {
110
+ className: "vdt:flex vdt:flex-col vdt:gap-3 vdt:p-3",
111
+ children: n.map(({ name: t, response: n, live: a }) => n === null ? /* @__PURE__ */ g(r, { children: [/* @__PURE__ */ h(o, {
112
+ Icon: e,
113
+ children: t
114
+ }), /* @__PURE__ */ h(i, {
115
+ className: "vdt:text-xs vdt:text-foreground-subtle",
116
+ children: s.offline
117
+ })] }, t) : /* @__PURE__ */ h(k, {
118
+ apiName: t,
119
+ response: n,
120
+ live: a
121
+ }, t))
122
+ });
123
+ }, k = ({ apiName: i, response: a, live: s }) => {
124
+ let c = t().indexes, l = [...a.subscriptions].sort((e, t) => t.subscriberCount - e.subscriberCount);
125
+ return /* @__PURE__ */ g(r, { children: [
126
+ /* @__PURE__ */ h(o, {
127
+ Icon: e,
128
+ right: /* @__PURE__ */ g("div", {
129
+ className: "vdt:flex vdt:items-center vdt:gap-1",
130
+ children: [/* @__PURE__ */ h(n, {
131
+ tone: "info",
132
+ children: c.subsBadge(a.subscriptions.length)
133
+ }), /* @__PURE__ */ h(n, {
134
+ tone: s ? "success" : "neutral",
135
+ children: s ? c.live : c.poll
136
+ })]
137
+ }),
138
+ children: i
139
+ }),
140
+ a.matcherStats.length > 0 && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
141
+ className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
142
+ children: c.tables
143
+ }), /* @__PURE__ */ h("div", {
144
+ className: "vdt:flex vdt:flex-col vdt:gap-1",
145
+ children: a.matcherStats.map((e) => /* @__PURE__ */ g("div", {
146
+ className: "vdt:flex vdt:items-baseline vdt:gap-3 vdt:text-xs",
147
+ children: [
148
+ /* @__PURE__ */ h("span", {
149
+ className: "vdt:font-mono vdt:text-foreground",
150
+ children: e.tableName
151
+ }),
152
+ /* @__PURE__ */ g("span", {
153
+ className: "vdt:text-foreground-subtle",
154
+ children: [e.tupleRouted + e.columnBucketed + e.rangeBucketed + e.unindexedFallback, " subs"]
155
+ }),
156
+ e.tupleRouted > 0 && /* @__PURE__ */ h(n, {
157
+ tone: "success",
158
+ children: `${e.tupleRouted} tuple`
159
+ }),
160
+ e.columnBucketed > 0 && /* @__PURE__ */ h(n, {
161
+ tone: "info",
162
+ children: `${e.columnBucketed} column`
163
+ }),
164
+ e.rangeBucketed > 0 && /* @__PURE__ */ h(n, {
165
+ tone: "neutral",
166
+ children: `${e.rangeBucketed} range`
167
+ }),
168
+ e.unindexedFallback > 0 && /* @__PURE__ */ h(n, {
169
+ tone: "warning",
170
+ children: `${e.unindexedFallback} unindexed`
171
+ }),
172
+ e.distinctTupleKeys > 0 && /* @__PURE__ */ g("span", {
173
+ className: "vdt:text-foreground-subtle",
174
+ children: [e.distinctTupleKeys, " tuple keys"]
175
+ })
176
+ ]
177
+ }, e.tableName))
178
+ })] }),
179
+ l.length > 0 && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
180
+ className: "vdt:text-[11px] vdt:uppercase vdt:tracking-wide vdt:text-foreground-subtle vdt:mt-3 vdt:mb-1",
181
+ children: c.subscriptionsSection
182
+ }), /* @__PURE__ */ h("div", {
183
+ className: "vdt:flex vdt:flex-col vdt:gap-2",
184
+ children: l.map((e) => /* @__PURE__ */ h(A, { sub: e }, e.fingerprint))
185
+ })] })
186
+ ] });
187
+ }, A = ({ sub: e }) => {
188
+ let r = t().indexes, i = S(e);
189
+ return /* @__PURE__ */ g("div", {
190
+ className: "vdt:flex vdt:flex-col vdt:gap-0.5 vdt:px-2 vdt:py-1 vdt:rounded-sm vdt:bg-muted/40",
191
+ children: [/* @__PURE__ */ g("div", {
192
+ className: "vdt:flex vdt:items-baseline vdt:gap-2 vdt:text-xs",
193
+ children: [
194
+ /* @__PURE__ */ h("span", {
195
+ className: "vdt:font-mono vdt:text-foreground",
196
+ children: e.table
197
+ }),
198
+ /* @__PURE__ */ h(n, {
199
+ tone: C(i),
200
+ children: w(i)
201
+ }),
202
+ e.usingIndex && /* @__PURE__ */ g("span", {
203
+ className: "vdt:text-foreground-subtle",
204
+ children: [
205
+ r.via,
206
+ " ",
207
+ /* @__PURE__ */ h("span", {
208
+ className: "vdt:font-mono",
209
+ children: e.usingIndex.name
210
+ })
211
+ ]
212
+ }),
213
+ /* @__PURE__ */ g("span", {
214
+ className: "vdt:text-foreground-subtle vdt:ml-auto",
215
+ children: [
216
+ e.subscriberCount,
217
+ " ",
218
+ r.clients(e.subscriberCount)
219
+ ]
220
+ })
221
+ ]
222
+ }), /* @__PURE__ */ h("div", {
223
+ className: "vdt:text-[11px] vdt:font-mono vdt:text-foreground-subtle vdt:break-all",
224
+ children: D(e.predicate)
225
+ })]
226
+ });
227
+ }, j = (e) => {
228
+ let t = y(e), n = 0;
229
+ for (let e of t) n += e.response?.subscriptions.length ?? 0;
230
+ return n;
231
+ };
232
+ //#endregion
233
+ export { O as IndexesPanel, j as useIndexesCount };
@@ -0,0 +1,55 @@
1
+ import "react";
2
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
3
+ //#region src/panels/logs.tsx
4
+ var n = {
5
+ trace: "vdt:text-foreground-subtle",
6
+ debug: "vdt:text-info",
7
+ info: "vdt:text-foreground",
8
+ warn: "vdt:text-warning",
9
+ error: "vdt:text-danger",
10
+ fatal: "vdt:text-danger vdt:font-bold"
11
+ }, r = (e) => {
12
+ if (Object.keys(e).length === 0) return "";
13
+ try {
14
+ return JSON.stringify(e, null, 2);
15
+ } catch {
16
+ return String(e);
17
+ }
18
+ }, i = (e) => {
19
+ let t = (e) => e < 10 ? `0${e}` : String(e);
20
+ return `${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${((e) => e < 100 ? e < 10 ? `00${e}` : `0${e}` : String(e))(e.getMilliseconds())}`;
21
+ }, a = ({ record: a }) => {
22
+ let o = r(a.fields);
23
+ return /* @__PURE__ */ t("div", {
24
+ className: "vdt:bg-background/60 vdt:px-3 vdt:py-2 vdt:flex vdt:flex-col vdt:gap-2",
25
+ children: [
26
+ /* @__PURE__ */ t("div", {
27
+ className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted",
28
+ children: [
29
+ i(a.ts),
30
+ a.scope ? ` · ${a.scope}` : "",
31
+ " · ",
32
+ a.level
33
+ ]
34
+ }),
35
+ /* @__PURE__ */ e("div", {
36
+ className: ["vdt:text-xs vdt:break-words", n[a.level]].join(" "),
37
+ children: a.message
38
+ }),
39
+ a.fiberId ? /* @__PURE__ */ t("div", {
40
+ className: "vdt:text-[10px] vdt:font-mono vdt:text-foreground-muted",
41
+ children: ["fiber: ", a.fiberId]
42
+ }) : null,
43
+ o ? /* @__PURE__ */ e("pre", {
44
+ className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
45
+ children: o
46
+ }) : null,
47
+ a.cause === void 0 ? null : /* @__PURE__ */ e("pre", {
48
+ className: "vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
49
+ children: a.cause instanceof Error ? a.cause.stack ?? `${a.cause.name}: ${a.cause.message}` : String(a.cause)
50
+ })
51
+ ]
52
+ });
53
+ };
54
+ //#endregion
55
+ export { a as LogDetail };
@@ -0,0 +1,81 @@
1
+ import { KeyValue as e } from "../components/primitives.js";
2
+ import "react";
3
+ import "@voltro/client";
4
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
+ //#region src/panels/mutations.tsx
6
+ var r = (e) => typeof e == "number" ? e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s` : "—", i = (e) => {
7
+ try {
8
+ return JSON.stringify(e, null, 2);
9
+ } catch {
10
+ return String(e);
11
+ }
12
+ }, a = ({ mutation: a }) => /* @__PURE__ */ n("div", {
13
+ className: "vdt:bg-background/60",
14
+ children: [
15
+ /* @__PURE__ */ t(e, { entries: [
16
+ {
17
+ key: "id",
18
+ value: a.id
19
+ },
20
+ {
21
+ key: "api",
22
+ value: a.apiName
23
+ },
24
+ {
25
+ key: "tag",
26
+ value: a.tag
27
+ },
28
+ {
29
+ key: "status",
30
+ value: a.status
31
+ },
32
+ {
33
+ key: "startedAt",
34
+ value: new Date(a.startedAt).toISOString()
35
+ },
36
+ {
37
+ key: "settledAt",
38
+ value: a.settledAt ? new Date(a.settledAt).toISOString() : "—"
39
+ },
40
+ {
41
+ key: "duration",
42
+ value: r(a.durationMs)
43
+ }
44
+ ] }),
45
+ /* @__PURE__ */ n("details", {
46
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
47
+ open: !0,
48
+ children: [/* @__PURE__ */ t("summary", {
49
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
50
+ children: "Input"
51
+ }), /* @__PURE__ */ t("pre", {
52
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
53
+ children: i(a.input)
54
+ })]
55
+ }),
56
+ a.status === "success" ? /* @__PURE__ */ n("details", {
57
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
58
+ open: !0,
59
+ children: [/* @__PURE__ */ t("summary", {
60
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-foreground-muted vdt:cursor-pointer",
61
+ children: "Output"
62
+ }), /* @__PURE__ */ t("pre", {
63
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-foreground",
64
+ children: i(a.output)
65
+ })]
66
+ }) : null,
67
+ a.status === "error" ? /* @__PURE__ */ n("details", {
68
+ className: "vdt:px-3 vdt:py-2 vdt:border-t vdt:border-border",
69
+ open: !0,
70
+ children: [/* @__PURE__ */ t("summary", {
71
+ className: "vdt:text-[10px] vdt:uppercase vdt:tracking-wider vdt:text-danger vdt:cursor-pointer",
72
+ children: "Error"
73
+ }), /* @__PURE__ */ t("pre", {
74
+ className: "vdt:mt-2 vdt:text-[11px] vdt:max-h-48 vdt:overflow-auto vdt:font-mono vdt:text-danger",
75
+ children: a.error instanceof Error ? `${a.error.name}: ${a.error.message}\n\n${a.error.stack ?? ""}` : i(a.error)
76
+ })]
77
+ }) : null
78
+ ]
79
+ });
80
+ //#endregion
81
+ export { a as MutationDetail };