@hansenexus/hud 0.3.0 → 0.5.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 (172) hide show
  1. package/README.md +782 -6
  2. package/dist/a11y-B5DUaiCs.js +246 -0
  3. package/dist/a11y-panel-p_t4eD7p.js +207 -0
  4. package/dist/access-C7zlaqj6.js +100 -0
  5. package/dist/access-D_ewAEJG.d.ts +61 -0
  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-CApnbI0r.d.ts +19 -0
  26. package/dist/env-CaiFPIhF.js +31 -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-BaqWsmrf.js +153 -0
  32. package/dist/force-state-CCqoTfVB.d.ts +23 -0
  33. package/dist/force-state-panel-_otVYh9i.js +97 -0
  34. package/dist/generate-C8lQl3Eh.js +53 -0
  35. package/dist/handler-BpVhxEmU.js +106 -0
  36. package/dist/handler-DtYVCZY6.d.ts +39 -0
  37. package/dist/index-BAV_1W8a.d.ts +43 -0
  38. package/dist/index-BJ26pse9.d.ts +70 -0
  39. package/dist/index-BnQ0dTZf.d.ts +19 -0
  40. package/dist/index-CwfX-W87.d.ts +72 -0
  41. package/dist/index-DcH9V3cU.d.ts +48 -0
  42. package/dist/index-DqOyNf1u.d.ts +65 -0
  43. package/dist/index-DstI_ike.d.ts +66 -0
  44. package/dist/index-Dxz4fn4j.d.ts +42 -0
  45. package/dist/index-Hhh7OXzU.d.ts +129 -0
  46. package/dist/index-ReFbhQ9p.d.ts +25 -0
  47. package/dist/index-RgXfMBuW.d.ts +48 -0
  48. package/dist/index-gCZBO53s.d.ts +73 -0
  49. package/dist/index.d.ts +6 -36
  50. package/dist/index.js +798 -240
  51. package/dist/inspect-C9Ft8fqn.js +142 -0
  52. package/dist/inspect-root-BkaupBMp.js +429 -0
  53. package/dist/marker-C66LxOhJ.d.ts +9 -0
  54. package/dist/marker-CMrvxPmS.d.ts +12 -0
  55. package/dist/marker-DjeGvL-F.js +9 -0
  56. package/dist/marker-uZYPOJ4M.js +12 -0
  57. package/dist/markers.d.ts +3 -0
  58. package/dist/markers.js +3 -0
  59. package/dist/meta-Bv0sEao3.js +6 -0
  60. package/dist/meta-C_G7MB5w.d.ts +49 -0
  61. package/dist/mocks-CA-wM2SB.d.ts +109 -0
  62. package/dist/mocks-ESiRqk9o.js +150 -0
  63. package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
  64. package/dist/next/config.d.ts +52 -0
  65. package/dist/next/config.js +78 -0
  66. package/dist/next.d.ts +14 -19
  67. package/dist/next.js +7 -30
  68. package/dist/observe-CdDnDBRP.js +89 -0
  69. package/dist/observe-panel-Cgp1M8oT.js +347 -0
  70. package/dist/ops-panel-CEqDe_UT.js +234 -0
  71. package/dist/payload-MUQ9ciER.d.ts +92 -0
  72. package/dist/plugins/a11y.d.ts +2 -0
  73. package/dist/plugins/a11y.js +2 -0
  74. package/dist/plugins/access/server.d.ts +122 -0
  75. package/dist/plugins/access/server.js +340 -0
  76. package/dist/plugins/access.d.ts +41 -0
  77. package/dist/plugins/access.js +51 -0
  78. package/dist/plugins/agent/server.d.ts +94 -0
  79. package/dist/plugins/agent/server.js +455 -0
  80. package/dist/plugins/agent.d.ts +37 -0
  81. package/dist/plugins/agent.js +69 -0
  82. package/dist/plugins/capture/server.d.ts +92 -0
  83. package/dist/plugins/capture/server.js +248 -0
  84. package/dist/plugins/capture.d.ts +24 -0
  85. package/dist/plugins/capture.js +70 -0
  86. package/dist/plugins/data/msw-browser.d.ts +2 -0
  87. package/dist/plugins/data/msw-browser.js +39 -0
  88. package/dist/plugins/data/msw-node.d.ts +36 -0
  89. package/dist/plugins/data/msw-node.js +68 -0
  90. package/dist/plugins/data/server.d.ts +257 -0
  91. package/dist/plugins/data/server.js +717 -0
  92. package/dist/plugins/data.d.ts +6 -0
  93. package/dist/plugins/data.js +51 -0
  94. package/dist/plugins/design/server.d.ts +54 -0
  95. package/dist/plugins/design/server.js +198 -0
  96. package/dist/plugins/design.d.ts +5 -0
  97. package/dist/plugins/design.js +4 -0
  98. package/dist/plugins/inspect/convex.d.ts +2 -0
  99. package/dist/plugins/inspect/convex.js +486 -0
  100. package/dist/plugins/inspect/react-query.d.ts +2 -0
  101. package/dist/plugins/inspect/react-query.js +225 -0
  102. package/dist/plugins/inspect/sockets.d.ts +51 -0
  103. package/dist/plugins/inspect/sockets.js +397 -0
  104. package/dist/plugins/inspect/swr.d.ts +2 -0
  105. package/dist/plugins/inspect/swr.js +218 -0
  106. package/dist/plugins/inspect.d.ts +4 -0
  107. package/dist/plugins/inspect.js +3 -0
  108. package/dist/plugins/observe.d.ts +4 -0
  109. package/dist/plugins/observe.js +2 -0
  110. package/dist/plugins/ops/server.d.ts +82 -0
  111. package/dist/plugins/ops/server.js +381 -0
  112. package/dist/plugins/ops.d.ts +27 -0
  113. package/dist/plugins/ops.js +41 -0
  114. package/dist/plugins/routes/server.d.ts +88 -0
  115. package/dist/plugins/routes/server.js +62 -0
  116. package/dist/plugins/routes.d.ts +3 -0
  117. package/dist/plugins/routes.js +216 -0
  118. package/dist/plugins/seo.d.ts +2 -0
  119. package/dist/plugins/seo.js +2 -0
  120. package/dist/plugins/vitals.d.ts +2 -25
  121. package/dist/plugins/vitals.js +4 -86
  122. package/dist/plugins-BZvDqGx5.d.ts +144 -0
  123. package/dist/{plugins-CzUiTn_r.js → plugins-DVy_vaYr.js} +3 -1
  124. package/dist/poll-CjKsWZi8.js +89 -0
  125. package/dist/requests-BwD6MKEq.js +282 -0
  126. package/dist/requests-CJrUf465.d.ts +50 -0
  127. package/dist/review.d.ts +181 -0
  128. package/dist/review.js +1017 -0
  129. package/dist/same-origin-BGet22CC.js +21 -0
  130. package/dist/scan-DzJNXqOk.js +165 -0
  131. package/dist/selector-NSYSe7AZ.js +28 -0
  132. package/dist/seo-Dq9q_QkO.js +551 -0
  133. package/dist/seo-panel-CfiY-TnT.js +124 -0
  134. package/dist/server.d.ts +3 -39
  135. package/dist/server.js +2 -105
  136. package/dist/sessions-panel-COvhPAzv.js +98 -0
  137. package/dist/shortcut-s_mjGeU8.js +179 -0
  138. package/dist/state-CjjZPjPJ.js +40 -0
  139. package/dist/state-boundary.d.ts +26 -0
  140. package/dist/state-boundary.js +61 -0
  141. package/dist/store/convex.d.ts +33 -0
  142. package/dist/store/convex.js +52 -0
  143. package/dist/store-CQqIIKTc.js +59 -0
  144. package/dist/store-Ync9eb1G.js +67 -0
  145. package/dist/store.d.ts +76 -0
  146. package/dist/store.js +188 -0
  147. package/dist/styles-BA8ueHoV.js +342 -0
  148. package/dist/styles-DKU_P8MH.js +139 -0
  149. package/dist/styles-DPpDPmzi.js +68 -0
  150. package/dist/tokens-panel-CbMQfasZ.js +142 -0
  151. package/dist/types-B-ulf2Jp.js +8 -0
  152. package/dist/types-BIgGf-0C.d.ts +25 -0
  153. package/dist/types-BIkI-qN8.js +30 -0
  154. package/dist/types-Cxh4twqc.d.ts +50 -0
  155. package/dist/types-DIdPfjtV.js +6 -0
  156. package/dist/types-DaJcsEjO.d.ts +44 -0
  157. package/dist/types-Dn68psVz.d.ts +118 -0
  158. package/dist/types-f3jlNxzw.d.ts +92 -0
  159. package/dist/types-szkr2QOF.d.ts +39 -0
  160. package/dist/unlock-store-4V3vR4Eg.js +96 -0
  161. package/dist/variant-groups-TIfO3NIj.js +137 -0
  162. package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
  163. package/dist/variants-panel-BDoSkwBJ.js +457 -0
  164. package/dist/variants-types-CcRf119M.d.ts +63 -0
  165. package/dist/variants.d.ts +43 -0
  166. package/dist/variants.js +83 -0
  167. package/dist/vitals-panel-BCmMUntW.js +30 -0
  168. package/dist/vite.d.ts +37 -0
  169. package/dist/vite.js +134 -0
  170. package/package.json +85 -5
  171. package/dist/define-hud-BHQR8Lbv.d.ts +0 -31
  172. package/dist/plugins-1QmTmZyL.d.ts +0 -76
