@coreframe/dashboard 0.4.0-next.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -23
- package/dist/package/access.d.ts +7 -0
- package/dist/package/access.js +30 -0
- package/dist/package/app/root.js +1 -1
- package/dist/package/app/sculpted-runtime.js +1 -0
- package/dist/package/app/shell.js +1 -1
- package/dist/package/app-client.d.ts +5 -4
- package/dist/package/app-client.js +1 -1
- package/dist/package/build.js +2 -2
- package/dist/package/config.d.ts +15 -3
- package/dist/package/index.d.ts +3 -3
- package/dist/package/node-fetch-adapter.js +1 -1
- package/dist/package/server.d.ts +8 -2
- package/dist/package/server.js +1 -1
- package/dist/package/types.d.ts +1 -17
- package/dist/package/web/styled-system/css/conditions.js +1 -1
- package/dist/package/web/styled-system/helpers.js +1 -1
- package/dist/package/web/styled-system/recipes/dashboard-button.js +1 -1
- package/dist/package/web/styled-system/recipes/dashboard-status.js +1 -1
- package/dist/package/web/styled-system/recipes/runtime.js +1 -1
- package/dist/package/web/ui/index.d.ts +1 -1
- package/dist/package/web/ui/styles.js +1 -1
- package/dist/package/web-shell/index.d.ts +2 -1
- package/dist/package/web-shell/index.js +1 -1
- package/dist/package/web-shell/menu.d.ts +19 -0
- package/dist/package/web-shell/menu.js +1 -0
- package/dist/package/web-shell/shell.d.ts +7 -6
- package/dist/package/web-shell/shell.js +6 -1
- package/dist/package/worker.d.ts +3 -3
- package/dist/package/worker.js +1 -1
- package/package.json +16 -33
- package/dist/package/plugins/diagnostics/api/contract.d.ts +0 -10
- 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 -30
- 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/shell.css +0 -390
- package/dist/package/styled-css.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,26 +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: [
|
|
20
|
+
plugins: [],
|
|
22
21
|
})
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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.
|
|
28
|
+
|
|
29
|
+
Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An adjacent `page.yaml` must define
|
|
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:
|
|
31
42
|
|
|
32
43
|
```yaml
|
|
44
|
+
icon: settings
|
|
33
45
|
title: Moderation
|
|
34
46
|
layout: standalone
|
|
35
47
|
```
|
|
36
48
|
|
|
37
|
-
|
|
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
|
|
38
66
|
the dashboard route, build, authentication, query-client, and error-handling boundaries. Build-time
|
|
39
67
|
composition validates slugs, metadata, route modules, identifiers, and paths before generating the
|
|
40
68
|
React Router route graph and navigation manifest.
|
|
@@ -48,15 +76,64 @@ Projects can opt into app-owned customization without copying the default scaffo
|
|
|
48
76
|
|
|
49
77
|
- `dashboard/document.tsx`, referenced as `document` in `dashboard.config.ts`, can provide a custom
|
|
50
78
|
document `Layout` and optional `links` or `meta` exports;
|
|
51
|
-
- `dashboard/
|
|
52
|
-
|
|
79
|
+
- `dashboard/panda.config.ts` owns theme and style overrides; an optional `dashboard/styles.css`
|
|
80
|
+
loads after the generated Panda stylesheet for additional project CSS; and
|
|
53
81
|
- `vite.config.ts` and `react-router.config.ts` remain small tool-level adapters for build changes.
|
|
54
82
|
|
|
83
|
+
## Style overrides
|
|
84
|
+
|
|
85
|
+
The dashboard app's Panda build generates all dashboard styles, including the document reset,
|
|
86
|
+
shell, tokens, and UI recipes. `@coreframe/dashboard` does not ship a compiled stylesheet.
|
|
87
|
+
The styles module loads Inter's font stylesheet, then `dashboard/styled-system/styles.css`, then
|
|
88
|
+
an optional `dashboard/styles.css`. Panda controls the layer order; shell and document rules live
|
|
89
|
+
in its `base` layer. Normal unlayered project CSS takes precedence over normal layered rules.
|
|
90
|
+
|
|
91
|
+
The dashboard Panda config includes `coreframeDashboardPreset()` from `@coreframe/panda` and
|
|
92
|
+
statically generates all dashboard recipe variants because package components select variants at
|
|
93
|
+
runtime. Keep that `staticCss.recipes` configuration when customizing the app. The preset installs
|
|
94
|
+
document-wide styles, so use it only in the dedicated dashboard build, not the host app's Panda config.
|
|
95
|
+
|
|
96
|
+
Customize `theme.extend.semanticTokens.colors.dashboard` for shared colors, `theme.extend.tokens.fonts`
|
|
97
|
+
for typography, and `theme.extend.recipes` or `theme.extend.slotRecipes` for reusable UI defaults.
|
|
98
|
+
The color roles are `canvas`, `panel`, `ink`, `muted`, `border`, `accent`, `danger`, `info`,
|
|
99
|
+
`success`, and `warning`. Shell styles consume the same tokens as the UI components.
|
|
100
|
+
|
|
101
|
+
For targeted menu changes, extend the public `.coreframe-dashboard__*` selectors through
|
|
102
|
+
`globalCss.extend` in `dashboard/panda.config.ts`. Using `extend` preserves the other defaults
|
|
103
|
+
for each selector:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
globalCss: {
|
|
107
|
+
extend: {
|
|
108
|
+
".coreframe-dashboard__floating-navigation": {
|
|
109
|
+
top: "1.5rem",
|
|
110
|
+
left: "1.5rem",
|
|
111
|
+
},
|
|
112
|
+
'.coreframe-dashboard__navigation-link[aria-current="page"]': {
|
|
113
|
+
fontWeight: "700",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The logo button exposes `aria-expanded`; navigation links expose `aria-current="page"` for the
|
|
120
|
+
current page. The reusable UI uses Panda recipe classes
|
|
121
|
+
such as `.dashboard-button` and `.dashboard-section__root`.
|
|
122
|
+
|
|
123
|
+
Sculpted source editing applies to supported project-owned static Panda `css({ ... })` sources;
|
|
124
|
+
it does not redirect package styles into project overrides or edit config recipes. Its current
|
|
125
|
+
root-level development endpoints need to be scoped to the dashboard's Vite base. Wrap the
|
|
126
|
+
dashboard's `sculpted()` plugin with `coreframeDashboardSculptedPlugin` from
|
|
127
|
+
`@coreframe/vite/dashboard-sculpted`; the generated dashboard does this and mounts the runtime in
|
|
128
|
+
development. The wrapper routes requests through `/__dashboard/` to this dashboard's own manifest
|
|
129
|
+
and writeback handlers. A custom document continues to get the runtime when it renders the root's
|
|
130
|
+
children. CSS and Panda overrides work independently of Sculpted.
|
|
131
|
+
|
|
55
132
|
## Runtime boundaries
|
|
56
133
|
|
|
57
134
|
The app dashboard uses the same React, React Router framework mode, React Compiler, PandaCSS,
|
|
58
|
-
|
|
59
|
-
Coreframe contributes the
|
|
135
|
+
Rouzer, Zod, TanStack Query, and Worker conventions as the main Coreframe application.
|
|
136
|
+
Coreframe contributes the logo navigation and default client/query runtime without
|
|
60
137
|
imposing a page-content component API.
|
|
61
138
|
|
|
62
139
|
Plugin APIs expose named `queries` and `commands`. Queries are `GET` operations and commands are
|
|
@@ -82,9 +159,6 @@ credentials, Worker bindings, environment secrets, and the raw request remain ou
|
|
|
82
159
|
contract. Typed operation errors expose safe error codes, and a failed local initialization can be
|
|
83
160
|
retried without restarting the host.
|
|
84
161
|
|
|
85
|
-
Each plugin’s `apiModule` must default-export its operation contract. Both the local host and
|
|
86
|
-
generated Worker target load that default export.
|
|
87
|
-
|
|
88
162
|
The compact plugin API uses `api`, `query`, and `command` for the shared contract, then derives a
|
|
89
163
|
browser client from that contract:
|
|
90
164
|
|
|
@@ -158,15 +232,27 @@ dashboard credentials, or user IDs.
|
|
|
158
232
|
|
|
159
233
|
App requests use credentialed same-origin transport. Explicit invalid-token challenges refresh and
|
|
160
234
|
replay once through the app transport. Other response statuses keep their normal meaning, including
|
|
161
|
-
distinct `401` and `403` failures. The dashboard
|
|
162
|
-
|
|
235
|
+
distinct `401` and `403` failures. The dashboard host requires the current app session and an
|
|
236
|
+
active user with `role === "admin"`. The plugin `DashboardSuperuser` actor remains a capability
|
|
237
|
+
marker; plugins do not receive the app identity.
|
|
163
238
|
|
|
164
|
-
|
|
239
|
+
If the route tree contains response codecs such as NDJSON, register their client plugins even when
|
|
240
|
+
the page does not call those routes. Rouzer validates codec registration during client construction.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import { createDashboardAppClient } from "@coreframe/dashboard/app-client"
|
|
244
|
+
import * as ndjson from "rouzer/ndjson"
|
|
245
|
+
|
|
246
|
+
const { client, session } = createDashboardAppClient(routes, {
|
|
247
|
+
plugins: [ndjson.clientPlugin],
|
|
248
|
+
})
|
|
249
|
+
```
|
|
165
250
|
|
|
166
|
-
The
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
251
|
+
The hosting app must separately register `ndjson.routerPlugin` in its API's `createRouter({ plugins })`
|
|
252
|
+
configuration. Keep its existing authentication middleware, and complete authentication and permission
|
|
253
|
+
checks before returning a stream. NDJSON actions resolve to an `AsyncIterable` of the declared item
|
|
254
|
+
type; the codec does not validate items against a runtime schema. This configuration applies to the
|
|
255
|
+
hosting app's `/api/` routes, independently of the dashboard plugin API.
|
|
170
256
|
|
|
171
257
|
Useful package checks:
|
|
172
258
|
|
|
@@ -178,3 +264,38 @@ pnpm --dir node/dashboard build
|
|
|
178
264
|
```
|
|
179
265
|
|
|
180
266
|
Design notes live in [`design/`](./design/).
|
|
267
|
+
|
|
268
|
+
## App navigation and sign-in
|
|
269
|
+
|
|
270
|
+
Apps import browser-safe navigation from `@coreframe/app/dashboard`:
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import { dashboard } from "@coreframe/app/dashboard"
|
|
274
|
+
|
|
275
|
+
export function DashboardLinks() {
|
|
276
|
+
return dashboard.pages.map((page) => (
|
|
277
|
+
<a key={page.id} href={page.href}>
|
|
278
|
+
{page.title}
|
|
279
|
+
</a>
|
|
280
|
+
))
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`dashboard` exposes `enabled`, `href`, and ordered `pages` containing `id`, `title`, optional
|
|
285
|
+
`description`, Tabler `icon`, and `href`. Composition uses the same app pages, plugin entries,
|
|
286
|
+
and environment filtering as the dashboard. Disabled dashboards and client-only builds expose
|
|
287
|
+
an empty list. This metadata is public in the app bundle and grants no access. Use browser links
|
|
288
|
+
because the dashboard owns a separate router.
|
|
289
|
+
|
|
290
|
+
The app host resolves the current durable session and database user for every dashboard request.
|
|
291
|
+
Only active users whose role is exactly `admin` may access documents, assets, or plugin APIs.
|
|
292
|
+
Signed-out document navigations receive an email/password sign-in form at the requested URL;
|
|
293
|
+
other unauthorized requests receive JSON `401`. Signed-in non-admins receive `403`, with an
|
|
294
|
+
account-switch action on document navigations. Login and sign-out use the app's existing auth
|
|
295
|
+
endpoints. Reloading after sign-in preserves the path, query, and fragment. Dashboard responses
|
|
296
|
+
are not cached. No dashboard password or alternate authentication mode is used.
|
|
297
|
+
|
|
298
|
+
The template owns the database/session integration in `src/api/worker/dashboard.ts`. Reusable
|
|
299
|
+
Worker handlers require a server-resolved access result; Node hosts fail closed unless an app
|
|
300
|
+
access resolver is supplied. Local development resolves access through the app's fixed origin,
|
|
301
|
+
including direct dashboard-server requests. Preview requires a running app auth boundary.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/access.d.ts
|
|
2
|
+
/** Result of resolving the app's current durable session and database user. */
|
|
3
|
+
type DashboardAccess = "admin" | "unauthenticated" | "forbidden";
|
|
4
|
+
/** Responds before any dashboard assets or operations are served. */
|
|
5
|
+
declare function dashboardAccessResponse(request: Request, access: DashboardAccess): Response | null;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { DashboardAccess, dashboardAccessResponse };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function e(e,n){if(n===`admin`)return null;let r=n===`unauthenticated`?401:403,i=new URL(e.url);if(!((e.method===`GET`||e.method===`HEAD`)&&!i.pathname.startsWith(`/__dashboard/api`)&&(e.headers.get(`sec-fetch-dest`)===`document`||e.headers.get(`accept`)?.includes(`text/html`))))return Response.json({error:n},{status:r,headers:{"cache-control":`no-store`}});let a=crypto.randomUUID();return new Response(e.method===`HEAD`?null:t(n,a),{status:r,headers:{"cache-control":`private, no-store`,"content-type":`text/html; charset=utf-8`,"content-security-policy":`default-src 'none'; script-src 'nonce-${a}'; style-src 'nonce-${a}'; connect-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'`,"x-content-type-options":`nosniff`,"referrer-policy":`same-origin`}})}function t(e,t){let n=e===`forbidden`;return`<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
3
|
+
<title>${n?`Dashboard access denied`:`Sign in to dashboard`}</title>
|
|
4
|
+
<style nonce="${t}">
|
|
5
|
+
body{font:16px system-ui,sans-serif;background:#f7f7f8;color:#202124;margin:0;display:grid;min-height:100svh;place-items:center}main{width:min(24rem,calc(100% - 4rem));padding:2rem}h1{font-size:1.6rem}form,label{display:grid;gap:.5rem}form{gap:1rem}input,button{font:inherit;padding:.75rem;border:1px solid #aaa;border-radius:.4rem}button{cursor:pointer;background:#202124;color:white}button:disabled{opacity:.6}#error{color:#a11919}
|
|
6
|
+
</style></head><body><main><p>Coreframe Dashboard</p>
|
|
7
|
+
<h1>${n?`You don’t have dashboard access`:`Sign in to dashboard`}</h1>
|
|
8
|
+
${n?`<p>An administrator account is required.</p><button id="switch" type="button">Switch accounts</button>`:`<form id="signin"><label>Email<input name="email" type="email" autocomplete="username" required></label><label>Password<input name="password" type="password" autocomplete="current-password" required></label><button type="submit">Sign in</button></form>`}
|
|
9
|
+
<p id="error" role="alert"></p>
|
|
10
|
+
<script nonce="${t}">
|
|
11
|
+
const error = document.getElementById('error');
|
|
12
|
+
async function submit(path, body, button) {
|
|
13
|
+
button.disabled = true; error.textContent = '';
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch('/api/auth/' + path, {method:'POST', credentials:'same-origin', headers:{'content-type':'application/json'}, body:JSON.stringify(body)});
|
|
16
|
+
if (!response.ok) { error.textContent = response.status === 429 ? 'Too many attempts. Try again later.' : 'Unable to sign in. Check your details and try again.'; return; }
|
|
17
|
+
try {
|
|
18
|
+
localStorage.removeItem('coreframe.auth-session-observation.v1');
|
|
19
|
+
sessionStorage.setItem('coreframe.auth-session-recheck', 'true');
|
|
20
|
+
} catch {}
|
|
21
|
+
location.reload();
|
|
22
|
+
} catch { error.textContent = 'Unable to connect. Try again.'; }
|
|
23
|
+
finally { button.disabled = false; }
|
|
24
|
+
}
|
|
25
|
+
document.getElementById('signin')?.addEventListener('submit', event => {
|
|
26
|
+
event.preventDefault(); const form = event.currentTarget; const values = new FormData(form);
|
|
27
|
+
void submit('sign-in/email', {email:values.get('email'), password:values.get('password')}, form.querySelector('button'));
|
|
28
|
+
});
|
|
29
|
+
document.getElementById('switch')?.addEventListener('click', event => { void submit('sign-out', {}, event.currentTarget); });
|
|
30
|
+
<\/script></main></body></html>`}export{e as dashboardAccessResponse};
|
package/dist/package/app/root.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Links as
|
|
1
|
+
import{DashboardSculptedRuntime as e}from"./sculpted-runtime.js";import{Links as t,Meta as n,Outlet as r,Scripts as i,ScrollRestoration as a}from"react-router";import{Suspense as o,lazy as s}from"react";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{dashboardApplication as u,dashboardManifest as d}from"virtual:coreframe-internal/dashboard/manifest";import{QueryClient as f,QueryClientProvider as p}from"@tanstack/react-query";import*as m from"virtual:coreframe-internal/dashboard/document";import"virtual:coreframe-internal/dashboard/styles";const h=new f({defaultOptions:{queries:{retry:1,staleTime:3e4}}}),g=import.meta.env.VITE_COREFRAME_MANAGED_DEV_OVERLAY_DEBUG===`1`,_=import.meta.env.DEV&&(import.meta.env.COREFRAME_MANAGED_DEV||g),v=import.meta.env.DEV?s(()=>import(`virtual:coreframe-internal/dashboard/managed-dev-overlay`).then(({ManagedDevOverlay:e})=>({default:e}))):null;function y({children:r}){let s=m.Layout,u=l(p,{client:h,children:[r,import.meta.env.DEV?c(e,{}):null,v&&_?c(o,{fallback:null,children:c(v,{debug:g})}):null]});return s?c(s,{children:u}):l(`html`,{lang:`en`,children:[l(`head`,{children:[c(`meta`,{charSet:`UTF-8`}),c(`meta`,{name:`viewport`,content:`width=device-width, initial-scale=1`}),c(n,{}),c(t,{})]}),l(`body`,{children:[u,c(a,{}),c(i,{})]})]})}const b=({location:e})=>{let t=e.pathname.split(`/`).filter(Boolean)[0];return[{title:`${d.find(e=>e.path===t)?.title||`Dashboard`} | ${u.name}`}]},x=m.links??(()=>[{rel:`icon`,href:u.favicon}]),S=m.meta??b;function C(){let e=m.default;return c(e||r,{})}export{y as Layout,C as default,x as links,S as meta};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as e}from"react";import{enabled as t}from"virtual:coreframe-internal/dashboard/sculpted-availability";function n(){return e(()=>{import.meta.env.DEV&&t&&import(`virtual:coreframe-internal/dashboard/sculpted-runtime`)},[]),null}export{n as DashboardSculptedRuntime};
|
|
@@ -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
|
|
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,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
|
-
/**
|
|
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; /**
|
|
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. */
|
|
@@ -49,7 +50,7 @@ type DashboardAppClientResult<Routes extends HttpRouteTree> = Readonly<{
|
|
|
49
50
|
*
|
|
50
51
|
* The client always targets the current page origin and `/api/`. It refreshes through the app's
|
|
51
52
|
* fixed `POST /api/auth/token` endpoint and sends credentialed same-origin requests. Dashboard
|
|
52
|
-
*
|
|
53
|
+
* admin authorization remains owned by the dashboard host and is not part of this client.
|
|
53
54
|
*/
|
|
54
55
|
declare function createDashboardAppClient<const Routes extends HttpRouteTree>(routes: Routes, options?: DashboardAppClientOptions): DashboardAppClientResult<Routes>;
|
|
55
56
|
/** The props accepted by {@link DashboardAppSessionBoundary}. */
|
|
@@ -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};
|
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{
|
|
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
|
|
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
|
@@ -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
|
-
/**
|
|
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,8 +10,10 @@ interface DashboardPageContribution {
|
|
|
10
10
|
/** Top-level URL segment below `/__dashboard/`. */
|
|
11
11
|
path: string;
|
|
12
12
|
title: string;
|
|
13
|
+
/** Tabler name, for example `settings`. */
|
|
14
|
+
icon: string;
|
|
13
15
|
description?: string;
|
|
14
|
-
/**
|
|
16
|
+
/** Defaults to floating logo navigation. Standalone pages can place DashboardMenu themselves. */
|
|
15
17
|
layout?: DashboardPageLayout;
|
|
16
18
|
/** React Router framework route module, resolved by the dashboard build. */
|
|
17
19
|
routeModule: string;
|
|
@@ -23,6 +25,8 @@ interface DashboardPluginNavigation {
|
|
|
23
25
|
/** Top-level URL segment below `/__dashboard/`. */
|
|
24
26
|
path: string;
|
|
25
27
|
title: string;
|
|
28
|
+
/** Tabler name, for example `settings`. */
|
|
29
|
+
icon: string;
|
|
26
30
|
description?: string;
|
|
27
31
|
/** Environments where the feature is available. Defaults to both. */
|
|
28
32
|
environments?: readonly DashboardEnvironment[];
|
|
@@ -33,7 +37,7 @@ interface DashboardPluginNavigation {
|
|
|
33
37
|
* than a public list of target-specific module paths.
|
|
34
38
|
*/
|
|
35
39
|
interface DashboardPluginBuild {
|
|
36
|
-
/** Module exporting the plugin's operation contract as
|
|
40
|
+
/** Module exporting the plugin's operation contract as `api`. */
|
|
37
41
|
apiModule: string;
|
|
38
42
|
/** Module exporting the local implementation factory as `createImplementation`. */
|
|
39
43
|
localImplementationModule: string;
|
|
@@ -60,6 +64,14 @@ interface DashboardPageManifestEntry {
|
|
|
60
64
|
id: string;
|
|
61
65
|
path: string;
|
|
62
66
|
title: string;
|
|
67
|
+
/** Tabler name, for example `settings`. */
|
|
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
|
+
};
|
|
63
75
|
description?: string;
|
|
64
76
|
layout?: DashboardPageLayout;
|
|
65
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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DashboardRequestError as e}from"./request-error.js";async function t(e,t,r){let i=await r(await n(e)),a={};i.headers.forEach((e,t)=>{a[t]=e}),t.writeHead(i.status,a),t.end(Buffer.from(await i.arrayBuffer()))}async function n(e){let t=e.method??`GET`,n=new Headers;for(let[t,r]of Object.entries(e.headers))Array.isArray(r)?r.forEach(e=>n.append(t,e)):r!==void 0&&n.set(t,r);return new Request(r(e),{method:t,headers:n,body:t===`GET`||t===`HEAD`?void 0:await i(e)})}function r(e){let t=e.headers[`x-forwarded-proto`]===`https`?`https`:`http`;return new URL(e.url??`/`,`${t}://${e.headers.host??`localhost`}`)}async function i(t){let n=[],r=0;for await(let i of t){let t=Buffer.isBuffer(i)?i:Buffer.from(i);if(r+=t.length,r>8192)throw new e(`Dashboard request is too large.`,413);n.push(t)}return Buffer.concat(n).toString(`utf8`)}export{t as handleFetchRequest};
|
|
1
|
+
import{DashboardRequestError as e}from"./request-error.js";async function t(e,t,r){let i=await r(await n(e)),a={};i.headers.forEach((e,t)=>{a[t]=e}),t.writeHead(i.status,a),t.end(Buffer.from(await i.arrayBuffer()))}async function n(e){let t=e.method??`GET`,n=new Headers;for(let[t,r]of Object.entries(e.headers))Array.isArray(r)?r.forEach(e=>n.append(t,e)):r!==void 0&&n.set(t,r);return new Request(r(e),{method:t,headers:n,body:t===`GET`||t===`HEAD`?void 0:await i(e)})}function r(e){let t=String(e.headers[`x-forwarded-proto`]??``).split(`,`)[0]?.trim()===`https`?`https`:`http`;return new URL(e.url??`/`,`${t}://${e.headers.host??`localhost`}`)}async function i(t){let n=[],r=0;for await(let i of t){let t=Buffer.isBuffer(i)?i:Buffer.from(i);if(r+=t.length,r>8192)throw new e(`Dashboard request is too large.`,413);n.push(t)}return Buffer.concat(n).toString(`utf8`)}export{t as handleFetchRequest};
|
package/dist/package/server.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { DashboardAccess } from "./access.js";
|
|
1
2
|
import { DashboardPluginRegistration } from "./api/contract.js";
|
|
2
3
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
4
|
+
import { SecureContextOptions } from "node:tls";
|
|
3
5
|
|
|
4
6
|
//#region src/server.d.ts
|
|
5
7
|
type DashboardServerOptions = {
|
|
6
|
-
/** Built dashboard client directory. Omit when the host only dispatches API requests. */clientDist?: string;
|
|
8
|
+
/** Built dashboard client directory. Omit when the host only dispatches API requests. */clientDist?: string; /** Resolves the current app session through the trusted app host. Fails closed if omitted. */
|
|
9
|
+
getAccess?: (request: IncomingMessage) => Promise<DashboardAccess>;
|
|
7
10
|
plugins: readonly DashboardPluginRegistration<DashboardLocalHostData>[];
|
|
8
11
|
projectRoot: string;
|
|
9
12
|
};
|
|
@@ -11,11 +14,14 @@ type DashboardLocalHostData = {
|
|
|
11
14
|
/** Root of the application the local dashboard is inspecting. */projectRoot: string;
|
|
12
15
|
};
|
|
13
16
|
type DashboardRequestHandler = {
|
|
17
|
+
/** Gates host-served development assets; writes the denied response and returns false on failure. */authorize(request: IncomingMessage, response: ServerResponse): Promise<boolean>;
|
|
14
18
|
dispose(): Promise<void>;
|
|
15
19
|
handle(request: IncomingMessage, response: ServerResponse): Promise<void>;
|
|
16
20
|
};
|
|
17
21
|
declare function createNodeServer(options: DashboardServerOptions): Server;
|
|
18
22
|
/** Creates the localhost-only Node handler for the built client and composed plugin operations. */
|
|
19
23
|
declare function createNodeHandler(options: DashboardServerOptions): DashboardRequestHandler;
|
|
24
|
+
/** Resolves access through a fixed app origin; request Host headers never select the destination. */
|
|
25
|
+
declare function createAppAccessResolver(getOrigin: () => string | undefined, tls?: Pick<SecureContextOptions, "ca">): (request: IncomingMessage) => Promise<DashboardAccess>;
|
|
20
26
|
//#endregion
|
|
21
|
-
export { DashboardLocalHostData, DashboardRequestHandler, DashboardServerOptions, createNodeHandler, createNodeServer };
|
|
27
|
+
export { DashboardLocalHostData, DashboardRequestHandler, DashboardServerOptions, createAppAccessResolver, createNodeHandler, createNodeServer };
|
package/dist/package/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{dashboardAccessResponse as e}from"./access.js";import{createDashboardPluginDispatcher as t}from"./api/dispatcher.js";import{DashboardRequestError as n}from"./request-error.js";import{assertDashboardApiRequestOrigin as r,assertLocalDashboardHost as i,getDashboardRequestId as a}from"./host-policy.js";import{handleFetchRequest as o}from"./node-fetch-adapter.js";import{readFile as s,stat as c}from"node:fs/promises";import{extname as l,isAbsolute as u,join as d,relative as f,resolve as p,sep as m}from"node:path";import{createServer as h,request as g}from"node:http";import{request as _}from"node:https";function v(e){let t=y(e),n=h(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function y(s){let c=t(s.plugins,{host:Object.freeze({projectRoot:s.projectRoot}),getRequestId:a});async function l(t,a){try{i(t);let n=s.getAccess?await s.getAccess(t):`unauthenticated`,o=String(t.headers[`x-forwarded-proto`]??``).split(`,`)[0]?.trim()===`https`?`https`:`http`,c=new URL(t.url??`/`,`${o}://${t.headers.host}`),l=e(new Request(c,{method:t.method,headers:{accept:t.headers.accept??``,"sec-fetch-dest":String(t.headers[`sec-fetch-dest`]??``)}}),n);if(!l)return r(t,c),!0;a.writeHead(l.status,Object.fromEntries(l.headers)),a.end(Buffer.from(await l.arrayBuffer()))}catch(e){x(a,e instanceof n?e.status:503,{error:`Dashboard access unavailable`})}return!1}return{authorize:l,dispose:async()=>void 0,async handle(e,t){try{i(e);let n=String(e.headers[`x-forwarded-proto`]??``).split(`,`)[0]?.trim()===`https`?`https`:`http`,r=new URL(e.url??`/`,`${n}://${e.headers.host??`127.0.0.1`}`);if(!await l(e,t))return;if(r.pathname.startsWith(`/__dashboard/api/plugins/`)){await o(e,t,c);return}if(r.pathname===`/__dashboard/api`||r.pathname.startsWith(`/__dashboard/api/`)){x(t,404,{error:`Not found`});return}if(!s.clientDist){x(t,404,{error:`Not found`});return}if(r.pathname===`/__dashboard`){t.writeHead(302,{location:`/__dashboard/`}),t.end();return}if(r.pathname.startsWith(`/__dashboard/`)){if(e.method!==`GET`&&e.method!==`HEAD`){x(t,405,{error:`Method not allowed`});return}await b(e,t,r.pathname.slice(12)||`/`,s.clientDist);return}x(t,404,{error:`Not found`})}catch(e){x(t,e instanceof n?e.status:500,{error:e instanceof Error?e.message:String(e)})}}}}async function b(e,t,n,r){let i=S(r,n);if(!i){x(t,404,{error:`Client asset not found`});return}let a=await C(i),o=!a&&l(n)===``,s=d(r,`index.html`),c=o?await C(s):void 0,u=a?i:s,f=a??c;if(!f){x(t,404,{error:`Client asset not found`});return}t.writeHead(200,{"content-type":w(u),"cache-control":`private, no-store`}),t.end(e.method===`HEAD`?void 0:f)}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 r;try{r=decodeURIComponent(t)}catch{throw new n(`Dashboard request path is invalid.`,400)}if(r.includes(`\0`))throw new n(`Dashboard request path is invalid.`,400);let i=p(e,r===`/`?`index.html`:r.slice(1)),a=f(e,i);if(!(a===``||a===`..`||a.startsWith(`..${m}`)||u(a)))return i}async function C(e){try{return(await c(e)).isFile()?await s(e):void 0}catch(e){if(T(e)&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function w(e){switch(l(e)){case`.css`:return`text/css; charset=utf-8`;case`.html`:return`text/html; charset=utf-8`;case`.ico`:return`image/x-icon`;case`.jpeg`:case`.jpg`:return`image/jpeg`;case`.js`:case`.mjs`:return`text/javascript; charset=utf-8`;case`.json`:case`.map`:return`application/json; charset=utf-8`;case`.png`:return`image/png`;case`.svg`:return`image/svg+xml`;case`.ttf`:return`font/ttf`;case`.wasm`:return`application/wasm`;case`.webp`:return`image/webp`;case`.woff`:return`font/woff`;case`.woff2`:return`font/woff2`;default:return`application/octet-stream`}}function T(e){return e instanceof Error&&`code`in e}function E(e,t={}){return async r=>{let i=e();if(!i)throw new n(`Dashboard app origin is unavailable.`,503);let a=new URL(`/api/dashboard/access`,i);if(a.protocol!==`http:`&&a.protocol!==`https:`)throw new n(`Dashboard app origin is invalid.`,503);return new Promise((e,i)=>{let o=a.protocol===`https:`?_:g,s=String(r.headers[`x-forwarded-proto`]??a.protocol.slice(0,-1)).split(`,`)[0].trim(),c=r.headers.origin??(r.headers.host?`${s}://${r.headers.host}`:a.origin),l=o(a,{...t,allowPartialTrustChain:!!t.ca,method:`GET`,headers:{cookie:r.headers.cookie??``,origin:c},timeout:1e4},t=>{let r=[],a=0;t.on(`data`,e=>{a+=e.length,a>1024?t.destroy(Error(`Invalid dashboard access response.`)):r.push(e)}),t.on(`error`,i),t.on(`end`,()=>{try{let{access:a}=JSON.parse(Buffer.concat(r).toString(`utf8`));t.statusCode===200&&a===`admin`?e(`admin`):t.statusCode===401&&a===`unauthenticated`?e(`unauthenticated`):t.statusCode===403&&a===`forbidden`?e(`forbidden`):i(new n(`Dashboard access check failed.`,503))}catch{i(new n(`Dashboard access check failed.`,503))}})});l.on(`timeout`,()=>l.destroy(Error(`Dashboard access check timed out.`))),l.on(`error`,()=>i(new n(`Dashboard access check failed.`,503))),l.end()})}}export{E as createAppAccessResolver,y as createNodeHandler,v as createNodeServer};
|
package/dist/package/types.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { WorkerEnvironmentStatus } from "@coreframe/deploy";
|
|
2
|
-
import { DiagnosticResult } from "@coreframe/diagnostics";
|
|
3
|
-
|
|
4
1
|
//#region src/types.d.ts
|
|
5
|
-
type LocalDashboardPayload = {
|
|
6
|
-
mode: "local";
|
|
7
|
-
diagnostics: DiagnosticResult;
|
|
8
|
-
workerEnvironment: WorkerEnvironmentStatus;
|
|
9
|
-
};
|
|
10
2
|
type DeployedConfigurationEntry = {
|
|
11
3
|
description: string;
|
|
12
4
|
kind: "secret" | "variable";
|
|
@@ -28,13 +20,5 @@ type DashboardReleaseIdentity = {
|
|
|
28
20
|
coreframeVersion?: string;
|
|
29
21
|
releaseName?: string;
|
|
30
22
|
};
|
|
31
|
-
type DeployedDashboardPayload = {
|
|
32
|
-
mode: "deployed";
|
|
33
|
-
environment: "production" | "staging";
|
|
34
|
-
release: DashboardReleaseIdentity;
|
|
35
|
-
configuration: DeployedConfigurationEntry[];
|
|
36
|
-
links: DashboardLink[];
|
|
37
|
-
};
|
|
38
|
-
type DashboardPayload = LocalDashboardPayload | DeployedDashboardPayload;
|
|
39
23
|
//#endregion
|
|
40
|
-
export { DashboardLink,
|
|
24
|
+
export { DashboardLink, DashboardReleaseIdentity, DeployedConfigurationEntry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withoutSpace as e}from"../helpers.js";const t=new Set(`2xl,2xlDown,2xlOnly,@/2xl,@/2xlDown,@/2xlOnly,@/2xlTo3xl,@/2xlTo4xl,@/2xlTo5xl,@/2xlTo6xl,@/2xlTo7xl,@/2xlTo8xl,@/2xs,@/2xsDown,@/2xsOnly,@/2xsTo2xl,@/2xsTo3xl,@/2xsTo4xl,@/2xsTo5xl,@/2xsTo6xl,@/2xsTo7xl,@/2xsTo8xl,@/2xsToLg,@/2xsToMd,@/2xsToSm,@/2xsToXl,@/2xsToXs,@/3xl,@/3xlDown,@/3xlOnly,@/3xlTo4xl,@/3xlTo5xl,@/3xlTo6xl,@/3xlTo7xl,@/3xlTo8xl,@/3xs,@/3xsDown,@/3xsOnly,@/3xsTo2xl,@/3xsTo2xs,@/3xsTo3xl,@/3xsTo4xl,@/3xsTo5xl,@/3xsTo6xl,@/3xsTo7xl,@/3xsTo8xl,@/3xsToLg,@/3xsToMd,@/3xsToSm,@/3xsToXl,@/3xsToXs,@/4xl,@/4xlDown,@/4xlOnly,@/4xlTo5xl,@/4xlTo6xl,@/4xlTo7xl,@/4xlTo8xl,@/5xl,@/5xlDown,@/5xlOnly,@/5xlTo6xl,@/5xlTo7xl,@/5xlTo8xl,@/6xl,@/6xlDown,@/6xlOnly,@/6xlTo7xl,@/6xlTo8xl,@/7xl,@/7xlDown,@/7xlOnly,@/7xlTo8xl,@/8xl,@/8xlDown,@/8xlOnly,@/lg,@/lgDown,@/lgOnly,@/lgTo2xl,@/lgTo3xl,@/lgTo4xl,@/lgTo5xl,@/lgTo6xl,@/lgTo7xl,@/lgTo8xl,@/lgToXl,@/md,@/mdDown,@/mdOnly,@/mdTo2xl,@/mdTo3xl,@/mdTo4xl,@/mdTo5xl,@/mdTo6xl,@/mdTo7xl,@/mdTo8xl,@/mdToLg,@/mdToXl,@/sm,@/smDown,@/smOnly,@/smTo2xl,@/smTo3xl,@/smTo4xl,@/smTo5xl,@/smTo6xl,@/smTo7xl,@/smTo8xl,@/smToLg,@/smToMd,@/smToXl,@/xl,@/xlDown,@/xlOnly,@/xlTo2xl,@/xlTo3xl,@/xlTo4xl,@/xlTo5xl,@/xlTo6xl,@/xlTo7xl,@/xlTo8xl,@/xs,@/xsDown,@/xsOnly,@/xsTo2xl,@/xsTo3xl,@/xsTo4xl,@/xsTo5xl,@/xsTo6xl,@/xsTo7xl,@/xsTo8xl,@/xsToLg,@/xsToMd,@/xsToSm,@/xsToXl,_active,_after,_atValue,_autofill,_backdrop,_before,_checked,_closed,_complete,_current,_currentPage,_currentStep,_dark,_default,_disabled,_dragging,_empty,_enabled,_even,_expanded,_file,_first,_firstLetter,_firstLine,_firstOfType,_focus,_focusVisible,_focusWithin,_fullscreen,_grabbed,_groupActive,_groupChecked,_groupDisabled,_groupExpanded,_groupFocus,_groupFocusVisible,_groupFocusWithin,_groupHover,_groupInvalid,_hidden,_highContrast,_highlighted,_horizontal,_hover,_icon,_inRange,_incomplete,_indeterminate,_invalid,_invertedColors,_landscape,_last,_lastOfType,_lessContrast,_light,_loading,_ltr,_marker,_moreContrast,_motionReduce,_motionSafe,_noscript,_now,_odd,_only,_onlyOfType,_open,_optional,_osDark,_osLight,_outOfRange,_overValue,_peerActive,_peerChecked,_peerDisabled,_peerExpanded,_peerFocus,_peerFocusVisible,_peerFocusWithin,_peerHover,_peerInvalid,_peerPlaceholderShown,_placeholder,_placeholderShown,_portrait,_pressed,_print,_rangeEnd,_rangeStart,_readOnly,_readWrite,_required,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_selected,_selection,_starting,_target,_today,_topmost,_unavailable,_underValue,_valid,_vertical,_visited,base,lg,lgDown,lgOnly,lgTo2xl,lgToXl,md,mdDown,mdOnly,mdTo2xl,mdToLg,mdToXl,sm,smDown,smOnly,smTo2xl,smToLg,smToMd,smToXl,xl,xlDown,xlOnly,xlTo2xl`.split(`,`)),n=/^@|&/,r=/^_/,i=/&|@/,a=[`base`,`sm`,`md`,`lg`,`xl`,`2xl`];function o(e){return t.has(e)||n.test(e)}function s(n){return n.map(n=>t.has(n)?n.replace(r,``):i.test(n)?`[${e(n.trim())}]`:n)}function c(e){return[...e].sort((e,t)=>{let n=o(e),r=o(t);return n&&!r?1:!n&&r?-1:0})}export{a as breakpointKeys,s as finalizeConditions,o as isCondition,c as sortConditions};
|
|
1
|
+
import{withoutSpace as e}from"../helpers.js";const t=new Set(`2xl,2xlDown,2xlOnly,@/2xl,@/2xlDown,@/2xlOnly,@/2xlTo3xl,@/2xlTo4xl,@/2xlTo5xl,@/2xlTo6xl,@/2xlTo7xl,@/2xlTo8xl,@/2xs,@/2xsDown,@/2xsOnly,@/2xsTo2xl,@/2xsTo3xl,@/2xsTo4xl,@/2xsTo5xl,@/2xsTo6xl,@/2xsTo7xl,@/2xsTo8xl,@/2xsToLg,@/2xsToMd,@/2xsToSm,@/2xsToXl,@/2xsToXs,@/3xl,@/3xlDown,@/3xlOnly,@/3xlTo4xl,@/3xlTo5xl,@/3xlTo6xl,@/3xlTo7xl,@/3xlTo8xl,@/3xs,@/3xsDown,@/3xsOnly,@/3xsTo2xl,@/3xsTo2xs,@/3xsTo3xl,@/3xsTo4xl,@/3xsTo5xl,@/3xsTo6xl,@/3xsTo7xl,@/3xsTo8xl,@/3xsToLg,@/3xsToMd,@/3xsToSm,@/3xsToXl,@/3xsToXs,@/4xl,@/4xlDown,@/4xlOnly,@/4xlTo5xl,@/4xlTo6xl,@/4xlTo7xl,@/4xlTo8xl,@/5xl,@/5xlDown,@/5xlOnly,@/5xlTo6xl,@/5xlTo7xl,@/5xlTo8xl,@/6xl,@/6xlDown,@/6xlOnly,@/6xlTo7xl,@/6xlTo8xl,@/7xl,@/7xlDown,@/7xlOnly,@/7xlTo8xl,@/8xl,@/8xlDown,@/8xlOnly,@/lg,@/lgDown,@/lgOnly,@/lgTo2xl,@/lgTo3xl,@/lgTo4xl,@/lgTo5xl,@/lgTo6xl,@/lgTo7xl,@/lgTo8xl,@/lgToXl,@/md,@/mdDown,@/mdOnly,@/mdTo2xl,@/mdTo3xl,@/mdTo4xl,@/mdTo5xl,@/mdTo6xl,@/mdTo7xl,@/mdTo8xl,@/mdToLg,@/mdToXl,@/sm,@/smDown,@/smOnly,@/smTo2xl,@/smTo3xl,@/smTo4xl,@/smTo5xl,@/smTo6xl,@/smTo7xl,@/smTo8xl,@/smToLg,@/smToMd,@/smToXl,@/xl,@/xlDown,@/xlOnly,@/xlTo2xl,@/xlTo3xl,@/xlTo4xl,@/xlTo5xl,@/xlTo6xl,@/xlTo7xl,@/xlTo8xl,@/xs,@/xsDown,@/xsOnly,@/xsTo2xl,@/xsTo3xl,@/xsTo4xl,@/xsTo5xl,@/xsTo6xl,@/xsTo7xl,@/xsTo8xl,@/xsToLg,@/xsToMd,@/xsToSm,@/xsToXl,_active,_after,_anyPointerCoarse,_anyPointerFine,_anyPointerNone,_atValue,_autofill,_backdrop,_before,_checked,_closed,_complete,_current,_currentPage,_currentStep,_dark,_default,_disabled,_dragging,_empty,_enabled,_even,_expanded,_file,_first,_firstLetter,_firstLine,_firstOfType,_focus,_focusVisible,_focusWithin,_fullscreen,_grabbed,_groupActive,_groupChecked,_groupDisabled,_groupExpanded,_groupFocus,_groupFocusVisible,_groupFocusWithin,_groupHover,_groupInvalid,_hidden,_highContrast,_highlighted,_horizontal,_hover,_icon,_inRange,_incomplete,_indeterminate,_inert,_invalid,_invertedColors,_landscape,_last,_lastOfType,_lessContrast,_light,_loading,_ltr,_marker,_moreContrast,_motionReduce,_motionSafe,_noscript,_now,_odd,_only,_onlyOfType,_open,_optional,_osDark,_osLight,_outOfRange,_overValue,_peerActive,_peerChecked,_peerDisabled,_peerExpanded,_peerFocus,_peerFocusVisible,_peerFocusWithin,_peerHover,_peerInvalid,_peerPlaceholderShown,_placeholder,_placeholderShown,_pointerCoarse,_pointerFine,_pointerNone,_portrait,_pressed,_print,_rangeEnd,_rangeStart,_readOnly,_readWrite,_required,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_selected,_selection,_starting,_target,_today,_topmost,_unavailable,_underValue,_userInvalid,_userValid,_valid,_vertical,_visited,base,lg,lgDown,lgOnly,lgTo2xl,lgToXl,md,mdDown,mdOnly,mdTo2xl,mdToLg,mdToXl,sm,smDown,smOnly,smTo2xl,smToLg,smToMd,smToXl,xl,xlDown,xlOnly,xlTo2xl`.split(`,`)),n=/^@|&/,r=/^_/,i=/&|@/,a=[`base`,`sm`,`md`,`lg`,`xl`,`2xl`];function o(e){return t.has(e)||n.test(e)}function s(n){return n.map(n=>t.has(n)?n.replace(r,``):i.test(n)?`[${e(n.trim())}]`:n)}function c(e){return[...e].sort((e,t)=>{let n=o(e),r=o(t);return n&&!r?1:!n&&r?-1:0})}export{a as breakpointKeys,s as finalizeConditions,o as isCondition,c as sortConditions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=Object.prototype.hasOwnProperty;function t(e){return e===`base`}function n(e){let n=[];for(let r=0;r<e.length;r++)t(e[r])||n.push(e[r]);return n}function r(e){let t=5381;for(let n=e.length;n;)t=t*33^e.charCodeAt(--n);let n=t>>>0,r=``;for(;n>52;n=n/52|0){let e=n%52;r=String.fromCharCode(e+(e>25?39:97))+r}let i=n%52;return String.fromCharCode(i+(i>25?39:97))+r}function i(e){let t={};if(!e)return t;for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function a(e,t){return{...e,...i(t)}}function o(e,t){for(let n in e){if(n===`css`||n===`className`||n===`classNames`)continue;let r=e[n],i=t[n];if(Array.isArray(r)?!r.includes(i):i!==r)return!1}return!0}function s(e,t,n){let r=[];for(let i of e)o(i,t)&&i.className&&r.push(n?n(i.className):i.className);return r.join(` `)}function c(e,t){let n=[];for(let r of e){let e=r.css?.[t],i=r.classNames?.[t]??r.className;if(!e&&!i)continue;let a=e?{css:e}:{};for(let e in r)e===`css`||e===`className`||e===`classNames`||(a[e]=r[e]);i&&(a.className=i),n.push(a)}return n}function l(e,t){let n={};for(let r=0;r<e.length;r++)e[r]!=null&&(n[t[r]]=e[r]);return n}function u(t,n,r){r||={};let{stop:i,getKey:a}=r,o=(t,r=[])=>{if(!t||typeof t!=`object`||i?.(t,r))return n(t,r);let s=Array.isArray(t)?[]:{};for(let n in t){if(!e.call(t,n)||n===`__proto__`)continue;let i=a?.(n,t[n])??n;r.push(i);let c=o(t[n],r);r.pop(),c!=null&&(s[i]=c)}return s};return o(t)}function d(e,t,n){let{utility:r,conditions:i}=t,{hasShorthand:a,resolveShorthand:o}=r;return n=n!==!1,u(e,e=>Array.isArray(e)?l(e,i.breakpoints.keys):e,{stop:Array.isArray,getKey:n?e=>a?o(e):e:void 0})}function f(e){let t=5381;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`object`||!r){t=t*33^1;continue}for(let e in r){let n=r[e],i=typeof n;if(n!==null&&i===`object`)return null;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);if(i===`string`)for(let e=0;e<n.length;e++)t=t*33^n.charCodeAt(e);else t=i===`number`?t*33^(n|0):i===`boolean`?t*33^(n?991:997):t*33^2}}return t>>>0}function p(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r===i)continue;if(r===null||i===null||typeof r!=`object`||typeof i!=`object`)return!1;let a=0;for(let e in r){if(r[e]!==i[e])return!1;a++}if(a!==Object.keys(i).length)return!1}return!0}function m(e){let t=new Map,n=new Map,r=new WeakSet,i=()=>({objects:new WeakMap,prims:new Map,out:void 0,has:!1}),a=i(),o,s,c,l=!1,u=0,d=(e,t)=>{if(typeof t==`object`&&t){let n=e.objects.get(t);return n===void 0&&(n=i(),e.objects.set(t,n)),n}let n=e.prims.get(t);return n===void 0&&(e.prims.size>64&&e.prims.clear(),n=i(),e.prims.set(t,n)),n},m=(e,t)=>{if(Array.isArray(t)){e=d(e,`\0[`);for(let n=0;n<t.length;n++)e=m(e,t[n]);return d(e,`\0]`)}return d(e,t)},h=(e,t)=>{if(e!==void 0){if(Array.isArray(t)){e=e.prims.get(`\0[`);for(let n=0;n<t.length&&e!==void 0;n++)e=h(e,t[n]);return e===void 0?void 0:e.prims.get(`\0]`)}return typeof t==`object`&&t?e.objects.get(t):e.prims.get(t)}},g=e=>{if(Array.isArray(e)){let t=!0;for(let n=0;n<e.length;n++)g(e[n])||(t=!1);return t}return typeof e!=`object`||!e||r.has(e)?!0:(r.add(e),!1)};return((...r)=>{let i=!1;for(let e=0;e<r.length;e++)if(Array.isArray(r[e])){i=!0;break}if(i){let t=a;for(let e=0;e<r.length&&t!==void 0;e++)t=h(t,r[e]);if(t!==void 0&&t.has)return t.out;let i=JSON.stringify(r),d=l&&o===void 0&&i===s?c:n.get(i);d===void 0&&(d=e(...r),n.set(i,d),n.size>500&&n.delete(n.keys().next().value));let f=!1;if(!(++u&3)){f=!0;for(let e=0;e<r.length;e++)g(r[e])||(f=!1)}if(f){let e=a;for(let t=0;t<r.length;t++)e=m(e,r[t]);e.out=d,e.has=!0}return o=void 0,s=i,c=d,l=!0,d}let d=f(r);if(d!==null){if(l&&o===d&&p(r,s))return c;let n=t.get(d);if(n){for(let e=0;e<n.length;e++)if(p(r,n[e].args))return o=d,s=r,c=n[e].out,l=!0,n[e].out}let i=e(...r);return n||(n=[],t.set(d,n)),n.push({args:r,out:i}),n.length>8&&n.shift(),t.size>500&&t.delete(t.keys().next().value),o=d,s=r,c=i,l=!0,i}let _=JSON.stringify(r);if(l&&o===void 0&&_===s)return c;let v=n.get(_);if(v!==void 0)return o=void 0,s=_,c=v,l=!0,v;let y=e(...r);return n.set(_,y),n.size>500&&n.delete(n.keys().next().value),o=void 0,s=_,c=y,l=!0,y})}function h(e){let t=new WeakMap;return(n=>{if(!n||typeof n!=`object`)return e(n);if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r})}const g=/[\n\s]+/g,_=e=>typeof e==`string`?e.replace(g,` `):e;function v(e){let t=e.utility,i=e.conditions,a=e.hash,o=e=>t.prefix?t.prefix+`-`+e:e,s=(e,n)=>{let s=i.finalize(e);return s.push(a?n:o(n)),a?o(t.toHash(s,r)):s.join(`:`)};return h(m(function({base:r,...a}={}){let o=d(r?Object.assign(a,r):a,e),c=new Set;u(o,(e,r)=>{if(e==null)return;let a=E(e),[o,...l]=i.shift(r),u=n(l),d=t.transform(o,w(D(_(e)))),f=s(u,d.className);a&&(f+=`!`),c.add(f)});let l=``;for(let e of c)l+=l?` `+e:e;return l}))}const y=new WeakMap;function b(e){let t=y.get(e);if(t)return t;t=Object.create(null);for(let n=0;n<e.length;n++)t[e[n]]=!0;return y.set(e,t),t}function x(e,t,n){let r=Object.getOwnPropertyDescriptor(e,n);if(r?.get||r?.set){Object.defineProperty(t,n,r);return}t[n]=e[n]}function S(e,...t){let n=Object.keys(e),r=t.length;if(r===1){let r=t[0],i={},a={};if(Array.isArray(r)){let t=b(r);for(let r=0;r<n.length;r++){let o=n[r];t[o]===!0?x(e,i,o):x(e,a,o)}return[i,a]}for(let t=0;t<n.length;t++){let o=n[t];r(o)?x(e,i,o):x(e,a,o)}return[i,a]}let i=Array(r);for(let e=0;e<r;e++){let n=t[e];i[e]=Array.isArray(n)?b(n):n}let a=Array(r+1);for(let e=0;e<=r;e++)a[e]={};let o=a[r];for(let t=0;t<n.length;t++){let s=n[t],c=!1;for(let t=0;t<r;t++){let n=i[t];if(typeof n==`function`?n(s):n[s]===!0){x(e,a[t],s),c=!0;break}}c||x(e,o,s)}return a}function C(...e){let t=new Set;for(let n of e)if(n)for(let e=0;e<n.length;e++)t.add(n[e]);return Array.from(t)}function w(e){return typeof e==`string`&&e.indexOf(` `)>=0?e.replaceAll(` `,`_`):e}const T=/\s*!(important)?\s*$/i;function E(e){return typeof e==`string`?T.test(e):!1}function D(e){return typeof e==`string`?e.replace(T,``).trim():e}export{i as compact,v as createSerializeCss,n as filterBaseConditions,s as getCompoundVariantClassNames,c as getSlotCompoundVariant,t as isBaseCondition,E as isImportant,m as memo,d as normalizeStyleObject,S as splitProps,r as toHash,l as toResponsiveObject,C as uniq,u as walkObject,h as weakMemo,a as withDefaults,D as withoutImportant,w as withoutSpace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRecipe as e}from"./runtime.js";const t=e({name:`dashboardButton`,className:`dashboard-button`,defaultVariants:{size:`md`,tone:`accent`,variant:`solid`},compoundVariants:[{tone:`neutral`,variant:`solid`,className:`dashboard-button--compound__tone_neutral__variant_solid`},{tone:`accent`,variant:`solid`,className:`dashboard-button--compound__tone_accent__variant_solid`},{tone:`danger`,variant:`solid`,className:`dashboard-button--compound__tone_danger__variant_solid`},{tone:`accent`,variant:`outline`,className:`dashboard-button--compound__tone_accent__variant_outline`},{tone:`danger`,variant:`outline`,className:`dashboard-button--compound__tone_danger__variant_outline`},{tone:`accent`,variant:`quiet`,className:`dashboard-button--compound__tone_accent__variant_quiet`},{tone:`danger`,variant:`quiet`,className:`dashboard-button--compound__tone_danger__variant_quiet`}],variantMap:{
|
|
1
|
+
import{createRecipe as e}from"./runtime.js";const t=e({name:`dashboardButton`,className:`dashboard-button`,defaultVariants:{size:`md`,tone:`accent`,variant:`solid`},compoundVariants:[{tone:`neutral`,variant:`solid`,className:`dashboard-button--compound__tone_neutral__variant_solid`},{tone:`accent`,variant:`solid`,className:`dashboard-button--compound__tone_accent__variant_solid`},{tone:`danger`,variant:`solid`,className:`dashboard-button--compound__tone_danger__variant_solid`},{tone:`accent`,variant:`outline`,className:`dashboard-button--compound__tone_accent__variant_outline`},{tone:`danger`,variant:`outline`,className:`dashboard-button--compound__tone_danger__variant_outline`},{tone:`accent`,variant:`quiet`,className:`dashboard-button--compound__tone_accent__variant_quiet`},{tone:`danger`,variant:`quiet`,className:`dashboard-button--compound__tone_danger__variant_quiet`}],variantMap:{variant:[`solid`,`outline`,`quiet`],tone:[`neutral`,`accent`,`danger`],size:[`sm`,`md`,`lg`]}});export{t as dashboardButton};
|