brumate 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-D-IdPy7B.d.ts → boot-C25Sa6vq.d.ts} +5 -2
- package/dist/cli.js +2 -2
- package/dist/{client-C0UCNL3J.js → client-BD6XT-s5.js} +435 -110
- package/dist/client-BD6XT-s5.js.map +1 -0
- package/dist/{client-MD0ZmcFR.d.ts → client-D0CqSxoO.d.ts} +114 -8
- package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
- package/dist/cookies-BzllthiF.js.map +1 -0
- package/dist/{defer-D0bo1Gqx.js → defer-BbD7JQhj.js} +6 -2
- package/dist/defer-BbD7JQhj.js.map +1 -0
- package/dist/devtools-CQgD7NPB.js +623 -0
- package/dist/devtools-CQgD7NPB.js.map +1 -0
- package/dist/devtools-panel-BVB-W5q4.js +1930 -0
- package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
- package/dist/events-CSs7OwIC.js +85 -0
- package/dist/events-CSs7OwIC.js.map +1 -0
- package/dist/{files-Bnn1JqHx.js → files-BXSSrQgc.js} +18 -5
- package/dist/files-BXSSrQgc.js.map +1 -0
- package/dist/forms-Bg-CwGqX.js +406 -0
- package/dist/forms-Bg-CwGqX.js.map +1 -0
- package/dist/forms-Cl21hkHt.d.ts +281 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +269 -0
- package/dist/highlight.js.map +1 -0
- package/dist/{html-y1q7-t7D.d.ts → html-Bq1rFxX_.d.ts} +36 -4
- package/dist/{html-bHZbkK-h.js → html-mNTKzaDD.js} +79 -8
- package/dist/html-mNTKzaDD.js.map +1 -0
- package/dist/index.d.ts +47 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BJtACnQp.js → inspect-BHpOw1LF.js} +625 -48
- package/dist/inspect-BHpOw1LF.js.map +1 -0
- package/dist/{loader-B18i3_-T.js → loader-Dos_3NP0.js} +5 -4
- package/dist/loader-Dos_3NP0.js.map +1 -0
- package/dist/{navigate-BwuZveDF.js → navigate-O78d_zGN.js} +45 -2
- package/dist/navigate-O78d_zGN.js.map +1 -0
- package/dist/{produce-D4K7qpaL.d.ts → produce-D0V0ICkz.d.ts} +45 -3
- package/dist/{produce-CWfJ4byV.js → produce-Doc91GkX.js} +113 -6
- package/dist/produce-Doc91GkX.js.map +1 -0
- package/dist/{rpc-B-Zkn6Ch.js → rpc-ygMRPmN4.js} +20 -10
- package/dist/rpc-ygMRPmN4.js.map +1 -0
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +188 -3
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +15 -0
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +5 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +38 -2
- package/dist/runtime/signals.js +12 -2
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/{server-BqfM95r1.js → server-CxVDYE_V.js} +776 -121
- package/dist/server-CxVDYE_V.js.map +1 -0
- package/dist/{server-BA9SJ2Vm.d.ts → server-DuFYRXrd.d.ts} +284 -15
- package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
- package/dist/{static-loader-DOygOFj5.js → static-loader-nZssh66R.js} +168 -51
- package/dist/static-loader-nZssh66R.js.map +1 -0
- package/dist/{stream-JaMHMdBD.js → stream-DCYZO4IF.js} +89 -10
- package/dist/stream-DCYZO4IF.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +170 -20
- package/dist/vite.js.map +1 -1
- package/forms/forms.brm.ts +141 -0
- package/package.json +31 -2
- package/dist/client-C0UCNL3J.js.map +0 -1
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/defer-D0bo1Gqx.js.map +0 -1
- package/dist/devtools-C50VH8gZ.js +0 -113
- package/dist/devtools-C50VH8gZ.js.map +0 -1
- package/dist/devtools-panel-AYjfwPhj.js +0 -435
- package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
- package/dist/events-BKWRqtMg.js +0 -52
- package/dist/events-BKWRqtMg.js.map +0 -1
- package/dist/files-Bnn1JqHx.js.map +0 -1
- package/dist/html-bHZbkK-h.js.map +0 -1
- package/dist/inspect-BJtACnQp.js.map +0 -1
- package/dist/loader-B18i3_-T.js.map +0 -1
- package/dist/navigate-BwuZveDF.js.map +0 -1
- package/dist/produce-CWfJ4byV.js.map +0 -1
- package/dist/rpc-B-Zkn6Ch.js.map +0 -1
- package/dist/server-BqfM95r1.js.map +0 -1
- package/dist/static-loader-DOygOFj5.js.map +0 -1
- package/dist/stream-JaMHMdBD.js.map +0 -1
|
@@ -0,0 +1,1930 @@
|
|
|
1
|
+
import { i as preview, n as PRELOADS, o as rootOf, t as LOGO } from "./devtools-CQgD7NPB.js";
|
|
2
|
+
//#region src/runtime/devtools-panel.ts
|
|
3
|
+
const STYLE = `
|
|
4
|
+
:host { all: initial; }
|
|
5
|
+
.panel {
|
|
6
|
+
--bg: #121113; --surface: #19181a; --raised: #222023; --hover: #2a282c; --line: #2f2c31;
|
|
7
|
+
--text: #ece8e4; --dim: #a39a92; --faint: #6f6862; --accent: #ee7a3e;
|
|
8
|
+
--blue: #7cb7ff; --purple: #c49bff; --green: #7fd99a; --yellow: #ffd166; --red: #ff7a7a;
|
|
9
|
+
--mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
10
|
+
position: fixed; left: 0; right: 0; bottom: 0; z-index: 2147483647;
|
|
11
|
+
display: flex; flex-direction: column; min-height: 160px; max-height: 90vh;
|
|
12
|
+
background: var(--bg); color: var(--text); border-top: 1px solid var(--line);
|
|
13
|
+
box-shadow: 0 -8px 32px #0007; font: 12px/1.5 system-ui, -apple-system, sans-serif;
|
|
14
|
+
color-scheme: dark;
|
|
15
|
+
}
|
|
16
|
+
.resize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; }
|
|
17
|
+
.top { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; overflow: hidden; }
|
|
18
|
+
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: -0.01em; }
|
|
19
|
+
.brand i { display: inline-block; width: 18px; height: 18px; }
|
|
20
|
+
.chip { padding: 1px 7px; border-radius: 999px; background: var(--raised); color: var(--dim); font: 11px var(--mono); }
|
|
21
|
+
.chip.accent { background: #ee7a3e22; color: #ffb48a; }
|
|
22
|
+
.route { font: 12px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; }
|
|
23
|
+
.stats { color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
|
|
24
|
+
.spacer { flex: 1; }
|
|
25
|
+
button, select, input { font: inherit; color: inherit; }
|
|
26
|
+
button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; cursor: pointer; }
|
|
27
|
+
button:hover { background: var(--hover); }
|
|
28
|
+
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
|
|
29
|
+
button.tool { display: inline-flex; align-items: center; gap: 6px; border-color: var(--line); background: var(--surface); }
|
|
30
|
+
button.tool .icon { color: var(--dim); flex: none; }
|
|
31
|
+
button.tool:hover .icon { color: var(--text); }
|
|
32
|
+
button.tool.only { padding: 3px 5px; }
|
|
33
|
+
.link { display: inline-flex; align-items: center; gap: 4px; }
|
|
34
|
+
.link .icon { opacity: 0.7; }
|
|
35
|
+
.zoom button.tool { background: var(--raised); }
|
|
36
|
+
button.tool[aria-pressed="true"] { border-color: var(--accent); background: #ee7a3e22; color: #ffb48a; }
|
|
37
|
+
select, input[type="search"] { background: var(--raised); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
|
|
38
|
+
.main { flex: 1; display: flex; min-height: 0; }
|
|
39
|
+
.nav { display: flex; flex-direction: column; gap: 1px; padding: 6px; width: 156px; flex: none; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
|
|
40
|
+
.nav .tab { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 4px 8px; color: var(--dim); }
|
|
41
|
+
.nav .tab { gap: 8px; }
|
|
42
|
+
.nav .tab .label { flex: 1; }
|
|
43
|
+
.icon { flex: none; }
|
|
44
|
+
.nav .tab .icon { color: var(--faint); transition: color 0.15s; }
|
|
45
|
+
.nav .tab:hover .icon { color: var(--dim); }
|
|
46
|
+
.nav .tab[aria-selected="true"] { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
|
|
47
|
+
.nav .tab[aria-selected="true"] .icon { color: var(--accent); }
|
|
48
|
+
.badge { min-width: 16px; padding: 0 5px; border-radius: 999px; background: var(--raised); color: var(--dim); font: 10px/16px var(--mono); text-align: center; }
|
|
49
|
+
.badge:empty { display: none; }
|
|
50
|
+
.tab[aria-selected="true"] .badge { background: var(--hover); }
|
|
51
|
+
.badge.warn { background: #ffd16622; color: var(--yellow); }
|
|
52
|
+
.badge.error, .tab[aria-selected="true"] .badge.error { background: #e5484d; color: #fff; }
|
|
53
|
+
.error-message { margin: 0 0 8px; color: var(--red); font: 600 14px/1.4 var(--mono); white-space: pre-wrap; }
|
|
54
|
+
.error-row { display: block; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; }
|
|
55
|
+
.error-row[aria-current="true"] { background: #e5484d14; box-shadow: 0 0 0 1px #e5484d40; }
|
|
56
|
+
.error-row .text { display: block; color: var(--text); font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
57
|
+
.error-row .when { color: var(--faint); font-size: 11px; }
|
|
58
|
+
.code { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #0d1117; overflow: auto; }
|
|
59
|
+
.code .twinkleplop { margin: 0; padding: 8px 0; font: 12px/1.6 var(--mono); background: none; white-space: normal; }
|
|
60
|
+
.code .l { display: block; padding: 0 12px 0 0; white-space: pre; min-height: 1.6em; }
|
|
61
|
+
.code .ln { display: inline-block; width: 44px; padding-right: 12px; text-align: right; color: var(--faint); user-select: none; }
|
|
62
|
+
.code .l.error-line { background: #e5484d24; }
|
|
63
|
+
.code .l.error-line .ln { color: var(--red); }
|
|
64
|
+
.code .error-mark { text-decoration: wavy underline #e5484d; text-underline-offset: 3px; }
|
|
65
|
+
.code pre.plain { margin: 0; padding: 8px 12px; font: 12px/1.6 var(--mono); white-space: pre; }
|
|
66
|
+
.frames { display: flex; flex-direction: column; gap: 1px; }
|
|
67
|
+
.frame { display: flex; gap: 10px; width: 100%; text-align: left; padding: 3px 8px; border-radius: 5px; font: 11.5px var(--mono); }
|
|
68
|
+
.frame .fn { color: var(--text); white-space: nowrap; }
|
|
69
|
+
.frame .where { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
70
|
+
.frame.library .fn, .frame.library .where { color: var(--faint); }
|
|
71
|
+
.frame[aria-current="true"] { background: #ee7a3e14; box-shadow: 0 0 0 1px #ee7a3e40; }
|
|
72
|
+
.frame[aria-current="true"] .fn { color: #ffb48a; }
|
|
73
|
+
.body { flex: 1; overflow: auto; padding: 12px 14px; min-width: 0; }
|
|
74
|
+
.split { display: flex; height: calc(100% + 24px); margin: -12px -14px; }
|
|
75
|
+
.split > .list { width: 280px; flex: none; overflow: auto; border-right: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 1px; }
|
|
76
|
+
.split > .list input { margin-bottom: 6px; }
|
|
77
|
+
.split > .detail { flex: 1; overflow: auto; padding: 12px 14px; min-width: 0; }
|
|
78
|
+
h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
|
|
79
|
+
h3 { margin: 14px 0 6px; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
|
|
80
|
+
.sub { color: var(--dim); font-weight: 400; }
|
|
81
|
+
.mono { font-family: var(--mono); }
|
|
82
|
+
.empty { color: var(--faint); padding: 16px 0; }
|
|
83
|
+
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
|
|
84
|
+
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 6px; }
|
|
85
|
+
.card { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
|
|
86
|
+
.card .label { color: var(--dim); font-size: 11px; }
|
|
87
|
+
.card .value { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
|
|
88
|
+
.card .note { color: var(--faint); font-size: 11px; }
|
|
89
|
+
.rows { width: 100%; border-collapse: collapse; }
|
|
90
|
+
.rows th { text-align: left; color: var(--faint); font-weight: 500; font-size: 11px; }
|
|
91
|
+
.rows td, .rows th { padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
|
|
92
|
+
.rows tr:hover td { background: #ffffff05; }
|
|
93
|
+
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; align-items: baseline; }
|
|
94
|
+
.kv > :nth-child(odd) { color: var(--dim); }
|
|
95
|
+
.pill { display: inline-block; padding: 0 7px; border-radius: 999px; font: 11px/18px var(--mono); background: var(--raised); color: var(--dim); white-space: nowrap; }
|
|
96
|
+
.pill.blue { background: #7cb7ff1f; color: var(--blue); } .pill.purple { background: #c49bff1f; color: var(--purple); }
|
|
97
|
+
.pill.green { background: #7fd99a1f; color: var(--green); } .pill.yellow { background: #ffd1661f; color: var(--yellow); }
|
|
98
|
+
.pill.red { background: #ff7a7a1f; color: var(--red); } .pill.accent { background: #ee7a3e22; color: #ffb48a; }
|
|
99
|
+
.pill .name { color: #ffc28f; }
|
|
100
|
+
.link { color: var(--blue); padding: 0; border: 0; font-family: var(--mono); text-align: left; }
|
|
101
|
+
.link:hover { background: none; text-decoration: underline; }
|
|
102
|
+
.tree-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 2px 6px; border-radius: 5px; }
|
|
103
|
+
.tree-row.component { font-weight: 600; margin-top: 4px; }
|
|
104
|
+
.tree-row .file { color: var(--faint); font: 11px var(--mono); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
105
|
+
.tree-row[aria-current="true"] { background: #ee7a3e14; box-shadow: 0 0 0 1px #ee7a3e40; }
|
|
106
|
+
.tree-row[aria-current="true"] > span:first-child { color: #ffb48a; }
|
|
107
|
+
.written { animation: flash 0.8s; }
|
|
108
|
+
@keyframes flash { from { background: #ffd16633; } to { background: transparent; } }
|
|
109
|
+
.slots td.name { color: #ffc28f; font-family: var(--mono); width: 1%; white-space: nowrap; }
|
|
110
|
+
.slots td.type { color: var(--faint); font-family: var(--mono); width: 1%; white-space: nowrap; }
|
|
111
|
+
.slot .value { font-family: var(--mono); cursor: text; border-bottom: 1px dotted var(--faint); }
|
|
112
|
+
.slot .value.fixed { cursor: default; border: 0; }
|
|
113
|
+
.slot input { font: 12px var(--mono); color: var(--text); background: #000; border: 1px solid var(--accent); border-radius: 4px; padding: 1px 6px; width: 100%; box-sizing: border-box; }
|
|
114
|
+
.filters label { display: inline-flex; gap: 4px; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--raised); cursor: pointer; }
|
|
115
|
+
.entry td { font-family: var(--mono); }
|
|
116
|
+
.entry .time { color: var(--faint); white-space: nowrap; width: 1%; }
|
|
117
|
+
.kind-handler { color: var(--blue); } .kind-part { color: var(--green); } .kind-write { color: var(--yellow); } .kind-call { color: #ff9ecf; }
|
|
118
|
+
.bar-cell { width: 40%; min-width: 160px; }
|
|
119
|
+
.navigation { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
|
|
120
|
+
.navigation .routes { display: flex; flex-direction: column; gap: 3px; }
|
|
121
|
+
tr.large td, tr.busy td { color: var(--yellow); }
|
|
122
|
+
tr.ended td { color: var(--faint); }
|
|
123
|
+
.bar-track { position: relative; height: 12px; }
|
|
124
|
+
.bar { position: absolute; top: 2px; height: 8px; min-width: 3px; border-radius: 3px; background: var(--blue); }
|
|
125
|
+
.bar.preload { background: var(--purple); } .bar.other { background: var(--faint); }
|
|
126
|
+
.bar.unused { background: repeating-linear-gradient(45deg, var(--purple) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--purple); }
|
|
127
|
+
.bar.failed { background: var(--red); }
|
|
128
|
+
.bar.render { background: var(--accent); } .bar.memo { background: var(--green); } .bar.body { background: var(--purple); } .bar.stream { background: var(--faint); }
|
|
129
|
+
tr.unused td:not(.bar-cell) { color: var(--yellow); }
|
|
130
|
+
tr.failed td:not(.bar-cell) { color: var(--red); }
|
|
131
|
+
.interaction { margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
|
|
132
|
+
.run-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
|
|
133
|
+
.run-head .what { font-weight: 600; }
|
|
134
|
+
.run-head .ref { color: var(--dim); font: 11.5px var(--mono); }
|
|
135
|
+
.run-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 90px; align-items: center; gap: 10px; font: 11.5px var(--mono); color: var(--dim); }
|
|
136
|
+
.run-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
137
|
+
.run-row .took { text-align: right; color: var(--text); }
|
|
138
|
+
.track { position: relative; height: 14px; overflow: hidden; border-radius: 4px; background-color: #ffffff08; }
|
|
139
|
+
.ruler { position: relative; height: 16px; color: var(--faint); font: 10.5px var(--mono); }
|
|
140
|
+
.ruler span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
|
|
141
|
+
.ruler span:first-child { transform: none; }
|
|
142
|
+
.ruler span.end { transform: translateX(-100%); }
|
|
143
|
+
.seg { position: absolute; top: 3px; height: 8px; min-width: 2px; border-radius: 3px; }
|
|
144
|
+
.seg.wait { background: repeating-linear-gradient(45deg, var(--faint) 0 3px, transparent 3px 6px); }
|
|
145
|
+
.seg.run { background: var(--blue); }
|
|
146
|
+
.seg.async { background: #7cb7ff55; }
|
|
147
|
+
.seg.call { background: #ff9ecf88; }
|
|
148
|
+
.seg.server { background: #ff9ecf; }
|
|
149
|
+
.seg.update { background: var(--green); }
|
|
150
|
+
.seg.failed { background: var(--red); }
|
|
151
|
+
.legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; color: var(--dim); }
|
|
152
|
+
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
|
|
153
|
+
.graph-wrap { display: flex; gap: 10px; height: calc(100% - 42px); min-height: 180px; }
|
|
154
|
+
.graph-view { position: relative; flex: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: radial-gradient(circle, #ffffff12 1px, transparent 1px) 0 0 / 16px 16px; cursor: grab; touch-action: none; }
|
|
155
|
+
.graph-view.dragging { cursor: grabbing; }
|
|
156
|
+
.graph-view svg { display: block; width: 100%; height: 100%; }
|
|
157
|
+
.graph-side { width: 250px; flex: none; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
|
|
158
|
+
.zoom { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; }
|
|
159
|
+
.zoom button { background: var(--raised); border-color: var(--line); min-width: 28px; }
|
|
160
|
+
svg .node rect.box { fill: var(--surface); stroke: var(--line); }
|
|
161
|
+
svg .node .kind { fill: var(--faint); }
|
|
162
|
+
svg .node .name { fill: var(--text); font: 600 11.5px var(--mono); }
|
|
163
|
+
svg .node .meta { fill: var(--dim); font: 10.5px var(--mono); }
|
|
164
|
+
svg .node { cursor: pointer; }
|
|
165
|
+
svg .node:hover rect.box { stroke: var(--dim); }
|
|
166
|
+
svg .k-signal .kind, svg .k-prop .kind { fill: var(--blue); }
|
|
167
|
+
svg .k-memo .kind { fill: var(--purple); }
|
|
168
|
+
svg .k-effect .kind { fill: var(--green); }
|
|
169
|
+
svg .node.selected rect.box { stroke: var(--accent); stroke-width: 1.5; }
|
|
170
|
+
svg .node.hot rect.box { fill: #3a3020; stroke: var(--yellow); }
|
|
171
|
+
svg .node.faded { opacity: 0.3; }
|
|
172
|
+
svg path.edge { fill: none; stroke: #8a828066; stroke-width: 1.25; }
|
|
173
|
+
svg path.edge.lit { stroke: var(--accent); stroke-width: 1.75; }
|
|
174
|
+
svg path.edge.hot-edge { stroke: var(--yellow); stroke-width: 1.75; }
|
|
175
|
+
svg path.edge.faded { opacity: 0.15; }
|
|
176
|
+
pre.report { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: 11.5px/1.55 var(--mono); white-space: pre-wrap; }
|
|
177
|
+
.inspect-card { position: fixed; z-index: 2147483647; display: flex; flex-direction: column; gap: 5px; max-width: 340px; padding: 9px 11px; border: 1px solid var(--line, #2f2c31); border-radius: 10px; background: #19181aee; color: #ece8e4; font: 12px/1.4 system-ui, -apple-system, sans-serif; box-shadow: 0 10px 28px #0008; pointer-events: none; backdrop-filter: blur(6px); }
|
|
178
|
+
.inspect-card .card-head { display: flex; justify-content: space-between; gap: 12px; color: #ffb48a; }
|
|
179
|
+
.inspect-card .card-component { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
|
|
180
|
+
.inspect-card .card-pills { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
181
|
+
.inspect-card .card-hint { margin-top: 2px; padding-top: 6px; border-top: 1px solid #2f2c31; color: #6f6862; font-size: 11px; }
|
|
182
|
+
.outline { position: fixed; pointer-events: none; border: 2px solid #ee7a3e; background: #ee7a3e22; border-radius: 3px; z-index: 2147483646; }
|
|
183
|
+
`;
|
|
184
|
+
const TABS = [
|
|
185
|
+
["overview", "Overview"],
|
|
186
|
+
["errors", "Errors"],
|
|
187
|
+
["scopes", "Components"],
|
|
188
|
+
["elements", "Elements"],
|
|
189
|
+
["graph", "Graph"],
|
|
190
|
+
["log", "Log"],
|
|
191
|
+
["timeline", "Timeline"],
|
|
192
|
+
["loading", "Loading"],
|
|
193
|
+
["state", "Page state"],
|
|
194
|
+
["effects", "Effects"],
|
|
195
|
+
["navigation", "Navigation"],
|
|
196
|
+
["server", "Server"],
|
|
197
|
+
["blocks", "Blocks"],
|
|
198
|
+
["report", "Report"]
|
|
199
|
+
];
|
|
200
|
+
const KINDS = [
|
|
201
|
+
"handler",
|
|
202
|
+
"part",
|
|
203
|
+
"write",
|
|
204
|
+
"call"
|
|
205
|
+
];
|
|
206
|
+
/** How long a write marks the nodes of the graph. */
|
|
207
|
+
const HOT_MS = 1500;
|
|
208
|
+
/** The height of the panel, kept between pages. */
|
|
209
|
+
const HEIGHT_KEY = "brumate:devtools:height";
|
|
210
|
+
const components = /* @__PURE__ */ new Map();
|
|
211
|
+
const known = /* @__PURE__ */ new Map();
|
|
212
|
+
/** Asks the dev server about a component, once. */
|
|
213
|
+
function componentInfo(state, id) {
|
|
214
|
+
let info = components.get(id);
|
|
215
|
+
if (!info) {
|
|
216
|
+
info = fetch(`${state.endpoint}/${encodeURIComponent(id)}`).then((response) => response.ok ? response.json() : void 0).then((value) => {
|
|
217
|
+
if (value) known.set(id, value);
|
|
218
|
+
return value;
|
|
219
|
+
}).catch(() => void 0);
|
|
220
|
+
components.set(id, info);
|
|
221
|
+
}
|
|
222
|
+
return info;
|
|
223
|
+
}
|
|
224
|
+
function element(tag, attributes = {}, ...children) {
|
|
225
|
+
const node = document.createElement(tag);
|
|
226
|
+
for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, value);
|
|
227
|
+
node.append(...children);
|
|
228
|
+
return node;
|
|
229
|
+
}
|
|
230
|
+
function svg(tag, attributes, ...children) {
|
|
231
|
+
const node = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
232
|
+
for (const [name, value] of Object.entries(attributes)) node.setAttribute(name, String(value));
|
|
233
|
+
node.append(...children);
|
|
234
|
+
return node;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The icons of the panel: strokes on a grid of 24, in the colour of the text.
|
|
238
|
+
*/
|
|
239
|
+
const ICONS = {
|
|
240
|
+
overview: "<rect x=\"3.5\" y=\"3.5\" width=\"7\" height=\"7\" rx=\"1.75\"/><rect x=\"13.5\" y=\"3.5\" width=\"7\" height=\"7\" rx=\"1.75\"/><rect x=\"3.5\" y=\"13.5\" width=\"7\" height=\"7\" rx=\"1.75\"/><rect x=\"13.5\" y=\"13.5\" width=\"7\" height=\"7\" rx=\"1.75\"/>",
|
|
241
|
+
errors: "<path d=\"M10.3 4.6a2 2 0 0 1 3.4 0l7 12.2a2 2 0 0 1-1.7 3H5a2 2 0 0 1-1.7-3z\"/><path d=\"M12 9.5v4\"/><path d=\"M12 16.8v.2\"/>",
|
|
242
|
+
scopes: "<rect x=\"9\" y=\"3\" width=\"6\" height=\"5\" rx=\"1.25\"/><rect x=\"3\" y=\"16\" width=\"6\" height=\"5\" rx=\"1.25\"/><rect x=\"15\" y=\"16\" width=\"6\" height=\"5\" rx=\"1.25\"/><path d=\"M12 8v4M6 16v-2.25A1.75 1.75 0 0 1 7.75 12h8.5A1.75 1.75 0 0 1 18 13.75V16\"/>",
|
|
243
|
+
elements: "<path d=\"M5 4.5 18 10l-5.5 2L10 17.5z\"/><path d=\"m13 13 5.5 5.5\"/>",
|
|
244
|
+
graph: "<circle cx=\"6\" cy=\"12\" r=\"2.5\"/><circle cx=\"18\" cy=\"6\" r=\"2.5\"/><circle cx=\"18\" cy=\"18\" r=\"2.5\"/><path d=\"m8.3 10.8 7.4-3.6M8.3 13.2l7.4 3.6\"/>",
|
|
245
|
+
log: "<path d=\"M9 6h11M9 12h11M9 18h11\"/><path d=\"M4.5 6h.01M4.5 12h.01M4.5 18h.01\" stroke-width=\"2.6\"/>",
|
|
246
|
+
loading: "<path d=\"M4 6h7M8 12h9M13 18h7\"/>",
|
|
247
|
+
state: "<ellipse cx=\"12\" cy=\"6\" rx=\"7.5\" ry=\"2.75\"/><path d=\"M4.5 6v6c0 1.5 3.4 2.75 7.5 2.75s7.5-1.25 7.5-2.75V6\"/><path d=\"M4.5 12v6c0 1.5 3.4 2.75 7.5 2.75s7.5-1.25 7.5-2.75v-6\"/>",
|
|
248
|
+
effects: "<path d=\"M19.5 12a7.5 7.5 0 1 1-2.2-5.3\"/><path d=\"M19.5 4v4h-4\"/>",
|
|
249
|
+
navigation: "<path d=\"M4 7h11M4 7l3.5-3.5M4 7l3.5 3.5\"/><path d=\"M20 17H9M20 17l-3.5-3.5M20 17l-3.5 3.5\"/>",
|
|
250
|
+
server: "<rect x=\"4\" y=\"4\" width=\"16\" height=\"6.5\" rx=\"1.5\"/><rect x=\"4\" y=\"13.5\" width=\"16\" height=\"6.5\" rx=\"1.5\"/><path d=\"M7.5 7.25h.01M7.5 16.75h.01\" stroke-width=\"2.6\"/>",
|
|
251
|
+
timeline: "<circle cx=\"12\" cy=\"13\" r=\"7.5\"/><path d=\"M12 9.5V13l2.5 1.6M10 3h4\"/>",
|
|
252
|
+
blocks: "<path d=\"M12 3.5 3.5 8 12 12.5 20.5 8z\"/><path d=\"M3.5 12 12 16.5 20.5 12M3.5 16 12 20.5 20.5 16\"/>",
|
|
253
|
+
report: "<path d=\"M14 3.5H7a1.5 1.5 0 0 0-1.5 1.5v14A1.5 1.5 0 0 0 7 20.5h10a1.5 1.5 0 0 0 1.5-1.5V8z\"/><path d=\"M14 3.5V8h4.5M9 12.5h6M9 16h6\"/>",
|
|
254
|
+
flash: "<path d=\"M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1\"/><circle cx=\"12\" cy=\"12\" r=\"2.5\"/>",
|
|
255
|
+
pick: "<circle cx=\"12\" cy=\"12\" r=\"7\"/><path d=\"M12 2.5v4M12 17.5v4M2.5 12h4M17.5 12h4\"/><circle cx=\"12\" cy=\"12\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/>",
|
|
256
|
+
close: "<path d=\"m6 9.5 6 6 6-6\"/>",
|
|
257
|
+
trash: "<path d=\"M4.5 7h15M9.5 7V5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v2M6.5 7l.9 12.1a1.5 1.5 0 0 0 1.5 1.4h6.2a1.5 1.5 0 0 0 1.5-1.4L17.5 7\"/>",
|
|
258
|
+
pause: "<path d=\"M9 5.5v13M15 5.5v13\"/>",
|
|
259
|
+
play: "<path d=\"M8 5.5v13l10.5-6.5z\"/>",
|
|
260
|
+
fit: "<path d=\"M4 9V5a1 1 0 0 1 1-1h4M20 9V5a1 1 0 0 0-1-1h-4M4 15v4a1 1 0 0 0 1 1h4M20 15v4a1 1 0 0 1-1 1h-4\"/>",
|
|
261
|
+
plus: "<path d=\"M12 5v14M5 12h14\"/>",
|
|
262
|
+
minus: "<path d=\"M5 12h14\"/>",
|
|
263
|
+
bolt: "<path d=\"M13 3 5 13.5h6L10 21l9-11h-6z\"/>",
|
|
264
|
+
open: "<path d=\"M14 4h6v6M20 4l-8.5 8.5M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10\"/>"
|
|
265
|
+
};
|
|
266
|
+
/** An icon by its name, for a button or a tab. */
|
|
267
|
+
function icon(name, size = 14) {
|
|
268
|
+
const node = svg("svg", {
|
|
269
|
+
class: "icon",
|
|
270
|
+
viewBox: "0 0 24 24",
|
|
271
|
+
width: size,
|
|
272
|
+
height: size,
|
|
273
|
+
fill: "none",
|
|
274
|
+
stroke: "currentColor",
|
|
275
|
+
"stroke-width": 1.8,
|
|
276
|
+
"stroke-linecap": "round",
|
|
277
|
+
"stroke-linejoin": "round",
|
|
278
|
+
"aria-hidden": "true"
|
|
279
|
+
});
|
|
280
|
+
node.innerHTML = ICONS[name];
|
|
281
|
+
return node;
|
|
282
|
+
}
|
|
283
|
+
/** A button with an icon, and its text or, for an icon alone, its label for screen readers. */
|
|
284
|
+
function iconButton(name, text, attributes = {}, iconOnly = false) {
|
|
285
|
+
const button = element("button", {
|
|
286
|
+
class: `tool${iconOnly ? " only" : ""}`,
|
|
287
|
+
...attributes
|
|
288
|
+
}, icon(name));
|
|
289
|
+
if (iconOnly) {
|
|
290
|
+
button.setAttribute("aria-label", text);
|
|
291
|
+
button.title ||= text;
|
|
292
|
+
} else button.append(text);
|
|
293
|
+
return button;
|
|
294
|
+
}
|
|
295
|
+
/** A value that can be edited as text: what JSON can hold. */
|
|
296
|
+
function editable(value) {
|
|
297
|
+
if (value === null || [
|
|
298
|
+
"string",
|
|
299
|
+
"number",
|
|
300
|
+
"boolean"
|
|
301
|
+
].includes(typeof value)) return true;
|
|
302
|
+
if (typeof value !== "object" || value instanceof Element) return false;
|
|
303
|
+
try {
|
|
304
|
+
JSON.stringify(value);
|
|
305
|
+
return true;
|
|
306
|
+
} catch {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/** Reads what a person typed: JSON, or else the text as a string. */
|
|
311
|
+
function parseValue(text) {
|
|
312
|
+
try {
|
|
313
|
+
return JSON.parse(text);
|
|
314
|
+
} catch {
|
|
315
|
+
return text;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/** The type of a value, for the column next to it. */
|
|
319
|
+
function typeOf(value) {
|
|
320
|
+
if (value === null) return "null";
|
|
321
|
+
if (Array.isArray(value)) return "array";
|
|
322
|
+
if (value instanceof Element) return "element";
|
|
323
|
+
if (typeof value === "object") {
|
|
324
|
+
const name = value.constructor?.name;
|
|
325
|
+
return name && name !== "Object" ? name : "object";
|
|
326
|
+
}
|
|
327
|
+
return typeof value;
|
|
328
|
+
}
|
|
329
|
+
/** A write with the name of its slot, once the dev server has said what it is. */
|
|
330
|
+
function describe(entry) {
|
|
331
|
+
const write = entry.write;
|
|
332
|
+
const info = write && known.get(write.component);
|
|
333
|
+
const name = info?.scopes[write.k]?.slots[write.slot];
|
|
334
|
+
return name ? `${info.name} ${name} = ${entry.text.split(" = ").slice(1).join(" = ")}` : entry.text;
|
|
335
|
+
}
|
|
336
|
+
const ms = (time) => `${Math.round(time)} ms`;
|
|
337
|
+
const seconds = (time) => `${(time / 1e3).toFixed(2)} s`;
|
|
338
|
+
const kilobytes = (bytes) => `${(bytes / 1024).toFixed(1)} kB`;
|
|
339
|
+
/** The bytes of the code of a part, as the dev server sent it, from the timing of its request. */
|
|
340
|
+
function bytesOf(info, part) {
|
|
341
|
+
if (!info?.url || typeof performance.getEntriesByType !== "function") return 0;
|
|
342
|
+
const entry = performance.getEntriesByType("resource").find((item) => {
|
|
343
|
+
const url = new URL(item.name, location.href);
|
|
344
|
+
return url.pathname === info.url && url.searchParams.has("brumate-client") && (part === "entry" || part === "all" ? !url.searchParams.has("part") : url.searchParams.get("part") === part);
|
|
345
|
+
});
|
|
346
|
+
return entry ? entry.encodedBodySize || entry.transferSize : 0;
|
|
347
|
+
}
|
|
348
|
+
/** The bytes of the code that loaded. */
|
|
349
|
+
function codeBytes(state) {
|
|
350
|
+
let bytes = 0;
|
|
351
|
+
for (const load of state.loads.values()) bytes += bytesOf(known.get(load.component), load.part);
|
|
352
|
+
return bytes;
|
|
353
|
+
}
|
|
354
|
+
/** The keys and values of an object, a map or a set, or the items of an array, in a row. */
|
|
355
|
+
function entriesOf(value) {
|
|
356
|
+
if (value instanceof Map) return [...value].flat();
|
|
357
|
+
if (value instanceof Set || Array.isArray(value)) return [...value];
|
|
358
|
+
return Object.entries(value).flat();
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* About how many bytes a value takes in the page state. The state is code
|
|
362
|
+
* that seroval writes, which this follows closely enough to compare values.
|
|
363
|
+
*/
|
|
364
|
+
function sizeOf(value, seen = /* @__PURE__ */ new Set()) {
|
|
365
|
+
if (value === null || value === void 0) return 6;
|
|
366
|
+
switch (typeof value) {
|
|
367
|
+
case "string": return value.length + 2;
|
|
368
|
+
case "number":
|
|
369
|
+
case "boolean":
|
|
370
|
+
case "bigint": return String(value).length;
|
|
371
|
+
case "function": return 24;
|
|
372
|
+
case "object": {
|
|
373
|
+
if (seen.has(value)) return 6;
|
|
374
|
+
seen.add(value);
|
|
375
|
+
if (value instanceof Date) return 30;
|
|
376
|
+
const entries = entriesOf(value);
|
|
377
|
+
let bytes = 2;
|
|
378
|
+
for (const entry of entries) bytes += sizeOf(entry, seen) + 1;
|
|
379
|
+
return bytes;
|
|
380
|
+
}
|
|
381
|
+
default: return 8;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/** The bytes of the state records of the page. */
|
|
385
|
+
function stateBytes() {
|
|
386
|
+
let bytes = 0;
|
|
387
|
+
for (const script of document.querySelectorAll("script[b-state]")) bytes += script.textContent?.length ?? 0;
|
|
388
|
+
return bytes;
|
|
389
|
+
}
|
|
390
|
+
/** The value of a name that a scope or one of the scopes around it holds. */
|
|
391
|
+
function valueOf(scope, name) {
|
|
392
|
+
for (let current = scope; current; current = current.p) {
|
|
393
|
+
const slot = (known.get(rootOf(current).m ?? "")?.scopes[current.k]?.slots)?.indexOf(name) ?? -1;
|
|
394
|
+
if (slot !== -1) return preview(current.s[slot]);
|
|
395
|
+
if (current.m !== void 0) break;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/** The colour of the pill of a reason to load. */
|
|
399
|
+
function reasonColor(reason) {
|
|
400
|
+
if (PRELOADS.has(reason)) return "purple";
|
|
401
|
+
return reason === "event" || reason === "block" ? "blue" : "";
|
|
402
|
+
}
|
|
403
|
+
const STATE_COLORS = {
|
|
404
|
+
waiting: "",
|
|
405
|
+
loading: "blue",
|
|
406
|
+
streaming: "blue",
|
|
407
|
+
rendered: "green",
|
|
408
|
+
failed: "red"
|
|
409
|
+
};
|
|
410
|
+
/** The colour of a node in the graph. Other kinds are blue when they hold a value. */
|
|
411
|
+
function nodeColor(kind, slot) {
|
|
412
|
+
if (kind === "memo") return "purple";
|
|
413
|
+
if (kind === "effect") return "green";
|
|
414
|
+
return slot === void 0 ? "" : "blue";
|
|
415
|
+
}
|
|
416
|
+
/** The colour of how long a run took, in milliseconds. */
|
|
417
|
+
function speedColor(total) {
|
|
418
|
+
if (total < 100) return "green";
|
|
419
|
+
return total < 300 ? "yellow" : "red";
|
|
420
|
+
}
|
|
421
|
+
const blockLabel = (block) => block.kind === "$client" ? "$client" : `#${block.kind}`;
|
|
422
|
+
const pill = (text, color = "") => element("span", { class: `pill ${color}` }, text);
|
|
423
|
+
/** A row of cells, as a table row. */
|
|
424
|
+
const row = (cells, tag = "td") => element("tr", {}, ...cells.map((cell) => element(tag, {}, cell)));
|
|
425
|
+
/** A card of a number, with a label above and a note below. */
|
|
426
|
+
const card = (label, value, note) => element("div", { class: "card" }, element("div", { class: "label" }, label), element("div", { class: "value" }, value), element("div", { class: "note" }, note));
|
|
427
|
+
/** A square of colour and its meaning, for a legend. */
|
|
428
|
+
const key = (color, text) => element("span", {}, element("i", { style: `background: ${color}` }), text);
|
|
429
|
+
/** A button that opens a place of a file in the editor, through the dev server. */
|
|
430
|
+
function source(info, at = "1:1") {
|
|
431
|
+
if (!info) return "";
|
|
432
|
+
const label = at === "1:1" ? info.file : `${info.file}:${at}`;
|
|
433
|
+
if (!info.path) return element("span", { class: "mono sub" }, label);
|
|
434
|
+
const open = element("button", {
|
|
435
|
+
class: "link",
|
|
436
|
+
title: "Open in the editor"
|
|
437
|
+
}, label, icon("open", 12));
|
|
438
|
+
open.addEventListener("click", () => {
|
|
439
|
+
fetch(`/__open-in-editor?file=${encodeURIComponent(`${info.path}:${at}`)}`);
|
|
440
|
+
});
|
|
441
|
+
return open;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Places the nodes of a graph in columns, left to right, by the longest
|
|
445
|
+
* path from a value that nothing feeds. Within a column, nodes are ordered
|
|
446
|
+
* by the average place of the nodes they connect to, a few times in each
|
|
447
|
+
* direction, so edges cross less. Each column is as wide as its widest node.
|
|
448
|
+
*/
|
|
449
|
+
function layoutGraph(nodes, edges, widthOf) {
|
|
450
|
+
const depth = nodes.map(() => 0);
|
|
451
|
+
for (let round = 0, changed = true; changed && round < nodes.length; round++) {
|
|
452
|
+
changed = false;
|
|
453
|
+
for (const [from, to] of edges) if (depth[from] + 1 > depth[to]) {
|
|
454
|
+
depth[to] = depth[from] + 1;
|
|
455
|
+
changed = true;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const columns = [];
|
|
459
|
+
nodes.forEach((_, index) => {
|
|
460
|
+
(columns[depth[index]] ??= []).push(index);
|
|
461
|
+
});
|
|
462
|
+
const filled = columns.filter(Boolean);
|
|
463
|
+
const order = /* @__PURE__ */ new Map();
|
|
464
|
+
for (const column of filled) column.forEach((node, index) => order.set(node, index));
|
|
465
|
+
const before = nodes.map(() => []);
|
|
466
|
+
const after = nodes.map(() => []);
|
|
467
|
+
for (const [from, to] of edges) {
|
|
468
|
+
after[from].push(to);
|
|
469
|
+
before[to].push(from);
|
|
470
|
+
}
|
|
471
|
+
const average = (list, fallback) => list.length === 0 ? fallback : list.reduce((sum, node) => sum + order.get(node), 0) / list.length;
|
|
472
|
+
for (let sweep = 0; sweep < 8; sweep++) {
|
|
473
|
+
const forward = sweep % 2 === 0;
|
|
474
|
+
const sequence = forward ? filled.slice(1) : filled.slice(0, -1).toReversed();
|
|
475
|
+
for (const column of sequence) {
|
|
476
|
+
const weight = new Map(column.map((node) => [node, average(forward ? before[node] : after[node], order.get(node))]));
|
|
477
|
+
column.sort((a, b) => weight.get(a) - weight.get(b));
|
|
478
|
+
column.forEach((node, index) => order.set(node, index));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const ROW = 50;
|
|
482
|
+
const GAP = 72;
|
|
483
|
+
const tallest = Math.max(1, ...filled.map((column) => column.length));
|
|
484
|
+
const result = [];
|
|
485
|
+
let x = 16;
|
|
486
|
+
for (const column of filled) {
|
|
487
|
+
const width = Math.max(...column.map(widthOf));
|
|
488
|
+
const top = 16 + (tallest - column.length) * ROW / 2;
|
|
489
|
+
column.forEach((node, index) => {
|
|
490
|
+
result[node] = {
|
|
491
|
+
x,
|
|
492
|
+
y: top + index * ROW,
|
|
493
|
+
width
|
|
494
|
+
};
|
|
495
|
+
});
|
|
496
|
+
x += width + GAP;
|
|
497
|
+
}
|
|
498
|
+
return result;
|
|
499
|
+
}
|
|
500
|
+
/** The scopes of a component instance, without the components inside it. */
|
|
501
|
+
function countScopes(scope) {
|
|
502
|
+
let count = 1;
|
|
503
|
+
for (const child of scope.children) if (child.m === void 0) count += countScopes(child);
|
|
504
|
+
return count;
|
|
505
|
+
}
|
|
506
|
+
/** A label cut to the width of a node of the graph. */
|
|
507
|
+
const clip = (text) => text.length > 34 ? `${text.slice(0, 33)}…` : text;
|
|
508
|
+
/** The text of an entry of the log. */
|
|
509
|
+
const textOf = (entry) => entry.kind === "write" ? describe(entry) : entry.text;
|
|
510
|
+
/** The class of the bar of a load: its reason, and whether it was used or failed. */
|
|
511
|
+
function barClass(load) {
|
|
512
|
+
if (load.failed) return "failed";
|
|
513
|
+
if (PRELOADS.has(load.reason)) return load.used ? "preload" : "unused";
|
|
514
|
+
return load.reason === "event" || load.reason === "block" ? "" : "other";
|
|
515
|
+
}
|
|
516
|
+
/** The places of a stack, with their files as the dev server can read them. */
|
|
517
|
+
function framesOf(stack) {
|
|
518
|
+
const frames = [];
|
|
519
|
+
for (const line of (stack ?? "").split("\n")) {
|
|
520
|
+
const match = /^\s*at (?:(.*?) \()?(.+?):(\d+):(\d+)\)?\s*$/.exec(line);
|
|
521
|
+
if (!match) continue;
|
|
522
|
+
let file = match[2];
|
|
523
|
+
let compiled = false;
|
|
524
|
+
if (/^[a-z-]+-extension:/.test(file) || file.startsWith("<")) continue;
|
|
525
|
+
if (/^https?:/.test(file)) {
|
|
526
|
+
const url = new URL(file);
|
|
527
|
+
if (url.origin !== location.origin) continue;
|
|
528
|
+
compiled = true;
|
|
529
|
+
file = url.pathname.startsWith("/@fs/") ? url.pathname.slice(4) : url.pathname;
|
|
530
|
+
} else if (file.startsWith("file://")) file = decodeURIComponent(new URL(file).pathname);
|
|
531
|
+
frames.push({
|
|
532
|
+
fn: match[1] ?? "(anonymous)",
|
|
533
|
+
file,
|
|
534
|
+
line: Number(match[3]),
|
|
535
|
+
column: Number(match[4]),
|
|
536
|
+
library: file.startsWith("node:") || file.includes("/node_modules/") || /\/brumate\/(?:src|dist)\/runtime\//.test(file) || file.includes("/@vite/"),
|
|
537
|
+
compiled
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return frames;
|
|
541
|
+
}
|
|
542
|
+
/** The places in the sources of frames that the browser ran, by their compiled place. */
|
|
543
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
544
|
+
/**
|
|
545
|
+
* Maps the frames that the browser ran to their sources, by the source maps
|
|
546
|
+
* of the dev server, so a frame of a component or a module function names
|
|
547
|
+
* its own file and line. A frame that the dev server cannot map stays as it is.
|
|
548
|
+
*/
|
|
549
|
+
function mapFrames(frames, urls) {
|
|
550
|
+
return Promise.all(frames.map((frame, index) => {
|
|
551
|
+
const url = urls[index];
|
|
552
|
+
if (!frame.compiled || frame.library || !url) return frame;
|
|
553
|
+
const unmapped = {
|
|
554
|
+
...frame,
|
|
555
|
+
url
|
|
556
|
+
};
|
|
557
|
+
const key = `${url}:${frame.line}:${frame.column}`;
|
|
558
|
+
let result = mapped.get(key);
|
|
559
|
+
if (!result) {
|
|
560
|
+
const query = new URLSearchParams({
|
|
561
|
+
url,
|
|
562
|
+
line: String(frame.line),
|
|
563
|
+
column: String(frame.column)
|
|
564
|
+
});
|
|
565
|
+
result = fetch(`/__brumate/position?${query}`).then((response) => response.ok ? response.json() : null).then((place) => place ? {
|
|
566
|
+
...frame,
|
|
567
|
+
...place,
|
|
568
|
+
compiled: false
|
|
569
|
+
} : unmapped).catch(() => unmapped);
|
|
570
|
+
mapped.set(key, result);
|
|
571
|
+
}
|
|
572
|
+
return result;
|
|
573
|
+
}));
|
|
574
|
+
}
|
|
575
|
+
/** The URLs that the frames of a stack name, as the dev server knows the modules. */
|
|
576
|
+
function frameUrls(stack) {
|
|
577
|
+
const urls = [];
|
|
578
|
+
for (const line of (stack ?? "").split("\n")) {
|
|
579
|
+
const file = /^\s*at (?:(.*?) \()?(.+?):(\d+):(\d+)\)?\s*$/.exec(line)?.[2];
|
|
580
|
+
if (!file || /^[a-z-]+-extension:/.test(file) || file.startsWith("<")) continue;
|
|
581
|
+
if (/^https?:/.test(file)) {
|
|
582
|
+
const url = new URL(file);
|
|
583
|
+
urls.push(url.origin === location.origin ? url.pathname + url.search : "");
|
|
584
|
+
if (url.origin !== location.origin) urls.pop();
|
|
585
|
+
} else urls.push("");
|
|
586
|
+
}
|
|
587
|
+
return urls;
|
|
588
|
+
}
|
|
589
|
+
/** The highlighter, which loads with the first code that the Errors tab shows. */
|
|
590
|
+
let highlighter;
|
|
591
|
+
/** The sources of files, by path. */
|
|
592
|
+
const sources = /* @__PURE__ */ new Map();
|
|
593
|
+
/** The code of a module as the dev server sent it to the browser. */
|
|
594
|
+
function compiledOf(url) {
|
|
595
|
+
let text = sources.get(url);
|
|
596
|
+
if (!text) {
|
|
597
|
+
text = fetch(url).then((response) => response.ok ? response.text() : void 0).catch(() => void 0);
|
|
598
|
+
sources.set(url, text);
|
|
599
|
+
}
|
|
600
|
+
return text;
|
|
601
|
+
}
|
|
602
|
+
function sourceOf(file) {
|
|
603
|
+
let text = sources.get(file);
|
|
604
|
+
if (!text) {
|
|
605
|
+
text = fetch(`/__brumate/source?file=${encodeURIComponent(file)}`).then((response) => response.ok ? response.text() : void 0).catch(() => void 0);
|
|
606
|
+
sources.set(file, text);
|
|
607
|
+
}
|
|
608
|
+
return text;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The lines around a place of a file, highlighted by twinkleplop, with the
|
|
612
|
+
* line of the place and the word at its column marked. Without the source,
|
|
613
|
+
* the frame of the error is shown as it is.
|
|
614
|
+
*/
|
|
615
|
+
async function codeView(place, fallback) {
|
|
616
|
+
const box = element("div", { class: "code" });
|
|
617
|
+
const [text, module] = await Promise.all([place.url ? compiledOf(place.url) : sourceOf(place.file), highlighter ??= import("./highlight.js")]);
|
|
618
|
+
if (text === void 0) {
|
|
619
|
+
box.append(element("pre", { class: "plain" }, fallback ?? "The dev server cannot read this file."));
|
|
620
|
+
return box;
|
|
621
|
+
}
|
|
622
|
+
const lines = text.split("\n");
|
|
623
|
+
const start = Math.max(1, place.line - 6);
|
|
624
|
+
const end = Math.min(lines.length, place.line + 6);
|
|
625
|
+
const target = place.line;
|
|
626
|
+
const word = /^[\w$.]*/.exec(lines[place.line - 1]?.slice(place.column - 1) ?? "")?.[0] ?? "";
|
|
627
|
+
box.append(element("style", {}, module.themeCSS("dark")));
|
|
628
|
+
box.insertAdjacentHTML("beforeend", module.highlightFile(place.url ? "compiled.ts" : place.file, text, {
|
|
629
|
+
line_numbers: { start: 1 },
|
|
630
|
+
line: (index) => index === target ? { class: "error-line" } : void 0,
|
|
631
|
+
overlays: word.length > 0 ? [{
|
|
632
|
+
start: {
|
|
633
|
+
line: target,
|
|
634
|
+
character: place.column - 1
|
|
635
|
+
},
|
|
636
|
+
end: {
|
|
637
|
+
line: target,
|
|
638
|
+
character: place.column - 1 + word.length
|
|
639
|
+
},
|
|
640
|
+
class: "error-mark"
|
|
641
|
+
}] : []
|
|
642
|
+
}));
|
|
643
|
+
[...box.querySelectorAll("code > .l")].forEach((line, index) => {
|
|
644
|
+
if (index + 1 < start || index + 1 > end) {
|
|
645
|
+
if (line.nextSibling?.nodeType === Node.TEXT_NODE) line.nextSibling.remove();
|
|
646
|
+
line.remove();
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
return box;
|
|
650
|
+
}
|
|
651
|
+
/** The name of a handler, such as `Index h16`, once the dev server said the component. */
|
|
652
|
+
const handlerName = (ref) => {
|
|
653
|
+
const [component, name = ""] = ref.split("#");
|
|
654
|
+
return `${known.get(component)?.name ?? component} ${name}`;
|
|
655
|
+
};
|
|
656
|
+
/** A round step for the ticks of a ruler: 1, 2 or 5 times a power of ten, at least `rough`. */
|
|
657
|
+
function tickStep(rough) {
|
|
658
|
+
const power = 10 ** Math.floor(Math.log10(rough));
|
|
659
|
+
for (const factor of [
|
|
660
|
+
1,
|
|
661
|
+
2,
|
|
662
|
+
5
|
|
663
|
+
]) if (factor * power >= rough) return factor * power;
|
|
664
|
+
return 10 * power;
|
|
665
|
+
}
|
|
666
|
+
let panel;
|
|
667
|
+
/** Switches the tab of the open panel. */
|
|
668
|
+
let showTab;
|
|
669
|
+
/** Stops picking, with its outline and card, when the panel closes. */
|
|
670
|
+
let endPick;
|
|
671
|
+
/** Opens the panel on a tab, or switches to it when the panel is open. */
|
|
672
|
+
function openPanel(root, state, tab) {
|
|
673
|
+
if (panel) showTab?.(tab);
|
|
674
|
+
else togglePanel(root, state, tab);
|
|
675
|
+
}
|
|
676
|
+
/** Opens the panel, or closes it when it is open. */
|
|
677
|
+
function togglePanel(root, state, initial = "overview") {
|
|
678
|
+
const opener = root.querySelector("button.open");
|
|
679
|
+
if (panel) {
|
|
680
|
+
endPick?.();
|
|
681
|
+
endPick = void 0;
|
|
682
|
+
panel.remove();
|
|
683
|
+
panel = void 0;
|
|
684
|
+
state.changed = void 0;
|
|
685
|
+
document.documentElement.style.removeProperty("padding-bottom");
|
|
686
|
+
if (opener) opener.hidden = false;
|
|
687
|
+
state.resize = void 0;
|
|
688
|
+
state.resized = void 0;
|
|
689
|
+
showTab = void 0;
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
let tab = initial;
|
|
693
|
+
let selectedError;
|
|
694
|
+
let selectedFrame = -1;
|
|
695
|
+
let selected;
|
|
696
|
+
let selectedScope;
|
|
697
|
+
let editing;
|
|
698
|
+
let paused = false;
|
|
699
|
+
let filter = "";
|
|
700
|
+
let logSearch = "";
|
|
701
|
+
const shown = new Set(KINDS);
|
|
702
|
+
let frozen;
|
|
703
|
+
let picked;
|
|
704
|
+
let graphNode;
|
|
705
|
+
let view = {
|
|
706
|
+
x: 0,
|
|
707
|
+
y: 0,
|
|
708
|
+
scale: 1,
|
|
709
|
+
fitted: ""
|
|
710
|
+
};
|
|
711
|
+
let height = 340;
|
|
712
|
+
try {
|
|
713
|
+
height = Number(localStorage.getItem(HEIGHT_KEY)) || height;
|
|
714
|
+
} catch {}
|
|
715
|
+
const errorPage = document.getElementById("brumate-error") !== null;
|
|
716
|
+
if (errorPage) height = window.innerHeight;
|
|
717
|
+
const body = element("div", { class: "body" });
|
|
718
|
+
const nav = element("div", {
|
|
719
|
+
class: "nav",
|
|
720
|
+
role: "tablist",
|
|
721
|
+
"aria-orientation": "vertical"
|
|
722
|
+
});
|
|
723
|
+
const badges = /* @__PURE__ */ new Map();
|
|
724
|
+
for (const [name, label] of TABS) {
|
|
725
|
+
const badge = element("span", { class: "badge" });
|
|
726
|
+
const button = element("button", {
|
|
727
|
+
class: "tab",
|
|
728
|
+
role: "tab",
|
|
729
|
+
"data-tab": name
|
|
730
|
+
}, icon(name === "scopes" ? "scopes" : name, 15), element("span", { class: "label" }, label), badge);
|
|
731
|
+
badges.set(name, badge);
|
|
732
|
+
button.addEventListener("click", () => {
|
|
733
|
+
tab = name;
|
|
734
|
+
draw();
|
|
735
|
+
});
|
|
736
|
+
nav.append(button);
|
|
737
|
+
}
|
|
738
|
+
const routeText = element("span", {
|
|
739
|
+
class: "route",
|
|
740
|
+
title: "The page"
|
|
741
|
+
});
|
|
742
|
+
const stats = element("span", { class: "stats" });
|
|
743
|
+
const pick = iconButton("pick", "Pick", {
|
|
744
|
+
"aria-pressed": "false",
|
|
745
|
+
title: "Click an element of the page to see its scope, handlers and code"
|
|
746
|
+
});
|
|
747
|
+
const flash = iconButton("flash", "Updates", {
|
|
748
|
+
"aria-pressed": String(state.flash),
|
|
749
|
+
title: "Outline the elements that change: green now and then, red often"
|
|
750
|
+
});
|
|
751
|
+
flash.addEventListener("click", () => {
|
|
752
|
+
state.setFlash?.(!state.flash);
|
|
753
|
+
flash.setAttribute("aria-pressed", String(state.flash));
|
|
754
|
+
});
|
|
755
|
+
const close = iconButton("close", "Close the devtools (Alt+Shift+D)", {}, true);
|
|
756
|
+
close.addEventListener("click", () => togglePanel(root, state));
|
|
757
|
+
const versions = [element("span", {
|
|
758
|
+
class: "chip accent",
|
|
759
|
+
title: "The version of brumate"
|
|
760
|
+
}, `v${state.meta.version ?? "?"}`)];
|
|
761
|
+
if (state.meta.vite) versions.push(element("span", {
|
|
762
|
+
class: "chip",
|
|
763
|
+
title: "The version of Vite"
|
|
764
|
+
}, `Vite ${state.meta.vite}`));
|
|
765
|
+
const logo = element("i");
|
|
766
|
+
logo.innerHTML = LOGO;
|
|
767
|
+
const resize = element("div", {
|
|
768
|
+
class: "resize",
|
|
769
|
+
title: "Drag to resize"
|
|
770
|
+
});
|
|
771
|
+
panel = element("div", {
|
|
772
|
+
class: "panel",
|
|
773
|
+
role: "region",
|
|
774
|
+
"aria-label": "brumate devtools"
|
|
775
|
+
}, element("style", {}, STYLE), resize, element("div", { class: "top" }, element("span", { class: "brand" }, logo, "brumate"), ...versions, routeText, stats, element("span", { class: "spacer" }), flash, pick, close), element("div", { class: "main" }, nav, body));
|
|
776
|
+
const applyHeight = () => {
|
|
777
|
+
panel.style.height = `${height}px`;
|
|
778
|
+
if (errorPage) panel.style.maxHeight = "none";
|
|
779
|
+
document.documentElement.style.paddingBottom = `${height}px`;
|
|
780
|
+
};
|
|
781
|
+
applyHeight();
|
|
782
|
+
root.append(panel);
|
|
783
|
+
if (opener) opener.hidden = true;
|
|
784
|
+
state.resize = (clientY) => {
|
|
785
|
+
height = Math.min(Math.max(window.innerHeight - clientY, 160), window.innerHeight * .9);
|
|
786
|
+
applyHeight();
|
|
787
|
+
};
|
|
788
|
+
state.resized = () => {
|
|
789
|
+
try {
|
|
790
|
+
localStorage.setItem(HEIGHT_KEY, String(Math.round(height)));
|
|
791
|
+
} catch {}
|
|
792
|
+
draw();
|
|
793
|
+
};
|
|
794
|
+
resize.addEventListener("pointerdown", (event) => {
|
|
795
|
+
event.preventDefault();
|
|
796
|
+
const move = (next) => state.resize?.(next.clientY);
|
|
797
|
+
const up = () => {
|
|
798
|
+
window.removeEventListener("pointermove", move);
|
|
799
|
+
window.removeEventListener("pointerup", up);
|
|
800
|
+
state.resized?.();
|
|
801
|
+
};
|
|
802
|
+
window.addEventListener("pointermove", move);
|
|
803
|
+
window.addEventListener("pointerup", up);
|
|
804
|
+
});
|
|
805
|
+
if (!state.scopes) document.dispatchEvent(new Event("brumate:core"));
|
|
806
|
+
const outlines = [];
|
|
807
|
+
const outline = (scope) => {
|
|
808
|
+
for (const box of outlines.splice(0)) box.remove();
|
|
809
|
+
if (scope === void 0) return;
|
|
810
|
+
for (const target of document.querySelectorAll(`[b-b^="${scope}:"]`)) {
|
|
811
|
+
const rect = target.getBoundingClientRect();
|
|
812
|
+
const box = element("div", {
|
|
813
|
+
class: "outline",
|
|
814
|
+
style: `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`
|
|
815
|
+
});
|
|
816
|
+
root.append(box);
|
|
817
|
+
outlines.push(box);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
const onPick = (event) => {
|
|
821
|
+
const clicked = event.target;
|
|
822
|
+
if (!clicked?.closest || event.composedPath().includes(panel)) return;
|
|
823
|
+
event.preventDefault();
|
|
824
|
+
event.stopImmediatePropagation();
|
|
825
|
+
stopPicking();
|
|
826
|
+
picked = clicked;
|
|
827
|
+
const id = clicked.closest("[b-b]")?.getAttribute("b-b").split(":")[0];
|
|
828
|
+
if (id !== void 0) {
|
|
829
|
+
selectedScope = /^-?\d+$/.test(id) ? Number(id) : id;
|
|
830
|
+
const scope = state.scopes?.get(selectedScope);
|
|
831
|
+
selected = scope ? rootOf(scope).m : selected;
|
|
832
|
+
}
|
|
833
|
+
tab = "elements";
|
|
834
|
+
draw();
|
|
835
|
+
};
|
|
836
|
+
const inspectCard = element("div", {
|
|
837
|
+
class: "inspect-card",
|
|
838
|
+
role: "tooltip"
|
|
839
|
+
});
|
|
840
|
+
const hoverBox = element("div", { class: "outline" });
|
|
841
|
+
let hovered;
|
|
842
|
+
let hoverToken = 0;
|
|
843
|
+
const onHover = (event) => {
|
|
844
|
+
const target = event.target;
|
|
845
|
+
if (!target?.closest || event.composedPath().includes(panel) || target === hovered) return;
|
|
846
|
+
hovered = target;
|
|
847
|
+
inspect(target);
|
|
848
|
+
};
|
|
849
|
+
const inspect = async (target) => {
|
|
850
|
+
const token = ++hoverToken;
|
|
851
|
+
const rect = target.getBoundingClientRect();
|
|
852
|
+
hoverBox.style.cssText = `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`;
|
|
853
|
+
root.append(hoverBox, inspectCard);
|
|
854
|
+
const rows = [element("div", { class: "card-head" }, element("span", { class: "mono" }, `${target.tagName.toLowerCase()}${[...target.classList].slice(0, 2).map((name) => `.${name}`).join("")}`), element("span", { class: "sub" }, `${Math.round(rect.width)} × ${Math.round(rect.height)}`))];
|
|
855
|
+
const anchored = target.closest("[b-b]");
|
|
856
|
+
const [id = "", anchorText = "0"] = anchored?.getAttribute("b-b").split(":") ?? [];
|
|
857
|
+
const scope = anchored ? scopeOf(id) : void 0;
|
|
858
|
+
if (scope) {
|
|
859
|
+
const { info, component: owner, place } = await anchorOf(scope, Number(anchorText));
|
|
860
|
+
if (token !== hoverToken) return;
|
|
861
|
+
rows.push(element("div", { class: "card-component" }, element("strong", {}, info?.name ?? owner.m ?? "component"), element("span", { class: "mono sub" }, place?.at ? `${info?.file}:${place.at}` : info?.file ?? "")), element("div", { class: "sub" }, `scope ${scope.id} · ${info?.scopes[scope.k]?.label ?? "scope"}${anchored === target ? "" : ` · in ${place?.label ?? "an element"}`}`));
|
|
862
|
+
const handled = target.closest("[b-on]");
|
|
863
|
+
if (handled && anchored.contains(handled)) {
|
|
864
|
+
const handlers = element("div", { class: "card-pills" });
|
|
865
|
+
for (const raw of (handled.getAttribute("b-on") ?? "").split(/\s+/).filter(Boolean)) {
|
|
866
|
+
const [head, ref = ""] = raw.split("=");
|
|
867
|
+
const [handlerComponent, name = ""] = ref.split("@")[0].split("#");
|
|
868
|
+
const part = /^[hct]\d/.test(name) ? name : "update";
|
|
869
|
+
const load = state.loads.get(`${handlerComponent}:${part}`) ?? state.loads.get(`${handlerComponent}:all`);
|
|
870
|
+
handlers.append(pill(`${head} · ${load?.end === void 0 ? "not loaded" : "loaded"}`, load?.end === void 0 ? "" : "green"));
|
|
871
|
+
}
|
|
872
|
+
rows.push(handlers);
|
|
873
|
+
}
|
|
874
|
+
if (place && place.reads.length > 0) rows.push(element("div", { class: "card-pills" }, ...drawReads(scope, place.reads.slice(0, 4))));
|
|
875
|
+
} else rows.push(element("div", { class: "sub" }, "Nothing in the browser updates this element."));
|
|
876
|
+
rows.push(element("div", { class: "card-hint" }, "Click to see it in Elements · Esc to stop"));
|
|
877
|
+
inspectCard.replaceChildren(...rows);
|
|
878
|
+
const cardHeight = inspectCard.offsetHeight;
|
|
879
|
+
const top = rect.bottom + 8 + cardHeight < window.innerHeight ? rect.bottom + 8 : Math.max(8, rect.top - 8 - cardHeight);
|
|
880
|
+
const left = Math.min(Math.max(8, rect.left), window.innerWidth - inspectCard.offsetWidth - 8);
|
|
881
|
+
inspectCard.style.cssText = `top:${top}px;left:${left}px`;
|
|
882
|
+
};
|
|
883
|
+
const onEscape = (event) => {
|
|
884
|
+
if (event.key === "Escape") stopPicking();
|
|
885
|
+
};
|
|
886
|
+
endPick = () => stopPicking();
|
|
887
|
+
const stopPicking = () => {
|
|
888
|
+
pick.setAttribute("aria-pressed", "false");
|
|
889
|
+
window.removeEventListener("click", onPick, true);
|
|
890
|
+
window.removeEventListener("pointermove", onHover, true);
|
|
891
|
+
window.removeEventListener("keydown", onEscape, true);
|
|
892
|
+
document.documentElement.style.cursor = "";
|
|
893
|
+
hovered = void 0;
|
|
894
|
+
hoverToken++;
|
|
895
|
+
hoverBox.remove();
|
|
896
|
+
inspectCard.remove();
|
|
897
|
+
};
|
|
898
|
+
pick.addEventListener("click", () => {
|
|
899
|
+
if (pick.getAttribute("aria-pressed") === "true") {
|
|
900
|
+
stopPicking();
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
pick.setAttribute("aria-pressed", "true");
|
|
904
|
+
document.documentElement.style.cursor = "crosshair";
|
|
905
|
+
window.addEventListener("click", onPick, true);
|
|
906
|
+
window.addEventListener("pointermove", onHover, true);
|
|
907
|
+
window.addEventListener("keydown", onEscape, true);
|
|
908
|
+
});
|
|
909
|
+
const roots = () => [...state.scopes?.values() ?? []].filter((scope) => scope.m !== void 0);
|
|
910
|
+
const scopeOf = (id) => state.scopes?.get(/^-?\d+$/.test(id) ? Number(id) : id);
|
|
911
|
+
/** The header and the counts of the tabs. */
|
|
912
|
+
const drawChrome = () => {
|
|
913
|
+
for (const button of nav.querySelectorAll(".tab")) button.setAttribute("aria-selected", String(button.dataset.tab === tab));
|
|
914
|
+
const list = roots();
|
|
915
|
+
const loads = [...state.loads.values()];
|
|
916
|
+
const code = codeBytes(state);
|
|
917
|
+
routeText.textContent = location.pathname + location.search;
|
|
918
|
+
stats.textContent = [
|
|
919
|
+
`${new Set(list.map((scope) => scope.m)).size} components`,
|
|
920
|
+
`${state.scopes?.size ?? 0} scopes`,
|
|
921
|
+
`${loads.length} parts${code ? ` (${kilobytes(code)})` : ""}`,
|
|
922
|
+
`state ${kilobytes(stateBytes())}`
|
|
923
|
+
].join(" · ");
|
|
924
|
+
const unused = loads.filter((load) => PRELOADS.has(load.reason) && !load.used).length;
|
|
925
|
+
const waiting = [...state.blocks.values()].filter((block) => block.state === "waiting").length;
|
|
926
|
+
const counts = {
|
|
927
|
+
errors: [state.errors.length, "Errors"],
|
|
928
|
+
scopes: [new Set(list.map((scope) => scope.m)).size],
|
|
929
|
+
log: [state.log.length],
|
|
930
|
+
loading: unused > 0 ? [unused, "Preloads that nothing used"] : [loads.length],
|
|
931
|
+
blocks: waiting > 0 ? [waiting, "Blocks that wait for their trigger"] : [state.blocks.size]
|
|
932
|
+
};
|
|
933
|
+
for (const [name, badge] of badges) {
|
|
934
|
+
const [count = 0, warning] = counts[name] ?? [];
|
|
935
|
+
badge.textContent = count > 0 ? String(count) : "";
|
|
936
|
+
let kind = warning ? " warn" : "";
|
|
937
|
+
if (name === "errors") kind = " error";
|
|
938
|
+
badge.className = `badge${kind}`;
|
|
939
|
+
badge.title = warning ?? "";
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
/** A select of the components on the page, for Graph and Report. */
|
|
943
|
+
const chooser = (current) => {
|
|
944
|
+
const select = element("select", { "aria-label": "Component" });
|
|
945
|
+
for (const id of new Set(roots().map((scope) => scope.m))) {
|
|
946
|
+
const info = known.get(id);
|
|
947
|
+
const option = element("option", { value: id }, info ? `${info.name} · ${info.file}` : id);
|
|
948
|
+
option.selected = id === current;
|
|
949
|
+
select.append(option);
|
|
950
|
+
}
|
|
951
|
+
select.addEventListener("change", () => {
|
|
952
|
+
selected = select.value;
|
|
953
|
+
graphNode = void 0;
|
|
954
|
+
draw();
|
|
955
|
+
});
|
|
956
|
+
return select;
|
|
957
|
+
};
|
|
958
|
+
const drawErrors = async () => {
|
|
959
|
+
if (state.errors.length === 0) {
|
|
960
|
+
body.replaceChildren(element("h2", {}, "Errors"), element("p", { class: "sub" }, "No errors. Errors of a render on the server, of Vite, such as a compile error after an edit, and of code in the browser show here."));
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
if (!selectedError || !state.errors.includes(selectedError)) {
|
|
964
|
+
selectedError = state.errors.at(-1);
|
|
965
|
+
selectedFrame = -1;
|
|
966
|
+
}
|
|
967
|
+
const error = selectedError;
|
|
968
|
+
const list = element("div", { class: "list" });
|
|
969
|
+
for (const entry of state.errors.toReversed()) {
|
|
970
|
+
const button = element("button", {
|
|
971
|
+
class: "error-row",
|
|
972
|
+
"aria-current": String(entry === error)
|
|
973
|
+
}, element("span", { class: "text" }, entry.message.split("\n")[0]), element("span", { class: "when" }, `${entry.source} · ${seconds(entry.time)}`));
|
|
974
|
+
button.addEventListener("click", () => {
|
|
975
|
+
selectedError = entry;
|
|
976
|
+
selectedFrame = -1;
|
|
977
|
+
draw();
|
|
978
|
+
});
|
|
979
|
+
list.append(button);
|
|
980
|
+
}
|
|
981
|
+
const clear = iconButton("trash", "Clear");
|
|
982
|
+
clear.addEventListener("click", () => {
|
|
983
|
+
state.errors.length = 0;
|
|
984
|
+
state.errorCount?.();
|
|
985
|
+
draw();
|
|
986
|
+
});
|
|
987
|
+
list.append(element("div", { style: "margin-top: 8px" }, clear));
|
|
988
|
+
const frames = await mapFrames(framesOf(error.stack), frameUrls(error.stack));
|
|
989
|
+
if (selectedFrame === -1) selectedFrame = error.loc ? -2 : frames.findIndex((frame) => !frame.library && !frame.compiled);
|
|
990
|
+
const frame = selectedFrame >= 0 ? frames[selectedFrame] : void 0;
|
|
991
|
+
const place = selectedFrame === -2 ? error.loc : frame;
|
|
992
|
+
const detail = element("div", { class: "detail" });
|
|
993
|
+
detail.append(element("pre", { class: "error-message" }, error.message), element("div", { class: "toolbar" }, pill(error.source, error.source === "browser" ? "yellow" : "red"), error.plugin ? pill(`plugin ${error.plugin}`) : "", place && !("url" in place && place.url) ? open(place) : ""));
|
|
994
|
+
if (place) detail.append(await codeView(place, error.frame));
|
|
995
|
+
else if (error.frame) detail.append(element("div", { class: "code" }, element("pre", { class: "plain" }, error.frame)));
|
|
996
|
+
if (frames.length > 0) {
|
|
997
|
+
const stack = element("div", { class: "frames" });
|
|
998
|
+
frames.forEach((item, index) => {
|
|
999
|
+
const button = element("button", {
|
|
1000
|
+
class: `frame${item.library ? " library" : ""}`,
|
|
1001
|
+
"aria-current": String(index === selectedFrame),
|
|
1002
|
+
title: item.compiled ? "The lines of code that the browser ran" : "Show this code"
|
|
1003
|
+
}, element("span", { class: "fn" }, item.fn), element("span", { class: "where" }, `${item.file}:${item.line}:${item.column}`));
|
|
1004
|
+
button.addEventListener("click", () => {
|
|
1005
|
+
selectedFrame = index;
|
|
1006
|
+
draw();
|
|
1007
|
+
});
|
|
1008
|
+
stack.append(button);
|
|
1009
|
+
});
|
|
1010
|
+
detail.append(element("h3", {}, "Stack"), stack);
|
|
1011
|
+
}
|
|
1012
|
+
body.replaceChildren(element("div", { class: "split" }, list, detail));
|
|
1013
|
+
};
|
|
1014
|
+
/** A button that opens a place of a file in the editor. */
|
|
1015
|
+
const open = (place) => {
|
|
1016
|
+
const button = element("button", {
|
|
1017
|
+
class: "link",
|
|
1018
|
+
title: "Open in the editor"
|
|
1019
|
+
}, `${place.file.replace(/^.*\/(src|test|routes)\//, "$1/")}:${place.line}:${place.column}`, icon("open", 12));
|
|
1020
|
+
button.addEventListener("click", () => {
|
|
1021
|
+
fetch(`/__open-in-editor?file=${encodeURIComponent(`${place.file}:${place.line}:${place.column}`)}`);
|
|
1022
|
+
});
|
|
1023
|
+
return button;
|
|
1024
|
+
};
|
|
1025
|
+
const drawOverview = async () => {
|
|
1026
|
+
const list = roots();
|
|
1027
|
+
const ids = [...new Set(list.map((scope) => scope.m))];
|
|
1028
|
+
const infos = await Promise.all(ids.map((id) => componentInfo(state, id)));
|
|
1029
|
+
const loads = [...state.loads.values()];
|
|
1030
|
+
const code = codeBytes(state);
|
|
1031
|
+
const unused = loads.filter((load) => PRELOADS.has(load.reason) && !load.used).length;
|
|
1032
|
+
const blocks = [...state.blocks.values()];
|
|
1033
|
+
const handlers = state.log.filter((entry) => entry.kind === "handler").length;
|
|
1034
|
+
const calls = state.log.filter((entry) => entry.kind === "call").length;
|
|
1035
|
+
const table = element("table", { class: "rows" }, row([
|
|
1036
|
+
"component",
|
|
1037
|
+
"file",
|
|
1038
|
+
"instances",
|
|
1039
|
+
"scopes",
|
|
1040
|
+
"parts loaded"
|
|
1041
|
+
], "th"));
|
|
1042
|
+
ids.forEach((id, index) => {
|
|
1043
|
+
const info = infos[index];
|
|
1044
|
+
const instances = list.filter((scope) => scope.m === id);
|
|
1045
|
+
const name = element("button", {
|
|
1046
|
+
class: "link",
|
|
1047
|
+
title: "Show its scopes"
|
|
1048
|
+
}, info?.name ?? id);
|
|
1049
|
+
name.addEventListener("click", () => {
|
|
1050
|
+
selected = id;
|
|
1051
|
+
selectedScope = instances[0]?.id;
|
|
1052
|
+
tab = "scopes";
|
|
1053
|
+
draw();
|
|
1054
|
+
});
|
|
1055
|
+
const parts = loads.filter((load) => load.component === id).map((load) => load.part);
|
|
1056
|
+
table.append(row([
|
|
1057
|
+
name,
|
|
1058
|
+
source(info),
|
|
1059
|
+
String(instances.length),
|
|
1060
|
+
String(instances.reduce((sum, scope) => sum + countScopes(scope), 0)),
|
|
1061
|
+
element("span", { class: "mono" }, parts.join(", ") || "—")
|
|
1062
|
+
]));
|
|
1063
|
+
});
|
|
1064
|
+
body.replaceChildren(element("div", {
|
|
1065
|
+
class: "kv",
|
|
1066
|
+
style: "margin-bottom: 12px"
|
|
1067
|
+
}, element("span", {}, "Page"), element("span", { class: "mono" }, location.href), element("span", {}, "brumate"), element("span", { class: "mono" }, state.meta.version ?? "unknown"), element("span", {}, "Vite"), element("span", { class: "mono" }, state.meta.vite ?? "unknown"), element("span", {}, "Open for"), element("span", { class: "mono" }, seconds(performance.now()))), element("div", { class: "cards" }, card("Components", String(ids.length), `${state.scopes?.size ?? 0} scopes in the browser`), card("Client code", code ? kilobytes(code) : String(loads.length), `${loads.length} parts loaded${unused ? `, ${unused} preloads unused` : ""}`), card("Page state", kilobytes(stateBytes()), "state records from the server"), card("Blocks", String(blocks.length), `${blocks.filter((block) => block.state === "waiting").length} waiting, ${blocks.filter((block) => block.state === "rendered").length} rendered`), card("Handlers run", String(handlers), `${calls} server function calls`)), element("h3", {}, "Components on the page"), ids.length > 0 ? table : element("div", { class: "empty" }, "No components with client state yet."));
|
|
1068
|
+
};
|
|
1069
|
+
/** A slot with its name, type and value. A value that JSON can hold can be edited. */
|
|
1070
|
+
const drawSlot = (scope, slot, name) => {
|
|
1071
|
+
const value = scope.s[slot];
|
|
1072
|
+
const cell = element("td");
|
|
1073
|
+
const line = element("tr", { class: "slot" }, element("td", { class: "name" }, name), element("td", { class: "type" }, typeOf(value)), cell);
|
|
1074
|
+
if (editing?.scope === scope.id && editing.slot === slot) {
|
|
1075
|
+
const input = element("input", { "aria-label": `New value of ${name}` });
|
|
1076
|
+
input.value = JSON.stringify(value) ?? "";
|
|
1077
|
+
input.addEventListener("keydown", (event) => {
|
|
1078
|
+
if (event.key === "Enter") {
|
|
1079
|
+
editing = void 0;
|
|
1080
|
+
state.set?.(scope, slot, parseValue(input.value));
|
|
1081
|
+
draw();
|
|
1082
|
+
} else if (event.key === "Escape") {
|
|
1083
|
+
editing = void 0;
|
|
1084
|
+
draw();
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
cell.append(input);
|
|
1088
|
+
queueMicrotask(() => input.focus());
|
|
1089
|
+
return line;
|
|
1090
|
+
}
|
|
1091
|
+
const canEdit = editable(value) && state.set !== void 0;
|
|
1092
|
+
const text = element("span", { class: canEdit ? "value" : "value fixed" }, preview(value));
|
|
1093
|
+
if (canEdit) {
|
|
1094
|
+
text.title = "Click to edit. Enter JSON, or text for a string.";
|
|
1095
|
+
text.addEventListener("click", () => {
|
|
1096
|
+
editing = {
|
|
1097
|
+
scope: scope.id,
|
|
1098
|
+
slot
|
|
1099
|
+
};
|
|
1100
|
+
draw();
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
cell.append(text);
|
|
1104
|
+
return line;
|
|
1105
|
+
};
|
|
1106
|
+
const drawScopes = async () => {
|
|
1107
|
+
const list = roots();
|
|
1108
|
+
const infos = await Promise.all(list.map((scope) => componentInfo(state, scope.m)));
|
|
1109
|
+
if (list.length === 0) {
|
|
1110
|
+
body.replaceChildren(element("div", { class: "empty" }, "No scopes yet. The first event loads them."));
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
const current = selectedScope !== void 0 && state.scopes?.get(selectedScope) || list[0];
|
|
1114
|
+
const search = element("input", {
|
|
1115
|
+
type: "search",
|
|
1116
|
+
placeholder: "Filter components and values",
|
|
1117
|
+
"aria-label": "Filter scopes"
|
|
1118
|
+
});
|
|
1119
|
+
search.value = filter;
|
|
1120
|
+
search.addEventListener("input", () => {
|
|
1121
|
+
filter = search.value;
|
|
1122
|
+
drawScopes().then(() => {
|
|
1123
|
+
const next = body.querySelector("input[type=\"search\"]");
|
|
1124
|
+
next?.focus();
|
|
1125
|
+
next?.setSelectionRange(filter.length, filter.length);
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1128
|
+
const tree = element("div", { class: "list" }, search);
|
|
1129
|
+
const visit = (scope, info, depth) => {
|
|
1130
|
+
const label = scope.m === void 0 ? `${info?.scopes[scope.k]?.label ?? "scope"}${scope.h ? " · hidden" : ""}` : info?.name ?? scope.m;
|
|
1131
|
+
const classes = ["tree-row"];
|
|
1132
|
+
if (scope.m !== void 0) classes.push("component");
|
|
1133
|
+
if (state.written.has(scope.id)) classes.push("written");
|
|
1134
|
+
const button = element("button", {
|
|
1135
|
+
class: classes.join(" "),
|
|
1136
|
+
style: `padding-left: ${6 + depth * 14}px`,
|
|
1137
|
+
"aria-current": String(scope === current)
|
|
1138
|
+
}, element("span", {}, label), element("span", { class: "file" }, scope.m === void 0 ? `#${scope.id}` : info?.file ?? ""));
|
|
1139
|
+
button.addEventListener("click", () => {
|
|
1140
|
+
selectedScope = scope.id;
|
|
1141
|
+
selected = rootOf(scope).m;
|
|
1142
|
+
draw();
|
|
1143
|
+
});
|
|
1144
|
+
button.addEventListener("mouseenter", () => outline(scope.id));
|
|
1145
|
+
button.addEventListener("mouseleave", () => outline());
|
|
1146
|
+
tree.append(button);
|
|
1147
|
+
for (const child of scope.children) if (child.m === void 0) visit(child, info, depth + 1);
|
|
1148
|
+
};
|
|
1149
|
+
const needle = filter.trim().toLowerCase();
|
|
1150
|
+
list.forEach((scope, index) => {
|
|
1151
|
+
const info = infos[index];
|
|
1152
|
+
if (needle && !`${info?.name ?? scope.m} ${info?.file ?? ""}`.toLowerCase().includes(needle) && !scope.s.some((value) => preview(value).toLowerCase().includes(needle))) return;
|
|
1153
|
+
visit(scope, info, 0);
|
|
1154
|
+
});
|
|
1155
|
+
const component = rootOf(current);
|
|
1156
|
+
const info = known.get(component.m ?? "");
|
|
1157
|
+
const plan = info?.scopes[current.k];
|
|
1158
|
+
const slots = element("table", { class: "rows slots" }, row([
|
|
1159
|
+
"name",
|
|
1160
|
+
"type",
|
|
1161
|
+
"value"
|
|
1162
|
+
], "th"));
|
|
1163
|
+
current.s.forEach((_, slot) => slots.append(drawSlot(current, slot, plan?.slots[slot] ?? `slot ${slot}`)));
|
|
1164
|
+
const graph = iconButton("graph", "Show the graph");
|
|
1165
|
+
graph.addEventListener("click", () => {
|
|
1166
|
+
selected = component.m;
|
|
1167
|
+
tab = "graph";
|
|
1168
|
+
draw();
|
|
1169
|
+
});
|
|
1170
|
+
const detail = element("div", { class: `detail${state.written.has(current.id) ? " written" : ""}` }, element("h2", {}, info?.name ?? component.m ?? "", element("span", { class: "sub" }, ` · ${plan?.label ?? "scope"}`)), element("div", { class: "toolbar" }, pill(`scope ${current.id}`), current.h ? pill("hidden", "yellow") : "", source(info), element("span", { class: "spacer" }), graph), current.s.length > 0 ? slots : element("div", { class: "empty" }, "This scope holds no values."));
|
|
1171
|
+
body.replaceChildren(element("div", { class: "split" }, tree, detail));
|
|
1172
|
+
body.querySelector("[aria-current=\"true\"]")?.scrollIntoView({ block: "nearest" });
|
|
1173
|
+
};
|
|
1174
|
+
/** What the dev server says about an anchor of a scope, with the component that has it. */
|
|
1175
|
+
const anchorOf = async (scope, anchor) => {
|
|
1176
|
+
const component = rootOf(scope);
|
|
1177
|
+
const info = component.m ? await componentInfo(state, component.m) : void 0;
|
|
1178
|
+
return {
|
|
1179
|
+
info,
|
|
1180
|
+
component,
|
|
1181
|
+
place: info?.anchors?.[scope.k]?.[anchor]
|
|
1182
|
+
};
|
|
1183
|
+
};
|
|
1184
|
+
/** The names that an anchor reads, with their values in the scope. */
|
|
1185
|
+
const drawReads = (scope, reads) => reads.map((name) => {
|
|
1186
|
+
const value = valueOf(scope, name);
|
|
1187
|
+
return element("span", {
|
|
1188
|
+
class: "pill",
|
|
1189
|
+
style: "margin: 0 4px 2px 0"
|
|
1190
|
+
}, element("span", { class: "name" }, name), value === void 0 ? "" : ` = ${value}`);
|
|
1191
|
+
});
|
|
1192
|
+
/** The handlers of an element, from its `b-on`, with the state of the code of each one. */
|
|
1193
|
+
const drawHandlers = (target) => {
|
|
1194
|
+
const table = element("table", { class: "rows" }, row([
|
|
1195
|
+
"event",
|
|
1196
|
+
"handler",
|
|
1197
|
+
"part",
|
|
1198
|
+
"code",
|
|
1199
|
+
"size"
|
|
1200
|
+
], "th"));
|
|
1201
|
+
for (const raw of (target.getAttribute("b-on") ?? "").split(/\s+/).filter(Boolean)) {
|
|
1202
|
+
const [head, ref = ""] = raw.split("=");
|
|
1203
|
+
const [type, ...modifiers] = head.split(":");
|
|
1204
|
+
const [component, name = ""] = ref.split("@")[0].split("#");
|
|
1205
|
+
const part = /^[hct]\d/.test(name) ? name : "update";
|
|
1206
|
+
const load = state.loads.get(`${component}:${part}`) ?? state.loads.get(`${component}:all`);
|
|
1207
|
+
const info = known.get(component);
|
|
1208
|
+
let status = pill("not loaded");
|
|
1209
|
+
if (load && load.end === void 0) status = pill("loading", "blue");
|
|
1210
|
+
else if (load && load.end !== void 0) status = pill(`${load.failed ? "failed" : "loaded"} in ${ms(load.end - load.start)} (${load.reason})`, load.failed ? "red" : "green");
|
|
1211
|
+
const bytes = bytesOf(info, load?.part ?? part);
|
|
1212
|
+
table.append(row([
|
|
1213
|
+
element("span", { class: "mono" }, [type, ...modifiers].join(":")),
|
|
1214
|
+
element("span", { class: "mono" }, `${info?.name ?? component} ${name}`),
|
|
1215
|
+
element("span", { class: "mono" }, part),
|
|
1216
|
+
status,
|
|
1217
|
+
bytes ? kilobytes(bytes) : ""
|
|
1218
|
+
]));
|
|
1219
|
+
}
|
|
1220
|
+
return table;
|
|
1221
|
+
};
|
|
1222
|
+
const drawElements = async () => {
|
|
1223
|
+
if (!picked?.isConnected) {
|
|
1224
|
+
const start = iconButton("pick", "Pick an element");
|
|
1225
|
+
start.addEventListener("click", () => pick.click());
|
|
1226
|
+
body.replaceChildren(element("h2", {}, "Elements"), element("p", { class: "sub" }, "Pick an element of the page to see the component that renders it, its place in the file, its handlers and the values that update it."), start);
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
const tag = `<${picked.tagName.toLowerCase()}>`;
|
|
1230
|
+
const content = element("div");
|
|
1231
|
+
const anchored = picked.closest("[b-b]");
|
|
1232
|
+
const [id = "", anchorText = "0"] = anchored?.getAttribute("b-b").split(":") ?? [];
|
|
1233
|
+
const scope = anchored ? scopeOf(id) : void 0;
|
|
1234
|
+
if (scope) {
|
|
1235
|
+
const anchor = Number(anchorText);
|
|
1236
|
+
const { info, component, place } = await anchorOf(scope, anchor);
|
|
1237
|
+
const scopeButton = element("button", {
|
|
1238
|
+
class: "link",
|
|
1239
|
+
title: "Show the scope"
|
|
1240
|
+
}, `scope ${scope.id}${info?.scopes[scope.k] ? ` · ${info.scopes[scope.k].label}` : ""}`);
|
|
1241
|
+
scopeButton.addEventListener("click", () => {
|
|
1242
|
+
selectedScope = scope.id;
|
|
1243
|
+
tab = "scopes";
|
|
1244
|
+
draw();
|
|
1245
|
+
});
|
|
1246
|
+
content.append(element("h2", {}, picked === anchored ? place?.label ?? tag : `${tag} in ${place?.label ?? "an element"}`, element("span", { class: "sub" }, ` · ${info?.name ?? component.m}`)), element("div", { class: "kv" }, element("span", {}, "source"), element("span", {}, place?.at ? source(info, place.at) : "—"), element("span", {}, "scope"), element("span", {}, scopeButton), element("span", {}, "anchor"), element("span", { class: "mono" }, String(anchor)), element("span", {}, "reads"), element("span", {}, ...place && place.reads.length > 0 ? drawReads(scope, place.reads) : ["—"])));
|
|
1247
|
+
const handled = picked.closest("[b-on]");
|
|
1248
|
+
if (handled && anchored.contains(handled)) content.append(element("h3", {}, "Handlers"), drawHandlers(handled));
|
|
1249
|
+
} else content.append(element("h2", {}, tag), element("div", { class: "empty" }, anchored ? `Scope ${id} is not in the browser yet.` : "Nothing in the browser updates this element or the elements around it."));
|
|
1250
|
+
const markers = [];
|
|
1251
|
+
const walker = document.createTreeWalker(picked, NodeFilter.SHOW_COMMENT);
|
|
1252
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1253
|
+
const data = node.data;
|
|
1254
|
+
const match = /^[tb](-?[\d.]+):(\d+)/.exec(data);
|
|
1255
|
+
const markerScope = match && scopeOf(match[1]);
|
|
1256
|
+
if (markerScope) markers.push({
|
|
1257
|
+
data,
|
|
1258
|
+
scope: markerScope,
|
|
1259
|
+
anchor: Number(match[2])
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
const places = await Promise.all(markers.map((marker) => anchorOf(marker.scope, marker.anchor)));
|
|
1263
|
+
const inside = element("table", { class: "rows" }, row([
|
|
1264
|
+
"marker",
|
|
1265
|
+
"source",
|
|
1266
|
+
"reads"
|
|
1267
|
+
], "th"));
|
|
1268
|
+
markers.forEach((marker, index) => {
|
|
1269
|
+
const { info, place } = places[index];
|
|
1270
|
+
inside.append(row([
|
|
1271
|
+
element("span", { class: "mono" }, place?.label ?? marker.data),
|
|
1272
|
+
place?.at ? source(info, place.at) : "",
|
|
1273
|
+
element("span", {}, ...drawReads(marker.scope, place?.reads ?? []))
|
|
1274
|
+
]));
|
|
1275
|
+
});
|
|
1276
|
+
if (markers.length > 0) content.append(element("h3", {}, "Inside it"), inside);
|
|
1277
|
+
body.replaceChildren(content);
|
|
1278
|
+
};
|
|
1279
|
+
let cooling;
|
|
1280
|
+
const drawGraph = async () => {
|
|
1281
|
+
const id = selected ?? roots()[0]?.m;
|
|
1282
|
+
const info = id ? await componentInfo(state, id) : void 0;
|
|
1283
|
+
if (!id || !info) {
|
|
1284
|
+
body.replaceChildren(element("div", { class: "empty" }, "No component yet."));
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
if (!info.graph) {
|
|
1288
|
+
body.replaceChildren(element("div", { class: "toolbar" }, chooser(id)), element("div", { class: "empty" }, "The dev server sent no graph. It runs an older brumate than this panel: restart it."));
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
const { nodes, edges } = info.graph;
|
|
1292
|
+
const instance = roots().find((scope) => scope.m === id);
|
|
1293
|
+
const scopeOfNode = /* @__PURE__ */ new Map();
|
|
1294
|
+
const visit = (scope) => {
|
|
1295
|
+
if (!scopeOfNode.has(scope.k)) scopeOfNode.set(scope.k, scope);
|
|
1296
|
+
for (const child of scope.children) if (child.m === void 0) visit(child);
|
|
1297
|
+
};
|
|
1298
|
+
if (instance) visit(instance);
|
|
1299
|
+
const now = performance.now();
|
|
1300
|
+
const hot = /* @__PURE__ */ new Set();
|
|
1301
|
+
for (const entry of state.log) if (entry.write?.component === id && now - entry.time < HOT_MS) nodes.forEach((node, index) => {
|
|
1302
|
+
if (node.scope === entry.write.k && node.slot === entry.write.slot) hot.add(index);
|
|
1303
|
+
});
|
|
1304
|
+
for (let grew = true; grew;) {
|
|
1305
|
+
grew = false;
|
|
1306
|
+
for (const [from, to] of edges) if (hot.has(from) && !hot.has(to)) {
|
|
1307
|
+
hot.add(to);
|
|
1308
|
+
grew = true;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
const parts = nodes.map((node) => {
|
|
1312
|
+
const at = /^(.*) (\d+:\d+)$/.exec(node.label);
|
|
1313
|
+
const owner = node.slot === void 0 ? void 0 : scopeOfNode.get(node.scope);
|
|
1314
|
+
const value = owner && node.slot !== void 0 ? preview(owner.s[node.slot]) : void 0;
|
|
1315
|
+
let meta = at ? `${node.kind} · ${at[2]}` : node.kind;
|
|
1316
|
+
if (value !== void 0) meta = `= ${value}`;
|
|
1317
|
+
return {
|
|
1318
|
+
name: at ? at[1] : node.label,
|
|
1319
|
+
meta,
|
|
1320
|
+
value,
|
|
1321
|
+
at: at?.[2]
|
|
1322
|
+
};
|
|
1323
|
+
});
|
|
1324
|
+
const widthOf = (index) => Math.min(262, Math.max(112, 36 + 7 * Math.max(clip(parts[index].name).length, clip(parts[index].meta).length)));
|
|
1325
|
+
const position = layoutGraph(nodes, edges, widthOf);
|
|
1326
|
+
const related = /* @__PURE__ */ new Set();
|
|
1327
|
+
if (graphNode !== void 0 && graphNode < nodes.length) {
|
|
1328
|
+
related.add(graphNode);
|
|
1329
|
+
for (const [from, to] of [[0, 1], [1, 0]]) {
|
|
1330
|
+
const queue = [graphNode];
|
|
1331
|
+
while (queue.length > 0) {
|
|
1332
|
+
const next = queue.pop();
|
|
1333
|
+
for (const edge of edges) if (edge[from] === next && !related.has(edge[to])) {
|
|
1334
|
+
related.add(edge[to]);
|
|
1335
|
+
queue.push(edge[to]);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
const graphWidth = Math.max(0, ...position.map((place) => place.x + place.width)) + 16;
|
|
1341
|
+
const graphHeight = Math.max(0, ...position.map((place) => place.y)) + 56;
|
|
1342
|
+
const layer = svg("g", { class: "layer" });
|
|
1343
|
+
for (const [from, to] of edges) {
|
|
1344
|
+
const a = position[from];
|
|
1345
|
+
const b = position[to];
|
|
1346
|
+
const x1 = a.x + a.width;
|
|
1347
|
+
const y1 = a.y + 19;
|
|
1348
|
+
const x2 = b.x - 3;
|
|
1349
|
+
const y2 = b.y + 19;
|
|
1350
|
+
const bend = Math.max(28, (x2 - x1) / 2);
|
|
1351
|
+
const classes = ["edge"];
|
|
1352
|
+
if (hot.has(from) && hot.has(to)) classes.push("hot-edge");
|
|
1353
|
+
else if (related.size > 0) classes.push(related.has(from) && related.has(to) ? "lit" : "faded");
|
|
1354
|
+
layer.append(svg("path", {
|
|
1355
|
+
class: classes.join(" "),
|
|
1356
|
+
d: `M${x1},${y1} C${x1 + bend},${y1} ${x2 - bend},${y2} ${x2},${y2}`,
|
|
1357
|
+
"marker-end": "url(#arrow)"
|
|
1358
|
+
}));
|
|
1359
|
+
}
|
|
1360
|
+
nodes.forEach((node, index) => {
|
|
1361
|
+
const { x, y, width: nodeWidth } = position[index];
|
|
1362
|
+
const part = parts[index];
|
|
1363
|
+
const classes = ["node", `k-${node.kind}`];
|
|
1364
|
+
if (hot.has(index)) classes.push("hot");
|
|
1365
|
+
if (graphNode === index) classes.push("selected");
|
|
1366
|
+
if (related.size > 0 && !related.has(index)) classes.push("faded");
|
|
1367
|
+
const name = svg("text", {
|
|
1368
|
+
class: "name",
|
|
1369
|
+
x: x + 23,
|
|
1370
|
+
y: y + 16
|
|
1371
|
+
});
|
|
1372
|
+
name.textContent = clip(part.name);
|
|
1373
|
+
const meta = svg("text", {
|
|
1374
|
+
class: "meta",
|
|
1375
|
+
x: x + 23,
|
|
1376
|
+
y: y + 30
|
|
1377
|
+
});
|
|
1378
|
+
meta.textContent = clip(part.meta);
|
|
1379
|
+
const title = svg("title", {});
|
|
1380
|
+
title.textContent = `${node.kind} ${node.label}${part.value === void 0 ? "" : ` = ${part.value}`}`;
|
|
1381
|
+
const group = svg("g", {
|
|
1382
|
+
class: classes.join(" "),
|
|
1383
|
+
"data-node": index
|
|
1384
|
+
}, svg("rect", {
|
|
1385
|
+
class: "box",
|
|
1386
|
+
x,
|
|
1387
|
+
y,
|
|
1388
|
+
width: nodeWidth,
|
|
1389
|
+
height: 38,
|
|
1390
|
+
rx: 7
|
|
1391
|
+
}), svg("circle", {
|
|
1392
|
+
class: "kind",
|
|
1393
|
+
cx: x + 13,
|
|
1394
|
+
cy: y + 12.5,
|
|
1395
|
+
r: 3.5
|
|
1396
|
+
}), name, meta, title);
|
|
1397
|
+
group.addEventListener("click", (event) => {
|
|
1398
|
+
event.stopPropagation();
|
|
1399
|
+
graphNode = graphNode === index ? void 0 : index;
|
|
1400
|
+
draw();
|
|
1401
|
+
});
|
|
1402
|
+
layer.append(group);
|
|
1403
|
+
});
|
|
1404
|
+
const canvas = svg("svg", {
|
|
1405
|
+
role: "img",
|
|
1406
|
+
"aria-label": `Graph of ${info.name}`
|
|
1407
|
+
}, svg("defs", {}, svg("marker", {
|
|
1408
|
+
id: "arrow",
|
|
1409
|
+
viewBox: "0 0 8 8",
|
|
1410
|
+
refX: 7,
|
|
1411
|
+
refY: 4,
|
|
1412
|
+
markerWidth: 6,
|
|
1413
|
+
markerHeight: 6,
|
|
1414
|
+
orient: "auto"
|
|
1415
|
+
}, svg("path", {
|
|
1416
|
+
d: "M0,0 L8,4 L0,8 z",
|
|
1417
|
+
fill: "#8a8280"
|
|
1418
|
+
}))), layer);
|
|
1419
|
+
const frame = element("div", { class: "graph-view" }, canvas);
|
|
1420
|
+
const apply = () => {
|
|
1421
|
+
layer.setAttribute("transform", `translate(${view.x},${view.y}) scale(${view.scale})`);
|
|
1422
|
+
};
|
|
1423
|
+
const fit = () => {
|
|
1424
|
+
const box = frame.getBoundingClientRect();
|
|
1425
|
+
if (box.width === 0) return;
|
|
1426
|
+
view.scale = Math.min(1.2, Math.max(.3, Math.min(box.width / graphWidth, box.height / graphHeight)));
|
|
1427
|
+
view.x = (box.width - graphWidth * view.scale) / 2;
|
|
1428
|
+
view.y = Math.max(0, (box.height - graphHeight * view.scale) / 2);
|
|
1429
|
+
apply();
|
|
1430
|
+
};
|
|
1431
|
+
const zoomAt = (factor, px, py) => {
|
|
1432
|
+
const next = Math.min(3, Math.max(.2, view.scale * factor));
|
|
1433
|
+
view.x = px - (px - view.x) * next / view.scale;
|
|
1434
|
+
view.y = py - (py - view.y) * next / view.scale;
|
|
1435
|
+
view.scale = next;
|
|
1436
|
+
apply();
|
|
1437
|
+
};
|
|
1438
|
+
frame.addEventListener("wheel", (event) => {
|
|
1439
|
+
event.preventDefault();
|
|
1440
|
+
const box = frame.getBoundingClientRect();
|
|
1441
|
+
zoomAt(event.deltaY < 0 ? 1.1 : 1 / 1.1, event.clientX - box.left, event.clientY - box.top);
|
|
1442
|
+
}, { passive: false });
|
|
1443
|
+
frame.addEventListener("pointerdown", (event) => {
|
|
1444
|
+
if (event.target.closest(".node, button")) return;
|
|
1445
|
+
const start = {
|
|
1446
|
+
x: event.clientX - view.x,
|
|
1447
|
+
y: event.clientY - view.y
|
|
1448
|
+
};
|
|
1449
|
+
frame.classList.add("dragging");
|
|
1450
|
+
const move = (next) => {
|
|
1451
|
+
view.x = next.clientX - start.x;
|
|
1452
|
+
view.y = next.clientY - start.y;
|
|
1453
|
+
apply();
|
|
1454
|
+
};
|
|
1455
|
+
const up = () => {
|
|
1456
|
+
frame.classList.remove("dragging");
|
|
1457
|
+
window.removeEventListener("pointermove", move);
|
|
1458
|
+
window.removeEventListener("pointerup", up);
|
|
1459
|
+
};
|
|
1460
|
+
window.addEventListener("pointermove", move);
|
|
1461
|
+
window.addEventListener("pointerup", up);
|
|
1462
|
+
});
|
|
1463
|
+
canvas.addEventListener("click", () => {
|
|
1464
|
+
if (graphNode !== void 0) {
|
|
1465
|
+
graphNode = void 0;
|
|
1466
|
+
draw();
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
const zoomButton = (name, title, factor) => {
|
|
1470
|
+
const button = iconButton(name, title, {}, true);
|
|
1471
|
+
button.addEventListener("click", () => {
|
|
1472
|
+
const box = frame.getBoundingClientRect();
|
|
1473
|
+
zoomAt(factor, box.width / 2, box.height / 2);
|
|
1474
|
+
});
|
|
1475
|
+
return button;
|
|
1476
|
+
};
|
|
1477
|
+
const fitButton = iconButton("fit", "Fit the graph in view", {}, true);
|
|
1478
|
+
fitButton.addEventListener("click", fit);
|
|
1479
|
+
frame.append(element("div", { class: "zoom" }, zoomButton("minus", "Zoom out", 1 / 1.2), zoomButton("plus", "Zoom in", 1.2), fitButton));
|
|
1480
|
+
const side = element("div", { class: "graph-side" });
|
|
1481
|
+
if (graphNode !== void 0 && graphNode < nodes.length) {
|
|
1482
|
+
const node = nodes[graphNode];
|
|
1483
|
+
const part = parts[graphNode];
|
|
1484
|
+
const list = (indexes) => indexes.length > 0 ? element("div", {}, ...indexes.map((index) => element("div", { class: "mono" }, nodes[index].label))) : element("div", { class: "sub" }, "nothing");
|
|
1485
|
+
const color = nodeColor(node.kind, node.slot);
|
|
1486
|
+
side.append(element("h2", {}, part.name), element("div", { class: "toolbar" }, pill(node.kind, color), part.at ? source(info, part.at) : ""), ...part.value === void 0 ? [] : [element("h3", {}, "Value"), element("div", { class: "mono" }, part.value)], element("h3", {}, "Reads"), list(edges.filter(([, to]) => to === graphNode).map(([from]) => from)), element("h3", {}, "Read by"), list(edges.filter(([from]) => from === graphNode).map(([, to]) => to)));
|
|
1487
|
+
} else side.append(element("h2", {}, info.name), element("p", {
|
|
1488
|
+
class: "sub",
|
|
1489
|
+
style: "margin-top: 0"
|
|
1490
|
+
}, "What changes in the browser, and what reads what, left to right. Click a node to follow it. Drag to pan, and scroll to zoom."), element("div", {
|
|
1491
|
+
class: "legend",
|
|
1492
|
+
style: "flex-direction: column; align-items: flex-start; gap: 4px"
|
|
1493
|
+
}, key("var(--blue)", "signals and props"), key("var(--purple)", "memos"), key("var(--faint)", "markup"), key("var(--green)", "effects"), key("var(--yellow)", "what a change reached")));
|
|
1494
|
+
body.replaceChildren(element("div", { class: "toolbar" }, chooser(id), element("span", { class: "sub" }, `${nodes.length} nodes · ${edges.length} edges`)), nodes.length > 0 ? element("div", { class: "graph-wrap" }, frame, side) : element("div", { class: "empty" }, "Nothing in this component changes in the browser."));
|
|
1495
|
+
if (view.fitted === id) apply();
|
|
1496
|
+
else {
|
|
1497
|
+
view = {
|
|
1498
|
+
x: 0,
|
|
1499
|
+
y: 0,
|
|
1500
|
+
scale: 1,
|
|
1501
|
+
fitted: id
|
|
1502
|
+
};
|
|
1503
|
+
apply();
|
|
1504
|
+
requestAnimationFrame(fit);
|
|
1505
|
+
}
|
|
1506
|
+
if (hot.size > 0) {
|
|
1507
|
+
clearTimeout(cooling);
|
|
1508
|
+
cooling = setTimeout(() => state.changed?.(), HOT_MS);
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
const drawLog = () => {
|
|
1512
|
+
const filters = element("div", { class: "toolbar filters" });
|
|
1513
|
+
for (const kind of KINDS) {
|
|
1514
|
+
const box = element("input", { type: "checkbox" });
|
|
1515
|
+
box.checked = shown.has(kind);
|
|
1516
|
+
box.addEventListener("change", () => {
|
|
1517
|
+
if (box.checked) shown.add(kind);
|
|
1518
|
+
else shown.delete(kind);
|
|
1519
|
+
draw();
|
|
1520
|
+
});
|
|
1521
|
+
filters.append(element("label", { class: `kind-${kind}` }, box, kind));
|
|
1522
|
+
}
|
|
1523
|
+
const search = element("input", {
|
|
1524
|
+
type: "search",
|
|
1525
|
+
placeholder: "Search the log",
|
|
1526
|
+
"aria-label": "Search the log"
|
|
1527
|
+
});
|
|
1528
|
+
search.value = logSearch;
|
|
1529
|
+
search.addEventListener("input", () => {
|
|
1530
|
+
logSearch = search.value;
|
|
1531
|
+
drawLog();
|
|
1532
|
+
const next = body.querySelector("input[type=\"search\"]");
|
|
1533
|
+
next?.focus();
|
|
1534
|
+
next?.setSelectionRange(logSearch.length, logSearch.length);
|
|
1535
|
+
});
|
|
1536
|
+
const pause = iconButton(paused ? "play" : "pause", paused ? "Resume" : "Pause", { "aria-pressed": String(paused) });
|
|
1537
|
+
pause.addEventListener("click", () => {
|
|
1538
|
+
paused = !paused;
|
|
1539
|
+
frozen = paused ? [...state.log] : void 0;
|
|
1540
|
+
draw();
|
|
1541
|
+
});
|
|
1542
|
+
const clear = iconButton("trash", "Clear");
|
|
1543
|
+
clear.addEventListener("click", () => {
|
|
1544
|
+
state.log.length = 0;
|
|
1545
|
+
frozen = paused ? [] : void 0;
|
|
1546
|
+
draw();
|
|
1547
|
+
});
|
|
1548
|
+
filters.append(search, pause, clear);
|
|
1549
|
+
const needle = logSearch.trim().toLowerCase();
|
|
1550
|
+
const entries = (frozen ?? state.log).filter((entry) => shown.has(entry.kind) && (!needle || textOf(entry).toLowerCase().includes(needle)));
|
|
1551
|
+
const list = element("table", { class: "rows" });
|
|
1552
|
+
for (const entry of entries.toReversed()) list.append(element("tr", { class: `entry ${entry.kind}` }, element("td", { class: "time" }, seconds(entry.time)), element("td", {
|
|
1553
|
+
class: `kind-${entry.kind}`,
|
|
1554
|
+
style: "width: 1%"
|
|
1555
|
+
}, entry.kind), element("td", {}, textOf(entry))));
|
|
1556
|
+
body.replaceChildren(filters, entries.length > 0 ? list : element("div", { class: "empty" }, "Nothing to show."));
|
|
1557
|
+
};
|
|
1558
|
+
const drawLoading = async () => {
|
|
1559
|
+
const loads = [...state.loads.values()].toSorted((a, b) => a.start - b.start);
|
|
1560
|
+
await Promise.all([...new Set(loads.map((load) => load.component))].map((id) => componentInfo(state, id)));
|
|
1561
|
+
const unused = loads.filter((load) => PRELOADS.has(load.reason) && !load.used).length;
|
|
1562
|
+
const end = Math.max(1, ...loads.map((load) => load.end ?? performance.now()));
|
|
1563
|
+
const total = codeBytes(state);
|
|
1564
|
+
const table = element("table", { class: "rows" }, row([
|
|
1565
|
+
"component",
|
|
1566
|
+
"part",
|
|
1567
|
+
"why",
|
|
1568
|
+
"took",
|
|
1569
|
+
"size",
|
|
1570
|
+
`when, 0 to ${seconds(end)}`
|
|
1571
|
+
], "th"));
|
|
1572
|
+
for (const load of loads) {
|
|
1573
|
+
const info = known.get(load.component);
|
|
1574
|
+
let marks = PRELOADS.has(load.reason) && !load.used ? "unused" : "";
|
|
1575
|
+
if (load.failed) marks = "failed";
|
|
1576
|
+
const stop = load.end ?? performance.now();
|
|
1577
|
+
const bytes = bytesOf(info, load.part);
|
|
1578
|
+
const tr = element("tr", {}, element("td", {}, info?.name ?? load.component), element("td", { class: "mono" }, load.part), element("td", {}, pill(load.reason, reasonColor(load.reason))), element("td", { class: "mono" }, load.end === void 0 ? "…" : ms(load.end - load.start)), element("td", { class: "mono" }, bytes ? kilobytes(bytes) : ""), element("td", { class: "bar-cell" }, element("div", { class: "bar-track" }, element("span", {
|
|
1579
|
+
class: `bar ${barClass(load)}`,
|
|
1580
|
+
style: `left:${load.start / end * 100}%;width:${(stop - load.start) / end * 100}%`,
|
|
1581
|
+
title: `${seconds(load.start)} to ${seconds(stop)}`
|
|
1582
|
+
}))));
|
|
1583
|
+
if (marks) {
|
|
1584
|
+
tr.className = marks;
|
|
1585
|
+
tr.title = marks === "unused" ? "Preloaded, and nothing has run it yet" : "It failed to load";
|
|
1586
|
+
}
|
|
1587
|
+
table.append(tr);
|
|
1588
|
+
}
|
|
1589
|
+
body.replaceChildren(element("div", { class: "cards" }, card("Parts loaded", String(loads.length), total ? `${kilobytes(total)} from the dev server` : "sizes come with the requests"), card("Unused preloads", String(unused), "loaded, and nothing ran them yet")), element("div", {
|
|
1590
|
+
class: "legend",
|
|
1591
|
+
style: "margin: 10px 0 6px"
|
|
1592
|
+
}, key("var(--blue)", "event or block"), key("var(--purple)", "preload"), element("span", {}, element("i", { style: "background: repeating-linear-gradient(45deg, var(--purple) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--purple)" }), "unused preload"), key("var(--faint)", "a write, state and others"), element("span", { class: "sub" }, "Sizes are of the dev server, which does not minify.")), loads.length > 0 ? table : element("div", { class: "empty" }, "No code loaded yet."));
|
|
1593
|
+
};
|
|
1594
|
+
/**
|
|
1595
|
+
* The values that the page state sends, by the slot that holds them, with
|
|
1596
|
+
* about how many bytes each takes and the client code that reads it, which
|
|
1597
|
+
* is why it is sent.
|
|
1598
|
+
*/
|
|
1599
|
+
const drawState = async () => {
|
|
1600
|
+
const scopes = [...state.scopes?.values() ?? []].filter((scope) => typeof scope.id !== "number" || scope.id >= 0);
|
|
1601
|
+
const ids = [...new Set(scopes.map((scope) => rootOf(scope).m ?? ""))].filter(Boolean);
|
|
1602
|
+
await Promise.all(ids.map((id) => componentInfo(state, id)));
|
|
1603
|
+
const slots = /* @__PURE__ */ new Map();
|
|
1604
|
+
for (const scope of scopes) {
|
|
1605
|
+
const component = rootOf(scope).m ?? "";
|
|
1606
|
+
scope.s.forEach((value, slot) => {
|
|
1607
|
+
const key = `${component}:${scope.k}:${slot}`;
|
|
1608
|
+
const entry = slots.get(key) ?? {
|
|
1609
|
+
component,
|
|
1610
|
+
k: scope.k,
|
|
1611
|
+
slot,
|
|
1612
|
+
bytes: 0,
|
|
1613
|
+
count: 0
|
|
1614
|
+
};
|
|
1615
|
+
entry.bytes += sizeOf(value);
|
|
1616
|
+
entry.count++;
|
|
1617
|
+
slots.set(key, entry);
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
const sorted = [...slots.values()].toSorted((a, b) => b.bytes - a.bytes);
|
|
1621
|
+
const first = document.querySelector("script[b-state][b-scopes]")?.textContent?.length ?? 0;
|
|
1622
|
+
const table = element("table", { class: "rows" }, row([
|
|
1623
|
+
"component",
|
|
1624
|
+
"scope",
|
|
1625
|
+
"value",
|
|
1626
|
+
"instances",
|
|
1627
|
+
"about",
|
|
1628
|
+
"read in the browser by"
|
|
1629
|
+
], "th"));
|
|
1630
|
+
for (const entry of sorted.slice(0, 200)) {
|
|
1631
|
+
const info = known.get(entry.component);
|
|
1632
|
+
const layout = info?.scopes[entry.k];
|
|
1633
|
+
const readers = layout?.readers?.[entry.slot] ?? [];
|
|
1634
|
+
const tr = element("tr", {}, element("td", {}, info?.name ?? entry.component), element("td", { class: "mono" }, layout?.label ?? String(entry.k)), element("td", { class: "mono" }, layout?.slots[entry.slot] ?? `slot ${entry.slot}`), element("td", { class: "mono" }, String(entry.count)), element("td", {
|
|
1635
|
+
class: "mono",
|
|
1636
|
+
style: "white-space: nowrap"
|
|
1637
|
+
}, kilobytes(entry.bytes)), element("td", { class: "mono" }, readers.join(", ") || "—"));
|
|
1638
|
+
if (entry.bytes > 1024) {
|
|
1639
|
+
tr.className = "large";
|
|
1640
|
+
tr.title = "More than 1 kB. Send only the fields that the browser reads.";
|
|
1641
|
+
}
|
|
1642
|
+
table.append(tr);
|
|
1643
|
+
}
|
|
1644
|
+
body.replaceChildren(element("div", { class: "cards" }, card("Page state", kilobytes(stateBytes()), "every state record of the page"), card("First record", kilobytes(first), "the state that the page started with"), card("Values", String(slots.size), `in ${scopes.length} scopes`)), element("div", {
|
|
1645
|
+
class: "legend",
|
|
1646
|
+
style: "margin: 10px 0 6px"
|
|
1647
|
+
}, element("span", { class: "sub" }, "A value is sent because code in the browser reads it. Sizes are about what the state takes, and a value of many instances adds them up.")), slots.size > 0 ? table : element("div", { class: "empty" }, "The page sent no state."));
|
|
1648
|
+
};
|
|
1649
|
+
/** The effects and `$client` callbacks, with how often each ran and when its cleanup ran. */
|
|
1650
|
+
const drawEffects = async () => {
|
|
1651
|
+
const effects = [...state.effects.values()];
|
|
1652
|
+
await Promise.all([...new Set(effects.map((effect) => effect.component))].map((id) => componentInfo(state, id)));
|
|
1653
|
+
const now = performance.now();
|
|
1654
|
+
const lastSecond = (recent) => recent.filter((at) => now - at < 1e3).length;
|
|
1655
|
+
const sorted = effects.toSorted((a, b) => lastSecond(b.recent) - lastSecond(a.recent) || b.runs - a.runs);
|
|
1656
|
+
const table = element("table", { class: "rows" }, row([
|
|
1657
|
+
"component",
|
|
1658
|
+
"scope",
|
|
1659
|
+
"name",
|
|
1660
|
+
"runs",
|
|
1661
|
+
"last second",
|
|
1662
|
+
"time",
|
|
1663
|
+
"cleanups",
|
|
1664
|
+
"last run"
|
|
1665
|
+
], "th"));
|
|
1666
|
+
for (const effect of sorted) {
|
|
1667
|
+
const info = known.get(effect.component);
|
|
1668
|
+
const recent = lastSecond(effect.recent);
|
|
1669
|
+
const last = effect.recent.at(-1);
|
|
1670
|
+
const tr = element("tr", {}, element("td", {}, info?.name ?? effect.component), element("td", { class: "mono" }, info?.scopes[effect.k]?.label ?? String(effect.scope)), element("td", {}, pill(effect.name.startsWith("c") ? "$client" : "$effect", effect.name.startsWith("c") ? "purple" : "blue"), " ", element("span", { class: "mono" }, effect.name)), element("td", { class: "mono" }, String(effect.runs)), element("td", { class: "mono" }, String(recent)), element("td", { class: "mono" }, ms(effect.time)), element("td", { class: "mono" }, String(effect.cleanups)), element("td", { class: "mono" }, last === void 0 ? "" : `${seconds(now - last)} ago`));
|
|
1671
|
+
if (recent >= 10) {
|
|
1672
|
+
tr.className = "busy";
|
|
1673
|
+
tr.title = "It ran 10 times or more in the last second. Check what it reads.";
|
|
1674
|
+
} else if (!effect.active) {
|
|
1675
|
+
tr.className = "ended";
|
|
1676
|
+
tr.title = "Its cleanup ran, and it has not run again, such as in a scope that went.";
|
|
1677
|
+
}
|
|
1678
|
+
table.append(tr);
|
|
1679
|
+
}
|
|
1680
|
+
const active = effects.filter((effect) => effect.active).length;
|
|
1681
|
+
body.replaceChildren(element("div", { class: "cards" }, card("Active", String(active), `of ${effects.length} that ran`), card("Runs", String(effects.reduce((sum, effect) => sum + effect.runs, 0)), "since the page loaded"), card("Busy", String(effects.filter((effect) => lastSecond(effect.recent) >= 10).length), "ran 10 times or more in the last second")), effects.length > 0 ? table : element("div", { class: "empty" }, "No effect or $client callback has run yet."));
|
|
1682
|
+
};
|
|
1683
|
+
/**
|
|
1684
|
+
* The client navigations of the page, newest first: the routes that
|
|
1685
|
+
* stayed, those that were replaced, or the whole page, and how far the
|
|
1686
|
+
* IDs of the new page moved.
|
|
1687
|
+
*/
|
|
1688
|
+
const drawNavigation = async () => {
|
|
1689
|
+
const items = state.navigations.toReversed().map((navigation) => {
|
|
1690
|
+
const path = new URL(navigation.url).pathname + new URL(navigation.url).search;
|
|
1691
|
+
const routes = element("div", { class: "routes" });
|
|
1692
|
+
if (navigation.full) routes.append(element("div", { class: "sub" }, navigation.kind === "form" ? "The whole page: a form changes what can show anywhere on it." : "The whole page: its root route or its layouts did not match the page before."));
|
|
1693
|
+
else {
|
|
1694
|
+
for (const key of navigation.kept) routes.append(element("div", { class: "mono" }, pill("kept", "green"), " ", key));
|
|
1695
|
+
for (const change of navigation.replaced) routes.append(element("div", { class: "mono" }, pill("replaced", "yellow"), ` ${change.slot}: ${change.from} → ${change.to}`));
|
|
1696
|
+
}
|
|
1697
|
+
return element("div", { class: "navigation" }, element("div", { class: "toolbar" }, element("span", { class: "mono" }, path), pill(navigation.kind, navigation.kind === "form" ? "purple" : "blue"), element("span", { class: "sub" }, `${ms(navigation.time)} until the page changed`), navigation.shift === void 0 ? "" : element("span", { class: "sub" }, `IDs moved by ${navigation.shift}`)), routes);
|
|
1698
|
+
});
|
|
1699
|
+
body.replaceChildren(...items.length > 0 ? items : [element("div", { class: "empty" }, "No client navigation yet. Follow a link of the page to see what it keeps.")]);
|
|
1700
|
+
};
|
|
1701
|
+
/**
|
|
1702
|
+
* What the server did for the last page that loaded: the render until the
|
|
1703
|
+
* page could stream, each memo that loaded and each server function call,
|
|
1704
|
+
* each `#loading` body, and the rest of the stream, on one scale. The
|
|
1705
|
+
* server writes it at the end of the page, in development.
|
|
1706
|
+
*/
|
|
1707
|
+
const drawServer = async () => {
|
|
1708
|
+
const script = [...document.querySelectorAll("script[b-trace]")].at(-1);
|
|
1709
|
+
let trace;
|
|
1710
|
+
try {
|
|
1711
|
+
trace = script ? JSON.parse(script.textContent ?? "") : void 0;
|
|
1712
|
+
} catch {
|
|
1713
|
+
trace = void 0;
|
|
1714
|
+
}
|
|
1715
|
+
if (!trace) {
|
|
1716
|
+
body.replaceChildren(element("div", { class: "empty" }, "No trace yet. The dev server writes one at the end of each page that it renders."));
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const entries = trace.entries.toSorted((a, b) => a.start - b.start);
|
|
1720
|
+
const total = Math.max(1, ...entries.map((entry) => entry.end ?? entry.start));
|
|
1721
|
+
const table = element("table", { class: "rows" }, row([
|
|
1722
|
+
"step",
|
|
1723
|
+
"what",
|
|
1724
|
+
"took",
|
|
1725
|
+
`when, 0 to ${ms(total)}`
|
|
1726
|
+
], "th"));
|
|
1727
|
+
for (const entry of entries) {
|
|
1728
|
+
const end = entry.end ?? total;
|
|
1729
|
+
const tr = element("tr", {}, element("td", {}, pill(entry.kind, entry.failed ? "red" : "")), element("td", { class: "mono" }, entry.label), element("td", { class: "mono" }, entry.end === void 0 ? "…" : ms(end - entry.start)), element("td", { class: "bar-cell" }, element("div", { class: "bar-track" }, element("span", {
|
|
1730
|
+
class: `bar ${entry.failed ? "failed" : entry.kind}`,
|
|
1731
|
+
style: `left:${entry.start / total * 100}%;width:${(end - entry.start) / total * 100}%`,
|
|
1732
|
+
title: `${ms(entry.start)} to ${ms(end)}`
|
|
1733
|
+
}))));
|
|
1734
|
+
if (entry.failed) tr.className = "failed";
|
|
1735
|
+
table.append(tr);
|
|
1736
|
+
}
|
|
1737
|
+
const render = entries.find((entry) => entry.kind === "render");
|
|
1738
|
+
const count = (kind) => entries.filter((entry) => entry.kind === kind).length;
|
|
1739
|
+
body.replaceChildren(element("div", { class: "cards" }, card("Until it streamed", render?.end === void 0 ? "…" : ms(render.end), `the render of ${trace.route}`), card("Whole page", ms(total), "until the last body streamed"), card("Memos that loaded", String(count("memo")), `${count("call")} server function calls`), card("Bodies", String(count("body")), "#loading bodies that streamed")), element("div", {
|
|
1740
|
+
class: "legend",
|
|
1741
|
+
style: "margin: 10px 0 6px"
|
|
1742
|
+
}, key("var(--accent)", "render"), key("var(--green)", "memo"), key("var(--blue)", "server function call"), key("var(--purple)", "#loading body"), key("var(--faint)", "the rest of the stream"), element("span", { class: "sub" }, "Of the last page that the dev server rendered.")), table);
|
|
1743
|
+
};
|
|
1744
|
+
const drawTimeline = async () => {
|
|
1745
|
+
const runs = state.timeline.toReversed().slice(0, 40);
|
|
1746
|
+
await Promise.all([...new Set(runs.map((run) => run.ref.split("#")[0]))].map((id) => componentInfo(state, id)));
|
|
1747
|
+
if (runs.length === 0) {
|
|
1748
|
+
body.replaceChildren(element("h2", {}, "Timeline"), element("p", { class: "sub" }, "Each handler that runs shows here, with the time its code took to load, its own run, the server functions it called and the updates that followed."));
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
const now = performance.now();
|
|
1752
|
+
const totals = runs.map((run) => (run.settled ?? now) - run.begun);
|
|
1753
|
+
const segment = (run, scale, start, end, kind, title) => {
|
|
1754
|
+
const left = Math.min(Math.max((start - run.begun) / scale * 100, 0), 100);
|
|
1755
|
+
const width = Math.min(Math.max((end - start) / scale * 100, 0), 100 - left);
|
|
1756
|
+
return element("span", {
|
|
1757
|
+
class: `seg ${kind}`,
|
|
1758
|
+
style: `left:${left}%;width:${width}%`,
|
|
1759
|
+
title
|
|
1760
|
+
});
|
|
1761
|
+
};
|
|
1762
|
+
const list = element("div");
|
|
1763
|
+
runs.forEach((run, index) => {
|
|
1764
|
+
const total = totals[index];
|
|
1765
|
+
const last = Math.max(run.settled ?? now, ...run.calls.map((call) => call.end ?? now), ...run.updates.map((update) => update.end));
|
|
1766
|
+
const step = tickStep(Math.max(last - run.begun, 1) / 4);
|
|
1767
|
+
const scale = Math.ceil(Math.max(last - run.begun, 1) / step) * step;
|
|
1768
|
+
const ticks = element("div", { class: "ruler" });
|
|
1769
|
+
for (let time = 0; time <= scale + step / 2; time += step) {
|
|
1770
|
+
const at = time / scale * 100;
|
|
1771
|
+
ticks.append(element("span", {
|
|
1772
|
+
class: at > 99 ? "end" : "",
|
|
1773
|
+
style: `left:${at}%`
|
|
1774
|
+
}, ms(time)));
|
|
1775
|
+
}
|
|
1776
|
+
const grid = `background-image: repeating-linear-gradient(to right, #ffffff1a 0 1px, transparent 1px ${step / scale * 100}%)`;
|
|
1777
|
+
const handler = element("div", {
|
|
1778
|
+
class: "track",
|
|
1779
|
+
style: grid
|
|
1780
|
+
}, ...run.ready - run.begun > .5 ? [segment(run, scale, run.begun, run.ready, "wait", `waiting for its code and the handlers before it: ${ms(run.ready - run.begun)}`)] : [], segment(run, scale, run.ready, run.end, run.failed ? "failed" : "run", `its run: ${ms(run.end - run.ready)}`), ...run.settled !== void 0 && run.settled - run.end > .5 ? [segment(run, scale, run.end, run.settled, "async", `its promise: ${ms(run.settled - run.end)}`)] : []);
|
|
1781
|
+
const rows = [element("div", { class: "run-row" }, element("span"), ticks, element("span")), element("div", { class: "run-row" }, element("span", { class: "name" }, "handler"), handler, element("span", { class: "took" }, run.settled === void 0 ? "…" : ms(total)))];
|
|
1782
|
+
for (const call of run.calls) {
|
|
1783
|
+
const end = call.end ?? now;
|
|
1784
|
+
const parts = [segment(run, scale, call.start, end, call.status === "failed" ? "failed" : "call", `the round trip: ${ms(end - call.start)}`)];
|
|
1785
|
+
if (call.server !== void 0) {
|
|
1786
|
+
const middle = call.start + (end - call.start - call.server) / 2;
|
|
1787
|
+
parts.push(segment(run, scale, middle, middle + call.server, "server", `on the server: ${ms(call.server)}`));
|
|
1788
|
+
}
|
|
1789
|
+
rows.push(element("div", { class: "run-row" }, element("span", {
|
|
1790
|
+
class: "name",
|
|
1791
|
+
title: call.name
|
|
1792
|
+
}, `call ${handlerName(call.name)}`), element("div", {
|
|
1793
|
+
class: "track",
|
|
1794
|
+
style: grid
|
|
1795
|
+
}, ...parts), element("span", { class: "took" }, call.end === void 0 ? "…" : `${ms(end - call.start)}${call.server === void 0 ? "" : ` (${ms(call.server)})`}`)));
|
|
1796
|
+
}
|
|
1797
|
+
if (run.updates.length > 0) {
|
|
1798
|
+
const count = run.updates.reduce((sum, update) => sum + update.count, 0);
|
|
1799
|
+
const took = run.updates.reduce((sum, update) => sum + update.end - update.start, 0);
|
|
1800
|
+
const batches = run.updates.length;
|
|
1801
|
+
rows.push(element("div", { class: "run-row" }, element("span", { class: "name" }, `${count} ${count === 1 ? "update" : "updates"}${batches > 1 ? `, ${batches} batches` : ""}`), element("div", {
|
|
1802
|
+
class: "track",
|
|
1803
|
+
style: grid
|
|
1804
|
+
}, ...run.updates.map((update) => segment(run, scale, update.start, update.end, "update", `${update.count} ${update.count === 1 ? "update" : "updates"} and their effects: ${ms(update.end - update.start)}`))), element("span", { class: "took" }, ms(took))));
|
|
1805
|
+
}
|
|
1806
|
+
const speed = speedColor(total);
|
|
1807
|
+
list.append(element("div", { class: "interaction" }, element("div", { class: "run-head" }, element("span", { class: "what" }, run.label), element("span", { class: "ref" }, handlerName(run.ref)), element("span", { class: "spacer" }), run.failed ? pill("failed", "red") : "", pill(run.settled === void 0 ? "running" : ms(total), run.settled === void 0 ? "blue" : speed), element("span", { class: "sub" }, seconds(run.begun))), ...rows));
|
|
1808
|
+
});
|
|
1809
|
+
const settled = totals.filter((_, index) => runs[index].settled !== void 0);
|
|
1810
|
+
const clear = iconButton("trash", "Clear");
|
|
1811
|
+
clear.addEventListener("click", () => {
|
|
1812
|
+
state.timeline.length = 0;
|
|
1813
|
+
draw();
|
|
1814
|
+
});
|
|
1815
|
+
body.replaceChildren(element("div", { class: "cards" }, card("Handlers", String(state.timeline.length), "the last 40 show here"), card("Slowest", settled.length > 0 ? ms(Math.max(...settled)) : "—", "from the event to the end of its promise"), card("Server calls", String(runs.reduce((sum, run) => sum + run.calls.length, 0)), "made by these handlers")), element("div", {
|
|
1816
|
+
class: "toolbar",
|
|
1817
|
+
style: "margin-top: 8px"
|
|
1818
|
+
}, element("div", { class: "legend" }, element("span", {}, element("i", { style: "background: repeating-linear-gradient(45deg, var(--faint) 0 2px, transparent 2px 4px)" }), "waiting for code"), key("var(--blue)", "run"), key("#7cb7ff55", "its promise"), key("#ff9ecf88", "server call"), key("#ff9ecf", "on the server"), key("var(--green)", "updates")), element("span", { class: "spacer" }), clear), list);
|
|
1819
|
+
};
|
|
1820
|
+
const drawBlocks = () => {
|
|
1821
|
+
const blocks = [...state.blocks.values()];
|
|
1822
|
+
const table = element("table", { class: "rows" }, row([
|
|
1823
|
+
"block",
|
|
1824
|
+
"id",
|
|
1825
|
+
"trigger",
|
|
1826
|
+
"state",
|
|
1827
|
+
"fired",
|
|
1828
|
+
"rendered",
|
|
1829
|
+
""
|
|
1830
|
+
], "th"));
|
|
1831
|
+
for (const block of blocks) {
|
|
1832
|
+
const action = element("span");
|
|
1833
|
+
if (block.state === "waiting" && (block.kind === "defer" || block.kind === "client")) {
|
|
1834
|
+
const fire = iconButton("bolt", "Fire", { title: "Fire the trigger now" });
|
|
1835
|
+
fire.addEventListener("click", () => {
|
|
1836
|
+
state.fire?.(block);
|
|
1837
|
+
draw();
|
|
1838
|
+
});
|
|
1839
|
+
action.append(fire);
|
|
1840
|
+
}
|
|
1841
|
+
const kept = globalThis.$bD?.[block.id];
|
|
1842
|
+
if (block.state === "rendered" && kept && (block.kind === "loading" || block.kind === "defer")) {
|
|
1843
|
+
const toggle = iconButton(block.fallback ? "play" : "pause", block.fallback ? "Body" : "Fallback", {
|
|
1844
|
+
title: block.fallback ? "Show the body again" : "Show the fallback in place of the body",
|
|
1845
|
+
"aria-pressed": String(block.fallback === true)
|
|
1846
|
+
});
|
|
1847
|
+
toggle.addEventListener("click", () => {
|
|
1848
|
+
state.showFallback?.(block, !block.fallback);
|
|
1849
|
+
draw();
|
|
1850
|
+
});
|
|
1851
|
+
action.append(toggle);
|
|
1852
|
+
}
|
|
1853
|
+
let took = "";
|
|
1854
|
+
if (block.rendered !== void 0) took = block.fired === void 0 ? seconds(block.rendered) : `+${ms(block.rendered - block.fired)}`;
|
|
1855
|
+
table.append(row([
|
|
1856
|
+
pill(blockLabel(block), block.kind === "$client" ? "blue" : "accent"),
|
|
1857
|
+
element("span", { class: "mono" }, block.id),
|
|
1858
|
+
block.trigger ?? "",
|
|
1859
|
+
pill(block.state, STATE_COLORS[block.state]),
|
|
1860
|
+
block.fired === void 0 ? "" : seconds(block.fired),
|
|
1861
|
+
took,
|
|
1862
|
+
action
|
|
1863
|
+
]));
|
|
1864
|
+
}
|
|
1865
|
+
body.replaceChildren(element("h2", {}, "Blocks that render after the page"), element("p", {
|
|
1866
|
+
class: "sub",
|
|
1867
|
+
style: "margin-top: 0"
|
|
1868
|
+
}, "Streaming bodies come with the page. Waiting ones wait for their trigger, and Fire runs it now. Fallback shows the fallback of a body again, to check both sides."), blocks.length > 0 ? table : element("div", { class: "empty" }, "No blocks that render later on this page."));
|
|
1869
|
+
};
|
|
1870
|
+
const drawReport = async () => {
|
|
1871
|
+
const id = selected ?? roots()[0]?.m;
|
|
1872
|
+
const info = id ? await componentInfo(state, id) : void 0;
|
|
1873
|
+
body.replaceChildren(...info ? [element("div", { class: "toolbar" }, chooser(id), source(info)), element("pre", { class: "report" }, info.text)] : [element("div", { class: "empty" }, "No component yet.")]);
|
|
1874
|
+
};
|
|
1875
|
+
/** The draw of each tab that loads what it shows. Log and Blocks draw at once. */
|
|
1876
|
+
const drawTab = {
|
|
1877
|
+
overview: drawOverview,
|
|
1878
|
+
errors: drawErrors,
|
|
1879
|
+
scopes: drawScopes,
|
|
1880
|
+
elements: drawElements,
|
|
1881
|
+
loading: drawLoading,
|
|
1882
|
+
state: drawState,
|
|
1883
|
+
effects: drawEffects,
|
|
1884
|
+
navigation: drawNavigation,
|
|
1885
|
+
server: drawServer,
|
|
1886
|
+
timeline: drawTimeline,
|
|
1887
|
+
graph: drawGraph,
|
|
1888
|
+
report: drawReport
|
|
1889
|
+
};
|
|
1890
|
+
let queued = false;
|
|
1891
|
+
const draw = () => {
|
|
1892
|
+
drawChrome();
|
|
1893
|
+
if (tab === "log") {
|
|
1894
|
+
drawLog();
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
if (tab === "blocks") {
|
|
1898
|
+
drawBlocks();
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
const drawing = tab;
|
|
1902
|
+
drawTab[tab]().then(() => {
|
|
1903
|
+
if (tab !== drawing) {
|
|
1904
|
+
draw();
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1907
|
+
drawChrome();
|
|
1908
|
+
if (tab === "scopes") state.written.clear();
|
|
1909
|
+
});
|
|
1910
|
+
};
|
|
1911
|
+
state.changed = () => {
|
|
1912
|
+
const typing = root.activeElement?.matches?.("input[type=\"search\"]");
|
|
1913
|
+
if (!queued && !editing && !typing && !(paused && tab === "log")) {
|
|
1914
|
+
queued = true;
|
|
1915
|
+
requestAnimationFrame(() => {
|
|
1916
|
+
queued = false;
|
|
1917
|
+
if (panel) draw();
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
showTab = (next) => {
|
|
1922
|
+
tab = next;
|
|
1923
|
+
draw();
|
|
1924
|
+
};
|
|
1925
|
+
draw();
|
|
1926
|
+
}
|
|
1927
|
+
//#endregion
|
|
1928
|
+
export { layoutGraph, openPanel, togglePanel };
|
|
1929
|
+
|
|
1930
|
+
//# sourceMappingURL=devtools-panel-BVB-W5q4.js.map
|