@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.
Files changed (159) hide show
  1. package/README.md +634 -12
  2. package/dist/a11y-B5DUaiCs.js +246 -0
  3. package/dist/a11y-panel-p_t4eD7p.js +207 -0
  4. package/dist/{capabilities-CjulXFQX.js → access-C7zlaqj6.js} +1 -90
  5. package/dist/{access-CNvJOwKM.d.ts → access-D_ewAEJG.d.ts} +11 -4
  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-vEjyJfPW.d.ts → env-CApnbI0r.d.ts} +2 -0
  26. package/dist/{env-DfxpPfs9.js → env-CaiFPIhF.js} +3 -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-panel-_otVYh9i.js +97 -0
  32. package/dist/generate-C8lQl3Eh.js +53 -0
  33. package/dist/handler-BpVhxEmU.js +106 -0
  34. package/dist/{handler-WmE4Lu7l.d.ts → handler-DtYVCZY6.d.ts} +1 -1
  35. package/dist/index-BAV_1W8a.d.ts +43 -0
  36. package/dist/index-BJ26pse9.d.ts +70 -0
  37. package/dist/index-BnQ0dTZf.d.ts +19 -0
  38. package/dist/index-CwfX-W87.d.ts +72 -0
  39. package/dist/index-DcH9V3cU.d.ts +48 -0
  40. package/dist/index-DqOyNf1u.d.ts +65 -0
  41. package/dist/index-DstI_ike.d.ts +66 -0
  42. package/dist/index-Dxz4fn4j.d.ts +42 -0
  43. package/dist/index-Hhh7OXzU.d.ts +129 -0
  44. package/dist/index-ReFbhQ9p.d.ts +25 -0
  45. package/dist/index-RgXfMBuW.d.ts +48 -0
  46. package/dist/{index-BYsdS-7d.d.ts → index-gCZBO53s.d.ts} +21 -3
  47. package/dist/index.d.ts +5 -5
  48. package/dist/index.js +710 -69
  49. package/dist/inspect-C9Ft8fqn.js +142 -0
  50. package/dist/inspect-root-BkaupBMp.js +429 -0
  51. package/dist/meta-Bv0sEao3.js +6 -0
  52. package/dist/meta-C_G7MB5w.d.ts +49 -0
  53. package/dist/mocks-CA-wM2SB.d.ts +109 -0
  54. package/dist/mocks-ESiRqk9o.js +150 -0
  55. package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
  56. package/dist/next/config.cjs +201 -0
  57. package/dist/next/config.d.cts +87 -0
  58. package/dist/next/config.d.ts +64 -0
  59. package/dist/next/config.js +84 -0
  60. package/dist/next.d.ts +14 -4
  61. package/dist/next.js +5 -3
  62. package/dist/observe-CdDnDBRP.js +89 -0
  63. package/dist/observe-panel-Cgp1M8oT.js +347 -0
  64. package/dist/ops-panel-CEqDe_UT.js +234 -0
  65. package/dist/{payload-CLKDVZWl.d.ts → payload-MUQ9ciER.d.ts} +25 -1
  66. package/dist/plugins/a11y.d.ts +2 -0
  67. package/dist/plugins/a11y.js +2 -0
  68. package/dist/plugins/access/server.d.ts +5 -5
  69. package/dist/plugins/access/server.js +4 -3
  70. package/dist/plugins/access.d.ts +5 -5
  71. package/dist/plugins/access.js +16 -215
  72. package/dist/plugins/agent/server.d.ts +3 -38
  73. package/dist/plugins/agent/server.js +47 -21
  74. package/dist/plugins/agent.d.ts +4 -4
  75. package/dist/plugins/agent.js +6 -348
  76. package/dist/plugins/capture/server.d.ts +92 -0
  77. package/dist/plugins/capture/server.js +248 -0
  78. package/dist/plugins/capture.d.ts +24 -0
  79. package/dist/plugins/capture.js +70 -0
  80. package/dist/plugins/data/msw-browser.d.ts +2 -0
  81. package/dist/plugins/data/msw-browser.js +39 -0
  82. package/dist/plugins/data/msw-node.d.ts +36 -0
  83. package/dist/plugins/data/msw-node.js +68 -0
  84. package/dist/plugins/data/server.d.ts +257 -0
  85. package/dist/plugins/data/server.js +717 -0
  86. package/dist/plugins/data.d.ts +6 -0
  87. package/dist/plugins/data.js +51 -0
  88. package/dist/plugins/design/server.d.ts +54 -0
  89. package/dist/plugins/design/server.js +198 -0
  90. package/dist/plugins/design.d.ts +4 -124
  91. package/dist/plugins/design.js +4 -619
  92. package/dist/plugins/inspect/convex.d.ts +2 -0
  93. package/dist/plugins/inspect/convex.js +486 -0
  94. package/dist/plugins/inspect/react-query.d.ts +2 -0
  95. package/dist/plugins/inspect/react-query.js +237 -0
  96. package/dist/plugins/inspect/sockets.d.ts +51 -0
  97. package/dist/plugins/inspect/sockets.js +397 -0
  98. package/dist/plugins/inspect/swr.d.ts +2 -0
  99. package/dist/plugins/inspect/swr.js +218 -0
  100. package/dist/plugins/inspect.d.ts +4 -0
  101. package/dist/plugins/inspect.js +3 -0
  102. package/dist/plugins/observe.d.ts +4 -64
  103. package/dist/plugins/observe.js +1 -616
  104. package/dist/plugins/ops/server.d.ts +1 -1
  105. package/dist/plugins/ops/server.js +2 -1
  106. package/dist/plugins/ops.d.ts +2 -1
  107. package/dist/plugins/ops.js +15 -336
  108. package/dist/plugins/routes/server.d.ts +88 -0
  109. package/dist/plugins/routes/server.js +62 -0
  110. package/dist/plugins/routes.d.ts +3 -0
  111. package/dist/plugins/routes.js +216 -0
  112. package/dist/plugins/seo.d.ts +2 -0
  113. package/dist/plugins/seo.js +2 -0
  114. package/dist/plugins/vitals.d.ts +2 -25
  115. package/dist/plugins/vitals.js +3 -2
  116. package/dist/{plugins-CQ_0w1ot.d.ts → plugins-BZvDqGx5.d.ts} +33 -3
  117. package/dist/poll-CjKsWZi8.js +89 -0
  118. package/dist/requests-BwD6MKEq.js +282 -0
  119. package/dist/requests-CJrUf465.d.ts +50 -0
  120. package/dist/review.js +2 -2
  121. package/dist/same-origin-BGet22CC.js +21 -0
  122. package/dist/scan-DzJNXqOk.js +165 -0
  123. package/dist/seo-Dq9q_QkO.js +551 -0
  124. package/dist/seo-panel-CfiY-TnT.js +124 -0
  125. package/dist/server.d.ts +2 -2
  126. package/dist/server.js +2 -105
  127. package/dist/sessions-panel-COvhPAzv.js +98 -0
  128. package/dist/{shortcut-U6ftVY06.js → shortcut-s_mjGeU8.js} +1 -44
  129. package/dist/{types-QJUajwWq.js → state-CjjZPjPJ.js} +13 -8
  130. package/dist/store/convex.d.ts +33 -0
  131. package/dist/store/convex.js +52 -0
  132. package/dist/{vitals-panel-Dvc5dnR-.js → store-CQqIIKTc.js} +1 -29
  133. package/dist/store-Ync9eb1G.js +67 -0
  134. package/dist/store.d.ts +76 -0
  135. package/dist/store.js +188 -0
  136. package/dist/{styles--slk86ZQ.js → styles-BA8ueHoV.js} +13 -3
  137. package/dist/styles-DKU_P8MH.js +139 -0
  138. package/dist/styles-DPpDPmzi.js +68 -0
  139. package/dist/tokens-panel-CbMQfasZ.js +142 -0
  140. package/dist/types-B-ulf2Jp.js +8 -0
  141. package/dist/types-BIgGf-0C.d.ts +25 -0
  142. package/dist/types-BIkI-qN8.js +30 -0
  143. package/dist/{types-DADBRiGk.d.ts → types-Cxh4twqc.d.ts} +1 -1
  144. package/dist/types-DIdPfjtV.js +6 -0
  145. package/dist/types-DaJcsEjO.d.ts +44 -0
  146. package/dist/types-Dn68psVz.d.ts +118 -0
  147. package/dist/types-szkr2QOF.d.ts +39 -0
  148. package/dist/unlock-store-4V3vR4Eg.js +96 -0
  149. package/dist/variant-groups-TIfO3NIj.js +137 -0
  150. package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
  151. package/dist/variants-panel-BDoSkwBJ.js +457 -0
  152. package/dist/variants-types-CcRf119M.d.ts +63 -0
  153. package/dist/variants.d.ts +43 -0
  154. package/dist/variants.js +83 -0
  155. package/dist/vitals-panel-BCmMUntW.js +30 -0
  156. package/dist/vite.d.ts +37 -0
  157. package/dist/vite.js +134 -0
  158. package/package.json +72 -5
  159. package/dist/define-hud-BBzsSl8b.d.ts +0 -36
