@hansenexus/hud 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +172 -25
  2. package/dist/{a11y-B5DUaiCs.js → a11y-BGWw4jBr.js} +14 -2
  3. package/dist/{a11y-panel-p_t4eD7p.js → a11y-panel-DcfXnPHk.js} +1 -1
  4. package/dist/{access-D_ewAEJG.d.ts → access-CwPCPsv0.d.ts} +1 -1
  5. package/dist/{access-panel-CEfTr9ZI.js → access-panel-grAsMEDk.js} +1 -1
  6. package/dist/auto/runtime.d.ts +9 -9
  7. package/dist/auto.d.ts +2 -2
  8. package/dist/auto.js +5 -5
  9. package/dist/cli.js +34 -1
  10. package/dist/{data-panel-BmcHCQnM.js → data-panel-B6WPNmV6.js} +1 -1
  11. package/dist/{data-store-ChF1td_P.js → data-store-FNTQKMkG.js} +1 -1
  12. package/dist/{define-hud-CHPedaQ5.d.ts → define-hud-B0aFXrcK.d.ts} +15 -5
  13. package/dist/{design-D0kGgPoP.js → design-BIXY1-Ex.js} +45 -11
  14. package/dist/{dispatch-panel-B-xr_Giy.js → dispatch-panel-BDHgMhOk.js} +1 -1
  15. package/dist/{force-state-panel-_otVYh9i.js → force-state-panel-D5oDydLs.js} +1 -1
  16. package/dist/{handler-BpVhxEmU.js → handler-BKzaOhlJ.js} +1 -1
  17. package/dist/{handler-DtYVCZY6.d.ts → handler-BmFhaA2D.d.ts} +1 -1
  18. package/dist/icons-ByDyNq_E.js +71 -0
  19. package/dist/index-5B7foZut.d.ts +116 -0
  20. package/dist/{index-ReFbhQ9p.d.ts → index-B2KCKkN0.d.ts} +5 -0
  21. package/dist/index-B7qaEUgh.d.ts +44 -0
  22. package/dist/{index-DcH9V3cU.d.ts → index-BGFyuJyN.d.ts} +3 -0
  23. package/dist/{index-Hhh7OXzU.d.ts → index-BeqWehuh.d.ts} +44 -10
  24. package/dist/{index-DstI_ike.d.ts → index-BqKysxTq.d.ts} +5 -1
  25. package/dist/{index-DqOyNf1u.d.ts → index-D97Fnoie.d.ts} +4 -2
  26. package/dist/{index-CwfX-W87.d.ts → index-DS0yT0c-.d.ts} +3 -0
  27. package/dist/{index-BAV_1W8a.d.ts → index-DvlCkGB1.d.ts} +3 -1
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +1226 -256
  30. package/dist/{inspect-C9Ft8fqn.js → inspect-CSkm8tn3.js} +14 -2
  31. package/dist/{inspect-root-BkaupBMp.js → inspect-root-CmiFX0e5.js} +1 -1
  32. package/dist/navigation-CX6AXm7H.js +176 -0
  33. package/dist/next.d.ts +4 -1
  34. package/dist/next.js +12 -1
  35. package/dist/{observe-CdDnDBRP.js → observe-CBNLU148.js} +12 -2
  36. package/dist/{observe-panel-Cgp1M8oT.js → observe-panel-zU5LD-U9.js} +1 -1
  37. package/dist/obstacles-CCmRFTcZ.js +176 -0
  38. package/dist/{ops-panel-CEqDe_UT.js → ops-panel-DHhAnChL.js} +1 -1
  39. package/dist/plugins/a11y.d.ts +1 -1
  40. package/dist/plugins/a11y.js +1 -1
  41. package/dist/plugins/access/server.d.ts +3 -3
  42. package/dist/plugins/access/server.js +1 -1
  43. package/dist/plugins/access.d.ts +5 -2
  44. package/dist/plugins/access.js +18 -5
  45. package/dist/plugins/agent/server.js +2 -2
  46. package/dist/plugins/agent.d.ts +4 -2
  47. package/dist/plugins/agent.js +6 -3
  48. package/dist/plugins/capture/server.js +1 -1
  49. package/dist/plugins/capture.d.ts +2 -2
  50. package/dist/plugins/capture.js +1 -1
  51. package/dist/plugins/data/server.d.ts +1 -1
  52. package/dist/plugins/data/server.js +2 -2
  53. package/dist/plugins/data.d.ts +1 -1
  54. package/dist/plugins/data.js +30 -9
  55. package/dist/plugins/design/server.d.ts +55 -15
  56. package/dist/plugins/design/server.js +188 -123
  57. package/dist/plugins/design.d.ts +3 -3
  58. package/dist/plugins/design.js +1 -1
  59. package/dist/plugins/inspect.d.ts +1 -1
  60. package/dist/plugins/inspect.js +1 -1
  61. package/dist/plugins/observe.d.ts +1 -1
  62. package/dist/plugins/observe.js +1 -1
  63. package/dist/plugins/ops/server.d.ts +1 -1
  64. package/dist/plugins/ops/server.js +1 -1
  65. package/dist/plugins/ops.d.ts +5 -1
  66. package/dist/plugins/ops.js +16 -4
  67. package/dist/plugins/routes/server.d.ts +1 -1
  68. package/dist/plugins/routes/server.js +1 -1
  69. package/dist/plugins/routes.d.ts +3 -3
  70. package/dist/plugins/routes.js +384 -53
  71. package/dist/plugins/seo.d.ts +1 -1
  72. package/dist/plugins/seo.js +1 -1
  73. package/dist/plugins/vitals.d.ts +1 -1
  74. package/dist/plugins/vitals.js +9 -1
  75. package/dist/{plugins-DVy_vaYr.js → plugins-CcW_K7c2.js} +9 -1
  76. package/dist/{plugins-BZvDqGx5.d.ts → plugins-pL2CoWzI.d.ts} +39 -3
  77. package/dist/{poll-CjKsWZi8.js → poll-Dm0OijM4.js} +1 -1
  78. package/dist/same-origin-BHuZO1_H.js +36 -0
  79. package/dist/{seo-Dq9q_QkO.js → seo-BnnGq_vj.js} +13 -2
  80. package/dist/{seo-panel-CfiY-TnT.js → seo-panel-BThx56KM.js} +1 -1
  81. package/dist/server.d.ts +2 -2
  82. package/dist/server.js +2 -2
  83. package/dist/{sessions-panel-COvhPAzv.js → sessions-panel-MknKsTge.js} +1 -1
  84. package/dist/store.d.ts +1 -1
  85. package/dist/store.js +2 -2
  86. package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
  87. package/dist/{unlock-store-4V3vR4Eg.js → unlock-store-CrGXQx1V.js} +1 -1
  88. package/dist/variant-bar-BzZ0ln-C.js +768 -0
  89. package/dist/variant-picks-Byc0hC8a.js +144 -0
  90. package/dist/variants-export-vEtZ-OGC.js +75 -0
  91. package/dist/{variants-panel-BDoSkwBJ.js → variants-panel-D23v5KIp.js} +72 -55
  92. package/dist/variants-types-BOsZ5fDz.js +65 -0
  93. package/dist/variants-types-VkW7vFZF.d.ts +139 -0
  94. package/dist/variants.d.ts +1 -1
  95. package/dist/variants.js +1 -1
  96. package/dist/vite.d.ts +2 -2
  97. package/dist/vite.js +1 -1
  98. package/package.json +1 -1
  99. package/dist/index-BnQ0dTZf.d.ts +0 -19
  100. package/dist/index-gCZBO53s.d.ts +0 -73
  101. package/dist/same-origin-BGet22CC.js +0 -21
  102. package/dist/variants-types-CcRf119M.d.ts +0 -63
