@coreframe/dashboard 0.1.1 → 0.1.3
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 +11 -14
- package/dist/src/development.js +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/server.d.ts +1 -6
- package/dist/src/server.js +1 -1
- package/package.json +2 -7
- package/dist/src/cli.d.ts +0 -1
- package/dist/src/cli.js +0 -8
package/README.md
CHANGED
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Local and deployed dashboard runtime for Coreframe projects.
|
|
4
4
|
|
|
5
|
-
The
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
The shared Vite preset serves the local dashboard at `/__dashboard`. The Node.js request handler
|
|
6
|
+
serves the compiled React client, production-readiness diagnostics, and controls for one
|
|
7
|
+
dashboard-owned development process.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
pnpm dev
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The command fails before launch when `https://coreframe.localhost` already
|
|
14
|
-
responds.
|
|
15
|
-
|
|
16
13
|
## Architecture
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
The `@coreframe/vite/dashboard` plugin mounts the Node.js request handler in the application Vite
|
|
16
|
+
server. This keeps the dashboard on the same local origin as the application and avoids a separate
|
|
17
|
+
dashboard process.
|
|
21
18
|
|
|
22
19
|
The browser setup intentionally mirrors the generated Coreframe web app where that contract is
|
|
23
20
|
useful: React Router owns the client-only route tree and hydration, TanStack Query owns server
|
|
@@ -27,8 +24,8 @@ does not import files from `template/`.
|
|
|
27
24
|
|
|
28
25
|
The runtime boundary remains dashboard-specific. A small Node adapter converts
|
|
29
26
|
`IncomingMessage`/`ServerResponse` to the Fetch API so Rouzer remains the single typed API
|
|
30
|
-
contract. Node
|
|
31
|
-
|
|
27
|
+
contract. Node owns local static files and development-process cleanup. A separate Worker-safe
|
|
28
|
+
entry point owns the reduced deployed runtime.
|
|
32
29
|
|
|
33
30
|
The backend exposes these routes:
|
|
34
31
|
|
|
@@ -70,10 +67,10 @@ Regenerate the committed Panda runtime after changing `panda.config.ts` or style
|
|
|
70
67
|
pnpm --dir dashboard codegen
|
|
71
68
|
```
|
|
72
69
|
|
|
73
|
-
Run the
|
|
70
|
+
Run the application development server, then open `/__dashboard`:
|
|
74
71
|
|
|
75
72
|
```bash
|
|
76
|
-
pnpm --dir
|
|
73
|
+
pnpm --dir template dev
|
|
77
74
|
```
|
|
78
75
|
|
|
79
76
|
Useful package checks:
|
package/dist/src/development.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{access as e}from"node:fs/promises";import{join as t}from"node:path";import{spawn as n}from"node:child_process";import{createServer as r}from"node:net";import{readProjectConfig as i}from"@coreframe/scripts/config";import{resolveDevPlatforms as a}from"@coreframe/scripts/dev";var o=class extends Error{status;constructor(e,t){super(e),this.status=t}};const s={web:`Web`,desktop:`Desktop`,ios:`iOS`,android:`Android`},c=process.platform===`win32`?`pnpm.cmd`:`pnpm`,l=RegExp(`\x1B\\][^\\x07]*(?:\\x07|\x1B\\\\)`,`g`),u=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`);function d({env:e=process.env,getAvailablePort:n=_,hostPlatform:r=process.platform,killProcess:l=b,probeWebUrl:u=v,projectRoot:d,readConfig:S=i,spawnProcess:C=m}){let w,T=0,E=[],D=1,O;async function k(){let e=a(await S({cwd:d})),n=await x(t(d,`tauri/src-tauri/tauri.conf.json`));return e.map(e=>{let t=f(e,{hasTauri:n,hostPlatform:r});return{platform:e,label:s[e],available:t===void 0,...t?{unavailableReason:t}:{}}})}async function A(){let e=await k();return O&&!e.some(e=>e.platform===O?.platform)&&e.push({platform:O.platform,label:s[O.platform],available:!0}),{targets:e,logs:[...E],...O?{session:O}:{}}}async function j(t){if(p(O))throw new o(`${s[O.platform]} development is already ${O.status}. Stop it before starting another target.`,409);let r=await k(),i=r.find(e=>e.platform===t);if(!i)throw new o(`Select a configured development target.`,400);if(!i.available)throw new o(i.unavailableReason??`${i.label} development is unavailable.`,400);let a=i.platform===`web`?await n():void 0,l=a===void 0?void 0:`http://localhost:${a}`;E=[],T=0,D=1,O={platform:i.platform,status:`starting`,startedAt:new Date().toISOString(),...l?{url:l}:{}};try{let t=C({args:i.platform===`web`?[`dev`]:[`dev`,i.platform],command:c,cwd:d,env:{...e,FORCE_COLOR:`0`,...a===void 0?{}:{COREFRAME_WEB_PORT:String(a)}}});w=t,h(t,P),t.once(`spawn`,()=>{w===t&&O?.status===`starting`&&(O={...O,status:`running`},l&&F(t,l))}),t.once(`error`,()=>{w===t&&(w=void 0,O={...O,status:`failed`,message:`The development process could not be started.`})}),t.once(`exit`,e=>{if(w!==t)return;w=void 0;let n=O?.status===`stopping`;O={...O,status:n||e===0?`stopped`:`failed`,...typeof e==`number`?{exitCode:e}:{},...!n&&e!==0?{message:`The development process exited before it was stopped.`}:{}}})}catch{let e=`The development process could not be started.`;throw w=void 0,O={...O,status:`failed`,message:e},new o(e,500)}return{targets:r,logs:[...E],session:O}}async function M(){if(!w||!p(O))throw new o(`No dashboard-owned development process is running.`,409);O={...O,status:`stopping`};try{await l(w)}catch{let e=`The development process could not be stopped.`;throw O={...O,status:`failed`,message:e},new o(e,500)}return A()}async function N(){if(w&&p(O))try{O={...O,status:`stopping`},await l(w)}catch{}}function P(e,t){let n=g(String(t)).slice(-16e3);if(n)for(E.push({sequence:D++,stream:e,text:n}),T+=n.length;T>2e5&&E.length>1;)T-=E.shift()?.text.length??0}async function F(e,t){for(;w===e&&p(O)&&!O.readyAt;){if(await u(t)){w===e&&p(O)&&(O={...O,readyAt:new Date().toISOString()});return}await y(250)}}return{dispose:N,getState:A,start:j,stop:M}}function f(e,t){if(e!==`web`){if(!t.hasTauri)return`Tauri is not configured for this project.`;if(e===`ios`&&t.hostPlatform!==`darwin`)return`iOS development requires macOS.`}}function p(e){return[`running`,`starting`,`stopping`].includes(e?.status??``)}function m(e){return n(e.command,e.args,{cwd:e.cwd,detached:process.platform!==`win32`,env:e.env,shell:!1,stdio:[`ignore`,`pipe`,`pipe`]})}function h(e,t){e.stdout?.on(`data`,e=>t(`stdout`,e)),e.stderr?.on(`data`,e=>t(`stderr`,e))}function g(e){return e.replace(l,``).replace(u,``)}async function _(){let e=r();try{await new Promise((t,n)=>{e.once(`error`,n),e.listen(0,`127.0.0.1`,t)});let t=e.address();if(!t||typeof t==`string`)throw Error(`Could not allocate a web development port.`);return t.port}finally{e.listening&&await new Promise((t,n)=>{e.close(e=>e?n(e):t())})}}async function v(e){try{return await fetch(e,{method:`HEAD`,signal:AbortSignal.timeout(750)}),!0}catch{return!1}}function y(e){return new Promise(t=>setTimeout(t,e))}async function b(e){if(!e.pid){e.kill(`SIGTERM`);return}if(process.platform===`win32`){await new Promise((t,r)=>{let i=n(`taskkill`,[`/pid`,String(e.pid),`/t`,`/f`],{shell:!1,stdio:`ignore`});i.once(`error`,r),i.once(`exit`,e=>{e===0?t():r(Error(`taskkill exited with code ${String(e)}`))})});return}try{process.kill(-e.pid,`SIGTERM`)}catch(e){if(!S(e)||e.code!==`ESRCH`)throw e}}async function x(t){try{return await e(t),!0}catch(e){if(S(e)&&e.code===`ENOENT`)return!1;throw e}}function S(e){return e instanceof Error&&`code`in e}export{o as DevelopmentRequestError,d as createDevelopmentManager};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DashboardPayload, DeployedDashboardPayload, DevelopmentSession, DevelopmentSessionStatus, DevelopmentState, DevelopmentTarget } from "./types.js";
|
|
2
|
-
import { DashboardRequestHandler, DashboardServerOptions,
|
|
3
|
-
export { type DashboardPayload, type DashboardRequestHandler, type DashboardServerOptions, type DeployedDashboardPayload, type DevelopmentSession, type DevelopmentSessionStatus, type DevelopmentState, type DevelopmentTarget,
|
|
2
|
+
import { DashboardRequestHandler, DashboardServerOptions, createDashboardRequestHandler, createDashboardServer, resolveDashboardClientDist } from "./server.js";
|
|
3
|
+
export { type DashboardPayload, type DashboardRequestHandler, type DashboardServerOptions, type DeployedDashboardPayload, type DevelopmentSession, type DevelopmentSessionStatus, type DevelopmentState, type DevelopmentTarget, createDashboardRequestHandler, createDashboardServer, resolveDashboardClientDist };
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDashboardRequestHandler as e,createDashboardServer as t,resolveDashboardClientDist as n
|
|
1
|
+
import{createDashboardRequestHandler as e,createDashboardServer as t,resolveDashboardClientDist as n}from"./server.js";export{e as createDashboardRequestHandler,t as createDashboardServer,n as resolveDashboardClientDist};
|
package/dist/src/server.d.ts
CHANGED
|
@@ -8,17 +8,12 @@ type DashboardServerOptions = {
|
|
|
8
8
|
mutationToken?: string;
|
|
9
9
|
projectRoot: string;
|
|
10
10
|
};
|
|
11
|
-
type StartedDashboardServer = {
|
|
12
|
-
server: Server;
|
|
13
|
-
url: string;
|
|
14
|
-
};
|
|
15
11
|
type DashboardRequestHandler = {
|
|
16
12
|
dispose(): Promise<void>;
|
|
17
13
|
handle(request: IncomingMessage, response: ServerResponse): Promise<void>;
|
|
18
14
|
};
|
|
19
15
|
declare function createDashboardServer(options: DashboardServerOptions): Server;
|
|
20
16
|
declare function createDashboardRequestHandler(options: DashboardServerOptions): DashboardRequestHandler;
|
|
21
|
-
declare function startDashboardServer(options: DashboardServerOptions): Promise<StartedDashboardServer>;
|
|
22
17
|
declare function resolveDashboardClientDist(): string;
|
|
23
18
|
//#endregion
|
|
24
|
-
export { DashboardRequestHandler, DashboardServerOptions,
|
|
19
|
+
export { DashboardRequestHandler, DashboardServerOptions, createDashboardRequestHandler, createDashboardServer, resolveDashboardClientDist };
|
package/dist/src/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DevelopmentRequestError as e,createDevelopmentManager as t}from"./development.js";import{createDashboardApiRouter as n}from"./api/router.js";import{handleFetchRequest as r}from"./node-fetch-adapter.js";import{readFile as
|
|
1
|
+
import{DevelopmentRequestError as e,createDevelopmentManager as t}from"./development.js";import{createDashboardApiRouter as n}from"./api/router.js";import{handleFetchRequest as r}from"./node-fetch-adapter.js";import{randomBytes as i}from"node:crypto";import{readFile as a,stat as o}from"node:fs/promises";import{createServer as s}from"node:http";import{dirname as c,extname as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{fileURLToPath as m}from"node:url";import{toFetchHandler as h}from"rouzer";function g(e){let t=_(e),n=s(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function _(r){let a=r.developmentManager??t({projectRoot:r.projectRoot}),o=r.mutationToken??i(32).toString(`base64url`),s=h(n({developmentManager:a,env:process.env,mutationToken:o,projectRoot:r.projectRoot}));return{dispose:()=>a.dispose(),async handle(t,n){try{await v(t,n,r,s)}catch(t){x(n,t instanceof e?t.status:500,{error:t instanceof Error?t.message:String(t)})}}}}async function v(e,t,n,i){y(e);let a=new URL(e.url??`/`,`http://127.0.0.1`);if(a.pathname===`/`){t.writeHead(302,{location:`/__dashboard`}),t.end();return}if(a.pathname.startsWith(`/__dashboard/api/`)){await r(e,t,i);return}if(a.pathname===`/__dashboard`){t.writeHead(302,{location:`/__dashboard/`}),t.end();return}if(a.pathname.startsWith(`/__dashboard/`)&&(e.method===`GET`||e.method===`HEAD`)){await b(t,a.pathname.slice(12)||`/`,n.clientDist);return}x(t,405,{error:`Method not allowed`})}function y(t){let n=t.headers.host;if(!n)throw new e(`Dashboard request host is missing.`,403);let r;try{r=new URL(`http://${n}`).hostname}catch{throw new e(`Dashboard request host was not authorized.`,403)}if(r!==`127.0.0.1`&&r!==`::1`&&r!==`localhost`&&!r.endsWith(`.localhost`))throw new e(`Dashboard request host was not authorized.`,403)}async function b(e,t,n=w()){let r=S(n,t),i=r?await C(r):void 0,a=r===void 0||l(t)===``,o=u(n,`index.html`),s=a?await C(o):void 0,c=i&&r?r:o,d=i??s;if(!d){x(e,404,{error:`Client asset not found`});return}e.writeHead(200,{"content-type":T(c),"cache-control":c.endsWith(`index.html`)?`no-store`:`public, max-age=31536000, immutable`}),e.end(e.req.method===`HEAD`?void 0:d)}function x(e,t,n){e.writeHead(t,{"content-type":`application/json; charset=utf-8`,"cache-control":`no-store`}),e.end(JSON.stringify(n))}function S(e,t){let n=decodeURIComponent(t),r=f(e,n===`/`?`index.html`:n.slice(1)),i=d(e,r);if(!(i.startsWith(`..`)||i===``||i.startsWith(p)))return r}async function C(e){try{return(await o(e)).isFile()?await a(e):void 0}catch(e){if(E(e)&&e.code===`ENOENT`)return;throw e}}function w(){let e=c(m(import.meta.url));return u(e.endsWith(`${p}dist${p}src`)?f(e,`../..`):e.endsWith(`${p}src`)?f(e,`..`):f(e,`../..`),`dist`,`client`)}function T(e){switch(l(e)){case`.css`:return`text/css; charset=utf-8`;case`.html`:return`text/html; charset=utf-8`;case`.js`:return`text/javascript; charset=utf-8`;case`.json`:return`application/json; charset=utf-8`;case`.svg`:return`image/svg+xml`;default:return`application/octet-stream`}}function E(e){return e instanceof Error&&`code`in e}export{_ as createDashboardRequestHandler,g as createDashboardServer,w as resolveDashboardClientDist};
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/dashboard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/airlock-labs/coreframe.git",
|
|
7
7
|
"directory": "dashboard"
|
|
8
8
|
},
|
|
9
|
-
"bin": {
|
|
10
|
-
"coreframe-dashboard": "./dist/src/cli.js"
|
|
11
|
-
},
|
|
12
9
|
"files": [
|
|
13
10
|
"dist/"
|
|
14
11
|
],
|
|
@@ -31,14 +28,13 @@
|
|
|
31
28
|
"@fontsource-variable/inter": "^5.2.8",
|
|
32
29
|
"@tanstack/react-query": "^5.101.2",
|
|
33
30
|
"nanoreset": "^7.0.0",
|
|
34
|
-
"portless": "^0.15.1",
|
|
35
31
|
"react": "^19.2.7",
|
|
36
32
|
"react-dom": "^19.2.7",
|
|
37
33
|
"react-router": "^8.2.0",
|
|
38
34
|
"rouzer": "^6.0.1",
|
|
39
35
|
"zod": "^4.4.3",
|
|
40
36
|
"@coreframe/diagnostics": "0.1.0",
|
|
41
|
-
"@coreframe/scripts": "0.1.
|
|
37
|
+
"@coreframe/scripts": "0.1.20"
|
|
42
38
|
},
|
|
43
39
|
"devDependencies": {
|
|
44
40
|
"@pandacss/dev": "2.0.0-beta.8",
|
|
@@ -65,7 +61,6 @@
|
|
|
65
61
|
"build:client": "react-router build",
|
|
66
62
|
"codegen": "panda codegen",
|
|
67
63
|
"build:server": "tsdown",
|
|
68
|
-
"dev": "pnpm build && node dist/src/cli.js",
|
|
69
64
|
"test": "vitest run",
|
|
70
65
|
"typecheck": "react-router typegen && tsc --noEmit -p tsconfig.json",
|
|
71
66
|
"format": "oxfmt",
|
package/dist/src/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/src/cli.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{spawn as e}from"node:child_process";import{access as t}from"node:fs/promises";import{dirname as n,join as r}from"node:path";import{fileURLToPath as i}from"node:url";const a=`https://coreframe.localhost/__dashboard`;async function o(){let t=process.argv.slice(2);if(t.includes(`--help`)||t.includes(`-h`)){s();return}let o=r(n(i(import.meta.url)),`server.js`),l=e(await c(),[`coreframe`,process.execPath,o],{stdio:`inherit`,shell:process.platform===`win32`,env:{...process.env,COREFRAME_DASHBOARD_PROJECT_ROOT:process.cwd(),COREFRAME_DASHBOARD_URL:a}});l.on(`exit`,(e,t)=>{if(t){process.kill(process.pid,t);return}process.exit(e??0)}),l.on(`error`,e=>{console.error(e.message),process.exit(1)})}function s(){console.log(`Coreframe Dashboard
|
|
3
|
-
|
|
4
|
-
Usage:
|
|
5
|
-
coreframe-dashboard
|
|
6
|
-
|
|
7
|
-
Starts the local dashboard at ${a}.
|
|
8
|
-
`)}async function c(){let e=r(r(n(i(import.meta.url)),`..`,`..`),`node_modules`,`.bin`,process.platform===`win32`?`portless.cmd`:`portless`);return await t(e),e}o().catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});export{};
|