@isoloop/devtools 0.0.0 → 0.1.0-next.5

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.
package/dist/panel.js ADDED
@@ -0,0 +1,1630 @@
1
+ /** Topics under this prefix belong to the kernel (ADR 0002). */
2
+ const SYSTEM_TOPIC_PREFIX = "isoloop.";
3
+ function isSystemTopic(topic) {
4
+ return topic.startsWith(SYSTEM_TOPIC_PREFIX);
5
+ }
6
+ Object.freeze([
7
+ "mcp",
8
+ "webmcp",
9
+ "builder"
10
+ ]);
11
+ /** Wraps a hand-written check as a Standard Schema that passes valid values through unchanged. */
12
+ function systemSchema(check) {
13
+ return { "~standard": {
14
+ version: 1,
15
+ vendor: "isoloop",
16
+ validate: (value) => {
17
+ const issues = check(value, []);
18
+ return issues.length === 0 ? { value } : { issues };
19
+ }
20
+ } };
21
+ }
22
+ /** Defines a system topic. The name must start with `isoloop.`. */
23
+ function systemTopic(name, def) {
24
+ if (!isSystemTopic(name)) throw new Error(`system topic names start with isoloop.: ${name}`);
25
+ return Object.freeze({
26
+ ...def,
27
+ name
28
+ });
29
+ }
30
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31
+ const issue = (path, message) => [{
32
+ message,
33
+ path
34
+ }];
35
+ /** Small building blocks for hand-written checks. */
36
+ const checks = {
37
+ string: (v, path) => typeof v === "string" ? [] : issue(path, "expected a string"),
38
+ optionalString: (v, path) => v === void 0 || typeof v === "string" ? [] : issue(path, "expected a string or nothing"),
39
+ object: (fields) => (v, path) => {
40
+ if (!isObject(v)) return issue(path, "expected an object");
41
+ return Object.entries(fields).flatMap(([k, check]) => check(v[k], [...path, k]));
42
+ },
43
+ any: () => []
44
+ };
45
+ const stringOrNull = (v, path) => v === null || typeof v === "string" ? [] : [{
46
+ message: "expected a string or null",
47
+ path
48
+ }];
49
+ systemTopic("isoloop.route.v1", {
50
+ schema: systemSchema(checks.object({
51
+ href: checks.string,
52
+ pathname: checks.string,
53
+ path: stringOrNull,
54
+ search: checks.string,
55
+ hash: checks.string,
56
+ state: checks.any
57
+ })),
58
+ retention: { kind: "compacted" }
59
+ });
60
+ /** `"0.4.2"` → `"0.4"`. Anything that isn't `major.minor[.patch…]` gives `undefined`. */
61
+ function majorMinor(version) {
62
+ const m = /^(\d+)\.(\d+)(?:[.+-].*)?$/.exec(version);
63
+ return m ? `${Number(m[1])}.${Number(m[2])}` : void 0;
64
+ }
65
+ // ../runtime/dist/index.js
66
+ /** This build's stamp: `major.minor` of the package version, inlined when tsdown bundles it. */
67
+ const REQUIRES = majorMinor("0.1.0-next.5") ?? "0.0";
68
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/dist/preact.mjs
69
+ var n;
70
+ var t$1;
71
+ var i$1;
72
+ var u$2;
73
+ var f$2;
74
+ var e$1;
75
+ var o$2;
76
+ var l$1;
77
+ var c$1;
78
+ var a$2;
79
+ var s$1;
80
+ var h$1 = Symbol.for("pv");
81
+ var p$1 = {};
82
+ var v$1 = [];
83
+ var y$1 = /^m(i|n|o|s|text|space)$/;
84
+ var w$1 = Array.isArray;
85
+ var d$1 = v$1.slice;
86
+ var _$1 = Object.assign;
87
+ function g$1(n) {
88
+ n && n.parentNode && n.remove();
89
+ }
90
+ function k$1(n, t, r) {
91
+ var i, u, f, e = {}, o = arguments.length;
92
+ for (f in t) "key" == f ? i = t[f] : "ref" == f && "function" != typeof n ? u = t[f] : e[f] = t[f];
93
+ return o > 2 && (e.children = o > 3 ? d$1.call(arguments, 2) : r), m$1(n, e, i, u, null);
94
+ }
95
+ function m$1(r, i, u, f, e) {
96
+ var o = {
97
+ type: r,
98
+ props: i,
99
+ key: u,
100
+ ref: f,
101
+ __k: null,
102
+ __: null,
103
+ __b: 0,
104
+ __e: null,
105
+ __c: null,
106
+ constructor: h$1,
107
+ __v: e || ++t$1,
108
+ __i: -1,
109
+ __u: 0
110
+ };
111
+ return !e && n.vnode && n.vnode(o), o;
112
+ }
113
+ function M(n) {
114
+ return n.children;
115
+ }
116
+ function x(n, t) {
117
+ this.props = n, this.context = t, this.__g = 0;
118
+ }
119
+ function S(n, t) {
120
+ if (null == t) return n.__ && S(n.__, n.__i + 1);
121
+ for (var r; t < n.__k.length; t++) if ((r = n.__k[t]) && r.__e) return r.__e;
122
+ return "function" != typeof n.type || n.props.__P ? null : S(n);
123
+ }
124
+ function C$1(n) {
125
+ if ((n = n.__) && n.__c && !n.props.__P) return n.__e = null, n.__k.some(function(t) {
126
+ return t && (n.__e = t.__e);
127
+ }), C$1(n);
128
+ }
129
+ function j$1(t) {
130
+ (8 & t.__g || (t.__g |= 8, i$1.push(t), f$2++)) && u$2 == n.debounceRendering || ((u$2 = n.debounceRendering) || queueMicrotask)(L);
131
+ }
132
+ function L() {
133
+ var t, r, o, l, c, a, s, p, v;
134
+ try {
135
+ for (r = 1; i$1.length;) i$1.length > r && i$1.sort(e$1), t = i$1.shift(), r = i$1.length, 8 & t.__g && (l = void 0, c = void 0, a = (c = (o = t).__v).__e, s = [], p = [], (v = o.__P) && ((l = _$1({ constructor: h$1 }, c)).__v = c.__v + 1, n.vnode && n.vnode(l), V(v, l, c, o.__n, v.namespaceURI, 32 & c.__u ? [a] : null, s, a || S(c), 32 & c.__u, p), l.__v = c.__v, l.__.__k[l.__i] = l, D$1(s, l, p), c.__ = c.__e = null, l.__e != a && C$1(l)));
136
+ } finally {
137
+ (f$2 = i$1.length) && (u$2 || queueMicrotask)(L);
138
+ }
139
+ }
140
+ function H(n, t, r, i, u, f, e, o, l, c, a) {
141
+ var s, h, y, w, d, _, g = i.__k || v$1, k = t.length;
142
+ for (l = I(r, t, g, l, k), s = 0; s < k; s++) null != (y = r.__k[s]) && (h = ~y.__i && g[y.__i] || p$1, y.__i = s, _ = V(n, y, h, u, f, e, o, l, c, a), w = y.__e, (h.ref != y.ref || 8 & h.__u) && (h.ref && F(h.ref, null, y, h), y.ref && a.push(y.ref, y.__c || w, y)), d = d || w, 4 & y.__u ? (l = q(y, l, n, !h.__v), h.__e && (h.__e = null)) : "function" == typeof y.type && void 0 !== _ ? l = _ : w && (l = w.nextSibling), y.__u &= -21);
143
+ return r.__e = d, l;
144
+ }
145
+ function I(n, t, r, i, u) {
146
+ var f, e, o, l, c, a, s, p, v, y = r.length, d = y, _ = 0, g = 0, k = n.__k = Array(u);
147
+ for (f = 0; f < u; f++) null != (e = t[f]) && "boolean" != typeof e && "function" != typeof e ? ("object" != typeof e || e.constructor === String ? e = k[f] = m$1(null, e) : w$1(e) ? e = k[f] = m$1(M, { children: e }) : e.constructor === h$1 && e.__b ? e = k[f] = m$1(e.type, e.props, e.key, e.ref, e.__v) : k[f] = e, l = f + _, e.__ = n, e.__b = n.__b + 1, o = null, ~(c = e.__i = O(e, r, l, d)) && (d--, (o = r[c]) && (o.__u |= 2)), o && o.__v ? (e.__u |= 16, c == l - 1 ? _-- : c == l + 1 ? _++ : c != l && (c > l ? _-- : _++, g = 1)) : (~c || (u > y ? _-- : u < y && _++), "function" != typeof e.type && (e.__u |= 4))) : k[f] = null;
148
+ if (g) {
149
+ for (a = [], s = [], f = 0; f < u; f++) if ((e = k[f]) && 16 & e.__u) {
150
+ for (_ = 0, p = a.length; _ < p;) a[v = _ + p >> 1] < e.__i ? _ = v + 1 : p = v;
151
+ a[_] = e.__i, s[f] = _ + 1;
152
+ }
153
+ for (_ = a.length; f--;) s[f] && (s[f] == _ ? _-- : k[f].__u |= 4);
154
+ }
155
+ if (d) for (f = 0; f < y; f++) !(o = r[f]) || 2 & o.__u || (o.__e == i && (i = S(o)), G$1(o, o));
156
+ return i;
157
+ }
158
+ function q(n, t, r, i) {
159
+ var u, f, e, o;
160
+ if ("function" == typeof n.type) {
161
+ if (n.props.__P) return t;
162
+ if (u = n.__k) for (f = 0; f < u.length; f++) u[f] && (u[f].__ = n, t = q(u[f], t, r, !1));
163
+ return t;
164
+ }
165
+ for (t && !t.parentNode && (t = S(n)) && !t.parentNode && (t = null), e = n.__e, o = t; o && 8 == o.nodeType;) o = o.nextSibling;
166
+ for (e != o && (!i && r.moveBefore && e.parentNode ? r.moveBefore(e, t) : r.insertBefore(e, t || null)), t = e; (t = t && t.nextSibling) && 8 == t.nodeType && !t.data.startsWith("$s"););
167
+ return t;
168
+ }
169
+ function O(n, t, r, i) {
170
+ var u, f = n.key, e = n.type, o = t[r], l = o && !(2 & o.__u);
171
+ if (null === o && null == f || l && f == o.key && e == o.type) return r;
172
+ if (i > (l ? 1 : 0)) {
173
+ for (u = r - 1; u >= 0; u--) if ((o = t[u]) && !(2 & o.__u) && f == o.key && e == o.type) return u;
174
+ for (u = r + 1; u < t.length; u++) if ((o = t[u]) && !(2 & o.__u) && f == o.key && e == o.type) return u;
175
+ }
176
+ return -1;
177
+ }
178
+ function P(n, t, r) {
179
+ r ??= "", "-" == t[0] ? n.setProperty(t, r) : n[t] = r;
180
+ }
181
+ function T$1(n, t, r, i, u) {
182
+ var f, e;
183
+ if ("style" == t) if ("string" == typeof r) n.style.cssText = r;
184
+ else {
185
+ if ("string" == typeof i && (n.style.cssText = i = ""), i) for (t in i) r && t in r || P(n.style, t);
186
+ if (r) for (t in r) i && r[t] == i[t] || P(n.style, t, r[t]);
187
+ }
188
+ else if ("o" == t[0] && "n" == t[1]) (n.__e || (n.__e = {}))[t] = r, r && i || (e = a$2[t] || (a$2[t] = N(t)), (n.__a || (n.__a = {}))[t] = c$1, f = t != (t = t.replace(l$1, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), r ? n.addEventListener(t, e, f) : n.removeEventListener(t, e, f));
189
+ else {
190
+ if ("http://www.w3.org/2000/svg" == u) t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
191
+ else if ("width" != t && "height" != t && "href" != t && "list" != t && "form" != t && "tabIndex" != t && "download" != t && "rowSpan" != t && "colSpan" != t && "role" != t && "popover" != t && t in n) try {
192
+ n[t] = null == r ? "" : r;
193
+ return;
194
+ } catch (n) {}
195
+ if ("function" == typeof r) return;
196
+ null == r || !1 === r && "-" != t[4] ? n.removeAttribute(t) : n.setAttribute(t, "popover" == t && 1 == r ? "" : r);
197
+ }
198
+ }
199
+ function N(t) {
200
+ return function(r) {
201
+ var i = this.__e;
202
+ if (i) {
203
+ if (i = i[t], null == r[o$2]) r[o$2] = c$1++;
204
+ else if (r[o$2] < this.__a[t]) return;
205
+ return i(n.event ? n.event(r) : r);
206
+ }
207
+ };
208
+ }
209
+ function V(t, r, i, u, f, e, o, l, c, a) {
210
+ var s, p, y, d, k, b, m, $, C, j, L, I, q, A, O, P, T, N, V = r.type;
211
+ if (r.constructor !== h$1) return null;
212
+ 128 & i.__u && (c = 32 & i.__u, s = i.__c.__z) && (r.__u |= c, p = e = [], 8 == s.nodeType ? l = z$1(s, e) : e.push(s), l = e[0] || l), (s = n.__b) && s(r);
213
+ n: if ("function" == typeof V) {
214
+ y = o.length;
215
+ try {
216
+ if ($ = r.props, C = (s = V.prototype) && s.render, j = (s = V.contextType) && u[s.__c], L = s ? j ? j.props.value : s.__ : u, (d = i.__c) ? (r.__c = d, 2 & d.__g && (d.__g |= 1)) : (C ? r.__c = d = new V($, L) : (r.__c = d = new x($, L), d.constructor = V, d.render = J), j && j.sub(d), d.state || (d.state = {}), d.__n = u, d.__g |= 8, d.__h = [], d.__k = []), C && (d.__s || (d.__s = d.state), V.getDerivedStateFromProps && (d.__s == d.state && (d.__s = _$1({}, d.__s)), _$1(d.__s, V.getDerivedStateFromProps($, d.__s)))), k = d.props, b = d.state, d.__v = r, i.__c) {
217
+ if ($ !== k && C && !V.getDerivedStateFromProps && d.componentWillReceiveProps && d.componentWillReceiveProps($, L), r.__v == i.__v && !(8 & d.__g) || !(4 & d.__g) && d.shouldComponentUpdate && !1 === d.shouldComponentUpdate($, d.__s, L)) {
218
+ r.__v != i.__v && (d.props = $, d.state = d.__s, d.__g &= -9), r.__e = i.__e, r.__k = i.__k, r.__k.some(function(n) {
219
+ n && (n.__ = r);
220
+ }), v$1.push.apply(d.__h, d.__k), d.__k = [], d.__h.length && o.push(d), l = S(i);
221
+ break n;
222
+ }
223
+ d.componentWillUpdate && d.componentWillUpdate($, d.__s, L), C && d.componentDidUpdate && d.__h.push(function() {
224
+ d.componentDidUpdate(k, b, m);
225
+ });
226
+ } else C && !V.getDerivedStateFromProps && d.componentWillMount && d.componentWillMount(), C && d.componentDidMount && d.__h.push(d.componentDidMount);
227
+ if (d.context = L, d.props = $, d.__P = t, d.__g &= -5, I = n.__r, q = 0, C) d.state = d.__s, d.__g &= -9, I && I(r), s = d.render(d.props, d.state, d.context), v$1.push.apply(d.__h, d.__k), d.__k = [];
228
+ else do
229
+ d.__g &= -9, I && I(r), s = d.render(d.props, d.state, d.context), d.state = d.__s;
230
+ while (8 & d.__g && ++q < 25);
231
+ d.state = d.__s, d.getChildContext && (u = _$1({}, u, d.getChildContext())), C && i.__c && d.getSnapshotBeforeUpdate && (m = d.getSnapshotBeforeUpdate(k, b)), A = s && s.type === M && null == s.key ? s.props.children : s, $.__P && (s = l, f = (t = $.__P).namespaceURI, c = e = null, i.props && i.props.__P != t && (i.__k.some(function(n) {
232
+ n && G$1(n, n);
233
+ }), i.__k = null), l = i.__k ? S(i, 0) : null), l = H(t, w$1(A) ? A : [A], r, i, u, f, e, o, l, c, a), $.__P && (r.__e = null, l = s), r.__u &= -161, p && p.some(g$1), d.__h.length && o.push(d), 1 & d.__g && (d.__g &= -4);
234
+ } catch (t) {
235
+ if (o.length = y, r.__v = null, c || e) if (t.then) {
236
+ if (O = 0, r.__u |= 128 | c, e) {
237
+ for (~(T = e.indexOf(l || void 0)) || (T = e.length); (N = e[T - 1]) && 8 == N.nodeType;) T--;
238
+ for (; T < e.length; T++) if (N = e[T]) {
239
+ if (e[T] = null, 8 == N.nodeType) {
240
+ if (N.data.startsWith("$s")) O++ || (P = N);
241
+ else if (O && N.data.startsWith("/$s") && !--O) break;
242
+ } else if (!O) break;
243
+ }
244
+ }
245
+ if (!P) {
246
+ for (; l && 8 == l.nodeType && l.nextSibling;) l = l.nextSibling;
247
+ P = l;
248
+ }
249
+ (s = z$1(P = r.__c.__z || (r.__c.__z = P))) ? (r.__e = P, l = s) : r.__e = l, l = l && l.nextSibling;
250
+ } else e && e.some(g$1);
251
+ else r.__e = i.__e;
252
+ r.__k || (r.__k = i.__k || []), t.then || B$1(r), n.__e(t, r, i);
253
+ }
254
+ } else l = r.__e = E$1(i.__e, r, i, u, f, e, o, c, a, t);
255
+ return (s = n.diffed) && s(r), l;
256
+ }
257
+ function z$1(n, t) {
258
+ if (n && 8 == n.nodeType && n.data.startsWith("$s")) for (var r = 1; n = n.nextSibling;) {
259
+ if (8 == n.nodeType) {
260
+ if (n.data.startsWith("$s")) r++;
261
+ else if (n.data.startsWith("/$s") && !--r) return n;
262
+ }
263
+ t && t.push(n);
264
+ }
265
+ }
266
+ function B$1(n) {
267
+ n && (n.__c && (n.__c.__g |= 4), n.__k && n.__k.some(B$1));
268
+ }
269
+ function D$1(t, r, i) {
270
+ for (var u = 0; u < i.length;) F(i[u++], i[u++], i[u++]);
271
+ n.__c && n.__c(r, t), t.some(function(r) {
272
+ try {
273
+ t = r.__h, r.__h = [], t.some(function(n) {
274
+ n.call(r);
275
+ });
276
+ } catch (t) {
277
+ n.__e(t, r.__v);
278
+ }
279
+ });
280
+ }
281
+ function E$1(t, r, i, u, f, e, o, l, c, a) {
282
+ var s, h, v, _, k, b, m, $, M, x = i.props || p$1, C = r.props, j = r.type;
283
+ if ("svg" == j ? f = "http://www.w3.org/2000/svg" : "math" == j ? f = "http://www.w3.org/1998/Math/MathML" : f || (f = "http://www.w3.org/1999/xhtml"), e) {
284
+ for (s = 0; s < e.length; s++) if ((k = e[s]) && (j ? k.localName == j : 3 == k.nodeType)) {
285
+ t = k, e[s] = null;
286
+ break;
287
+ }
288
+ }
289
+ if (!t) {
290
+ if ($ = a.ownerDocument || document, !j) return $.createTextNode(C);
291
+ t = $.createElementNS(f, j, C.is && C), l && (n.__m && n.__m(r, e), l = !1), e = null;
292
+ }
293
+ if (j) {
294
+ if (a = "template" == j && t.content || t, e = "textarea" == j && null != C.defaultValue ? null : e && d$1.call(a.childNodes), !l && e) for (x = {}, s = 0; s < t.attributes.length; s++) x[(k = t.attributes[s]).name] = k.value;
295
+ for (s in x) k = x[s], "dangerouslySetInnerHTML" == s ? v = k : "children" == s || s in C || "value" == s && "defaultValue" in C || "checked" == s && "defaultChecked" in C || T$1(t, s, null, k, f);
296
+ for (s in M = 1 & i.__u, C) k = C[s], "children" == s ? _ = k : "dangerouslySetInnerHTML" == s ? h = k : "value" == s ? b = k : "checked" == s ? m = k : l && "function" != typeof k || !(x[s] !== k || M && null != k) || T$1(t, s, k, x[s], f);
297
+ h ? (l || v && (h.__html == v.__html || h.__html == t.innerHTML) || (t.innerHTML = h.__html), r.__k = []) : (v && (t.textContent = ""), ("foreignObject" == j || "http://www.w3.org/1998/Math/MathML" == f && y$1.test(j)) && (f = "http://www.w3.org/1999/xhtml"), H(a, w$1(_) ? _ : [_], r, i, u, f, e, o, e ? e[0] : i.__k && S(i, 0), l, c), e && e.some(g$1)), l && "textarea" != j || (s = "value", "progress" == j && null == b ? t.removeAttribute(s) : null == b || b === t[s] && ("progress" != j || b) || T$1(t, s, b, x[s], f), s = "checked", null != m && m != t[s] && T$1(t, s, m, x[s], f));
298
+ } else x === C || l && t.data == C || (t.data = C);
299
+ return t;
300
+ }
301
+ function F(t, r, i, u) {
302
+ try {
303
+ "function" == typeof t ? r ? r.__x = t(r) || 1 : u && (u = u.__c || u.__e) && (r = u.__x) && (u.__x = null, "function" == typeof r ? r() : t(null)) : t.current = r;
304
+ } catch (t) {
305
+ n.__e(t, i);
306
+ }
307
+ }
308
+ function G$1(t, r, i) {
309
+ var u, f, e, o;
310
+ if (n.unmount && n.unmount(t), !(u = t.ref) || u.current && u.current != t.__e || F(u, null, r, t), u = t.__c) {
311
+ if (u.componentWillUnmount) try {
312
+ u.componentWillUnmount();
313
+ } catch (t) {
314
+ n.__e(t, r);
315
+ }
316
+ u.__P = u.__n = null;
317
+ }
318
+ if (u = t.__k) for (o = 0; o < u.length; o++) u[o] && G$1(u[o], r, "function" != typeof t.type || i && !t.props.__P);
319
+ !i && (u = t.__c) && (u = u.__z) && (f = z$1(u, e = [])) && (u == t.__e && e.some(g$1), g$1(f), g$1(u)), (u = t.__e) && (i || g$1(u), u.__e && (u.__e = null)), t.__e = t.__c = t.__ = null;
320
+ }
321
+ function J(n, t, r) {
322
+ return this.constructor(n, r);
323
+ }
324
+ function K(t, r) {
325
+ var i, u, f, e;
326
+ n.__ && n.__(t, r), 9 == r.nodeType && (r = r.documentElement), u = (i = t && 32 & t.__u) ? null : r.__k, r.__k = m$1(M, { children: [t] }), f = [], e = [], V(r, r.__k, u || p$1, p$1, r.namespaceURI, u ? null : r.firstChild ? d$1.call(r.childNodes) : null, f, u ? u.__e : r.firstChild, i, e), D$1(f, r.__k, e), r.__k.props.children = null;
327
+ }
328
+ function R(n) {
329
+ function t(n) {
330
+ var r, i;
331
+ return this.getChildContext || (r = /* @__PURE__ */ new Set(), (i = {})[t.__c] = this, this.getChildContext = function() {
332
+ return i;
333
+ }, this.shouldComponentUpdate = function(n) {
334
+ this.props.value != n.value && r.forEach(function(n) {
335
+ n.__g |= 4, j$1(n);
336
+ });
337
+ }, this.sub = function(n) {
338
+ r.add(n);
339
+ var t = n.componentWillUnmount;
340
+ n.componentWillUnmount = function() {
341
+ r.delete(n), t && t.call(n);
342
+ };
343
+ }), n.children;
344
+ }
345
+ return t.__c = "__cC" + s$1++, t.__ = n, t.Provider = (t.Consumer = function(n, t) {
346
+ return n.children(t);
347
+ }).contextType = t, t;
348
+ }
349
+ n = { __e: function(n, t, r, i) {
350
+ for (var u, e, o; t = t.__;) if ((u = t.__c) && !(1 & u.__g)) {
351
+ u.__g |= 4;
352
+ try {
353
+ if ((o = (e = u.constructor) && e.getDerivedStateFromError) && u.setState(e.getDerivedStateFromError(n)), u.componentDidCatch && (u.componentDidCatch(n, i || {}), o = 1), o && 8 & u.__g) return void (u.__g |= 2);
354
+ } catch (t) {
355
+ n = t;
356
+ }
357
+ }
358
+ throw f$2 = 0, n;
359
+ } }, t$1 = 0, x.prototype.setState = function(n, t) {
360
+ var r = this.__s;
361
+ r && r != this.state || (r = this.__s = _$1({}, this.state)), "function" == typeof n && (n = n(_$1({}, r), this.props)), n && (_$1(r, n), this.__v && (t && this.__k.push(t), j$1(this)));
362
+ }, x.prototype.forceUpdate = function(n) {
363
+ this.__v && (this.__g |= 4, n && this.__h.push(n), j$1(this));
364
+ }, x.prototype.render = M, i$1 = [], f$2 = 0, e$1 = function(n, t) {
365
+ return n.__v.__b - t.__v.__b;
366
+ }, o$2 = Symbol(), l$1 = /(PointerCapture)$|Capture$/i, c$1 = 0, a$2 = {}, s$1 = 0;
367
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/hooks/dist/hooks.mjs
368
+ var t;
369
+ var r;
370
+ var u$1;
371
+ var i;
372
+ var o$1 = Object.is;
373
+ var f$1 = 0;
374
+ var c = [];
375
+ var e = [];
376
+ var a$1 = n;
377
+ var v = a$1.__b;
378
+ var l = a$1.__r;
379
+ var m = a$1.diffed;
380
+ var h = a$1.__c;
381
+ var s = a$1.unmount;
382
+ var p = a$1.__;
383
+ function y(n, t) {
384
+ a$1.__h && a$1.__h(r, n, f$1 || t), f$1 = 0;
385
+ var u = r.__H || (r.__H = {
386
+ __: [],
387
+ __h: []
388
+ });
389
+ return n >= u.__.length && u.__.push({}), u.__[n];
390
+ }
391
+ function d(n) {
392
+ return f$1 = 1, _(G, n);
393
+ }
394
+ function _(n, u, i) {
395
+ var f = y(t++, 2);
396
+ if (f.t = n, !f.__c && (f.__ = [i ? i(u) : G(void 0, u), function(n) {
397
+ var t = f.__N ? f.__N[0] : f.__[0], r = f.t(t, n);
398
+ o$1(t, r) || (f.__N = [r, f.__[1]], f.__c.setState({}));
399
+ }], f.__c = r, !r.__f)) {
400
+ r.__f = !0;
401
+ var c = r.shouldComponentUpdate;
402
+ r.shouldComponentUpdate = function(n, t, r) {
403
+ var u = this.__H;
404
+ if (!u) return !0;
405
+ var i = !1, f = this.props != n;
406
+ if (u.__.some(function(n) {
407
+ n.__N && (i = !0, o$1(n.__[0], n.__N[0]) || (f = !0));
408
+ }), c) {
409
+ var e = c.call(this, n, t, r);
410
+ return i ? e || f : e;
411
+ }
412
+ return !i || f;
413
+ };
414
+ }
415
+ return f.__;
416
+ }
417
+ function A(n, u) {
418
+ var i = y(t++, 3);
419
+ !a$1.__s && E(i.__H, u) && (i.__P = !0, i.__ = n, i.u = u, r.__H.__h.push(i));
420
+ }
421
+ function T(n) {
422
+ return f$1 = 5, w(function() {
423
+ return { current: n };
424
+ }, []);
425
+ }
426
+ function w(n, r) {
427
+ var u = y(t++, 7);
428
+ return E(u.__H, r) && (u.__ = n(), u.__H = r), u.__;
429
+ }
430
+ function j(n) {
431
+ var u = r.context[n.__c], i = y(t++, 9);
432
+ return i.c = n, u ? (i.__ ?? (i.__ = !0, u.sub(r)), u.props.value) : n.__;
433
+ }
434
+ function g() {
435
+ var n;
436
+ do {
437
+ for (; n = e.shift();) try {
438
+ C(n);
439
+ } catch (t) {
440
+ a$1.__e(t, { __: (n = n.__P) && n.__v });
441
+ }
442
+ for (; n = c.shift();) {
443
+ var t = n.__H;
444
+ if (n.__P && t) try {
445
+ t.__h.some(C), t.__h.some(D), t.__h = [];
446
+ } catch (r) {
447
+ t.__h = [], a$1.__e(r, n.__v);
448
+ }
449
+ }
450
+ } while (e.length);
451
+ }
452
+ a$1.__b = function(n) {
453
+ r = null, v && v(n);
454
+ }, a$1.__ = function(n, t) {
455
+ n && t.__k && t.__k.__m && (n.__m = t.__k.__m), p && p(n, t);
456
+ }, a$1.__r = function(n) {
457
+ l && l(n), t = 0;
458
+ var i = (r = n.__c).__H;
459
+ i && (u$1 == r ? r.__h = [] : (i.__h.some(C), i.__h.some(D), t = 0), i.__h = [], i.__.some(function(n) {
460
+ n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
461
+ })), u$1 = r;
462
+ }, a$1.diffed = function(n) {
463
+ m && m(n);
464
+ var t = n.__c;
465
+ t && t.__H && (t.__H.__h.length && B(c.push(t)), t.__H.__.some(function(n) {
466
+ n.u && (n.__H = n.u);
467
+ })), u$1 = r = null;
468
+ }, a$1.__c = function(n, t) {
469
+ t.some(function(n) {
470
+ try {
471
+ n.__h.some(C), n.__h = n.__h.filter(function(n) {
472
+ return !n.__ || D(n);
473
+ });
474
+ } catch (t) {
475
+ n.__h = [function() {
476
+ throw t;
477
+ }];
478
+ }
479
+ }), h && h(n, t);
480
+ }, a$1.unmount = function(n) {
481
+ s && s(n);
482
+ var t, r, u = n.__c;
483
+ u && u.__H && (u.__H.__.some(function(u) {
484
+ try {
485
+ if (u.__P && u.__c) {
486
+ if (void 0 === r) {
487
+ for (r = n.__; r && (!r.__c || !r.__c.__P);) r = r.__;
488
+ r = r && r.__c;
489
+ }
490
+ u.__P = r, B(e.push(u));
491
+ } else C(u);
492
+ } catch (n) {
493
+ t = n;
494
+ }
495
+ }), u.__H = void 0, t && a$1.__e(t, u.__v));
496
+ };
497
+ var k = "function" == typeof requestAnimationFrame;
498
+ function z(n) {
499
+ var t, r = function() {
500
+ clearTimeout(u), k && cancelAnimationFrame(t), setTimeout(n);
501
+ }, u = setTimeout(r, 35);
502
+ k && (t = requestAnimationFrame(r));
503
+ }
504
+ function B(n) {
505
+ 1 != n && i == a$1.requestAnimationFrame || ((i = a$1.requestAnimationFrame) || z)(g);
506
+ }
507
+ function C(n) {
508
+ var t = r, u = n.__c;
509
+ "function" == typeof u && (n.__c = void 0, u()), r = t;
510
+ }
511
+ function D(n) {
512
+ var t = r;
513
+ n.__c = n.__(), r = t;
514
+ }
515
+ function E(n, t) {
516
+ return !n || n.length != t.length || t.some(function(t, r) {
517
+ return !o$1(t, n[r]);
518
+ });
519
+ }
520
+ function G(n, t) {
521
+ return "function" == typeof t ? t(n) : t;
522
+ }
523
+ // ../preact/dist/index.js
524
+ const IsolateCtx = R(null);
525
+ /** The isolate context. Throws outside a component that `defineIsolate` rendered. */
526
+ function useIsolate() {
527
+ const ctx = j(IsolateCtx);
528
+ if (!ctx) throw new Error("useIsolate: not inside a component rendered by defineIsolate()");
529
+ return ctx;
530
+ }
531
+ /**
532
+ * Catches a render error at the isolate's root and reports it as this
533
+ * isolate's own (`ctx.reportError`), so in a pool it crashes only this member
534
+ * (ADR 0015, decision 8). Under a runtime without `reportError` (ADR 0012) the
535
+ * error is rethrown, as before.
536
+ */
537
+ var Boundary = class extends x {
538
+ state = { failed: false };
539
+ static getDerivedStateFromError() {
540
+ return { failed: true };
541
+ }
542
+ componentDidCatch(error) {
543
+ const { ctx } = this.props;
544
+ if (typeof ctx.reportError === "function") ctx.reportError(error);
545
+ else queueMicrotask(() => {
546
+ throw error;
547
+ });
548
+ }
549
+ render() {
550
+ return this.state.failed ? null : this.props.children;
551
+ }
552
+ };
553
+ /** The runtime's internal hook on a context (ADR 0017), by its `Symbol.for` key. */
554
+ const BUSY = Symbol.for("isoloop.busy");
555
+ /** Set on `options` once its render batches are bound, by any copy of this adapter. */
556
+ const BOUND = Symbol.for("isoloop.preact.batches");
557
+ /** Preact 10's default: a resolved promise's callback. */
558
+ const defer = (cb) => {
559
+ Promise.resolve().then(cb);
560
+ };
561
+ /**
562
+ * Preact renders a batch in a promise callback, which the runtime can't see.
563
+ * Through `options.debounceRendering` (public), each batch runs as the code
564
+ * that scheduled it, so the members whose roots it changes share its time
565
+ * (ADR 0017). The batch is still scheduled as Preact schedules it by default,
566
+ * or by a `debounceRendering` already set.
567
+ */
568
+ function bindBatches(ctx) {
569
+ if (Reflect.get(n, BOUND) === true) return;
570
+ const hook = Reflect.get(ctx, BUSY);
571
+ const bind = typeof hook === "object" && hook !== null ? Reflect.get(hook, "bind") : void 0;
572
+ if (typeof bind !== "function") return;
573
+ const prev = Reflect.get(n, "debounceRendering");
574
+ const schedule = (cb) => {
575
+ if (typeof prev === "function") Reflect.apply(prev, void 0, [cb]);
576
+ else defer(cb);
577
+ };
578
+ n.debounceRendering = (cb) => {
579
+ const bound = Reflect.apply(bind, hook, [cb]);
580
+ schedule(typeof bound === "function" ? () => {
581
+ Reflect.apply(bound, void 0, []);
582
+ } : cb);
583
+ };
584
+ Reflect.set(n, BOUND, true);
585
+ }
586
+ function defineIsolate(Component) {
587
+ return {
588
+ requires: REQUIRES,
589
+ start(ctx) {
590
+ const container = ctx.root;
591
+ if (!(container instanceof Element)) throw new Error(`defineIsolate (Preact): "${ctx.id}" is headless; Preact needs a surface`);
592
+ bindBatches(ctx);
593
+ K(k$1(IsolateCtx.Provider, { value: ctx }, k$1(Boundary, { ctx }, k$1(Component, { config: ctx.config }))), container);
594
+ ctx.onShutdown(() => {
595
+ K(null, container);
596
+ });
597
+ }
598
+ };
599
+ }
600
+ /** `snap` with one feed message applied. Pure. */
601
+ function applyMessage(snap, m) {
602
+ switch (m.t) {
603
+ case "snapshot": return m.p;
604
+ case "event": {
605
+ const events = [...snap.events, m.p].slice(-200);
606
+ return {
607
+ ...snap,
608
+ at: Math.max(snap.at, m.p.at),
609
+ events
610
+ };
611
+ }
612
+ case "beats": {
613
+ const byId = new Map(m.p.beats.map((b) => [b.id, b]));
614
+ const isolates = snap.isolates.map((i) => {
615
+ const b = byId.get(i.id);
616
+ if (!b) return i;
617
+ const next = {
618
+ ...i,
619
+ lagMs: b.lagMs,
620
+ lastBeatAt: b.at
621
+ };
622
+ if (b.busyMs !== void 0) next.busyMs = b.busyMs;
623
+ return next;
624
+ });
625
+ return {
626
+ ...snap,
627
+ at: Math.max(snap.at, m.p.at),
628
+ isolates
629
+ };
630
+ }
631
+ case "metrics": return {
632
+ ...snap,
633
+ bus: {
634
+ ...snap.bus,
635
+ metrics: m.p
636
+ }
637
+ };
638
+ case "memory": {
639
+ const byId = new Map(m.p.isolates.map((x) => [x.id, x.memory]));
640
+ const isolates = snap.isolates.map((i) => {
641
+ const memory = byId.get(i.id);
642
+ return memory ? {
643
+ ...i,
644
+ memory
645
+ } : i;
646
+ });
647
+ return {
648
+ ...snap,
649
+ at: Math.max(snap.at, m.p.at),
650
+ isolates
651
+ };
652
+ }
653
+ default: return snap;
654
+ }
655
+ }
656
+ /**
657
+ * The feed as state: `undefined` until the first snapshot arrives (and for
658
+ * good without an inspector).
659
+ */
660
+ function useFeed(inspector) {
661
+ const [snap, setSnap] = d(void 0);
662
+ A(() => {
663
+ if (!inspector) return void 0;
664
+ let alive = true;
665
+ let timer;
666
+ const refresh = () => {
667
+ timer = void 0;
668
+ inspector.snapshot().then((s) => {
669
+ if (alive) setSnap(s);
670
+ }, () => {});
671
+ };
672
+ const off = inspector.on((m) => {
673
+ setSnap((s) => s ? applyMessage(s, m) : s);
674
+ if (m.t === "event" && timer === void 0) timer = setTimeout(refresh, 100);
675
+ });
676
+ refresh();
677
+ return () => {
678
+ alive = false;
679
+ off();
680
+ if (timer !== void 0) clearTimeout(timer);
681
+ };
682
+ }, [inspector]);
683
+ return snap;
684
+ }
685
+ const UNWELL = /* @__PURE__ */ new Set([
686
+ "restarting",
687
+ "crashed",
688
+ "blocked"
689
+ ]);
690
+ function healthOf(snap) {
691
+ if (!snap) return "ok";
692
+ if (snap.isolates.some((i) => i.state === "failed")) return "failed";
693
+ return snap.isolates.some((i) => UNWELL.has(i.state)) ? "unwell" : "ok";
694
+ }
695
+ // src/persist.ts
696
+ const DB = "isoloop-devtools";
697
+ const STORE = "settings";
698
+ const KEY = "panel";
699
+ const POSITIONS$1 = /* @__PURE__ */ new Set([
700
+ "bottom-right",
701
+ "bottom-left",
702
+ "top-right",
703
+ "top-left"
704
+ ]);
705
+ const isPosition = (v) => typeof v === "string" && POSITIONS$1.has(v);
706
+ /** The stored fields that are well formed; anything else is dropped. */
707
+ function parseUi(v) {
708
+ if (typeof v !== "object" || v === null) return {};
709
+ const out = {};
710
+ const open = Reflect.get(v, "open");
711
+ const width = Reflect.get(v, "width");
712
+ const height = Reflect.get(v, "height");
713
+ const position = Reflect.get(v, "position");
714
+ if (typeof open === "boolean") out.open = open;
715
+ if (typeof width === "number" && Number.isFinite(width)) out.width = width;
716
+ if (typeof height === "number" && Number.isFinite(height)) out.height = height;
717
+ if (isPosition(position)) out.position = position;
718
+ return out;
719
+ }
720
+ /** Settles with a request's result; rejects on its error. */
721
+ const settle = (req) => new Promise((resolve, reject) => {
722
+ req.addEventListener("success", () => {
723
+ resolve(req.result);
724
+ });
725
+ req.addEventListener("error", () => {
726
+ reject(req.error ?? /* @__PURE__ */ new Error("IndexedDB request failed"));
727
+ });
728
+ });
729
+ function openDb() {
730
+ const req = indexedDB.open(DB, 1);
731
+ req.addEventListener("upgradeneeded", () => {
732
+ req.result.createObjectStore(STORE);
733
+ });
734
+ return Promise.race([settle(req), new Promise((_resolve, reject) => {
735
+ req.addEventListener("blocked", () => {
736
+ reject(/* @__PURE__ */ new Error("indexedDB.open blocked"));
737
+ });
738
+ })]);
739
+ }
740
+ let db;
741
+ const database = () => {
742
+ db ??= openDb();
743
+ return db;
744
+ };
745
+ /** The stored settings, or `{}` when there are none or storage isn't there. */
746
+ async function loadUi() {
747
+ try {
748
+ const d = await database();
749
+ return parseUi(await settle(d.transaction(STORE, "readonly").objectStore(STORE).get(KEY)));
750
+ } catch {
751
+ return {};
752
+ }
753
+ }
754
+ /** Stores the settings; failures are ignored. Resolves once written (or not). */
755
+ async function saveUi(s) {
756
+ try {
757
+ const tx = (await database()).transaction(STORE, "readwrite");
758
+ tx.objectStore(STORE).put({ ...s }, KEY);
759
+ await new Promise((resolve) => {
760
+ for (const type of [
761
+ "complete",
762
+ "error",
763
+ "abort"
764
+ ]) tx.addEventListener(type, () => {
765
+ resolve();
766
+ });
767
+ });
768
+ } catch {}
769
+ }
770
+ // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
771
+ var f = Symbol.for("pv");
772
+ var o = 0;
773
+ Array.isArray;
774
+ function a(t, e, n$1, u, a, i) {
775
+ e || (e = {});
776
+ var c, l, p = e;
777
+ if ("ref" in p && "function" != typeof t) for (l in p = {}, e) "ref" == l ? c = e[l] : p[l] = e[l];
778
+ var s = {
779
+ type: t,
780
+ props: p,
781
+ key: n$1,
782
+ ref: c,
783
+ __k: null,
784
+ __: null,
785
+ __b: 0,
786
+ __e: null,
787
+ __c: null,
788
+ constructor: f,
789
+ __v: --o,
790
+ __i: -1,
791
+ __u: 0
792
+ };
793
+ return (a || i) && (s.__source = a, s.__self = i), n.vnode && n.vnode(s), s;
794
+ }
795
+ // src/bus-view.tsx
796
+ const rate = (n) => n >= 10 ? String(Math.round(n)) : n.toFixed(1);
797
+ const bytes = (n) => n >= 1048576 ? `${(n / 1048576).toFixed(1)} MB` : n >= 1024 ? `${(n / 1024).toFixed(1)} KB` : `${Math.round(n)} B`;
798
+ function Topics(props) {
799
+ const { topics } = props.metrics;
800
+ if (topics.length === 0) return /* @__PURE__ */ a("p", {
801
+ class: "dt-muted",
802
+ children: "No topics."
803
+ });
804
+ return /* @__PURE__ */ a("table", {
805
+ class: "dt-table",
806
+ "data-view": "topics",
807
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
808
+ /* @__PURE__ */ a("th", { children: "Topic" }),
809
+ /* @__PURE__ */ a("th", {
810
+ class: "dt-num",
811
+ children: "Records/s"
812
+ }),
813
+ /* @__PURE__ */ a("th", {
814
+ class: "dt-num",
815
+ children: "Bytes/s"
816
+ }),
817
+ /* @__PURE__ */ a("th", {
818
+ class: "dt-num",
819
+ title: "The next offset to be written",
820
+ children: "Head"
821
+ }),
822
+ /* @__PURE__ */ a("th", {
823
+ class: "dt-num",
824
+ title: "Records the topic still holds",
825
+ children: "Retained"
826
+ })
827
+ ] }) }), /* @__PURE__ */ a("tbody", { children: topics.map((t) => /* @__PURE__ */ a("tr", {
828
+ "data-topic": t.topic,
829
+ children: [
830
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: t.topic }) }),
831
+ /* @__PURE__ */ a("td", {
832
+ class: "dt-num",
833
+ children: rate(t.recordsPerSec)
834
+ }),
835
+ /* @__PURE__ */ a("td", {
836
+ class: "dt-num",
837
+ children: bytes(t.bytesPerSec)
838
+ }),
839
+ /* @__PURE__ */ a("td", {
840
+ class: "dt-num",
841
+ "data-head": t.head,
842
+ children: t.head
843
+ }),
844
+ /* @__PURE__ */ a("td", {
845
+ class: "dt-num",
846
+ "data-retained": t.retained,
847
+ children: t.retained
848
+ })
849
+ ]
850
+ }, t.topic)) })]
851
+ });
852
+ }
853
+ function Subscriptions(props) {
854
+ const { subscriptions } = props.metrics;
855
+ if (subscriptions.length === 0) return /* @__PURE__ */ a("p", {
856
+ class: "dt-muted",
857
+ children: "No subscriptions."
858
+ });
859
+ return /* @__PURE__ */ a("table", {
860
+ class: "dt-table",
861
+ "data-view": "subscriptions",
862
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
863
+ /* @__PURE__ */ a("th", { children: "Consumer" }),
864
+ /* @__PURE__ */ a("th", { children: "Topic" }),
865
+ /* @__PURE__ */ a("th", {
866
+ class: "dt-num",
867
+ title: "Head minus the consumer's cursor",
868
+ children: "Lag"
869
+ }),
870
+ /* @__PURE__ */ a("th", {
871
+ class: "dt-num",
872
+ title: "Records that may still be delivered before its next commit",
873
+ children: "Credit"
874
+ })
875
+ ] }) }), /* @__PURE__ */ a("tbody", { children: subscriptions.map((s) => /* @__PURE__ */ a("tr", {
876
+ "data-consumer": s.consumer,
877
+ "data-subscription": s.topic,
878
+ children: [
879
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: s.consumer }) }),
880
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: s.topic }) }),
881
+ /* @__PURE__ */ a("td", {
882
+ class: "dt-num",
883
+ "data-lag": s.lag,
884
+ children: s.lag
885
+ }),
886
+ /* @__PURE__ */ a("td", {
887
+ class: "dt-num",
888
+ "data-credit": s.credit,
889
+ children: s.credit
890
+ })
891
+ ]
892
+ }, `${s.consumer} ${s.topic}`)) })]
893
+ });
894
+ }
895
+ function Rejected(props) {
896
+ const entries = Object.entries(props.metrics.rejected).filter((e) => typeof e[1] === "number" && e[1] > 0);
897
+ if (entries.length === 0) return /* @__PURE__ */ a("p", {
898
+ class: "dt-muted",
899
+ children: "None."
900
+ });
901
+ return /* @__PURE__ */ a("ul", {
902
+ style: "margin:0;padding:0;list-style:none;",
903
+ "data-view": "rejected",
904
+ children: entries.map(([code, n]) => /* @__PURE__ */ a("li", {
905
+ "data-rejected": code,
906
+ children: [
907
+ /* @__PURE__ */ a("code", { children: code }),
908
+ " ",
909
+ n
910
+ ]
911
+ }, code))
912
+ });
913
+ }
914
+ function BusView(props) {
915
+ const { bus } = props;
916
+ const m = bus.metrics;
917
+ return /* @__PURE__ */ a("div", {
918
+ class: "dt-view",
919
+ "data-view": "bus",
920
+ children: [/* @__PURE__ */ a("p", {
921
+ class: "dt-muted",
922
+ style: "margin:0 0 4px;",
923
+ "data-bus-state": bus.state,
924
+ children: [
925
+ "Bus ",
926
+ /* @__PURE__ */ a("span", {
927
+ class: `dt-state-${bus.state}`,
928
+ children: bus.state
929
+ }),
930
+ " · ",
931
+ bus.restarts,
932
+ " restarts",
933
+ m?.storage ? ` · storage ${bytes(m.storage.usage)} of ${bytes(m.storage.quota)}` : ""
934
+ ]
935
+ }), m ? /* @__PURE__ */ a(M, { children: [
936
+ /* @__PURE__ */ a("h3", {
937
+ class: "dt-h",
938
+ children: "Topics"
939
+ }),
940
+ /* @__PURE__ */ a(Topics, { metrics: m }),
941
+ /* @__PURE__ */ a("h3", {
942
+ class: "dt-h",
943
+ children: "Subscriptions"
944
+ }),
945
+ /* @__PURE__ */ a(Subscriptions, { metrics: m }),
946
+ /* @__PURE__ */ a("h3", {
947
+ class: "dt-h",
948
+ children: "Rejected publishes, since the bus worker started"
949
+ }),
950
+ /* @__PURE__ */ a(Rejected, { metrics: m })
951
+ ] }) : /* @__PURE__ */ a("p", {
952
+ class: "dt-muted",
953
+ children: bus.state === "none" ? "No bus: the kernel has no contracts." : "Waiting for bus metrics…"
954
+ })]
955
+ });
956
+ }
957
+ /** Splits the filter into tap patterns: `*` (every topic) when empty. */
958
+ const patternsOf = (filter) => {
959
+ const p = filter.split(/[\s,]+/).map((s) => s.trim()).filter((s) => s.length > 0);
960
+ return p.length > 0 ? p : ["*"];
961
+ };
962
+ const pad = (n, w = 2) => String(n).padStart(w, "0");
963
+ const time = (ts) => {
964
+ const d = new Date(ts);
965
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
966
+ };
967
+ function LogView() {
968
+ const inspector = useIsolate().inspector;
969
+ const [filter, setFilter] = d("");
970
+ const [applied, setApplied] = d(["*"]);
971
+ const [paused, setPaused] = d(false);
972
+ const [entries, setEntries] = d([]);
973
+ const [skipped, setSkipped] = d(0);
974
+ A(() => {
975
+ if (!inspector || paused) return void 0;
976
+ let n = 0;
977
+ const onSkipped = (count) => {
978
+ setSkipped((x) => x + count);
979
+ };
980
+ return inspector.tap({
981
+ topics: applied,
982
+ maxPerSec: 50,
983
+ onSkipped
984
+ }, (r) => {
985
+ n += 1;
986
+ const entry = {
987
+ ...r,
988
+ n
989
+ };
990
+ setEntries((prev) => [entry, ...prev].slice(0, 200));
991
+ });
992
+ }, [
993
+ inspector,
994
+ applied,
995
+ paused
996
+ ]);
997
+ return /* @__PURE__ */ a("div", {
998
+ class: "dt-view",
999
+ "data-view": "log",
1000
+ children: [
1001
+ /* @__PURE__ */ a("form", {
1002
+ class: "dt-log-bar",
1003
+ onSubmit: (e) => {
1004
+ e.preventDefault();
1005
+ setApplied(patternsOf(filter));
1006
+ },
1007
+ children: [
1008
+ /* @__PURE__ */ a("input", {
1009
+ type: "text",
1010
+ "aria-label": "Topics to log, as patterns (empty for every topic)",
1011
+ placeholder: "Topics, e.g. orders.* (empty: all)",
1012
+ value: filter,
1013
+ "data-log-filter": "",
1014
+ onInput: (e) => {
1015
+ setFilter(e.currentTarget.value);
1016
+ }
1017
+ }),
1018
+ /* @__PURE__ */ a("button", {
1019
+ type: "submit",
1020
+ "data-log-apply": "",
1021
+ children: "Apply"
1022
+ }),
1023
+ /* @__PURE__ */ a("button", {
1024
+ type: "button",
1025
+ "data-log-pause": "",
1026
+ "aria-pressed": paused ? "true" : "false",
1027
+ onClick: () => {
1028
+ setPaused((p) => !p);
1029
+ },
1030
+ children: paused ? "Resume" : "Pause"
1031
+ }),
1032
+ /* @__PURE__ */ a("button", {
1033
+ type: "button",
1034
+ "data-log-clear": "",
1035
+ onClick: () => {
1036
+ setEntries([]);
1037
+ },
1038
+ children: "Clear"
1039
+ })
1040
+ ]
1041
+ }),
1042
+ /* @__PURE__ */ a("p", {
1043
+ class: "dt-muted",
1044
+ style: "margin:4px 0;",
1045
+ children: [
1046
+ paused ? "Paused" : `Tapping ${applied.join(", ")}`,
1047
+ " · newest first ·",
1048
+ " ",
1049
+ /* @__PURE__ */ a("span", {
1050
+ "data-log-skipped": skipped,
1051
+ children: [
1052
+ 50,
1053
+ "/s cap · ",
1054
+ skipped,
1055
+ " skipped"
1056
+ ]
1057
+ })
1058
+ ]
1059
+ }),
1060
+ entries.length === 0 ? /* @__PURE__ */ a("p", {
1061
+ class: "dt-muted",
1062
+ children: "No records yet."
1063
+ }) : /* @__PURE__ */ a("table", {
1064
+ class: "dt-table",
1065
+ "data-log-table": "",
1066
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1067
+ /* @__PURE__ */ a("th", { children: "Time" }),
1068
+ /* @__PURE__ */ a("th", { children: "Topic" }),
1069
+ /* @__PURE__ */ a("th", {
1070
+ class: "dt-num",
1071
+ children: "Offset"
1072
+ }),
1073
+ /* @__PURE__ */ a("th", { children: "Key" }),
1074
+ /* @__PURE__ */ a("th", { children: "Producer" }),
1075
+ /* @__PURE__ */ a("th", {
1076
+ class: "dt-num",
1077
+ children: "Size"
1078
+ }),
1079
+ /* @__PURE__ */ a("th", { children: "Value" })
1080
+ ] }) }), /* @__PURE__ */ a("tbody", { children: entries.map((r) => /* @__PURE__ */ a("tr", {
1081
+ "data-log-topic": r.topic,
1082
+ "data-offset": r.offset,
1083
+ children: [
1084
+ /* @__PURE__ */ a("td", { children: time(r.ts) }),
1085
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: r.topic }) }),
1086
+ /* @__PURE__ */ a("td", {
1087
+ class: "dt-num",
1088
+ children: r.offset
1089
+ }),
1090
+ /* @__PURE__ */ a("td", { children: r.key ?? "" }),
1091
+ /* @__PURE__ */ a("td", { children: r.producer }),
1092
+ /* @__PURE__ */ a("td", {
1093
+ class: "dt-num",
1094
+ children: [r.bytes, " B"]
1095
+ }),
1096
+ /* @__PURE__ */ a("td", {
1097
+ class: "dt-value",
1098
+ title: r.truncated ? "Cut to a 2 KB preview" : "",
1099
+ children: /* @__PURE__ */ a("code", { children: [r.preview, r.truncated ? "…" : ""] })
1100
+ })
1101
+ ]
1102
+ }, `${r.topic} ${r.offset} ${r.n}`)) })]
1103
+ })
1104
+ ]
1105
+ });
1106
+ }
1107
+ // src/views.tsx
1108
+ /** How long the block control busy-loops an isolate's worker. */
1109
+ const BLOCK_MS = 2e3;
1110
+ const CSS = `
1111
+ .dt-tabs { display: flex; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid #374151; }
1112
+ .dt-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #9ca3af;
1113
+ font: inherit; padding: 4px 8px; cursor: pointer; }
1114
+ .dt-tab[aria-selected="true"] { color: #e5e7eb; border-bottom-color: #60a5fa; }
1115
+ .dt-view { padding: 6px 8px; }
1116
+ .dt-muted { color: #9ca3af; }
1117
+ .dt-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
1118
+ .dt-table th { text-align: left; font-weight: 600; color: #9ca3af; padding: 2px 6px 4px 0;
1119
+ white-space: nowrap; }
1120
+ .dt-table td { padding: 3px 6px 3px 0; border-top: 1px solid #1f2937; vertical-align: top;
1121
+ white-space: nowrap; }
1122
+ .dt-table td.dt-num, .dt-table th.dt-num { text-align: right; }
1123
+ .dt-badge { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px;
1124
+ background: #1e3a8a; color: #bfdbfe; font-size: 10px; }
1125
+ .dt-pool { display: block; color: #9ca3af; font-size: 11px; }
1126
+ .dt-state-running { color: #86efac; }
1127
+ .dt-state-blocked, .dt-state-crashed, .dt-state-restarting { color: #fcd34d; }
1128
+ .dt-state-failed { color: #fca5a5; }
1129
+ .dt-actions { display: flex; gap: 4px; }
1130
+ .dt-actions button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
1131
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 6px; cursor: pointer; }
1132
+ .dt-actions button:focus-visible, .dt-tab:focus-visible { outline: 2px solid #60a5fa;
1133
+ outline-offset: 1px; }
1134
+ .dt-status { margin: 6px 0 0; color: #fca5a5; }
1135
+ .dt-h { margin: 10px 0 4px; font-size: 12px; color: #9ca3af; }
1136
+ .dt-warning { color: #fcd34d; }
1137
+ .dt-state-none { color: #9ca3af; }
1138
+ .dt-log-bar { display: flex; gap: 4px; }
1139
+ .dt-log-bar input { flex: 1; min-width: 0; background: #0b1220; color: #e5e7eb;
1140
+ border: 1px solid #374151; border-radius: 4px; font: inherit; padding: 2px 6px; }
1141
+ .dt-log-bar button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
1142
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 8px; cursor: pointer; }
1143
+ .dt-log-bar input:focus-visible, .dt-log-bar button:focus-visible { outline: 2px solid #60a5fa;
1144
+ outline-offset: 1px; }
1145
+ .dt-table td.dt-value { white-space: normal; word-break: break-all; max-width: 40ch; }
1146
+ `;
1147
+ const ms = (n) => n === void 0 ? "–" : `${Math.round(n)} ms`;
1148
+ const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
1149
+ /** A memory figure, its age against the feed's latest time, and what it covers. */
1150
+ function Memory(props) {
1151
+ const { memory } = props;
1152
+ if (!memory) return /* @__PURE__ */ a("span", {
1153
+ class: "dt-muted",
1154
+ title: "Measured only in Chromium on a cross-origin isolated page (ADR 0020, decision 4)",
1155
+ children: "–"
1156
+ });
1157
+ const age = Math.max(0, Math.round((props.now - memory.at) / 1e3));
1158
+ return /* @__PURE__ */ a("span", {
1159
+ "data-memory": memory.bytes,
1160
+ title: `Chromium, cross-origin isolated. Measured ${age} s ago${memory.shared ? "; the whole pool worker, shared by its members" : ""}.`,
1161
+ children: [
1162
+ mb(memory.bytes),
1163
+ memory.shared ? " (pool)" : "",
1164
+ /* @__PURE__ */ a("span", {
1165
+ class: "dt-muted",
1166
+ children: [
1167
+ " · ",
1168
+ age,
1169
+ " s"
1170
+ ]
1171
+ })
1172
+ ]
1173
+ });
1174
+ }
1175
+ function Controls(props) {
1176
+ const act = (name, run) => () => {
1177
+ props.onError(void 0);
1178
+ run().catch((e) => {
1179
+ props.onError(`${name} ${props.id}: ${e instanceof Error ? e.message : String(e)}`);
1180
+ });
1181
+ };
1182
+ const { id, inspector } = props;
1183
+ return /* @__PURE__ */ a("span", {
1184
+ class: "dt-actions",
1185
+ children: [
1186
+ /* @__PURE__ */ a("button", {
1187
+ type: "button",
1188
+ "data-control": "restart",
1189
+ "aria-label": `Restart ${id}`,
1190
+ title: `Restart ${id}`,
1191
+ onClick: act("restart", () => inspector.restart(id)),
1192
+ children: "Restart"
1193
+ }),
1194
+ /* @__PURE__ */ a("button", {
1195
+ type: "button",
1196
+ "data-control": "kill",
1197
+ "aria-label": `Kill ${id}`,
1198
+ title: `End ${id}'s worker as a crash; the supervisor restarts it. In a pool, every member restarts.`,
1199
+ onClick: act("kill", () => inspector.kill(id)),
1200
+ children: "Kill"
1201
+ }),
1202
+ /* @__PURE__ */ a("button", {
1203
+ type: "button",
1204
+ "data-control": "block",
1205
+ "aria-label": `Block ${id} for ${BLOCK_MS / 1e3} s`,
1206
+ title: `Busy-loop ${id}'s worker for ${BLOCK_MS / 1e3} s`,
1207
+ onClick: act("block", () => inspector.block(id, BLOCK_MS)),
1208
+ children: [
1209
+ "Block ",
1210
+ BLOCK_MS / 1e3,
1211
+ " s"
1212
+ ]
1213
+ })
1214
+ ]
1215
+ });
1216
+ }
1217
+ function IsolateRow(props) {
1218
+ const i = props.isolate;
1219
+ return /* @__PURE__ */ a("tr", {
1220
+ "data-isolate": i.id,
1221
+ "data-state": i.state,
1222
+ children: [
1223
+ /* @__PURE__ */ a("td", { children: [
1224
+ /* @__PURE__ */ a("code", { children: i.id }),
1225
+ props.self ? /* @__PURE__ */ a("span", {
1226
+ class: "dt-badge",
1227
+ "data-devtools-self": "",
1228
+ children: "devtools"
1229
+ }) : null,
1230
+ i.pool === void 0 ? null : /* @__PURE__ */ a("span", {
1231
+ class: "dt-pool",
1232
+ children: ["pool ", i.pool]
1233
+ })
1234
+ ] }),
1235
+ /* @__PURE__ */ a("td", {
1236
+ class: `dt-state-${i.state}`,
1237
+ title: i.error ?? i.reason ?? "",
1238
+ children: i.state
1239
+ }),
1240
+ /* @__PURE__ */ a("td", {
1241
+ class: "dt-num",
1242
+ "data-lag": i.lagMs,
1243
+ children: ms(i.lagMs)
1244
+ }),
1245
+ /* @__PURE__ */ a("td", {
1246
+ class: "dt-num",
1247
+ title: "Busy time from its last beat (ADR 0017)",
1248
+ children: ms(i.busyMs)
1249
+ }),
1250
+ /* @__PURE__ */ a("td", {
1251
+ class: "dt-num",
1252
+ children: /* @__PURE__ */ a(Memory, {
1253
+ memory: i.memory,
1254
+ now: props.now
1255
+ })
1256
+ }),
1257
+ /* @__PURE__ */ a("td", {
1258
+ class: "dt-num",
1259
+ "data-restarts": i.restarts,
1260
+ children: i.restarts
1261
+ }),
1262
+ /* @__PURE__ */ a("td", {
1263
+ class: "dt-num",
1264
+ title: "Patch batches waiting for the compositor",
1265
+ children: i.surface ? i.surface.queued : "–"
1266
+ }),
1267
+ /* @__PURE__ */ a("td", { children: props.inspector ? /* @__PURE__ */ a(Controls, {
1268
+ id: i.id,
1269
+ inspector: props.inspector,
1270
+ onError: props.onError
1271
+ }) : null })
1272
+ ]
1273
+ });
1274
+ }
1275
+ function IsolatesView(props) {
1276
+ const ctx = useIsolate();
1277
+ const [error, setError] = d(void 0);
1278
+ const { snap } = props;
1279
+ return /* @__PURE__ */ a("div", {
1280
+ class: "dt-view",
1281
+ "data-view": "isolates",
1282
+ children: [
1283
+ /* @__PURE__ */ a("p", {
1284
+ "data-isoloop-devtools-summary": "",
1285
+ class: "dt-muted",
1286
+ style: "margin:0 0 4px;",
1287
+ children: [
1288
+ snap.isolates.length,
1289
+ " isolates · bus ",
1290
+ snap.bus.state
1291
+ ]
1292
+ }),
1293
+ /* @__PURE__ */ a("table", {
1294
+ class: "dt-table",
1295
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1296
+ /* @__PURE__ */ a("th", { children: "Isolate" }),
1297
+ /* @__PURE__ */ a("th", { children: "State" }),
1298
+ /* @__PURE__ */ a("th", {
1299
+ class: "dt-num",
1300
+ children: "Lag"
1301
+ }),
1302
+ /* @__PURE__ */ a("th", {
1303
+ class: "dt-num",
1304
+ children: "Busy"
1305
+ }),
1306
+ /* @__PURE__ */ a("th", {
1307
+ class: "dt-num",
1308
+ children: "Memory"
1309
+ }),
1310
+ /* @__PURE__ */ a("th", {
1311
+ class: "dt-num",
1312
+ children: "Restarts"
1313
+ }),
1314
+ /* @__PURE__ */ a("th", {
1315
+ class: "dt-num",
1316
+ children: "Queue"
1317
+ }),
1318
+ /* @__PURE__ */ a("th", {})
1319
+ ] }) }), /* @__PURE__ */ a("tbody", { children: snap.isolates.map((i) => /* @__PURE__ */ a(IsolateRow, {
1320
+ isolate: i,
1321
+ self: i.id === ctx.id,
1322
+ now: snap.at,
1323
+ inspector: ctx.inspector,
1324
+ onError: setError
1325
+ }, i.id)) })]
1326
+ }),
1327
+ error === void 0 ? null : /* @__PURE__ */ a("p", {
1328
+ class: "dt-status",
1329
+ role: "status",
1330
+ "data-isoloop-devtools-status": "",
1331
+ children: error
1332
+ }),
1333
+ snap.pools.length === 0 ? null : /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("h3", {
1334
+ class: "dt-h",
1335
+ children: "Pools"
1336
+ }), /* @__PURE__ */ a("table", {
1337
+ class: "dt-table",
1338
+ "data-view": "pools",
1339
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1340
+ /* @__PURE__ */ a("th", { children: "Pool" }),
1341
+ /* @__PURE__ */ a("th", { children: "Members" }),
1342
+ /* @__PURE__ */ a("th", { children: "Worker" })
1343
+ ] }) }), /* @__PURE__ */ a("tbody", { children: snap.pools.map((p) => /* @__PURE__ */ a("tr", {
1344
+ "data-pool": p.name,
1345
+ children: [
1346
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: p.name }) }),
1347
+ /* @__PURE__ */ a("td", {
1348
+ style: "white-space:normal;",
1349
+ children: [p.members.join(", "), p.warning === void 0 ? null : /* @__PURE__ */ a("span", {
1350
+ class: "dt-pool dt-warning",
1351
+ children: p.warning
1352
+ })]
1353
+ }),
1354
+ /* @__PURE__ */ a("td", { children: p.running ? "running" : "stopped" })
1355
+ ]
1356
+ }, p.name)) })]
1357
+ })] })
1358
+ ]
1359
+ });
1360
+ }
1361
+ const TABS = [
1362
+ {
1363
+ id: "isolates",
1364
+ label: "Isolates"
1365
+ },
1366
+ {
1367
+ id: "bus",
1368
+ label: "Bus"
1369
+ },
1370
+ {
1371
+ id: "log",
1372
+ label: "Log"
1373
+ }
1374
+ ];
1375
+ const tabId = (t) => `dt-tab-${t}`;
1376
+ const panelId = (t) => `dt-panel-${t}`;
1377
+ function Body(props) {
1378
+ const ctx = useIsolate();
1379
+ const [tab, setTab] = d("isolates");
1380
+ A(() => {
1381
+ ctx.styles(CSS);
1382
+ }, []);
1383
+ const { snap } = props;
1384
+ const buttons = T({});
1385
+ const onKey = (e) => {
1386
+ const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
1387
+ if (step === 0) return;
1388
+ const i = TABS.findIndex((t) => t.id === tab);
1389
+ const next = TABS[(i + step + TABS.length) % TABS.length];
1390
+ if (!next) return;
1391
+ setTab(next.id);
1392
+ const el = buttons.current[next.id];
1393
+ if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
1394
+ };
1395
+ let view;
1396
+ if (!snap) view = /* @__PURE__ */ a("p", {
1397
+ class: "dt-view dt-muted",
1398
+ children: "Waiting for the inspection feed…"
1399
+ });
1400
+ else if (tab === "bus") view = /* @__PURE__ */ a(BusView, { bus: snap.bus });
1401
+ else if (tab === "log") view = /* @__PURE__ */ a(LogView, {});
1402
+ else view = /* @__PURE__ */ a(IsolatesView, { snap });
1403
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("div", {
1404
+ class: "dt-tabs",
1405
+ role: "tablist",
1406
+ "aria-label": "Devtools views",
1407
+ onKeyDown: onKey,
1408
+ children: TABS.map((t) => /* @__PURE__ */ a("button", {
1409
+ ref: (el) => {
1410
+ buttons.current[t.id] = el ?? void 0;
1411
+ },
1412
+ id: tabId(t.id),
1413
+ type: "button",
1414
+ role: "tab",
1415
+ "data-tab": t.id,
1416
+ "aria-selected": tab === t.id ? "true" : "false",
1417
+ "aria-controls": panelId(t.id),
1418
+ tabindex: tab === t.id ? 0 : -1,
1419
+ class: "dt-tab",
1420
+ onClick: () => {
1421
+ setTab(t.id);
1422
+ },
1423
+ children: t.label
1424
+ }, t.id))
1425
+ }), /* @__PURE__ */ a("div", {
1426
+ role: "tabpanel",
1427
+ id: panelId(tab),
1428
+ "aria-labelledby": tabId(tab),
1429
+ children: view
1430
+ })] });
1431
+ }
1432
+ // src/panel.tsx
1433
+ const POSITIONS = [
1434
+ "bottom-right",
1435
+ "bottom-left",
1436
+ "top-left",
1437
+ "top-right"
1438
+ ];
1439
+ const MIN_WIDTH = 280;
1440
+ const MIN_HEIGHT = 160;
1441
+ const GAP = 12;
1442
+ const font = "font:12px/1.4 ui-sans-serif,system-ui,sans-serif;";
1443
+ const configPosition = (config) => {
1444
+ const p = typeof config === "object" && config !== null ? Reflect.get(config, "position") : void 0;
1445
+ return POSITIONS.find((x) => x === p) ?? "bottom-right";
1446
+ };
1447
+ /**
1448
+ * CSS placing a box in `position`'s corner of the viewport. Fixed, not
1449
+ * absolute: the compositor's own element in the surface has no height.
1450
+ */
1451
+ const corner = (position) => {
1452
+ const [v, h] = position.split("-");
1453
+ return `position:fixed;${v}:${GAP}px;${h}:${GAP}px;`;
1454
+ };
1455
+ const DOT = {
1456
+ ok: void 0,
1457
+ unwell: "#f59e0b",
1458
+ failed: "#dc2626"
1459
+ };
1460
+ function Fab(props) {
1461
+ const dot = DOT[props.health];
1462
+ return /* @__PURE__ */ a("button", {
1463
+ type: "button",
1464
+ "data-isoloop-devtools-toggle": "",
1465
+ "data-health": props.health,
1466
+ "aria-label": "Open Isoloop devtools (Alt+Shift+D)",
1467
+ title: "Isoloop devtools (Alt+Shift+D)",
1468
+ onClick: props.onOpen,
1469
+ style: `${corner(props.position)}pointer-events:auto;width:40px;height:40px;border-radius:20px;border:1px solid #374151;background:#111827;color:#e5e7eb;cursor:pointer;padding:0;box-shadow:0 2px 8px rgb(0 0 0 / 0.3);${font}`,
1470
+ children: [/* @__PURE__ */ a("svg", {
1471
+ width: "20",
1472
+ height: "20",
1473
+ viewBox: "0 0 20 20",
1474
+ "aria-hidden": "true",
1475
+ children: [/* @__PURE__ */ a("circle", {
1476
+ cx: "10",
1477
+ cy: "10",
1478
+ r: "6.5",
1479
+ fill: "none",
1480
+ stroke: "currentColor",
1481
+ "stroke-width": "2"
1482
+ }), /* @__PURE__ */ a("circle", {
1483
+ cx: "10",
1484
+ cy: "3.5",
1485
+ r: "2",
1486
+ fill: "currentColor"
1487
+ })]
1488
+ }), dot ? /* @__PURE__ */ a("span", {
1489
+ "data-dot": props.health,
1490
+ style: `position:absolute;top:2px;right:2px;width:10px;height:10px;border-radius:5px;background:${dot};border:2px solid #111827;`
1491
+ }) : null]
1492
+ });
1493
+ }
1494
+ function Dock(props) {
1495
+ const { ui } = props;
1496
+ const [v, h] = ui.position.split("-");
1497
+ const [drag, setDrag] = d(void 0);
1498
+ const sx = h === "right" ? 1 : -1;
1499
+ const sy = v === "bottom" ? 1 : -1;
1500
+ const sizeAt = (d, x, y) => [Math.max(280, Math.round(d.width + (d.x - x) * sx)), Math.max(160, Math.round(d.height + (d.y - y) * sy))];
1501
+ const handleV = v === "bottom" ? "top" : "bottom";
1502
+ const handleH = h === "right" ? "left" : "right";
1503
+ const cursor = sx === sy ? "nwse-resize" : "nesw-resize";
1504
+ return /* @__PURE__ */ a("div", {
1505
+ "data-isoloop-devtools-panel": "",
1506
+ role: "dialog",
1507
+ "aria-label": "Isoloop devtools",
1508
+ onKeyDown: (e) => {
1509
+ if (e.key === "Escape") props.onClose();
1510
+ },
1511
+ style: `${corner(ui.position)}pointer-events:auto;box-sizing:border-box;width:${ui.width}px;height:${ui.height}px;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);display:flex;flex-direction:column;border:1px solid #374151;border-radius:8px;background:#111827;color:#e5e7eb;box-shadow:0 4px 16px rgb(0 0 0 / 0.35);overflow:hidden;${font}`,
1512
+ children: [
1513
+ /* @__PURE__ */ a("div", {
1514
+ style: "display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid #374151;",
1515
+ children: [
1516
+ /* @__PURE__ */ a("strong", {
1517
+ style: "flex:1;",
1518
+ children: "Isoloop devtools"
1519
+ }),
1520
+ /* @__PURE__ */ a("button", {
1521
+ type: "button",
1522
+ "data-isoloop-devtools-move": "",
1523
+ "aria-label": "Dock in the next corner",
1524
+ title: "Dock in the next corner",
1525
+ onClick: props.onMove,
1526
+ style: "background:none;border:0;color:inherit;cursor:pointer;",
1527
+ children: "⤢"
1528
+ }),
1529
+ /* @__PURE__ */ a("button", {
1530
+ type: "button",
1531
+ "data-isoloop-devtools-toggle": "",
1532
+ "aria-label": "Close Isoloop devtools (Alt+Shift+D)",
1533
+ title: "Close (Alt+Shift+D)",
1534
+ onClick: props.onClose,
1535
+ style: "background:none;border:0;color:inherit;cursor:pointer;",
1536
+ children: "✕"
1537
+ })
1538
+ ]
1539
+ }),
1540
+ /* @__PURE__ */ a("div", {
1541
+ style: "flex:1;overflow:auto;",
1542
+ children: /* @__PURE__ */ a(Body, { snap: props.snap })
1543
+ }),
1544
+ /* @__PURE__ */ a("div", {
1545
+ "data-isoloop-devtools-resize": "",
1546
+ "aria-hidden": "true",
1547
+ onPointerDown: (e) => {
1548
+ setDrag({
1549
+ x: e.clientX,
1550
+ y: e.clientY,
1551
+ width: ui.width,
1552
+ height: ui.height
1553
+ });
1554
+ },
1555
+ style: `position:absolute;${handleV}:0;${handleH}:0;width:14px;height:14px;cursor:${cursor};`
1556
+ }),
1557
+ drag ? /* @__PURE__ */ a("div", {
1558
+ "data-isoloop-devtools-drag": "",
1559
+ onPointerMove: (e) => {
1560
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
1561
+ props.onResize(w, ht, false);
1562
+ },
1563
+ onPointerUp: (e) => {
1564
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
1565
+ setDrag(void 0);
1566
+ props.onResize(w, ht, true);
1567
+ },
1568
+ style: `position:fixed;inset:0;pointer-events:auto;cursor:${cursor};`
1569
+ }) : null
1570
+ ]
1571
+ });
1572
+ }
1573
+ function Panel({ config }) {
1574
+ const snap = useFeed(useIsolate().inspector);
1575
+ const [ui, setUi] = d(void 0);
1576
+ const latest = T(void 0);
1577
+ latest.current = ui;
1578
+ A(() => {
1579
+ let alive = true;
1580
+ loadUi().then((stored) => {
1581
+ if (!alive) return;
1582
+ setUi({
1583
+ open: false,
1584
+ width: 420,
1585
+ height: 320,
1586
+ position: configPosition(config),
1587
+ ...stored
1588
+ });
1589
+ });
1590
+ return () => {
1591
+ alive = false;
1592
+ };
1593
+ }, []);
1594
+ if (!ui) return null;
1595
+ const update = (patch, persist = true) => {
1596
+ const next = {
1597
+ ...latest.current ?? ui,
1598
+ ...patch
1599
+ };
1600
+ latest.current = next;
1601
+ setUi(next);
1602
+ if (persist) saveUi(next);
1603
+ };
1604
+ if (!ui.open) return /* @__PURE__ */ a(Fab, {
1605
+ position: ui.position,
1606
+ health: healthOf(snap),
1607
+ onOpen: () => {
1608
+ update({ open: true });
1609
+ }
1610
+ });
1611
+ return /* @__PURE__ */ a(Dock, {
1612
+ ui,
1613
+ snap,
1614
+ onClose: () => {
1615
+ update({ open: false });
1616
+ },
1617
+ onMove: () => {
1618
+ const i = POSITIONS.indexOf(ui.position);
1619
+ update({ position: POSITIONS[(i + 1) % POSITIONS.length] ?? "bottom-right" });
1620
+ },
1621
+ onResize: (width, height, done) => {
1622
+ update({
1623
+ width,
1624
+ height
1625
+ }, done);
1626
+ }
1627
+ });
1628
+ }
1629
+ const panel = defineIsolate(Panel);
1630
+ export { MIN_HEIGHT, MIN_WIDTH, panel as default };