@hansenexus/hud 0.6.0 → 0.8.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 +172 -25
- package/dist/{a11y-B5DUaiCs.js → a11y-BGWw4jBr.js} +14 -2
- package/dist/{a11y-panel-p_t4eD7p.js → a11y-panel-DcfXnPHk.js} +1 -1
- package/dist/{access-D_ewAEJG.d.ts → access-CwPCPsv0.d.ts} +1 -1
- package/dist/{access-panel-CEfTr9ZI.js → access-panel-grAsMEDk.js} +1 -1
- package/dist/auto/runtime.d.ts +9 -9
- package/dist/auto.d.ts +2 -2
- package/dist/auto.js +5 -5
- package/dist/cli.js +34 -1
- package/dist/{data-panel-BmcHCQnM.js → data-panel-B6WPNmV6.js} +1 -1
- package/dist/{data-store-ChF1td_P.js → data-store-FNTQKMkG.js} +1 -1
- package/dist/{define-hud-CHPedaQ5.d.ts → define-hud-B0aFXrcK.d.ts} +15 -5
- package/dist/{design-D0kGgPoP.js → design-BIXY1-Ex.js} +45 -11
- package/dist/{dispatch-panel-B-xr_Giy.js → dispatch-panel-BDHgMhOk.js} +1 -1
- package/dist/{force-state-panel-_otVYh9i.js → force-state-panel-D5oDydLs.js} +1 -1
- package/dist/{handler-BpVhxEmU.js → handler-BKzaOhlJ.js} +1 -1
- package/dist/{handler-DtYVCZY6.d.ts → handler-BmFhaA2D.d.ts} +1 -1
- package/dist/icons-ByDyNq_E.js +71 -0
- package/dist/index-5B7foZut.d.ts +116 -0
- package/dist/{index-ReFbhQ9p.d.ts → index-B2KCKkN0.d.ts} +5 -0
- package/dist/index-B7qaEUgh.d.ts +44 -0
- package/dist/{index-DcH9V3cU.d.ts → index-BGFyuJyN.d.ts} +3 -0
- package/dist/{index-Hhh7OXzU.d.ts → index-BeqWehuh.d.ts} +44 -10
- package/dist/{index-DstI_ike.d.ts → index-BqKysxTq.d.ts} +5 -1
- package/dist/{index-DqOyNf1u.d.ts → index-D97Fnoie.d.ts} +4 -2
- package/dist/{index-CwfX-W87.d.ts → index-DS0yT0c-.d.ts} +3 -0
- package/dist/{index-BAV_1W8a.d.ts → index-DvlCkGB1.d.ts} +3 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1226 -256
- package/dist/{inspect-C9Ft8fqn.js → inspect-CSkm8tn3.js} +14 -2
- package/dist/{inspect-root-BkaupBMp.js → inspect-root-CmiFX0e5.js} +1 -1
- package/dist/navigation-CX6AXm7H.js +176 -0
- package/dist/next.d.ts +4 -1
- package/dist/next.js +12 -1
- package/dist/{observe-CdDnDBRP.js → observe-CBNLU148.js} +12 -2
- package/dist/{observe-panel-Cgp1M8oT.js → observe-panel-zU5LD-U9.js} +1 -1
- package/dist/obstacles-CCmRFTcZ.js +176 -0
- package/dist/{ops-panel-CEqDe_UT.js → ops-panel-DHhAnChL.js} +1 -1
- package/dist/plugins/a11y.d.ts +1 -1
- package/dist/plugins/a11y.js +1 -1
- package/dist/plugins/access/server.d.ts +3 -3
- package/dist/plugins/access/server.js +1 -1
- package/dist/plugins/access.d.ts +5 -2
- package/dist/plugins/access.js +18 -5
- package/dist/plugins/agent/server.js +2 -2
- package/dist/plugins/agent.d.ts +4 -2
- package/dist/plugins/agent.js +6 -3
- package/dist/plugins/capture/server.js +1 -1
- package/dist/plugins/capture.d.ts +2 -2
- package/dist/plugins/capture.js +1 -1
- package/dist/plugins/data/server.d.ts +1 -1
- package/dist/plugins/data/server.js +2 -2
- package/dist/plugins/data.d.ts +1 -1
- package/dist/plugins/data.js +30 -9
- package/dist/plugins/design/server.d.ts +55 -15
- package/dist/plugins/design/server.js +188 -123
- package/dist/plugins/design.d.ts +3 -3
- package/dist/plugins/design.js +1 -1
- package/dist/plugins/inspect.d.ts +1 -1
- package/dist/plugins/inspect.js +1 -1
- package/dist/plugins/observe.d.ts +1 -1
- package/dist/plugins/observe.js +1 -1
- package/dist/plugins/ops/server.d.ts +1 -1
- package/dist/plugins/ops/server.js +1 -1
- package/dist/plugins/ops.d.ts +5 -1
- package/dist/plugins/ops.js +16 -4
- package/dist/plugins/routes/server.d.ts +1 -1
- package/dist/plugins/routes/server.js +1 -1
- package/dist/plugins/routes.d.ts +3 -3
- package/dist/plugins/routes.js +384 -53
- package/dist/plugins/seo.d.ts +1 -1
- package/dist/plugins/seo.js +1 -1
- package/dist/plugins/vitals.d.ts +1 -1
- package/dist/plugins/vitals.js +9 -1
- package/dist/{plugins-DVy_vaYr.js → plugins-CcW_K7c2.js} +9 -1
- package/dist/{plugins-BZvDqGx5.d.ts → plugins-pL2CoWzI.d.ts} +39 -3
- package/dist/{poll-CjKsWZi8.js → poll-Dm0OijM4.js} +1 -1
- package/dist/same-origin-BHuZO1_H.js +36 -0
- package/dist/{seo-Dq9q_QkO.js → seo-BnnGq_vj.js} +13 -2
- package/dist/{seo-panel-CfiY-TnT.js → seo-panel-BThx56KM.js} +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/{sessions-panel-COvhPAzv.js → sessions-panel-MknKsTge.js} +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.js +2 -2
- package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
- package/dist/{unlock-store-4V3vR4Eg.js → unlock-store-CrGXQx1V.js} +1 -1
- package/dist/variant-bar-BzZ0ln-C.js +768 -0
- package/dist/variant-picks-Byc0hC8a.js +144 -0
- package/dist/variants-export-vEtZ-OGC.js +75 -0
- package/dist/{variants-panel-BDoSkwBJ.js → variants-panel-D23v5KIp.js} +72 -55
- package/dist/variants-types-BOsZ5fDz.js +65 -0
- package/dist/variants-types-VkW7vFZF.d.ts +139 -0
- package/dist/variants.d.ts +1 -1
- package/dist/variants.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +1 -1
- package/dist/index-BnQ0dTZf.d.ts +0 -19
- package/dist/index-gCZBO53s.d.ts +0 -73
- package/dist/same-origin-BGet22CC.js +0 -21
- package/dist/variants-types-CcRf119M.d.ts +0 -63
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { n as useGrab, t as createGrabber } from "./store-Ync9eb1G.js";
|
|
2
|
+
import { i as hudIcon, n as HudIconGlyph, r as IconSprite, t as HUD_ICON_NAMES } from "./icons-ByDyNq_E.js";
|
|
2
3
|
import { n as HUD_HOST_TAG, t as HUD_DEV_MARKER } from "./marker-uZYPOJ4M.js";
|
|
3
|
-
import { a as
|
|
4
|
+
import { a as ratingTone, i as definePlugin, n as HudApiError, o as resolvePlugins, r as createPluginContext } from "./plugins-CcW_K7c2.js";
|
|
4
5
|
import { a as buildGrabPayload, i as parseShortcut, n as isApplePlatform, o as describeElement, r as matchesShortcut, s as matchComponentHints, t as formatShortcut } from "./shortcut-s_mjGeU8.js";
|
|
5
6
|
import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles-BA8ueHoV.js";
|
|
7
|
+
import { a as usePanels, i as PanelsContext, n as useObstacles, r as useVisualViewport, t as offsetObstacles } from "./obstacles-CCmRFTcZ.js";
|
|
6
8
|
import { Component, Suspense, createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
7
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
//#region src/core/grabber/outline.tsx
|
|
@@ -218,14 +220,77 @@ function CommandProvider({ commands, children }) {
|
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
//#endregion
|
|
223
|
+
//#region src/shell/panels/types.ts
|
|
224
|
+
const EDGES = [
|
|
225
|
+
"left",
|
|
226
|
+
"right",
|
|
227
|
+
"bottom"
|
|
228
|
+
];
|
|
229
|
+
/** Search order when the pill picks its own corner: the bottom first, top-right last (host CTAs). */
|
|
230
|
+
const CORNERS = [
|
|
231
|
+
"bottom-left",
|
|
232
|
+
"bottom-right",
|
|
233
|
+
"top-left",
|
|
234
|
+
"top-right"
|
|
235
|
+
];
|
|
236
|
+
const DOCK_SIDES = ["left", "right"];
|
|
237
|
+
/** Cycle order of the chip click and ⌘⇧D. */
|
|
238
|
+
const RAIL_DETAILS = [
|
|
239
|
+
"chip",
|
|
240
|
+
"icons",
|
|
241
|
+
"labels"
|
|
242
|
+
];
|
|
243
|
+
//#endregion
|
|
221
244
|
//#region src/shell/panels/layout.ts
|
|
222
245
|
const EMPTY_LAYOUT = {
|
|
223
246
|
open: [],
|
|
224
247
|
floats: {},
|
|
225
248
|
pins: {},
|
|
226
249
|
hidden: false,
|
|
227
|
-
pill: null
|
|
250
|
+
pill: null,
|
|
251
|
+
side: "right",
|
|
252
|
+
detail: "chip",
|
|
253
|
+
order: [],
|
|
254
|
+
hiddenItems: []
|
|
228
255
|
};
|
|
256
|
+
/** The next detail level: chip → icons → labels → chip. */
|
|
257
|
+
function cycleDetail(layout) {
|
|
258
|
+
const index = RAIL_DETAILS.indexOf(layout.detail);
|
|
259
|
+
const detail = RAIL_DETAILS[(index + 1) % RAIL_DETAILS.length] ?? "chip";
|
|
260
|
+
return {
|
|
261
|
+
...layout,
|
|
262
|
+
detail
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/** `ids` in the user's order: listed ids first, in that order, then the rest as given. */
|
|
266
|
+
function railOrder(ids, order) {
|
|
267
|
+
const present = new Set(ids);
|
|
268
|
+
const placed = order.filter((id) => present.has(id));
|
|
269
|
+
const seen = new Set(placed);
|
|
270
|
+
return [...placed, ...ids.filter((id) => !seen.has(id))];
|
|
271
|
+
}
|
|
272
|
+
/** Moves `id` to position `index` among `ids` (the rail's current ids) and stores the full order. */
|
|
273
|
+
function moveItem(layout, ids, id, index) {
|
|
274
|
+
const current = railOrder(ids, layout.order);
|
|
275
|
+
const from = current.indexOf(id);
|
|
276
|
+
if (from === -1) return layout;
|
|
277
|
+
const to = Math.max(0, Math.min(current.length - 1, index));
|
|
278
|
+
if (from === to) return layout;
|
|
279
|
+
const next = [...current];
|
|
280
|
+
next.splice(from, 1);
|
|
281
|
+
next.splice(to, 0, id);
|
|
282
|
+
return {
|
|
283
|
+
...layout,
|
|
284
|
+
order: next
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function setItemHidden(layout, id, hidden) {
|
|
288
|
+
if (hidden === layout.hiddenItems.includes(id)) return layout;
|
|
289
|
+
return {
|
|
290
|
+
...layout,
|
|
291
|
+
hiddenItems: hidden ? [...layout.hiddenItems, id] : layout.hiddenItems.filter((item) => item !== id)
|
|
292
|
+
};
|
|
293
|
+
}
|
|
229
294
|
/** A pinned edge never takes more than this share of the viewport. */
|
|
230
295
|
const MAX_SHARE = .4;
|
|
231
296
|
function visiblePanels(layout) {
|
|
@@ -502,28 +567,6 @@ function PanelSheet({ panels, active, onSelect, onClose, children }) {
|
|
|
502
567
|
});
|
|
503
568
|
}
|
|
504
569
|
//#endregion
|
|
505
|
-
//#region src/shell/panels/panels-context.ts
|
|
506
|
-
const PanelsContext = createContext(null);
|
|
507
|
-
function usePanels() {
|
|
508
|
-
const api = useContext(PanelsContext);
|
|
509
|
-
if (!api) throw new Error("usePanels() used outside <PanelManager>");
|
|
510
|
-
return api;
|
|
511
|
-
}
|
|
512
|
-
//#endregion
|
|
513
|
-
//#region src/shell/panels/types.ts
|
|
514
|
-
const EDGES = [
|
|
515
|
-
"left",
|
|
516
|
-
"right",
|
|
517
|
-
"bottom"
|
|
518
|
-
];
|
|
519
|
-
/** Search order when the pill picks its own corner: the bottom first, top-right last (host CTAs). */
|
|
520
|
-
const CORNERS = [
|
|
521
|
-
"bottom-left",
|
|
522
|
-
"bottom-right",
|
|
523
|
-
"top-left",
|
|
524
|
-
"top-right"
|
|
525
|
-
];
|
|
526
|
-
//#endregion
|
|
527
570
|
//#region src/shell/panels/reserve.ts
|
|
528
571
|
const PADDING = {
|
|
529
572
|
left: "padding-left",
|
|
@@ -600,6 +643,16 @@ function isCorner(value) {
|
|
|
600
643
|
function isEdge(value) {
|
|
601
644
|
return EDGES.some((edge) => edge === value);
|
|
602
645
|
}
|
|
646
|
+
function isSide(value) {
|
|
647
|
+
return DOCK_SIDES.some((side) => side === value);
|
|
648
|
+
}
|
|
649
|
+
function isDetail(value) {
|
|
650
|
+
return RAIL_DETAILS.some((detail) => detail === value);
|
|
651
|
+
}
|
|
652
|
+
/** The distinct strings of a stored list; anything else is dropped. */
|
|
653
|
+
function strings(value) {
|
|
654
|
+
return Array.isArray(value) ? [...new Set(value.filter((item) => typeof item === "string"))] : [];
|
|
655
|
+
}
|
|
603
656
|
function sanitizeLayout(value, known) {
|
|
604
657
|
if (!isRecord(value) || value.v !== VERSION) return EMPTY_LAYOUT;
|
|
605
658
|
const open = Array.isArray(value.open) ? [...new Set(value.open.filter((id) => typeof id === "string" && known.has(id)))] : [];
|
|
@@ -619,14 +672,18 @@ function sanitizeLayout(value, known) {
|
|
|
619
672
|
floats,
|
|
620
673
|
pins,
|
|
621
674
|
hidden: value.hidden === true,
|
|
622
|
-
pill: isCorner(value.pill) ? value.pill : null
|
|
675
|
+
pill: isCorner(value.pill) ? value.pill : null,
|
|
676
|
+
side: isSide(value.side) ? value.side : EMPTY_LAYOUT.side,
|
|
677
|
+
detail: isDetail(value.detail) ? value.detail : value.folded === false ? "icons" : "chip",
|
|
678
|
+
order: strings(value.order),
|
|
679
|
+
hiddenItems: strings(value.hiddenItems)
|
|
623
680
|
};
|
|
624
681
|
}
|
|
625
682
|
function subscribeResize(listener) {
|
|
626
683
|
window.addEventListener("resize", listener);
|
|
627
684
|
return () => window.removeEventListener("resize", listener);
|
|
628
685
|
}
|
|
629
|
-
let cached
|
|
686
|
+
let cached = {
|
|
630
687
|
w: 0,
|
|
631
688
|
h: 0
|
|
632
689
|
};
|
|
@@ -638,11 +695,11 @@ function readViewport() {
|
|
|
638
695
|
const root = document.documentElement;
|
|
639
696
|
const w = root.clientWidth || window.innerWidth;
|
|
640
697
|
const h = root.clientHeight || window.innerHeight;
|
|
641
|
-
if (w !== cached
|
|
698
|
+
if (w !== cached.w || h !== cached.h) cached = {
|
|
642
699
|
w,
|
|
643
700
|
h
|
|
644
701
|
};
|
|
645
|
-
return cached
|
|
702
|
+
return cached;
|
|
646
703
|
}
|
|
647
704
|
function useViewport() {
|
|
648
705
|
return useSyncExternalStore(subscribeResize, readViewport, readViewport);
|
|
@@ -654,12 +711,24 @@ function useNarrow() {
|
|
|
654
711
|
}
|
|
655
712
|
//#endregion
|
|
656
713
|
//#region src/shell/panels/panel-manager.tsx
|
|
657
|
-
/**
|
|
658
|
-
|
|
714
|
+
/** Room the rail and its gap take from the edge a panel opens beside. */
|
|
715
|
+
const RAIL_GUTTER = 52;
|
|
716
|
+
/** The widest a floating panel renders (`.panel { max-width }`), so it clears the rail on the right. */
|
|
717
|
+
const PANEL_MAX_WIDTH = 420;
|
|
718
|
+
/**
|
|
719
|
+
* Where a panel opens the first time: beside the rail on its side, stacked
|
|
720
|
+
* inward and up; with the pill, up and right from above its corner.
|
|
721
|
+
*/
|
|
722
|
+
function defaultPosition(index, side, viewport) {
|
|
659
723
|
const step = 28 * index;
|
|
724
|
+
const y = Math.max(12, viewport.h - 300 - step);
|
|
725
|
+
if (side === "right") return {
|
|
726
|
+
x: Math.max(12, viewport.w - RAIL_GUTTER - PANEL_MAX_WIDTH - step),
|
|
727
|
+
y
|
|
728
|
+
};
|
|
660
729
|
return {
|
|
661
|
-
x: 12 + step,
|
|
662
|
-
y
|
|
730
|
+
x: (side ? RAIL_GUTTER : 12) + step,
|
|
731
|
+
y
|
|
663
732
|
};
|
|
664
733
|
}
|
|
665
734
|
/**
|
|
@@ -673,7 +742,7 @@ function PanelManager({ commands, ...props }) {
|
|
|
673
742
|
children: /* @__PURE__ */ jsx(Workspace, { ...props })
|
|
674
743
|
});
|
|
675
744
|
}
|
|
676
|
-
function Workspace({ appSlug, panels, apiRef, children }) {
|
|
745
|
+
function Workspace({ appSlug, dock, panels, apiRef, children }) {
|
|
677
746
|
const byId = useMemo(() => new Map(panels.map((panel) => [panel.id, panel])), [panels]);
|
|
678
747
|
const [layout, setLayout] = useState(() => loadLayout(appSlug, new Set(byId.keys())));
|
|
679
748
|
const viewport = useViewport();
|
|
@@ -695,12 +764,13 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
695
764
|
right,
|
|
696
765
|
bottom
|
|
697
766
|
]);
|
|
767
|
+
const position = useCallback((l) => defaultPosition(l.open.length, dock === "rail" ? l.side : null, viewport), [dock, viewport]);
|
|
698
768
|
const api = useMemo(() => ({
|
|
699
769
|
panels,
|
|
700
770
|
isOpen: (id) => !layout.hidden && layout.open.includes(id),
|
|
701
|
-
open: (id) => setLayout((l) => openPanel(l, id,
|
|
771
|
+
open: (id) => setLayout((l) => openPanel(l, id, position(l))),
|
|
702
772
|
close: (id) => setLayout((l) => closePanel(l, id)),
|
|
703
|
-
toggle: (id) => setLayout((l) => !l.hidden && l.open.includes(id) ? closePanel(l, id) : openPanel(l, id,
|
|
773
|
+
toggle: (id) => setLayout((l) => !l.hidden && l.open.includes(id) ? closePanel(l, id) : openPanel(l, id, position(l))),
|
|
704
774
|
pin: (id, edge) => setLayout((l) => pinPanel(l, id, edge)),
|
|
705
775
|
reserve: {
|
|
706
776
|
left,
|
|
@@ -711,13 +781,28 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
711
781
|
setPillCorner: (pill) => setLayout((l) => l.pill === pill ? l : {
|
|
712
782
|
...l,
|
|
713
783
|
pill
|
|
714
|
-
})
|
|
784
|
+
}),
|
|
785
|
+
side: layout.side,
|
|
786
|
+
setSide: (side) => setLayout((l) => l.side === side ? l : {
|
|
787
|
+
...l,
|
|
788
|
+
side
|
|
789
|
+
}),
|
|
790
|
+
detail: layout.detail,
|
|
791
|
+
setDetail: (detail) => setLayout((l) => l.detail === detail ? l : {
|
|
792
|
+
...l,
|
|
793
|
+
detail
|
|
794
|
+
}),
|
|
795
|
+
order: layout.order,
|
|
796
|
+
moveItem: (ids, id, index) => setLayout((l) => moveItem(l, ids, id, index)),
|
|
797
|
+
hiddenItems: layout.hiddenItems,
|
|
798
|
+
setItemHidden: (id, hidden) => setLayout((l) => setItemHidden(l, id, hidden))
|
|
715
799
|
}), [
|
|
716
800
|
panels,
|
|
717
801
|
layout,
|
|
718
802
|
left,
|
|
719
803
|
right,
|
|
720
|
-
bottom
|
|
804
|
+
bottom,
|
|
805
|
+
position
|
|
721
806
|
]);
|
|
722
807
|
useLayoutEffect(() => {
|
|
723
808
|
if (!apiRef) return;
|
|
@@ -726,16 +811,29 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
726
811
|
apiRef.current = null;
|
|
727
812
|
};
|
|
728
813
|
}, [apiRef, api]);
|
|
729
|
-
useRegisterCommands(useMemo(() => [
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
814
|
+
useRegisterCommands(useMemo(() => [
|
|
815
|
+
{
|
|
816
|
+
id: "hud.toggle-layout",
|
|
817
|
+
title: "Toggle layout",
|
|
818
|
+
shortcut: "mod+shift+h",
|
|
819
|
+
run: () => setLayout((l) => toggleLayout(l, panels[0]?.id, position(l)))
|
|
820
|
+
},
|
|
821
|
+
...dock === "rail" ? [{
|
|
822
|
+
id: "hud.detail",
|
|
823
|
+
title: "Cycle rail detail",
|
|
824
|
+
shortcut: "mod+shift+d",
|
|
825
|
+
run: () => setLayout(cycleDetail)
|
|
826
|
+
}] : [],
|
|
827
|
+
{
|
|
828
|
+
id: "hud.reset-layout",
|
|
829
|
+
title: "Reset layout",
|
|
830
|
+
run: () => setLayout(EMPTY_LAYOUT)
|
|
831
|
+
}
|
|
832
|
+
], [
|
|
833
|
+
panels,
|
|
834
|
+
position,
|
|
835
|
+
dock
|
|
836
|
+
]));
|
|
739
837
|
const zOrder = visiblePanels(layout);
|
|
740
838
|
const visible = panels.filter((panel) => zOrder.includes(panel.id));
|
|
741
839
|
const active = byId.get(zOrder.at(-1) ?? "");
|
|
@@ -766,7 +864,10 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
766
864
|
title: panel.title,
|
|
767
865
|
z: zOrder.indexOf(panel.id) + 1,
|
|
768
866
|
viewport,
|
|
769
|
-
position: layout.floats[panel.id] ??
|
|
867
|
+
position: layout.floats[panel.id] ?? position({
|
|
868
|
+
...layout,
|
|
869
|
+
open: []
|
|
870
|
+
}),
|
|
770
871
|
pinned: edge && rect ? {
|
|
771
872
|
edge,
|
|
772
873
|
rect
|
|
@@ -857,6 +958,43 @@ function nearestCorner(x, y, viewport) {
|
|
|
857
958
|
return `${y > viewport.h / 2 ? "bottom" : "top"}-${x > viewport.w / 2 ? "right" : "left"}`;
|
|
858
959
|
}
|
|
859
960
|
const isNarrow = (viewport) => viewport.w < 900;
|
|
961
|
+
/** The side a dragged rail chip lands on: the half of the viewport it was dropped in. */
|
|
962
|
+
function nearestSide(x, viewport) {
|
|
963
|
+
return x > viewport.w / 2 ? "right" : "left";
|
|
964
|
+
}
|
|
965
|
+
/** The rail's box: flush against its edge (next to a pinned panel there), `top` down. */
|
|
966
|
+
function railRect({ top }, size, viewport, reserve, side) {
|
|
967
|
+
return {
|
|
968
|
+
left: side === "right" ? viewport.w - reserve.right - size.width : reserve.left,
|
|
969
|
+
top,
|
|
970
|
+
width: size.width,
|
|
971
|
+
height: size.height
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Where the rail goes on its edge: centred, unless a host element sits there.
|
|
976
|
+
* Then the nearest free spot above or below the obstacles, scored by the
|
|
977
|
+
* distance moved, like the pill's shift; past the shift cap it stays centred
|
|
978
|
+
* and overlaps rather than leaving the viewport.
|
|
979
|
+
*/
|
|
980
|
+
function placeRail(options) {
|
|
981
|
+
const { viewport, size, obstacles, reserve, side } = options;
|
|
982
|
+
const minTop = 12;
|
|
983
|
+
const maxTop = viewport.h - reserve.bottom - 12 - size.height;
|
|
984
|
+
const centre = Math.min(Math.max(Math.round((viewport.h - reserve.bottom - size.height) / 2), minTop), maxTop);
|
|
985
|
+
const at = (top) => railRect({ top }, size, viewport, reserve, side);
|
|
986
|
+
const column = at(centre);
|
|
987
|
+
const inColumn = obstacles.filter((o) => o.left < column.left + column.width && column.left < o.left + o.width);
|
|
988
|
+
const candidates = [centre, ...inColumn.flatMap((o) => [o.top - CLEARANCE - size.height, o.top + o.height + CLEARANCE])];
|
|
989
|
+
const max = viewport.h * MAX_SHIFT_SHARE;
|
|
990
|
+
let best = null;
|
|
991
|
+
for (const top of candidates) {
|
|
992
|
+
if (top < minTop || top > maxTop || Math.abs(top - centre) > max) continue;
|
|
993
|
+
if (inColumn.some((o) => intersects(at(top), o))) continue;
|
|
994
|
+
if (best === null || Math.abs(top - centre) < Math.abs(best - centre)) best = top;
|
|
995
|
+
}
|
|
996
|
+
return { top: best ?? centre };
|
|
997
|
+
}
|
|
860
998
|
/**
|
|
861
999
|
* Width left for plugin items next to the fixed controls of `fixed` pixels
|
|
862
1000
|
* (`chrome` is the pill's own padding and border). On a narrow viewport the
|
|
@@ -904,55 +1042,6 @@ function clampOffset(rect, area, margin) {
|
|
|
904
1042
|
};
|
|
905
1043
|
}
|
|
906
1044
|
//#endregion
|
|
907
|
-
//#region src/shell/pill/visual-viewport.ts
|
|
908
|
-
function subscribe(listener) {
|
|
909
|
-
const vv = window.visualViewport;
|
|
910
|
-
window.addEventListener("resize", listener);
|
|
911
|
-
vv?.addEventListener("resize", listener);
|
|
912
|
-
vv?.addEventListener("scroll", listener);
|
|
913
|
-
return () => {
|
|
914
|
-
window.removeEventListener("resize", listener);
|
|
915
|
-
vv?.removeEventListener("resize", listener);
|
|
916
|
-
vv?.removeEventListener("scroll", listener);
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
let cached = {
|
|
920
|
-
x: 0,
|
|
921
|
-
y: 0,
|
|
922
|
-
w: 0,
|
|
923
|
-
h: 0,
|
|
924
|
-
detached: false
|
|
925
|
-
};
|
|
926
|
-
/**
|
|
927
|
-
* On a phone, a page wider than the screen (an image with a fixed width is
|
|
928
|
-
* enough) grows the layout viewport past the visible area, and a pill fixed
|
|
929
|
-
* to the bottom edge ends up below the fold. The visual viewport is what the
|
|
930
|
-
* user sees; the pill places itself in it.
|
|
931
|
-
*/
|
|
932
|
-
function read() {
|
|
933
|
-
const root = document.documentElement;
|
|
934
|
-
const layoutW = root.clientWidth || window.innerWidth;
|
|
935
|
-
const layoutH = root.clientHeight || window.innerHeight;
|
|
936
|
-
const vv = window.visualViewport;
|
|
937
|
-
const x = vv?.offsetLeft ?? 0;
|
|
938
|
-
const y = vv?.offsetTop ?? 0;
|
|
939
|
-
const w = Math.round(vv?.width ?? layoutW);
|
|
940
|
-
const h = Math.round(vv?.height ?? layoutH);
|
|
941
|
-
const detached = x !== 0 || y !== 0 || window.innerWidth > w + 1 || window.innerHeight > h + 1;
|
|
942
|
-
const next = {
|
|
943
|
-
x,
|
|
944
|
-
y,
|
|
945
|
-
w: detached ? w : layoutW,
|
|
946
|
-
h: detached ? h : layoutH,
|
|
947
|
-
detached
|
|
948
|
-
};
|
|
949
|
-
if (next.x !== cached.x || next.y !== cached.y || next.w !== cached.w || next.h !== cached.h || next.detached !== cached.detached) cached = next;
|
|
950
|
-
return cached;
|
|
951
|
-
}
|
|
952
|
-
function useVisualViewport() {
|
|
953
|
-
return useSyncExternalStore(subscribe, read, read);
|
|
954
|
-
}
|
|
955
|
-
//#endregion
|
|
956
1045
|
//#region src/shell/panels/pill-menu.tsx
|
|
957
1046
|
/** Distance the open menu keeps from the edges of the visible area. */
|
|
958
1047
|
const MENU_MARGIN = 8;
|
|
@@ -961,11 +1050,11 @@ const NO_OFFSET = {
|
|
|
961
1050
|
y: 0
|
|
962
1051
|
};
|
|
963
1052
|
/**
|
|
964
|
-
* The
|
|
965
|
-
* layout. `overflow` counts the pill items
|
|
966
|
-
* reachable here.
|
|
1053
|
+
* The dock's "⋯" menu: every panel, every command with its shortcut, Reset
|
|
1054
|
+
* layout, and on the rail the dock side. `overflow` counts the pill items
|
|
1055
|
+
* that did not fit; their panels are reachable here.
|
|
967
1056
|
*/
|
|
968
|
-
function PillMenu({ overflow = 0 }) {
|
|
1057
|
+
function PillMenu({ overflow = 0, dock, inline = false }) {
|
|
969
1058
|
const panels = usePanels();
|
|
970
1059
|
const commands = useCommands();
|
|
971
1060
|
const apple = useMemo(isApplePlatform, []);
|
|
@@ -976,7 +1065,7 @@ function PillMenu({ overflow = 0 }) {
|
|
|
976
1065
|
const [offset, setOffset] = useState(NO_OFFSET);
|
|
977
1066
|
useLayoutEffect(() => {
|
|
978
1067
|
const menu = menuRef.current;
|
|
979
|
-
if (!open || !menu) {
|
|
1068
|
+
if (!open || !menu || inline) {
|
|
980
1069
|
setOffset(NO_OFFSET);
|
|
981
1070
|
return;
|
|
982
1071
|
}
|
|
@@ -996,6 +1085,7 @@ function PillMenu({ overflow = 0 }) {
|
|
|
996
1085
|
if (next.x !== offset.x || next.y !== offset.y) setOffset(next);
|
|
997
1086
|
}, [
|
|
998
1087
|
open,
|
|
1088
|
+
inline,
|
|
999
1089
|
visual,
|
|
1000
1090
|
offset
|
|
1001
1091
|
]);
|
|
@@ -1014,13 +1104,32 @@ function PillMenu({ overflow = 0 }) {
|
|
|
1014
1104
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
1015
1105
|
};
|
|
1016
1106
|
}, [open]);
|
|
1107
|
+
const label = overflow > 0 ? `HUD menu, ${overflow} more` : "HUD menu";
|
|
1017
1108
|
return /* @__PURE__ */ jsxs("div", {
|
|
1018
1109
|
className: "menu-anchor",
|
|
1019
1110
|
ref,
|
|
1020
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
1111
|
+
children: [dock === "rail" ? /* @__PURE__ */ jsxs("button", {
|
|
1112
|
+
type: "button",
|
|
1113
|
+
className: "rail-button",
|
|
1114
|
+
"aria-label": label,
|
|
1115
|
+
"aria-haspopup": "menu",
|
|
1116
|
+
"aria-expanded": open,
|
|
1117
|
+
onClick: () => setOpen((o) => !o),
|
|
1118
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1119
|
+
className: "rail-glyph",
|
|
1120
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "ellipsis" })
|
|
1121
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1122
|
+
className: "rail-tip",
|
|
1123
|
+
role: "tooltip",
|
|
1124
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1125
|
+
className: "rail-tip-title",
|
|
1126
|
+
children: "Menu"
|
|
1127
|
+
})
|
|
1128
|
+
})]
|
|
1129
|
+
}) : /* @__PURE__ */ jsxs("button", {
|
|
1021
1130
|
type: "button",
|
|
1022
1131
|
className: "pill-item",
|
|
1023
|
-
"aria-label":
|
|
1132
|
+
"aria-label": label,
|
|
1024
1133
|
"aria-haspopup": "menu",
|
|
1025
1134
|
"aria-expanded": open,
|
|
1026
1135
|
onClick: () => setOpen((o) => !o),
|
|
@@ -1044,12 +1153,32 @@ function PillMenu({ overflow = 0 }) {
|
|
|
1044
1153
|
role: "menuitemcheckbox",
|
|
1045
1154
|
className: "menu-item",
|
|
1046
1155
|
"aria-checked": panels.isOpen(panel.id),
|
|
1047
|
-
onClick: () =>
|
|
1156
|
+
onClick: () => {
|
|
1157
|
+
panels.toggle(panel.id);
|
|
1158
|
+
if (dock === "rail") setOpen(false);
|
|
1159
|
+
},
|
|
1048
1160
|
children: [/* @__PURE__ */ jsx("span", { children: panel.title }), /* @__PURE__ */ jsx("span", {
|
|
1049
1161
|
className: "menu-check",
|
|
1050
1162
|
children: panels.isOpen(panel.id) ? "✓" : ""
|
|
1051
1163
|
})]
|
|
1052
1164
|
}, panel.id)),
|
|
1165
|
+
dock === "rail" && !inline && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
1166
|
+
className: "menu-label",
|
|
1167
|
+
children: "Dock"
|
|
1168
|
+
}), DOCK_SIDES.map((side) => /* @__PURE__ */ jsxs("button", {
|
|
1169
|
+
type: "button",
|
|
1170
|
+
role: "menuitemradio",
|
|
1171
|
+
className: "menu-item",
|
|
1172
|
+
"aria-checked": panels.side === side,
|
|
1173
|
+
onClick: () => {
|
|
1174
|
+
setOpen(false);
|
|
1175
|
+
panels.setSide(side);
|
|
1176
|
+
},
|
|
1177
|
+
children: [/* @__PURE__ */ jsxs("span", { children: ["Dock ", side] }), /* @__PURE__ */ jsx("span", {
|
|
1178
|
+
className: "menu-check",
|
|
1179
|
+
children: panels.side === side ? "✓" : ""
|
|
1180
|
+
})]
|
|
1181
|
+
}, side))] }),
|
|
1053
1182
|
/* @__PURE__ */ jsx("div", {
|
|
1054
1183
|
className: "menu-label",
|
|
1055
1184
|
children: "Commands"
|
|
@@ -1301,142 +1430,52 @@ function PluginPanelBody({ slot }) {
|
|
|
1301
1430
|
})
|
|
1302
1431
|
});
|
|
1303
1432
|
}
|
|
1433
|
+
/** A plugin's overlay. A loading or failed overlay is nothing; the rest of the HUD keeps going. */
|
|
1434
|
+
function PluginOverlay({ slot }) {
|
|
1435
|
+
const Overlay = slot.plugin.overlay;
|
|
1436
|
+
if (!Overlay) return null;
|
|
1437
|
+
return /* @__PURE__ */ jsx(PanelBoundary, {
|
|
1438
|
+
title: slot.title,
|
|
1439
|
+
silent: true,
|
|
1440
|
+
children: /* @__PURE__ */ jsx(Suspense, {
|
|
1441
|
+
fallback: null,
|
|
1442
|
+
children: /* @__PURE__ */ jsx(Overlay, { ctx: slot.ctx })
|
|
1443
|
+
})
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1304
1446
|
var PanelBoundary = class extends Component {
|
|
1305
1447
|
state = { error: null };
|
|
1306
1448
|
static getDerivedStateFromError(error) {
|
|
1307
1449
|
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
1308
1450
|
}
|
|
1309
1451
|
componentDidCatch(error, info) {
|
|
1310
|
-
|
|
1452
|
+
const what = this.props.silent ? "overlay" : "panel";
|
|
1453
|
+
console.error(`hud: the ${this.props.title} ${what} failed`, error, info.componentStack);
|
|
1311
1454
|
}
|
|
1312
1455
|
render() {
|
|
1313
1456
|
const { error } = this.state;
|
|
1314
|
-
if (error)
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1457
|
+
if (error) {
|
|
1458
|
+
if (this.props.silent) return null;
|
|
1459
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
1460
|
+
className: "empty panel-error",
|
|
1461
|
+
role: "alert",
|
|
1462
|
+
children: [
|
|
1463
|
+
this.props.title,
|
|
1464
|
+
" failed: ",
|
|
1465
|
+
error.message
|
|
1466
|
+
]
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1323
1469
|
return this.props.children;
|
|
1324
1470
|
}
|
|
1325
1471
|
};
|
|
1326
1472
|
//#endregion
|
|
1327
|
-
//#region src/shell/pill/obstacles.ts
|
|
1328
|
-
/** Fixed elements covering more than this share of the viewport are backdrops, not corners. */
|
|
1329
|
-
const MAX_AREA_SHARE = .5;
|
|
1330
|
-
/** DOM changes settle for this long before the page is scanned again. */
|
|
1331
|
-
const RESCAN_MS = 250;
|
|
1332
|
-
function isFloating(el) {
|
|
1333
|
-
const { position } = getComputedStyle(el);
|
|
1334
|
-
return position === "fixed" || position === "sticky";
|
|
1335
|
-
}
|
|
1336
|
-
/**
|
|
1337
|
-
* The host page's fixed and sticky elements: what fights the pill for a
|
|
1338
|
-
* corner. Nested ones are dropped since their floating ancestor already
|
|
1339
|
-
* counts, and the HUD's own host is skipped.
|
|
1340
|
-
*/
|
|
1341
|
-
function scanFloating(root = document.body) {
|
|
1342
|
-
const found = [];
|
|
1343
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
|
|
1344
|
-
const el = node;
|
|
1345
|
-
if (el.localName === "hn-hud") return NodeFilter.FILTER_REJECT;
|
|
1346
|
-
return isFloating(el) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
1347
|
-
} });
|
|
1348
|
-
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1349
|
-
const el = node;
|
|
1350
|
-
if (!found.some((outer) => outer.contains(el))) found.push(el);
|
|
1351
|
-
}
|
|
1352
|
-
return found;
|
|
1353
|
-
}
|
|
1354
|
-
/** Visible rects of `elements`, minus backdrops and anything off screen. */
|
|
1355
|
-
function obstacleRects(elements) {
|
|
1356
|
-
const vw = window.innerWidth;
|
|
1357
|
-
const vh = window.innerHeight;
|
|
1358
|
-
const rects = [];
|
|
1359
|
-
for (const el of elements) {
|
|
1360
|
-
const { left, top, width, height } = el.getBoundingClientRect();
|
|
1361
|
-
if (width === 0 || height === 0) continue;
|
|
1362
|
-
if (width * height > vw * vh * MAX_AREA_SHARE) continue;
|
|
1363
|
-
if (left >= vw || top >= vh || left + width <= 0 || top + height <= 0) continue;
|
|
1364
|
-
const style = getComputedStyle(el);
|
|
1365
|
-
if (style.visibility === "hidden" || style.opacity === "0") continue;
|
|
1366
|
-
rects.push({
|
|
1367
|
-
left,
|
|
1368
|
-
top,
|
|
1369
|
-
width,
|
|
1370
|
-
height
|
|
1371
|
-
});
|
|
1372
|
-
}
|
|
1373
|
-
return rects;
|
|
1374
|
-
}
|
|
1375
|
-
function sameRects(a, b) {
|
|
1376
|
-
return a.length === b.length && a.every((r, i) => r.left === b[i]?.left && r.top === b[i]?.top && r.width === b[i]?.width && r.height === b[i]?.height);
|
|
1377
|
-
}
|
|
1378
|
-
const NONE = [];
|
|
1379
|
-
/**
|
|
1380
|
-
* Live obstacle rects. The element list is rescanned when the DOM settles
|
|
1381
|
-
* after a change; rects are re-measured on scroll (sticky elements move) and
|
|
1382
|
-
* resize, once per frame.
|
|
1383
|
-
*/
|
|
1384
|
-
function useObstacles() {
|
|
1385
|
-
const [rects, setRects] = useState(NONE);
|
|
1386
|
-
useEffect(() => {
|
|
1387
|
-
let elements = scanFloating();
|
|
1388
|
-
let frame = 0;
|
|
1389
|
-
let timer;
|
|
1390
|
-
const measure = () => {
|
|
1391
|
-
frame = 0;
|
|
1392
|
-
const next = obstacleRects(elements);
|
|
1393
|
-
setRects((prev) => sameRects(prev, next) ? prev : next);
|
|
1394
|
-
};
|
|
1395
|
-
const schedule = () => {
|
|
1396
|
-
if (!frame) frame = requestAnimationFrame(measure);
|
|
1397
|
-
};
|
|
1398
|
-
const rescan = () => {
|
|
1399
|
-
schedule();
|
|
1400
|
-
clearTimeout(timer);
|
|
1401
|
-
timer = setTimeout(() => {
|
|
1402
|
-
elements = scanFloating();
|
|
1403
|
-
schedule();
|
|
1404
|
-
}, RESCAN_MS);
|
|
1405
|
-
};
|
|
1406
|
-
measure();
|
|
1407
|
-
const observer = new MutationObserver(rescan);
|
|
1408
|
-
observer.observe(document.body, {
|
|
1409
|
-
childList: true,
|
|
1410
|
-
subtree: true,
|
|
1411
|
-
attributes: true,
|
|
1412
|
-
attributeFilter: [
|
|
1413
|
-
"class",
|
|
1414
|
-
"style",
|
|
1415
|
-
"hidden"
|
|
1416
|
-
]
|
|
1417
|
-
});
|
|
1418
|
-
window.addEventListener("scroll", schedule, {
|
|
1419
|
-
capture: true,
|
|
1420
|
-
passive: true
|
|
1421
|
-
});
|
|
1422
|
-
window.addEventListener("resize", schedule);
|
|
1423
|
-
return () => {
|
|
1424
|
-
observer.disconnect();
|
|
1425
|
-
clearTimeout(timer);
|
|
1426
|
-
if (frame) cancelAnimationFrame(frame);
|
|
1427
|
-
window.removeEventListener("scroll", schedule, { capture: true });
|
|
1428
|
-
window.removeEventListener("resize", schedule);
|
|
1429
|
-
};
|
|
1430
|
-
}, []);
|
|
1431
|
-
return rects;
|
|
1432
|
-
}
|
|
1433
|
-
//#endregion
|
|
1434
1473
|
//#region src/shell/pill/pill.tsx
|
|
1435
1474
|
/** `.pill` gap, padding and border, which the item widths do not include. */
|
|
1436
1475
|
const ITEM_GAP = 2;
|
|
1437
1476
|
const CHROME = 8;
|
|
1438
1477
|
/** A press that moves less than this is a click, not a drag. */
|
|
1439
|
-
const DRAG_THRESHOLD = 4;
|
|
1478
|
+
const DRAG_THRESHOLD$1 = 4;
|
|
1440
1479
|
const EMPTY = {
|
|
1441
1480
|
items: {},
|
|
1442
1481
|
fixed: 0,
|
|
@@ -1566,11 +1605,10 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1566
1605
|
h: visual.h
|
|
1567
1606
|
}), [visual.w, visual.h]);
|
|
1568
1607
|
const rawObstacles = useObstacles();
|
|
1569
|
-
const obstacles = useMemo(() =>
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
})), [
|
|
1608
|
+
const obstacles = useMemo(() => offsetObstacles(rawObstacles, {
|
|
1609
|
+
x: visual.x,
|
|
1610
|
+
y: visual.y
|
|
1611
|
+
}), [
|
|
1574
1612
|
rawObstacles,
|
|
1575
1613
|
visual.x,
|
|
1576
1614
|
visual.y
|
|
@@ -1617,7 +1655,7 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1617
1655
|
if (!start) return;
|
|
1618
1656
|
const x = e.clientX - start.x;
|
|
1619
1657
|
const y = e.clientY - start.y;
|
|
1620
|
-
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD) return;
|
|
1658
|
+
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD$1) return;
|
|
1621
1659
|
start.moved = true;
|
|
1622
1660
|
setDrag({
|
|
1623
1661
|
x,
|
|
@@ -1636,7 +1674,7 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1636
1674
|
};
|
|
1637
1675
|
return /* @__PURE__ */ jsxs("div", {
|
|
1638
1676
|
ref,
|
|
1639
|
-
className: "pill",
|
|
1677
|
+
className: "pill hud-dock",
|
|
1640
1678
|
role: "toolbar",
|
|
1641
1679
|
"aria-label": `${appSlug} hud`,
|
|
1642
1680
|
"data-corner": placement.corner,
|
|
@@ -1671,37 +1709,960 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1671
1709
|
onClick: () => grabbing ? grab.cancel() : grab.start(),
|
|
1672
1710
|
children: "⌖"
|
|
1673
1711
|
}),
|
|
1674
|
-
/* @__PURE__ */ jsx(PillMenu, {
|
|
1712
|
+
/* @__PURE__ */ jsx(PillMenu, {
|
|
1713
|
+
overflow: hidden,
|
|
1714
|
+
dock: "pill"
|
|
1715
|
+
})
|
|
1675
1716
|
]
|
|
1676
1717
|
});
|
|
1677
1718
|
}
|
|
1719
|
+
/**
|
|
1720
|
+
* How far the rail keeps its contents from the right edge so the page's
|
|
1721
|
+
* scrollbar does not paint over them. A classic scrollbar takes its own
|
|
1722
|
+
* gutter and `position: fixed` resolves inside it, so nothing is needed.
|
|
1723
|
+
* An overlay scrollbar (macOS, mobile) takes none and draws on top of the
|
|
1724
|
+
* rail whenever the page scrolls: then the rail leaves it a lane.
|
|
1725
|
+
*/
|
|
1726
|
+
function scrollbarLane(win = window) {
|
|
1727
|
+
const root = win.document.documentElement;
|
|
1728
|
+
const clientWidth = root.clientWidth;
|
|
1729
|
+
if (!clientWidth) return 0;
|
|
1730
|
+
const scrolls = root.scrollHeight > root.clientHeight;
|
|
1731
|
+
const gutter = win.innerWidth - clientWidth;
|
|
1732
|
+
return scrolls && gutter <= 0 ? 12 : 0;
|
|
1733
|
+
}
|
|
1734
|
+
function subscribe(listener) {
|
|
1735
|
+
const root = document.documentElement;
|
|
1736
|
+
window.addEventListener("resize", listener);
|
|
1737
|
+
if (typeof ResizeObserver === "undefined") return () => window.removeEventListener("resize", listener);
|
|
1738
|
+
const observer = new ResizeObserver(listener);
|
|
1739
|
+
observer.observe(root);
|
|
1740
|
+
if (document.body) observer.observe(document.body);
|
|
1741
|
+
return () => {
|
|
1742
|
+
window.removeEventListener("resize", listener);
|
|
1743
|
+
observer.disconnect();
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
const read = () => scrollbarLane();
|
|
1747
|
+
function useScrollbarLane() {
|
|
1748
|
+
return useSyncExternalStore(subscribe, read, () => 0);
|
|
1749
|
+
}
|
|
1750
|
+
//#endregion
|
|
1751
|
+
//#region src/shell/rail/rail.tsx
|
|
1752
|
+
/** A press that moves less than this is a click, not a drag. */
|
|
1753
|
+
const DRAG_THRESHOLD = 4;
|
|
1754
|
+
/** The round button the rail becomes on a narrow viewport. */
|
|
1755
|
+
const FAB = {
|
|
1756
|
+
width: 44,
|
|
1757
|
+
height: 44
|
|
1758
|
+
};
|
|
1759
|
+
/** Dots on the chip. */
|
|
1760
|
+
const SUMMARY_DOTS = 3;
|
|
1761
|
+
const DefaultIcon = hudIcon("plug");
|
|
1762
|
+
const NO_SIZE = {
|
|
1763
|
+
width: 0,
|
|
1764
|
+
height: 0
|
|
1765
|
+
};
|
|
1766
|
+
/** Plugins that take a rail row: a panel to open, or live pill text to show. */
|
|
1767
|
+
const onRail = (slot) => Boolean(slot.plugin.panel || slot.plugin.pill);
|
|
1768
|
+
/**
|
|
1769
|
+
* Tones of the chip's summary: the badges of the plugins with the highest
|
|
1770
|
+
* priority (then rail order), `off` while a badge reports nothing.
|
|
1771
|
+
*/
|
|
1772
|
+
function summaryTones(slots, badges) {
|
|
1773
|
+
return slots.map((slot, index) => ({
|
|
1774
|
+
slot,
|
|
1775
|
+
index
|
|
1776
|
+
})).filter(({ slot }) => slot.plugin.badge).sort((a, b) => (b.slot.plugin.pillPriority ?? 0) - (a.slot.plugin.pillPriority ?? 0) || a.index - b.index).slice(0, SUMMARY_DOTS).map(({ slot }) => badges[slot.plugin.id]?.tone ?? "off");
|
|
1777
|
+
}
|
|
1778
|
+
/** The FAB's count: every badge count summed, else how many badges are not good. */
|
|
1779
|
+
function badgeTotal(badges) {
|
|
1780
|
+
const list = Object.values(badges).filter((badge) => badge !== null);
|
|
1781
|
+
const counted = list.reduce((sum, badge) => sum + (badge.count ?? 0), 0);
|
|
1782
|
+
if (counted > 0) return counted;
|
|
1783
|
+
return list.filter((badge) => badge.tone === "warn" || badge.tone === "poor").length;
|
|
1784
|
+
}
|
|
1785
|
+
function sameBadge(a, b) {
|
|
1786
|
+
if (!a || !b) return a === b;
|
|
1787
|
+
return a.tone === b.tone && (a.count ?? 0) === (b.count ?? 0);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* One plugin on the rail: its icon with the badge on it and its label (title,
|
|
1791
|
+
* then the live `pill` output). At the icons level the label is a tooltip; at
|
|
1792
|
+
* the labels level, in the phone sheet and while customising it is in the
|
|
1793
|
+
* row. The pill content is mounted from the start, shown or not, since
|
|
1794
|
+
* built-in pills start their capture on mount; a hidden row stays mounted too.
|
|
1795
|
+
*/
|
|
1796
|
+
function RailItem({ slot, open, hidden, editing, inline, onToggle, onBadge, onHide, onMove, onGrip }) {
|
|
1797
|
+
const { plugin, ctx, title } = slot;
|
|
1798
|
+
const Icon = plugin.icon ?? DefaultIcon;
|
|
1799
|
+
const PillContent = plugin.pill;
|
|
1800
|
+
const badge = plugin.badge ? plugin.badge({ ctx }) : null;
|
|
1801
|
+
const tone = badge?.tone;
|
|
1802
|
+
const count = badge?.count ?? 0;
|
|
1803
|
+
useEffect(() => {
|
|
1804
|
+
onBadge(plugin.id, hidden ? null : tone ? {
|
|
1805
|
+
tone,
|
|
1806
|
+
count
|
|
1807
|
+
} : null);
|
|
1808
|
+
}, [
|
|
1809
|
+
onBadge,
|
|
1810
|
+
plugin.id,
|
|
1811
|
+
tone,
|
|
1812
|
+
count,
|
|
1813
|
+
hidden
|
|
1814
|
+
]);
|
|
1815
|
+
if (!onRail(slot)) return null;
|
|
1816
|
+
const glyph = /* @__PURE__ */ jsxs("span", {
|
|
1817
|
+
className: "rail-glyph",
|
|
1818
|
+
children: [/* @__PURE__ */ jsx(Icon, {}), tone && (count > 0 ? /* @__PURE__ */ jsx("span", {
|
|
1819
|
+
className: "rail-count",
|
|
1820
|
+
"data-tone": tone,
|
|
1821
|
+
children: count
|
|
1822
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1823
|
+
className: "rail-badge",
|
|
1824
|
+
"data-tone": tone
|
|
1825
|
+
}))]
|
|
1826
|
+
});
|
|
1827
|
+
const label = /* @__PURE__ */ jsxs("span", {
|
|
1828
|
+
className: "rail-tip",
|
|
1829
|
+
role: inline ? void 0 : "tooltip",
|
|
1830
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1831
|
+
className: "rail-tip-title",
|
|
1832
|
+
children: title
|
|
1833
|
+
}), PillContent && /* @__PURE__ */ jsx("span", {
|
|
1834
|
+
className: "rail-pill",
|
|
1835
|
+
"data-pill-id": plugin.id,
|
|
1836
|
+
children: /* @__PURE__ */ jsx(PillContent, { ctx })
|
|
1837
|
+
})]
|
|
1838
|
+
});
|
|
1839
|
+
const gone = hidden && !editing;
|
|
1840
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1841
|
+
className: "rail-item",
|
|
1842
|
+
"data-rail-id": plugin.id,
|
|
1843
|
+
"data-hidden": hidden || void 0,
|
|
1844
|
+
hidden: gone,
|
|
1845
|
+
inert: gone,
|
|
1846
|
+
children: [
|
|
1847
|
+
editing && /* @__PURE__ */ jsx("button", {
|
|
1848
|
+
type: "button",
|
|
1849
|
+
className: "rail-tool rail-grip",
|
|
1850
|
+
"aria-label": `Drag to move ${title}`,
|
|
1851
|
+
title: "Drag to reorder",
|
|
1852
|
+
onPointerDown: onGrip,
|
|
1853
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "grip" })
|
|
1854
|
+
}),
|
|
1855
|
+
plugin.panel && !editing ? /* @__PURE__ */ jsxs("button", {
|
|
1856
|
+
type: "button",
|
|
1857
|
+
className: "rail-button",
|
|
1858
|
+
"aria-pressed": open,
|
|
1859
|
+
"data-open": open || void 0,
|
|
1860
|
+
onClick: onToggle,
|
|
1861
|
+
children: [glyph, label]
|
|
1862
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
1863
|
+
className: "rail-button",
|
|
1864
|
+
children: [glyph, label]
|
|
1865
|
+
}),
|
|
1866
|
+
editing && /* @__PURE__ */ jsxs("span", {
|
|
1867
|
+
className: "rail-edit",
|
|
1868
|
+
children: [
|
|
1869
|
+
/* @__PURE__ */ jsx("button", {
|
|
1870
|
+
type: "button",
|
|
1871
|
+
className: "rail-tool",
|
|
1872
|
+
"aria-label": `Move ${title} up`,
|
|
1873
|
+
onClick: () => onMove(-1),
|
|
1874
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "chevron-up" })
|
|
1875
|
+
}),
|
|
1876
|
+
/* @__PURE__ */ jsx("button", {
|
|
1877
|
+
type: "button",
|
|
1878
|
+
className: "rail-tool",
|
|
1879
|
+
"aria-label": `Move ${title} down`,
|
|
1880
|
+
onClick: () => onMove(1),
|
|
1881
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "chevron-down" })
|
|
1882
|
+
}),
|
|
1883
|
+
/* @__PURE__ */ jsx("button", {
|
|
1884
|
+
type: "button",
|
|
1885
|
+
className: "rail-tool",
|
|
1886
|
+
role: "switch",
|
|
1887
|
+
"aria-checked": !hidden,
|
|
1888
|
+
"aria-label": `Show ${title} on the rail`,
|
|
1889
|
+
onClick: () => onHide(!hidden),
|
|
1890
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: hidden ? "eye-off" : "eye" })
|
|
1891
|
+
})
|
|
1892
|
+
]
|
|
1893
|
+
})
|
|
1894
|
+
]
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
function railStyle(top, size, reserve, side, visual) {
|
|
1898
|
+
if (visual.detached) {
|
|
1899
|
+
const rect = railRect({ top }, size, {
|
|
1900
|
+
w: visual.w,
|
|
1901
|
+
h: visual.h
|
|
1902
|
+
}, reserve, side);
|
|
1903
|
+
return {
|
|
1904
|
+
top: visual.y + rect.top,
|
|
1905
|
+
left: visual.x + rect.left,
|
|
1906
|
+
right: "auto",
|
|
1907
|
+
bottom: "auto"
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
return {
|
|
1911
|
+
top,
|
|
1912
|
+
bottom: "auto",
|
|
1913
|
+
left: side === "left" ? reserve.left : "auto",
|
|
1914
|
+
right: side === "right" ? reserve.right : "auto"
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* The edge rail: the default dock. Three detail levels, cycled by the env
|
|
1919
|
+
* chip and ⌘⇧D: the chip alone with summary dots, an icon strip with tooltips,
|
|
1920
|
+
* or a labelled strip with title and live pill text per row. At the strip
|
|
1921
|
+
* levels it spans the full height of its edge, square and flat: the head at
|
|
1922
|
+
* the top, the rows under it, the tools at the bottom. The chip alone moves
|
|
1923
|
+
* off a host fixed element. Customise rail (⋯ menu) lets the user hide
|
|
1924
|
+
* rows and reorder them by drag or arrows. Side, level, order and hidden rows
|
|
1925
|
+
* persist per app. Below 900 px it is one round button bottom-right that
|
|
1926
|
+
* opens a grid sheet of every plugin.
|
|
1927
|
+
*/
|
|
1928
|
+
function Rail({ appSlug, envLabel, slots, grab }) {
|
|
1929
|
+
const panels = usePanels();
|
|
1930
|
+
const { grabbing } = useGrab(grab);
|
|
1931
|
+
const visual = useVisualViewport();
|
|
1932
|
+
const lane = useScrollbarLane();
|
|
1933
|
+
const viewport = useMemo(() => ({
|
|
1934
|
+
w: visual.w,
|
|
1935
|
+
h: visual.h
|
|
1936
|
+
}), [visual.w, visual.h]);
|
|
1937
|
+
const rawObstacles = useObstacles();
|
|
1938
|
+
const obstacles = useMemo(() => offsetObstacles(rawObstacles, {
|
|
1939
|
+
x: visual.x,
|
|
1940
|
+
y: visual.y
|
|
1941
|
+
}), [
|
|
1942
|
+
rawObstacles,
|
|
1943
|
+
visual.x,
|
|
1944
|
+
visual.y
|
|
1945
|
+
]);
|
|
1946
|
+
const mode = isNarrow(viewport) ? "fab" : "rail";
|
|
1947
|
+
const { side, detail, reserve, hiddenItems } = panels;
|
|
1948
|
+
const [editing, setEditing] = useState(false);
|
|
1949
|
+
/** The level the rows lay out at: customising always shows the labels. */
|
|
1950
|
+
const level = editing ? "labels" : detail;
|
|
1951
|
+
const strip = mode === "rail" && level !== "chip";
|
|
1952
|
+
const ref = useRef(null);
|
|
1953
|
+
const bodyRef = useRef(null);
|
|
1954
|
+
const listRef = useRef(null);
|
|
1955
|
+
const midRef = useRef(null);
|
|
1956
|
+
const [size, setSize] = useState(NO_SIZE);
|
|
1957
|
+
/** The rows outgrow the strip: the middle section scrolls (and clips its tooltips). */
|
|
1958
|
+
const [scrolls, setScrolls] = useState(false);
|
|
1959
|
+
const [badges, setBadges] = useState({});
|
|
1960
|
+
const [sheet, setSheet] = useState(false);
|
|
1961
|
+
const [drag, setDrag] = useState(null);
|
|
1962
|
+
const [dragging, setDragging] = useState(null);
|
|
1963
|
+
const press = useRef(null);
|
|
1964
|
+
const dragged = useRef(false);
|
|
1965
|
+
const rows = useMemo(() => slots.filter(onRail), [slots]);
|
|
1966
|
+
const ids = useMemo(() => railOrder(rows.map((slot) => slot.plugin.id), panels.order), [rows, panels.order]);
|
|
1967
|
+
const ordered = useMemo(() => ids.flatMap((id) => {
|
|
1968
|
+
const slot = rows.find((row) => row.plugin.id === id);
|
|
1969
|
+
return slot ? [slot] : [];
|
|
1970
|
+
}), [ids, rows]);
|
|
1971
|
+
const shown = useMemo(() => ordered.filter((slot) => !hiddenItems.includes(slot.plugin.id)), [ordered, hiddenItems]);
|
|
1972
|
+
const onBadge = useCallback((id, badge) => {
|
|
1973
|
+
setBadges((prev) => sameBadge(prev[id], badge) ? prev : {
|
|
1974
|
+
...prev,
|
|
1975
|
+
[id]: badge
|
|
1976
|
+
});
|
|
1977
|
+
}, []);
|
|
1978
|
+
useRegisterCommands(useMemo(() => [{
|
|
1979
|
+
id: "hud.customise-rail",
|
|
1980
|
+
title: "Customise rail",
|
|
1981
|
+
run: () => setEditing(true)
|
|
1982
|
+
}], []));
|
|
1983
|
+
useLayoutEffect(() => {
|
|
1984
|
+
const body = bodyRef.current;
|
|
1985
|
+
const mid = midRef.current;
|
|
1986
|
+
if (!body || !mid) return;
|
|
1987
|
+
const update = () => {
|
|
1988
|
+
setSize((prev) => prev.width === body.offsetWidth && prev.height === body.offsetHeight ? prev : {
|
|
1989
|
+
width: body.offsetWidth,
|
|
1990
|
+
height: body.offsetHeight
|
|
1991
|
+
});
|
|
1992
|
+
setScrolls(mid.scrollHeight > mid.clientHeight + 1);
|
|
1993
|
+
};
|
|
1994
|
+
update();
|
|
1995
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1996
|
+
const observer = new ResizeObserver(update);
|
|
1997
|
+
observer.observe(body);
|
|
1998
|
+
observer.observe(mid);
|
|
1999
|
+
return () => observer.disconnect();
|
|
2000
|
+
}, []);
|
|
2001
|
+
const dismissable = mode === "fab" && sheet || editing;
|
|
2002
|
+
useEffect(() => {
|
|
2003
|
+
if (!dismissable) return;
|
|
2004
|
+
const onPointerDown = (e) => {
|
|
2005
|
+
if (ref.current && !e.composedPath().includes(ref.current)) {
|
|
2006
|
+
setSheet(false);
|
|
2007
|
+
setEditing(false);
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
const onKeyDown = (e) => {
|
|
2011
|
+
if (e.key === "Escape") {
|
|
2012
|
+
setSheet(false);
|
|
2013
|
+
setEditing(false);
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
window.addEventListener("pointerdown", onPointerDown, true);
|
|
2017
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
2018
|
+
return () => {
|
|
2019
|
+
window.removeEventListener("pointerdown", onPointerDown, true);
|
|
2020
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
2021
|
+
};
|
|
2022
|
+
}, [dismissable]);
|
|
2023
|
+
const placed = useMemo(() => {
|
|
2024
|
+
if (mode === "fab" || strip) return null;
|
|
2025
|
+
return placeRail({
|
|
2026
|
+
viewport,
|
|
2027
|
+
size,
|
|
2028
|
+
obstacles,
|
|
2029
|
+
reserve,
|
|
2030
|
+
side
|
|
2031
|
+
});
|
|
2032
|
+
}, [
|
|
2033
|
+
mode,
|
|
2034
|
+
strip,
|
|
2035
|
+
viewport,
|
|
2036
|
+
size,
|
|
2037
|
+
obstacles,
|
|
2038
|
+
reserve,
|
|
2039
|
+
side
|
|
2040
|
+
]);
|
|
2041
|
+
const style = useMemo(() => {
|
|
2042
|
+
if (mode === "fab") return placementStyle(placePill({
|
|
2043
|
+
viewport,
|
|
2044
|
+
size: FAB,
|
|
2045
|
+
obstacles,
|
|
2046
|
+
reserve,
|
|
2047
|
+
pinned: "bottom-right"
|
|
2048
|
+
}) ?? {
|
|
2049
|
+
corner: "bottom-right",
|
|
2050
|
+
shift: 0
|
|
2051
|
+
}, FAB, reserve, visual);
|
|
2052
|
+
const top = placed?.top ?? 0;
|
|
2053
|
+
if (!strip) return railStyle(top, size, reserve, side, visual);
|
|
2054
|
+
const edge = railStyle(0, size, reserve, side, visual);
|
|
2055
|
+
return visual.detached ? {
|
|
2056
|
+
...edge,
|
|
2057
|
+
height: visual.h,
|
|
2058
|
+
width: size.width
|
|
2059
|
+
} : {
|
|
2060
|
+
...edge,
|
|
2061
|
+
top: 0,
|
|
2062
|
+
bottom: reserve.bottom,
|
|
2063
|
+
width: size.width
|
|
2064
|
+
};
|
|
2065
|
+
}, [
|
|
2066
|
+
mode,
|
|
2067
|
+
strip,
|
|
2068
|
+
placed,
|
|
2069
|
+
viewport,
|
|
2070
|
+
size,
|
|
2071
|
+
obstacles,
|
|
2072
|
+
reserve,
|
|
2073
|
+
side,
|
|
2074
|
+
visual
|
|
2075
|
+
]);
|
|
2076
|
+
const onPointerDown = (e) => {
|
|
2077
|
+
if (e.button !== 0 || mode !== "rail") return;
|
|
2078
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2079
|
+
press.current = {
|
|
2080
|
+
x: e.clientX,
|
|
2081
|
+
y: e.clientY,
|
|
2082
|
+
moved: false
|
|
2083
|
+
};
|
|
2084
|
+
};
|
|
2085
|
+
const onPointerMove = (e) => {
|
|
2086
|
+
const start = press.current;
|
|
2087
|
+
if (!start) return;
|
|
2088
|
+
const x = e.clientX - start.x;
|
|
2089
|
+
const y = e.clientY - start.y;
|
|
2090
|
+
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD) return;
|
|
2091
|
+
start.moved = true;
|
|
2092
|
+
setDrag({
|
|
2093
|
+
x,
|
|
2094
|
+
y
|
|
2095
|
+
});
|
|
2096
|
+
};
|
|
2097
|
+
const onPointerUp = (e) => {
|
|
2098
|
+
const start = press.current;
|
|
2099
|
+
press.current = null;
|
|
2100
|
+
setDrag(null);
|
|
2101
|
+
if (!start?.moved) return;
|
|
2102
|
+
dragged.current = true;
|
|
2103
|
+
panels.setSide(nearestSide(e.clientX, viewport));
|
|
2104
|
+
};
|
|
2105
|
+
const onChipClick = () => {
|
|
2106
|
+
if (dragged.current) {
|
|
2107
|
+
dragged.current = false;
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
if (mode === "fab") setSheet((open) => !open);
|
|
2111
|
+
else if (editing) setEditing(false);
|
|
2112
|
+
else panels.setDetail({
|
|
2113
|
+
chip: "icons",
|
|
2114
|
+
icons: "labels",
|
|
2115
|
+
labels: "chip"
|
|
2116
|
+
}[detail]);
|
|
2117
|
+
};
|
|
2118
|
+
/** Drag a row's grip: the row follows the pointer through the list, the order updates live. */
|
|
2119
|
+
const onGrip = (id) => (e) => {
|
|
2120
|
+
if (e.button !== 0) return;
|
|
2121
|
+
const grip = e.currentTarget;
|
|
2122
|
+
grip.setPointerCapture(e.pointerId);
|
|
2123
|
+
setDragging(id);
|
|
2124
|
+
const move = (event) => {
|
|
2125
|
+
const list = listRef.current;
|
|
2126
|
+
if (!list) return;
|
|
2127
|
+
const index = [...list.querySelectorAll("[data-rail-id]")].filter((row) => row.dataset.railId !== id).filter((row) => {
|
|
2128
|
+
const box = row.getBoundingClientRect();
|
|
2129
|
+
return box.top + box.height / 2 < event.clientY;
|
|
2130
|
+
}).length;
|
|
2131
|
+
panels.moveItem(ids, id, index);
|
|
2132
|
+
};
|
|
2133
|
+
const up = () => {
|
|
2134
|
+
grip.removeEventListener("pointermove", move);
|
|
2135
|
+
grip.removeEventListener("pointerup", up);
|
|
2136
|
+
grip.removeEventListener("pointercancel", up);
|
|
2137
|
+
setDragging(null);
|
|
2138
|
+
};
|
|
2139
|
+
grip.addEventListener("pointermove", move);
|
|
2140
|
+
grip.addEventListener("pointerup", up);
|
|
2141
|
+
grip.addEventListener("pointercancel", up);
|
|
2142
|
+
};
|
|
2143
|
+
const listHidden = mode === "fab" ? !sheet : level === "chip";
|
|
2144
|
+
const total = badgeTotal(badges);
|
|
2145
|
+
const chipTitle = mode === "fab" ? `${envLabel} HUD` : editing ? "Done customising" : "Click for the next detail level · ⌘⇧D · drag to the other edge";
|
|
2146
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2147
|
+
ref,
|
|
2148
|
+
className: "rail hud-dock",
|
|
2149
|
+
role: "toolbar",
|
|
2150
|
+
"aria-label": `${appSlug} hud`,
|
|
2151
|
+
"data-side": side,
|
|
2152
|
+
"data-mode": mode,
|
|
2153
|
+
"data-detail": level,
|
|
2154
|
+
"data-editing": editing || void 0,
|
|
2155
|
+
"data-dragging": drag ? true : void 0,
|
|
2156
|
+
style: {
|
|
2157
|
+
...style,
|
|
2158
|
+
"--rail-lane": `${side === "right" && mode === "rail" ? lane : 0}px`,
|
|
2159
|
+
...drag ? { transform: `translate(${drag.x}px, ${drag.y}px)` } : {}
|
|
2160
|
+
},
|
|
2161
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2162
|
+
ref: bodyRef,
|
|
2163
|
+
className: "rail-body",
|
|
2164
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2165
|
+
className: "rail-top",
|
|
2166
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2167
|
+
className: "rail-head",
|
|
2168
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
2169
|
+
type: "button",
|
|
2170
|
+
className: "rail-chip env",
|
|
2171
|
+
"aria-label": `${envLabel} HUD`,
|
|
2172
|
+
"aria-expanded": !listHidden,
|
|
2173
|
+
title: chipTitle,
|
|
2174
|
+
onClick: onChipClick,
|
|
2175
|
+
onPointerDown,
|
|
2176
|
+
onPointerMove,
|
|
2177
|
+
onPointerUp,
|
|
2178
|
+
onPointerCancel: () => {
|
|
2179
|
+
press.current = null;
|
|
2180
|
+
setDrag(null);
|
|
2181
|
+
},
|
|
2182
|
+
children: mode === "fab" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HudIconGlyph, { name: "wrench" }), total > 0 && /* @__PURE__ */ jsx("span", {
|
|
2183
|
+
className: "rail-count",
|
|
2184
|
+
children: total
|
|
2185
|
+
})] }) : envLabel
|
|
2186
|
+
}), editing && /* @__PURE__ */ jsx("button", {
|
|
2187
|
+
type: "button",
|
|
2188
|
+
className: "rail-done",
|
|
2189
|
+
onClick: () => setEditing(false),
|
|
2190
|
+
children: "Done"
|
|
2191
|
+
})]
|
|
2192
|
+
}), mode === "rail" && level === "chip" && /* @__PURE__ */ jsx("span", {
|
|
2193
|
+
className: "rail-dots",
|
|
2194
|
+
"aria-hidden": "true",
|
|
2195
|
+
children: summaryTones(shown, badges).map((tone, i) => /* @__PURE__ */ jsx("span", {
|
|
2196
|
+
className: "dot",
|
|
2197
|
+
"data-tone": tone
|
|
2198
|
+
}, i))
|
|
2199
|
+
})]
|
|
2200
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2201
|
+
ref: listRef,
|
|
2202
|
+
className: "rail-list",
|
|
2203
|
+
inert: listHidden,
|
|
2204
|
+
children: [
|
|
2205
|
+
mode === "fab" && /* @__PURE__ */ jsxs("div", {
|
|
2206
|
+
className: "rail-sheet-head",
|
|
2207
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2208
|
+
className: "env",
|
|
2209
|
+
children: envLabel
|
|
2210
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
2211
|
+
type: "button",
|
|
2212
|
+
className: "rail-button rail-close",
|
|
2213
|
+
"aria-label": "Close HUD sheet",
|
|
2214
|
+
onClick: () => setSheet(false),
|
|
2215
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "x" })
|
|
2216
|
+
})]
|
|
2217
|
+
}),
|
|
2218
|
+
/* @__PURE__ */ jsx("div", {
|
|
2219
|
+
ref: midRef,
|
|
2220
|
+
className: "rail-mid",
|
|
2221
|
+
"data-scroll": scrolls || void 0,
|
|
2222
|
+
children: ordered.map((slot, index) => /* @__PURE__ */ jsx(RailItem, {
|
|
2223
|
+
slot,
|
|
2224
|
+
open: panels.isOpen(slot.plugin.id),
|
|
2225
|
+
hidden: hiddenItems.includes(slot.plugin.id),
|
|
2226
|
+
editing,
|
|
2227
|
+
inline: level === "labels" || mode === "fab",
|
|
2228
|
+
onToggle: () => panels.toggle(slot.plugin.id),
|
|
2229
|
+
onBadge,
|
|
2230
|
+
onHide: (hidden) => panels.setItemHidden(slot.plugin.id, hidden),
|
|
2231
|
+
onMove: (delta) => panels.moveItem(ids, slot.plugin.id, index + delta),
|
|
2232
|
+
onGrip: onGrip(slot.plugin.id)
|
|
2233
|
+
}, slot.plugin.id))
|
|
2234
|
+
}),
|
|
2235
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2236
|
+
className: "rail-bottom",
|
|
2237
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2238
|
+
className: "rail-item",
|
|
2239
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
2240
|
+
type: "button",
|
|
2241
|
+
className: "rail-button grab-toggle",
|
|
2242
|
+
"aria-label": "Grab element",
|
|
2243
|
+
"aria-pressed": grabbing,
|
|
2244
|
+
onClick: () => grabbing ? grab.cancel() : grab.start(),
|
|
2245
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2246
|
+
className: "rail-glyph",
|
|
2247
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "crosshair" })
|
|
2248
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2249
|
+
className: "rail-tip",
|
|
2250
|
+
role: "tooltip",
|
|
2251
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2252
|
+
className: "rail-tip-title",
|
|
2253
|
+
children: "Grab element"
|
|
2254
|
+
})
|
|
2255
|
+
})]
|
|
2256
|
+
})
|
|
2257
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2258
|
+
className: "rail-item",
|
|
2259
|
+
children: /* @__PURE__ */ jsx(PillMenu, {
|
|
2260
|
+
dock: "rail",
|
|
2261
|
+
inline: mode === "fab"
|
|
2262
|
+
})
|
|
2263
|
+
})]
|
|
2264
|
+
})
|
|
2265
|
+
]
|
|
2266
|
+
})]
|
|
2267
|
+
}), dragging && /* @__PURE__ */ jsx("span", {
|
|
2268
|
+
className: "rail-drag-hint",
|
|
2269
|
+
"aria-hidden": "true"
|
|
2270
|
+
})]
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
1678
2273
|
//#endregion
|
|
1679
2274
|
//#region src/shell/hud.tsx
|
|
1680
|
-
const CSS = HUD_CSS + PANEL_CSS +
|
|
2275
|
+
const CSS = HUD_CSS + PANEL_CSS + `
|
|
2276
|
+
.rail {
|
|
2277
|
+
--hud-bg: rgba(24, 24, 27, 0.94);
|
|
2278
|
+
--hud-bg-subtle: rgba(255, 255, 255, 0.08);
|
|
2279
|
+
--hud-fg: #f4f4f5;
|
|
2280
|
+
--hud-fg-muted: #a1a1aa;
|
|
2281
|
+
--hud-border: rgba(255, 255, 255, 0.1);
|
|
2282
|
+
--hud-accent: #7dd3fc;
|
|
2283
|
+
--hud-accent-fg: #082f49;
|
|
2284
|
+
--hud-good: #4ade80;
|
|
2285
|
+
--hud-warn: #fbbf24;
|
|
2286
|
+
--hud-poor: #f87171;
|
|
2287
|
+
--hud-off: #71717a;
|
|
2288
|
+
--hud-shadow: -4px 0 20px rgba(0, 0, 0, 0.18);
|
|
2289
|
+
|
|
2290
|
+
position: fixed;
|
|
2291
|
+
/* Above floating panels (1..n) and the bottom sheet (1000): the dock, its tooltips and its menu stay reachable. */
|
|
2292
|
+
z-index: 1001;
|
|
2293
|
+
display: flex;
|
|
2294
|
+
flex-direction: column;
|
|
2295
|
+
align-items: stretch;
|
|
2296
|
+
background: var(--hud-bg);
|
|
2297
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2298
|
+
backdrop-filter: blur(10px);
|
|
2299
|
+
border: 1px solid var(--hud-border);
|
|
2300
|
+
border-right: 0;
|
|
2301
|
+
border-radius: 10px 0 0 10px;
|
|
2302
|
+
box-shadow: var(--hud-shadow);
|
|
2303
|
+
color: var(--hud-fg);
|
|
2304
|
+
font-family: var(--hud-mono);
|
|
2305
|
+
font-size: 11px;
|
|
2306
|
+
line-height: 1;
|
|
2307
|
+
pointer-events: auto;
|
|
2308
|
+
transition: top 0.18s ease;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
.rail[data-side="left"] {
|
|
2312
|
+
--hud-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
|
|
2313
|
+
border-right: 1px solid var(--hud-border);
|
|
2314
|
+
border-left: 0;
|
|
2315
|
+
border-radius: 0 10px 10px 0;
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
.rail[data-dragging] { opacity: 0.85; transition: none; }
|
|
2319
|
+
|
|
2320
|
+
/* Three sections: the head (chip, dots), the plugin rows, the tools (grab, menu). The
|
|
2321
|
+
right-docked body also leaves the page's overlay scrollbar its lane (\`--rail-lane\`). */
|
|
2322
|
+
.rail-body {
|
|
2323
|
+
display: flex;
|
|
2324
|
+
flex-direction: column;
|
|
2325
|
+
padding: 0 var(--rail-lane, 0px) 0 0;
|
|
2326
|
+
}
|
|
2327
|
+
.rail-top, .rail-bottom {
|
|
2328
|
+
display: flex;
|
|
2329
|
+
flex-direction: column;
|
|
2330
|
+
gap: 2px;
|
|
2331
|
+
padding: 4px;
|
|
2332
|
+
background: var(--hud-zone, rgba(255, 255, 255, 0.04));
|
|
2333
|
+
}
|
|
2334
|
+
.rail-top { border-bottom: 1px solid var(--hud-border); }
|
|
2335
|
+
.rail-bottom { border-top: 1px solid var(--hud-border); }
|
|
2336
|
+
.rail-mid { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; }
|
|
2337
|
+
/* The strip: the rows take the room between the head and the tools, aligned under the head;
|
|
2338
|
+
too many of them and the middle section scrolls between the two pinned sections. */
|
|
2339
|
+
.rail[data-mode="rail"] .rail-list,
|
|
2340
|
+
.rail[data-mode="rail"] .rail-mid { flex: 1; min-height: 0; }
|
|
2341
|
+
.rail[data-mode="rail"] .rail-mid[data-scroll] { overflow-y: auto; scrollbar-width: thin; }
|
|
2342
|
+
|
|
2343
|
+
/* Icons and labels: a flat strip down the whole edge, the head at its top and the tools at its bottom. */
|
|
2344
|
+
.rail[data-mode="rail"]:not([data-detail="chip"]) {
|
|
2345
|
+
border-radius: 0;
|
|
2346
|
+
box-shadow: none;
|
|
2347
|
+
border-top: 0;
|
|
2348
|
+
border-bottom: 0;
|
|
2349
|
+
transition: none;
|
|
2350
|
+
}
|
|
2351
|
+
.rail[data-mode="rail"]:not([data-detail="chip"]) .rail-body {
|
|
2352
|
+
/* Shrink-wraps its rows; the strip takes its measured width (no right: 0, or the two would size each other). */
|
|
2353
|
+
position: absolute;
|
|
2354
|
+
top: 0;
|
|
2355
|
+
bottom: 0;
|
|
2356
|
+
left: 0;
|
|
2357
|
+
}
|
|
2358
|
+
.rail[data-detail="labels"] .rail-body { width: calc(224px + var(--rail-lane, 0px)); }
|
|
2359
|
+
|
|
2360
|
+
.rail-head { display: flex; align-items: center; gap: 4px; }
|
|
2361
|
+
.hud .rail-chip {
|
|
2362
|
+
flex: 1;
|
|
2363
|
+
display: flex;
|
|
2364
|
+
align-items: center;
|
|
2365
|
+
justify-content: center;
|
|
2366
|
+
height: 24px;
|
|
2367
|
+
min-width: 28px;
|
|
2368
|
+
border-radius: 5px;
|
|
2369
|
+
background: var(--hud-bg-subtle);
|
|
2370
|
+
color: var(--hud-accent);
|
|
2371
|
+
font-size: 9px;
|
|
2372
|
+
font-weight: 600;
|
|
2373
|
+
letter-spacing: 0.08em;
|
|
2374
|
+
cursor: grab;
|
|
2375
|
+
touch-action: none;
|
|
2376
|
+
user-select: none;
|
|
2377
|
+
}
|
|
2378
|
+
.hud .rail-chip:hover { background: var(--hud-border); }
|
|
2379
|
+
.rail[data-dragging] .rail-chip { cursor: grabbing; }
|
|
2380
|
+
.rail[data-detail="chip"] .rail-chip { height: 28px; min-width: 36px; }
|
|
2381
|
+
.hud .rail-done {
|
|
2382
|
+
padding: 0 8px;
|
|
2383
|
+
height: 24px;
|
|
2384
|
+
border-radius: 5px;
|
|
2385
|
+
background: var(--hud-accent);
|
|
2386
|
+
color: var(--hud-accent-fg);
|
|
2387
|
+
font-weight: 600;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
.rail-dots { display: flex; justify-content: center; gap: 3px; padding: 4px 0 2px; }
|
|
2391
|
+
.rail .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hud-off); }
|
|
2392
|
+
.rail .dot[data-tone="good"] { background: var(--hud-good); }
|
|
2393
|
+
.rail .dot[data-tone="warn"] { background: var(--hud-warn); }
|
|
2394
|
+
.rail .dot[data-tone="poor"] { background: var(--hud-poor); }
|
|
2395
|
+
|
|
2396
|
+
.rail-list { display: flex; flex-direction: column; overflow: visible; }
|
|
2397
|
+
.rail[data-detail="chip"] .rail-list { display: none; }
|
|
2398
|
+
.rail[data-detail="chip"] .rail-top { border-bottom: 0; background: none; }
|
|
2399
|
+
|
|
2400
|
+
.rail-item { position: relative; display: flex; align-items: center; gap: 2px; }
|
|
2401
|
+
.rail-item[hidden] { display: none; }
|
|
2402
|
+
.rail-item[data-hidden] .rail-button { opacity: 0.45; }
|
|
2403
|
+
|
|
2404
|
+
.hud .rail-button {
|
|
2405
|
+
position: relative;
|
|
2406
|
+
display: flex;
|
|
2407
|
+
align-items: center;
|
|
2408
|
+
justify-content: center;
|
|
2409
|
+
width: 28px;
|
|
2410
|
+
height: 28px;
|
|
2411
|
+
border-radius: 6px;
|
|
2412
|
+
color: var(--hud-fg-muted);
|
|
2413
|
+
}
|
|
2414
|
+
.hud .rail-button:hover,
|
|
2415
|
+
.hud .rail-button[aria-pressed="true"] { background: var(--hud-bg-subtle); color: var(--hud-fg); }
|
|
2416
|
+
.hud .rail-button[data-open] { color: var(--hud-accent); }
|
|
2417
|
+
.hud span.rail-button:hover { background: none; }
|
|
2418
|
+
|
|
2419
|
+
.rail-glyph { position: relative; display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; flex: none; }
|
|
2420
|
+
.rail .icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
|
|
2421
|
+
.rail-chip .icon { width: 18px; height: 18px; }
|
|
2422
|
+
|
|
2423
|
+
.rail-badge { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--hud-off); }
|
|
2424
|
+
.rail-badge[data-tone="good"] { background: var(--hud-good); }
|
|
2425
|
+
.rail-badge[data-tone="warn"] { background: var(--hud-warn); }
|
|
2426
|
+
.rail-badge[data-tone="poor"] { background: var(--hud-poor); }
|
|
2427
|
+
|
|
2428
|
+
.rail-count {
|
|
2429
|
+
position: absolute;
|
|
2430
|
+
top: 1px;
|
|
2431
|
+
right: 1px;
|
|
2432
|
+
display: flex;
|
|
2433
|
+
align-items: center;
|
|
2434
|
+
justify-content: center;
|
|
2435
|
+
min-width: 13px;
|
|
2436
|
+
height: 13px;
|
|
2437
|
+
padding: 0 3px;
|
|
2438
|
+
border-radius: 7px;
|
|
2439
|
+
background: var(--hud-poor);
|
|
2440
|
+
color: #fff;
|
|
2441
|
+
font-size: 9px;
|
|
2442
|
+
font-weight: 600;
|
|
2443
|
+
line-height: 1;
|
|
2444
|
+
}
|
|
2445
|
+
.rail-count[data-tone="good"] { background: var(--hud-good); color: #052e16; }
|
|
2446
|
+
.rail-count[data-tone="warn"] { background: var(--hud-warn); color: #451a03; }
|
|
2447
|
+
.rail-count[data-tone="off"] { background: var(--hud-off); }
|
|
2448
|
+
|
|
2449
|
+
/* Icons level: the label is a tooltip beside the rail, away from the edge. Its pill content is always mounted. */
|
|
2450
|
+
.rail-tip {
|
|
2451
|
+
position: absolute;
|
|
2452
|
+
top: 50%;
|
|
2453
|
+
right: calc(100% + 10px);
|
|
2454
|
+
display: flex;
|
|
2455
|
+
align-items: center;
|
|
2456
|
+
gap: 6px;
|
|
2457
|
+
padding: 6px 9px;
|
|
2458
|
+
border: 1px solid var(--hud-border);
|
|
2459
|
+
border-radius: 7px;
|
|
2460
|
+
background: var(--hud-bg);
|
|
2461
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2462
|
+
backdrop-filter: blur(10px);
|
|
2463
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
|
|
2464
|
+
color: var(--hud-fg);
|
|
2465
|
+
white-space: nowrap;
|
|
2466
|
+
transform: translateY(-50%);
|
|
2467
|
+
opacity: 0;
|
|
2468
|
+
visibility: hidden;
|
|
2469
|
+
pointer-events: none;
|
|
2470
|
+
transition: opacity 0.12s;
|
|
2471
|
+
}
|
|
2472
|
+
.rail[data-side="left"] .rail-tip { right: auto; left: calc(100% + 10px); }
|
|
2473
|
+
.rail-button:hover .rail-tip,
|
|
2474
|
+
.rail-button:focus-visible .rail-tip { opacity: 1; visibility: visible; }
|
|
2475
|
+
.rail-tip-title { font-weight: 600; }
|
|
2476
|
+
/* In the tooltip the live pill sits behind a hairline, like the rail's own sections. */
|
|
2477
|
+
.rail-pill {
|
|
2478
|
+
display: inline-flex;
|
|
2479
|
+
align-items: center;
|
|
2480
|
+
gap: 6px;
|
|
2481
|
+
padding-left: 8px;
|
|
2482
|
+
border-left: 1px solid var(--hud-border);
|
|
2483
|
+
color: var(--hud-fg-muted);
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
/* Labels level and the phone sheet: the label sits in the row. */
|
|
2487
|
+
.rail[data-detail="labels"] .rail-item,
|
|
2488
|
+
.rail[data-mode="fab"] .rail-item { min-width: 0; }
|
|
2489
|
+
.hud .rail[data-detail="labels"] .rail-button,
|
|
2490
|
+
.hud .rail[data-mode="fab"] .rail-button {
|
|
2491
|
+
flex: 1;
|
|
2492
|
+
width: auto;
|
|
2493
|
+
height: auto;
|
|
2494
|
+
min-width: 0;
|
|
2495
|
+
justify-content: flex-start;
|
|
2496
|
+
gap: 4px;
|
|
2497
|
+
padding: 2px 6px 2px 0;
|
|
2498
|
+
}
|
|
2499
|
+
.rail[data-detail="labels"] .rail-tip,
|
|
2500
|
+
.rail[data-mode="fab"] .rail-tip {
|
|
2501
|
+
position: static;
|
|
2502
|
+
min-width: 0;
|
|
2503
|
+
transform: none;
|
|
2504
|
+
opacity: 1;
|
|
2505
|
+
visibility: visible;
|
|
2506
|
+
padding: 0;
|
|
2507
|
+
border: 0;
|
|
2508
|
+
background: none;
|
|
2509
|
+
pointer-events: auto;
|
|
2510
|
+
}
|
|
2511
|
+
.rail[data-detail="labels"] .rail-pill,
|
|
2512
|
+
.rail[data-mode="fab"] .rail-pill { min-width: 0; overflow: hidden; padding-left: 0; border-left: 0; }
|
|
2513
|
+
.rail[data-detail="labels"] .rail-pill::before,
|
|
2514
|
+
.rail[data-mode="fab"] .rail-pill::before { content: "·"; color: var(--hud-fg-muted); }
|
|
2515
|
+
.rail[data-detail="labels"] .rail-pill > :last-child,
|
|
2516
|
+
.rail[data-mode="fab"] .rail-pill > :last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2517
|
+
|
|
2518
|
+
/* Customise rail: grip, arrows and the show switch per row. */
|
|
2519
|
+
.hud .rail-tool {
|
|
2520
|
+
display: flex;
|
|
2521
|
+
align-items: center;
|
|
2522
|
+
justify-content: center;
|
|
2523
|
+
width: 20px;
|
|
2524
|
+
height: 24px;
|
|
2525
|
+
border-radius: 4px;
|
|
2526
|
+
color: var(--hud-fg-muted);
|
|
2527
|
+
flex: none;
|
|
2528
|
+
}
|
|
2529
|
+
.hud .rail-tool:hover { background: var(--hud-bg-subtle); color: var(--hud-fg); }
|
|
2530
|
+
.hud .rail-grip { cursor: grab; touch-action: none; }
|
|
2531
|
+
.hud .rail-grip:active { cursor: grabbing; }
|
|
2532
|
+
.rail-edit { display: flex; gap: 0; flex: none; }
|
|
2533
|
+
.hud .rail-tool[role="switch"][aria-checked="true"] { color: var(--hud-accent); }
|
|
2534
|
+
|
|
2535
|
+
/* The menu opens beside the rail, from its bottom item, in the rail's own language:
|
|
2536
|
+
tinted section heads behind hairlines, mono type, flat rows. */
|
|
2537
|
+
.rail .menu { left: auto; right: calc(100% + 10px); top: auto; bottom: 0; }
|
|
2538
|
+
.rail[data-side="left"] .menu { right: auto; left: calc(100% + 10px); }
|
|
2539
|
+
.rail[data-mode="rail"] .menu {
|
|
2540
|
+
padding: 0 0 4px;
|
|
2541
|
+
border-radius: 8px;
|
|
2542
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2543
|
+
backdrop-filter: blur(10px);
|
|
2544
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
|
2545
|
+
font-family: var(--hud-mono);
|
|
2546
|
+
font-size: 11px;
|
|
2547
|
+
}
|
|
2548
|
+
.rail[data-mode="rail"] .menu-label {
|
|
2549
|
+
padding: 6px 8px;
|
|
2550
|
+
margin-bottom: 4px;
|
|
2551
|
+
background: var(--hud-zone, rgba(255, 255, 255, 0.04));
|
|
2552
|
+
border-bottom: 1px solid var(--hud-border);
|
|
2553
|
+
}
|
|
2554
|
+
.rail[data-mode="rail"] .menu-label:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--hud-border); }
|
|
2555
|
+
.hud .rail[data-mode="rail"] .menu-item { margin: 0 4px; border-radius: 5px; }
|
|
2556
|
+
|
|
2557
|
+
/* Phone: one round button bottom-right; the list is a grid sheet above it. */
|
|
2558
|
+
.rail[data-mode="fab"] {
|
|
2559
|
+
--hud-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
|
|
2560
|
+
border: 0;
|
|
2561
|
+
background: none;
|
|
2562
|
+
-webkit-backdrop-filter: none;
|
|
2563
|
+
backdrop-filter: none;
|
|
2564
|
+
box-shadow: none;
|
|
2565
|
+
border-radius: 0;
|
|
2566
|
+
}
|
|
2567
|
+
.rail[data-mode="fab"] .rail-body { padding: 0; }
|
|
2568
|
+
.rail[data-mode="fab"] .rail-top { padding: 0; background: none; border: 0; }
|
|
2569
|
+
.rail[data-mode="fab"] .rail-mid,
|
|
2570
|
+
.rail[data-mode="fab"] .rail-bottom { display: contents; }
|
|
2571
|
+
.rail[data-mode="fab"] .rail-bottom > .rail-item:first-child { margin-top: 4px; border-top: 1px solid var(--hud-border); padding-top: 4px; grid-column: 1 / -1; }
|
|
2572
|
+
.hud .rail[data-mode="fab"] .rail-chip {
|
|
2573
|
+
position: relative;
|
|
2574
|
+
flex: none;
|
|
2575
|
+
width: 44px;
|
|
2576
|
+
height: 44px;
|
|
2577
|
+
min-width: 0;
|
|
2578
|
+
border-radius: 50%;
|
|
2579
|
+
background: var(--hud-bg);
|
|
2580
|
+
border: 1px solid var(--hud-border);
|
|
2581
|
+
box-shadow: var(--hud-shadow);
|
|
2582
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2583
|
+
backdrop-filter: blur(10px);
|
|
2584
|
+
cursor: pointer;
|
|
2585
|
+
}
|
|
2586
|
+
.rail[data-mode="fab"] .rail-head { justify-content: flex-end; }
|
|
2587
|
+
.rail[data-mode="fab"] .rail-done { position: absolute; right: 52px; bottom: 10px; }
|
|
2588
|
+
.rail[data-mode="fab"] .rail-chip .rail-count { top: -2px; right: -2px; min-width: 16px; height: 16px; font-size: 10px; }
|
|
2589
|
+
.rail[data-mode="fab"] .rail-list {
|
|
2590
|
+
position: absolute;
|
|
2591
|
+
right: 0;
|
|
2592
|
+
bottom: calc(100% + 10px);
|
|
2593
|
+
display: grid;
|
|
2594
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
2595
|
+
gap: 2px;
|
|
2596
|
+
width: min(300px, calc(100vw - 24px));
|
|
2597
|
+
max-height: 60vh;
|
|
2598
|
+
overflow: auto;
|
|
2599
|
+
padding: 6px;
|
|
2600
|
+
background: var(--hud-bg);
|
|
2601
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2602
|
+
backdrop-filter: blur(10px);
|
|
2603
|
+
border: 1px solid var(--hud-border);
|
|
2604
|
+
border-radius: 12px;
|
|
2605
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
2606
|
+
}
|
|
2607
|
+
.rail[data-mode="fab"][data-editing] .rail-list { grid-template-columns: minmax(0, 1fr); }
|
|
2608
|
+
.rail[data-mode="fab"] .rail-list[inert] { display: none; }
|
|
2609
|
+
.rail-sheet-head {
|
|
2610
|
+
grid-column: 1 / -1;
|
|
2611
|
+
display: flex;
|
|
2612
|
+
align-items: center;
|
|
2613
|
+
justify-content: space-between;
|
|
2614
|
+
padding: 4px 6px 6px;
|
|
2615
|
+
margin-bottom: 4px;
|
|
2616
|
+
border-bottom: 1px solid var(--hud-border);
|
|
2617
|
+
}
|
|
2618
|
+
.rail-sheet-head .env { color: var(--hud-accent); font-weight: 600; letter-spacing: 0.08em; cursor: default; }
|
|
2619
|
+
.hud .rail[data-mode="fab"] .rail-button { padding: 5px 6px; }
|
|
2620
|
+
.hud .rail[data-mode="fab"] .rail-close { flex: none; width: 28px; height: 28px; padding: 0; justify-content: center; }
|
|
2621
|
+
/* In the sheet the menu is not a popover (the scrolling grid would clip it): it unfolds
|
|
2622
|
+
below the Menu row, across both columns, and scrolls with the sheet. */
|
|
2623
|
+
.rail[data-mode="fab"] .rail-item:has(.menu-anchor) { grid-column: 1 / -1; }
|
|
2624
|
+
.rail[data-mode="fab"] .menu-anchor { width: 100%; flex-direction: column; }
|
|
2625
|
+
.rail[data-mode="fab"] .menu {
|
|
2626
|
+
position: static;
|
|
2627
|
+
min-width: 0;
|
|
2628
|
+
max-height: none;
|
|
2629
|
+
margin-top: 4px;
|
|
2630
|
+
border: 0;
|
|
2631
|
+
border-top: 1px solid var(--hud-border);
|
|
2632
|
+
border-radius: 0;
|
|
2633
|
+
box-shadow: none;
|
|
2634
|
+
background: none;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2638
|
+
.rail, .rail * { transition: none !important; }
|
|
2639
|
+
}
|
|
2640
|
+
` + GRAB_CSS;
|
|
1681
2641
|
const NO_PLUGINS = [];
|
|
1682
2642
|
const GRANT_ALL = () => true;
|
|
1683
2643
|
/**
|
|
1684
|
-
* The HUD shell: a shadow-rooted
|
|
2644
|
+
* The HUD shell: a shadow-rooted dock (rail or pill) and floating panels.
|
|
1685
2645
|
*
|
|
1686
2646
|
* It renders unconditionally. Keeping it out of production builds is the
|
|
1687
2647
|
* loader's job, at the import site, so a bundler can drop the whole module
|
|
1688
2648
|
* (see `@hansenexus/hud/next`).
|
|
1689
2649
|
*/
|
|
1690
|
-
function Hud({ appSlug, envLabel = "DEV", plugins = NO_PLUGINS, apiBase = "/api/hud", can = GRANT_ALL }) {
|
|
2650
|
+
function Hud({ appSlug, envLabel = "DEV", plugins = NO_PLUGINS, apiBase = "/api/hud", can = GRANT_ALL, dock = "rail" }) {
|
|
1691
2651
|
const resolved = useMemo(() => resolvePlugins(plugins, can), [plugins, can]);
|
|
1692
|
-
return /* @__PURE__ */
|
|
2652
|
+
return /* @__PURE__ */ jsxs(ShadowHost, {
|
|
1693
2653
|
css: CSS,
|
|
1694
2654
|
marker: HUD_DEV_MARKER,
|
|
1695
|
-
children: /* @__PURE__ */ jsx(Shell, {
|
|
2655
|
+
children: [/* @__PURE__ */ jsx(IconSprite, {}), /* @__PURE__ */ jsx(Shell, {
|
|
1696
2656
|
appSlug,
|
|
1697
2657
|
envLabel,
|
|
1698
2658
|
plugins: resolved,
|
|
1699
2659
|
apiBase,
|
|
1700
|
-
can
|
|
1701
|
-
|
|
2660
|
+
can,
|
|
2661
|
+
dock
|
|
2662
|
+
})]
|
|
1702
2663
|
});
|
|
1703
2664
|
}
|
|
1704
|
-
function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
2665
|
+
function Shell({ appSlug, envLabel, plugins, apiBase, can, dock }) {
|
|
1705
2666
|
const panelsRef = useRef(null);
|
|
1706
2667
|
const close = useCallback((id) => panelsRef.current?.close(id), []);
|
|
1707
2668
|
const open = useCallback((id) => panelsRef.current?.open(id), []);
|
|
@@ -1734,19 +2695,24 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
|
1734
2695
|
})))], [slots, grab]);
|
|
1735
2696
|
return /* @__PURE__ */ jsxs(PanelManager, {
|
|
1736
2697
|
appSlug,
|
|
2698
|
+
dock,
|
|
1737
2699
|
panels,
|
|
1738
2700
|
commands,
|
|
1739
2701
|
apiRef: panelsRef,
|
|
1740
|
-
children: [
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
2702
|
+
children: [
|
|
2703
|
+
/* @__PURE__ */ jsx(dock === "rail" ? Rail : Pill, {
|
|
2704
|
+
appSlug,
|
|
2705
|
+
envLabel,
|
|
2706
|
+
slots,
|
|
2707
|
+
grab
|
|
2708
|
+
}),
|
|
2709
|
+
slots.map((slot) => slot.plugin.overlay && /* @__PURE__ */ jsx(PluginOverlay, { slot }, slot.plugin.id)),
|
|
2710
|
+
/* @__PURE__ */ jsx(Grabber, {
|
|
2711
|
+
app: appSlug,
|
|
2712
|
+
store: grab,
|
|
2713
|
+
slots
|
|
2714
|
+
})
|
|
2715
|
+
]
|
|
1750
2716
|
});
|
|
1751
2717
|
}
|
|
1752
2718
|
//#endregion
|
|
@@ -1761,15 +2727,16 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
|
1761
2727
|
* Returns a component. The plugin list is frozen here, so the shell sees a
|
|
1762
2728
|
* stable array across renders.
|
|
1763
2729
|
*/
|
|
1764
|
-
function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
2730
|
+
function defineHud({ app, plugins, auto, apiBase, can, dock }) {
|
|
1765
2731
|
if (!plugins && !auto) throw new Error("hud: defineHud needs `plugins`, `auto` or both");
|
|
1766
2732
|
const explicit = resolvePlugins(plugins ?? [], () => true);
|
|
1767
2733
|
const detected = typeof auto === "function" ? auto() : auto ?? [];
|
|
1768
2734
|
const list = Object.freeze(mergePlugins(detected, explicit));
|
|
1769
2735
|
resolvePlugins(list, () => true);
|
|
1770
2736
|
const access = list.find((plugin) => plugin.access)?.access;
|
|
1771
|
-
function DefinedHud({ envLabel, env = "development" }) {
|
|
2737
|
+
function DefinedHud({ envLabel, env = "development", dock: mountDock }) {
|
|
1772
2738
|
if (env === "disabled") return null;
|
|
2739
|
+
const chosen = mountDock ?? dock;
|
|
1773
2740
|
if (access) return /* @__PURE__ */ jsx(AccessHud, {
|
|
1774
2741
|
access,
|
|
1775
2742
|
env,
|
|
@@ -1777,7 +2744,8 @@ function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
|
1777
2744
|
plugins: list,
|
|
1778
2745
|
apiBase: apiBase ?? "/api/hud",
|
|
1779
2746
|
...envLabel === void 0 ? {} : { envLabel },
|
|
1780
|
-
...can === void 0 ? {} : { can }
|
|
2747
|
+
...can === void 0 ? {} : { can },
|
|
2748
|
+
...chosen === void 0 ? {} : { dock: chosen }
|
|
1781
2749
|
});
|
|
1782
2750
|
if (env !== "development") return null;
|
|
1783
2751
|
return /* @__PURE__ */ jsx(Hud, {
|
|
@@ -1785,7 +2753,8 @@ function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
|
1785
2753
|
plugins: list,
|
|
1786
2754
|
...envLabel === void 0 ? {} : { envLabel },
|
|
1787
2755
|
...apiBase === void 0 ? {} : { apiBase },
|
|
1788
|
-
...can === void 0 ? {} : { can }
|
|
2756
|
+
...can === void 0 ? {} : { can },
|
|
2757
|
+
...chosen === void 0 ? {} : { dock: chosen }
|
|
1789
2758
|
});
|
|
1790
2759
|
}
|
|
1791
2760
|
DefinedHud.displayName = `Hud(${app})`;
|
|
@@ -1809,7 +2778,7 @@ function mergePlugins(detected, explicit) {
|
|
|
1809
2778
|
* in the bundle and its routes are one URL away. The server guard
|
|
1810
2779
|
* (`accessGuard`) is what enforces the tier.
|
|
1811
2780
|
*/
|
|
1812
|
-
function AccessHud({ access, env, app, plugins, apiBase, envLabel, can }) {
|
|
2781
|
+
function AccessHud({ access, env, app, plugins, apiBase, envLabel, can, dock }) {
|
|
1813
2782
|
const unlocked = access.useUnlocked(env, apiBase);
|
|
1814
2783
|
const gated = useCallback((capability) => access.can(env, capability) && (can?.(capability) ?? true), [
|
|
1815
2784
|
access,
|
|
@@ -1822,8 +2791,9 @@ function AccessHud({ access, env, app, plugins, apiBase, envLabel, can }) {
|
|
|
1822
2791
|
plugins: shown,
|
|
1823
2792
|
apiBase,
|
|
1824
2793
|
can: gated,
|
|
1825
|
-
...envLabel === void 0 ? {} : { envLabel }
|
|
2794
|
+
...envLabel === void 0 ? {} : { envLabel },
|
|
2795
|
+
...dock === void 0 ? {} : { dock }
|
|
1826
2796
|
});
|
|
1827
2797
|
}
|
|
1828
2798
|
//#endregion
|
|
1829
|
-
export { ElementOutline, ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, matchComponentHints, useGrab };
|
|
2799
|
+
export { ElementOutline, ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, HUD_ICON_NAMES, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, hudIcon, matchComponentHints, ratingTone, useGrab };
|