@hansenexus/hud 0.4.0 → 0.5.1

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.
Files changed (159) hide show
  1. package/README.md +634 -12
  2. package/dist/a11y-B5DUaiCs.js +246 -0
  3. package/dist/a11y-panel-p_t4eD7p.js +207 -0
  4. package/dist/{capabilities-CjulXFQX.js → access-C7zlaqj6.js} +1 -90
  5. package/dist/{access-CNvJOwKM.d.ts → access-D_ewAEJG.d.ts} +11 -4
  6. package/dist/access-panel-CEfTr9ZI.js +123 -0
  7. package/dist/adapter-BYoxPYTI.d.ts +33 -0
  8. package/dist/adapter-hcwmJtNx.js +65 -0
  9. package/dist/auto/runtime.d.ts +65 -0
  10. package/dist/auto/runtime.js +50 -0
  11. package/dist/auto.d.ts +15 -0
  12. package/dist/auto.js +33 -0
  13. package/dist/capabilities-rDSKjXpq.js +110 -0
  14. package/dist/capture-CwrIwLqi.js +300 -0
  15. package/dist/capture-buffer-Bbbo6omF.d.ts +35 -0
  16. package/dist/cli.d.ts +1 -0
  17. package/dist/cli.js +275 -0
  18. package/dist/data-panel-DhxAmP91.js +817 -0
  19. package/dist/data-store-ChF1td_P.js +164 -0
  20. package/dist/define-hud-CHPedaQ5.d.ts +50 -0
  21. package/dist/design-D0kGgPoP.js +87 -0
  22. package/dist/detect-BxHZ0pxW.d.ts +25 -0
  23. package/dist/detect-CHZiSeZs.js +63 -0
  24. package/dist/dispatch-panel-B-xr_Giy.js +279 -0
  25. package/dist/{env-vEjyJfPW.d.ts → env-CApnbI0r.d.ts} +2 -0
  26. package/dist/{env-DfxpPfs9.js → env-CaiFPIhF.js} +3 -0
  27. package/dist/file-xdSaQ2uR.js +103 -0
  28. package/dist/flags-DVtaJ8pQ.d.ts +58 -0
  29. package/dist/flags.d.ts +2 -0
  30. package/dist/flags.js +82 -0
  31. package/dist/force-state-panel-_otVYh9i.js +97 -0
  32. package/dist/generate-C8lQl3Eh.js +53 -0
  33. package/dist/handler-BpVhxEmU.js +106 -0
  34. package/dist/{handler-WmE4Lu7l.d.ts → handler-DtYVCZY6.d.ts} +1 -1
  35. package/dist/index-BAV_1W8a.d.ts +43 -0
  36. package/dist/index-BJ26pse9.d.ts +70 -0
  37. package/dist/index-BnQ0dTZf.d.ts +19 -0
  38. package/dist/index-CwfX-W87.d.ts +72 -0
  39. package/dist/index-DcH9V3cU.d.ts +48 -0
  40. package/dist/index-DqOyNf1u.d.ts +65 -0
  41. package/dist/index-DstI_ike.d.ts +66 -0
  42. package/dist/index-Dxz4fn4j.d.ts +42 -0
  43. package/dist/index-Hhh7OXzU.d.ts +129 -0
  44. package/dist/index-ReFbhQ9p.d.ts +25 -0
  45. package/dist/index-RgXfMBuW.d.ts +48 -0
  46. package/dist/{index-BYsdS-7d.d.ts → index-gCZBO53s.d.ts} +21 -3
  47. package/dist/index.d.ts +5 -5
  48. package/dist/index.js +710 -69
  49. package/dist/inspect-C9Ft8fqn.js +142 -0
  50. package/dist/inspect-root-BkaupBMp.js +429 -0
  51. package/dist/meta-Bv0sEao3.js +6 -0
  52. package/dist/meta-C_G7MB5w.d.ts +49 -0
  53. package/dist/mocks-CA-wM2SB.d.ts +109 -0
  54. package/dist/mocks-ESiRqk9o.js +150 -0
  55. package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
  56. package/dist/next/config.cjs +201 -0
  57. package/dist/next/config.d.cts +87 -0
  58. package/dist/next/config.d.ts +64 -0
  59. package/dist/next/config.js +84 -0
  60. package/dist/next.d.ts +14 -4
  61. package/dist/next.js +5 -3
  62. package/dist/observe-CdDnDBRP.js +89 -0
  63. package/dist/observe-panel-Cgp1M8oT.js +347 -0
  64. package/dist/ops-panel-CEqDe_UT.js +234 -0
  65. package/dist/{payload-CLKDVZWl.d.ts → payload-MUQ9ciER.d.ts} +25 -1
  66. package/dist/plugins/a11y.d.ts +2 -0
  67. package/dist/plugins/a11y.js +2 -0
  68. package/dist/plugins/access/server.d.ts +5 -5
  69. package/dist/plugins/access/server.js +4 -3
  70. package/dist/plugins/access.d.ts +5 -5
  71. package/dist/plugins/access.js +16 -215
  72. package/dist/plugins/agent/server.d.ts +3 -38
  73. package/dist/plugins/agent/server.js +47 -21
  74. package/dist/plugins/agent.d.ts +4 -4
  75. package/dist/plugins/agent.js +6 -348
  76. package/dist/plugins/capture/server.d.ts +92 -0
  77. package/dist/plugins/capture/server.js +248 -0
  78. package/dist/plugins/capture.d.ts +24 -0
  79. package/dist/plugins/capture.js +70 -0
  80. package/dist/plugins/data/msw-browser.d.ts +2 -0
  81. package/dist/plugins/data/msw-browser.js +39 -0
  82. package/dist/plugins/data/msw-node.d.ts +36 -0
  83. package/dist/plugins/data/msw-node.js +68 -0
  84. package/dist/plugins/data/server.d.ts +257 -0
  85. package/dist/plugins/data/server.js +717 -0
  86. package/dist/plugins/data.d.ts +6 -0
  87. package/dist/plugins/data.js +51 -0
  88. package/dist/plugins/design/server.d.ts +54 -0
  89. package/dist/plugins/design/server.js +198 -0
  90. package/dist/plugins/design.d.ts +4 -124
  91. package/dist/plugins/design.js +4 -619
  92. package/dist/plugins/inspect/convex.d.ts +2 -0
  93. package/dist/plugins/inspect/convex.js +486 -0
  94. package/dist/plugins/inspect/react-query.d.ts +2 -0
  95. package/dist/plugins/inspect/react-query.js +237 -0
  96. package/dist/plugins/inspect/sockets.d.ts +51 -0
  97. package/dist/plugins/inspect/sockets.js +397 -0
  98. package/dist/plugins/inspect/swr.d.ts +2 -0
  99. package/dist/plugins/inspect/swr.js +218 -0
  100. package/dist/plugins/inspect.d.ts +4 -0
  101. package/dist/plugins/inspect.js +3 -0
  102. package/dist/plugins/observe.d.ts +4 -64
  103. package/dist/plugins/observe.js +1 -616
  104. package/dist/plugins/ops/server.d.ts +1 -1
  105. package/dist/plugins/ops/server.js +2 -1
  106. package/dist/plugins/ops.d.ts +2 -1
  107. package/dist/plugins/ops.js +15 -336
  108. package/dist/plugins/routes/server.d.ts +88 -0
  109. package/dist/plugins/routes/server.js +62 -0
  110. package/dist/plugins/routes.d.ts +3 -0
  111. package/dist/plugins/routes.js +216 -0
  112. package/dist/plugins/seo.d.ts +2 -0
  113. package/dist/plugins/seo.js +2 -0
  114. package/dist/plugins/vitals.d.ts +2 -25
  115. package/dist/plugins/vitals.js +3 -2
  116. package/dist/{plugins-CQ_0w1ot.d.ts → plugins-BZvDqGx5.d.ts} +33 -3
  117. package/dist/poll-CjKsWZi8.js +89 -0
  118. package/dist/requests-BwD6MKEq.js +282 -0
  119. package/dist/requests-CJrUf465.d.ts +50 -0
  120. package/dist/review.js +2 -2
  121. package/dist/same-origin-BGet22CC.js +21 -0
  122. package/dist/scan-DzJNXqOk.js +165 -0
  123. package/dist/seo-Dq9q_QkO.js +551 -0
  124. package/dist/seo-panel-CfiY-TnT.js +124 -0
  125. package/dist/server.d.ts +2 -2
  126. package/dist/server.js +2 -105
  127. package/dist/sessions-panel-COvhPAzv.js +98 -0
  128. package/dist/{shortcut-U6ftVY06.js → shortcut-s_mjGeU8.js} +1 -44
  129. package/dist/{types-QJUajwWq.js → state-CjjZPjPJ.js} +13 -8
  130. package/dist/store/convex.d.ts +33 -0
  131. package/dist/store/convex.js +52 -0
  132. package/dist/{vitals-panel-Dvc5dnR-.js → store-CQqIIKTc.js} +1 -29
  133. package/dist/store-Ync9eb1G.js +67 -0
  134. package/dist/store.d.ts +76 -0
  135. package/dist/store.js +188 -0
  136. package/dist/{styles--slk86ZQ.js → styles-BA8ueHoV.js} +13 -3
  137. package/dist/styles-DKU_P8MH.js +139 -0
  138. package/dist/styles-DPpDPmzi.js +68 -0
  139. package/dist/tokens-panel-CbMQfasZ.js +142 -0
  140. package/dist/types-B-ulf2Jp.js +8 -0
  141. package/dist/types-BIgGf-0C.d.ts +25 -0
  142. package/dist/types-BIkI-qN8.js +30 -0
  143. package/dist/{types-DADBRiGk.d.ts → types-Cxh4twqc.d.ts} +1 -1
  144. package/dist/types-DIdPfjtV.js +6 -0
  145. package/dist/types-DaJcsEjO.d.ts +44 -0
  146. package/dist/types-Dn68psVz.d.ts +118 -0
  147. package/dist/types-szkr2QOF.d.ts +39 -0
  148. package/dist/unlock-store-4V3vR4Eg.js +96 -0
  149. package/dist/variant-groups-TIfO3NIj.js +137 -0
  150. package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
  151. package/dist/variants-panel-BDoSkwBJ.js +457 -0
  152. package/dist/variants-types-CcRf119M.d.ts +63 -0
  153. package/dist/variants.d.ts +43 -0
  154. package/dist/variants.js +83 -0
  155. package/dist/vitals-panel-BCmMUntW.js +30 -0
  156. package/dist/vite.d.ts +37 -0
  157. package/dist/vite.js +134 -0
  158. package/package.json +72 -5
  159. package/dist/define-hud-BBzsSl8b.d.ts +0 -36
