@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
@@ -0,0 +1,282 @@
1
+ //#region src/plugins/observe/capture-buffer.ts
2
+ /**
3
+ * Fixed-size ring buffer with a referentially-stable snapshot, shaped for
4
+ * `useSyncExternalStore`: the snapshot array is replaced on every mutation
5
+ * and reused between mutations. Entries get an increasing `id` and a `ts`.
6
+ */
7
+ var RingBuffer = class {
8
+ entries = [];
9
+ snapshot = [];
10
+ listeners = /* @__PURE__ */ new Set();
11
+ nextId = 1;
12
+ maxEntries;
13
+ constructor(maxEntries = 500) {
14
+ this.maxEntries = maxEntries;
15
+ }
16
+ push(input) {
17
+ const entry = {
18
+ id: this.nextId++,
19
+ ts: Date.now(),
20
+ ...input
21
+ };
22
+ this.entries.push(entry);
23
+ if (this.entries.length > this.maxEntries) this.entries.splice(0, this.entries.length - this.maxEntries);
24
+ this.emit();
25
+ return entry;
26
+ }
27
+ /** Merges `patch` into the entry with `id`; a no-op once the ring has dropped it. */
28
+ update(id, patch) {
29
+ const index = this.entries.findIndex((entry) => entry.id === id);
30
+ if (index === -1) return;
31
+ this.entries[index] = {
32
+ ...this.entries[index],
33
+ ...patch
34
+ };
35
+ this.emit();
36
+ }
37
+ clear() {
38
+ if (this.entries.length === 0) return;
39
+ this.entries = [];
40
+ this.emit();
41
+ }
42
+ getSnapshot = () => this.snapshot;
43
+ subscribe = (listener) => {
44
+ this.listeners.add(listener);
45
+ return () => this.listeners.delete(listener);
46
+ };
47
+ emit() {
48
+ this.snapshot = [...this.entries];
49
+ for (const listener of this.listeners) listener();
50
+ }
51
+ };
52
+ var CaptureBuffer = class extends RingBuffer {};
53
+ /** Shared buffer the capture patches write into and the console tab reads from. */
54
+ const captureBuffer = new CaptureBuffer(500);
55
+ /**
56
+ * What the pill counts as an error: `console.error`, uncaught errors and
57
+ * rejections, and requests that failed outright or answered 5xx. A 4xx is the
58
+ * app's business (a 404 probe, a 401 before login), so it stays a plain fetch.
59
+ */
60
+ function isError(entry) {
61
+ if (entry.kind === "error") return true;
62
+ return (entry.kind === "fetch" || entry.kind === "xhr") && entry.status !== void 0 && (entry.status === 0 || entry.status >= 500);
63
+ }
64
+ //#endregion
65
+ //#region src/plugins/observe/redact.ts
66
+ /**
67
+ * Redaction for captured requests. Runs at capture time, so a secret never
68
+ * sits in the HUD's buffer: `authorization`, `cookie`, `set-cookie` and every
69
+ * header, query parameter, form field or JSON key whose name looks like a
70
+ * token are replaced with `[redacted]`, as are bearer tokens and JWTs found
71
+ * in free text.
72
+ */
73
+ const REDACTED = "[redacted]";
74
+ /**
75
+ * Known token fields, matched on the lower-cased name with `-`, `_`, `.` and
76
+ * spaces removed: `x-api-key`, `access_token`, `Set-Cookie`, `clientSecret`.
77
+ * `auth` alone (or `x-auth`) counts; `author` does not.
78
+ */
79
+ const SENSITIVE = /token|secret|password|passwd|pwd|apikey|authorization|credential|privatekey|cookie|jwt|accesskey|clientkey|signature/;
80
+ function isSensitiveKey(key) {
81
+ const normalised = key.toLowerCase().replace(/[-_.\s]/g, "");
82
+ return SENSITIVE.test(normalised) || normalised === "auth" || normalised === "xauth";
83
+ }
84
+ /** Headers as a plain lower-cased record, sensitive values replaced. */
85
+ function redactHeaders(headers) {
86
+ const out = {};
87
+ const entries = headers instanceof Headers || Symbol.iterator in headers ? headers : Object.entries(headers);
88
+ for (const [name, value] of entries) {
89
+ const key = name.toLowerCase();
90
+ out[key] = isSensitiveKey(key) ? REDACTED : value;
91
+ }
92
+ return out;
93
+ }
94
+ /** Replaces the value of every sensitive query parameter; the rest of the URL is untouched. */
95
+ function redactUrl(url) {
96
+ const query = url.indexOf("?");
97
+ if (query === -1) return url;
98
+ const hash = url.indexOf("#", query);
99
+ const search = url.slice(query + 1, hash === -1 ? void 0 : hash);
100
+ if (!search) return url;
101
+ const redacted = search.split("&").map((pair) => {
102
+ const eq = pair.indexOf("=");
103
+ const name = eq === -1 ? pair : pair.slice(0, eq);
104
+ return eq !== -1 && isSensitiveKey(safeDecode(name)) ? `${name}=${REDACTED}` : pair;
105
+ }).join("&");
106
+ return `${url.slice(0, query + 1)}${redacted}${hash === -1 ? "" : url.slice(hash)}`;
107
+ }
108
+ function safeDecode(text) {
109
+ try {
110
+ return decodeURIComponent(text);
111
+ } catch {
112
+ return text;
113
+ }
114
+ }
115
+ const BEARER = /\b(Bearer|Basic|Token)\s+[A-Za-z0-9._~+/=-]{8,}/g;
116
+ const JWT = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]*/g;
117
+ /** `"key": "value"` inside text that did not parse as JSON. */
118
+ const JSON_PAIR = /("([^"\\]|\\.)*")(\s*:\s*)"(?:[^"\\]|\\.)*"/g;
119
+ /** A multipart part: the disposition line, a blank line, then the value. */
120
+ const MULTIPART = /(Content-Disposition:\s*form-data;\s*name="([^"]*)"[^\r\n]*\r?\n(?:[^\r\n]+\r?\n)*\r?\n)([^\r\n]*)/gi;
121
+ /** Free-text pass: bearer tokens, JWTs, JSON-looking pairs and multipart fields. */
122
+ function redactText(text) {
123
+ return text.replace(BEARER, `$1 ${REDACTED}`).replace(JWT, REDACTED).replace(JSON_PAIR, (match, quotedKey, _inner, colon) => isSensitiveKey(quotedKey.slice(1, -1)) ? `${quotedKey}${colon}"${REDACTED}"` : match).replace(MULTIPART, (match, head, name, value) => isSensitiveKey(name) && value ? `${head}${REDACTED}` : match);
124
+ }
125
+ function redactJsonValue(value, sensitive) {
126
+ if (Array.isArray(value)) return value.map((item) => redactJsonValue(item, sensitive));
127
+ if (value !== null && typeof value === "object") {
128
+ const out = {};
129
+ for (const [key, inner] of Object.entries(value)) out[key] = redactJsonValue(inner, sensitive || isSensitiveKey(key));
130
+ return out;
131
+ }
132
+ if (sensitive && value !== null && value !== void 0) return REDACTED;
133
+ return typeof value === "string" ? redactText(value) : value;
134
+ }
135
+ /** JSON: every value under a sensitive key, at any depth, becomes `[redacted]`. */
136
+ function redactJson(value) {
137
+ return redactJsonValue(value, false);
138
+ }
139
+ function redactForm(text) {
140
+ const params = new URLSearchParams(text);
141
+ const out = new URLSearchParams();
142
+ for (const [key, value] of params) out.append(key, isSensitiveKey(key) ? REDACTED : value);
143
+ return out.toString();
144
+ }
145
+ const FORM_SHAPE = /^[^=&\s]+=[^&\n]*(&[^=&\s]+=[^&\n]*)*$/;
146
+ /**
147
+ * Redacts a captured body by its content type: JSON is walked by key, a URL
148
+ * encoded form by field, anything else gets the free-text pass.
149
+ */
150
+ function redactBody(text, contentType = "") {
151
+ const type = contentType.toLowerCase();
152
+ if (type.includes("json") || !type && /^\s*[[{]/.test(text)) try {
153
+ return JSON.stringify(redactJson(JSON.parse(text)));
154
+ } catch {}
155
+ if (type.includes("x-www-form-urlencoded") || !type && FORM_SHAPE.test(text)) return redactForm(text);
156
+ return redactText(text);
157
+ }
158
+ //#endregion
159
+ //#region src/plugins/observe/requests.ts
160
+ /**
161
+ * Detailed request capture for the inspect plugin: headers, bodies and
162
+ * timing per fetch, XHR and Server Action, redacted on the way in. The
163
+ * capture patches feed it only while a plugin asked for request detail
164
+ * (`installCapture({ requests: true })`); the console tab's one-line entries
165
+ * are always recorded.
166
+ */
167
+ /** Characters kept per body. */
168
+ const MAX_BODY = 16384;
169
+ const requestBuffer = new RingBuffer(200);
170
+ function isRequestError(entry) {
171
+ return entry.status !== void 0 && (entry.status === 0 || entry.status >= 500);
172
+ }
173
+ const TEXT_TYPES = /^(text\/|application\/(json|x-www-form-urlencoded|xml|javascript|graphql))/;
174
+ const STREAM_TYPES = /^text\/event-stream/;
175
+ /** Whether a content type is worth reading as text. Unknown types are read; binaries are not. */
176
+ function isTextType(contentType) {
177
+ if (!contentType) return true;
178
+ const type = contentType.toLowerCase();
179
+ return TEXT_TYPES.test(type) || /\+(json|xml)\b/.test(type) || type.includes("x-component");
180
+ }
181
+ function isStreamType(contentType) {
182
+ return contentType !== void 0 && STREAM_TYPES.test(contentType.toLowerCase());
183
+ }
184
+ /** Caps and redacts a text body. */
185
+ function capturedText(text, contentType) {
186
+ const truncated = text.length > MAX_BODY;
187
+ const body = redactBody(truncated ? text.slice(0, MAX_BODY) : text, contentType);
188
+ return truncated ? {
189
+ body,
190
+ bodyTruncated: true
191
+ } : { body };
192
+ }
193
+ /** Multipart fields with sensitive names redacted; files become a note. */
194
+ function capturedForm(data) {
195
+ const form = [];
196
+ for (const [name, value] of data) if (typeof value === "string") form.push([name, isSensitiveKey(name) ? REDACTED : value]);
197
+ else form.push([name, `[file ${value.name || "blob"}, ${value.size} bytes]`]);
198
+ return {
199
+ body: form.map(([name, value]) => `${name}=${value}`).join("\n"),
200
+ form
201
+ };
202
+ }
203
+ /**
204
+ * Describes a fetch `init.body` (or an XHR `send` argument) without reading a
205
+ * stream: strings and URL-encoded params are captured as text, FormData by
206
+ * field, blobs and buffers as a note.
207
+ */
208
+ function captureRequestBody(body, contentType) {
209
+ if (body === null || body === void 0) return {};
210
+ if (typeof body === "string") return capturedText(body, contentType);
211
+ if (body instanceof URLSearchParams) return capturedText(body.toString(), "application/x-www-form-urlencoded");
212
+ if (typeof FormData !== "undefined" && body instanceof FormData) return capturedForm(body);
213
+ if (typeof Blob !== "undefined" && body instanceof Blob) return { bodyNote: `[blob ${body.type || "application/octet-stream"}, ${body.size} bytes]` };
214
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) return { bodyNote: `[binary, ${body.byteLength} bytes]` };
215
+ if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) return { bodyNote: "[stream]" };
216
+ return { bodyNote: "[document]" };
217
+ }
218
+ /**
219
+ * Reads a stream as text up to `MAX_BODY` characters, then cancels it. Used
220
+ * on a clone, so the app's own read is unaffected.
221
+ */
222
+ async function readCapped(stream, contentType) {
223
+ const reader = stream.getReader();
224
+ const decoder = new TextDecoder();
225
+ let text = "";
226
+ try {
227
+ while (text.length <= MAX_BODY) {
228
+ const { done, value } = await reader.read();
229
+ if (done) break;
230
+ text += decoder.decode(value, { stream: true });
231
+ }
232
+ } finally {
233
+ reader.cancel().catch(() => {});
234
+ }
235
+ return capturedText(text, contentType);
236
+ }
237
+ /** Headers, body note or body of a `Response` (its clone is read in the background). */
238
+ function captureResponse(response, onBody) {
239
+ const headers = redactHeaders(response.headers);
240
+ const contentType = headers["content-type"];
241
+ const payload = { headers };
242
+ if (!response.body) return payload;
243
+ if (isStreamType(contentType)) return {
244
+ ...payload,
245
+ bodyNote: "[stream]"
246
+ };
247
+ if (!isTextType(contentType)) return {
248
+ ...payload,
249
+ bodyNote: `[binary ${contentType}]`
250
+ };
251
+ try {
252
+ readCapped(response.clone().body ?? new ReadableStream(), contentType).then(onBody).catch((error) => onBody({ bodyNote: `[unreadable: ${String(error)}]` }));
253
+ } catch (error) {
254
+ return {
255
+ ...payload,
256
+ bodyNote: `[unreadable: ${String(error)}]`
257
+ };
258
+ }
259
+ return payload;
260
+ }
261
+ /** Parses `XMLHttpRequest.getAllResponseHeaders()`. */
262
+ function parseRawHeaders(raw) {
263
+ const out = {};
264
+ for (const line of raw.split(/\r?\n/)) {
265
+ const colon = line.indexOf(":");
266
+ if (colon <= 0) continue;
267
+ out[line.slice(0, colon).trim().toLowerCase()] = line.slice(colon + 1).trim();
268
+ }
269
+ return redactHeaders(out);
270
+ }
271
+ let pendingReplayOf;
272
+ /** Tags the next captured fetch as a replay of `id`; the fetch patch consumes it. */
273
+ function markReplay(id) {
274
+ pendingReplayOf = id;
275
+ }
276
+ function takeReplay() {
277
+ const id = pendingReplayOf;
278
+ pendingReplayOf = void 0;
279
+ return id;
280
+ }
281
+ //#endregion
282
+ export { captureBuffer as _, isRequestError as a, readCapped as c, REDACTED as d, isSensitiveKey as f, RingBuffer as g, redactUrl as h, capturedText as i, requestBuffer as l, redactHeaders as m, captureRequestBody as n, markReplay as o, redactBody as p, captureResponse as r, parseRawHeaders as s, MAX_BODY as t, takeReplay as u, isError as v };
@@ -0,0 +1,50 @@
1
+ import { i as Stamped, r as RingBuffer } from "./capture-buffer-Bbbo6omF.js";
2
+ //#region src/plugins/observe/capture.d.ts
3
+ /**
4
+ * Browser-side capture into the shared ring buffer: console.log/warn/error,
5
+ * uncaught errors and rejections, fetch and XHR timing, and long tasks. The
6
+ * observe pill installs it when the HUD mounts, so whatever happens before
7
+ * the panel is first opened is already there. With `requests: true` (the
8
+ * inspect plugin) every fetch, XHR and Server Action also lands in
9
+ * `requestBuffer` with its headers and bodies, redacted.
10
+ */
11
+ interface CaptureOptions {
12
+ /** Requests to leave out of the log. Default: the HUD's own `/api/hud/` calls. */
13
+ ignore?: (url: string) => boolean;
14
+ /** Also record headers and bodies into `requestBuffer` while this install is held. */
15
+ requests?: boolean;
16
+ }
17
+ //#endregion
18
+ //#region src/plugins/observe/requests.d.ts
19
+ type RequestTransport = "fetch" | "xhr";
20
+ interface RequestPayload {
21
+ /** Lower-cased names; sensitive values are `[redacted]`. */
22
+ headers: Record<string, string>;
23
+ /** Redacted text, at most `MAX_BODY` characters. */
24
+ body?: string;
25
+ bodyTruncated?: boolean;
26
+ /** Why there is no `body`: `[binary image/png]`, `[stream]`, `[file …]`. */
27
+ bodyNote?: string;
28
+ /** Multipart fields (files left out), so a form request can be replayed. */
29
+ form?: [string, string][];
30
+ }
31
+ interface InspectRequestInput {
32
+ transport: RequestTransport;
33
+ method: string;
34
+ /** As the app passed it, query tokens redacted. */
35
+ url: string;
36
+ /** Next Server Action id, from the `Next-Action` request header. */
37
+ actionId?: string;
38
+ /** Set on a request the inspector replayed. */
39
+ replayOf?: number;
40
+ /** Undefined while in flight; 0 when the request failed outright. */
41
+ status?: number;
42
+ error?: string;
43
+ durationMs?: number;
44
+ request: RequestPayload;
45
+ response?: RequestPayload;
46
+ }
47
+ interface InspectRequest extends InspectRequestInput, Stamped {}
48
+ declare const requestBuffer: RingBuffer<InspectRequestInput>;
49
+ //#endregion
50
+ export { CaptureOptions as a, requestBuffer as i, RequestPayload as n, RequestTransport as r, InspectRequest as t };
package/dist/review.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as buildAnchorSelector, t as anchorLabelFor } from "./selector-NSYSe7AZ.js";
2
- import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles--slk86ZQ.js";
2
+ import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles-BA8ueHoV.js";
3
3
  import { t as HUD_REVIEW_MARKER } from "./marker-DjeGvL-F.js";
