@aevantec/litevue 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -853
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -717
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.iife.js +1 -12
- package/dist/litevue.mjs +1 -1890
- package/dist/litevue.umd.js +1 -12
- package/dist/plugins/collapse.iife.js +1 -1
- package/dist/plugins/collapse.mjs +1 -46
- package/dist/plugins/collapse.umd.js +1 -1
- package/dist/plugins/focus.iife.js +1 -1
- package/dist/plugins/focus.mjs +1 -69
- package/dist/plugins/focus.umd.js +1 -1
- package/dist/plugins/intersect.iife.js +1 -1
- package/dist/plugins/intersect.mjs +1 -20
- package/dist/plugins/intersect.umd.js +1 -1
- package/dist/plugins/mask.iife.js +1 -1
- package/dist/plugins/mask.mjs +1 -37
- package/dist/plugins/mask.umd.js +1 -1
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -204
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -174
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/plugins/persist.iife.js +1 -1
- package/dist/plugins/persist.mjs +1 -86
- package/dist/plugins/persist.umd.js +1 -1
- package/dist/plugins/resize.iife.js +1 -1
- package/dist/plugins/resize.mjs +1 -15
- package/dist/plugins/resize.umd.js +1 -1
- package/dist/plugins/transition.iife.js +1 -1
- package/dist/plugins/transition.mjs +1 -76
- package/dist/plugins/transition.umd.js +1 -1
- package/dist/types/app.d.mts +30 -2
- package/dist/types/app.d.ts +30 -2
- package/dist/types/block.d.mts +7 -0
- package/dist/types/block.d.ts +7 -0
- package/dist/types/context.d.mts +7 -0
- package/dist/types/context.d.ts +7 -0
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ownership.d.mts +30 -0
- package/dist/types/ownership.d.ts +30 -0
- package/dist/types/plugins/media/index.d.mts +0 -4
- package/dist/types/plugins/media/index.d.ts +0 -4
- package/dist/types/scheduler.d.mts +3 -0
- package/dist/types/scheduler.d.ts +3 -0
- package/dist/types/warn.d.mts +16 -0
- package/dist/types/warn.d.ts +16 -0
- package/package.json +15 -8
|
@@ -1,853 +1 @@
|
|
|
1
|
-
const css = `
|
|
2
|
-
:host {
|
|
3
|
-
all: initial;
|
|
4
|
-
--bg: #1e1e1e;
|
|
5
|
-
--bg2: #252526;
|
|
6
|
-
--hover: #2a2d2e;
|
|
7
|
-
--border: #3c3c3c;
|
|
8
|
-
--fg: #d4d4d4;
|
|
9
|
-
--muted: #808080;
|
|
10
|
-
--accent: #42b883;
|
|
11
|
-
--sel: #094771;
|
|
12
|
-
--key: #9cdcfe;
|
|
13
|
-
--val: #ce9178;
|
|
14
|
-
--exp: #6a9955;
|
|
15
|
-
}
|
|
16
|
-
:host(.light) {
|
|
17
|
-
--bg: #ffffff;
|
|
18
|
-
--bg2: #f3f3f3;
|
|
19
|
-
--hover: #ececec;
|
|
20
|
-
--border: #d0d0d0;
|
|
21
|
-
--fg: #383a42;
|
|
22
|
-
--muted: #8e8e90;
|
|
23
|
-
--sel: #d2e5f5;
|
|
24
|
-
--key: #0451a5;
|
|
25
|
-
--val: #a31515;
|
|
26
|
-
--exp: #22863a;
|
|
27
|
-
}
|
|
28
|
-
* {
|
|
29
|
-
box-sizing: border-box;
|
|
30
|
-
}
|
|
31
|
-
.pill, .panel {
|
|
32
|
-
position: fixed;
|
|
33
|
-
right: 12px;
|
|
34
|
-
bottom: 12px;
|
|
35
|
-
z-index: 2147483646;
|
|
36
|
-
font: 11px/1.5 ui-monospace, Menlo, Consolas, monospace;
|
|
37
|
-
color: var(--fg);
|
|
38
|
-
}
|
|
39
|
-
.pill {
|
|
40
|
-
background: var(--bg);
|
|
41
|
-
border: 1px solid var(--border);
|
|
42
|
-
border-radius: 999px;
|
|
43
|
-
padding: 4px 10px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
user-select: none;
|
|
46
|
-
}
|
|
47
|
-
.pill:hover {
|
|
48
|
-
border-color: var(--accent);
|
|
49
|
-
}
|
|
50
|
-
.panel {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
width: 640px;
|
|
54
|
-
max-width: calc(100vw - 24px);
|
|
55
|
-
height: 440px;
|
|
56
|
-
max-height: calc(100vh - 24px);
|
|
57
|
-
min-width: 320px;
|
|
58
|
-
min-height: 200px;
|
|
59
|
-
background: var(--bg);
|
|
60
|
-
border: 1px solid var(--border);
|
|
61
|
-
border-radius: 6px;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
resize: both;
|
|
64
|
-
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
|
|
65
|
-
}
|
|
66
|
-
.header {
|
|
67
|
-
display: flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
gap: 8px;
|
|
70
|
-
padding: 4px 8px;
|
|
71
|
-
background: var(--bg2);
|
|
72
|
-
border-bottom: 1px solid var(--border);
|
|
73
|
-
user-select: none;
|
|
74
|
-
cursor: move;
|
|
75
|
-
}
|
|
76
|
-
.title {
|
|
77
|
-
color: var(--accent);
|
|
78
|
-
font-weight: bold;
|
|
79
|
-
margin-right: auto;
|
|
80
|
-
}
|
|
81
|
-
.btn {
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
background: none;
|
|
85
|
-
border: 1px solid var(--border);
|
|
86
|
-
border-radius: 3px;
|
|
87
|
-
color: var(--fg);
|
|
88
|
-
font: inherit;
|
|
89
|
-
padding: 3px 7px;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
}
|
|
92
|
-
.btn svg {
|
|
93
|
-
display: block;
|
|
94
|
-
}
|
|
95
|
-
.btn:hover {
|
|
96
|
-
border-color: var(--accent);
|
|
97
|
-
}
|
|
98
|
-
.btn.active {
|
|
99
|
-
background: var(--accent);
|
|
100
|
-
border-color: var(--accent);
|
|
101
|
-
color: var(--bg);
|
|
102
|
-
}
|
|
103
|
-
.body {
|
|
104
|
-
display: flex;
|
|
105
|
-
flex: 1;
|
|
106
|
-
min-height: 0;
|
|
107
|
-
}
|
|
108
|
-
.side {
|
|
109
|
-
display: flex;
|
|
110
|
-
flex-direction: column;
|
|
111
|
-
width: 40%;
|
|
112
|
-
min-width: 0;
|
|
113
|
-
border-right: 1px solid var(--border);
|
|
114
|
-
}
|
|
115
|
-
.tabs {
|
|
116
|
-
display: flex;
|
|
117
|
-
border-bottom: 1px solid var(--border);
|
|
118
|
-
user-select: none;
|
|
119
|
-
}
|
|
120
|
-
.tab {
|
|
121
|
-
flex: 1;
|
|
122
|
-
padding: 4px 0;
|
|
123
|
-
text-align: center;
|
|
124
|
-
color: var(--muted);
|
|
125
|
-
border-bottom: 2px solid transparent;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
}
|
|
128
|
-
.tab:hover {
|
|
129
|
-
color: var(--fg);
|
|
130
|
-
}
|
|
131
|
-
.tab.active {
|
|
132
|
-
color: var(--fg);
|
|
133
|
-
border-bottom-color: var(--accent);
|
|
134
|
-
}
|
|
135
|
-
.filter {
|
|
136
|
-
margin: 6px 6px 2px;
|
|
137
|
-
background: var(--bg2);
|
|
138
|
-
border: 1px solid var(--border);
|
|
139
|
-
border-radius: 3px;
|
|
140
|
-
color: var(--fg);
|
|
141
|
-
font: inherit;
|
|
142
|
-
padding: 2px 6px;
|
|
143
|
-
outline: none;
|
|
144
|
-
}
|
|
145
|
-
.filter:focus {
|
|
146
|
-
border-color: var(--accent);
|
|
147
|
-
}
|
|
148
|
-
.filter::placeholder {
|
|
149
|
-
color: var(--muted);
|
|
150
|
-
}
|
|
151
|
-
.tree {
|
|
152
|
-
flex: 1;
|
|
153
|
-
overflow: auto;
|
|
154
|
-
padding: 4px 0;
|
|
155
|
-
}
|
|
156
|
-
.state {
|
|
157
|
-
flex: 1;
|
|
158
|
-
overflow: auto;
|
|
159
|
-
padding: 4px 0;
|
|
160
|
-
}
|
|
161
|
-
.row {
|
|
162
|
-
padding: 2px 8px;
|
|
163
|
-
white-space: nowrap;
|
|
164
|
-
overflow: hidden;
|
|
165
|
-
text-overflow: ellipsis;
|
|
166
|
-
cursor: pointer;
|
|
167
|
-
}
|
|
168
|
-
.row:hover {
|
|
169
|
-
background: var(--hover);
|
|
170
|
-
}
|
|
171
|
-
.row.sel {
|
|
172
|
-
background: var(--sel);
|
|
173
|
-
}
|
|
174
|
-
.row .name {
|
|
175
|
-
color: var(--key);
|
|
176
|
-
}
|
|
177
|
-
.row .punct {
|
|
178
|
-
color: var(--muted);
|
|
179
|
-
}
|
|
180
|
-
.row .exp {
|
|
181
|
-
color: var(--exp);
|
|
182
|
-
}
|
|
183
|
-
.prop {
|
|
184
|
-
display: flex;
|
|
185
|
-
gap: 6px;
|
|
186
|
-
padding: 2px 8px;
|
|
187
|
-
align-items: center;
|
|
188
|
-
}
|
|
189
|
-
.prop .key {
|
|
190
|
-
color: var(--key);
|
|
191
|
-
flex-shrink: 0;
|
|
192
|
-
}
|
|
193
|
-
.arrow {
|
|
194
|
-
width: 12px;
|
|
195
|
-
flex-shrink: 0;
|
|
196
|
-
color: var(--muted);
|
|
197
|
-
font-size: 9px;
|
|
198
|
-
transition: transform 0.1s;
|
|
199
|
-
}
|
|
200
|
-
.arrow.open {
|
|
201
|
-
transform: rotate(90deg);
|
|
202
|
-
}
|
|
203
|
-
.spacer {
|
|
204
|
-
width: 12px;
|
|
205
|
-
flex-shrink: 0;
|
|
206
|
-
}
|
|
207
|
-
.prop.toggle {
|
|
208
|
-
cursor: pointer;
|
|
209
|
-
user-select: none;
|
|
210
|
-
}
|
|
211
|
-
.prop.toggle:hover {
|
|
212
|
-
background: var(--hover);
|
|
213
|
-
}
|
|
214
|
-
.preview {
|
|
215
|
-
flex: 1;
|
|
216
|
-
min-width: 0;
|
|
217
|
-
color: var(--muted);
|
|
218
|
-
white-space: nowrap;
|
|
219
|
-
overflow: hidden;
|
|
220
|
-
text-overflow: ellipsis;
|
|
221
|
-
}
|
|
222
|
-
.muted {
|
|
223
|
-
color: var(--muted);
|
|
224
|
-
padding: 2px 8px;
|
|
225
|
-
}
|
|
226
|
-
.check {
|
|
227
|
-
margin: 0;
|
|
228
|
-
flex-shrink: 0;
|
|
229
|
-
accent-color: var(--accent);
|
|
230
|
-
cursor: pointer;
|
|
231
|
-
}
|
|
232
|
-
.del {
|
|
233
|
-
visibility: hidden;
|
|
234
|
-
flex-shrink: 0;
|
|
235
|
-
background: none;
|
|
236
|
-
border: none;
|
|
237
|
-
padding: 0 2px;
|
|
238
|
-
color: var(--muted);
|
|
239
|
-
font: inherit;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
}
|
|
242
|
-
.prop:hover .del {
|
|
243
|
-
visibility: visible;
|
|
244
|
-
}
|
|
245
|
-
.del:hover {
|
|
246
|
-
color: #e5534b;
|
|
247
|
-
}
|
|
248
|
-
.adder .key-in {
|
|
249
|
-
flex: 0 0 30%;
|
|
250
|
-
color: var(--key);
|
|
251
|
-
}
|
|
252
|
-
.adder input::placeholder {
|
|
253
|
-
color: var(--muted);
|
|
254
|
-
}
|
|
255
|
-
.adder input {
|
|
256
|
-
border-color: var(--border);
|
|
257
|
-
}
|
|
258
|
-
.bool {
|
|
259
|
-
color: var(--val);
|
|
260
|
-
}
|
|
261
|
-
.prop.inherited .key {
|
|
262
|
-
color: var(--muted);
|
|
263
|
-
}
|
|
264
|
-
.prop .val {
|
|
265
|
-
flex: 1;
|
|
266
|
-
min-width: 0;
|
|
267
|
-
background: none;
|
|
268
|
-
border: 1px solid transparent;
|
|
269
|
-
border-radius: 3px;
|
|
270
|
-
color: var(--val);
|
|
271
|
-
font: inherit;
|
|
272
|
-
padding: 0 3px;
|
|
273
|
-
white-space: nowrap;
|
|
274
|
-
overflow: hidden;
|
|
275
|
-
text-overflow: ellipsis;
|
|
276
|
-
}
|
|
277
|
-
input.val:hover, input.val:focus {
|
|
278
|
-
border-color: var(--border);
|
|
279
|
-
outline: none;
|
|
280
|
-
background: var(--bg2);
|
|
281
|
-
}
|
|
282
|
-
.divider {
|
|
283
|
-
padding: 4px 8px 1px;
|
|
284
|
-
color: var(--muted);
|
|
285
|
-
font-size: 10px;
|
|
286
|
-
text-transform: uppercase;
|
|
287
|
-
user-select: none;
|
|
288
|
-
}
|
|
289
|
-
.empty {
|
|
290
|
-
padding: 8px;
|
|
291
|
-
color: var(--muted);
|
|
292
|
-
}
|
|
293
|
-
.highlight {
|
|
294
|
-
position: fixed;
|
|
295
|
-
z-index: 2147483645;
|
|
296
|
-
background: rgba(66, 184, 131, 0.25);
|
|
297
|
-
border: 1px solid var(--accent);
|
|
298
|
-
pointer-events: none;
|
|
299
|
-
display: none;
|
|
300
|
-
}
|
|
301
|
-
`;
|
|
302
|
-
let devtools;
|
|
303
|
-
let shadow;
|
|
304
|
-
let panelEl;
|
|
305
|
-
let pillEl;
|
|
306
|
-
let treeEl;
|
|
307
|
-
let stateEl;
|
|
308
|
-
let pickBtn;
|
|
309
|
-
let themeBtn;
|
|
310
|
-
let highlightEl;
|
|
311
|
-
let selected = null;
|
|
312
|
-
let selectedStore = null;
|
|
313
|
-
let picking = false;
|
|
314
|
-
let filterText = "";
|
|
315
|
-
let activeTab = "Elements";
|
|
316
|
-
let elementsTab;
|
|
317
|
-
let storesTab;
|
|
318
|
-
const icon = (paths) => '<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">' + paths + "</svg>";
|
|
319
|
-
const THEME_KEY = "litevue-devtools-theme";
|
|
320
|
-
const UI_KEY = "litevue-devtools-ui";
|
|
321
|
-
const loadUi = () => {
|
|
322
|
-
try {
|
|
323
|
-
return JSON.parse(localStorage.getItem(UI_KEY) || "{}");
|
|
324
|
-
} catch {
|
|
325
|
-
return {};
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const saveUi = (patch) => {
|
|
329
|
-
try {
|
|
330
|
-
localStorage.setItem(UI_KEY, JSON.stringify({ ...loadUi(), ...patch }));
|
|
331
|
-
} catch {
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
const themeIcons = {
|
|
335
|
-
dark: icon('<path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z"/>'),
|
|
336
|
-
light: icon(
|
|
337
|
-
'<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.2" y1="4.2" x2="5.6" y2="5.6"/><line x1="18.4" y1="18.4" x2="19.8" y2="19.8"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.2" y1="19.8" x2="5.6" y2="18.4"/><line x1="18.4" y1="5.6" x2="19.8" y2="4.2"/>'
|
|
338
|
-
),
|
|
339
|
-
system: icon(
|
|
340
|
-
'<rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/>'
|
|
341
|
-
)
|
|
342
|
-
};
|
|
343
|
-
const nextTheme = {
|
|
344
|
-
dark: "light",
|
|
345
|
-
light: "system",
|
|
346
|
-
system: "dark"
|
|
347
|
-
};
|
|
348
|
-
let theme = "dark";
|
|
349
|
-
try {
|
|
350
|
-
const saved = localStorage.getItem(THEME_KEY);
|
|
351
|
-
if (saved === "light" || saved === "system") theme = saved;
|
|
352
|
-
} catch {
|
|
353
|
-
}
|
|
354
|
-
const prefersLight = matchMedia("(prefers-color-scheme: light)");
|
|
355
|
-
const applyTheme = () => {
|
|
356
|
-
const light = theme === "light" || theme === "system" && prefersLight.matches;
|
|
357
|
-
shadow.host.classList.toggle("light", light);
|
|
358
|
-
themeBtn.innerHTML = themeIcons[theme];
|
|
359
|
-
themeBtn.title = "theme: " + theme;
|
|
360
|
-
};
|
|
361
|
-
const expandedPaths = /* @__PURE__ */ new Set();
|
|
362
|
-
const h = (tag, className, text) => {
|
|
363
|
-
const el = document.createElement(tag);
|
|
364
|
-
el.className = className;
|
|
365
|
-
if (text != null) el.textContent = text;
|
|
366
|
-
return el;
|
|
367
|
-
};
|
|
368
|
-
const tagOf = (el) => {
|
|
369
|
-
const label = h("span", "label");
|
|
370
|
-
label.appendChild(h("span", "punct", "<"));
|
|
371
|
-
label.appendChild(h("span", "name", nameOf(el)));
|
|
372
|
-
label.appendChild(h("span", "punct", ">"));
|
|
373
|
-
return label;
|
|
374
|
-
};
|
|
375
|
-
const depthOf = (el) => {
|
|
376
|
-
let depth = 0;
|
|
377
|
-
let p = el.parentElement;
|
|
378
|
-
while (p) {
|
|
379
|
-
if (devtools.scopes.has(p)) depth++;
|
|
380
|
-
p = p.parentElement;
|
|
381
|
-
}
|
|
382
|
-
return depth;
|
|
383
|
-
};
|
|
384
|
-
const fmt = (v) => {
|
|
385
|
-
let s;
|
|
386
|
-
try {
|
|
387
|
-
s = v === void 0 ? "undefined" : JSON.stringify(v) ?? String(v);
|
|
388
|
-
} catch (e) {
|
|
389
|
-
s = String(v);
|
|
390
|
-
}
|
|
391
|
-
return s.length > 60 ? s.slice(0, 60) + "…" : s;
|
|
392
|
-
};
|
|
393
|
-
const coerce = (raw, old) => {
|
|
394
|
-
if (typeof old === "number") {
|
|
395
|
-
const n = parseFloat(raw);
|
|
396
|
-
return isNaN(n) ? raw : n;
|
|
397
|
-
}
|
|
398
|
-
return raw;
|
|
399
|
-
};
|
|
400
|
-
const descriptorOf = (o, key) => {
|
|
401
|
-
for (let t = o; t && t !== Object.prototype; t = Object.getPrototypeOf(t)) {
|
|
402
|
-
const d = Object.getOwnPropertyDescriptor(t, key);
|
|
403
|
-
if (d) return d;
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
const isReadOnly = (desc) => {
|
|
407
|
-
if (!desc) return false;
|
|
408
|
-
if (desc.get && !desc.set) return true;
|
|
409
|
-
const raw = desc.value;
|
|
410
|
-
return !!raw && raw.__v_isRef === true && raw.__v_isReadonly === true;
|
|
411
|
-
};
|
|
412
|
-
const collectProps = (scope) => {
|
|
413
|
-
const isData = (o, k) => k[0] !== "$" && typeof o[k] !== "function";
|
|
414
|
-
const own = Object.keys(scope).filter((k) => isData(scope, k));
|
|
415
|
-
const seen = new Set(own);
|
|
416
|
-
const inherited = [];
|
|
417
|
-
let proto = Object.getPrototypeOf(scope);
|
|
418
|
-
while (proto && proto !== Object.prototype) {
|
|
419
|
-
for (const k of Object.keys(proto)) {
|
|
420
|
-
if (!seen.has(k) && isData(proto, k)) {
|
|
421
|
-
seen.add(k);
|
|
422
|
-
inherited.push(k);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
proto = Object.getPrototypeOf(proto);
|
|
426
|
-
}
|
|
427
|
-
return { own, inherited };
|
|
428
|
-
};
|
|
429
|
-
const showHighlight = (el) => {
|
|
430
|
-
const r = el.getBoundingClientRect();
|
|
431
|
-
highlightEl.style.cssText = `display:block;left:${r.left}px;top:${r.top}px;width:${r.width}px;height:${r.height}px`;
|
|
432
|
-
};
|
|
433
|
-
const hideHighlight = () => {
|
|
434
|
-
highlightEl.style.display = "none";
|
|
435
|
-
};
|
|
436
|
-
const select = (el) => {
|
|
437
|
-
if (el !== selected) expandedPaths.clear();
|
|
438
|
-
selectedStore = null;
|
|
439
|
-
selected = el;
|
|
440
|
-
activeTab = "Elements";
|
|
441
|
-
window.$scope = el ? devtools.scopes.get(el) : void 0;
|
|
442
|
-
renderTree();
|
|
443
|
-
renderState();
|
|
444
|
-
};
|
|
445
|
-
const selectStore = (name) => {
|
|
446
|
-
if (name !== selectedStore) expandedPaths.clear();
|
|
447
|
-
selected = null;
|
|
448
|
-
selectedStore = name;
|
|
449
|
-
activeTab = "Stores";
|
|
450
|
-
window.$scope = devtools.stores.get(name);
|
|
451
|
-
renderTree();
|
|
452
|
-
renderState();
|
|
453
|
-
};
|
|
454
|
-
const switchTab = (tab) => {
|
|
455
|
-
activeTab = tab;
|
|
456
|
-
renderTree();
|
|
457
|
-
};
|
|
458
|
-
const nameOf = (el) => devtools.names.get(el) || el.id || el.tagName.toLowerCase();
|
|
459
|
-
const renderTabs = () => {
|
|
460
|
-
const storeCount = devtools.stores ? devtools.stores.size : 0;
|
|
461
|
-
elementsTab.textContent = `Elements (${devtools.scopes.size})`;
|
|
462
|
-
elementsTab.className = activeTab === "Elements" ? "tab active" : "tab";
|
|
463
|
-
storesTab.textContent = `Stores (${storeCount})`;
|
|
464
|
-
storesTab.className = activeTab === "Stores" ? "tab active" : "tab";
|
|
465
|
-
};
|
|
466
|
-
const renderTree = () => {
|
|
467
|
-
renderTabs();
|
|
468
|
-
treeEl.textContent = "";
|
|
469
|
-
if (activeTab === "Elements") {
|
|
470
|
-
const roots = [...devtools.scopes.keys()].filter((el) => nameOf(el).toLowerCase().includes(filterText)).sort(
|
|
471
|
-
(a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
|
|
472
|
-
);
|
|
473
|
-
if (!roots.length) {
|
|
474
|
-
treeEl.appendChild(
|
|
475
|
-
h(
|
|
476
|
-
"div",
|
|
477
|
-
"empty",
|
|
478
|
-
filterText ? "no matching scopes" : "no scopes mounted"
|
|
479
|
-
)
|
|
480
|
-
);
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
for (const el of roots) {
|
|
484
|
-
const row = h("div", el === selected ? "row sel" : "row");
|
|
485
|
-
row.style.paddingLeft = 8 + depthOf(el) * 12 + "px";
|
|
486
|
-
row.appendChild(tagOf(el));
|
|
487
|
-
const exp = devtools.exps.get(el);
|
|
488
|
-
if (exp) row.appendChild(h("span", "exp", " " + exp));
|
|
489
|
-
row.onclick = () => select(el);
|
|
490
|
-
row.onmouseenter = () => showHighlight(el);
|
|
491
|
-
row.onmouseleave = hideHighlight;
|
|
492
|
-
treeEl.appendChild(row);
|
|
493
|
-
}
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
const storeNames = [
|
|
497
|
-
...devtools.stores ? devtools.stores.keys() : []
|
|
498
|
-
].filter((n) => n.toLowerCase().includes(filterText));
|
|
499
|
-
if (!storeNames.length) {
|
|
500
|
-
treeEl.appendChild(
|
|
501
|
-
h(
|
|
502
|
-
"div",
|
|
503
|
-
"empty",
|
|
504
|
-
filterText ? "no matching stores" : "no stores registered"
|
|
505
|
-
)
|
|
506
|
-
);
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
for (const name of storeNames) {
|
|
510
|
-
const row = h("div", name === selectedStore ? "row sel" : "row");
|
|
511
|
-
const label = h("span", "label");
|
|
512
|
-
label.appendChild(h("span", "punct", "$store."));
|
|
513
|
-
label.appendChild(h("span", "name", name));
|
|
514
|
-
row.appendChild(label);
|
|
515
|
-
row.onclick = () => selectStore(name);
|
|
516
|
-
treeEl.appendChild(row);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
const renderState = () => {
|
|
520
|
-
if (stateEl.contains(shadow.activeElement)) return;
|
|
521
|
-
stateEl.textContent = "";
|
|
522
|
-
const scope = selectedStore ? devtools.stores.get(selectedStore) : selected ? devtools.scopes.get(selected) : void 0;
|
|
523
|
-
if (!scope) {
|
|
524
|
-
stateEl.appendChild(h("div", "empty", "Select a scope"));
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
const { own, inherited } = collectProps(scope);
|
|
528
|
-
own.forEach((k) => addNode(k, scope, k, 0, "prop", []));
|
|
529
|
-
if (inherited.length) {
|
|
530
|
-
stateEl.appendChild(h("div", "divider", "inherited"));
|
|
531
|
-
inherited.forEach((k) => addNode(k, scope, k, 0, "prop inherited", []));
|
|
532
|
-
}
|
|
533
|
-
if (!own.length && !inherited.length) {
|
|
534
|
-
stateEl.appendChild(h("div", "empty", "empty scope"));
|
|
535
|
-
}
|
|
536
|
-
stateEl.appendChild(buildAdder(scope));
|
|
537
|
-
};
|
|
538
|
-
const buildAdder = (scope) => {
|
|
539
|
-
const row = h("div", "prop adder");
|
|
540
|
-
row.appendChild(h("span", "spacer"));
|
|
541
|
-
const keyIn = h("input", "val key-in");
|
|
542
|
-
keyIn.placeholder = "key";
|
|
543
|
-
const valIn = h("input", "val");
|
|
544
|
-
valIn.placeholder = "value";
|
|
545
|
-
const commit = () => {
|
|
546
|
-
const k = keyIn.value.trim();
|
|
547
|
-
if (!k) return;
|
|
548
|
-
const raw = valIn.value;
|
|
549
|
-
let v = raw;
|
|
550
|
-
if (raw === "true") v = true;
|
|
551
|
-
else if (raw === "false") v = false;
|
|
552
|
-
else if (raw !== "" && !isNaN(+raw)) v = +raw;
|
|
553
|
-
scope[k] = v;
|
|
554
|
-
keyIn.blur();
|
|
555
|
-
valIn.blur();
|
|
556
|
-
scheduleRender();
|
|
557
|
-
setTimeout(() => {
|
|
558
|
-
const next = stateEl.querySelector(".adder .key-in");
|
|
559
|
-
if (next) next.focus();
|
|
560
|
-
});
|
|
561
|
-
};
|
|
562
|
-
keyIn.onkeydown = valIn.onkeydown = (e) => {
|
|
563
|
-
if (e.key === "Enter") commit();
|
|
564
|
-
};
|
|
565
|
-
row.appendChild(keyIn);
|
|
566
|
-
row.appendChild(valIn);
|
|
567
|
-
return row;
|
|
568
|
-
};
|
|
569
|
-
const previewOf = (v) => Array.isArray(v) ? `(${v.length}) ${fmt(v)}` : fmt(v);
|
|
570
|
-
const addNode = (key, container, path, depth, cls, ancestors) => {
|
|
571
|
-
const v = container[key];
|
|
572
|
-
const row = h("div", cls);
|
|
573
|
-
row.style.paddingLeft = 8 + depth * 14 + "px";
|
|
574
|
-
if (v !== null && typeof v === "object") {
|
|
575
|
-
const circular = ancestors.indexOf(v) > -1;
|
|
576
|
-
const open = !circular && expandedPaths.has(path);
|
|
577
|
-
row.appendChild(h("span", open ? "arrow open" : "arrow", "▶"));
|
|
578
|
-
row.appendChild(h("span", "key", key));
|
|
579
|
-
row.appendChild(
|
|
580
|
-
h("span", "preview", circular ? "(circular)" : previewOf(v))
|
|
581
|
-
);
|
|
582
|
-
if (!circular) {
|
|
583
|
-
row.classList.add("toggle");
|
|
584
|
-
row.onclick = () => {
|
|
585
|
-
open ? expandedPaths.delete(path) : expandedPaths.add(path);
|
|
586
|
-
renderState();
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
appendDelete(row, container, key, depth, cls);
|
|
590
|
-
stateEl.appendChild(row);
|
|
591
|
-
if (open) {
|
|
592
|
-
const keys = Object.keys(v);
|
|
593
|
-
if (!keys.length) {
|
|
594
|
-
const empty = h("div", "muted", "(empty)");
|
|
595
|
-
empty.style.paddingLeft = 22 + (depth + 1) * 14 + "px";
|
|
596
|
-
stateEl.appendChild(empty);
|
|
597
|
-
}
|
|
598
|
-
for (const k of keys) {
|
|
599
|
-
addNode(k, v, path + "." + k, depth + 1, cls, ancestors.concat([v]));
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
row.appendChild(h("span", "spacer"));
|
|
605
|
-
row.appendChild(h("span", "key", key));
|
|
606
|
-
const desc = descriptorOf(container, key);
|
|
607
|
-
if (typeof v === "function") {
|
|
608
|
-
row.appendChild(h("span", "preview", "ƒ"));
|
|
609
|
-
} else if (isReadOnly(desc)) {
|
|
610
|
-
row.appendChild(h("span", "preview", fmt(v)));
|
|
611
|
-
} else if (typeof v === "boolean") {
|
|
612
|
-
row.appendChild(h("span", "bool", String(v)));
|
|
613
|
-
const cb = h("input", "check");
|
|
614
|
-
cb.type = "checkbox";
|
|
615
|
-
cb.checked = v;
|
|
616
|
-
cb.onchange = () => {
|
|
617
|
-
container[key] = cb.checked;
|
|
618
|
-
cb.blur();
|
|
619
|
-
scheduleRender();
|
|
620
|
-
};
|
|
621
|
-
row.appendChild(cb);
|
|
622
|
-
} else {
|
|
623
|
-
const input = h("input", "val");
|
|
624
|
-
input.value = fmt(v);
|
|
625
|
-
input.onfocus = () => {
|
|
626
|
-
input.value = typeof v === "string" ? v : String(v);
|
|
627
|
-
};
|
|
628
|
-
input.onkeydown = (e) => {
|
|
629
|
-
if (e.key === "Enter") input.blur();
|
|
630
|
-
if (e.key === "Escape") {
|
|
631
|
-
input.value = fmt(v);
|
|
632
|
-
input.blur();
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
input.onblur = () => {
|
|
636
|
-
const next = coerce(input.value, v);
|
|
637
|
-
if (next !== v) {
|
|
638
|
-
container[key] = next;
|
|
639
|
-
scheduleRender();
|
|
640
|
-
} else {
|
|
641
|
-
input.value = fmt(v);
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
row.appendChild(input);
|
|
645
|
-
}
|
|
646
|
-
appendDelete(row, container, key, depth, cls);
|
|
647
|
-
stateEl.appendChild(row);
|
|
648
|
-
};
|
|
649
|
-
const appendDelete = (row, container, key, depth, cls) => {
|
|
650
|
-
if (depth !== 0 || cls !== "prop") return;
|
|
651
|
-
const desc = Object.getOwnPropertyDescriptor(container, key);
|
|
652
|
-
if (desc && desc.get) return;
|
|
653
|
-
const del = h("button", "del", "✕");
|
|
654
|
-
del.title = `delete "${key}"`;
|
|
655
|
-
del.onclick = (e) => {
|
|
656
|
-
e.stopPropagation();
|
|
657
|
-
const active = shadow.activeElement;
|
|
658
|
-
if (active && active.blur) active.blur();
|
|
659
|
-
delete container[key];
|
|
660
|
-
scheduleRender();
|
|
661
|
-
};
|
|
662
|
-
row.appendChild(del);
|
|
663
|
-
};
|
|
664
|
-
const onPickClick = (e) => {
|
|
665
|
-
const target = e.target;
|
|
666
|
-
if (target === shadow.host) return;
|
|
667
|
-
e.preventDefault();
|
|
668
|
-
e.stopPropagation();
|
|
669
|
-
stopPicking();
|
|
670
|
-
let el = target;
|
|
671
|
-
while (el && !devtools.scopes.has(el)) el = el.parentElement;
|
|
672
|
-
if (el) select(el);
|
|
673
|
-
};
|
|
674
|
-
const onPickMove = (e) => {
|
|
675
|
-
let el = e.target;
|
|
676
|
-
if (el === shadow.host) return;
|
|
677
|
-
while (el && !devtools.scopes.has(el)) el = el.parentElement;
|
|
678
|
-
el ? showHighlight(el) : hideHighlight();
|
|
679
|
-
};
|
|
680
|
-
const startPicking = () => {
|
|
681
|
-
picking = true;
|
|
682
|
-
pickBtn.classList.add("active");
|
|
683
|
-
document.addEventListener("click", onPickClick, true);
|
|
684
|
-
document.addEventListener("mousemove", onPickMove, true);
|
|
685
|
-
};
|
|
686
|
-
const stopPicking = () => {
|
|
687
|
-
picking = false;
|
|
688
|
-
pickBtn.classList.remove("active");
|
|
689
|
-
hideHighlight();
|
|
690
|
-
document.removeEventListener("click", onPickClick, true);
|
|
691
|
-
document.removeEventListener("mousemove", onPickMove, true);
|
|
692
|
-
};
|
|
693
|
-
let renderQueued = false;
|
|
694
|
-
const scheduleRender = () => {
|
|
695
|
-
if (renderQueued) return;
|
|
696
|
-
renderQueued = true;
|
|
697
|
-
setTimeout(() => {
|
|
698
|
-
renderQueued = false;
|
|
699
|
-
if (panelEl.style.display === "none") return;
|
|
700
|
-
renderTree();
|
|
701
|
-
renderState();
|
|
702
|
-
});
|
|
703
|
-
};
|
|
704
|
-
const build = () => {
|
|
705
|
-
const host = document.createElement("div");
|
|
706
|
-
shadow = host.attachShadow({ mode: "open" });
|
|
707
|
-
const style = document.createElement("style");
|
|
708
|
-
style.textContent = css;
|
|
709
|
-
shadow.appendChild(style);
|
|
710
|
-
highlightEl = h("div", "highlight");
|
|
711
|
-
shadow.appendChild(highlightEl);
|
|
712
|
-
pillEl = h("div", "pill", "⚡ LiteVue");
|
|
713
|
-
pillEl.onclick = () => {
|
|
714
|
-
pillEl.style.display = "none";
|
|
715
|
-
panelEl.style.display = "flex";
|
|
716
|
-
saveUi({ open: true });
|
|
717
|
-
scheduleRender();
|
|
718
|
-
};
|
|
719
|
-
shadow.appendChild(pillEl);
|
|
720
|
-
panelEl = h("div", "panel");
|
|
721
|
-
panelEl.style.display = "none";
|
|
722
|
-
const header = h("div", "header");
|
|
723
|
-
header.appendChild(h("span", "title", "⚡ LiteVue"));
|
|
724
|
-
header.addEventListener("mousedown", (e) => {
|
|
725
|
-
if (e.target.closest(".btn")) return;
|
|
726
|
-
e.preventDefault();
|
|
727
|
-
const rect = panelEl.getBoundingClientRect();
|
|
728
|
-
const startRight = window.innerWidth - rect.right;
|
|
729
|
-
const startBottom = window.innerHeight - rect.bottom;
|
|
730
|
-
const startX = e.clientX;
|
|
731
|
-
const startY = e.clientY;
|
|
732
|
-
const move = (ev) => {
|
|
733
|
-
panelEl.style.right = Math.max(0, startRight - (ev.clientX - startX)) + "px";
|
|
734
|
-
panelEl.style.bottom = Math.max(0, startBottom - (ev.clientY - startY)) + "px";
|
|
735
|
-
};
|
|
736
|
-
const up = () => {
|
|
737
|
-
document.removeEventListener("mousemove", move);
|
|
738
|
-
document.removeEventListener("mouseup", up);
|
|
739
|
-
saveUi({
|
|
740
|
-
right: parseInt(panelEl.style.right) || 12,
|
|
741
|
-
bottom: parseInt(panelEl.style.bottom) || 12
|
|
742
|
-
});
|
|
743
|
-
};
|
|
744
|
-
document.addEventListener("mousemove", move);
|
|
745
|
-
document.addEventListener("mouseup", up);
|
|
746
|
-
});
|
|
747
|
-
themeBtn = h("button", "btn");
|
|
748
|
-
themeBtn.onclick = () => {
|
|
749
|
-
theme = nextTheme[theme];
|
|
750
|
-
try {
|
|
751
|
-
localStorage.setItem(THEME_KEY, theme);
|
|
752
|
-
} catch {
|
|
753
|
-
}
|
|
754
|
-
applyTheme();
|
|
755
|
-
};
|
|
756
|
-
header.appendChild(themeBtn);
|
|
757
|
-
prefersLight.addEventListener("change", () => {
|
|
758
|
-
if (theme === "system") applyTheme();
|
|
759
|
-
});
|
|
760
|
-
applyTheme();
|
|
761
|
-
pickBtn = h("button", "btn");
|
|
762
|
-
pickBtn.title = "pick an element on the page";
|
|
763
|
-
pickBtn.innerHTML = icon(
|
|
764
|
-
'<circle cx="12" cy="12" r="7"/><line x1="12" y1="1" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="23"/><line x1="1" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="23" y2="12"/>'
|
|
765
|
-
);
|
|
766
|
-
pickBtn.onclick = () => picking ? stopPicking() : startPicking();
|
|
767
|
-
header.appendChild(pickBtn);
|
|
768
|
-
const closeBtn = h("button", "btn", "✕");
|
|
769
|
-
closeBtn.onclick = () => {
|
|
770
|
-
if (picking) stopPicking();
|
|
771
|
-
panelEl.style.display = "none";
|
|
772
|
-
pillEl.style.display = "";
|
|
773
|
-
saveUi({ open: false });
|
|
774
|
-
};
|
|
775
|
-
header.appendChild(closeBtn);
|
|
776
|
-
panelEl.appendChild(header);
|
|
777
|
-
const body = h("div", "body");
|
|
778
|
-
const side = h("div", "side");
|
|
779
|
-
const tabs = h("div", "tabs");
|
|
780
|
-
elementsTab = h("div", "tab active");
|
|
781
|
-
elementsTab.onclick = () => switchTab("Elements");
|
|
782
|
-
storesTab = h("div", "tab");
|
|
783
|
-
storesTab.onclick = () => switchTab("Stores");
|
|
784
|
-
tabs.appendChild(elementsTab);
|
|
785
|
-
tabs.appendChild(storesTab);
|
|
786
|
-
side.appendChild(tabs);
|
|
787
|
-
const filterInput = h("input", "filter");
|
|
788
|
-
filterInput.placeholder = "Filter by name";
|
|
789
|
-
filterInput.oninput = () => {
|
|
790
|
-
filterText = filterInput.value.trim().toLowerCase();
|
|
791
|
-
renderTree();
|
|
792
|
-
};
|
|
793
|
-
filterInput.onkeydown = (e) => {
|
|
794
|
-
if (e.key === "Escape") {
|
|
795
|
-
filterInput.value = "";
|
|
796
|
-
filterText = "";
|
|
797
|
-
renderTree();
|
|
798
|
-
}
|
|
799
|
-
};
|
|
800
|
-
side.appendChild(filterInput);
|
|
801
|
-
treeEl = h("div", "tree");
|
|
802
|
-
side.appendChild(treeEl);
|
|
803
|
-
stateEl = h("div", "state");
|
|
804
|
-
body.appendChild(side);
|
|
805
|
-
body.appendChild(stateEl);
|
|
806
|
-
panelEl.appendChild(body);
|
|
807
|
-
shadow.appendChild(panelEl);
|
|
808
|
-
const ui = loadUi();
|
|
809
|
-
if (ui.right != null) panelEl.style.right = ui.right + "px";
|
|
810
|
-
if (ui.bottom != null) panelEl.style.bottom = ui.bottom + "px";
|
|
811
|
-
if (ui.w) panelEl.style.width = ui.w + "px";
|
|
812
|
-
if (ui.h) panelEl.style.height = ui.h + "px";
|
|
813
|
-
if (ui.open) {
|
|
814
|
-
pillEl.style.display = "none";
|
|
815
|
-
panelEl.style.display = "flex";
|
|
816
|
-
scheduleRender();
|
|
817
|
-
}
|
|
818
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
819
|
-
let t;
|
|
820
|
-
new ResizeObserver(() => {
|
|
821
|
-
clearTimeout(t);
|
|
822
|
-
t = setTimeout(() => {
|
|
823
|
-
if (panelEl.style.display !== "none" && panelEl.offsetWidth) {
|
|
824
|
-
saveUi({ w: panelEl.offsetWidth, h: panelEl.offsetHeight });
|
|
825
|
-
}
|
|
826
|
-
}, 300);
|
|
827
|
-
}).observe(panelEl);
|
|
828
|
-
}
|
|
829
|
-
document.body.appendChild(host);
|
|
830
|
-
devtools.on("scope:mount", scheduleRender);
|
|
831
|
-
devtools.on("scope:unmount", (el) => {
|
|
832
|
-
if (el === selected) selected = null;
|
|
833
|
-
scheduleRender();
|
|
834
|
-
});
|
|
835
|
-
if (devtools.stores) {
|
|
836
|
-
devtools.on("store:register", scheduleRender);
|
|
837
|
-
}
|
|
838
|
-
devtools.on("flush", scheduleRender);
|
|
839
|
-
};
|
|
840
|
-
const init = () => {
|
|
841
|
-
const d = window.__LITE_VUE__;
|
|
842
|
-
if (!d) {
|
|
843
|
-
console.warn(
|
|
844
|
-
"[LiteVue devtools] window.__LITE_VUE__ not found — load LiteVue before the devtools panel script."
|
|
845
|
-
);
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
devtools = d;
|
|
849
|
-
document.body ? build() : addEventListener("DOMContentLoaded", build);
|
|
850
|
-
};
|
|
851
|
-
init();
|
|
852
|
-
|
|
853
|
-
export { init };
|
|
1
|
+
var e,n,t,o,r,i,l,d,a,s,p,c,h=null,u=null,g=!1,f="",v="Elements",x="float",b="",y="",m="",w="",k=e=>'<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">'+e+"</svg>",C="litevue-devtools-theme",L="litevue-devtools-ui",E=()=>{try{return JSON.parse(localStorage.getItem(L)||"{}")}catch{return{}}},O=e=>{try{localStorage.setItem(L,JSON.stringify({...E(),...e}))}catch{}},S={dark:k('<path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z"/>'),light:k('<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.2" y1="4.2" x2="5.6" y2="5.6"/><line x1="18.4" y1="18.4" x2="19.8" y2="19.8"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.2" y1="19.8" x2="5.6" y2="18.4"/><line x1="18.4" y1="5.6" x2="19.8" y2="4.2"/>'),system:k('<rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/>')},_={float:k('<rect x="2" y="4" width="14" height="11" rx="1"/><rect x="9" y="10" width="13" height="10" rx="1" fill="currentColor"/>'),bottom:k('<rect x="2" y="3" width="20" height="18" rx="1"/><rect x="2" y="14" width="20" height="7" fill="currentColor"/>'),right:k('<rect x="2" y="3" width="20" height="18" rx="1"/><rect x="14" y="3" width="8" height="18" fill="currentColor"/>')},z={float:"bottom",bottom:"right",right:"float"},$={float:"floating",bottom:"docked to bottom",right:"docked to right"},M={dark:"light",light:"system",system:"dark"},N="dark";try{const e=localStorage.getItem(C);"light"!==e&&"system"!==e||(N=e)}catch{}var j=matchMedia("(prefers-color-scheme: light)"),T=()=>{const e="light"===N||"system"===N&&j.matches;n.host.classList.toggle("light",e),d.innerHTML=S[N],d.title="theme: "+N},I=/* @__PURE__ */new Set,P=/* @__PURE__ */new WeakSet,D=e=>{"float"===x&&(b=t.style.width||b,y=t.style.height||y,m=t.style.right||m,w=t.style.bottom||w),x=e;const n="float"!==e;t.classList.toggle("dock-bottom","bottom"===e),t.classList.toggle("dock-right","right"===e),t.style.right=n?"":m,t.style.bottom=n?"":w,t.style.width="bottom"===e?"":b,t.style.height="right"===e?"":y,s.innerHTML=_[e],s.title="panel: "+$[e]},R=(e,n,t)=>{const o=document.createElement(e);return o.className=n,null!=t&&(o.textContent=t),o},V=e=>{const n=R("span","label");return n.appendChild(R("span","punct","<")),n.appendChild(R("span","name",Y(e))),n.appendChild(R("span","punct",">")),n},H=n=>{let t=n.parentElement;for(;t;){if(e.scopes.has(t))return t;t=t.parentElement}return null},W=(e,n)=>{const t=/* @__PURE__ */new Set,o=(e,r,i)=>{if(null!=e){if("object"!=typeof e)return String(e).toLowerCase().includes(n)?r:void 0;if(i>4||t.has(e))return;t.add(e);for(const t of Object.keys(e)){if("$"===t[0])continue;let l;try{l=e[t]}catch{continue}if("function"==typeof l)continue;const d=r?`${r}.${t}`:t;if(t.toLowerCase().includes(n))return d;const a=o(l,d,i+1);if(a)return a}}};return o(e,"",0)},A=e=>{let n;try{n=void 0===e?"undefined":JSON.stringify(e)??String(e)}catch(t){n=String(e)}return n.length>60?n.slice(0,60)+"\u2026":n},B=e=>{const n=e.getBoundingClientRect();a.style.cssText=`display:block;left:${n.left}px;top:${n.top}px;width:${n.width}px;height:${n.height}px`},F=()=>{a.style.display="none"},J=n=>{n!==h&&I.clear(),u=null,h=n,v="Elements",window.$scope=n?e.scopes.get(n):void 0,q(),G()},U=n=>{n!==u&&I.clear(),h=null,u=n,v="Stores",window.$scope=e.stores.get(n),q(),G()},X=e=>{v=e,q()},Y=n=>e.names.get(n)||n.id||n.tagName.toLowerCase(),q=()=>{if((()=>{const n=e.stores?e.stores.size:0;p.textContent=`Elements (${e.scopes.size})`,p.className="Elements"===v?"tab active":"tab",c.textContent=`Stores (${n})`,c.className="Stores"===v?"tab active":"tab"})(),r.textContent="","Elements"===v){const n=[...e.scopes.keys()].sort((e,n)=>e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),t=/* @__PURE__ */new Map;for(const r of n)if(!f||Y(r).toLowerCase().includes(f))t.set(r,void 0);else{const n=W(e.scopes.get(r),f);n&&t.set(r,n)}if(!t.size)return void r.appendChild(R("div","empty",f?"no matching scopes":"no scopes mounted"));const o=/* @__PURE__ */new Set;for(const e of t.keys()){o.add(e);for(let n=H(e);n;n=H(n))o.add(n)}const i=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(const e of n){if(!o.has(e))continue;const n=H(e);i.set(e,n),d.set(e,n?(d.get(n)??0)+1:0),n&&l.set(n,(l.get(n)||0)+1)}const a=e=>{for(let n=i.get(e);n;n=i.get(n)??null)if(P.has(n))return!0;return!1};for(const s of n){if(!o.has(s)||a(s))continue;const n=R("div",s===h?"row sel":"row");n.style.paddingLeft=8+12*(d.get(s)??0)+"px";const i=P.has(s);if(l.get(s)){const e=R("span",i?"arrow":"arrow open","\u25b6");e.onclick=e=>{e.stopPropagation(),i?P.delete(s):P.add(s),q()},n.appendChild(e)}else n.appendChild(R("span","spacer"));n.appendChild(V(s));const p=e.exps.get(s);p&&n.appendChild(R("span","exp"," "+p));const c=t.get(s);c&&n.appendChild(R("span","hit"," "+c)),n.onclick=()=>J(s),n.onmouseenter=()=>B(s),n.onmouseleave=F,r.appendChild(n)}return}const n=/* @__PURE__ */new Map;for(const o of e.stores?e.stores.keys():[])if(!f||o.toLowerCase().includes(f))n.set(o,void 0);else{const t=W(e.stores.get(o),f);t&&n.set(o,t)}const t=[...n.keys()];if(t.length)for(const e of t){const t=R("div",e===u?"row sel":"row"),o=R("span","label");o.appendChild(R("span","punct","$store.")),o.appendChild(R("span","name",e)),t.appendChild(o);const i=n.get(e);i&&t.appendChild(R("span","hit"," "+i)),t.onclick=()=>U(e),r.appendChild(t)}else r.appendChild(R("div","empty",f?"no matching stores":"no stores registered"))},G=()=>{if(i.contains(n.activeElement))return;i.textContent="";const t=u?e.stores.get(u):h?e.scopes.get(h):void 0;if(!t)return void i.appendChild(R("div","empty","Select a scope"));const{own:o,inherited:r}=(e=>{const n=(e,n)=>"$"!==n[0]&&"function"!=typeof e[n],t=Object.keys(e).filter(t=>n(e,t)),o=new Set(t),r=[];let i=Object.getPrototypeOf(e);for(;i&&i!==Object.prototype;){for(const e of Object.keys(i))!o.has(e)&&n(i,e)&&(o.add(e),r.push(e));i=Object.getPrototypeOf(i)}return{own:t,inherited:r}})(t);o.forEach(e=>Q(e,t,e,0,"prop",[])),r.length&&(i.appendChild(R("div","divider","inherited")),r.forEach(e=>Q(e,t,e,0,"prop inherited",[]))),o.length||r.length||i.appendChild(R("div","empty","empty scope")),i.appendChild(K(t))},K=e=>{const n=R("div","prop adder");n.appendChild(R("span","spacer"));const t=R("input","val key-in");t.placeholder="key";const o=R("input","val");o.placeholder="value";return t.onkeydown=o.onkeydown=n=>{"Enter"===n.key&&(()=>{const n=t.value.trim();if(!n)return;const r=o.value;let l=r;"true"===r?l=!0:"false"===r?l=!1:""===r||isNaN(+r)||(l=+r),e[n]=l,t.blur(),o.blur(),re(),setTimeout(()=>{const e=i.querySelector(".adder .key-in");e&&e.focus()})})()},n.appendChild(t),n.appendChild(o),n},Q=(e,n,t,o,r,l)=>{const d=n[e],a=R("div",r);if(a.style.paddingLeft=8+14*o+"px",null!==d&&"object"==typeof d){const s=l.indexOf(d)>-1,p=!s&&I.has(t);if(a.appendChild(R("span",p?"arrow open":"arrow","\u25b6")),a.appendChild(R("span","key",e)),a.appendChild(R("span","preview",s?"(circular)":(e=>Array.isArray(e)?`(${e.length}) ${A(e)}`:A(e))(d))),s||(a.classList.add("toggle"),a.onclick=()=>{p?I.delete(t):I.add(t),G()}),Z(a,n,e,o,r),i.appendChild(a),p){const e=Object.keys(d);if(!e.length){const e=R("div","muted","(empty)");e.style.paddingLeft=22+14*(o+1)+"px",i.appendChild(e)}for(const n of e)Q(n,d,t+"."+n,o+1,r,l.concat([d]))}return}a.appendChild(R("span","spacer")),a.appendChild(R("span","key",e));const s=((e,n)=>{for(let t=e;t&&t!==Object.prototype;t=Object.getPrototypeOf(t)){const e=Object.getOwnPropertyDescriptor(t,n);if(e)return e}})(n,e);if("function"==typeof d)a.appendChild(R("span","preview","\u0192"));else if((e=>{if(!e)return!1;if(e.get&&!e.set)return!0;const n=e.value;return!!n&&!0===n.__v_isRef&&!0===n.__v_isReadonly})(s))a.appendChild(R("span","preview",A(d)));else if("boolean"==typeof d){a.appendChild(R("span","bool",String(d)));const t=R("input","check");t.type="checkbox",t.checked=d,t.onchange=()=>{n[e]=t.checked,t.blur(),re()},a.appendChild(t)}else{const t=R("input","val");t.value=A(d),t.onfocus=()=>{t.value="string"==typeof d?d:String(d)},t.onkeydown=e=>{"Enter"===e.key&&t.blur(),"Escape"===e.key&&(t.value=A(d),t.blur())},t.onblur=()=>{const o=((e,n)=>{if("number"==typeof n){const n=parseFloat(e);return isNaN(n)?e:n}return e})(t.value,d);o!==d?(n[e]=o,re()):t.value=A(d)},a.appendChild(t)}Z(a,n,e,o,r),i.appendChild(a)},Z=(e,t,o,r,i)=>{if(0!==r||"prop"!==i)return;const l=Object.getOwnPropertyDescriptor(t,o);if(l&&l.get)return;const d=R("button","del","\u2715");d.title=`delete "${o}"`,d.onclick=e=>{e.stopPropagation();const r=n.activeElement;r&&r.blur&&r.blur(),delete t[o],re()},e.appendChild(d)},ee=t=>{const o=t.target;if(o===n.host)return;t.preventDefault(),t.stopPropagation(),te();let r=o;for(;r&&!e.scopes.has(r);)r=r.parentElement;r&&J(r)},ne=t=>{let o=t.target;if(o!==n.host){for(;o&&!e.scopes.has(o);)o=o.parentElement;o?B(o):F()}},te=()=>{g=!1,l.classList.remove("active"),F(),document.removeEventListener("click",ee,!0),document.removeEventListener("mousemove",ne,!0)},oe=!1,re=()=>{oe||(oe=!0,setTimeout(()=>{oe=!1,"none"!==t.style.display&&(q(),G())}))},ie=()=>{const u=document.createElement("div");n=u.attachShadow({mode:"open"});const v=document.createElement("style");v.textContent="\n:host {\n all: initial;\n --bg: #1e1e1e;\n --bg2: #252526;\n --hover: #2a2d2e;\n --border: #3c3c3c;\n --fg: #d4d4d4;\n --muted: #808080;\n --accent: #42b883;\n --sel: #094771;\n --key: #9cdcfe;\n --val: #ce9178;\n --exp: #6a9955;\n}\n:host(.light) {\n --bg: #ffffff;\n --bg2: #f3f3f3;\n --hover: #ececec;\n --border: #d0d0d0;\n --fg: #383a42;\n --muted: #8e8e90;\n --sel: #d2e5f5;\n --key: #0451a5;\n --val: #a31515;\n --exp: #22863a;\n}\n* {\n box-sizing: border-box;\n}\n.pill, .panel {\n position: fixed;\n right: 12px;\n bottom: 12px;\n z-index: 2147483646;\n font: 11px/1.5 ui-monospace, Menlo, Consolas, monospace;\n color: var(--fg);\n}\n.pill {\n background: var(--bg);\n border: 1px solid var(--border);\n border-radius: 999px;\n padding: 4px 10px;\n cursor: pointer;\n user-select: none;\n}\n.pill:hover {\n border-color: var(--accent);\n}\n.panel {\n display: flex;\n flex-direction: column;\n width: 640px;\n max-width: calc(100vw - 24px);\n height: 440px;\n max-height: calc(100vh - 24px);\n min-width: 320px;\n min-height: 320px;\n background: var(--bg);\n border: 1px solid var(--border);\n border-radius: 6px;\n overflow: hidden;\n resize: both;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);\n}\n.panel.dock-bottom {\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n max-width: none;\n border-radius: 0;\n border-left: 0;\n border-right: 0;\n border-bottom: 0;\n resize: vertical;\n}\n.panel.dock-right {\n top: 0;\n right: 0;\n bottom: 0;\n height: 100%;\n max-height: none;\n border-radius: 0;\n border-top: 0;\n border-right: 0;\n border-bottom: 0;\n resize: horizontal;\n}\n.panel.dock-bottom .header,\n.panel.dock-right .header {\n cursor: default;\n}\n.header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 4px 8px;\n background: var(--bg2);\n border-bottom: 1px solid var(--border);\n user-select: none;\n cursor: move;\n}\n.title {\n color: var(--accent);\n font-weight: bold;\n margin-right: auto;\n}\n.btn {\n display: flex;\n align-items: center;\n background: none;\n border: 1px solid var(--border);\n border-radius: 3px;\n color: var(--fg);\n font: inherit;\n padding: 3px 7px;\n cursor: pointer;\n}\n.btn svg {\n display: block;\n}\n.btn:hover {\n border-color: var(--accent);\n}\n.btn.active {\n background: var(--accent);\n border-color: var(--accent);\n color: var(--bg);\n}\n.body {\n display: flex;\n flex: 1;\n min-height: 0;\n}\n.side {\n display: flex;\n flex-direction: column;\n width: 40%;\n min-width: 0;\n border-right: 1px solid var(--border);\n}\n.tabs {\n display: flex;\n border-bottom: 1px solid var(--border);\n user-select: none;\n}\n.tab {\n flex: 1;\n padding: 4px 0;\n text-align: center;\n color: var(--muted);\n border-bottom: 2px solid transparent;\n cursor: pointer;\n}\n.tab:hover {\n color: var(--fg);\n}\n.tab.active {\n color: var(--fg);\n border-bottom-color: var(--accent);\n}\n.filter {\n margin: 6px 6px 2px;\n background: var(--bg2);\n border: 1px solid var(--border);\n border-radius: 3px;\n color: var(--fg);\n font: inherit;\n padding: 2px 6px;\n outline: none;\n}\n.filter:focus {\n border-color: var(--accent);\n}\n.filter::placeholder {\n color: var(--muted);\n}\n.tree {\n flex: 1;\n overflow: auto;\n padding: 4px 0;\n}\n.state {\n flex: 1;\n overflow: auto;\n padding: 4px 0;\n}\n.row {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 2px 8px;\n white-space: nowrap;\n overflow: hidden;\n cursor: pointer;\n}\n.row .label {\n flex-shrink: 0;\n}\n.row .arrow {\n cursor: pointer;\n padding: 3px 4px;\n margin: -3px -4px;\n box-sizing: content-box;\n}\n.row .arrow:hover {\n color: var(--key);\n}\n.row .hit {\n color: var(--exp);\n opacity: 0.75;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.row:hover {\n background: var(--hover);\n}\n.row.sel {\n background: var(--sel);\n}\n.row .name {\n color: var(--key);\n}\n.row .punct {\n color: var(--muted);\n}\n.row .exp {\n color: var(--exp);\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.prop {\n display: flex;\n gap: 6px;\n padding: 2px 8px;\n align-items: center;\n}\n.prop .key {\n color: var(--key);\n flex-shrink: 0;\n}\n.arrow {\n width: 12px;\n flex-shrink: 0;\n color: var(--muted);\n font-size: 9px;\n transition: transform 0.1s;\n}\n.arrow.open {\n transform: rotate(90deg);\n}\n.spacer {\n width: 12px;\n flex-shrink: 0;\n}\n.prop.toggle {\n cursor: pointer;\n user-select: none;\n}\n.prop.toggle:hover {\n background: var(--hover);\n}\n.preview {\n flex: 1;\n min-width: 0;\n color: var(--muted);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.muted {\n color: var(--muted);\n padding: 2px 8px;\n}\n.check {\n margin: 0;\n flex-shrink: 0;\n accent-color: var(--accent);\n cursor: pointer;\n}\n.del {\n visibility: hidden;\n flex-shrink: 0;\n background: none;\n border: none;\n padding: 0 2px;\n color: var(--muted);\n font: inherit;\n cursor: pointer;\n}\n.prop:hover .del {\n visibility: visible;\n}\n.del:hover {\n color: #e5534b;\n}\n.adder .key-in {\n flex: 0 0 30%;\n color: var(--key);\n}\n.adder input::placeholder {\n color: var(--muted);\n}\n.adder input {\n border-color: var(--border);\n}\n.bool {\n color: var(--val);\n}\n.prop.inherited .key {\n color: var(--muted);\n}\n.prop .val {\n flex: 1;\n min-width: 0;\n background: none;\n border: 1px solid transparent;\n border-radius: 3px;\n color: var(--val);\n font: inherit;\n padding: 0 3px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\ninput.val:hover, input.val:focus {\n border-color: var(--border);\n outline: none;\n background: var(--bg2);\n}\n.divider {\n padding: 4px 8px 1px;\n color: var(--muted);\n font-size: 10px;\n text-transform: uppercase;\n user-select: none;\n}\n.empty {\n padding: 8px;\n color: var(--muted);\n}\n.highlight {\n position: fixed;\n z-index: 2147483645;\n background: rgba(66, 184, 131, 0.25);\n border: 1px solid var(--accent);\n pointer-events: none;\n display: none;\n}\n",n.appendChild(v),a=R("div","highlight"),n.appendChild(a),(o=R("div","pill","\u26a1 LiteVue")).onclick=()=>{o.style.display="none",t.style.display="flex",O({open:!0}),re()},n.appendChild(o),(t=R("div","panel")).style.display="none";const L=R("div","header");L.appendChild(R("span","title","\u26a1 LiteVue")),L.addEventListener("mousedown",e=>{if(e.target.closest(".btn"))return;if("float"!==x)return;e.preventDefault();const n=t.getBoundingClientRect(),o=window.innerWidth-n.right,r=window.innerHeight-n.bottom,i=e.clientX,l=e.clientY,d=e=>{t.style.right=Math.max(0,o-(e.clientX-i))+"px",t.style.bottom=Math.max(0,r-(e.clientY-l))+"px"},a=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",a),O({right:parseInt(t.style.right)||12,bottom:parseInt(t.style.bottom)||12})};document.addEventListener("mousemove",d),document.addEventListener("mouseup",a)}),(s=R("button","btn")).onclick=()=>{D(z[x]),O({dock:x})},L.appendChild(s),(d=R("button","btn")).onclick=()=>{N=M[N];try{localStorage.setItem(C,N)}catch{}T()},L.appendChild(d),j.addEventListener("change",()=>{"system"===N&&T()}),T(),(l=R("button","btn")).title="pick an element on the page",l.innerHTML=k('<circle cx="12" cy="12" r="7"/><line x1="12" y1="1" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="23"/><line x1="1" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="23" y2="12"/>'),l.onclick=()=>g?te():(g=!0,l.classList.add("active"),document.addEventListener("click",ee,!0),void document.addEventListener("mousemove",ne,!0)),L.appendChild(l);const S=R("button","btn","\u2715");S.onclick=()=>{g&&te(),t.style.display="none",o.style.display="",O({open:!1})},L.appendChild(S),t.appendChild(L);const _=R("div","body"),$=R("div","side"),I=R("div","tabs");(p=R("div","tab active")).onclick=()=>X("Elements"),(c=R("div","tab")).onclick=()=>X("Stores"),I.appendChild(p),I.appendChild(c),$.appendChild(I);const P=R("input","filter");P.placeholder="Filter by name or state",P.oninput=()=>{f=P.value.trim().toLowerCase(),q()},P.onkeydown=e=>{"Escape"===e.key&&(P.value="",f="",q())},$.appendChild(P),r=R("div","tree"),$.appendChild(r),i=R("div","state"),_.appendChild($),_.appendChild(i),t.appendChild(_),n.appendChild(t);const V=E();if(null!=V.right&&(m=t.style.right=V.right+"px"),null!=V.bottom&&(w=t.style.bottom=V.bottom+"px"),V.w&&(b=t.style.width=V.w+"px"),V.h&&(y=t.style.height=V.h+"px"),D(V.dock||"float"),V.open&&(o.style.display="none",t.style.display="flex",re()),"undefined"!=typeof ResizeObserver){let e;new ResizeObserver(()=>{clearTimeout(e),e=setTimeout(()=>{"none"!==t.style.display&&t.offsetWidth&&O({..."bottom"!==x&&{w:t.offsetWidth},..."right"!==x&&{h:t.offsetHeight}})},300)}).observe(t)}document.body.appendChild(u),e.on("scope:mount",re),e.on("scope:unmount",e=>{e===h&&(h=null),re()}),e.stores&&e.on("store:register",re),e.on("flush",re)},le=()=>{const n=window.__LITE_VUE__;n?(e=n,document.body?ie():addEventListener("DOMContentLoaded",ie)):console.warn("[LiteVue devtools] window.__LITE_VUE__ not found \u2014 load LiteVue before the devtools panel script.")};le();export{le as init};
|