@isoloop/devtools 0.0.0-stage → 0.1.0-next.4

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,1463 @@
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.4") ?? "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
+ // src/views.tsx
958
+ /** How long the block control busy-loops an isolate's worker. */
959
+ const BLOCK_MS = 2e3;
960
+ const CSS = `
961
+ .dt-tabs { display: flex; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid #374151; }
962
+ .dt-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #9ca3af;
963
+ font: inherit; padding: 4px 8px; cursor: pointer; }
964
+ .dt-tab[aria-selected="true"] { color: #e5e7eb; border-bottom-color: #60a5fa; }
965
+ .dt-view { padding: 6px 8px; }
966
+ .dt-muted { color: #9ca3af; }
967
+ .dt-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
968
+ .dt-table th { text-align: left; font-weight: 600; color: #9ca3af; padding: 2px 6px 4px 0;
969
+ white-space: nowrap; }
970
+ .dt-table td { padding: 3px 6px 3px 0; border-top: 1px solid #1f2937; vertical-align: top;
971
+ white-space: nowrap; }
972
+ .dt-table td.dt-num, .dt-table th.dt-num { text-align: right; }
973
+ .dt-badge { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px;
974
+ background: #1e3a8a; color: #bfdbfe; font-size: 10px; }
975
+ .dt-pool { display: block; color: #9ca3af; font-size: 11px; }
976
+ .dt-state-running { color: #86efac; }
977
+ .dt-state-blocked, .dt-state-crashed, .dt-state-restarting { color: #fcd34d; }
978
+ .dt-state-failed { color: #fca5a5; }
979
+ .dt-actions { display: flex; gap: 4px; }
980
+ .dt-actions button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
981
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 6px; cursor: pointer; }
982
+ .dt-actions button:focus-visible, .dt-tab:focus-visible { outline: 2px solid #60a5fa;
983
+ outline-offset: 1px; }
984
+ .dt-status { margin: 6px 0 0; color: #fca5a5; }
985
+ .dt-h { margin: 10px 0 4px; font-size: 12px; color: #9ca3af; }
986
+ .dt-warning { color: #fcd34d; }
987
+ `;
988
+ const ms = (n) => n === void 0 ? "–" : `${Math.round(n)} ms`;
989
+ const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
990
+ /** A memory figure, its age against the feed's latest time, and what it covers. */
991
+ function Memory(props) {
992
+ const { memory } = props;
993
+ if (!memory) return /* @__PURE__ */ a("span", {
994
+ class: "dt-muted",
995
+ title: "Measured only in Chromium on a cross-origin isolated page (ADR 0020, decision 4)",
996
+ children: "–"
997
+ });
998
+ const age = Math.max(0, Math.round((props.now - memory.at) / 1e3));
999
+ return /* @__PURE__ */ a("span", {
1000
+ "data-memory": memory.bytes,
1001
+ title: `Chromium, cross-origin isolated. Measured ${age} s ago${memory.shared ? "; the whole pool worker, shared by its members" : ""}.`,
1002
+ children: [
1003
+ mb(memory.bytes),
1004
+ memory.shared ? " (pool)" : "",
1005
+ /* @__PURE__ */ a("span", {
1006
+ class: "dt-muted",
1007
+ children: [
1008
+ " · ",
1009
+ age,
1010
+ " s"
1011
+ ]
1012
+ })
1013
+ ]
1014
+ });
1015
+ }
1016
+ function Controls(props) {
1017
+ const act = (name, run) => () => {
1018
+ props.onError(void 0);
1019
+ run().catch((e) => {
1020
+ props.onError(`${name} ${props.id}: ${e instanceof Error ? e.message : String(e)}`);
1021
+ });
1022
+ };
1023
+ const { id, inspector } = props;
1024
+ return /* @__PURE__ */ a("span", {
1025
+ class: "dt-actions",
1026
+ children: [
1027
+ /* @__PURE__ */ a("button", {
1028
+ type: "button",
1029
+ "data-control": "restart",
1030
+ "aria-label": `Restart ${id}`,
1031
+ title: `Restart ${id}`,
1032
+ onClick: act("restart", () => inspector.restart(id)),
1033
+ children: "Restart"
1034
+ }),
1035
+ /* @__PURE__ */ a("button", {
1036
+ type: "button",
1037
+ "data-control": "kill",
1038
+ "aria-label": `Kill ${id}`,
1039
+ title: `End ${id}'s worker as a crash; the supervisor restarts it. In a pool, every member restarts.`,
1040
+ onClick: act("kill", () => inspector.kill(id)),
1041
+ children: "Kill"
1042
+ }),
1043
+ /* @__PURE__ */ a("button", {
1044
+ type: "button",
1045
+ "data-control": "block",
1046
+ "aria-label": `Block ${id} for ${BLOCK_MS / 1e3} s`,
1047
+ title: `Busy-loop ${id}'s worker for ${BLOCK_MS / 1e3} s`,
1048
+ onClick: act("block", () => inspector.block(id, BLOCK_MS)),
1049
+ children: [
1050
+ "Block ",
1051
+ BLOCK_MS / 1e3,
1052
+ " s"
1053
+ ]
1054
+ })
1055
+ ]
1056
+ });
1057
+ }
1058
+ function IsolateRow(props) {
1059
+ const i = props.isolate;
1060
+ return /* @__PURE__ */ a("tr", {
1061
+ "data-isolate": i.id,
1062
+ "data-state": i.state,
1063
+ children: [
1064
+ /* @__PURE__ */ a("td", { children: [
1065
+ /* @__PURE__ */ a("code", { children: i.id }),
1066
+ props.self ? /* @__PURE__ */ a("span", {
1067
+ class: "dt-badge",
1068
+ "data-devtools-self": "",
1069
+ children: "devtools"
1070
+ }) : null,
1071
+ i.pool === void 0 ? null : /* @__PURE__ */ a("span", {
1072
+ class: "dt-pool",
1073
+ children: ["pool ", i.pool]
1074
+ })
1075
+ ] }),
1076
+ /* @__PURE__ */ a("td", {
1077
+ class: `dt-state-${i.state}`,
1078
+ title: i.error ?? i.reason ?? "",
1079
+ children: i.state
1080
+ }),
1081
+ /* @__PURE__ */ a("td", {
1082
+ class: "dt-num",
1083
+ "data-lag": i.lagMs,
1084
+ children: ms(i.lagMs)
1085
+ }),
1086
+ /* @__PURE__ */ a("td", {
1087
+ class: "dt-num",
1088
+ title: "Busy time from its last beat (ADR 0017)",
1089
+ children: ms(i.busyMs)
1090
+ }),
1091
+ /* @__PURE__ */ a("td", {
1092
+ class: "dt-num",
1093
+ children: /* @__PURE__ */ a(Memory, {
1094
+ memory: i.memory,
1095
+ now: props.now
1096
+ })
1097
+ }),
1098
+ /* @__PURE__ */ a("td", {
1099
+ class: "dt-num",
1100
+ "data-restarts": i.restarts,
1101
+ children: i.restarts
1102
+ }),
1103
+ /* @__PURE__ */ a("td", {
1104
+ class: "dt-num",
1105
+ title: "Patch batches waiting for the compositor",
1106
+ children: i.surface ? i.surface.queued : "–"
1107
+ }),
1108
+ /* @__PURE__ */ a("td", { children: props.inspector ? /* @__PURE__ */ a(Controls, {
1109
+ id: i.id,
1110
+ inspector: props.inspector,
1111
+ onError: props.onError
1112
+ }) : null })
1113
+ ]
1114
+ });
1115
+ }
1116
+ function IsolatesView(props) {
1117
+ const ctx = useIsolate();
1118
+ const [error, setError] = d(void 0);
1119
+ const { snap } = props;
1120
+ return /* @__PURE__ */ a("div", {
1121
+ class: "dt-view",
1122
+ "data-view": "isolates",
1123
+ children: [
1124
+ /* @__PURE__ */ a("p", {
1125
+ "data-isoloop-devtools-summary": "",
1126
+ class: "dt-muted",
1127
+ style: "margin:0 0 4px;",
1128
+ children: [
1129
+ snap.isolates.length,
1130
+ " isolates · bus ",
1131
+ snap.bus.state
1132
+ ]
1133
+ }),
1134
+ /* @__PURE__ */ a("table", {
1135
+ class: "dt-table",
1136
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1137
+ /* @__PURE__ */ a("th", { children: "Isolate" }),
1138
+ /* @__PURE__ */ a("th", { children: "State" }),
1139
+ /* @__PURE__ */ a("th", {
1140
+ class: "dt-num",
1141
+ children: "Lag"
1142
+ }),
1143
+ /* @__PURE__ */ a("th", {
1144
+ class: "dt-num",
1145
+ children: "Busy"
1146
+ }),
1147
+ /* @__PURE__ */ a("th", {
1148
+ class: "dt-num",
1149
+ children: "Memory"
1150
+ }),
1151
+ /* @__PURE__ */ a("th", {
1152
+ class: "dt-num",
1153
+ children: "Restarts"
1154
+ }),
1155
+ /* @__PURE__ */ a("th", {
1156
+ class: "dt-num",
1157
+ children: "Queue"
1158
+ }),
1159
+ /* @__PURE__ */ a("th", {})
1160
+ ] }) }), /* @__PURE__ */ a("tbody", { children: snap.isolates.map((i) => /* @__PURE__ */ a(IsolateRow, {
1161
+ isolate: i,
1162
+ self: i.id === ctx.id,
1163
+ now: snap.at,
1164
+ inspector: ctx.inspector,
1165
+ onError: setError
1166
+ }, i.id)) })]
1167
+ }),
1168
+ error === void 0 ? null : /* @__PURE__ */ a("p", {
1169
+ class: "dt-status",
1170
+ role: "status",
1171
+ "data-isoloop-devtools-status": "",
1172
+ children: error
1173
+ }),
1174
+ snap.pools.length === 0 ? null : /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("h3", {
1175
+ class: "dt-h",
1176
+ children: "Pools"
1177
+ }), /* @__PURE__ */ a("table", {
1178
+ class: "dt-table",
1179
+ "data-view": "pools",
1180
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1181
+ /* @__PURE__ */ a("th", { children: "Pool" }),
1182
+ /* @__PURE__ */ a("th", { children: "Members" }),
1183
+ /* @__PURE__ */ a("th", { children: "Worker" })
1184
+ ] }) }), /* @__PURE__ */ a("tbody", { children: snap.pools.map((p) => /* @__PURE__ */ a("tr", {
1185
+ "data-pool": p.name,
1186
+ children: [
1187
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: p.name }) }),
1188
+ /* @__PURE__ */ a("td", {
1189
+ style: "white-space:normal;",
1190
+ children: [p.members.join(", "), p.warning === void 0 ? null : /* @__PURE__ */ a("span", {
1191
+ class: "dt-pool dt-warning",
1192
+ children: p.warning
1193
+ })]
1194
+ }),
1195
+ /* @__PURE__ */ a("td", { children: p.running ? "running" : "stopped" })
1196
+ ]
1197
+ }, p.name)) })]
1198
+ })] })
1199
+ ]
1200
+ });
1201
+ }
1202
+ const TABS = [{
1203
+ id: "isolates",
1204
+ label: "Isolates"
1205
+ }, {
1206
+ id: "bus",
1207
+ label: "Bus"
1208
+ }];
1209
+ const tabId = (t) => `dt-tab-${t}`;
1210
+ const panelId = (t) => `dt-panel-${t}`;
1211
+ function Body(props) {
1212
+ const ctx = useIsolate();
1213
+ const [tab, setTab] = d("isolates");
1214
+ A(() => {
1215
+ ctx.styles(CSS);
1216
+ }, []);
1217
+ const { snap } = props;
1218
+ const buttons = T({});
1219
+ const onKey = (e) => {
1220
+ const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
1221
+ if (step === 0) return;
1222
+ const i = TABS.findIndex((t) => t.id === tab);
1223
+ const next = TABS[(i + step + TABS.length) % TABS.length];
1224
+ if (!next) return;
1225
+ setTab(next.id);
1226
+ const el = buttons.current[next.id];
1227
+ if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
1228
+ };
1229
+ let view;
1230
+ if (!snap) view = /* @__PURE__ */ a("p", {
1231
+ class: "dt-view dt-muted",
1232
+ children: "Waiting for the inspection feed…"
1233
+ });
1234
+ else if (tab === "bus") view = /* @__PURE__ */ a(BusView, { bus: snap.bus });
1235
+ else view = /* @__PURE__ */ a(IsolatesView, { snap });
1236
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("div", {
1237
+ class: "dt-tabs",
1238
+ role: "tablist",
1239
+ "aria-label": "Devtools views",
1240
+ onKeyDown: onKey,
1241
+ children: TABS.map((t) => /* @__PURE__ */ a("button", {
1242
+ ref: (el) => {
1243
+ buttons.current[t.id] = el ?? void 0;
1244
+ },
1245
+ id: tabId(t.id),
1246
+ type: "button",
1247
+ role: "tab",
1248
+ "data-tab": t.id,
1249
+ "aria-selected": tab === t.id ? "true" : "false",
1250
+ "aria-controls": panelId(t.id),
1251
+ tabindex: tab === t.id ? 0 : -1,
1252
+ class: "dt-tab",
1253
+ onClick: () => {
1254
+ setTab(t.id);
1255
+ },
1256
+ children: t.label
1257
+ }, t.id))
1258
+ }), /* @__PURE__ */ a("div", {
1259
+ role: "tabpanel",
1260
+ id: panelId(tab),
1261
+ "aria-labelledby": tabId(tab),
1262
+ children: view
1263
+ })] });
1264
+ }
1265
+ // src/panel.tsx
1266
+ const POSITIONS = [
1267
+ "bottom-right",
1268
+ "bottom-left",
1269
+ "top-left",
1270
+ "top-right"
1271
+ ];
1272
+ const MIN_WIDTH = 280;
1273
+ const MIN_HEIGHT = 160;
1274
+ const GAP = 12;
1275
+ const font = "font:12px/1.4 ui-sans-serif,system-ui,sans-serif;";
1276
+ const configPosition = (config) => {
1277
+ const p = typeof config === "object" && config !== null ? Reflect.get(config, "position") : void 0;
1278
+ return POSITIONS.find((x) => x === p) ?? "bottom-right";
1279
+ };
1280
+ /**
1281
+ * CSS placing a box in `position`'s corner of the viewport. Fixed, not
1282
+ * absolute: the compositor's own element in the surface has no height.
1283
+ */
1284
+ const corner = (position) => {
1285
+ const [v, h] = position.split("-");
1286
+ return `position:fixed;${v}:${GAP}px;${h}:${GAP}px;`;
1287
+ };
1288
+ const DOT = {
1289
+ ok: void 0,
1290
+ unwell: "#f59e0b",
1291
+ failed: "#dc2626"
1292
+ };
1293
+ function Fab(props) {
1294
+ const dot = DOT[props.health];
1295
+ return /* @__PURE__ */ a("button", {
1296
+ type: "button",
1297
+ "data-isoloop-devtools-toggle": "",
1298
+ "data-health": props.health,
1299
+ "aria-label": "Open Isoloop devtools (Alt+Shift+D)",
1300
+ title: "Isoloop devtools (Alt+Shift+D)",
1301
+ onClick: props.onOpen,
1302
+ 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}`,
1303
+ children: [/* @__PURE__ */ a("svg", {
1304
+ width: "20",
1305
+ height: "20",
1306
+ viewBox: "0 0 20 20",
1307
+ "aria-hidden": "true",
1308
+ children: [/* @__PURE__ */ a("circle", {
1309
+ cx: "10",
1310
+ cy: "10",
1311
+ r: "6.5",
1312
+ fill: "none",
1313
+ stroke: "currentColor",
1314
+ "stroke-width": "2"
1315
+ }), /* @__PURE__ */ a("circle", {
1316
+ cx: "10",
1317
+ cy: "3.5",
1318
+ r: "2",
1319
+ fill: "currentColor"
1320
+ })]
1321
+ }), dot ? /* @__PURE__ */ a("span", {
1322
+ "data-dot": props.health,
1323
+ style: `position:absolute;top:2px;right:2px;width:10px;height:10px;border-radius:5px;background:${dot};border:2px solid #111827;`
1324
+ }) : null]
1325
+ });
1326
+ }
1327
+ function Dock(props) {
1328
+ const { ui } = props;
1329
+ const [v, h] = ui.position.split("-");
1330
+ const [drag, setDrag] = d(void 0);
1331
+ const sx = h === "right" ? 1 : -1;
1332
+ const sy = v === "bottom" ? 1 : -1;
1333
+ 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))];
1334
+ const handleV = v === "bottom" ? "top" : "bottom";
1335
+ const handleH = h === "right" ? "left" : "right";
1336
+ const cursor = sx === sy ? "nwse-resize" : "nesw-resize";
1337
+ return /* @__PURE__ */ a("div", {
1338
+ "data-isoloop-devtools-panel": "",
1339
+ role: "dialog",
1340
+ "aria-label": "Isoloop devtools",
1341
+ onKeyDown: (e) => {
1342
+ if (e.key === "Escape") props.onClose();
1343
+ },
1344
+ 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}`,
1345
+ children: [
1346
+ /* @__PURE__ */ a("div", {
1347
+ style: "display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid #374151;",
1348
+ children: [
1349
+ /* @__PURE__ */ a("strong", {
1350
+ style: "flex:1;",
1351
+ children: "Isoloop devtools"
1352
+ }),
1353
+ /* @__PURE__ */ a("button", {
1354
+ type: "button",
1355
+ "data-isoloop-devtools-move": "",
1356
+ "aria-label": "Dock in the next corner",
1357
+ title: "Dock in the next corner",
1358
+ onClick: props.onMove,
1359
+ style: "background:none;border:0;color:inherit;cursor:pointer;",
1360
+ children: "⤢"
1361
+ }),
1362
+ /* @__PURE__ */ a("button", {
1363
+ type: "button",
1364
+ "data-isoloop-devtools-toggle": "",
1365
+ "aria-label": "Close Isoloop devtools (Alt+Shift+D)",
1366
+ title: "Close (Alt+Shift+D)",
1367
+ onClick: props.onClose,
1368
+ style: "background:none;border:0;color:inherit;cursor:pointer;",
1369
+ children: "✕"
1370
+ })
1371
+ ]
1372
+ }),
1373
+ /* @__PURE__ */ a("div", {
1374
+ style: "flex:1;overflow:auto;",
1375
+ children: /* @__PURE__ */ a(Body, { snap: props.snap })
1376
+ }),
1377
+ /* @__PURE__ */ a("div", {
1378
+ "data-isoloop-devtools-resize": "",
1379
+ "aria-hidden": "true",
1380
+ onPointerDown: (e) => {
1381
+ setDrag({
1382
+ x: e.clientX,
1383
+ y: e.clientY,
1384
+ width: ui.width,
1385
+ height: ui.height
1386
+ });
1387
+ },
1388
+ style: `position:absolute;${handleV}:0;${handleH}:0;width:14px;height:14px;cursor:${cursor};`
1389
+ }),
1390
+ drag ? /* @__PURE__ */ a("div", {
1391
+ "data-isoloop-devtools-drag": "",
1392
+ onPointerMove: (e) => {
1393
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
1394
+ props.onResize(w, ht, false);
1395
+ },
1396
+ onPointerUp: (e) => {
1397
+ const [w, ht] = sizeAt(drag, e.clientX, e.clientY);
1398
+ setDrag(void 0);
1399
+ props.onResize(w, ht, true);
1400
+ },
1401
+ style: `position:fixed;inset:0;pointer-events:auto;cursor:${cursor};`
1402
+ }) : null
1403
+ ]
1404
+ });
1405
+ }
1406
+ function Panel({ config }) {
1407
+ const snap = useFeed(useIsolate().inspector);
1408
+ const [ui, setUi] = d(void 0);
1409
+ const latest = T(void 0);
1410
+ latest.current = ui;
1411
+ A(() => {
1412
+ let alive = true;
1413
+ loadUi().then((stored) => {
1414
+ if (!alive) return;
1415
+ setUi({
1416
+ open: false,
1417
+ width: 420,
1418
+ height: 320,
1419
+ position: configPosition(config),
1420
+ ...stored
1421
+ });
1422
+ });
1423
+ return () => {
1424
+ alive = false;
1425
+ };
1426
+ }, []);
1427
+ if (!ui) return null;
1428
+ const update = (patch, persist = true) => {
1429
+ const next = {
1430
+ ...latest.current ?? ui,
1431
+ ...patch
1432
+ };
1433
+ latest.current = next;
1434
+ setUi(next);
1435
+ if (persist) saveUi(next);
1436
+ };
1437
+ if (!ui.open) return /* @__PURE__ */ a(Fab, {
1438
+ position: ui.position,
1439
+ health: healthOf(snap),
1440
+ onOpen: () => {
1441
+ update({ open: true });
1442
+ }
1443
+ });
1444
+ return /* @__PURE__ */ a(Dock, {
1445
+ ui,
1446
+ snap,
1447
+ onClose: () => {
1448
+ update({ open: false });
1449
+ },
1450
+ onMove: () => {
1451
+ const i = POSITIONS.indexOf(ui.position);
1452
+ update({ position: POSITIONS[(i + 1) % POSITIONS.length] ?? "bottom-right" });
1453
+ },
1454
+ onResize: (width, height, done) => {
1455
+ update({
1456
+ width,
1457
+ height
1458
+ }, done);
1459
+ }
1460
+ });
1461
+ }
1462
+ const panel = defineIsolate(Panel);
1463
+ export { MIN_HEIGHT, MIN_WIDTH, panel as default };