@isoloop/devtools 0.1.0-next.7 → 0.1.0-next.9

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 CHANGED
@@ -63,8 +63,12 @@ function majorMinor(version) {
63
63
  return m ? `${Number(m[1])}.${Number(m[2])}` : void 0;
64
64
  }
65
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.7") ?? "0.0";
66
+ /**
67
+ * This build's stamp: `major.minor` of the package version, inlined when tsdown bundles it.
68
+ *
69
+ * @internal
70
+ */
71
+ const REQUIRES = majorMinor("0.1.0-next.9") ?? "0.0";
68
72
  // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/dist/preact.mjs
69
73
  var n;
70
74
  var t$1;
@@ -693,8 +697,12 @@ function healthOf(snap) {
693
697
  return snap.isolates.some((i) => UNWELL.has(i.state)) ? "unwell" : "ok";
694
698
  }
695
699
  // src/persist.ts
700
+ const isMode = (v) => v === "normal" || v === "wide" || v === "max";
696
701
  const DB = "isoloop-devtools";
697
702
  const STORE = "settings";
703
+ /** The kernel events of each page session, and the sessions themselves (`event-store.ts`). */
704
+ const EVENTS_STORE = "events";
705
+ const SESSIONS_STORE = "sessions";
698
706
  const KEY = "panel";
699
707
  const POSITIONS$1 = /* @__PURE__ */ new Set([
700
708
  "bottom-right",
@@ -715,6 +723,8 @@ function parseUi(v) {
715
723
  if (typeof width === "number" && Number.isFinite(width)) out.width = width;
716
724
  if (typeof height === "number" && Number.isFinite(height)) out.height = height;
717
725
  if (isPosition(position)) out.position = position;
726
+ const mode = Reflect.get(v, "mode");
727
+ if (isMode(mode)) out.mode = mode;
718
728
  return out;
719
729
  }
720
730
  /** Settles with a request's result; rejects on its error. */
@@ -727,16 +737,30 @@ const settle = (req) => new Promise((resolve, reject) => {
727
737
  });
728
738
  });
729
739
  function openDb() {
730
- const req = indexedDB.open(DB, 1);
740
+ const req = indexedDB.open(DB, 2);
731
741
  req.addEventListener("upgradeneeded", () => {
732
- req.result.createObjectStore(STORE);
742
+ const d = req.result;
743
+ if (!d.objectStoreNames.contains(STORE)) d.createObjectStore(STORE);
744
+ if (!d.objectStoreNames.contains("events")) d.createObjectStore(EVENTS_STORE, {
745
+ keyPath: "id",
746
+ autoIncrement: true
747
+ }).createIndex("session", "session");
748
+ if (!d.objectStoreNames.contains("sessions")) d.createObjectStore(SESSIONS_STORE, { keyPath: "id" });
733
749
  });
734
- return Promise.race([settle(req), new Promise((_resolve, reject) => {
750
+ const opened = settle(req).then((d) => {
751
+ d.addEventListener("versionchange", () => {
752
+ d.close();
753
+ db = void 0;
754
+ });
755
+ return d;
756
+ });
757
+ return Promise.race([opened, new Promise((_resolve, reject) => {
735
758
  req.addEventListener("blocked", () => {
736
759
  reject(/* @__PURE__ */ new Error("indexedDB.open blocked"));
737
760
  });
738
761
  })]);
739
762
  }
763
+ /** The open connection, shared; reset when the database is closed from under it. */
740
764
  let db;
741
765
  const database = () => {
742
766
  db ??= openDb();
@@ -767,6 +791,402 @@ async function saveUi(s) {
767
791
  });
768
792
  } catch {}
769
793
  }
794
+ const UNWELL_STATES = /* @__PURE__ */ new Set([
795
+ "restarting",
796
+ "crashed",
797
+ "blocked"
798
+ ]);
799
+ /** `ok` below `warn`, `unwell` below `bad`, `failed` from `bad` up. */
800
+ const by = (value, warn, bad) => value < warn ? "ok" : value < bad ? "unwell" : "failed";
801
+ const max = (xs) => xs.reduce((a, b) => Math.max(a, b), 0);
802
+ const unknown = (id, label) => ({
803
+ id,
804
+ label,
805
+ level: "unknown"
806
+ });
807
+ /** The ring's checks, always `RING_SLOTS` of them: grey ones while there's no data. */
808
+ function checksOf(snap) {
809
+ if (!snap) return Array.from({ length: 12 }, (_, i) => unknown(`c${i}`, "No data yet"));
810
+ const { isolates, pools, bus } = snap;
811
+ const m = bus.metrics;
812
+ const surfaces = isolates.flatMap((i) => i.surface ? [i.surface] : []);
813
+ const memory = isolates.flatMap((i) => i.memory ? [i.memory.bytes] : []);
814
+ const rejected = m ? Object.values(m.rejected).reduce((n, v) => n + (v ?? 0), 0) : 0;
815
+ const storage = m?.storage;
816
+ return [
817
+ {
818
+ id: "isolates",
819
+ label: "Isolates",
820
+ level: isolates.some((i) => i.state === "failed") ? "failed" : isolates.some((i) => UNWELL_STATES.has(i.state)) ? "unwell" : "ok"
821
+ },
822
+ {
823
+ id: "restarts",
824
+ label: "Restarts",
825
+ level: by(max(isolates.map((i) => i.restarts)), 1, 3)
826
+ },
827
+ {
828
+ id: "lag",
829
+ label: "Heartbeat lag",
830
+ level: by(max(isolates.map((i) => i.lagMs)), 100, 500)
831
+ },
832
+ {
833
+ id: "holds",
834
+ label: "Held isolates",
835
+ level: by(max(isolates.flatMap((i) => (i.holds ?? []).map((h) => h.ageMs))), 1, 1e3)
836
+ },
837
+ {
838
+ id: "errors",
839
+ label: "Isolate errors",
840
+ level: isolates.some((i) => i.error !== void 0) ? "unwell" : "ok"
841
+ },
842
+ {
843
+ id: "frames",
844
+ label: "Dropped or rejected updates",
845
+ level: surfaces.some((s) => s.dropped + s.rejected > 0) ? "unwell" : "ok"
846
+ },
847
+ {
848
+ id: "bus",
849
+ label: "Bus",
850
+ level: bus.state === "running" ? "ok" : bus.state === "failed" ? "failed" : bus.state === "starting" || bus.state === "loading" ? "unknown" : "unwell"
851
+ },
852
+ m ? {
853
+ id: "rejected",
854
+ label: "Rejected publishes",
855
+ level: by(rejected, 1, 100)
856
+ } : unknown("rejected", "Rejected publishes"),
857
+ m ? {
858
+ id: "consumers",
859
+ label: "Consumer lag",
860
+ level: by(max(m.subscriptions.map((s) => s.lag)), 100, 1e3)
861
+ } : unknown("consumers", "Consumer lag"),
862
+ storage ? {
863
+ id: "storage",
864
+ label: "Storage",
865
+ level: by(storage.usage / Math.max(1, storage.quota), .7, .9)
866
+ } : unknown("storage", "Storage"),
867
+ {
868
+ id: "pools",
869
+ label: "Pools",
870
+ level: pools.some((p) => !p.running) ? "unwell" : "ok"
871
+ },
872
+ memory.length > 0 ? {
873
+ id: "memory",
874
+ label: "Memory",
875
+ level: "ok"
876
+ } : unknown("memory", "Memory")
877
+ ];
878
+ }
879
+ const levelOf = (state) => state === "failed" ? "failed" : UNWELL_STATES.has(state) ? "unwell" : state === "loading" || state === "starting" ? "unknown" : "ok";
880
+ const RANK = {
881
+ failed: 3,
882
+ unwell: 2,
883
+ ok: 1,
884
+ unknown: 0
885
+ };
886
+ /**
887
+ * The ring: the isolates in the order they were spawned, shared out over
888
+ * `RING_SLOTS` arcs (a few to an arc when there are many, one isolate over
889
+ * several arcs when there are few), each arc the worst state among its own.
890
+ * A crash lights the arc its isolate is in, so where on the ring tells you
891
+ * roughly which one.
892
+ */
893
+ function arcsOf(snap) {
894
+ const list = snap?.isolates ?? [];
895
+ const n = list.length;
896
+ return Array.from({ length: 12 }, (_, i) => {
897
+ if (n === 0) return {
898
+ id: `a${i}`,
899
+ label: "No isolates yet",
900
+ level: "unknown"
901
+ };
902
+ const from = Math.floor(i * n / 12);
903
+ const to = Math.max(from + 1, Math.floor((i + 1) * n / 12));
904
+ const members = list.slice(from, to);
905
+ let level = "unknown";
906
+ const bad = [];
907
+ for (const m of members) {
908
+ const l = levelOf(m.state);
909
+ if (RANK[l] > RANK[level]) level = l;
910
+ if (l === "failed" || l === "unwell") bad.push(`${m.id} ${m.state}`);
911
+ }
912
+ const first = members[0]?.id ?? "";
913
+ const last = members.at(-1)?.id ?? "";
914
+ const range = first === last ? first : `${first} … ${last}`;
915
+ return {
916
+ id: `a${i}`,
917
+ label: bad.length > 0 ? `${range}: ${bad.join(", ")}` : range,
918
+ level
919
+ };
920
+ });
921
+ }
922
+ /** A line for the button's label: how many isolates need attention, and which other checks do. */
923
+ function summaryOf(arcs, checks) {
924
+ const bad = arcs.filter((a) => a.level === "failed").length;
925
+ const warn = arcs.filter((a) => a.level === "unwell").length;
926
+ const other = checks.filter((c) => c.id !== "isolates" && (c.level === "failed" || c.level === "unwell"));
927
+ const parts = [
928
+ bad > 0 ? `${bad} of 12 ring sections failed` : "",
929
+ warn > 0 ? `${warn} of 12 ring sections need attention` : "",
930
+ other.length > 0 ? `Also: ${other.map((c) => c.label).join(", ")}` : ""
931
+ ].filter(Boolean);
932
+ return parts.length > 0 ? parts.join(". ") : "All checks pass";
933
+ }
934
+ /** The SVG path of arc `i` of `RING_SLOTS` on a circle. Neighbours overlap a hair so no seam shows. */
935
+ function arcPath(i, cx, cy, r) {
936
+ const step = 30;
937
+ const gap = -.8;
938
+ const a0 = (-90 + i * step + gap / 2) * Math.PI / 180;
939
+ const a1 = (-90 + (i + 1) * step - gap / 2) * Math.PI / 180;
940
+ const p = (a) => `${(cx + r * Math.cos(a)).toFixed(2)} ${(cy + r * Math.sin(a)).toFixed(2)}`;
941
+ return `M${p(a0)}A${r} ${r} 0 0 1 ${p(a1)}`;
942
+ }
943
+ /**
944
+ * The pie slice of arc `i` on a circle of radius `r` about (`cx`, `cy`), at the
945
+ * same angles as `arcPath`: the logo filled with these puts each colour on the
946
+ * same side of the button as its arc in the ring.
947
+ */
948
+ function wedgePath(i, cx, cy, r) {
949
+ const step = 30;
950
+ const over = .8;
951
+ const a0 = (-90 + i * step - over / 2) * Math.PI / 180;
952
+ const a1 = (-90 + (i + 1) * step + over / 2) * Math.PI / 180;
953
+ const p = (a) => `${(cx + r * Math.cos(a)).toFixed(2)} ${(cy + r * Math.sin(a)).toFixed(2)}`;
954
+ return `M${cx} ${cy}L${p(a0)}A${r} ${r} 0 0 1 ${p(a1)}Z`;
955
+ }
956
+ // src/event-level.ts
957
+ const str = (v) => typeof v === "string" ? v : "";
958
+ /** How serious an event is, in the ring's terms: failed is red, a crash or a stall amber. */
959
+ function levelOfEvent(e) {
960
+ switch (e.event) {
961
+ case "isolate:failed":
962
+ case "bus:failed": return "bad";
963
+ case "isolate:crash":
964
+ case "isolate:error":
965
+ case "bus:crash":
966
+ case "bus:recovered":
967
+ case "bus:quota":
968
+ case "bus:durability_degraded":
969
+ case "workers:budget":
970
+ case "agents:unmatched": return "warn";
971
+ case "isolate:ready":
972
+ case "bus:ready": return "good";
973
+ case "isolate:state": {
974
+ const state = str(e.data["state"]);
975
+ if (state === "failed") return "bad";
976
+ if (state === "running") return "good";
977
+ return [
978
+ "blocked",
979
+ "restarting",
980
+ "crashed"
981
+ ].includes(state) ? "warn" : "info";
982
+ }
983
+ default: return "info";
984
+ }
985
+ }
986
+ /** What the event is about: its isolate, or the bus. */
987
+ const subjectOf = (e) => {
988
+ const id = str(e.data["id"]);
989
+ if (id) return id;
990
+ return e.event.startsWith("bus:") ? "bus" : "";
991
+ };
992
+ const show = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? String(v) : JSON.stringify(v);
993
+ /** One line of what happened. */
994
+ function detailOf(e) {
995
+ const d = e.data;
996
+ if (e.event === "isolate:state") return `${str(d["prev"])} → ${str(d["state"])}`;
997
+ if (e.event === "isolate:crash" || e.event === "isolate:failed" || e.event === "bus:crash") return [str(d["reason"]), str(d["message"])].filter(Boolean).join(": ");
998
+ if (e.event === "isolate:error") return str(d["message"]);
999
+ return Object.entries(d).filter(([k]) => k !== "id").map(([k, v]) => `${k}=${show(v)}`).join(" ");
1000
+ }
1001
+ // src/event-store.ts
1002
+ const PER_SESSION = 6e3;
1003
+ /** How long events wait to be written together. Problems are written at once. */
1004
+ const FLUSH_MS = 250;
1005
+ const isSession = (v) => typeof v === "object" && v !== null && typeof Reflect.get(v, "id") === "string" && typeof Reflect.get(v, "started") === "number";
1006
+ const isRow = (v) => typeof v === "object" && v !== null && typeof Reflect.get(v, "at") === "number" && typeof Reflect.get(v, "event") === "string" && typeof Reflect.get(v, "wall") === "number" && ["number", "undefined"].includes(typeof Reflect.get(v, "n")) && typeof Reflect.get(v, "data") === "object";
1007
+ const keyOf = (e) => `${e.at} ${e.event} ${JSON.stringify(e.data)}`;
1008
+ const done = (tx) => new Promise((resolve) => {
1009
+ for (const type of [
1010
+ "complete",
1011
+ "error",
1012
+ "abort"
1013
+ ]) tx.addEventListener(type, () => {
1014
+ resolve();
1015
+ });
1016
+ });
1017
+ function createRecorder() {
1018
+ const session = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
1019
+ const started = Date.now();
1020
+ /** This session's events, oldest first. */
1021
+ let mem = [];
1022
+ const seen = /* @__PURE__ */ new Set();
1023
+ let pending = [];
1024
+ let timer;
1025
+ let written = 0;
1026
+ let seq = 0;
1027
+ let acked = 0;
1028
+ let ready;
1029
+ /** Opens storage, notes this session and drops the sessions beyond the last few before it. */
1030
+ const open = () => {
1031
+ ready ??= (async () => {
1032
+ try {
1033
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readwrite");
1034
+ const sessions = tx.objectStore(SESSIONS_STORE);
1035
+ sessions.put({
1036
+ id: session,
1037
+ started
1038
+ });
1039
+ const old = (await settle(sessions.getAll())).filter(isSession).toSorted((a, b) => b.started - a.started).slice(4);
1040
+ const events = tx.objectStore(EVENTS_STORE).index("session");
1041
+ for (const s of old) {
1042
+ sessions.delete(s.id);
1043
+ const cursor = events.openKeyCursor(IDBKeyRange.only(s.id));
1044
+ cursor.addEventListener("success", () => {
1045
+ const c = cursor.result;
1046
+ if (!c) return;
1047
+ tx.objectStore(EVENTS_STORE).delete(c.primaryKey);
1048
+ c.continue();
1049
+ });
1050
+ }
1051
+ await done(tx);
1052
+ return true;
1053
+ } catch {
1054
+ return false;
1055
+ }
1056
+ })();
1057
+ return ready;
1058
+ };
1059
+ const flush = async () => {
1060
+ timer = void 0;
1061
+ const batch = pending;
1062
+ pending = [];
1063
+ if (batch.length === 0 || !await open()) return;
1064
+ try {
1065
+ const tx = (await database()).transaction(EVENTS_STORE, "readwrite");
1066
+ const store = tx.objectStore(EVENTS_STORE);
1067
+ for (const e of batch) store.add({
1068
+ ...e,
1069
+ session
1070
+ });
1071
+ written += batch.length;
1072
+ if (written > 6e3) {
1073
+ let drop = written - PER_SESSION;
1074
+ written = PER_SESSION;
1075
+ const cursor = store.index("session").openKeyCursor(IDBKeyRange.only(session));
1076
+ cursor.addEventListener("success", () => {
1077
+ const c = cursor.result;
1078
+ if (!c || drop <= 0) return;
1079
+ drop -= 1;
1080
+ store.delete(c.primaryKey);
1081
+ c.continue();
1082
+ });
1083
+ }
1084
+ await done(tx);
1085
+ } catch {}
1086
+ };
1087
+ const schedule = (urgent) => {
1088
+ if (urgent) {
1089
+ if (timer !== void 0) clearTimeout(timer);
1090
+ flush();
1091
+ } else timer ??= setTimeout(() => void flush(), FLUSH_MS);
1092
+ };
1093
+ /** Records events not seen yet; the same event arriving twice (live and in a snapshot) counts once. */
1094
+ const add = (events, wall = Date.now()) => {
1095
+ let urgent = false;
1096
+ let changed = false;
1097
+ for (const e of events) {
1098
+ const k = keyOf(e);
1099
+ if (seen.has(k)) continue;
1100
+ seen.add(k);
1101
+ const stored = {
1102
+ ...e,
1103
+ wall,
1104
+ n: ++seq
1105
+ };
1106
+ mem.push(stored);
1107
+ pending.push(stored);
1108
+ changed = true;
1109
+ const l = levelOfEvent(e);
1110
+ if (l === "bad" || l === "warn") urgent = true;
1111
+ }
1112
+ if (!changed) return;
1113
+ mem = mem.toSorted((a, b) => a.at - b.at);
1114
+ if (mem.length > 6e3) mem = mem.slice(mem.length - PER_SESSION);
1115
+ schedule(urgent);
1116
+ };
1117
+ return {
1118
+ session,
1119
+ started,
1120
+ add,
1121
+ /** This session's events, oldest first. */
1122
+ events: () => mem,
1123
+ isNew: (e) => (e.n ?? 0) > acked,
1124
+ unacknowledged: () => mem.filter((e) => {
1125
+ const l = levelOfEvent(e);
1126
+ return (l === "bad" || l === "warn") && (e.n ?? 0) > acked;
1127
+ }).length,
1128
+ acknowledge() {
1129
+ acked = seq;
1130
+ },
1131
+ /**
1132
+ * Starts recording from `inspector`: every event as it comes, and the ring
1133
+ * it already holds (what happened before the panel connected).
1134
+ */
1135
+ start(inspector) {
1136
+ const off = inspector.on((m) => {
1137
+ if (m.t === "event") add([m.p]);
1138
+ });
1139
+ inspector.snapshot().then((s) => {
1140
+ const now = Date.now();
1141
+ for (const e of s.events) add([e], now - Math.max(0, s.at - e.at));
1142
+ }, () => void 0);
1143
+ return off;
1144
+ },
1145
+ /** This and the earlier sessions kept in storage, newest first. */
1146
+ async sessions() {
1147
+ if (!await open()) return [];
1148
+ try {
1149
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readonly");
1150
+ const all = (await settle(tx.objectStore(SESSIONS_STORE).getAll())).filter(isSession);
1151
+ const index = tx.objectStore(EVENTS_STORE).index("session");
1152
+ return await Promise.all(all.toSorted((a, b) => b.started - a.started).map(async (s) => ({
1153
+ id: s.id,
1154
+ started: s.started,
1155
+ count: await settle(index.count(IDBKeyRange.only(s.id)))
1156
+ })));
1157
+ } catch {
1158
+ return [];
1159
+ }
1160
+ },
1161
+ /** One stored session's events, oldest first. */
1162
+ async load(id) {
1163
+ try {
1164
+ const d = await database();
1165
+ return (await settle(d.transaction(EVENTS_STORE, "readonly").objectStore(EVENTS_STORE).index("session").getAll(IDBKeyRange.only(id)))).filter(isRow).map(({ session: _s, id: _i, ...e }) => e);
1166
+ } catch {
1167
+ return [];
1168
+ }
1169
+ },
1170
+ /** Forgets everything stored, this session's and the earlier ones. */
1171
+ async clear() {
1172
+ mem = [];
1173
+ pending = [];
1174
+ seen.clear();
1175
+ written = 0;
1176
+ acked = seq;
1177
+ try {
1178
+ const tx = (await database()).transaction([SESSIONS_STORE, EVENTS_STORE], "readwrite");
1179
+ tx.objectStore(EVENTS_STORE).clear();
1180
+ tx.objectStore(SESSIONS_STORE).clear();
1181
+ tx.objectStore(SESSIONS_STORE).put({
1182
+ id: session,
1183
+ started
1184
+ });
1185
+ await done(tx);
1186
+ } catch {}
1187
+ }
1188
+ };
1189
+ }
770
1190
  // ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
771
1191
  var f = Symbol.for("pv");
772
1192
  var o = 0;
@@ -912,7 +1332,7 @@ function Rejected(props) {
912
1332
  });
913
1333
  }
