@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,106 @@
1
+ import { getLogs as e, subscribeLogs as t } from "../logsBus.js";
2
+ import { defaultDevtoolsStrings as n, useDevtoolsStrings as r } from "../strings.js";
3
+ import { formatCacheKey as i, useLiveApiSections as a } from "../panels/subscriptions.js";
4
+ import { fmtDuration as o, useTracesAcrossApis as s } from "../panels/traces.js";
5
+ import { compactJson as c } from "./searchIndex.js";
6
+ import { useMemo as l, useSyncExternalStore as u } from "react";
7
+ import { getMutations as d, subscribeMutations as f } from "@voltro/client";
8
+ //#region src/console/sources.ts
9
+ var p = (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", m = (e, t) => {
10
+ let n = i(t.key), r = [];
11
+ 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");
12
+ let a = t.snapshot.error ? "error" : t.recovery.phase === "steady" ? void 0 : t.recovery.phase;
13
+ return {
14
+ id: `sub:${e}:${t.key}`,
15
+ source: "subscription",
16
+ apiName: e,
17
+ name: n,
18
+ summary: r.join(" · "),
19
+ ...a === void 0 ? {} : { status: a },
20
+ tone: p(t),
21
+ at: 0,
22
+ haystack: `${e} ${t.key} ${t.tag ?? ""} ${t.source ?? ""} ${a ?? ""}`.toLowerCase(),
23
+ detail: {
24
+ source: "subscription",
25
+ apiName: e,
26
+ entry: t
27
+ }
28
+ };
29
+ }, h = (e) => e.status === "pending" ? "info" : e.status === "success" ? "ok" : "err", g = (e) => e.status === "error" ? e.error instanceof Error && e.error.name !== "Error" ? e.error.name : "error" : e.status, _ = (e) => {
30
+ let t = e.kind === "action" ? "action" : "mutation", n = c(e.input, 160), r = e.status === "error" ? e.error instanceof Error ? `${e.error.name} ${e.error.message}` : c(e.error, 200) : "";
31
+ return {
32
+ id: `mut:${e.id}`,
33
+ source: t,
34
+ apiName: e.apiName,
35
+ name: e.tag,
36
+ summary: n,
37
+ status: g(e),
38
+ tone: h(e),
39
+ at: e.startedAt,
40
+ haystack: `${t} ${e.apiName} ${e.tag} ${e.status} ${n} ${r}`.toLowerCase(),
41
+ detail: {
42
+ source: t,
43
+ mutation: e
44
+ }
45
+ };
46
+ }, v = (e) => {
47
+ switch (e.level) {
48
+ case "error":
49
+ case "fatal": return "err";
50
+ case "warn": return "warn";
51
+ case "info": return "info";
52
+ default: return "idle";
53
+ }
54
+ }, y = (e, t) => ({
55
+ id: `log:${e.ts.getTime()}:${t}`,
56
+ source: "log",
57
+ name: e.scope ?? "log",
58
+ summary: e.message,
59
+ status: e.level,
60
+ tone: v(e),
61
+ at: e.ts.getTime(),
62
+ haystack: `${e.scope ?? ""} ${e.level} ${e.message} ${c(e.fields, 300)}`.toLowerCase(),
63
+ detail: {
64
+ source: "log",
65
+ record: e
66
+ }
67
+ }), b = (e, t, r = n.traces) => {
68
+ let i = t.spans.map((e) => e.attributes["db.operation.name"] ?? e.attributes["db.operation"]).find((e) => typeof e == "string"), a = t.spans.filter((e) => e.name !== t.rootName).slice(0, 3).map((e) => e.name).join(" → "), s = t.kind === "subscription" ? `${t.deliveryCount ?? 0} ${r.delivery(t.deliveryCount ?? 0)}` : [
69
+ o(t.durationMs),
70
+ r.spans(t.spanCount),
71
+ i ?? a
72
+ ].filter(Boolean).join(" · "), c = t.spans.filter((e) => e.status === "error").map((e) => `${e.name} ${e.statusMessage ?? ""}`).join(" ");
73
+ return {
74
+ id: `trace:${e}:${t.traceId}`,
75
+ source: "trace",
76
+ apiName: e,
77
+ name: t.rootName,
78
+ summary: s,
79
+ status: t.hasError ? "error" : "ok",
80
+ tone: t.hasError ? "err" : "ok",
81
+ at: t.startMs,
82
+ haystack: `${e} ${t.rootName} ${t.traceId} ${t.spans.map((e) => e.name).join(" ")} ${c}`.toLowerCase(),
83
+ detail: {
84
+ source: "trace",
85
+ apiName: e,
86
+ trace: t
87
+ }
88
+ };
89
+ }, x = () => u(f, d, d), S = () => u(t, e, e), C = (e, t = !1) => {
90
+ let n = r().traces, i = a(), o = x(), c = S(), u = s(e, t);
91
+ return l(() => {
92
+ let e = [];
93
+ for (let t of i) for (let n of t.entries) e.push(m(t.name, n));
94
+ for (let t of o) e.push(_(t));
95
+ for (let t of u) e.push(b(t.apiName, t.trace, n));
96
+ return c.forEach((t, n) => e.push(y(t, n))), e;
97
+ }, [
98
+ i,
99
+ o,
100
+ c,
101
+ u,
102
+ n
103
+ ]);
104
+ };
105
+ //#endregion
106
+ export { y as logItem, _ as mutationItem, m as subscriptionItem, b as traceItem, C as useConsoleItems };
@@ -0,0 +1,76 @@
1
+ import { subscribeConsoleCalls as e } from "@voltro/web";
2
+ //#region src/consoleBridge.ts
3
+ var t = (e) => e === "warn" || e === "error", n = (e) => {
4
+ if (typeof e == "string") return e;
5
+ if (e instanceof Error) return `${e.name}: ${e.message}`;
6
+ if (e === void 0) return "undefined";
7
+ if (typeof e == "function") return `[function ${e.name || "anonymous"}]`;
8
+ if (typeof e == "symbol" || typeof e == "bigint") return String(e);
9
+ try {
10
+ let t = JSON.stringify(e);
11
+ return t === void 0 ? String(e) : t.length > 500 ? `${t.slice(0, 499)}…` : t;
12
+ } catch {
13
+ return String(e);
14
+ }
15
+ }, r = (e, t, r = /* @__PURE__ */ new Date()) => {
16
+ let i = t.find((e) => e instanceof Error), a = {};
17
+ return t.forEach((e, t) => {
18
+ typeof e != "string" && !(e instanceof Error) && typeof e == "object" && e && (a[`arg${t}`] = e);
19
+ }), {
20
+ ts: r,
21
+ level: e,
22
+ scope: `console.${e}`,
23
+ message: t.map(n).join(" "),
24
+ fields: a,
25
+ ...i === void 0 ? {} : { cause: i }
26
+ };
27
+ }, i = (e, t, r = /* @__PURE__ */ new Date()) => {
28
+ let i = t instanceof Error ? t : void 0;
29
+ return {
30
+ ts: r,
31
+ level: "error",
32
+ scope: e,
33
+ message: t instanceof Error ? `${t.name}: ${t.message}` : `${e === "window.error" ? "Uncaught" : "Unhandled rejection"}: ${n(t)}`,
34
+ fields: {},
35
+ ...i === void 0 ? {} : { cause: i }
36
+ };
37
+ }, a = Symbol.for("voltro.devtools.consoleBridge"), o = (n, o = e) => {
38
+ let s = globalThis, c = s[a];
39
+ if (c !== void 0) return c;
40
+ let l = [], u = !1, d = () => {
41
+ u = !1;
42
+ let e = l;
43
+ l = [];
44
+ for (let t of e) t.claimed || n(t.record);
45
+ }, f = (e) => {
46
+ l.push({
47
+ record: e,
48
+ claimed: !1
49
+ }), u || (u = !0, queueMicrotask(d));
50
+ }, p = (e) => {
51
+ if (e.message !== "") {
52
+ for (let t of l) if (!t.claimed && t.record.level === e.level && t.record.message.includes(e.message)) {
53
+ t.claimed = !0;
54
+ break;
55
+ }
56
+ }
57
+ }, m = o((e) => {
58
+ if (t(e.level)) try {
59
+ f(r(e.level, e.args, new Date(e.ts)));
60
+ } catch {}
61
+ }), h = (e) => {
62
+ n(i("window.error", e.error ?? e.message));
63
+ }, g = (e) => {
64
+ n(i("unhandledrejection", e.reason));
65
+ }, _ = typeof window < "u";
66
+ _ && (window.addEventListener("error", h), window.addEventListener("unhandledrejection", g));
67
+ let v = {
68
+ noteLoggerRecord: p,
69
+ dispose: () => {
70
+ m(), _ && (window.removeEventListener("error", h), window.removeEventListener("unhandledrejection", g)), delete s[a];
71
+ }
72
+ };
73
+ return s[a] = v, v;
74
+ };
75
+ //#endregion
76
+ export { r as consoleRecord, o as installConsoleBridge, i as uncaughtRecord };
@@ -0,0 +1,9 @@
1
+ //#region src/externalWindow.ts
2
+ var e = (e, t) => {
3
+ let n = window.open("", `voltro-devtools-${Date.now().toString(36)}`, `popup,width=${Math.round(e.w)},height=${Math.round(e.h)}`);
4
+ if (n === null) return null;
5
+ let r = n.document;
6
+ return r.title = t, r.documentElement.style.setProperty("color-scheme", "dark"), r.documentElement.style.setProperty("background", "#100c19"), r.body.style.setProperty("margin", "0"), n;
7
+ };
8
+ //#endregion
9
+ export { e as openExternalWindow };