brumate 0.2.0 → 0.4.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.
Files changed (138) hide show
  1. package/README.md +2 -2
  2. package/check.d.ts +49 -0
  3. package/dist/{boot-D-IdPy7B.d.ts → boot-DLlRmD9z.d.ts} +11 -10
  4. package/dist/cli.js +275 -15
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client-BvDsC6Qr.js +3463 -0
  7. package/dist/client-BvDsC6Qr.js.map +1 -0
  8. package/dist/client-DBwL2wKQ.d.ts +669 -0
  9. package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
  10. package/dist/client-routes-BtGpYCef.js.map +1 -0
  11. package/dist/{cookies-Av5WFmcf.js → cookies-Cnbf4w-S.js} +15 -7
  12. package/dist/cookies-Cnbf4w-S.js.map +1 -0
  13. package/dist/{defer-D0bo1Gqx.js → defer-CKWZLv2K.js} +8 -4
  14. package/dist/defer-CKWZLv2K.js.map +1 -0
  15. package/dist/devtools-4uTPwR_v.js +597 -0
  16. package/dist/devtools-4uTPwR_v.js.map +1 -0
  17. package/dist/devtools-panel-Be9pxYgv.js +1994 -0
  18. package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
  19. package/dist/events-LgLdp1R7.js +114 -0
  20. package/dist/events-LgLdp1R7.js.map +1 -0
  21. package/dist/features-CHY5Ekku.js +30 -0
  22. package/dist/features-CHY5Ekku.js.map +1 -0
  23. package/dist/files-WW4RlajL.js +506 -0
  24. package/dist/files-WW4RlajL.js.map +1 -0
  25. package/dist/forms-j1xPAR14.d.ts +281 -0
  26. package/dist/forms-nXK7-Lv_.js +440 -0
  27. package/dist/forms-nXK7-Lv_.js.map +1 -0
  28. package/dist/highlight.d.ts +17 -0
  29. package/dist/highlight.js +278 -0
  30. package/dist/highlight.js.map +1 -0
  31. package/dist/html-BtKRyi7g.js +305 -0
  32. package/dist/html-BtKRyi7g.js.map +1 -0
  33. package/dist/html-Bw9Qwu6F.d.ts +107 -0
  34. package/dist/index.d.ts +142 -11
  35. package/dist/index.js +641 -106
  36. package/dist/index.js.map +1 -1
  37. package/dist/{inspect-BJtACnQp.js → inspect-Y6y4uNZp.js} +4333 -681
  38. package/dist/inspect-Y6y4uNZp.js.map +1 -0
  39. package/dist/{loader-B18i3_-T.js → loader-BjKGJzLN.js} +21 -14
  40. package/dist/loader-BjKGJzLN.js.map +1 -0
  41. package/dist/logo-DQ_OYhBi.js +10 -0
  42. package/dist/logo-DQ_OYhBi.js.map +1 -0
  43. package/dist/{navigate-BwuZveDF.js → navigate-CfOr-TRF.js} +130 -24
  44. package/dist/navigate-CfOr-TRF.js.map +1 -0
  45. package/dist/nesting-DA5vJw9X.js +265 -0
  46. package/dist/nesting-DA5vJw9X.js.map +1 -0
  47. package/dist/produce-B7X9ori9.js +402 -0
  48. package/dist/produce-B7X9ori9.js.map +1 -0
  49. package/dist/produce-DIgHBVwL.d.ts +148 -0
  50. package/dist/{rpc-B-Zkn6Ch.js → rpc-Q-XkLwFh.js} +28 -13
  51. package/dist/rpc-Q-XkLwFh.js.map +1 -0
  52. package/dist/runtime/batch.js +9 -7
  53. package/dist/runtime/batch.js.map +1 -1
  54. package/dist/runtime/client.d.ts +4 -4
  55. package/dist/runtime/client.js +4 -4
  56. package/dist/runtime/devtools.d.ts +172 -5
  57. package/dist/runtime/devtools.js +3 -1
  58. package/dist/runtime/env.js +14 -2
  59. package/dist/runtime/env.js.map +1 -1
  60. package/dist/runtime/events.d.ts +38 -1
  61. package/dist/runtime/events.js +1 -1
  62. package/dist/runtime/forms.d.ts +2 -0
  63. package/dist/runtime/forms.js +1 -0
  64. package/dist/runtime/gather.d.ts +25 -0
  65. package/dist/runtime/gather.js +33 -0
  66. package/dist/runtime/gather.js.map +1 -0
  67. package/dist/runtime/hot.d.ts +1 -1
  68. package/dist/runtime/hot.js +5 -2
  69. package/dist/runtime/hot.js.map +1 -1
  70. package/dist/runtime/html.d.ts +2 -2
  71. package/dist/runtime/html.js +1 -1
  72. package/dist/runtime/loader.d.ts +2 -2
  73. package/dist/runtime/loader.js +2 -2
  74. package/dist/runtime/routes.js +4 -1
  75. package/dist/runtime/routes.js.map +1 -1
  76. package/dist/runtime/server.d.ts +5 -4
  77. package/dist/runtime/server.js +5 -5
  78. package/dist/runtime/signals.d.ts +75 -2
  79. package/dist/runtime/signals.js +44 -2
  80. package/dist/runtime/signals.js.map +1 -1
  81. package/dist/runtime/static-loader.d.ts +2 -2
  82. package/dist/runtime/static-loader.js +1 -1
  83. package/dist/runtime/testing.d.ts +18 -3
  84. package/dist/runtime/testing.js +150 -33
  85. package/dist/runtime/testing.js.map +1 -1
  86. package/dist/runtime/values.d.ts +2 -0
  87. package/dist/runtime/values.js +24 -0
  88. package/dist/runtime/values.js.map +1 -0
  89. package/dist/{server-BA9SJ2Vm.d.ts → server-BvPIg9pT.d.ts} +363 -32
  90. package/dist/{server-BqfM95r1.js → server-DjyOVJtJ.js} +1309 -220
  91. package/dist/server-DjyOVJtJ.js.map +1 -0
  92. package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
  93. package/dist/static-loader-BZR17hSw.js +312 -0
  94. package/dist/static-loader-BZR17hSw.js.map +1 -0
  95. package/dist/{stream-JaMHMdBD.js → stream-BP5AVmg5.js} +182 -17
  96. package/dist/stream-BP5AVmg5.js.map +1 -0
  97. package/dist/values-B8C7CLvG.d.ts +63 -0
  98. package/dist/vite.d.ts +20 -20
  99. package/dist/vite.js +2031 -539
  100. package/dist/vite.js.map +1 -1
  101. package/elements.d.ts +951 -0
  102. package/forms/forms.brm.ts +141 -0
  103. package/package.json +41 -3
  104. package/skills/brumate/SKILL.md +58 -0
  105. package/skills/brumate/references/errors.md +2078 -0
  106. package/skills/brumate/references/events.md +117 -0
  107. package/skills/brumate/references/signals.md +61 -0
  108. package/skills/brumate/references/state.md +235 -0
  109. package/skills/brumate/references/syntax.md +250 -0
  110. package/types.d.ts +4 -4
  111. package/dist/client-C0UCNL3J.js +0 -1643
  112. package/dist/client-C0UCNL3J.js.map +0 -1
  113. package/dist/client-MD0ZmcFR.d.ts +0 -354
  114. package/dist/client-routes-JTbGtukf.js.map +0 -1
  115. package/dist/cookies-Av5WFmcf.js.map +0 -1
  116. package/dist/defer-D0bo1Gqx.js.map +0 -1
  117. package/dist/devtools-C50VH8gZ.js +0 -113
  118. package/dist/devtools-C50VH8gZ.js.map +0 -1
  119. package/dist/devtools-panel-AYjfwPhj.js +0 -435
  120. package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
  121. package/dist/events-BKWRqtMg.js +0 -52
  122. package/dist/events-BKWRqtMg.js.map +0 -1
  123. package/dist/files-Bnn1JqHx.js +0 -192
  124. package/dist/files-Bnn1JqHx.js.map +0 -1
  125. package/dist/html-bHZbkK-h.js +0 -170
  126. package/dist/html-bHZbkK-h.js.map +0 -1
  127. package/dist/html-y1q7-t7D.d.ts +0 -60
  128. package/dist/inspect-BJtACnQp.js.map +0 -1
  129. package/dist/loader-B18i3_-T.js.map +0 -1
  130. package/dist/navigate-BwuZveDF.js.map +0 -1
  131. package/dist/produce-CWfJ4byV.js +0 -167
  132. package/dist/produce-CWfJ4byV.js.map +0 -1
  133. package/dist/produce-D4K7qpaL.d.ts +0 -72
  134. package/dist/rpc-B-Zkn6Ch.js.map +0 -1
  135. package/dist/server-BqfM95r1.js.map +0 -1
  136. package/dist/static-loader-DOygOFj5.js +0 -216
  137. package/dist/static-loader-DOygOFj5.js.map +0 -1
  138. package/dist/stream-JaMHMdBD.js.map +0 -1
