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