@hansenexus/hud 0.4.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.
- package/README.md +603 -9
- package/dist/a11y-B5DUaiCs.js +246 -0
- package/dist/a11y-panel-p_t4eD7p.js +207 -0
- package/dist/{capabilities-CjulXFQX.js → access-C7zlaqj6.js} +1 -90
- package/dist/{access-CNvJOwKM.d.ts → access-D_ewAEJG.d.ts} +11 -4
- package/dist/access-panel-CEfTr9ZI.js +123 -0
- package/dist/adapter-BYoxPYTI.d.ts +33 -0
- package/dist/adapter-hcwmJtNx.js +65 -0
- package/dist/auto/runtime.d.ts +65 -0
- package/dist/auto/runtime.js +50 -0
- package/dist/auto.d.ts +15 -0
- package/dist/auto.js +33 -0
- package/dist/capabilities-rDSKjXpq.js +110 -0
- package/dist/capture-CwrIwLqi.js +300 -0
- package/dist/capture-buffer-Bbbo6omF.d.ts +35 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +275 -0
- package/dist/data-panel-DhxAmP91.js +817 -0
- package/dist/data-store-ChF1td_P.js +164 -0
- package/dist/define-hud-CHPedaQ5.d.ts +50 -0
- package/dist/design-D0kGgPoP.js +87 -0
- package/dist/detect-BxHZ0pxW.d.ts +25 -0
- package/dist/detect-CHZiSeZs.js +63 -0
- package/dist/dispatch-panel-B-xr_Giy.js +279 -0
- package/dist/{env-vEjyJfPW.d.ts → env-CApnbI0r.d.ts} +2 -0
- package/dist/{env-DfxpPfs9.js → env-CaiFPIhF.js} +3 -0
- package/dist/file-xdSaQ2uR.js +103 -0
- package/dist/flags-DVtaJ8pQ.d.ts +58 -0
- package/dist/flags.d.ts +2 -0
- package/dist/flags.js +82 -0
- package/dist/force-state-panel-_otVYh9i.js +97 -0
- package/dist/generate-C8lQl3Eh.js +53 -0
- package/dist/handler-BpVhxEmU.js +106 -0
- package/dist/{handler-WmE4Lu7l.d.ts → handler-DtYVCZY6.d.ts} +1 -1
- package/dist/index-BAV_1W8a.d.ts +43 -0
- package/dist/index-BJ26pse9.d.ts +70 -0
- package/dist/index-BnQ0dTZf.d.ts +19 -0
- package/dist/index-CwfX-W87.d.ts +72 -0
- package/dist/index-DcH9V3cU.d.ts +48 -0
- package/dist/index-DqOyNf1u.d.ts +65 -0
- package/dist/index-DstI_ike.d.ts +66 -0
- package/dist/index-Dxz4fn4j.d.ts +42 -0
- package/dist/index-Hhh7OXzU.d.ts +129 -0
- package/dist/index-ReFbhQ9p.d.ts +25 -0
- package/dist/index-RgXfMBuW.d.ts +48 -0
- package/dist/{index-BYsdS-7d.d.ts → index-gCZBO53s.d.ts} +21 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +710 -69
- package/dist/inspect-C9Ft8fqn.js +142 -0
- package/dist/inspect-root-BkaupBMp.js +429 -0
- package/dist/meta-Bv0sEao3.js +6 -0
- package/dist/meta-C_G7MB5w.d.ts +49 -0
- package/dist/mocks-CA-wM2SB.d.ts +109 -0
- package/dist/mocks-ESiRqk9o.js +150 -0
- package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
- package/dist/next/config.d.ts +52 -0
- package/dist/next/config.js +78 -0
- package/dist/next.d.ts +14 -4
- package/dist/next.js +5 -3
- package/dist/observe-CdDnDBRP.js +89 -0
- package/dist/observe-panel-Cgp1M8oT.js +347 -0
- package/dist/ops-panel-CEqDe_UT.js +234 -0
- package/dist/{payload-CLKDVZWl.d.ts → payload-MUQ9ciER.d.ts} +25 -1
- package/dist/plugins/a11y.d.ts +2 -0
- package/dist/plugins/a11y.js +2 -0
- package/dist/plugins/access/server.d.ts +5 -5
- package/dist/plugins/access/server.js +4 -3
- package/dist/plugins/access.d.ts +5 -5
- package/dist/plugins/access.js +16 -215
- package/dist/plugins/agent/server.d.ts +3 -38
- package/dist/plugins/agent/server.js +47 -21
- package/dist/plugins/agent.d.ts +4 -4
- package/dist/plugins/agent.js +6 -348
- package/dist/plugins/capture/server.d.ts +92 -0
- package/dist/plugins/capture/server.js +248 -0
- package/dist/plugins/capture.d.ts +24 -0
- package/dist/plugins/capture.js +70 -0
- package/dist/plugins/data/msw-browser.d.ts +2 -0
- package/dist/plugins/data/msw-browser.js +39 -0
- package/dist/plugins/data/msw-node.d.ts +36 -0
- package/dist/plugins/data/msw-node.js +68 -0
- package/dist/plugins/data/server.d.ts +257 -0
- package/dist/plugins/data/server.js +717 -0
- package/dist/plugins/data.d.ts +6 -0
- package/dist/plugins/data.js +51 -0
- package/dist/plugins/design/server.d.ts +54 -0
- package/dist/plugins/design/server.js +198 -0
- package/dist/plugins/design.d.ts +4 -124
- package/dist/plugins/design.js +4 -619
- package/dist/plugins/inspect/convex.d.ts +2 -0
- package/dist/plugins/inspect/convex.js +486 -0
- package/dist/plugins/inspect/react-query.d.ts +2 -0
- package/dist/plugins/inspect/react-query.js +225 -0
- package/dist/plugins/inspect/sockets.d.ts +51 -0
- package/dist/plugins/inspect/sockets.js +397 -0
- package/dist/plugins/inspect/swr.d.ts +2 -0
- package/dist/plugins/inspect/swr.js +218 -0
- package/dist/plugins/inspect.d.ts +4 -0
- package/dist/plugins/inspect.js +3 -0
- package/dist/plugins/observe.d.ts +4 -64
- package/dist/plugins/observe.js +1 -616
- package/dist/plugins/ops/server.d.ts +1 -1
- package/dist/plugins/ops/server.js +2 -1
- package/dist/plugins/ops.d.ts +2 -1
- package/dist/plugins/ops.js +15 -336
- package/dist/plugins/routes/server.d.ts +88 -0
- package/dist/plugins/routes/server.js +62 -0
- package/dist/plugins/routes.d.ts +3 -0
- package/dist/plugins/routes.js +216 -0
- package/dist/plugins/seo.d.ts +2 -0
- package/dist/plugins/seo.js +2 -0
- package/dist/plugins/vitals.d.ts +2 -25
- package/dist/plugins/vitals.js +3 -2
- package/dist/{plugins-CQ_0w1ot.d.ts → plugins-BZvDqGx5.d.ts} +33 -3
- package/dist/poll-CjKsWZi8.js +89 -0
- package/dist/requests-BwD6MKEq.js +282 -0
- package/dist/requests-CJrUf465.d.ts +50 -0
- package/dist/review.js +2 -2
- package/dist/same-origin-BGet22CC.js +21 -0
- package/dist/scan-DzJNXqOk.js +165 -0
- package/dist/seo-Dq9q_QkO.js +551 -0
- package/dist/seo-panel-CfiY-TnT.js +124 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -105
- package/dist/sessions-panel-COvhPAzv.js +98 -0
- package/dist/{shortcut-U6ftVY06.js → shortcut-s_mjGeU8.js} +1 -44
- package/dist/{types-QJUajwWq.js → state-CjjZPjPJ.js} +13 -8
- package/dist/store/convex.d.ts +33 -0
- package/dist/store/convex.js +52 -0
- package/dist/{vitals-panel-Dvc5dnR-.js → store-CQqIIKTc.js} +1 -29
- package/dist/store-Ync9eb1G.js +67 -0
- package/dist/store.d.ts +76 -0
- package/dist/store.js +188 -0
- package/dist/{styles--slk86ZQ.js → styles-BA8ueHoV.js} +13 -3
- package/dist/styles-DKU_P8MH.js +139 -0
- package/dist/styles-DPpDPmzi.js +68 -0
- package/dist/tokens-panel-CbMQfasZ.js +142 -0
- package/dist/types-B-ulf2Jp.js +8 -0
- package/dist/types-BIgGf-0C.d.ts +25 -0
- package/dist/types-BIkI-qN8.js +30 -0
- package/dist/{types-DADBRiGk.d.ts → types-Cxh4twqc.d.ts} +1 -1
- package/dist/types-DIdPfjtV.js +6 -0
- package/dist/types-DaJcsEjO.d.ts +44 -0
- package/dist/types-Dn68psVz.d.ts +118 -0
- package/dist/types-szkr2QOF.d.ts +39 -0
- package/dist/unlock-store-4V3vR4Eg.js +96 -0
- package/dist/variant-groups-TIfO3NIj.js +137 -0
- package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
- package/dist/variants-panel-BDoSkwBJ.js +457 -0
- package/dist/variants-types-CcRf119M.d.ts +63 -0
- package/dist/variants.d.ts +43 -0
- package/dist/variants.js +83 -0
- package/dist/vitals-panel-BCmMUntW.js +30 -0
- package/dist/vite.d.ts +37 -0
- package/dist/vite.js +134 -0
- package/package.json +65 -5
- package/dist/define-hud-BBzsSl8b.d.ts +0 -36
package/dist/server.js
CHANGED
|
@@ -1,106 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 };
|
|
@@ -1,47 +1,4 @@
|
|
|
1
1
|
import { n as buildAnchorSelector, t as anchorLabelFor } from "./selector-NSYSe7AZ.js";
|
|
2
|
-
import { useSyncExternalStore } from "react";
|
|
3
|
-
//#region src/core/grabber/store.ts
|
|
4
|
-
const IDLE = {
|
|
5
|
-
grabbing: false,
|
|
6
|
-
payload: null
|
|
7
|
-
};
|
|
8
|
-
function createGrabber() {
|
|
9
|
-
let state = IDLE;
|
|
10
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
11
|
-
const set = (next) => {
|
|
12
|
-
if (next.grabbing === state.grabbing && next.payload === state.payload) return;
|
|
13
|
-
state = next;
|
|
14
|
-
for (const listener of listeners) listener();
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
start: () => set({
|
|
18
|
-
...state,
|
|
19
|
-
grabbing: true
|
|
20
|
-
}),
|
|
21
|
-
cancel: () => set({
|
|
22
|
-
...state,
|
|
23
|
-
grabbing: false
|
|
24
|
-
}),
|
|
25
|
-
clear: () => set({
|
|
26
|
-
...state,
|
|
27
|
-
payload: null
|
|
28
|
-
}),
|
|
29
|
-
complete: (payload) => set({
|
|
30
|
-
grabbing: false,
|
|
31
|
-
payload
|
|
32
|
-
}),
|
|
33
|
-
getState: () => state,
|
|
34
|
-
subscribe: (listener) => {
|
|
35
|
-
listeners.add(listener);
|
|
36
|
-
return () => listeners.delete(listener);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/** Subscribes a component to a HUD's grab state: `useGrab(ctx.grab)`. */
|
|
41
|
-
function useGrab(grab) {
|
|
42
|
-
return useSyncExternalStore(grab.subscribe, grab.getState, grab.getState);
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
2
|
//#region src/core/grabber/inspect.ts
|
|
46
3
|
const MAX_OWNERS = 5;
|
|
47
4
|
/** React's internal fiber key on a DOM node: `__reactFiber$<random>`. */
|
|
@@ -219,4 +176,4 @@ function formatShortcut(shortcut, apple) {
|
|
|
219
176
|
].filter(Boolean).join("+");
|
|
220
177
|
}
|
|
221
178
|
//#endregion
|
|
222
|
-
export { buildGrabPayload as a,
|
|
179
|
+
export { buildGrabPayload as a, parseShortcut as i, isApplePlatform as n, describeElement as o, matchesShortcut as r, matchComponentHints as s, formatShortcut as t };
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
const OPS_CAPABILITY = "cicd.read";
|
|
3
3
|
//#endregion
|
|
4
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
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Combines the states of one commit's runs: any failure fails it, anything
|
|
7
19
|
* still going keeps it running, and it only passes when something passed.
|
|
@@ -25,11 +37,4 @@ function stateRating(state) {
|
|
|
25
37
|
}
|
|
26
38
|
}
|
|
27
39
|
//#endregion
|
|
28
|
-
|
|
29
|
-
const TELEMETRY_RANGES = [
|
|
30
|
-
"1h",
|
|
31
|
-
"24h",
|
|
32
|
-
"7d"
|
|
33
|
-
];
|
|
34
|
-
//#endregion
|
|
35
|
-
export { OPS_CAPABILITY as i, combineStates as n, stateRating as r, TELEMETRY_RANGES as t };
|
|
40
|
+
export { OPS_CAPABILITY as a, stateRating as i, combineStates as n, stateLabel as r, CI_POLL_MS as t };
|
|
@@ -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 };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { onCLS, onFCP, onINP, onLCP, onTTFB } from "web-vitals";
|
|
4
3
|
//#region src/plugins/vitals/store.ts
|
|
5
4
|
/** Display order: the three Core Web Vitals first, then the diagnostics. */
|
|
@@ -57,31 +56,4 @@ function formatVital(name, value) {
|
|
|
57
56
|
return `${Math.round(value)} ms`;
|
|
58
57
|
}
|
|
59
58
|
//#endregion
|
|
60
|
-
|
|
61
|
-
function VitalsPanel() {
|
|
62
|
-
const vitals = useVitals();
|
|
63
|
-
const rows = VITAL_ORDER.flatMap((name) => {
|
|
64
|
-
const vital = vitals[name];
|
|
65
|
-
return vital ? [vital] : [];
|
|
66
|
-
});
|
|
67
|
-
if (rows.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
68
|
-
className: "empty",
|
|
69
|
-
children: "No metrics yet. LCP reports after the first interaction or tab switch."
|
|
70
|
-
});
|
|
71
|
-
return /* @__PURE__ */ jsx("table", {
|
|
72
|
-
className: "vitals",
|
|
73
|
-
children: /* @__PURE__ */ jsx("tbody", { children: rows.map((vital) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", {
|
|
74
|
-
className: "label",
|
|
75
|
-
children: vital.name
|
|
76
|
-
}), /* @__PURE__ */ jsxs("td", { children: [/* @__PURE__ */ jsx("span", {
|
|
77
|
-
className: "dot",
|
|
78
|
-
"data-rating": vital.rating,
|
|
79
|
-
style: {
|
|
80
|
-
display: "inline-block",
|
|
81
|
-
marginRight: 6
|
|
82
|
-
}
|
|
83
|
-
}), formatVital(vital.name, vital.value)] })] }, vital.name)) })
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { useVitals as i, formatVital as n, startVitals as r, VitalsPanel as t };
|
|
59
|
+
export { useVitals as i, formatVital as n, startVitals as r, VITAL_ORDER as t };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
//#region src/core/grabber/store.ts
|
|
3
|
+
const IDLE = {
|
|
4
|
+
grabbing: false,
|
|
5
|
+
payload: null,
|
|
6
|
+
highlight: null
|
|
7
|
+
};
|
|
8
|
+
function createGrabber() {
|
|
9
|
+
let state = IDLE;
|
|
10
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
11
|
+
const set = (next) => {
|
|
12
|
+
if (next.grabbing === state.grabbing && next.payload === state.payload && next.highlight === state.highlight) return;
|
|
13
|
+
state = next;
|
|
14
|
+
for (const listener of listeners) listener();
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
start: () => set({
|
|
18
|
+
...state,
|
|
19
|
+
grabbing: true,
|
|
20
|
+
highlight: null
|
|
21
|
+
}),
|
|
22
|
+
cancel: () => set({
|
|
23
|
+
...state,
|
|
24
|
+
grabbing: false
|
|
25
|
+
}),
|
|
26
|
+
clear: () => set({
|
|
27
|
+
...state,
|
|
28
|
+
payload: null
|
|
29
|
+
}),
|
|
30
|
+
amend: (patch) => {
|
|
31
|
+
if (state.payload) set({
|
|
32
|
+
...state,
|
|
33
|
+
payload: {
|
|
34
|
+
...state.payload,
|
|
35
|
+
...patch
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
highlight: (element, label = element.tagName.toLowerCase()) => set({
|
|
40
|
+
...state,
|
|
41
|
+
highlight: {
|
|
42
|
+
element,
|
|
43
|
+
label
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
clearHighlight: () => set({
|
|
47
|
+
...state,
|
|
48
|
+
highlight: null
|
|
49
|
+
}),
|
|
50
|
+
complete: (payload) => set({
|
|
51
|
+
...state,
|
|
52
|
+
grabbing: false,
|
|
53
|
+
payload
|
|
54
|
+
}),
|
|
55
|
+
getState: () => state,
|
|
56
|
+
subscribe: (listener) => {
|
|
57
|
+
listeners.add(listener);
|
|
58
|
+
return () => listeners.delete(listener);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Subscribes a component to a HUD's grab state: `useGrab(ctx.grab)`. */
|
|
63
|
+
function useGrab(grab) {
|
|
64
|
+
return useSyncExternalStore(grab.subscribe, grab.getState, grab.getState);
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { useGrab as n, createGrabber as t };
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { d as HudRoutes, r as HudCapability } from "./plugins-BZvDqGx5.js";
|
|
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
|
+
//#region src/store/file.d.ts
|
|
4
|
+
interface FileStoreOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Directory the collections live in. Default `<cwd>/.hud`, the dev
|
|
7
|
+
* server's root, so `.hud/variants.json` sits next to the app and an agent
|
|
8
|
+
* in the same checkout can edit it.
|
|
9
|
+
*/
|
|
10
|
+
dir?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The default store: one JSON file per collection under `.hud/`, keyed by id,
|
|
14
|
+
* so a human or an agent can read and edit it (`.hud/variants.json`:
|
|
15
|
+
* `{ "hero:b": { "score": 8, "rationale": "…", "scoredBy": "claude" } }`).
|
|
16
|
+
*
|
|
17
|
+
* Server side only: the browser reaches it through `storeRoutes()` or a
|
|
18
|
+
* plugin's own routes. The collection name is validated and the resolved
|
|
19
|
+
* path checked against `dir`, so no request can name a file outside it.
|
|
20
|
+
* Writes go to a temporary file and are renamed into place, one at a time
|
|
21
|
+
* per collection.
|
|
22
|
+
*/
|
|
23
|
+
export declare function file({ dir }?: FileStoreOptions): HudStore;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/store/http.d.ts
|
|
26
|
+
interface HttpStoreOptions {
|
|
27
|
+
/** Where `storeRoutes()` is mounted, e.g. `/api/hud/store`. */
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
/** Default: the global `fetch`. */
|
|
30
|
+
fetch?: typeof fetch;
|
|
31
|
+
/** Extra headers on every request, such as a token for a remote store. */
|
|
32
|
+
headers?: HeadersInit;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A store over HTTP, against `storeRoutes()` (or anything speaking the same
|
|
36
|
+
* three routes): `GET <base>/<collection>` lists, `GET <base>/<collection>/<id>`
|
|
37
|
+
* reads (404 reads as null), `PUT <base>/<collection>/<id>` writes a JSON
|
|
38
|
+
* object. Runs in a browser or on a server; it is how a client panel reaches
|
|
39
|
+
* the dev server's `file()`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function http({ baseUrl, fetch: doFetch, headers }: HttpStoreOptions): HudStore;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/store/memory.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* An in-memory store: tests, the playground (where MSW runs the server half
|
|
46
|
+
* in the browser) and anything that may forget on restart. `seed` maps
|
|
47
|
+
* collection to documents by id.
|
|
48
|
+
*/
|
|
49
|
+
export declare function memory(seed?: Record<string, Record<string, HudStoreValue>>): HudStore;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/store/routes.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* The three routes `http()` speaks, over any store. Mount them in a plugin's
|
|
54
|
+
* `routes` (`storeServer()` is the ready-made one) and the browser's
|
|
55
|
+
* `http({ baseUrl })` becomes a view onto the server's `file()`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function storeRoutes(store: HudStore): HudRoutes;
|
|
58
|
+
interface StoreServerOptions {
|
|
59
|
+
store: HudStore;
|
|
60
|
+
/** Plugin id, and therefore the URL segment. Default `store`. */
|
|
61
|
+
id?: string;
|
|
62
|
+
/** Default `data.write`: the deployed-tier matrix never grants it, so a deployed HUD cannot write. */
|
|
63
|
+
capability?: HudCapability;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A plugin that exposes a store over HTTP at `<apiBase>/<id>/…`, for
|
|
67
|
+
* `http({ baseUrl: "<apiBase>/<id>" })` in the browser. Carries `data.write`
|
|
68
|
+
* by default, which `access` denies on every deployed tier.
|
|
69
|
+
*/
|
|
70
|
+
export declare function storeServer({ store, id, capability }: StoreServerOptions): {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly capability: string;
|
|
73
|
+
readonly routes: HudRoutes;
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { type FileStoreOptions, type HttpStoreOptions, type HudStore, type HudStoreEntry, HudStoreError, type HudStoreValue, STORE_COLLECTION, STORE_ID, type StoreServerOptions, assertCollection, assertId, assertValue, isStoreValue };
|