package/dist/index.js CHANGED
@@ -1,9 +1,95 @@
1
- import { a as buildGrabPayload, c as createGrabber, i as parseShortcut, l as useGrab, n as isApplePlatform, o as describeElement, r as matchesShortcut, s as matchComponentHints, t as formatShortcut } from "./shortcut-U6ftVY06.js";
1
+ import { n as useGrab, t as createGrabber } from "./store-Ync9eb1G.js";
2
2
  import { n as HUD_HOST_TAG, t as HUD_DEV_MARKER } from "./marker-uZYPOJ4M.js";
3
3
  import { a as resolvePlugins, i as definePlugin, n as HudApiError, r as createPluginContext } from "./plugins-DVy_vaYr.js";
4
- import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles--slk86ZQ.js";
5
- import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
4
+ 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
+ import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles-BA8ueHoV.js";
6
+ import { Component, Suspense, createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/core/grabber/outline.tsx
9
+ function toBox(element) {
10
+ const r = element.getBoundingClientRect();
11
+ return {
12
+ left: r.left,
13
+ top: r.top,
14
+ width: r.width,
15
+ height: r.height
16
+ };
17
+ }
18
+ /**
19
+ * Outlines one element with the grabber's overlay without entering grab mode:
20
+ * findings in a panel point at the page this way. The box follows scrolling
21
+ * and resizes; the outline goes away on Escape, on a press on the page, or
22
+ * when the element is removed.
23
+ */
24
+ function ElementOutline({ element, label, onDismiss, reveal = true }) {
25
+ const layer = useRef(null);
26
+ const [box, setBox] = useState(null);
27
+ const dismiss = useRef(onDismiss);
28
+ dismiss.current = onDismiss;
29
+ useEffect(() => {
30
+ if (!element) {
31
+ setBox(null);
32
+ return;
33
+ }
34
+ const doc = element.ownerDocument;
35
+ const win = doc.defaultView ?? window;
36
+ const root = layer.current?.getRootNode();
37
+ const ownHost = root instanceof ShadowRoot ? root.host : null;
38
+ if (reveal && typeof element.scrollIntoView === "function") element.scrollIntoView({
39
+ block: "center",
40
+ inline: "nearest"
41
+ });
42
+ function measure() {
43
+ if (!element?.isConnected) {
44
+ dismiss.current();
45
+ return;
46
+ }
47
+ setBox(toBox(element));
48
+ }
49
+ function onKey(event) {
50
+ if (event.key === "Escape") dismiss.current();
51
+ }
52
+ function onPress(event) {
53
+ if (ownHost && event.composedPath().includes(ownHost)) return;
54
+ dismiss.current();
55
+ }
56
+ measure();
57
+ win.addEventListener("scroll", measure, true);
58
+ win.addEventListener("resize", measure);
59
+ win.addEventListener("keydown", onKey, true);
60
+ doc.addEventListener("pointerdown", onPress, true);
61
+ return () => {
62
+ win.removeEventListener("scroll", measure, true);
63
+ win.removeEventListener("resize", measure);
64
+ win.removeEventListener("keydown", onKey, true);
65
+ doc.removeEventListener("pointerdown", onPress, true);
66
+ setBox(null);
67
+ };
68
+ }, [element, reveal]);
69
+ return /* @__PURE__ */ jsx("div", {
70
+ ref: layer,
71
+ className: "grab-layer",
72
+ "data-outline": "",
73
+ hidden: !element || !box,
74
+ children: element && box && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
75
+ className: "grab-outline",
76
+ style: {
77
+ left: box.left - 2,
78
+ top: box.top - 2,
79
+ width: box.width + 4,
80
+ height: box.height + 4
81
+ }
82
+ }), /* @__PURE__ */ jsx("div", {
83
+ className: "grab-label",
84
+ style: {
85
+ left: Math.max(box.left - 2, 4),
86
+ top: box.top >= 22 ? box.top - 20 : box.top + box.height + 4
87
+ },
88
+ children: label
89
+ })] })
90
+ });
91
+ }
92
+ //#endregion
7
93
  //#region src/shell/grabber.tsx