package/dist/server.d.ts CHANGED
@@ -1,39 +1,3 @@
1
- import { a as HudPlugin, c as HudRouteContext, f as definePlugin, i as HudHttpMethod, l as HudRouteHandler, n as HudCapability, u as HudRoutes } from "./plugins-1QmTmZyL.js";
2
- //#region src/server/handler.d.ts
3
- /**
4
- * Decides whether a request may reach a plugin route. Return a `Response` to
5
- * refuse it (404, 401, 403 ...) or `null` to let it through. The `access`
6
- * plugin supplies one for deployed tiers.
7
- */
8
- type HudGuard = (request: Request, capability: HudCapability | undefined) => Response | null | Promise<Response | null>;
9
- interface HudHandlerOptions {
10
- /** Path the catch-all route is mounted at. Default `/api/hud`. */
11
- basePath?: string;
12
- /** Default: `developmentOnly`, which answers 404 unless `NODE_ENV` is `development`. */
13
- guard?: HudGuard;
14
- /** Drops plugins server side, like `defineHud({ can })` does client side. Default: grant all. */
15
- can?: (capability: HudCapability) => boolean;
16
- }
17
- type HudRequestHandler = (request: Request) => Promise<Response>;
18
- /** One function per method, so a Next route can `export const { GET, POST } = createHudHandler(...)`. */
19
- type HudHandler = {
20
- handle: HudRequestHandler;
21
- } & Record<HudHttpMethod, HudRequestHandler>;
22
- /**
23
- * The default guard. Core assumes development, so a deployed build that
24
- * mounts the route without an `access` guard serves nothing and reveals
25
- * nothing about which plugins exist.
26
- */
27
- export declare const developmentOnly: HudGuard;
28
- /**
29
- * Serves every plugin's routes from one catch-all route
30
- * (`app/api/hud/[...hud]/route.ts` in Next). A request to
31
- * `<basePath>/<plugin id>/<path>` reaches that plugin's `routes[path][method]`;
32
- * unknown plugin or path answers 404, a known path with another method 405.
33
- *
34
- * Pass the server halves (`@hansenexus/hud/plugins/<id>/server`): they carry
35
- * `routes` and no React.
36
- */
37
- export declare function createHudHandler(plugins: readonly HudPlugin[], options?: HudHandlerOptions): HudHandler;
38
- //#endregion
39
- export { type HudGuard, type HudHandler, type HudHandlerOptions, type HudHttpMethod, type HudPlugin, type HudRequestHandler, type HudRouteContext, type HudRouteHandler, type HudRoutes, definePlugin };
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";
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,106 +1,3 @@
1
- import { a as resolvePlugins, i as definePlugin, t as HUD_HTTP_METHODS } from "./plugins-CzUiTn_r.js";
2
- //#region src/server/handler.ts
3
- function json(status, body, headers) {
4
- const res = Response.json(body, { status });
5
- if (headers) for (const [key, value] of new Headers(headers)) res.headers.set(key, value);
6
- return res;
7
- }
8
- function notFound() {
9
- return json(404, {
10
- ok: false,
11
- error: "not found"
12
- });
13
- }
14
- /**
15
- * The default guard. Core assumes development, so a deployed build that
16
- * mounts the route without an `access` guard serves nothing and reveals
17
- * nothing about which plugins exist.
18
- */
19
- const developmentOnly = () => {
20
- return (typeof process === "undefined" ? void 0 : process.env.NODE_ENV) === "development" ? null : notFound();
21
- };
22
- function splitPath(path) {
23
- return path.split("/").filter(Boolean);
24
- }
25
- function compile(plugin) {
26
- return Object.entries(plugin.routes ?? {}).map(([path, methods]) => ({
27
- segments: splitPath(path),
28
- methods
29
- }));
30
- }
31
- function match(route, segments) {
32
- if (route.segments.length !== segments.length) return null;
33
- const params = {};
34
- for (const [i, pattern] of route.segments.entries()) {
35
- const segment = segments[i] ?? "";
36
- if (!pattern.startsWith(":")) {
37
- if (pattern !== segment) return null;
38
- continue;
39
- }
40
- try {
41
- params[pattern.slice(1)] = decodeURIComponent(segment);
42
- } catch {
43
- return null;
44
- }
45
- }
46
- return params;
47
- }
48
- function isMethod(method) {
49
- return HUD_HTTP_METHODS.includes(method);
50
- }
51
- /**
52
- * Serves every plugin's routes from one catch-all route
53
- * (`app/api/hud/[...hud]/route.ts` in Next). A request to
54
- * `<basePath>/<plugin id>/<path>` reaches that plugin's `routes[path][method]`;
55
- * unknown plugin or path answers 404, a known path with another method 405.
56
- *
57
- * Pass the server halves (`@hansenexus/hud/plugins/<id>/server`): they carry
58
- * `routes` and no React.
59
- */
60
- function createHudHandler(plugins, options = {}) {
61
- const basePath = splitPath(options.basePath ?? "/api/hud");
62
- const guard = options.guard ?? developmentOnly;
63
- const table = new Map(resolvePlugins(plugins, options.can ?? (() => true)).map((plugin) => [plugin.id, {
64
- plugin,
65
- routes: compile(plugin)
66
- }]));
67
- const handle = async (request) => {
68
- const segments = splitPath(new URL(request.url).pathname);
69
- if (!basePath.every((segment, i) => segments[i] === segment)) return notFound();
70
- const [pluginId, ...rest] = segments.slice(basePath.length);
71
- const entry = pluginId === void 0 ? void 0 : table.get(pluginId);
72
- const refusal = await guard(request, entry?.plugin.capability);
73
- if (refusal) return refusal;
74
- if (!entry) return notFound();
75
- for (const route of entry.routes) {
76
- const params = match(route, rest);
77
- if (!params) continue;
78
- const method = request.method === "HEAD" ? "GET" : request.method;
79
- const fn = isMethod(method) ? route.methods[method] : void 0;
80
- if (!fn) return json(405, {
81
- ok: false,
82
- error: "method not allowed"
83
- }, { allow: HUD_HTTP_METHODS.filter((m) => route.methods[m]).join(", ") });
84
- try {
85
- return await fn(request, { params });
86
- } catch (error) {
87
- console.error(`hud: ${entry.plugin.id} ${request.method} /${rest.join("/")} failed`, error);
88
- return json(500, {
89
- ok: false,
90
- error: "plugin route failed"
91
- });
92
- }
93
- }
94
- return notFound();
95
- };
96
- return {
97
- handle,
98
- GET: handle,
99
- POST: handle,
100
- PUT: handle,
101
- PATCH: handle,
102
- DELETE: handle
103
- };
104
- }
105
- //#endregion
1
+ import { i as definePlugin } from "./plugins-DVy_vaYr.js";
2
+ import { n as developmentOnly, t as createHudHandler } from "./handler-BpVhxEmU.js";
106
3
  export { createHudHandler, definePlugin, developmentOnly };
