@typeonce/ritmo-devtools 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +283 -0
- package/README.md +303 -55
- package/dist/Desync.d.ts +23 -3
- package/dist/Desync.d.ts.map +1 -1
- package/dist/Desync.js +17 -15
- package/dist/Desync.js.map +1 -1
- package/dist/Determinism.d.ts +20 -6
- package/dist/Determinism.d.ts.map +1 -1
- package/dist/Determinism.js +11 -3
- package/dist/Determinism.js.map +1 -1
- package/dist/Format.d.ts +43 -8
- package/dist/Format.d.ts.map +1 -1
- package/dist/Format.js +66 -31
- package/dist/Format.js.map +1 -1
- package/dist/Fuzz.d.ts +275 -0
- package/dist/Fuzz.d.ts.map +1 -0
- package/dist/Fuzz.js +362 -0
- package/dist/Fuzz.js.map +1 -0
- package/dist/Invariant.d.ts +9 -2
- package/dist/Invariant.d.ts.map +1 -1
- package/dist/Invariant.js.map +1 -1
- package/dist/Lint.d.ts +11 -5
- package/dist/Lint.d.ts.map +1 -1
- package/dist/Lint.js.map +1 -1
- package/dist/PlaywrightEngine.d.ts +29 -0
- package/dist/PlaywrightEngine.d.ts.map +1 -0
- package/dist/PlaywrightEngine.js +196 -0
- package/dist/PlaywrightEngine.js.map +1 -0
- package/dist/Replay.d.ts +47 -23
- package/dist/Replay.d.ts.map +1 -1
- package/dist/Replay.js +26 -30
- package/dist/Replay.js.map +1 -1
- package/dist/ReplayNodeSink.d.ts.map +1 -1
- package/dist/ReplayNodeSink.js +4 -1
- package/dist/ReplayNodeSink.js.map +1 -1
- package/dist/ReplayVitePlugin.d.ts +1 -0
- package/dist/ReplayVitePlugin.d.ts.map +1 -1
- package/dist/ReplayVitePlugin.js.map +1 -1
- package/dist/Session.d.ts +224 -18
- package/dist/Session.d.ts.map +1 -1
- package/dist/Session.js +571 -58
- package/dist/Session.js.map +1 -1
- package/dist/Verify.d.ts +150 -0
- package/dist/Verify.d.ts.map +1 -0
- package/dist/Verify.js +154 -0
- package/dist/Verify.js.map +1 -0
- package/dist/cli.js +157 -16
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/dependencyScan.d.ts +44 -0
- package/dist/internal/dependencyScan.d.ts.map +1 -0
- package/dist/internal/dependencyScan.js +313 -0
- package/dist/internal/dependencyScan.js.map +1 -0
- package/dist/internal/fuzzNetwork.d.ts +56 -0
- package/dist/internal/fuzzNetwork.d.ts.map +1 -0
- package/dist/internal/fuzzNetwork.js +96 -0
- package/dist/internal/fuzzNetwork.js.map +1 -0
- package/dist/internal/simulationCoverage.d.ts.map +1 -1
- package/dist/internal/simulationCoverage.js +2 -1
- package/dist/internal/simulationCoverage.js.map +1 -1
- package/dist/internal/skillLink.d.ts +14 -0
- package/dist/internal/skillLink.d.ts.map +1 -0
- package/dist/internal/skillLink.js +46 -0
- package/dist/internal/skillLink.js.map +1 -0
- package/dist/internal/values.d.ts +9 -1
- package/dist/internal/values.d.ts.map +1 -1
- package/dist/internal/values.js +11 -1
- package/dist/internal/values.js.map +1 -1
- package/dist/internal/verifyRunner.d.ts +19 -0
- package/dist/internal/verifyRunner.d.ts.map +1 -0
- package/dist/internal/verifyRunner.js +47 -0
- package/dist/internal/verifyRunner.js.map +1 -0
- package/dist/internal/version.d.ts +1 -1
- package/dist/internal/version.js +1 -1
- package/package.json +28 -3
- package/src/Desync.ts +40 -17
- package/src/Determinism.ts +49 -11
- package/src/Format.ts +101 -34
- package/src/Fuzz.ts +551 -0
- package/src/Invariant.ts +9 -2
- package/src/Lint.ts +11 -5
- package/src/PlaywrightEngine.ts +232 -0
- package/src/Replay.ts +100 -47
- package/src/ReplayNodeSink.ts +4 -1
- package/src/ReplayVitePlugin.ts +1 -0
- package/src/Session.ts +816 -73
- package/src/Verify.ts +276 -0
- package/src/cli.ts +150 -15
- package/src/index.ts +3 -2
- package/src/internal/dependencyScan.ts +356 -0
- package/src/internal/fuzzNetwork.ts +130 -0
- package/src/internal/simulationCoverage.ts +2 -1
- package/src/internal/skillLink.ts +53 -0
- package/src/internal/values.ts +20 -1
- package/src/internal/verifyRunner.ts +46 -0
- package/src/internal/version.ts +1 -1
- package/dist/Monitor.d.ts +0 -101
- package/dist/Monitor.d.ts.map +0 -1
- package/dist/Monitor.js +0 -602
- package/dist/Monitor.js.map +0 -1
- package/dist/internal/monitor.d.ts +0 -126
- package/dist/internal/monitor.d.ts.map +0 -1
- package/dist/internal/monitor.js +0 -279
- package/dist/internal/monitor.js.map +0 -1
- package/src/Monitor.ts +0 -713
- package/src/internal/monitor.ts +0 -370
package/dist/Monitor.js
DELETED
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import * as Format from "./Format.js";
|
|
2
|
-
import { Collector, recentSchedule, recentSystem } from "./internal/monitor.js";
|
|
3
|
-
/**
|
|
4
|
-
* The numbers behind the panel, without DOM: pass `collector.observe` to
|
|
5
|
-
* `debug.observe`, call `sample(now)` periodically, read `history`, `alerts`,
|
|
6
|
-
* spawn kinds, and the selected entity's changes. Use it for a custom UI or in
|
|
7
|
-
* tests.
|
|
8
|
-
*/
|
|
9
|
-
export { Collector, recentSchedule, recentSystem };
|
|
10
|
-
/** Samples used for "recent" numbers (about two seconds at the default refresh). */
|
|
11
|
-
const RECENT = 8;
|
|
12
|
-
const escape = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13
|
-
const number = (value, digits = 2) => !Number.isFinite(value) ? String(value) : value >= 100 ? value.toFixed(0) : value.toFixed(digits);
|
|
14
|
-
/** The most common `prefix/` among names, stripped for display. */
|
|
15
|
-
const commonPrefix = (names) => {
|
|
16
|
-
const counts = new Map();
|
|
17
|
-
for (const name of names) {
|
|
18
|
-
const slash = name.indexOf("/");
|
|
19
|
-
if (slash > 0)
|
|
20
|
-
counts.set(name.slice(0, slash + 1), (counts.get(name.slice(0, slash + 1)) ?? 0) + 1);
|
|
21
|
-
}
|
|
22
|
-
let best = "";
|
|
23
|
-
let bestCount = 0;
|
|
24
|
-
for (const [prefix, count] of counts) {
|
|
25
|
-
if (count > bestCount) {
|
|
26
|
-
best = prefix;
|
|
27
|
-
bestCount = count;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return bestCount >= names.length / 2 ? best : "";
|
|
31
|
-
};
|
|
32
|
-
const sparkline = (values, width = 96, height = 18) => {
|
|
33
|
-
if (values.length < 2)
|
|
34
|
-
return `<svg class="btm-spark" width="${width}" height="${height}"></svg>`;
|
|
35
|
-
const max = Math.max(...values);
|
|
36
|
-
const min = Math.min(...values);
|
|
37
|
-
const span = max - min || 1;
|
|
38
|
-
const points = values.map((value, index) => `${((index / (values.length - 1)) * width).toFixed(1)},${(height - 2 - ((value - min) / span) * (height - 4)).toFixed(1)}`);
|
|
39
|
-
return `<svg class="btm-spark" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><polyline points="${points.join(" ")}"/></svg>`;
|
|
40
|
-
};
|
|
41
|
-
const statusOf = (window) => window.failures > 0 ? "failed"
|
|
42
|
-
: window.runs > 0 && window.writes + window.events + window.commands + window.spawns + window.despawns > 0 ? "active"
|
|
43
|
-
: window.runs > 0 ? "idle"
|
|
44
|
-
: window.skips > 0 ? "skipped"
|
|
45
|
-
: "stopped";
|
|
46
|
-
const statusText = {
|
|
47
|
-
failed: "failed recently",
|
|
48
|
-
active: "running and changing things",
|
|
49
|
-
idle: "running, changing nothing right now",
|
|
50
|
-
skipped: "skipped by its run condition",
|
|
51
|
-
stopped: "not running (other schedule, or never scheduled now)"
|
|
52
|
-
};
|
|
53
|
-
const accessOf = (system) => {
|
|
54
|
-
const unique = (values) => [...new Set(values)];
|
|
55
|
-
const writes = unique(system.queries.flatMap((query) => query.writes));
|
|
56
|
-
return {
|
|
57
|
-
reads: unique(system.queries.flatMap((query) => [...query.reads, ...query.optional, ...query.added, ...query.changed, ...query.anyOf.flatMap((members) => [...members.added, ...members.changed])])).filter((name) => !writes.includes(name)),
|
|
58
|
-
writes,
|
|
59
|
-
resourceReads: system.resources.reads.filter((name) => !system.resources.writes.includes(name)),
|
|
60
|
-
resourceWrites: system.resources.writes,
|
|
61
|
-
eventReads: system.events.reads,
|
|
62
|
-
eventWrites: system.events.writes,
|
|
63
|
-
machineReads: system.machines.reads.filter((name) => !system.machines.next.includes(name)),
|
|
64
|
-
machineWrites: [...system.machines.next, ...system.machines.updates]
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const STYLE = `
|
|
68
|
-
.btm { font: 12px/1.35 "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; color: #e6edf3; }
|
|
69
|
-
.btm-toggle { position: fixed; left: 12px; bottom: 12px; z-index: 2147483000; font: inherit; font-size: 11px; color: #9da7b3; background: rgba(13,17,23,.85); border: 1px solid #30363d; border-radius: 12px; padding: 3px 10px; cursor: pointer; }
|
|
70
|
-
.btm-toggle:hover { color: #e6edf3; border-color: #4ecdc4; }
|
|
71
|
-
.btm-panel { position: fixed; top: 12px; left: 12px; bottom: 44px; width: 440px; z-index: 2147483000; display: flex; flex-direction: column; background: rgba(13,17,23,.95); border: 1px solid #30363d; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
|
|
72
|
-
.btm-panel[hidden] { display: none; }
|
|
73
|
-
.btm-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #30363d; }
|
|
74
|
-
.btm-title { color: #4ecdc4; font-weight: 700; margin-right: 6px; }
|
|
75
|
-
.btm-tab { font: inherit; color: #9da7b3; background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 8px; cursor: pointer; }
|
|
76
|
-
.btm-tab.is-on { color: #e6edf3; border-color: #30363d; background: #21262d; }
|
|
77
|
-
.btm-close { margin-left: auto; font: inherit; color: #9da7b3; background: none; border: none; cursor: pointer; font-size: 14px; }
|
|
78
|
-
.btm-status { padding: 4px 10px; color: #7d8590; font-size: 11px; border-bottom: 1px solid #21262d; }
|
|
79
|
-
.btm-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid #21262d; }
|
|
80
|
-
.btm-controls[hidden] { display: none; }
|
|
81
|
-
.btm-controls button, .btm-controls input, .btm-controls select { font: inherit; color: inherit; background: #0d1117; border: 1px solid #30363d; border-radius: 4px; padding: 2px 6px; }
|
|
82
|
-
.btm-controls button { background: #21262d; cursor: pointer; }
|
|
83
|
-
.btm-controls button.is-on { border-color: #4ecdc4; color: #4ecdc4; }
|
|
84
|
-
.btm-controls input { width: 64px; }
|
|
85
|
-
.btm-body { overflow: auto; padding: 6px 10px 12px; flex: 1; }
|
|
86
|
-
.btm h3 { margin: 10px 0 4px; font-size: 11px; font-weight: 600; color: #7d8590; text-transform: uppercase; letter-spacing: .06em; }
|
|
87
|
-
.btm-hint { color: #7d8590; font-size: 11px; margin: 2px 0 6px; }
|
|
88
|
-
.btm-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 1px 0; }
|
|
89
|
-
.btm-row.is-wide { grid-template-columns: 1fr 64px 60px 100px; }
|
|
90
|
-
.btm-num { text-align: right; color: #c9d1d9; font-variant-numeric: tabular-nums; }
|
|
91
|
-
.btm-dim { color: #7d8590; }
|
|
92
|
-
.btm-bar { height: 6px; background: #4ecdc4; border-radius: 3px; min-width: 1px; }
|
|
93
|
-
.btm-barbox { width: 100px; background: #161b22; border-radius: 3px; }
|
|
94
|
-
.btm-spark polyline { fill: none; stroke: #4ecdc4; stroke-width: 1.3; }
|
|
95
|
-
.btm-alert { padding: 3px 6px; margin: 2px 0; border-left: 2px solid #ff7b72; background: rgba(255,123,114,.08); }
|
|
96
|
-
.btm-alert.is-info { border-left-color: #d29922; background: rgba(210,153,34,.08); }
|
|
97
|
-
.btm-group { margin: 6px 0; border: 1px solid #21262d; border-radius: 6px; }
|
|
98
|
-
.btm-group-head { padding: 3px 8px; color: #d2a8ff; font-size: 11px; border-bottom: 1px solid #21262d; }
|
|
99
|
-
.btm-marker { padding: 2px 8px; color: #7d8590; font-size: 11px; border-top: 1px dashed #30363d; }
|
|
100
|
-
.btm-sys { padding: 4px 8px; border-top: 1px solid #161b22; cursor: pointer; transition: opacity .15s; }
|
|
101
|
-
.btm-sys:first-child { border-top: none; }
|
|
102
|
-
.btm-sys-line { display: flex; align-items: center; gap: 6px; }
|
|
103
|
-
.btm-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #30363d; }
|
|
104
|
-
.is-active > .btm-sys-line .btm-dot { background: #3fb950; box-shadow: 0 0 6px #3fb950; }
|
|
105
|
-
.is-idle > .btm-sys-line .btm-dot { background: #2f6f3a; }
|
|
106
|
-
.is-skipped > .btm-sys-line .btm-dot { background: transparent; border: 1px dashed #7d8590; box-sizing: border-box; }
|
|
107
|
-
.is-failed > .btm-sys-line .btm-dot { background: #ff7b72; box-shadow: 0 0 6px #ff7b72; }
|
|
108
|
-
.btm-name { flex: 1; }
|
|
109
|
-
.btm-sys .btm-ms { color: #7d8590; font-size: 11px; }
|
|
110
|
-
.btm-chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0 0 14px; }
|
|
111
|
-
.btm-chip { font-size: 10.5px; padding: 0 5px; border-radius: 3px; border: 1px solid; cursor: default; white-space: nowrap; }
|
|
112
|
-
.btm-chip.is-read { color: #79c0ff; border-color: rgba(121,192,255,.35); }
|
|
113
|
-
.btm-chip.is-write { color: #ffa657; border-color: rgba(255,166,87,.45); }
|
|
114
|
-
.btm-chip.is-event { color: #d2a8ff; border-color: rgba(210,168,255,.4); }
|
|
115
|
-
.btm-chip.is-spawn { color: #3fb950; border-color: rgba(63,185,80,.4); }
|
|
116
|
-
.btm-chip.is-resource { font-style: italic; }
|
|
117
|
-
.btm-chip.is-machine { font-weight: 700; }
|
|
118
|
-
.btm-chip.is-lit { background: rgba(255,255,255,.12); }
|
|
119
|
-
.btm-map.has-focus .btm-sys { opacity: .28; }
|
|
120
|
-
.btm-map.has-focus .btm-sys.is-writer, .btm-map.has-focus .btm-sys.is-reader { opacity: 1; }
|
|
121
|
-
.btm-sys.is-writer { box-shadow: inset 3px 0 #ffa657; }
|
|
122
|
-
.btm-sys.is-reader { box-shadow: inset 3px 0 #79c0ff; }
|
|
123
|
-
.btm-details { margin: 4px 0 2px 14px; color: #9da7b3; font-size: 11px; }
|
|
124
|
-
.btm-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; color: #7d8590; font-size: 11px; margin-bottom: 4px; }
|
|
125
|
-
.btm-kv { display: grid; grid-template-columns: 150px 1fr; gap: 2px 8px; }
|
|
126
|
-
.btm-kv > span:nth-child(odd) { color: #79c0ff; overflow: hidden; text-overflow: ellipsis; }
|
|
127
|
-
.btm-kv > span:nth-child(even) { word-break: break-all; }
|
|
128
|
-
.btm-flash { animation: btm-flash .6s ease-out; }
|
|
129
|
-
@keyframes btm-flash { from { background: rgba(247,201,72,.35); } to { background: transparent; } }
|
|
130
|
-
.btm-line { color: #9da7b3; font-size: 11px; padding: 1px 0; }
|
|
131
|
-
.btm-ids { display: flex; flex-wrap: wrap; gap: 3px; }
|
|
132
|
-
.btm-ids button { font: inherit; font-size: 11px; color: #79c0ff; background: #161b22; border: 1px solid #30363d; border-radius: 3px; padding: 0 5px; cursor: pointer; }
|
|
133
|
-
.btm-marker-ring { position: fixed; z-index: 2147482999; width: 40px; height: 40px; margin: -20px 0 0 -20px; border: 2px solid #f7c948; border-radius: 50%; pointer-events: none; box-shadow: 0 0 12px rgba(247,201,72,.7); }
|
|
134
|
-
.btm-marker-ring[hidden] { display: none; }
|
|
135
|
-
.btm-picking, .btm-picking * { cursor: crosshair !important; }
|
|
136
|
-
`;
|
|
137
|
-
/**
|
|
138
|
-
* Adds the monitor to the page. The panel starts closed unless `open` is set;
|
|
139
|
-
* toggle it with the key (`Backslash` by default) or the corner button.
|
|
140
|
-
*/
|
|
141
|
-
export const attach = (runtime, options) => {
|
|
142
|
-
const debug = runtime.debug;
|
|
143
|
-
debug.nameSchedules(options.schedules);
|
|
144
|
-
const host = options.host;
|
|
145
|
-
const mount = options.mount ?? host.document.body;
|
|
146
|
-
const key = options.key ?? "Backslash";
|
|
147
|
-
const refreshMs = options.refreshMs ?? 250;
|
|
148
|
-
if (host.document.getElementById("btm-style") === null) {
|
|
149
|
-
const style = host.document.createElement("style");
|
|
150
|
-
style.id = "btm-style";
|
|
151
|
-
style.textContent = STYLE;
|
|
152
|
-
host.document.head.append(style);
|
|
153
|
-
}
|
|
154
|
-
const root = host.document.createElement("div");
|
|
155
|
-
root.className = "btm";
|
|
156
|
-
root.innerHTML = `
|
|
157
|
-
<button class="btm-toggle" type="button" title="Toggle the Ritmo monitor">◉ monitor</button>
|
|
158
|
-
<section class="btm-panel" hidden>
|
|
159
|
-
<div class="btm-head">
|
|
160
|
-
<span class="btm-title">Ritmo</span>
|
|
161
|
-
<button class="btm-tab" data-tab="overview" type="button">Overview</button>
|
|
162
|
-
<button class="btm-tab" data-tab="systems" type="button">Systems</button>
|
|
163
|
-
<button class="btm-tab" data-tab="entity" type="button">Entity</button>
|
|
164
|
-
${options.replay === undefined ? "" : `<button class="btm-save-replay" type="button" title="Save the last seconds of play as a replay">Save replay</button>`}
|
|
165
|
-
<button class="btm-close" type="button" title="Close">×</button>
|
|
166
|
-
</div>
|
|
167
|
-
<div class="btm-status"></div>
|
|
168
|
-
<div class="btm-controls" hidden>
|
|
169
|
-
<button class="btm-pick" type="button">Pick on screen</button>
|
|
170
|
-
<input class="btm-id" type="number" min="1" placeholder="id" />
|
|
171
|
-
<select class="btm-browse"><option value="">browse by component…</option></select>
|
|
172
|
-
<button class="btm-clear" type="button">Clear</button>
|
|
173
|
-
</div>
|
|
174
|
-
<div class="btm-body"></div>
|
|
175
|
-
</section>
|
|
176
|
-
<div class="btm-marker-ring" hidden></div>`;
|
|
177
|
-
mount.append(root);
|
|
178
|
-
const query = (selector) => root.querySelector(selector);
|
|
179
|
-
const toggleButton = query(".btm-toggle");
|
|
180
|
-
const panel = query(".btm-panel");
|
|
181
|
-
const status = query(".btm-status");
|
|
182
|
-
const controls = query(".btm-controls");
|
|
183
|
-
const body = query(".btm-body");
|
|
184
|
-
const pickButton = query(".btm-pick");
|
|
185
|
-
const idInput = query(".btm-id");
|
|
186
|
-
const browse = query(".btm-browse");
|
|
187
|
-
const ring = query(".btm-marker-ring");
|
|
188
|
-
toggleButton.textContent = `◉ monitor (${key.replace(/^Key|^Digit/, "")})`;
|
|
189
|
-
if (options.pick === undefined)
|
|
190
|
-
pickButton.disabled = true;
|
|
191
|
-
let tab = "overview";
|
|
192
|
-
let collector;
|
|
193
|
-
let stopObserving;
|
|
194
|
-
let timer;
|
|
195
|
-
let openedAt = 0;
|
|
196
|
-
let description;
|
|
197
|
-
/** How many systems read each component, to name what systems spawn. */
|
|
198
|
-
let readers = new Map();
|
|
199
|
-
let prefix = "";
|
|
200
|
-
let focus;
|
|
201
|
-
const expanded = new Set();
|
|
202
|
-
let selected;
|
|
203
|
-
let browsed;
|
|
204
|
-
let previousValues = new Map();
|
|
205
|
-
let picking = false;
|
|
206
|
-
let renderMs = 0;
|
|
207
|
-
const short = (name) => (prefix !== "" && name.startsWith(prefix) ? name.slice(prefix.length) : name);
|
|
208
|
-
// ── Overview ───────────────────────────────────────────────────────────
|
|
209
|
-
const renderOverview = (history) => {
|
|
210
|
-
const parts = [];
|
|
211
|
-
const scheduleNames = Object.keys(options.schedules);
|
|
212
|
-
parts.push("<h3>Schedules</h3>", `<div class="btm-hint">Time per tick of each schedule over the last ~2s, including tracing overhead (tracing runs only while this panel is open). The line shows the last ${history.length} samples.</div>`);
|
|
213
|
-
parts.push(`<div class="btm-row is-wide btm-dim"><span>schedule</span><span class="btm-num">ticks/s</span><span class="btm-num">ms/tick</span><span></span></div>`);
|
|
214
|
-
for (const name of scheduleNames) {
|
|
215
|
-
const recent = recentSchedule(history, name, RECENT);
|
|
216
|
-
const series = history.map((sample) => {
|
|
217
|
-
const window = sample.schedules.get(name);
|
|
218
|
-
return window === undefined || window.ticks === 0 ? 0 : window.ms / window.ticks;
|
|
219
|
-
});
|
|
220
|
-
parts.push(`<div class="btm-row is-wide"><span>${escape(name)}</span><span class="btm-num">${recent.seconds === 0 ? "–" : number(recent.ticks / recent.seconds, 0)}</span><span class="btm-num" title="max ${number(recent.maxMs, 3)}ms">${recent.ticks === 0 ? "–" : number(recent.ms / recent.ticks, 3)}</span>${sparkline(series)}</div>`);
|
|
221
|
-
}
|
|
222
|
-
const names = new Set();
|
|
223
|
-
for (const sample of history.slice(-RECENT))
|
|
224
|
-
for (const name of sample.systems.keys())
|
|
225
|
-
names.add(name);
|
|
226
|
-
const busiest = [...names]
|
|
227
|
-
.map((name) => ({ name, recent: recentSystem(history, name, RECENT) }))
|
|
228
|
-
.filter((entry) => entry.recent.runs > 0)
|
|
229
|
-
.sort((left, right) => right.recent.ms - left.recent.ms)
|
|
230
|
-
.slice(0, 8);
|
|
231
|
-
const top = busiest[0]?.recent.ms ?? 0;
|
|
232
|
-
parts.push("<h3>Busiest systems</h3>", `<div class="btm-hint">Share of time over the last ~2s, and average ms per run.</div>`);
|
|
233
|
-
for (const { name, recent } of busiest) {
|
|
234
|
-
parts.push(`<div class="btm-row"><span title="${escape(name)}">${escape(short(name))}</span><span class="btm-barbox"><div class="btm-bar" style="width:${top === 0 ? 0 : (recent.ms / top) * 100}%"></div></span><span class="btm-num">${number(recent.ms / recent.runs, 3)}</span></div>`);
|
|
235
|
-
}
|
|
236
|
-
const latest = history[history.length - 1];
|
|
237
|
-
if (latest !== undefined) {
|
|
238
|
-
parts.push(`<h3>Population</h3>`, `<div class="btm-hint">Live entities, and entities per component. A line that only goes up is a leak.</div>`);
|
|
239
|
-
parts.push(`<div class="btm-row"><span><b>entities</b></span><span class="btm-num">${latest.population.entities}</span>${sparkline(history.map((sample) => sample.population.entities))}</div>`);
|
|
240
|
-
const components = Object.keys(latest.population.components)
|
|
241
|
-
.filter((component) => history.some((sample) => (sample.population.components[component] ?? 0) > 0))
|
|
242
|
-
.sort((left, right) => (latest.population.components[right] ?? 0) - (latest.population.components[left] ?? 0));
|
|
243
|
-
for (const component of components) {
|
|
244
|
-
parts.push(`<div class="btm-row"><span title="${escape(component)}">${escape(short(component))}</span><span class="btm-num">${latest.population.components[component] ?? 0}</span>${sparkline(history.map((sample) => sample.population.components[component] ?? 0))}</div>`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
const machines = Object.entries(debug.dump({ limit: 0 }).machines);
|
|
248
|
-
if (machines.length > 0) {
|
|
249
|
-
parts.push("<h3>State machines</h3>");
|
|
250
|
-
for (const [name, machine] of machines) {
|
|
251
|
-
const pending = machine.pending === undefined ? "" : ` <span class="btm-dim">→ ${escape(Format.state(machine.pending))} (queued)</span>`;
|
|
252
|
-
parts.push(`<div class="btm-row"><span>${escape(short(name))}</span><span class="btm-num">${escape(Format.state(machine.current))}${pending}</span><span></span></div>`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
parts.push("<h3>Alerts</h3>");
|
|
256
|
-
const alerts = [...(collector?.alerts.values() ?? [])];
|
|
257
|
-
if (alerts.length === 0)
|
|
258
|
-
parts.push(`<div class="btm-dim">None since the monitor opened.</div>`);
|
|
259
|
-
for (const alert of alerts) {
|
|
260
|
-
parts.push(`<div class="btm-alert${alert.code === "discarded-messages" ? " is-info" : ""}">${escape(alert.message)} <span class="btm-dim">×${alert.count}, f${alert.firstFrame}–f${alert.lastFrame}</span></div>`);
|
|
261
|
-
}
|
|
262
|
-
return parts.join("");
|
|
263
|
-
};
|
|
264
|
-
// ── Systems map ────────────────────────────────────────────────────────
|
|
265
|
-
const chip = (kind, subject, text, title) => `<span class="btm-chip ${kind}${focus === subject ? " is-lit" : ""}" data-subject="${escape(subject)}" title="${escape(title)}">${escape(text)}</span>`;
|
|
266
|
-
const renderSystem = (system, history, conditionReads) => {
|
|
267
|
-
const access = accessOf(system);
|
|
268
|
-
const recent = recentSystem(history, system.name, 2);
|
|
269
|
-
const longer = recentSystem(history, system.name, RECENT);
|
|
270
|
-
const state = statusOf(recent);
|
|
271
|
-
const writesFocus = focus !== undefined && [...access.writes, ...access.resourceWrites, ...access.eventWrites, ...access.machineWrites].includes(focus);
|
|
272
|
-
const readsFocus = focus !== undefined && [...access.reads, ...access.resourceReads, ...access.eventReads, ...access.machineReads].includes(focus);
|
|
273
|
-
// Name spawned entities by their most specific component: fewest live entities, then most readers.
|
|
274
|
-
const counts = history[history.length - 1]?.population.components ?? {};
|
|
275
|
-
const spawns = collector?.spawnNames(system.name, (left, right) => (counts[left] ?? 0) - (counts[right] ?? 0) || (readers.get(right) ?? 0) - (readers.get(left) ?? 0)) ?? [];
|
|
276
|
-
const hidden = new Set(conditionReads);
|
|
277
|
-
// What the system does first (writes, events, spawns), then what it reads.
|
|
278
|
-
const chips = [
|
|
279
|
-
...access.writes.map((name) => chip("is-write", name, short(name), `writes component ${name}`)),
|
|
280
|
-
...access.resourceWrites.map((name) => chip("is-write is-resource", name, short(name), `writes resource ${name}`)),
|
|
281
|
-
...access.machineWrites.map((name) => chip("is-write is-machine", name, `→${short(name)}`, `queues the next state of ${name}`)),
|
|
282
|
-
...access.eventWrites.map((name) => chip("is-event", name, `${short(name)}→`, `emits event ${name}`)),
|
|
283
|
-
...(spawns.length === 0 ? [] : [chip("is-spawn", `spawn:${system.name}`, `+${spawns.map(short).join(", +")}`, "spawns entities (learned while running; details on click)")]),
|
|
284
|
-
...access.eventReads.map((name) => chip("is-event", name, `←${short(name)}`, `reads event ${name}`)),
|
|
285
|
-
...access.reads.map((name) => chip("is-read", name, short(name), `reads component ${name}`)),
|
|
286
|
-
...access.resourceReads.filter((name) => !hidden.has(name)).map((name) => chip("is-read is-resource", name, short(name), `reads resource ${name}`)),
|
|
287
|
-
...access.machineReads.filter((name) => !hidden.has(name)).map((name) => chip("is-read is-machine", name, short(name), `reads state machine ${name}`))
|
|
288
|
-
];
|
|
289
|
-
const details = [];
|
|
290
|
-
if (expanded.has(system.name)) {
|
|
291
|
-
const perSecond = (value) => number(value / Math.max(longer.seconds, 1e-6), 1);
|
|
292
|
-
details.push(`<div class="btm-details">`);
|
|
293
|
-
details.push(`<div>${statusText[state]}</div>`);
|
|
294
|
-
details.push(`<div>${perSecond(longer.runs)} runs/s · ${longer.runs === 0 ? "–" : number(longer.ms / longer.runs, 3)} ms/run · max ${number(longer.maxMs, 3)} ms</div>`);
|
|
295
|
-
if (longer.runs > 0) {
|
|
296
|
-
details.push(`<div>per run: ${number(longer.writes / longer.runs, 1)} writes · ${number(longer.events / longer.runs, 1)} events · ${number(longer.commands / longer.runs, 1)} commands</div>`);
|
|
297
|
-
}
|
|
298
|
-
if (longer.spawns + longer.despawns > 0)
|
|
299
|
-
details.push(`<div>${perSecond(longer.spawns)} spawns/s · ${perSecond(longer.despawns)} despawns/s</div>`);
|
|
300
|
-
if (longer.skips > 0)
|
|
301
|
-
details.push(`<div>${perSecond(longer.skips)} skips/s — ${escape(collector?.skippedBy.get(system.name) ?? "")}</div>`);
|
|
302
|
-
for (const kind of collector?.spawnsOf(system.name) ?? []) {
|
|
303
|
-
details.push(`<div>spawned ×${kind.count}: ${escape(kind.components.map(short).join(", "))}</div>`);
|
|
304
|
-
}
|
|
305
|
-
const error = collector?.lastError.get(system.name);
|
|
306
|
-
if (error !== undefined)
|
|
307
|
-
details.push(`<div style="color:#ff7b72">last error: ${escape(error)}</div>`);
|
|
308
|
-
if (system.when.length > 0)
|
|
309
|
-
details.push(`<div>runs when: ${escape(system.when.join(", "))}</div>`);
|
|
310
|
-
if (system.pauseWhen.length > 0)
|
|
311
|
-
details.push(`<div>pauses when: ${escape(system.pauseWhen.join(", "))}</div>`);
|
|
312
|
-
if (system.local)
|
|
313
|
-
details.push(`<div class="btm-dim">holds local state</div>`);
|
|
314
|
-
details.push(`<div class="btm-dim">at ${escape(system.placements.join(", "))}</div>`);
|
|
315
|
-
details.push(`</div>`);
|
|
316
|
-
}
|
|
317
|
-
const classes = ["btm-sys", `is-${state}`, writesFocus ? "is-writer" : "", readsFocus && !writesFocus ? "is-reader" : ""].filter(Boolean).join(" ");
|
|
318
|
-
return `<div class="${classes}" data-system="${escape(system.name)}" title="${escape(statusText[state])}">
|
|
319
|
-
<div class="btm-sys-line"><span class="btm-dot"></span><span class="btm-name">${escape(short(system.name))}</span><span class="btm-ms">${recent.runs === 0 ? "" : `${number(recent.ms / recent.runs, 3)}ms`}</span></div>
|
|
320
|
-
<div class="btm-chips">${chips.join("")}</div>${details.join("")}
|
|
321
|
-
</div>`;
|
|
322
|
-
};
|
|
323
|
-
const renderSystems = (history) => {
|
|
324
|
-
if (description === undefined)
|
|
325
|
-
return "";
|
|
326
|
-
const byName = new Map(description.systems.map((system) => [system.name, system]));
|
|
327
|
-
const parts = [
|
|
328
|
-
`<div class="btm-legend"><span>● working</span><span style="color:#2f6f3a">● idle</span><span>◌ skipped</span><span style="color:#79c0ff">reads</span><span style="color:#ffa657">writes</span><span style="color:#d2a8ff">events</span><span style="color:#3fb950">spawns</span><span><i>italic</i> resource</span><span><b>bold</b> state</span></div>`,
|
|
329
|
-
`<div class="btm-hint">Systems run top to bottom. Hover a name to see who writes it (orange edge) and who reads it (blue edge). Click a system for details.</div>`
|
|
330
|
-
];
|
|
331
|
-
parts.push(`<div class="btm-map${focus === undefined ? "" : " has-focus"}">`);
|
|
332
|
-
const runnable = new Set(Object.keys(options.schedules));
|
|
333
|
-
const ordered = [...description.schedules].sort((left, right) => Number(runnable.has(right.name)) - Number(runnable.has(left.name)));
|
|
334
|
-
for (const schedule of ordered) {
|
|
335
|
-
parts.push(`<h3>${escape(schedule.name)}</h3>`);
|
|
336
|
-
// Consecutive steps with the same run conditions form a group.
|
|
337
|
-
const groups = [];
|
|
338
|
-
for (const step of schedule.steps) {
|
|
339
|
-
const when = step.kind === "system" ? (byName.get(step.system)?.when.join(", ") ?? "") : undefined;
|
|
340
|
-
const last = groups[groups.length - 1];
|
|
341
|
-
if (last !== undefined && (when === undefined || last.when === when))
|
|
342
|
-
last.steps.push(step);
|
|
343
|
-
else
|
|
344
|
-
groups.push({ when: when ?? "", steps: [step] });
|
|
345
|
-
}
|
|
346
|
-
for (const group of groups) {
|
|
347
|
-
const members = group.steps.flatMap((step) => (step.kind === "system" ? [byName.get(step.system)] : []));
|
|
348
|
-
// Resources and machines every member reads come from the group's
|
|
349
|
-
// conditions (a check's reads count as the gated system's reads).
|
|
350
|
-
const conditionReads = !group.when.includes("check(") || members.length === 0
|
|
351
|
-
? []
|
|
352
|
-
: [...members[0].resources.reads, ...members[0].machines.reads].filter((name) => members.every((member) => member.resources.reads.includes(name) || member.machines.reads.includes(name)));
|
|
353
|
-
const head = group.when === ""
|
|
354
|
-
? ""
|
|
355
|
-
: `<div class="btm-group-head">when ${escape(group.when)}${conditionReads.length === 0 ? "" : ` <span class="btm-dim">· the condition reads ${escape(conditionReads.map(short).join(", "))}</span>`}</div>`;
|
|
356
|
-
const items = group.steps.map((step) => {
|
|
357
|
-
if (step.kind === "system")
|
|
358
|
-
return renderSystem(byName.get(step.system), history, conditionReads);
|
|
359
|
-
const label = step.kind === "applyDeferred" ? "apply commands" : `apply state transitions${step.schedules.length > 0 ? ` (runs ${step.schedules.length} transition schedules)` : ""}`;
|
|
360
|
-
return `<div class="btm-marker">⟂ ${escape(label)}</div>`;
|
|
361
|
-
});
|
|
362
|
-
parts.push(`<div class="btm-group">${head}${items.join("")}</div>`);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
parts.push("</div>");
|
|
366
|
-
return parts.join("");
|
|
367
|
-
};
|
|
368
|
-
// ── Entity ─────────────────────────────────────────────────────────────
|
|
369
|
-
const renderEntity = () => {
|
|
370
|
-
const parts = [];
|
|
371
|
-
if (browsed !== undefined) {
|
|
372
|
-
parts.push(`<h3>Entities with ${escape(short(browsed.component))} (${browsed.ids.length})</h3><div class="btm-ids">`);
|
|
373
|
-
for (const id of browsed.ids.slice(0, 80))
|
|
374
|
-
parts.push(`<button type="button" data-entity="${id}">e${id}</button>`);
|
|
375
|
-
parts.push(browsed.ids.length > 80 ? `<span class="btm-dim">…+${browsed.ids.length - 80}</span>` : "", "</div>");
|
|
376
|
-
}
|
|
377
|
-
if (selected === undefined) {
|
|
378
|
-
parts.push(`<div class="btm-hint" style="margin-top:8px">${options.pick === undefined ? "Enter an entity id" : "Pick an entity on screen, enter an id,"} or browse by component.</div>`);
|
|
379
|
-
return parts.join("");
|
|
380
|
-
}
|
|
381
|
-
const dumped = debug.dump({ entities: [selected] }).entities[0];
|
|
382
|
-
parts.push(`<h3 style="text-transform:none">e${selected}</h3>`);
|
|
383
|
-
if (dumped === undefined) {
|
|
384
|
-
parts.push(`<div class="btm-dim">Not alive (despawned).</div>`);
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
const values = new Map();
|
|
388
|
-
parts.push(`<div class="btm-kv">`);
|
|
389
|
-
for (const [component, value] of Object.entries(dumped.components)) {
|
|
390
|
-
const text = Format.value(value, { depth: 2, items: 6 });
|
|
391
|
-
values.set(component, text);
|
|
392
|
-
const changed = previousValues.has(component) && previousValues.get(component) !== text;
|
|
393
|
-
parts.push(`<span title="${escape(component)}">${escape(short(component))}</span><span${changed ? ` class="btm-flash"` : ""}>${escape(text)}</span>`);
|
|
394
|
-
}
|
|
395
|
-
for (const [relation, target] of Object.entries(dumped.relations)) {
|
|
396
|
-
parts.push(`<span>${escape(short(relation))}</span><span>→ e${target}</span>`);
|
|
397
|
-
}
|
|
398
|
-
parts.push(`</div>`);
|
|
399
|
-
previousValues = values;
|
|
400
|
-
}
|
|
401
|
-
parts.push(`<h3>Recent changes</h3>`);
|
|
402
|
-
const lines = [...(collector?.entityLines ?? [])].reverse();
|
|
403
|
-
if (lines.length === 0)
|
|
404
|
-
parts.push(`<div class="btm-dim">No changes since it was selected.</div>`);
|
|
405
|
-
for (const line of lines) {
|
|
406
|
-
parts.push(`<div class="btm-line"><span class="btm-dim">f${line.frame}</span> ${escape(short(line.system))}: ${escape(line.text)}</div>`);
|
|
407
|
-
}
|
|
408
|
-
return parts.join("");
|
|
409
|
-
};
|
|
410
|
-
// ── Refresh ────────────────────────────────────────────────────────────
|
|
411
|
-
const render = () => {
|
|
412
|
-
if (collector === undefined)
|
|
413
|
-
return;
|
|
414
|
-
const started = host.performance.now();
|
|
415
|
-
const history = collector.history;
|
|
416
|
-
const latest = history.slice(-RECENT);
|
|
417
|
-
const overhead = latest.reduce((total, sample) => total + sample.overheadMs, 0);
|
|
418
|
-
const ticks = latest.reduce((total, sample) => total + [...sample.schedules.values()].reduce((sum, window) => sum + window.ticks, 0), 0);
|
|
419
|
-
status.textContent = `observing for ${Math.round((host.performance.now() - openedAt) / 1000)}s · frame ${debug.frame()} · panel ${ticks === 0 ? "–" : number(overhead / ticks, 3)} ms/tick + ${number(renderMs, 1)} ms/refresh`;
|
|
420
|
-
status.title = "The panel's own work. Tracing (on only while the panel is open) also slows every system run a little, and the times shown include it: compare them with each other, not with a closed-monitor run.";
|
|
421
|
-
body.innerHTML = tab === "overview" ? renderOverview(history) : tab === "systems" ? renderSystems(history) : renderEntity();
|
|
422
|
-
renderMs = host.performance.now() - started;
|
|
423
|
-
};
|
|
424
|
-
const refresh = () => {
|
|
425
|
-
if (collector === undefined)
|
|
426
|
-
return;
|
|
427
|
-
collector.sample(host.performance.now());
|
|
428
|
-
render();
|
|
429
|
-
};
|
|
430
|
-
const placeRing = () => {
|
|
431
|
-
const at = selected === undefined || options.locate === undefined || panel.hidden ? undefined : options.locate(selected);
|
|
432
|
-
ring.hidden = at === undefined;
|
|
433
|
-
if (at !== undefined) {
|
|
434
|
-
ring.style.left = `${at.x}px`;
|
|
435
|
-
ring.style.top = `${at.y}px`;
|
|
436
|
-
}
|
|
437
|
-
if (!panel.hidden)
|
|
438
|
-
host.requestAnimationFrame(placeRing);
|
|
439
|
-
};
|
|
440
|
-
const setTab = (next) => {
|
|
441
|
-
tab = next;
|
|
442
|
-
for (const button of root.querySelectorAll(".btm-tab"))
|
|
443
|
-
button.classList.toggle("is-on", button.dataset["tab"] === next);
|
|
444
|
-
controls.hidden = next !== "entity";
|
|
445
|
-
render();
|
|
446
|
-
};
|
|
447
|
-
const open = () => {
|
|
448
|
-
if (!panel.hidden)
|
|
449
|
-
return;
|
|
450
|
-
description = debug.describe();
|
|
451
|
-
readers = new Map(description.access.components.map((entry) => [entry.name, entry.readers.length]));
|
|
452
|
-
prefix = commonPrefix([...description.systems.map((system) => system.name), ...description.components.map((component) => component.name)]);
|
|
453
|
-
browse.replaceChildren(new Option("browse by component…", ""), ...description.components.map((component) => new Option(short(component.name), component.name)));
|
|
454
|
-
collector = new Collector(() => debug.population(), () => host.performance.now());
|
|
455
|
-
collector.select(selected);
|
|
456
|
-
stopObserving = debug.observe(collector.observe);
|
|
457
|
-
openedAt = host.performance.now();
|
|
458
|
-
panel.hidden = false;
|
|
459
|
-
timer = host.setInterval(refresh, refreshMs);
|
|
460
|
-
setTab(tab);
|
|
461
|
-
host.requestAnimationFrame(placeRing);
|
|
462
|
-
};
|
|
463
|
-
const close = () => {
|
|
464
|
-
if (panel.hidden)
|
|
465
|
-
return;
|
|
466
|
-
panel.hidden = true;
|
|
467
|
-
ring.hidden = true;
|
|
468
|
-
stopObserving?.();
|
|
469
|
-
stopObserving = undefined;
|
|
470
|
-
if (timer !== undefined)
|
|
471
|
-
host.clearInterval(timer);
|
|
472
|
-
timer = undefined;
|
|
473
|
-
collector = undefined;
|
|
474
|
-
setPicking(false);
|
|
475
|
-
};
|
|
476
|
-
const select = (entity) => {
|
|
477
|
-
selected = entity;
|
|
478
|
-
previousValues = new Map();
|
|
479
|
-
collector?.select(entity);
|
|
480
|
-
idInput.value = entity === undefined ? "" : String(entity);
|
|
481
|
-
render();
|
|
482
|
-
};
|
|
483
|
-
const onPick = (event) => {
|
|
484
|
-
if (event.target instanceof Node && root.contains(event.target))
|
|
485
|
-
return;
|
|
486
|
-
event.preventDefault();
|
|
487
|
-
event.stopPropagation();
|
|
488
|
-
event.stopImmediatePropagation();
|
|
489
|
-
const entity = options.pick?.(event);
|
|
490
|
-
setPicking(false);
|
|
491
|
-
if (entity !== undefined) {
|
|
492
|
-
if (tab !== "entity")
|
|
493
|
-
setTab("entity");
|
|
494
|
-
select(entity);
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
function setPicking(on) {
|
|
498
|
-
if (picking === on)
|
|
499
|
-
return;
|
|
500
|
-
picking = on;
|
|
501
|
-
pickButton.classList.toggle("is-on", on);
|
|
502
|
-
pickButton.textContent = on ? "Click an entity… (Esc)" : "Pick on screen";
|
|
503
|
-
host.document.documentElement.classList.toggle("btm-picking", on);
|
|
504
|
-
if (on)
|
|
505
|
-
host.addEventListener("pointerdown", onPick, { capture: true });
|
|
506
|
-
else
|
|
507
|
-
host.removeEventListener("pointerdown", onPick, { capture: true });
|
|
508
|
-
}
|
|
509
|
-
// ── Events ─────────────────────────────────────────────────────────────
|
|
510
|
-
const onKey = (event) => {
|
|
511
|
-
const target = event.target;
|
|
512
|
-
if (target !== null && (target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA"))
|
|
513
|
-
return;
|
|
514
|
-
if (event.code === key) {
|
|
515
|
-
if (panel.hidden)
|
|
516
|
-
open();
|
|
517
|
-
else
|
|
518
|
-
close();
|
|
519
|
-
}
|
|
520
|
-
else if (event.code === "Escape" && picking) {
|
|
521
|
-
setPicking(false);
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
host.addEventListener("keydown", onKey);
|
|
525
|
-
toggleButton.addEventListener("click", () => (panel.hidden ? open() : close()));
|
|
526
|
-
query(".btm-close").addEventListener("click", close);
|
|
527
|
-
const replay = options.replay;
|
|
528
|
-
if (replay !== undefined) {
|
|
529
|
-
const button = query(".btm-save-replay");
|
|
530
|
-
button.addEventListener("click", () => {
|
|
531
|
-
replay.save("Save replay button");
|
|
532
|
-
button.textContent = "Saved";
|
|
533
|
-
host.setTimeout(() => { button.textContent = "Save replay"; }, 1500);
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
for (const button of root.querySelectorAll(".btm-tab")) {
|
|
537
|
-
button.addEventListener("click", () => setTab(button.dataset["tab"]));
|
|
538
|
-
}
|
|
539
|
-
pickButton.addEventListener("click", () => setPicking(!picking));
|
|
540
|
-
idInput.addEventListener("keydown", (event) => event.stopPropagation());
|
|
541
|
-
idInput.addEventListener("change", () => {
|
|
542
|
-
const value = Number.parseInt(idInput.value, 10);
|
|
543
|
-
select(Number.isFinite(value) && value > 0 ? value : undefined);
|
|
544
|
-
});
|
|
545
|
-
browse.addEventListener("change", () => {
|
|
546
|
-
const component = browse.value;
|
|
547
|
-
browsed = component === ""
|
|
548
|
-
? undefined
|
|
549
|
-
: { component, ids: debug.dump().entities.filter((entity) => component in entity.components).map((entity) => entity.id) };
|
|
550
|
-
render();
|
|
551
|
-
});
|
|
552
|
-
query(".btm-clear").addEventListener("click", () => {
|
|
553
|
-
browsed = undefined;
|
|
554
|
-
browse.value = "";
|
|
555
|
-
select(undefined);
|
|
556
|
-
});
|
|
557
|
-
body.addEventListener("click", (event) => {
|
|
558
|
-
const target = event.target;
|
|
559
|
-
const entity = target.closest("[data-entity]");
|
|
560
|
-
if (entity !== null) {
|
|
561
|
-
select(Number(entity.dataset["entity"]));
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const system = target.closest("[data-system]");
|
|
565
|
-
if (system !== null && target.closest("[data-subject]") === null) {
|
|
566
|
-
const name = system.dataset["system"];
|
|
567
|
-
if (expanded.has(name))
|
|
568
|
-
expanded.delete(name);
|
|
569
|
-
else
|
|
570
|
-
expanded.add(name);
|
|
571
|
-
render();
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
body.addEventListener("mouseover", (event) => {
|
|
575
|
-
const subject = event.target.closest("[data-subject]")?.dataset["subject"];
|
|
576
|
-
if (subject === focus || tab !== "systems")
|
|
577
|
-
return;
|
|
578
|
-
focus = subject?.startsWith("spawn:") ? undefined : subject;
|
|
579
|
-
render();
|
|
580
|
-
});
|
|
581
|
-
body.addEventListener("mouseleave", () => {
|
|
582
|
-
if (focus === undefined)
|
|
583
|
-
return;
|
|
584
|
-
focus = undefined;
|
|
585
|
-
render();
|
|
586
|
-
});
|
|
587
|
-
setTab("overview");
|
|
588
|
-
if (options.open === true)
|
|
589
|
-
open();
|
|
590
|
-
return {
|
|
591
|
-
open,
|
|
592
|
-
close,
|
|
593
|
-
toggle: () => (panel.hidden ? open() : close()),
|
|
594
|
-
select,
|
|
595
|
-
detach: () => {
|
|
596
|
-
close();
|
|
597
|
-
host.removeEventListener("keydown", onKey);
|
|
598
|
-
root.remove();
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
//# sourceMappingURL=Monitor.js.map
|