8
94
  const GRAB_CSS = PICKER_CSS + `
9
95
  .hud .grab-toggle { font-size: 14px; line-height: 1; padding: 2px 6px; }
@@ -12,10 +98,11 @@ const GRAB_CSS = PICKER_CSS + `
12
98
  /**
13
99
  * Grab mode for the shell. It lives beside the panels, not inside one, so a
14
100
  * grab never unmounts or closes a panel; the picker ignores clicks inside the
15
- * HUD, so open panels stay usable while it is active.
101
+ * HUD, so open panels stay usable while it is active. Outside a grab the same
102
+ * overlay outlines whatever a plugin pointed at with `ctx.grab.highlight`.
16
103
  */
17
104
  function Grabber({ app, store, slots }) {
18
- const { grabbing } = useGrab(store);
105
+ const { grabbing, highlight } = useGrab(store);
19
106
  const onPick = useCallback((element) => {
20
107
  const payload = buildGrabPayload(element, { app });
21
108
  store.complete(payload);
@@ -29,13 +116,17 @@ function Grabber({ app, store, slots }) {
29
116
  store,
30
117
  slots
31
118
  ]);
32
- return /* @__PURE__ */ jsx(ElementPicker, {
119
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ElementPicker, {
33
120
  active: grabbing,
34
121
  onPick,
35
122
  onCancel: store.cancel,
36
123
  describe: describeElement,
37
124
  hint: "Grab: click an element · Esc cancels"
38
- });
125
+ }), !grabbing && /* @__PURE__ */ jsx(ElementOutline, {
126
+ element: highlight?.element ?? null,
127
+ label: highlight?.label ?? "",
128
+ onDismiss: store.clearHighlight
129
+ })] });
39
130
  }
40
131
  //#endregion
41
132
  //#region src/shell/commands/context.ts
@@ -132,7 +223,8 @@ const EMPTY_LAYOUT = {
132
223
  open: [],
133
224
  floats: {},
134
225
  pins: {},
135
- hidden: false
226
+ hidden: false,
227
+ pill: null
136
228
  };
137
229
  /** A pinned edge never takes more than this share of the viewport. */
138
230
  const MAX_SHARE = .4;
@@ -424,6 +516,13 @@ const EDGES = [
424
516
  "right",
425
517
  "bottom"
426
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
+ ];
427
526
  //#endregion
428
527
  //#region src/shell/panels/reserve.ts
