aktion-runtime 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -31
- package/dist/aktion.iife.js +106 -460
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +5688 -5055
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +106 -460
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/devtools.js +1367 -0
- package/dist/devtools.js.map +1 -0
- package/dist/language.js +15311 -0
- package/dist/language.js.map +1 -0
- package/dist/plugin.cjs +2650 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +2650 -0
- package/dist/plugin.js.map +1 -0
- package/dist/system_prompt.txt +164 -447
- package/dist/system_prompt_chat.txt +33 -84
- package/dist/testing.js +29496 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/aktion-modules.d.ts +18 -0
- package/dist/types/compiler/index.d.ts +12 -0
- package/dist/types/compiler/linker.d.ts +27 -0
- package/dist/types/compiler/project.d.ts +45 -0
- package/dist/types/compiler/runtime.d.ts +59 -0
- package/dist/types/devtools/hook.d.ts +88 -0
- package/dist/types/devtools/index.d.ts +35 -0
- package/dist/types/devtools/panel.d.ts +109 -0
- package/dist/types/devtools/protocol.d.ts +130 -0
- package/dist/types/devtools/styles.d.ts +7 -0
- package/dist/types/element.d.ts +76 -8
- package/dist/types/index.d.ts +1 -0
- package/dist/types/language-api.d.ts +15 -0
- package/dist/types/parser/types.d.ts +38 -1
- package/dist/types/plugin/index.d.ts +17 -0
- package/dist/types/renderer/renderer.d.ts +28 -0
- package/dist/types/runtime/builtins.d.ts +5 -11
- package/dist/types/runtime/effects.d.ts +15 -0
- package/dist/types/runtime/http.d.ts +0 -1
- package/dist/types/testing/index.d.ts +201 -0
- package/dist/types/theme/index.d.ts +3 -3
- package/dist/types/theme/styles.d.ts +1 -1
- package/dist/types/tooling/formatter.d.ts +7 -1
- package/dist/types/tooling/index.d.ts +0 -3
- package/package.json +35 -2
- package/dist/types/library/components/theme.d.ts +0 -2
- package/dist/types/tooling/codemod.d.ts +0 -36
package/dist/devtools.js
ADDED
|
@@ -0,0 +1,1367 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const HOOK_KEY = "__AKTION_DEVTOOLS_HOOK__";
|
|
5
|
+
const DEVTOOLS_PROTOCOL_VERSION = 1;
|
|
6
|
+
function hookGlobal() {
|
|
7
|
+
return globalThis;
|
|
8
|
+
}
|
|
9
|
+
function getDevtoolsHook() {
|
|
10
|
+
return hookGlobal()[HOOK_KEY];
|
|
11
|
+
}
|
|
12
|
+
function isDevtoolsActive() {
|
|
13
|
+
const hook = getDevtoolsHook();
|
|
14
|
+
return hook !== void 0 && hook.active;
|
|
15
|
+
}
|
|
16
|
+
function installDevtoolsHook(libraryVersion = "0.5.x") {
|
|
17
|
+
const existing = getDevtoolsHook();
|
|
18
|
+
if (existing) {
|
|
19
|
+
existing.libraryVersion = libraryVersion;
|
|
20
|
+
return existing;
|
|
21
|
+
}
|
|
22
|
+
const eventListeners = /* @__PURE__ */ new Set();
|
|
23
|
+
const appListeners = /* @__PURE__ */ new Set();
|
|
24
|
+
const apps = /* @__PURE__ */ new Map();
|
|
25
|
+
const buffer = [];
|
|
26
|
+
const hook = {
|
|
27
|
+
aktion: true,
|
|
28
|
+
protocolVersion: DEVTOOLS_PROTOCOL_VERSION,
|
|
29
|
+
libraryVersion,
|
|
30
|
+
apps,
|
|
31
|
+
buffer,
|
|
32
|
+
bufferLimit: 500,
|
|
33
|
+
get active() {
|
|
34
|
+
return eventListeners.size > 0 || appListeners.size > 0;
|
|
35
|
+
},
|
|
36
|
+
emit(event) {
|
|
37
|
+
buffer.push(event);
|
|
38
|
+
if (buffer.length > hook.bufferLimit) {
|
|
39
|
+
buffer.splice(0, buffer.length - hook.bufferLimit);
|
|
40
|
+
}
|
|
41
|
+
for (const listener of [...eventListeners]) {
|
|
42
|
+
try {
|
|
43
|
+
listener(event);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error("[aktion-devtools] event listener threw", err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
registerApp(app) {
|
|
50
|
+
apps.set(app.id, app);
|
|
51
|
+
for (const listener of [...appListeners]) {
|
|
52
|
+
try {
|
|
53
|
+
listener("register", app);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error("[aktion-devtools] app listener threw", err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
unregisterApp(id) {
|
|
60
|
+
const app = apps.get(id);
|
|
61
|
+
if (!app) return;
|
|
62
|
+
apps.delete(id);
|
|
63
|
+
for (const listener of [...appListeners]) {
|
|
64
|
+
try {
|
|
65
|
+
listener("unregister", app);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error("[aktion-devtools] app listener threw", err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
subscribe(listener) {
|
|
72
|
+
eventListeners.add(listener);
|
|
73
|
+
return () => eventListeners.delete(listener);
|
|
74
|
+
},
|
|
75
|
+
subscribeApps(listener) {
|
|
76
|
+
appListeners.add(listener);
|
|
77
|
+
return () => appListeners.delete(listener);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
hookGlobal()[HOOK_KEY] = hook;
|
|
81
|
+
return hook;
|
|
82
|
+
}
|
|
83
|
+
const devtoolsStyles = `
|
|
84
|
+
:host {
|
|
85
|
+
--dt-bg: #16181d;
|
|
86
|
+
--dt-bg-raised: #1d2026;
|
|
87
|
+
--dt-bg-inset: #101216;
|
|
88
|
+
--dt-border: #2b2f38;
|
|
89
|
+
--dt-border-strong: #3a3f4b;
|
|
90
|
+
--dt-text: #e6e8ec;
|
|
91
|
+
--dt-text-dim: #9aa0ab;
|
|
92
|
+
--dt-text-faint: #6b7280;
|
|
93
|
+
--dt-accent: #7c9cff;
|
|
94
|
+
--dt-accent-soft: #2a3357;
|
|
95
|
+
--dt-green: #5ad19b;
|
|
96
|
+
--dt-blue: #6aa6ff;
|
|
97
|
+
--dt-amber: #f0b35e;
|
|
98
|
+
--dt-grey: #5b626f;
|
|
99
|
+
--dt-red: #f87171;
|
|
100
|
+
--dt-purple: #c08cf0;
|
|
101
|
+
--dt-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
102
|
+
--dt-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
103
|
+
all: initial;
|
|
104
|
+
position: fixed;
|
|
105
|
+
z-index: 2147483000;
|
|
106
|
+
font-family: var(--dt-sans);
|
|
107
|
+
color: var(--dt-text);
|
|
108
|
+
contain: layout style;
|
|
109
|
+
}
|
|
110
|
+
:host([hidden]) { display: none; }
|
|
111
|
+
|
|
112
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
113
|
+
|
|
114
|
+
.panel {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
width: 480px;
|
|
118
|
+
height: 560px;
|
|
119
|
+
max-width: 96vw;
|
|
120
|
+
max-height: 92vh;
|
|
121
|
+
background: var(--dt-bg);
|
|
122
|
+
border: 1px solid var(--dt-border-strong);
|
|
123
|
+
border-radius: 12px;
|
|
124
|
+
box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
font-size: 12px;
|
|
127
|
+
line-height: 1.45;
|
|
128
|
+
}
|
|
129
|
+
.panel.is-collapsed { height: auto !important; }
|
|
130
|
+
.panel.is-collapsed .panel-body,
|
|
131
|
+
.panel.is-collapsed .tabs { display: none; }
|
|
132
|
+
|
|
133
|
+
/* ---- Header ---- */
|
|
134
|
+
.header {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 8px;
|
|
138
|
+
padding: 8px 10px;
|
|
139
|
+
background: var(--dt-bg-raised);
|
|
140
|
+
border-bottom: 1px solid var(--dt-border);
|
|
141
|
+
cursor: grab;
|
|
142
|
+
user-select: none;
|
|
143
|
+
}
|
|
144
|
+
.header.is-dragging { cursor: grabbing; }
|
|
145
|
+
.brand {
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
gap: 6px;
|
|
149
|
+
font-weight: 700;
|
|
150
|
+
font-size: 12px;
|
|
151
|
+
letter-spacing: 0.2px;
|
|
152
|
+
white-space: nowrap;
|
|
153
|
+
}
|
|
154
|
+
.brand .bolt { color: var(--dt-accent); font-size: 13px; }
|
|
155
|
+
.brand .ver { color: var(--dt-text-faint); font-weight: 500; font-size: 10px; }
|
|
156
|
+
.header .spacer { flex: 1; }
|
|
157
|
+
|
|
158
|
+
.app-select {
|
|
159
|
+
appearance: none;
|
|
160
|
+
background: var(--dt-bg-inset);
|
|
161
|
+
color: var(--dt-text);
|
|
162
|
+
border: 1px solid var(--dt-border);
|
|
163
|
+
border-radius: 6px;
|
|
164
|
+
padding: 3px 22px 3px 8px;
|
|
165
|
+
font-size: 11px;
|
|
166
|
+
font-family: var(--dt-sans);
|
|
167
|
+
max-width: 150px;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5 5 6.5 8 3.5' stroke='%239aa0ab' fill='none' stroke-width='1.4'/></svg>");
|
|
170
|
+
background-repeat: no-repeat;
|
|
171
|
+
background-position: right 6px center;
|
|
172
|
+
}
|
|
173
|
+
.app-select:focus { outline: none; border-color: var(--dt-accent); }
|
|
174
|
+
|
|
175
|
+
.icon-btn {
|
|
176
|
+
display: inline-flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
justify-content: center;
|
|
179
|
+
gap: 5px;
|
|
180
|
+
height: 24px;
|
|
181
|
+
min-width: 24px;
|
|
182
|
+
padding: 0 6px;
|
|
183
|
+
background: var(--dt-bg-inset);
|
|
184
|
+
color: var(--dt-text-dim);
|
|
185
|
+
border: 1px solid var(--dt-border);
|
|
186
|
+
border-radius: 6px;
|
|
187
|
+
font-size: 11px;
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
font-family: var(--dt-sans);
|
|
190
|
+
}
|
|
191
|
+
.icon-btn:hover { color: var(--dt-text); border-color: var(--dt-border-strong); }
|
|
192
|
+
.icon-btn.is-on { color: var(--dt-text); border-color: var(--dt-accent); }
|
|
193
|
+
.rec-dot {
|
|
194
|
+
width: 8px; height: 8px; border-radius: 50%;
|
|
195
|
+
background: var(--dt-red);
|
|
196
|
+
}
|
|
197
|
+
.rec-dot.is-paused { background: var(--dt-text-faint); }
|
|
198
|
+
|
|
199
|
+
/* ---- Tabs ---- */
|
|
200
|
+
.tabs {
|
|
201
|
+
display: flex;
|
|
202
|
+
gap: 2px;
|
|
203
|
+
padding: 6px 8px 0;
|
|
204
|
+
background: var(--dt-bg-raised);
|
|
205
|
+
border-bottom: 1px solid var(--dt-border);
|
|
206
|
+
}
|
|
207
|
+
.tab {
|
|
208
|
+
appearance: none;
|
|
209
|
+
background: transparent;
|
|
210
|
+
border: none;
|
|
211
|
+
border-bottom: 2px solid transparent;
|
|
212
|
+
color: var(--dt-text-dim);
|
|
213
|
+
padding: 6px 12px 8px;
|
|
214
|
+
font-size: 12px;
|
|
215
|
+
font-family: var(--dt-sans);
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
border-radius: 6px 6px 0 0;
|
|
218
|
+
}
|
|
219
|
+
.tab:hover { color: var(--dt-text); background: rgba(255,255,255,0.03); }
|
|
220
|
+
.tab.is-active { color: var(--dt-text); border-bottom-color: var(--dt-accent); font-weight: 600; }
|
|
221
|
+
.tab .count {
|
|
222
|
+
margin-left: 5px;
|
|
223
|
+
font-size: 10px;
|
|
224
|
+
color: var(--dt-text-faint);
|
|
225
|
+
font-variant-numeric: tabular-nums;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ---- Body ---- */
|
|
229
|
+
.panel-body {
|
|
230
|
+
flex: 1;
|
|
231
|
+
overflow: auto;
|
|
232
|
+
background: var(--dt-bg);
|
|
233
|
+
}
|
|
234
|
+
.panel-body::-webkit-scrollbar { width: 10px; height: 10px; }
|
|
235
|
+
.panel-body::-webkit-scrollbar-thumb { background: var(--dt-border-strong); border-radius: 6px; border: 2px solid var(--dt-bg); }
|
|
236
|
+
|
|
237
|
+
.toolbar {
|
|
238
|
+
position: sticky;
|
|
239
|
+
top: 0;
|
|
240
|
+
z-index: 2;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
gap: 8px;
|
|
244
|
+
padding: 7px 10px;
|
|
245
|
+
background: var(--dt-bg);
|
|
246
|
+
border-bottom: 1px solid var(--dt-border);
|
|
247
|
+
}
|
|
248
|
+
.toolbar .grow { flex: 1; }
|
|
249
|
+
.search {
|
|
250
|
+
flex: 1;
|
|
251
|
+
background: var(--dt-bg-inset);
|
|
252
|
+
border: 1px solid var(--dt-border);
|
|
253
|
+
border-radius: 6px;
|
|
254
|
+
padding: 4px 8px;
|
|
255
|
+
color: var(--dt-text);
|
|
256
|
+
font-size: 11px;
|
|
257
|
+
font-family: var(--dt-mono);
|
|
258
|
+
}
|
|
259
|
+
.search:focus { outline: none; border-color: var(--dt-accent); }
|
|
260
|
+
.muted { color: var(--dt-text-dim); font-size: 11px; }
|
|
261
|
+
.faint { color: var(--dt-text-faint); }
|
|
262
|
+
.empty {
|
|
263
|
+
padding: 28px 16px;
|
|
264
|
+
text-align: center;
|
|
265
|
+
color: var(--dt-text-faint);
|
|
266
|
+
font-size: 12px;
|
|
267
|
+
}
|
|
268
|
+
.empty code { color: var(--dt-text-dim); font-family: var(--dt-mono); }
|
|
269
|
+
|
|
270
|
+
/* ---- State inspector tree ---- */
|
|
271
|
+
.tree { padding: 4px 0; }
|
|
272
|
+
.row {
|
|
273
|
+
display: flex;
|
|
274
|
+
align-items: flex-start;
|
|
275
|
+
gap: 4px;
|
|
276
|
+
padding: 2px 10px 2px 0;
|
|
277
|
+
font-family: var(--dt-mono);
|
|
278
|
+
font-size: 11.5px;
|
|
279
|
+
white-space: nowrap;
|
|
280
|
+
}
|
|
281
|
+
.row:hover { background: rgba(255,255,255,0.035); }
|
|
282
|
+
.row .twist {
|
|
283
|
+
width: 14px;
|
|
284
|
+
flex: 0 0 14px;
|
|
285
|
+
color: var(--dt-text-faint);
|
|
286
|
+
cursor: pointer;
|
|
287
|
+
text-align: center;
|
|
288
|
+
user-select: none;
|
|
289
|
+
}
|
|
290
|
+
.row .twist.is-leaf { visibility: hidden; }
|
|
291
|
+
.row .k { color: var(--dt-purple); }
|
|
292
|
+
.row .sep { color: var(--dt-text-faint); }
|
|
293
|
+
.row .v { color: var(--dt-text); cursor: text; }
|
|
294
|
+
.row .v.t-string { color: var(--dt-green); }
|
|
295
|
+
.row .v.t-number { color: var(--dt-amber); }
|
|
296
|
+
.row .v.t-boolean { color: var(--dt-blue); }
|
|
297
|
+
.row .v.t-null, .row .v.t-undefined { color: var(--dt-text-faint); font-style: italic; }
|
|
298
|
+
.row .v.t-object, .row .v.t-array, .row .v.t-function { color: var(--dt-text-dim); }
|
|
299
|
+
.row .tag {
|
|
300
|
+
margin-left: 6px;
|
|
301
|
+
font-size: 9px;
|
|
302
|
+
font-family: var(--dt-sans);
|
|
303
|
+
color: var(--dt-text-faint);
|
|
304
|
+
border: 1px solid var(--dt-border);
|
|
305
|
+
border-radius: 4px;
|
|
306
|
+
padding: 0 4px;
|
|
307
|
+
text-transform: uppercase;
|
|
308
|
+
letter-spacing: 0.3px;
|
|
309
|
+
}
|
|
310
|
+
.row.is-changed { background: var(--dt-accent-soft); animation: dt-flash 1.1s ease-out; }
|
|
311
|
+
@keyframes dt-flash {
|
|
312
|
+
0% { background: rgba(124,156,255,0.55); }
|
|
313
|
+
100% { background: transparent; }
|
|
314
|
+
}
|
|
315
|
+
.edit-input {
|
|
316
|
+
background: var(--dt-bg-inset);
|
|
317
|
+
border: 1px solid var(--dt-accent);
|
|
318
|
+
border-radius: 4px;
|
|
319
|
+
color: var(--dt-text);
|
|
320
|
+
font-family: var(--dt-mono);
|
|
321
|
+
font-size: 11.5px;
|
|
322
|
+
padding: 0 4px;
|
|
323
|
+
min-width: 80px;
|
|
324
|
+
}
|
|
325
|
+
.edit-input:focus { outline: none; }
|
|
326
|
+
|
|
327
|
+
/* ---- Profiler ---- */
|
|
328
|
+
.commit-strip {
|
|
329
|
+
display: flex;
|
|
330
|
+
align-items: flex-end;
|
|
331
|
+
gap: 2px;
|
|
332
|
+
height: 64px;
|
|
333
|
+
padding: 8px 10px;
|
|
334
|
+
background: var(--dt-bg-inset);
|
|
335
|
+
border-bottom: 1px solid var(--dt-border);
|
|
336
|
+
overflow-x: auto;
|
|
337
|
+
}
|
|
338
|
+
.commit-bar {
|
|
339
|
+
flex: 0 0 9px;
|
|
340
|
+
min-height: 3px;
|
|
341
|
+
background: var(--dt-blue);
|
|
342
|
+
border-radius: 2px 2px 0 0;
|
|
343
|
+
cursor: pointer;
|
|
344
|
+
opacity: 0.65;
|
|
345
|
+
transition: opacity 0.1s;
|
|
346
|
+
}
|
|
347
|
+
.commit-bar:hover { opacity: 1; }
|
|
348
|
+
.commit-bar.is-full { background: var(--dt-amber); }
|
|
349
|
+
.commit-bar.is-initial { background: var(--dt-green); }
|
|
350
|
+
.commit-bar.is-selected { opacity: 1; outline: 1.5px solid var(--dt-text); outline-offset: 1px; }
|
|
351
|
+
|
|
352
|
+
.section { padding: 10px; border-bottom: 1px solid var(--dt-border); }
|
|
353
|
+
.section-title {
|
|
354
|
+
font-size: 10px;
|
|
355
|
+
text-transform: uppercase;
|
|
356
|
+
letter-spacing: 0.6px;
|
|
357
|
+
color: var(--dt-text-faint);
|
|
358
|
+
margin: 0 0 7px;
|
|
359
|
+
font-weight: 700;
|
|
360
|
+
}
|
|
361
|
+
.kv { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 6px; }
|
|
362
|
+
.kv span { font-size: 11px; color: var(--dt-text-dim); }
|
|
363
|
+
.kv b { color: var(--dt-text); font-weight: 600; }
|
|
364
|
+
.kv .mono { font-family: var(--dt-mono); }
|
|
365
|
+
.chip {
|
|
366
|
+
display: inline-block;
|
|
367
|
+
font-size: 10px;
|
|
368
|
+
padding: 1px 6px;
|
|
369
|
+
border-radius: 999px;
|
|
370
|
+
font-family: var(--dt-mono);
|
|
371
|
+
}
|
|
372
|
+
.chip.green { background: rgba(90,209,155,0.16); color: var(--dt-green); }
|
|
373
|
+
.chip.blue { background: rgba(106,166,255,0.16); color: var(--dt-blue); }
|
|
374
|
+
.chip.amber { background: rgba(240,179,94,0.16); color: var(--dt-amber); }
|
|
375
|
+
.chip.grey { background: rgba(91,98,111,0.22); color: var(--dt-text-dim); }
|
|
376
|
+
.chip.red { background: rgba(248,113,113,0.16); color: var(--dt-red); }
|
|
377
|
+
.chip.purple { background: rgba(192,140,240,0.16); color: var(--dt-purple); }
|
|
378
|
+
|
|
379
|
+
/* flamegraph rows */
|
|
380
|
+
.flame-row {
|
|
381
|
+
display: flex;
|
|
382
|
+
align-items: center;
|
|
383
|
+
gap: 8px;
|
|
384
|
+
padding: 1px 0;
|
|
385
|
+
font-size: 11px;
|
|
386
|
+
}
|
|
387
|
+
.flame-bar-wrap { flex: 1; min-width: 0; }
|
|
388
|
+
.flame-bar {
|
|
389
|
+
height: 16px;
|
|
390
|
+
border-radius: 3px;
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
padding: 0 6px;
|
|
394
|
+
color: #0c0e12;
|
|
395
|
+
font-family: var(--dt-mono);
|
|
396
|
+
font-size: 10px;
|
|
397
|
+
font-weight: 600;
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
overflow: hidden;
|
|
400
|
+
min-width: 2px;
|
|
401
|
+
}
|
|
402
|
+
.flame-bar.p-mount { background: var(--dt-green); }
|
|
403
|
+
.flame-bar.p-update { background: var(--dt-blue); }
|
|
404
|
+
.flame-bar.p-memo { background: var(--dt-grey); color: var(--dt-text-dim); opacity: 0.8; }
|
|
405
|
+
.flame-time { flex: 0 0 56px; text-align: right; font-family: var(--dt-mono); color: var(--dt-text-dim); font-size: 10px; }
|
|
406
|
+
.flame-reason { font-size: 10px; color: var(--dt-text-faint); }
|
|
407
|
+
|
|
408
|
+
/* tables */
|
|
409
|
+
table.dt-table { width: 100%; border-collapse: collapse; font-size: 11px; }
|
|
410
|
+
table.dt-table th {
|
|
411
|
+
text-align: left;
|
|
412
|
+
color: var(--dt-text-faint);
|
|
413
|
+
font-weight: 600;
|
|
414
|
+
font-size: 10px;
|
|
415
|
+
text-transform: uppercase;
|
|
416
|
+
letter-spacing: 0.4px;
|
|
417
|
+
padding: 4px 6px;
|
|
418
|
+
border-bottom: 1px solid var(--dt-border);
|
|
419
|
+
position: sticky;
|
|
420
|
+
top: 0;
|
|
421
|
+
background: var(--dt-bg);
|
|
422
|
+
}
|
|
423
|
+
table.dt-table td {
|
|
424
|
+
padding: 3px 6px;
|
|
425
|
+
border-bottom: 1px solid rgba(43,47,56,0.5);
|
|
426
|
+
font-variant-numeric: tabular-nums;
|
|
427
|
+
}
|
|
428
|
+
table.dt-table td.name { font-family: var(--dt-mono); color: var(--dt-text); }
|
|
429
|
+
table.dt-table td.num { text-align: right; font-family: var(--dt-mono); color: var(--dt-text-dim); }
|
|
430
|
+
table.dt-table tr:hover td { background: rgba(255,255,255,0.03); }
|
|
431
|
+
.bar-cell { position: relative; }
|
|
432
|
+
.bar-cell .barfill {
|
|
433
|
+
position: absolute;
|
|
434
|
+
left: 0; top: 2px; bottom: 2px;
|
|
435
|
+
background: rgba(124,156,255,0.22);
|
|
436
|
+
border-radius: 3px;
|
|
437
|
+
z-index: 0;
|
|
438
|
+
}
|
|
439
|
+
.bar-cell span { position: relative; z-index: 1; }
|
|
440
|
+
|
|
441
|
+
/* ---- Effect timeline ---- */
|
|
442
|
+
.lane {
|
|
443
|
+
display: flex;
|
|
444
|
+
align-items: center;
|
|
445
|
+
gap: 8px;
|
|
446
|
+
padding: 5px 10px;
|
|
447
|
+
border-bottom: 1px solid rgba(43,47,56,0.5);
|
|
448
|
+
}
|
|
449
|
+
.lane .lane-name { font-family: var(--dt-mono); color: var(--dt-text); font-size: 11px; flex: 0 0 auto; }
|
|
450
|
+
.lane .lane-trig { font-family: var(--dt-mono); color: var(--dt-text-faint); font-size: 10px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
451
|
+
.lane .lane-stat { color: var(--dt-text-dim); font-size: 10px; font-variant-numeric: tabular-nums; }
|
|
452
|
+
|
|
453
|
+
.log-row {
|
|
454
|
+
display: flex;
|
|
455
|
+
align-items: center;
|
|
456
|
+
gap: 8px;
|
|
457
|
+
padding: 2px 10px;
|
|
458
|
+
font-size: 11px;
|
|
459
|
+
border-bottom: 1px solid rgba(43,47,56,0.35);
|
|
460
|
+
}
|
|
461
|
+
.log-row:hover { background: rgba(255,255,255,0.03); }
|
|
462
|
+
.log-row .t { flex: 0 0 62px; text-align: right; font-family: var(--dt-mono); color: var(--dt-text-faint); font-size: 10px; }
|
|
463
|
+
.log-row .ph { flex: 0 0 64px; }
|
|
464
|
+
.log-row .lbl { font-family: var(--dt-mono); color: var(--dt-text-dim); }
|
|
465
|
+
.log-row .rsn { flex: 1; font-family: var(--dt-mono); color: var(--dt-text-faint); font-size: 10px; text-align: right; }
|
|
466
|
+
|
|
467
|
+
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
|
|
468
|
+
.filter-chip {
|
|
469
|
+
font-size: 10px;
|
|
470
|
+
padding: 2px 8px;
|
|
471
|
+
border-radius: 999px;
|
|
472
|
+
border: 1px solid var(--dt-border);
|
|
473
|
+
background: var(--dt-bg-inset);
|
|
474
|
+
color: var(--dt-text-faint);
|
|
475
|
+
cursor: pointer;
|
|
476
|
+
font-family: var(--dt-sans);
|
|
477
|
+
}
|
|
478
|
+
.filter-chip.is-on { color: var(--dt-text); border-color: var(--dt-border-strong); background: var(--dt-bg-raised); }
|
|
479
|
+
|
|
480
|
+
/* ---- Resize grip ---- */
|
|
481
|
+
.resize {
|
|
482
|
+
position: absolute;
|
|
483
|
+
width: 16px;
|
|
484
|
+
height: 16px;
|
|
485
|
+
right: 0;
|
|
486
|
+
bottom: 0;
|
|
487
|
+
cursor: nwse-resize;
|
|
488
|
+
background: linear-gradient(135deg, transparent 50%, var(--dt-border-strong) 50%, var(--dt-border-strong) 60%, transparent 60%, transparent 72%, var(--dt-border-strong) 72%, var(--dt-border-strong) 82%, transparent 82%);
|
|
489
|
+
border-bottom-right-radius: 12px;
|
|
490
|
+
}
|
|
491
|
+
`;
|
|
492
|
+
const DEVTOOLS_UI_VERSION = "0.5";
|
|
493
|
+
const RESERVED_ATOMS = /* @__PURE__ */ new Set(["route"]);
|
|
494
|
+
const MAX_COMMITS = 200;
|
|
495
|
+
const MAX_EFFECT_EVENTS = 400;
|
|
496
|
+
const FLASH_MS = 1100;
|
|
497
|
+
function emptyModel() {
|
|
498
|
+
return { commits: [], effects: [], state: {}, changed: /* @__PURE__ */ new Map(), firstTime: null };
|
|
499
|
+
}
|
|
500
|
+
function h(tag, attrs = {}, ...children) {
|
|
501
|
+
const node = document.createElement(tag);
|
|
502
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
503
|
+
if (v == null || v === false) continue;
|
|
504
|
+
if (k === "class") node.className = String(v);
|
|
505
|
+
else if (k === "style") node.setAttribute("style", String(v));
|
|
506
|
+
else if (k.startsWith("on") && typeof v === "function") {
|
|
507
|
+
node.addEventListener(k.slice(2).toLowerCase(), v);
|
|
508
|
+
} else if (v === true) node.setAttribute(k, "");
|
|
509
|
+
else node.setAttribute(k, String(v));
|
|
510
|
+
}
|
|
511
|
+
for (const child of children) {
|
|
512
|
+
if (child == null || child === false) continue;
|
|
513
|
+
node.appendChild(typeof child === "string" ? document.createTextNode(child) : child);
|
|
514
|
+
}
|
|
515
|
+
return node;
|
|
516
|
+
}
|
|
517
|
+
function valueType(v) {
|
|
518
|
+
if (v === null) return "null";
|
|
519
|
+
if (Array.isArray(v)) return "array";
|
|
520
|
+
return typeof v;
|
|
521
|
+
}
|
|
522
|
+
function isExpandable(v) {
|
|
523
|
+
const t = valueType(v);
|
|
524
|
+
return (t === "object" || t === "array") && childEntries(v).length > 0;
|
|
525
|
+
}
|
|
526
|
+
function childEntries(v) {
|
|
527
|
+
if (Array.isArray(v)) return v.map((item, i) => [String(i), item]);
|
|
528
|
+
if (v && typeof v === "object") return Object.entries(v);
|
|
529
|
+
return [];
|
|
530
|
+
}
|
|
531
|
+
function previewValue(v) {
|
|
532
|
+
switch (valueType(v)) {
|
|
533
|
+
case "string":
|
|
534
|
+
return JSON.stringify(v);
|
|
535
|
+
case "number":
|
|
536
|
+
case "boolean":
|
|
537
|
+
return String(v);
|
|
538
|
+
case "null":
|
|
539
|
+
return "null";
|
|
540
|
+
case "undefined":
|
|
541
|
+
return "undefined";
|
|
542
|
+
case "function":
|
|
543
|
+
return "ƒ ()";
|
|
544
|
+
case "array":
|
|
545
|
+
return `Array(${v.length})`;
|
|
546
|
+
case "object": {
|
|
547
|
+
const keys = Object.keys(v);
|
|
548
|
+
const head = keys.slice(0, 3).join(", ");
|
|
549
|
+
return `{ ${head}${keys.length > 3 ? ", …" : ""} }`;
|
|
550
|
+
}
|
|
551
|
+
default:
|
|
552
|
+
return String(v);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function parseEdit(raw) {
|
|
556
|
+
try {
|
|
557
|
+
return JSON.parse(raw);
|
|
558
|
+
} catch {
|
|
559
|
+
return raw;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function fmtMs(n) {
|
|
563
|
+
if (!isFinite(n)) return "—";
|
|
564
|
+
if (n >= 100) return `${n.toFixed(0)} ms`;
|
|
565
|
+
if (n >= 10) return `${n.toFixed(1)} ms`;
|
|
566
|
+
return `${n.toFixed(2)} ms`;
|
|
567
|
+
}
|
|
568
|
+
function fmtRel(ms) {
|
|
569
|
+
if (ms >= 1e4) return `${(ms / 1e3).toFixed(1)} s`;
|
|
570
|
+
return `${ms.toFixed(0)} ms`;
|
|
571
|
+
}
|
|
572
|
+
const PHASE_CHIP = {
|
|
573
|
+
mount: "green",
|
|
574
|
+
update: "blue",
|
|
575
|
+
memo: "grey",
|
|
576
|
+
run: "blue",
|
|
577
|
+
cleanup: "purple",
|
|
578
|
+
unmount: "grey",
|
|
579
|
+
error: "red"
|
|
580
|
+
};
|
|
581
|
+
class AktionDevtoolsElement extends HTMLElement {
|
|
582
|
+
constructor() {
|
|
583
|
+
super(...arguments);
|
|
584
|
+
__publicField(this, "hook", null);
|
|
585
|
+
__publicField(this, "unsubEvents", null);
|
|
586
|
+
__publicField(this, "unsubApps", null);
|
|
587
|
+
__publicField(this, "models", /* @__PURE__ */ new Map());
|
|
588
|
+
__publicField(this, "selectedAppId", null);
|
|
589
|
+
__publicField(this, "tab", "state");
|
|
590
|
+
__publicField(this, "paused", false);
|
|
591
|
+
// State tab
|
|
592
|
+
__publicField(this, "stateFilter", "");
|
|
593
|
+
__publicField(this, "expanded", /* @__PURE__ */ new Set());
|
|
594
|
+
__publicField(this, "editingPath", null);
|
|
595
|
+
// Profiler tab
|
|
596
|
+
__publicField(this, "selectedCommitId", null);
|
|
597
|
+
__publicField(this, "flashOnCommit", false);
|
|
598
|
+
// Effects tab
|
|
599
|
+
__publicField(this, "phaseFilter", /* @__PURE__ */ new Set(["mount", "run", "cleanup", "unmount", "error"]));
|
|
600
|
+
// chrome
|
|
601
|
+
__publicField(this, "collapsed", false);
|
|
602
|
+
__publicField(this, "renderScheduled", false);
|
|
603
|
+
__publicField(this, "flashTimer", null);
|
|
604
|
+
// skeleton refs
|
|
605
|
+
__publicField(this, "root");
|
|
606
|
+
__publicField(this, "panelEl");
|
|
607
|
+
__publicField(this, "controlsEl");
|
|
608
|
+
__publicField(this, "tabsEl");
|
|
609
|
+
__publicField(this, "bodyEl");
|
|
610
|
+
}
|
|
611
|
+
connectedCallback() {
|
|
612
|
+
if (!this.root) this.buildSkeleton();
|
|
613
|
+
this.hook = installDevtoolsHook(DEVTOOLS_UI_VERSION);
|
|
614
|
+
for (const app of this.hook.apps.values()) this.adopt(app);
|
|
615
|
+
if (!this.selectedAppId && this.hook.apps.size > 0) {
|
|
616
|
+
this.selectedAppId = [...this.hook.apps.keys()][0];
|
|
617
|
+
}
|
|
618
|
+
for (const event of this.hook.buffer) this.ingest(
|
|
619
|
+
event,
|
|
620
|
+
/* fromBuffer */
|
|
621
|
+
true
|
|
622
|
+
);
|
|
623
|
+
this.unsubEvents = this.hook.subscribe((event) => this.onEvent(event));
|
|
624
|
+
this.unsubApps = this.hook.subscribeApps((action, app) => this.onApp(action, app));
|
|
625
|
+
this.discoverApps();
|
|
626
|
+
this.scheduleRender();
|
|
627
|
+
}
|
|
628
|
+
disconnectedCallback() {
|
|
629
|
+
this.unsubEvents?.();
|
|
630
|
+
this.unsubApps?.();
|
|
631
|
+
this.unsubEvents = null;
|
|
632
|
+
this.unsubApps = null;
|
|
633
|
+
if (this.flashTimer) clearTimeout(this.flashTimer);
|
|
634
|
+
}
|
|
635
|
+
/* ---- public controller surface ---- */
|
|
636
|
+
open() {
|
|
637
|
+
this.hidden = false;
|
|
638
|
+
}
|
|
639
|
+
close() {
|
|
640
|
+
this.hidden = true;
|
|
641
|
+
}
|
|
642
|
+
toggle() {
|
|
643
|
+
this.hidden = !this.hidden;
|
|
644
|
+
}
|
|
645
|
+
selectApp(id) {
|
|
646
|
+
this.selectedAppId = id;
|
|
647
|
+
this.selectedCommitId = null;
|
|
648
|
+
this.scheduleRender();
|
|
649
|
+
}
|
|
650
|
+
/** Test/inspection hook: the derived model for an app (or the selected one). */
|
|
651
|
+
getModel(appId) {
|
|
652
|
+
const id = appId ?? this.selectedAppId;
|
|
653
|
+
return id ? this.models.get(id) ?? null : null;
|
|
654
|
+
}
|
|
655
|
+
/* ---- event ingestion ---- */
|
|
656
|
+
ensureModel(appId) {
|
|
657
|
+
let m = this.models.get(appId);
|
|
658
|
+
if (!m) {
|
|
659
|
+
m = emptyModel();
|
|
660
|
+
this.models.set(appId, m);
|
|
661
|
+
}
|
|
662
|
+
return m;
|
|
663
|
+
}
|
|
664
|
+
/** Adopt an app: ensure a model and seed its current state snapshot. */
|
|
665
|
+
adopt(app) {
|
|
666
|
+
const m = this.ensureModel(app.id);
|
|
667
|
+
try {
|
|
668
|
+
m.state = app.getState();
|
|
669
|
+
} catch {
|
|
670
|
+
}
|
|
671
|
+
return m;
|
|
672
|
+
}
|
|
673
|
+
/** Ask every `<aktion-app>` on the page to register with the hook. */
|
|
674
|
+
discoverApps() {
|
|
675
|
+
if (typeof document === "undefined") return;
|
|
676
|
+
document.querySelectorAll("aktion-app").forEach((el) => {
|
|
677
|
+
try {
|
|
678
|
+
el.connectDevtools?.();
|
|
679
|
+
} catch {
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
onApp(action, app) {
|
|
684
|
+
if (action === "register") {
|
|
685
|
+
this.adopt(app);
|
|
686
|
+
if (!this.selectedAppId) this.selectedAppId = app.id;
|
|
687
|
+
} else if (this.selectedAppId === app.id) {
|
|
688
|
+
const next = [...this.hook.apps.keys()].find((id) => id !== app.id) ?? null;
|
|
689
|
+
this.selectedAppId = next;
|
|
690
|
+
}
|
|
691
|
+
this.scheduleRender();
|
|
692
|
+
}
|
|
693
|
+
onEvent(event) {
|
|
694
|
+
if (this.paused) return;
|
|
695
|
+
this.ingest(event, false);
|
|
696
|
+
if (event.kind === "commit" && this.flashOnCommit && event.appId === this.selectedAppId) {
|
|
697
|
+
this.flashApp(event.appId);
|
|
698
|
+
}
|
|
699
|
+
this.scheduleRender();
|
|
700
|
+
}
|
|
701
|
+
ingest(event, fromBuffer) {
|
|
702
|
+
const model = this.ensureModel(event.appId);
|
|
703
|
+
const t = eventTime(event);
|
|
704
|
+
if (model.firstTime === null || t < model.firstTime) model.firstTime = t;
|
|
705
|
+
switch (event.kind) {
|
|
706
|
+
case "commit": {
|
|
707
|
+
model.commits.push(event);
|
|
708
|
+
if (model.commits.length > MAX_COMMITS) model.commits.shift();
|
|
709
|
+
if (!fromBuffer || this.selectedCommitId === null) this.selectedCommitId = event.commitId;
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
case "state": {
|
|
713
|
+
model.state = event.snapshot;
|
|
714
|
+
for (const p of event.changedPaths) {
|
|
715
|
+
model.changed.set(rootOf(p), event.time);
|
|
716
|
+
}
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case "effect": {
|
|
720
|
+
model.effects.push(event);
|
|
721
|
+
if (model.effects.length > MAX_EFFECT_EVENTS) model.effects.shift();
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
/* ---- render scheduling ---- */
|
|
727
|
+
scheduleRender() {
|
|
728
|
+
if (this.renderScheduled) return;
|
|
729
|
+
this.renderScheduled = true;
|
|
730
|
+
queueMicrotask(() => {
|
|
731
|
+
this.renderScheduled = false;
|
|
732
|
+
try {
|
|
733
|
+
this.render();
|
|
734
|
+
} catch (err) {
|
|
735
|
+
console.error("[aktion-devtools] render failed", err);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
currentApp() {
|
|
740
|
+
if (!this.selectedAppId || !this.hook) return null;
|
|
741
|
+
return this.hook.apps.get(this.selectedAppId) ?? null;
|
|
742
|
+
}
|
|
743
|
+
render() {
|
|
744
|
+
if (this.hidden) return;
|
|
745
|
+
if (this.tab === "state" && this.editingPath) {
|
|
746
|
+
this.renderControls();
|
|
747
|
+
this.renderTabs();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
this.renderControls();
|
|
751
|
+
this.renderTabs();
|
|
752
|
+
this.renderBody();
|
|
753
|
+
}
|
|
754
|
+
/* ---- skeleton ---- */
|
|
755
|
+
buildSkeleton() {
|
|
756
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
757
|
+
const style = document.createElement("style");
|
|
758
|
+
style.textContent = devtoolsStyles;
|
|
759
|
+
this.controlsEl = h("div", { class: "controls", style: "display:flex;gap:6px;align-items:center;" });
|
|
760
|
+
const header = h(
|
|
761
|
+
"div",
|
|
762
|
+
{ class: "header" },
|
|
763
|
+
h(
|
|
764
|
+
"div",
|
|
765
|
+
{ class: "brand" },
|
|
766
|
+
h("span", { class: "bolt" }, "⚡"),
|
|
767
|
+
h("span", {}, "Aktion DevTools"),
|
|
768
|
+
h("span", { class: "ver" }, `v${DEVTOOLS_UI_VERSION}`)
|
|
769
|
+
),
|
|
770
|
+
h("div", { class: "spacer" }),
|
|
771
|
+
this.controlsEl
|
|
772
|
+
);
|
|
773
|
+
this.makeDraggable(header);
|
|
774
|
+
this.tabsEl = h("div", { class: "tabs" });
|
|
775
|
+
this.bodyEl = h("div", { class: "panel-body" });
|
|
776
|
+
const grip = h("div", { class: "resize", title: "Drag to resize" });
|
|
777
|
+
this.makeResizable(grip);
|
|
778
|
+
this.panelEl = h("div", { class: "panel" }, header, this.tabsEl, this.bodyEl, grip);
|
|
779
|
+
this.root.append(style, this.panelEl);
|
|
780
|
+
const w = 480, hgt = 560;
|
|
781
|
+
const vw = typeof window !== "undefined" ? window.innerWidth : 1280;
|
|
782
|
+
const vh = typeof window !== "undefined" ? window.innerHeight : 800;
|
|
783
|
+
this.style.left = `${Math.max(8, vw - w - 16)}px`;
|
|
784
|
+
this.style.top = `${Math.max(8, vh - hgt - 16)}px`;
|
|
785
|
+
}
|
|
786
|
+
renderControls() {
|
|
787
|
+
const apps = this.hook ? [...this.hook.apps.values()] : [];
|
|
788
|
+
const select = h("select", {
|
|
789
|
+
class: "app-select",
|
|
790
|
+
title: "Inspected app",
|
|
791
|
+
onchange: (e) => this.selectApp(e.target.value)
|
|
792
|
+
});
|
|
793
|
+
if (apps.length === 0) {
|
|
794
|
+
select.appendChild(h("option", {}, "no app detected"));
|
|
795
|
+
select.disabled = true;
|
|
796
|
+
} else {
|
|
797
|
+
for (const app of apps) {
|
|
798
|
+
const opt = h("option", { value: app.id }, app.label);
|
|
799
|
+
if (app.id === this.selectedAppId) opt.selected = true;
|
|
800
|
+
select.appendChild(opt);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const rec = h(
|
|
804
|
+
"button",
|
|
805
|
+
{
|
|
806
|
+
class: `icon-btn ${this.paused ? "" : "is-on"}`,
|
|
807
|
+
title: this.paused ? "Paused — click to resume recording" : "Recording — click to pause",
|
|
808
|
+
onclick: () => {
|
|
809
|
+
this.paused = !this.paused;
|
|
810
|
+
this.scheduleRender();
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
h("span", { class: `rec-dot ${this.paused ? "is-paused" : ""}` }),
|
|
814
|
+
this.paused ? "Paused" : "Rec"
|
|
815
|
+
);
|
|
816
|
+
const collapse = h("button", {
|
|
817
|
+
class: "icon-btn",
|
|
818
|
+
title: this.collapsed ? "Expand" : "Collapse",
|
|
819
|
+
onclick: () => {
|
|
820
|
+
this.collapsed = !this.collapsed;
|
|
821
|
+
this.panelEl.classList.toggle("is-collapsed", this.collapsed);
|
|
822
|
+
}
|
|
823
|
+
}, this.collapsed ? "▢" : "—");
|
|
824
|
+
const close = h("button", { class: "icon-btn", title: "Close", onclick: () => this.close() }, "✕");
|
|
825
|
+
this.controlsEl.replaceChildren(select, rec, collapse, close);
|
|
826
|
+
}
|
|
827
|
+
renderTabs() {
|
|
828
|
+
const model = this.getModel();
|
|
829
|
+
const defs = [
|
|
830
|
+
["state", "State", model ? Object.keys(model.state).length : 0],
|
|
831
|
+
["profiler", "Profiler", model ? model.commits.length : 0],
|
|
832
|
+
["effects", "Effects", model ? model.effects.length : 0]
|
|
833
|
+
];
|
|
834
|
+
this.tabsEl.replaceChildren(
|
|
835
|
+
...defs.map(
|
|
836
|
+
([id, label, count]) => h(
|
|
837
|
+
"button",
|
|
838
|
+
{
|
|
839
|
+
class: `tab ${this.tab === id ? "is-active" : ""}`,
|
|
840
|
+
onclick: () => {
|
|
841
|
+
this.tab = id;
|
|
842
|
+
this.scheduleRender();
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
label,
|
|
846
|
+
h("span", { class: "count" }, String(count))
|
|
847
|
+
)
|
|
848
|
+
)
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
renderBody() {
|
|
852
|
+
const app = this.currentApp();
|
|
853
|
+
const model = this.getModel();
|
|
854
|
+
if (!app || !model) {
|
|
855
|
+
this.bodyEl.replaceChildren(
|
|
856
|
+
h(
|
|
857
|
+
"div",
|
|
858
|
+
{ class: "empty" },
|
|
859
|
+
h("p", {}, "No Aktion app detected on this page."),
|
|
860
|
+
h("p", { class: "faint" }, "Mount an ", h("code", {}, "<aktion-app>"), " and it will appear here.")
|
|
861
|
+
)
|
|
862
|
+
);
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
if (this.tab === "state") this.renderStateTab(app, model);
|
|
866
|
+
else if (this.tab === "profiler") this.renderProfilerTab(model);
|
|
867
|
+
else this.renderEffectsTab(model);
|
|
868
|
+
}
|
|
869
|
+
/* ---------------------------------------------------------------------- */
|
|
870
|
+
/* State inspector */
|
|
871
|
+
/* ---------------------------------------------------------------------- */
|
|
872
|
+
renderStateTab(app, model) {
|
|
873
|
+
const toolbar = h(
|
|
874
|
+
"div",
|
|
875
|
+
{ class: "toolbar" },
|
|
876
|
+
h("input", {
|
|
877
|
+
class: "search",
|
|
878
|
+
placeholder: "Filter atoms…",
|
|
879
|
+
value: this.stateFilter,
|
|
880
|
+
oninput: (e) => {
|
|
881
|
+
this.stateFilter = e.target.value;
|
|
882
|
+
this.renderTreeOnly(app, model);
|
|
883
|
+
}
|
|
884
|
+
}),
|
|
885
|
+
h("span", { class: "muted" }, `${Object.keys(model.state).length} atoms`)
|
|
886
|
+
);
|
|
887
|
+
const tree = h("div", { class: "tree" });
|
|
888
|
+
this.fillTree(tree, app, model);
|
|
889
|
+
this.bodyEl.replaceChildren(toolbar, tree);
|
|
890
|
+
}
|
|
891
|
+
/** Re-render only the tree (used by the filter box to keep its focus). */
|
|
892
|
+
renderTreeOnly(app, model) {
|
|
893
|
+
const tree = this.bodyEl.querySelector(".tree");
|
|
894
|
+
if (!tree) return;
|
|
895
|
+
tree.replaceChildren();
|
|
896
|
+
this.fillTree(tree, app, model);
|
|
897
|
+
}
|
|
898
|
+
fillTree(tree, app, model) {
|
|
899
|
+
const filter = this.stateFilter.trim().toLowerCase();
|
|
900
|
+
const names = Object.keys(model.state).sort((a, b) => a.localeCompare(b));
|
|
901
|
+
const now = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
902
|
+
let shown = 0;
|
|
903
|
+
for (const name of names) {
|
|
904
|
+
if (filter && !name.toLowerCase().includes(filter)) continue;
|
|
905
|
+
shown += 1;
|
|
906
|
+
this.appendRow(tree, app, model, name, name, model.state[name], 0, now);
|
|
907
|
+
}
|
|
908
|
+
if (shown === 0) {
|
|
909
|
+
tree.appendChild(h("div", { class: "empty" }, filter ? "No atoms match the filter." : "No reactive state yet."));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
appendRow(container, app, model, path, key, value, depth, now) {
|
|
913
|
+
const type = valueType(value);
|
|
914
|
+
const expandable = isExpandable(value);
|
|
915
|
+
const isOpen = this.expanded.has(path);
|
|
916
|
+
const reserved = depth === 0 && RESERVED_ATOMS.has(key);
|
|
917
|
+
const changedAt = model.changed.get(rootOf(path));
|
|
918
|
+
const justChanged = changedAt != null && now - changedAt < FLASH_MS;
|
|
919
|
+
const twist = h("span", {
|
|
920
|
+
class: `twist ${expandable ? "" : "is-leaf"}`,
|
|
921
|
+
onclick: expandable ? () => {
|
|
922
|
+
if (this.expanded.has(path)) this.expanded.delete(path);
|
|
923
|
+
else this.expanded.add(path);
|
|
924
|
+
this.renderTreeOnly(app, model);
|
|
925
|
+
} : void 0
|
|
926
|
+
}, expandable ? isOpen ? "▾" : "▸" : "•");
|
|
927
|
+
const valueSpan = h("span", { class: `v t-${type}` }, expandable ? previewValue(value) : previewValue(value));
|
|
928
|
+
const editable = !reserved && !expandable && type !== "function";
|
|
929
|
+
if (editable) {
|
|
930
|
+
valueSpan.title = "Click to edit";
|
|
931
|
+
valueSpan.addEventListener("click", () => this.beginEdit(app, path, value, valueSpan));
|
|
932
|
+
}
|
|
933
|
+
const row = h(
|
|
934
|
+
"div",
|
|
935
|
+
{ class: `row ${justChanged ? "is-changed" : ""}`, style: `padding-left:${8 + depth * 14}px` },
|
|
936
|
+
twist,
|
|
937
|
+
h("span", { class: "k" }, key),
|
|
938
|
+
h("span", { class: "sep" }, ": "),
|
|
939
|
+
valueSpan,
|
|
940
|
+
reserved ? h("span", { class: "tag" }, "reserved") : null
|
|
941
|
+
);
|
|
942
|
+
container.appendChild(row);
|
|
943
|
+
if (expandable && isOpen) {
|
|
944
|
+
for (const [childKey, childValue] of childEntries(value)) {
|
|
945
|
+
this.appendRow(container, app, model, `${path}.${childKey}`, childKey, childValue, depth + 1, now);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
beginEdit(app, path, value, valueSpan) {
|
|
950
|
+
if (this.editingPath) return;
|
|
951
|
+
this.editingPath = path;
|
|
952
|
+
const initial = valueType(value) === "string" ? String(value) : previewValue(value);
|
|
953
|
+
const input = h("input", { class: "edit-input", value: initial });
|
|
954
|
+
const commit = (apply) => {
|
|
955
|
+
if (this.editingPath !== path) return;
|
|
956
|
+
this.editingPath = null;
|
|
957
|
+
if (apply) {
|
|
958
|
+
try {
|
|
959
|
+
app.setState(path, parseEdit(input.value));
|
|
960
|
+
} catch (err) {
|
|
961
|
+
console.error("[aktion-devtools] edit failed", err);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
this.scheduleRender();
|
|
965
|
+
};
|
|
966
|
+
input.addEventListener("keydown", (e) => {
|
|
967
|
+
if (e.key === "Enter") {
|
|
968
|
+
e.preventDefault();
|
|
969
|
+
commit(true);
|
|
970
|
+
} else if (e.key === "Escape") {
|
|
971
|
+
e.preventDefault();
|
|
972
|
+
commit(false);
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
input.addEventListener("blur", () => commit(true));
|
|
976
|
+
valueSpan.replaceWith(input);
|
|
977
|
+
input.focus();
|
|
978
|
+
input.select();
|
|
979
|
+
}
|
|
980
|
+
/* ---------------------------------------------------------------------- */
|
|
981
|
+
/* Render profiler */
|
|
982
|
+
/* ---------------------------------------------------------------------- */
|
|
983
|
+
renderProfilerTab(model) {
|
|
984
|
+
this.currentApp();
|
|
985
|
+
const last = model.commits[model.commits.length - 1];
|
|
986
|
+
const toolbar = h(
|
|
987
|
+
"div",
|
|
988
|
+
{ class: "toolbar" },
|
|
989
|
+
h(
|
|
990
|
+
"span",
|
|
991
|
+
{ class: "muted" },
|
|
992
|
+
`${model.commits.length} commit${model.commits.length === 1 ? "" : "s"}`,
|
|
993
|
+
last ? ` · last ${fmtMs(last.duration)}` : ""
|
|
994
|
+
),
|
|
995
|
+
h("div", { class: "grow" }),
|
|
996
|
+
h("button", {
|
|
997
|
+
class: `filter-chip ${this.flashOnCommit ? "is-on" : ""}`,
|
|
998
|
+
title: "Outline the app element on every commit",
|
|
999
|
+
onclick: () => {
|
|
1000
|
+
this.flashOnCommit = !this.flashOnCommit;
|
|
1001
|
+
this.scheduleRender();
|
|
1002
|
+
}
|
|
1003
|
+
}, "Flash on commit"),
|
|
1004
|
+
h("button", {
|
|
1005
|
+
class: "icon-btn",
|
|
1006
|
+
title: "Clear commits",
|
|
1007
|
+
onclick: () => {
|
|
1008
|
+
model.commits.length = 0;
|
|
1009
|
+
this.selectedCommitId = null;
|
|
1010
|
+
this.scheduleRender();
|
|
1011
|
+
}
|
|
1012
|
+
}, "Clear")
|
|
1013
|
+
);
|
|
1014
|
+
if (model.commits.length === 0) {
|
|
1015
|
+
this.bodyEl.replaceChildren(toolbar, h(
|
|
1016
|
+
"div",
|
|
1017
|
+
{ class: "empty" },
|
|
1018
|
+
h("p", {}, "No commits recorded yet."),
|
|
1019
|
+
h("p", { class: "faint" }, "Interact with the app to capture renders.")
|
|
1020
|
+
));
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
const maxDur = Math.max(...model.commits.map((c) => c.duration), 1e-3);
|
|
1024
|
+
const strip = h("div", { class: "commit-strip" });
|
|
1025
|
+
for (const c of model.commits) {
|
|
1026
|
+
const height = Math.max(3, Math.round(c.duration / maxDur * 52));
|
|
1027
|
+
strip.appendChild(h("div", {
|
|
1028
|
+
class: `commit-bar ${c.initial ? "is-initial" : c.fullRender ? "is-full" : ""} ${c.commitId === this.selectedCommitId ? "is-selected" : ""}`,
|
|
1029
|
+
style: `height:${height}px`,
|
|
1030
|
+
title: `#${c.commitId} · ${fmtMs(c.duration)} · ${c.rendered} rendered / ${c.memoized} memoized`,
|
|
1031
|
+
onclick: () => {
|
|
1032
|
+
this.selectedCommitId = c.commitId;
|
|
1033
|
+
this.scheduleRender();
|
|
1034
|
+
}
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1037
|
+
const selected = model.commits.find((c) => c.commitId === this.selectedCommitId) ?? last;
|
|
1038
|
+
const detail = this.renderCommitDetail(selected);
|
|
1039
|
+
const ranked = this.renderRankedComponents(model);
|
|
1040
|
+
this.bodyEl.replaceChildren(toolbar, strip, detail, ranked);
|
|
1041
|
+
}
|
|
1042
|
+
renderCommitDetail(commit) {
|
|
1043
|
+
const trigger = commit.initial ? "initial mount" : commit.changedPaths.length > 0 ? commit.changedPaths.join(", ") : "forced (async / effect / timer)";
|
|
1044
|
+
const meta = h(
|
|
1045
|
+
"div",
|
|
1046
|
+
{ class: "kv" },
|
|
1047
|
+
h("span", {}, "commit ", h("b", {}, `#${commit.commitId}`)),
|
|
1048
|
+
h("span", {}, "duration ", h("b", { class: "mono" }, fmtMs(commit.duration))),
|
|
1049
|
+
h("span", {}, "rendered ", h("b", {}, String(commit.rendered))),
|
|
1050
|
+
h("span", {}, "memoized ", h("b", {}, String(commit.memoized))),
|
|
1051
|
+
h("span", {}, commit.fullRender ? h("span", { class: "chip amber" }, "full render") : h("span", { class: "chip blue" }, "incremental"))
|
|
1052
|
+
);
|
|
1053
|
+
const triggerLine = h(
|
|
1054
|
+
"div",
|
|
1055
|
+
{ class: "kv" },
|
|
1056
|
+
h("span", {}, "trigger ", h("b", { class: "mono" }, trigger))
|
|
1057
|
+
);
|
|
1058
|
+
const flame = h("div", {});
|
|
1059
|
+
if (commit.components.length === 0) {
|
|
1060
|
+
flame.appendChild(h("div", { class: "faint", style: "font-size:11px" }, "No component instances in this commit (primitive root)."));
|
|
1061
|
+
} else {
|
|
1062
|
+
const maxSelf = Math.max(...commit.components.map((c) => c.selfTime), 1e-3);
|
|
1063
|
+
const minDepth = Math.min(...commit.components.map((c) => c.depth));
|
|
1064
|
+
for (const c of commit.components) {
|
|
1065
|
+
flame.appendChild(this.renderFlameRow(c, maxSelf, minDepth));
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return h(
|
|
1069
|
+
"div",
|
|
1070
|
+
{ class: "section" },
|
|
1071
|
+
h("p", { class: "section-title" }, "Commit detail"),
|
|
1072
|
+
meta,
|
|
1073
|
+
triggerLine,
|
|
1074
|
+
flame
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
renderFlameRow(c, maxSelf, minDepth) {
|
|
1078
|
+
const indent = (c.depth - minDepth) * 12;
|
|
1079
|
+
const widthPct = c.phase === "memo" ? 22 : Math.max(6, Math.round(c.selfTime / maxSelf * 100));
|
|
1080
|
+
const label = `${c.kind === "user" ? "" : "▪ "}${c.name}`;
|
|
1081
|
+
const bar = h("div", {
|
|
1082
|
+
class: `flame-bar p-${c.phase}`,
|
|
1083
|
+
style: `width:${widthPct}%`,
|
|
1084
|
+
title: `${c.name} — ${c.phase} — ${fmtMs(c.selfTime)}
|
|
1085
|
+
${c.reason}${c.deps && c.deps.length ? `
|
|
1086
|
+
deps: ${c.deps.join(", ")}` : ""}`
|
|
1087
|
+
}, label);
|
|
1088
|
+
return h(
|
|
1089
|
+
"div",
|
|
1090
|
+
{ class: "flame-row", style: `padding-left:${indent}px` },
|
|
1091
|
+
h("div", { class: "flame-bar-wrap" }, bar),
|
|
1092
|
+
h("span", { class: "flame-time" }, c.phase === "memo" ? "memo" : fmtMs(c.selfTime))
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
renderRankedComponents(model) {
|
|
1096
|
+
const aggs = /* @__PURE__ */ new Map();
|
|
1097
|
+
for (const commit of model.commits) {
|
|
1098
|
+
for (const c of commit.components) {
|
|
1099
|
+
let a = aggs.get(c.name);
|
|
1100
|
+
if (!a) {
|
|
1101
|
+
a = { name: c.name, kind: c.kind, renders: 0, memo: 0, total: 0 };
|
|
1102
|
+
aggs.set(c.name, a);
|
|
1103
|
+
}
|
|
1104
|
+
if (c.phase === "memo") a.memo += 1;
|
|
1105
|
+
else {
|
|
1106
|
+
a.renders += 1;
|
|
1107
|
+
a.total += c.selfTime;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const rows = [...aggs.values()].sort((a, b) => b.total - a.total);
|
|
1112
|
+
const maxTotal = Math.max(...rows.map((r) => r.total), 1e-3);
|
|
1113
|
+
const table = h(
|
|
1114
|
+
"table",
|
|
1115
|
+
{ class: "dt-table" },
|
|
1116
|
+
h("thead", {}, h(
|
|
1117
|
+
"tr",
|
|
1118
|
+
{},
|
|
1119
|
+
h("th", {}, "Component"),
|
|
1120
|
+
h("th", {}, "Type"),
|
|
1121
|
+
h("th", { style: "text-align:right" }, "Renders"),
|
|
1122
|
+
h("th", { style: "text-align:right" }, "Memo"),
|
|
1123
|
+
h("th", { style: "text-align:right" }, "Total"),
|
|
1124
|
+
h("th", { style: "text-align:right" }, "Avg")
|
|
1125
|
+
)),
|
|
1126
|
+
h("tbody", {}, ...rows.map(
|
|
1127
|
+
(r) => h(
|
|
1128
|
+
"tr",
|
|
1129
|
+
{},
|
|
1130
|
+
h("td", { class: "name" }, r.name),
|
|
1131
|
+
h("td", {}, h("span", { class: `chip ${r.kind === "user" ? "purple" : "grey"}` }, r.kind)),
|
|
1132
|
+
h("td", { class: "num" }, String(r.renders)),
|
|
1133
|
+
h("td", { class: "num" }, String(r.memo)),
|
|
1134
|
+
h(
|
|
1135
|
+
"td",
|
|
1136
|
+
{ class: "num bar-cell" },
|
|
1137
|
+
h("span", { class: "barfill", style: `width:${Math.round(r.total / maxTotal * 100)}%` }),
|
|
1138
|
+
h("span", {}, fmtMs(r.total))
|
|
1139
|
+
),
|
|
1140
|
+
h("td", { class: "num" }, r.renders ? fmtMs(r.total / r.renders) : "—")
|
|
1141
|
+
)
|
|
1142
|
+
))
|
|
1143
|
+
);
|
|
1144
|
+
return h(
|
|
1145
|
+
"div",
|
|
1146
|
+
{ class: "section" },
|
|
1147
|
+
h("p", { class: "section-title" }, "Components — ranked by total self time"),
|
|
1148
|
+
rows.length ? table : h("div", { class: "faint", style: "font-size:11px" }, "No component renders captured.")
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
/* ---------------------------------------------------------------------- */
|
|
1152
|
+
/* Effect timeline */
|
|
1153
|
+
/* ---------------------------------------------------------------------- */
|
|
1154
|
+
renderEffectsTab(model) {
|
|
1155
|
+
const phases = ["mount", "run", "cleanup", "unmount", "error"];
|
|
1156
|
+
const toolbar = h(
|
|
1157
|
+
"div",
|
|
1158
|
+
{ class: "toolbar" },
|
|
1159
|
+
h("div", { class: "filters" }, ...phases.map(
|
|
1160
|
+
(p) => h("button", {
|
|
1161
|
+
class: `filter-chip ${this.phaseFilter.has(p) ? "is-on" : ""}`,
|
|
1162
|
+
onclick: () => {
|
|
1163
|
+
if (this.phaseFilter.has(p)) this.phaseFilter.delete(p);
|
|
1164
|
+
else this.phaseFilter.add(p);
|
|
1165
|
+
this.scheduleRender();
|
|
1166
|
+
}
|
|
1167
|
+
}, p)
|
|
1168
|
+
)),
|
|
1169
|
+
h("div", { class: "grow" }),
|
|
1170
|
+
h("button", {
|
|
1171
|
+
class: "icon-btn",
|
|
1172
|
+
title: "Clear effect events",
|
|
1173
|
+
onclick: () => {
|
|
1174
|
+
model.effects.length = 0;
|
|
1175
|
+
this.scheduleRender();
|
|
1176
|
+
}
|
|
1177
|
+
}, "Clear")
|
|
1178
|
+
);
|
|
1179
|
+
if (model.effects.length === 0) {
|
|
1180
|
+
this.bodyEl.replaceChildren(toolbar, h(
|
|
1181
|
+
"div",
|
|
1182
|
+
{ class: "empty" },
|
|
1183
|
+
h("p", {}, "No effects observed yet."),
|
|
1184
|
+
h("p", { class: "faint" }, "Effects appear as they mount, run, and clean up.")
|
|
1185
|
+
));
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
this.bodyEl.replaceChildren(toolbar, this.renderEffectLanes(model), this.renderEffectLog(model));
|
|
1189
|
+
}
|
|
1190
|
+
renderEffectLanes(model) {
|
|
1191
|
+
const lanes = /* @__PURE__ */ new Map();
|
|
1192
|
+
for (const e of model.effects) {
|
|
1193
|
+
let lane = lanes.get(e.effectKey);
|
|
1194
|
+
if (!lane) {
|
|
1195
|
+
lane = { key: e.effectKey, label: e.label, triggers: e.triggers, runs: 0, total: 0, lastReason: e.reason, instance: e.instanceKey != null };
|
|
1196
|
+
lanes.set(e.effectKey, lane);
|
|
1197
|
+
}
|
|
1198
|
+
if (e.phase === "run") {
|
|
1199
|
+
lane.runs += 1;
|
|
1200
|
+
lane.total += e.duration ?? 0;
|
|
1201
|
+
lane.lastReason = e.reason;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
const list = [...lanes.values()].sort((a, b) => b.runs - a.runs);
|
|
1205
|
+
const wrap = h("div", { class: "section", style: "padding:0" });
|
|
1206
|
+
wrap.appendChild(h("p", { class: "section-title", style: "padding:8px 10px 0" }, `Effects (${list.length})`));
|
|
1207
|
+
for (const lane of list) {
|
|
1208
|
+
wrap.appendChild(h(
|
|
1209
|
+
"div",
|
|
1210
|
+
{ class: "lane" },
|
|
1211
|
+
h("span", { class: "lane-name" }, lane.label),
|
|
1212
|
+
lane.instance ? h("span", { class: "chip purple", style: "flex:0 0 auto" }, "instance") : null,
|
|
1213
|
+
h("span", { class: "lane-trig" }, lane.triggers),
|
|
1214
|
+
h("span", { class: "lane-stat" }, `${lane.runs} run${lane.runs === 1 ? "" : "s"} · ${fmtMs(lane.total)}`)
|
|
1215
|
+
));
|
|
1216
|
+
}
|
|
1217
|
+
return wrap;
|
|
1218
|
+
}
|
|
1219
|
+
renderEffectLog(model) {
|
|
1220
|
+
const base = model.firstTime ?? 0;
|
|
1221
|
+
const filtered = model.effects.filter((e) => this.phaseFilter.has(e.phase));
|
|
1222
|
+
const rows = filtered.slice(-250).reverse();
|
|
1223
|
+
const wrap = h("div", { class: "section", style: "padding:0;border-bottom:none" });
|
|
1224
|
+
wrap.appendChild(h("p", { class: "section-title", style: "padding:8px 10px 0" }, "Timeline"));
|
|
1225
|
+
if (rows.length === 0) {
|
|
1226
|
+
wrap.appendChild(h("div", { class: "faint", style: "font-size:11px;padding:0 10px 10px" }, "No events match the active filters."));
|
|
1227
|
+
return wrap;
|
|
1228
|
+
}
|
|
1229
|
+
for (const e of rows) {
|
|
1230
|
+
wrap.appendChild(h(
|
|
1231
|
+
"div",
|
|
1232
|
+
{ class: "log-row" },
|
|
1233
|
+
h("span", { class: "t" }, fmtRel(e.time - base)),
|
|
1234
|
+
h("span", { class: "ph" }, h("span", { class: `chip ${PHASE_CHIP[e.phase] ?? "grey"}` }, e.phase)),
|
|
1235
|
+
h("span", { class: "lbl" }, e.label),
|
|
1236
|
+
h(
|
|
1237
|
+
"span",
|
|
1238
|
+
{ class: "rsn" },
|
|
1239
|
+
e.reason,
|
|
1240
|
+
e.phase === "run" && e.duration != null ? ` · ${fmtMs(e.duration)}` : "",
|
|
1241
|
+
e.phase === "cleanup" && e.cleanups != null ? ` · ${e.cleanups}×` : "",
|
|
1242
|
+
e.error ? ` · ${e.error}` : ""
|
|
1243
|
+
)
|
|
1244
|
+
));
|
|
1245
|
+
}
|
|
1246
|
+
return wrap;
|
|
1247
|
+
}
|
|
1248
|
+
/* ---------------------------------------------------------------------- */
|
|
1249
|
+
/* Highlight + drag/resize */
|
|
1250
|
+
/* ---------------------------------------------------------------------- */
|
|
1251
|
+
flashApp(appId) {
|
|
1252
|
+
const app = this.hook?.apps.get(appId);
|
|
1253
|
+
if (!app) return;
|
|
1254
|
+
const el = app.element;
|
|
1255
|
+
const prev = el.style.outline;
|
|
1256
|
+
el.style.outline = "2px solid rgba(124,156,255,0.9)";
|
|
1257
|
+
el.style.outlineOffset = "1px";
|
|
1258
|
+
if (this.flashTimer) clearTimeout(this.flashTimer);
|
|
1259
|
+
this.flashTimer = setTimeout(() => {
|
|
1260
|
+
el.style.outline = prev;
|
|
1261
|
+
el.style.outlineOffset = "";
|
|
1262
|
+
}, 140);
|
|
1263
|
+
}
|
|
1264
|
+
makeDraggable(handle) {
|
|
1265
|
+
let startX = 0, startY = 0, originLeft = 0, originTop = 0, dragging = false;
|
|
1266
|
+
const onDown = (e) => {
|
|
1267
|
+
if (e.target.closest("button, select, input")) return;
|
|
1268
|
+
dragging = true;
|
|
1269
|
+
handle.classList.add("is-dragging");
|
|
1270
|
+
startX = e.clientX;
|
|
1271
|
+
startY = e.clientY;
|
|
1272
|
+
const rect = this.getBoundingClientRect();
|
|
1273
|
+
originLeft = rect.left;
|
|
1274
|
+
originTop = rect.top;
|
|
1275
|
+
e.preventDefault();
|
|
1276
|
+
window.addEventListener("mousemove", onMove);
|
|
1277
|
+
window.addEventListener("mouseup", onUp);
|
|
1278
|
+
};
|
|
1279
|
+
const onMove = (e) => {
|
|
1280
|
+
if (!dragging) return;
|
|
1281
|
+
this.style.left = `${Math.max(0, originLeft + (e.clientX - startX))}px`;
|
|
1282
|
+
this.style.top = `${Math.max(0, originTop + (e.clientY - startY))}px`;
|
|
1283
|
+
};
|
|
1284
|
+
const onUp = () => {
|
|
1285
|
+
dragging = false;
|
|
1286
|
+
handle.classList.remove("is-dragging");
|
|
1287
|
+
window.removeEventListener("mousemove", onMove);
|
|
1288
|
+
window.removeEventListener("mouseup", onUp);
|
|
1289
|
+
};
|
|
1290
|
+
handle.addEventListener("mousedown", onDown);
|
|
1291
|
+
}
|
|
1292
|
+
makeResizable(grip) {
|
|
1293
|
+
let startX = 0, startY = 0, startW = 0, startH = 0, resizing = false;
|
|
1294
|
+
const onDown = (e) => {
|
|
1295
|
+
resizing = true;
|
|
1296
|
+
startX = e.clientX;
|
|
1297
|
+
startY = e.clientY;
|
|
1298
|
+
const rect = this.panelEl.getBoundingClientRect();
|
|
1299
|
+
startW = rect.width;
|
|
1300
|
+
startH = rect.height;
|
|
1301
|
+
e.preventDefault();
|
|
1302
|
+
e.stopPropagation();
|
|
1303
|
+
window.addEventListener("mousemove", onMove);
|
|
1304
|
+
window.addEventListener("mouseup", onUp);
|
|
1305
|
+
};
|
|
1306
|
+
const onMove = (e) => {
|
|
1307
|
+
if (!resizing) return;
|
|
1308
|
+
this.panelEl.style.width = `${Math.max(320, startW + (e.clientX - startX))}px`;
|
|
1309
|
+
this.panelEl.style.height = `${Math.max(240, startH + (e.clientY - startY))}px`;
|
|
1310
|
+
};
|
|
1311
|
+
const onUp = () => {
|
|
1312
|
+
resizing = false;
|
|
1313
|
+
window.removeEventListener("mousemove", onMove);
|
|
1314
|
+
window.removeEventListener("mouseup", onUp);
|
|
1315
|
+
};
|
|
1316
|
+
grip.addEventListener("mousedown", onDown);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
__publicField(AktionDevtoolsElement, "tagName", "aktion-devtools");
|
|
1320
|
+
function eventTime(event) {
|
|
1321
|
+
if (event.kind === "commit") return event.startTime;
|
|
1322
|
+
if (event.kind === "state") return event.time;
|
|
1323
|
+
return event.time;
|
|
1324
|
+
}
|
|
1325
|
+
function rootOf(path) {
|
|
1326
|
+
const dot = path.indexOf(".");
|
|
1327
|
+
return dot < 0 ? path : path.slice(0, dot);
|
|
1328
|
+
}
|
|
1329
|
+
function defineDevtoolsElement() {
|
|
1330
|
+
if (typeof customElements === "undefined") return;
|
|
1331
|
+
if (!customElements.get(AktionDevtoolsElement.tagName)) {
|
|
1332
|
+
customElements.define(AktionDevtoolsElement.tagName, AktionDevtoolsElement);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function mountDevtools(options = {}) {
|
|
1336
|
+
const hook = installDevtoolsHook(DEVTOOLS_UI_VERSION);
|
|
1337
|
+
defineDevtoolsElement();
|
|
1338
|
+
const element = document.createElement(AktionDevtoolsElement.tagName);
|
|
1339
|
+
(options.container ?? document.body).appendChild(element);
|
|
1340
|
+
if (options.appId) element.selectApp(options.appId);
|
|
1341
|
+
if (options.open === false) element.close();
|
|
1342
|
+
return {
|
|
1343
|
+
element,
|
|
1344
|
+
hook,
|
|
1345
|
+
open: () => element.open(),
|
|
1346
|
+
close: () => element.close(),
|
|
1347
|
+
toggle: () => element.toggle(),
|
|
1348
|
+
selectApp: (id) => element.selectApp(id),
|
|
1349
|
+
destroy: () => element.remove()
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function isDevtoolsInstalled() {
|
|
1353
|
+
return getDevtoolsHook() !== void 0;
|
|
1354
|
+
}
|
|
1355
|
+
defineDevtoolsElement();
|
|
1356
|
+
export {
|
|
1357
|
+
AktionDevtoolsElement,
|
|
1358
|
+
DEVTOOLS_PROTOCOL_VERSION,
|
|
1359
|
+
HOOK_KEY,
|
|
1360
|
+
defineDevtoolsElement,
|
|
1361
|
+
getDevtoolsHook,
|
|
1362
|
+
installDevtoolsHook,
|
|
1363
|
+
isDevtoolsActive,
|
|
1364
|
+
isDevtoolsInstalled,
|
|
1365
|
+
mountDevtools
|
|
1366
|
+
};
|
|
1367
|
+
//# sourceMappingURL=devtools.js.map
|