package/dist/store.js ADDED
@@ -0,0 +1,188 @@
1
+ import { i as definePlugin } from "./plugins-DVy_vaYr.js";
2
+ import { t as refuseCrossSite } from "./same-origin-BGet22CC.js";
3
+ import { a as assertId, i as assertCollection, n as STORE_COLLECTION, o as assertValue, r as STORE_ID, s as isStoreValue, t as HudStoreError } from "./types-BIkI-qN8.js";
4
+ import { t as file } from "./file-xdSaQ2uR.js";
5
+ //#region src/store/http.ts
6
+ function errorOf(body) {
7
+ if (isStoreValue(body) && typeof body.error === "string") return body.error;
8
+ }
9
+ /**
10
+ * A store over HTTP, against `storeRoutes()` (or anything speaking the same
11
+ * three routes): `GET <base>/<collection>` lists, `GET <base>/<collection>/<id>`
12
+ * reads (404 reads as null), `PUT <base>/<collection>/<id>` writes a JSON
13
+ * object. Runs in a browser or on a server; it is how a client panel reaches
14
+ * the dev server's `file()`.
15
+ */
16
+ function http({ baseUrl, fetch: doFetch, headers }) {
17
+ const base = baseUrl.replace(/\/+$/, "");
18
+ const call = doFetch ?? ((input, init) => fetch(input, init));
19
+ async function request(url, init = {}) {
20
+ const merged = new Headers(headers);
21
+ for (const [key, value] of new Headers(init.headers)) merged.set(key, value);
22
+ if (!merged.has("accept")) merged.set("accept", "application/json");
23
+ return call(url, {
24
+ ...init,
25
+ headers: merged
26
+ });
27
+ }
28
+ async function body(res) {
29
+ const text = await res.text();
30
+ if (!text) return void 0;
31
+ try {
32
+ return JSON.parse(text);
33
+ } catch {
34
+ return text;
35
+ }
36
+ }
37
+ async function fail(res, what) {
38
+ const parsed = await body(res);
39
+ throw new HudStoreError(`hud store: ${what} answered ${res.status}${errorOf(parsed) ? `: ${errorOf(parsed)}` : ""}`, res.status);
40
+ }
41
+ return {
42
+ async get(collection, id) {
43
+ assertCollection(collection);
44
+ assertId(id);
45
+ const res = await request(`${base}/${collection}/${encodeURIComponent(id)}`);
46
+ if (res.status === 404) return null;
47
+ if (!res.ok) return fail(res, `GET ${collection}/${id}`);
48
+ const parsed = await body(res);
49
+ return isStoreValue(parsed) && isStoreValue(parsed.value) ? parsed.value : null;
50
+ },
51
+ async set(collection, id, value) {
52
+ assertCollection(collection);
53
+ assertId(id);
54
+ assertValue(value);
55
+ const res = await request(`${base}/${collection}/${encodeURIComponent(id)}`, {
56
+ method: "PUT",
57
+ headers: { "content-type": "application/json" },
58
+ body: JSON.stringify(value)
59
+ });
60
+ if (!res.ok) return fail(res, `PUT ${collection}/${id}`);
61
+ },
62
+ async list(collection) {
63
+ assertCollection(collection);
64
+ const res = await request(`${base}/${collection}`);
65
+ if (res.status === 404) return [];
66
+ if (!res.ok) return fail(res, `GET ${collection}`);
67
+ const parsed = await body(res);
68
+ return (isStoreValue(parsed) && Array.isArray(parsed.entries) ? parsed.entries : []).filter((entry) => isStoreValue(entry) && typeof entry.id === "string" && isStoreValue(entry.value));
69
+ }
70
+ };
71
+ }
72
+ //#endregion
73
+ //#region src/store/memory.ts
74
+ /**
75
+ * An in-memory store: tests, the playground (where MSW runs the server half
76
+ * in the browser) and anything that may forget on restart. `seed` maps
77
+ * collection to documents by id.
78
+ */
79
+ function memory(seed = {}) {
80
+ const collections = /* @__PURE__ */ new Map();
81
+ for (const [collection, documents] of Object.entries(seed)) {
82
+ assertCollection(collection);
83
+ collections.set(collection, new Map(Object.entries(documents)));
84
+ }
85
+ return {
86
+ async get(collection, id) {
87
+ assertCollection(collection);
88
+ assertId(id);
89
+ return collections.get(collection)?.get(id) ?? null;
90
+ },
91
+ async set(collection, id, value) {
92
+ assertCollection(collection);
93
+ assertId(id);
94
+ assertValue(value);
95
+ let documents = collections.get(collection);
96
+ if (!documents) {
97
+ documents = /* @__PURE__ */ new Map();
98
+ collections.set(collection, documents);
99
+ }
100
+ documents.set(id, structuredClone(value));
101
+ },
102
+ async list(collection) {
103
+ assertCollection(collection);
104
+ const documents = collections.get(collection);
105
+ if (!documents) return [];
106
+ return [...documents].map(([id, value]) => ({
107
+ id,
108
+ value
109
+ }));
110
+ }
111
+ };
112
+ }
113
+ //#endregion
114
+ //#region src/store/routes.ts
115
+ const NO_STORE = { "cache-control": "no-store" };
116
+ function failed(error) {
117
+ if (error instanceof HudStoreError) return Response.json({
118
+ ok: false,
119
+ error: error.message
120
+ }, { status: error.status });
121
+ console.error("hud store: route failed", error);
122
+ return Response.json({
123
+ ok: false,
124
+ error: "store failed"
125
+ }, { status: 500 });
126
+ }
127
+ /**
128
+ * The three routes `http()` speaks, over any store. Mount them in a plugin's
129
+ * `routes` (`storeServer()` is the ready-made one) and the browser's
130
+ * `http({ baseUrl })` becomes a view onto the server's `file()`.
131
+ */
132
+ function storeRoutes(store) {
133
+ return {
134
+ "/:collection": { GET: async (_request, { params }) => {
135
+ try {
136
+ const entries = await store.list(params.collection ?? "");
137
+ return Response.json({
138
+ ok: true,
139
+ entries
140
+ }, { headers: NO_STORE });
141
+ } catch (error) {
142
+ return failed(error);
143
+ }
144
+ } },
145
+ "/:collection/:id": {
146
+ GET: async (_request, { params }) => {
147
+ try {
148
+ const value = await store.get(params.collection ?? "", params.id ?? "");
149
+ if (value === null) return Response.json({
150
+ ok: false,
151
+ error: "not found"
152
+ }, { status: 404 });
153
+ return Response.json({
154
+ ok: true,
155
+ value
156
+ }, { headers: NO_STORE });
157
+ } catch (error) {
158
+ return failed(error);
159
+ }
160
+ },
161
+ PUT: async (request, { params }) => {
162
+ const refusal = refuseCrossSite(request);
163
+ if (refusal) return refusal;
164
+ const value = await request.json().catch(() => void 0);
165
+ try {
166
+ await store.set(params.collection ?? "", params.id ?? "", value);
167
+ return Response.json({ ok: true });
168
+ } catch (error) {
169
+ return failed(error);
170
+ }
171
+ }
172
+ }
173
+ };
174
+ }
175
+ /**
176
+ * A plugin that exposes a store over HTTP at `<apiBase>/<id>/…`, for
177
+ * `http({ baseUrl: "<apiBase>/<id>" })` in the browser. Carries `data.write`
178
+ * by default, which `access` denies on every deployed tier.
179
+ */
180
+ function storeServer({ store, id = "store", capability = "data.write" }) {
181
+ return definePlugin({
182
+ id,
183
+ capability,
184
+ routes: storeRoutes(store)
185
+ });
186
+ }
187
+ //#endregion
188
+ export { HudStoreError, STORE_COLLECTION, STORE_ID, assertCollection, assertId, assertValue, file, http, isStoreValue, memory, storeRoutes, storeServer };
@@ -288,10 +288,10 @@ const HUD_CSS = `
288
288
 
289
289
  .hud :focus-visible { outline: 2px solid var(--hud-accent); outline-offset: 1px; }
290
290
 
291
+ /* Corner and offsets are inline, from the pill's placement. */
291
292
  .pill {
292
293
  position: fixed;
293
- left: 12px;
294
- bottom: 12px;
294
+ max-width: calc(100vw - 24px);
295
295
  display: flex;
296
296
  align-items: center;
297
297
  gap: 2px;
@@ -315,7 +315,17 @@ const HUD_CSS = `
315
315
 
