@voltro/devtools 0.85.0 → 0.87.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/CHANGELOG.md +5987 -0
- package/THIRD-PARTY-NOTICES.md +1125 -34
- package/dist/Devtools.js +327 -0
- package/dist/capsuleClearance.js +42 -0
- package/dist/capsulePlacement.js +66 -0
- package/dist/components/boundary.js +47 -0
- package/dist/components/dockMenu.js +121 -0
- package/dist/components/icons.js +236 -0
- package/dist/components/primitives.js +75 -0
- package/dist/console/Capsule.js +169 -0
- package/dist/console/Console.js +508 -0
- package/dist/console/InspectRefusals.js +89 -0
- package/dist/console/searchIndex.js +63 -0
- package/dist/console/sources.js +106 -0
- package/dist/consoleBridge.js +76 -0
- package/dist/externalWindow.js +9 -0
- package/dist/index.js +3 -4382
- package/dist/inspectAuth.js +16 -0
- package/dist/inspectFetch.js +46 -0
- package/dist/inspectRefusal.js +45 -0
- package/dist/inspectStream.js +88 -0
- package/dist/logsBus.js +22 -0
- package/dist/panels/desktop.js +101 -0
- package/dist/panels/indexes.js +233 -0
- package/dist/panels/logs.js +55 -0
- package/dist/panels/mutations.js +81 -0
- package/dist/panels/pwa.js +171 -0
- package/dist/panels/routes.js +69 -0
- package/dist/panels/runtimes.js +67 -0
- package/dist/panels/stores.js +125 -0
- package/dist/panels/subscriptions.js +117 -0
- package/dist/panels/traces.js +160 -0
- package/dist/panels/webhooks.js +248 -0
- package/dist/panels/workflows.js +478 -0
- package/dist/pushPage.js +36 -0
- package/dist/shadowHost.js +77 -0
- package/dist/strings.js +332 -0
- package/dist/styles.css +20 -0
- package/dist/useCapsuleClearance.js +85 -0
- package/dist/useDevStatuses.js +6 -0
- package/dist/useDock.js +181 -0
- package/dist/useDocumentVisible.js +5 -0
- package/dist/useLiveCacheEntries.js +19 -0
- package/package.json +4 -4
package/dist/Devtools.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { DevtoolsStringsProvider as e, useDevtoolsStrings as t } from "./strings.js";
|
|
2
|
+
import { CAPSULE_SNAP_POINTS as n, capsulePlacementFromDrag as r, isSamePlacement as i } from "./capsulePlacement.js";
|
|
3
|
+
import { Capsule as a } from "./console/Capsule.js";
|
|
4
|
+
import { clampDockState as o, clampEdgeSize as s, clampWindow as c, dockForArrow as ee, isEdgeDock as l, useDockState as te, useViewport as ne } from "./useDock.js";
|
|
5
|
+
import { clearInspectRefusals as re } from "./inspectRefusal.js";
|
|
6
|
+
import { InspectTokenProvider as u, resolveInspectToken as d } from "./inspectAuth.js";
|
|
7
|
+
import { Console as ie } from "./console/Console.js";
|
|
8
|
+
import { OverlayBoundary as f } from "./components/boundary.js";
|
|
9
|
+
import { ShadowHost as p } from "./shadowHost.js";
|
|
10
|
+
import { useDevStatuses as ae } from "./useDevStatuses.js";
|
|
11
|
+
import { engagePush as oe } from "./pushPage.js";
|
|
12
|
+
import { openExternalWindow as se } from "./externalWindow.js";
|
|
13
|
+
import { useCallback as m, useEffect as h, useMemo as ce, useRef as g, useState as _ } from "react";
|
|
14
|
+
import { selectDevStatus as le } from "@voltro/web";
|
|
15
|
+
import { Fragment as ue, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
16
|
+
//#region src/Devtools.tsx
|
|
17
|
+
var b = "voltro:devtools:open", x = (e) => {
|
|
18
|
+
if (typeof window > "u") return e;
|
|
19
|
+
try {
|
|
20
|
+
let t = window.localStorage.getItem(b);
|
|
21
|
+
return t === null ? e : t === "1";
|
|
22
|
+
} catch {
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
}, de = (e) => {
|
|
26
|
+
if (typeof window < "u") try {
|
|
27
|
+
window.localStorage.setItem(b, e ? "1" : "0");
|
|
28
|
+
} catch {}
|
|
29
|
+
}, S = ({ initialIsOpen: t = !1, initialDock: n = "bottom", strings: r, inspectToken: i } = {}) => {
|
|
30
|
+
let a = d(i);
|
|
31
|
+
return /* @__PURE__ */ v(u, {
|
|
32
|
+
token: a,
|
|
33
|
+
children: /* @__PURE__ */ v(e, {
|
|
34
|
+
strings: r ?? {},
|
|
35
|
+
children: /* @__PURE__ */ v(k, {
|
|
36
|
+
initialIsOpen: t,
|
|
37
|
+
initialDock: n
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}, C = (e) => {
|
|
42
|
+
switch (e.dock) {
|
|
43
|
+
case "bottom":
|
|
44
|
+
case "top": return { height: e.sizes[e.dock] };
|
|
45
|
+
case "left":
|
|
46
|
+
case "right": return { width: e.sizes[e.dock] };
|
|
47
|
+
case "window": return {
|
|
48
|
+
left: e.window.x,
|
|
49
|
+
top: e.window.y,
|
|
50
|
+
width: e.window.w,
|
|
51
|
+
height: e.window.h
|
|
52
|
+
};
|
|
53
|
+
case "external": return {};
|
|
54
|
+
}
|
|
55
|
+
}, w = (e, t) => {
|
|
56
|
+
let n = {
|
|
57
|
+
"--vdt-capsule-x": e.x,
|
|
58
|
+
"--vdt-capsule-y": e.y
|
|
59
|
+
};
|
|
60
|
+
return t !== void 0 && (n.width = t.w, n.height = t.h), n;
|
|
61
|
+
}, T = (e, t, n, r) => {
|
|
62
|
+
switch (e) {
|
|
63
|
+
case "bottom": return t - r;
|
|
64
|
+
case "top": return t + r;
|
|
65
|
+
case "left": return t + n;
|
|
66
|
+
case "right": return t - n;
|
|
67
|
+
}
|
|
68
|
+
}, E = (e) => {
|
|
69
|
+
console.error("[voltro devtools] the overlay hit an error and was contained:", e);
|
|
70
|
+
}, D = (e) => {
|
|
71
|
+
let t = document.body.style;
|
|
72
|
+
e !== null && t.setProperty("cursor", e), t.setProperty("user-select", "none"), t.setProperty("-webkit-user-select", "none");
|
|
73
|
+
}, O = () => {
|
|
74
|
+
let e = document.body.style;
|
|
75
|
+
e.removeProperty("cursor"), e.removeProperty("user-select"), e.removeProperty("-webkit-user-select");
|
|
76
|
+
}, fe = (e) => e instanceof Element && e.closest("button, input, a, [role=\"menu\"], [role=\"tablist\"], label") !== null, k = ({ initialIsOpen: e, initialDock: u }) => {
|
|
77
|
+
let d = t().shell, [b, S] = te(u), [k, A] = _(() => x(e) && b.dock !== "external"), [pe, j] = _("all"), M = g(null), [me, he] = _(0), ge = ae(), _e = le(ge);
|
|
78
|
+
h(() => {
|
|
79
|
+
de(k);
|
|
80
|
+
}, [k]), h(() => {
|
|
81
|
+
k || re();
|
|
82
|
+
}, [k]);
|
|
83
|
+
let { dock: N, push: P } = b, { setDock: F, setEdgeSize: I, setWindowRect: L, setPush: ve, setCapsule: R } = S, z = ne(), B = ce(() => o(b, z), [b, z]), [V, H] = _(k);
|
|
84
|
+
k && !V && H(!0);
|
|
85
|
+
let U = V && !k, W = g(null);
|
|
86
|
+
h(() => {
|
|
87
|
+
if (!U) return;
|
|
88
|
+
let e = W.current?.getAnimations?.() ?? [];
|
|
89
|
+
if (e.length === 0) {
|
|
90
|
+
H(!1);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let t = !1, n = () => {
|
|
94
|
+
t || H(!1);
|
|
95
|
+
};
|
|
96
|
+
return Promise.all(e.map((e) => e.finished)).then(n, n), () => {
|
|
97
|
+
t = !0;
|
|
98
|
+
};
|
|
99
|
+
}, [U]);
|
|
100
|
+
let G = g(null), K = g(!1);
|
|
101
|
+
h(() => {
|
|
102
|
+
V ? K.current = !0 : K.current && G.current?.focus();
|
|
103
|
+
}, [V]);
|
|
104
|
+
let [q, ye] = _(null), be = k && N === "external";
|
|
105
|
+
h(() => {
|
|
106
|
+
if (!be || typeof window > "u") return;
|
|
107
|
+
let e = se(b.window, d.brand);
|
|
108
|
+
if (e === null) {
|
|
109
|
+
console.warn(`[voltro devtools] ${d.externalBlocked}`), A(!1);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
ye(e), e.focus();
|
|
113
|
+
let t = window.setInterval(() => {
|
|
114
|
+
e.closed && A(!1);
|
|
115
|
+
}, 400), n = () => {
|
|
116
|
+
e.close();
|
|
117
|
+
};
|
|
118
|
+
return window.addEventListener("pagehide", n), () => {
|
|
119
|
+
window.clearInterval(t), window.removeEventListener("pagehide", n), ye(null), e.close();
|
|
120
|
+
};
|
|
121
|
+
}, [be]), h(() => {
|
|
122
|
+
if (typeof window > "u") return;
|
|
123
|
+
let e = (e, t, n) => e.code === t || e.key.toLowerCase() === n, t = (t) => {
|
|
124
|
+
if (t.altKey && !t.shiftKey && !t.metaKey && !t.ctrlKey && e(t, "KeyV", "v")) t.preventDefault(), A((e) => !e);
|
|
125
|
+
else if ((t.metaKey || t.ctrlKey) && !t.altKey && e(t, "KeyK", "k")) t.preventDefault(), A(!0), j((e) => e === "stores" || e === "indexes" || e === "webhooks" || e === "routes" || e === "runtimes" || e === "pwa" || e === "desktop" ? "all" : e), he((e) => e + 1);
|
|
126
|
+
else if (t.altKey && t.shiftKey) {
|
|
127
|
+
let e = ee(t.key);
|
|
128
|
+
e !== null && (t.preventDefault(), A(!0), F(e));
|
|
129
|
+
}
|
|
130
|
+
}, n = q === null ? [window] : [window, q];
|
|
131
|
+
for (let e of n) e.addEventListener("keydown", t);
|
|
132
|
+
return () => {
|
|
133
|
+
for (let e of n) e.removeEventListener("keydown", t);
|
|
134
|
+
};
|
|
135
|
+
}, [F, q]), h(() => {
|
|
136
|
+
if (!k) return;
|
|
137
|
+
let e = requestAnimationFrame(() => M.current?.focus());
|
|
138
|
+
return () => cancelAnimationFrame(e);
|
|
139
|
+
}, [
|
|
140
|
+
k,
|
|
141
|
+
me,
|
|
142
|
+
q
|
|
143
|
+
]);
|
|
144
|
+
let J = V && P && l(N) ? N : null, Y = g(null);
|
|
145
|
+
h(() => {
|
|
146
|
+
if (typeof document > "u" || J === null) return;
|
|
147
|
+
let e = oe(J, B.sizes[J]);
|
|
148
|
+
return Y.current = e, () => {
|
|
149
|
+
Y.current = null, e.release();
|
|
150
|
+
};
|
|
151
|
+
}, [J]);
|
|
152
|
+
let X = J === null ? null : B.sizes[J];
|
|
153
|
+
h(() => {
|
|
154
|
+
X !== null && Y.current?.resize(X);
|
|
155
|
+
}, [X]);
|
|
156
|
+
let xe = m((e) => {
|
|
157
|
+
if (!l(N)) return;
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
let t = N, n = {
|
|
160
|
+
x: e.clientX,
|
|
161
|
+
y: e.clientY,
|
|
162
|
+
size: B.sizes[t]
|
|
163
|
+
}, r = (e) => {
|
|
164
|
+
I(t, s(t, T(t, n.size, e.clientX - n.x, e.clientY - n.y)));
|
|
165
|
+
}, i = () => {
|
|
166
|
+
window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i), window.removeEventListener("pointercancel", i), O();
|
|
167
|
+
};
|
|
168
|
+
window.addEventListener("pointermove", r), window.addEventListener("pointerup", i), window.addEventListener("pointercancel", i), D(t === "left" || t === "right" ? "col-resize" : "row-resize");
|
|
169
|
+
}, [
|
|
170
|
+
N,
|
|
171
|
+
B.sizes,
|
|
172
|
+
I
|
|
173
|
+
]), Se = m((e) => {
|
|
174
|
+
if (N !== "window" || fe(e.target)) return;
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
let t = {
|
|
177
|
+
x: e.clientX,
|
|
178
|
+
y: e.clientY,
|
|
179
|
+
rect: B.window
|
|
180
|
+
}, n = (e) => {
|
|
181
|
+
L(c({
|
|
182
|
+
...t.rect,
|
|
183
|
+
x: t.rect.x + (e.clientX - t.x),
|
|
184
|
+
y: t.rect.y + (e.clientY - t.y)
|
|
185
|
+
}));
|
|
186
|
+
}, r = () => {
|
|
187
|
+
window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), O();
|
|
188
|
+
};
|
|
189
|
+
window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r), D(null);
|
|
190
|
+
}, [
|
|
191
|
+
N,
|
|
192
|
+
B.window,
|
|
193
|
+
L
|
|
194
|
+
]), Ce = m((e) => {
|
|
195
|
+
if (N !== "window") return;
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
let t = {
|
|
198
|
+
x: e.clientX,
|
|
199
|
+
y: e.clientY,
|
|
200
|
+
rect: B.window
|
|
201
|
+
}, n = (e) => {
|
|
202
|
+
L(c({
|
|
203
|
+
...t.rect,
|
|
204
|
+
w: t.rect.w + (e.clientX - t.x),
|
|
205
|
+
h: t.rect.h + (e.clientY - t.y)
|
|
206
|
+
}));
|
|
207
|
+
}, r = () => {
|
|
208
|
+
window.removeEventListener("pointermove", n), window.removeEventListener("pointerup", r), window.removeEventListener("pointercancel", r), O();
|
|
209
|
+
};
|
|
210
|
+
window.addEventListener("pointermove", n), window.addEventListener("pointerup", r), window.addEventListener("pointercancel", r), D("nwse-resize");
|
|
211
|
+
}, [
|
|
212
|
+
N,
|
|
213
|
+
B.window,
|
|
214
|
+
L
|
|
215
|
+
]), [Z, we] = _(null), Q = g(!1), Te = m((e) => {
|
|
216
|
+
if (e.button !== 0) return;
|
|
217
|
+
let t = e.currentTarget.getBoundingClientRect(), n = e.currentTarget.style, i = {
|
|
218
|
+
x: Number(n.getPropertyValue("--vdt-capsule-x") || b.capsule.x),
|
|
219
|
+
y: Number(n.getPropertyValue("--vdt-capsule-y") || b.capsule.y)
|
|
220
|
+
}, a = {
|
|
221
|
+
x: e.clientX,
|
|
222
|
+
y: e.clientY,
|
|
223
|
+
placement: i,
|
|
224
|
+
size: {
|
|
225
|
+
w: t.width,
|
|
226
|
+
h: t.height
|
|
227
|
+
}
|
|
228
|
+
}, o = !1, s = (e) => {
|
|
229
|
+
let t = e.clientX - a.x, n = e.clientY - a.y;
|
|
230
|
+
if (!o) {
|
|
231
|
+
if (Math.hypot(t, n) < 4) return;
|
|
232
|
+
o = !0, Q.current = !0, we(a.size), D("grabbing");
|
|
233
|
+
}
|
|
234
|
+
R(r(a.placement, a.size, {
|
|
235
|
+
width: window.innerWidth,
|
|
236
|
+
height: window.innerHeight
|
|
237
|
+
}, t, n));
|
|
238
|
+
}, c = () => {
|
|
239
|
+
window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", c), o && (we(null), O(), setTimeout(() => {
|
|
240
|
+
Q.current = !1;
|
|
241
|
+
}, 0));
|
|
242
|
+
};
|
|
243
|
+
window.addEventListener("pointermove", s), window.addEventListener("pointerup", c), window.addEventListener("pointercancel", c);
|
|
244
|
+
}, [b.capsule, R]), Ee = m(() => A(!1), []), De = m(() => {
|
|
245
|
+
Q.current ? Q.current = !1 : A(!0);
|
|
246
|
+
}, []), Oe = N === "external", $ = V ? /* @__PURE__ */ y("section", {
|
|
247
|
+
ref: W,
|
|
248
|
+
className: "vdt-console",
|
|
249
|
+
role: "dialog",
|
|
250
|
+
"aria-label": d.brand,
|
|
251
|
+
"data-dock": N,
|
|
252
|
+
"data-closing": U ? "true" : void 0,
|
|
253
|
+
inert: U,
|
|
254
|
+
style: C(B),
|
|
255
|
+
children: [
|
|
256
|
+
l(N) ? /* @__PURE__ */ v("div", {
|
|
257
|
+
className: "vdt-grip",
|
|
258
|
+
role: "separator",
|
|
259
|
+
"aria-label": d.resizeLabel,
|
|
260
|
+
"aria-orientation": N === "left" || N === "right" ? "vertical" : "horizontal",
|
|
261
|
+
onPointerDown: xe
|
|
262
|
+
}) : null,
|
|
263
|
+
/* @__PURE__ */ v(f, {
|
|
264
|
+
onError: E,
|
|
265
|
+
children: /* @__PURE__ */ v(ie, {
|
|
266
|
+
dock: N,
|
|
267
|
+
push: P,
|
|
268
|
+
onDock: F,
|
|
269
|
+
onPush: ve,
|
|
270
|
+
onClose: Ee,
|
|
271
|
+
scope: pe,
|
|
272
|
+
onScope: j,
|
|
273
|
+
searchRef: M,
|
|
274
|
+
onHeaderPointerDown: N === "window" ? Se : void 0
|
|
275
|
+
})
|
|
276
|
+
}),
|
|
277
|
+
N === "window" ? /* @__PURE__ */ v("div", {
|
|
278
|
+
className: "vdt-win-resize",
|
|
279
|
+
role: "separator",
|
|
280
|
+
"aria-label": d.resizeLabel,
|
|
281
|
+
onPointerDown: Ce
|
|
282
|
+
}) : null
|
|
283
|
+
]
|
|
284
|
+
}) : null;
|
|
285
|
+
return /* @__PURE__ */ y(ue, { children: [/* @__PURE__ */ v(p, { children: /* @__PURE__ */ v("div", {
|
|
286
|
+
className: "vdt-host",
|
|
287
|
+
"data-open": k ? "true" : "false",
|
|
288
|
+
"data-dock": N,
|
|
289
|
+
"data-push": J === null ? "false" : "true",
|
|
290
|
+
children: /* @__PURE__ */ v("div", {
|
|
291
|
+
className: "vdt-scope",
|
|
292
|
+
children: V ? Oe ? null : $ : /* @__PURE__ */ y(f, {
|
|
293
|
+
onError: E,
|
|
294
|
+
children: [Z === null ? null : /* @__PURE__ */ v("div", {
|
|
295
|
+
className: "vdt-capsule-slots",
|
|
296
|
+
"aria-hidden": "true",
|
|
297
|
+
children: n.map((e) => /* @__PURE__ */ v("span", {
|
|
298
|
+
className: "vdt-capsule-slot",
|
|
299
|
+
"data-active": i(e, b.capsule) ? "true" : void 0,
|
|
300
|
+
style: w(e, Z)
|
|
301
|
+
}, `${e.x}:${e.y}`))
|
|
302
|
+
}), /* @__PURE__ */ v(a, {
|
|
303
|
+
status: _e,
|
|
304
|
+
onOpen: De,
|
|
305
|
+
buttonRef: G,
|
|
306
|
+
style: w(b.capsule),
|
|
307
|
+
dragging: Z !== null,
|
|
308
|
+
onPointerDown: Te
|
|
309
|
+
})]
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
}) }), Oe && q !== null ? /* @__PURE__ */ v(p, {
|
|
313
|
+
target: q.document,
|
|
314
|
+
children: /* @__PURE__ */ v("div", {
|
|
315
|
+
className: "vdt-host",
|
|
316
|
+
"data-open": "true",
|
|
317
|
+
"data-dock": "external",
|
|
318
|
+
"data-push": "false",
|
|
319
|
+
children: /* @__PURE__ */ v("div", {
|
|
320
|
+
className: "vdt-scope",
|
|
321
|
+
children: $
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
}) : null] });
|
|
325
|
+
};
|
|
326
|
+
//#endregion
|
|
327
|
+
export { S as VoltroDevtools, w as capsuleStyle, C as consoleStyle, T as edgeSizeFromDrag, x as readStoredOpen };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CAPSULE_SNAP_POINTS as e, isSamePlacement as t } from "./capsulePlacement.js";
|
|
2
|
+
//#region src/capsuleClearance.ts
|
|
3
|
+
var n = 8, r = (e, t, r, i) => {
|
|
4
|
+
let a = 18 + e.x * Math.max(0, r.width - 36 - t.w), o = 18 + e.y * Math.max(0, r.height - 36 - t.h);
|
|
5
|
+
return i.filter((e) => a < e.right + n && a + t.w > e.left - n && o < e.bottom + n && o + t.h > e.top - n);
|
|
6
|
+
}, i = (e, t, n, i) => r(e, t, n, i).length === 0, a = (i, a, o, s, c) => {
|
|
7
|
+
let l = Math.max(0, s.width - 36 - o.w), u = Math.max(0, s.height - 36 - o.h), d = (e) => r(e, o, s, c);
|
|
8
|
+
if (d(i).length === 0) return i;
|
|
9
|
+
if (!t(i, a) && d(a).length === 0) return a;
|
|
10
|
+
let f = [], p = /* @__PURE__ */ new Set(), m = (e) => {
|
|
11
|
+
if (p.size >= 256) return;
|
|
12
|
+
let t = {
|
|
13
|
+
x: Math.max(0, Math.min(1, e.x)),
|
|
14
|
+
y: Math.max(0, Math.min(1, e.y))
|
|
15
|
+
}, n = `${(t.x * l).toFixed(2)}:${(t.y * u).toFixed(2)}`;
|
|
16
|
+
p.has(n) || (p.add(n), f.push(t));
|
|
17
|
+
}, h = (e) => Math.hypot((e.x - i.x) * l, (e.y - i.y) * u);
|
|
18
|
+
m(i), e.forEach(m);
|
|
19
|
+
for (let e = 0; e < 64 && f.length > 0; e++) {
|
|
20
|
+
f.sort((e, t) => h(e) - h(t));
|
|
21
|
+
let e = f.shift();
|
|
22
|
+
if (!e) break;
|
|
23
|
+
let t = d(e);
|
|
24
|
+
if (t.length === 0) return e;
|
|
25
|
+
for (let r of t.slice(0, 8)) l > 0 && (m({
|
|
26
|
+
x: (r.left - n - o.w - 18) / l,
|
|
27
|
+
y: e.y
|
|
28
|
+
}), m({
|
|
29
|
+
x: (r.right + n - 18) / l,
|
|
30
|
+
y: e.y
|
|
31
|
+
})), u > 0 && (m({
|
|
32
|
+
x: e.x,
|
|
33
|
+
y: (r.top - n - o.h - 18) / u
|
|
34
|
+
}), m({
|
|
35
|
+
x: e.x,
|
|
36
|
+
y: (r.bottom + n - 18) / u
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
return [...e].sort((e, t) => h(e) - h(t)).find((e) => d(e).length === 0) ?? i;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { a as clearCapsulePlacement, i as hasCapsuleClearance };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/capsulePlacement.ts
|
|
2
|
+
var e = {
|
|
3
|
+
x: .5,
|
|
4
|
+
y: 1
|
|
5
|
+
}, t = [
|
|
6
|
+
{
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
x: .5,
|
|
12
|
+
y: 0
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
x: 1,
|
|
16
|
+
y: 0
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
x: 0,
|
|
20
|
+
y: .5
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
x: 1,
|
|
24
|
+
y: .5
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 1
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
x: .5,
|
|
32
|
+
y: 1
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
x: 1,
|
|
36
|
+
y: 1
|
|
37
|
+
}
|
|
38
|
+
], n = (e) => Math.min(1, Math.max(0, e)), r = (e, t) => ({
|
|
39
|
+
x: Math.max(0, t.width - 36 - e.w),
|
|
40
|
+
y: Math.max(0, t.height - 36 - e.h)
|
|
41
|
+
}), i = (e, t) => e.x === t.x && e.y === t.y, a = (e, n, i) => {
|
|
42
|
+
let a = r(n, i), o = null, s = 48;
|
|
43
|
+
for (let n of t) {
|
|
44
|
+
let t = Math.hypot((e.x - n.x) * a.x, (e.y - n.y) * a.y);
|
|
45
|
+
t <= s && (o = n, s = t);
|
|
46
|
+
}
|
|
47
|
+
return o === null ? e : {
|
|
48
|
+
x: a.x > 0 ? o.x : e.x,
|
|
49
|
+
y: a.y > 0 ? o.y : e.y
|
|
50
|
+
};
|
|
51
|
+
}, o = (e, t, i, o, s) => {
|
|
52
|
+
let c = r(t, i);
|
|
53
|
+
return a({
|
|
54
|
+
x: c.x > 0 ? n((e.x * c.x + o) / c.x) : e.x,
|
|
55
|
+
y: c.y > 0 ? n((e.y * c.y + s) / c.y) : e.y
|
|
56
|
+
}, t, i);
|
|
57
|
+
}, s = (e) => typeof e == "number" && Number.isFinite(e), c = (t) => {
|
|
58
|
+
if (typeof t != "object" || !t) return e;
|
|
59
|
+
let r = t;
|
|
60
|
+
return {
|
|
61
|
+
x: s(r.x) ? n(r.x) : e.x,
|
|
62
|
+
y: s(r.y) ? n(r.y) : e.y
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { t as CAPSULE_SNAP_POINTS, e as DEFAULT_CAPSULE_PLACEMENT, o as capsulePlacementFromDrag, c as decodeCapsulePlacement, i as isSamePlacement, a as snapCapsulePlacement };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useDevtoolsStrings as e } from "../strings.js";
|
|
2
|
+
import { Component as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/boundary.tsx
|
|
5
|
+
var i = ({ error: t, onReset: i }) => {
|
|
6
|
+
let a = e().shell;
|
|
7
|
+
return /* @__PURE__ */ r("div", {
|
|
8
|
+
role: "alert",
|
|
9
|
+
className: "vdt-crash",
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ n("div", {
|
|
12
|
+
className: "vdt-crash-title",
|
|
13
|
+
children: a.crashTitle
|
|
14
|
+
}),
|
|
15
|
+
/* @__PURE__ */ r("pre", {
|
|
16
|
+
className: "vdt-crash-message",
|
|
17
|
+
children: [
|
|
18
|
+
t.name,
|
|
19
|
+
": ",
|
|
20
|
+
t.message
|
|
21
|
+
]
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ n("button", {
|
|
24
|
+
type: "button",
|
|
25
|
+
className: "vdt-crash-reset",
|
|
26
|
+
onClick: i,
|
|
27
|
+
children: a.crashReset
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
}, a = class extends t {
|
|
32
|
+
state = { error: null };
|
|
33
|
+
static getDerivedStateFromError(e) {
|
|
34
|
+
return { error: e };
|
|
35
|
+
}
|
|
36
|
+
componentDidCatch(e, t) {
|
|
37
|
+
this.props.onError?.(e, t);
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
return this.state.error === null ? this.props.children : /* @__PURE__ */ n(i, {
|
|
41
|
+
error: this.state.error,
|
|
42
|
+
onReset: () => this.setState({ error: null })
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { a as OverlayBoundary };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { DockBottom as e, DockExternal as t, DockLeft as n, DockRight as r, DockTop as i, DockWindow as a } from "./icons.js";
|
|
2
|
+
import { useDevtoolsStrings as o } from "../strings.js";
|
|
3
|
+
import { ALL_DOCKS as s, isEdgeDock as c } from "../useDock.js";
|
|
4
|
+
import { useEffect as l, useRef as u, useState as d } from "react";
|
|
5
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/dockMenu.tsx
|
|
7
|
+
var m = {
|
|
8
|
+
bottom: e,
|
|
9
|
+
top: i,
|
|
10
|
+
left: n,
|
|
11
|
+
right: r,
|
|
12
|
+
window: a,
|
|
13
|
+
external: t
|
|
14
|
+
}, h = ({ dock: e, push: t, onDock: n, onPush: r }) => {
|
|
15
|
+
let i = o().shell, [a, h] = d(!1), g = u(null), _ = {
|
|
16
|
+
bottom: i.dockBottom,
|
|
17
|
+
top: i.dockTop,
|
|
18
|
+
left: i.dockLeft,
|
|
19
|
+
right: i.dockRight,
|
|
20
|
+
window: i.dockWindow,
|
|
21
|
+
external: i.dockExternal
|
|
22
|
+
};
|
|
23
|
+
l(() => {
|
|
24
|
+
if (!a) return;
|
|
25
|
+
let e = g.current?.ownerDocument ?? document, t = (e) => {
|
|
26
|
+
g.current !== null && !e.composedPath().includes(g.current) && h(!1);
|
|
27
|
+
}, n = (e) => {
|
|
28
|
+
e.key === "Escape" && h(!1);
|
|
29
|
+
};
|
|
30
|
+
return e.addEventListener("mousedown", t), e.addEventListener("keydown", n), () => {
|
|
31
|
+
e.removeEventListener("mousedown", t), e.removeEventListener("keydown", n);
|
|
32
|
+
};
|
|
33
|
+
}, [a]);
|
|
34
|
+
let v = u([]);
|
|
35
|
+
l(() => {
|
|
36
|
+
if (!a) return;
|
|
37
|
+
let t = s.indexOf(e);
|
|
38
|
+
v.current[t === -1 ? 0 : t]?.focus();
|
|
39
|
+
}, [a, e]);
|
|
40
|
+
let y = (e) => {
|
|
41
|
+
let t = v.current.filter((e) => e !== null);
|
|
42
|
+
if (t.length === 0) return;
|
|
43
|
+
let n = t.findIndex((t) => t === e.target), r = null;
|
|
44
|
+
switch (e.key) {
|
|
45
|
+
case "ArrowRight":
|
|
46
|
+
case "ArrowDown":
|
|
47
|
+
r = (n + 1) % t.length;
|
|
48
|
+
break;
|
|
49
|
+
case "ArrowLeft":
|
|
50
|
+
case "ArrowUp":
|
|
51
|
+
r = (n - 1 + t.length) % t.length;
|
|
52
|
+
break;
|
|
53
|
+
case "Home":
|
|
54
|
+
r = 0;
|
|
55
|
+
break;
|
|
56
|
+
case "End":
|
|
57
|
+
r = t.length - 1;
|
|
58
|
+
break;
|
|
59
|
+
default: return;
|
|
60
|
+
}
|
|
61
|
+
e.preventDefault(), t[r]?.focus();
|
|
62
|
+
}, b = m[e];
|
|
63
|
+
return /* @__PURE__ */ p("div", {
|
|
64
|
+
ref: g,
|
|
65
|
+
className: "vdt-dockmenu",
|
|
66
|
+
children: [/* @__PURE__ */ f("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
className: `vdt-iconbtn${a ? " vdt-iconbtn-on" : ""}`,
|
|
69
|
+
title: i.dockMenuTitle,
|
|
70
|
+
"aria-label": i.dockMenuTitle,
|
|
71
|
+
"aria-haspopup": "menu",
|
|
72
|
+
"aria-expanded": a,
|
|
73
|
+
onClick: () => h((e) => !e),
|
|
74
|
+
children: /* @__PURE__ */ f(b, { className: "vdt:w-4 vdt:h-4" })
|
|
75
|
+
}), a ? /* @__PURE__ */ p("div", {
|
|
76
|
+
role: "menu",
|
|
77
|
+
"aria-label": i.dockMenuTitle,
|
|
78
|
+
className: "vdt-dockmenu-pop",
|
|
79
|
+
children: [/* @__PURE__ */ f("div", {
|
|
80
|
+
className: "vdt-dockmenu-row",
|
|
81
|
+
onKeyDown: y,
|
|
82
|
+
children: s.map((t, r) => {
|
|
83
|
+
let i = m[t], a = t === e;
|
|
84
|
+
return /* @__PURE__ */ f("button", {
|
|
85
|
+
ref: (e) => {
|
|
86
|
+
v.current[r] = e;
|
|
87
|
+
},
|
|
88
|
+
type: "button",
|
|
89
|
+
role: "menuitemradio",
|
|
90
|
+
"aria-checked": a,
|
|
91
|
+
"aria-label": _[t],
|
|
92
|
+
title: _[t],
|
|
93
|
+
className: `vdt-dockmenu-item${a ? " vdt-dockmenu-item-on" : ""}`,
|
|
94
|
+
onClick: () => {
|
|
95
|
+
n(t), h(!1);
|
|
96
|
+
},
|
|
97
|
+
children: /* @__PURE__ */ f(i, { className: "vdt:w-4 vdt:h-4" })
|
|
98
|
+
}, t);
|
|
99
|
+
})
|
|
100
|
+
}), /* @__PURE__ */ p("label", {
|
|
101
|
+
className: `vdt-dockmenu-push${c(e) ? "" : " vdt-dockmenu-push-off"}`,
|
|
102
|
+
children: [/* @__PURE__ */ f("input", {
|
|
103
|
+
type: "checkbox",
|
|
104
|
+
role: "menuitemcheckbox",
|
|
105
|
+
"aria-checked": t,
|
|
106
|
+
checked: t,
|
|
107
|
+
disabled: !c(e),
|
|
108
|
+
onChange: (e) => r(e.target.checked)
|
|
109
|
+
}), /* @__PURE__ */ p("span", { children: [/* @__PURE__ */ f("span", {
|
|
110
|
+
className: "vdt-dockmenu-push-label",
|
|
111
|
+
children: i.pushPage
|
|
112
|
+
}), /* @__PURE__ */ f("span", {
|
|
113
|
+
className: "vdt-dockmenu-push-hint",
|
|
114
|
+
children: i.pushPageHint
|
|
115
|
+
})] })]
|
|
116
|
+
})]
|
|
117
|
+
}) : null]
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
export { h as DockMenu };
|