914
1334
  function BusView(props) {
915
- const { bus } = props;
1335
+ const { bus, sub } = props;
916
1336
  const m = bus.metrics;
917
1337
  return /* @__PURE__ */ a("div", {
918
1338
  class: "dt-view",
@@ -933,27 +1353,505 @@ function BusView(props) {
933
1353
  m?.storage ? ` · storage ${bytes(m.storage.usage)} of ${bytes(m.storage.quota)}` : ""
934
1354
  ]
935
1355
  }), 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 })
1356
+ sub === "topics" ? /* @__PURE__ */ a(Topics, { metrics: m }) : null,
1357
+ sub === "subscriptions" ? /* @__PURE__ */ a(Subscriptions, { metrics: m }) : null,
1358
+ sub === "rejected" ? /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("p", {
1359
+ class: "dt-muted",
1360
+ style: "margin:0 0 4px;",
1361
+ children: "Publishes rejected since the bus worker started."
1362
+ }), /* @__PURE__ */ a(Rejected, { metrics: m })] }) : null
951
1363
  ] }) : /* @__PURE__ */ a("p", {
952
1364
  class: "dt-muted",
953
1365
  children: bus.state === "none" ? "No bus: the kernel has no contracts." : "Waiting for bus metrics…"
954
1366
  })]
955
1367
  });
956
1368
  }
