@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,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 };
@@ -0,0 +1,28 @@
1
+ //#region src/core/grabber/selector.ts
2
+ /**
3
+ * `nth-of-type` path from `root` down to `el`. Ported from hn-monorepo
4
+ * `review-kit/anchor`, where console's design comments and the old HUD
5
+ * grabber shared it.
6
+ */
7
+ function buildAnchorSelector(el, root) {
8
+ const segments = [];
9
+ let node = el;
10
+ while (node && node !== root) {
11
+ const tag = node.tagName.toLowerCase();
12
+ const parent = node.parentElement;
13
+ if (!parent) break;
14
+ const siblings = [...parent.children].filter((c) => c.tagName === node?.tagName);
15
+ const index = siblings.indexOf(node) + 1;
16
+ segments.unshift(siblings.length > 1 ? `${tag}:nth-of-type(${index})` : tag);
17
+ node = parent;
18
+ }
19
+ return segments.join(" > ");
20
+ }
21
+ /** Human label such as `button “Termin buchen”`. */
22
+ function anchorLabelFor(el) {
23
+ const text = (el.textContent ?? "").trim().replace(/\s+/g, " ");
24
+ const tag = el.tagName.toLowerCase();
25
+ return text ? `${tag} “${text.slice(0, 32)}${text.length > 32 ? "…" : ""}”` : tag;
26
+ }
27
+ //#endregion
28
+ export { buildAnchorSelector as n, anchorLabelFor as t };