@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,12 @@
1
1
  //#region src/core/plugins.ts
2
+ /**
3
+ * Maps a vitals-style rating (`.dot[data-rating]`, what the built-in pills
4
+ * render) to a badge tone. `undefined` stays undefined: no rating yet.
5
+ */
6
+ function ratingTone(rating) {
7
+ if (rating === "needs-improvement") return "warn";
8
+ return rating;
9
+ }
2
10
  const HUD_HTTP_METHODS = [
3
11
  "GET",
4
12
  "POST",
@@ -67,4 +75,4 @@ function parseBody(text) {
67
75
  }
68
76
  }
69
77
  //#endregion
70
- export { resolvePlugins as a, definePlugin as i, HudApiError as n, createPluginContext as r, HUD_HTTP_METHODS as t };
78
+ export { ratingTone as a, definePlugin as i, HudApiError as n, resolvePlugins as o, createPluginContext as r, HUD_HTTP_METHODS as t };
@@ -68,6 +68,19 @@ interface HudPluginContext {
68
68
  interface HudPluginProps {
69
69
  ctx: HudPluginContext;
70
70
  }
71
+ /** Colour of a rail badge: the dot on the plugin's icon, or its count bubble. */
72
+ type HudBadgeTone = "good" | "warn" | "poor" | "off";
73
+ /** What a plugin's `badge` hook reports: a tone, and a count for a bubble instead of a dot. */
74
+ interface HudBadge {
75
+ tone: HudBadgeTone;
76
+ /** Shown as a number on the icon when above 0; the dot otherwise. */
77
+ count?: number;
78
+ }
79
+ /**
80
+ * Maps a vitals-style rating (`.dot[data-rating]`, what the built-in pills
81
+ * render) to a badge tone. `undefined` stays undefined: no rating yet.
82
+ */
83
+ declare function ratingTone(rating: "good" | "needs-improvement" | "poor" | undefined): HudBadgeTone | undefined;
71
84
  interface HudCommand {
72
85
  /** Unique within the plugin. */
73
86
  id: string;
@@ -108,12 +121,35 @@ interface HudPlugin {
108
121
  * loading state and contains a panel that fails.
109
122
  */
110
123
  panel?: ComponentType<HudPluginProps>;
111
- /** Live content inside the plugin's pill item. Keep it inline and non-interactive. */
124
+ /**
125
+ * Live content inside the plugin's pill item; on the rail it is the
126
+ * tooltip text beside the icon. Keep it inline and non-interactive.
127
+ */
112
128
  pill?: ComponentType<HudPluginProps>;
129
+ /**
130
+ * The rail's icon for this plugin: `hudIcon("database")` for a built-in
131
+ * shape, or any 24×24 SVG component. Without one the rail shows a plug.
132
+ */
133
+ icon?: ComponentType;
134
+ /**
135
+ * Status on the rail icon, called like a component (hooks are allowed):
136
+ * a 6 px dot in the badge's tone, or a count bubble when `count` is above
137
+ * 0. `null` shows nothing. The three highest-priority badges also make up
138
+ * the folded rail's summary dots.
139
+ */
140
+ badge?: (props: HudPluginProps) => HudBadge | null;
141
+ /**
142
+ * Always-mounted content inside the HUD's shadow root, with no panel frame:
143
+ * it positions itself and opts in with `pointer-events: auto`. Make it a
144
+ * dynamic import like `panel`; while it loads, and when it fails, it is
145
+ * nothing.
146
+ */
147
+ overlay?: ComponentType<HudPluginProps>;
113
148
  /**
114
149
  * When the pill runs out of room, items with a higher priority stay visible
115
150
  * longest; the rest move into the pill menu. Above 0 the item also survives
116
- * compact mode. Default 0.
151
+ * compact mode. On the rail the three highest make the folded summary.
152
+ * Default 0.
117
153
  */
118
154
  pillPriority?: number;
119
155
  commands?: readonly HudCommand[];
@@ -141,4 +177,4 @@ declare class HudApiError extends Error {
141
177
  constructor(status: number, body: unknown, url: string);
142
178
  }
143
179
  //#endregion
144
- export { useGrab as _, HudHttpMethod as a, HudPluginProps as c, HudRoutes as d, PinEdge as f, HudHighlight as g, HudGrabState as h, HudCommand as i, HudRouteContext as l, HudGrab as m, HudApiError as n, HudPlugin as o, definePlugin as p, HudCapability as r, HudPluginContext as s, HudAccessControl as t, HudRouteHandler as u };
180
+ export { HudGrab as _, HudCapability as a, useGrab as b, HudPlugin as c, HudRouteContext as d, HudRouteHandler as f, ratingTone as g, definePlugin as h, HudBadgeTone as i, HudPluginContext as l, PinEdge as m, HudApiError as n, HudCommand as o, HudRoutes as p, HudBadge as r, HudHttpMethod as s, HudAccessControl as t, HudPluginProps as u, HudGrabState as v, HudHighlight as y };
@@ -1,4 +1,4 @@
1
- import { n as HudApiError } from "./plugins-DVy_vaYr.js";
1
+ import { n as HudApiError } from "./plugins-CcW_K7c2.js";
2
2
  import { useCallback, useSyncExternalStore } from "react";
3
3
  //#region src/plugins/ops/poll.ts
4
4
  /** Entries per plugin context, so the pill and the panel share one poller per path. */
@@ -0,0 +1,36 @@
1
+ //#region src/server/same-origin.ts
2
+ /** The host the browser asked for: a proxy in front of the dev server forwards its own. */
3
+ function requestHosts(request) {
4
+ const named = [request.headers.get("x-forwarded-host"), request.headers.get("host")].flatMap((host) => host ? [host.toLowerCase()] : []);
5
+ return named.length > 0 ? named : [new URL(request.url).host];
6
+ }
7
+ function fromOwnHost(request, origin) {
8
+ try {
9
+ return requestHosts(request).includes(new URL(origin).host);
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ /**
15
+ * Refuses a state-changing request from another origin. A page elsewhere must
16
+ * not be able to write through the developer's browser: a JSON content type
17
+ * forces a CORS preflight that HUD routes never answer, and `Sec-Fetch-Site`
18
+ * rejects cross-site requests outright where the browser sends it. It does
19
+ * not on plain http to another machine (a phone on `http://<lan ip>:3000`);
20
+ * there the `Origin` has to name the host the request went to.
21
+ */
22
+ function refuseCrossSite(request) {
23
+ const site = request.headers.get("sec-fetch-site");
24
+ const origin = request.headers.get("origin");
25
+ if (site ? site !== "same-origin" && site !== "none" : origin !== null && !fromOwnHost(request, origin)) return Response.json({
26
+ ok: false,
27
+ error: "cross-site request refused"
28
+ }, { status: 403 });
29
+ if (!request.headers.get("content-type")?.toLowerCase().startsWith("application/json")) return Response.json({
30
+ ok: false,
31
+ error: "expected application/json"
32
+ }, { status: 415 });
33
+ return null;
34
+ }
35
+ //#endregion
36
+ export { refuseCrossSite as t };
@@ -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, useEffect, useSyncExternalStore } from "react";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  //#region src/plugins/seo/pill.ts
@@ -519,7 +520,7 @@ function useSeo() {
519
520
  }
520
521
  //#endregion
521
522
  //#region src/plugins/seo/index.tsx
522
- const SeoPanel = lazy(() => import("./seo-panel-CfiY-TnT.js"));
523
+ const SeoPanel = lazy(() => import("./seo-panel-BThx56KM.js"));
523
524
  /**
524
525
  * Checks the page's title, description, canonical, Open Graph, JSON-LD,
525
526
  * hreflang and robots meta, from mount on and again whenever `<head>` changes.
@@ -535,9 +536,19 @@ function seo() {
535
536
  "data-rating": rating
536
537
  }), pillText(snapshot)] });
537
538
  }
539
+ function useSeoBadge() {
540
+ const { errors, checkedAt } = useSeo();
541
+ if (checkedAt === null) return null;
542
+ return errors > 0 ? {
543
+ tone: "poor",
544
+ count: errors
545
+ } : { tone: "good" };
546
+ }
538
547
  return definePlugin({
539
548
  id: "seo",
540
549
  title: "SEO",
550
+ icon: hudIcon("search"),
551
+ badge: useSeoBadge,
541
552
  pill: SeoPill,
542
553
  panel: SeoPanel,
543
554
  commands: [{
@@ -1,4 +1,4 @@
1
- import { i as SEO_GROUPS, n as checkSeo, r as useSeo } from "./seo-Dq9q_QkO.js";
1
+ import { i as SEO_GROUPS, n as checkSeo, r as useSeo } from "./seo-BnnGq_vj.js";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  //#region src/plugins/seo/styles.ts
4
4
  /**
package/dist/server.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as HudHttpMethod, d as HudRoutes, l as HudRouteContext, o as HudPlugin, p as definePlugin, u as HudRouteHandler } from "./plugins-BZvDqGx5.js";
2
- import { a as createHudHandler, i as HudRequestHandler, n as HudHandler, o as developmentOnly, r as HudHandlerOptions, t as HudGuard } from "./handler-DtYVCZY6.js";
1
+ import { c as HudPlugin, d as HudRouteContext, f as HudRouteHandler, h as definePlugin, p as HudRoutes, s as HudHttpMethod } from "./plugins-pL2CoWzI.js";
2
+ import { a as createHudHandler, i as HudRequestHandler, n as HudHandler, o as developmentOnly, r as HudHandlerOptions, t as HudGuard } from "./handler-BmFhaA2D.js";
3
3
  export { type HudGuard, type HudHandler, type HudHandlerOptions, type HudHttpMethod, type HudPlugin, type HudRequestHandler, type HudRouteContext, type HudRouteHandler, type HudRoutes, createHudHandler, definePlugin, developmentOnly };
package/dist/server.js CHANGED
@@ -1,3 +1,3 @@
1
- import { i as definePlugin } from "./plugins-DVy_vaYr.js";
2
- import { n as developmentOnly, t as createHudHandler } from "./handler-BpVhxEmU.js";
1
+ import { i as definePlugin } from "./plugins-CcW_K7c2.js";
2
+ import { n as developmentOnly, t as createHudHandler } from "./handler-BKzaOhlJ.js";
3
3
  export { createHudHandler, definePlugin, developmentOnly };
@@ -1,4 +1,4 @@
1
- import { n as HudApiError } from "./plugins-DVy_vaYr.js";
1
+ import { n as HudApiError } from "./plugins-CcW_K7c2.js";
2
2
  import { t as AGENT_CSS } from "./styles-DPpDPmzi.js";
3
3
  import { useCallback, useEffect, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
package/dist/store.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { d as HudRoutes, r as HudCapability } from "./plugins-BZvDqGx5.js";
1
+ import { a as HudCapability, p as HudRoutes } from "./plugins-pL2CoWzI.js";
2
2
  import { a as STORE_COLLECTION, c as assertId, i as HudStoreValue, l as assertValue, n as HudStoreEntry, o as STORE_ID, r as HudStoreError, s as assertCollection, t as HudStore, u as isStoreValue } from "./types-DaJcsEjO.js";
3
3
  //#region src/store/file.d.ts
4
4
  interface FileStoreOptions {
package/dist/store.js CHANGED
@@ -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
  import { a as assertId, i as assertCollection, n as STORE_COLLECTION, o as assertValue, r as STORE_ID, s as isStoreValue, t as HudStoreError } from "./types-BIkI-qN8.js";
4
4
  import { t as file } from "./file-xdSaQ2uR.js";
5
5
  //#region src/store/http.ts
@@ -1,3 +1,8 @@
1
+ //#region src/plugins/routes/meta.d.ts
2
+ /** Shared by both halves, so client and server gate on the same capability. */
3
+ declare const ROUTES_ID = "routes";
4
+ declare const ROUTES_CAPABILITY = "routes.read";
5
+ //#endregion
1
6
  //#region src/plugins/routes/types.d.ts
2
7
  /** One dynamic segment of a route pattern. */
3
8
  interface RouteSegment {
@@ -41,9 +46,4 @@ interface RoutesResponse {
41
46
  routes: RouteEntry[];
42
47
  }
43
48
  //#endregion
44
- //#region src/plugins/routes/meta.d.ts
45
- /** Shared by both halves, so client and server gate on the same capability. */
46
- declare const ROUTES_ID = "routes";
47
- declare const ROUTES_CAPABILITY = "routes.read";
48
- //#endregion
49
- export { RouteUrl as a, RouteSegment as i, ROUTES_ID as n, RoutesResponse as o, RouteEntry as r, ROUTES_CAPABILITY as t };
49
+ export { ROUTES_CAPABILITY as a, RoutesResponse as i, RouteSegment as n, ROUTES_ID as o, RouteUrl as r, RouteEntry as t };
@@ -1,4 +1,4 @@
1
- import { n as HudApiError } from "./plugins-DVy_vaYr.js";
1
+ import { n as HudApiError } from "./plugins-CcW_K7c2.js";
2
2
  import { n as hudRequiresUnlock, o as resolveHudAccess } from "./access-C7zlaqj6.js";
3
3
  import { c as toHudEnv } from "./capabilities-rDSKjXpq.js";
4
4
  import { useEffect, useSyncExternalStore } from "react";