1369
+ // src/format.ts
1370
+ const pad$2 = (n) => " ".repeat(n);
1371
+ /**
1372
+ * The text indented like JSON, one member or element to a line. The values are
1373
+ * JSON-like, not always JSON (`Float32Array(50)`, or a preview cut short), so
1374
+ * this walks the text instead of parsing it: strings and anything in
1375
+ * parentheses stay whole, and a cut-off ending is left as it is.
1376
+ */
1377
+ function pretty(text) {
1378
+ let out = "";
1379
+ let depth = 0;
1380
+ let parens = 0;
1381
+ let fresh = false;
1382
+ for (let i = 0; i < text.length; i++) {
1383
+ const c = text.charAt(i);
1384
+ const wasFresh = fresh;
1385
+ fresh = false;
1386
+ if (c === "\"") {
1387
+ let j = i + 1;
1388
+ while (j < text.length && text.charAt(j) !== "\"") j += text.charAt(j) === "\\" ? 2 : 1;
1389
+ out += text.slice(i, j + 1);
1390
+ i = j;
1391
+ } else if (parens > 0 || c === "(") {
1392
+ if (c === "(") parens++;
1393
+ else if (c === ")") parens--;
1394
+ out += c;
1395
+ } else if (c === "{" || c === "[") {
1396
+ const close = c === "{" ? "}" : "]";
1397
+ if (text.charAt(i + 1) === close) {
1398
+ out += c + close;
1399
+ i++;
1400
+ } else {
1401
+ depth++;
1402
+ out += `${c}\n${pad$2(depth)}`;
1403
+ fresh = true;
1404
+ }
1405
+ } else if (c === "}" || c === "]") {
1406
+ depth = Math.max(0, depth - 1);
1407
+ out += `\n${pad$2(depth)}${c}`;
1408
+ } else if (c === ",") {
1409
+ out += `,\n${pad$2(depth)}`;
1410
+ fresh = true;
1411
+ } else if (c === ":") {
1412
+ out += ": ";
1413
+ fresh = true;
1414
+ } else if (!(wasFresh && /\s/.test(c))) out += c;
1415
+ }
1416
+ return out;
1417
+ }
1418
+ const TOKEN = /("(?:\\.|[^"\\])*")(\s*:)?|\b(?:true|false|null)\b|(?<![\w$.])-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(?![\w$])/g;
1419
+ /** Splits JSON-like text into parts to colour: keys, strings, numbers, true/false/null. */
1420
+ function highlight(text) {
1421
+ const parts = [];
1422
+ let last = 0;
1423
+ for (const m of text.matchAll(TOKEN)) {
1424
+ const at = m.index;
1425
+ if (at > last) parts.push({ text: text.slice(last, at) });
1426
+ if (m[1] !== void 0) {
1427
+ if (m[2] === void 0) parts.push({
1428
+ text: m[1],
1429
+ kind: "string"
1430
+ });
1431
+ else {
1432
+ parts.push({
1433
+ text: m[1],
1434
+ kind: "key"
1435
+ });
1436
+ parts.push({ text: m[2] });
1437
+ }
1438
+ } else parts.push({
1439
+ text: m[0],
1440
+ kind: /^[-\d]/.test(m[0]) ? "number" : "literal"
1441
+ });
1442
+ last = at + m[0].length;
1443
+ }
1444
+ if (last < text.length) parts.push({ text: text.slice(last) });
1445
+ return parts;
1446
+ }
1447
+ /** What a record is besides its value, as indented JSON (for the Record panel's Copy). */
1448
+ function recordJson(r) {
1449
+ return JSON.stringify({
1450
+ topic: r.topic,
1451
+ offset: r.offset,
1452
+ ...r.key === void 0 ? {} : { key: r.key },
1453
+ time: new Date(r.ts).toISOString(),
1454
+ ts: r.ts,
1455
+ producer: r.producer,
1456
+ bytes: r.bytes,
1457
+ truncated: r.truncated,
1458
+ ...r.req === void 0 ? {} : { req: r.req }
1459
+ }, null, 2);
1460
+ }
1461
+ // src/events-view.tsx
1462
+ const pad$1 = (n, w = 2) => String(n).padStart(w, "0");
1463
+ /** Time since the page started, as the host's clock has it: m:ss.mmm. */
1464
+ const since = (at) => {
1465
+ const total = Math.max(0, Math.round(at));
1466
+ return `${Math.floor(total / 6e4)}:${pad$1(Math.floor(total / 1e3) % 60)}.${pad$1(total % 1e3, 3)}`;
1467
+ };
1468
+ /** Newest first, each with a key that stays the same while newer events arrive. */
1469
+ function rowsOf(events) {
1470
+ const seen = /* @__PURE__ */ new Map();
1471
+ const oldestFirst = events.map((e) => {
1472
+ const subject = subjectOf(e);
1473
+ const base = `${e.at} ${e.event} ${subject}`;
1474
+ const n = (seen.get(base) ?? 0) + 1;
1475
+ seen.set(base, n);
1476
+ return {
1477
+ key: `${base} ${n}`,
1478
+ e,
1479
+ level: levelOfEvent(e),
1480
+ subject,
1481
+ detail: detailOf(e)
1482
+ };
1483
+ });
1484
+ const rows = [];
1485
+ for (let i = oldestFirst.length - 1; i >= 0; i--) {
1486
+ const r = oldestFirst[i];
1487
+ if (r) rows.push(r);
1488
+ }
1489
+ return rows;
1490
+ }
1491
+ const isProblem = (l) => l === "bad" || l === "warn";
1492
+ const MARK$1 = {
1493
+ bad: "●",
1494
+ warn: "●",
1495
+ good: "●",
1496
+ info: "○"
1497
+ };
1498
+ const PAGE = 500;
1499
+ const when = (ms) => new Date(ms).toLocaleString(void 0, {
1500
+ dateStyle: "short",
1501
+ timeStyle: "medium"
1502
+ });
1503
+ function EventsView(props) {
1504
+ const { recorder } = props;
1505
+ const [filter, setFilter] = d("");
1506
+ const [problems, setProblems] = d(false);
1507
+ const [open, setOpen] = d(/* @__PURE__ */ new Set());
1508
+ const [copied, setCopied] = d(void 0);
1509
+ const [limit, setLimit] = d(PAGE);
1510
+ const [sessions, setSessions] = d([]);
1511
+ const [session, setSession] = d(recorder.session);
1512
+ const [earlier, setEarlier] = d(void 0);
1513
+ const current = session === recorder.session;
1514
+ const refreshSessions = () => {
1515
+ recorder.sessions().then(setSessions);
1516
+ };
1517
+ A(refreshSessions, []);
1518
+ A(() => {
1519
+ let alive = true;
1520
+ setEarlier(void 0);
1521
+ if (!current) recorder.load(session).then((rows) => {
1522
+ if (alive) setEarlier(rows);
1523
+ });
1524
+ return () => {
1525
+ alive = false;
1526
+ };
1527
+ }, [session]);
1528
+ const events = current ? recorder.events() : earlier ?? [];
1529
+ const q = filter.trim().toLowerCase();
1530
+ const all = rowsOf(events);
1531
+ const matching = all.filter((r) => (!problems || r.level === "bad" || r.level === "warn") && (q === "" || `${r.e.event} ${r.subject} ${r.detail}`.toLowerCase().includes(q)));
1532
+ const rows = matching.slice(0, limit);
1533
+ const others = sessions.filter((s) => s.id !== recorder.session);
1534
+ const unseen = recorder.unacknowledged();
1535
+ return /* @__PURE__ */ a("div", {
1536
+ class: "dt-view dt-log",
1537
+ "data-view": "events",
1538
+ children: [
1539
+ /* @__PURE__ */ a("form", {
1540
+ class: "dt-log-bar",
1541
+ onSubmit: (e) => {
1542
+ e.preventDefault();
1543
+ },
1544
+ children: [
1545
+ /* @__PURE__ */ a("input", {
1546
+ type: "text",
1547
+ "aria-label": "Filter the events",
1548
+ placeholder: "Filter, e.g. feed-T1 or crash",
1549
+ value: filter,
1550
+ "data-events-filter": "",
1551
+ onInput: (e) => {
1552
+ setFilter(e.currentTarget.value);
1553
+ setLimit(PAGE);
1554
+ }
1555
+ }),
1556
+ /* @__PURE__ */ a("button", {
1557
+ type: "button",
1558
+ "data-events-problems": "",
1559
+ "aria-pressed": problems ? "true" : "false",
1560
+ onClick: () => {
1561
+ setProblems(!problems);
1562
+ setLimit(PAGE);
1563
+ },
1564
+ children: "Problems only"
1565
+ }),
1566
+ others.length > 0 ? /* @__PURE__ */ a("select", {
1567
+ "aria-label": "Session",
1568
+ "data-events-session": "",
1569
+ value: session,
1570
+ onChange: (e) => {
1571
+ setSession(e.currentTarget.value);
1572
+ setLimit(PAGE);
1573
+ setOpen(/* @__PURE__ */ new Set());
1574
+ },
1575
+ children: [/* @__PURE__ */ a("option", {
1576
+ value: recorder.session,
1577
+ children: "This session"
1578
+ }), others.map((s) => /* @__PURE__ */ a("option", {
1579
+ value: s.id,
1580
+ children: [
1581
+ when(s.started),
1582
+ " · ",
1583
+ s.count,
1584
+ " events"
1585
+ ]
1586
+ }, s.id))]
1587
+ }) : null,
1588
+ /* @__PURE__ */ a("button", {
1589
+ type: "button",
1590
+ "data-events-ack": "",
1591
+ disabled: unseen === 0,
1592
+ title: "Mark the problems listed as seen, which clears the count on the tab",
1593
+ onClick: () => {
1594
+ recorder.acknowledge();
1595
+ props.onAck();
1596
+ },
1597
+ children: ["Acknowledge", unseen > 0 ? ` (${unseen})` : ""]
1598
+ }),
1599
+ /* @__PURE__ */ a("button", {
1600
+ type: "button",
1601
+ "data-events-clear": "",
1602
+ title: `Forget the stored events of every session. Kept in this browser (IndexedDB): this session and the last 3 before it, up to ${PER_SESSION} events each.`,
1603
+ onClick: () => {
1604
+ recorder.clear().then(() => {
1605
+ setSession(recorder.session);
1606
+ setOpen(/* @__PURE__ */ new Set());
1607
+ refreshSessions();
1608
+ props.onAck();
1609
+ });
1610
+ },
1611
+ children: "Clear"
1612
+ })
1613
+ ]
1614
+ }),
1615
+ /* @__PURE__ */ a("p", {
1616
+ class: "dt-muted",
1617
+ style: "margin:4px 0;",
1618
+ children: [
1619
+ matching.length === all.length ? `${all.length} events` : `${matching.length} of ${all.length} events`,
1620
+ " · newest first · ",
1621
+ current ? "this page session" : `session from ${when(sessions.find((s) => s.id === session)?.started ?? 0)}`,
1622
+ current && all.length >= 6e3 ? ` · the oldest are dropped past ${PER_SESSION}` : ""
1623
+ ]
1624
+ }),
1625
+ /* @__PURE__ */ a("div", {
1626
+ class: "dt-log-rows",
1627
+ children: rows.length === 0 ? /* @__PURE__ */ a("p", {
1628
+ class: "dt-muted",
1629
+ children: !current && earlier === void 0 ? "Loading…" : all.length === 0 ? "No events yet." : "No events match."
1630
+ }) : /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("table", {
1631
+ class: "dt-table",
1632
+ "data-events-table": "",
1633
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1634
+ /* @__PURE__ */ a("th", {
1635
+ class: "dt-c-chev",
1636
+ children: /* @__PURE__ */ a("span", {
1637
+ class: "dt-sr",
1638
+ children: "Details"
1639
+ })
1640
+ }),
1641
+ /* @__PURE__ */ a("th", {
1642
+ class: "dt-c-time",
1643
+ children: "Since start"
1644
+ }),
1645
+ /* @__PURE__ */ a("th", { children: "Event" }),
1646
+ /* @__PURE__ */ a("th", { children: "Isolate" }),
1647
+ /* @__PURE__ */ a("th", { children: "What happened" })
1648
+ ] }) }), /* @__PURE__ */ a("tbody", { children: rows.map((r) => {
1649
+ const isOpen = open.has(r.key);
1650
+ const text = JSON.stringify(r.e.data, null, 2);
1651
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("tr", {
1652
+ class: `dt-log-row dt-ev-${r.level}${current && isProblem(r.level) && recorder.isNew(r.e) ? " dt-ev-new" : ""}`,
1653
+ "data-event": r.e.event,
1654
+ "data-level": r.level,
1655
+ "aria-expanded": isOpen ? "true" : "false",
1656
+ onClick: () => {
1657
+ const next = new Set(open);
1658
+ if (isOpen) next.delete(r.key);
1659
+ else next.add(r.key);
1660
+ setOpen(next);
1661
+ },
1662
+ children: [
1663
+ /* @__PURE__ */ a("td", {
1664
+ class: "dt-c-chev",
1665
+ children: /* @__PURE__ */ a("button", {
1666
+ type: "button",
1667
+ class: "dt-chev",
1668
+ "aria-expanded": isOpen ? "true" : "false",
1669
+ "aria-label": isOpen ? "Hide the event" : "Show the event",
1670
+ children: isOpen ? "▾" : "▸"
1671
+ })
1672
+ }),
1673
+ /* @__PURE__ */ a("td", {
1674
+ class: "dt-c-time",
1675
+ title: when(r.e.wall),
1676
+ children: since(r.e.at)
1677
+ }),
1678
+ /* @__PURE__ */ a("td", { children: [
1679
+ /* @__PURE__ */ a("span", {
1680
+ class: "dt-ev-dot",
1681
+ "aria-hidden": "true",
1682
+ children: MARK$1[r.level]
1683
+ }),
1684
+ " ",
1685
+ /* @__PURE__ */ a("code", { children: r.e.event })
1686
+ ] }),
1687
+ /* @__PURE__ */ a("td", { children: r.subject }),
1688
+ /* @__PURE__ */ a("td", {
1689
+ class: "dt-vclip",
1690
+ children: r.detail
1691
+ })
1692
+ ]
1693
+ }), isOpen ? /* @__PURE__ */ a("tr", {
1694
+ class: "dt-log-detail",
1695
+ "data-event-detail": "",
1696
+ children: /* @__PURE__ */ a("td", {
1697
+ colSpan: 5,
1698
+ children: /* @__PURE__ */ a("div", {
1699
+ class: "dt-detail",
1700
+ children: /* @__PURE__ */ a("div", {
1701
+ class: "dt-detail-part dt-detail-value",
1702
+ children: [/* @__PURE__ */ a("div", {
1703
+ class: "dt-detail-bar",
1704
+ children: [/* @__PURE__ */ a("strong", {
1705
+ class: "dt-detail-h",
1706
+ children: "Data"
1707
+ }), /* @__PURE__ */ a("button", {
1708
+ type: "button",
1709
+ "data-isoloop-copy": text,
1710
+ "data-log-copy": "event",
1711
+ onClick: () => {
1712
+ setCopied(r.key);
1713
+ setTimeout(() => {
1714
+ setCopied((c) => c === r.key ? void 0 : c);
1715
+ }, 1500);
1716
+ },
1717
+ children: copied === r.key ? "Copied" : "Copy"
1718
+ })]
1719
+ }), /* @__PURE__ */ a("pre", {
1720
+ class: "dt-json",
1721
+ children: highlight(text).map((part, i) => /* @__PURE__ */ a("span", {
1722
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
1723
+ children: part.text
1724
+ }, i))
1725
+ })]
1726
+ })
1727
+ })
1728
+ })
1729
+ }) : null] }, r.key);
1730
+ }) })]
1731
+ }), matching.length > rows.length ? /* @__PURE__ */ a("p", {
1732
+ style: "margin:6px 0;",
1733
+ children: /* @__PURE__ */ a("button", {
1734
+ type: "button",
1735
+ class: "dt-more",
1736
+ "data-events-older": "",
1737
+ onClick: () => {
1738
+ setLimit(limit + PAGE);
1739
+ },
1740
+ children: [
1741
+ "Load older (",
1742
+ matching.length - rows.length,
1743
+ " more)"
1744
+ ]
1745
+ })
1746
+ }) : null] })
1747
+ })
1748
+ ]
1749
+ });
1750
+ }
1751
+ // src/record-detail.tsx
1752
+ const ITEMS = [{
1753
+ id: "value",
1754
+ label: "Value"
1755
+ }, {
1756
+ id: "record",
1757
+ label: "Record"
1758
+ }];
1759
+ function Value(props) {
1760
+ return /* @__PURE__ */ a("pre", {
1761
+ class: "dt-json",
1762
+ children: highlight(props.text).map((part, i) => /* @__PURE__ */ a("span", {
1763
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
1764
+ children: part.text
1765
+ }, i))
1766
+ });
1767
+ }
1768
+ const dim = (v) => /* @__PURE__ */ a("span", {
1769
+ class: "dt-dim",
1770
+ children: v
1771
+ });
1772
+ function Fields(props) {
1773
+ const { r } = props;
1774
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("dl", {
1775
+ class: "dt-rec",
1776
+ children: [
1777
+ [
1778
+ "Time",
1779
+ "mono",
1780
+ new Date(r.ts).toISOString()
1781
+ ],
1782
+ [
1783
+ "Topic",
1784
+ "topic",
1785
+ r.topic
1786
+ ],
1787
+ [
1788
+ "Offset",
1789
+ "num",
1790
+ String(r.offset)
1791
+ ],
1792
+ [
1793
+ "Key",
1794
+ r.key === void 0 ? "" : "str",
1795
+ r.key ?? dim("–")
1796
+ ],
1797
+ [
1798
+ "Producer",
1799
+ "",
1800
+ r.producer
1801
+ ],
1802
+ [
1803
+ "Size",
1804
+ "num",
1805
+ `${r.bytes} B`
1806
+ ],
1807
+ [
1808
+ "Request",
1809
+ "",
1810
+ r.req ? `${r.req.from} · ${r.req.id}${r.req.via ? ` · via ${r.req.via}` : ""}` : dim("–")
1811
+ ]
1812
+ ].map(([k, kind, v]) => /* @__PURE__ */ a("div", {
1813
+ class: "dt-rec-row",
1814
+ children: [/* @__PURE__ */ a("dt", { children: k }), /* @__PURE__ */ a("dd", {
1815
+ class: kind ? `dt-rec-${kind}` : void 0,
1816
+ children: v
1817
+ })]
1818
+ }, k))
1819
+ }), r.truncated ? /* @__PURE__ */ a("p", {
1820
+ class: "dt-rec-note",
1821
+ children: "The value is cut to a 2 KB preview."
1822
+ }) : null] });
1823
+ }
1824
+ function RecordDetail(props) {
1825
+ const { r } = props;
1826
+ const [copied, setCopied] = d(void 0);
1827
+ const value = pretty(r.preview);
1828
+ const record = recordJson(r);
1829
+ const copy = (p) => /* @__PURE__ */ a("button", {
1830
+ type: "button",
1831
+ "data-isoloop-copy": p === "value" ? value : record,
1832
+ "data-log-copy": p,
1833
+ onClick: () => {
1834
+ setCopied(p);
1835
+ setTimeout(() => {
1836
+ setCopied((c) => c === p ? void 0 : c);
1837
+ }, 1500);
1838
+ },
1839
+ children: copied === p ? "Copied" : "Copy"
1840
+ });
1841
+ return /* @__PURE__ */ a("div", {
1842
+ class: "dt-detail dt-detail-cols",
1843
+ children: ITEMS.map((it) => /* @__PURE__ */ a("section", {
1844
+ class: `dt-detail-part dt-detail-${it.id}`,
1845
+ children: [/* @__PURE__ */ a("div", {
1846
+ class: "dt-detail-bar",
1847
+ children: [/* @__PURE__ */ a("strong", {
1848
+ class: "dt-detail-h",
1849
+ children: it.label
1850
+ }), copy(it.id)]
1851
+ }), it.id === "value" ? /* @__PURE__ */ a(Value, { text: value }) : /* @__PURE__ */ a(Fields, { r })]
1852
+ }, it.id))
1853
+ });
1854
+ }
957
1855
  /** Splits the filter into tap patterns: `*` (every topic) when empty. */
