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