@coreframe/dashboard 0.3.29 → 0.3.31

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 (36) hide show
  1. package/README.md +94 -19
  2. package/dist/package/app-client.d.ts +4 -3
  3. package/dist/package/app-client.js +1 -1
  4. package/dist/package/build.js +2 -2
  5. package/dist/package/config.d.ts +11 -5
  6. package/dist/package/index.d.ts +3 -3
  7. package/dist/package/shell.css +933 -204
  8. package/dist/package/types.d.ts +1 -17
  9. package/dist/package/web/styled-system/helpers.js +1 -1
  10. package/dist/package/web/ui/index.d.ts +1 -1
  11. package/dist/package/web-shell/index.d.ts +2 -1
  12. package/dist/package/web-shell/index.js +1 -1
  13. package/dist/package/web-shell/menu.d.ts +19 -0
  14. package/dist/package/web-shell/menu.js +1 -0
  15. package/dist/package/web-shell/shell.d.ts +2 -8
  16. package/dist/package/web-shell/shell.js +6 -1
  17. package/package.json +4 -26
  18. package/dist/package/plugins/diagnostics/api/contract.d.ts +0 -13
  19. package/dist/package/plugins/diagnostics/api/contract.js +0 -1
  20. package/dist/package/plugins/diagnostics/api/local.d.ts +0 -10
  21. package/dist/package/plugins/diagnostics/api/local.js +0 -1
  22. package/dist/package/plugins/diagnostics/api/worker.d.ts +0 -8
  23. package/dist/package/plugins/diagnostics/api/worker.js +0 -1
  24. package/dist/package/plugins/diagnostics/index.d.ts +0 -32
  25. package/dist/package/plugins/diagnostics/index.js +0 -1
  26. package/dist/package/plugins/diagnostics/web/queries.js +0 -1
  27. package/dist/package/plugins/diagnostics/web.d.ts +0 -4
  28. package/dist/package/plugins/diagnostics/web.js +0 -1
  29. package/dist/package/web/dashboard/dashboard-page.js +0 -1
  30. package/dist/package/web/dashboard/dashboard-section.js +0 -1
  31. package/dist/package/web/dashboard/dashboard.style.js +0 -1
  32. package/dist/package/web/dashboard/deployed-dashboard-page.js +0 -1
  33. package/dist/package/web/dashboard/findings.js +0 -1
  34. package/dist/package/web/dashboard/worker-environment.js +0 -1
  35. package/dist/package/web/root.style.js +0 -1
  36. package/dist/package/web/styled-system/css/css.js +0 -1
package/README.md CHANGED
@@ -15,29 +15,54 @@ assets are merged into `dist/client/__dashboard` and remain mounted at `/__dashb
15
15
 
16
16
  ```ts
17
17
  import { defineConfig } from "@coreframe/dashboard/config"
18
- import { diagnostics } from "@coreframe/dashboard/plugins/diagnostics"
19
18
 
20
19
  export default defineConfig({
21
- plugins: [diagnostics()],
20
+ plugins: [],
22
21
  })
23
22
  ```
24
23
 
25
- Removing `diagnostics()` removes the feature's root navigation entry and its runtime operations.
26
- Plugins are never discovered or installed at runtime.
24
+ The default dashboard has no built-in pages or operations. Its landing page introduces page
25
+ creation and customization until an app-owned page exists, then redirects to the first configured
26
+ page. Optional plugins do not suppress the introduction. Plugins are never discovered or installed
27
+ at runtime.
27
28
 
28
29
  Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An adjacent `page.yaml` must define
29
- `icon` as a Codicon name (for example, `icon: settings-gear`) and may define `title`, `description`,
30
- and `layout`. Plugin navigation also requires `icon`. The sidebar uses the application package name
31
- and `src/assets/favicon.svg`. Set `layout: standalone` when a page owns its full viewport presentation
32
- and should render without the dashboard navigation, heading, or shell spacing.
30
+ `icon` as a Tabler name (for example, `icon: settings`) and may define `title`, `description`,
31
+ and `layout`. Plugin navigation also requires `icon`. Navigation uses `src/assets/favicon.svg` for
32
+ the logo and omits the project slug. With multiple pages, a small logo floats in the top-left corner and opens a
33
+ navigation popover on hover, click, or keyboard activation. Pages own their headings, layout, and
34
+ spacing; Coreframe adds no page header or content wrapper. Leave room around the floating logo.
35
+ The logo and menu are omitted when the dashboard has at most one page, including project-placed menus.
36
+ Icon names are resolved during composition. The browser receives only the selected SVGs and their
37
+ dimensions, rather than the full Tabler catalog.
38
+
39
+ Set `layout: standalone` to omit the floating logo. A standalone page may place `DashboardMenu`
40
+ from `@coreframe/dashboard/web` in its own header or layout; it receives the current application and
41
+ page list automatically:
33
42
 
34
43
  ```yaml
