@coreframe/dashboard 0.3.11 → 0.3.13

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.
@@ -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 typeof window<`u`&&(window.addEventListener(`storage`,y),window.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(),typeof window<`u`&&(window.removeEventListener(`storage`,y),window.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(typeof window<`u`)try{n=t({key:`coreframe.auth-session-observation.v1`,storage:window.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,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 +1 @@
1
- import{DashboardRequestError as e}from"./request-error.js";import{assertDashboardApiRequestOrigin as t,assertLocalDashboardHost as n,getDashboardRequestId as r}from"./host-policy.js";import{handleFetchRequest as i}from"./node-fetch-adapter.js";import{createDashboardPluginDispatcher as a}from"./api/dispatcher.js";import{readFile as o,stat as s}from"node:fs/promises";import{extname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{createServer as m}from"node:http";function h(e){let t=g(e),n=m(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function g(o){let s=a(o.plugins,{host:Object.freeze({projectRoot:o.projectRoot}),getRequestId:r});return{dispose:async()=>void 0,async handle(r,a){try{n(r);let e=r.headers[`x-forwarded-proto`]===`https`?`https`:`http`,c=new URL(r.url??`/`,`${e}://${r.headers.host??`127.0.0.1`}`);if(c.pathname.startsWith(`/__dashboard/api/plugins/`)){t(r,c),await i(r,a,s);return}if(c.pathname===`/__dashboard/api`||c.pathname.startsWith(`/__dashboard/api/`)){v(a,404,{error:`Not found`});return}if(!o.clientDist){v(a,404,{error:`Not found`});return}if(c.pathname===`/__dashboard`){a.writeHead(302,{location:`/__dashboard/`}),a.end();return}if(c.pathname.startsWith(`/__dashboard/`)){if(r.method!==`GET`&&r.method!==`HEAD`){v(a,405,{error:`Method not allowed`});return}await _(r,a,c.pathname.slice(12)||`/`,o.clientDist);return}v(a,404,{error:`Not found`})}catch(t){v(a,t instanceof e?t.status:500,{error:t instanceof Error?t.message:String(t)})}}}}async function _(e,t,n,r){let i=y(r,n);if(!i){v(t,404,{error:`Client asset not found`});return}let a=await b(i),o=!a&&c(n)===``,s=u(r,`index.html`),l=o?await b(s):void 0,d=a?i:s,f=a??l;if(!f){v(t,404,{error:`Client asset not found`});return}t.writeHead(200,{"content-type":x(d),"cache-control":d.endsWith(`index.html`)?`no-store`:`public, max-age=31536000, immutable`}),t.end(e.method===`HEAD`?void 0:f)}function v(e,t,n){e.writeHead(t,{"content-type":`application/json; charset=utf-8`,"cache-control":`no-store`}),e.end(JSON.stringify(n))}function y(t,n){let r;try{r=decodeURIComponent(n)}catch{throw new e(`Dashboard request path is invalid.`,400)}if(r.includes(`\0`))throw new e(`Dashboard request path is invalid.`,400);let i=f(t,r===`/`?`index.html`:r.slice(1)),a=d(t,i);if(!(a===``||a===`..`||a.startsWith(`..${p}`)||l(a)))return i}async function b(e){try{return(await s(e)).isFile()?await o(e):void 0}catch(e){if(S(e)&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function x(e){switch(c(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 S(e){return e instanceof Error&&`code`in e}export{g as createDashboardRequestHandler,h as createDashboardServer};
1
+ import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{DashboardRequestError as t}from"./request-error.js";import{assertDashboardApiRequestOrigin as n,assertLocalDashboardHost as r,getDashboardRequestId as i}from"./host-policy.js";import{handleFetchRequest as a}from"./node-fetch-adapter.js";import{readFile as o,stat as s}from"node:fs/promises";import{extname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{createServer as m}from"node:http";function h(e){let t=g(e),n=m(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function g(o){let s=e(o.plugins,{host:Object.freeze({projectRoot:o.projectRoot}),getRequestId:i});return{dispose:async()=>void 0,async handle(e,i){try{r(e);let t=e.headers[`x-forwarded-proto`]===`https`?`https`:`http`,c=new URL(e.url??`/`,`${t}://${e.headers.host??`127.0.0.1`}`);if(c.pathname.startsWith(`/__dashboard/api/plugins/`)){n(e,c),await a(e,i,s);return}if(c.pathname===`/__dashboard/api`||c.pathname.startsWith(`/__dashboard/api/`)){v(i,404,{error:`Not found`});return}if(!o.clientDist){v(i,404,{error:`Not found`});return}if(c.pathname===`/__dashboard`){i.writeHead(302,{location:`/__dashboard/`}),i.end();return}if(c.pathname.startsWith(`/__dashboard/`)){if(e.method!==`GET`&&e.method!==`HEAD`){v(i,405,{error:`Method not allowed`});return}await _(e,i,c.pathname.slice(12)||`/`,o.clientDist);return}v(i,404,{error:`Not found`})}catch(e){v(i,e instanceof t?e.status:500,{error:e instanceof Error?e.message:String(e)})}}}}async function _(e,t,n,r){let i=y(r,n);if(!i){v(t,404,{error:`Client asset not found`});return}let a=await b(i),o=!a&&c(n)===``,s=u(r,`index.html`),l=o?await b(s):void 0,d=a?i:s,f=a??l;if(!f){v(t,404,{error:`Client asset not found`});return}t.writeHead(200,{"content-type":x(d),"cache-control":d.endsWith(`index.html`)?`no-store`:`public, max-age=31536000, immutable`}),t.end(e.method===`HEAD`?void 0:f)}function v(e,t,n){e.writeHead(t,{"content-type":`application/json; charset=utf-8`,"cache-control":`no-store`}),e.end(JSON.stringify(n))}function y(e,n){let r;try{r=decodeURIComponent(n)}catch{throw new t(`Dashboard request path is invalid.`,400)}if(r.includes(`\0`))throw new t(`Dashboard request path is invalid.`,400);let i=f(e,r===`/`?`index.html`:r.slice(1)),a=d(e,i);if(!(a===``||a===`..`||a.startsWith(`..${p}`)||l(a)))return i}async function b(e){try{return(await s(e)).isFile()?await o(e):void 0}catch(e){if(S(e)&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function x(e){switch(c(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 S(e){return e instanceof Error&&`code`in e}export{g as createDashboardRequestHandler,h as createDashboardServer};
@@ -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(()=>typeof window<`u`&&window.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=window.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`,{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`,onClick:()=>{u?h(e=>!e):v(e=>!e)},children:d(`span`,{"aria-hidden":`true`,children:C?`←`:`☰`})}),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__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`})]}),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}`,onClick:()=>h(!1),children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-dot`}),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`,children:[S?f(`header`,{className:`coreframe-dashboard__page-header`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),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{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`,{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`,onClick:()=>{u?h(e=>!e):v(e=>!e)},children:d(`span`,{"aria-hidden":`true`,children:C?`←`:`☰`})}),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__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`})]}),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}`,onClick:()=>h(!1),children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-dot`}),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`,children:[S?f(`header`,{className:`coreframe-dashboard__page-header`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),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 +1 @@
1
- import{getDashboardRequestId as e,isSameOriginDashboardMutation as t}from"./host-policy.js";import{createDashboardPluginDispatcher as n}from"./api/dispatcher.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(t){let r=n(t.plugins,{getRequestId:e});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,n,a,o,s){if(!n.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,n.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return t(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,n,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!n.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await n.ASSETS.fetch(new Request(a,e)),d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createDashboardWorkerHandler,s as handleDashboardRequest};
1
+ import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{getDashboardRequestId as t,isSameOriginDashboardMutation as n}from"./host-policy.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(n){let r=e(n.plugins,{getRequestId:t});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,t,a,o,s){if(!t.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,t.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return n(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,t,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!t.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await t.ASSETS.fetch(new Request(a,e)),d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createDashboardWorkerHandler,s as handleDashboardRequest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/dashboard",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -83,9 +83,9 @@
83
83
  "rouzer": "^6.0.1",
84
84
  "yaml": "^2.9.0",
85
85
  "zod": "^4.4.3",
86
+ "@coreframe/deploy": "0.1.11",
86
87
  "@coreframe/diagnostics": "0.2.3",
87
- "@coreframe/deploy": "0.1.9",
88
- "@coreframe/lib": "^0.2.11"
88
+ "@coreframe/lib": "^0.2.13"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@pandacss/dev": "2.0.0-beta.8",
@@ -99,7 +99,7 @@
99
99
  "typescript": "6.0.3",
100
100
  "vite": "^8.1.4",
101
101
  "vitest": "^4.1.10",
102
- "@coreframe/panda": "0.1.4"
102
+ "@coreframe/panda": "0.1.6"
103
103
  },
104
104
  "scripts": {
105
105
  "build": "pnpm --dir ../diagnostics build && pnpm build:server && pnpm build:check",