@@ -1,435 +0,0 @@
1
- import { n as preview, r as rootOf } from "./devtools-C50VH8gZ.js";
2
- //#region src/runtime/devtools-panel.ts
3
- const STYLE = `
4
- :host { all: initial; }
5
- .panel { position: fixed; right: 12px; bottom: 52px; z-index: 2147483647; width: min(520px, calc(100vw - 24px)); height: min(64vh, 620px); display: flex; flex-direction: column; background: #111; color: #eee; font: 12px/1.5 ui-monospace, monospace; border: 1px solid #8884; border-radius: 8px; box-shadow: 0 8px 32px #0006; overflow: hidden; }
6
- .bar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid #8883; align-items: center; flex-wrap: wrap; }
7
- button, select { font: inherit; color: inherit; background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 8px; cursor: pointer; }
8
- select { border-color: #8884; background: #111; }
9
- .bar .tab[aria-selected="true"], .bar button[aria-pressed="true"] { border-color: #8886; background: #fff1; }
10
- .bar .end { margin-left: auto; }
11
- .body { flex: 1; overflow: auto; padding: 8px; }
12
- .component { margin-bottom: 10px; }
13
- .component > button { font-weight: 600; color: #9cf; padding: 0; }
14
- .scope { margin-left: 12px; padding-left: 8px; border-left: 1px solid #8883; }
15
- .scope.selected { border-left-color: #9cf; background: #9cf1; }
16
- .scope-label { color: #aaa; cursor: default; }
17
- .slot { white-space: pre; }
18
- .slot .name { color: #fc9; }
19
- .slot .value { cursor: text; border-bottom: 1px dotted #8886; }
20
- .slot input { font: inherit; color: inherit; background: #000; border: 1px solid #9cf; border-radius: 3px; padding: 0 4px; width: 60%; }
21
- .written { animation: flash 0.8s; }
22
- @keyframes flash { from { background: #fd04; } to { background: transparent; } }
23
- .entry { white-space: pre-wrap; border-bottom: 1px solid #8882; padding: 2px 0; }
24
- .entry .time { color: #888; margin-right: 6px; }
25
- .entry.handler .kind { color: #9cf; }
26
- .entry.part .kind { color: #9e9; }
27
- .entry.write .kind { color: #fc9; }
28
- .entry.call .kind { color: #f9c; }
29
- .filters label { display: inline-flex; gap: 3px; align-items: center; margin-right: 6px; }
30
- pre { margin: 0; white-space: pre-wrap; }
31
- .empty { color: #888; }
32
- svg text { fill: #eee; font: 11px ui-monospace, monospace; }
33
- svg rect { fill: #222; stroke: #8886; }
34
- svg .kind-signal rect, svg .kind-prop rect { stroke: #9cf; }
35
- svg .kind-memo rect { stroke: #c9f; }
36
- svg .kind-effect rect { stroke: #9e9; }
37
- svg .hot rect { fill: #fd03; stroke: #fd0; }
38
- .legend { color: #aaa; margin: 6px 0; }
39
- .legend b { font-weight: normal; }
40
- .legend .signal { color: #9cf; } .legend .memo { color: #c9f; } .legend .effect { color: #9e9; } .legend .hot { color: #fd0; }
41
- svg line { stroke: #8886; }
42
- svg .hot-edge { stroke: #fd0; }
43
- .outline { position: fixed; pointer-events: none; border: 2px solid #9cf; background: #9cf2; border-radius: 3px; z-index: 2147483646; }
44
- `;
45
- const KINDS = [
46
- "handler",
47
- "part",
48
- "write",
49
- "call"
50
- ];
51
- /** How long a write marks the nodes of the graph. */
52
- const HOT_MS = 1500;
53
- const components = /* @__PURE__ */ new Map();
54
- const known = /* @__PURE__ */ new Map();
55
- /** Asks the dev server about a component, once. */
56
- function componentInfo(state, id) {
57
- let info = components.get(id);
58
- if (!info) {
59
- info = fetch(`${state.endpoint}/${encodeURIComponent(id)}`).then((response) => response.ok ? response.json() : void 0).then((value) => {
60
- if (value) known.set(id, value);
61
- return value;
62
- }).catch(() => void 0);
63
- components.set(id, info);
64
- }
65
- return info;
66
- }
67
- function element(tag, attributes = {}, ...children) {
68
- const node = document.createElement(tag);
69
- for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value);
70
- node.append(...children);
71
- return node;
72
- }
73
- function svg(tag, attributes, ...children) {
74
- const node = document.createElementNS("http://www.w3.org/2000/svg", tag);
75
- for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, String(value));
76
- node.append(...children);
77
- return node;
78
- }
79
- /** A value that can be edited as text: what JSON can hold. */
80
- function editable(value) {
81
- if (value === null || [
82
- "string",
83
- "number",
84
- "boolean"
85
- ].includes(typeof value)) return true;
86
- if (typeof value !== "object" || value instanceof Element) return false;
87
- try {
88
- JSON.stringify(value);
89
- return true;
90
- } catch {
91
- return false;
92
- }
93
- }
94
- /** Reads what a person typed: JSON, or else the text as a string. */
95
- function parseValue(text) {
96
- try {
97
- return JSON.parse(text);
98
- } catch {
99
- return text;
100
- }
101
- }
102
- /** A write with the name of its slot, once the dev server has said what it is. */
103
- function describe(entry) {
104
- const write = entry.write;
105
- const info = write && known.get(write.component);
106
- const name = info?.scopes[write.k]?.slots[write.slot];
107
- return name ? `${info.name} ${name} = ${entry.text.split(" = ").slice(1).join(" = ")}` : entry.text;
108
- }
109
- let panel;
110
- /** Opens the panel, or closes it when it is open. */
111
- function togglePanel(root, state) {
112
- if (panel) {
113
- panel.remove();
114
- panel = void 0;
115
- state.changed = void 0;
116
- return;
117
- }
118
- let tab = "scopes";
119
- let selected;
120
- let selectedScope;
121
- let editing;
122
- let paused = false;
123
- const shown = new Set(KINDS);
124
- let frozen;
125
- const body = element("div", { class: "body" });
126
- const bar = element("div", {
127
- class: "bar",
128
- role: "tablist"
129
- });
130
- for (const [name, label] of [
131
- ["scopes", "Scopes"],
132
- ["graph", "Graph"],
133
- ["log", "Log"],
134
- ["report", "Report"]
135
- ]) {
136
- const button = element("button", {
137
- class: "tab",
138
- role: "tab",
139
- "data-tab": name
140
- }, label);
141
- button.addEventListener("click", () => {
142
- tab = name;
143
- draw();
144
- });
145
- bar.append(button);
146
- }
147
- const pick = element("button", {
148
- class: "end",
149
- "aria-pressed": "false",
150
- title: "Click an element of the page to find its scope"
151
- }, "Pick");
152
- bar.append(pick);
153
- panel = element("div", { class: "panel" }, element("style", {}, STYLE), bar, body);
154
- root.append(panel);
155
- if (!state.scopes) document.dispatchEvent(new Event("brumate:core"));
156
- const outlines = [];
157
- const outline = (scope) => {
158
- for (const box of outlines.splice(0)) box.remove();
159
- if (scope === void 0) return;
160
- for (const target of document.querySelectorAll(`[b-b^="${scope}:"]`)) {
161
- const rect = target.getBoundingClientRect();
162
- const box = element("div", {
163
- class: "outline",
164
- style: `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`
165
- });
166
- root.append(box);
167
- outlines.push(box);
168
- }
169
- };
170
- const onPick = (event) => {
171
- const target = event.target?.closest?.("[b-b]");
172
- if (!target || event.composedPath().includes(panel)) return;
173
- event.preventDefault();
174
- event.stopImmediatePropagation();
175
- stopPicking();
176
- const id = target.getAttribute("b-b").split(":")[0];
177
- selectedScope = /^-?\d+$/.test(id) ? Number(id) : id;
178
- const scope = state.scopes?.get(selectedScope);
179
- selected = scope ? rootOf(scope).m : selected;
180
- tab = "scopes";
181
- draw();
182
- };
183
- const stopPicking = () => {
184
- pick.setAttribute("aria-pressed", "false");
185
- window.removeEventListener("click", onPick, true);
186
- document.documentElement.style.cursor = "";
187
- };
188
- pick.addEventListener("click", () => {
189
- if (pick.getAttribute("aria-pressed") === "true") {
190
- stopPicking();
191
- return;
192
- }
193
- pick.setAttribute("aria-pressed", "true");
194
- document.documentElement.style.cursor = "crosshair";
195
- window.addEventListener("click", onPick, true);
196
- });
197
- /** A slot with its name and value. A value that JSON can hold can be edited. */
198
- const drawSlot = (scope, slot, name) => {
199
- const value = scope.s[slot];
200
- const line = element("div", { class: "slot" }, element("span", { class: "name" }, name), " = ");
201
- if (editing?.scope === scope.id && editing.slot === slot) {
202
- const input = element("input", { "aria-label": `New value of ${name}` });
203
- input.value = JSON.stringify(value) ?? "";
204
- input.addEventListener("keydown", (event) => {
205
- if (event.key === "Enter") {
206
- editing = void 0;
207
- state.set?.(scope, slot, parseValue(input.value));
208
- draw();
209
- } else if (event.key === "Escape") {
210
- editing = void 0;
211
- draw();
212
- }
213
- });
214
- line.append(input);
215
- queueMicrotask(() => input.focus());
216
- return line;
217
- }
218
- const canEdit = editable(value) && state.set !== void 0;
219
- const text = element("span", { class: canEdit ? "value" : "" }, preview(value));
220
- if (canEdit) {
221
- text.title = "Click to edit. Enter JSON, or text for a string.";
222
- text.addEventListener("click", () => {
223
- editing = {
224
- scope: scope.id,
225
- slot
226
- };
227
- draw();
228
- });
229
- }
230
- line.append(text);
231
- return line;
232
- };
233
- /** A scope with its slots and the scopes inside it, other than components. */
234
- const drawScope = (scope, info) => {
235
- const plan = info?.scopes[scope.k];
236
- const classes = ["scope"];
237
- if (state.written.has(scope.id)) classes.push("written");
238
- if (selectedScope === scope.id) classes.push("selected");
239
- const label = element("div", { class: "scope-label" }, `scope ${scope.id}${plan ? ` · ${plan.label}` : ""}${scope.h ? " · hidden" : ""}`);
240
- label.addEventListener("mouseenter", () => outline(scope.id));
241
- label.addEventListener("mouseleave", () => outline());
242
- const box = element("div", { class: classes.join(" ") }, label);
243
- scope.s.forEach((_, slot) => box.append(drawSlot(scope, slot, plan?.slots[slot] ?? `slot ${slot}`)));
244
- for (const child of scope.children) if (child.m === void 0) box.append(drawScope(child, info));
245
- return box;
246
- };
247
- const roots = () => [...state.scopes?.values() ?? []].filter((scope) => scope.m !== void 0);
248
- const drawScopes = async () => {
249
- const list = roots();
250
- const infos = await Promise.all(list.map((scope) => componentInfo(state, scope.m)));
251
- const content = element("div");
252
- list.forEach((scope, index) => {
253
- const info = infos[index];
254
- const name = element("button", {}, info ? `${info.name} (${info.file})` : scope.m);
255
- name.title = "Show the graph of this component";
256
- name.addEventListener("click", () => {
257
- selected = scope.m;
258
- tab = "graph";
259
- draw();
260
- });
261
- content.append(element("div", { class: "component" }, name, drawScope(scope, info)));
262
- });
263
- if (list.length === 0) content.append(element("div", { class: "empty" }, "No scopes yet. The first event loads them."));
264
- body.replaceChildren(content);
265
- body.querySelector(".selected")?.scrollIntoView({ block: "nearest" });
266
- };
267
- /** A select of the components on the page, for Graph and Report. */
268
- const chooser = (current) => {
269
- const select = element("select", { "aria-label": "Component" });
270
- for (const id of new Set(roots().map((scope) => scope.m))) {
271
- const option = element("option", { value: id }, known.get(id)?.name ?? id);
272
- option.selected = id === current;
273
- select.append(option);
274
- }
275
- select.addEventListener("change", () => {
276
- selected = select.value;
277
- draw();
278
- });
279
- return element("div", {}, select);
280
- };
281
- let cooling;
282
- const drawGraph = async () => {
283
- const id = selected ?? roots()[0]?.m;
284
- const info = id ? await componentInfo(state, id) : void 0;
285
- if (!id || !info) {
286
- body.replaceChildren(element("div", { class: "empty" }, "No component yet."));
287
- return;
288
- }
289
- if (!info.graph) {
290
- body.replaceChildren(chooser(id), element("div", { class: "empty" }, "The dev server sent no graph. It runs an older brumate than this panel: restart it."));
291
- return;
292
- }
293
- const { nodes, edges } = info.graph;
294
- const instance = roots().find((scope) => scope.m === id);
295
- const scopeOfNode = /* @__PURE__ */ new Map();
296
- const visit = (scope) => {
297
- if (!scopeOfNode.has(scope.k)) scopeOfNode.set(scope.k, scope);
298
- for (const child of scope.children) if (child.m === void 0) visit(child);
299
- };
300
- if (instance) visit(instance);
301
- const now = performance.now();
302
- const hot = /* @__PURE__ */ new Set();
303
- for (const entry of state.log) if (entry.write?.component === id && now - entry.time < HOT_MS) nodes.forEach((node, index) => {
304
- if (node.scope === entry.write.k && node.slot === entry.write.slot) hot.add(index);
305
- });
306
- for (let grew = true; grew;) {
307
- grew = false;
308
- for (const [from, to] of edges) if (hot.has(from) && !hot.has(to)) {
309
- hot.add(to);
310
- grew = true;
311
- }
312
- }
313
- const depth = nodes.map(() => 0);
314
- for (let round = 0, changed = true; changed && round < nodes.length; round++) {
315
- changed = false;
316
- for (const [from, to] of edges) if (depth[from] + 1 > depth[to]) {
317
- depth[to] = depth[from] + 1;
318
- changed = true;
319
- }
320
- }
321
- const rows = /* @__PURE__ */ new Map();
322
- const position = nodes.map((_, index) => {
323
- const column = depth[index];
324
- const row = rows.get(column) ?? 0;
325
- rows.set(column, row + 1);
326
- return {
327
- x: 8 + column * 150,
328
- y: 8 + row * 34
329
- };
330
- });
331
- const graph = svg("svg", {
332
- width: 8 + (Math.max(0, ...depth) + 1) * 150,
333
- height: 8 + Math.max(1, ...rows.values()) * 34,
334
- role: "img",
335
- "aria-label": `Graph of ${info.name}`
336
- });
337
- for (const [from, to] of edges) {
338
- const a = position[from];
339
- const b = position[to];
340
- graph.append(svg("line", {
341
- x1: a.x + 132,
342
- y1: a.y + 12,
343
- x2: b.x,
344
- y2: b.y + 12,
345
- class: hot.has(from) && hot.has(to) ? "hot-edge" : ""
346
- }));
347
- }
348
- nodes.forEach((node, index) => {
349
- const { x, y } = position[index];
350
- const text = svg("text", {
351
- x: x + 6,
352
- y: y + 16
353
- });
354
- const owner = node.slot === void 0 ? void 0 : scopeOfNode.get(node.scope);
355
- const value = owner && node.slot !== void 0 ? ` = ${preview(owner.s[node.slot])}` : "";
356
- text.textContent = `${node.label}${value}`.slice(0, 22);
357
- const title = svg("title", {});
358
- title.textContent = `${node.kind} ${node.label}${value}`;
359
- graph.append(svg("g", { class: `kind-${node.kind}${hot.has(index) ? " hot" : ""}` }, svg("rect", {
360
- x,
361
- y,
362
- width: 132,
363
- height: 24,
364
- rx: 4
365
- }), text, title));
366
- });
367
- const legend = element("div", { class: "legend" }, "What reads what, left to right: ", element("b", { class: "signal" }, "signals and props"), ", ", element("b", { class: "memo" }, "memos"), ", markup and ", element("b", { class: "effect" }, "effects"), ". A change lights up in ", element("b", { class: "hot" }, "yellow"), " what it reaches.");
368
- body.replaceChildren(chooser(id), ...nodes.length > 0 ? [legend, graph] : [element("div", { class: "empty" }, "Nothing in this component changes in the browser.")]);
369
- if (hot.size > 0) {
370
- clearTimeout(cooling);
371
- cooling = setTimeout(() => state.changed?.(), HOT_MS);
372
- }
373
- };
374
- const drawLog = () => {
375
- const filters = element("div", { class: "filters" });
376
- for (const kind of KINDS) {
377
- const box = element("input", { type: "checkbox" });
378
- box.checked = shown.has(kind);
379
- box.addEventListener("change", () => {
380
- if (box.checked) shown.add(kind);
381
- else shown.delete(kind);
382
- draw();
383
- });
384
- filters.append(element("label", {}, box, kind));
385
- }
386
- const pause = element("button", { "aria-pressed": String(paused) }, paused ? "Resume" : "Pause");
387
- pause.addEventListener("click", () => {
388
- paused = !paused;
389
- frozen = paused ? [...state.log] : void 0;
390
- draw();
391
- });
392
- const clear = element("button", {}, "Clear");
393
- clear.addEventListener("click", () => {
394
- state.log.length = 0;
395
- frozen = paused ? [] : void 0;
396
- draw();
397
- });
398
- filters.append(pause, clear);
399
- const list = element("div");
400
- const entries = (frozen ?? state.log).filter((entry) => shown.has(entry.kind));
401
- for (const entry of entries.toReversed()) list.append(element("div", { class: `entry ${entry.kind}` }, element("span", { class: "time" }, `${(entry.time / 1e3).toFixed(2)}s`), element("span", { class: "kind" }, entry.kind), ` ${entry.kind === "write" ? describe(entry) : entry.text}`));
402
- if (entries.length === 0) list.append(element("div", { class: "empty" }, "Nothing to show."));
403
- body.replaceChildren(filters, list);
404
- };
405
- const drawReport = async () => {
406
- const id = selected ?? roots()[0]?.m;
407
- const info = id ? await componentInfo(state, id) : void 0;
408
- body.replaceChildren(...info ? [chooser(id), element("pre", {}, info.text)] : [element("div", { class: "empty" }, "No component yet.")]);
409
- };
410
- let queued = false;
411
- const draw = () => {
412
- for (const button of bar.querySelectorAll(".tab")) button.setAttribute("aria-selected", String(button.dataset.tab === tab));
413
- if (tab === "log") {
414
- drawLog();
415
- return;
416
- }
417
- (tab === "scopes" ? drawScopes() : tab === "graph" ? drawGraph() : drawReport()).then(() => {
418
- if (tab === "scopes") state.written.clear();
419
- });
420
- };
421
- state.changed = () => {
422
- if (!queued && !editing && !(paused && tab === "log")) {
423
- queued = true;
424
- requestAnimationFrame(() => {
425
- queued = false;
426
- if (panel) draw();
427
- });
428
- }
429
- };
430
- draw();
431
- }
432
- //#endregion
433
- export { togglePanel };
434
-
435
- //# sourceMappingURL=devtools-panel-AYjfwPhj.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtools-panel-AYjfwPhj.js","names":[],"sources":["../src/runtime/devtools-panel.ts"],"sourcesContent":["// The panel of the devtools overlay. It reads the core through the hooks in\n// `devtools.ts`, and asks the dev server about each component.\n//\n// - Scopes: each component on the page, its scopes and the value of each\n// slot by name. A value can be edited, which writes it as a handler does.\n// Hovering a scope outlines its elements, and Pick finds the scope of an\n// element of the page.\n// - Graph: the values and markup of a component that change in the\n// browser, and what reads what. A write marks its node and the nodes after it.\n// - Log: handlers, loaded parts, writes and server function calls.\n// - Report: the inspect report of a component.\n\nimport type { Scope } from './client.ts';\nimport type { ScopeId } from './shared.ts';\nimport { preview, rootOf } from './devtools.ts';\nimport type { DevtoolsEntry, DevtoolsState } from './devtools.ts';\n\n/** What the dev server tells about a component: see the inspect endpoint of the plugin. */\ninterface ComponentInfo {\n name: string;\n file: string;\n /** Each scope of the component, by its number in the compiled component. */\n scopes: Record<number, { label: string; slots: string[] }>;\n graph?: {\n nodes: { kind: string; label: string; scope: number; slot?: number }[];\n /** Pairs of node indexes: the first is read by the second. */\n edges: [number, number][];\n };\n /** The inspect report as text. */\n text: string;\n}\n\nconst STYLE = `\n:host { all: initial; }\n.panel { position: fixed; right: 12px; bottom: 52px; z-index: 2147483647; width: min(520px, calc(100vw - 24px)); height: min(64vh, 620px); display: flex; flex-direction: column; background: #111; color: #eee; font: 12px/1.5 ui-monospace, monospace; border: 1px solid #8884; border-radius: 8px; box-shadow: 0 8px 32px #0006; overflow: hidden; }\n.bar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid #8883; align-items: center; flex-wrap: wrap; }\nbutton, select { font: inherit; color: inherit; background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 8px; cursor: pointer; }\nselect { border-color: #8884; background: #111; }\n.bar .tab[aria-selected=\"true\"], .bar button[aria-pressed=\"true\"] { border-color: #8886; background: #fff1; }\n.bar .end { margin-left: auto; }\n.body { flex: 1; overflow: auto; padding: 8px; }\n.component { margin-bottom: 10px; }\n.component > button { font-weight: 600; color: #9cf; padding: 0; }\n.scope { margin-left: 12px; padding-left: 8px; border-left: 1px solid #8883; }\n.scope.selected { border-left-color: #9cf; background: #9cf1; }\n.scope-label { color: #aaa; cursor: default; }\n.slot { white-space: pre; }\n.slot .name { color: #fc9; }\n.slot .value { cursor: text; border-bottom: 1px dotted #8886; }\n.slot input { font: inherit; color: inherit; background: #000; border: 1px solid #9cf; border-radius: 3px; padding: 0 4px; width: 60%; }\n.written { animation: flash 0.8s; }\n@keyframes flash { from { background: #fd04; } to { background: transparent; } }\n.entry { white-space: pre-wrap; border-bottom: 1px solid #8882; padding: 2px 0; }\n.entry .time { color: #888; margin-right: 6px; }\n.entry.handler .kind { color: #9cf; }\n.entry.part .kind { color: #9e9; }\n.entry.write .kind { color: #fc9; }\n.entry.call .kind { color: #f9c; }\n.filters label { display: inline-flex; gap: 3px; align-items: center; margin-right: 6px; }\npre { margin: 0; white-space: pre-wrap; }\n.empty { color: #888; }\nsvg text { fill: #eee; font: 11px ui-monospace, monospace; }\nsvg rect { fill: #222; stroke: #8886; }\nsvg .kind-signal rect, svg .kind-prop rect { stroke: #9cf; }\nsvg .kind-memo rect { stroke: #c9f; }\nsvg .kind-effect rect { stroke: #9e9; }\nsvg .hot rect { fill: #fd03; stroke: #fd0; }\n.legend { color: #aaa; margin: 6px 0; }\n.legend b { font-weight: normal; }\n.legend .signal { color: #9cf; } .legend .memo { color: #c9f; } .legend .effect { color: #9e9; } .legend .hot { color: #fd0; }\nsvg line { stroke: #8886; }\nsvg .hot-edge { stroke: #fd0; }\n.outline { position: fixed; pointer-events: none; border: 2px solid #9cf; background: #9cf2; border-radius: 3px; z-index: 2147483646; }\n`;\n\ntype Tab = 'scopes' | 'graph' | 'log' | 'report';\nconst KINDS: DevtoolsEntry['kind'][] = ['handler', 'part', 'write', 'call'];\n/** How long a write marks the nodes of the graph. */\nconst HOT_MS = 1500;\n\nconst components = new Map<string, Promise<ComponentInfo | undefined>>();\nconst known = new Map<string, ComponentInfo>();\n\n/** Asks the dev server about a component, once. */\nfunction componentInfo(state: DevtoolsState, id: string): Promise<ComponentInfo | undefined> {\n let info = components.get(id);\n if (!info) {\n info = fetch(`${state.endpoint}/${encodeURIComponent(id)}`)\n .then((response) => (response.ok ? (response.json() as Promise<ComponentInfo>) : undefined))\n .then((value) => {\n if (value) {\n known.set(id, value);\n }\n return value;\n })\n .catch(() => undefined);\n components.set(id, info);\n }\n return info;\n}\n\nfunction element<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attributes: Record<string, string> = {},\n ...children: (Node | string)[]\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n for (const [name, value] of Object.entries(attributes)) {\n node.setAttribute(name, value);\n }\n node.append(...children);\n return node;\n}\n\nfunction svg(\n tag: string,\n attributes: Record<string, string | number>,\n ...children: Node[]\n): SVGElement {\n const node = document.createElementNS('http://www.w3.org/2000/svg', tag);\n for (const [name, value] of Object.entries(attributes)) {\n node.setAttribute(name, String(value));\n }\n node.append(...children);\n return node;\n}\n\n/** A value that can be edited as text: what JSON can hold. */\nfunction editable(value: unknown): boolean {\n if (value === null || ['string', 'number', 'boolean'].includes(typeof value)) {\n return true;\n }\n if (typeof value !== 'object' || value instanceof Element) {\n return false;\n }\n try {\n JSON.stringify(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Reads what a person typed: JSON, or else the text as a string. */\nfunction parseValue(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\n/** A write with the name of its slot, once the dev server has said what it is. */\nfunction describe(entry: DevtoolsEntry): string {\n const write = entry.write;\n const info = write && known.get(write.component);\n const name = info?.scopes[write!.k]?.slots[write!.slot];\n return name\n ? `${info!.name} ${name} = ${entry.text.split(' = ').slice(1).join(' = ')}`\n : entry.text;\n}\n\nlet panel: HTMLElement | undefined;\n\n/** Opens the panel, or closes it when it is open. */\nexport function togglePanel(root: ShadowRoot, state: DevtoolsState): void {\n if (panel) {\n panel.remove();\n panel = undefined;\n state.changed = undefined;\n return;\n }\n let tab: Tab = 'scopes';\n let selected: string | undefined;\n let selectedScope: ScopeId | undefined;\n let editing: { scope: ScopeId; slot: number } | undefined;\n let paused = false;\n const shown = new Set<DevtoolsEntry['kind']>(KINDS);\n // The log as it was when Pause was pressed.\n let frozen: DevtoolsEntry[] | undefined;\n\n const body = element('div', { class: 'body' });\n const bar = element('div', { class: 'bar', role: 'tablist' });\n for (const [name, label] of [\n ['scopes', 'Scopes'],\n ['graph', 'Graph'],\n ['log', 'Log'],\n ['report', 'Report'],\n ] as const) {\n const button = element('button', { class: 'tab', role: 'tab', 'data-tab': name }, label);\n button.addEventListener('click', () => {\n tab = name;\n draw();\n });\n bar.append(button);\n }\n const pick = element(\n 'button',\n {\n class: 'end',\n 'aria-pressed': 'false',\n title: 'Click an element of the page to find its scope',\n },\n 'Pick',\n );\n bar.append(pick);\n panel = element('div', { class: 'panel' }, element('style', {}, STYLE), bar, body);\n root.append(panel);\n // Without an event, the core has not loaded yet, and nothing knows the components of the page.\n if (!state.scopes) {\n document.dispatchEvent(new Event('brumate:core'));\n }\n\n // Outlines the elements of a scope on the page.\n const outlines: HTMLElement[] = [];\n const outline = (scope?: ScopeId): void => {\n for (const box of outlines.splice(0)) {\n box.remove();\n }\n if (scope === undefined) {\n return;\n }\n for (const target of document.querySelectorAll(`[b-b^=\"${scope}:\"]`)) {\n const rect = target.getBoundingClientRect();\n const box = element('div', {\n class: 'outline',\n style: `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`,\n });\n root.append(box);\n outlines.push(box);\n }\n };\n\n // Pick: the next click on the page selects the scope of its element.\n const onPick = (event: MouseEvent): void => {\n const target = (event.target as Element | null)?.closest?.('[b-b]');\n if (!target || event.composedPath().includes(panel!)) {\n return;\n }\n event.preventDefault();\n event.stopImmediatePropagation();\n stopPicking();\n const id = target.getAttribute('b-b')!.split(':')[0]!;\n selectedScope = /^-?\\d+$/.test(id) ? Number(id) : id;\n const scope = state.scopes?.get(selectedScope);\n selected = scope ? rootOf(scope).m : selected;\n tab = 'scopes';\n draw();\n };\n const stopPicking = (): void => {\n pick.setAttribute('aria-pressed', 'false');\n window.removeEventListener('click', onPick, true);\n document.documentElement.style.cursor = '';\n };\n pick.addEventListener('click', () => {\n if (pick.getAttribute('aria-pressed') === 'true') {\n stopPicking();\n return;\n }\n pick.setAttribute('aria-pressed', 'true');\n document.documentElement.style.cursor = 'crosshair';\n // On the window, so it runs before the listeners of the loader on the document.\n window.addEventListener('click', onPick, true);\n });\n\n /** A slot with its name and value. A value that JSON can hold can be edited. */\n const drawSlot = (scope: Scope, slot: number, name: string): HTMLElement => {\n const value = scope.s[slot];\n const line = element('div', { class: 'slot' }, element('span', { class: 'name' }, name), ' = ');\n if (editing?.scope === scope.id && editing.slot === slot) {\n const input = element('input', { 'aria-label': `New value of ${name}` });\n input.value = JSON.stringify(value) ?? '';\n input.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n editing = undefined;\n state.set?.(scope, slot, parseValue(input.value));\n draw();\n } else if (event.key === 'Escape') {\n editing = undefined;\n draw();\n }\n });\n line.append(input);\n queueMicrotask(() => input.focus());\n return line;\n }\n const canEdit = editable(value) && state.set !== undefined;\n const text = element('span', { class: canEdit ? 'value' : '' }, preview(value));\n if (canEdit) {\n text.title = 'Click to edit. Enter JSON, or text for a string.';\n text.addEventListener('click', () => {\n editing = { scope: scope.id, slot };\n draw();\n });\n }\n line.append(text);\n return line;\n };\n\n /** A scope with its slots and the scopes inside it, other than components. */\n const drawScope = (scope: Scope, info: ComponentInfo | undefined): HTMLElement => {\n const plan = info?.scopes[scope.k];\n const classes = ['scope'];\n if (state.written.has(scope.id)) {\n classes.push('written');\n }\n if (selectedScope === scope.id) {\n classes.push('selected');\n }\n const label = element(\n 'div',\n { class: 'scope-label' },\n // A hidden `#offscreen` body keeps its scope and its slots.\n `scope ${scope.id}${plan ? ` · ${plan.label}` : ''}${scope.h ? ' · hidden' : ''}`,\n );\n label.addEventListener('mouseenter', () => outline(scope.id));\n label.addEventListener('mouseleave', () => outline());\n const box = element('div', { class: classes.join(' ') }, label);\n scope.s.forEach((_, slot) =>\n box.append(drawSlot(scope, slot, plan?.slots[slot] ?? `slot ${slot}`)),\n );\n for (const child of scope.children) {\n if (child.m === undefined) {\n box.append(drawScope(child, info));\n }\n }\n return box;\n };\n\n const roots = (): Scope[] =>\n [...(state.scopes?.values() ?? [])].filter((scope) => scope.m !== undefined);\n\n const drawScopes = async (): Promise<void> => {\n const list = roots();\n const infos = await Promise.all(list.map((scope) => componentInfo(state, scope.m!)));\n const content = element('div');\n list.forEach((scope, index) => {\n const info = infos[index];\n const name = element('button', {}, info ? `${info.name} (${info.file})` : scope.m!);\n name.title = 'Show the graph of this component';\n name.addEventListener('click', () => {\n selected = scope.m;\n tab = 'graph';\n draw();\n });\n content.append(element('div', { class: 'component' }, name, drawScope(scope, info)));\n });\n if (list.length === 0) {\n content.append(\n element('div', { class: 'empty' }, 'No scopes yet. The first event loads them.'),\n );\n }\n body.replaceChildren(content);\n body.querySelector('.selected')?.scrollIntoView({ block: 'nearest' });\n };\n\n /** A select of the components on the page, for Graph and Report. */\n const chooser = (current: string | undefined): HTMLElement => {\n const select = element('select', { 'aria-label': 'Component' });\n for (const id of new Set(roots().map((scope) => scope.m!))) {\n const option = element('option', { value: id }, known.get(id)?.name ?? id);\n option.selected = id === current;\n select.append(option);\n }\n select.addEventListener('change', () => {\n selected = select.value;\n draw();\n });\n return element('div', {}, select);\n };\n\n let cooling: ReturnType<typeof setTimeout> | undefined;\n\n const drawGraph = async (): Promise<void> => {\n const id = selected ?? roots()[0]?.m;\n const info = id ? await componentInfo(state, id) : undefined;\n if (!id || !info) {\n body.replaceChildren(element('div', { class: 'empty' }, 'No component yet.'));\n return;\n }\n if (!info.graph) {\n body.replaceChildren(\n chooser(id),\n element(\n 'div',\n { class: 'empty' },\n 'The dev server sent no graph. It runs an older brumate than this panel: restart it.',\n ),\n );\n return;\n }\n const { nodes, edges } = info.graph;\n // The current value of each value node, from the first instance of the component.\n const instance = roots().find((scope) => scope.m === id);\n // The first scope of the instance for each scope in the compiled component.\n const scopeOfNode = new Map<number, Scope>();\n const visit = (scope: Scope): void => {\n if (!scopeOfNode.has(scope.k)) {\n scopeOfNode.set(scope.k, scope);\n }\n for (const child of scope.children) {\n if (child.m === undefined) {\n visit(child);\n }\n }\n };\n if (instance) {\n visit(instance);\n }\n // Nodes that a recent write reached: the written value, and what reads it.\n const now = performance.now();\n const hot = new Set<number>();\n for (const entry of state.log) {\n if (entry.write?.component === id && now - entry.time < HOT_MS) {\n nodes.forEach((node, index) => {\n if (node.scope === entry.write!.k && node.slot === entry.write!.slot) {\n hot.add(index);\n }\n });\n }\n }\n for (let grew = true; grew;) {\n grew = false;\n for (const [from, to] of edges) {\n if (hot.has(from) && !hot.has(to)) {\n hot.add(to);\n grew = true;\n }\n }\n }\n // Columns by the longest path from a value that nothing feeds.\n const depth = nodes.map(() => 0);\n for (let round = 0, changed = true; changed && round < nodes.length; round++) {\n changed = false;\n for (const [from, to] of edges) {\n if (depth[from]! + 1 > depth[to]!) {\n depth[to] = depth[from]! + 1;\n changed = true;\n }\n }\n }\n const rows = new Map<number, number>();\n const position = nodes.map((_, index) => {\n const column = depth[index]!;\n const row = rows.get(column) ?? 0;\n rows.set(column, row + 1);\n return { x: 8 + column * 150, y: 8 + row * 34 };\n });\n const width = 8 + (Math.max(0, ...depth) + 1) * 150;\n const height = 8 + Math.max(1, ...rows.values()) * 34;\n const graph = svg('svg', { width, height, role: 'img', 'aria-label': `Graph of ${info.name}` });\n for (const [from, to] of edges) {\n const a = position[from]!;\n const b = position[to]!;\n graph.append(\n svg('line', {\n x1: a.x + 132,\n y1: a.y + 12,\n x2: b.x,\n y2: b.y + 12,\n class: hot.has(from) && hot.has(to) ? 'hot-edge' : '',\n }),\n );\n }\n nodes.forEach((node, index) => {\n const { x, y } = position[index]!;\n const text = svg('text', { x: x + 6, y: y + 16 });\n const owner = node.slot === undefined ? undefined : scopeOfNode.get(node.scope);\n const value = owner && node.slot !== undefined ? ` = ${preview(owner.s[node.slot])}` : '';\n text.textContent = `${node.label}${value}`.slice(0, 22);\n const title = svg('title', {});\n title.textContent = `${node.kind} ${node.label}${value}`;\n graph.append(\n svg(\n 'g',\n { class: `kind-${node.kind}${hot.has(index) ? ' hot' : ''}` },\n svg('rect', { x, y, width: 132, height: 24, rx: 4 }),\n text,\n title,\n ),\n );\n });\n const legend = element(\n 'div',\n { class: 'legend' },\n 'What reads what, left to right: ',\n element('b', { class: 'signal' }, 'signals and props'),\n ', ',\n element('b', { class: 'memo' }, 'memos'),\n ', markup and ',\n element('b', { class: 'effect' }, 'effects'),\n '. A change lights up in ',\n element('b', { class: 'hot' }, 'yellow'),\n ' what it reaches.',\n );\n body.replaceChildren(\n chooser(id),\n ...(nodes.length > 0\n ? [legend, graph]\n : [\n element('div', { class: 'empty' }, 'Nothing in this component changes in the browser.'),\n ]),\n );\n // Draws again when the marks of the last write expire.\n if (hot.size > 0) {\n clearTimeout(cooling);\n cooling = setTimeout(() => state.changed?.(), HOT_MS);\n }\n };\n\n const drawLog = (): void => {\n const filters = element('div', { class: 'filters' });\n for (const kind of KINDS) {\n const box = element('input', { type: 'checkbox' });\n box.checked = shown.has(kind);\n box.addEventListener('change', () => {\n if (box.checked) {\n shown.add(kind);\n } else {\n shown.delete(kind);\n }\n draw();\n });\n filters.append(element('label', {}, box, kind));\n }\n const pause = element(\n 'button',\n { 'aria-pressed': String(paused) },\n paused ? 'Resume' : 'Pause',\n );\n pause.addEventListener('click', () => {\n paused = !paused;\n frozen = paused ? [...state.log] : undefined;\n draw();\n });\n const clear = element('button', {}, 'Clear');\n clear.addEventListener('click', () => {\n state.log.length = 0;\n frozen = paused ? [] : undefined;\n draw();\n });\n filters.append(pause, clear);\n const list = element('div');\n const entries = (frozen ?? state.log).filter((entry) => shown.has(entry.kind));\n for (const entry of entries.toReversed()) {\n list.append(\n element(\n 'div',\n { class: `entry ${entry.kind}` },\n element('span', { class: 'time' }, `${(entry.time / 1000).toFixed(2)}s`),\n element('span', { class: 'kind' }, entry.kind),\n ` ${entry.kind === 'write' ? describe(entry) : entry.text}`,\n ),\n );\n }\n if (entries.length === 0) {\n list.append(element('div', { class: 'empty' }, 'Nothing to show.'));\n }\n body.replaceChildren(filters, list);\n };\n\n const drawReport = async (): Promise<void> => {\n const id = selected ?? roots()[0]?.m;\n const info = id ? await componentInfo(state, id) : undefined;\n body.replaceChildren(\n ...(info\n ? [chooser(id), element('pre', {}, info.text)]\n : [element('div', { class: 'empty' }, 'No component yet.')]),\n );\n };\n\n let queued = false;\n const draw = (): void => {\n for (const button of bar.querySelectorAll('.tab')) {\n button.setAttribute('aria-selected', String((button as HTMLElement).dataset.tab === tab));\n }\n if (tab === 'log') {\n drawLog();\n return;\n }\n const drawn = tab === 'scopes' ? drawScopes() : tab === 'graph' ? drawGraph() : drawReport();\n // Marks of writes show once, on the next draw of the scopes.\n void drawn.then(() => {\n if (tab === 'scopes') {\n state.written.clear();\n }\n });\n };\n // Changes come in bursts, so the panel draws once per frame. It waits while a value is edited.\n state.changed = () => {\n if (!queued && !editing && !(paused && tab === 'log')) {\n queued = true;\n requestAnimationFrame(() => {\n queued = false;\n if (panel) {\n draw();\n }\n });\n }\n };\n draw();\n}\n"],"mappings":";;AAgCA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4Cd,MAAM,QAAiC;CAAC;CAAW;CAAQ;CAAS;AAAM;;AAE1E,MAAM,SAAS;AAEf,MAAM,6BAAa,IAAI,IAAgD;AACvE,MAAM,wBAAQ,IAAI,IAA2B;;AAG7C,SAAS,cAAc,OAAsB,IAAgD;CAC3F,IAAI,OAAO,WAAW,IAAI,EAAE;CAC5B,IAAI,CAAC,MAAM;EACT,OAAO,MAAM,GAAG,MAAM,SAAS,GAAG,mBAAmB,EAAE,GAAG,CAAC,CACxD,MAAM,aAAc,SAAS,KAAM,SAAS,KAAK,IAA+B,KAAA,CAAU,CAAC,CAC3F,MAAM,UAAU;GACf,IAAI,OACF,MAAM,IAAI,IAAI,KAAK;GAErB,OAAO;EACT,CAAC,CAAC,CACD,YAAY,KAAA,CAAS;EACxB,WAAW,IAAI,IAAI,IAAI;CACzB;CACA,OAAO;AACT;AAEA,SAAS,QACP,KACA,aAAqC,CAAC,GACtC,GAAG,UACuB;CAC1B,MAAM,OAAO,SAAS,cAAc,GAAG;CACvC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,KAAK,aAAa,MAAM,KAAK;CAE/B,KAAK,OAAO,GAAG,QAAQ;CACvB,OAAO;AACT;AAEA,SAAS,IACP,KACA,YACA,GAAG,UACS;CACZ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O,CAAC,GAAG,KAAK,IAAI,CAAC,IAC3C,CAAC,QAAQ,OAAO,EAAE,OAAO,QAAQ,GAAG,mBAAmB,CAAC,CAC9D;CACF;CAEA,IAAI,SAAS;CACb,MAAM,aAAmB;EACvB,KAAK,MAAM,UAAU,IAAI,iBAAiB,MAAM,GAC9C,OAAO,aAAa,iBAAiB,OAAQ,OAAuB,QAAQ,QAAQ,GAAG,CAAC;EAE1F,IAAI,QAAQ,OAAO;GACjB,QAAQ;GACR;EACF;EAGA,CAFc,QAAQ,WAAW,WAAW,IAAI,QAAQ,UAAU,UAAU,IAAI,WAAW,EAAA,CAEhF,WAAW;GACpB,IAAI,QAAQ,UACV,MAAM,QAAQ,MAAM;EAExB,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,QAAQ,QAAQ;GACrD,SAAS;GACT,4BAA4B;IAC1B,SAAS;IACT,IAAI,OACF,KAAK;GAET,CAAC;EACH;CACF;CACA,KAAK;AACP"}
@@ -1,52 +0,0 @@
1
- //#region src/runtime/events.ts
2
- /** The keys that `prevent` can name, by their `event.key`. `Space` is the space bar. */
3
- const KEY_NAMES = [
4
- "Enter",
5
- "Escape",
6
- "Tab",
7
- "Space",
8
- "Backspace",
9
- "Delete",
10
- "Insert",
11
- "ArrowUp",
12
- "ArrowDown",
13
- "ArrowLeft",
14
- "ArrowRight",
15
- "Home",
16
- "End",
17
- "PageUp",
18
- "PageDown",
19
- "ContextMenu",
20
- ...Array.from({ length: 12 }, (_, index) => `F${index + 1}`)
21
- ];
22
- /** The modifiers of a handler, which `spread` writes into `b-on`. A symbol of the registry. */
23
- const MODIFIERS = Symbol.for("brumate.modifiers");
24
- function tagged(handler, modifier) {
25
- const copy = ((...args) => handler(...args));
26
- copy[MODIFIERS] = [...handler[MODIFIERS] ?? [], modifier];
27
- return copy;
28
- }
29
- /**
30
- * Prevents the default action of the event, before the handler's code
31
- * loads. With keys, on a keyboard event, it prevents only those keys, and
32
- * the handler still runs for every key.
33
- */
34
- function prevent(handler, ...keys) {
35
- return tagged(handler, keys.length > 0 ? `prevent(${keys.join(",")})` : "prevent");
36
- }
37
- /** Stops the event at this element, so the handlers of the elements around it do not run. */
38
- function stop(handler) {
39
- return tagged(handler, "stop");
40
- }
41
- /** Runs the handler for the first event only. */
42
- function once(handler) {
43
- return tagged(handler, "once");
44
- }
45
- /** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */
46
- function capture(handler) {
47
- return tagged(handler, "capture");
48
- }
49
- //#endregion
50
- export { prevent as a, once as i, MODIFIERS as n, stop as o, capture as r, KEY_NAMES as t };
51
-
52
- //# sourceMappingURL=events-BKWRqtMg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events-BKWRqtMg.js","names":[],"sources":["../src/runtime/events.ts"],"sourcesContent":["// Wrappers for event handlers that act before the handler's code loads. The\n// compiler reads the calls in markup and writes them into `b-on`, so the\n// loader applies them on the first event. At run time, each returns a copy of\n// the handler that carries its modifiers, so a handler passed on as a prop\n// keeps them.\n\n/** The keys that `prevent` can name, by their `event.key`. `Space` is the space bar. */\nexport const KEY_NAMES: readonly string[] = [\n 'Enter',\n 'Escape',\n 'Tab',\n 'Space',\n 'Backspace',\n 'Delete',\n 'Insert',\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'ContextMenu',\n ...Array.from({ length: 12 }, (_, index) => `F${index + 1}`),\n];\n\ntype Letter =\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z';\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\ntype FunctionKey = `F${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;\n\n/** A key by its `event.key`: a named key, a letter or a digit. */\nexport type KeyName =\n | 'Enter'\n | 'Escape'\n | 'Tab'\n | 'Space'\n | 'Backspace'\n | 'Delete'\n | 'Insert'\n | 'ArrowUp'\n | 'ArrowDown'\n | 'ArrowLeft'\n | 'ArrowRight'\n | 'Home'\n | 'End'\n | 'PageUp'\n | 'PageDown'\n | 'ContextMenu'\n | FunctionKey\n | Letter\n | Uppercase<Letter>\n | Digit;\n\n/** The modifiers of a handler, which `spread` writes into `b-on`. A symbol of the registry. */\nexport const MODIFIERS: unique symbol = Symbol.for('brumate.modifiers');\n\n/** A handler with the modifiers of its wrappers. */\n// oxlint-disable-next-line typescript/no-explicit-any -- Handlers take any event.\ntype Handler = (...args: any[]) => unknown;\n\nfunction tagged<H extends Handler>(handler: H, modifier: string): H {\n const copy = ((...args: unknown[]) => handler(...args)) as H & { [MODIFIERS]?: string[] };\n copy[MODIFIERS] = [...((handler as { [MODIFIERS]?: string[] })[MODIFIERS] ?? []), modifier];\n return copy;\n}\n\n/**\n * Prevents the default action of the event, before the handler's code\n * loads. With keys, on a keyboard event, it prevents only those keys, and\n * the handler still runs for every key.\n */\nexport function prevent<H extends Handler>(handler: H, ...keys: KeyName[]): H {\n return tagged(handler, keys.length > 0 ? `prevent(${keys.join(',')})` : 'prevent');\n}\n\n/** Stops the event at this element, so the handlers of the elements around it do not run. */\nexport function stop<H extends Handler>(handler: H): H {\n return tagged(handler, 'stop');\n}\n\n/** Runs the handler for the first event only. */\nexport function once<H extends Handler>(handler: H): H {\n return tagged(handler, 'once');\n}\n\n/** Runs the handler before the handlers of the elements inside, as a listener in the capture phase. */\nexport function capture<H extends Handler>(handler: H): H {\n return tagged(handler, 'capture');\n}\n"],"mappings":";;AAOA,MAAa,YAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAG,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,IAAI,QAAQ,GAAG;AAC7D;;AAwDA,MAAa,YAA2B,OAAO,IAAI,mBAAmB;AAMtE,SAAS,OAA0B,SAAY,UAAqB;CAClE,MAAM,SAAS,GAAG,SAAoB,QAAQ,GAAG,IAAI;CACrD,KAAK,aAAa,CAAC,GAAK,QAAuC,cAAc,CAAC,GAAI,QAAQ;CAC1F,OAAO;AACT;;;;;;AAOA,SAAgB,QAA2B,SAAY,GAAG,MAAoB;CAC5E,OAAO,OAAO,SAAS,KAAK,SAAS,IAAI,WAAW,KAAK,KAAK,GAAG,EAAE,KAAK,SAAS;AACnF;;AAGA,SAAgB,KAAwB,SAAe;CACrD,OAAO,OAAO,SAAS,MAAM;AAC/B;;AAGA,SAAgB,KAAwB,SAAe;CACrD,OAAO,OAAO,SAAS,MAAM;AAC/B;;AAGA,SAAgB,QAA2B,SAAe;CACxD,OAAO,OAAO,SAAS,SAAS;AAClC"}