@coreframe/dashboard 0.3.26 → 0.3.27

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 CHANGED
@@ -25,8 +25,9 @@ export default defineConfig({
25
25
  Removing `diagnostics()` removes the feature's root navigation entry and its runtime operations.
26
26
  Plugins are never discovered or installed at runtime.
27
27
 
28
- Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An optional adjacent `page.yaml` may
29
- define `title` and `description`. Build-time composition validates slugs, metadata, route modules,
28
+ Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An adjacent `page.yaml` must define `icon` as a Codicon name (for example,
29
+ `icon: settings-gear`) and may define `title` and `description`. Plugin navigation also requires
30
+ `icon`. The sidebar uses the application package name and `src/assets/favicon.svg`. Build-time composition validates slugs, metadata, route modules,
30
31
  identifiers, and paths before generating the React Router route graph and navigation manifest.
31
32
 
32
33
  The generated dashboard does not need route adapters, a document root, a query-client module, or an
@@ -1 +1 @@
1
- import{DashboardErrorBoundary as e,DashboardShell as t}from"../web-shell/shell.js";import"../web-shell/index.js";import{jsx as n}from"react/jsx-runtime";import{dashboardManifest as r}from"virtual:coreframe-internal/dashboard/manifest";const i=e;function a(){return n(t,{pages:r})}export{i as ErrorBoundary,a as default};
1
+ import{DashboardErrorBoundary as e,DashboardShell as t}from"../web-shell/shell.js";import"../web-shell/index.js";import{jsx as n}from"react/jsx-runtime";import{dashboardApplication as r,dashboardManifest as i}from"virtual:coreframe-internal/dashboard/manifest";const a=e;function o(){return n(t,{pages:i,application:r})}export{a as ErrorBoundary,o as default};
@@ -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{parseDocument as s}from"yaml";import{z as c}from"zod";const l=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,u=c.object({title:c.string().trim().min(1,`title must not be empty`).optional(),description:c.string().trim().min(1,`description must not be empty`).optional()}).strict(),d=c.object({id:c.string(),path:c.string(),title:c.string(),description:c.string().optional(),routeModule:c.string(),environments:c.array(c.enum([`local`,`deployed`])).optional()}).strict(),f=c.string().trim().min(1,`module reference must not be empty`),p=c.object({path:c.string(),title:c.string(),description:c.string().optional(),environments:c.array(c.enum([`local`,`deployed`])).optional()}).strict(),m=c.object({document:f.optional(),plugins:c.array(c.object({id:c.string(),navigation:p,pageModule:f,api:c.unknown().optional()}).strict()).optional()}).strict();async function h(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(N(e)&&e.code===`ENOENT`)return[];throw new S(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>M(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);A(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw N(e)&&e.code===`ENOENT`?new S(i,`missing required React Router route.tsx`):new S(i,`could not read route.tsx`,e)}let o=await C(a(r,`page.yaml`));return{id:e,path:e,title:o?.title??j(e),...o?.description?{description:o.description}:{},routeModule:`pages/${e}/route.tsx`}}))}function g(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=O(e);for(let e of o.plugins??[]){if(A(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new S(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=T(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:w(e,`app`)})).sort((e,t)=>M(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)D(e,r)&&a.push(t);return E(a),a}function _(e,t){let n=O(e),r=new Set,i=[];for(let e of n.plugins??[]){if(A(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new S(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=k(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function v(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/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()}).strict(),p=l.object({id:l.string(),path:l.string(),icon:d,title:l.string(),description:l.string().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}:{},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 y(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 b(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):x(e.routeModule,t)}))}function x(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 S(e,`could not resolve dashboard module`,t)}}var S=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function C(e){let t;try{t=await n(e,`utf8`)}catch(t){if(N(t)&&t.code===`ENOENT`)return;throw new S(e,`could not read page metadata`,t)}let r=s(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new S(e,r.errors[0]?.message??`invalid YAML`);let i=u.safeParse(r.toJS());if(!i.success)throw new S(e,c.prettifyError(i.error));return i.data}function w(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=d.safeParse(e);if(!i.success)throw new S(r,c.prettifyError(i.error));let a=i.data;A(a.id,r,`page id`),A(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new S(r,`page title must not be empty`);if(!a.routeModule.trim())throw new S(r,`page routeModule must not be empty`);let s=a.description?.trim();if(a.description!==void 0&&!s)throw new S(r,`page description must not be empty`);return{id:a.id,path:a.path,title:o,...s?{description:s}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function T(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=p.safeParse(e.navigation);if(!i.success)throw new S(r,c.prettifyError(i.error));let a=i.data;if(A(e.id,r,`plugin id`),A(a.path,r,`navigation path`),!a.title.trim())throw new S(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new S(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new S(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=k(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return w({id:e.id,path:a.path,title:a.title,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function E(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new S(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 S(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function D(e,t){return e.environments?e.environments.includes(t):!0}function O(e){let t=m.safeParse(e);if(!t.success)throw new S(`dashboard.config.ts`,c.prettifyError(t.error));return e}function k(t,n){let r=e(t);if(!r)throw new S(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new S(`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 S(`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 S(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function A(e,t,n){if(!l.test(e))throw new S(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function j(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function M(e,t){return e<t?-1:+(e>t)}function N(e){return e instanceof Error&&`code`in e}export{S as DashboardCompositionError,g as composeDashboardManifest,_ as composeDashboardPluginTarget,y as composeDashboardRoutes,h as discoverDashboardPages,v as renderDashboardPluginTargetModule,x as resolveDashboardModuleReference,b 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 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}:{},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};
@@ -8,6 +8,8 @@ interface DashboardPageContribution {
8
8
  /** Top-level URL segment below `/__dashboard/`. */
9
9
  path: string;
10
10
  title: string;
11
+ /** Codicon name, for example `settings-gear`. */
12
+ icon: string;
11
13
  description?: string;
12
14
  /** React Router framework route module, resolved by the dashboard build. */
13
15
  routeModule: string;
@@ -19,6 +21,8 @@ interface DashboardPluginNavigation {
19
21
  /** Top-level URL segment below `/__dashboard/`. */
20
22
  path: string;
21
23
  title: string;
24
+ /** Codicon name, for example `settings-gear`. */
25
+ icon: string;
22
26
  description?: string;
23
27
  /** Environments where the feature is available. Defaults to both. */
24
28
  environments?: readonly DashboardEnvironment[];
@@ -56,6 +60,8 @@ interface DashboardPageManifestEntry {
56
60
  id: string;
57
61
  path: string;
58
62
  title: string;
63
+ /** Codicon name, for example `settings-gear`. */
64
+ icon: string;
59
65
  description?: string;
60
66
  routeModule: string;
61
67
  source: "app" | "plugin";
@@ -5,6 +5,7 @@ declare const diagnosticsPlugin: {
5
5
  readonly id: "diagnostics";
6
6
  readonly navigation: {
7
7
  readonly path: "diagnostics";
8
+ readonly icon: "checklist";
8
9
  readonly title: "Production readiness";
9
10
  readonly description: "Review launch readiness, deployment configuration, and project health.";
10
11
  };
@@ -18,6 +19,7 @@ declare function diagnostics(): {
18
19
  readonly id: "diagnostics";
19
20
  readonly navigation: {
20
21
  readonly path: "diagnostics";
22
+ readonly icon: "checklist";
21
23
  readonly title: "Production readiness";
22
24
  readonly description: "Review launch readiness, deployment configuration, and project health.";
23
25
  };
@@ -1 +1 @@
1
- import{definePlugin as e}from"../../config.js";import{diagnosticsApi as t}from"./api/contract.js";const n=e({id:`diagnostics`,navigation:{path:`diagnostics`,title:`Production readiness`,description:`Review launch readiness, deployment configuration, and project health.`},pageModule:`@coreframe/dashboard/plugins/diagnostics/web`,api:t},{apiModule:`@coreframe/dashboard/plugins/diagnostics/api/contract`,localImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/local`,deployedImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/worker`});function r(){return n}export{r as diagnostics,n as diagnosticsPlugin};
1
+ import{definePlugin as e}from"../../config.js";import{diagnosticsApi as t}from"./api/contract.js";const n=e({id:`diagnostics`,navigation:{path:`diagnostics`,icon:`checklist`,title:`Production readiness`,description:`Review launch readiness, deployment configuration, and project health.`},pageModule:`@coreframe/dashboard/plugins/diagnostics/web`,api:t},{apiModule:`@coreframe/dashboard/plugins/diagnostics/api/contract`,localImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/local`,deployedImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/worker`});function r(){return n}export{r as diagnostics,n as diagnosticsPlugin};
@@ -195,8 +195,7 @@
195
195
  flex: 0 0 auto;
196
196
  place-items: center;
197
197
  border-radius: 0.375rem;
198
- background: var(--dashboard-foreground);
199
- color: var(--dashboard-surface);
198
+ object-fit: contain;
200
199
  font-size: 0.875rem;
201
200
  font-weight: 700;
202
201
  }
@@ -235,7 +234,7 @@
235
234
  color: var(--dashboard-foreground);
236
235
  }
237
236
 
238
- .coreframe-dashboard__navigation-initials {
237
+ .coreframe-dashboard__navigation-icon {
239
238
  display: grid;
240
239
  width: 1.5rem;
241
240
  height: 1.5rem;
@@ -248,8 +247,7 @@
248
247
  line-height: 1;
249
248
  }
250
249
 
251
- .coreframe-dashboard__navigation-link[aria-current="page"]
252
- .coreframe-dashboard__navigation-initials {
250
+ .coreframe-dashboard__navigation-link[aria-current="page"] .coreframe-dashboard__navigation-icon {
253
251
  background: color-mix(in srgb, var(--dashboard-accent) 12%, var(--dashboard-background));
254
252
  color: var(--dashboard-accent);
255
253
  }
@@ -2,10 +2,15 @@ import { DashboardPageManifestEntry } from "../config.js";
2
2
 
3
3
  //#region src/web-shell/shell.d.ts
4
4
  interface DashboardShellProps {
5
+ application?: {
6
+ name: string;
7
+ favicon: string;
8
+ };
5
9
  pages: readonly DashboardPageManifestEntry[];
6
10
  }
7
11
  declare function DashboardShell({
8
- pages
12
+ pages,
13
+ application
9
14
  }: DashboardShellProps): import("react").JSX.Element;
10
15
  declare function DashboardIndexRedirect({
11
16
  pages
@@ -1 +1 @@
1
- import{useEffect as e,useRef as t,useState as n}from"react";import{Link as r,NavLink as i,Navigate as a,Outlet as o,isRouteErrorResponse as s,useLocation as c,useNavigation as l,useRouteError as u}from"react-router";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p({pages:r}){let a=c(),s=l(),[u,p]=n(()=>globalThis.window!==void 0&&globalThis.matchMedia(`(max-width: 47.999rem)`).matches),[m,h]=n(!1),[g,v]=n(!1),y=t(null),b=t(null),x=t(!1),S=_(r,a.pathname);e(()=>{let e=globalThis.matchMedia(`(max-width: 47.999rem)`),t=()=>p(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),e(()=>{u&&(m?b.current?.focus():x.current&&y.current?.focus(),x.current=m)},[u,m]),e(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&h(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m]);let C=u?m:!g;return f(`div`,{className:`coreframe-dashboard`,"data-collapsed":!u&&g?`true`:`false`,"data-drawer-open":u&&m?`true`:`false`,children:[d(`button`,{type:`button`,className:`coreframe-dashboard__backdrop`,"aria-label":`Close dashboard navigation`,tabIndex:u&&m?0:-1,onClick:()=>h(!1)}),d(`aside`,{className:`coreframe-dashboard__sidebar`,role:u?`dialog`:void 0,"aria-label":u?`Dashboard navigation`:void 0,"aria-modal":u&&m?!0:void 0,"aria-hidden":u&&!m?!0:void 0,inert:u&&!m?!0:void 0,children:f(`nav`,{ref:b,id:`coreframe-dashboard-navigation`,className:`coreframe-dashboard__navigation`,"aria-label":`Dashboard`,tabIndex:u?-1:void 0,children:[f(`div`,{className:`coreframe-dashboard__sidebar-header`,children:[f(`div`,{className:`coreframe-dashboard__brand`,"aria-label":`Coreframe Dashboard`,children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__mark`,children:`C`}),d(`span`,{className:`coreframe-dashboard__navigation-text`,children:`Coreframe`})]}),u?d(`button`,{type:`button`,className:`coreframe-dashboard__drawer-close`,"aria-label":`Close dashboard navigation`,onClick:()=>h(!1),children:d(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:d(`path`,{d:`m6 6 12 12M6 18 18 6`})})}):null]}),r.length>0?d(`ul`,{className:`coreframe-dashboard__navigation-list`,children:r.map(e=>d(`li`,{children:f(i,{className:`coreframe-dashboard__navigation-link`,to:`/${e.path}`,title:e.title,onClick:()=>h(!1),children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-initials`,children:e.title.match(/[\p{L}\p{N}]+/gu)?.slice(0,2).map(e=>Array.from(e)[0]).join(``).toUpperCase()}),d(`span`,{className:`coreframe-dashboard__navigation-text`,children:e.title})]})},e.id))}):d(`p`,{className:`coreframe-dashboard__navigation-empty`,children:`No pages`})]})}),f(`main`,{className:`coreframe-dashboard__main`,inert:u&&m?!0:void 0,children:[f(`header`,{className:`coreframe-dashboard__page-header`,children:[d(`button`,{ref:y,type:`button`,className:`coreframe-dashboard__toggle`,"aria-controls":`coreframe-dashboard-navigation`,"aria-expanded":C,"aria-label":C?`Collapse dashboard navigation`:`Expand dashboard navigation`,title:C?`Collapse dashboard navigation`:`Expand dashboard navigation`,onClick:()=>{u?h(e=>!e):v(e=>!e)},children:f(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[d(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`3`}),d(`path`,{d:`M9 3v18`}),d(`path`,{d:C?`m16 9-3 3 3 3`:`m13 9 3 3-3 3`})]})}),S?f(`div`,{className:`coreframe-dashboard__page-heading`,children:[d(`h1`,{children:S.title}),S.description?d(`p`,{children:S.description}):null]}):null,s.state===`idle`?null:d(`div`,{className:`coreframe-dashboard__pending`,role:`status`,children:`Loading page…`})]}),d(`div`,{className:`coreframe-dashboard__content`,children:d(o,{})})]})]})}function m({pages:e}){let t=e[0];return t?d(a,{replace:!0,to:`/${t.path}`}):d(h,{})}function h(){return f(`section`,{className:`coreframe-dashboard__state`,"aria-labelledby":`dashboard-empty-title`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),d(`h1`,{id:`dashboard-empty-title`,children:`No dashboard pages yet`}),f(`p`,{children:[`Add a page under `,d(`code`,{children:`dashboard/pages/`}),` or register a plugin in`,` `,d(`code`,{children:`dashboard.config.ts`}),`.`]})]})}function g(){let e=u(),t=s(e)&&e.status===404,n=import.meta.env.DEV&&e instanceof Error?e.message:t?`The requested dashboard page does not exist.`:`The dashboard hit an unexpected error.`;return f(`main`,{className:`coreframe-dashboard__state`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Coreframe Dashboard`}),d(`h1`,{children:t?`Page not found`:`Dashboard unavailable`}),d(`p`,{children:n}),d(r,{className:`coreframe-dashboard__button`,to:`/`,children:`Go to dashboard`})]})}function _(e,t){let n=t.split(`/`).filter(Boolean)[0];return e.find(e=>e.path===n)??(n?void 0:e[0])}export{h as DashboardEmptyState,g as DashboardErrorBoundary,m as DashboardIndexRedirect,p as DashboardShell};
1
+ import{icons as e}from"@iconify-json/codicon";import{useEffect as t,useRef as n,useState as r}from"react";import{Link as i,NavLink as a,Navigate as o,Outlet as s,isRouteErrorResponse as c,useLocation as l,useNavigation as u,useRouteError as d}from"react-router";import{jsx as f,jsxs as p}from"react/jsx-runtime";function m({pages:i,application:o}){let c=l(),d=u(),[m,h]=r(()=>globalThis.window!==void 0&&globalThis.matchMedia(`(max-width: 47.999rem)`).matches),[g,_]=r(!1),[y,b]=r(!1),x=n(null),S=n(null),C=n(!1),w=v(i,c.pathname);t(()=>{let e=globalThis.matchMedia(`(max-width: 47.999rem)`),t=()=>h(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),t(()=>{m&&(g?S.current?.focus():C.current&&x.current?.focus(),C.current=g)},[m,g]),t(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g]);let T=m?g:!y;return p(`div`,{className:`coreframe-dashboard`,"data-collapsed":!m&&y?`true`:`false`,"data-drawer-open":m&&g?`true`:`false`,children:[f(`button`,{type:`button`,className:`coreframe-dashboard__backdrop`,"aria-label":`Close dashboard navigation`,tabIndex:m&&g?0:-1,onClick:()=>_(!1)}),f(`aside`,{className:`coreframe-dashboard__sidebar`,role:m?`dialog`:void 0,"aria-label":m?`Dashboard navigation`:void 0,"aria-modal":m&&g?!0:void 0,"aria-hidden":m&&!g?!0:void 0,inert:m&&!g?!0:void 0,children:p(`nav`,{ref:S,id:`coreframe-dashboard-navigation`,className:`coreframe-dashboard__navigation`,"aria-label":`Dashboard`,tabIndex:m?-1:void 0,children:[p(`div`,{className:`coreframe-dashboard__sidebar-header`,children:[p(`div`,{className:`coreframe-dashboard__brand`,"aria-label":o?.name,children:[o?f(`img`,{src:o.favicon,alt:``,className:`coreframe-dashboard__mark`}):null,f(`span`,{className:`coreframe-dashboard__navigation-text`,children:o?.name})]}),m?f(`button`,{type:`button`,className:`coreframe-dashboard__drawer-close`,"aria-label":`Close dashboard navigation`,onClick:()=>_(!1),children:f(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:f(`path`,{d:`m6 6 12 12M6 18 18 6`})})}):null]}),i.length>0?f(`ul`,{className:`coreframe-dashboard__navigation-list`,children:i.map(t=>f(`li`,{children:p(a,{className:`coreframe-dashboard__navigation-link`,to:`/${t.path}`,title:t.title,onClick:()=>_(!1),children:[f(`svg`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-icon`,width:`20`,height:`20`,viewBox:`0 0 ${e.width} ${e.height}`,fill:`currentColor`,dangerouslySetInnerHTML:{__html:e.icons[t.icon].body}}),f(`span`,{className:`coreframe-dashboard__navigation-text`,children:t.title})]})},t.id))}):f(`p`,{className:`coreframe-dashboard__navigation-empty`,children:`No pages`})]})}),p(`main`,{className:`coreframe-dashboard__main`,inert:m&&g?!0:void 0,children:[p(`header`,{className:`coreframe-dashboard__page-header`,children:[f(`button`,{ref:x,type:`button`,className:`coreframe-dashboard__toggle`,"aria-controls":`coreframe-dashboard-navigation`,"aria-expanded":T,"aria-label":T?`Collapse dashboard navigation`:`Expand dashboard navigation`,title:T?`Collapse dashboard navigation`:`Expand dashboard navigation`,onClick:()=>{m?_(e=>!e):b(e=>!e)},children:p(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[f(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`3`}),f(`path`,{d:`M9 3v18`}),f(`path`,{d:T?`m16 9-3 3 3 3`:`m13 9 3 3-3 3`})]})}),w?p(`div`,{className:`coreframe-dashboard__page-heading`,children:[f(`h1`,{children:w.title}),w.description?f(`p`,{children:w.description}):null]}):null,d.state===`idle`?null:f(`div`,{className:`coreframe-dashboard__pending`,role:`status`,children:`Loading page…`})]}),f(`div`,{className:`coreframe-dashboard__content`,children:f(s,{})})]})]})}function h({pages:e}){let t=e[0];return t?f(o,{replace:!0,to:`/${t.path}`}):f(g,{})}function g(){return p(`section`,{className:`coreframe-dashboard__state`,"aria-labelledby":`dashboard-empty-title`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),f(`h1`,{id:`dashboard-empty-title`,children:`No dashboard pages yet`}),p(`p`,{children:[`Add a page under `,f(`code`,{children:`dashboard/pages/`}),` or register a plugin in`,` `,f(`code`,{children:`dashboard.config.ts`}),`.`]})]})}function _(){let e=d(),t=c(e)&&e.status===404,n=import.meta.env.DEV&&e instanceof Error?e.message:t?`The requested dashboard page does not exist.`:`The dashboard hit an unexpected error.`;return p(`main`,{className:`coreframe-dashboard__state`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Coreframe Dashboard`}),f(`h1`,{children:t?`Page not found`:`Dashboard unavailable`}),f(`p`,{children:n}),f(i,{className:`coreframe-dashboard__button`,to:`/`,children:`Go to dashboard`})]})}function v(e,t){let n=t.split(`/`).filter(Boolean)[0];return e.find(e=>e.path===n)??(n?void 0:e[0])}export{g as DashboardEmptyState,_ as DashboardErrorBoundary,h as DashboardIndexRedirect,m as DashboardShell};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/dashboard",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -80,6 +80,7 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "@fontsource-variable/inter": "^5.2.8",
83
+ "@iconify-json/codicon": "^1.2.77",
83
84
  "@tanstack/react-query": "^5.101.2",
84
85
  "react": "19.2.8",
85
86
  "react-dom": "19.2.8",