958
1856
  const patternsOf = (filter) => {
959
1857
  const p = filter.split(/[\s,]+/).map((s) => s.trim()).filter((s) => s.length > 0);
@@ -964,13 +1862,16 @@ const time = (ts) => {
964
1862
  const d = new Date(ts);
965
1863
  return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
966
1864
  };
967
- function LogView() {
1865
+ /** The row's one-line value is coloured once, from its first characters (the cell clips the rest). */
1866
+ const GLANCE = 240;
1867
+ function MessagesView() {
968
1868
  const inspector = useIsolate().inspector;
969
1869
  const [filter, setFilter] = d("");
970
1870
  const [applied, setApplied] = d(["*"]);
971
1871
  const [paused, setPaused] = d(false);
972
1872
  const [entries, setEntries] = d([]);
973
1873
  const [skipped, setSkipped] = d(0);
1874
+ const [open, setOpen] = d(/* @__PURE__ */ new Set());
974
1875
  A(() => {
975
1876
  if (!inspector || paused) return void 0;
976
1877
  let n = 0;
@@ -985,7 +1886,8 @@ function LogView() {
985
1886
  n += 1;
986
1887
  const entry = {
987
1888
  ...r,
988
- n
1889
+ n,
1890
+ glance: highlight(r.preview.slice(0, GLANCE))
989
1891
  };
990
1892
  setEntries((prev) => [entry, ...prev].slice(0, 200));
991
1893
  });
@@ -995,8 +1897,8 @@ function LogView() {
995
1897
  paused
996
1898
  ]);
997
1899
  return /* @__PURE__ */ a("div", {
998
- class: "dt-view",
999
- "data-view": "log",
1900
+ class: "dt-view dt-log",
1901
+ "data-view": "messages",
1000
1902
  children: [
1001
1903
  /* @__PURE__ */ a("form", {
1002
1904
  class: "dt-log-bar",
@@ -1057,76 +1959,202 @@ function LogView() {
1057
1959
  })
1058
1960
  ]
1059
1961
  }),
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
1962
+ /* @__PURE__ */ a("div", {
1963
+ class: "dt-log-rows",
1964
+ children: entries.length === 0 ? /* @__PURE__ */ a("p", {
1965
+ class: "dt-muted",
1966
+ children: "No records yet."
1967
+ }) : /* @__PURE__ */ a("table", {
1968
+ class: "dt-table",
1969
+ "data-log-table": "",
1970
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
1971
+ /* @__PURE__ */ a("th", {
1972
+ class: "dt-c-chev",
1973
+ children: /* @__PURE__ */ a("span", {
1974
+ class: "dt-sr",
1975
+ children: "Details"
1976
+ })
1977
+ }),
1978
+ /* @__PURE__ */ a("th", {
1979
+ class: "dt-c-time",
1980
+ children: "Time"
1981
+ }),
1982
+ /* @__PURE__ */ a("th", { children: "Topic" }),
1983
+ /* @__PURE__ */ a("th", {
1984
+ class: "dt-num dt-c-offset",
1985
+ children: "Offset"
1986
+ }),
1987
+ /* @__PURE__ */ a("th", {
1988
+ class: "dt-c-key",
1989
+ children: "Key"
1089
1990
  }),
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"]
1991
+ /* @__PURE__ */ a("th", { children: "Producer" }),
1992
+ /* @__PURE__ */ a("th", {
1993
+ class: "dt-num dt-c-size",
1994
+ children: "Size"
1095
1995
  }),
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}`)) })]
1996
+ /* @__PURE__ */ a("th", { children: "Value" })
1997
+ ] }) }), /* @__PURE__ */ a("tbody", { children: entries.map((r) => {
1998
+ const id = `${r.topic} ${r.offset} ${r.n}`;
1999
+ const isOpen = open.has(id);
2000
+ return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("tr", {
2001
+ class: "dt-log-row",
2002
+ "data-log-topic": r.topic,
2003
+ "data-offset": r.offset,
2004
+ "aria-expanded": isOpen ? "true" : "false",
2005
+ onClick: () => {
2006
+ const next = new Set(open);
2007
+ if (isOpen) next.delete(id);
2008
+ else next.add(id);
2009
+ setOpen(next);
2010
+ },
2011
+ children: [
2012
+ /* @__PURE__ */ a("td", {
2013
+ class: "dt-c-chev",
2014
+ children: /* @__PURE__ */ a("button", {
2015
+ type: "button",
2016
+ class: "dt-chev",
2017
+ "aria-expanded": isOpen ? "true" : "false",
2018
+ "aria-label": isOpen ? "Hide the record" : "Show the record",
2019
+ children: isOpen ? "▾" : "▸"
2020
+ })
2021
+ }),
2022
+ /* @__PURE__ */ a("td", {
2023
+ class: "dt-c-time",
2024
+ children: time(r.ts)
2025
+ }),
2026
+ /* @__PURE__ */ a("td", {
2027
+ class: "dt-col-topic",
2028
+ children: /* @__PURE__ */ a("code", { children: r.topic })
2029
+ }),
2030
+ /* @__PURE__ */ a("td", {
2031
+ class: "dt-num dt-c-offset dt-col-num",
2032
+ children: r.offset
2033
+ }),
2034
+ /* @__PURE__ */ a("td", {
2035
+ class: "dt-c-key dt-col-str",
2036
+ title: r.key ?? "",
2037
+ children: r.key ?? ""
2038
+ }),
2039
+ /* @__PURE__ */ a("td", { children: r.producer }),
2040
+ /* @__PURE__ */ a("td", {
2041
+ class: "dt-num dt-c-size",
2042
+ children: [r.bytes, " B"]
2043
+ }),
2044
+ /* @__PURE__ */ a("td", {
2045
+ class: "dt-vclip",
2046
+ children: /* @__PURE__ */ a("code", { children: r.glance.map((part, i) => /* @__PURE__ */ a("span", {
2047
+ class: part.kind ? `dt-j-${part.kind}` : void 0,
2048
+ children: part.text
2049
+ }, i)) })
2050
+ })
2051
+ ]
2052
+ }), isOpen ? /* @__PURE__ */ a("tr", {
2053
+ class: "dt-log-detail",
2054
+ "data-log-detail": "",
2055
+ children: /* @__PURE__ */ a("td", {
2056
+ colSpan: 8,
2057
+ children: /* @__PURE__ */ a(RecordDetail, { r })
2058
+ })
2059
+ }) : null] }, id);
2060
+ }) })]
2061
+ })
1103
2062
  })
1104
2063
  ]
1105
2064
  });
1106
2065
  }
2066
+ // src/subtabs.tsx
2067
+ const subId = (group, id) => `dt-sub-${group}-${id}`;
2068
+ const subPanelId = (group) => `dt-subpanel-${group}`;
2069
+ function SubTabs(props) {
2070
+ const ctx = useIsolate();
2071
+ const buttons = T({});
2072
+ const { items, value } = props;
2073
+ const onKey = (e) => {
2074
+ const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
2075
+ if (step === 0) return;
2076
+ const i = items.findIndex((t) => t.id === value);
2077
+ const next = items[(i + step + items.length) % items.length];
2078
+ if (!next) return;
2079
+ props.onChange(next.id);
2080
+ const el = buttons.current[next.id];
2081
+ if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
2082
+ };
2083
+ return /* @__PURE__ */ a("div", {
2084
+ class: "dt-subtabs",
2085
+ role: "tablist",
2086
+ "aria-label": props.label,
2087
+ onKeyDown: onKey,
2088
+ children: items.map((t) => /* @__PURE__ */ a("button", {
2089
+ ref: (el) => {
2090
+ buttons.current[t.id] = el ?? void 0;
2091
+ },
2092
+ id: subId(props.group, t.id),
2093
+ type: "button",
2094
+ role: "tab",
2095
+ "data-subtab": t.id,
2096
+ "aria-selected": value === t.id ? "true" : "false",
2097
+ "aria-controls": subPanelId(props.group),
2098
+ tabindex: value === t.id ? 0 : -1,
2099
+ class: "dt-subtab",
2100
+ onClick: () => {
2101
+ props.onChange(t.id);
2102
+ },
2103
+ children: [t.label, t.count === void 0 ? null : /* @__PURE__ */ a("span", {
2104
+ class: "dt-subcount",
2105
+ children: t.count
2106
+ })]
2107
+ }, t.id))
2108
+ });
2109
+ }
1107
2110
  // src/views.tsx
1108
2111
  /** How long the block control busy-loops an isolate's worker. */
1109
2112
  const BLOCK_MS = 2e3;
1110
2113
  const CSS = `
1111
- .dt-tabs { display: flex; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid #374151; }
2114
+ .dt-root { display: flex; flex-direction: column; flex: 1; min-height: 0; }
2115
+ .dt-nav { background: #0b1220; }
2116
+ .dt-scroll { flex: 1; min-height: 0; overflow: auto; }
2117
+ /* The log keeps its toolbar in place and scrolls only its rows. */
2118
+ .dt-scroll-fill { display: flex; flex-direction: column; overflow: hidden; }
2119
+ .dt-tabs { display: flex; gap: 2px; padding: 4px 12px 0; border-bottom: 1px solid #374151; }
2120
+ .dt-subtabs { display: flex; gap: 4px; padding: 4px 12px; background: #0f1a2e;
2121
+ border-bottom: 1px solid #1f2937; }
2122
+ .dt-subtab { background: none; border: 1px solid transparent; border-radius: 999px; color: #8b95a7;
2123
+ font: inherit; font-size: 11px; padding: 1px 9px; cursor: pointer; }
2124
+ .dt-subtab:hover { color: #e5e7eb; }
2125
+ .dt-subtab[aria-selected="true"] { background: #1e293b; border-color: #334155; color: #e5e7eb; }
2126
+ .dt-subtab:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2127
+ .dt-subcount { margin-left: 5px; color: #64748b; font-variant-numeric: tabular-nums; }
2128
+ .dt-subtab[aria-selected="true"] .dt-subcount { color: #93c5fd; }
1112
2129
  .dt-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #9ca3af;
1113
2130
  font: inherit; padding: 4px 8px; cursor: pointer; }
1114
2131
  .dt-tab[aria-selected="true"] { color: #e5e7eb; border-bottom-color: #60a5fa; }
1115
- .dt-view { padding: 6px 8px; }
2132
+ .dt-view { padding: 6px 12px; }
1116
2133
  .dt-muted { color: #9ca3af; }
1117
2134
  .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;
2135
+ .dt-table th { text-align: left; font-weight: 600; color: #9ca3af; padding: 2px 12px 4px 0;
1119
2136
  white-space: nowrap; }
1120
- .dt-table td { padding: 3px 6px 3px 0; border-top: 1px solid #1f2937; vertical-align: top;
2137
+ .dt-table td { padding: 3px 12px 3px 0; border-top: 1px solid #1f2937; vertical-align: top;
1121
2138
  white-space: nowrap; }
2139
+ .dt-table th { position: sticky; top: 0; z-index: 1; background: #111827; box-shadow: 0 1px 0 #374151; }
1122
2140
  .dt-table td.dt-num, .dt-table th.dt-num { text-align: right; }
2141
+ .dt-chips { display: flex; flex-wrap: wrap; gap: 3px; }
2142
+ .dt-chip { background: #1f2937; border: 1px solid #374151; border-radius: 4px; padding: 0 5px;
2143
+ font-size: 11px; color: #d1d5db; }
2144
+ .dt-more { background: none; border: 1px dashed #4b5563; border-radius: 4px; color: #93c5fd;
2145
+ font: inherit; font-size: 11px; padding: 0 5px; cursor: pointer; }
2146
+ .dt-more:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2147
+ .dt-pool-note { margin-top: 3px; font-size: 11px; }
1123
2148
  .dt-badge { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px;
1124
2149
  background: #1e3a8a; color: #bfdbfe; font-size: 10px; }
2150
+ /* The Events tab's count of problems: amber, like the ring's arcs. */
2151
+ .dt-badge-warn { background: #f59e0b; color: #111827; font-weight: 600; }
1125
2152
  .dt-pool { display: block; color: #9ca3af; font-size: 11px; }
1126
2153
  .dt-state-running { color: #86efac; }
1127
2154
  .dt-state-blocked, .dt-state-crashed, .dt-state-restarting { color: #fcd34d; }
1128
2155
  .dt-state-failed { color: #fca5a5; }
1129
- .dt-actions { display: flex; gap: 4px; }
2156
+ .dt-actions { display: flex; justify-content: center; gap: 4px; }
2157
+ .dt-table th.dt-center { text-align: center; }
1130
2158
  .dt-actions button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
1131
2159
  border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 6px; cursor: pointer; }
1132
2160
  .dt-actions button:focus-visible, .dt-tab:focus-visible { outline: 2px solid #60a5fa;
@@ -1135,14 +2163,80 @@ const CSS = `
1135
2163
  .dt-h { margin: 10px 0 4px; font-size: 12px; color: #9ca3af; }
1136
2164
  .dt-warning { color: #fcd34d; }
1137
2165
  .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;
2166
+ .dt-log { display: flex; flex-direction: column; flex: 1; min-height: 0; }
2167
+ .dt-log-rows { flex: 1; min-height: 0; overflow: auto; container-type: inline-size; }
2168
+ /* The detail keeps the width you can see, so a wide table doesn't push its panels out of view. */
2169
+ .dt-detail { position: sticky; left: 0; width: calc(100cqw - 16px); box-sizing: border-box; }
2170
+ .dt-log-bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
2171
+ .dt-log-bar input { flex: 1 1 9em; min-width: 9em; box-sizing: border-box; background: #0b1220; color: #e5e7eb;
1140
2172
  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;
2173
+ .dt-log-bar button { white-space: nowrap; box-sizing: border-box; background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
1142
2174
  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;
2175
+ .dt-log-bar select { box-sizing: border-box; background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2176
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 4px; max-width: 14em; }
2177
+ .dt-log-bar input:focus-visible, .dt-log-bar select:focus-visible, .dt-log-bar button:focus-visible { outline: 2px solid #60a5fa;
1144
2178
  outline-offset: 1px; }
1145
2179
  .dt-table td.dt-value { white-space: normal; word-break: break-all; max-width: 40ch; }
2180
+ /* The log's columns with a known width keep it; the value takes the rest, on one line. */
2181
+ .dt-table .dt-c-time { width: 12ch; min-width: 12ch; }
2182
+ .dt-table .dt-c-offset { width: 7ch; min-width: 7ch; }
2183
+ .dt-table .dt-c-size { width: 9ch; min-width: 9ch; }
2184
+ .dt-table .dt-c-key { width: 12ch; min-width: 12ch; max-width: 12ch; overflow: hidden;
2185
+ text-overflow: ellipsis; }
2186
+ .dt-table td.dt-vclip { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
2187
+ .dt-table .dt-c-chev { width: 18px; min-width: 18px; padding-right: 0; }
2188
+ .dt-chev { background: none; border: 0; color: #6b7280; font: inherit; font-size: 11px;
2189
+ padding: 0; width: 16px; cursor: pointer; }
2190
+ .dt-log-row:hover .dt-chev, .dt-log-row[aria-expanded="true"] .dt-chev { color: #e5e7eb; }
2191
+ .dt-chev:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2192
+ .dt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden;
2193
+ clip: rect(0 0 0 0); white-space: nowrap; }
2194
+ .dt-log-row { cursor: pointer; }
2195
+ .dt-ev-new td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
2196
+ .dt-log-bar button:disabled { opacity: 0.45; cursor: default; }
2197
+ .dt-ev-bad .dt-ev-dot { color: #ef4444; }
2198
+ .dt-ev-warn .dt-ev-dot { color: #f59e0b; }
2199
+ .dt-ev-good .dt-ev-dot { color: #22c55e; }
2200
+ .dt-ev-info .dt-ev-dot { color: #64748b; }
2201
+ .dt-ev-bad td.dt-vclip { color: #fca5a5; }
2202
+ .dt-ev-warn td.dt-vclip { color: #fcd34d; }
2203
+ .dt-log-row:hover { background: #172033; }
2204
+ .dt-log-row[aria-expanded="true"] { background: #172033; }
2205
+ .dt-table tr.dt-log-detail td { white-space: normal; background: #0b1220; padding: 6px 8px; }
2206
+ .dt-detail-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
2207
+ .dt-detail-bar .dt-subtabs { background: none; border: 0; padding: 0; }
2208
+ .dt-detail-bar button[data-log-copy] { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
2209
+ border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 8px; cursor: pointer; }
2210
+ .dt-detail-bar button[data-log-copy]:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
2211
+ .dt-detail-h { color: #9ca3af; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
2212
+ .dt-detail-cols { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
2213
+ .dt-detail-part { box-sizing: border-box; min-width: 0; background: #0f1a2e; border: 1px solid #1f2937;
2214
+ border-left-width: 3px; border-radius: 6px; padding: 6px 10px 8px; }
2215
+ .dt-detail-value { flex: 1 1 260px; border-left-color: #4ade80; }
2216
+ /* The record is as wide as its content, up to 30% of what you can see. */
2217
+ .dt-detail-record { flex: 0 1 auto; width: max-content; max-width: 30%; min-width: 200px;
2218
+ border-left-color: #60a5fa; }
2219
+ .dt-rec { margin: 0; }
2220
+ .dt-rec-row { display: grid; grid-template-columns: 4.5em 1fr; gap: 0 12px; padding: 3px 0;
2221
+ border-top: 1px solid #1c2a40; }
2222
+ .dt-rec-row:first-child { border-top: 0; }
2223
+ .dt-rec dt { color: #8b95a7; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
2224
+ padding-top: 1px; }
2225
+ .dt-rec dd { margin: 0; color: #e5e7eb; word-break: break-word; }
2226
+ .dt-rec-mono, .dt-rec-topic, .dt-rec-num, .dt-rec-str { font: 11px/1.5 ui-monospace, SFMono-Regular,
2227
+ Menlo, monospace; }
2228
+ .dt-rec-topic, .dt-col-topic { color: #93c5fd; }
2229
+ .dt-rec-num, .dt-col-num { color: #fcd34d; }
2230
+ .dt-rec-str, .dt-col-str { color: #86efac; }
2231
+ .dt-dim { color: #64748b; }
2232
+ .dt-rec-note { margin: 4px 0 0; color: #9ca3af; font-size: 11px; }
2233
+ .dt-json { margin: 0; max-height: 240px; overflow: auto; white-space: pre-wrap;
2234
+ word-break: break-word; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
2235
+ color: #d1d5db; }
2236
+ .dt-j-key { color: #93c5fd; }
2237
+ .dt-j-string { color: #86efac; }
2238
+ .dt-j-number { color: #fcd34d; }
2239
+ .dt-j-literal { color: #c4b5fd; }
1146
2240
  `;
1147
2241
  const ms = (n) => n === void 0 ? "–" : `${Math.round(n)} ms`;
1148
2242
  const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
@@ -1272,10 +2366,74 @@ function IsolateRow(props) {
1272
2366
  ]
1273
2367
  });
1274
2368
  }
2369
+ /** How many members a pool row lists before "+N more". */
2370
+ const POOL_PREVIEW = 8;
2371
+ function PoolRow(props) {
2372
+ const { pool: p } = props;
2373
+ const [all, setAll] = d(false);
2374
+ const shown = all ? p.members : p.members.slice(0, POOL_PREVIEW);
2375
+ const rest = p.members.length - shown.length;
2376
+ return /* @__PURE__ */ a("tr", {
2377
+ "data-pool": p.name,
2378
+ children: [
2379
+ /* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: p.name }) }),
2380
+ /* @__PURE__ */ a("td", {
2381
+ class: p.running ? "dt-state-running" : "dt-state-failed",
2382
+ children: p.running ? "running" : "stopped"
2383
+ }),
2384
+ /* @__PURE__ */ a("td", {
2385
+ class: "dt-num",
2386
+ children: p.members.length
2387
+ }),
2388
+ /* @__PURE__ */ a("td", {
2389
+ style: "white-space:normal;",
2390
+ children: [/* @__PURE__ */ a("div", {
2391
+ class: "dt-chips",
2392
+ children: [shown.map((m) => /* @__PURE__ */ a("span", {
2393
+ class: "dt-chip",
2394
+ children: m
2395
+ }, m)), p.members.length > POOL_PREVIEW ? /* @__PURE__ */ a("button", {
2396
+ type: "button",
2397
+ class: "dt-more",
2398
+ "data-pool-more": p.name,
2399
+ "aria-expanded": all ? "true" : "false",
2400
+ onClick: () => {
2401
+ setAll(!all);
2402
+ },
2403
+ children: all ? "Show fewer" : `+${rest} more`
2404
+ }) : null]
2405
+ }), p.warning === void 0 ? null : /* @__PURE__ */ a("div", {
2406
+ class: "dt-pool-note dt-warning",
2407
+ children: ["⚠ ", p.warning]
2408
+ })]
2409
+ })
2410
+ ]
2411
+ });
2412
+ }
2413
+ function PoolsTable(props) {
2414
+ return /* @__PURE__ */ a("table", {
2415
+ class: "dt-table",
2416
+ "data-view": "pools",
2417
+ children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
2418
+ /* @__PURE__ */ a("th", { children: "Pool" }),
2419
+ /* @__PURE__ */ a("th", { children: "Worker" }),
2420
+ /* @__PURE__ */ a("th", {
2421
+ class: "dt-num",
2422
+ children: "Isolates"
2423
+ }),
2424
+ /* @__PURE__ */ a("th", { children: "Members" })
2425
+ ] }) }), /* @__PURE__ */ a("tbody", { children: props.snap.pools.map((p) => /* @__PURE__ */ a(PoolRow, { pool: p }, p.name)) })]
2426
+ });
2427
+ }
1275
2428
  function IsolatesView(props) {
1276
2429
  const ctx = useIsolate();
1277
2430
  const [error, setError] = d(void 0);
1278
- const { snap } = props;
2431
+ const { snap, sub } = props;
2432
+ if (sub === "pools") return /* @__PURE__ */ a("div", {
2433
+ class: "dt-view",
2434
+ "data-view": "isolates",
2435
+ children: /* @__PURE__ */ a(PoolsTable, { snap })
2436
+ });
1279
2437
  return /* @__PURE__ */ a("div", {
1280
2438
  class: "dt-view",
1281
2439
  "data-view": "isolates",
@@ -1315,7 +2473,10 @@ function IsolatesView(props) {
1315
2473
  class: "dt-num",
1316
2474
  children: "Queue"
1317
2475
  }),
1318
- /* @__PURE__ */ a("th", {})
2476
+ /* @__PURE__ */ a("th", {
2477
+ class: "dt-center",
2478
+ children: "Actions"
2479
+ })
1319
2480
  ] }) }), /* @__PURE__ */ a("tbody", { children: snap.isolates.map((i) => /* @__PURE__ */ a(IsolateRow, {
1320
2481
  isolate: i,
1321
2482
  self: i.id === ctx.id,
@@ -1329,32 +2490,7 @@ function IsolatesView(props) {
1329
2490
  role: "status",
1330
2491
  "data-isoloop-devtools-status": "",
1331
2492
  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
- })] })
2493
+ })
1358
2494
  ]
1359
2495
  });
1360
2496
  }
@@ -1368,8 +2504,12 @@ const TABS = [
1368
2504
  label: "Bus"
1369
2505
  },
1370
2506
  {
1371
- id: "log",
1372
- label: "Log"
2507
+ id: "events",
2508
+ label: "Events"
2509
+ },
2510
+ {
2511
+ id: "messages",
2512
+ label: "Messages"
1373
2513
  }
1374
2514
  ];
1375
2515
  const tabId = (t) => `dt-tab-${t}`;
@@ -1377,10 +2517,14 @@ const panelId = (t) => `dt-panel-${t}`;
1377
2517
  function Body(props) {
1378
2518
  const ctx = useIsolate();
1379
2519
  const [tab, setTab] = d("isolates");
2520
+ const [isoSub, setIsoSub] = d("isolates");
2521
+ const [busSub, setBusSub] = d("topics");
1380
2522
  A(() => {
1381
2523
  ctx.styles(CSS);
1382
2524
  }, []);
1383
2525
  const { snap } = props;
2526
+ const [, setAcks] = d(0);
2527
+ const eventProblems = props.recorder.unacknowledged();
1384
2528
  const buttons = T({});
1385
2529
  const onKey = (e) => {
1386
2530
  const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
@@ -1393,41 +2537,117 @@ function Body(props) {
1393
2537
  if (el !== void 0) ctx.host.focus(el).catch(() => void 0);
1394
2538
  };
1395
2539
  let view;
2540
+ let subBar = null;
2541
+ let subGroup = "";
2542
+ let subValue = "";
1396
2543
  if (!snap) view = /* @__PURE__ */ a("p", {
1397
2544
  class: "dt-view dt-muted",
1398
2545
  children: "Waiting for the inspection feed…"
1399
2546
  });
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;
2547
+ else if (tab === "bus") {
2548
+ const m = snap.bus.metrics;
2549
+ const items = m ? [
2550
+ {
2551
+ id: "topics",
2552
+ label: "Topics",
2553
+ count: m.topics.length
1411
2554
  },
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);
2555
+ {
2556
+ id: "subscriptions",
2557
+ label: "Subscriptions",
2558
+ count: m.subscriptions.length
1422
2559
  },
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
- })] });
2560
+ {
2561
+ id: "rejected",
2562
+ label: "Rejected",
2563
+ count: Object.values(m.rejected).reduce((n, v) => n + (typeof v === "number" ? v : 0), 0)
2564
+ }
2565
+ ] : [];
2566
+ subGroup = "bus";
2567
+ subValue = busSub;
2568
+ if (items.length > 0) subBar = /* @__PURE__ */ a(SubTabs, {
2569
+ group: "bus",
2570
+ label: "Bus views",
2571
+ items,
2572
+ value: busSub,
2573
+ onChange: setBusSub
2574
+ });
2575
+ view = /* @__PURE__ */ a(BusView, {
2576
+ bus: snap.bus,
2577
+ sub: busSub
2578
+ });
2579
+ } else if (tab === "events") view = /* @__PURE__ */ a(EventsView, {
2580
+ recorder: props.recorder,
2581
+ onAck: () => {
2582
+ setAcks((n) => n + 1);
2583
+ }
2584
+ });
2585
+ else if (tab === "messages") view = /* @__PURE__ */ a(MessagesView, {});
2586
+ else {
2587
+ const hasPools = snap.pools.length > 0;
2588
+ const sub = hasPools ? isoSub : "isolates";
2589
+ const items = [{
2590
+ id: "isolates",
2591
+ label: "Isolates",
2592
+ count: snap.isolates.length
2593
+ }, ...hasPools ? [{
2594
+ id: "pools",
2595
+ label: "Pools",
2596
+ count: snap.pools.length
2597
+ }] : []];
2598
+ subGroup = "isolates";
2599
+ subValue = sub;
2600
+ if (hasPools) subBar = /* @__PURE__ */ a(SubTabs, {
2601
+ group: "isolates",
2602
+ label: "Isolates views",
2603
+ items,
2604
+ value: sub,
2605
+ onChange: setIsoSub
2606
+ });
2607
+ view = /* @__PURE__ */ a(IsolatesView, {
2608
+ snap,
2609
+ sub
2610
+ });
2611
+ }
2612
+ return /* @__PURE__ */ a("div", {
2613
+ class: "dt-root",
2614
+ children: [/* @__PURE__ */ a("div", {
2615
+ class: "dt-nav",
2616
+ children: [/* @__PURE__ */ a("div", {
2617
+ class: "dt-tabs",
2618
+ role: "tablist",
2619
+ "aria-label": "Devtools views",
2620
+ onKeyDown: onKey,
2621
+ children: TABS.map((t) => /* @__PURE__ */ a("button", {
2622
+ ref: (el) => {
2623
+ buttons.current[t.id] = el ?? void 0;
2624
+ },
2625
+ id: tabId(t.id),
2626
+ type: "button",
2627
+ role: "tab",
2628
+ "data-tab": t.id,
2629
+ "aria-selected": tab === t.id ? "true" : "false",
2630
+ "aria-controls": panelId(t.id),
2631
+ tabindex: tab === t.id ? 0 : -1,
2632
+ class: "dt-tab",
2633
+ onClick: () => {
2634
+ setTab(t.id);
2635
+ },
2636
+ children: [t.label, t.id === "events" && eventProblems > 0 ? /* @__PURE__ */ a("span", {
2637
+ class: "dt-badge dt-badge-warn",
2638
+ title: "Problem events you haven't acknowledged",
2639
+ children: eventProblems > 99 ? "99+" : eventProblems
2640
+ }) : null]
2641
+ }, t.id))
2642
+ }), subBar]
2643
+ }), /* @__PURE__ */ a("div", {
2644
+ class: tab === "messages" || tab === "events" ? "dt-scroll dt-scroll-fill" : "dt-scroll",
2645
+ role: "tabpanel",
2646
+ id: subBar ? subPanelId(subGroup) : panelId(tab),
2647
+ "aria-labelledby": subBar ? subId(subGroup, subValue) : tabId(tab),
2648
+ children: view
2649
+ })]
2650
+ });
1431
2651
  }
1432
2652
  // src/panel.tsx
1433
2653
  const POSITIONS = [
@@ -1439,7 +2659,15 @@ const POSITIONS = [
1439
2659
  const MIN_WIDTH = 280;
1440
2660
  const MIN_HEIGHT = 160;
1441
2661
  const GAP = 12;
2662
+ /** The open panel docks flush to the viewport edges, so it can be dragged to the very edge. */
2663
+ const DOCK_GAP = 0;
2664
+ /** Isoloop one-colour mark (logo exploration 6-cube v108), traced to a path. */
2665
+ const MARK = "M33.9 79.4L31.7 79.4L28.4 79.2L26.3 78.8L23.5 78.1L19.9 76.6L17.1 75.0L15.2 73.7L12.5 71.4L10.6 69.3L9.1 67.3L7.7 65.0L6.6 62.1L5.9 59.7L5.4 56.7L5.2 53.3L0.1 53.2L5.4 43.7L6.0 40.3L6.9 36.7L7.9 33.8L9.2 30.7L11.1 27.0L13.9 22.9L15.5 20.8L17.6 18.4L19.9 16.2L24.2 12.7L26.7 11.0L30.5 8.9L33.9 7.4L38.6 5.7L42.9 4.8L47.5 4.3L51.6 4.2L55.2 4.5L59.2 5.2L63.8 6.5L67.3 7.9L71.6 10.1L75.4 12.5L77.7 14.3L80.1 16.5L83.3 19.8L84.9 21.8L87.1 25.0L89.7 29.6L90.9 32.3L92.3 36.0L93.1 38.8L93.8 42.0L94.3 45.9L99.7 46.1L94.4 55.9L93.2 60.7L91.6 65.4L91.6 65.5L91.1 64.8L80.0 46.2L86.0 46.1L85.9 43.7L85.5 41.3L84.8 38.3L84.2 36.4L83.4 34.2L82.0 31.0L80.2 27.8L79.0 26.1L77.7 24.4L75.7 22.1L72.1 18.8L68.7 16.3L66.4 15.0L64.2 13.9L59.9 12.3L56.3 11.5L53.7 11.1L51.6 10.9L48.7 10.9L46.3 11.0L41.5 11.9L37.6 13.1L33.7 14.7L30.7 16.3L26.5 19.4L23.9 21.7L20.8 25.1L18.3 28.5L16.5 31.8L15.5 34.2L14.4 37.6L13.8 40.1L13.5 43.5L13.7 44.0L19.3 53.1L19.2 53.2L13.5 53.3L13.1 53.4L13.3 55.3L14.1 58.4L15.3 61.4L16.6 63.6L18.4 65.9L21.0 68.3L23.7 70.0L25.9 71.0L27.2 71.4L30.2 71.9L32.1 72.1L34.7 71.9L36.7 71.7L38.9 71.1L41.0 70.5L42.6 69.8L44.5 68.7L46.1 67.6L46.9 66.9L48.5 65.0L49.4 63.2L50.0 61.4L50.2 59.5L50.3 51.2L77.6 35.1L77.7 36.5L77.8 65.2L77.7 65.4L72.0 68.8L71.4 69.1L71.3 69.0L71.1 65.9L70.4 62.0L70.3 47.3L70.1 47.2L57.1 54.8L57.0 62.0L56.9 63.3L56.5 65.2L55.7 67.4L54.6 69.5L53.1 71.4L51.8 72.6L49.8 74.2L47.6 75.6L45.7 76.6L43.0 77.7L38.4 78.9ZM32.8 39.5L30.1 38.1L23.1 33.9L24.4 33.1L49.9 18.0L69.9 29.5L69.1 30.0L62.6 33.8L50.1 26.5L42.6 30.6L38.9 33.0L37.5 34.1L35.2 36.3ZM30.2 60.9L30.0 60.9L30.0 51.5L30.2 49.0L30.6 46.7L31.1 45.0L31.8 43.2L32.9 41.0L35.1 37.9L36.9 35.9L38.5 34.5L42.3 31.9L49.5 27.8L49.7 30.0L49.7 35.2L49.6 41.0L44.9 38.4L43.4 39.6L41.6 41.4L39.8 43.7L38.6 45.9L37.8 48.4L37.5 50.7L37.5 52.6L41.1 54.7L41.2 54.9ZM50.6 40.8L50.6 27.9L61.5 34.4L60.5 35.0ZM49.7 50.4L40.3 45.0L40.5 44.4L41.8 42.7L43.7 40.6L44.9 39.6L45.0 39.5L45.8 39.9L49.9 42.3L70.9 30.1L77.5 33.9ZM33.6 71.1L31.4 71.1L22.3 65.5L22.4 34.7L32.2 40.3L31.0 42.7L30.2 44.8L29.5 47.4L29.2 48.9L29.0 51.4L29.1 61.8L39.0 67.7L41.4 69.2L40.1 69.8L37.4 70.6L35.1 71.0ZM42.9 68.5L42.6 68.6L42.5 68.2L42.6 54.6L38.4 52.0L38.6 49.0L39.0 47.6L39.7 45.8L49.3 51.4L49.3 59.7L49.0 61.4L48.6 62.7L47.7 64.6L46.8 65.6L45.2 67.2ZM69.4 61.3L58.5 55.0L69.3 48.7L69.4 48.8L69.4 48.9L69.5 58.3L69.5 61.2ZM41.6 68.0L41.4 68.0L40.4 67.4L30.9 61.9L30.8 61.7L41.6 55.8ZM56.1 69.2L55.9 69.3L55.8 69.2L56.7 67.6L57.3 65.8L57.9 63.2L58.0 60.9L58.0 56.0L58.1 55.9L58.6 56.2L68.6 62.0L68.6 62.1ZM52.8 95.6L46.0 95.6L43.1 95.3L39.3 94.7L35.8 93.7L33.2 92.7L31.2 91.8L27.6 89.9L24.4 87.7L22.2 86.0L19.3 83.3L17.5 81.4L15.6 79.1L13.5 76.1L11.3 72.6L10.2 70.5L10.3 70.5L12.2 72.4L14.3 74.1L18.5 77.0L22.6 78.7L25.0 79.4L28.2 80.0L31.8 82.6L35.8 84.6L38.6 85.7L42.4 86.6L46.4 87.0L49.3 86.9L51.8 86.4L53.9 85.5L55.9 84.2L58.2 82.0L59.4 80.3L60.3 78.7L61.5 75.3L61.9 72.9L62.0 71.4L61.9 69.0L61.6 67.3L69.5 62.7L69.8 64.0L70.3 67.6L70.4 70.4L70.2 73.0L69.8 75.6L69.3 77.6L68.4 80.1L67.2 82.2L64.8 85.6L62.7 87.7L60.4 89.6L58.1 91.1L56.3 92.1L53.2 93.4L49.7 94.5L50.3 94.5L51.7 94.4L54.4 93.7L57.7 92.3L60.3 90.9L62.9 88.9L64.5 87.4L66.2 85.5L67.8 83.2L68.8 81.4L72.0 78.9L75.4 75.7L78.1 72.4L81.1 68.0L83.6 63.1L84.7 60.3L85.6 57.5L91.1 66.7L89.0 71.1L87.1 74.2L84.5 77.9L82.4 80.5L78.8 84.2L75.5 86.9L72.0 89.3L69.1 91.0L64.8 92.9L60.7 94.2L56.2 95.2ZM50.6 81.7L50.6 74.8L52.9 72.9L54.7 71.0L60.7 67.7L61.0 69.5L61.1 71.6L60.9 73.9L60.5 75.4ZM49.7 82.3L49.4 82.3L45.6 80.1L43.2 78.6L46.9 77.0L49.7 75.5Z";
1442
2666
  const font = "font:12px/1.4 ui-sans-serif,system-ui,sans-serif;";
2667
+ const configStatus = (config) => {
2668
+ const v = typeof config === "object" && config !== null ? Reflect.get(config, "healthStatus") : void 0;
2669
+ return v === "radar" || v === "off" ? v : "ring";
2670
+ };
1443
2671
  const configPosition = (config) => {
1444
2672
  const p = typeof config === "object" && config !== null ? Reflect.get(config, "position") : void 0;
1445
2673
  return POSITIONS.find((x) => x === p) ?? "bottom-right";
@@ -1448,59 +2676,248 @@ const configPosition = (config) => {
1448
2676
  * CSS placing a box in `position`'s corner of the viewport. Fixed, not
1449
2677
  * absolute: the compositor's own element in the surface has no height.
1450
2678
  */
1451
- const corner = (position) => {
2679
+ const corner = (position, gap = GAP) => {
1452
2680
  const [v, h] = position.split("-");
1453
- return `position:fixed;${v}:${GAP}px;${h}:${GAP}px;`;
2681
+ return `position:fixed;${v}:${gap}px;${h}:${gap}px;`;
2682
+ };
2683
+ /**
2684
+ * The panel's size. Stretched or maximized, it is pinned to both edges instead
2685
+ * of given the viewport's width: `100vw` counts the page's scrollbar, so the
2686
+ * panel would run a few pixels past the window.
2687
+ */
2688
+ const OPPOSITE = {
2689
+ left: "right",
2690
+ right: "left",
2691
+ top: "bottom",
2692
+ bottom: "top"
1454
2693
  };
1455
- const DOT = {
1456
- ok: void 0,
2694
+ const fill = (ui) => {
2695
+ const [v, h] = ui.position.split("-");
2696
+ return `${ui.mode !== "normal" ? `${OPPOSITE[h ?? ""] ?? "left"}:0;` : ""}${ui.mode === "max" ? `${OPPOSITE[v ?? ""] ?? "top"}:0;` : ""}${ui.mode === "normal" ? `width:${ui.width}px;` : "width:auto;"}${ui.mode === "max" ? "height:auto;" : `height:${ui.height}px;`}max-width:100%;max-height:100%;`;
2697
+ };
2698
+ /** The closed button: a round tile of 70px, the mark inside at 58px. */
2699
+ const FAB_SIZE = 70;
2700
+ const FAB_MARK = 46;
2701
+ /** The ring's thickness: it sits on the button's outer edge, with nothing outside it. */
2702
+ const RING_WIDTH = 4;
2703
+ /** Seconds for the wave to go once around the ring. */
2704
+ const RING_PERIOD = 2.4;
2705
+ /**
2706
+ * The wave: every arc brightens and dims on the same clock, each a step behind
2707
+ * the last (the delays are set per arc), so brightness runs round the ring. The
2708
+ * colour is animated, not the opacity, so where two arcs overlap by a hair no
2709
+ * seam shows. A failing arc pulses faster; a grey one sits still. Reduced
2710
+ * motion: no motion.
2711
+ */
2712
+ const RING_CSS = `
2713
+ @keyframes dt-flow-ok { 0%, 100% { stroke: #15803d; } 50% { stroke: #22c55e; } }
2714
+ @keyframes dt-flow-unwell { 0%, 100% { stroke: #a16207; } 50% { stroke: #f59e0b; } }
2715
+ @keyframes dt-alarm { 0%, 100% { stroke: #ef4444; } 50% { stroke: #7f1d1d; } }
2716
+ @keyframes dt-fill-ok { 0%, 100% { fill: #15803d; } 50% { fill: #4ade80; } }
2717
+ @keyframes dt-fill-unwell { 0%, 100% { fill: #a16207; } 50% { fill: #fbbf24; } }
2718
+ @keyframes dt-fill-alarm { 0%, 100% { fill: #ef4444; } 50% { fill: #7f1d1d; } }
2719
+ .dt-ring path[data-level="ok"] { animation: dt-flow-ok ${RING_PERIOD}s ease-in-out infinite; }
2720
+ .dt-ring path[data-level="unwell"] { animation: dt-flow-unwell ${RING_PERIOD}s ease-in-out infinite; }
2721
+ .dt-ring path[data-level="failed"] { animation: dt-alarm 0.9s ease-in-out infinite; }
2722
+ .dt-mark path[data-level="ok"] { animation: dt-fill-ok ${RING_PERIOD}s ease-in-out infinite; }
2723
+ .dt-mark path[data-level="unwell"] { animation: dt-fill-unwell ${RING_PERIOD}s ease-in-out infinite; }
2724
+ .dt-mark path[data-level="failed"] { animation: dt-fill-alarm 0.9s ease-in-out infinite; }
2725
+ @media (prefers-reduced-motion: reduce) {
2726
+ .dt-ring path, .dt-mark path { animation: none; }
2727
+ }
2728
+ `;
2729
+ const LEVEL_COLOR = {
2730
+ ok: "#22c55e",
1457
2731
  unwell: "#f59e0b",
1458
- failed: "#dc2626"
2732
+ failed: "#ef4444",
2733
+ unknown: "#334155"
2734
+ };
2735
+ const STEP = {
2736
+ "bottom-left": {
2737
+ horizontal: "bottom-right",
2738
+ vertical: "top-left"
2739
+ },
2740
+ "bottom-right": {
2741
+ horizontal: "bottom-left",
2742
+ vertical: "top-right"
2743
+ },
2744
+ "top-left": {
2745
+ horizontal: "top-right",
2746
+ vertical: "bottom-left"
2747
+ },
2748
+ "top-right": {
2749
+ horizontal: "top-left",
2750
+ vertical: "bottom-right"
2751
+ }
1459
2752
  };
2753
+ /** The corner one step across (`horizontal`) or up or down (`vertical`) from `position`. */
2754
+ const stepPosition = (position, axis) => STEP[position][axis];
2755
+ const ARROW = 24;
2756
+ const ARROW_GAP = 4;
2757
+ /** Chevron paths on the 14 px icon grid. */
2758
+ const CHEVRON = {
2759
+ left: "M8.5 3 4.5 7l4 4",
2760
+ right: "M5.5 3l4 4-4 4",
2761
+ up: "M3 8.5l4-4 4 4",
2762
+ down: "M3 5.5l4 4 4-4"
2763
+ };
2764
+ const arrowStyle = `position:absolute;width:${ARROW}px;height:${ARROW}px;padding:0;border-radius:${ARROW / 2}px;display:flex;align-items:center;justify-content:center;border:1px solid #374151;background:#111827;color:#e5e7eb;cursor:pointer;box-shadow:0 2px 6px rgb(0 0 0 / 0.5);`;
1460
2765
  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"
2766
+ const [hover, setHover] = d(false);
2767
+ const [v, h] = props.position.split("-");
2768
+ const toH = stepPosition(props.position, "horizontal");
2769
+ const toV = stepPosition(props.position, "vertical");
2770
+ const chevH = h === "left" ? CHEVRON.right : CHEVRON.left;
2771
+ const chevV = v === "top" ? CHEVRON.down : CHEVRON.up;
2772
+ const mid = 23;
2773
+ const offH = h === "left" ? 74 : -28;
2774
+ const offV = v === "top" ? 74 : -28;
2775
+ const bridgeH = h === "left" ? FAB_SIZE : -4;
2776
+ const bridgeV = v === "top" ? FAB_SIZE : -4;
2777
+ return /* @__PURE__ */ a(M, { children: [hover ? /* @__PURE__ */ a("div", {
2778
+ "data-isoloop-devtools-fab-away": "",
2779
+ onPointerMove: () => {
2780
+ setHover(false);
2781
+ },
2782
+ onPointerDown: () => {
2783
+ setHover(false);
2784
+ },
2785
+ style: "position:fixed;inset:0;pointer-events:auto;z-index:0;"
2786
+ }) : null, /* @__PURE__ */ a("div", {
2787
+ "data-isoloop-devtools-fab": "",
2788
+ onPointerMove: () => {
2789
+ if (!hover) setHover(true);
2790
+ },
2791
+ style: `${corner(props.position)}pointer-events:auto;z-index:1;width:${FAB_SIZE}px;height:${FAB_SIZE}px;`,
2792
+ children: [/* @__PURE__ */ a("button", {
2793
+ type: "button",
2794
+ "data-isoloop-devtools-toggle": "",
2795
+ "data-health": props.health,
2796
+ "aria-label": `Open Isoloop devtools (Alt+Shift+D)${props.summary ? `. ${props.summary}` : ""}`,
2797
+ title: `Isoloop devtools (Alt+Shift+D)${props.summary ? `\n${props.summary}` : ""}`,
2798
+ onClick: props.onOpen,
2799
+ style: `position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:${FAB_SIZE / 2}px;border:0;background:#111827;box-shadow:0 0 0 3px rgb(0 0 0 / 0.35),0 4px 14px rgb(0 0 0 / 0.7);color:#e5e7eb;cursor:pointer;padding:0;overflow:hidden;${font}`,
2800
+ children: [/* @__PURE__ */ a("svg", {
2801
+ class: "dt-ring",
2802
+ width: FAB_SIZE,
2803
+ height: FAB_SIZE,
2804
+ viewBox: `0 0 ${FAB_SIZE} ${FAB_SIZE}`,
2805
+ "aria-hidden": "true",
2806
+ style: "position:absolute;inset:0;",
2807
+ children: props.status === "off" ? /* @__PURE__ */ a("circle", {
2808
+ cx: FAB_SIZE / 2,
2809
+ cy: FAB_SIZE / 2,
2810
+ r: FAB_SIZE / 2 - RING_WIDTH / 2,
2811
+ fill: "none",
2812
+ stroke: "#f8fafc",
2813
+ "stroke-width": RING_WIDTH
2814
+ }) : props.arcs.map((c, i) => /* @__PURE__ */ a("path", {
2815
+ "data-level": c.level,
2816
+ d: arcPath(i, FAB_SIZE / 2, FAB_SIZE / 2, FAB_SIZE / 2 - RING_WIDTH / 2),
2817
+ stroke: LEVEL_COLOR[c.level],
2818
+ "stroke-width": RING_WIDTH,
2819
+ "stroke-linecap": "butt",
2820
+ fill: "none",
2821
+ style: `animation-delay:-${(i / 12 * RING_PERIOD).toFixed(2)}s;`,
2822
+ children: /* @__PURE__ */ a("title", { children: c.label })
2823
+ }, c.id))
2824
+ }), props.status === "radar" ? /* @__PURE__ */ a("svg", {
2825
+ class: "dt-mark",
2826
+ width: FAB_MARK,
2827
+ height: FAB_MARK,
2828
+ viewBox: "0 0 100 100",
2829
+ "aria-hidden": "true",
2830
+ children: [/* @__PURE__ */ a("defs", { children: /* @__PURE__ */ a("clipPath", {
2831
+ id: "dt-mark-clip",
2832
+ children: /* @__PURE__ */ a("path", {
2833
+ d: MARK,
2834
+ "clip-rule": "evenodd"
2835
+ })
2836
+ }) }), /* @__PURE__ */ a("g", {
2837
+ "clip-path": "url(#dt-mark-clip)",
2838
+ children: props.arcs.map((c, i) => /* @__PURE__ */ a("path", {
2839
+ "data-level": c.level,
2840
+ d: wedgePath(i, 50, 50, 75),
2841
+ fill: LEVEL_COLOR[c.level],
2842
+ style: `animation-delay:-${(i / 12 * RING_PERIOD).toFixed(2)}s;`
2843
+ }, c.id))
2844
+ })]
2845
+ }) : /* @__PURE__ */ a("svg", {
2846
+ width: FAB_MARK,
2847
+ height: FAB_MARK,
2848
+ viewBox: "0 0 100 100",
2849
+ "aria-hidden": "true",
2850
+ children: /* @__PURE__ */ a("path", {
2851
+ d: MARK,
2852
+ fill: "#fff",
2853
+ "fill-rule": "evenodd"
2854
+ })
1487
2855
  })]
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
- });
2856
+ }), hover ? /* @__PURE__ */ a(M, { children: [
2857
+ /* @__PURE__ */ a("span", { style: `position:absolute;left:${bridgeH}px;top:${mid}px;width:${ARROW_GAP}px;height:${ARROW}px;` }),
2858
+ /* @__PURE__ */ a("span", { style: `position:absolute;top:${bridgeV}px;left:${mid}px;width:${ARROW}px;height:${ARROW_GAP}px;` }),
2859
+ /* @__PURE__ */ a("button", {
2860
+ type: "button",
2861
+ "data-isoloop-devtools-move": "horizontal",
2862
+ "aria-label": `Move the button ${h === "left" ? "right" : "left"}`,
2863
+ title: `Move ${h === "left" ? "right" : "left"}`,
2864
+ onClick: () => {
2865
+ props.onMove(toH);
2866
+ },
2867
+ style: `${arrowStyle}top:${mid}px;left:${offH}px;`,
2868
+ children: /* @__PURE__ */ a(Icon, { d: chevH })
2869
+ }),
2870
+ /* @__PURE__ */ a("button", {
2871
+ type: "button",
2872
+ "data-isoloop-devtools-move": "vertical",
2873
+ "aria-label": `Move the button ${v === "top" ? "down" : "up"}`,
2874
+ title: `Move ${v === "top" ? "down" : "up"}`,
2875
+ onClick: () => {
2876
+ props.onMove(toV);
2877
+ },
2878
+ style: `${arrowStyle}top:${offV}px;left:${mid}px;`,
2879
+ children: /* @__PURE__ */ a(Icon, { d: chevV })
2880
+ })
2881
+ ] }) : null]
2882
+ })] });
1493
2883
  }
2884
+ /** A toolbar button: the same 26 px square, its icon centered. */
2885
+ const tool = (active) => `display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;box-sizing:border-box;background:${active ? "#374151" : "none"};border:0;border-radius:4px;color:inherit;cursor:pointer;padding:0;`;
2886
+ const Icon = (props) => /* @__PURE__ */ a("svg", {
2887
+ width: "14",
2888
+ height: "14",
2889
+ viewBox: "0 0 14 14",
2890
+ "aria-hidden": "true",
2891
+ style: "display:block;",
2892
+ children: /* @__PURE__ */ a("path", {
2893
+ d: props.d,
2894
+ fill: "none",
2895
+ stroke: "currentColor",
2896
+ "stroke-width": "1.5",
2897
+ "stroke-linecap": "round",
2898
+ "stroke-linejoin": "round"
2899
+ })
2900
+ });
1494
2901
  function Dock(props) {
1495
2902
  const { ui } = props;
1496
2903
  const [v, h] = ui.position.split("-");
1497
2904
  const [drag, setDrag] = d(void 0);
1498
2905
  const sx = h === "right" ? 1 : -1;
1499
2906
  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))];
2907
+ const sizeAt = (d, x, y) => [d.axis === "y" ? d.width : Math.max(280, Math.round(d.width + (d.x - x) * sx)), d.axis === "x" ? d.height : Math.max(160, Math.round(d.height + (d.y - y) * sy))];
1501
2908
  const handleV = v === "bottom" ? "top" : "bottom";
1502
2909
  const handleH = h === "right" ? "left" : "right";
1503
- const cursor = sx === sy ? "nwse-resize" : "nesw-resize";
2910
+ const cornerCursor = sx === sy ? "nwse-resize" : "nesw-resize";
2911
+ const cursor = drag?.axis === "x" ? "ew-resize" : drag?.axis === "y" ? "ns-resize" : cornerCursor;
2912
+ const start = (axis, e) => {
2913
+ setDrag({
2914
+ x: e.clientX,
2915
+ y: e.clientY,
2916
+ width: ui.width,
2917
+ height: ui.height,
2918
+ axis
2919
+ });
2920
+ };
1504
2921
  return /* @__PURE__ */ a("div", {
1505
2922
  "data-isoloop-devtools-panel": "",
1506
2923
  role: "dialog",
@@ -1508,10 +2925,10 @@ function Dock(props) {
1508
2925
  onKeyDown: (e) => {
1509
2926
  if (e.key === "Escape") props.onClose();
1510
2927
  },
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}`,
2928
+ style: `${corner(ui.position, DOCK_GAP)}${fill(ui)}pointer-events:auto;box-sizing:border-box;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
2929
  children: [
1513
2930
  /* @__PURE__ */ a("div", {
1514
- style: "display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid #374151;",
2931
+ style: "display:flex;align-items:center;gap:4px;padding:6px 12px;border-bottom:1px solid #374151;",
1515
2932
  children: [
1516
2933
  /* @__PURE__ */ a("strong", {
1517
2934
  style: "flex:1;",
@@ -1519,12 +2936,27 @@ function Dock(props) {
1519
2936
  }),
1520
2937
  /* @__PURE__ */ a("button", {
1521
2938
  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: "⤢"
2939
+ "data-isoloop-devtools-stretch": "",
2940
+ "aria-label": "Stretch across the window's width",
2941
+ "aria-pressed": ui.mode === "wide",
2942
+ title: ui.mode === "wide" ? "Restore width" : "Stretch across the width",
2943
+ onClick: () => {
2944
+ props.onMode(ui.mode === "wide" ? "normal" : "wide");
2945
+ },
2946
+ style: tool(ui.mode === "wide"),
2947
+ children: /* @__PURE__ */ a(Icon, { d: "M1.5 7h11M4 4.5 1.5 7 4 9.5M10 4.5 12.5 7 10 9.5" })
2948
+ }),
2949
+ /* @__PURE__ */ a("button", {
2950
+ type: "button",
2951
+ "data-isoloop-devtools-maximize": "",
2952
+ "aria-label": "Fill the window",
2953
+ "aria-pressed": ui.mode === "max",
2954
+ title: ui.mode === "max" ? "Restore size" : "Fill the window",
2955
+ onClick: () => {
2956
+ props.onMode(ui.mode === "max" ? "normal" : "max");
2957
+ },
2958
+ style: tool(ui.mode === "max"),
2959
+ children: /* @__PURE__ */ a(Icon, { d: "M2.5 2.5h9v9h-9z" })
1528
2960
  }),
1529
2961
  /* @__PURE__ */ a("button", {
1530
2962
  type: "button",
@@ -1532,28 +2964,41 @@ function Dock(props) {
1532
2964
  "aria-label": "Close Isoloop devtools (Alt+Shift+D)",
1533
2965
  title: "Close (Alt+Shift+D)",
1534
2966
  onClick: props.onClose,
1535
- style: "background:none;border:0;color:inherit;cursor:pointer;",
1536
- children: "✕"
2967
+ style: tool(false),
2968
+ children: /* @__PURE__ */ a(Icon, { d: "M3 3l8 8M11 3l-8 8" })
1537
2969
  })
1538
2970
  ]
1539
2971
  }),
1540
2972
  /* @__PURE__ */ a("div", {
1541
- style: "flex:1;overflow:auto;",
1542
- children: /* @__PURE__ */ a(Body, { snap: props.snap })
2973
+ style: "flex:1;min-height:0;display:flex;flex-direction:column;",
2974
+ children: /* @__PURE__ */ a(Body, {
2975
+ snap: props.snap,
2976
+ recorder: props.recorder
2977
+ })
1543
2978
  }),
1544
- /* @__PURE__ */ a("div", {
1545
- "data-isoloop-devtools-resize": "",
2979
+ ui.mode === "max" ? null : /* @__PURE__ */ a("div", {
2980
+ "data-isoloop-devtools-resize-y": "",
1546
2981
  "aria-hidden": "true",
1547
2982
  onPointerDown: (e) => {
1548
- setDrag({
1549
- x: e.clientX,
1550
- y: e.clientY,
1551
- width: ui.width,
1552
- height: ui.height
1553
- });
2983
+ start("y", e);
1554
2984
  },
1555
- style: `position:absolute;${handleV}:0;${handleH}:0;width:14px;height:14px;cursor:${cursor};`
2985
+ style: `position:absolute;${handleV}:0;left:0;right:0;height:5px;cursor:ns-resize;`
1556
2986
  }),
2987
+ ui.mode === "normal" ? /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("div", {
2988
+ "data-isoloop-devtools-resize-x": "",
2989
+ "aria-hidden": "true",
2990
+ onPointerDown: (e) => {
2991
+ start("x", e);
2992
+ },
2993
+ style: `position:absolute;${handleH}:0;top:0;bottom:0;width:5px;cursor:ew-resize;`
2994
+ }), /* @__PURE__ */ a("div", {
2995
+ "data-isoloop-devtools-resize": "",
2996
+ "aria-hidden": "true",
2997
+ onPointerDown: (e) => {
2998
+ start("both", e);
2999
+ },
3000
+ style: `position:absolute;${handleV}:0;${handleH}:0;width:14px;height:14px;cursor:${cornerCursor};`
3001
+ })] }) : null,
1557
3002
  drag ? /* @__PURE__ */ a("div", {
1558
3003
  "data-isoloop-devtools-drag": "",
1559
3004
  onPointerMove: (e) => {
@@ -1571,7 +3016,14 @@ function Dock(props) {
1571
3016
  });
1572
3017
  }
1573
3018
  function Panel({ config }) {
1574
- const snap = useFeed(useIsolate().inspector);
3019
+ const ctx = useIsolate();
3020
+ const status = configStatus(config);
3021
+ A(() => {
3022
+ ctx.styles(RING_CSS);
3023
+ }, []);
3024
+ const snap = useFeed(ctx.inspector);
3025
+ const [recorder] = d(createRecorder);
3026
+ A(() => ctx.inspector ? recorder.start(ctx.inspector) : void 0, [ctx.inspector]);
1575
3027
  const [ui, setUi] = d(void 0);
1576
3028
  const latest = T(void 0);
1577
3029
  latest.current = ui;
@@ -1584,6 +3036,7 @@ function Panel({ config }) {
1584
3036
  width: 420,
1585
3037
  height: 320,
1586
3038
  position: configPosition(config),
3039
+ mode: "normal",
1587
3040
  ...stored
1588
3041
  });
1589
3042
  });
@@ -1604,19 +3057,25 @@ function Panel({ config }) {
1604
3057
  if (!ui.open) return /* @__PURE__ */ a(Fab, {
1605
3058
  position: ui.position,
1606
3059
  health: healthOf(snap),
3060
+ arcs: status === "off" ? [] : arcsOf(snap),
3061
+ summary: status === "off" ? "" : summaryOf(arcsOf(snap), checksOf(snap)),
3062
+ status,
1607
3063
  onOpen: () => {
1608
3064
  update({ open: true });
3065
+ },
3066
+ onMove: (position) => {
3067
+ update({ position });
1609
3068
  }
1610
3069
  });
1611
3070
  return /* @__PURE__ */ a(Dock, {
1612
3071
  ui,
1613
3072
  snap,
3073
+ recorder,
1614
3074
  onClose: () => {
1615
3075
  update({ open: false });
1616
3076
  },
1617
- onMove: () => {
1618
- const i = POSITIONS.indexOf(ui.position);
1619
- update({ position: POSITIONS[(i + 1) % POSITIONS.length] ?? "bottom-right" });
3077
+ onMode: (mode) => {
3078
+ update({ mode });
1620
3079
  },
1621
3080
  onResize: (width, height, done) => {
1622
3081
  update({
@@ -1627,4 +3086,4 @@ function Panel({ config }) {
1627
3086
  });
1628
3087
  }
1629
3088
  const panel = defineIsolate(Panel);
1630
- export { MIN_HEIGHT, MIN_WIDTH, panel as default };
3089
+ export { MIN_HEIGHT, MIN_WIDTH, panel as default, stepPosition };