@coreframe/dashboard 0.3.30 → 0.3.32
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 +13 -16
- package/dist/package/build.js +2 -2
- package/dist/package/config.d.ts +9 -3
- package/dist/package/index.d.ts +3 -3
- package/dist/package/shell.css +48 -726
- package/dist/package/types.d.ts +1 -17
- package/dist/package/web/styled-system/helpers.js +1 -1
- package/dist/package/web-shell/menu.d.ts +1 -1
- package/dist/package/web-shell/menu.js +1 -1
- package/dist/package/web-shell/shell.js +6 -1
- package/package.json +5 -27
- package/dist/package/plugins/diagnostics/api/contract.d.ts +0 -13
- package/dist/package/plugins/diagnostics/api/contract.js +0 -1
- package/dist/package/plugins/diagnostics/api/local.d.ts +0 -10
- package/dist/package/plugins/diagnostics/api/local.js +0 -1
- package/dist/package/plugins/diagnostics/api/worker.d.ts +0 -8
- package/dist/package/plugins/diagnostics/api/worker.js +0 -1
- package/dist/package/plugins/diagnostics/index.d.ts +0 -32
- package/dist/package/plugins/diagnostics/index.js +0 -1
- package/dist/package/plugins/diagnostics/web/queries.js +0 -1
- package/dist/package/plugins/diagnostics/web.d.ts +0 -4
- package/dist/package/plugins/diagnostics/web.js +0 -1
- package/dist/package/web/dashboard/dashboard-page.js +0 -1
- package/dist/package/web/dashboard/dashboard-section.js +0 -1
- package/dist/package/web/dashboard/dashboard.style.js +0 -1
- package/dist/package/web/dashboard/deployed-dashboard-page.js +0 -1
- package/dist/package/web/dashboard/findings.js +0 -1
- package/dist/package/web/dashboard/worker-environment.js +0 -1
- package/dist/package/web/root.style.js +0 -1
- package/dist/package/web/styled-system/css/css.js +0 -1
package/README.md
CHANGED
|
@@ -15,29 +15,33 @@ 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: [
|
|
20
|
+
plugins: [],
|
|
22
21
|
})
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
30
|
-
and `layout`. Plugin navigation also requires `icon`. Navigation uses
|
|
31
|
-
and
|
|
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
|
|
32
33
|
navigation popover on hover, click, or keyboard activation. Pages own their headings, layout, and
|
|
33
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.
|
|
34
38
|
|
|
35
39
|
Set `layout: standalone` to omit the floating logo. A standalone page may place `DashboardMenu`
|
|
36
40
|
from `@coreframe/dashboard/web` in its own header or layout; it receives the current application and
|
|
37
41
|
page list automatically:
|
|
38
42
|
|
|
39
43
|
```yaml
|
|
40
|
-
icon: settings
|
|
44
|
+
icon: settings
|
|
41
45
|
title: Moderation
|
|
42
46
|
layout: standalone
|
|
43
47
|
```
|
|
@@ -80,7 +84,7 @@ Projects can opt into app-owned customization without copying the default scaffo
|
|
|
80
84
|
|
|
81
85
|
Keep customization in the project; package styles do not need to be copied or ejected. Styles load
|
|
82
86
|
in this order: the package shell, `dashboard/styled-system/styles.css`, then `dashboard/styles.css`.
|
|
83
|
-
The package stylesheet includes
|
|
87
|
+
The package stylesheet includes reusable UI defaults and tokens.
|
|
84
88
|
Normal unlayered rules in `styles.css` take precedence over layered Panda rules. Shell rules are
|
|
85
89
|
unlayered, so match the relevant selector's specificity when overriding them.
|
|
86
90
|
|
|
@@ -239,13 +243,6 @@ checks before returning a stream. NDJSON actions resolve to an `AsyncIterable` o
|
|
|
239
243
|
type; the codec does not validate items against a runtime schema. This configuration applies to the
|
|
240
244
|
hosting app's `/api/` routes, independently of the dashboard plugin API.
|
|
241
245
|
|
|
242
|
-
## Built-in diagnostics
|
|
243
|
-
|
|
244
|
-
The diagnostics plugin preserves the full local production-readiness inspection and provides a
|
|
245
|
-
reduced deployed view. Its page is a normal module and its browser data uses a typed operation client
|
|
246
|
-
with TanStack Query. Local collection may use Node.js through its narrow host data; deployed
|
|
247
|
-
collection never receives ambient Worker bindings or raw configuration values.
|
|
248
|
-
|
|
249
246
|
Useful package checks:
|
|
250
247
|
|
|
251
248
|
```bash
|
package/dist/package/build.js
CHANGED
|
@@ -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/
|
|
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
|
|
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};
|
package/dist/package/config.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface DashboardPageContribution {
|
|
|
10
10
|
/** Top-level URL segment below `/__dashboard/`. */
|
|
11
11
|
path: string;
|
|
12
12
|
title: string;
|
|
13
|
-
/**
|
|
13
|
+
/** Tabler name, for example `settings`. */
|
|
14
14
|
icon: string;
|
|
15
15
|
description?: string;
|
|
16
16
|
/** Defaults to floating logo navigation. Standalone pages can place DashboardMenu themselves. */
|
|
@@ -25,7 +25,7 @@ interface DashboardPluginNavigation {
|
|
|
25
25
|
/** Top-level URL segment below `/__dashboard/`. */
|
|
26
26
|
path: string;
|
|
27
27
|
title: string;
|
|
28
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
package/dist/package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export { type
|
|
1
|
+
import { DashboardReleaseIdentity } from "./types.js";
|
|
2
|
+
import { createNodeHandler, createNodeServer } from "./server.js";
|
|
3
|
+
export { type DashboardReleaseIdentity, createNodeHandler, createNodeServer };
|