@chuvenger/devdock 0.5.0 → 0.7.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/README.md +200 -12
- package/dist/{chunk-3MVFATRN.js → chunk-2IQRWZ7T.js} +3 -3
- package/dist/{chunk-3MVFATRN.js.map → chunk-2IQRWZ7T.js.map} +1 -1
- package/dist/{chunk-NXZNFF34.js → chunk-2YX4DI2D.js} +253 -145
- package/dist/chunk-2YX4DI2D.js.map +1 -0
- package/dist/{dock-d3HqT25k.d.cts → dock-C7wZ8pQb.d.cts} +1 -1
- package/dist/{dock-P6l6pKjS.d.ts → dock-DJZuGmih.d.ts} +1 -1
- package/dist/index.cjs +253 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/{match-DwGIF1Xt.d.ts → match-C8MsaP6h.d.ts} +1 -1
- package/dist/{match-DDSJIRYW.d.cts → match-Dw1CSS0G.d.cts} +1 -1
- package/dist/react-router.cjs +348 -148
- package/dist/react-router.cjs.map +1 -1
- package/dist/react-router.d.cts +59 -11
- package/dist/react-router.d.ts +59 -11
- package/dist/react-router.js +101 -8
- package/dist/react-router.js.map +1 -1
- package/dist/react.cjs +250 -143
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +2 -2
- package/dist/svelte.cjs +253 -143
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.d.cts +4 -3
- package/dist/svelte.d.ts +4 -3
- package/dist/svelte.js +2 -2
- package/dist/svelte.js.map +1 -1
- package/dist/sveltekit.cjs +253 -143
- package/dist/sveltekit.cjs.map +1 -1
- package/dist/sveltekit.d.cts +5 -4
- package/dist/sveltekit.d.ts +5 -4
- package/dist/sveltekit.js +2 -2
- package/dist/{types-B_SpF32A.d.cts → types-B8WgSe7o.d.cts} +103 -3
- package/dist/{types-B_SpF32A.d.ts → types-B8WgSe7o.d.ts} +103 -3
- package/package.json +4 -1
- package/dist/chunk-NXZNFF34.js.map +0 -1
package/dist/svelte.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var cn = require('cn');
|
|
4
|
+
|
|
5
|
+
// src/core/dock.ts
|
|
6
|
+
|
|
3
7
|
// src/core/hotkey.ts
|
|
4
8
|
function matchHotkey(spec, e) {
|
|
5
9
|
const parts = spec.toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
|
|
@@ -18,6 +22,188 @@ function matchHotkey(spec, e) {
|
|
|
18
22
|
return e.key.toLowerCase() === key;
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
// src/core/theme.ts
|
|
26
|
+
var partClass = {
|
|
27
|
+
root: "devdock-root",
|
|
28
|
+
button: "devdock-button",
|
|
29
|
+
dot: "devdock-dot",
|
|
30
|
+
buttonLabel: "devdock-button-label",
|
|
31
|
+
panel: "devdock-panel",
|
|
32
|
+
title: "devdock-title",
|
|
33
|
+
inputWrap: "devdock-input-wrap",
|
|
34
|
+
input: "devdock-input",
|
|
35
|
+
body: "devdock-body",
|
|
36
|
+
list: "devdock-list",
|
|
37
|
+
section: "devdock-section",
|
|
38
|
+
group: "devdock-group",
|
|
39
|
+
row: "devdock-row",
|
|
40
|
+
rowActive: "",
|
|
41
|
+
rowLabel: "devdock-row-label",
|
|
42
|
+
rowPath: "devdock-row-path",
|
|
43
|
+
check: "devdock-check",
|
|
44
|
+
empty: "devdock-empty",
|
|
45
|
+
viewLabel: "devdock-view-label",
|
|
46
|
+
view: "devdock-view"
|
|
47
|
+
};
|
|
48
|
+
var STYLE_MARKER = "data-devdock-styles";
|
|
49
|
+
var FONT = "ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif";
|
|
50
|
+
var BASE_CSS = `
|
|
51
|
+
.devdock-root { font-family: var(--devdock-font, ${FONT}); }
|
|
52
|
+
|
|
53
|
+
.devdock-button {
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: 6px;
|
|
57
|
+
padding: 8px 12px;
|
|
58
|
+
font-size: 12px;
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
letter-spacing: 0.6px;
|
|
61
|
+
color: var(--devdock-button-fg, #fff);
|
|
62
|
+
background: var(--devdock-button-bg, #111317);
|
|
63
|
+
border: 1px solid var(--devdock-border, #2a2e37);
|
|
64
|
+
border-radius: 999px;
|
|
65
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
.devdock-button:where([aria-expanded="true"]) {
|
|
69
|
+
background: var(--devdock-accent, #2563eb);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.devdock-dot {
|
|
73
|
+
width: 8px;
|
|
74
|
+
height: 8px;
|
|
75
|
+
border-radius: 999px;
|
|
76
|
+
background: var(--devdock-success, #22c55e);
|
|
77
|
+
display: inline-block;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.devdock-panel {
|
|
81
|
+
width: var(--devdock-width, 280px);
|
|
82
|
+
max-height: var(--devdock-max-height, 70vh);
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
background: var(--devdock-bg, #16181d);
|
|
86
|
+
color: var(--devdock-fg, #e7e9ee);
|
|
87
|
+
border: 1px solid var(--devdock-border, #2a2e37);
|
|
88
|
+
border-radius: var(--devdock-radius, 12px);
|
|
89
|
+
box-shadow: var(--devdock-shadow, 0 12px 40px rgba(0, 0, 0, 0.45));
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.devdock-title {
|
|
94
|
+
padding: 10px 12px;
|
|
95
|
+
border-bottom: 1px solid var(--devdock-border, #2a2e37);
|
|
96
|
+
font-size: 12px;
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
letter-spacing: 0.4px;
|
|
99
|
+
text-transform: uppercase;
|
|
100
|
+
color: var(--devdock-muted, #8b909c);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.devdock-input-wrap { padding: 8px; }
|
|
104
|
+
|
|
105
|
+
.devdock-input {
|
|
106
|
+
width: 100%;
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
padding: 8px 10px;
|
|
109
|
+
font-size: 13px;
|
|
110
|
+
color: var(--devdock-fg, #e7e9ee);
|
|
111
|
+
background: var(--devdock-input-bg, #0f1115);
|
|
112
|
+
border: 1px solid var(--devdock-border, #2a2e37);
|
|
113
|
+
border-radius: var(--devdock-radius-sm, 8px);
|
|
114
|
+
outline: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.devdock-body {
|
|
118
|
+
overflow-y: auto;
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.devdock-list { padding: 0 6px 8px; }
|
|
124
|
+
|
|
125
|
+
.devdock-section { margin-top: 6px; }
|
|
126
|
+
|
|
127
|
+
.devdock-group {
|
|
128
|
+
padding: 6px 8px 2px;
|
|
129
|
+
font-size: 10px;
|
|
130
|
+
font-weight: 700;
|
|
131
|
+
letter-spacing: 0.6px;
|
|
132
|
+
text-transform: uppercase;
|
|
133
|
+
color: var(--devdock-subtle, #6b7280);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.devdock-row {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
gap: 8px;
|
|
141
|
+
width: 100%;
|
|
142
|
+
text-align: left;
|
|
143
|
+
padding: 8px 10px;
|
|
144
|
+
font-size: 13px;
|
|
145
|
+
color: var(--devdock-fg, #e7e9ee);
|
|
146
|
+
background: transparent;
|
|
147
|
+
border: none;
|
|
148
|
+
border-radius: var(--devdock-radius-sm, 8px);
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
}
|
|
151
|
+
.devdock-row:where([data-active]) {
|
|
152
|
+
background: var(--devdock-accent, #2563eb);
|
|
153
|
+
color: var(--devdock-accent-fg, #e7e9ee);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.devdock-row-label {
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
white-space: nowrap;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.devdock-row-path {
|
|
163
|
+
font-size: 11px;
|
|
164
|
+
color: var(--devdock-subtle, #6b7280);
|
|
165
|
+
font-family: ui-monospace, SFMono-Regular, monospace;
|
|
166
|
+
flex-shrink: 0;
|
|
167
|
+
}
|
|
168
|
+
:where(.devdock-row[data-active]) .devdock-row-path {
|
|
169
|
+
/* Whatever colour the row ended up with, stepped back: currentColor in the
|
|
170
|
+
color property means the inherited one, so this tracks the row however it
|
|
171
|
+
was set - a token, a class of yours - instead of guessing at the accent. */
|
|
172
|
+
color: color-mix(in oklab, currentColor 75%, transparent);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.devdock-check {
|
|
176
|
+
flex-shrink: 0;
|
|
177
|
+
width: 12px;
|
|
178
|
+
text-align: center;
|
|
179
|
+
color: var(--devdock-success, #22c55e);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.devdock-empty {
|
|
183
|
+
padding: 12px;
|
|
184
|
+
font-size: 13px;
|
|
185
|
+
color: var(--devdock-subtle, #6b7280);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.devdock-view-label {
|
|
189
|
+
padding: 4px 8px 0;
|
|
190
|
+
font-size: 11px;
|
|
191
|
+
color: var(--devdock-muted, #8b909c);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.devdock-view { padding: 2px 8px 6px; }
|
|
195
|
+
`;
|
|
196
|
+
var DEFAULT_LAYER = "devdock";
|
|
197
|
+
function dockStyles(layer) {
|
|
198
|
+
if (!layer) return BASE_CSS;
|
|
199
|
+
const block = `@layer ${layer} {${BASE_CSS}}
|
|
200
|
+
`;
|
|
201
|
+
if (layer !== DEFAULT_LAYER) return block;
|
|
202
|
+
const order = `@layer theme, base, components, ${layer}, utilities;`;
|
|
203
|
+
return `${order}
|
|
204
|
+
${block}`;
|
|
205
|
+
}
|
|
206
|
+
|
|
21
207
|
// src/core/dock.ts
|
|
22
208
|
var viteDevFlag = () => {
|
|
23
209
|
try {
|
|
@@ -48,33 +234,12 @@ var isDevHost = () => {
|
|
|
48
234
|
if (!host) return true;
|
|
49
235
|
return host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host === "::1" || host === "0.0.0.0" || isLocalIPv4(host);
|
|
50
236
|
};
|
|
51
|
-
function el(tag,
|
|
237
|
+
function el(tag, props) {
|
|
52
238
|
const node = document.createElement(tag);
|
|
53
|
-
if (styles) Object.assign(node.style, styles);
|
|
54
239
|
if (props) Object.assign(node, props);
|
|
55
240
|
return node;
|
|
56
241
|
}
|
|
57
|
-
|
|
58
|
-
return el(
|
|
59
|
-
"div",
|
|
60
|
-
{
|
|
61
|
-
padding: "6px 8px 2px",
|
|
62
|
-
fontSize: "10px",
|
|
63
|
-
fontWeight: "700",
|
|
64
|
-
letterSpacing: "0.6px",
|
|
65
|
-
textTransform: "uppercase",
|
|
66
|
-
color: "#6b7280"
|
|
67
|
-
},
|
|
68
|
-
{ textContent: text }
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
function viewLabel(text) {
|
|
72
|
-
return el(
|
|
73
|
-
"div",
|
|
74
|
-
{ padding: "4px 8px 0", fontSize: "11px", color: "#8b909c" },
|
|
75
|
-
{ textContent: text }
|
|
76
|
-
);
|
|
77
|
-
}
|
|
242
|
+
var PARTS = Object.keys(partClass);
|
|
78
243
|
function cornerStyle(position) {
|
|
79
244
|
const gap = "16px";
|
|
80
245
|
switch (position) {
|
|
@@ -97,7 +262,6 @@ function panelAnchor(position) {
|
|
|
97
262
|
[isRight ? "right" : "left"]: "0"
|
|
98
263
|
};
|
|
99
264
|
}
|
|
100
|
-
var FONT = "ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif";
|
|
101
265
|
function keyViews(views) {
|
|
102
266
|
const used = /* @__PURE__ */ new Set();
|
|
103
267
|
return views.map((view, i) => {
|
|
@@ -114,96 +278,67 @@ function createDevDock(initial = {}) {
|
|
|
114
278
|
} };
|
|
115
279
|
}
|
|
116
280
|
let opts = { ...initial };
|
|
281
|
+
const cls = (...parts) => cn.cn(parts.map((part) => [partClass[part], opts.classNames?.[part]]));
|
|
282
|
+
const classSig = () => PARTS.map((p) => cn.cn(opts.classNames?.[p])).join("\0");
|
|
117
283
|
let open = false;
|
|
118
284
|
let query = "";
|
|
119
285
|
let active = 0;
|
|
120
286
|
let mounted = false;
|
|
121
287
|
const host = el("div");
|
|
122
288
|
host.setAttribute("data-devdock", "");
|
|
123
|
-
const shadowMode = initial.shadow ?? true;
|
|
289
|
+
const shadowMode = initial.shadow ?? (initial.classNames ? "inherit" : true);
|
|
124
290
|
const useShadow = shadowMode !== false && typeof host.attachShadow === "function";
|
|
125
291
|
const shadowRoot = useShadow ? host.attachShadow({ mode: "open" }) : null;
|
|
126
292
|
const mountPoint = shadowRoot ?? host;
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const root = el("div", { fontFamily: FONT });
|
|
130
|
-
mountPoint.appendChild(root);
|
|
131
|
-
const panel = el("div", {
|
|
132
|
-
width: "280px",
|
|
133
|
-
maxHeight: "min(70vh, 480px)",
|
|
134
|
-
display: "flex",
|
|
135
|
-
flexDirection: "column",
|
|
136
|
-
background: "#16181d",
|
|
137
|
-
color: "#e7e9ee",
|
|
138
|
-
border: "1px solid #2a2e37",
|
|
139
|
-
borderRadius: "12px",
|
|
140
|
-
boxShadow: "0 12px 40px rgba(0,0,0,0.45)",
|
|
141
|
-
overflow: "hidden"
|
|
293
|
+
const baseStyle = el("style", {
|
|
294
|
+
textContent: dockStyles(initial.cssLayer ?? DEFAULT_LAYER)
|
|
142
295
|
});
|
|
296
|
+
baseStyle.setAttribute(STYLE_MARKER, "");
|
|
297
|
+
if (shadowRoot) mountPoint.appendChild(baseStyle);
|
|
298
|
+
const styleSlot = shadowRoot && shadowMode === "inherit" ? el("div") : null;
|
|
299
|
+
if (styleSlot) {
|
|
300
|
+
styleSlot.style.display = "contents";
|
|
301
|
+
mountPoint.appendChild(styleSlot);
|
|
302
|
+
}
|
|
303
|
+
const root = el("div");
|
|
304
|
+
mountPoint.appendChild(root);
|
|
305
|
+
const panel = el("div");
|
|
143
306
|
panel.setAttribute("role", "dialog");
|
|
144
|
-
const heading = el("div"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
fontSize: "12px",
|
|
148
|
-
fontWeight: "600",
|
|
149
|
-
letterSpacing: "0.4px",
|
|
150
|
-
textTransform: "uppercase",
|
|
151
|
-
color: "#8b909c"
|
|
152
|
-
});
|
|
153
|
-
const inputWrap = el("div", { padding: "8px" });
|
|
154
|
-
const input = el("input", {
|
|
155
|
-
width: "100%",
|
|
156
|
-
boxSizing: "border-box",
|
|
157
|
-
padding: "8px 10px",
|
|
158
|
-
fontSize: "13px",
|
|
159
|
-
color: "#e7e9ee",
|
|
160
|
-
background: "#0f1115",
|
|
161
|
-
border: "1px solid #2a2e37",
|
|
162
|
-
borderRadius: "8px",
|
|
163
|
-
outline: "none"
|
|
164
|
-
});
|
|
307
|
+
const heading = el("div");
|
|
308
|
+
const inputWrap = el("div");
|
|
309
|
+
const input = el("input");
|
|
165
310
|
input.placeholder = "Filter\u2026";
|
|
166
311
|
inputWrap.appendChild(input);
|
|
167
|
-
const list = el("div"
|
|
312
|
+
const list = el("div");
|
|
168
313
|
list.setAttribute("data-devdock-list", "");
|
|
169
314
|
const viewsBefore = el("div");
|
|
170
315
|
viewsBefore.setAttribute("data-devdock-views", "before");
|
|
171
316
|
const viewsAfter = el("div");
|
|
172
317
|
viewsAfter.setAttribute("data-devdock-views", "after");
|
|
173
|
-
const body = el("div"
|
|
174
|
-
overflowY: "auto",
|
|
175
|
-
display: "flex",
|
|
176
|
-
flexDirection: "column"
|
|
177
|
-
});
|
|
318
|
+
const body = el("div");
|
|
178
319
|
body.append(viewsBefore, list, viewsAfter);
|
|
179
320
|
panel.append(heading, inputWrap, body);
|
|
180
|
-
const button = el("button"
|
|
181
|
-
display: "inline-flex",
|
|
182
|
-
alignItems: "center",
|
|
183
|
-
gap: "6px",
|
|
184
|
-
padding: "8px 12px",
|
|
185
|
-
fontSize: "12px",
|
|
186
|
-
fontWeight: "700",
|
|
187
|
-
letterSpacing: "0.6px",
|
|
188
|
-
color: "#fff",
|
|
189
|
-
background: "#111317",
|
|
190
|
-
border: "1px solid #2a2e37",
|
|
191
|
-
borderRadius: "999px",
|
|
192
|
-
boxShadow: "0 4px 14px rgba(0,0,0,0.35)",
|
|
193
|
-
cursor: "pointer"
|
|
194
|
-
});
|
|
321
|
+
const button = el("button");
|
|
195
322
|
button.type = "button";
|
|
196
323
|
button.setAttribute("aria-label", "Toggle dev menu");
|
|
197
|
-
const dot = el("span"
|
|
198
|
-
width: "8px",
|
|
199
|
-
height: "8px",
|
|
200
|
-
borderRadius: "999px",
|
|
201
|
-
background: "#22c55e",
|
|
202
|
-
display: "inline-block"
|
|
203
|
-
});
|
|
324
|
+
const dot = el("span");
|
|
204
325
|
const buttonLabel = el("span");
|
|
205
326
|
button.append(dot, buttonLabel);
|
|
206
327
|
root.appendChild(button);
|
|
328
|
+
const sectionHeading = (text) => el("div", { className: cls("group"), textContent: text });
|
|
329
|
+
const viewLabel = (text) => el("div", { className: cls("viewLabel"), textContent: text });
|
|
330
|
+
const paintClasses = () => {
|
|
331
|
+
root.className = cls("root");
|
|
332
|
+
button.className = cls("button");
|
|
333
|
+
dot.className = cls("dot");
|
|
334
|
+
buttonLabel.className = cls("buttonLabel");
|
|
335
|
+
panel.className = cls("panel");
|
|
336
|
+
heading.className = cls("title");
|
|
337
|
+
inputWrap.className = cls("inputWrap");
|
|
338
|
+
input.className = cls("input");
|
|
339
|
+
body.className = cls("body");
|
|
340
|
+
list.className = cls("list");
|
|
341
|
+
};
|
|
207
342
|
const enabled = () => {
|
|
208
343
|
const e = opts.enabled;
|
|
209
344
|
if (typeof e === "function") return e();
|
|
@@ -287,9 +422,9 @@ function createDevDock(initial = {}) {
|
|
|
287
422
|
const paintActive = () => {
|
|
288
423
|
rows.forEach((row, idx) => {
|
|
289
424
|
const isActive = idx === active;
|
|
290
|
-
row.node.
|
|
291
|
-
|
|
292
|
-
|
|
425
|
+
if (isActive) row.node.setAttribute("data-active", "");
|
|
426
|
+
else row.node.removeAttribute("data-active");
|
|
427
|
+
row.node.className = isActive ? cls("row", "rowActive") : cls("row");
|
|
293
428
|
});
|
|
294
429
|
};
|
|
295
430
|
const setActive = (next, scroll = false) => {
|
|
@@ -301,7 +436,7 @@ function createDevDock(initial = {}) {
|
|
|
301
436
|
const renderList = () => {
|
|
302
437
|
const filtered = getFiltered();
|
|
303
438
|
active = Math.min(active, Math.max(0, filtered.length - 1));
|
|
304
|
-
const sig = filtered.map(itemSig).join("\n");
|
|
439
|
+
const sig = [classSig(), ...filtered.map(itemSig)].join("\n");
|
|
305
440
|
if (sig === rowsSig) {
|
|
306
441
|
filtered.forEach((it, idx) => {
|
|
307
442
|
const row = rows[idx];
|
|
@@ -317,11 +452,7 @@ function createDevDock(initial = {}) {
|
|
|
317
452
|
list.replaceChildren();
|
|
318
453
|
if (filtered.length === 0) {
|
|
319
454
|
list.appendChild(
|
|
320
|
-
el(
|
|
321
|
-
"div",
|
|
322
|
-
{ padding: "12px", fontSize: "13px", color: "#6b7280" },
|
|
323
|
-
{ textContent: "Nothing here." }
|
|
324
|
-
)
|
|
455
|
+
el("div", { className: cls("empty"), textContent: "Nothing here." })
|
|
325
456
|
);
|
|
326
457
|
return;
|
|
327
458
|
}
|
|
@@ -332,55 +463,26 @@ function createDevDock(initial = {}) {
|
|
|
332
463
|
groups.set(it.group, arr);
|
|
333
464
|
}
|
|
334
465
|
for (const [groupName, groupItems] of groups) {
|
|
335
|
-
const section = el("div", {
|
|
466
|
+
const section = el("div", { className: cls("section") });
|
|
336
467
|
section.appendChild(sectionHeading(groupName));
|
|
337
468
|
for (const it of groupItems) {
|
|
338
469
|
const idx = filtered.indexOf(it);
|
|
339
|
-
const row = el("button", {
|
|
340
|
-
display: "flex",
|
|
341
|
-
alignItems: "center",
|
|
342
|
-
justifyContent: "space-between",
|
|
343
|
-
gap: "8px",
|
|
344
|
-
width: "100%",
|
|
345
|
-
textAlign: "left",
|
|
346
|
-
padding: "8px 10px",
|
|
347
|
-
fontSize: "13px",
|
|
348
|
-
color: "#e7e9ee",
|
|
349
|
-
background: "transparent",
|
|
350
|
-
border: "none",
|
|
351
|
-
borderRadius: "8px",
|
|
352
|
-
cursor: "pointer"
|
|
353
|
-
});
|
|
470
|
+
const row = el("button", { className: cls("row") });
|
|
354
471
|
row.type = "button";
|
|
355
|
-
const labelSpan = el("span", {
|
|
356
|
-
overflow: "hidden",
|
|
357
|
-
textOverflow: "ellipsis",
|
|
358
|
-
whiteSpace: "nowrap"
|
|
359
|
-
});
|
|
472
|
+
const labelSpan = el("span", { className: cls("rowLabel") });
|
|
360
473
|
row.appendChild(labelSpan);
|
|
361
474
|
let pathSpan = null;
|
|
362
475
|
if (it.kind === "route" && it.route.path !== it.label) {
|
|
363
|
-
pathSpan = el(
|
|
364
|
-
"
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
color: "#6b7280",
|
|
368
|
-
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
369
|
-
flexShrink: "0"
|
|
370
|
-
},
|
|
371
|
-
{ textContent: it.route.path }
|
|
372
|
-
);
|
|
476
|
+
pathSpan = el("span", {
|
|
477
|
+
className: cls("rowPath"),
|
|
478
|
+
textContent: it.route.path
|
|
479
|
+
});
|
|
373
480
|
row.appendChild(pathSpan);
|
|
374
481
|
}
|
|
375
482
|
let checkSpan = null;
|
|
376
483
|
if (it.kind === "command" && it.checked !== null) {
|
|
377
484
|
row.setAttribute("role", "checkbox");
|
|
378
|
-
checkSpan = el("span", {
|
|
379
|
-
flexShrink: "0",
|
|
380
|
-
width: "12px",
|
|
381
|
-
textAlign: "center",
|
|
382
|
-
color: "#22c55e"
|
|
383
|
-
});
|
|
485
|
+
checkSpan = el("span", { className: cls("check") });
|
|
384
486
|
row.appendChild(checkSpan);
|
|
385
487
|
}
|
|
386
488
|
const rec = { item: it, node: row, labelSpan, pathSpan, checkSpan };
|
|
@@ -409,11 +511,14 @@ function createDevDock(initial = {}) {
|
|
|
409
511
|
};
|
|
410
512
|
const renderViews = () => {
|
|
411
513
|
const keyed = keyViews(opts.views ?? []);
|
|
412
|
-
const sig =
|
|
413
|
-
(
|
|
414
|
-
|
|
514
|
+
const sig = [
|
|
515
|
+
classSig(),
|
|
516
|
+
...keyed.map(
|
|
517
|
+
({ view, key }) => [key, viewOrder(view), view.group ?? "", view.label ?? ""].join(
|
|
518
|
+
"\0"
|
|
519
|
+
)
|
|
415
520
|
)
|
|
416
|
-
|
|
521
|
+
].join("\n");
|
|
417
522
|
if (sig === viewsSig) return;
|
|
418
523
|
viewsSig = sig;
|
|
419
524
|
const live = new Set(keyed.map(({ key }) => key));
|
|
@@ -441,7 +546,7 @@ function createDevDock(initial = {}) {
|
|
|
441
546
|
});
|
|
442
547
|
}
|
|
443
548
|
for (const section of sections.values()) {
|
|
444
|
-
const wrap = el("div", {
|
|
549
|
+
const wrap = el("div", { className: cls("section") });
|
|
445
550
|
if (section.heading) wrap.appendChild(sectionHeading(section.heading));
|
|
446
551
|
for (const { view, key } of section.items) {
|
|
447
552
|
if (view.group != null && view.label)
|
|
@@ -451,7 +556,7 @@ function createDevDock(initial = {}) {
|
|
|
451
556
|
wrap.appendChild(existing.host);
|
|
452
557
|
continue;
|
|
453
558
|
}
|
|
454
|
-
const viewHost = el("div", {
|
|
559
|
+
const viewHost = el("div", { className: cls("view") });
|
|
455
560
|
viewHost.setAttribute("data-devdock-view", view.id ?? "");
|
|
456
561
|
wrap.appendChild(viewHost);
|
|
457
562
|
pending.push({ view, key, host: viewHost });
|
|
@@ -478,7 +583,9 @@ function createDevDock(initial = {}) {
|
|
|
478
583
|
}
|
|
479
584
|
}
|
|
480
585
|
const sheets = [
|
|
481
|
-
...document.querySelectorAll(
|
|
586
|
+
...document.querySelectorAll(
|
|
587
|
+
`style:not([${STYLE_MARKER}]), link[rel~="stylesheet" i]`
|
|
588
|
+
)
|
|
482
589
|
];
|
|
483
590
|
const sig = sheets.map((n) => `${n.tagName}\0${n.getAttribute("href") ?? n.textContent}`).join("\n");
|
|
484
591
|
if (sig === clonesSig) return;
|
|
@@ -524,8 +631,8 @@ function createDevDock(initial = {}) {
|
|
|
524
631
|
panel.setAttribute("aria-label", opts.title ?? "Dev Menu");
|
|
525
632
|
Object.assign(panel.style, panelAnchor(position));
|
|
526
633
|
buttonLabel.textContent = opts.label ?? "DEV";
|
|
527
|
-
button.style.background = open ? "#2563eb" : "#111317";
|
|
528
634
|
button.setAttribute("aria-expanded", String(open));
|
|
635
|
+
paintClasses();
|
|
529
636
|
};
|
|
530
637
|
function setOpen(next) {
|
|
531
638
|
if (open === next) return;
|
|
@@ -587,6 +694,8 @@ function createDevDock(initial = {}) {
|
|
|
587
694
|
};
|
|
588
695
|
const mount = () => {
|
|
589
696
|
if (mounted) return;
|
|
697
|
+
if (!shadowRoot)
|
|
698
|
+
(document.head ?? document.documentElement).prepend(baseStyle);
|
|
590
699
|
(opts.container ?? document.body).appendChild(host);
|
|
591
700
|
addListeners();
|
|
592
701
|
syncStyles();
|
|
@@ -597,6 +706,7 @@ function createDevDock(initial = {}) {
|
|
|
597
706
|
if (!mounted) return;
|
|
598
707
|
removeListeners();
|
|
599
708
|
unwatchStyles();
|
|
709
|
+
if (!shadowRoot) baseStyle.remove();
|
|
600
710
|
host.remove();
|
|
601
711
|
mounted = false;
|
|
602
712
|
};
|