@hansenexus/hud 0.4.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 (157) hide show
  1. package/README.md +603 -9
  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.d.ts +52 -0
  57. package/dist/next/config.js +78 -0
  58. package/dist/next.d.ts +14 -4
  59. package/dist/next.js +5 -3
  60. package/dist/observe-CdDnDBRP.js +89 -0
  61. package/dist/observe-panel-Cgp1M8oT.js +347 -0
  62. package/dist/ops-panel-CEqDe_UT.js +234 -0
  63. package/dist/{payload-CLKDVZWl.d.ts → payload-MUQ9ciER.d.ts} +25 -1
  64. package/dist/plugins/a11y.d.ts +2 -0
  65. package/dist/plugins/a11y.js +2 -0
  66. package/dist/plugins/access/server.d.ts +5 -5
  67. package/dist/plugins/access/server.js +4 -3
  68. package/dist/plugins/access.d.ts +5 -5
  69. package/dist/plugins/access.js +16 -215
  70. package/dist/plugins/agent/server.d.ts +3 -38
  71. package/dist/plugins/agent/server.js +47 -21
  72. package/dist/plugins/agent.d.ts +4 -4
  73. package/dist/plugins/agent.js +6 -348
  74. package/dist/plugins/capture/server.d.ts +92 -0
  75. package/dist/plugins/capture/server.js +248 -0
  76. package/dist/plugins/capture.d.ts +24 -0
  77. package/dist/plugins/capture.js +70 -0
  78. package/dist/plugins/data/msw-browser.d.ts +2 -0
  79. package/dist/plugins/data/msw-browser.js +39 -0
  80. package/dist/plugins/data/msw-node.d.ts +36 -0
  81. package/dist/plugins/data/msw-node.js +68 -0
  82. package/dist/plugins/data/server.d.ts +257 -0
  83. package/dist/plugins/data/server.js +717 -0
  84. package/dist/plugins/data.d.ts +6 -0
  85. package/dist/plugins/data.js +51 -0
  86. package/dist/plugins/design/server.d.ts +54 -0
  87. package/dist/plugins/design/server.js +198 -0
  88. package/dist/plugins/design.d.ts +4 -124
  89. package/dist/plugins/design.js +4 -619
  90. package/dist/plugins/inspect/convex.d.ts +2 -0
  91. package/dist/plugins/inspect/convex.js +486 -0
  92. package/dist/plugins/inspect/react-query.d.ts +2 -0
  93. package/dist/plugins/inspect/react-query.js +225 -0
  94. package/dist/plugins/inspect/sockets.d.ts +51 -0
  95. package/dist/plugins/inspect/sockets.js +397 -0
  96. package/dist/plugins/inspect/swr.d.ts +2 -0
  97. package/dist/plugins/inspect/swr.js +218 -0
  98. package/dist/plugins/inspect.d.ts +4 -0
  99. package/dist/plugins/inspect.js +3 -0
  100. package/dist/plugins/observe.d.ts +4 -64
  101. package/dist/plugins/observe.js +1 -616
  102. package/dist/plugins/ops/server.d.ts +1 -1
  103. package/dist/plugins/ops/server.js +2 -1
  104. package/dist/plugins/ops.d.ts +2 -1
  105. package/dist/plugins/ops.js +15 -336
  106. package/dist/plugins/routes/server.d.ts +88 -0
  107. package/dist/plugins/routes/server.js +62 -0
  108. package/dist/plugins/routes.d.ts +3 -0
  109. package/dist/plugins/routes.js +216 -0
  110. package/dist/plugins/seo.d.ts +2 -0
  111. package/dist/plugins/seo.js +2 -0
  112. package/dist/plugins/vitals.d.ts +2 -25
  113. package/dist/plugins/vitals.js +3 -2
  114. package/dist/{plugins-CQ_0w1ot.d.ts → plugins-BZvDqGx5.d.ts} +33 -3
  115. package/dist/poll-CjKsWZi8.js +89 -0
  116. package/dist/requests-BwD6MKEq.js +282 -0
  117. package/dist/requests-CJrUf465.d.ts +50 -0
  118. package/dist/review.js +2 -2
  119. package/dist/same-origin-BGet22CC.js +21 -0
  120. package/dist/scan-DzJNXqOk.js +165 -0
  121. package/dist/seo-Dq9q_QkO.js +551 -0
  122. package/dist/seo-panel-CfiY-TnT.js +124 -0
  123. package/dist/server.d.ts +2 -2
  124. package/dist/server.js +2 -105
  125. package/dist/sessions-panel-COvhPAzv.js +98 -0
  126. package/dist/{shortcut-U6ftVY06.js → shortcut-s_mjGeU8.js} +1 -44
  127. package/dist/{types-QJUajwWq.js → state-CjjZPjPJ.js} +13 -8
  128. package/dist/store/convex.d.ts +33 -0
  129. package/dist/store/convex.js +52 -0
  130. package/dist/{vitals-panel-Dvc5dnR-.js → store-CQqIIKTc.js} +1 -29
  131. package/dist/store-Ync9eb1G.js +67 -0
  132. package/dist/store.d.ts +76 -0
  133. package/dist/store.js +188 -0
  134. package/dist/{styles--slk86ZQ.js → styles-BA8ueHoV.js} +13 -3
  135. package/dist/styles-DKU_P8MH.js +139 -0
  136. package/dist/styles-DPpDPmzi.js +68 -0
  137. package/dist/tokens-panel-CbMQfasZ.js +142 -0
  138. package/dist/types-B-ulf2Jp.js +8 -0
  139. package/dist/types-BIgGf-0C.d.ts +25 -0
  140. package/dist/types-BIkI-qN8.js +30 -0
  141. package/dist/{types-DADBRiGk.d.ts → types-Cxh4twqc.d.ts} +1 -1
  142. package/dist/types-DIdPfjtV.js +6 -0
  143. package/dist/types-DaJcsEjO.d.ts +44 -0
  144. package/dist/types-Dn68psVz.d.ts +118 -0
  145. package/dist/types-szkr2QOF.d.ts +39 -0
  146. package/dist/unlock-store-4V3vR4Eg.js +96 -0
  147. package/dist/variant-groups-TIfO3NIj.js +137 -0
  148. package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
  149. package/dist/variants-panel-BDoSkwBJ.js +457 -0
  150. package/dist/variants-types-CcRf119M.d.ts +63 -0
  151. package/dist/variants.d.ts +43 -0
  152. package/dist/variants.js +83 -0
  153. package/dist/vitals-panel-BCmMUntW.js +30 -0
  154. package/dist/vite.d.ts +37 -0
  155. package/dist/vite.js +134 -0
  156. package/package.json +65 -5
  157. package/dist/define-hud-BBzsSl8b.d.ts +0 -36
