@voltro/devtools 0.89.2 → 0.91.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.
@@ -2,23 +2,92 @@ import { getLogs as e, subscribeLogs as t } from "../logsBus.js";
2
2
  import { Spinner as n, VoltroMark as r } from "../components/icons.js";
3
3
  import { useDevtoolsStrings as i } from "../strings.js";
4
4
  import { useSubscriptionsCount as a } from "../panels/subscriptions.js";
5
- import { DEFAULT_CAPSULE_PLACEMENT as o } from "../capsulePlacement.js";
6
- import { useCapsuleClearance as s } from "../useCapsuleClearance.js";
7
- import { useCallback as c, useEffect as l, useLayoutEffect as u, useRef as d, useSyncExternalStore as f } from "react";
8
- import { getMutations as p, subscribeMutations as m, useConnectionStatus as h, useFrameworkRuntimes as g } from "@voltro/client";
9
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
5
+ import { useCapsuleClearance as o } from "../useCapsuleClearance.js";
6
+ import { DEFAULT_CAPSULE_PLACEMENT as s } from "../capsulePlacement.js";
7
+ import { useCallback as c, useEffect as l, useLayoutEffect as u, useRef as d, useState as f, useSyncExternalStore as p } from "react";
8
+ import { getMutations as m, subscribeMutations as h, useConnectionStatus as g, useFrameworkRuntimes as _ } from "@voltro/client";
9
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
10
10
  // src/console/Capsule.tsx