429
528
  const PADDING = {
@@ -495,6 +594,9 @@ function isRecord(value) {
495
594
  function isPosition(value) {
496
595
  return isRecord(value) && Number.isFinite(value.x) && Number.isFinite(value.y);
497
596
  }
597
+ function isCorner(value) {
598
+ return CORNERS.some((corner) => corner === value);
599
+ }
498
600
  function isEdge(value) {
499
601
  return EDGES.some((edge) => edge === value);
500
602
  }
@@ -516,14 +618,15 @@ function sanitizeLayout(value, known) {
516
618
  open,
517
619
  floats,
518
620
  pins,
519
- hidden: value.hidden === true
621
+ hidden: value.hidden === true,
622
+ pill: isCorner(value.pill) ? value.pill : null
520
623
  };
521
624
  }
522
625
  function subscribeResize(listener) {
523
626
  window.addEventListener("resize", listener);
524
627
  return () => window.removeEventListener("resize", listener);
525
628
  }
526
- let cached = {
629
+ let cached$1 = {
527
630
  w: 0,
528
631
  h: 0
529
632
  };
@@ -535,11 +638,11 @@ function readViewport() {
535
638
  const root = document.documentElement;
536
639
  const w = root.clientWidth || window.innerWidth;
537
640
  const h = root.clientHeight || window.innerHeight;
538
- if (w !== cached.w || h !== cached.h) cached = {
641
+ if (w !== cached$1.w || h !== cached$1.h) cached$1 = {
539
642
  w,
540
643
  h
541
644
  };
542
- return cached;
645
+ return cached$1;
543
646
  }
544
647
  function useViewport() {
545
648
  return useSyncExternalStore(subscribeResize, readViewport, readViewport);
@@ -598,8 +701,24 @@ function Workspace({ appSlug, panels, apiRef, children }) {
598
701
  open: (id) => setLayout((l) => openPanel(l, id, defaultPosition(l.open.length))),
599
702
  close: (id) => setLayout((l) => closePanel(l, id)),
600
703
  toggle: (id) => setLayout((l) => !l.hidden && l.open.includes(id) ? closePanel(l, id) : openPanel(l, id, defaultPosition(l.open.length))),
601
- pin: (id, edge) => setLayout((l) => pinPanel(l, id, edge))
602
- }), [panels, layout]);
704
+ pin: (id, edge) => setLayout((l) => pinPanel(l, id, edge)),
705
+ reserve: {
706
+ left,
707
+ right,
708
+ bottom
709
+ },
710
+ pillCorner: layout.pill,
711
+ setPillCorner: (pill) => setLayout((l) => l.pill === pill ? l : {
712
+ ...l,
713
+ pill
714
+ })
715
+ }), [
716
+ panels,
717
+ layout,
718
+ left,
719
+ right,
720
+ bottom
721
+ ]);
603
722
  useLayoutEffect(() => {
604
723
  if (!apiRef) return;
605
724
  apiRef.current = api;
@@ -628,15 +747,10 @@ function Workspace({ appSlug, panels, apiRef, children }) {
628
747
  close: () => api.close(id)
629
748
  });
630
749
  const snapRect = snap ? pinGeometry(pinPanel(layout, snap.id, snap.edge), viewport).rects[snap.id] : void 0;
631
- const offsets = {
632
- "--hud-reserve-left": `${left}px`,
633
- "--hud-reserve-bottom": `${bottom}px`
634
- };
635
750
  return /* @__PURE__ */ jsx(PanelsContext.Provider, {
636
751
  value: api,
637
752
  children: /* @__PURE__ */ jsxs("div", {
638
753
  className: "hud-layout",
639
- style: offsets,
640
754
  children: [
641
755
  children,
642
756
  narrow ? active && /* @__PURE__ */ jsx(PanelSheet, {
@@ -678,8 +792,12 @@ function Workspace({ appSlug, panels, apiRef, children }) {
678
792
  }
679
793
  //#endregion
680
794
  //#region src/shell/panels/pill-menu.tsx
681
- /** The pill's "⋯" menu: every panel, every command with its shortcut, and Reset layout. */
682
- function PillMenu() {
795
+ /**
796
+ * The pill's "⋯" menu: every panel, every command with its shortcut, and Reset
797
+ * layout. `overflow` counts the pill items that did not fit; their panels are
798
+ * reachable here.
799
+ */
800
+ function PillMenu({ overflow = 0 }) {
683
801
  const panels = usePanels();
684
802
  const commands = useCommands();
685
803
  const apple = useMemo(isApplePlatform, []);
@@ -703,14 +821,17 @@ function PillMenu() {
703
821
  return /* @__PURE__ */ jsxs("div", {
704
822
  className: "menu-anchor",
705
823
  ref,
706
- children: [/* @__PURE__ */ jsx("button", {
824
+ children: [/* @__PURE__ */ jsxs("button", {
707
825
  type: "button",
708
826
  className: "pill-item",
709
- "aria-label": "HUD menu",
827
+ "aria-label": overflow > 0 ? `HUD menu, ${overflow} more` : "HUD menu",
710
828
  "aria-haspopup": "menu",
711
829
  "aria-expanded": open,
712
830
  onClick: () => setOpen((o) => !o),
713
- children: "⋯"
831
+ children: ["⋯", overflow > 0 && /* @__PURE__ */ jsxs("span", {
832
+ className: "menu-badge",
833
+ children: ["+", overflow]
834
+ })]
714
835
  }), open && /* @__PURE__ */ jsxs("div", {
715
836
  className: "menu",
716
837
  role: "menu",
@@ -758,14 +879,25 @@ function PillMenu() {
758
879
  const PANEL_CSS = `
759
880
  .hud-layout { display: contents; }
760
881
 
761
- /* Pinned panels push the page; the pill moves with it so it stays visible. */
762
- .pill {
763
- left: calc(12px + var(--hud-reserve-left, 0px));
764
- bottom: calc(12px + var(--hud-reserve-bottom, 0px));
765
- }
766
-
767
882
  .menu-anchor { position: relative; display: flex; }
768
883
 
884
+ /* The menu opens away from the pill's corner. */
885
+ .pill[data-corner^="top"] .menu { bottom: auto; top: calc(100% + 8px); }
886
+ .pill[data-corner$="right"] .menu { left: auto; right: 0; }
887
+
888
+ .menu-badge {
889
+ position: absolute;
890
+ top: -6px;
891
+ right: -4px;
892
+ padding: 0 4px;
893
+ border-radius: 999px;
894
+ background: var(--hud-accent);
895
+ color: var(--hud-accent-fg);
896
+ font-size: 9px;
897
+ line-height: 14px;
898
+ pointer-events: none;
899
+ }
900
+
769
901
  .menu {
770
902
  position: absolute;
771
903
  left: 0;
@@ -773,6 +905,8 @@ const PANEL_CSS = `
773
905
  display: flex;
774
906
  flex-direction: column;
775
907
  min-width: 220px;
908
+ max-height: min(70vh, 520px);
909
+ overflow-y: auto;
776
910
  padding: 4px;
777
911
  background: var(--hud-bg);
778
912
  border: 1px solid var(--hud-border);
@@ -854,6 +988,7 @@ const PANEL_CSS = `
854
988
  }
855
989
  .hud .panel-action:hover { background: var(--hud-border); color: var(--hud-fg); }
856
990
  .panel-body { flex: 1; padding: 8px 10px; overflow: auto; }
991
+ .panel-error { color: var(--hud-poor); }
857
992
 
858
993
  .snap-zone {
859
994
  position: fixed;
@@ -924,26 +1059,548 @@ function usePluginSlots(plugins, { app, apiBase, can, close, open, pin, grab })
924
1059
  * A plugin's pill item. With a panel it is a toggle button; without one it
925
1060
  * only shows the plugin's `pill` content.
926
1061
  */
927
- function PluginPillItem({ slot, open, onToggle }) {
1062
+ function PluginPillItem({ slot, open, overflow = false, onToggle }) {
928
1063
  const { plugin, ctx, title } = slot;
929
1064
  const Pill = plugin.pill;
930
1065
  const content = Pill ? /* @__PURE__ */ jsx(Pill, { ctx }) : title;
1066
+ const shared = {
1067
+ className: overflow ? "pill-item pill-overflow" : "pill-item",
1068
+ "data-pill-id": plugin.id,
1069
+ "aria-hidden": overflow || void 0
1070
+ };
931
1071
  if (!plugin.panel) return Pill ? /* @__PURE__ */ jsx("span", {
932
- className: "pill-item",
1072
+ ...shared,
933
1073
  children: content
934
1074
  }) : null;
935
1075
  return /* @__PURE__ */ jsx("button", {
936
1076
  type: "button",
937
- className: "pill-item",
1077
+ ...shared,
1078
+ tabIndex: overflow ? -1 : void 0,
938
1079
  "aria-pressed": open,
939
1080
  title,
940
1081
  onClick: onToggle,
941
1082
  children: content
942
1083
  });
943
1084
  }
1085
+ /**
1086
+ * A plugin's panel content. Panels are dynamic imports (`lazy(() => import(...))`),
1087
+ * so the body suspends on first open and shows a loading line meanwhile. A
1088
+ * panel that fails to load or throws while rendering is contained here: the
1089
+ * frame stays, the message replaces the body, the rest of the HUD keeps going.
1090
+ */
944
1091
  function PluginPanelBody({ slot }) {
945
1092
  const Panel = slot.plugin.panel;
946
- return Panel ? /* @__PURE__ */ jsx(Panel, { ctx: slot.ctx }) : null;
1093
+ if (!Panel) return null;
1094
+ return /* @__PURE__ */ jsx(PanelBoundary, {
1095
+ title: slot.title,
1096
+ children: /* @__PURE__ */ jsx(Suspense, {
1097
+ fallback: /* @__PURE__ */ jsx("p", {
1098
+ className: "empty panel-loading",
1099
+ role: "status",
1100
+ children: "Loading…"
1101
+ }),
1102
+ children: /* @__PURE__ */ jsx(Panel, { ctx: slot.ctx })
1103
+ })
1104
+ });
1105
+ }
1106
+ var PanelBoundary = class extends Component {
1107
+ state = { error: null };
1108
+ static getDerivedStateFromError(error) {
1109
+ return { error: error instanceof Error ? error : new Error(String(error)) };
1110
+ }
1111
+ componentDidCatch(error, info) {
1112
+ console.error(`hud: the ${this.props.title} panel failed`, error, info.componentStack);
1113
+ }
1114
+ render() {
1115
+ const { error } = this.state;
1116
+ if (error) return /* @__PURE__ */ jsxs("p", {
1117
+ className: "empty panel-error",
1118
+ role: "alert",
1119
+ children: [
1120
+ this.props.title,
1121
+ " failed: ",
1122
+ error.message
1123
+ ]
1124
+ });
1125
+ return this.props.children;
1126
+ }
1127
+ };
1128
+ //#endregion
1129
+ //#region src/shell/pill/obstacles.ts
1130
+ /** Fixed elements covering more than this share of the viewport are backdrops, not corners. */
1131
+ const MAX_AREA_SHARE = .5;
1132
+ /** DOM changes settle for this long before the page is scanned again. */
1133
+ const RESCAN_MS = 250;
1134
+ function isFloating(el) {
1135
+ const { position } = getComputedStyle(el);
1136
+ return position === "fixed" || position === "sticky";
1137
+ }
1138
+ /**
1139
+ * The host page's fixed and sticky elements: what fights the pill for a
1140
+ * corner. Nested ones are dropped since their floating ancestor already
1141
+ * counts, and the HUD's own host is skipped.
1142
+ */
1143
+ function scanFloating(root = document.body) {
1144
+ const found = [];
1145
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
1146
+ const el = node;
1147
+ if (el.localName === "hn-hud") return NodeFilter.FILTER_REJECT;
1148
+ return isFloating(el) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
1149
+ } });
1150
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
1151
+ const el = node;
1152
+ if (!found.some((outer) => outer.contains(el))) found.push(el);
1153
+ }
1154
+ return found;
1155
+ }
1156
+ /** Visible rects of `elements`, minus backdrops and anything off screen. */
1157
+ function obstacleRects(elements) {
1158
+ const vw = window.innerWidth;
1159
+ const vh = window.innerHeight;
1160
+ const rects = [];
1161
+ for (const el of elements) {
1162
+ const { left, top, width, height } = el.getBoundingClientRect();
1163
+ if (width === 0 || height === 0) continue;
1164
+ if (width * height > vw * vh * MAX_AREA_SHARE) continue;
1165
+ if (left >= vw || top >= vh || left + width <= 0 || top + height <= 0) continue;
1166
+ const style = getComputedStyle(el);
1167
+ if (style.visibility === "hidden" || style.opacity === "0") continue;
1168
+ rects.push({
1169
+ left,
1170
+ top,
1171
+ width,
1172
+ height
1173
+ });
1174
+ }
1175
+ return rects;
1176
+ }
1177
+ function sameRects(a, b) {
1178
+ 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);
1179
+ }
1180
+ const NONE = [];
1181
+ /**
1182
+ * Live obstacle rects. The element list is rescanned when the DOM settles
1183
+ * after a change; rects are re-measured on scroll (sticky elements move) and
1184
+ * resize, once per frame.
1185
+ */
1186
+ function useObstacles() {
1187
+ const [rects, setRects] = useState(NONE);
1188
+ useEffect(() => {
1189
+ let elements = scanFloating();
1190
+ let frame = 0;
1191
+ let timer;
1192
+ const measure = () => {
1193
+ frame = 0;
1194
+ const next = obstacleRects(elements);
1195
+ setRects((prev) => sameRects(prev, next) ? prev : next);
1196
+ };
1197
+ const schedule = () => {
1198
+ if (!frame) frame = requestAnimationFrame(measure);
1199
+ };
1200
+ const rescan = () => {
1201
+ schedule();
1202
+ clearTimeout(timer);
1203
+ timer = setTimeout(() => {
1204
+ elements = scanFloating();
1205
+ schedule();
1206
+ }, RESCAN_MS);
1207
+ };
1208
+ measure();
1209
+ const observer = new MutationObserver(rescan);
1210
+ observer.observe(document.body, {
1211
+ childList: true,
1212
+ subtree: true,
1213
+ attributes: true,
1214
+ attributeFilter: [
1215
+ "class",
1216
+ "style",
1217
+ "hidden"
1218
+ ]
1219
+ });
1220
+ window.addEventListener("scroll", schedule, {
1221
+ capture: true,
1222
+ passive: true
1223
+ });
1224
+ window.addEventListener("resize", schedule);
1225
+ return () => {
1226
+ observer.disconnect();
1227
+ clearTimeout(timer);
1228
+ if (frame) cancelAnimationFrame(frame);
1229
+ window.removeEventListener("scroll", schedule, { capture: true });
1230
+ window.removeEventListener("resize", schedule);
1231
+ };
1232
+ }, []);
1233
+ return rects;
1234
+ }
1235
+ /** Clearance kept between the pill and a host element it moves away from. */
1236
+ const CLEARANCE = 8;
1237
+ /** The pill never moves further than this share of the viewport height off its edge. */
1238
+ const MAX_SHIFT_SHARE = .4;
1239
+ /** Extra cost of a top corner when every corner needs a shift: host navs live up there. */
1240
+ const TOP_PENALTY = 48;
1241
+ const isBottom = (corner) => corner.startsWith("bottom");
1242
+ const isRight = (corner) => corner.endsWith("right");
1243
+ function pillRect({ corner, shift }, size, viewport, reserve) {
1244
+ return {
1245
+ left: isRight(corner) ? viewport.w - reserve.right - 12 - size.width : reserve.left + 12,
1246
+ top: isBottom(corner) ? viewport.h - reserve.bottom - 12 - shift - size.height : 12 + shift,
1247
+ width: size.width,
1248
+ height: size.height
1249
+ };
1250
+ }
1251
+ function intersects(a, b) {
1252
+ return a.left < b.left + b.width && b.left < a.left + a.width && a.top < b.top + b.height && b.top < a.top + a.height;
1253
+ }
1254
+ /**
1255
+ * Shifts the pill away from its corner's edge until it clears every obstacle,
1256
+ * or returns null when that would take it past the shift cap.
1257
+ */
1258
+ function shiftWithin(corner, options) {
1259
+ const { viewport, size, obstacles, reserve } = options;
1260
+ const max = viewport.h * MAX_SHIFT_SHARE;
1261
+ let placement = {
1262
+ corner,
1263
+ shift: 0
1264
+ };
1265
+ for (let round = 0; round <= obstacles.length; round++) {
1266
+ const rect = pillRect(placement, size, viewport, reserve);
1267
+ const hits = obstacles.filter((o) => intersects(rect, o));
1268
+ if (hits.length === 0) return placement;
1269
+ const shift = Math.max(...hits.map((o) => isBottom(corner) ? viewport.h - reserve.bottom - 12 - o.top + CLEARANCE : o.top + o.height + CLEARANCE - 12));
1270
+ if (shift > max || shift <= placement.shift) return null;
1271
+ placement = {
1272
+ corner,
1273
+ shift
1274
+ };
1275
+ }
1276
+ return null;
1277
+ }
1278
+ /**
1279
+ * Where the pill goes. A dragged corner is kept and only shifted. Otherwise the
1280
+ * first corner that is free as is wins; when none is, the corner that needs
1281
+ * the smallest shift, with top corners penalised. Null when no corner clears its obstacles within the cap:
1282
+ * the caller then shrinks the pill to compact mode and tries again.
1283
+ */
1284
+ function placePill(options) {
1285
+ if (options.pinned) return shiftWithin(options.pinned, options);
1286
+ const cost = ({ corner, shift }) => shift + (isBottom(corner) ? 0 : TOP_PENALTY);
1287
+ let best = null;
1288
+ for (const corner of CORNERS) {
1289
+ const placement = shiftWithin(corner, options);
1290
+ if (placement?.shift === 0) return placement;
1291
+ if (placement && (!best || cost(placement) < cost(best))) best = placement;
1292
+ }
1293
+ return best;
1294
+ }
1295
+ /** The corner a dragged pill lands in: the viewport quadrant of the drop point. */
1296
+ function nearestCorner(x, y, viewport) {
1297
+ return `${y > viewport.h / 2 ? "bottom" : "top"}-${x > viewport.w / 2 ? "right" : "left"}`;
1298
+ }
1299
+ /**
1300
+ * Which plugin items fit in `budget` pixels. Higher priority first, then pill
1301
+ * order; an item that does not fit is skipped, so a smaller one after it can
1302
+ * still take the remaining room. `compact` keeps only prioritised items.
1303
+ */
1304
+ function fitItems(items, budget, { compact = false, gap = 0 } = {}) {
1305
+ const ranked = items.map((item, index) => ({
1306
+ item,
1307
+ index
1308
+ })).filter(({ item }) => !compact || item.priority > 0).sort((a, b) => b.item.priority - a.item.priority || a.index - b.index);
1309
+ const visible = /* @__PURE__ */ new Set();
1310
+ let left = budget;
1311
+ for (const { item } of ranked) {
1312
+ const cost = item.width + gap;
1313
+ if (cost > left) continue;
1314
+ visible.add(item.id);
1315
+ left -= cost;
1316
+ }
1317
+ return visible;
1318
+ }
1319
+ //#endregion
1320
+ //#region src/shell/pill/visual-viewport.ts
1321
+ function subscribe(listener) {
1322
+ const vv = window.visualViewport;
1323
+ window.addEventListener("resize", listener);
1324
+ vv?.addEventListener("resize", listener);
1325
+ vv?.addEventListener("scroll", listener);
1326
+ return () => {
1327
+ window.removeEventListener("resize", listener);
1328
+ vv?.removeEventListener("resize", listener);
1329
+ vv?.removeEventListener("scroll", listener);
1330
+ };
1331
+ }
1332
+ let cached = {
1333
+ x: 0,
1334
+ y: 0,
1335
+ w: 0,
1336
+ h: 0,
1337
+ detached: false
1338
+ };
1339
+ /**
1340
+ * On a phone, a page wider than the screen (an image with a fixed width is
1341
+ * enough) grows the layout viewport past the visible area, and a pill fixed
1342
+ * to the bottom edge ends up below the fold. The visual viewport is what the
1343
+ * user sees; the pill places itself in it.
1344
+ */
1345
+ function read() {
1346
+ const root = document.documentElement;
1347
+ const layoutW = root.clientWidth || window.innerWidth;
1348
+ const layoutH = root.clientHeight || window.innerHeight;
1349
+ const vv = window.visualViewport;
1350
+ const x = vv?.offsetLeft ?? 0;
1351
+ const y = vv?.offsetTop ?? 0;
1352
+ const w = Math.round(vv?.width ?? layoutW);
1353
+ const h = Math.round(vv?.height ?? layoutH);
1354
+ const detached = x !== 0 || y !== 0 || window.innerWidth > w + 1 || window.innerHeight > h + 1;
1355
+ const next = {
1356
+ x,
1357
+ y,
1358
+ w: detached ? w : layoutW,
1359
+ h: detached ? h : layoutH,
1360
+ detached
1361
+ };
1362
+ if (next.x !== cached.x || next.y !== cached.y || next.w !== cached.w || next.h !== cached.h || next.detached !== cached.detached) cached = next;
1363
+ return cached;
1364
+ }
1365
+ function useVisualViewport() {
1366
+ return useSyncExternalStore(subscribe, read, read);
1367
+ }
1368
+ //#endregion
1369
+ //#region src/shell/pill/pill.tsx
1370
+ /** `.pill` gap, padding and border, which the item widths do not include. */
1371
+ const ITEM_GAP = 2;
1372
+ const CHROME = 8;
1373
+ /** A press that moves less than this is a click, not a drag. */
1374
+ const DRAG_THRESHOLD = 4;
1375
+ const EMPTY = {
1376
+ items: {},
1377
+ fixed: 0,
1378
+ height: 0
1379
+ };
1380
+ function measure(pill) {
1381
+ const items = {};
1382
+ let fixed = 0;
1383
+ let count = 0;
1384
+ for (const child of pill.children) {
1385
+ if (!(child instanceof HTMLElement)) continue;
1386
+ const id = child.dataset.pillId;
1387
+ if (id) items[id] = child.offsetWidth;
1388
+ else {
1389
+ fixed += child.offsetWidth;
1390
+ count++;
1391
+ }
1392
+ }
1393
+ return {
1394
+ items,
1395
+ fixed: fixed + ITEM_GAP * Math.max(0, count - 1),
1396
+ height: pill.offsetHeight
1397
+ };
1398
+ }
1399
+ function sameMeasure(a, b) {
1400
+ const keys = Object.keys(b.items);
1401
+ return a.fixed === b.fixed && a.height === b.height && keys.length === Object.keys(a.items).length && keys.every((key) => a.items[key] === b.items[key]);
1402
+ }
1403
+ /**
1404
+ * Fits the items into the width left by pinned panels, then places the pill.
1405
+ * When no corner is free even after shifting, compact mode keeps only
1406
+ * prioritised items and the pill is placed again at that size.
1407
+ */
1408
+ function arrange(slots, measured, options) {
1409
+ const { viewport, reserve } = options;
1410
+ const items = slots.map(({ plugin }) => ({
1411
+ id: plugin.id,
1412
+ width: measured.items[plugin.id] ?? 0,
1413
+ priority: plugin.pillPriority ?? 0
1414
+ }));
1415
+ const budget = viewport.w - reserve.left - reserve.right - 24 - CHROME - measured.fixed;
1416
+ const sizeOf = (visible) => ({
1417
+ width: CHROME + measured.fixed + items.reduce((sum, item) => sum + (visible.has(item.id) ? item.width + ITEM_GAP : 0), 0),
1418
+ height: measured.height
1419
+ });
1420
+ const full = fitItems(items, budget, { gap: ITEM_GAP });
1421
+ const fullSize = sizeOf(full);
1422
+ const placed = placePill({
1423
+ ...options,
1424
+ size: fullSize
1425
+ });
1426
+ if (placed) return {
1427
+ visible: full,
1428
+ placement: placed,
1429
+ size: fullSize,
1430
+ compact: false
1431
+ };
1432
+ const compact = fitItems(items, budget, {
1433
+ gap: ITEM_GAP,
1434
+ compact: true
1435
+ });
1436
+ const compactSize = sizeOf(compact);
1437
+ const fallback = {
1438
+ corner: options.pinned ?? "bottom-left",
1439
+ shift: 0
1440
+ };
1441
+ return {
1442
+ visible: compact,
1443
+ placement: placePill({
1444
+ ...options,
1445
+ size: compactSize
1446
+ }) ?? fallback,
1447
+ size: compactSize,
1448
+ compact: true
1449
+ };
1450
+ }
1451
+ /**
1452
+ * Anchored to its corner's edges, so the pill stays put while its width
1453
+ * changes. When the visible area is detached from the layout viewport (a
1454
+ * page wider than the phone), it is positioned inside the visible area.
1455
+ */
1456
+ function placementStyle(placement, size, reserve, visual) {
1457
+ if (visual.detached) {
1458
+ const rect = pillRect(placement, size, {
1459
+ w: visual.w,
1460
+ h: visual.h
1461
+ }, reserve);
1462
+ return {
1463
+ top: visual.y + rect.top,
1464
+ left: visual.x + rect.left,
1465
+ bottom: "auto",
1466
+ right: "auto"
1467
+ };
1468
+ }
1469
+ const { corner, shift } = placement;
1470
+ const bottom = corner.startsWith("bottom");
1471
+ const right = corner.endsWith("right");
1472
+ const vertical = 12 + shift + (bottom ? reserve.bottom : 0);
1473
+ const horizontal = 12 + (right ? reserve.right : reserve.left);
1474
+ return {
1475
+ top: bottom ? "auto" : vertical,
1476
+ bottom: bottom ? vertical : "auto",
1477
+ left: right ? "auto" : horizontal,
1478
+ right: right ? horizontal : "auto"
1479
+ };
1480
+ }
1481
+ /**
1482
+ * The status pill. It picks a corner free of the host's fixed and sticky
1483
+ * elements, moves low-priority items into its menu when the viewport is too
1484
+ * narrow, and can be dragged by its env badge into another corner, which is
1485
+ * then kept (Reset layout forgets it).
1486
+ */
1487
+ function Pill({ appSlug, envLabel, slots, grab }) {
1488
+ const panels = usePanels();
1489
+ const { grabbing } = useGrab(grab);
1490
+ const visual = useVisualViewport();
1491
+ const viewport = useMemo(() => ({
1492
+ w: visual.w,
1493
+ h: visual.h
1494
+ }), [visual.w, visual.h]);
1495
+ const rawObstacles = useObstacles();
1496
+ const obstacles = useMemo(() => visual.x === 0 && visual.y === 0 ? rawObstacles : rawObstacles.map((o) => ({
1497
+ ...o,
1498
+ left: o.left - visual.x,
1499
+ top: o.top - visual.y
1500
+ })), [
1501
+ rawObstacles,
1502
+ visual.x,
1503
+ visual.y
1504
+ ]);
1505
+ const ref = useRef(null);
1506
+ const [measured, setMeasured] = useState(EMPTY);
1507
+ const [drag, setDrag] = useState(null);
1508
+ const press = useRef(null);
1509
+ useLayoutEffect(() => {
1510
+ const pill = ref.current;
1511
+ if (!pill) return;
1512
+ const update = () => setMeasured((prev) => sameMeasure(prev, measure(pill)) ? prev : measure(pill));
1513
+ update();
1514
+ if (typeof ResizeObserver === "undefined") return;
1515
+ const observer = new ResizeObserver(update);
1516
+ for (const child of pill.children) observer.observe(child);
1517
+ return () => observer.disconnect();
1518
+ }, [slots]);
1519
+ const { visible, placement, size, compact } = useMemo(() => arrange(slots, measured, {
1520
+ viewport,
1521
+ reserve: panels.reserve,
1522
+ obstacles,
1523
+ pinned: panels.pillCorner
1524
+ }), [
1525
+ slots,
1526
+ measured,
1527
+ viewport,
1528
+ panels.reserve,
1529
+ panels.pillCorner,
1530
+ obstacles
1531
+ ]);
1532
+ const hidden = slots.filter(({ plugin }) => !visible.has(plugin.id)).length;
1533
+ const onPointerDown = (e) => {
1534
+ if (e.button !== 0) return;
1535
+ e.currentTarget.setPointerCapture(e.pointerId);
1536
+ press.current = {
1537
+ x: e.clientX,
1538
+ y: e.clientY,
1539
+ moved: false
1540
+ };
1541
+ };
1542
+ const onPointerMove = (e) => {
1543
+ const start = press.current;
1544
+ if (!start) return;
1545
+ const x = e.clientX - start.x;
1546
+ const y = e.clientY - start.y;
1547
+ if (!start.moved && Math.hypot(x, y) < DRAG_THRESHOLD) return;
1548
+ start.moved = true;
1549
+ setDrag({
1550
+ x,
1551
+ y
1552
+ });
1553
+ };
1554
+ const onPointerUp = (e) => {
1555
+ const start = press.current;
1556
+ press.current = null;
1557
+ setDrag(null);
1558
+ if (start?.moved) panels.setPillCorner(nearestCorner(e.clientX, e.clientY, viewport));
1559
+ };
1560
+ const style = {
1561
+ ...placementStyle(placement, size, panels.reserve, visual),
1562
+ ...drag ? { transform: `translate(${drag.x}px, ${drag.y}px)` } : {}
1563
+ };
1564
+ return /* @__PURE__ */ jsxs("div", {
1565
+ ref,
1566
+ className: "pill",
1567
+ role: "toolbar",
1568
+ "aria-label": `${appSlug} hud`,
1569
+ "data-corner": placement.corner,
1570
+ "data-compact": compact || void 0,
1571
+ "data-dragging": drag ? true : void 0,
1572
+ style,
1573
+ children: [
1574
+ /* @__PURE__ */ jsx("span", {
1575
+ className: "pill-item env",
1576
+ title: "Drag to move the pill to another corner",
1577
+ onPointerDown,
1578
+ onPointerMove,
1579
+ onPointerUp,
1580
+ onPointerCancel: () => {
1581
+ press.current = null;
1582
+ setDrag(null);
1583
+ },
1584
+ children: envLabel
1585
+ }),
1586
+ slots.map((slot) => /* @__PURE__ */ jsx(PluginPillItem, {
1587
+ slot,
1588
+ open: panels.isOpen(slot.plugin.id),
1589
+ overflow: !visible.has(slot.plugin.id),
1590
+ onToggle: () => panels.toggle(slot.plugin.id)
1591
+ }, slot.plugin.id)),
1592
+ /* @__PURE__ */ jsx("button", {
1593
+ type: "button",
1594
+ className: "pill-item grab-toggle",
1595
+ "aria-label": "Grab element",
1596
+ "aria-pressed": grabbing,
1597
+ title: "Grab element",
1598
+ onClick: () => grabbing ? grab.cancel() : grab.start(),
1599
+ children: "⌖"
1600
+ }),
1601
+ /* @__PURE__ */ jsx(PillMenu, { overflow: hidden })
1602
+ ]
1603
+ });
947
1604
  }
948
1605
  //#endregion
949
1606
  //#region src/shell/hud.tsx
@@ -1019,36 +1676,6 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can }) {
1019
1676
  })]
1020
1677
  });
1021
1678
  }
1022
- function Pill({ appSlug, envLabel, slots, grab }) {
1023
- const panels = usePanels();
1024
- const { grabbing } = useGrab(grab);
1025
- return /* @__PURE__ */ jsxs("div", {
1026
- className: "pill",
1027
- role: "toolbar",
1028
- "aria-label": `${appSlug} hud`,
1029
- children: [
1030
- /* @__PURE__ */ jsx("span", {
1031
- className: "pill-item env",
1032
- children: envLabel
1033
- }),
1034
- slots.map((slot) => /* @__PURE__ */ jsx(PluginPillItem, {
1035
- slot,
1036
- open: panels.isOpen(slot.plugin.id),
1037
- onToggle: () => panels.toggle(slot.plugin.id)
1038
- }, slot.plugin.id)),
1039
- /* @__PURE__ */ jsx("button", {
1040
- type: "button",
1041
- className: "pill-item grab-toggle",
1042
- "aria-label": "Grab element",
1043
- "aria-pressed": grabbing,
1044
- title: "Grab element",
1045
- onClick: () => grabbing ? grab.cancel() : grab.start(),
1046
- children: "⌖"
1047
- }),
1048
- /* @__PURE__ */ jsx(PillMenu, {})
1049
- ]
1050
- });
1051
- }
1052
1679
  //#endregion
1053
1680
  //#region src/core/define-hud.tsx
1054
1681
  /**
@@ -1061,9 +1688,12 @@ function Pill({ appSlug, envLabel, slots, grab }) {
1061
1688
  * Returns a component. The plugin list is frozen here, so the shell sees a
1062
1689
  * stable array across renders.
1063
1690
  */
1064
- function defineHud({ app, plugins, apiBase, can }) {
1065
- resolvePlugins(plugins, () => true);
1066
- const list = Object.freeze([...plugins]);
1691
+ function defineHud({ app, plugins, auto, apiBase, can }) {
1692
+ if (!plugins && !auto) throw new Error("hud: defineHud needs `plugins`, `auto` or both");
1693
+ const explicit = resolvePlugins(plugins ?? [], () => true);
1694
+ const detected = typeof auto === "function" ? auto() : auto ?? [];
1695
+ const list = Object.freeze(mergePlugins(detected, explicit));
1696
+ resolvePlugins(list, () => true);
1067
1697
  const access = list.find((plugin) => plugin.access)?.access;
1068
1698
  function DefinedHud({ envLabel, env = "development" }) {
1069
1699
  if (env === "disabled") return null;
@@ -1089,6 +1719,17 @@ function defineHud({ app, plugins, apiBase, can }) {
1089
1719
  return DefinedHud;
1090
1720
  }
1091
1721
  /**
1722
+ * The detected list with explicit plugins merged in: same id replaces in
1723
+ * place (pill position kept), a new id goes to the end.
1724
+ */
1725
+ function mergePlugins(detected, explicit) {
1726
+ const byId = new Map(explicit.map((plugin) => [plugin.id, plugin]));
1727
+ const merged = detected.map((plugin) => byId.get(plugin.id) ?? plugin);
1728
+ const seen = new Set(detected.map((plugin) => plugin.id));
1729
+ for (const plugin of explicit) if (!seen.has(plugin.id)) merged.push(plugin);
1730
+ return merged;
1731
+ }
1732
+ /**
1092
1733
  * The shell behind the access plugin's lock and capability matrix.
1093
1734
  *
1094
1735
  * Display only: hiding a plugin here protects nothing, since its code ships
@@ -1112,4 +1753,4 @@ function AccessHud({ access, env, app, plugins, apiBase, envLabel, can }) {
1112
1753
  });
1113
1754
  }
1114
1755
  //#endregion
1115
- export { ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, matchComponentHints, useGrab };
1756
+ export { ElementOutline, ElementPicker, HUD_DEV_MARKER, HUD_HOST_TAG, Hud, HudApiError, PICKER_CSS, defineHud, definePlugin, matchComponentHints, useGrab };