@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.
- package/README.md +782 -6
- package/dist/a11y-B5DUaiCs.js +246 -0
- package/dist/a11y-panel-p_t4eD7p.js +207 -0
- package/dist/access-C7zlaqj6.js +100 -0
- package/dist/access-D_ewAEJG.d.ts +61 -0
- package/dist/access-panel-CEfTr9ZI.js +123 -0
- package/dist/adapter-BYoxPYTI.d.ts +33 -0
- package/dist/adapter-hcwmJtNx.js +65 -0
- package/dist/auto/runtime.d.ts +65 -0
- package/dist/auto/runtime.js +50 -0
- package/dist/auto.d.ts +15 -0
- package/dist/auto.js +33 -0
- package/dist/capabilities-rDSKjXpq.js +110 -0
- package/dist/capture-CwrIwLqi.js +300 -0
- package/dist/capture-buffer-Bbbo6omF.d.ts +35 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +275 -0
- package/dist/data-panel-DhxAmP91.js +817 -0
- package/dist/data-store-ChF1td_P.js +164 -0
- package/dist/define-hud-CHPedaQ5.d.ts +50 -0
- package/dist/design-D0kGgPoP.js +87 -0
- package/dist/detect-BxHZ0pxW.d.ts +25 -0
- package/dist/detect-CHZiSeZs.js +63 -0
- package/dist/dispatch-panel-B-xr_Giy.js +279 -0
- package/dist/env-CApnbI0r.d.ts +19 -0
- package/dist/env-CaiFPIhF.js +31 -0
- package/dist/file-xdSaQ2uR.js +103 -0
- package/dist/flags-DVtaJ8pQ.d.ts +58 -0
- package/dist/flags.d.ts +2 -0
- package/dist/flags.js +82 -0
- package/dist/force-state-BaqWsmrf.js +153 -0
- package/dist/force-state-CCqoTfVB.d.ts +23 -0
- package/dist/force-state-panel-_otVYh9i.js +97 -0
- package/dist/generate-C8lQl3Eh.js +53 -0
- package/dist/handler-BpVhxEmU.js +106 -0
- package/dist/handler-DtYVCZY6.d.ts +39 -0
- package/dist/index-BAV_1W8a.d.ts +43 -0
- package/dist/index-BJ26pse9.d.ts +70 -0
- package/dist/index-BnQ0dTZf.d.ts +19 -0
- package/dist/index-CwfX-W87.d.ts +72 -0
- package/dist/index-DcH9V3cU.d.ts +48 -0
- package/dist/index-DqOyNf1u.d.ts +65 -0
- package/dist/index-DstI_ike.d.ts +66 -0
- package/dist/index-Dxz4fn4j.d.ts +42 -0
- package/dist/index-Hhh7OXzU.d.ts +129 -0
- package/dist/index-ReFbhQ9p.d.ts +25 -0
- package/dist/index-RgXfMBuW.d.ts +48 -0
- package/dist/index-gCZBO53s.d.ts +73 -0
- package/dist/index.d.ts +6 -36
- package/dist/index.js +798 -240
- package/dist/inspect-C9Ft8fqn.js +142 -0
- package/dist/inspect-root-BkaupBMp.js +429 -0
- package/dist/marker-C66LxOhJ.d.ts +9 -0
- package/dist/marker-CMrvxPmS.d.ts +12 -0
- package/dist/marker-DjeGvL-F.js +9 -0
- package/dist/marker-uZYPOJ4M.js +12 -0
- package/dist/markers.d.ts +3 -0
- package/dist/markers.js +3 -0
- package/dist/meta-Bv0sEao3.js +6 -0
- package/dist/meta-C_G7MB5w.d.ts +49 -0
- package/dist/mocks-CA-wM2SB.d.ts +109 -0
- package/dist/mocks-ESiRqk9o.js +150 -0
- package/dist/msw-browser-wjaYgkB7.d.ts +31 -0
- package/dist/next/config.d.ts +52 -0
- package/dist/next/config.js +78 -0
- package/dist/next.d.ts +14 -19
- package/dist/next.js +7 -30
- package/dist/observe-CdDnDBRP.js +89 -0
- package/dist/observe-panel-Cgp1M8oT.js +347 -0
- package/dist/ops-panel-CEqDe_UT.js +234 -0
- package/dist/payload-MUQ9ciER.d.ts +92 -0
- package/dist/plugins/a11y.d.ts +2 -0
- package/dist/plugins/a11y.js +2 -0
- package/dist/plugins/access/server.d.ts +122 -0
- package/dist/plugins/access/server.js +340 -0
- package/dist/plugins/access.d.ts +41 -0
- package/dist/plugins/access.js +51 -0
- package/dist/plugins/agent/server.d.ts +94 -0
- package/dist/plugins/agent/server.js +455 -0
- package/dist/plugins/agent.d.ts +37 -0
- package/dist/plugins/agent.js +69 -0
- package/dist/plugins/capture/server.d.ts +92 -0
- package/dist/plugins/capture/server.js +248 -0
- package/dist/plugins/capture.d.ts +24 -0
- package/dist/plugins/capture.js +70 -0
- package/dist/plugins/data/msw-browser.d.ts +2 -0
- package/dist/plugins/data/msw-browser.js +39 -0
- package/dist/plugins/data/msw-node.d.ts +36 -0
- package/dist/plugins/data/msw-node.js +68 -0
- package/dist/plugins/data/server.d.ts +257 -0
- package/dist/plugins/data/server.js +717 -0
- package/dist/plugins/data.d.ts +6 -0
- package/dist/plugins/data.js +51 -0
- package/dist/plugins/design/server.d.ts +54 -0
- package/dist/plugins/design/server.js +198 -0
- package/dist/plugins/design.d.ts +5 -0
- package/dist/plugins/design.js +4 -0
- package/dist/plugins/inspect/convex.d.ts +2 -0
- package/dist/plugins/inspect/convex.js +486 -0
- package/dist/plugins/inspect/react-query.d.ts +2 -0
- package/dist/plugins/inspect/react-query.js +225 -0
- package/dist/plugins/inspect/sockets.d.ts +51 -0
- package/dist/plugins/inspect/sockets.js +397 -0
- package/dist/plugins/inspect/swr.d.ts +2 -0
- package/dist/plugins/inspect/swr.js +218 -0
- package/dist/plugins/inspect.d.ts +4 -0
- package/dist/plugins/inspect.js +3 -0
- package/dist/plugins/observe.d.ts +4 -0
- package/dist/plugins/observe.js +2 -0
- package/dist/plugins/ops/server.d.ts +82 -0
- package/dist/plugins/ops/server.js +381 -0
- package/dist/plugins/ops.d.ts +27 -0
- package/dist/plugins/ops.js +41 -0
- package/dist/plugins/routes/server.d.ts +88 -0
- package/dist/plugins/routes/server.js +62 -0
- package/dist/plugins/routes.d.ts +3 -0
- package/dist/plugins/routes.js +216 -0
- package/dist/plugins/seo.d.ts +2 -0
- package/dist/plugins/seo.js +2 -0
- package/dist/plugins/vitals.d.ts +2 -25
- package/dist/plugins/vitals.js +4 -86
- package/dist/plugins-BZvDqGx5.d.ts +144 -0
- package/dist/{plugins-CzUiTn_r.js → plugins-DVy_vaYr.js} +3 -1
- package/dist/poll-CjKsWZi8.js +89 -0
- package/dist/requests-BwD6MKEq.js +282 -0
- package/dist/requests-CJrUf465.d.ts +50 -0
- package/dist/review.d.ts +181 -0
- package/dist/review.js +1017 -0
- package/dist/same-origin-BGet22CC.js +21 -0
- package/dist/scan-DzJNXqOk.js +165 -0
- package/dist/selector-NSYSe7AZ.js +28 -0
- package/dist/seo-Dq9q_QkO.js +551 -0
- package/dist/seo-panel-CfiY-TnT.js +124 -0
- package/dist/server.d.ts +3 -39
- package/dist/server.js +2 -105
- package/dist/sessions-panel-COvhPAzv.js +98 -0
- package/dist/shortcut-s_mjGeU8.js +179 -0
- package/dist/state-CjjZPjPJ.js +40 -0
- package/dist/state-boundary.d.ts +26 -0
- package/dist/state-boundary.js +61 -0
- package/dist/store/convex.d.ts +33 -0
- package/dist/store/convex.js +52 -0
- package/dist/store-CQqIIKTc.js +59 -0
- package/dist/store-Ync9eb1G.js +67 -0
- package/dist/store.d.ts +76 -0
- package/dist/store.js +188 -0
- package/dist/styles-BA8ueHoV.js +342 -0
- package/dist/styles-DKU_P8MH.js +139 -0
- package/dist/styles-DPpDPmzi.js +68 -0
- package/dist/tokens-panel-CbMQfasZ.js +142 -0
- package/dist/types-B-ulf2Jp.js +8 -0
- package/dist/types-BIgGf-0C.d.ts +25 -0
- package/dist/types-BIkI-qN8.js +30 -0
- package/dist/types-Cxh4twqc.d.ts +50 -0
- package/dist/types-DIdPfjtV.js +6 -0
- package/dist/types-DaJcsEjO.d.ts +44 -0
- package/dist/types-Dn68psVz.d.ts +118 -0
- package/dist/types-f3jlNxzw.d.ts +92 -0
- package/dist/types-szkr2QOF.d.ts +39 -0
- package/dist/unlock-store-4V3vR4Eg.js +96 -0
- package/dist/variant-groups-TIfO3NIj.js +137 -0
- package/dist/variant-groups-aAIrcNK5.d.ts +36 -0
- package/dist/variants-panel-BDoSkwBJ.js +457 -0
- package/dist/variants-types-CcRf119M.d.ts +63 -0
- package/dist/variants.d.ts +43 -0
- package/dist/variants.js +83 -0
- package/dist/vitals-panel-BCmMUntW.js +30 -0
- package/dist/vite.d.ts +37 -0
- package/dist/vite.js +134 -0
- package/package.json +85 -5
- package/dist/define-hud-BHQR8Lbv.d.ts +0 -31
- package/dist/plugins-1QmTmZyL.d.ts +0 -76
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { o as HudPlugin } from "./plugins-BZvDqGx5.js";
|
|
2
|
+
import { r as HudHandlerOptions, t as HudGuard } from "./handler-DtYVCZY6.js";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
//#region src/vite/index.d.ts
|
|
5
|
+
export interface HudViteOptions extends HudHandlerOptions {
|
|
6
|
+
/** The plugins' server halves (`@hansenexus/hud/plugins/<id>/server`). Default: none. */
|
|
7
|
+
plugins?: readonly HudPlugin[];
|
|
8
|
+
/**
|
|
9
|
+
* The package.json detection reads for `@hansenexus/hud/auto`. Default:
|
|
10
|
+
* `package.json` in Vite's root.
|
|
11
|
+
*/
|
|
12
|
+
packageJson?: string;
|
|
13
|
+
}
|
|
14
|
+
/** What the app imports; the plugin resolves it to the generated module. */
|
|
15
|
+
export declare const AUTO_ID = "@hansenexus/hud/auto";
|
|
16
|
+
/** The source of `@hansenexus/hud/auto` for the package.json at `path`; a missing file detects nothing. */
|
|
17
|
+
export declare function loadAutoModule(path: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Two jobs. In `vite dev` the plugin routes: `createHudHandler` runs as
|
|
20
|
+
* middleware under `basePath` (default `/api/hud`), ahead of Vite's own
|
|
21
|
+
* middlewares, so `/api/hud/<plugin>/<path>` never falls through to
|
|
22
|
+
* `index.html`; `vite build` and `vite preview` never see it, and the client
|
|
23
|
+
* build gate stays the consumer's `import.meta.env.DEV` literal around the
|
|
24
|
+
* `import()`.
|
|
25
|
+
*
|
|
26
|
+
* In dev and build alike, `@hansenexus/hud/auto`: the plugin reads the app's
|
|
27
|
+
* package.json and serves a module that imports only the plugins the
|
|
28
|
+
* dependencies call for (`enforce: "pre"`, so Vite's resolver never reaches
|
|
29
|
+
* the package's stand-in). The file is watched; editing package.json
|
|
30
|
+
* regenerates the module.
|
|
31
|
+
*
|
|
32
|
+
* `guard` and `can` work as in `createHudHandler`. The default guard answers
|
|
33
|
+
* 404 unless `NODE_ENV` is `development`, which Vite sets for `vite dev`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hud(options?: HudViteOptions): Plugin;
|
|
36
|
+
//#endregion
|
|
37
|
+
export type { HudGuard, HudHandlerOptions };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { t as createHudHandler } from "./handler-BpVhxEmU.js";
|
|
2
|
+
import { n as detectHudAuto, r as parsePackageJson } from "./detect-CHZiSeZs.js";
|
|
3
|
+
import { t as generateAutoModule } from "./generate-C8lQl3Eh.js";
|
|
4
|
+
//#region src/vite/bridge.ts
|
|
5
|
+
const BODYLESS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
6
|
+
/** Absolute URL of a Node request; the host header supplies the origin. */
|
|
7
|
+
function requestUrl(req) {
|
|
8
|
+
const host = req.headers.host;
|
|
9
|
+
const origin = `${req.socket?.encrypted ? "https" : "http"}://${typeof host === "string" && host ? host : "localhost"}`;
|
|
10
|
+
return new URL(req.url ?? "/", origin);
|
|
11
|
+
}
|
|
12
|
+
function concat(chunks) {
|
|
13
|
+
const out = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.byteLength, 0));
|
|
14
|
+
let offset = 0;
|
|
15
|
+
for (const chunk of chunks) {
|
|
16
|
+
out.set(chunk, offset);
|
|
17
|
+
offset += chunk.byteLength;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
/** A Fetch `Request` with the Node request's method, headers and (buffered) body. */
|
|
22
|
+
async function toRequest(req, url = requestUrl(req)) {
|
|
23
|
+
const method = req.method ?? "GET";
|
|
24
|
+
const headers = new Headers();
|
|
25
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
26
|
+
if (value === void 0) continue;
|
|
27
|
+
if (Array.isArray(value)) for (const entry of value) headers.append(name, entry);
|
|
28
|
+
else headers.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
let body;
|
|
31
|
+
if (!BODYLESS.has(method)) {
|
|
32
|
+
const chunks = [];
|
|
33
|
+
for await (const chunk of req) chunks.push(chunk);
|
|
34
|
+
body = concat(chunks);
|
|
35
|
+
}
|
|
36
|
+
return new Request(url, {
|
|
37
|
+
method,
|
|
38
|
+
headers,
|
|
39
|
+
body: body ?? null
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Streams a Fetch `Response` into the Node response; every `Set-Cookie` survives. */
|
|
43
|
+
async function writeResponse(response, res) {
|
|
44
|
+
res.statusCode = response.status;
|
|
45
|
+
for (const [name, value] of response.headers) if (name !== "set-cookie") res.setHeader(name, value);
|
|
46
|
+
const cookies = response.headers.getSetCookie();
|
|
47
|
+
if (cookies.length > 0) res.setHeader("set-cookie", cookies);
|
|
48
|
+
if (!response.body) {
|
|
49
|
+
res.end();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const reader = response.body.getReader();
|
|
53
|
+
res.on("close", () => {
|
|
54
|
+
reader.cancel().catch(() => {});
|
|
55
|
+
});
|
|
56
|
+
for (;;) {
|
|
57
|
+
const { done, value } = await reader.read();
|
|
58
|
+
if (done) break;
|
|
59
|
+
res.write(value);
|
|
60
|
+
}
|
|
61
|
+
res.end();
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/vite/index.ts
|
|
65
|
+
/** What the app imports; the plugin resolves it to the generated module. */
|
|
66
|
+
const AUTO_ID = "@hansenexus/hud/auto";
|
|
67
|
+
const RESOLVED_AUTO_ID = "\0hansenexus-hud:auto";
|
|
68
|
+
function normalizeBase(basePath) {
|
|
69
|
+
return `/${basePath.split("/").filter(Boolean).join("/")}`;
|
|
70
|
+
}
|
|
71
|
+
/** The source of `@hansenexus/hud/auto` for the package.json at `path`; a missing file detects nothing. */
|
|
72
|
+
async function loadAutoModule(path) {
|
|
73
|
+
const { readFile } = await import("node:fs/promises");
|
|
74
|
+
let text = "{}";
|
|
75
|
+
try {
|
|
76
|
+
text = await readFile(path, "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
console.warn(`hud: ${path} not found; @hansenexus/hud/auto enables the base plugins only`);
|
|
79
|
+
}
|
|
80
|
+
return generateAutoModule(detectHudAuto(parsePackageJson(text)), path);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Two jobs. In `vite dev` the plugin routes: `createHudHandler` runs as
|
|
84
|
+
* middleware under `basePath` (default `/api/hud`), ahead of Vite's own
|
|
85
|
+
* middlewares, so `/api/hud/<plugin>/<path>` never falls through to
|
|
86
|
+
* `index.html`; `vite build` and `vite preview` never see it, and the client
|
|
87
|
+
* build gate stays the consumer's `import.meta.env.DEV` literal around the
|
|
88
|
+
* `import()`.
|
|
89
|
+
*
|
|
90
|
+
* In dev and build alike, `@hansenexus/hud/auto`: the plugin reads the app's
|
|
91
|
+
* package.json and serves a module that imports only the plugins the
|
|
92
|
+
* dependencies call for (`enforce: "pre"`, so Vite's resolver never reaches
|
|
93
|
+
* the package's stand-in). The file is watched; editing package.json
|
|
94
|
+
* regenerates the module.
|
|
95
|
+
*
|
|
96
|
+
* `guard` and `can` work as in `createHudHandler`. The default guard answers
|
|
97
|
+
* 404 unless `NODE_ENV` is `development`, which Vite sets for `vite dev`.
|
|
98
|
+
*/
|
|
99
|
+
function hud(options = {}) {
|
|
100
|
+
const { plugins = [], packageJson, ...handlerOptions } = options;
|
|
101
|
+
const basePath = normalizeBase(handlerOptions.basePath ?? "/api/hud");
|
|
102
|
+
const handler = createHudHandler(plugins, {
|
|
103
|
+
...handlerOptions,
|
|
104
|
+
basePath
|
|
105
|
+
});
|
|
106
|
+
let manifest = packageJson ?? "package.json";
|
|
107
|
+
return {
|
|
108
|
+
name: "hansenexus-hud",
|
|
109
|
+
enforce: "pre",
|
|
110
|
+
configResolved(config) {
|
|
111
|
+
manifest = packageJson ?? `${config.root}/package.json`;
|
|
112
|
+
},
|
|
113
|
+
resolveId(id) {
|
|
114
|
+
return id === "@hansenexus/hud/auto" ? RESOLVED_AUTO_ID : null;
|
|
115
|
+
},
|
|
116
|
+
async load(id) {
|
|
117
|
+
if (id !== RESOLVED_AUTO_ID) return null;
|
|
118
|
+
this.addWatchFile(manifest);
|
|
119
|
+
return loadAutoModule(manifest);
|
|
120
|
+
},
|
|
121
|
+
configureServer(server) {
|
|
122
|
+
server.middlewares.use((req, res, next) => {
|
|
123
|
+
const url = requestUrl(req);
|
|
124
|
+
if (url.pathname !== basePath && !url.pathname.startsWith(`${basePath}/`)) {
|
|
125
|
+
next();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
toRequest(req, url).then((request) => handler.handle(request)).then((response) => writeResponse(response, res)).catch(next);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { AUTO_ID, hud, loadAutoModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hansenexus/hud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Modular dev HUD for React apps: status pill, floating panels, element grabber, plugin API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
"workspaces": [
|
|
12
12
|
".",
|
|
13
|
-
"playground"
|
|
13
|
+
"playground",
|
|
14
|
+
"fixtures/next-app",
|
|
15
|
+
"fixtures/vite-app"
|
|
14
16
|
],
|
|
15
17
|
"files": [
|
|
16
18
|
"dist",
|
|
@@ -30,11 +32,58 @@
|
|
|
30
32
|
"types": "./dist/next.d.ts",
|
|
31
33
|
"import": "./dist/next.js"
|
|
32
34
|
},
|
|
35
|
+
"./next/config": {
|
|
36
|
+
"types": "./dist/next/config.d.ts",
|
|
37
|
+
"import": "./dist/next/config.js"
|
|
38
|
+
},
|
|
39
|
+
"./vite": {
|
|
40
|
+
"types": "./dist/vite.d.ts",
|
|
41
|
+
"import": "./dist/vite.js"
|
|
42
|
+
},
|
|
43
|
+
"./auto": {
|
|
44
|
+
"types": "./dist/auto.d.ts",
|
|
45
|
+
"import": "./dist/auto.js"
|
|
46
|
+
},
|
|
47
|
+
"./auto/runtime": {
|
|
48
|
+
"types": "./dist/auto/runtime.d.ts",
|
|
49
|
+
"import": "./dist/auto/runtime.js"
|
|
50
|
+
},
|
|
33
51
|
"./plugins/*": {
|
|
34
52
|
"types": "./dist/plugins/*.d.ts",
|
|
35
53
|
"import": "./dist/plugins/*.js"
|
|
54
|
+
},
|
|
55
|
+
"./state-boundary": {
|
|
56
|
+
"types": "./dist/state-boundary.d.ts",
|
|
57
|
+
"import": "./dist/state-boundary.js"
|
|
58
|
+
},
|
|
59
|
+
"./variants": {
|
|
60
|
+
"types": "./dist/variants.d.ts",
|
|
61
|
+
"import": "./dist/variants.js"
|
|
62
|
+
},
|
|
63
|
+
"./flags": {
|
|
64
|
+
"types": "./dist/flags.d.ts",
|
|
65
|
+
"import": "./dist/flags.js"
|
|
66
|
+
},
|
|
67
|
+
"./store": {
|
|
68
|
+
"types": "./dist/store.d.ts",
|
|
69
|
+
"import": "./dist/store.js"
|
|
70
|
+
},
|
|
71
|
+
"./store/convex": {
|
|
72
|
+
"types": "./dist/store/convex.d.ts",
|
|
73
|
+
"import": "./dist/store/convex.js"
|
|
74
|
+
},
|
|
75
|
+
"./review": {
|
|
76
|
+
"types": "./dist/review.d.ts",
|
|
77
|
+
"import": "./dist/review.js"
|
|
78
|
+
},
|
|
79
|
+
"./markers": {
|
|
80
|
+
"types": "./dist/markers.d.ts",
|
|
81
|
+
"import": "./dist/markers.js"
|
|
36
82
|
}
|
|
37
83
|
},
|
|
84
|
+
"bin": {
|
|
85
|
+
"hud": "./dist/cli.js"
|
|
86
|
+
},
|
|
38
87
|
"sideEffects": false,
|
|
39
88
|
"scripts": {
|
|
40
89
|
"dev": "bun run --cwd playground dev",
|
|
@@ -44,29 +93,60 @@
|
|
|
44
93
|
"format": "biome check --write .",
|
|
45
94
|
"test": "vitest run",
|
|
46
95
|
"test:watch": "vitest",
|
|
47
|
-
"
|
|
96
|
+
"test:e2e": "playwright test",
|
|
97
|
+
"check": "bun run lint && bun run typecheck && bun run test && bun run build && bun run check:pack && bun run check:size",
|
|
48
98
|
"changeset": "changeset",
|
|
49
99
|
"version-packages": "changeset version",
|
|
50
|
-
"check:pack": "bun scripts/check-pack.ts"
|
|
100
|
+
"check:pack": "bun scripts/check-pack.ts",
|
|
101
|
+
"check:size": "bun scripts/check-size.ts"
|
|
51
102
|
},
|
|
52
103
|
"dependencies": {
|
|
53
104
|
"web-vitals": "^6.2.3"
|
|
54
105
|
},
|
|
55
106
|
"peerDependencies": {
|
|
56
107
|
"react": "^19.0.0",
|
|
57
|
-
"react-dom": "^19.0.0"
|
|
108
|
+
"react-dom": "^19.0.0",
|
|
109
|
+
"convex": "^1.43.0",
|
|
110
|
+
"playwright": ">=1.40.0",
|
|
111
|
+
"@playwright/test": ">=1.40.0",
|
|
112
|
+
"vite": ">=6.0.0",
|
|
113
|
+
"msw": ">=3.0.0"
|
|
114
|
+
},
|
|
115
|
+
"peerDependenciesMeta": {
|
|
116
|
+
"convex": {
|
|
117
|
+
"optional": true
|
|
118
|
+
},
|
|
119
|
+
"playwright": {
|
|
120
|
+
"optional": true
|
|
121
|
+
},
|
|
122
|
+
"@playwright/test": {
|
|
123
|
+
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"vite": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"msw": {
|
|
129
|
+
"optional": true
|
|
130
|
+
}
|
|
58
131
|
},
|
|
59
132
|
"devDependencies": {
|
|
60
133
|
"@biomejs/biome": "^2.5.15",
|
|
61
134
|
"@changesets/changelog-github": "^1.0.1",
|
|
62
135
|
"@changesets/cli": "^3.0.3",
|
|
136
|
+
"@playwright/test": "1.63.0",
|
|
137
|
+
"@tanstack/react-query": "^5.104.1",
|
|
63
138
|
"@testing-library/react": "^16.3.3",
|
|
64
139
|
"@types/react": "^19.3.0",
|
|
65
140
|
"@types/react-dom": "^19.3.0",
|
|
141
|
+
"convex": "^1.46.0",
|
|
66
142
|
"jsdom": "^30.1.2",
|
|
143
|
+
"msw": "^3.0.2",
|
|
144
|
+
"playwright": "1.63.0",
|
|
67
145
|
"rolldown": "^1.2.12",
|
|
146
|
+
"swr": "^2.5.1",
|
|
68
147
|
"tsdown": "^0.23.0",
|
|
69
148
|
"typescript": "^7.0.2",
|
|
149
|
+
"vite": "^8.3.3",
|
|
70
150
|
"vitest": "^5.0.3"
|
|
71
151
|
},
|
|
72
152
|
"publishConfig": {
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { a as HudPlugin, n as HudCapability } from "./plugins-1QmTmZyL.js";
|
|
2
|
-
import { ComponentType } from "react";
|
|
3
|
-
//#region src/core/define-hud.d.ts
|
|
4
|
-
interface DefineHudOptions {
|
|
5
|
-
/** App slug: labels the pill and keys the persisted layout. */
|
|
6
|
-
app: string;
|
|
7
|
-
/** Client halves (`@hansenexus/hud/plugins/<id>`), in pill order. */
|
|
8
|
-
plugins: readonly HudPlugin[];
|
|
9
|
-
/** Base path of the catch-all route serving `createHudHandler`. Default "/api/hud". */
|
|
10
|
-
apiBase?: string;
|
|
11
|
-
/** Capability check. Default: grant all (core assumes development). */
|
|
12
|
-
can?: (capability: HudCapability) => boolean;
|
|
13
|
-
}
|
|
14
|
-
/** Props the loader passes in at mount time. */
|
|
15
|
-
interface HudMountProps {
|
|
16
|
-
/** Badge at the start of the pill. Default "DEV". */
|
|
17
|
-
envLabel?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The app's one HUD file:
|
|
21
|
-
*
|
|
22
|
-
* ```tsx
|
|
23
|
-
* export default defineHud({ app: "hansenexus", plugins: [vitals()] });
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Returns a component. The plugin list is frozen here, so the shell sees a
|
|
27
|
-
* stable array across renders.
|
|
28
|
-
*/
|
|
29
|
-
declare function defineHud({ app, plugins, apiBase, can }: DefineHudOptions): ComponentType<HudMountProps>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { HudMountProps as n, defineHud as r, DefineHudOptions as t };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from "react";
|
|
2
|
-
//#region src/core/plugins.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* A capability a plugin needs, such as `"cicd.read"`. Core assumes development
|
|
5
|
-
* and grants everything; the `access` plugin brings a matrix for deployed tiers.
|
|
6
|
-
*/
|
|
7
|
-
type HudCapability = string;
|
|
8
|
-
type PinEdge = "left" | "right" | "bottom";
|
|
9
|
-
/** What a plugin's panel and pill receive from the shell. */
|
|
10
|
-
interface HudPluginContext {
|
|
11
|
-
/** App slug from `defineHud({ app })`. */
|
|
12
|
-
app: string;
|
|
13
|
-
/** Whether the current tier grants `capability`. */
|
|
14
|
-
can: (capability: HudCapability) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Fetches JSON from this plugin's server routes: `api("/runs")` requests
|
|
17
|
-
* `<apiBase>/<plugin id>/runs`. Rejects with `HudApiError` on a non-2xx status.
|
|
18
|
-
*/
|
|
19
|
-
api: <T = unknown>(path: string, init?: RequestInit) => Promise<T>;
|
|
20
|
-
/** Pins this plugin's panel to an edge. Below 768 px the pin is kept but not applied. */
|
|
21
|
-
pin: (edge: PinEdge) => void;
|
|
22
|
-
/** Closes this plugin's panel. */
|
|
23
|
-
close: () => void;
|
|
24
|
-
}
|
|
25
|
-
interface HudPluginProps {
|
|
26
|
-
ctx: HudPluginContext;
|
|
27
|
-
}
|
|
28
|
-
interface HudCommand {
|
|
29
|
-
/** Unique within the plugin. */
|
|
30
|
-
id: string;
|
|
31
|
-
title: string;
|
|
32
|
-
/** Shortcut in `mod+shift+k` form; `mod` is ⌘ on macOS and Ctrl elsewhere. */
|
|
33
|
-
shortcut?: string;
|
|
34
|
-
run: (ctx: HudPluginContext) => void;
|
|
35
|
-
}
|
|
36
|
-
type HudHttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
37
|
-
interface HudRouteContext {
|
|
38
|
-
/** Values of `:name` segments in the matched path. */
|
|
39
|
-
params: Record<string, string>;
|
|
40
|
-
}
|
|
41
|
-
type HudRouteHandler = (request: Request, ctx: HudRouteContext) => Response | Promise<Response>;
|
|
42
|
-
/**
|
|
43
|
-
* Server routes keyed by path below the plugin's prefix, then by method:
|
|
44
|
-
* `{ "/runs/:id": { GET } }` serves `GET <apiBase>/<plugin id>/runs/42`.
|
|
45
|
-
*/
|
|
46
|
-
type HudRoutes = Record<string, Partial<Record<HudHttpMethod, HudRouteHandler>>>;
|
|
47
|
-
/**
|
|
48
|
-
* The plugin contract. A plugin ships as two subpath exports that share this
|
|
49
|
-
* type: `@hansenexus/hud/plugins/<id>` carries the client half (`panel`,
|
|
50
|
-
* `pill`, `commands`) and `@hansenexus/hud/plugins/<id>/server` the server half
|
|
51
|
-
* (`routes`), so route code never reaches a client bundle and React never
|
|
52
|
-
* reaches the route handler. Both halves carry the same `id` and `capability`.
|
|
53
|
-
*/
|
|
54
|
-
interface HudPlugin {
|
|
55
|
-
/** Unique per HUD; also the URL segment of the plugin's routes. */
|
|
56
|
-
id: string;
|
|
57
|
-
/** Panel title and pill label when the plugin has no `pill`. Defaults to `id`. */
|
|
58
|
-
title?: string;
|
|
59
|
-
/** Without it the plugin is dropped, client and server side. */
|
|
60
|
-
capability?: HudCapability;
|
|
61
|
-
/** Floating panel content, opened from the plugin's pill item. */
|
|
62
|
-
panel?: ComponentType<HudPluginProps>;
|
|
63
|
-
/** Live content inside the plugin's pill item. Keep it inline and non-interactive. */
|
|
64
|
-
pill?: ComponentType<HudPluginProps>;
|
|
65
|
-
commands?: readonly HudCommand[];
|
|
66
|
-
routes?: HudRoutes;
|
|
67
|
-
}
|
|
68
|
-
/** Identity helper that types a plugin object without widening it. */
|
|
69
|
-
declare function definePlugin<const P extends HudPlugin>(plugin: P): P;
|
|
70
|
-
declare class HudApiError extends Error {
|
|
71
|
-
readonly status: number;
|
|
72
|
-
readonly body: unknown;
|
|
73
|
-
constructor(status: number, body: unknown, url: string);
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
export { HudPlugin as a, HudRouteContext as c, PinEdge as d, definePlugin as f, HudHttpMethod as i, HudRouteHandler as l, HudCapability as n, HudPluginContext as o, HudCommand as r, HudPluginProps as s, HudApiError as t, HudRoutes as u };
|