@hansenexus/hud 0.5.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -14
- 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-Bc709qpl.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/{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-DTv3njuU.d.ts} +15 -5
- package/dist/{design-D0kGgPoP.js → design-BXG1a4we.js} +21 -5
- package/dist/{dispatch-panel-B-xr_Giy.js → dispatch-panel-BDHgMhOk.js} +1 -1
- package/dist/{force-state-panel-_otVYh9i.js → force-state-panel-mu-txJnA.js} +1 -1
- package/dist/{handler-BpVhxEmU.js → handler-BKzaOhlJ.js} +1 -1
- package/dist/{handler-DtYVCZY6.d.ts → handler-DMzSTqyG.d.ts} +1 -1
- package/dist/icons-ByDyNq_E.js +71 -0
- package/dist/{index-BnQ0dTZf.d.ts → index-B1vHAY9p.d.ts} +2 -1
- package/dist/{index-DstI_ike.d.ts → index-BJJoAXJ2.d.ts} +5 -1
- package/dist/{index-BAV_1W8a.d.ts → index-BNoPbSYD.d.ts} +3 -1
- package/dist/{index-CwfX-W87.d.ts → index-BR5OB7DO.d.ts} +3 -0
- package/dist/index-C3wzZS3o.d.ts +116 -0
- package/dist/{index-DcH9V3cU.d.ts → index-CQXiuMZQ.d.ts} +3 -0
- package/dist/{index-Hhh7OXzU.d.ts → index-Caohnz3B.d.ts} +7 -1
- package/dist/{index-ReFbhQ9p.d.ts → index-D-hI-DRJ.d.ts} +5 -0
- package/dist/{index-DqOyNf1u.d.ts → index-DLCSLWW4.d.ts} +4 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1230 -88
- package/dist/{inspect-C9Ft8fqn.js → inspect-CSkm8tn3.js} +14 -2
- package/dist/{inspect-root-BkaupBMp.js → inspect-root-CmiFX0e5.js} +1 -1
- package/dist/next.d.ts +1 -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/{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 +1 -1
- 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 +1 -1
- package/dist/plugins/data.d.ts +1 -1
- package/dist/plugins/data.js +30 -9
- package/dist/plugins/design/server.d.ts +1 -1
- package/dist/plugins/design/server.js +1 -1
- package/dist/plugins/design.d.ts +1 -1
- 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.js +1 -1
- package/dist/plugins/routes.d.ts +1 -1
- package/dist/plugins/routes.js +3 -1
- 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-BZvDqGx5.d.ts → plugins-BZT-1LBe.d.ts} +32 -3
- package/dist/{plugins-DVy_vaYr.js → plugins-CcW_K7c2.js} +9 -1
- package/dist/{poll-CjKsWZi8.js → poll-Dm0OijM4.js} +1 -1
- 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 +1 -1
- package/dist/{unlock-store-4V3vR4Eg.js → unlock-store-CrGXQx1V.js} +1 -1
- package/dist/{variants-panel-BDoSkwBJ.js → variants-panel-B6zWcknV.js} +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +1 -1
- package/dist/index-gCZBO53s.d.ts +0 -73
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
6
7
|
import { Component, Suspense, createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -218,14 +219,77 @@ function CommandProvider({ commands, children }) {
|
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
//#endregion
|
|
222
|
+
//#region src/shell/panels/types.ts
|
|
223
|
+
const EDGES = [
|
|
224
|
+
"left",
|
|
225
|
+
"right",
|
|
226
|
+
"bottom"
|
|
227
|
+
];
|
|
228
|
+
/** Search order when the pill picks its own corner: the bottom first, top-right last (host CTAs). */
|
|
229
|
+
const CORNERS = [
|
|
230
|
+
"bottom-left",
|
|
231
|
+
"bottom-right",
|
|
232
|
+
"top-left",
|
|
233
|
+
"top-right"
|
|
234
|
+
];
|
|
235
|
+
const DOCK_SIDES = ["left", "right"];
|
|
236
|
+
/** Cycle order of the chip click and ⌘⇧D. */
|
|
237
|
+
const RAIL_DETAILS = [
|
|
238
|
+
"chip",
|
|
239
|
+
"icons",
|
|
240
|
+
"labels"
|
|
241
|
+
];
|
|
242
|
+
//#endregion
|
|
221
243
|
//#region src/shell/panels/layout.ts
|
|
222
244
|
const EMPTY_LAYOUT = {
|
|
223
245
|
open: [],
|
|
224
246
|
floats: {},
|
|
225
247
|
pins: {},
|
|
226
248
|
hidden: false,
|
|
227
|
-
pill: null
|
|
249
|
+
pill: null,
|
|
250
|
+
side: "right",
|
|
251
|
+
detail: "chip",
|
|
252
|
+
order: [],
|
|
253
|
+
hiddenItems: []
|
|
228
254
|
};
|
|
255
|
+
/** The next detail level: chip → icons → labels → chip. */
|
|
256
|
+
function cycleDetail(layout) {
|
|
257
|
+
const index = RAIL_DETAILS.indexOf(layout.detail);
|
|
258
|
+
const detail = RAIL_DETAILS[(index + 1) % RAIL_DETAILS.length] ?? "chip";
|
|
259
|
+
return {
|
|
260
|
+
...layout,
|
|
261
|
+
detail
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/** `ids` in the user's order: listed ids first, in that order, then the rest as given. */
|
|
265
|
+
function railOrder(ids, order) {
|
|
266
|
+
const present = new Set(ids);
|
|
267
|
+
const placed = order.filter((id) => present.has(id));
|
|
268
|
+
const seen = new Set(placed);
|
|
269
|
+
return [...placed, ...ids.filter((id) => !seen.has(id))];
|
|
270
|
+
}
|
|
271
|
+
/** Moves `id` to position `index` among `ids` (the rail's current ids) and stores the full order. */
|
|
272
|
+
function moveItem(layout, ids, id, index) {
|
|
273
|
+
const current = railOrder(ids, layout.order);
|
|
274
|
+
const from = current.indexOf(id);
|
|
275
|
+
if (from === -1) return layout;
|
|
276
|
+
const to = Math.max(0, Math.min(current.length - 1, index));
|
|
277
|
+
if (from === to) return layout;
|
|
278
|
+
const next = [...current];
|
|
279
|
+
next.splice(from, 1);
|
|
280
|
+
next.splice(to, 0, id);
|
|
281
|
+
return {
|
|
282
|
+
...layout,
|
|
283
|
+
order: next
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function setItemHidden(layout, id, hidden) {
|
|
287
|
+
if (hidden === layout.hiddenItems.includes(id)) return layout;
|
|
288
|
+
return {
|
|
289
|
+
...layout,
|
|
290
|
+
hiddenItems: hidden ? [...layout.hiddenItems, id] : layout.hiddenItems.filter((item) => item !== id)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
229
293
|
/** A pinned edge never takes more than this share of the viewport. */
|
|
230
294
|
const MAX_SHARE = .4;
|
|
231
295
|
function visiblePanels(layout) {
|
|
@@ -510,20 +574,6 @@ function usePanels() {
|
|
|
510
574
|
return api;
|
|
511
575
|
}
|
|
512
576
|
//#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
577
|
//#region src/shell/panels/reserve.ts
|
|
528
578
|
const PADDING = {
|
|
529
579
|
left: "padding-left",
|
|
@@ -600,6 +650,16 @@ function isCorner(value) {
|
|
|
600
650
|
function isEdge(value) {
|
|
601
651
|
return EDGES.some((edge) => edge === value);
|
|
602
652
|
}
|
|
653
|
+
function isSide(value) {
|
|
654
|
+
return DOCK_SIDES.some((side) => side === value);
|
|
655
|
+
}
|
|
656
|
+
function isDetail(value) {
|
|
657
|
+
return RAIL_DETAILS.some((detail) => detail === value);
|
|
658
|
+
}
|
|
659
|
+
/** The distinct strings of a stored list; anything else is dropped. */
|
|
660
|
+
function strings(value) {
|
|
661
|
+
return Array.isArray(value) ? [...new Set(value.filter((item) => typeof item === "string"))] : [];
|
|
662
|
+
}
|
|
603
663
|
function sanitizeLayout(value, known) {
|
|
604
664
|
if (!isRecord(value) || value.v !== VERSION) return EMPTY_LAYOUT;
|
|
605
665
|
const open = Array.isArray(value.open) ? [...new Set(value.open.filter((id) => typeof id === "string" && known.has(id)))] : [];
|
|
@@ -619,7 +679,11 @@ function sanitizeLayout(value, known) {
|
|
|
619
679
|
floats,
|
|
620
680
|
pins,
|
|
621
681
|
hidden: value.hidden === true,
|
|
622
|
-
pill: isCorner(value.pill) ? value.pill : null
|
|
682
|
+
pill: isCorner(value.pill) ? value.pill : null,
|
|
683
|
+
side: isSide(value.side) ? value.side : EMPTY_LAYOUT.side,
|
|
684
|
+
detail: isDetail(value.detail) ? value.detail : value.folded === false ? "icons" : "chip",
|
|
685
|
+
order: strings(value.order),
|
|
686
|
+
hiddenItems: strings(value.hiddenItems)
|
|
623
687
|
};
|
|
624
688
|
}
|
|
625
689
|
function subscribeResize(listener) {
|
|
@@ -654,12 +718,24 @@ function useNarrow() {
|
|
|
654
718
|
}
|
|
655
719
|
//#endregion
|
|
656
720
|
//#region src/shell/panels/panel-manager.tsx
|
|
657
|
-
/**
|
|
658
|
-
|
|
721
|
+
/** Room the rail and its gap take from the edge a panel opens beside. */
|
|
722
|
+
const RAIL_GUTTER = 52;
|
|
723
|
+
/** The widest a floating panel renders (`.panel { max-width }`), so it clears the rail on the right. */
|
|
724
|
+
const PANEL_MAX_WIDTH = 420;
|
|
725
|
+
/**
|
|
726
|
+
* Where a panel opens the first time: beside the rail on its side, stacked
|
|
727
|
+
* inward and up; with the pill, up and right from above its corner.
|
|
728
|
+
*/
|
|
729
|
+
function defaultPosition(index, side, viewport) {
|
|
659
730
|
const step = 28 * index;
|
|
731
|
+
const y = Math.max(12, viewport.h - 300 - step);
|
|
732
|
+
if (side === "right") return {
|
|
733
|
+
x: Math.max(12, viewport.w - RAIL_GUTTER - PANEL_MAX_WIDTH - step),
|
|
734
|
+
y
|
|
735
|
+
};
|
|
660
736
|
return {
|
|
661
|
-
x: 12 + step,
|
|
662
|
-
y
|
|
737
|
+
x: (side ? RAIL_GUTTER : 12) + step,
|
|
738
|
+
y
|
|
663
739
|
};
|
|
664
740
|
}
|
|
665
741
|
/**
|
|
@@ -673,7 +749,7 @@ function PanelManager({ commands, ...props }) {
|
|
|
673
749
|
children: /* @__PURE__ */ jsx(Workspace, { ...props })
|
|
674
750
|
});
|
|
675
751
|
}
|
|
676
|
-
function Workspace({ appSlug, panels, apiRef, children }) {
|
|
752
|
+
function Workspace({ appSlug, dock, panels, apiRef, children }) {
|
|
677
753
|
const byId = useMemo(() => new Map(panels.map((panel) => [panel.id, panel])), [panels]);
|
|
678
754
|
const [layout, setLayout] = useState(() => loadLayout(appSlug, new Set(byId.keys())));
|
|
679
755
|
const viewport = useViewport();
|
|
@@ -695,12 +771,13 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
695
771
|
right,
|
|
696
772
|
bottom
|
|
697
773
|
]);
|
|
774
|
+
const position = useCallback((l) => defaultPosition(l.open.length, dock === "rail" ? l.side : null, viewport), [dock, viewport]);
|
|
698
775
|
const api = useMemo(() => ({
|
|
699
776
|
panels,
|
|
700
777
|
isOpen: (id) => !layout.hidden && layout.open.includes(id),
|
|
701
|
-
open: (id) => setLayout((l) => openPanel(l, id,
|
|
778
|
+
open: (id) => setLayout((l) => openPanel(l, id, position(l))),
|
|
702
779
|
close: (id) => setLayout((l) => closePanel(l, id)),
|
|
703
|
-
toggle: (id) => setLayout((l) => !l.hidden && l.open.includes(id) ? closePanel(l, id) : openPanel(l, id,
|
|
780
|
+
toggle: (id) => setLayout((l) => !l.hidden && l.open.includes(id) ? closePanel(l, id) : openPanel(l, id, position(l))),
|
|
704
781
|
pin: (id, edge) => setLayout((l) => pinPanel(l, id, edge)),
|
|
705
782
|
reserve: {
|
|
706
783
|
left,
|
|
@@ -711,13 +788,28 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
711
788
|
setPillCorner: (pill) => setLayout((l) => l.pill === pill ? l : {
|
|
712
789
|
...l,
|
|
713
790
|
pill
|
|
714
|
-
})
|
|
791
|
+
}),
|
|
792
|
+
side: layout.side,
|
|
793
|
+
setSide: (side) => setLayout((l) => l.side === side ? l : {
|
|
794
|
+
...l,
|
|
795
|
+
side
|
|
796
|
+
}),
|
|
797
|
+
detail: layout.detail,
|
|
798
|
+
setDetail: (detail) => setLayout((l) => l.detail === detail ? l : {
|
|
799
|
+
...l,
|
|
800
|
+
detail
|
|
801
|
+
}),
|
|
802
|
+
order: layout.order,
|
|
803
|
+
moveItem: (ids, id, index) => setLayout((l) => moveItem(l, ids, id, index)),
|
|
804
|
+
hiddenItems: layout.hiddenItems,
|
|
805
|
+
setItemHidden: (id, hidden) => setLayout((l) => setItemHidden(l, id, hidden))
|
|
715
806
|
}), [
|
|
716
807
|
panels,
|
|
717
808
|
layout,
|
|
718
809
|
left,
|
|
719
810
|
right,
|
|
720
|
-
bottom
|
|
811
|
+
bottom,
|
|
812
|
+
position
|
|
721
813
|
]);
|
|
722
814
|
useLayoutEffect(() => {
|
|
723
815
|
if (!apiRef) return;
|
|
@@ -726,16 +818,29 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
726
818
|
apiRef.current = null;
|
|
727
819
|
};
|
|
728
820
|
}, [apiRef, api]);
|
|
729
|
-
useRegisterCommands(useMemo(() => [
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
821
|
+
useRegisterCommands(useMemo(() => [
|
|
822
|
+
{
|
|
823
|
+
id: "hud.toggle-layout",
|
|
824
|
+
title: "Toggle layout",
|
|
825
|
+
shortcut: "mod+shift+h",
|
|
826
|
+
run: () => setLayout((l) => toggleLayout(l, panels[0]?.id, position(l)))
|
|
827
|
+
},
|
|
828
|
+
...dock === "rail" ? [{
|
|
829
|
+
id: "hud.detail",
|
|
830
|
+
title: "Cycle rail detail",
|
|
831
|
+
shortcut: "mod+shift+d",
|
|
832
|
+
run: () => setLayout(cycleDetail)
|
|
833
|
+
}] : [],
|
|
834
|
+
{
|
|
835
|
+
id: "hud.reset-layout",
|
|
836
|
+
title: "Reset layout",
|
|
837
|
+
run: () => setLayout(EMPTY_LAYOUT)
|
|
838
|
+
}
|
|
839
|
+
], [
|
|
840
|
+
panels,
|
|
841
|
+
position,
|
|
842
|
+
dock
|
|
843
|
+
]));
|
|
739
844
|
const zOrder = visiblePanels(layout);
|
|
740
845
|
const visible = panels.filter((panel) => zOrder.includes(panel.id));
|
|
741
846
|
const active = byId.get(zOrder.at(-1) ?? "");
|
|
@@ -766,7 +871,10 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
766
871
|
title: panel.title,
|
|
767
872
|
z: zOrder.indexOf(panel.id) + 1,
|
|
768
873
|
viewport,
|
|
769
|
-
position: layout.floats[panel.id] ??
|
|
874
|
+
position: layout.floats[panel.id] ?? position({
|
|
875
|
+
...layout,
|
|
876
|
+
open: []
|
|
877
|
+
}),
|
|
770
878
|
pinned: edge && rect ? {
|
|
771
879
|
edge,
|
|
772
880
|
rect
|
|
@@ -794,6 +902,8 @@ function Workspace({ appSlug, panels, apiRef, children }) {
|
|
|
794
902
|
const CLEARANCE = 8;
|
|
795
903
|
/** The pill never moves further than this share of the viewport height off its edge. */
|
|
796
904
|
const MAX_SHIFT_SHARE = .4;
|
|
905
|
+
/** On a narrow viewport the pill takes at most this share of the width. */
|
|
906
|
+
const NARROW_SHARE = .4;
|
|
797
907
|
/** Extra cost of a top corner when every corner needs a shift: host navs live up there. */
|
|
798
908
|
const TOP_PENALTY = 48;
|
|
799
909
|
const isBottom = (corner) => corner.startsWith("bottom");
|
|
@@ -854,6 +964,54 @@ function placePill(options) {
|
|
|
854
964
|
function nearestCorner(x, y, viewport) {
|
|
855
965
|
return `${y > viewport.h / 2 ? "bottom" : "top"}-${x > viewport.w / 2 ? "right" : "left"}`;
|
|
856
966
|
}
|
|
967
|
+
const isNarrow = (viewport) => viewport.w < 900;
|
|
968
|
+
/** The side a dragged rail chip lands on: the half of the viewport it was dropped in. */
|
|
969
|
+
function nearestSide(x, viewport) {
|
|
970
|
+
return x > viewport.w / 2 ? "right" : "left";
|
|
971
|
+
}
|
|
972
|
+
/** The rail's box: flush against its edge (next to a pinned panel there), `top` down. */
|
|
973
|
+
function railRect({ top }, size, viewport, reserve, side) {
|
|
974
|
+
return {
|
|
975
|
+
left: side === "right" ? viewport.w - reserve.right - size.width : reserve.left,
|
|
976
|
+
top,
|
|
977
|
+
width: size.width,
|
|
978
|
+
height: size.height
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Where the rail goes on its edge: centred, unless a host element sits there.
|
|
983
|
+
* Then the nearest free spot above or below the obstacles, scored by the
|
|
984
|
+
* distance moved, like the pill's shift; past the shift cap it stays centred
|
|
985
|
+
* and overlaps rather than leaving the viewport.
|
|
986
|
+
*/
|
|
987
|
+
function placeRail(options) {
|
|
988
|
+
const { viewport, size, obstacles, reserve, side } = options;
|
|
989
|
+
const minTop = 12;
|
|
990
|
+
const maxTop = viewport.h - reserve.bottom - 12 - size.height;
|
|
991
|
+
const centre = Math.min(Math.max(Math.round((viewport.h - reserve.bottom - size.height) / 2), minTop), maxTop);
|
|
992
|
+
const at = (top) => railRect({ top }, size, viewport, reserve, side);
|
|
993
|
+
const column = at(centre);
|
|
994
|
+
const inColumn = obstacles.filter((o) => o.left < column.left + column.width && column.left < o.left + o.width);
|
|
995
|
+
const candidates = [centre, ...inColumn.flatMap((o) => [o.top - CLEARANCE - size.height, o.top + o.height + CLEARANCE])];
|
|
996
|
+
const max = viewport.h * MAX_SHIFT_SHARE;
|
|
997
|
+
let best = null;
|
|
998
|
+
for (const top of candidates) {
|
|
999
|
+
if (top < minTop || top > maxTop || Math.abs(top - centre) > max) continue;
|
|
1000
|
+
if (inColumn.some((o) => intersects(at(top), o))) continue;
|
|
1001
|
+
if (best === null || Math.abs(top - centre) < Math.abs(best - centre)) best = top;
|
|
1002
|
+
}
|
|
1003
|
+
return { top: best ?? centre };
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Width left for plugin items next to the fixed controls of `fixed` pixels
|
|
1007
|
+
* (`chrome` is the pill's own padding and border). On a narrow viewport the
|
|
1008
|
+
* share cap applies on top of the room pinned panels leave.
|
|
1009
|
+
*/
|
|
1010
|
+
function itemBudget({ viewport, reserve, fixed, chrome }) {
|
|
1011
|
+
const room = viewport.w - reserve.left - reserve.right - 24 - chrome - fixed;
|
|
1012
|
+
if (!isNarrow(viewport)) return room;
|
|
1013
|
+
return Math.min(room, Math.floor(viewport.w * NARROW_SHARE) - chrome - fixed);
|
|
1014
|
+
}
|
|
857
1015
|
/**
|
|
858
1016
|
* Which plugin items fit in `budget` pixels. Higher priority first, then pill
|
|
859
1017
|
* order; an item that does not fit is skipped, so a smaller one after it can
|
|
@@ -892,7 +1050,7 @@ function clampOffset(rect, area, margin) {
|
|
|
892
1050
|
}
|
|
893
1051
|
//#endregion
|
|
894
1052
|
//#region src/shell/pill/visual-viewport.ts
|
|
895
|
-
function subscribe(listener) {
|
|
1053
|
+
function subscribe$1(listener) {
|
|
896
1054
|
const vv = window.visualViewport;
|
|
897
1055
|
window.addEventListener("resize", listener);
|
|
898
1056
|
vv?.addEventListener("resize", listener);
|
|
@@ -916,7 +1074,7 @@ let cached = {
|
|
|
916
1074
|
* to the bottom edge ends up below the fold. The visual viewport is what the
|
|
917
1075
|
* user sees; the pill places itself in it.
|
|
918
1076
|
*/
|
|
919
|
-
function read() {
|
|
1077
|
+
function read$1() {
|
|
920
1078
|
const root = document.documentElement;
|
|
921
1079
|
const layoutW = root.clientWidth || window.innerWidth;
|
|
922
1080
|
const layoutH = root.clientHeight || window.innerHeight;
|
|
@@ -937,7 +1095,7 @@ function read() {
|
|
|
937
1095
|
return cached;
|
|
938
1096
|
}
|
|
939
1097
|
function useVisualViewport() {
|
|
940
|
-
return useSyncExternalStore(subscribe, read, read);
|
|
1098
|
+
return useSyncExternalStore(subscribe$1, read$1, read$1);
|
|
941
1099
|
}
|
|
942
1100
|
//#endregion
|
|
943
1101
|
//#region src/shell/panels/pill-menu.tsx
|
|
@@ -948,11 +1106,11 @@ const NO_OFFSET = {
|
|
|
948
1106
|
y: 0
|
|
949
1107
|
};
|
|
950
1108
|
/**
|
|
951
|
-
* The
|
|
952
|
-
* layout. `overflow` counts the pill items
|
|
953
|
-
* reachable here.
|
|
1109
|
+
* The dock's "⋯" menu: every panel, every command with its shortcut, Reset
|
|
1110
|
+
* layout, and on the rail the dock side. `overflow` counts the pill items
|
|
1111
|
+
* that did not fit; their panels are reachable here.
|
|
954
1112
|
*/
|
|
955
|
-
function PillMenu({ overflow = 0 }) {
|
|
1113
|
+
function PillMenu({ overflow = 0, dock, inline = false }) {
|
|
956
1114
|
const panels = usePanels();
|
|
957
1115
|
const commands = useCommands();
|
|
958
1116
|
const apple = useMemo(isApplePlatform, []);
|
|
@@ -963,7 +1121,7 @@ function PillMenu({ overflow = 0 }) {
|
|
|
963
1121
|
const [offset, setOffset] = useState(NO_OFFSET);
|
|
964
1122
|
useLayoutEffect(() => {
|
|
965
1123
|
const menu = menuRef.current;
|
|
966
|
-
if (!open || !menu) {
|
|
1124
|
+
if (!open || !menu || inline) {
|
|
967
1125
|
setOffset(NO_OFFSET);
|
|
968
1126
|
return;
|
|
969
1127
|
}
|
|
@@ -983,6 +1141,7 @@ function PillMenu({ overflow = 0 }) {
|
|
|
983
1141
|
if (next.x !== offset.x || next.y !== offset.y) setOffset(next);
|
|
984
1142
|
}, [
|
|
985
1143
|
open,
|
|
1144
|
+
inline,
|
|
986
1145
|
visual,
|
|
987
1146
|
offset
|
|
988
1147
|
]);
|
|
@@ -1001,13 +1160,32 @@ function PillMenu({ overflow = 0 }) {
|
|
|
1001
1160
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
1002
1161
|
};
|
|
1003
1162
|
}, [open]);
|
|
1163
|
+
const label = overflow > 0 ? `HUD menu, ${overflow} more` : "HUD menu";
|
|
1004
1164
|
return /* @__PURE__ */ jsxs("div", {
|
|
1005
1165
|
className: "menu-anchor",
|
|
1006
1166
|
ref,
|
|
1007
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
1167
|
+
children: [dock === "rail" ? /* @__PURE__ */ jsxs("button", {
|
|
1168
|
+
type: "button",
|
|
1169
|
+
className: "rail-button",
|
|
1170
|
+
"aria-label": label,
|
|
1171
|
+
"aria-haspopup": "menu",
|
|
1172
|
+
"aria-expanded": open,
|
|
1173
|
+
onClick: () => setOpen((o) => !o),
|
|
1174
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1175
|
+
className: "rail-glyph",
|
|
1176
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "ellipsis" })
|
|
1177
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1178
|
+
className: "rail-tip",
|
|
1179
|
+
role: "tooltip",
|
|
1180
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1181
|
+
className: "rail-tip-title",
|
|
1182
|
+
children: "Menu"
|
|
1183
|
+
})
|
|
1184
|
+
})]
|
|
1185
|
+
}) : /* @__PURE__ */ jsxs("button", {
|
|
1008
1186
|
type: "button",
|
|
1009
1187
|
className: "pill-item",
|
|
1010
|
-
"aria-label":
|
|
1188
|
+
"aria-label": label,
|
|
1011
1189
|
"aria-haspopup": "menu",
|
|
1012
1190
|
"aria-expanded": open,
|
|
1013
1191
|
onClick: () => setOpen((o) => !o),
|
|
@@ -1031,12 +1209,32 @@ function PillMenu({ overflow = 0 }) {
|
|
|
1031
1209
|
role: "menuitemcheckbox",
|
|
1032
1210
|
className: "menu-item",
|
|
1033
1211
|
"aria-checked": panels.isOpen(panel.id),
|
|
1034
|
-
onClick: () =>
|
|
1212
|
+
onClick: () => {
|
|
1213
|
+
panels.toggle(panel.id);
|
|
1214
|
+
if (dock === "rail") setOpen(false);
|
|
1215
|
+
},
|
|
1035
1216
|
children: [/* @__PURE__ */ jsx("span", { children: panel.title }), /* @__PURE__ */ jsx("span", {
|
|
1036
1217
|
className: "menu-check",
|
|
1037
1218
|
children: panels.isOpen(panel.id) ? "✓" : ""
|
|
1038
1219
|
})]
|
|
1039
1220
|
}, panel.id)),
|
|
1221
|
+
dock === "rail" && !inline && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
1222
|
+
className: "menu-label",
|
|
1223
|
+
children: "Dock"
|
|
1224
|
+
}), DOCK_SIDES.map((side) => /* @__PURE__ */ jsxs("button", {
|
|
1225
|
+
type: "button",
|
|
1226
|
+
role: "menuitemradio",
|
|
1227
|
+
className: "menu-item",
|
|
1228
|
+
"aria-checked": panels.side === side,
|
|
1229
|
+
onClick: () => {
|
|
1230
|
+
setOpen(false);
|
|
1231
|
+
panels.setSide(side);
|
|
1232
|
+
},
|
|
1233
|
+
children: [/* @__PURE__ */ jsxs("span", { children: ["Dock ", side] }), /* @__PURE__ */ jsx("span", {
|
|
1234
|
+
className: "menu-check",
|
|
1235
|
+
children: panels.side === side ? "✓" : ""
|
|
1236
|
+
})]
|
|
1237
|
+
}, side))] }),
|
|
1040
1238
|
/* @__PURE__ */ jsx("div", {
|
|
1041
1239
|
className: "menu-label",
|
|
1042
1240
|
children: "Commands"
|
|
@@ -1363,6 +1561,15 @@ function sameRects(a, b) {
|
|
|
1363
1561
|
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);
|
|
1364
1562
|
}
|
|
1365
1563
|
const NONE = [];
|
|
1564
|
+
/** Obstacle rects moved into visible-area coordinates when the visual viewport is offset. */
|
|
1565
|
+
function offsetObstacles(rects, offset) {
|
|
1566
|
+
if (offset.x === 0 && offset.y === 0) return rects;
|
|
1567
|
+
return rects.map((o) => ({
|
|
1568
|
+
...o,
|
|
1569
|
+
left: o.left - offset.x,
|
|
1570
|
+
top: o.top - offset.y
|
|
1571
|
+
}));
|
|
1572
|
+
}
|
|
1366
1573
|
/**
|
|
1367
1574
|
* Live obstacle rects. The element list is rescanned when the DOM settles
|
|
1368
1575
|
* after a change; rects are re-measured on scroll (sticky elements move) and
|
|
@@ -1423,7 +1630,7 @@ function useObstacles() {
|
|
|
1423
1630
|
const ITEM_GAP = 2;
|
|
1424
1631
|
const CHROME = 8;
|
|
1425
1632
|
/** A press that moves less than this is a click, not a drag. */
|
|
1426
|
-
const DRAG_THRESHOLD = 4;
|
|
1633
|
+
const DRAG_THRESHOLD$1 = 4;
|
|
1427
1634
|
const EMPTY = {
|
|
1428
1635
|
items: {},
|
|
1429
1636
|
fixed: 0,
|
|
@@ -1454,8 +1661,9 @@ function sameMeasure(a, b) {
|
|
|
1454
1661
|
}
|
|
1455
1662
|
/**
|
|
1456
1663
|
* Fits the items into the width left by pinned panels, then places the pill.
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1664
|
+
* On a narrow viewport, or when no corner is free even after shifting,
|
|
1665
|
+
* compact mode keeps only prioritised items (within 40 percent of the width
|
|
1666
|
+
* on a narrow viewport) and the pill is placed at that size.
|
|
1459
1667
|
*/
|
|
1460
1668
|
function arrange(slots, measured, options) {
|
|
1461
1669
|
const { viewport, reserve } = options;
|
|
@@ -1464,23 +1672,30 @@ function arrange(slots, measured, options) {
|
|
|
1464
1672
|
width: measured.items[plugin.id] ?? 0,
|
|
1465
1673
|
priority: plugin.pillPriority ?? 0
|
|
1466
1674
|
}));
|
|
1467
|
-
const budget =
|
|
1675
|
+
const budget = itemBudget({
|
|
1676
|
+
viewport,
|
|
1677
|
+
reserve,
|
|
1678
|
+
fixed: measured.fixed,
|
|
1679
|
+
chrome: CHROME
|
|
1680
|
+
});
|
|
1468
1681
|
const sizeOf = (visible) => ({
|
|
1469
1682
|
width: CHROME + measured.fixed + items.reduce((sum, item) => sum + (visible.has(item.id) ? item.width + ITEM_GAP : 0), 0),
|
|
1470
1683
|
height: measured.height
|
|
1471
1684
|
});
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1685
|
+
if (!isNarrow(viewport)) {
|
|
1686
|
+
const full = fitItems(items, budget, { gap: ITEM_GAP });
|
|
1687
|
+
const fullSize = sizeOf(full);
|
|
1688
|
+
const placed = placePill({
|
|
1689
|
+
...options,
|
|
1690
|
+
size: fullSize
|
|
1691
|
+
});
|
|
1692
|
+
if (placed) return {
|
|
1693
|
+
visible: full,
|
|
1694
|
+
placement: placed,
|
|
1695
|
+
size: fullSize,
|
|
1696
|
+
compact: false
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1484
1699
|
const compact = fitItems(items, budget, {
|
|
1485
1700
|
gap: ITEM_GAP,
|
|
1486
1701
|
compact: true
|
|
@@ -1545,11 +1760,10 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1545
1760
|
h: visual.h
|
|
1546
1761
|
}), [visual.w, visual.h]);
|
|
1547
1762
|
const rawObstacles = useObstacles();
|
|
1548
|
-
const obstacles = useMemo(() =>
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
})), [
|
|
1763
|
+
const obstacles = useMemo(() => offsetObstacles(rawObstacles, {
|
|
1764
|
+
x: visual.x,
|
|
1765
|
+
y: visual.y
|
|
1766
|
+
}), [
|
|
1553
1767
|
rawObstacles,
|
|
1554
1768
|
visual.x,
|
|
1555
1769
|
visual.y
|
|
@@ -1596,7 +1810,7 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1596
1810
|
if (!start) return;
|
|
1597
1811
|
const x = e.clientX - start.x;
|
|
1598
1812
|
const y = e.clientY - start.y;
|
|
1599
|
-
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD) return;
|
|
1813
|
+
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD$1) return;
|
|
1600
1814
|
start.moved = true;
|
|
1601
1815
|
setDrag({
|
|
1602
1816
|
x,
|
|
@@ -1615,7 +1829,7 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1615
1829
|
};
|
|
1616
1830
|
return /* @__PURE__ */ jsxs("div", {
|
|
1617
1831
|
ref,
|
|
1618
|
-
className: "pill",
|
|
1832
|
+
className: "pill hud-dock",
|
|
1619
1833
|
role: "toolbar",
|
|
1620
1834
|
"aria-label": `${appSlug} hud`,
|
|
1621
1835
|
"data-corner": placement.corner,
|
|
@@ -1650,37 +1864,960 @@ function Pill({ appSlug, envLabel, slots, grab }) {
|
|
|
1650
1864
|
onClick: () => grabbing ? grab.cancel() : grab.start(),
|
|
1651
1865
|
children: "⌖"
|
|
1652
1866
|
}),
|
|
1653
|
-
/* @__PURE__ */ jsx(PillMenu, {
|
|
1867
|
+
/* @__PURE__ */ jsx(PillMenu, {
|
|
1868
|
+
overflow: hidden,
|
|
1869
|
+
dock: "pill"
|
|
1870
|
+
})
|
|
1654
1871
|
]
|
|
1655
1872
|
});
|
|
1656
1873
|
}
|
|
1874
|
+
/**
|
|
1875
|
+
* How far the rail keeps its contents from the right edge so the page's
|
|
1876
|
+
* scrollbar does not paint over them. A classic scrollbar takes its own
|
|
1877
|
+
* gutter and `position: fixed` resolves inside it, so nothing is needed.
|
|
1878
|
+
* An overlay scrollbar (macOS, mobile) takes none and draws on top of the
|
|
1879
|
+
* rail whenever the page scrolls: then the rail leaves it a lane.
|
|
1880
|
+
*/
|
|
1881
|
+
function scrollbarLane(win = window) {
|
|
1882
|
+
const root = win.document.documentElement;
|
|
1883
|
+
const clientWidth = root.clientWidth;
|
|
1884
|
+
if (!clientWidth) return 0;
|
|
1885
|
+
const scrolls = root.scrollHeight > root.clientHeight;
|
|
1886
|
+
const gutter = win.innerWidth - clientWidth;
|
|
1887
|
+
return scrolls && gutter <= 0 ? 12 : 0;
|
|
1888
|
+
}
|
|
1889
|
+
function subscribe(listener) {
|
|
1890
|
+
const root = document.documentElement;
|
|
1891
|
+
window.addEventListener("resize", listener);
|
|
1892
|
+
if (typeof ResizeObserver === "undefined") return () => window.removeEventListener("resize", listener);
|
|
1893
|
+
const observer = new ResizeObserver(listener);
|
|
1894
|
+
observer.observe(root);
|
|
1895
|
+
if (document.body) observer.observe(document.body);
|
|
1896
|
+
return () => {
|
|
1897
|
+
window.removeEventListener("resize", listener);
|
|
1898
|
+
observer.disconnect();
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
const read = () => scrollbarLane();
|
|
1902
|
+
function useScrollbarLane() {
|
|
1903
|
+
return useSyncExternalStore(subscribe, read, () => 0);
|
|
1904
|
+
}
|
|
1905
|
+
//#endregion
|
|
1906
|
+
//#region src/shell/rail/rail.tsx
|
|
1907
|
+
/** A press that moves less than this is a click, not a drag. */
|
|
1908
|
+
const DRAG_THRESHOLD = 4;
|
|
1909
|
+
/** The round button the rail becomes on a narrow viewport. */
|
|
1910
|
+
const FAB = {
|
|
1911
|
+
width: 44,
|
|
1912
|
+
height: 44
|
|
1913
|
+
};
|
|
1914
|
+
/** Dots on the chip. */
|
|
1915
|
+
const SUMMARY_DOTS = 3;
|
|
1916
|
+
const DefaultIcon = hudIcon("plug");
|
|
1917
|
+
const NO_SIZE = {
|
|
1918
|
+
width: 0,
|
|
1919
|
+
height: 0
|
|
1920
|
+
};
|
|
1921
|
+
/** Plugins that take a rail row: a panel to open, or live pill text to show. */
|
|
1922
|
+
const onRail = (slot) => Boolean(slot.plugin.panel || slot.plugin.pill);
|
|
1923
|
+
/**
|
|
1924
|
+
* Tones of the chip's summary: the badges of the plugins with the highest
|
|
1925
|
+
* priority (then rail order), `off` while a badge reports nothing.
|
|
1926
|
+
*/
|
|
1927
|
+
function summaryTones(slots, badges) {
|
|
1928
|
+
return slots.map((slot, index) => ({
|
|
1929
|
+
slot,
|
|
1930
|
+
index
|
|
1931
|
+
})).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");
|
|
1932
|
+
}
|
|
1933
|
+
/** The FAB's count: every badge count summed, else how many badges are not good. */
|
|
1934
|
+
function badgeTotal(badges) {
|
|
1935
|
+
const list = Object.values(badges).filter((badge) => badge !== null);
|
|
1936
|
+
const counted = list.reduce((sum, badge) => sum + (badge.count ?? 0), 0);
|
|
1937
|
+
if (counted > 0) return counted;
|
|
1938
|
+
return list.filter((badge) => badge.tone === "warn" || badge.tone === "poor").length;
|
|
1939
|
+
}
|
|
1940
|
+
function sameBadge(a, b) {
|
|
1941
|
+
if (!a || !b) return a === b;
|
|
1942
|
+
return a.tone === b.tone && (a.count ?? 0) === (b.count ?? 0);
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* One plugin on the rail: its icon with the badge on it and its label (title,
|
|
1946
|
+
* then the live `pill` output). At the icons level the label is a tooltip; at
|
|
1947
|
+
* the labels level, in the phone sheet and while customising it is in the
|
|
1948
|
+
* row. The pill content is mounted from the start, shown or not, since
|
|
1949
|
+
* built-in pills start their capture on mount; a hidden row stays mounted too.
|
|
1950
|
+
*/
|
|
1951
|
+
function RailItem({ slot, open, hidden, editing, inline, onToggle, onBadge, onHide, onMove, onGrip }) {
|
|
1952
|
+
const { plugin, ctx, title } = slot;
|
|
1953
|
+
const Icon = plugin.icon ?? DefaultIcon;
|
|
1954
|
+
const PillContent = plugin.pill;
|
|
1955
|
+
const badge = plugin.badge ? plugin.badge({ ctx }) : null;
|
|
1956
|
+
const tone = badge?.tone;
|
|
1957
|
+
const count = badge?.count ?? 0;
|
|
1958
|
+
useEffect(() => {
|
|
1959
|
+
onBadge(plugin.id, hidden ? null : tone ? {
|
|
1960
|
+
tone,
|
|
1961
|
+
count
|
|
1962
|
+
} : null);
|
|
1963
|
+
}, [
|
|
1964
|
+
onBadge,
|
|
1965
|
+
plugin.id,
|
|
1966
|
+
tone,
|
|
1967
|
+
count,
|
|
1968
|
+
hidden
|
|
1969
|
+
]);
|
|
1970
|
+
if (!onRail(slot)) return null;
|
|
1971
|
+
const glyph = /* @__PURE__ */ jsxs("span", {
|
|
1972
|
+
className: "rail-glyph",
|
|
1973
|
+
children: [/* @__PURE__ */ jsx(Icon, {}), tone && (count > 0 ? /* @__PURE__ */ jsx("span", {
|
|
1974
|
+
className: "rail-count",
|
|
1975
|
+
"data-tone": tone,
|
|
1976
|
+
children: count
|
|
1977
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
1978
|
+
className: "rail-badge",
|
|
1979
|
+
"data-tone": tone
|
|
1980
|
+
}))]
|
|
1981
|
+
});
|
|
1982
|
+
const label = /* @__PURE__ */ jsxs("span", {
|
|
1983
|
+
className: "rail-tip",
|
|
1984
|
+
role: inline ? void 0 : "tooltip",
|
|
1985
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1986
|
+
className: "rail-tip-title",
|
|
1987
|
+
children: title
|
|
1988
|
+
}), PillContent && /* @__PURE__ */ jsx("span", {
|
|
1989
|
+
className: "rail-pill",
|
|
1990
|
+
"data-pill-id": plugin.id,
|
|
1991
|
+
children: /* @__PURE__ */ jsx(PillContent, { ctx })
|
|
1992
|
+
})]
|
|
1993
|
+
});
|
|
1994
|
+
const gone = hidden && !editing;
|
|
1995
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1996
|
+
className: "rail-item",
|
|
1997
|
+
"data-rail-id": plugin.id,
|
|
1998
|
+
"data-hidden": hidden || void 0,
|
|
1999
|
+
hidden: gone,
|
|
2000
|
+
inert: gone,
|
|
2001
|
+
children: [
|
|
2002
|
+
editing && /* @__PURE__ */ jsx("button", {
|
|
2003
|
+
type: "button",
|
|
2004
|
+
className: "rail-tool rail-grip",
|
|
2005
|
+
"aria-label": `Drag to move ${title}`,
|
|
2006
|
+
title: "Drag to reorder",
|
|
2007
|
+
onPointerDown: onGrip,
|
|
2008
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "grip" })
|
|
2009
|
+
}),
|
|
2010
|
+
plugin.panel && !editing ? /* @__PURE__ */ jsxs("button", {
|
|
2011
|
+
type: "button",
|
|
2012
|
+
className: "rail-button",
|
|
2013
|
+
"aria-pressed": open,
|
|
2014
|
+
"data-open": open || void 0,
|
|
2015
|
+
onClick: onToggle,
|
|
2016
|
+
children: [glyph, label]
|
|
2017
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
2018
|
+
className: "rail-button",
|
|
2019
|
+
children: [glyph, label]
|
|
2020
|
+
}),
|
|
2021
|
+
editing && /* @__PURE__ */ jsxs("span", {
|
|
2022
|
+
className: "rail-edit",
|
|
2023
|
+
children: [
|
|
2024
|
+
/* @__PURE__ */ jsx("button", {
|
|
2025
|
+
type: "button",
|
|
2026
|
+
className: "rail-tool",
|
|
2027
|
+
"aria-label": `Move ${title} up`,
|
|
2028
|
+
onClick: () => onMove(-1),
|
|
2029
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "chevron-up" })
|
|
2030
|
+
}),
|
|
2031
|
+
/* @__PURE__ */ jsx("button", {
|
|
2032
|
+
type: "button",
|
|
2033
|
+
className: "rail-tool",
|
|
2034
|
+
"aria-label": `Move ${title} down`,
|
|
2035
|
+
onClick: () => onMove(1),
|
|
2036
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "chevron-down" })
|
|
2037
|
+
}),
|
|
2038
|
+
/* @__PURE__ */ jsx("button", {
|
|
2039
|
+
type: "button",
|
|
2040
|
+
className: "rail-tool",
|
|
2041
|
+
role: "switch",
|
|
2042
|
+
"aria-checked": !hidden,
|
|
2043
|
+
"aria-label": `Show ${title} on the rail`,
|
|
2044
|
+
onClick: () => onHide(!hidden),
|
|
2045
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: hidden ? "eye-off" : "eye" })
|
|
2046
|
+
})
|
|
2047
|
+
]
|
|
2048
|
+
})
|
|
2049
|
+
]
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
function railStyle(top, size, reserve, side, visual) {
|
|
2053
|
+
if (visual.detached) {
|
|
2054
|
+
const rect = railRect({ top }, size, {
|
|
2055
|
+
w: visual.w,
|
|
2056
|
+
h: visual.h
|
|
2057
|
+
}, reserve, side);
|
|
2058
|
+
return {
|
|
2059
|
+
top: visual.y + rect.top,
|
|
2060
|
+
left: visual.x + rect.left,
|
|
2061
|
+
right: "auto",
|
|
2062
|
+
bottom: "auto"
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
return {
|
|
2066
|
+
top,
|
|
2067
|
+
bottom: "auto",
|
|
2068
|
+
left: side === "left" ? reserve.left : "auto",
|
|
2069
|
+
right: side === "right" ? reserve.right : "auto"
|
|
2070
|
+
};
|
|
2071
|
+
}
|
|
2072
|
+
/**
|
|
2073
|
+
* The edge rail: the default dock. Three detail levels, cycled by the env
|
|
2074
|
+
* chip and ⌘⇧D: the chip alone with summary dots, an icon strip with tooltips,
|
|
2075
|
+
* or a labelled strip with title and live pill text per row. At the strip
|
|
2076
|
+
* levels it spans the full height of its edge, square and flat: the head at
|
|
2077
|
+
* the top, the rows under it, the tools at the bottom. The chip alone moves
|
|
2078
|
+
* off a host fixed element. Customise rail (⋯ menu) lets the user hide
|
|
2079
|
+
* rows and reorder them by drag or arrows. Side, level, order and hidden rows
|
|
2080
|
+
* persist per app. Below 900 px it is one round button bottom-right that
|
|
2081
|
+
* opens a grid sheet of every plugin.
|
|
2082
|
+
*/
|
|
2083
|
+
function Rail({ appSlug, envLabel, slots, grab }) {
|
|
2084
|
+
const panels = usePanels();
|
|
2085
|
+
const { grabbing } = useGrab(grab);
|
|
2086
|
+
const visual = useVisualViewport();
|
|
2087
|
+
const lane = useScrollbarLane();
|
|
2088
|
+
const viewport = useMemo(() => ({
|
|
2089
|
+
w: visual.w,
|
|
2090
|
+
h: visual.h
|
|
2091
|
+
}), [visual.w, visual.h]);
|
|
2092
|
+
const rawObstacles = useObstacles();
|
|
2093
|
+
const obstacles = useMemo(() => offsetObstacles(rawObstacles, {
|
|
2094
|
+
x: visual.x,
|
|
2095
|
+
y: visual.y
|
|
2096
|
+
}), [
|
|
2097
|
+
rawObstacles,
|
|
2098
|
+
visual.x,
|
|
2099
|
+
visual.y
|
|
2100
|
+
]);
|
|
2101
|
+
const mode = isNarrow(viewport) ? "fab" : "rail";
|
|
2102
|
+
const { side, detail, reserve, hiddenItems } = panels;
|
|
2103
|
+
const [editing, setEditing] = useState(false);
|
|
2104
|
+
/** The level the rows lay out at: customising always shows the labels. */
|
|
2105
|
+
const level = editing ? "labels" : detail;
|
|
2106
|
+
const strip = mode === "rail" && level !== "chip";
|
|
2107
|
+
const ref = useRef(null);
|
|
2108
|
+
const bodyRef = useRef(null);
|
|
2109
|
+
const listRef = useRef(null);
|
|
2110
|
+
const midRef = useRef(null);
|
|
2111
|
+
const [size, setSize] = useState(NO_SIZE);
|
|
2112
|
+
/** The rows outgrow the strip: the middle section scrolls (and clips its tooltips). */
|
|
2113
|
+
const [scrolls, setScrolls] = useState(false);
|
|
2114
|
+
const [badges, setBadges] = useState({});
|
|
2115
|
+
const [sheet, setSheet] = useState(false);
|
|
2116
|
+
const [drag, setDrag] = useState(null);
|
|
2117
|
+
const [dragging, setDragging] = useState(null);
|
|
2118
|
+
const press = useRef(null);
|
|
2119
|
+
const dragged = useRef(false);
|
|
2120
|
+
const rows = useMemo(() => slots.filter(onRail), [slots]);
|
|
2121
|
+
const ids = useMemo(() => railOrder(rows.map((slot) => slot.plugin.id), panels.order), [rows, panels.order]);
|
|
2122
|
+
const ordered = useMemo(() => ids.flatMap((id) => {
|
|
2123
|
+
const slot = rows.find((row) => row.plugin.id === id);
|
|
2124
|
+
return slot ? [slot] : [];
|
|
2125
|
+
}), [ids, rows]);
|
|
2126
|
+
const shown = useMemo(() => ordered.filter((slot) => !hiddenItems.includes(slot.plugin.id)), [ordered, hiddenItems]);
|
|
2127
|
+
const onBadge = useCallback((id, badge) => {
|
|
2128
|
+
setBadges((prev) => sameBadge(prev[id], badge) ? prev : {
|
|
2129
|
+
...prev,
|
|
2130
|
+
[id]: badge
|
|
2131
|
+
});
|
|
2132
|
+
}, []);
|
|
2133
|
+
useRegisterCommands(useMemo(() => [{
|
|
2134
|
+
id: "hud.customise-rail",
|
|
2135
|
+
title: "Customise rail",
|
|
2136
|
+
run: () => setEditing(true)
|
|
2137
|
+
}], []));
|
|
2138
|
+
useLayoutEffect(() => {
|
|
2139
|
+
const body = bodyRef.current;
|
|
2140
|
+
const mid = midRef.current;
|
|
2141
|
+
if (!body || !mid) return;
|
|
2142
|
+
const update = () => {
|
|
2143
|
+
setSize((prev) => prev.width === body.offsetWidth && prev.height === body.offsetHeight ? prev : {
|
|
2144
|
+
width: body.offsetWidth,
|
|
2145
|
+
height: body.offsetHeight
|
|
2146
|
+
});
|
|
2147
|
+
setScrolls(mid.scrollHeight > mid.clientHeight + 1);
|
|
2148
|
+
};
|
|
2149
|
+
update();
|
|
2150
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
2151
|
+
const observer = new ResizeObserver(update);
|
|
2152
|
+
observer.observe(body);
|
|
2153
|
+
observer.observe(mid);
|
|
2154
|
+
return () => observer.disconnect();
|
|
2155
|
+
}, []);
|
|
2156
|
+
const dismissable = mode === "fab" && sheet || editing;
|
|
2157
|
+
useEffect(() => {
|
|
2158
|
+
if (!dismissable) return;
|
|
2159
|
+
const onPointerDown = (e) => {
|
|
2160
|
+
if (ref.current && !e.composedPath().includes(ref.current)) {
|
|
2161
|
+
setSheet(false);
|
|
2162
|
+
setEditing(false);
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
const onKeyDown = (e) => {
|
|
2166
|
+
if (e.key === "Escape") {
|
|
2167
|
+
setSheet(false);
|
|
2168
|
+
setEditing(false);
|
|
2169
|
+
}
|
|
2170
|
+
};
|
|
2171
|
+
window.addEventListener("pointerdown", onPointerDown, true);
|
|
2172
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
2173
|
+
return () => {
|
|
2174
|
+
window.removeEventListener("pointerdown", onPointerDown, true);
|
|
2175
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
2176
|
+
};
|
|
2177
|
+
}, [dismissable]);
|
|
2178
|
+
const placed = useMemo(() => {
|
|
2179
|
+
if (mode === "fab" || strip) return null;
|
|
2180
|
+
return placeRail({
|
|
2181
|
+
viewport,
|
|
2182
|
+
size,
|
|
2183
|
+
obstacles,
|
|
2184
|
+
reserve,
|
|
2185
|
+
side
|
|
2186
|
+
});
|
|
2187
|
+
}, [
|
|
2188
|
+
mode,
|
|
2189
|
+
strip,
|
|
2190
|
+
viewport,
|
|
2191
|
+
size,
|
|
2192
|
+
obstacles,
|
|
2193
|
+
reserve,
|
|
2194
|
+
side
|
|
2195
|
+
]);
|
|
2196
|
+
const style = useMemo(() => {
|
|
2197
|
+
if (mode === "fab") return placementStyle(placePill({
|
|
2198
|
+
viewport,
|
|
2199
|
+
size: FAB,
|
|
2200
|
+
obstacles,
|
|
2201
|
+
reserve,
|
|
2202
|
+
pinned: "bottom-right"
|
|
2203
|
+
}) ?? {
|
|
2204
|
+
corner: "bottom-right",
|
|
2205
|
+
shift: 0
|
|
2206
|
+
}, FAB, reserve, visual);
|
|
2207
|
+
const top = placed?.top ?? 0;
|
|
2208
|
+
if (!strip) return railStyle(top, size, reserve, side, visual);
|
|
2209
|
+
const edge = railStyle(0, size, reserve, side, visual);
|
|
2210
|
+
return visual.detached ? {
|
|
2211
|
+
...edge,
|
|
2212
|
+
height: visual.h,
|
|
2213
|
+
width: size.width
|
|
2214
|
+
} : {
|
|
2215
|
+
...edge,
|
|
2216
|
+
top: 0,
|
|
2217
|
+
bottom: reserve.bottom,
|
|
2218
|
+
width: size.width
|
|
2219
|
+
};
|
|
2220
|
+
}, [
|
|
2221
|
+
mode,
|
|
2222
|
+
strip,
|
|
2223
|
+
placed,
|
|
2224
|
+
viewport,
|
|
2225
|
+
size,
|
|
2226
|
+
obstacles,
|
|
2227
|
+
reserve,
|
|
2228
|
+
side,
|
|
2229
|
+
visual
|
|
2230
|
+
]);
|
|
2231
|
+
const onPointerDown = (e) => {
|
|
2232
|
+
if (e.button !== 0 || mode !== "rail") return;
|
|
2233
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2234
|
+
press.current = {
|
|
2235
|
+
x: e.clientX,
|
|
2236
|
+
y: e.clientY,
|
|
2237
|
+
moved: false
|
|
2238
|
+
};
|
|
2239
|
+
};
|
|
2240
|
+
const onPointerMove = (e) => {
|
|
2241
|
+
const start = press.current;
|
|
2242
|
+
if (!start) return;
|
|
2243
|
+
const x = e.clientX - start.x;
|
|
2244
|
+
const y = e.clientY - start.y;
|
|
2245
|
+
if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD) return;
|
|
2246
|
+
start.moved = true;
|
|
2247
|
+
setDrag({
|
|
2248
|
+
x,
|
|
2249
|
+
y
|
|
2250
|
+
});
|
|
2251
|
+
};
|
|
2252
|
+
const onPointerUp = (e) => {
|
|
2253
|
+
const start = press.current;
|
|
2254
|
+
press.current = null;
|
|
2255
|
+
setDrag(null);
|
|
2256
|
+
if (!start?.moved) return;
|
|
2257
|
+
dragged.current = true;
|
|
2258
|
+
panels.setSide(nearestSide(e.clientX, viewport));
|
|
2259
|
+
};
|
|
2260
|
+
const onChipClick = () => {
|
|
2261
|
+
if (dragged.current) {
|
|
2262
|
+
dragged.current = false;
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
if (mode === "fab") setSheet((open) => !open);
|
|
2266
|
+
else if (editing) setEditing(false);
|
|
2267
|
+
else panels.setDetail({
|
|
2268
|
+
chip: "icons",
|
|
2269
|
+
icons: "labels",
|
|
2270
|
+
labels: "chip"
|
|
2271
|
+
}[detail]);
|
|
2272
|
+
};
|
|
2273
|
+
/** Drag a row's grip: the row follows the pointer through the list, the order updates live. */
|
|
2274
|
+
const onGrip = (id) => (e) => {
|
|
2275
|
+
if (e.button !== 0) return;
|
|
2276
|
+
const grip = e.currentTarget;
|
|
2277
|
+
grip.setPointerCapture(e.pointerId);
|
|
2278
|
+
setDragging(id);
|
|
2279
|
+
const move = (event) => {
|
|
2280
|
+
const list = listRef.current;
|
|
2281
|
+
if (!list) return;
|
|
2282
|
+
const index = [...list.querySelectorAll("[data-rail-id]")].filter((row) => row.dataset.railId !== id).filter((row) => {
|
|
2283
|
+
const box = row.getBoundingClientRect();
|
|
2284
|
+
return box.top + box.height / 2 < event.clientY;
|
|
2285
|
+
}).length;
|
|
2286
|
+
panels.moveItem(ids, id, index);
|
|
2287
|
+
};
|
|
2288
|
+
const up = () => {
|
|
2289
|
+
grip.removeEventListener("pointermove", move);
|
|
2290
|
+
grip.removeEventListener("pointerup", up);
|
|
2291
|
+
grip.removeEventListener("pointercancel", up);
|
|
2292
|
+
setDragging(null);
|
|
2293
|
+
};
|
|
2294
|
+
grip.addEventListener("pointermove", move);
|
|
2295
|
+
grip.addEventListener("pointerup", up);
|
|
2296
|
+
grip.addEventListener("pointercancel", up);
|
|
2297
|
+
};
|
|
2298
|
+
const listHidden = mode === "fab" ? !sheet : level === "chip";
|
|
2299
|
+
const total = badgeTotal(badges);
|
|
2300
|
+
const chipTitle = mode === "fab" ? `${envLabel} HUD` : editing ? "Done customising" : "Click for the next detail level · ⌘⇧D · drag to the other edge";
|
|
2301
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2302
|
+
ref,
|
|
2303
|
+
className: "rail hud-dock",
|
|
2304
|
+
role: "toolbar",
|
|
2305
|
+
"aria-label": `${appSlug} hud`,
|
|
2306
|
+
"data-side": side,
|
|
2307
|
+
"data-mode": mode,
|
|
2308
|
+
"data-detail": level,
|
|
2309
|
+
"data-editing": editing || void 0,
|
|
2310
|
+
"data-dragging": drag ? true : void 0,
|
|
2311
|
+
style: {
|
|
2312
|
+
...style,
|
|
2313
|
+
"--rail-lane": `${side === "right" && mode === "rail" ? lane : 0}px`,
|
|
2314
|
+
...drag ? { transform: `translate(${drag.x}px, ${drag.y}px)` } : {}
|
|
2315
|
+
},
|
|
2316
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2317
|
+
ref: bodyRef,
|
|
2318
|
+
className: "rail-body",
|
|
2319
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2320
|
+
className: "rail-top",
|
|
2321
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2322
|
+
className: "rail-head",
|
|
2323
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
2324
|
+
type: "button",
|
|
2325
|
+
className: "rail-chip env",
|
|
2326
|
+
"aria-label": `${envLabel} HUD`,
|
|
2327
|
+
"aria-expanded": !listHidden,
|
|
2328
|
+
title: chipTitle,
|
|
2329
|
+
onClick: onChipClick,
|
|
2330
|
+
onPointerDown,
|
|
2331
|
+
onPointerMove,
|
|
2332
|
+
onPointerUp,
|
|
2333
|
+
onPointerCancel: () => {
|
|
2334
|
+
press.current = null;
|
|
2335
|
+
setDrag(null);
|
|
2336
|
+
},
|
|
2337
|
+
children: mode === "fab" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HudIconGlyph, { name: "wrench" }), total > 0 && /* @__PURE__ */ jsx("span", {
|
|
2338
|
+
className: "rail-count",
|
|
2339
|
+
children: total
|
|
2340
|
+
})] }) : envLabel
|
|
2341
|
+
}), editing && /* @__PURE__ */ jsx("button", {
|
|
2342
|
+
type: "button",
|
|
2343
|
+
className: "rail-done",
|
|
2344
|
+
onClick: () => setEditing(false),
|
|
2345
|
+
children: "Done"
|
|
2346
|
+
})]
|
|
2347
|
+
}), mode === "rail" && level === "chip" && /* @__PURE__ */ jsx("span", {
|
|
2348
|
+
className: "rail-dots",
|
|
2349
|
+
"aria-hidden": "true",
|
|
2350
|
+
children: summaryTones(shown, badges).map((tone, i) => /* @__PURE__ */ jsx("span", {
|
|
2351
|
+
className: "dot",
|
|
2352
|
+
"data-tone": tone
|
|
2353
|
+
}, i))
|
|
2354
|
+
})]
|
|
2355
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2356
|
+
ref: listRef,
|
|
2357
|
+
className: "rail-list",
|
|
2358
|
+
inert: listHidden,
|
|
2359
|
+
children: [
|
|
2360
|
+
mode === "fab" && /* @__PURE__ */ jsxs("div", {
|
|
2361
|
+
className: "rail-sheet-head",
|
|
2362
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2363
|
+
className: "env",
|
|
2364
|
+
children: envLabel
|
|
2365
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
2366
|
+
type: "button",
|
|
2367
|
+
className: "rail-button rail-close",
|
|
2368
|
+
"aria-label": "Close HUD sheet",
|
|
2369
|
+
onClick: () => setSheet(false),
|
|
2370
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "x" })
|
|
2371
|
+
})]
|
|
2372
|
+
}),
|
|
2373
|
+
/* @__PURE__ */ jsx("div", {
|
|
2374
|
+
ref: midRef,
|
|
2375
|
+
className: "rail-mid",
|
|
2376
|
+
"data-scroll": scrolls || void 0,
|
|
2377
|
+
children: ordered.map((slot, index) => /* @__PURE__ */ jsx(RailItem, {
|
|
2378
|
+
slot,
|
|
2379
|
+
open: panels.isOpen(slot.plugin.id),
|
|
2380
|
+
hidden: hiddenItems.includes(slot.plugin.id),
|
|
2381
|
+
editing,
|
|
2382
|
+
inline: level === "labels" || mode === "fab",
|
|
2383
|
+
onToggle: () => panels.toggle(slot.plugin.id),
|
|
2384
|
+
onBadge,
|
|
2385
|
+
onHide: (hidden) => panels.setItemHidden(slot.plugin.id, hidden),
|
|
2386
|
+
onMove: (delta) => panels.moveItem(ids, slot.plugin.id, index + delta),
|
|
2387
|
+
onGrip: onGrip(slot.plugin.id)
|
|
2388
|
+
}, slot.plugin.id))
|
|
2389
|
+
}),
|
|
2390
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2391
|
+
className: "rail-bottom",
|
|
2392
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2393
|
+
className: "rail-item",
|
|
2394
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
2395
|
+
type: "button",
|
|
2396
|
+
className: "rail-button grab-toggle",
|
|
2397
|
+
"aria-label": "Grab element",
|
|
2398
|
+
"aria-pressed": grabbing,
|
|
2399
|
+
onClick: () => grabbing ? grab.cancel() : grab.start(),
|
|
2400
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2401
|
+
className: "rail-glyph",
|
|
2402
|
+
children: /* @__PURE__ */ jsx(HudIconGlyph, { name: "crosshair" })
|
|
2403
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2404
|
+
className: "rail-tip",
|
|
2405
|
+
role: "tooltip",
|
|
2406
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2407
|
+
className: "rail-tip-title",
|
|
2408
|
+
children: "Grab element"
|
|
2409
|
+
})
|
|
2410
|
+
})]
|
|
2411
|
+
})
|
|
2412
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2413
|
+
className: "rail-item",
|
|
2414
|
+
children: /* @__PURE__ */ jsx(PillMenu, {
|
|
2415
|
+
dock: "rail",
|
|
2416
|
+
inline: mode === "fab"
|
|
2417
|
+
})
|
|
2418
|
+
})]
|
|
2419
|
+
})
|
|
2420
|
+
]
|
|
2421
|
+
})]
|
|
2422
|
+
}), dragging && /* @__PURE__ */ jsx("span", {
|
|
2423
|
+
className: "rail-drag-hint",
|
|
2424
|
+
"aria-hidden": "true"
|
|
2425
|
+
})]
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
1657
2428
|
//#endregion
|
|
1658
2429
|
//#region src/shell/hud.tsx
|
|
1659
|
-
const CSS = HUD_CSS + PANEL_CSS +
|
|
2430
|
+
const CSS = HUD_CSS + PANEL_CSS + `
|
|
2431
|
+
.rail {
|
|
2432
|
+
--hud-bg: rgba(24, 24, 27, 0.94);
|
|
2433
|
+
--hud-bg-subtle: rgba(255, 255, 255, 0.08);
|
|
2434
|
+
--hud-fg: #f4f4f5;
|
|
2435
|
+
--hud-fg-muted: #a1a1aa;
|
|
2436
|
+
--hud-border: rgba(255, 255, 255, 0.1);
|
|
2437
|
+
--hud-accent: #7dd3fc;
|
|
2438
|
+
--hud-accent-fg: #082f49;
|
|
2439
|
+
--hud-good: #4ade80;
|
|
2440
|
+
--hud-warn: #fbbf24;
|
|
2441
|
+
--hud-poor: #f87171;
|
|
2442
|
+
--hud-off: #71717a;
|
|
2443
|
+
--hud-shadow: -4px 0 20px rgba(0, 0, 0, 0.18);
|
|
2444
|
+
|
|
2445
|
+
position: fixed;
|
|
2446
|
+
/* Above floating panels (1..n) and the bottom sheet (1000): the dock, its tooltips and its menu stay reachable. */
|
|
2447
|
+
z-index: 1001;
|
|
2448
|
+
display: flex;
|
|
2449
|
+
flex-direction: column;
|
|
2450
|
+
align-items: stretch;
|
|
2451
|
+
background: var(--hud-bg);
|
|
2452
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2453
|
+
backdrop-filter: blur(10px);
|
|
2454
|
+
border: 1px solid var(--hud-border);
|
|
2455
|
+
border-right: 0;
|
|
2456
|
+
border-radius: 10px 0 0 10px;
|
|
2457
|
+
box-shadow: var(--hud-shadow);
|
|
2458
|
+
color: var(--hud-fg);
|
|
2459
|
+
font-family: var(--hud-mono);
|
|
2460
|
+
font-size: 11px;
|
|
2461
|
+
line-height: 1;
|
|
2462
|
+
pointer-events: auto;
|
|
2463
|
+
transition: top 0.18s ease;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
.rail[data-side="left"] {
|
|
2467
|
+
--hud-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
|
|
2468
|
+
border-right: 1px solid var(--hud-border);
|
|
2469
|
+
border-left: 0;
|
|
2470
|
+
border-radius: 0 10px 10px 0;
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
.rail[data-dragging] { opacity: 0.85; transition: none; }
|
|
2474
|
+
|
|
2475
|
+
/* Three sections: the head (chip, dots), the plugin rows, the tools (grab, menu). The
|
|
2476
|
+
right-docked body also leaves the page's overlay scrollbar its lane (\`--rail-lane\`). */
|
|
2477
|
+
.rail-body {
|
|
2478
|
+
display: flex;
|
|
2479
|
+
flex-direction: column;
|
|
2480
|
+
padding: 0 var(--rail-lane, 0px) 0 0;
|
|
2481
|
+
}
|
|
2482
|
+
.rail-top, .rail-bottom {
|
|
2483
|
+
display: flex;
|
|
2484
|
+
flex-direction: column;
|
|
2485
|
+
gap: 2px;
|
|
2486
|
+
padding: 4px;
|
|
2487
|
+
background: var(--hud-zone, rgba(255, 255, 255, 0.04));
|
|
2488
|
+
}
|
|
2489
|
+
.rail-top { border-bottom: 1px solid var(--hud-border); }
|
|
2490
|
+
.rail-bottom { border-top: 1px solid var(--hud-border); }
|
|
2491
|
+
.rail-mid { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; }
|
|
2492
|
+
/* The strip: the rows take the room between the head and the tools, aligned under the head;
|
|
2493
|
+
too many of them and the middle section scrolls between the two pinned sections. */
|
|
2494
|
+
.rail[data-mode="rail"] .rail-list,
|
|
2495
|
+
.rail[data-mode="rail"] .rail-mid { flex: 1; min-height: 0; }
|
|
2496
|
+
.rail[data-mode="rail"] .rail-mid[data-scroll] { overflow-y: auto; scrollbar-width: thin; }
|
|
2497
|
+
|
|
2498
|
+
/* Icons and labels: a flat strip down the whole edge, the head at its top and the tools at its bottom. */
|
|
2499
|
+
.rail[data-mode="rail"]:not([data-detail="chip"]) {
|
|
2500
|
+
border-radius: 0;
|
|
2501
|
+
box-shadow: none;
|
|
2502
|
+
border-top: 0;
|
|
2503
|
+
border-bottom: 0;
|
|
2504
|
+
transition: none;
|
|
2505
|
+
}
|
|
2506
|
+
.rail[data-mode="rail"]:not([data-detail="chip"]) .rail-body {
|
|
2507
|
+
/* Shrink-wraps its rows; the strip takes its measured width (no right: 0, or the two would size each other). */
|
|
2508
|
+
position: absolute;
|
|
2509
|
+
top: 0;
|
|
2510
|
+
bottom: 0;
|
|
2511
|
+
left: 0;
|
|
2512
|
+
}
|
|
2513
|
+
.rail[data-detail="labels"] .rail-body { width: calc(224px + var(--rail-lane, 0px)); }
|
|
2514
|
+
|
|
2515
|
+
.rail-head { display: flex; align-items: center; gap: 4px; }
|
|
2516
|
+
.hud .rail-chip {
|
|
2517
|
+
flex: 1;
|
|
2518
|
+
display: flex;
|
|
2519
|
+
align-items: center;
|
|
2520
|
+
justify-content: center;
|
|
2521
|
+
height: 24px;
|
|
2522
|
+
min-width: 28px;
|
|
2523
|
+
border-radius: 5px;
|
|
2524
|
+
background: var(--hud-bg-subtle);
|
|
2525
|
+
color: var(--hud-accent);
|
|
2526
|
+
font-size: 9px;
|
|
2527
|
+
font-weight: 600;
|
|
2528
|
+
letter-spacing: 0.08em;
|
|
2529
|
+
cursor: grab;
|
|
2530
|
+
touch-action: none;
|
|
2531
|
+
user-select: none;
|
|
2532
|
+
}
|
|
2533
|
+
.hud .rail-chip:hover { background: var(--hud-border); }
|
|
2534
|
+
.rail[data-dragging] .rail-chip { cursor: grabbing; }
|
|
2535
|
+
.rail[data-detail="chip"] .rail-chip { height: 28px; min-width: 36px; }
|
|
2536
|
+
.hud .rail-done {
|
|
2537
|
+
padding: 0 8px;
|
|
2538
|
+
height: 24px;
|
|
2539
|
+
border-radius: 5px;
|
|
2540
|
+
background: var(--hud-accent);
|
|
2541
|
+
color: var(--hud-accent-fg);
|
|
2542
|
+
font-weight: 600;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
.rail-dots { display: flex; justify-content: center; gap: 3px; padding: 4px 0 2px; }
|
|
2546
|
+
.rail .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hud-off); }
|
|
2547
|
+
.rail .dot[data-tone="good"] { background: var(--hud-good); }
|
|
2548
|
+
.rail .dot[data-tone="warn"] { background: var(--hud-warn); }
|
|
2549
|
+
.rail .dot[data-tone="poor"] { background: var(--hud-poor); }
|
|
2550
|
+
|
|
2551
|
+
.rail-list { display: flex; flex-direction: column; overflow: visible; }
|
|
2552
|
+
.rail[data-detail="chip"] .rail-list { display: none; }
|
|
2553
|
+
.rail[data-detail="chip"] .rail-top { border-bottom: 0; background: none; }
|
|
2554
|
+
|
|
2555
|
+
.rail-item { position: relative; display: flex; align-items: center; gap: 2px; }
|
|
2556
|
+
.rail-item[hidden] { display: none; }
|
|
2557
|
+
.rail-item[data-hidden] .rail-button { opacity: 0.45; }
|
|
2558
|
+
|
|
2559
|
+
.hud .rail-button {
|
|
2560
|
+
position: relative;
|
|
2561
|
+
display: flex;
|
|
2562
|
+
align-items: center;
|
|
2563
|
+
justify-content: center;
|
|
2564
|
+
width: 28px;
|
|
2565
|
+
height: 28px;
|
|
2566
|
+
border-radius: 6px;
|
|
2567
|
+
color: var(--hud-fg-muted);
|
|
2568
|
+
}
|
|
2569
|
+
.hud .rail-button:hover,
|
|
2570
|
+
.hud .rail-button[aria-pressed="true"] { background: var(--hud-bg-subtle); color: var(--hud-fg); }
|
|
2571
|
+
.hud .rail-button[data-open] { color: var(--hud-accent); }
|
|
2572
|
+
.hud span.rail-button:hover { background: none; }
|
|
2573
|
+
|
|
2574
|
+
.rail-glyph { position: relative; display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; flex: none; }
|
|
2575
|
+
.rail .icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
|
|
2576
|
+
.rail-chip .icon { width: 18px; height: 18px; }
|
|
2577
|
+
|
|
2578
|
+
.rail-badge { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--hud-off); }
|
|
2579
|
+
.rail-badge[data-tone="good"] { background: var(--hud-good); }
|
|
2580
|
+
.rail-badge[data-tone="warn"] { background: var(--hud-warn); }
|
|
2581
|
+
.rail-badge[data-tone="poor"] { background: var(--hud-poor); }
|
|
2582
|
+
|
|
2583
|
+
.rail-count {
|
|
2584
|
+
position: absolute;
|
|
2585
|
+
top: 1px;
|
|
2586
|
+
right: 1px;
|
|
2587
|
+
display: flex;
|
|
2588
|
+
align-items: center;
|
|
2589
|
+
justify-content: center;
|
|
2590
|
+
min-width: 13px;
|
|
2591
|
+
height: 13px;
|
|
2592
|
+
padding: 0 3px;
|
|
2593
|
+
border-radius: 7px;
|
|
2594
|
+
background: var(--hud-poor);
|
|
2595
|
+
color: #fff;
|
|
2596
|
+
font-size: 9px;
|
|
2597
|
+
font-weight: 600;
|
|
2598
|
+
line-height: 1;
|
|
2599
|
+
}
|
|
2600
|
+
.rail-count[data-tone="good"] { background: var(--hud-good); color: #052e16; }
|
|
2601
|
+
.rail-count[data-tone="warn"] { background: var(--hud-warn); color: #451a03; }
|
|
2602
|
+
.rail-count[data-tone="off"] { background: var(--hud-off); }
|
|
2603
|
+
|
|
2604
|
+
/* Icons level: the label is a tooltip beside the rail, away from the edge. Its pill content is always mounted. */
|
|
2605
|
+
.rail-tip {
|
|
2606
|
+
position: absolute;
|
|
2607
|
+
top: 50%;
|
|
2608
|
+
right: calc(100% + 10px);
|
|
2609
|
+
display: flex;
|
|
2610
|
+
align-items: center;
|
|
2611
|
+
gap: 6px;
|
|
2612
|
+
padding: 6px 9px;
|
|
2613
|
+
border: 1px solid var(--hud-border);
|
|
2614
|
+
border-radius: 7px;
|
|
2615
|
+
background: var(--hud-bg);
|
|
2616
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2617
|
+
backdrop-filter: blur(10px);
|
|
2618
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
|
|
2619
|
+
color: var(--hud-fg);
|
|
2620
|
+
white-space: nowrap;
|
|
2621
|
+
transform: translateY(-50%);
|
|
2622
|
+
opacity: 0;
|
|
2623
|
+
visibility: hidden;
|
|
2624
|
+
pointer-events: none;
|
|
2625
|
+
transition: opacity 0.12s;
|
|
2626
|
+
}
|
|
2627
|
+
.rail[data-side="left"] .rail-tip { right: auto; left: calc(100% + 10px); }
|
|
2628
|
+
.rail-button:hover .rail-tip,
|
|
2629
|
+
.rail-button:focus-visible .rail-tip { opacity: 1; visibility: visible; }
|
|
2630
|
+
.rail-tip-title { font-weight: 600; }
|
|
2631
|
+
/* In the tooltip the live pill sits behind a hairline, like the rail's own sections. */
|
|
2632
|
+
.rail-pill {
|
|
2633
|
+
display: inline-flex;
|
|
2634
|
+
align-items: center;
|
|
2635
|
+
gap: 6px;
|
|
2636
|
+
padding-left: 8px;
|
|
2637
|
+
border-left: 1px solid var(--hud-border);
|
|
2638
|
+
color: var(--hud-fg-muted);
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
/* Labels level and the phone sheet: the label sits in the row. */
|
|
2642
|
+
.rail[data-detail="labels"] .rail-item,
|
|
2643
|
+
.rail[data-mode="fab"] .rail-item { min-width: 0; }
|
|
2644
|
+
.hud .rail[data-detail="labels"] .rail-button,
|
|
2645
|
+
.hud .rail[data-mode="fab"] .rail-button {
|
|
2646
|
+
flex: 1;
|
|
2647
|
+
width: auto;
|
|
2648
|
+
height: auto;
|
|
2649
|
+
min-width: 0;
|
|
2650
|
+
justify-content: flex-start;
|
|
2651
|
+
gap: 4px;
|
|
2652
|
+
padding: 2px 6px 2px 0;
|
|
2653
|
+
}
|
|
2654
|
+
.rail[data-detail="labels"] .rail-tip,
|
|
2655
|
+
.rail[data-mode="fab"] .rail-tip {
|
|
2656
|
+
position: static;
|
|
2657
|
+
min-width: 0;
|
|
2658
|
+
transform: none;
|
|
2659
|
+
opacity: 1;
|
|
2660
|
+
visibility: visible;
|
|
2661
|
+
padding: 0;
|
|
2662
|
+
border: 0;
|
|
2663
|
+
background: none;
|
|
2664
|
+
pointer-events: auto;
|
|
2665
|
+
}
|
|
2666
|
+
.rail[data-detail="labels"] .rail-pill,
|
|
2667
|
+
.rail[data-mode="fab"] .rail-pill { min-width: 0; overflow: hidden; padding-left: 0; border-left: 0; }
|
|
2668
|
+
.rail[data-detail="labels"] .rail-pill::before,
|
|
2669
|
+
.rail[data-mode="fab"] .rail-pill::before { content: "·"; color: var(--hud-fg-muted); }
|
|
2670
|
+
.rail[data-detail="labels"] .rail-pill > :last-child,
|
|
2671
|
+
.rail[data-mode="fab"] .rail-pill > :last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2672
|
+
|
|
2673
|
+
/* Customise rail: grip, arrows and the show switch per row. */
|
|
2674
|
+
.hud .rail-tool {
|
|
2675
|
+
display: flex;
|
|
2676
|
+
align-items: center;
|
|
2677
|
+
justify-content: center;
|
|
2678
|
+
width: 20px;
|
|
2679
|
+
height: 24px;
|
|
2680
|
+
border-radius: 4px;
|
|
2681
|
+
color: var(--hud-fg-muted);
|
|
2682
|
+
flex: none;
|
|
2683
|
+
}
|
|
2684
|
+
.hud .rail-tool:hover { background: var(--hud-bg-subtle); color: var(--hud-fg); }
|
|
2685
|
+
.hud .rail-grip { cursor: grab; touch-action: none; }
|
|
2686
|
+
.hud .rail-grip:active { cursor: grabbing; }
|
|
2687
|
+
.rail-edit { display: flex; gap: 0; flex: none; }
|
|
2688
|
+
.hud .rail-tool[role="switch"][aria-checked="true"] { color: var(--hud-accent); }
|
|
2689
|
+
|
|
2690
|
+
/* The menu opens beside the rail, from its bottom item, in the rail's own language:
|
|
2691
|
+
tinted section heads behind hairlines, mono type, flat rows. */
|
|
2692
|
+
.rail .menu { left: auto; right: calc(100% + 10px); top: auto; bottom: 0; }
|
|
2693
|
+
.rail[data-side="left"] .menu { right: auto; left: calc(100% + 10px); }
|
|
2694
|
+
.rail[data-mode="rail"] .menu {
|
|
2695
|
+
padding: 0 0 4px;
|
|
2696
|
+
border-radius: 8px;
|
|
2697
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2698
|
+
backdrop-filter: blur(10px);
|
|
2699
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
|
2700
|
+
font-family: var(--hud-mono);
|
|
2701
|
+
font-size: 11px;
|
|
2702
|
+
}
|
|
2703
|
+
.rail[data-mode="rail"] .menu-label {
|
|
2704
|
+
padding: 6px 8px;
|
|
2705
|
+
margin-bottom: 4px;
|
|
2706
|
+
background: var(--hud-zone, rgba(255, 255, 255, 0.04));
|
|
2707
|
+
border-bottom: 1px solid var(--hud-border);
|
|
2708
|
+
}
|
|
2709
|
+
.rail[data-mode="rail"] .menu-label:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--hud-border); }
|
|
2710
|
+
.hud .rail[data-mode="rail"] .menu-item { margin: 0 4px; border-radius: 5px; }
|
|
2711
|
+
|
|
2712
|
+
/* Phone: one round button bottom-right; the list is a grid sheet above it. */
|
|
2713
|
+
.rail[data-mode="fab"] {
|
|
2714
|
+
--hud-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
|
|
2715
|
+
border: 0;
|
|
2716
|
+
background: none;
|
|
2717
|
+
-webkit-backdrop-filter: none;
|
|
2718
|
+
backdrop-filter: none;
|
|
2719
|
+
box-shadow: none;
|
|
2720
|
+
border-radius: 0;
|
|
2721
|
+
}
|
|
2722
|
+
.rail[data-mode="fab"] .rail-body { padding: 0; }
|
|
2723
|
+
.rail[data-mode="fab"] .rail-top { padding: 0; background: none; border: 0; }
|
|
2724
|
+
.rail[data-mode="fab"] .rail-mid,
|
|
2725
|
+
.rail[data-mode="fab"] .rail-bottom { display: contents; }
|
|
2726
|
+
.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; }
|
|
2727
|
+
.hud .rail[data-mode="fab"] .rail-chip {
|
|
2728
|
+
position: relative;
|
|
2729
|
+
flex: none;
|
|
2730
|
+
width: 44px;
|
|
2731
|
+
height: 44px;
|
|
2732
|
+
min-width: 0;
|
|
2733
|
+
border-radius: 50%;
|
|
2734
|
+
background: var(--hud-bg);
|
|
2735
|
+
border: 1px solid var(--hud-border);
|
|
2736
|
+
box-shadow: var(--hud-shadow);
|
|
2737
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2738
|
+
backdrop-filter: blur(10px);
|
|
2739
|
+
cursor: pointer;
|
|
2740
|
+
}
|
|
2741
|
+
.rail[data-mode="fab"] .rail-head { justify-content: flex-end; }
|
|
2742
|
+
.rail[data-mode="fab"] .rail-done { position: absolute; right: 52px; bottom: 10px; }
|
|
2743
|
+
.rail[data-mode="fab"] .rail-chip .rail-count { top: -2px; right: -2px; min-width: 16px; height: 16px; font-size: 10px; }
|
|
2744
|
+
.rail[data-mode="fab"] .rail-list {
|
|
2745
|
+
position: absolute;
|
|
2746
|
+
right: 0;
|
|
2747
|
+
bottom: calc(100% + 10px);
|
|
2748
|
+
display: grid;
|
|
2749
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
2750
|
+
gap: 2px;
|
|
2751
|
+
width: min(300px, calc(100vw - 24px));
|
|
2752
|
+
max-height: 60vh;
|
|
2753
|
+
overflow: auto;
|
|
2754
|
+
padding: 6px;
|
|
2755
|
+
background: var(--hud-bg);
|
|
2756
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2757
|
+
backdrop-filter: blur(10px);
|
|
2758
|
+
border: 1px solid var(--hud-border);
|
|
2759
|
+
border-radius: 12px;
|
|
2760
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
2761
|
+
}
|
|
2762
|
+
.rail[data-mode="fab"][data-editing] .rail-list { grid-template-columns: minmax(0, 1fr); }
|
|
2763
|
+
.rail[data-mode="fab"] .rail-list[inert] { display: none; }
|
|
2764
|
+
.rail-sheet-head {
|
|
2765
|
+
grid-column: 1 / -1;
|
|
2766
|
+
display: flex;
|
|
2767
|
+
align-items: center;
|
|
2768
|
+
justify-content: space-between;
|
|
2769
|
+
padding: 4px 6px 6px;
|
|
2770
|
+
margin-bottom: 4px;
|
|
2771
|
+
border-bottom: 1px solid var(--hud-border);
|
|
2772
|
+
}
|
|
2773
|
+
.rail-sheet-head .env { color: var(--hud-accent); font-weight: 600; letter-spacing: 0.08em; cursor: default; }
|
|
2774
|
+
.hud .rail[data-mode="fab"] .rail-button { padding: 5px 6px; }
|
|
2775
|
+
.hud .rail[data-mode="fab"] .rail-close { flex: none; width: 28px; height: 28px; padding: 0; justify-content: center; }
|
|
2776
|
+
/* In the sheet the menu is not a popover (the scrolling grid would clip it): it unfolds
|
|
2777
|
+
below the Menu row, across both columns, and scrolls with the sheet. */
|
|
2778
|
+
.rail[data-mode="fab"] .rail-item:has(.menu-anchor) { grid-column: 1 / -1; }
|
|
2779
|
+
.rail[data-mode="fab"] .menu-anchor { width: 100%; flex-direction: column; }
|
|
2780
|
+
.rail[data-mode="fab"] .menu {
|
|
2781
|
+
position: static;
|
|
2782
|
+
min-width: 0;
|
|
2783
|
+
max-height: none;
|
|
2784
|
+
margin-top: 4px;
|
|
2785
|
+
border: 0;
|
|
2786
|
+
border-top: 1px solid var(--hud-border);
|
|
2787
|
+
border-radius: 0;
|
|
2788
|
+
box-shadow: none;
|
|
2789
|
+
background: none;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2793
|
+
.rail, .rail * { transition: none !important; }
|
|
2794
|
+
}
|
|
2795
|
+
` + GRAB_CSS;
|
|
1660
2796
|
const NO_PLUGINS = [];
|
|
1661
2797
|
const GRANT_ALL = () => true;
|
|
1662
2798
|
/**
|
|
1663
|
-
* The HUD shell: a shadow-rooted
|
|
2799
|
+
* The HUD shell: a shadow-rooted dock (rail or pill) and floating panels.
|
|
1664
2800
|
*
|
|
1665
2801
|
* It renders unconditionally. Keeping it out of production builds is the
|
|
1666
2802
|
* loader's job, at the import site, so a bundler can drop the whole module
|
|
1667
2803
|
* (see `@hansenexus/hud/next`).
|
|
1668
2804
|
*/
|
|
1669
|
-
function Hud({ appSlug, envLabel = "DEV", plugins = NO_PLUGINS, apiBase = "/api/hud", can = GRANT_ALL }) {
|
|
2805
|
+
function Hud({ appSlug, envLabel = "DEV", plugins = NO_PLUGINS, apiBase = "/api/hud", can = GRANT_ALL, dock = "rail" }) {
|
|
1670
2806
|
const resolved = useMemo(() => resolvePlugins(plugins, can), [plugins, can]);
|
|
1671
|
-
return /* @__PURE__ */
|
|
2807
|
+
return /* @__PURE__ */ jsxs(ShadowHost, {
|
|
1672
2808
|
css: CSS,
|
|
1673
2809
|
marker: HUD_DEV_MARKER,
|
|
1674
|
-
children: /* @__PURE__ */ jsx(Shell, {
|
|
2810
|
+
children: [/* @__PURE__ */ jsx(IconSprite, {}), /* @__PURE__ */ jsx(Shell, {
|
|
1675
2811
|
appSlug,
|
|
1676
2812
|
envLabel,
|
|
1677
2813
|
plugins: resolved,
|
|
1678
2814
|
apiBase,
|
|
1679
|
-
can
|
|
1680
|
-
|
|
2815
|
+
can,
|
|
2816
|
+
dock
|
|
2817
|
+
})]
|
|
1681
2818
|
});
|
|
1682
2819
|
}
|
|
1683
|
-
function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
2820
|
+
function Shell({ appSlug, envLabel, plugins, apiBase, can, dock }) {
|
|
1684
2821
|
const panelsRef = useRef(null);
|
|
1685
2822
|
const close = useCallback((id) => panelsRef.current?.close(id), []);
|
|
1686
2823
|
const open = useCallback((id) => panelsRef.current?.open(id), []);
|
|
@@ -1713,10 +2850,11 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
|
1713
2850
|
})))], [slots, grab]);
|
|
1714
2851
|
return /* @__PURE__ */ jsxs(PanelManager, {
|
|
1715
2852
|
appSlug,
|
|
2853
|
+
dock,
|
|
1716
2854
|
panels,
|
|
1717
2855
|
commands,
|
|
1718
2856
|
apiRef: panelsRef,
|
|
1719
|
-
children: [/* @__PURE__ */ jsx(Pill, {
|
|
2857
|
+
children: [/* @__PURE__ */ jsx(dock === "rail" ? Rail : Pill, {
|
|
1720
2858
|
appSlug,
|
|
1721
2859
|
envLabel,
|
|
1722
2860
|
slots,
|
|
@@ -1740,15 +2878,16 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
|
|
|
1740
2878
|
* Returns a component. The plugin list is frozen here, so the shell sees a
|
|
1741
2879
|
* stable array across renders.
|
|
1742
2880
|
*/
|
|
1743
|
-
function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
2881
|
+
function defineHud({ app, plugins, auto, apiBase, can, dock }) {
|
|
1744
2882
|
if (!plugins && !auto) throw new Error("hud: defineHud needs `plugins`, `auto` or both");
|
|
1745
2883
|
const explicit = resolvePlugins(plugins ?? [], () => true);
|
|
1746
2884
|
const detected = typeof auto === "function" ? auto() : auto ?? [];
|
|
1747
2885
|
const list = Object.freeze(mergePlugins(detected, explicit));
|
|
1748
2886
|
resolvePlugins(list, () => true);
|
|
1749
2887
|
const access = list.find((plugin) => plugin.access)?.access;
|
|
1750
|
-
function DefinedHud({ envLabel, env = "development" }) {
|
|
2888
|
+
function DefinedHud({ envLabel, env = "development", dock: mountDock }) {
|
|
1751
2889
|
if (env === "disabled") return null;
|
|
2890
|
+
const chosen = mountDock ?? dock;
|
|
1752
2891
|
if (access) return /* @__PURE__ */ jsx(AccessHud, {
|
|
1753
2892
|
access,
|
|
1754
2893
|
env,
|
|
@@ -1756,7 +2895,8 @@ function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
|
1756
2895
|
plugins: list,
|
|
1757
2896
|
apiBase: apiBase ?? "/api/hud",
|
|
1758
2897
|
...envLabel === void 0 ? {} : { envLabel },
|
|
1759
|
-
...can === void 0 ? {} : { can }
|
|
2898
|
+
...can === void 0 ? {} : { can },
|
|
2899
|
+
...chosen === void 0 ? {} : { dock: chosen }
|
|
1760
2900
|
});
|
|
1761
2901
|
if (env !== "development") return null;
|
|
1762
2902
|
return /* @__PURE__ */ jsx(Hud, {
|
|
@@ -1764,7 +2904,8 @@ function defineHud({ app, plugins, auto, apiBase, can }) {
|
|
|
1764
2904
|
plugins: list,
|
|
1765
2905
|
...envLabel === void 0 ? {} : { envLabel },
|
|
1766
2906
|
...apiBase === void 0 ? {} : { apiBase },
|
|
1767
|
-
...can === void 0 ? {} : { can }
|
|
2907
|
+
...can === void 0 ? {} : { can },
|
|
2908
|
+
...chosen === void 0 ? {} : { dock: chosen }
|
|
1768
2909
|
});
|
|
1769
2910
|
}
|
|
1770
2911
|
DefinedHud.displayName = `Hud(${app})`;
|
|
@@ -1788,7 +2929,7 @@ function mergePlugins(detected, explicit) {
|
|
|
1788
2929
|
* in the bundle and its routes are one URL away. The server guard
|
|
1789
2930
|
* (`accessGuard`) is what enforces the tier.
|
|
1790
2931
|
*/
|
|
1791
|
-
function AccessHud({ access, env, app, plugins, apiBase, envLabel, can }) {
|
|
2932
|
+
function AccessHud({ access, env, app, plugins, apiBase, envLabel, can, dock }) {
|
|
1792
2933
|
const unlocked = access.useUnlocked(env, apiBase);
|
|
1793
2934
|
const gated = useCallback((capability) => access.can(env, capability) && (can?.(capability) ?? true), [
|
|
1794
2935
|
access,
|
|
@@ -1801,8 +2942,9 @@ function AccessHud({ access, env, app, plugins, apiBase, envLabel, can }) {
|
|
|
1801
2942
|
plugins: shown,
|
|
1802
2943
|
apiBase,
|
|
1803
2944
|
can: gated,
|
|
1804
|
-
...envLabel === void 0 ? {} : { envLabel }
|
|
2945
|
+
...envLabel === void 0 ? {} : { envLabel },
|
|
2946
|
+
...dock === void 0 ? {} : { dock }
|
|
1805
2947
|
});
|
|
1806
2948
|
}
|
|
1807
2949
|
//#endregion
|
|
1808
|
-
export { ElementOutline, ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, matchComponentHints, useGrab };
|
|
2950
|
+
export { ElementOutline, ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, HUD_ICON_NAMES, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, hudIcon, matchComponentHints, ratingTone, useGrab };
|