4
4
  import { useCallback, useEffect, useRef, useState } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { ConvexClient } from "convex/browser";
7
6
  import { makeFunctionReference } from "convex/server";
7
+ import { ConvexClient } from "convex/browser";
8
8
  //#region src/review/anchor/viewport.ts
9
9
  /** Tailwind's `md` (768) and `xl` (1280) — the breakpoints the apps already lay out against. */
10
10
  const BUCKET_BREAKPOINTS = {
@@ -0,0 +1,21 @@
1
+ //#region src/server/same-origin.ts
2
+ /**
3
+ * Refuses a state-changing request from another origin. A page elsewhere must
4
+ * not be able to write through the developer's browser: a JSON content type
5
+ * forces a CORS preflight that HUD routes never answer, and `Sec-Fetch-Site`
6
+ * rejects cross-site requests outright where the browser sends it.
7
+ */
8
+ function refuseCrossSite(request) {
9
+ const site = request.headers.get("sec-fetch-site");
10
+ if (site && site !== "same-origin" && site !== "none") return Response.json({
11
+ ok: false,
12
+ error: "cross-site request refused"
13
+ }, { status: 403 });
14
+ if (!request.headers.get("content-type")?.toLowerCase().startsWith("application/json")) return Response.json({
15
+ ok: false,
16
+ error: "expected application/json"
17
+ }, { status: 415 });
18
+ return null;
19
+ }
20
+ //#endregion
21
+ export { refuseCrossSite as t };
@@ -0,0 +1,165 @@
1
+ //#region src/plugins/routes/scan.ts
2
+ /** A page file by Next's convention. `route.ts` handlers are not pages and are skipped. */
3
+ const PAGE_FILE = /^page\.(tsx|jsx|ts|js|mdx|md)$/;
4
+ /** `(marketing)`: adds no URL segment. Not an intercepting route like `(.)photo`. */
5
+ function isRouteGroup(part) {
6
+ return part.startsWith("(") && part.endsWith(")") && !part.startsWith("(.");
7
+ }
8
+ /** `[slug]`, `[...parts]`, `[[...parts]]`. */
9
+ function isDynamicSegment(part) {
10
+ return part.startsWith("[") && part.endsWith("]");
11
+ }
12
+ /**
13
+ * Folders whose pages have no URL of their own: private `_lib`, parallel
14
+ * slots `@modal`, intercepting routes `(.)photo`, `(..)photo`, `(...)photo`.
15
+ */
16
+ function isSkippedFolder(part) {
17
+ return part.startsWith("_") || part.startsWith("@") || part.startsWith("(.");
18
+ }
19
+ function parseSegment(part) {
20
+ const optional = part.startsWith("[[") && part.endsWith("]]");
21
+ const inner = optional ? part.slice(2, -2) : part.slice(1, -1);
22
+ const catchAll = inner.startsWith("...");
23
+ return {
24
+ raw: part,
25
+ name: catchAll ? inner.slice(3) : inner,
26
+ catchAll,
27
+ optional
28
+ };
29
+ }
30
+ /** `posts/[slug]` (a page folder relative to the app dir) → `/posts/[slug]`; `` → `/`. */
31
+ function toPattern(relDir) {
32
+ const dir = relDir.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
33
+ return dir === "" ? "/" : `/${dir}`;
34
+ }
35
+ function parts(pattern) {
36
+ return pattern.split("/").filter(Boolean);
37
+ }
38
+ /** The pattern without its route groups: `/(shop)/posts/[slug]` → `/posts/[slug]`. */
39
+ function toPath(pattern) {
40
+ const kept = parts(pattern).filter((part) => !isRouteGroup(part));
41
+ return kept.length === 0 ? "/" : `/${kept.join("/")}`;
42
+ }
43
+ /** Name of the outermost route group, or null. */
44
+ function routeGroup(pattern) {
45
+ const group = parts(pattern).find(isRouteGroup);
46
+ return group ? group.slice(1, -1) : null;
47
+ }
48
+ function patternSegments(pattern) {
49
+ return parts(pattern).filter(isDynamicSegment).map(parseSegment);
50
+ }
51
+ /** Exact match, or a trailing `*` prefix glob, against the URL path or the folder pattern. */
52
+ function isExcluded(entry, exclude) {
53
+ if (!exclude) return false;
54
+ return exclude.some((rule) => {
55
+ if (rule.endsWith("*")) {
56
+ const prefix = rule.slice(0, -1);
57
+ return entry.path.startsWith(prefix) || entry.pattern.startsWith(prefix);
58
+ }
59
+ return rule === entry.path || rule === entry.pattern;
60
+ });
61
+ }
62
+ async function resolveFixture(value, ctx) {
63
+ if (value === void 0) return void 0;
64
+ const resolved = typeof value === "function" ? await value(ctx) : value;
65
+ return typeof resolved === "string" ? [resolved] : resolved;
66
+ }
67
+ function encodeSegment(value) {
68
+ return value.split("/").filter(Boolean).map((part) => encodeURIComponent(part)).join("/");
69
+ }
70
+ /**
71
+ * Every concrete URL of a pattern from its fixture values: one per
72
+ * combination, in fixture order. An optional catch-all without a fixture
73
+ * resolves to the parent path; any other segment without one leaves the
74
+ * route unresolved and `urls` empty.
75
+ */
76
+ function buildUrls(pattern, values) {
77
+ const unresolved = [];
78
+ let combos = [{
79
+ parts: [],
80
+ params: {}
81
+ }];
82
+ for (const part of parts(pattern)) {
83
+ if (isRouteGroup(part)) continue;
84
+ if (!isDynamicSegment(part)) {
85
+ for (const combo of combos) combo.parts.push(part);
86
+ continue;
87
+ }
88
+ const segment = parseSegment(part);
89
+ const options = values[segment.name] ?? (segment.optional ? [""] : void 0);
90
+ if (options === void 0 || options.length === 0) {
91
+ unresolved.push(segment.name);
92
+ continue;
93
+ }
94
+ combos = combos.flatMap((combo) => options.map((value) => ({
95
+ parts: value === "" ? [...combo.parts] : [...combo.parts, encodeSegment(value)],
96
+ params: {
97
+ ...combo.params,
98
+ [segment.name]: value
99
+ }
100
+ })));
101
+ }
102
+ if (unresolved.length > 0) return {
103
+ urls: [],
104
+ unresolved
105
+ };
106
+ return {
107
+ urls: combos.map(({ parts: p, params }) => ({
108
+ url: p.length ? `/${p.join("/")}` : "/",
109
+ params
110
+ })),
111
+ unresolved: []
112
+ };
113
+ }
114
+ /** Page files under `dir`, sorted by folder. Skips private, parallel and intercepting folders. */
115
+ async function findPages(dir, fs) {
116
+ const found = [];
117
+ async function walk(rel) {
118
+ const entries = [...await fs.readdir(rel ? `${dir}/${rel}` : dir)].sort((a, b) => a.name.localeCompare(b.name));
119
+ const page = entries.find((entry) => entry.isFile() && PAGE_FILE.test(entry.name));
120
+ if (page) found.push({
121
+ rel,
122
+ file: page.name
123
+ });
124
+ for (const entry of entries) {
125
+ if (!entry.isDirectory() || isSkippedFolder(entry.name)) continue;
126
+ await walk(rel ? `${rel}/${entry.name}` : entry.name);
127
+ }
128
+ }
129
+ await walk("");
130
+ return found.sort((a, b) => a.rel.localeCompare(b.rel));
131
+ }
132
+ /** Every page under the app directory as a `RouteEntry`, sorted by pattern. */
133
+ async function scanRoutes(dir, fs, { fixtures = {}, exclude } = {}) {
134
+ const routes = [];
135
+ for (const { rel, file } of await findPages(dir, fs)) {
136
+ const pattern = toPattern(rel);
137
+ const path = toPath(pattern);
138
+ if (isExcluded({
139
+ pattern,
140
+ path
141
+ }, exclude)) continue;
142
+ const segments = patternSegments(pattern);
143
+ const values = {};
144
+ for (const segment of segments) {
145
+ const resolved = await resolveFixture(fixtures[segment.name], {
146
+ param: segment.name,
147
+ pattern
148
+ });
149
+ if (resolved) values[segment.name] = resolved;
150
+ }
151
+ const { urls, unresolved } = buildUrls(pattern, values);
152
+ routes.push({
153
+ pattern,
154
+ path,
155
+ group: routeGroup(pattern),
156
+ segments,
157
+ urls,
158
+ unresolved,
159
+ source: rel ? `${rel}/${file}` : file
160
+ });
161
+ }
162
+ return routes.sort((a, b) => a.pattern.localeCompare(b.pattern));
163
+ }
164
+ //#endregion
165
+ export { scanRoutes as i, findPages as n, isExcluded as r, buildUrls as t };