11
- var y = (e) => e === "compiling" || e === "loading" || e === "reconnecting", b = () => f(t, e, e), x = ({ name: e }) => {
12
- let t = h(e).status;
13
- return /* @__PURE__ */ v("span", {
11
+ var b = (e) => e === "compiling" || e === "loading" || e === "reconnecting", x = () => p(t, e, e), S = ({ name: e }) => {
12
+ let t = g(e).status;
13
+ return /* @__PURE__ */ y("span", {
14
14
  className: "vdt-chip",
15
15
  "data-status": t,
16
- children: [/* @__PURE__ */ _("span", {
16
+ children: [/* @__PURE__ */ v("span", {
17
17
  className: `vdt-dot vdt-dot-${t === "connected" ? "ok" : t === "recovering" ? "warn" : "err"}`,
18
18
  "aria-hidden": "true"
19
- }), /* @__PURE__ */ _("b", { children: e })]
19
+ }), /* @__PURE__ */ v("b", { children: e })]
20
20
  });
21
- }, S = 260, C = "cubic-bezier(0.2, 0.8, 0.2, 1)", w = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, T = (e, t, n) => {
21
+ }, C = (e) => {
22
+ let t = e.indexOf(" /");
23
+ if (t < 0) return {
24
+ verb: e,
25
+ head: "",
26
+ tail: "",
27
+ path: null
28
+ };
29
+ let n = e.slice(0, t + 1), r = e.slice(t + 1), i = r.split("/"), a = i.length > 3 ? 2 : i.length - 1, o = i.length - a;
30
+ return {
31
+ verb: n,
32
+ head: i.slice(0, o).join("/"),
33
+ tail: `/${i.slice(o).join("/")}`.replace(/^\/\//, "/"),
34
+ path: r
35
+ };
36
+ }, w = (e) => e === null ? "chips" : `${e.kind}:${e.label.replace(/[…\.\s]+$/, "")}`, T = (e) => {
37
+ let [t, n] = f(e), r = d(null), i = d(e);
38
+ i.current = e;
39
+ let a = w(t), o = w(e);
40
+ return l(() => {
41
+ if (r.current === null && (r.current = Date.now()), o === a) {
42
+ e !== t && n(e);
43
+ return;
44
+ }
45
+ let s = () => {
46
+ r.current = Date.now(), n(i.current);
47
+ }, c = e === null ? null : C(e.label).path;
48
+ if (c !== null && (t === null || C(t.label).path !== c) || t === null || !b(t.kind) || e !== null && !b(e.kind)) {
49
+ s();
50
+ return;
51
+ }
52
+ let l = e === null ? 250 : Math.max(0, 600 - (Date.now() - (r.current ?? 0)));
53
+ if (l === 0) {
54
+ s();
55
+ return;
56
+ }
57
+ let u = setTimeout(s, l);
58
+ return () => clearTimeout(u);
59
+ }, [
60
+ o,
61
+ a,
62
+ e,
63
+ t
64
+ ]), t;
65
+ }, E = ({ label: e }) => {
66
+ let { verb: t, head: n, tail: r, path: i } = C(e);
67
+ return i === null ? /* @__PURE__ */ v("span", {
68
+ className: "vdt-capsule-label",
69
+ children: /* @__PURE__ */ v("span", {
70
+ className: "vdt-capsule-label-head",
71
+ children: t
72
+ })
73
+ }) : /* @__PURE__ */ y("span", {
74
+ className: "vdt-capsule-label",
75
+ children: [
76
+ /* @__PURE__ */ v("span", {
77
+ className: "vdt-capsule-label-verb",
78
+ children: t
79
+ }),
80
+ n === "" ? null : /* @__PURE__ */ v("span", {
81
+ className: "vdt-capsule-label-head",
82
+ children: n
83
+ }),
84
+ /* @__PURE__ */ v("span", {
85
+ className: "vdt-capsule-label-tail",
86
+ children: r
87
+ })
88
+ ]
89
+ });
90
+ }, D = 260, O = "cubic-bezier(0.2, 0.8, 0.2, 1)", k = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, A = (e, t, n) => {
22
91
  let r = d(null), i = d(null), a = d(e), o = c((e) => {
23
92
  n.current = e, t && (t.current = e);
24
93
  }, [t, n]);
@@ -34,15 +103,15 @@ var y = (e) => e === "compiling" || e === "loading" || e === "reconnecting", b =
34
103
  if (a.current === e) return;
35
104
  a.current = e;
36
105
  let t = n.current;
37
- if (t === null || typeof t.animate != "function" || w()) return;
106
+ if (t === null || typeof t.animate != "function" || k()) return;
38
107
  let o = i.current === null ? r.current : t.offsetWidth;
39
108
  i.current?.cancel(), i.current = null;
40
109
  let s = t.offsetWidth;
41
110
  if (o === null || o === s) return;
42
111
  t.setAttribute("data-morphing", "true");
43
112
  let c = t.animate([{ width: `${o}px` }, { width: `${s}px` }], {
44
- duration: S,
45
- easing: C
113
+ duration: D,
114
+ easing: O
46
115
  });
47
116
  i.current = c;
48
117
  let l = () => {
@@ -50,114 +119,114 @@ var y = (e) => e === "compiling" || e === "loading" || e === "reconnecting", b =
50
119
  };
51
120
  c.addEventListener("finish", l), c.addEventListener("cancel", l);
52
121
  }, [e]), o;
53
- }, E = ({ status: e, onOpen: t, buttonRef: c, style: l, dragging: u = !1, onPointerDown: h }) => {
54
- let S = i().shell, C = g(), w = a(), E = f(m, p, p), D = b(), O = E.filter((e) => e.status === "pending").length, k = E.filter((e) => e.status === "error").length, A = D.filter((e) => e.level === "error" || e.level === "fatal").length, j = D.filter((e) => e.level === "warn").length, M = e !== null, N = e?.kind ?? "idle", P = e === null ? "" : y(N) ? e.label.replace(/[…\.\s]+$/, "") : e.label, F = M ? `${N}:${P}` : "chips", I = d(null), L = T(F, c, I), R = {
55
- x: l?.["--vdt-capsule-x"] ?? o.x,
56
- y: l?.["--vdt-capsule-y"] ?? o.y
57
- }, z = s(I, R, !u), B = {
122
+ }, j = ({ status: e, onOpen: t, buttonRef: c, style: l, dragging: u = !1, pinned: f = !1, onPointerDown: g }) => {
123
+ let C = T(e), w = i().shell, D = _(), O = a(), k = p(h, m, m), j = x(), M = k.filter((e) => e.status === "pending").length, N = k.filter((e) => e.status === "error").length, P = j.filter((e) => e.level === "error" || e.level === "fatal").length, F = j.filter((e) => e.level === "warn").length, I = C !== null, L = C?.kind ?? "idle", R = C === null ? "" : b(L) ? C.label.replace(/[…\.\s]+$/, "") : C.label, z = I ? `${L}:${R}` : "chips", B = d(null), V = A(z, c, B), H = {
124
+ x: l?.["--vdt-capsule-x"] ?? s.x,
125
+ y: l?.["--vdt-capsule-y"] ?? s.y
126
+ }, U = o(B, H, !u && !f), W = f ? {
127
+ placement: H,
128
+ compact: !1
129
+ } : U, G = {
58
130
  ...l,
59
- "--vdt-capsule-x": z.placement.x,
60
- "--vdt-capsule-y": z.placement.y
61
- }, V = M ? P : [
62
- ...C.names,
63
- `${w} ${S.live}`,
64
- ...O > 0 ? [`${O} ${S.pending}`] : [],
65
- ...k > 0 ? [`${k} ${S.failed}`] : [],
66
- ...A > 0 ? [`${A} ${S.errorsWord(A)}`] : [],
67
- ...A === 0 && j > 0 ? [`${j} ${S.warningsWord(j)}`] : []
131
+ "--vdt-capsule-x": W.placement.x,
132
+ "--vdt-capsule-y": W.placement.y
133
+ }, K = I ? R : [
134
+ ...D.names,
135
+ `${O} ${w.live}`,
136
+ ...M > 0 ? [`${M} ${w.pending}`] : [],
137
+ ...N > 0 ? [`${N} ${w.failed}`] : [],
138
+ ...P > 0 ? [`${P} ${w.errorsWord(P)}`] : [],
139
+ ...P === 0 && F > 0 ? [`${F} ${w.warningsWord(F)}`] : []
68
140
  ].join(", ");
69
- return /* @__PURE__ */ v("button", {
70
- ref: L,
141
+ return /* @__PURE__ */ y("button", {
142
+ ref: V,
71
143
  type: "button",
72
144
  className: "vdt-capsule",
73
- "data-busy": M ? "true" : "false",
74
- "data-kind": N,
145
+ "data-busy": I ? "true" : "false",
146
+ "data-kind": L,
75
147
  "data-dragging": u ? "true" : void 0,
76
- "data-clearance-compact": z.compact ? "true" : void 0,
77
- style: B,
148
+ "data-clearance-compact": W.compact ? "true" : void 0,
149
+ style: G,
78
150
  onClick: t,
79
- onPointerDown: h,
80
- title: M || z.compact ? `${S.openTitle}: ${V}` : S.openTitle,
81
- "aria-label": M || z.compact ? `${S.openLabel}: ${V}` : S.openLabel,
151
+ onPointerDown: g,
152
+ title: I || W.compact ? `${w.openTitle}: ${K}` : w.openTitle,
153
+ "aria-label": I || W.compact ? `${w.openLabel}: ${K}` : w.openLabel,
82
154
  children: [
83
- /* @__PURE__ */ _("span", {
155
+ /* @__PURE__ */ v("span", {
84
156
  className: "vdt-capsule-halo vdt-capsule-aura",
85
157
  "aria-hidden": "true"
86
158
  }),
87
- /* @__PURE__ */ _("span", {
159
+ /* @__PURE__ */ v("span", {
88
160
  className: "vdt-capsule-halo",
89
161
  "aria-hidden": "true"
90
162
  }),
91
- M ? /* @__PURE__ */ _(n, { className: "vdt-capsule-mark vdt-spinner" }) : /* @__PURE__ */ _(r, { className: "vdt-capsule-mark" }),
92
- M ? /* @__PURE__ */ v("span", {
163
+ I ? /* @__PURE__ */ v(n, { className: "vdt-capsule-mark vdt-spinner" }) : /* @__PURE__ */ v(r, { className: "vdt-capsule-mark" }),
164
+ I ? /* @__PURE__ */ y("span", {
93
165
  className: "vdt-capsule-status",
94
- children: [/* @__PURE__ */ _("span", {
95
- className: "vdt-capsule-label",
96
- children: P
97
- }), y(N) ? /* @__PURE__ */ v("span", {
166
+ children: [/* @__PURE__ */ v(E, { label: R }), b(L) ? /* @__PURE__ */ y("span", {
98
167
  className: "vdt-dots",
99
168
  "aria-hidden": "true",
100
169
  children: [
101
- /* @__PURE__ */ _("span", {}),
102
- /* @__PURE__ */ _("span", {}),
103
- /* @__PURE__ */ _("span", {})
170
+ /* @__PURE__ */ v("span", {}),
171
+ /* @__PURE__ */ v("span", {}),
172
+ /* @__PURE__ */ v("span", {})
104
173
  ]
105
174
  }) : null]
106
- }, F) : /* @__PURE__ */ v("span", {
175
+ }, z) : /* @__PURE__ */ y("span", {
107
176
  className: "vdt-capsule-chips",
108
177
  children: [
109
- C.names.map((e) => /* @__PURE__ */ _(x, { name: e }, e)),
110
- /* @__PURE__ */ v("span", {
178
+ D.names.map((e) => /* @__PURE__ */ v(S, { name: e }, e)),
179
+ /* @__PURE__ */ y("span", {
111
180
  className: "vdt-chip",
112
181
  "data-chip": "live",
113
182
  children: [
114
- /* @__PURE__ */ _("b", { children: w }),
183
+ /* @__PURE__ */ v("b", { children: O }),
115
184
  " ",
116
- S.live
185
+ w.live
117
186
  ]
118
187
  }),
119
- O > 0 ? /* @__PURE__ */ v("span", {
188
+ M > 0 ? /* @__PURE__ */ y("span", {
120
189
  className: "vdt-chip vdt-chip-info",
121
190
  "data-chip": "pending",
122
191
  children: [
123
- /* @__PURE__ */ _("span", {
192
+ /* @__PURE__ */ v("span", {
124
193
  className: "vdt-dot vdt-dot-info",
125
194
  "aria-hidden": "true"
126
195
  }),
127
- /* @__PURE__ */ _("b", { children: O }),
196
+ /* @__PURE__ */ v("b", { children: M }),
128
197
  " ",
129
- S.pending
198
+ w.pending
130
199
  ]
131
200
  }) : null,
132
- k > 0 ? /* @__PURE__ */ v("span", {
201
+ N > 0 ? /* @__PURE__ */ y("span", {
133
202
  className: "vdt-chip vdt-chip-err",
134
203
  "data-chip": "failed",
135
204
  children: [
136
- /* @__PURE__ */ _("span", {
205
+ /* @__PURE__ */ v("span", {
137
206
  className: "vdt-dot vdt-dot-err",
138
207
  "aria-hidden": "true"
139
208
  }),
140
- /* @__PURE__ */ _("b", { children: k }),
209
+ /* @__PURE__ */ v("b", { children: N }),
141
210
  " ",
142
- S.failed
211
+ w.failed
143
212
  ]
144
213
  }) : null,
145
- A > 0 ? /* @__PURE__ */ v("span", {
214
+ P > 0 ? /* @__PURE__ */ y("span", {
146
215
  className: "vdt-chip vdt-chip-err",
147
216
  "data-chip": "errors",
148
217
  children: [
149
- /* @__PURE__ */ _("b", { children: A }),
218
+ /* @__PURE__ */ v("b", { children: P }),
150
219
  " ",
151
- S.errorsWord(A)
220
+ w.errorsWord(P)
152
221
  ]
153
222
  }) : null,
154
- A === 0 && j > 0 ? /* @__PURE__ */ v("span", {
223
+ P === 0 && F > 0 ? /* @__PURE__ */ y("span", {
155
224
  className: "vdt-chip vdt-chip-warn",
156
225
  "data-chip": "warnings",
157
226
  children: [
158
- /* @__PURE__ */ _("b", { children: j }),
227
+ /* @__PURE__ */ v("b", { children: F }),
159
228
  " ",
160
- S.warningsWord(j)
229
+ w.warningsWord(F)
161
230
  ]
162
231
  }) : null
163
232
  ]
@@ -165,4 +234,4 @@ var y = (e) => e === "compiling" || e === "loading" || e === "reconnecting", b =
165
234
  ]
166
235
  });
167
236
  };
168
- export { E as Capsule };
237
+ export { j as Capsule, C as splitStatusLabel, T as useSteadyStatus };