@hansenexus/hud 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +634 -12
- 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.cjs +201 -0
- package/dist/next/config.d.cts +87 -0
- package/dist/next/config.d.ts +64 -0
- package/dist/next/config.js +84 -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 +237 -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 +72 -5
- package/dist/define-hud-BBzsSl8b.d.ts +0 -36
package/dist/plugins/ops.js
CHANGED
|
@@ -1,336 +1,10 @@
|
|
|
1
|
-
import { i as definePlugin
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as definePlugin } from "../plugins-DVy_vaYr.js";
|
|
2
|
+
import { a as OPS_CAPABILITY, i as stateRating, r as stateLabel, t as CI_POLL_MS } from "../state-CjjZPjPJ.js";
|
|
3
|
+
import { t as usePoll } from "../poll-CjKsWZi8.js";
|
|
4
|
+
import { lazy } from "react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
//#region src/plugins/ops/poll.ts
|
|
6
|
-
/** Entries per plugin context, so the pill and the panel share one poller per path. */
|
|
7
|
-
const entries = /* @__PURE__ */ new WeakMap();
|
|
8
|
-
function entryFor(ctx, path) {
|
|
9
|
-
let byPath = entries.get(ctx);
|
|
10
|
-
if (!byPath) {
|
|
11
|
-
byPath = /* @__PURE__ */ new Map();
|
|
12
|
-
entries.set(ctx, byPath);
|
|
13
|
-
}
|
|
14
|
-
let entry = byPath.get(path);
|
|
15
|
-
if (!entry) {
|
|
16
|
-
entry = {
|
|
17
|
-
state: { loading: true },
|
|
18
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
19
|
-
inflight: false
|
|
20
|
-
};
|
|
21
|
-
byPath.set(path, entry);
|
|
22
|
-
}
|
|
23
|
-
return entry;
|
|
24
|
-
}
|
|
25
|
-
/** A readable message for a failed poll; 502 bodies carry the provider's own. */
|
|
26
|
-
function describeError(error) {
|
|
27
|
-
if (error instanceof HudApiError) {
|
|
28
|
-
if (error.status === 404) return "route not mounted: add ops() to createHudHandler";
|
|
29
|
-
const body = error.body;
|
|
30
|
-
if (typeof body?.error === "string") return body.error;
|
|
31
|
-
return `HTTP ${error.status}`;
|
|
32
|
-
}
|
|
33
|
-
return error instanceof Error ? error.message : "request failed";
|
|
34
|
-
}
|
|
35
|
-
function set(entry, state) {
|
|
36
|
-
entry.state = state;
|
|
37
|
-
for (const listener of entry.listeners) listener();
|
|
38
|
-
}
|
|
39
|
-
async function tick(ctx, path, entry, force = false) {
|
|
40
|
-
if (entry.inflight || !force && typeof document !== "undefined" && document.hidden) return;
|
|
41
|
-
entry.inflight = true;
|
|
42
|
-
try {
|
|
43
|
-
set(entry, {
|
|
44
|
-
data: await ctx.api(path),
|
|
45
|
-
loading: false
|
|
46
|
-
});
|
|
47
|
-
} catch (error) {
|
|
48
|
-
set(entry, {
|
|
49
|
-
...entry.state,
|
|
50
|
-
error: describeError(error),
|
|
51
|
-
loading: false
|
|
52
|
-
});
|
|
53
|
-
} finally {
|
|
54
|
-
entry.inflight = false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Polls one of the plugin's routes while anything renders it. Pauses while
|
|
59
|
-
* the tab is hidden; subscribers of the same path share one request.
|
|
60
|
-
*/
|
|
61
|
-
function usePoll(ctx, path, intervalMs) {
|
|
62
|
-
const entry = entryFor(ctx, path);
|
|
63
|
-
const subscribe = useCallback((listener) => {
|
|
64
|
-
entry.listeners.add(listener);
|
|
65
|
-
if (entry.listeners.size === 1) {
|
|
66
|
-
tick(ctx, path, entry);
|
|
67
|
-
entry.timer = setInterval(() => void tick(ctx, path, entry), intervalMs);
|
|
68
|
-
}
|
|
69
|
-
return () => {
|
|
70
|
-
entry.listeners.delete(listener);
|
|
71
|
-
if (entry.listeners.size === 0) clearInterval(entry.timer);
|
|
72
|
-
};
|
|
73
|
-
}, [
|
|
74
|
-
ctx,
|
|
75
|
-
path,
|
|
76
|
-
entry,
|
|
77
|
-
intervalMs
|
|
78
|
-
]);
|
|
79
|
-
const state = useSyncExternalStore(subscribe, () => entry.state, () => entry.state);
|
|
80
|
-
const refresh = useCallback(() => void tick(ctx, path, entry, true), [
|
|
81
|
-
ctx,
|
|
82
|
-
path,
|
|
83
|
-
entry
|
|
84
|
-
]);
|
|
85
|
-
return {
|
|
86
|
-
...state,
|
|
87
|
-
refresh
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/plugins/ops/styles.ts
|
|
92
|
-
/** Panel styles, rendered as a `<style>` inside the panel, so inside the shadow root. */
|
|
93
|
-
const OPS_CSS = `
|
|
94
|
-
.ops { display: grid; gap: 12px; }
|
|
95
|
-
.ops section { display: grid; gap: 6px; }
|
|
96
|
-
.ops h3 {
|
|
97
|
-
margin: 0;
|
|
98
|
-
font-size: 10px;
|
|
99
|
-
font-weight: 600;
|
|
100
|
-
letter-spacing: 0.06em;
|
|
101
|
-
text-transform: uppercase;
|
|
102
|
-
color: var(--hud-fg-muted);
|
|
103
|
-
}
|
|
104
|
-
.ops .head { display: flex; align-items: center; gap: 6px; font-family: var(--hud-mono); }
|
|
105
|
-
.ops .head .branch { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
106
|
-
.ops .warn { color: var(--hud-warn); margin: 0; }
|
|
107
|
-
.ops .muted { color: var(--hud-fg-muted); }
|
|
108
|
-
.ops ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
|
|
109
|
-
.ops li a, .ops li > span {
|
|
110
|
-
display: grid;
|
|
111
|
-
grid-template-columns: 6px minmax(0, 1fr) auto auto;
|
|
112
|
-
align-items: center;
|
|
113
|
-
gap: 8px;
|
|
114
|
-
padding: 3px 4px;
|
|
115
|
-
border-radius: 4px;
|
|
116
|
-
color: inherit;
|
|
117
|
-
text-decoration: none;
|
|
118
|
-
}
|
|
119
|
-
.ops li a:hover { background: var(--hud-bg-subtle); }
|
|
120
|
-
.ops .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
121
|
-
.ops .title small { color: var(--hud-fg-muted); margin-left: 6px; }
|
|
122
|
-
.ops .mono { font-family: var(--hud-mono); color: var(--hud-fg-muted); }
|
|
123
|
-
.ops .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
|
|
124
|
-
.ops .stat { padding: 6px 8px; border: 1px solid var(--hud-border); border-radius: 6px; }
|
|
125
|
-
.ops .stat b { display: block; font-family: var(--hud-mono); font-size: 13px; }
|
|
126
|
-
.ops .stat span { font-size: 10px; color: var(--hud-fg-muted); }
|
|
127
|
-
.ops .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
|
|
128
|
-
.ops .ranges { display: flex; gap: 2px; }
|
|
129
|
-
.ops button.chip { padding: 1px 6px; border-radius: 999px; font-family: var(--hud-mono); }
|
|
130
|
-
.ops button.chip:hover, .ops button.chip[aria-pressed="true"] { background: var(--hud-bg-subtle); }
|
|
131
|
-
`;
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/plugins/ops/ops-panel.tsx
|
|
134
|
-
const CI_POLL_MS = 6e4;
|
|
135
|
-
const TELEMETRY_POLL_MS = 6e4;
|
|
136
|
-
const STATE_LABEL = {
|
|
137
|
-
success: "passing",
|
|
138
|
-
failure: "failing",
|
|
139
|
-
cancelled: "cancelled",
|
|
140
|
-
running: "running",
|
|
141
|
-
queued: "queued",
|
|
142
|
-
neutral: "neutral"
|
|
143
|
-
};
|
|
144
|
-
function stateLabel(state) {
|
|
145
|
-
return state ? STATE_LABEL[state] : "no runs";
|
|
146
|
-
}
|
|
147
|
-
/** `3m`, `5h`, `2d` since `iso`. */
|
|
148
|
-
function age(iso, now = Date.now()) {
|
|
149
|
-
if (!iso) return "";
|
|
150
|
-
const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1e3));
|
|
151
|
-
if (seconds < 60) return `${seconds}s`;
|
|
152
|
-
if (seconds < 3600) return `${Math.round(seconds / 60)}m`;
|
|
153
|
-
if (seconds < 86400) return `${Math.round(seconds / 3600)}h`;
|
|
154
|
-
return `${Math.round(seconds / 86400)}d`;
|
|
155
|
-
}
|
|
156
|
-
function Missing({ name }) {
|
|
157
|
-
return /* @__PURE__ */ jsxs("p", {
|
|
158
|
-
className: "warn",
|
|
159
|
-
children: [
|
|
160
|
-
"Not configured: set ",
|
|
161
|
-
/* @__PURE__ */ jsx("code", { children: name ?? "its env" }),
|
|
162
|
-
" in the app's server env."
|
|
163
|
-
]
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
function RunRow({ run }) {
|
|
167
|
-
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
168
|
-
/* @__PURE__ */ jsx("span", {
|
|
169
|
-
className: "dot",
|
|
170
|
-
"data-rating": stateRating(run.state),
|
|
171
|
-
title: STATE_LABEL[run.state]
|
|
172
|
-
}),
|
|
173
|
-
/* @__PURE__ */ jsxs("span", {
|
|
174
|
-
className: "title",
|
|
175
|
-
title: run.title,
|
|
176
|
-
children: [run.name, /* @__PURE__ */ jsx("small", { children: run.title })]
|
|
177
|
-
}),
|
|
178
|
-
/* @__PURE__ */ jsx("span", {
|
|
179
|
-
className: "mono",
|
|
180
|
-
children: run.sha
|
|
181
|
-
}),
|
|
182
|
-
/* @__PURE__ */ jsx("span", {
|
|
183
|
-
className: "mono",
|
|
184
|
-
children: age(run.startedAt)
|
|
185
|
-
})
|
|
186
|
-
] });
|
|
187
|
-
return /* @__PURE__ */ jsx("li", { children: run.url ? /* @__PURE__ */ jsx("a", {
|
|
188
|
-
href: run.url,
|
|
189
|
-
target: "_blank",
|
|
190
|
-
rel: "noreferrer",
|
|
191
|
-
children: content
|
|
192
|
-
}) : /* @__PURE__ */ jsx("span", { children: content }) });
|
|
193
|
-
}
|
|
194
|
-
function Deployment({ deployment }) {
|
|
195
|
-
if (!deployment) return /* @__PURE__ */ jsx("p", {
|
|
196
|
-
className: "muted",
|
|
197
|
-
children: "Nothing deployed."
|
|
198
|
-
});
|
|
199
|
-
const rows = [
|
|
200
|
-
["Environment", deployment.environment],
|
|
201
|
-
["Image", deployment.image],
|
|
202
|
-
["Sha", deployment.sha],
|
|
203
|
-
["Ready", deployment.ready],
|
|
204
|
-
["Since", deployment.at && `${age(deployment.at)} ago`]
|
|
205
|
-
];
|
|
206
|
-
return /* @__PURE__ */ jsx("table", {
|
|
207
|
-
className: "vitals",
|
|
208
|
-
children: /* @__PURE__ */ jsx("tbody", { children: rows.flatMap(([label, value]) => value ? /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", {
|
|
209
|
-
className: "label",
|
|
210
|
-
children: label
|
|
211
|
-
}), /* @__PURE__ */ jsx("td", { children: value })] }, label) : []) })
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function CiSection({ ctx }) {
|
|
215
|
-
const { data, error, loading, refresh } = usePoll(ctx, "/ci", CI_POLL_MS);
|
|
216
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("section", {
|
|
217
|
-
"aria-label": "CI",
|
|
218
|
-
children: [
|
|
219
|
-
/* @__PURE__ */ jsxs("div", {
|
|
220
|
-
className: "row",
|
|
221
|
-
children: [/* @__PURE__ */ jsxs("h3", { children: ["CI", data ? ` · ${data.repo}` : ""] }), /* @__PURE__ */ jsx("button", {
|
|
222
|
-
type: "button",
|
|
223
|
-
className: "chip",
|
|
224
|
-
onClick: refresh,
|
|
225
|
-
children: "refresh"
|
|
226
|
-
})]
|
|
227
|
-
}),
|
|
228
|
-
loading && /* @__PURE__ */ jsx("p", {
|
|
229
|
-
className: "muted",
|
|
230
|
-
children: "Loading…"
|
|
231
|
-
}),
|
|
232
|
-
error && /* @__PURE__ */ jsx("p", {
|
|
233
|
-
className: "warn",
|
|
234
|
-
children: error
|
|
235
|
-
}),
|
|
236
|
-
data && !data.configured && /* @__PURE__ */ jsx(Missing, { name: data.missing }),
|
|
237
|
-
data?.configured && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
238
|
-
className: "head",
|
|
239
|
-
children: [
|
|
240
|
-
/* @__PURE__ */ jsx("span", {
|
|
241
|
-
className: "dot",
|
|
242
|
-
"data-rating": stateRating(data.state)
|
|
243
|
-
}),
|
|
244
|
-
/* @__PURE__ */ jsx("span", {
|
|
245
|
-
className: "branch",
|
|
246
|
-
children: data.branch ?? "no branch"
|
|
247
|
-
}),
|
|
248
|
-
/* @__PURE__ */ jsxs("span", {
|
|
249
|
-
className: "muted",
|
|
250
|
-
children: [data.branch ? stateLabel(data.state) : "latest runs, all branches", data.sha ? ` @ ${data.sha}` : ""]
|
|
251
|
-
})
|
|
252
|
-
]
|
|
253
|
-
}), data.runs.length > 0 ? /* @__PURE__ */ jsx("ul", { children: data.runs.map((run) => /* @__PURE__ */ jsx(RunRow, { run }, run.id)) }) : /* @__PURE__ */ jsxs("p", {
|
|
254
|
-
className: "muted",
|
|
255
|
-
children: [
|
|
256
|
-
"No runs",
|
|
257
|
-
data.branch ? ` on ${data.branch}` : "",
|
|
258
|
-
"."
|
|
259
|
-
]
|
|
260
|
-
})] })
|
|
261
|
-
]
|
|
262
|
-
}), data && data.deployment !== void 0 && /* @__PURE__ */ jsxs("section", {
|
|
263
|
-
"aria-label": "Deployment",
|
|
264
|
-
children: [/* @__PURE__ */ jsx("h3", { children: "Deployment" }), /* @__PURE__ */ jsx(Deployment, { deployment: data.deployment })]
|
|
265
|
-
})] });
|
|
266
|
-
}
|
|
267
|
-
function formatStat(value, unit) {
|
|
268
|
-
if (value === null) return "–";
|
|
269
|
-
return `${value.toFixed(value < 10 ? 2 : 0)}${unit}`;
|
|
270
|
-
}
|
|
271
|
-
function TelemetrySection({ ctx }) {
|
|
272
|
-
const [range, setRange] = useState("1h");
|
|
273
|
-
const { data, error, loading } = usePoll(ctx, `/telemetry?range=${range}`, TELEMETRY_POLL_MS);
|
|
274
|
-
return /* @__PURE__ */ jsxs("section", {
|
|
275
|
-
"aria-label": "Telemetry",
|
|
276
|
-
children: [
|
|
277
|
-
/* @__PURE__ */ jsxs("div", {
|
|
278
|
-
className: "row",
|
|
279
|
-
children: [/* @__PURE__ */ jsxs("h3", { children: ["Telemetry", data ? ` · ${data.service}` : ""] }), /* @__PURE__ */ jsx("div", {
|
|
280
|
-
className: "ranges",
|
|
281
|
-
children: TELEMETRY_RANGES.map((r) => /* @__PURE__ */ jsx("button", {
|
|
282
|
-
type: "button",
|
|
283
|
-
className: "chip",
|
|
284
|
-
"aria-pressed": r === range,
|
|
285
|
-
onClick: () => setRange(r),
|
|
286
|
-
children: r
|
|
287
|
-
}, r))
|
|
288
|
-
})]
|
|
289
|
-
}),
|
|
290
|
-
loading && !data && /* @__PURE__ */ jsx("p", {
|
|
291
|
-
className: "muted",
|
|
292
|
-
children: "Loading…"
|
|
293
|
-
}),
|
|
294
|
-
error && /* @__PURE__ */ jsx("p", {
|
|
295
|
-
className: "warn",
|
|
296
|
-
children: error
|
|
297
|
-
}),
|
|
298
|
-
data && !data.configured && /* @__PURE__ */ jsx(Missing, { name: data.missing }),
|
|
299
|
-
data?.configured && /* @__PURE__ */ jsxs("div", {
|
|
300
|
-
className: "stats",
|
|
301
|
-
children: [
|
|
302
|
-
/* @__PURE__ */ jsxs("div", {
|
|
303
|
-
className: "stat",
|
|
304
|
-
children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.errorRate, "/s") }), /* @__PURE__ */ jsx("span", { children: "errors" })]
|
|
305
|
-
}),
|
|
306
|
-
/* @__PURE__ */ jsxs("div", {
|
|
307
|
-
className: "stat",
|
|
308
|
-
children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.p95Ms, " ms") }), /* @__PURE__ */ jsx("span", { children: "p95" })]
|
|
309
|
-
}),
|
|
310
|
-
/* @__PURE__ */ jsxs("div", {
|
|
311
|
-
className: "stat",
|
|
312
|
-
children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.requestRate, "/s") }), /* @__PURE__ */ jsx("span", { children: "requests" })]
|
|
313
|
-
})
|
|
314
|
-
]
|
|
315
|
-
})
|
|
316
|
-
]
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
function createOpsPanel({ ci, telemetry }) {
|
|
320
|
-
function OpsPanel({ ctx }) {
|
|
321
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
322
|
-
className: "ops",
|
|
323
|
-
children: [
|
|
324
|
-
/* @__PURE__ */ jsx("style", { children: OPS_CSS }),
|
|
325
|
-
ci && /* @__PURE__ */ jsx(CiSection, { ctx }),
|
|
326
|
-
telemetry && /* @__PURE__ */ jsx(TelemetrySection, { ctx })
|
|
327
|
-
]
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
return OpsPanel;
|
|
331
|
-
}
|
|
332
|
-
//#endregion
|
|
333
6
|
//#region src/plugins/ops/index.tsx
|
|
7
|
+
const Panel = lazy(() => import("../ops-panel-CEqDe_UT.js"));
|
|
334
8
|
function OpsPill({ ctx }) {
|
|
335
9
|
const { data, error } = usePoll(ctx, "/ci", CI_POLL_MS);
|
|
336
10
|
const label = !data && error ? "error" : !data ? "–" : !data.configured ? "off" : stateLabel(data.state);
|
|
@@ -347,15 +21,20 @@ function OpsPill({ ctx }) {
|
|
|
347
21
|
* from env and never sends them to the browser.
|
|
348
22
|
*/
|
|
349
23
|
function ops({ ci = true, telemetry = true } = {}) {
|
|
24
|
+
function OpsPanel({ ctx }) {
|
|
25
|
+
return /* @__PURE__ */ jsx(Panel, {
|
|
26
|
+
ctx,
|
|
27
|
+
ci,
|
|
28
|
+
telemetry
|
|
29
|
+
});
|
|
30
|
+
}
|
|
350
31
|
return definePlugin({
|
|
351
32
|
id: "ops",
|
|
352
33
|
title: "Ops",
|
|
353
34
|
capability: OPS_CAPABILITY,
|
|
354
|
-
panel:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}),
|
|
358
|
-
...ci ? { pill: OpsPill } : {}
|
|
35
|
+
panel: OpsPanel,
|
|
36
|
+
...ci ? { pill: OpsPill } : {},
|
|
37
|
+
pillPriority: 10
|
|
359
38
|
});
|
|
360
39
|
}
|
|
361
40
|
//#endregion
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { a as RouteUrl, i as RouteSegment, n as ROUTES_ID, o as RoutesResponse, r as RouteEntry, t as ROUTES_CAPABILITY } from "../../meta-C_G7MB5w.js";
|
|
2
|
+
//#region src/plugins/routes/scan.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Pure derivation over a Next `app/` tree: folder names to patterns, patterns
|
|
5
|
+
* to URLs. No clock, no randomness; the filesystem comes in through `ScanFs`,
|
|
6
|
+
* so the walk is testable without a disk.
|
|
7
|
+
*/
|
|
8
|
+
/** What the walk needs from the filesystem. `readdir` rejects for a missing directory. */
|
|
9
|
+
interface ScanFs {
|
|
10
|
+
readdir(dir: string): Promise<{
|
|
11
|
+
name: string;
|
|
12
|
+
isDirectory(): boolean;
|
|
13
|
+
isFile(): boolean;
|
|
14
|
+
}[]>;
|
|
15
|
+
}
|
|
16
|
+
interface FixtureContext {
|
|
17
|
+
/** Param name the value is for. */
|
|
18
|
+
param: string;
|
|
19
|
+
/** Folder pattern of the route being resolved. */
|
|
20
|
+
pattern: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Value(s) for a dynamic segment: one string, several (one URL each), or a
|
|
24
|
+
* function returning either, called per route. A catch-all takes `a/b`
|
|
25
|
+
* for several segments. The empty string drops the segment, which is how an
|
|
26
|
+
* `as-needed` default locale or an optional catch-all resolves to the parent.
|
|
27
|
+
*/
|
|
28
|
+
type FixtureValue = string | readonly string[] | ((ctx: FixtureContext) => string | readonly string[] | Promise<string | readonly string[]>);
|
|
29
|
+
/** Fixture values keyed by param name: `{ slug: ["hello", "welt"], locale: "" }`. */
|
|
30
|
+
type RouteFixtures = Record<string, FixtureValue>;
|
|
31
|
+
/**
|
|
32
|
+
* Every concrete URL of a pattern from its fixture values: one per
|
|
33
|
+
* combination, in fixture order. An optional catch-all without a fixture
|
|
34
|
+
* resolves to the parent path; any other segment without one leaves the
|
|
35
|
+
* route unresolved and `urls` empty.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildUrls(pattern: string, values: Record<string, readonly string[]>): {
|
|
38
|
+
urls: RouteUrl[];
|
|
39
|
+
unresolved: string[];
|
|
40
|
+
};
|
|
41
|
+
interface PageFile {
|
|
42
|
+
/** Folder relative to the app dir; `` for the root page. */
|
|
43
|
+
rel: string;
|
|
44
|
+
/** `page.tsx`, `page.jsx`, ... */
|
|
45
|
+
file: string;
|
|
46
|
+
}
|
|
47
|
+
/** Page files under `dir`, sorted by folder. Skips private, parallel and intercepting folders. */
|
|
48
|
+
export declare function findPages(dir: string, fs: ScanFs): Promise<PageFile[]>;
|
|
49
|
+
interface ScanOptions {
|
|
50
|
+
fixtures?: RouteFixtures;
|
|
51
|
+
exclude?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/** Every page under the app directory as a `RouteEntry`, sorted by pattern. */
|
|
54
|
+
export declare function scanRoutes(dir: string, fs: ScanFs, { fixtures, exclude }?: ScanOptions): Promise<RouteEntry[]>;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/plugins/routes/server.d.ts
|
|
57
|
+
export interface RoutesServerOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The Next `app/` directory. Default: `app` or `src/app` under `process.cwd()`,
|
|
60
|
+
* the dev server's root.
|
|
61
|
+
*/
|
|
62
|
+
dir?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Values for dynamic segments, keyed by param name: a string, several
|
|
65
|
+
* strings (one URL each) or a function returning either, called per route.
|
|
66
|
+
* A segment without one leaves its route listed but unresolved.
|
|
67
|
+
*/
|
|
68
|
+
fixtures?: RouteFixtures;
|
|
69
|
+
/** URL paths or folder patterns to drop: exact, or a trailing `*` prefix. */
|
|
70
|
+
exclude?: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Server half of the `routes` plugin: `GET <basePath>/routes/routes` walks
|
|
74
|
+
* the app directory on every request (development only, like every HUD
|
|
75
|
+
* route) and answers the page routes with their fixture-filled URLs. The
|
|
76
|
+
* `hud sweep` CLI reads the same route.
|
|
77
|
+
*/
|
|
78
|
+
export declare function routes(options?: RoutesServerOptions): {
|
|
79
|
+
readonly id: "routes";
|
|
80
|
+
readonly capability: "routes.read";
|
|
81
|
+
readonly routes: {
|
|
82
|
+
"/routes": {
|
|
83
|
+
GET: () => Promise<Response>;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { type FixtureContext, type FixtureValue, ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteFixtures, type RouteSegment, type RouteUrl, type RoutesResponse, type ScanFs };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
|
|
2
|
+
import { n as ROUTES_ID, t as ROUTES_CAPABILITY } from "../../meta-Bv0sEao3.js";
|
|
3
|
+
import { i as scanRoutes, n as findPages, t as buildUrls } from "../../scan-DzJNXqOk.js";
|
|
4
|
+
//#region src/plugins/routes/server.ts
|
|
5
|
+
const NO_STORE = { "cache-control": "no-store" };
|
|
6
|
+
const DEFAULT_DIRS = ["app", "src/app"];
|
|
7
|
+
function currentDir() {
|
|
8
|
+
const proc = globalThis.process;
|
|
9
|
+
return typeof proc?.cwd === "function" ? proc.cwd() : void 0;
|
|
10
|
+
}
|
|
11
|
+
async function nodeFs() {
|
|
12
|
+
try {
|
|
13
|
+
return await import("node:fs/promises");
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function findAppDir(fs, cwd) {
|
|
19
|
+
for (const candidate of DEFAULT_DIRS) try {
|
|
20
|
+
if ((await fs.stat(`${cwd}/${candidate}`)).isDirectory()) return candidate;
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Server half of the `routes` plugin: `GET <basePath>/routes/routes` walks
|
|
25
|
+
* the app directory on every request (development only, like every HUD
|
|
26
|
+
* route) and answers the page routes with their fixture-filled URLs. The
|
|
27
|
+
* `hud sweep` CLI reads the same route.
|
|
28
|
+
*/
|
|
29
|
+
function routes(options = {}) {
|
|
30
|
+
return definePlugin({
|
|
31
|
+
id: ROUTES_ID,
|
|
32
|
+
capability: ROUTES_CAPABILITY,
|
|
33
|
+
routes: { "/routes": { GET: async () => {
|
|
34
|
+
const fs = await nodeFs();
|
|
35
|
+
if (!fs) return Response.json({
|
|
36
|
+
ok: false,
|
|
37
|
+
error: "routes: no filesystem in this runtime"
|
|
38
|
+
}, {
|
|
39
|
+
status: 500,
|
|
40
|
+
headers: NO_STORE
|
|
41
|
+
});
|
|
42
|
+
const cwd = currentDir() ?? ".";
|
|
43
|
+
const dir = options.dir ?? await findAppDir(fs, cwd);
|
|
44
|
+
if (!dir) return Response.json({
|
|
45
|
+
ok: false,
|
|
46
|
+
error: `routes: no ${DEFAULT_DIRS.join(" or ")} under ${cwd}`
|
|
47
|
+
}, {
|
|
48
|
+
status: 500,
|
|
49
|
+
headers: NO_STORE
|
|
50
|
+
});
|
|
51
|
+
const absolute = /^([\\/]|[A-Za-z]:)/.test(dir) ? dir : `${cwd}/${dir}`;
|
|
52
|
+
const body = {
|
|
53
|
+
ok: true,
|
|
54
|
+
dir,
|
|
55
|
+
routes: await scanRoutes(absolute, { readdir: (path) => fs.readdir(path, { withFileTypes: true }) }, options)
|
|
56
|
+
};
|
|
57
|
+
return Response.json(body, { headers: NO_STORE });
|
|
58
|
+
} } }
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ROUTES_CAPABILITY, ROUTES_ID, buildUrls, findPages, routes, scanRoutes };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as RouteUrl, i as RouteSegment, n as ROUTES_ID, o as RoutesResponse, r as RouteEntry, t as ROUTES_CAPABILITY } from "../meta-C_G7MB5w.js";
|
|
2
|
+
import { t as routes } from "../index-BnQ0dTZf.js";
|
|
3
|
+
export { ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteSegment, type RouteUrl, type RoutesResponse, routes };
|