@@ -1,4 +1,5 @@
1
- import { i as definePlugin } from "./plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "./icons-ByDyNq_E.js";
2
+ import { i as definePlugin } from "./plugins-CcW_K7c2.js";
2
3
  import { a as isRequestError, l as requestBuffer, o as markReplay } from "./requests-BwD6MKEq.js";
3
4
  import { t as installCapture } from "./capture-CwrIwLqi.js";
4
5
  import { lazy, useEffect, useSyncExternalStore } from "react";
@@ -85,7 +86,7 @@ async function replay(entry) {
85
86
  }
86
87
  //#endregion
87
88
  //#region src/plugins/inspect/index.tsx
88
- const InspectRoot = lazy(() => import("./inspect-root-BkaupBMp.js"));
89
+ const InspectRoot = lazy(() => import("./inspect-root-CmiFX0e5.js"));
89
90
  const INSPECT_CAPABILITY = "inspect.read";
90
91
  /**
91
92
  * Data inspector on top of the observe capture: every fetch, XHR and Next
@@ -122,10 +123,21 @@ function inspect({ ignore, adapters = [] } = {}) {
122
123
  function Panel() {
123
124
  return /* @__PURE__ */ jsx(InspectRoot, { adapters });
124
125
  }
126
+ function useInspectBadge() {
127
+ const entries = useRequests();
128
+ const failed = entries.filter(isRequestError).length;
129
+ if (failed > 0) return {
130
+ tone: "poor",
131
+ count: failed
132
+ };
133
+ return { tone: entries.some((entry) => entry.status === void 0) ? "warn" : "good" };
134
+ }
125
135
  return definePlugin({
126
136
  id: "inspect",
127
137
  title: "Inspect",
128
138
  capability: INSPECT_CAPABILITY,
139
+ icon: hudIcon("activity"),
140
+ badge: useInspectBadge,
129
141
  pill: InspectPill,
130
142
  panel: Panel,
131
143
  commands: [{
@@ -1,5 +1,5 @@
1
1
  import { a as isRequestError, l as requestBuffer } from "./requests-BwD6MKEq.js";
2
- import { a as FILTERS, c as setView, i as replayBlocker, l as useRequests, o as REQUESTS_TAB, r as replay, s as matches, u as useView } from "./inspect-C9Ft8fqn.js";
2
+ import { a as FILTERS, c as setView, i as replayBlocker, l as useRequests, o as REQUESTS_TAB, r as replay, s as matches, u as useView } from "./inspect-CSkm8tn3.js";
3
3
  import { useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/plugins/inspect/inspect-panel.tsx
@@ -0,0 +1,176 @@
1
+ import { useSyncExternalStore } from "react";
2
+ const VERSION = 1;
3
+ const EMPTY_PREFS = {
4
+ pins: [],
5
+ recent: []
6
+ };
7
+ function prefsKey(app) {
8
+ return `hansenexus-hud:routes:${app}`;
9
+ }
10
+ const prefs = /* @__PURE__ */ new Map();
11
+ const prefsListeners = /* @__PURE__ */ new Set();
12
+ function strings(value) {
13
+ return Array.isArray(value) ? [...new Set(value.filter((item) => typeof item === "string"))] : [];
14
+ }
15
+ /** Storage can be missing, blocked or hold someone else's JSON; every failure reads as empty. */
16
+ function loadPrefs(app) {
17
+ try {
18
+ const raw = window.localStorage.getItem(prefsKey(app));
19
+ const value = raw ? JSON.parse(raw) : null;
20
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return EMPTY_PREFS;
21
+ const record = value;
22
+ if (record.v !== VERSION) return EMPTY_PREFS;
23
+ return {
24
+ pins: strings(record.pins),
25
+ recent: strings(record.recent).slice(0, 8)
26
+ };
27
+ } catch {
28
+ return EMPTY_PREFS;
29
+ }
30
+ }
31
+ function savePrefs(app, value) {
32
+ prefs.set(app, value);
33
+ try {
34
+ window.localStorage.setItem(prefsKey(app), JSON.stringify({
35
+ v: VERSION,
36
+ ...value
37
+ }));
38
+ } catch {}
39
+ for (const listener of prefsListeners) listener();
40
+ }
41
+ function getPrefs(app) {
42
+ let value = prefs.get(app);
43
+ if (!value) {
44
+ value = typeof window === "undefined" ? EMPTY_PREFS : loadPrefs(app);
45
+ prefs.set(app, value);
46
+ }
47
+ return value;
48
+ }
49
+ function subscribePrefs(listener) {
50
+ prefsListeners.add(listener);
51
+ return () => prefsListeners.delete(listener);
52
+ }
53
+ /** The app's pins and recent routes; re-renders on every change. */
54
+ function usePrefs(app) {
55
+ return useSyncExternalStore(subscribePrefs, () => getPrefs(app), () => EMPTY_PREFS);
56
+ }
57
+ function togglePin(app, pathname) {
58
+ const current = getPrefs(app);
59
+ const pins = current.pins.includes(pathname) ? current.pins.filter((pin) => pin !== pathname) : [...current.pins, pathname];
60
+ savePrefs(app, {
61
+ ...current,
62
+ pins
63
+ });
64
+ }
65
+ /** Puts `pathname` at the head of the app's recent list. */
66
+ function recordVisit(app, pathname) {
67
+ const current = getPrefs(app);
68
+ const recent = [pathname, ...current.recent.filter((p) => p !== pathname)].slice(0, 8);
69
+ if (recent.length === current.recent.length && recent.every((p, i) => p === current.recent[i])) return;
70
+ savePrefs(app, {
71
+ ...current,
72
+ recent
73
+ });
74
+ }
75
+ let observedApp = null;
76
+ let pathname = "";
77
+ let restore = null;
78
+ const pathListeners = /* @__PURE__ */ new Set();
79
+ function readPathname() {
80
+ return typeof location === "undefined" ? "" : location.pathname;
81
+ }
82
+ function onNavigate() {
83
+ const next = readPathname();
84
+ if (next === pathname) return;
85
+ pathname = next;
86
+ if (observedApp !== null) recordVisit(observedApp, next);
87
+ for (const listener of pathListeners) listener();
88
+ }
89
+ function patch(method) {
90
+ const original = history[method];
91
+ const patched = function(...args) {
92
+ original.apply(this, args);
93
+ queueMicrotask(onNavigate);
94
+ };
95
+ history[method] = patched;
96
+ return () => {
97
+ if (history[method] === patched) history[method] = original;
98
+ };
99
+ }
100
+ /**
101
+ * Starts recording visits for `app`: the current pathname now, then every
102
+ * `pushState`, `replaceState` and `popstate`. Idempotent; the plugin calls it
103
+ * from its rail badge (HUD mount) and from the panel.
104
+ */
105
+ function startNavigationObserver(app) {
106
+ if (typeof window === "undefined") return;
107
+ if (restore) {
108
+ if (observedApp !== app) {
109
+ observedApp = app;
110
+ recordVisit(app, pathname);
111
+ }
112
+ return;
113
+ }
114
+ observedApp = app;
115
+ pathname = readPathname();
116
+ recordVisit(app, pathname);
117
+ const unpatch = [patch("pushState"), patch("replaceState")];
118
+ window.addEventListener("popstate", onNavigate);
119
+ restore = () => {
120
+ for (const undo of unpatch) undo();
121
+ window.removeEventListener("popstate", onNavigate);
122
+ };
123
+ }
124
+ function getPathname() {
125
+ return restore ? pathname : readPathname();
126
+ }
127
+ function subscribePathname(listener) {
128
+ pathListeners.add(listener);
129
+ return () => pathListeners.delete(listener);
130
+ }
131
+ /** The page's pathname, live across client-side navigation. */
132
+ function usePathname() {
133
+ return useSyncExternalStore(subscribePathname, getPathname, () => "");
134
+ }
135
+ /** Next's app or pages router, which dev builds expose as `window.next.router`. */
136
+ function clientRouter() {
137
+ if (typeof window === "undefined") return void 0;
138
+ const router = window.next?.router;
139
+ if (typeof router === "object" && router !== null && "push" in router) {
140
+ if (typeof router.push === "function") return router;
141
+ }
142
+ }
143
+ /** Client-side through the app's router when there is one, else a full load. */
144
+ function navigateTo(url) {
145
+ const router = clientRouter();
146
+ if (router) {
147
+ router.push(url);
148
+ return;
149
+ }
150
+ location.assign(url);
151
+ }
152
+ let focusPending = false;
153
+ let focusTick = 0;
154
+ const focusListeners = /* @__PURE__ */ new Set();
155
+ /** The command asks the panel to focus its filter; the panel takes the request once mounted. */
156
+ function requestFilterFocus() {
157
+ focusPending = true;
158
+ focusTick += 1;
159
+ for (const listener of focusListeners) listener();
160
+ }
161
+ /** Consumes the pending request; true once per `requestFilterFocus`. */
162
+ function takeFilterFocus() {
163
+ const pending = focusPending;
164
+ focusPending = false;
165
+ return pending;
166
+ }
167
+ function subscribeFocus(listener) {
168
+ focusListeners.add(listener);
169
+ return () => focusListeners.delete(listener);
170
+ }
171
+ /** Changes whenever the command runs, so the panel's focus effect re-runs. */
172
+ function useFilterFocusTick() {
173
+ return useSyncExternalStore(subscribeFocus, () => focusTick, () => 0);
174
+ }
175
+ //#endregion
176
+ export { togglePin as a, usePrefs as c, takeFilterFocus as i, requestFilterFocus as n, useFilterFocusTick as o, startNavigationObserver as r, usePathname as s, navigateTo as t };
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as HudMountProps } from "./define-hud-CHPedaQ5.js";
1
+ import { r as HudMountProps } from "./define-hud-B0aFXrcK.js";
2
2
  import { n as hudEnvLabel, r as resolveHudEnv, t as HudEnv } from "./env-CApnbI0r.js";
3
3
  import { ComponentType } from "react";
4
4
  //#region src/next/loader.d.ts
@@ -36,6 +36,9 @@ interface HudLoaderOptions {
36
36
  * chunk would ship unreachable but readable (hn-monorepo#1283). Pass `null`
37
37
  * and the loader renders nothing.
38
38
  *
39
+ * A HUD chunk that fails to load renders nothing: a dev tool must not take
40
+ * the page down with it. The reason goes to the console.
41
+ *
39
42
  * Outside Next (Vite), gate on `import.meta.env.DEV` and pass `{ env }`.
40
43
  */
41
44
  export declare function createHudLoader(load: HudModuleLoader | null, options?: HudLoaderOptions): ComponentType<HudMountProps>;
package/dist/next.js CHANGED
@@ -25,11 +25,14 @@ import { jsx } from "react/jsx-runtime";
25
25
  * chunk would ship unreachable but readable (hn-monorepo#1283). Pass `null`
26
26
  * and the loader renders nothing.
27
27
  *
28
+ * A HUD chunk that fails to load renders nothing: a dev tool must not take
29
+ * the page down with it. The reason goes to the console.
30
+ *
28
31
  * Outside Next (Vite), gate on `import.meta.env.DEV` and pass `{ env }`.
29
32
  */
30
33
  function createHudLoader(load, options = {}) {
31
34
  if (!load) return NoHud;
32
- const LazyHud = lazy(load);
35
+ const LazyHud = lazy(() => loadOrNothing(load));
33
36
  function HudLoader(props) {
34
37
  const [mounted, setMounted] = useState(false);
35
38
  useEffect(() => setMounted(true), []);
@@ -47,6 +50,14 @@ function createHudLoader(load, options = {}) {
47
50
  }
48
51
  return HudLoader;
49
52
  }
53
+ async function loadOrNothing(load) {
54
+ try {
55
+ return await load();
56
+ } catch (error) {
57
+ console.warn("hud: the HUD chunk failed to load, rendering nothing", error);
58
+ return { default: NoHud };
59
+ }
60
+ }
50
61
  function NoHud(_props) {
51
62
  return null;
52
63
  }
@@ -1,4 +1,5 @@
1
- import { i as definePlugin } from "./plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "./icons-ByDyNq_E.js";
2
+ import { i as definePlugin } from "./plugins-CcW_K7c2.js";
2
3
  import { _ as captureBuffer, v as isError } from "./requests-BwD6MKEq.js";
3
4
  import { t as installCapture } from "./capture-CwrIwLqi.js";
4
5
  import { r as startVitals } from "./store-CQqIIKTc.js";
@@ -44,7 +45,7 @@ function useCapture() {
44
45
  }
45
46
  //#endregion
46
47
  //#region src/plugins/observe/index.tsx
47
- const Panel = lazy(() => import("./observe-panel-Cgp1M8oT.js"));
48
+ const Panel = lazy(() => import("./observe-panel-zU5LD-U9.js"));
48
49
  const NO_ENV = {};
49
50
  const noUser = () => void 0;
50
51
  function useErrorCount() {
@@ -72,9 +73,18 @@ function observe({ env = NO_ENV, useUser = noUser, ignore } = {}) {
72
73
  useUser
73
74
  });
74
75
  }
76
+ function useObserveBadge() {
77
+ const errors = useErrorCount();
78
+ return errors > 0 ? {
79
+ tone: "poor",
80
+ count: errors
81
+ } : { tone: "good" };
82
+ }
75
83
  return definePlugin({
76
84
  id: "observe",
77
85
  title: "Observe",
86
+ icon: hudIcon("bug"),
87
+ badge: useObserveBadge,
78
88
  pill: ObservePill,
79
89
  pillPriority: 20,
80
90
  panel: ObservePanel,
@@ -1,5 +1,5 @@
1
1
  import { _ as captureBuffer, v as isError } from "./requests-BwD6MKEq.js";
2
- import { a as useCapture, i as setView, n as FILTERS, o as useView, r as matches } from "./observe-CdDnDBRP.js";
2
+ import { a as useCapture, i as setView, n as FILTERS, o as useView, r as matches } from "./observe-CBNLU148.js";
3
3
  import { VitalsPanel } from "./vitals-panel-BCmMUntW.js";
4
4
  import { useEffect, useLayoutEffect, useState, version } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -0,0 +1,176 @@
1
+ import "./marker-uZYPOJ4M.js";
2
+ import { createContext, useContext, useEffect, useState, useSyncExternalStore } from "react";
3
+ //#region src/shell/panels/panels-context.ts
4
+ const PanelsContext = createContext(null);
5
+ function usePanels() {
6
+ const api = useContext(PanelsContext);
7
+ if (!api) throw new Error("usePanels() used outside <PanelManager>");
8
+ return api;
9
+ }
10
+ //#endregion
11
+ //#region src/shell/pill/visual-viewport.ts
12
+ function subscribe(listener) {
13
+ const vv = window.visualViewport;
14
+ window.addEventListener("resize", listener);
15
+ vv?.addEventListener("resize", listener);
16
+ vv?.addEventListener("scroll", listener);
17
+ return () => {
18
+ window.removeEventListener("resize", listener);
19
+ vv?.removeEventListener("resize", listener);
20
+ vv?.removeEventListener("scroll", listener);
21
+ };
22
+ }
23
+ let cached = {
24
+ x: 0,
25
+ y: 0,
26
+ w: 0,
27
+ h: 0,
28
+ detached: false
29
+ };
30
+ /**
31
+ * On a phone, a page wider than the screen (an image with a fixed width is
32
+ * enough) grows the layout viewport past the visible area, and a pill fixed
33
+ * to the bottom edge ends up below the fold. The visual viewport is what the
34
+ * user sees; the pill places itself in it.
35
+ */
36
+ function read() {
37
+ const root = document.documentElement;
38
+ const layoutW = root.clientWidth || window.innerWidth;
39
+ const layoutH = root.clientHeight || window.innerHeight;
40
+ const vv = window.visualViewport;
41
+ const x = vv?.offsetLeft ?? 0;
42
+ const y = vv?.offsetTop ?? 0;
43
+ const w = Math.round(vv?.width ?? layoutW);
44
+ const h = Math.round(vv?.height ?? layoutH);
45
+ const detached = x !== 0 || y !== 0 || window.innerWidth > w + 1 || window.innerHeight > h + 1;
46
+ const next = {
47
+ x,
48
+ y,
49
+ w: detached ? w : layoutW,
50
+ h: detached ? h : layoutH,
51
+ detached
52
+ };
53
+ if (next.x !== cached.x || next.y !== cached.y || next.w !== cached.w || next.h !== cached.h || next.detached !== cached.detached) cached = next;
54
+ return cached;
55
+ }
56
+ function useVisualViewport() {
57
+ return useSyncExternalStore(subscribe, read, read);
58
+ }
59
+ //#endregion
60
+ //#region src/shell/pill/obstacles.ts
61
+ /** Fixed elements covering more than this share of the viewport are backdrops, not corners. */
62
+ const MAX_AREA_SHARE = .5;
63
+ /** DOM changes settle for this long before the page is scanned again. */
64
+ const RESCAN_MS = 250;
65
+ function isFloating(el) {
66
+ const { position } = getComputedStyle(el);
67
+ return position === "fixed" || position === "sticky";
68
+ }
69
+ /**
70
+ * The host page's fixed and sticky elements: what fights the pill for a
71
+ * corner. Nested ones are dropped since their floating ancestor already
72
+ * counts, and the HUD's own host is skipped.
73
+ */
74
+ function scanFloating(root = document.body) {
75
+ const found = [];
76
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
77
+ const el = node;
78
+ if (el.localName === "hn-hud") return NodeFilter.FILTER_REJECT;
79
+ return isFloating(el) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
80
+ } });
81
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
82
+ const el = node;
83
+ if (!found.some((outer) => outer.contains(el))) found.push(el);
84
+ }
85
+ return found;
86
+ }
87
+ /** Visible rects of `elements`, minus backdrops and anything off screen. */
88
+ function obstacleRects(elements) {
89
+ const vw = window.innerWidth;
90
+ const vh = window.innerHeight;
91
+ const rects = [];
92
+ for (const el of elements) {
93
+ const { left, top, width, height } = el.getBoundingClientRect();
94
+ if (width === 0 || height === 0) continue;
95
+ if (width * height > vw * vh * MAX_AREA_SHARE) continue;
96
+ if (left >= vw || top >= vh || left + width <= 0 || top + height <= 0) continue;
97
+ const style = getComputedStyle(el);
98
+ if (style.visibility === "hidden" || style.opacity === "0") continue;
99
+ rects.push({
100
+ left,
101
+ top,
102
+ width,
103
+ height
104
+ });
105
+ }
106
+ return rects;
107
+ }
108
+ function sameRects(a, b) {
109
+ 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);
110
+ }
111
+ const NONE = [];
112
+ /** Obstacle rects moved into visible-area coordinates when the visual viewport is offset. */
113
+ function offsetObstacles(rects, offset) {
114
+ if (offset.x === 0 && offset.y === 0) return rects;
115
+ return rects.map((o) => ({
116
+ ...o,
117
+ left: o.left - offset.x,
118
+ top: o.top - offset.y
119
+ }));
120
+ }
121
+ /**
122
+ * Live obstacle rects. The element list is rescanned when the DOM settles
123
+ * after a change; rects are re-measured on scroll (sticky elements move) and
124
+ * resize, once per frame.
125
+ */
126
+ function useObstacles() {
127
+ const [rects, setRects] = useState(NONE);
128
+ useEffect(() => {
129
+ let elements = scanFloating();
130
+ let frame = 0;
131
+ let timer;
132
+ const measure = () => {
133
+ frame = 0;
134
+ const next = obstacleRects(elements);
135
+ setRects((prev) => sameRects(prev, next) ? prev : next);
136
+ };
137
+ const schedule = () => {
138
+ if (!frame) frame = requestAnimationFrame(measure);
139
+ };
140
+ const rescan = () => {
141
+ schedule();
142
+ clearTimeout(timer);
143
+ timer = setTimeout(() => {
144
+ elements = scanFloating();
145
+ schedule();
146
+ }, RESCAN_MS);
147
+ };
148
+ measure();
149
+ const observer = new MutationObserver(rescan);
150
+ observer.observe(document.body, {
151
+ childList: true,
152
+ subtree: true,
153
+ attributes: true,
154
+ attributeFilter: [
155
+ "class",
156
+ "style",
157
+ "hidden"
158
+ ]
159
+ });
160
+ window.addEventListener("scroll", schedule, {
161
+ capture: true,
162
+ passive: true
163
+ });
164
+ window.addEventListener("resize", schedule);
165
+ return () => {
166
+ observer.disconnect();
167
+ clearTimeout(timer);
168
+ if (frame) cancelAnimationFrame(frame);
169
+ window.removeEventListener("scroll", schedule, { capture: true });
170
+ window.removeEventListener("resize", schedule);
171
+ };
172
+ }, []);
173
+ return rects;
174
+ }
175
+ //#endregion
176
+ export { usePanels as a, PanelsContext as i, useObstacles as n, useVisualViewport as r, offsetObstacles as t };
@@ -1,5 +1,5 @@
1
1
  import { i as stateRating, r as stateLabel, t as CI_POLL_MS } from "./state-CjjZPjPJ.js";
2
- import { t as usePoll } from "./poll-CjKsWZi8.js";
2
+ import { t as usePoll } from "./poll-Dm0OijM4.js";
3
3
  import { t as TELEMETRY_RANGES } from "./types-B-ulf2Jp.js";
4
4
  import { useState } from "react";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -1,2 +1,2 @@
1
- import { a as A11yFinding, c as AxeImpact, i as A11yStatus, n as a11y, o as AXE_URL, r as A11ySnapshot, s as AXE_VERSION, t as A11yOptions } from "../index-DqOyNf1u.js";
1
+ import { a as A11yFinding, c as AxeImpact, i as A11yStatus, n as a11y, o as AXE_URL, r as A11ySnapshot, s as AXE_VERSION, t as A11yOptions } from "../index-D97Fnoie.js";
2
2
  export { type A11yFinding, A11yOptions, type A11ySnapshot, type A11yStatus, AXE_URL, AXE_VERSION, type AxeImpact, a11y };
@@ -1,2 +1,2 @@
1
- import { a as AXE_VERSION, i as AXE_URL, t as a11y } from "../a11y-B5DUaiCs.js";
1
+ import { a as AXE_VERSION, i as AXE_URL, t as a11y } from "../a11y-BGWw4jBr.js";
2
2
  export { AXE_URL, AXE_VERSION, a11y };
@@ -1,7 +1,7 @@
1
- import { r as HudCapability } from "../../plugins-BZvDqGx5.js";
1
+ import { a as HudCapability } from "../../plugins-pL2CoWzI.js";
2
2
  import { t as HudEnv } from "../../env-CApnbI0r.js";
3
- import { a as signHudUnlockToken, c as CAPABILITY_MATRIX, d as hasCapability, f as isHudVisible, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, o as verifyHudUnlockToken, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, t as HUD_UNLOCK_COOKIE, u as HUD_CAPABILITIES } from "../../access-D_ewAEJG.js";
4
- import { t as HudGuard } from "../../handler-DtYVCZY6.js";
3
+ import { a as signHudUnlockToken, c as CAPABILITY_MATRIX, d as hasCapability, f as isHudVisible, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, o as verifyHudUnlockToken, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, t as HUD_UNLOCK_COOKIE, u as HUD_CAPABILITIES } from "../../access-CwPCPsv0.js";
4
+ import { t as HudGuard } from "../../handler-BmFhaA2D.js";
5
5
  //#region src/plugins/access/server/settings.d.ts
6
6
  /** What the server half reads from its environment, per request. */
7
7
  interface AccessSettings {
@@ -1,4 +1,4 @@
1
- import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
1
+ import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
2
2
  import { n as resolveHudEnv } from "../../env-CaiFPIhF.js";
3
3
  import { a as readCookie, c as timingSafeEqual, i as hudUnlockTtlMs, l as verifyHudUnlockToken, n as hudRequiresUnlock, o as resolveHudAccess, r as hudUnlockCookieString, s as signHudUnlockToken, t as HUD_UNLOCK_COOKIE } from "../../access-C7zlaqj6.js";
4
4
  import { a as isHudVisible, i as hasCapability, n as CAPABILITY_MATRIX, o as isProductionDenied, r as HUD_CAPABILITIES, s as resolveMatrix, t as ACCESS_UNLOCK_CAPABILITY } from "../../capabilities-rDSKjXpq.js";
@@ -1,7 +1,8 @@
1
- import { c as HudPluginProps, r as HudCapability } from "../plugins-BZvDqGx5.js";
2
- import { c as CAPABILITY_MATRIX, d as hasCapability, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, u as HUD_CAPABILITIES } from "../access-D_ewAEJG.js";
1
+ import { a as HudCapability, r as HudBadge, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
2
+ import { c as CAPABILITY_MATRIX, d as hasCapability, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, u as HUD_CAPABILITIES } from "../access-CwPCPsv0.js";
3
3
  //#region src/plugins/access/access-pill.d.ts
4
4
  declare function AccessPill(): import("react").JSX.Element;
5
+ declare function useAccessBadge(): HudBadge;
5
6
  //#endregion
6
7
  //#region src/plugins/access/unlock-store.d.ts
7
8
  type UnlockStatus = "checking" | "locked" | "unlocked" | "unconfigured";
@@ -29,6 +30,8 @@ export declare function access(options?: AccessOptions): {
29
30
  readonly id: "access";
30
31
  readonly title: "Access";
31
32
  readonly capability: "access.unlock";
33
+ readonly icon: import("react").ComponentType;
34
+ readonly badge: typeof useAccessBadge;
32
35
  readonly pill: typeof AccessPill;
33
36
  readonly pillPriority: 30;
34
37
  readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
@@ -1,22 +1,33 @@
1
- import { i as definePlugin } from "../plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "../icons-ByDyNq_E.js";
2
+ import { i as definePlugin } from "../plugins-CcW_K7c2.js";
2
3
  import { n as hudRequiresUnlock, o as resolveHudAccess } from "../access-C7zlaqj6.js";
3
4
  import { c as toHudEnv, i as hasCapability, n as CAPABILITY_MATRIX, o as isProductionDenied, r as HUD_CAPABILITIES, s as resolveMatrix, t as ACCESS_UNLOCK_CAPABILITY } from "../capabilities-rDSKjXpq.js";
4
- import { n as useUnlockState, r as useUnlocked } from "../unlock-store-4V3vR4Eg.js";
5
+ import { n as useUnlockState, r as useUnlocked } from "../unlock-store-CrGXQx1V.js";
5
6
  import { lazy } from "react";
6
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/plugins/access/access-pill.tsx
8
- function AccessPill() {
9
+ function useAccessState() {
9
10
  const { env, status } = useUnlockState();
10
11
  const access = resolveHudAccess(env);
11
12
  const unlocked = access === "open" || status === "unlocked";
13
+ return {
14
+ unlocked,
15
+ label: access === "open" ? "Open" : unlocked ? "Unlocked" : "Locked"
16
+ };
17
+ }
18
+ function AccessPill() {
19
+ const { label, unlocked } = useAccessState();
12
20
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
13
21
  className: "dot",
14
22
  "data-rating": unlocked ? "good" : "poor"
15
- }), access === "open" ? "Open" : unlocked ? "Unlocked" : "Locked"] });
23
+ }), label] });
24
+ }
25
+ function useAccessBadge() {
26
+ return { tone: useAccessState().unlocked ? "good" : "poor" };
16
27
  }