316
316
  .pill-item:hover, .pill-item[aria-pressed="true"] { background: var(--hud-bg-subtle); }
317
317
 
318
- .env { font-weight: 600; color: var(--hud-accent); }
318
+ /* Out of flow but mounted and measurable: its live content keeps running. */
319
+ .hud .pill-overflow {
320
+ position: absolute;
321
+ visibility: hidden;
322
+ pointer-events: none;
323
+ }
324
+
325
+ .pill[data-dragging] { opacity: 0.85; transition: none; }
326
+
327
+ .env { font-weight: 600; color: var(--hud-accent); cursor: grab; touch-action: none; user-select: none; }
328
+ .pill[data-dragging] .env { cursor: grabbing; }
319
329
 
320
330
  .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hud-fg-muted); }
321
331
  .dot[data-rating="good"] { background: var(--hud-good); }
@@ -0,0 +1,139 @@
1
+ //#region src/plugins/design/styles.ts
2
+ /**
3
+ * Design plugin styles. Each panel renders them in a `<style>` inside the
4
+ * HUD's shadow root, so the core stylesheet carries nothing for an app that
5
+ * omits the plugin. Built on the shell's `--hud-*` tokens.
6
+ */
7
+ const DESIGN_CSS = `
8
+ .design { display: flex; flex-direction: column; gap: 12px; }
9
+ .design-section { display: flex; flex-direction: column; gap: 6px; }
10
+ .design-heading {
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: space-between;
14
+ gap: 8px;
15
+ font-size: 10px;
16
+ font-weight: 600;
17
+ letter-spacing: 0.06em;
18
+ text-transform: uppercase;
19
+ color: var(--hud-fg-muted);
20
+ }
21
+ .design-muted { color: var(--hud-fg-muted); }
22
+ .design-hint { color: var(--hud-fg-muted); font-size: 11px; }
23
+ .design-mono { font-family: var(--hud-mono); }
24
+ .hud .design-link {
25
+ color: var(--hud-accent);
26
+ text-decoration: none;
27
+ cursor: pointer;
28
+ }
29
+ .hud .design-link:hover { text-decoration: underline; }
30
+
31
+ .design-swatches {
32
+ display: grid;
33
+ grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
34
+ gap: 6px;
35
+ }
36
+ .hud .design-swatch {
37
+ display: flex;
38
+ flex-direction: column;
39
+ overflow: hidden;
40
+ border: 1px solid var(--hud-border);
41
+ border-radius: 6px;
42
+ text-align: left;
43
+ }
44
+ .hud .design-swatch:hover { border-color: var(--hud-accent); }
45
+ .design-chip {
46
+ display: block;
47
+ height: 28px;
48
+ border-bottom: 1px solid var(--hud-border);
49
+ background-image: repeating-linear-gradient(
50
+ 45deg, var(--hud-bg-subtle) 0 4px, transparent 4px 8px
51
+ );
52
+ }
53
+ .design-swatch-text {
54
+ display: flex;
55
+ flex-direction: column;
56
+ padding: 3px 6px;
57
+ min-width: 0;
58
+ font-family: var(--hud-mono);
59
+ font-size: 10px;
60
+ }
61
+ .design-swatch-text span {
62
+ overflow: hidden;
63
+ text-overflow: ellipsis;
64
+ white-space: nowrap;
65
+ }
66
+
67
+ .design-row {
68
+ display: flex;
69
+ align-items: center;
70
+ gap: 8px;
71
+ min-width: 0;
72
+ }
73
+ .design-grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
74
+ .design-badge {
75
+ padding: 0 6px;
76
+ border: 1px solid var(--hud-border);
77
+ border-radius: 999px;
78
+ font-family: var(--hud-mono);
79
+ font-size: 10px;
80
+ white-space: nowrap;
81
+ }
82
+ .design-badge[data-tone="active"] { color: var(--hud-good); border-color: currentColor; }
83
+ .design-badge[data-tone="forced"] {
84
+ color: var(--hud-bg);
85
+ background: var(--hud-warn);
86
+ border-color: var(--hud-warn);
87
+ }
88
+
89
+ .design-group { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
90
+ .design-variants { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
91
+ .design-variant { display: flex; flex-direction: column; gap: 2px; }
92
+ .design-variant .design-segment { text-align: left; }
93
+ .design-score { font-variant-numeric: tabular-nums; }
94
+ .design-rationale { margin: 0 0 0 8px; color: var(--hud-fg-muted); font-size: 11px; }
95
+ .design code { font-family: var(--hud-mono); font-size: 10px; }
96
+
97
+ .design-boundary { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
98
+ .design-segments { display: flex; gap: 2px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
99
+ .hud .design-segment {
100
+ flex: 1;
101
+ padding: 2px 4px;
102
+ border: 1px solid var(--hud-border);
103
+ border-radius: 4px;
104
+ font-family: var(--hud-mono);
105
+ font-size: 10px;
106
+ text-align: center;
107
+ }
108
+ .hud .design-segment:hover { background: var(--hud-bg-subtle); }
109
+ .hud .design-segment[aria-pressed="true"] {
110
+ background: var(--hud-accent);
111
+ border-color: var(--hud-accent);
112
+ color: var(--hud-bg);
113
+ }
114
+
115
+ .hud .design-button {
116
+ align-self: flex-start;
117
+ padding: 2px 10px;
118
+ border: 1px solid var(--hud-border);
119
+ border-radius: 4px;
120
+ }
121
+ .hud .design-button:hover:not(:disabled) { background: var(--hud-bg-subtle); }
122
+ .hud .design-button:disabled { opacity: 0.5; cursor: default; }
123
+
124
+ .design-field {
125
+ width: 100%;
126
+ padding: 4px 6px;
127
+ border: 1px solid var(--hud-border);
128
+ border-radius: 4px;
129
+ background: var(--hud-bg-subtle);
130
+ color: var(--hud-fg);
131
+ font-family: var(--hud-mono);
132
+ font-size: 11px;
133
+ }
134
+ textarea.design-field { min-height: 44px; resize: vertical; }
135
+ .design-result[data-ok="true"] { color: var(--hud-good); }
136
+ .design-result[data-ok="false"] { color: var(--hud-poor); }
137
+ `;
138
+ //#endregion
139
+ export { DESIGN_CSS as t };
@@ -0,0 +1,68 @@
1
+ //#region src/plugins/agent/styles.ts
2
+ /**
3
+ * The agent panels' styles. Each panel renders them in a `<style>` inside the
4
+ * HUD's shadow root, so the plugin brings its CSS without touching core's.
5
+ */
6
+ const AGENT_CSS = `
7
+ .agent { display: grid; gap: 10px; }
8
+ .agent-row { display: flex; align-items: center; gap: 8px; }
9
+ .agent-grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
10
+ .agent-muted { color: var(--hud-fg-muted); }
11
+ .agent-mono { font-family: var(--hud-mono); font-size: 11px; }
12
+ .hud .agent-btn {
13
+ padding: 3px 10px;
14
+ border: 1px solid var(--hud-border);
15
+ border-radius: 6px;
16
+ background: var(--hud-bg-subtle);
17
+ }
18
+ .hud .agent-btn[data-primary] { background: var(--hud-accent); color: var(--hud-accent-fg); border-color: transparent; }
19
+ .hud .agent-btn:disabled { opacity: 0.5; cursor: not-allowed; }
20
+ .agent-card {
21
+ display: grid;
22
+ gap: 2px;
23
+ padding: 6px 8px;
24
+ border: 1px solid var(--hud-border);
25
+ border-radius: 6px;
26
+ background: var(--hud-bg-subtle);
27
+ }
28
+ .agent textarea {
29
+ font: inherit;
30
+ color: inherit;
31
+ background: var(--hud-bg);
32
+ border: 1px solid var(--hud-border);
33
+ border-radius: 6px;
34
+ padding: 6px 8px;
35
+ min-height: 56px;
36
+ resize: vertical;
37
+ }
38
+ .agent fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 4px; }
39
+ .agent label.agent-target { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
40
+ .agent label.agent-target[data-disabled] { opacity: 0.55; cursor: not-allowed; }
41
+ .agent-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
42
+ .agent-badge {
43
+ flex: none;
44
+ padding: 0 6px;
45
+ border-radius: 999px;
46
+ border: 1px solid currentColor;
47
+ font-size: 10px;
48
+ line-height: 16px;
49
+ color: var(--hud-fg-muted);
50
+ }
51
+ .agent-badge[data-status="running"], .agent-badge[data-status="dispatched"] { color: var(--hud-good); }
52
+ .agent-badge[data-status="sending"], .agent-badge[data-status="queued"] { color: var(--hud-warn); }
53
+ .agent-badge[data-status="failed"] { color: var(--hud-poor); }
54
+ .agent details pre { max-height: 160px; overflow: auto; margin: 4px 0 0; font-size: 10px; }
55
+ .agent-shot { display: grid; gap: 2px; margin-top: 4px; }
56
+ .agent-thumb {
57
+ max-width: 100%;
58
+ max-height: 140px;
59
+ width: auto;
60
+ justify-self: start;
61
+ border: 1px solid var(--hud-border);
62
+ border-radius: 4px;
63
+ background: var(--hud-bg);
64
+ }
65
+ .agent-hint { display: block; padding: 2px 6px; border-radius: 4px; background: var(--hud-bg); user-select: all; }
66
+ `;
67
+ //#endregion
68
+ export { AGENT_CSS as t };
@@ -0,0 +1,142 @@
1
+ import { t as DESIGN_CSS } from "./styles-DKU_P8MH.js";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/plugins/design/tokens.ts
5
+ function describe(token) {
6
+ return typeof token === "string" ? { cssVar: token } : token;
7
+ }
8
+ /**
9
+ * Reads every token's computed value from the host document.
10
+ *
11
+ * The HUD renders in a shadow root, and host selectors such as
12
+ * `[data-theme="brand"]` never match inside it, so painting `var(--x)` there
13
+ * shows the wrong value for scoped tokens. Instead each group gets a hidden
14
+ * probe element in the host `<body>`, carrying the group's scope attribute,
15
+ * and the panel paints the probe's resolved values.
16
+ */
17
+ function readTokens(adapter, doc = document) {
18
+ const view = doc.defaultView;
19
+ if (!view) return [];
20
+ return adapter.groups.map((group) => {
21
+ const probe = doc.createElement("div");
22
+ probe.setAttribute("data-hud-token-probe", "");
23
+ probe.setAttribute("aria-hidden", "true");
24
+ probe.style.setProperty("display", "none", "important");
25
+ if (group.scope) probe.setAttribute(group.scope.attribute, group.scope.value ?? "");
26
+ doc.body.appendChild(probe);
27
+ try {
28
+ const style = view.getComputedStyle(probe);
29
+ return {
30
+ label: group.label,
31
+ tokens: group.tokens.map(describe).map(({ cssVar, label }) => ({
32
+ cssVar,
33
+ label: label ?? cssVar.replace(/^--/, ""),
34
+ value: style.getPropertyValue(cssVar).trim()
35
+ }))
36
+ };
37
+ } finally {
38
+ probe.remove();
39
+ }
40
+ });
41
+ }
42
+ /**
43
+ * The value as a paintable color, or null. shadcn-style themes store bare HSL
44
+ * channels (`222 47% 11%`), which paint once wrapped in `hsl()`.
45
+ */
46
+ function tokenColor(value) {
47
+ if (!value || typeof CSS === "undefined" || typeof CSS.supports !== "function") return null;
48
+ if (CSS.supports("color", value)) return value;
49
+ const hsl = `hsl(${value})`;
50
+ return CSS.supports("color", hsl) ? hsl : null;
51
+ }
52
+ /**
53
+ * Calls `onChange` whenever the host's resolved tokens may have changed: a
54
+ * theme class or attribute flips on `<html>` or `<body>`, a stylesheet is
55
+ * added or removed (HMR), or the OS color scheme changes.
56
+ */
57
+ function watchTokens(onChange, doc = document) {
58
+ const observer = new MutationObserver((records) => {
59
+ if (records.some((record) => record.type === "attributes" || [...record.addedNodes, ...record.removedNodes].some((node) => node.nodeName === "STYLE" || node.nodeName === "LINK"))) onChange();
60
+ });
61
+ observer.observe(doc.documentElement, { attributes: true });
62
+ observer.observe(doc.head, { childList: true });
63
+ observer.observe(doc.body, { attributes: true });
64
+ const media = doc.defaultView?.matchMedia?.("(prefers-color-scheme: dark)");
65
+ media?.addEventListener("change", onChange);
66
+ return () => {
67
+ observer.disconnect();
68
+ media?.removeEventListener("change", onChange);
69
+ };
70
+ }
71
+ //#endregion
72
+ //#region src/plugins/design/tokens-panel.tsx
73
+ /**
74
+ * Live design-token swatches. Values are read from the host document (see
75
+ * `readTokens`), re-read when the host's theme changes, and painted as
76
+ * resolved literals. Click copies `var(<token>)`.
77
+ */
78
+ function TokensPanel({ adapter }) {
79
+ const [groups, setGroups] = useState(() => readTokens(adapter));
80
+ const [copied, setCopied] = useState(null);
81
+ const refresh = useCallback(() => setGroups(readTokens(adapter)), [adapter]);
82
+ useEffect(() => {
83
+ refresh();
84
+ return watchTokens(refresh);
85
+ }, [refresh]);
86
+ useEffect(() => {
87
+ if (copied === null) return;
88
+ const timer = window.setTimeout(() => setCopied(null), 1200);
89
+ return () => window.clearTimeout(timer);
90
+ }, [copied]);
91
+ const copy = (cssVar) => {
92
+ navigator.clipboard?.writeText(`var(${cssVar})`).catch(() => {});
93
+ setCopied(cssVar);
94
+ };
95
+ return /* @__PURE__ */ jsxs("div", {
96
+ className: "design",
97
+ children: [
98
+ /* @__PURE__ */ jsx("style", { children: DESIGN_CSS }),
99
+ groups.map((group) => /* @__PURE__ */ jsxs("section", {
100
+ className: "design-section",
101
+ "aria-label": group.label,
102
+ children: [/* @__PURE__ */ jsxs("div", {
103
+ className: "design-heading",
104
+ children: [/* @__PURE__ */ jsx("span", { children: group.label }), /* @__PURE__ */ jsx("button", {
105
+ type: "button",
106
+ className: "design-link",
107
+ onClick: refresh,
108
+ children: "refresh"
109
+ })]
110
+ }), /* @__PURE__ */ jsx("div", {
111
+ className: "design-swatches",
112
+ children: group.tokens.map((token) => {
113
+ const color = tokenColor(token.value);
114
+ return /* @__PURE__ */ jsxs("button", {
115
+ type: "button",
116
+ className: "design-swatch",
117
+ title: `var(${token.cssVar}) = ${token.value || "unset"} (click to copy)`,
118
+ onClick: () => copy(token.cssVar),
119
+ children: [/* @__PURE__ */ jsx("span", {
120
+ className: "design-chip",
121
+ "data-token-chip": token.cssVar,
122
+ style: color ? { background: color } : void 0
123
+ }), /* @__PURE__ */ jsxs("span", {
124
+ className: "design-swatch-text",
125
+ children: [/* @__PURE__ */ jsx("span", { children: copied === token.cssVar ? "copied" : token.label }), /* @__PURE__ */ jsx("span", {
126
+ className: "design-muted",
127
+ children: token.value || "unset"
128
+ })]
129
+ })]
130
+ }, token.cssVar);
131
+ })
132
+ })]
133
+ }, group.label)),
134
+ adapter.sourceHint && /* @__PURE__ */ jsx("p", {
135
+ className: "design-hint design-mono",
136
+ children: adapter.sourceHint
137
+ })
138
+ ]
139
+ });
140
+ }
141
+ //#endregion
142
+ export { TokensPanel, TokensPanel as default };
@@ -0,0 +1,8 @@
1
+ //#region src/plugins/ops/types.ts
2
+ const TELEMETRY_RANGES = [
3
+ "1h",
4
+ "24h",
5
+ "7d"
6
+ ];
7
+ //#endregion
8
+ export { TELEMETRY_RANGES as t };
@@ -0,0 +1,25 @@
1
+ import { a as GrabScreenshotImage } from "./payload-MUQ9ciER.js";
2
+ //#region src/plugins/capture/types.d.ts
3
+ declare const CAPTURE_CAPABILITY = "capture.screenshot";
4
+ /** `POST <apiBase>/capture/screenshot`. */
5
+ interface ScreenshotRequest {
6
+ /** Page to render; must share the dev server's origin. */
7
+ url: string;
8
+ /** CSS path of the element to crop to (`GrabAnchor.selector`). Without one: the viewport. */
9
+ selector?: string;
10
+ /** Viewport of the headless page. Default 1280×800. */
11
+ viewport?: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ }
16
+ type ScreenshotResponse = ({
17
+ ok: true;
18
+ } & Omit<GrabScreenshotImage, "status">) | {
19
+ ok: false;
20
+ error: string;
21
+ /** What to run to make screenshots work, when the error is a missing setup. */
22
+ hint?: string;
23
+ };
24
+ //#endregion
25
+ export { ScreenshotRequest as n, ScreenshotResponse as r, CAPTURE_CAPABILITY as t };
@@ -0,0 +1,30 @@
1
+ //#region src/store/types.ts
2
+ /**
3
+ * A collection becomes a file name under `.hud/` (and a URL segment), so it
4
+ * is restricted to a slug: no dots, no slashes, no traversal.
5
+ */
6
+ const STORE_COLLECTION = /^[a-z0-9][a-z0-9-]{0,63}$/;
7
+ /** Ids are document keys (`hero:b`); printable, one line, bounded. */
8
+ const STORE_ID = /^[^\s/\\]{1,200}$/;
9
+ var HudStoreError = class extends Error {
10
+ status;
11
+ constructor(message, status = 400) {
12
+ super(message);
13
+ this.status = status;
14
+ this.name = "HudStoreError";
15
+ }
16
+ };
17
+ function assertCollection(collection) {
18
+ if (!STORE_COLLECTION.test(collection)) throw new HudStoreError(`hud store: collection "${collection}" must match ${STORE_COLLECTION}`);
19
+ }
20
+ function assertId(id) {
21
+ if (!STORE_ID.test(id)) throw new HudStoreError(`hud store: id "${id}" must match ${STORE_ID}`);
22
+ }
23
+ function isStoreValue(value) {
24
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25
+ }
26
+ function assertValue(value) {
27
+ if (!isStoreValue(value)) throw new HudStoreError("hud store: value must be a JSON object");
28
+ }
29
+ //#endregion
30
+ export { assertId as a, assertCollection as i, STORE_COLLECTION as n, assertValue as o, STORE_ID as r, isStoreValue as s, HudStoreError as t };
@@ -1,4 +1,4 @@
1
- import { r as GrabPayload, t as ComponentHint } from "./payload-CLKDVZWl.js";
1
+ import { r as GrabPayload, t as ComponentHint } from "./payload-MUQ9ciER.js";
2
2
  //#region src/plugins/agent/types.d.ts
3
3
  /** Wire types shared by the agent plugins' client and server halves. */
4
4
  /** One dispatch target as `GET <apiBase>/agent-dispatch/targets` lists it. */
@@ -0,0 +1,6 @@
1
+ //#region src/plugins/capture/types.ts
2
+ /** Wire types shared by the `capture` plugin's client and server halves. */
3
+ const CAPTURE_ID = "capture";
4
+ const CAPTURE_CAPABILITY = "capture.screenshot";
5
+ //#endregion
6
+ export { CAPTURE_ID as n, CAPTURE_CAPABILITY as t };