@isoloop/devtools 0.1.0-next.4 → 0.1.0-next.6
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/README.md +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/panel.js +175 -8
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ A devtools panel for Isoloop, drawn by a visual isolate in its own worker, so a
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { connectDevtools } from '@isoloop/devtools';
|
|
7
|
-
// With @isoloop/vite, emit the panel like your own isolates:
|
|
8
|
-
import panel from '@isoloop/devtools/panel?isolate';
|
|
9
7
|
|
|
10
|
-
const disconnect = connectDevtools(kernel, {
|
|
8
|
+
const disconnect = connectDevtools(kernel, { position: 'bottom-right' });
|
|
11
9
|
```
|
|
12
10
|
|
|
11
|
+
With `@isoloop/vite` the default panel URL works in dev and in a build. With another bundler, pass `src`: the URL it serves `@isoloop/devtools/panel` at. See `docs/guide/devtools.md`.
|
|
12
|
+
|
|
13
13
|
Alt+Shift+D opens and closes it. Its open state, size and corner are kept in IndexedDB.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export type DevtoolsPosition = "bottom-right" | "bottom-left" | "top-right" | "t
|
|
|
5
5
|
export type DevtoolsOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* The panel isolate's module URL. Defaults to the `panel.js` next to this
|
|
8
|
-
* module in the published package
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* module in the published package, which `@isoloop/vite` serves in dev and
|
|
9
|
+
* Vite emits in a build. With another bundler, pass the URL it serves
|
|
10
|
+
* `@isoloop/devtools/panel` at.
|
|
11
11
|
*/
|
|
12
12
|
src?: string;
|
|
13
13
|
/** Where the closed button and the opened panel sit. Default `'bottom-right'`. */
|
package/dist/panel.js
CHANGED
|
@@ -64,7 +64,7 @@ function majorMinor(version) {
|
|
|
64
64
|
}
|
|
65
65
|
// ../runtime/dist/index.js
|
|
66
66
|
/** This build's stamp: `major.minor` of the package version, inlined when tsdown bundles it. */
|
|
67
|
-
const REQUIRES = majorMinor("0.1.0-next.
|
|
67
|
+
const REQUIRES = majorMinor("0.1.0-next.6") ?? "0.0";
|
|
68
68
|
// ../../node_modules/.pnpm/preact@11.1.1/node_modules/preact/dist/preact.mjs
|
|
69
69
|
var n;
|
|
70
70
|
var t$1;
|
|
@@ -954,6 +954,156 @@ function BusView(props) {
|
|
|
954
954
|
})]
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
+
/** Splits the filter into tap patterns: `*` (every topic) when empty. */
|
|
958
|
+
const patternsOf = (filter) => {
|
|
959
|
+
const p = filter.split(/[\s,]+/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
960
|
+
return p.length > 0 ? p : ["*"];
|
|
961
|
+
};
|
|
962
|
+
const pad = (n, w = 2) => String(n).padStart(w, "0");
|
|
963
|
+
const time = (ts) => {
|
|
964
|
+
const d = new Date(ts);
|
|
965
|
+
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds(), 3)}`;
|
|
966
|
+
};
|
|
967
|
+
function LogView() {
|
|
968
|
+
const inspector = useIsolate().inspector;
|
|
969
|
+
const [filter, setFilter] = d("");
|
|
970
|
+
const [applied, setApplied] = d(["*"]);
|
|
971
|
+
const [paused, setPaused] = d(false);
|
|
972
|
+
const [entries, setEntries] = d([]);
|
|
973
|
+
const [skipped, setSkipped] = d(0);
|
|
974
|
+
A(() => {
|
|
975
|
+
if (!inspector || paused) return void 0;
|
|
976
|
+
let n = 0;
|
|
977
|
+
const onSkipped = (count) => {
|
|
978
|
+
setSkipped((x) => x + count);
|
|
979
|
+
};
|
|
980
|
+
return inspector.tap({
|
|
981
|
+
topics: applied,
|
|
982
|
+
maxPerSec: 50,
|
|
983
|
+
onSkipped
|
|
984
|
+
}, (r) => {
|
|
985
|
+
n += 1;
|
|
986
|
+
const entry = {
|
|
987
|
+
...r,
|
|
988
|
+
n
|
|
989
|
+
};
|
|
990
|
+
setEntries((prev) => [entry, ...prev].slice(0, 200));
|
|
991
|
+
});
|
|
992
|
+
}, [
|
|
993
|
+
inspector,
|
|
994
|
+
applied,
|
|
995
|
+
paused
|
|
996
|
+
]);
|
|
997
|
+
return /* @__PURE__ */ a("div", {
|
|
998
|
+
class: "dt-view",
|
|
999
|
+
"data-view": "log",
|
|
1000
|
+
children: [
|
|
1001
|
+
/* @__PURE__ */ a("form", {
|
|
1002
|
+
class: "dt-log-bar",
|
|
1003
|
+
onSubmit: (e) => {
|
|
1004
|
+
e.preventDefault();
|
|
1005
|
+
setApplied(patternsOf(filter));
|
|
1006
|
+
},
|
|
1007
|
+
children: [
|
|
1008
|
+
/* @__PURE__ */ a("input", {
|
|
1009
|
+
type: "text",
|
|
1010
|
+
"aria-label": "Topics to log, as patterns (empty for every topic)",
|
|
1011
|
+
placeholder: "Topics, e.g. orders.* (empty: all)",
|
|
1012
|
+
value: filter,
|
|
1013
|
+
"data-log-filter": "",
|
|
1014
|
+
onInput: (e) => {
|
|
1015
|
+
setFilter(e.currentTarget.value);
|
|
1016
|
+
}
|
|
1017
|
+
}),
|
|
1018
|
+
/* @__PURE__ */ a("button", {
|
|
1019
|
+
type: "submit",
|
|
1020
|
+
"data-log-apply": "",
|
|
1021
|
+
children: "Apply"
|
|
1022
|
+
}),
|
|
1023
|
+
/* @__PURE__ */ a("button", {
|
|
1024
|
+
type: "button",
|
|
1025
|
+
"data-log-pause": "",
|
|
1026
|
+
"aria-pressed": paused ? "true" : "false",
|
|
1027
|
+
onClick: () => {
|
|
1028
|
+
setPaused((p) => !p);
|
|
1029
|
+
},
|
|
1030
|
+
children: paused ? "Resume" : "Pause"
|
|
1031
|
+
}),
|
|
1032
|
+
/* @__PURE__ */ a("button", {
|
|
1033
|
+
type: "button",
|
|
1034
|
+
"data-log-clear": "",
|
|
1035
|
+
onClick: () => {
|
|
1036
|
+
setEntries([]);
|
|
1037
|
+
},
|
|
1038
|
+
children: "Clear"
|
|
1039
|
+
})
|
|
1040
|
+
]
|
|
1041
|
+
}),
|
|
1042
|
+
/* @__PURE__ */ a("p", {
|
|
1043
|
+
class: "dt-muted",
|
|
1044
|
+
style: "margin:4px 0;",
|
|
1045
|
+
children: [
|
|
1046
|
+
paused ? "Paused" : `Tapping ${applied.join(", ")}`,
|
|
1047
|
+
" · newest first ·",
|
|
1048
|
+
" ",
|
|
1049
|
+
/* @__PURE__ */ a("span", {
|
|
1050
|
+
"data-log-skipped": skipped,
|
|
1051
|
+
children: [
|
|
1052
|
+
50,
|
|
1053
|
+
"/s cap · ",
|
|
1054
|
+
skipped,
|
|
1055
|
+
" skipped"
|
|
1056
|
+
]
|
|
1057
|
+
})
|
|
1058
|
+
]
|
|
1059
|
+
}),
|
|
1060
|
+
entries.length === 0 ? /* @__PURE__ */ a("p", {
|
|
1061
|
+
class: "dt-muted",
|
|
1062
|
+
children: "No records yet."
|
|
1063
|
+
}) : /* @__PURE__ */ a("table", {
|
|
1064
|
+
class: "dt-table",
|
|
1065
|
+
"data-log-table": "",
|
|
1066
|
+
children: [/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: [
|
|
1067
|
+
/* @__PURE__ */ a("th", { children: "Time" }),
|
|
1068
|
+
/* @__PURE__ */ a("th", { children: "Topic" }),
|
|
1069
|
+
/* @__PURE__ */ a("th", {
|
|
1070
|
+
class: "dt-num",
|
|
1071
|
+
children: "Offset"
|
|
1072
|
+
}),
|
|
1073
|
+
/* @__PURE__ */ a("th", { children: "Key" }),
|
|
1074
|
+
/* @__PURE__ */ a("th", { children: "Producer" }),
|
|
1075
|
+
/* @__PURE__ */ a("th", {
|
|
1076
|
+
class: "dt-num",
|
|
1077
|
+
children: "Size"
|
|
1078
|
+
}),
|
|
1079
|
+
/* @__PURE__ */ a("th", { children: "Value" })
|
|
1080
|
+
] }) }), /* @__PURE__ */ a("tbody", { children: entries.map((r) => /* @__PURE__ */ a("tr", {
|
|
1081
|
+
"data-log-topic": r.topic,
|
|
1082
|
+
"data-offset": r.offset,
|
|
1083
|
+
children: [
|
|
1084
|
+
/* @__PURE__ */ a("td", { children: time(r.ts) }),
|
|
1085
|
+
/* @__PURE__ */ a("td", { children: /* @__PURE__ */ a("code", { children: r.topic }) }),
|
|
1086
|
+
/* @__PURE__ */ a("td", {
|
|
1087
|
+
class: "dt-num",
|
|
1088
|
+
children: r.offset
|
|
1089
|
+
}),
|
|
1090
|
+
/* @__PURE__ */ a("td", { children: r.key ?? "" }),
|
|
1091
|
+
/* @__PURE__ */ a("td", { children: r.producer }),
|
|
1092
|
+
/* @__PURE__ */ a("td", {
|
|
1093
|
+
class: "dt-num",
|
|
1094
|
+
children: [r.bytes, " B"]
|
|
1095
|
+
}),
|
|
1096
|
+
/* @__PURE__ */ a("td", {
|
|
1097
|
+
class: "dt-value",
|
|
1098
|
+
title: r.truncated ? "Cut to a 2 KB preview" : "",
|
|
1099
|
+
children: /* @__PURE__ */ a("code", { children: [r.preview, r.truncated ? "…" : ""] })
|
|
1100
|
+
})
|
|
1101
|
+
]
|
|
1102
|
+
}, `${r.topic} ${r.offset} ${r.n}`)) })]
|
|
1103
|
+
})
|
|
1104
|
+
]
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
957
1107
|
// src/views.tsx
|
|
958
1108
|
/** How long the block control busy-loops an isolate's worker. */
|
|
959
1109
|
const BLOCK_MS = 2e3;
|
|
@@ -984,6 +1134,15 @@ const CSS = `
|
|
|
984
1134
|
.dt-status { margin: 6px 0 0; color: #fca5a5; }
|
|
985
1135
|
.dt-h { margin: 10px 0 4px; font-size: 12px; color: #9ca3af; }
|
|
986
1136
|
.dt-warning { color: #fcd34d; }
|
|
1137
|
+
.dt-state-none { color: #9ca3af; }
|
|
1138
|
+
.dt-log-bar { display: flex; gap: 4px; }
|
|
1139
|
+
.dt-log-bar input { flex: 1; min-width: 0; background: #0b1220; color: #e5e7eb;
|
|
1140
|
+
border: 1px solid #374151; border-radius: 4px; font: inherit; padding: 2px 6px; }
|
|
1141
|
+
.dt-log-bar button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
|
|
1142
|
+
border-radius: 4px; font: inherit; font-size: 11px; padding: 1px 8px; cursor: pointer; }
|
|
1143
|
+
.dt-log-bar input:focus-visible, .dt-log-bar button:focus-visible { outline: 2px solid #60a5fa;
|
|
1144
|
+
outline-offset: 1px; }
|
|
1145
|
+
.dt-table td.dt-value { white-space: normal; word-break: break-all; max-width: 40ch; }
|
|
987
1146
|
`;
|
|
988
1147
|
const ms = (n) => n === void 0 ? "–" : `${Math.round(n)} ms`;
|
|
989
1148
|
const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
|
|
@@ -1199,13 +1358,20 @@ function IsolatesView(props) {
|
|
|
1199
1358
|
]
|
|
1200
1359
|
});
|
|
1201
1360
|
}
|
|
1202
|
-
const TABS = [
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1361
|
+
const TABS = [
|
|
1362
|
+
{
|
|
1363
|
+
id: "isolates",
|
|
1364
|
+
label: "Isolates"
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
id: "bus",
|
|
1368
|
+
label: "Bus"
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
id: "log",
|
|
1372
|
+
label: "Log"
|
|
1373
|
+
}
|
|
1374
|
+
];
|
|
1209
1375
|
const tabId = (t) => `dt-tab-${t}`;
|
|
1210
1376
|
const panelId = (t) => `dt-panel-${t}`;
|
|
1211
1377
|
function Body(props) {
|
|
@@ -1232,6 +1398,7 @@ function Body(props) {
|
|
|
1232
1398
|
children: "Waiting for the inspection feed…"
|
|
1233
1399
|
});
|
|
1234
1400
|
else if (tab === "bus") view = /* @__PURE__ */ a(BusView, { bus: snap.bus });
|
|
1401
|
+
else if (tab === "log") view = /* @__PURE__ */ a(LogView, {});
|
|
1235
1402
|
else view = /* @__PURE__ */ a(IsolatesView, { snap });
|
|
1236
1403
|
return /* @__PURE__ */ a(M, { children: [/* @__PURE__ */ a("div", {
|
|
1237
1404
|
class: "dt-tabs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoloop/devtools",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.6",
|
|
4
4
|
"description": "Devtools panel for Isoloop, drawn by an isolate of its own and fed by the inspection feed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@isoloop/host": "0.1.0-next.
|
|
26
|
+
"@isoloop/host": "0.1.0-next.6"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@isoloop/preact": "0.1.0-next.
|
|
30
|
-
"@isoloop/protocol": "0.1.0-next.
|
|
31
|
-
"@isoloop/runtime": "0.1.0-next.
|
|
29
|
+
"@isoloop/preact": "0.1.0-next.6",
|
|
30
|
+
"@isoloop/protocol": "0.1.0-next.6",
|
|
31
|
+
"@isoloop/runtime": "0.1.0-next.6",
|
|
32
32
|
"typescript": "7.0.2"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|