35
- icon: settings-gear
44
+ icon: settings
36
45
  title: Moderation
37
46
  layout: standalone
38
47
  ```
39
48
 
40
- Omitting `layout`, or setting it to `default`, retains the standard shell. Standalone pages remain in
49
+ ```tsx
50
+ import { DashboardMenu } from "@coreframe/dashboard/web"
51
+
52
+ export default function Moderation() {
53
+ return (
54
+ <main>
55
+ <header>
56
+ <DashboardMenu />
57
+ <h1>Moderation</h1>
58
+ </header>
59
+ {/* Page content */}
60
+ </main>
61
+ )
62
+ }
63
+ ```
64
+
65
+ Omitting `layout`, or setting it to `default`, retains the floating logo. Standalone pages remain in
41
66
  the dashboard route, build, authentication, query-client, and error-handling boundaries. Build-time
42
67
  composition validates slugs, metadata, route modules, identifiers, and paths before generating the
43
68
  React Router route graph and navigation manifest.
@@ -51,15 +76,54 @@ Projects can opt into app-owned customization without copying the default scaffo
51
76
 
52
77
  - `dashboard/document.tsx`, referenced as `document` in `dashboard.config.ts`, can provide a custom
53
78
  document `Layout` and optional `links` or `meta` exports;
54
- - `dashboard/styles.css` is loaded after the package stylesheet, while `panda.config.ts` remains the
55
- theme and generated-style override; and
79
+ - `dashboard/styles.css` is loaded after the package stylesheet and generated Panda stylesheet,
80
+ while `panda.config.ts` remains the theme and generated-style override; and
56
81
  - `vite.config.ts` and `react-router.config.ts` remain small tool-level adapters for build changes.
57
82
 
83
+ ## Style overrides
84
+
85
+ Keep customization in the project; package styles do not need to be copied or ejected. Styles load
86
+ in this order: the package shell, `dashboard/styled-system/styles.css`, then `dashboard/styles.css`.
87
+ The package stylesheet includes reusable UI defaults and tokens.
88
+ Normal unlayered rules in `styles.css` take precedence over layered Panda rules. Shell rules are
89
+ unlayered, so match the relevant selector's specificity when overriding them.
90
+
91
+ The dashboard Panda config includes `coreframeDashboardPreset()` from `@coreframe/panda` and
92
+ generates all dashboard recipe variants because package components select variants at runtime.
93
+ Customize `theme.extend.semanticTokens.colors.dashboard` for shared colors, or
94
+ `theme.extend.recipes` and `theme.extend.slotRecipes` for reusable UI defaults. The color roles are
95
+ `canvas`, `panel`, `ink`, `muted`, `border`, `accent`, `danger`, `info`, `success`, and `warning`.
96
+ The shell consumes the same color tokens, with fallback values when no tokens are generated.
97
+
98
+ For logo placement and targeted menu changes, use the public `.coreframe-dashboard__*` selectors in
99
+ `dashboard/styles.css`, for example:
100
+
101
+ ```css
102
+ .coreframe-dashboard__floating-navigation {
103
+ top: 1.5rem;
104
+ left: 1.5rem;
105
+ }
106
+
107
+ .coreframe-dashboard__navigation-link[aria-current="page"] {
108
+ font-weight: 700;
109
+ }
110
+ ```
111
+
112
+ The logo button exposes `aria-expanded`; navigation links expose `aria-current="page"` for the
113
+ current page. The reusable UI uses Panda recipe classes
114
+ such as `.dashboard-button` and `.dashboard-section__root`.
115
+
116
+ Sculpted source editing applies to supported project-owned static Panda `css({ ... })` sources;
117
+ it does not redirect package styles into project overrides or edit config recipes. Its current
118
+ root-level development endpoints also require separate integration for the dashboard's proxied
119
+ development server. The dashboard Vite config registers the plugin, but the default document does
120
+ not mount its runtime yet. CSS and Panda overrides work independently of Sculpted.
121
+
58
122
  ## Runtime boundaries
59
123
 
60
124
  The app dashboard uses the same React, React Router framework mode, React Compiler, PandaCSS,
61
- Sculpted, Rouzer, Zod, TanStack Query, and Worker conventions as the main Coreframe application.
62
- Coreframe contributes the responsive navigation shell and default client/query runtime without
125
+ Rouzer, Zod, TanStack Query, and Worker conventions as the main Coreframe application.
126
+ Coreframe contributes the logo navigation and default client/query runtime without
63
127
  imposing a page-content component API.
64
128
 
65
129
  Plugin APIs expose named `queries` and `commands`. Queries are `GET` operations and commands are
@@ -161,12 +225,23 @@ replay once through the app transport. Other response statuses keep their normal
161
225
  distinct `401` and `403` failures. The dashboard password and plugin `DashboardSuperuser` actor are
162
226
  separate from app authentication, and the client does not proxy or translate between them.
163
227
 
164
- ## Built-in diagnostics
228
+ If the route tree contains response codecs such as NDJSON, register their client plugins even when
229
+ the page does not call those routes. Rouzer validates codec registration during client construction.
230
+
231
+ ```ts
232
+ import { createDashboardAppClient } from "@coreframe/dashboard/app-client"
233
+ import * as ndjson from "rouzer/ndjson"
234
+
235
+ const { client, session } = createDashboardAppClient(routes, {
236
+ plugins: [ndjson.clientPlugin],
237
+ })
238
+ ```
165
239
 
166
- The diagnostics plugin preserves the full local production-readiness inspection and provides a
167
- reduced deployed view. Its page is a normal module and its browser data uses a typed operation client
168
- with TanStack Query. Local collection may use Node.js through its narrow host data; deployed
169
- collection never receives ambient Worker bindings or raw configuration values.
240
+ The hosting app must separately register `ndjson.routerPlugin` in its API's `createRouter({ plugins })`
241
+ configuration. Keep its existing authentication middleware, and complete authentication and permission
242
+ checks before returning a stream. NDJSON actions resolve to an `AsyncIterable` of the declared item
243
+ type; the codec does not validate items against a runtime schema. This configuration applies to the
244
+ hosting app's `/api/` routes, independently of the dashboard plugin API.
170
245
 
171
246
  Useful package checks:
172
247
 
@@ -1,14 +1,15 @@
1
1
  import { AuthSessionHintStore } from "@coreframe/lib/auth-transport";
2
2
  import { ReactNode } from "react";
3
- import { RouzerClient } from "rouzer";
3
+ import { ClientResponsePlugin, RouzerClient } from "rouzer";
4
4
  import { HttpRouteTree } from "rouzer/http";
5
5
 
6
6
  //#region src/app-client.d.ts
7
7
  /** The authentication states exposed by a dashboard app session. */
8
8
  type DashboardAppSessionStatus = "authenticated" | "checking" | "unauthenticated" | "unknown";
9
- /** The browser-only seams accepted by {@link createDashboardAppClient}. */
9
+ /** Response codecs and browser transport options for {@link createDashboardAppClient}. */
10
10
  type DashboardAppClientOptions = Readonly<{
11
- /** Replaces the browser fetch implementation in focused transport tests. */fetch?: typeof globalThis.fetch; /** Replaces the browser session hint store in focused session tests. */
11
+ /** Replaces the browser fetch implementation in focused transport tests. */fetch?: typeof globalThis.fetch; /** Response codecs required by the route tree, including routes the caller does not invoke. */
12
+ plugins?: readonly ClientResponsePlugin[]; /** Replaces the browser session hint store in focused session tests. */
12
13
  sessionHint?: AuthSessionHintStore;
13
14
  }>;
14
15
  /** The public state of a dashboard app session at one point in time. */
@@ -1 +1 @@
1
- import{createAuthSessionHintStore as e}from"@coreframe/lib/auth-transport";import{createBrowserAuthSessionHintPersistence as t,createBrowserAuthenticatedFetch as n}from"@coreframe/lib/auth-transport/browser";import{useSyncExternalStore as r}from"react";import{createClient as i}from"rouzer";function a(e,t={}){let r=p(),a=m(t.fetch??((e,t)=>globalThis.fetch(e,t)),r),o=t.sessionHint??f(),s=n({appOrigin:r,fetch:a,refreshAccess:()=>a(new URL(`/api/auth/token`,r),{credentials:`include`,method:`POST`}),sessionHint:o});return{client:i({baseURL:new URL(`/api/`,r).href,fetch:s.fetch,headers:{"content-type":`application/json`},onJsonError:h,routes:e}),session:l(s,o)}}function o(e){return r(e.subscribe,e.get,e.get)}function s({children:e,pending:t,session:n,unauthenticated:r,unknown:i}){switch(o(n).status){case`authenticated`:return e;case`checking`:return g(t,n);case`unauthenticated`:return g(r,n);case`unknown`:return g(i,n)}}var c=class extends Error{status;constructor(e){super(`Request failed with status ${e}.`),this.name=`DashboardAppResponseError`,this.status=e}};function l(e,t){let n=u(t.get()),r,i,a=!1;function o(){return n}function s(e,t){let r=d(e,t);r.status===n.status&&r.expiresAt===n.expiresAt||(n=r,l())}let c=new Set;function l(){for(let e of c)e()}function f(e){return c.add(e),()=>c.delete(e)}function p(){i!==void 0&&(clearTimeout(i),i=void 0)}function m(e){p(),i=setTimeout(()=>{i=void 0,t.get(),h()},Math.max(0,e-Date.now()))}function h(){if(a)return;let e=t.get();if(e.status===`authenticated`){s(`authenticated`,e.validUntil),m(e.validUntil);return}if(e.status===`unauthenticated`){s(`unauthenticated`,null),m(e.validUntil);return}p(),s(`checking`,null),g()}function g(){if(a)return Promise.resolve(n);if(t.get().status!==`unknown`)return h(),Promise.resolve(n);if(s(`checking`,null),r)return r;let i=e.refreshAccessToken().then(r=>{if(a)return n;let i=t.get();return i.status===`authenticated`||i.status===`unauthenticated`?h():r?s(`unknown`,null):(e.setUnauthenticated(),h()),n}).catch(()=>{if(!a){let e=t.get();e.status===`authenticated`||e.status===`unauthenticated`?h():s(`unknown`,null)}return n});return r=i,i.then(()=>{r===i&&(r=void 0)}),i}function _(){return a?Promise.resolve(n):(t.invalidate(),g())}let v=t.subscribe(h),y=()=>t.syncFromPersistence(),b=()=>{n.status===`unknown`&&g()};return globalThis.window!==void 0&&(globalThis.addEventListener(`storage`,y),globalThis.addEventListener(`online`,b)),h(),{get expiresAt(){return n.expiresAt},get isPending(){return n.isPending},get status(){return n.status},dispose(){a||(a=!0,p(),v(),globalThis.window!==void 0&&(globalThis.removeEventListener(`storage`,y),globalThis.removeEventListener(`online`,b)))},get:o,refresh:_,subscribe:f}}function u(e){return e.status===`authenticated`?d(`authenticated`,e.validUntil):e.status===`unauthenticated`?d(`unauthenticated`,null):d(`checking`,null)}function d(e,t){return Object.freeze({expiresAt:t,isPending:e!==`authenticated`&&e!==`unauthenticated`,status:e})}function f(){let n=!1;if(globalThis.window!==void 0)try{n=t({key:`coreframe.auth-session-observation.v1`,storage:globalThis.localStorage})}catch{n=!1}return e({persistence:n,unauthenticatedTtlMs:3e5})}function p(){let e=globalThis.location?.origin;if(!e)throw Error(`createDashboardAppClient() requires a browser location.`);let t;try{t=new URL(e)}catch{throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`);return t.origin}function m(e,t){return(n,r)=>{if(new URL(n instanceof Request?n.url:n.toString(),t).origin!==t)throw TypeError(`Dashboard app client only allows same-origin requests.`);return e(n,{...r,credentials:`include`})}}async function h(e){throw new c(e.status)}function g(e,t){return typeof e==`function`?e(t):e??null}export{c as DashboardAppResponseError,s as DashboardAppSessionBoundary,a as createDashboardAppClient,o as useDashboardAppSession};
1
+ import{createAuthSessionHintStore as e}from"@coreframe/lib/auth-transport";import{createBrowserAuthSessionHintPersistence as t,createBrowserAuthenticatedFetch as n}from"@coreframe/lib/auth-transport/browser";import{useSyncExternalStore as r}from"react";import{createClient as i}from"rouzer";function a(e,t={}){let r=p(),a=m(t.fetch??((e,t)=>globalThis.fetch(e,t)),r),o=t.sessionHint??f(),s=n({appOrigin:r,fetch:a,refreshAccess:()=>a(new URL(`/api/auth/token`,r),{credentials:`include`,method:`POST`}),sessionHint:o});return{client:i({baseURL:new URL(`/api/`,r).href,fetch:s.fetch,headers:{"content-type":`application/json`},onJsonError:h,plugins:t.plugins,routes:e}),session:l(s,o)}}function o(e){return r(e.subscribe,e.get,e.get)}function s({children:e,pending:t,session:n,unauthenticated:r,unknown:i}){switch(o(n).status){case`authenticated`:return e;case`checking`:return g(t,n);case`unauthenticated`:return g(r,n);case`unknown`:return g(i,n)}}var c=class extends Error{status;constructor(e){super(`Request failed with status ${e}.`),this.name=`DashboardAppResponseError`,this.status=e}};function l(e,t){let n=u(t.get()),r,i,a=!1;function o(){return n}function s(e,t){let r=d(e,t);r.status===n.status&&r.expiresAt===n.expiresAt||(n=r,l())}let c=new Set;function l(){for(let e of c)e()}function f(e){return c.add(e),()=>c.delete(e)}function p(){i!==void 0&&(clearTimeout(i),i=void 0)}function m(e){p(),i=setTimeout(()=>{i=void 0,t.get(),h()},Math.max(0,e-Date.now()))}function h(){if(a)return;let e=t.get();if(e.status===`authenticated`){s(`authenticated`,e.validUntil),m(e.validUntil);return}if(e.status===`unauthenticated`){s(`unauthenticated`,null),m(e.validUntil);return}p(),s(`checking`,null),g()}function g(){if(a)return Promise.resolve(n);if(t.get().status!==`unknown`)return h(),Promise.resolve(n);if(s(`checking`,null),r)return r;let i=e.refreshAccessToken().then(r=>{if(a)return n;let i=t.get();return i.status===`authenticated`||i.status===`unauthenticated`?h():r?s(`unknown`,null):(e.setUnauthenticated(),h()),n}).catch(()=>{if(!a){let e=t.get();e.status===`authenticated`||e.status===`unauthenticated`?h():s(`unknown`,null)}return n});return r=i,i.then(()=>{r===i&&(r=void 0)}),i}function _(){return a?Promise.resolve(n):(t.invalidate(),g())}let v=t.subscribe(h),y=()=>t.syncFromPersistence(),b=()=>{n.status===`unknown`&&g()};return globalThis.window!==void 0&&(globalThis.addEventListener(`storage`,y),globalThis.addEventListener(`online`,b)),h(),{get expiresAt(){return n.expiresAt},get isPending(){return n.isPending},get status(){return n.status},dispose(){a||(a=!0,p(),v(),globalThis.window!==void 0&&(globalThis.removeEventListener(`storage`,y),globalThis.removeEventListener(`online`,b)))},get:o,refresh:_,subscribe:f}}function u(e){return e.status===`authenticated`?d(`authenticated`,e.validUntil):e.status===`unauthenticated`?d(`unauthenticated`,null):d(`checking`,null)}function d(e,t){return Object.freeze({expiresAt:t,isPending:e!==`authenticated`&&e!==`unauthenticated`,status:e})}function f(){let n=!1;if(globalThis.window!==void 0)try{n=t({key:`coreframe.auth-session-observation.v1`,storage:globalThis.localStorage})}catch{n=!1}return e({persistence:n,unauthenticatedTtlMs:3e5})}function p(){let e=globalThis.location?.origin;if(!e)throw Error(`createDashboardAppClient() requires a browser location.`);let t;try{t=new URL(e)}catch{throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`);return t.origin}function m(e,t){return(n,r)=>{if(new URL(n instanceof Request?n.url:n.toString(),t).origin!==t)throw TypeError(`Dashboard app client only allows same-origin requests.`);return e(n,{...r,credentials:`include`})}}async function h(e){throw new c(e.status)}function g(e,t){return typeof e==`function`?e(t):e??null}export{c as DashboardAppResponseError,s as DashboardAppSessionBoundary,a as createDashboardAppClient,o as useDashboardAppSession};
@@ -1,3 +1,3 @@
1
- import{getDashboardPluginBuild as e}from"./config.js";import{createRequire as t}from"node:module";import{readFile as n,readdir as r}from"node:fs/promises";import{isAbsolute as i,join as a,resolve as o}from"node:path";import{icons as s}from"@iconify-json/codicon";import{parseDocument as c}from"yaml";import{z as l}from"zod";const u=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,d=l.string().refine(e=>Object.hasOwn(s.icons,e),`must be a valid Codicon name`),f=l.object({icon:d,title:l.string().trim().min(1,`title must not be empty`).optional(),description:l.string().trim().min(1,`description must not be empty`).optional(),layout:l.enum([`default`,`standalone`]).optional()}).strict(),p=l.object({id:l.string(),path:l.string(),icon:d,title:l.string(),description:l.string().optional(),layout:l.enum([`default`,`standalone`]).optional(),routeModule:l.string(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),m=l.string().trim().min(1,`module reference must not be empty`),h=l.object({path:l.string(),icon:d,title:l.string(),description:l.string().optional(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),g=l.object({document:m.optional(),plugins:l.array(l.object({id:l.string(),navigation:h,pageModule:m,api:l.unknown().optional()}).strict()).optional()}).strict();async function _(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(F(e)&&e.code===`ENOENT`)return[];throw new w(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>P(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);M(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw F(e)&&e.code===`ENOENT`?new w(i,`missing required React Router route.tsx`):new w(i,`could not read route.tsx`,e)}let o=await T(a(r,`page.yaml`));return{id:e,path:e,icon:o.icon,title:o?.title??N(e),...o?.description?{description:o.description}:{},...o?.layout?{layout:o.layout}:{},routeModule:`pages/${e}/route.tsx`}}))}function v(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=A(e);for(let e of o.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=D(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:E(e,`app`)})).sort((e,t)=>P(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)k(e,r)&&a.push(t);return O(a),a}function y(e,t){let n=A(e),r=new Set,i=[];for(let e of n.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=j(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function b(e){let t=[],n=[];for(let[r,i]of e.entries())t.push(`import { api as api${r} } from ${JSON.stringify(i.apiModule)}`,`import { createImplementation as createImplementation${r} } from ${JSON.stringify(i.implementationModule)}`),n.push(`{ api: api${r}, createImplementation: createImplementation${r} }`);return`${t.join(`
1
+ import{getDashboardPluginBuild as e}from"./config.js";import{createRequire as t}from"node:module";import{readFile as n,readdir as r}from"node:fs/promises";import{isAbsolute as i,join as a,resolve as o}from"node:path";import{icons as s}from"@iconify-json/tabler";import{parseDocument as c}from"yaml";import{z as l}from"zod";const u=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,d=l.string().refine(e=>Object.hasOwn(s.icons,e),`must be a valid Tabler name`),f=l.object({icon:d,title:l.string().trim().min(1,`title must not be empty`).optional(),description:l.string().trim().min(1,`description must not be empty`).optional(),layout:l.enum([`default`,`standalone`]).optional()}).strict(),p=l.object({id:l.string(),path:l.string(),icon:d,title:l.string(),description:l.string().optional(),layout:l.enum([`default`,`standalone`]).optional(),routeModule:l.string(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),m=l.string().trim().min(1,`module reference must not be empty`),h=l.object({path:l.string(),icon:d,title:l.string(),description:l.string().optional(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),g=l.object({document:m.optional(),plugins:l.array(l.object({id:l.string(),navigation:h,pageModule:m,api:l.unknown().optional()}).strict()).optional()}).strict();async function _(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(F(e)&&e.code===`ENOENT`)return[];throw new w(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>P(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);M(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw F(e)&&e.code===`ENOENT`?new w(i,`missing required React Router route.tsx`):new w(i,`could not read route.tsx`,e)}let o=await T(a(r,`page.yaml`));return{id:e,path:e,icon:o.icon,title:o?.title??N(e),...o?.description?{description:o.description}:{},...o?.layout?{layout:o.layout}:{},routeModule:`pages/${e}/route.tsx`}}))}function v(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=A(e);for(let e of o.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=D(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:E(e,`app`)})).sort((e,t)=>P(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)k(e,r)&&a.push(t);return O(a),a}function y(e,t){let n=A(e),r=new Set,i=[];for(let e of n.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=j(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function b(e){let t=[],n=[];for(let[r,i]of e.entries())t.push(`import { api as api${r} } from ${JSON.stringify(i.apiModule)}`,`import { createImplementation as createImplementation${r} } from ${JSON.stringify(i.implementationModule)}`),n.push(`{ api: api${r}, createImplementation: createImplementation${r} }`);return`${t.join(`
2
2
  `)}\n\nexport const dashboardPlugins = [\n${n.map(e=>` ${e},`).join(`
3
- `)}\n]\n`}function x(e,t){let n=[e.length>0?{index:!0,file:t.indexRoute}:{index:!0,file:t.emptyRoute},...e.map(e=>({id:`dashboard-page-${e.id}`,path:e.path,file:e.routeModule})),...t.notFoundRoute?[{path:`*`,file:t.notFoundRoute}]:[]];return[{id:`dashboard-shell`,file:t.shellRoute,children:n}]}function S(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):C(e.routeModule,t)}))}function C(e,n={}){let r=o(n.dashboardDirectory??a(process.cwd(),`dashboard`)),s=t(a(o(n.projectRoot??a(r,`..`)),`package.json`));if(i(e)||e.startsWith(`.`))return o(r,e);try{return s.resolve(e)}catch(t){throw new w(e,`could not resolve dashboard module`,t)}}var w=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function T(e){let t;try{t=await n(e,`utf8`)}catch(t){throw F(t)&&t.code===`ENOENT`?new w(e,`missing required page.yaml with a Codicon icon`):new w(e,`could not read page metadata`,t)}let r=c(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new w(e,r.errors[0]?.message??`invalid YAML`);let i=f.safeParse(r.toJS());if(!i.success)throw new w(e,l.prettifyError(i.error));return i.data}function E(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=p.safeParse(e);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;M(a.id,r,`page id`),M(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new w(r,`page title must not be empty`);if(!a.routeModule.trim())throw new w(r,`page routeModule must not be empty`);let s=a.description?.trim();if(a.description!==void 0&&!s)throw new w(r,`page description must not be empty`);return{id:a.id,path:a.path,title:o,icon:a.icon,...s?{description:s}:{},...a.layout?{layout:a.layout}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function D(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=h.safeParse(e.navigation);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;if(M(e.id,r,`plugin id`),M(a.path,r,`navigation path`),!a.title.trim())throw new w(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new w(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new w(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=j(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return E({id:e.id,path:a.path,title:a.title,icon:a.icon,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function O(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new w(r.routeModule,`duplicate page id "${r.id}" also contributed by ${e.routeModule}`);t.set(r.id,r);let i=n.get(r.path);if(i)throw new w(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function k(e,t){return e.environments?e.environments.includes(t):!0}function A(e){let t=g.safeParse(e);if(!t.success)throw new w(`dashboard.config.ts`,l.prettifyError(t.error));return e}function j(t,n){let r=e(t);if(!r)throw new w(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new w(`dashboard.config.ts plugin "${t.id}"`,`API id "${t.api.id}" does not match the plugin id`);for(let e of[`apiModule`,`localImplementationModule`]){let n=r[e];if(typeof n!=`string`||!n.trim())throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "${e}" must be a non-empty module reference`)}if(r.deployedImplementationModule!==void 0&&(typeof r.deployedImplementationModule!=`string`||!r.deployedImplementationModule.trim()))throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function M(e,t,n){if(!u.test(e))throw new w(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function N(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function P(e,t){return e<t?-1:+(e>t)}function F(e){return e instanceof Error&&`code`in e}export{w as DashboardCompositionError,v as composeDashboardManifest,y as composeDashboardPluginTarget,x as composeDashboardRoutes,_ as discoverDashboardPages,b as renderDashboardPluginTargetModule,C as resolveDashboardModuleReference,S as resolveDashboardRouteModules};
3
+ `)}\n]\n`}function x(e,t){let n=[e.length>0?{index:!0,file:t.indexRoute}:{index:!0,file:t.emptyRoute},...e.map(e=>({id:`dashboard-page-${e.id}`,path:e.path,file:e.routeModule})),...t.notFoundRoute?[{path:`*`,file:t.notFoundRoute}]:[]];return[{id:`dashboard-shell`,file:t.shellRoute,children:n}]}function S(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):C(e.routeModule,t)}))}function C(e,n={}){let r=o(n.dashboardDirectory??a(process.cwd(),`dashboard`)),s=t(a(o(n.projectRoot??a(r,`..`)),`package.json`));if(i(e)||e.startsWith(`.`))return o(r,e);try{return s.resolve(e)}catch(t){throw new w(e,`could not resolve dashboard module`,t)}}var w=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function T(e){let t;try{t=await n(e,`utf8`)}catch(t){throw F(t)&&t.code===`ENOENT`?new w(e,`missing required page.yaml with a Tabler icon`):new w(e,`could not read page metadata`,t)}let r=c(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new w(e,r.errors[0]?.message??`invalid YAML`);let i=f.safeParse(r.toJS());if(!i.success)throw new w(e,l.prettifyError(i.error));return i.data}function E(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=p.safeParse(e);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;M(a.id,r,`page id`),M(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new w(r,`page title must not be empty`);if(!a.routeModule.trim())throw new w(r,`page routeModule must not be empty`);let c=a.description?.trim();if(a.description!==void 0&&!c)throw new w(r,`page description must not be empty`);let u=s.icons[a.icon];return{id:a.id,path:a.path,title:o,icon:a.icon,iconData:{body:u.body,width:u.width??s.width??16,height:u.height??s.height??16},...c?{description:c}:{},...a.layout?{layout:a.layout}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function D(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=h.safeParse(e.navigation);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;if(M(e.id,r,`plugin id`),M(a.path,r,`navigation path`),!a.title.trim())throw new w(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new w(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new w(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=j(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return E({id:e.id,path:a.path,title:a.title,icon:a.icon,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function O(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new w(r.routeModule,`duplicate page id "${r.id}" also contributed by ${e.routeModule}`);t.set(r.id,r);let i=n.get(r.path);if(i)throw new w(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function k(e,t){return e.environments?e.environments.includes(t):!0}function A(e){let t=g.safeParse(e);if(!t.success)throw new w(`dashboard.config.ts`,l.prettifyError(t.error));return e}function j(t,n){let r=e(t);if(!r)throw new w(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new w(`dashboard.config.ts plugin "${t.id}"`,`API id "${t.api.id}" does not match the plugin id`);for(let e of[`apiModule`,`localImplementationModule`]){let n=r[e];if(typeof n!=`string`||!n.trim())throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "${e}" must be a non-empty module reference`)}if(r.deployedImplementationModule!==void 0&&(typeof r.deployedImplementationModule!=`string`||!r.deployedImplementationModule.trim()))throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function M(e,t,n){if(!u.test(e))throw new w(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function N(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function P(e,t){return e<t?-1:+(e>t)}function F(e){return e instanceof Error&&`code`in e}export{w as DashboardCompositionError,v as composeDashboardManifest,y as composeDashboardPluginTarget,x as composeDashboardRoutes,_ as discoverDashboardPages,b as renderDashboardPluginTargetModule,C as resolveDashboardModuleReference,S as resolveDashboardRouteModules};
@@ -2,7 +2,7 @@ import { DashboardPluginApi } from "./api/contract.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  type DashboardEnvironment = "local" | "deployed";
5
- /** Presentation supplied around a dashboard page route. */
5
+ /** Whether Coreframe places floating navigation or the page owns navigation placement. */
6
6
  type DashboardPageLayout = "default" | "standalone";
7
7
  interface DashboardPageContribution {
8
8
  /** Stable page identity. It must be a lowercase, URL-safe slug. */
@@ -10,10 +10,10 @@ interface DashboardPageContribution {
10
10
  /** Top-level URL segment below `/__dashboard/`. */
11
11
  path: string;
12
12
  title: string;
13
- /** Codicon name, for example `settings-gear`. */
13
+ /** Tabler name, for example `settings`. */
14
14
  icon: string;
15
15
  description?: string;
16
- /** Presentation supplied around the route. Defaults to the dashboard shell. */
16
+ /** Defaults to floating logo navigation. Standalone pages can place DashboardMenu themselves. */
17
17
  layout?: DashboardPageLayout;
18
18
  /** React Router framework route module, resolved by the dashboard build. */
19
19
  routeModule: string;
@@ -25,7 +25,7 @@ interface DashboardPluginNavigation {
25
25
  /** Top-level URL segment below `/__dashboard/`. */
26
26
  path: string;
27
27
  title: string;
28
- /** Codicon name, for example `settings-gear`. */
28
+ /** Tabler name, for example `settings`. */
29
29
  icon: string;
30
30
  description?: string;
31
31
  /** Environments where the feature is available. Defaults to both. */
@@ -64,8 +64,14 @@ interface DashboardPageManifestEntry {
64
64
  id: string;
65
65
  path: string;
66
66
  title: string;
67
- /** Codicon name, for example `settings-gear`. */
67
+ /** Tabler name, for example `settings`. */
68
68
  icon: string;
69
+ /** Selected SVG data resolved during composition; the browser does not load the icon catalog. */
70
+ iconData: {
71
+ body: string;
72
+ width: number;
73
+ height: number;
74
+ };
69
75
  description?: string;
70
76
  layout?: DashboardPageLayout;
71
77
  routeModule: string;
@@ -1,3 +1,3 @@
1
- import { DashboardPayload, DashboardReleaseIdentity, DeployedDashboardPayload } from "./types.js";
2
- import { DashboardRequestHandler, DashboardServerOptions, createNodeHandler, createNodeServer } from "./server.js";
3
- export { type DashboardPayload, type DashboardReleaseIdentity, type DashboardRequestHandler, type DashboardServerOptions, type DeployedDashboardPayload, createNodeHandler, createNodeServer };
1
+ import { DashboardReleaseIdentity } from "./types.js";
2
+ import { createNodeHandler, createNodeServer } from "./server.js";
3
+ export { type DashboardReleaseIdentity, createNodeHandler, createNodeServer };