@@ -0,0 +1,98 @@
1
+ import { n as HudApiError } from "./plugins-DVy_vaYr.js";
2
+ import { t as AGENT_CSS } from "./styles-DPpDPmzi.js";
3
+ import { useCallback, useEffect, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/plugins/agent/sessions-panel.tsx
6
+ function age(iso) {
7
+ if (!iso) return "";
8
+ const seconds = Math.max(0, Math.round((Date.now() - Date.parse(iso)) / 1e3));
9
+ if (seconds < 60) return `${seconds}s`;
10
+ if (seconds < 3600) return `${Math.round(seconds / 60)}m`;
11
+ if (seconds < 86400) return `${Math.round(seconds / 3600)}h`;
12
+ return `${Math.round(seconds / 86400)}d`;
13
+ }
14
+ function SessionRow({ session }) {
15
+ return /* @__PURE__ */ jsxs("li", {
16
+ className: "agent-row agent-mono",
17
+ title: session.detail ?? session.id,
18
+ children: [
19
+ /* @__PURE__ */ jsx("span", {
20
+ className: "agent-badge",
21
+ "data-status": session.status,
22
+ children: session.status
23
+ }),
24
+ /* @__PURE__ */ jsx("span", {
25
+ className: "agent-grow",
26
+ children: session.title
27
+ }),
28
+ /* @__PURE__ */ jsxs("span", {
29
+ className: "agent-muted",
30
+ children: [
31
+ session.provider,
32
+ " ",
33
+ age(session.updatedAt ?? session.startedAt)
34
+ ]
35
+ })
36
+ ]
37
+ });
38
+ }
39
+ function SessionsPanel({ ctx, intervalMs }) {
40
+ const [data, setData] = useState(null);
41
+ const [error, setError] = useState(null);
42
+ const load = useCallback(async () => {
43
+ try {
44
+ setData(await ctx.api("/sessions"));
45
+ setError(null);
46
+ } catch (e) {
47
+ setError(e instanceof HudApiError ? `HTTP ${e.status}` : String(e));
48
+ }
49
+ }, [ctx]);
50
+ useEffect(() => {
51
+ load();
52
+ const timer = setInterval(() => {
53
+ if (!document.hidden) load();
54
+ }, intervalMs);
55
+ return () => clearInterval(timer);
56
+ }, [load, intervalMs]);
57
+ return /* @__PURE__ */ jsxs("div", {
58
+ className: "agent",
59
+ children: [
60
+ /* @__PURE__ */ jsx("style", { children: AGENT_CSS }),
61
+ /* @__PURE__ */ jsxs("div", {
62
+ className: "agent-row",
63
+ children: [/* @__PURE__ */ jsx("span", {
64
+ className: "agent-grow agent-muted",
65
+ children: data ? `${data.sessions.length} sessions` : "Loading…"
66
+ }), /* @__PURE__ */ jsx("button", {
67
+ type: "button",
68
+ className: "agent-btn",
69
+ onClick: () => void load(),
70
+ children: "Refresh"
71
+ })]
72
+ }),
73
+ error && /* @__PURE__ */ jsxs("p", {
74
+ className: "empty",
75
+ children: ["Sessions unavailable: ", error]
76
+ }),
77
+ data?.errors.map((e) => /* @__PURE__ */ jsxs("p", {
78
+ className: "empty",
79
+ children: [
80
+ e.provider,
81
+ ": ",
82
+ e.error
83
+ ]
84
+ }, e.provider)),
85
+ data && data.sessions.length === 0 && /* @__PURE__ */ jsx("p", {
86
+ className: "empty",
87
+ children: "No sessions."
88
+ }),
89
+ data && data.sessions.length > 0 && /* @__PURE__ */ jsx("ul", {
90
+ className: "agent-list",
91
+ "aria-label": "Agent sessions",
92
+ children: data.sessions.map((session) => /* @__PURE__ */ jsx(SessionRow, { session }, `${session.provider}:${session.id}`))
93
+ })
94
+ ]
95
+ });
96
+ }
97
+ //#endregion
98
+ export { SessionsPanel, SessionsPanel as default };
@@ -0,0 +1,179 @@
1
+ import { n as buildAnchorSelector, t as anchorLabelFor } from "./selector-NSYSe7AZ.js";
2
+ //#region src/core/grabber/inspect.ts
3
+ const MAX_OWNERS = 5;
4
+ /** React's internal fiber key on a DOM node: `__reactFiber$<random>`. */
5
+ function fiberOf(el) {
6
+ for (const key of Object.keys(el)) if (key.startsWith("__reactFiber$")) {
7
+ const fiber = el[key];
8
+ return fiber && typeof fiber === "object" ? fiber : null;
9
+ }
10
+ return null;
11
+ }
12
+ /** Display name of a component fiber's type; null for host elements, fragments, providers. */
13
+ function componentName(type) {
14
+ if (typeof type === "function") {
15
+ const fn = type;
16
+ const name = typeof fn.displayName === "string" ? fn.displayName : fn.name;
17
+ return typeof name === "string" && name ? name : null;
18
+ }
19
+ if (type && typeof type === "object") {
20
+ const wrapper = type;
21
+ if (typeof wrapper.displayName === "string" && wrapper.displayName) return wrapper.displayName;
22
+ return componentName(wrapper.render) ?? componentName(wrapper.type);
23
+ }
24
+ return null;
25
+ }
26
+ /** Internal frames between the caller and React: the JSX runtime, React itself, bundler glue. */
27
+ const INTERNAL_FRAME = /react-stack-top-frame|jsx-?dev|jsx-runtime|\/react(-dom)?[./@]|node_modules/;
28
+ /**
29
+ * Turns a frame location such as `http://localhost:5173/src/site.tsx?t=1:12:5`
30
+ * or `webpack-internal:///(app-pages-browser)/./src/hero.tsx:8:3` into
31
+ * `src/site.tsx:12:5`.
32
+ */
33
+ function cleanSourceLocation(location) {
34
+ const match = /^(.*?):(\d+)(?::(\d+))?$/.exec(location.trim());
35
+ if (!match) return location;
36
+ const [, rawPath = "", line, column] = match;
37
+ let path = rawPath.replace(/[?#].*$/, "");
38
+ const bundled = /^webpack-internal:\/\/\/(?:\([^)]*\)\/)?(.*)$/.exec(path);
39
+ const url = /^[a-z][a-z0-9+.-]*:\/\/[^/]*\/(.*)$/i.exec(path);
40
+ path = bundled?.[1] ?? url?.[1] ?? path;
41
+ path = path.replace(/^\.\//, "").replace(/^\/?@fs\//, "/");
42
+ if (!path) path = rawPath;
43
+ return column ? `${path}:${line}:${column}` : `${path}:${line}`;
44
+ }
45
+ /** First non-internal frame of a V8 or SpiderMonkey/JSC stack. */
46
+ function sourceFromStack(stack) {
47
+ for (const line of stack.split("\n").slice(1)) {
48
+ if (INTERNAL_FRAME.test(line)) continue;
49
+ const v8 = /^\s*at (?:.*? \()?(.+?)\)?$/.exec(line);
50
+ const gecko = /@(.+)$/.exec(line);
51
+ const location = v8?.[1] ?? gecko?.[1];
52
+ if (location && /:\d+(:\d+)?$/.test(location)) return cleanSourceLocation(location);
53
+ }
54
+ }
55
+ function sourceOf(fiber) {
56
+ const legacy = fiber._debugSource;
57
+ if (legacy?.fileName && legacy.lineNumber) return cleanSourceLocation(`${legacy.fileName}:${legacy.lineNumber}${legacy.columnNumber ? `:${legacy.columnNumber}` : ""}`);
58
+ const stack = fiber._debugStack?.stack;
59
+ return typeof stack === "string" ? sourceFromStack(stack) : void 0;
60
+ }
61
+ function inspectComponent(el) {
62
+ const host = fiberOf(el);
63
+ if (!host) return null;
64
+ const names = [];
65
+ let source = sourceOf(host);
66
+ for (let fiber = host.return; fiber && names.length <= MAX_OWNERS; fiber = fiber.return) {
67
+ const name = componentName(fiber.type);
68
+ if (!name) continue;
69
+ names.push(name);
70
+ source ??= sourceOf(fiber);
71
+ }
72
+ const [name, ...owners] = names;
73
+ if (!name) return null;
74
+ return source ? {
75
+ name,
76
+ owners,
77
+ source
78
+ } : {
79
+ name,
80
+ owners
81
+ };
82
+ }
83
+ //#endregion
84
+ //#region src/core/grabber/payload.ts
85
+ function pct(part, whole) {
86
+ return whole > 0 ? Number((part / whole * 100).toFixed(1)) : 0;
87
+ }
88
+ function buildGrabAnchor(el) {
89
+ const doc = el.ownerDocument;
90
+ const win = doc.defaultView;
91
+ const width = win?.innerWidth ?? 0;
92
+ const height = win?.innerHeight ?? 0;
93
+ const r = el.getBoundingClientRect();
94
+ return {
95
+ selector: buildAnchorSelector(el, doc.body),
96
+ label: anchorLabelFor(el),
97
+ tag: el.tagName.toLowerCase(),
98
+ rect: {
99
+ x: pct(r.left, width),
100
+ y: pct(r.top, height),
101
+ width: pct(r.width, width),
102
+ height: pct(r.height, height)
103
+ }
104
+ };
105
+ }
106
+ function buildGrabPayload(el, { app }) {
107
+ const win = el.ownerDocument.defaultView;
108
+ return {
109
+ app,
110
+ url: win?.location.href ?? "",
111
+ route: win?.location.pathname ?? "/",
112
+ anchor: buildGrabAnchor(el),
113
+ component: inspectComponent(el),
114
+ viewport: {
115
+ width: win?.innerWidth ?? 0,
116
+ height: win?.innerHeight ?? 0
117
+ },
118
+ grabbedAt: (/* @__PURE__ */ new Date()).toISOString()
119
+ };
120
+ }
121
+ /** The picker's hover label: component and source when React reports them, the tag otherwise. */
122
+ function describeElement(el) {
123
+ const tag = el.tagName.toLowerCase();
124
+ const component = inspectComponent(el);
125
+ if (!component) return tag;
126
+ const file = component.source?.split("/").pop()?.replace(/(:\d+)+$/, "");
127
+ return `<${component.name}> ${tag}${file ? ` · ${file}` : ""}`;
128
+ }
129
+ /**
130
+ * Scores manifest entries against the route and anchor label. Pure token
131
+ * overlap: a hint for the agent, not a resolution. Ported from the old HUD's
132
+ * `grabber/payload.ts`.
133
+ */
134
+ function matchComponentHints(hints, route, label, max = 5) {
135
+ if (!hints?.length) return [];
136
+ const tokens = `${route} ${label}`.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 2);
137
+ if (tokens.length === 0) return hints.slice(0, max);
138
+ return hints.map((hint) => {
139
+ const haystack = `${hint.name} ${hint.path}`.toLowerCase();
140
+ return {
141
+ hint,
142
+ score: tokens.reduce((n, token) => haystack.includes(token) ? n + 1 : n, 0)
143
+ };
144
+ }).filter((h) => h.score > 0).sort((a, b) => b.score - a.score).slice(0, max).map((h) => h.hint);
145
+ }
146
+ //#endregion
147
+ //#region src/shell/commands/shortcut.ts
148
+ function parseShortcut(spec) {
149
+ const parts = spec.toLowerCase().split("+");
150
+ return {
151
+ key: parts.at(-1) ?? "",
152
+ mod: parts.includes("mod"),
153
+ shift: parts.includes("shift"),
154
+ alt: parts.includes("alt")
155
+ };
156
+ }
157
+ function isApplePlatform() {
158
+ return typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.userAgent);
159
+ }
160
+ function matchesShortcut(event, shortcut, apple) {
161
+ if ((apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey) !== shortcut.mod) return false;
162
+ if (event.shiftKey !== shortcut.shift || event.altKey !== shortcut.alt) return false;
163
+ if (event.key.toLowerCase() === shortcut.key) return true;
164
+ if (/^[a-z]$/.test(shortcut.key)) return event.code === `Key${shortcut.key.toUpperCase()}`;
165
+ if (/^\d$/.test(shortcut.key)) return event.code === `Digit${shortcut.key}`;
166
+ return false;
167
+ }
168
+ function formatShortcut(shortcut, apple) {
169
+ const key = shortcut.key.toUpperCase();
170
+ if (apple) return `${shortcut.mod ? "⌘" : ""}${shortcut.alt ? "⌥" : ""}${shortcut.shift ? "⇧" : ""}${key}`;
171
+ return [
172
+ shortcut.mod && "Ctrl",
173
+ shortcut.alt && "Alt",
174
+ shortcut.shift && "Shift",
175
+ key
176
+ ].filter(Boolean).join("+");
177
+ }
178
+ //#endregion
179
+ export { buildGrabPayload as a, parseShortcut as i, isApplePlatform as n, describeElement as o, matchesShortcut as r, matchComponentHints as s, formatShortcut as t };
@@ -0,0 +1,40 @@
1
+ //#region src/plugins/ops/meta.ts
2
+ const OPS_CAPABILITY = "cicd.read";
3
+ //#endregion
4
+ //#region src/plugins/ops/state.ts
5
+ const CI_POLL_MS = 6e4;
6
+ const STATE_LABEL = {
7
+ success: "passing",
8
+ failure: "failing",
9
+ cancelled: "cancelled",
10
+ running: "running",
11
+ queued: "queued",
12
+ neutral: "neutral"
13
+ };
14
+ function stateLabel(state) {
15
+ return state ? STATE_LABEL[state] : "no runs";
16
+ }
17
+ /**
18
+ * Combines the states of one commit's runs: any failure fails it, anything
19
+ * still going keeps it running, and it only passes when something passed.
20
+ */
21
+ function combineStates(states) {
22
+ if (states.length === 0) return null;
23
+ if (states.includes("failure")) return "failure";
24
+ if (states.includes("running")) return "running";
25
+ if (states.includes("queued")) return "queued";
26
+ if (states.includes("cancelled")) return "cancelled";
27
+ return states.includes("success") ? "success" : "neutral";
28
+ }
29
+ /** Maps a state onto the shell's `.dot[data-rating]` colours. */
30
+ function stateRating(state) {
31
+ switch (state) {
32
+ case "success": return "good";
33
+ case "running":
34
+ case "queued": return "needs-improvement";
35
+ case "failure": return "poor";
36
+ default: return;
37
+ }
38
+ }
39
+ //#endregion
40
+ export { OPS_CAPABILITY as a, stateRating as i, combineStates as n, stateLabel as r, CI_POLL_MS as t };
@@ -0,0 +1,26 @@
1
+ import { i as ForcedState } from "./force-state-CCqoTfVB.js";
2
+ import { ReactNode } from "react";
3
+ //#region src/plugins/design/state-boundary.d.ts
4
+ export interface StateBoundaryProps {
5
+ /** Stable, page-unique id; the HUD States panel lists boundaries by it. */
6
+ id: string;
7
+ /** Renders the boundary; `forced` is the state to show instead of the real one, or null. */
8
+ children: (forced: ForcedState | null) => ReactNode;
9
+ }
10
+ /**
11
+ * Registers a loading/empty/error boundary with the HUD States panel
12
+ * (`forceState()` from `@hansenexus/hud/plugins/design`) and `?__state=`.
13
+ * Wrap the part of a page that branches on a query result:
14
+ *
15
+ * ```tsx
16
+ * <StateBoundary id="blog-post">
17
+ * {(forced) => forced === "loading" || post === undefined ? <Skeleton /> : …}
18
+ * </StateBoundary>
19
+ * ```
20
+ *
21
+ * Production-safe to import: outside development it renders `children(null)`
22
+ * and nothing else.
23
+ */
24
+ export declare function StateBoundary({ id, children }: StateBoundaryProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
25
+ //#endregion
26
+ export type { ForcedState };
@@ -0,0 +1,61 @@
1
+ import { a as getForceStateSnapshot, c as subscribeForceState, o as getForceStateStore, s as resolveForcedState } from "./force-state-BaqWsmrf.js";
2
+ import { createContext, useContext, useEffect, useSyncExternalStore } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/plugins/design/state-boundary.tsx
5
+ /**
6
+ * Build-time gate. A literal once the consumer's bundler inlines NODE_ENV, so
7
+ * a production build folds `StateBoundary` to `children(null)` and drops
8
+ * everything below, the store included: no production code path reads
9
+ * `?__state=`.
10
+ */
11
+ const FORCE_STATE_ENABLED = process.env.NODE_ENV === "development";
12
+ /**
13
+ * Registers a loading/empty/error boundary with the HUD States panel
14
+ * (`forceState()` from `@hansenexus/hud/plugins/design`) and `?__state=`.
15
+ * Wrap the part of a page that branches on a query result:
16
+ *
17
+ * ```tsx
18
+ * <StateBoundary id="blog-post">
19
+ * {(forced) => forced === "loading" || post === undefined ? <Skeleton /> : …}
20
+ * </StateBoundary>
21
+ * ```
22
+ *
23
+ * Production-safe to import: outside development it renders `children(null)`
24
+ * and nothing else.
25
+ */
26
+ function StateBoundary({ id, children }) {
27
+ if (!FORCE_STATE_ENABLED) return children(null);
28
+ return /* @__PURE__ */ jsx(DevStateBoundary, {
29
+ id,
30
+ children
31
+ });
32
+ }
33
+ /** The enclosing boundary's id, so the store knows which boundaries are top-level. */
34
+ const ParentBoundary = /* @__PURE__ */ createContext(null);
35
+ const SERVER_SNAPSHOT = {
36
+ boundaries: [],
37
+ overrides: {},
38
+ param: null
39
+ };
40
+ function getServerSnapshot() {
41
+ return SERVER_SNAPSHOT;
42
+ }
43
+ function DevStateBoundary({ id, children }) {
44
+ const parentId = useContext(ParentBoundary);
45
+ const snapshot = useSyncExternalStore(subscribeForceState, getForceStateSnapshot, getServerSnapshot);
46
+ useEffect(() => {
47
+ const store = getForceStateStore();
48
+ store.syncSearch(window.location.search);
49
+ return store.register(id, parentId);
50
+ }, [id, parentId]);
51
+ const forced = resolveForcedState(snapshot, {
52
+ id,
53
+ parentId
54
+ });
55
+ return /* @__PURE__ */ jsx(ParentBoundary.Provider, {
56
+ value: id,
57
+ children: children(forced)
58
+ });
59
+ }
60
+ //#endregion
61
+ export { StateBoundary };
@@ -0,0 +1,33 @@
1
+ import { t as HudStore } from "../types-DaJcsEjO.js";
2
+ import { FunctionReference } from "convex/server";
3
+ //#region src/store/convex.d.ts
4
+ /** The three Convex functions a deployment exposes for the HUD store. */
5
+ export interface ConvexStoreFunctions {
6
+ /** Query `{ collection, id }` → the document or null. Default `hudStore:get`. */
7
+ get?: string;
8
+ /** Mutation `{ collection, id, value }`. Default `hudStore:set`. */
9
+ set?: string;
10
+ /** Query `{ collection }` → `[{ id, value }]`. Default `hudStore:list`. */
11
+ list?: string;
12
+ }
13
+ /** What `convex()` calls on the client; `ConvexClient` fits, so does a test double. */
14
+ export interface ConvexStoreClient {
15
+ query: (reference: FunctionReference<"query">, args: Record<string, unknown>) => Promise<unknown>;
16
+ mutation: (reference: FunctionReference<"mutation">, args: Record<string, unknown>) => Promise<unknown>;
17
+ }
18
+ export interface ConvexStoreOptions {
19
+ /** The deployment URL. Ignored when `client` is given. */
20
+ url?: string;
21
+ /** Function names in the deployment; see `ConvexStoreFunctions` for the contract. */
22
+ functions?: ConvexStoreFunctions;
23
+ /** An existing client, or a test double. */
24
+ client?: ConvexStoreClient;
25
+ }
26
+ /**
27
+ * A store on a Convex deployment, the one adapter in the package that
28
+ * imports `convex` (an optional peer dependency). Function references go by
29
+ * name, so the deployment's `convex/_generated` is not needed here; the
30
+ * names are a contract with that deployment.
31
+ */
32
+ export declare function convex({ url, functions, client }: ConvexStoreOptions): HudStore;
33
+ //#endregion
@@ -0,0 +1,52 @@
1
+ import { a as assertId, i as assertCollection, o as assertValue, s as isStoreValue } from "../types-BIkI-qN8.js";
2
+ import { makeFunctionReference } from "convex/server";
3
+ import { ConvexClient } from "convex/browser";
4
+ //#region src/store/convex.ts
5
+ /**
6
+ * A store on a Convex deployment, the one adapter in the package that
7
+ * imports `convex` (an optional peer dependency). Function references go by
8
+ * name, so the deployment's `convex/_generated` is not needed here; the
9
+ * names are a contract with that deployment.
10
+ */
11
+ function convex({ url, functions = {}, client }) {
12
+ if (!client && !url) throw new Error("hud store: convex() needs a url or a client");
13
+ const fn = {
14
+ get: makeFunctionReference(functions.get ?? "hudStore:get"),
15
+ set: makeFunctionReference(functions.set ?? "hudStore:set"),
16
+ list: makeFunctionReference(functions.list ?? "hudStore:list")
17
+ };
18
+ let instance = client;
19
+ const connection = () => {
20
+ instance ??= new ConvexClient(url ?? "");
21
+ return instance;
22
+ };
23
+ return {
24
+ async get(collection, id) {
25
+ assertCollection(collection);
26
+ assertId(id);
27
+ const value = await connection().query(fn.get, {
28
+ collection,
29
+ id
30
+ });
31
+ return isStoreValue(value) ? value : null;
32
+ },
33
+ async set(collection, id, value) {
34
+ assertCollection(collection);
35
+ assertId(id);
36
+ assertValue(value);
37
+ await connection().mutation(fn.set, {
38
+ collection,
39
+ id,
40
+ value
41
+ });
42
+ },
43
+ async list(collection) {
44
+ assertCollection(collection);
45
+ const entries = await connection().query(fn.list, { collection });
46
+ if (!Array.isArray(entries)) return [];
47
+ return entries.filter((entry) => isStoreValue(entry) && typeof entry.id === "string" && isStoreValue(entry.value));
48
+ }
49
+ };
50
+ }
51
+ //#endregion
52
+ export { convex };