@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
@@ -0,0 +1,347 @@
1
+ import { _ as captureBuffer, v as isError } from "./requests-BwD6MKEq.js";
2
+ import { a as useCapture, i as setView, n as FILTERS, o as useView, r as matches } from "./observe-CdDnDBRP.js";
3
+ import { VitalsPanel } from "./vitals-panel-BCmMUntW.js";
4
+ import { useEffect, useLayoutEffect, useState, version } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/plugins/observe/console-tab.tsx
7
+ function statusLevel(status) {
8
+ if (status === 0 || status >= 500) return "error";
9
+ return status >= 400 ? "warn" : "ok";
10
+ }
11
+ /** Console, fetch and long-task capture, newest first. */
12
+ function ConsoleTab() {
13
+ const entries = useCapture();
14
+ const { filter } = useView();
15
+ const rows = entries.filter((entry) => matches(entry, filter)).slice(-200).reverse();
16
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
17
+ className: "obs-toolbar",
18
+ role: "toolbar",
19
+ "aria-label": "Filter",
20
+ children: [FILTERS.map((f) => /* @__PURE__ */ jsxs("button", {
21
+ type: "button",
22
+ className: "obs-chip",
23
+ "aria-pressed": filter === f,
24
+ onClick: () => setView({ filter: f }),
25
+ children: [f, f !== "all" && /* @__PURE__ */ jsx("span", {
26
+ className: "obs-count",
27
+ children: entries.filter((e) => matches(e, f)).length
28
+ })]
29
+ }, f)), /* @__PURE__ */ jsx("button", {
30
+ type: "button",
31
+ className: "obs-chip obs-clear",
32
+ onClick: () => captureBuffer.clear(),
33
+ children: "clear"
34
+ })]
35
+ }), /* @__PURE__ */ jsx("div", {
36
+ className: "obs-log",
37
+ children: rows.length === 0 ? /* @__PURE__ */ jsx("p", {
38
+ className: "empty",
39
+ children: filter === "all" ? "Nothing captured yet. Console output, requests and long tasks land here." : `No ${filter} captured.`
40
+ }) : rows.map((entry) => /* @__PURE__ */ jsx(EntryRow, { entry }, entry.id))
41
+ })] });
42
+ }
43
+ function EntryRow({ entry }) {
44
+ const time = new Date(entry.ts).toLocaleTimeString(void 0, { hour12: false });
45
+ return /* @__PURE__ */ jsxs("div", {
46
+ className: "obs-row",
47
+ "data-kind": entry.kind,
48
+ children: [
49
+ /* @__PURE__ */ jsx("span", {
50
+ className: "obs-time",
51
+ children: time
52
+ }),
53
+ /* @__PURE__ */ jsx("span", {
54
+ className: "obs-kind",
55
+ "data-kind": entry.kind,
56
+ children: entry.kind
57
+ }),
58
+ /* @__PURE__ */ jsx("span", {
59
+ className: "obs-text",
60
+ title: entry.text,
61
+ children: entry.text
62
+ }),
63
+ entry.status !== void 0 && /* @__PURE__ */ jsx("span", {
64
+ className: "obs-status",
65
+ "data-level": statusLevel(entry.status),
66
+ children: entry.status || "ERR"
67
+ }),
68
+ entry.durationMs !== void 0 && /* @__PURE__ */ jsxs("span", {
69
+ className: "obs-ms",
70
+ children: [entry.durationMs, " ms"]
71
+ })
72
+ ]
73
+ });
74
+ }
75
+ //#endregion
76
+ //#region src/plugins/observe/info-tab.tsx
77
+ /** App, build, browser and user snapshot: what runs here right now. */
78
+ function InfoTab({ app, env, useUser }) {
79
+ const user = useUser();
80
+ const viewport = useViewportLabel();
81
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ /* @__PURE__ */ jsxs(Section, {
83
+ title: "App",
84
+ children: [
85
+ /* @__PURE__ */ jsx(Row, {
86
+ label: "App",
87
+ value: app
88
+ }),
89
+ /* @__PURE__ */ jsx(Row, {
90
+ label: "Origin",
91
+ value: window.location.origin,
92
+ copy: true
93
+ }),
94
+ /* @__PURE__ */ jsx(Row, {
95
+ label: "Path",
96
+ value: window.location.pathname + window.location.search,
97
+ copy: true
98
+ })
99
+ ]
100
+ }),
101
+ /* @__PURE__ */ jsxs(Section, {
102
+ title: "Build",
103
+ children: [/* @__PURE__ */ jsx(Row, {
104
+ label: "React",
105
+ value: version
106
+ }), Object.entries(env).map(([label, value]) => /* @__PURE__ */ jsx(Row, {
107
+ label,
108
+ value: value ?? "not set",
109
+ copy: value !== void 0
110
+ }, label))]
111
+ }),
112
+ user && /* @__PURE__ */ jsxs(Section, {
113
+ title: "User",
114
+ children: [
115
+ user.name !== void 0 && /* @__PURE__ */ jsx(Row, {
116
+ label: "Name",
117
+ value: user.name
118
+ }),
119
+ user.email !== void 0 && /* @__PURE__ */ jsx(Row, {
120
+ label: "Email",
121
+ value: user.email,
122
+ copy: true
123
+ }),
124
+ user.id !== void 0 && /* @__PURE__ */ jsx(Row, {
125
+ label: "ID",
126
+ value: user.id,
127
+ copy: true
128
+ }),
129
+ user.role !== void 0 && /* @__PURE__ */ jsx(Row, {
130
+ label: "Role",
131
+ value: user.role
132
+ }),
133
+ Object.entries(user.extra ?? {}).map(([label, value]) => /* @__PURE__ */ jsx(Row, {
134
+ label,
135
+ value
136
+ }, label))
137
+ ]
138
+ }),
139
+ /* @__PURE__ */ jsxs(Section, {
140
+ title: "Browser",
141
+ children: [
142
+ /* @__PURE__ */ jsx(Row, {
143
+ label: "Viewport",
144
+ value: viewport
145
+ }),
146
+ /* @__PURE__ */ jsx(Row, {
147
+ label: "Language",
148
+ value: navigator.language
149
+ }),
150
+ /* @__PURE__ */ jsx(Row, {
151
+ label: "User agent",
152
+ value: navigator.userAgent,
153
+ copy: true
154
+ })
155
+ ]
156
+ })
157
+ ] });
158
+ }
159
+ function viewportLabel() {
160
+ const dark = window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? false;
161
+ return `${window.innerWidth}×${window.innerHeight} @${window.devicePixelRatio}x · ${dark ? "dark" : "light"}`;
162
+ }
163
+ function useViewportLabel() {
164
+ const [label, setLabel] = useState(viewportLabel);
165
+ useEffect(() => {
166
+ const update = () => setLabel(viewportLabel());
167
+ window.addEventListener("resize", update);
168
+ return () => window.removeEventListener("resize", update);
169
+ }, []);
170
+ return label;
171
+ }
172
+ function Section({ title, children }) {
173
+ return /* @__PURE__ */ jsxs("section", {
174
+ className: "obs-section",
175
+ "aria-label": title,
176
+ children: [/* @__PURE__ */ jsx("h4", {
177
+ className: "obs-heading",
178
+ children: title
179
+ }), /* @__PURE__ */ jsx("dl", {
180
+ className: "obs-info",
181
+ children
182
+ })]
183
+ });
184
+ }
185
+ function Row({ label, value, copy = false }) {
186
+ const [copied, setCopied] = useState(false);
187
+ useEffect(() => {
188
+ if (!copied) return;
189
+ const timer = setTimeout(() => setCopied(false), 1200);
190
+ return () => clearTimeout(timer);
191
+ }, [copied]);
192
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
193
+ title: label,
194
+ children: label
195
+ }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsxs("div", {
196
+ className: "obs-value",
197
+ children: [/* @__PURE__ */ jsx("span", {
198
+ title: value,
199
+ children: value
200
+ }), copy && /* @__PURE__ */ jsx("button", {
201
+ type: "button",
202
+ className: "obs-copy",
203
+ "aria-label": `Copy ${label}`,
204
+ onClick: () => {
205
+ navigator.clipboard?.writeText(value).then(() => setCopied(true), () => {});
206
+ },
207
+ children: copied ? "copied" : "copy"
208
+ })]
209
+ }) })] });
210
+ }
211
+ //#endregion
212
+ //#region src/plugins/observe/styles.ts
213
+ /**
214
+ * The observe panel's styles. The panel renders them in its own `<style>`,
215
+ * which still sits inside the HUD's shadow root, so they ship only with this
216
+ * plugin and build on the shell's `--hud-*` tokens.
217
+ */
218
+ const OBSERVE_CSS = `
219
+ /* Fixed width, so switching tabs does not resize the floating panel. */
220
+ .obs { display: flex; flex-direction: column; gap: 8px; width: 396px; max-width: 100%; }
221
+
222
+ .obs-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hud-border); }
223
+ .hud .obs-tab {
224
+ padding: 3px 10px 5px;
225
+ margin-bottom: -1px;
226
+ border-bottom: 2px solid transparent;
227
+ color: var(--hud-fg-muted);
228
+ }
229
+ .hud .obs-tab[aria-selected="true"] { border-bottom-color: var(--hud-accent); color: var(--hud-fg); font-weight: 600; }
230
+
231
+ .obs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
232
+ .hud .obs-chip {
233
+ padding: 1px 7px;
234
+ border-radius: 999px;
235
+ font-family: var(--hud-mono);
236
+ font-size: 11px;
237
+ color: var(--hud-fg-muted);
238
+ }
239
+ .hud .obs-chip:hover { background: var(--hud-bg-subtle); }
240
+ .hud .obs-chip[aria-pressed="true"] { background: var(--hud-bg-subtle); color: var(--hud-fg); }
241
+ .obs-chip .obs-count { margin-left: 4px; opacity: 0.6; }
242
+ .hud .obs-clear { margin-left: auto; }
243
+
244
+ .obs-log {
245
+ max-height: 320px;
246
+ overflow: auto;
247
+ border: 1px solid var(--hud-border);
248
+ border-radius: 4px;
249
+ font-family: var(--hud-mono);
250
+ font-size: 11px;
251
+ }
252
+ .obs-row { display: flex; align-items: baseline; gap: 8px; padding: 2px 6px; }
253
+ .obs-row:hover { background: var(--hud-bg-subtle); }
254
+ .obs-row + .obs-row { border-top: 1px solid var(--hud-border); }
255
+ .obs-time, .obs-ms { flex-shrink: 0; color: var(--hud-fg-muted); }
256
+ .obs-kind { flex-shrink: 0; width: 56px; text-transform: uppercase; color: var(--hud-fg-muted); }
257
+ .obs-kind[data-kind="warn"] { color: var(--hud-warn); }
258
+ .obs-kind[data-kind="error"] { color: var(--hud-poor); }
259
+ .obs-kind[data-kind="fetch"], .obs-kind[data-kind="xhr"] { color: var(--hud-accent); }
260
+ .obs-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
261
+ .obs-status { flex-shrink: 0; color: var(--hud-good); }
262
+ .obs-status[data-level="warn"] { color: var(--hud-warn); }
263
+ .obs-status[data-level="error"] { color: var(--hud-poor); }
264
+ .obs-log .empty { margin: 0; padding: 6px; font-family: var(--hud-font); }
265
+
266
+ .obs-section + .obs-section { margin-top: 10px; }
267
+ .obs-heading {
268
+ margin: 0 0 4px;
269
+ font-size: 10px;
270
+ font-weight: 600;
271
+ letter-spacing: 0.06em;
272
+ text-transform: uppercase;
273
+ color: var(--hud-fg-muted);
274
+ }
275
+ .obs-info {
276
+ display: grid;
277
+ grid-template-columns: 88px minmax(0, 1fr);
278
+ gap: 2px 12px;
279
+ margin: 0;
280
+ }
281
+ .obs-info dt { color: var(--hud-fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
282
+ .obs-info dd { margin: 0; min-width: 0; font-family: var(--hud-mono); }
283
+ .obs-value { display: flex; align-items: center; gap: 6px; }
284
+ .obs-value span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
285
+ .hud .obs-copy { flex-shrink: 0; padding: 0 4px; border-radius: 4px; font-size: 10px; color: var(--hud-fg-muted); }
286
+ .hud .obs-copy:hover { background: var(--hud-bg-subtle); color: var(--hud-fg); }
287
+ `;
288
+ //#endregion
289
+ //#region src/plugins/observe/observe-panel.tsx
290
+ const TABS = [
291
+ {
292
+ id: "console",
293
+ label: "Console"
294
+ },
295
+ {
296
+ id: "info",
297
+ label: "Info"
298
+ },
299
+ {
300
+ id: "vitals",
301
+ label: "Vitals"
302
+ }
303
+ ];
304
+ /** The observe panel: console, info and vitals tabs. Loaded on first open. */
305
+ function ObservePanel({ ctx, env, useUser }) {
306
+ const { tab } = useView();
307
+ useLayoutEffect(() => {
308
+ if (captureBuffer.getSnapshot().some(isError)) setView({
309
+ tab: "console",
310
+ filter: "errors"
311
+ });
312
+ }, []);
313
+ return /* @__PURE__ */ jsxs("div", {
314
+ className: "obs",
315
+ children: [
316
+ /* @__PURE__ */ jsx("style", { children: OBSERVE_CSS }),
317
+ /* @__PURE__ */ jsx("div", {
318
+ className: "obs-tabs",
319
+ role: "tablist",
320
+ "aria-label": "Observe",
321
+ children: TABS.map(({ id, label }) => /* @__PURE__ */ jsx("button", {
322
+ type: "button",
323
+ role: "tab",
324
+ className: "obs-tab",
325
+ "aria-selected": tab === id,
326
+ onClick: () => setView({ tab: id }),
327
+ children: label
328
+ }, id))
329
+ }),
330
+ /* @__PURE__ */ jsxs("div", {
331
+ role: "tabpanel",
332
+ "aria-label": TABS.find((t) => t.id === tab)?.label,
333
+ children: [
334
+ tab === "console" && /* @__PURE__ */ jsx(ConsoleTab, {}),
335
+ tab === "info" && /* @__PURE__ */ jsx(InfoTab, {
336
+ app: ctx.app,
337
+ env,
338
+ useUser
339
+ }),
340
+ tab === "vitals" && /* @__PURE__ */ jsx(VitalsPanel, {})
341
+ ]
342
+ })
343
+ ]
344
+ });
345
+ }
346
+ //#endregion
347
+ export { ObservePanel as default };
@@ -0,0 +1,234 @@
1
+ import { i as stateRating, r as stateLabel, t as CI_POLL_MS } from "./state-CjjZPjPJ.js";
2
+ import { t as usePoll } from "./poll-CjKsWZi8.js";
3
+ import { t as TELEMETRY_RANGES } from "./types-B-ulf2Jp.js";
4
+ import { useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/plugins/ops/styles.ts
7
+ /** Panel styles, rendered as a `<style>` inside the panel, so inside the shadow root. */
8
+ const OPS_CSS = `
9
+ .ops { display: grid; gap: 12px; }
10
+ .ops section { display: grid; gap: 6px; }
11
+ .ops h3 {
12
+ margin: 0;
13
+ font-size: 10px;
14
+ font-weight: 600;
15
+ letter-spacing: 0.06em;
16
+ text-transform: uppercase;
17
+ color: var(--hud-fg-muted);
18
+ }
19
+ .ops .head { display: flex; align-items: center; gap: 6px; font-family: var(--hud-mono); }
20
+ .ops .head .branch { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
21
+ .ops .warn { color: var(--hud-warn); margin: 0; }
22
+ .ops .muted { color: var(--hud-fg-muted); }
23
+ .ops ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
24
+ .ops li a, .ops li > span {
25
+ display: grid;
26
+ grid-template-columns: 6px minmax(0, 1fr) auto auto;
27
+ align-items: center;
28
+ gap: 8px;
29
+ padding: 3px 4px;
30
+ border-radius: 4px;
31
+ color: inherit;
32
+ text-decoration: none;
33
+ }
34
+ .ops li a:hover { background: var(--hud-bg-subtle); }
35
+ .ops .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
36
+ .ops .title small { color: var(--hud-fg-muted); margin-left: 6px; }
37
+ .ops .mono { font-family: var(--hud-mono); color: var(--hud-fg-muted); }
38
+ .ops .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
39
+ .ops .stat { padding: 6px 8px; border: 1px solid var(--hud-border); border-radius: 6px; }
40
+ .ops .stat b { display: block; font-family: var(--hud-mono); font-size: 13px; }
41
+ .ops .stat span { font-size: 10px; color: var(--hud-fg-muted); }
42
+ .ops .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
43
+ .ops .ranges { display: flex; gap: 2px; }
44
+ .ops button.chip { padding: 1px 6px; border-radius: 999px; font-family: var(--hud-mono); }
45
+ .ops button.chip:hover, .ops button.chip[aria-pressed="true"] { background: var(--hud-bg-subtle); }
46
+ `;
47
+ //#endregion
48
+ //#region src/plugins/ops/ops-panel.tsx
49
+ const TELEMETRY_POLL_MS = 6e4;
50
+ /** `3m`, `5h`, `2d` since `iso`. */
51
+ function age(iso, now = Date.now()) {
52
+ if (!iso) return "";
53
+ const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1e3));
54
+ if (seconds < 60) return `${seconds}s`;
55
+ if (seconds < 3600) return `${Math.round(seconds / 60)}m`;
56
+ if (seconds < 86400) return `${Math.round(seconds / 3600)}h`;
57
+ return `${Math.round(seconds / 86400)}d`;
58
+ }
59
+ function Missing({ name }) {
60
+ return /* @__PURE__ */ jsxs("p", {
61
+ className: "warn",
62
+ children: [
63
+ "Not configured: set ",
64
+ /* @__PURE__ */ jsx("code", { children: name ?? "its env" }),
65
+ " in the app's server env."
66
+ ]
67
+ });
68
+ }
69
+ function RunRow({ run }) {
70
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
71
+ /* @__PURE__ */ jsx("span", {
72
+ className: "dot",
73
+ "data-rating": stateRating(run.state),
74
+ title: stateLabel(run.state)
75
+ }),
76
+ /* @__PURE__ */ jsxs("span", {
77
+ className: "title",
78
+ title: run.title,
79
+ children: [run.name, /* @__PURE__ */ jsx("small", { children: run.title })]
80
+ }),
81
+ /* @__PURE__ */ jsx("span", {
82
+ className: "mono",
83
+ children: run.sha
84
+ }),
85
+ /* @__PURE__ */ jsx("span", {
86
+ className: "mono",
87
+ children: age(run.startedAt)
88
+ })
89
+ ] });
90
+ return /* @__PURE__ */ jsx("li", { children: run.url ? /* @__PURE__ */ jsx("a", {
91
+ href: run.url,
92
+ target: "_blank",
93
+ rel: "noreferrer",
94
+ children: content
95
+ }) : /* @__PURE__ */ jsx("span", { children: content }) });
96
+ }
97
+ function Deployment({ deployment }) {
98
+ if (!deployment) return /* @__PURE__ */ jsx("p", {
99
+ className: "muted",
100
+ children: "Nothing deployed."
101
+ });
102
+ const rows = [
103
+ ["Environment", deployment.environment],
104
+ ["Image", deployment.image],
105
+ ["Sha", deployment.sha],
106
+ ["Ready", deployment.ready],
107
+ ["Since", deployment.at && `${age(deployment.at)} ago`]
108
+ ];
109
+ return /* @__PURE__ */ jsx("table", {
110
+ className: "vitals",
111
+ children: /* @__PURE__ */ jsx("tbody", { children: rows.flatMap(([label, value]) => value ? /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", {
112
+ className: "label",
113
+ children: label
114
+ }), /* @__PURE__ */ jsx("td", { children: value })] }, label) : []) })
115
+ });
116
+ }
117
+ function CiSection({ ctx }) {
118
+ const { data, error, loading, refresh } = usePoll(ctx, "/ci", CI_POLL_MS);
119
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("section", {
120
+ "aria-label": "CI",
121
+ children: [
122
+ /* @__PURE__ */ jsxs("div", {
123
+ className: "row",
124
+ children: [/* @__PURE__ */ jsxs("h3", { children: ["CI", data ? ` · ${data.repo}` : ""] }), /* @__PURE__ */ jsx("button", {
125
+ type: "button",
126
+ className: "chip",
127
+ onClick: refresh,
128
+ children: "refresh"
129
+ })]
130
+ }),
131
+ loading && /* @__PURE__ */ jsx("p", {
132
+ className: "muted",
133
+ children: "Loading…"
134
+ }),
135
+ error && /* @__PURE__ */ jsx("p", {
136
+ className: "warn",
137
+ children: error
138
+ }),
139
+ data && !data.configured && /* @__PURE__ */ jsx(Missing, { name: data.missing }),
140
+ data?.configured && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
141
+ className: "head",
142
+ children: [
143
+ /* @__PURE__ */ jsx("span", {
144
+ className: "dot",
145
+ "data-rating": stateRating(data.state)
146
+ }),
147
+ /* @__PURE__ */ jsx("span", {
148
+ className: "branch",
149
+ children: data.branch ?? "no branch"
150
+ }),
151
+ /* @__PURE__ */ jsxs("span", {
152
+ className: "muted",
153
+ children: [data.branch ? stateLabel(data.state) : "latest runs, all branches", data.sha ? ` @ ${data.sha}` : ""]
154
+ })
155
+ ]
156
+ }), data.runs.length > 0 ? /* @__PURE__ */ jsx("ul", { children: data.runs.map((run) => /* @__PURE__ */ jsx(RunRow, { run }, run.id)) }) : /* @__PURE__ */ jsxs("p", {
157
+ className: "muted",
158
+ children: [
159
+ "No runs",
160
+ data.branch ? ` on ${data.branch}` : "",
161
+ "."
162
+ ]
163
+ })] })
164
+ ]
165
+ }), data && data.deployment !== void 0 && /* @__PURE__ */ jsxs("section", {
166
+ "aria-label": "Deployment",
167
+ children: [/* @__PURE__ */ jsx("h3", { children: "Deployment" }), /* @__PURE__ */ jsx(Deployment, { deployment: data.deployment })]
168
+ })] });
169
+ }
170
+ function formatStat(value, unit) {
171
+ if (value === null) return "–";
172
+ return `${value.toFixed(value < 10 ? 2 : 0)}${unit}`;
173
+ }
174
+ function TelemetrySection({ ctx }) {
175
+ const [range, setRange] = useState("1h");
176
+ const { data, error, loading } = usePoll(ctx, `/telemetry?range=${range}`, TELEMETRY_POLL_MS);
177
+ return /* @__PURE__ */ jsxs("section", {
178
+ "aria-label": "Telemetry",
179
+ children: [
180
+ /* @__PURE__ */ jsxs("div", {
181
+ className: "row",
182
+ children: [/* @__PURE__ */ jsxs("h3", { children: ["Telemetry", data ? ` · ${data.service}` : ""] }), /* @__PURE__ */ jsx("div", {
183
+ className: "ranges",
184
+ children: TELEMETRY_RANGES.map((r) => /* @__PURE__ */ jsx("button", {
185
+ type: "button",
186
+ className: "chip",
187
+ "aria-pressed": r === range,
188
+ onClick: () => setRange(r),
189
+ children: r
190
+ }, r))
191
+ })]
192
+ }),
193
+ loading && !data && /* @__PURE__ */ jsx("p", {
194
+ className: "muted",
195
+ children: "Loading…"
196
+ }),
197
+ error && /* @__PURE__ */ jsx("p", {
198
+ className: "warn",
199
+ children: error
200
+ }),
201
+ data && !data.configured && /* @__PURE__ */ jsx(Missing, { name: data.missing }),
202
+ data?.configured && /* @__PURE__ */ jsxs("div", {
203
+ className: "stats",
204
+ children: [
205
+ /* @__PURE__ */ jsxs("div", {
206
+ className: "stat",
207
+ children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.errorRate, "/s") }), /* @__PURE__ */ jsx("span", { children: "errors" })]
208
+ }),
209
+ /* @__PURE__ */ jsxs("div", {
210
+ className: "stat",
211
+ children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.p95Ms, " ms") }), /* @__PURE__ */ jsx("span", { children: "p95" })]
212
+ }),
213
+ /* @__PURE__ */ jsxs("div", {
214
+ className: "stat",
215
+ children: [/* @__PURE__ */ jsx("b", { children: formatStat(data.requestRate, "/s") }), /* @__PURE__ */ jsx("span", { children: "requests" })]
216
+ })
217
+ ]
218
+ })
219
+ ]
220
+ });
221
+ }
222
+ /** The ops panel: CI runs and deployment, telemetry. Loaded on first open. */
223
+ function OpsPanel({ ctx, ci, telemetry }) {
224
+ return /* @__PURE__ */ jsxs("div", {
225
+ className: "ops",
226
+ children: [
227
+ /* @__PURE__ */ jsx("style", { children: OPS_CSS }),
228
+ ci && /* @__PURE__ */ jsx(CiSection, { ctx }),
229
+ telemetry && /* @__PURE__ */ jsx(TelemetrySection, { ctx })
230
+ ]
231
+ });
232
+ }
233
+ //#endregion
234
+ export { age, OpsPanel as default };
@@ -0,0 +1,92 @@
1
+ //#region src/core/grabber/inspect.d.ts
2
+ /**
3
+ * Which React component rendered a DOM element, read from the fiber React
4
+ * attaches to it in development. Best effort by design: fibers are React
5
+ * internals, so every field is probed rather than trusted, and a page that is
6
+ * not React (or a production build) simply yields `null`.
7
+ */
8
+ interface GrabComponent {
9
+ /** Nearest named component above the element, e.g. `HeroCta`. */
10
+ name: string;
11
+ /** Named components further up, nearest first, at most five. */
12
+ owners: string[];
13
+ /**
14
+ * Where the element's JSX was written, e.g. `src/site.tsx:12:5`. A hint, not
15
+ * a resolution: the file is reliable, the line is the position in the
16
+ * dev server's transformed module and can sit a few lines below the original.
17
+ */
18
+ source?: string;
19
+ }
20
+ //#endregion
21
+ //#region src/core/grabber/payload.d.ts
22
+ /** Box in viewport percentages, measured at grab time. */
23
+ interface GrabRect {
24
+ x: number;
25
+ y: number;
26
+ width: number;
27
+ height: number;
28
+ }
29
+ interface GrabAnchor {
30
+ /** `nth-of-type` path from `<body>`. */
31
+ selector: string;
32
+ /** Human label, e.g. `button “Termin buchen”`. */
33
+ label: string;
34
+ tag: string;
35
+ /**
36
+ * Viewport-relative, so correct only for a grab that is acted on at once.
37
+ * Anything that persists a position (review pins) needs document-relative
38
+ * coordinates instead.
39
+ */
40
+ rect: GrabRect;
41
+ }
42
+ /** One entry of an app's component manifest: a name and the file it lives in. */
43
+ interface ComponentHint {
44
+ name: string;
45
+ path: string;
46
+ }
47
+ /** A PNG of the grabbed element, as the `capture` plugin attaches it. */
48
+ interface GrabScreenshotImage {
49
+ status: "ready";
50
+ mime: "image/png";
51
+ /** The PNG, base64 encoded. */
52
+ base64: string;
53
+ width: number;
54
+ height: number;
55
+ /** `element` when the crop matched the selector, `viewport` when it fell back to the page. */
56
+ scope: "element" | "viewport";
57
+ }
58
+ /**
59
+ * The grab's screenshot: absent without the `capture` plugin, `pending` while
60
+ * it renders, `unavailable` with a reason (and a setup hint) when it cannot.
61
+ */
62
+ type GrabScreenshot = {
63
+ status: "pending";
64
+ } | GrabScreenshotImage | {
65
+ status: "unavailable";
66
+ reason: string;
67
+ hint?: string;
68
+ };
69
+ /** What a completed grab hands to plugins (`onGrab`, `ctx.grab`). */
70
+ interface GrabPayload {
71
+ app: string;
72
+ url: string;
73
+ route: string;
74
+ anchor: GrabAnchor;
75
+ /** The React component that rendered the element, when the page is React in development. */
76
+ component: GrabComponent | null;
77
+ viewport: {
78
+ width: number;
79
+ height: number;
80
+ };
81
+ grabbedAt: string;
82
+ /** Attached after the grab by the `capture` plugin's `onGrab`; see `HudGrab.amend`. */
83
+ screenshot?: GrabScreenshot;
84
+ }
85
+ /**
86
+ * Scores manifest entries against the route and anchor label. Pure token
87
+ * overlap: a hint for the agent, not a resolution. Ported from the old HUD's
88
+ * `grabber/payload.ts`.
89
+ */
90
+ declare function matchComponentHints(hints: readonly ComponentHint[] | undefined, route: string, label: string, max?: number): ComponentHint[];
91
+ //#endregion
92
+ export { GrabScreenshotImage as a, GrabScreenshot as i, GrabAnchor as n, matchComponentHints as o, GrabPayload as r, GrabComponent as s, ComponentHint as t };
@@ -0,0 +1,2 @@
1
+ import { a as A11yFinding, c as AxeImpact, i as A11yStatus, n as a11y, o as AXE_URL, r as A11ySnapshot, s as AXE_VERSION, t as A11yOptions } from "../index-DqOyNf1u.js";
2
+ export { type A11yFinding, A11yOptions, type A11ySnapshot, type A11yStatus, AXE_URL, AXE_VERSION, type AxeImpact, a11y };
@@ -0,0 +1,2 @@
1
+ import { a as AXE_VERSION, i as AXE_URL, t as a11y } from "../a11y-B5DUaiCs.js";
2
+ export { AXE_URL, AXE_VERSION, a11y };