17
28
  //#endregion
18
29
  //#region src/plugins/access/index.tsx
19
- const Panel = lazy(() => import("../access-panel-CEfTr9ZI.js"));
30
+ const Panel = lazy(() => import("../access-panel-grAsMEDk.js"));
20
31
  /**
21
32
  * Opt-in for deployed tiers. Without it `defineHud` renders nothing outside
22
33
  * development. With it the HUD follows the env ladder: a tier's capability
@@ -38,6 +49,8 @@ function access(options = {}) {
38
49
  id: "access",
39
50
  title: "Access",
40
51
  capability: ACCESS_UNLOCK_CAPABILITY,
52
+ icon: hudIcon("lock"),
53
+ badge: useAccessBadge,
41
54
  pill: AccessPill,
42
55
  pillPriority: 30,
43
56
  panel: AccessPanel,
@@ -1,5 +1,5 @@
1
- import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
2
- import { t as refuseCrossSite } from "../../same-origin-BGet22CC.js";
1
+ import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
2
+ import { t as refuseCrossSite } from "../../same-origin-BHuZO1_H.js";
3
3
  //#region src/plugins/agent/prompt.ts
4
4
  /** The task text every provider receives: grab context first, then the instruction. */
5
5
  function dispatchPrompt({ note, payload, hints = [] }) {
@@ -1,6 +1,6 @@
1
1
  import { r as GrabPayload, t as ComponentHint } from "../payload-MUQ9ciER.js";
2
- import { c as HudPluginProps, s as HudPluginContext } from "../plugins-BZvDqGx5.js";
3
- import "../index-gCZBO53s.js";
2
+ import { l as HudPluginContext, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
3
+ import "../index-5B7foZut.js";
4
4
  import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../types-Cxh4twqc.js";
5
5
  //#region src/plugins/agent/index.d.ts
6
6
  export interface AgentDispatchOptions {
@@ -20,6 +20,7 @@ export interface AgentDispatchOptions {
20
20
  export declare function agentDispatch({ componentHints, openOnGrab }?: AgentDispatchOptions): {
21
21
  readonly id: "agent-dispatch";
22
22
  readonly title: "Dispatch";
23
+ readonly icon: import("react").ComponentType;
23
24
  readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
24
25
  readonly onGrab?: (_payload: GrabPayload, ctx: HudPluginContext) => void;
25
26
  };
@@ -31,6 +32,7 @@ export interface AgentSessionsOptions {
31
32
  export declare function agentSessions({ intervalMs }?: AgentSessionsOptions): {
32
33
  readonly id: "agent-sessions";
33
34
  readonly title: "Sessions";
35
+ readonly icon: import("react").ComponentType;
34
36
  readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
35
37
  };
36
38
  //#endregion
@@ -1,4 +1,5 @@
1
- import { i as definePlugin } from "../plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "../icons-ByDyNq_E.js";
2
+ import { i as definePlugin } from "../plugins-CcW_K7c2.js";
2
3
  import { lazy } from "react";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  //#region src/plugins/agent/run-log.ts
@@ -28,8 +29,8 @@ function createRunLog() {
28
29
  }
29
30
  //#endregion
30
31
  //#region src/plugins/agent/index.tsx
31
- const DispatchPanel = lazy(() => import("../dispatch-panel-B-xr_Giy.js"));
32
- const SessionsPanel = lazy(() => import("../sessions-panel-COvhPAzv.js"));
32
+ const DispatchPanel = lazy(() => import("../dispatch-panel-BDHgMhOk.js"));
33
+ const SessionsPanel = lazy(() => import("../sessions-panel-MknKsTge.js"));
33
34
  /**
34
35
  * Dispatch panel: the last grab plus an instruction, sent to one of the
35
36
  * server's providers (`hermes()`, `claudeCode()`). Mount the server half from
@@ -47,6 +48,7 @@ function agentDispatch({ componentHints, openOnGrab = true } = {}) {
47
48
  return definePlugin({
48
49
  id: "agent-dispatch",
49
50
  title: "Dispatch",
51
+ icon: hudIcon("send"),
50
52
  panel: Panel,
51
53
  ...openOnGrab ? { onGrab: (_payload, ctx) => ctx.open() } : {}
52
54
  });
@@ -62,6 +64,7 @@ function agentSessions({ intervalMs = 1e4 } = {}) {
62
64
  return definePlugin({
63
65
  id: "agent-sessions",
64
66
  title: "Sessions",
67
+ icon: hudIcon("terminal"),
65
68
  panel: Panel
66
69
  });
67
70
  }