@@ -0,0 +1,218 @@
1
+ import { a as preview, i as prettyPreview, o as useNow, r as oneLine, t as ago } from "../../adapter-hcwmJtNx.js";
2
+ import { useState, useSyncExternalStore } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/plugins/inspect/swr/index.tsx
5
+ const MAX_ROWS = 100;
6
+ /** SWR's own bookkeeping keys (infinite pages, subscriptions). */
7
+ const INTERNAL_KEY = /^\$(inf|sub)\$/;
8
+ /**
9
+ * SWR tab for the inspect plugin: every cache key with its data (redacted),
10
+ * error, validation state and age, and Revalidate per key. Wraps the cache's
11
+ * `set` and `delete` when called, so writes are timestamped and the tab
12
+ * re-renders; `dispose()` restores the cache.
13
+ */
14
+ function inspectSwr({ cache, mutate }) {
15
+ const stamps = /* @__PURE__ */ new Map();
16
+ let version = 0;
17
+ const listeners = /* @__PURE__ */ new Set();
18
+ const notify = () => {
19
+ version++;
20
+ for (const listener of listeners) listener();
21
+ };
22
+ const subscribe = (listener) => {
23
+ listeners.add(listener);
24
+ return () => listeners.delete(listener);
25
+ };
26
+ const getVersion = () => version;
27
+ const originalSet = cache.set;
28
+ const originalDelete = cache.delete;
29
+ cache.set = (key, value) => {
30
+ const previous = cache.get(key);
31
+ originalSet.call(cache, key, value);
32
+ if (!INTERNAL_KEY.test(key)) {
33
+ const stamp = stamps.get(key) ?? {};
34
+ const now = Date.now();
35
+ if (value.isValidating && !previous?.isValidating) stamp.validatingSince = now;
36
+ if (previous?.isValidating && !value.isValidating || value.data !== void 0 && value.data !== previous?.data) stamp.updatedAt = now;
37
+ stamps.set(key, stamp);
38
+ }
39
+ notify();
40
+ };
41
+ cache.delete = (key) => {
42
+ originalDelete.call(cache, key);
43
+ stamps.delete(key);
44
+ notify();
45
+ };
46
+ const useEntries = () => {
47
+ useSyncExternalStore(subscribe, getVersion, getVersion);
48
+ const entries = [];
49
+ for (const key of cache.keys()) {
50
+ if (INTERNAL_KEY.test(key)) continue;
51
+ const state = cache.get(key);
52
+ if (state) entries.push({
53
+ key,
54
+ state,
55
+ stamp: stamps.get(key) ?? {}
56
+ });
57
+ }
58
+ return entries;
59
+ };
60
+ const revalidate = (entry) => {
61
+ mutate(entry.state._k ?? entry.key).catch(() => {});
62
+ };
63
+ function Panel() {
64
+ const entries = useEntries();
65
+ const now = useNow();
66
+ const [selected, setSelected] = useState(null);
67
+ const rows = [...entries].sort((a, b) => (b.stamp.updatedAt ?? 0) - (a.stamp.updatedAt ?? 0)).slice(0, MAX_ROWS);
68
+ const current = selected === null ? void 0 : entries.find((e) => e.key === selected);
69
+ const validating = entries.filter((e) => e.state.isValidating).length;
70
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
71
+ /* @__PURE__ */ jsxs("div", {
72
+ className: "insp-toolbar",
73
+ role: "toolbar",
74
+ "aria-label": "SWR",
75
+ children: [
76
+ /* @__PURE__ */ jsx("span", {
77
+ className: "insp-chip",
78
+ children: entries.length === 1 ? "1 key" : `${entries.length} keys`
79
+ }),
80
+ /* @__PURE__ */ jsxs("span", {
81
+ className: "insp-chip",
82
+ children: [validating, " validating"]
83
+ }),
84
+ /* @__PURE__ */ jsx("button", {
85
+ type: "button",
86
+ className: "insp-chip insp-clear",
87
+ onClick: () => {
88
+ for (const entry of entries) revalidate(entry);
89
+ },
90
+ children: "revalidate all"
91
+ })
92
+ ]
93
+ }),
94
+ /* @__PURE__ */ jsx("div", {
95
+ className: "insp-log",
96
+ role: "listbox",
97
+ "aria-label": "SWR cache",
98
+ children: rows.length === 0 ? /* @__PURE__ */ jsx("p", {
99
+ className: "empty",
100
+ children: "No SWR keys in the cache yet."
101
+ }) : rows.map((entry) => /* @__PURE__ */ jsx(SwrRow, {
102
+ entry,
103
+ now,
104
+ selected: entry.key === selected,
105
+ onClick: () => setSelected((value) => value === entry.key ? null : entry.key)
106
+ }, entry.key))
107
+ }),
108
+ current && /* @__PURE__ */ jsx(SwrDetail, {
109
+ entry: current,
110
+ now,
111
+ onRevalidate: () => revalidate(current)
112
+ })
113
+ ] });
114
+ }
115
+ return {
116
+ id: "swr",
117
+ title: "SWR",
118
+ Panel,
119
+ useCount: () => useEntries().length,
120
+ dispose: () => {
121
+ cache.set = originalSet;
122
+ cache.delete = originalDelete;
123
+ }
124
+ };
125
+ }
126
+ function level(state) {
127
+ if (state.error !== void 0 && state.error !== null) return "error";
128
+ return state.data === void 0 ? "pending" : "ok";
129
+ }
130
+ function phase(state) {
131
+ if (state.isLoading) return "loading";
132
+ if (state.isValidating) return "validating";
133
+ return "settled";
134
+ }
135
+ function SwrRow({ entry, now, selected, onClick }) {
136
+ const { state, stamp } = entry;
137
+ return /* @__PURE__ */ jsxs("button", {
138
+ type: "button",
139
+ role: "option",
140
+ className: "insp-row",
141
+ "aria-selected": selected,
142
+ onClick,
143
+ children: [
144
+ /* @__PURE__ */ jsx("span", {
145
+ className: "insp-method",
146
+ children: state.isValidating ? "fetch" : "cache"
147
+ }),
148
+ /* @__PURE__ */ jsx("span", {
149
+ className: "insp-url",
150
+ title: entry.key,
151
+ children: entry.key
152
+ }),
153
+ state.isValidating && /* @__PURE__ */ jsx("span", {
154
+ className: "insp-badge",
155
+ "data-kind": "replay",
156
+ children: phase(state)
157
+ }),
158
+ /* @__PURE__ */ jsx("span", {
159
+ className: "insp-status",
160
+ "data-level": level(state),
161
+ children: level(state) === "error" ? "ERR" : level(state) === "ok" ? "ok" : "…"
162
+ }),
163
+ /* @__PURE__ */ jsxs("span", {
164
+ className: "insp-sub",
165
+ children: [
166
+ phase(state),
167
+ " · updated ",
168
+ ago(stamp.updatedAt, now)
169
+ ]
170
+ })
171
+ ]
172
+ });
173
+ }
174
+ function SwrDetail({ entry, now, onRevalidate }) {
175
+ const { state, stamp } = entry;
176
+ const error = state.error;
177
+ return /* @__PURE__ */ jsxs("section", {
178
+ className: "insp-detail",
179
+ "aria-label": "Key detail",
180
+ children: [
181
+ /* @__PURE__ */ jsx("div", {
182
+ className: "insp-actions",
183
+ children: /* @__PURE__ */ jsx("button", {
184
+ type: "button",
185
+ className: "insp-action",
186
+ onClick: onRevalidate,
187
+ children: "Revalidate"
188
+ })
189
+ }),
190
+ /* @__PURE__ */ jsxs("dl", {
191
+ className: "insp-kv",
192
+ children: [
193
+ /* @__PURE__ */ jsx("dt", { children: "key" }),
194
+ /* @__PURE__ */ jsx("dd", { children: entry.key }),
195
+ /* @__PURE__ */ jsx("dt", { children: "state" }),
196
+ /* @__PURE__ */ jsx("dd", { children: phase(state) }),
197
+ /* @__PURE__ */ jsx("dt", { children: "updated" }),
198
+ /* @__PURE__ */ jsx("dd", { children: ago(stamp.updatedAt, now) }),
199
+ error !== void 0 && error !== null && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: "error" }), /* @__PURE__ */ jsx("dd", {
200
+ className: "insp-error",
201
+ children: oneLine(error instanceof Error ? error.message : error, 200)
202
+ })] })
203
+ ]
204
+ }),
205
+ state.data !== void 0 && /* @__PURE__ */ jsxs("details", {
206
+ className: "insp-section",
207
+ open: true,
208
+ children: [/* @__PURE__ */ jsx("summary", { children: "Data" }), /* @__PURE__ */ jsx("pre", {
209
+ className: "insp-body",
210
+ "data-section": "data",
211
+ children: prettyPreview(preview(state.data))
212
+ })]
213
+ })
214
+ ]
215
+ });
216
+ }
217
+ //#endregion
218
+ export { inspectSwr };
@@ -0,0 +1,4 @@
1
+ import { i as requestBuffer, n as RequestPayload, r as RequestTransport, t as InspectRequest } from "../requests-CJrUf465.js";
2
+ import { t as InspectAdapter } from "../adapter-BYoxPYTI.js";
3
+ import { a as replay, c as isSensitiveKey, d as redactUrl, i as InspectFilter, l as redactBody, n as InspectOptions, o as replayBlocker, r as inspect, s as REDACTED, t as INSPECT_CAPABILITY, u as redactHeaders } from "../index-CwfX-W87.js";
4
+ export { INSPECT_CAPABILITY, type InspectAdapter, type InspectFilter, InspectOptions, type InspectRequest, REDACTED, type RequestPayload, type RequestTransport, inspect, isSensitiveKey, redactBody, redactHeaders, redactUrl, replay, replayBlocker, requestBuffer };
@@ -0,0 +1,3 @@
1
+ import { d as REDACTED, f as isSensitiveKey, h as redactUrl, l as requestBuffer, m as redactHeaders, p as redactBody } from "../requests-BwD6MKEq.js";
2
+ import { i as replayBlocker, n as inspect, r as replay, t as INSPECT_CAPABILITY } from "../inspect-C9Ft8fqn.js";
3
+ export { INSPECT_CAPABILITY, REDACTED, inspect, isSensitiveKey, redactBody, redactHeaders, redactUrl, replay, replayBlocker, requestBuffer };
@@ -1,64 +1,4 @@
1
- import { c as HudPluginProps } from "../plugins-CQ_0w1ot.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 timing, and long tasks. The observe
6
- * pill installs it when the HUD mounts, so whatever happens before the panel
7
- * is first opened is already there.
8
- */
9
- interface CaptureOptions {
10
- /** Requests to leave out of the log. Default: the HUD's own `/api/hud/` calls. */
11
- ignore?: (url: string) => boolean;
12
- }
13
- //#endregion
14
- //#region src/plugins/observe/info-tab.d.ts
15
- /** The signed-in user as the app knows it. Every field is optional. */
16
- interface HudUserInfo {
17
- name?: string;
18
- email?: string;
19
- id?: string;
20
- role?: string;
21
- /** App-specific extras (organization, tier, locale ...). */
22
- extra?: Record<string, string>;
23
- }
24
- //#endregion
25
- //#region src/plugins/observe/capture-buffer.d.ts
26
- type CaptureKind = "log" | "warn" | "error" | "fetch" | "longtask";
27
- interface CaptureEntry {
28
- id: number;
29
- ts: number;
30
- kind: CaptureKind;
31
- text: string;
32
- status?: number;
33
- durationMs?: number;
34
- }
35
- //#endregion
36
- //#region src/plugins/observe/index.d.ts
37
- export interface ObserveOptions extends CaptureOptions {
38
- /**
39
- * Values for the Info tab, read at the app's import site so Next can inline
40
- * them: `{ NODE_ENV: process.env.NODE_ENV, CONVEX_URL: process.env.NEXT_PUBLIC_CONVEX_URL }`.
41
- * `undefined` shows as "not set".
42
- */
43
- env?: Readonly<Record<string, string | undefined>>;
44
- /** A hook returning the signed-in user, called inside the Info tab. */
45
- useUser?: () => HudUserInfo | null | undefined;
46
- }
47
- /**
48
- * Console and network capture, an app/build/browser/user snapshot and the
49
- * page's Web Vitals. The pill counts errors; opening the panel while there are
50
- * any lands on the console filtered to them.
51
- */
52
- export declare function observe({ env, useUser, ignore }?: ObserveOptions): {
53
- readonly id: "observe";
54
- readonly title: "Observe";
55
- readonly pill: () => import("react").JSX.Element;
56
- readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
57
- readonly commands: readonly [{
58
- readonly id: "clear";
59
- readonly title: "Clear console capture";
60
- readonly run: () => void;
61
- }];
62
- };
63
- //#endregion
64
- export type { CaptureEntry, CaptureKind, CaptureOptions, HudUserInfo };
1
+ import { a as CaptureOptions, n as RequestPayload, r as RequestTransport, t as InspectRequest } from "../requests-CJrUf465.js";
2
+ import { n as CaptureKind, t as CaptureEntry } from "../capture-buffer-Bbbo6omF.js";
3
+ import { n as observe, r as HudUserInfo, t as ObserveOptions } from "../index-BAV_1W8a.js";
4
+ export { type CaptureEntry, type CaptureKind, type CaptureOptions, type HudUserInfo, type InspectRequest, ObserveOptions, type RequestPayload, type RequestTransport, observe };