@coreframe/vite 0.2.27 → 0.2.29
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/client.d.ts
CHANGED
|
@@ -10,27 +10,3 @@ interface ImportMetaEnv {
|
|
|
10
10
|
interface ImportMeta {
|
|
11
11
|
readonly env: ImportMetaEnv
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
declare module "virtual:coreframe-shell" {
|
|
15
|
-
export const shell: import("@coreframe/lib/shell").CoreframeShell
|
|
16
|
-
export const ShellHost: (props: Record<string, never>) => import("react").ReactNode
|
|
17
|
-
export const NativeRouteLink: (
|
|
18
|
-
props: import("@coreframe/lib/shell").NativeRouteLinkProps,
|
|
19
|
-
) => import("react").ReactNode
|
|
20
|
-
export type NativeSurfaceProps = import("@coreframe/flutter-js/composition").NativeSurfaceProps
|
|
21
|
-
export const NativeSurface: (props: NativeSurfaceProps) => import("react").ReactNode
|
|
22
|
-
export function configureShellClient(): void
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare module "virtual:coreframe-shell/auth" {
|
|
26
|
-
export function createAuthenticatedFetch(
|
|
27
|
-
options: import("@coreframe/lib/auth-transport").AuthenticatedFetchOptions,
|
|
28
|
-
): import("@coreframe/lib/auth-transport").AuthenticatedFetch
|
|
29
|
-
export function createAuthClient(
|
|
30
|
-
options: import("@coreframe/lib/auth-transport").AuthClientOptions,
|
|
31
|
-
): import("@coreframe/lib/auth-transport").AuthClient
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module "virtual:coreframe-router" {
|
|
35
|
-
export * from "@coreframe/flutter-js/router"
|
|
36
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as e}from"node:fs";import{readFile as t}from"node:fs/promises";import{dirname as n,isAbsolute as r,resolve as i}from"node:path";import{readProjectConfig as a}from"@coreframe/config";import{composeDashboardManifest as o,composeDashboardPluginTarget as s,discoverDashboardPages as c,renderDashboardPluginTargetModule as l,resolveDashboardModuleReference as u,resolveDashboardRouteModules as d}from"@coreframe/dashboard/build";import{createDashboardRequestHandler as f}from"@coreframe/dashboard/server";import{createServer as p,loadConfigFromFile as m,normalizePath as h}from"vite";const g=`/__dashboard`,_=`virtual:coreframe-dashboard
|
|
1
|
+
import{existsSync as e}from"node:fs";import{readFile as t}from"node:fs/promises";import{dirname as n,isAbsolute as r,resolve as i}from"node:path";import{readProjectConfig as a}from"@coreframe/config";import{composeDashboardManifest as o,composeDashboardPluginTarget as s,discoverDashboardPages as c,renderDashboardPluginTargetModule as l,resolveDashboardModuleReference as u,resolveDashboardRouteModules as d}from"@coreframe/dashboard/build";import{createDashboardRequestHandler as f}from"@coreframe/dashboard/server";import{createServer as p,loadConfigFromFile as m,normalizePath as h}from"vite";const g=`/__dashboard`,_=`virtual:coreframe-internal/dashboard/worker-plugins`,v=`\0${_}`,y=`virtual:coreframe-internal/dashboard/manifest`,b=`\0${y}`,x=`virtual:coreframe-internal/dashboard/routes`,S=`\0${x}`,C=`virtual:coreframe-internal/dashboard/document`,w=`\0${C}`,T=`virtual:coreframe-internal/dashboard/styles`,E=`\0${T}`;function D({dashboardConfig:e=`dashboard/dashboard.config.ts`,dashboardOrigin:t=process.env.COREFRAME_DASHBOARD_ORIGIN??`http://127.0.0.1:5174`,env:r=process.env,projectRoot:a=process.cwd()}={}){let o,c,u=()=>c??=M(a,e,o);return{name:`coreframe:dashboard`,async config(e,n){return o=n,{define:{__COREFRAME_DASHBOARD_BUILD__:JSON.stringify(await L(a,r))},server:{proxy:{[g]:{target:t}}}}},resolveId(e){if(e===_)return v},async load(e){if(e===v)return l(s(await u(),`deployed`))},configureServer(e){return()=>{let t=e.printUrls.bind(e);e.printUrls=()=>{t();let n=e.resolvedUrls?.local[0];n&&e.config.logger.info(` ➜ Dashboard: ${new URL(g,n)}`)}}},configurePreviewServer:{order:`pre`,async handler(t){let r=await p({appType:`custom`,configFile:!1,envFile:!1,logLevel:`silent`,mode:t.config.mode,resolve:{alias:t.config.resolve.alias,dedupe:t.config.resolve.dedupe,tsconfigPaths:t.config.resolve.tsconfigPaths},root:a,server:{hmr:!1,middlewareMode:!0,watch:null}}),o;try{let s=await F(r.ssrLoadModule.bind(r),await u(),n(N(a,e))),c=t.config.environments.client.build.outDir;o=f({clientDist:i(t.config.root,c,g.slice(1)),plugins:s,projectRoot:a})}catch(e){throw await r.close(),e}t.middlewares.use(async(e,t,n)=>{if(!e.url||!P(e.url)){n();return}await o.handle(e,t)});let s,c=()=>s??=Promise.all([o.dispose(),r.close()]).then(()=>void 0),l=t.close.bind(t);return t.close=async()=>{await Promise.all([c(),l()])},t.httpServer.once(`close`,()=>{c()}),()=>{let e=t.printUrls.bind(t);t.printUrls=()=>{e();let n=t.resolvedUrls?.local[0];n&&t.config.logger.info(` ➜ Dashboard: ${new URL(g,n)}`)}}}}}}function O({dashboardDirectory:e=process.cwd(),environment:t=process.env.DEPLOY_ENV?`deployed`:`local`,projectRoot:n=i(e,`..`)}={}){let r,a,s,l=i(e,`dashboard.config.ts`),u=()=>a??=M(n,l,r);return{name:`coreframe:dashboard-app`,config(e,t){return r=t,{ssr:{noExternal:[`@coreframe/dashboard`]}}},resolveId(e){if(e===y)return b;if(e===x)return S;if(e===C)return w;if(e===T)return E},async load(r){if(r===E)return A(e);if(r===w)return k((await u()).document,e,n);if(r!==b&&r!==S)return;let[i,a]=await Promise.all([u(),c({dashboardDirectory:e})]),s=o(i,a,{environment:t});if(r===S){let t=d(s,{dashboardDirectory:e,projectRoot:n});return`export const dashboardRoutePages = ${JSON.stringify(t)}\n`}return`export const dashboardManifest = ${JSON.stringify(s)}\n`},async configureServer(t){s=f({plugins:await F(t.ssrLoadModule.bind(t),await u(),e),projectRoot:n}),t.middlewares.use(async(e,t,n)=>{if(!e.url||!e.url.startsWith(`${g}/api/plugins/`)){n();return}await s.handle(e,t)}),t.httpServer?.once(`close`,()=>{s?.dispose()})}}}function k(e,t,n){if(!e)return[`export const Layout = undefined`,`export const links = undefined`,`export const meta = undefined`,`export default undefined`,``].join(`
|
|
2
2
|
`);let r=j(u(e,{dashboardDirectory:t,projectRoot:n}));return[`import * as document from ${JSON.stringify(r)}`,`export const Layout = document.Layout`,`export const links = document.links`,`export const meta = document.meta`,`export default document.default`,``].join(`
|
|
3
3
|
`)}function A(t){let n=[`import ${JSON.stringify(`@coreframe/dashboard/shell.css`)}`];for(let r of[`styles.css`,`styled-system/styles.css`]){let a=i(t,r);e(a)&&n.push(`import ${JSON.stringify(j(a))}`)}return`${n.join(`
|
|
4
4
|
`)}\n`}function j(e){return`/@fs/${h(e)}`}async function M(e,t,n){let r=N(e,t),i=await m(n,r,e,void 0,void 0,`runner`);if(!i)throw Error(`Could not load dashboard configuration at ${r}.`);return i.config}function N(e,t){return r(t)?t:i(e,t)}function P(e){let[t]=e.split(`?`,1);return t===g||t.startsWith(`${g}/`)}async function F(e,t,n){let r=s(t,`local`);return Promise.all(r.map(async t=>{let[r,i]=await Promise.all([e(I(t.apiModule,n)),e(I(t.implementationModule,n))]);return{api:r.api,createImplementation:i.createImplementation}}))}function I(e,t){return e.startsWith(`.`)?`/@fs/${h(i(n(i(t,`dashboard.config.ts`)),e))}`:e}async function L(e,n){let[r,o]=await Promise.all([t(i(e,`package.json`),`utf8`),a({cwd:e})]),s=JSON.parse(r),c=Object.entries(o.worker?.environment??{}).flatMap(([e,t])=>t.kind===`generated`?[]:[{description:t.description,kind:t.kind,name:e,requiredIn:t.requiredIn??[]}]);return{applicationName:s.name??`Coreframe application`,applicationVersion:s.version,commit:n.GITHUB_SHA,configuration:c,coreframeVersion:s.engines?.coreframe,deployUrls:{production:o.deploy?.environments?.production?.url,staging:o.deploy?.environments?.staging?.url}}}export{O as coreframeDashboardAppPlugin,D as coreframeDashboardPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir as e,writeFile as t}from"node:fs/promises";import n from"node:path";import{readProjectConfig as r}from"@coreframe/config";import{randomUUID as i}from"node:crypto";import{managedDevEnv as a,managedDevEvents as o,managedDevFlutterRestartFileEnv as s}from"@coreframe/dev-contracts/managed-dev";import{startManagedDevSession as c}from"@coreframe/dev/managed-dev";import{connectExistingDevSupervisor as l}from"@coreframe/dev/supervisor";const u=Symbol.for(`@coreframe/vite/managed-dev-session-states`),d=(()=>{let e=globalThis;return e[u]??=new Map})();function f({connectSupervisor:u=l,env:d=process.env,startSession:f=c}={}){let h=d[a]===`1`,g,_,v,y,b,x,S,C=!1,w=!1,T=new Map,E={mode:`waiting`,warnings:[]},D=()=>S??=(async()=>{w=!0,await x,C=!1;let e=g,t=_,n=v;g=void 0,_=void 0,v=void 0,y?.(),y=void 0,e&&b&&await m(b,e),t&&(n&&await t.release(n).catch(()=>void 0),t.close())})();return{name:`coreframe:managed-dev`,apply:`serve`,config(){return{define:{"import.meta.env.COREFRAME_MANAGED_DEV":JSON.stringify(h)}}},configureServer(a){if(!h)return;let c=a.config.root;b=c;let l=!1,S=!1,O=()=>g?.getStatus()??E,k=()=>{w||a.ws.send(o.status,{status:O()})},A=()=>{S||w||(S=!0,queueMicrotask(()=>{S=!1,Promise.resolve(a.restart()).catch(e=>{let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development restart failed: ${t}`,{error:e instanceof Error?e:void 0})})}))},j=e=>{if(w||e.event!==`managed-dev`)return;if(e.kind===`status`){E=e.status,k();return}if(e.kind===`restart`){l=!0,T.size===0&&(l=!1,A());return}let t=T.get(e.requestId);!t||!e.codex||typeof e.codex!=`object`||t.send(o.codex,{...e.codex,requestId:e.requestId})},M=async(e,t)=>{if(_&&C)try{E=(await _.managedDevStatus()).status}catch(e){let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development status failed: ${t}`,{error:e instanceof Error?e:void 0})}t.send(o.status,{status:O()})},N=async(e,t)=>{let n;try{if(!C)throw Error(`Managed development is still initializing.`);let n=_;if(n){T.set(e.requestId,t);try{let r=await n.managedDevAction({action:e.action,requestId:e.requestId});r.status&&(E=r.status),t.send(o.actionResult,{...r,requestId:e.requestId}),!r.error&&l&&(l=!1,A())}finally{T.delete(e.requestId)}return}let r=g;if(!r)throw Error(`Managed development is still initializing.`);let i=await r.action(e.action,{onCodexEvent:n=>t.send(o.codex,{...n,requestId:e.requestId})});t.send(o.actionResult,{requestId:e.requestId,...i}),l&&(l=!1,queueMicrotask(()=>{D().then(()=>a.restart()).catch(e=>{let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development restart failed: ${t}`,{error:e instanceof Error?e:void 0})})}));return}catch(e){n=e}let r=n instanceof Error?n.message:String(n);a.config.logger.error(`Coreframe managed development action failed: ${r}`,{error:n instanceof Error?n:void 0}),t.send(o.actionResult,{error:r,requestId:e.requestId,status:O()})};a.ws.on(o.statusRequest,M),a.ws.on(o.action,N),x=(async()=>{let o,h;try{if(o=await u({cwd:c,env:d}),o){if(w){o.close();return}_=o,y=o.onEvent(j),await o.subscribe([`managed-dev`]);let e=await o.acquireManagedDev({env:d});if(v=e.leaseId,E=e.status,w){await o.release(e.leaseId).catch(()=>void 0),v=void 0,y?.(),y=void 0,_=void 0,o.close();return}C=!0;return}let b=await r({cwd:c});if(w)return;if(h=await f({config:b,cwd:c,env:d,onRestart:()=>{l=!0},onFlutterRestart:async()=>{let r=d[s];if(r)try{await e(n.dirname(r),{recursive:!0}),await t(r,`${i()}\n`,{mode:384})}catch(e){let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe Flutter restart request failed: ${t}`,{error:e instanceof Error?e:void 0})}},onStatusChange:e=>{E=e,k()}}),g=h,E=h.getStatus(),w){g=void 0,await h.close();return}if(await p(c,h),w){g=void 0,await m(c,h);return}C=!0}catch(e){if(o&&_===o&&(y?.(),y=void 0,_=void 0,o.close()),g===h&&(g=void 0),!w){let t=e instanceof Error?e.message:String(e);E={message:t,mode:`error`,warnings:[t]},a.config.logger.error(`Coreframe managed development initialization failed: ${t}`,{error:e instanceof Error?e:void 0}),k()}}})(),a.httpServer?.once(`close`,()=>{a.ws.off(o.statusRequest,M),a.ws.off(o.action,N),D()})},async closeBundle(){await D()}}}async function p(e,t){await h(e,async e=>{let n=e.session;e.session=void 0,await n?.close();try{await t.activate(),e.session=t}catch(e){throw await t.close(),e}})}async function m(e,t){await h(e,async e=>{e.session===t&&(e.session=void 0),await t.close()})}async function h(e,t){let n=d.get(e);n||(n={transition:Promise.resolve()},d.set(e,n));let r=n.transition,i;n.transition=new Promise(e=>{i=()=>e()}),await r;try{await t(n)}finally{i()}}export{f as coreframeManagedDevPlugin};
|
|
1
|
+
import{mkdir as e,writeFile as t}from"node:fs/promises";import n from"node:path";import{readProjectConfig as r}from"@coreframe/config";import{randomUUID as i}from"node:crypto";import{managedDevEnv as a,managedDevEvents as o,managedDevFlutterRestartFileEnv as s}from"@coreframe/dev-contracts/managed-dev";import{startManagedDevSession as c}from"@coreframe/dev/managed-dev";import{connectExistingDevSupervisor as l}from"@coreframe/dev/supervisor";const u=Symbol.for(`@coreframe/vite/managed-dev-session-states`),d=(()=>{let e=globalThis;return e[u]??=new Map})();function f({connectSupervisor:u=l,env:d=process.env,startSession:f=c}={}){let h=d[a]===`1`,g,_,v,y,b,x,S,C=!1,w=!1,T=new Map,E={mode:`waiting`,warnings:[]},D=()=>S??=(async()=>{w=!0,await x,C=!1;let e=g,t=_,n=v;g=void 0,_=void 0,v=void 0,y?.(),y=void 0,e&&b&&await m(b,e),t&&(n&&await t.release(n).catch(()=>void 0),t.close())})();return{name:`coreframe:managed-dev`,apply:`serve`,config(){return{define:{"import.meta.env.COREFRAME_MANAGED_DEV":JSON.stringify(h)}}},configureServer(a){if(!h)return;let c=a.config.root;b=c;let l=!1,S=!1,O=()=>g?.getStatus()??E,k=()=>{w||a.ws.send(o.status,{status:O()})},A=()=>{S||w||(S=!0,queueMicrotask(()=>{S=!1,Promise.resolve(a.restart()).catch(e=>{let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development restart failed: ${t}`,{error:e instanceof Error?e:void 0})})}))},j=e=>{if(w||e.event!==`managed-dev`)return;if(e.kind===`status`){E=e.status,k();return}if(e.kind===`restart`){l=!0,T.size===0&&(l=!1,A());return}let t=T.get(e.requestId);!t||!e.codex||typeof e.codex!=`object`||t.send(o.codex,{...e.codex,requestId:e.requestId})},M=async(e,t)=>{if(_&&C)try{E=(await _.managedDevStatus()).status}catch(e){let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development status failed: ${t}`,{error:e instanceof Error?e:void 0})}t.send(o.status,{status:O()})},N=async(e,t)=>{let n;try{if(!C)throw Error(`Managed development is still initializing.`);let n=_;if(n){T.set(e.requestId,t);try{let r=await n.managedDevAction({action:e.action,requestId:e.requestId});r.status&&(E=r.status),t.send(o.actionResult,{...r,requestId:e.requestId}),!r.error&&l&&(l=!1,A())}finally{T.delete(e.requestId)}return}let r=g;if(!r)throw Error(`Managed development is still initializing.`);let i=await r.action(e.action,{onCodexEvent:n=>t.send(o.codex,{...n,requestId:e.requestId})});t.send(o.actionResult,{requestId:e.requestId,...i}),l&&(l=!1,queueMicrotask(()=>{D().then(()=>a.restart()).catch(e=>{let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe managed development restart failed: ${t}`,{error:e instanceof Error?e:void 0})})}));return}catch(e){n=e}let r=n instanceof Error?n.message:String(n);a.config.logger.error(`Coreframe managed development action failed: ${r}`,{error:n instanceof Error?n:void 0}),t.send(o.actionResult,{error:r,requestId:e.requestId,status:O()})};a.ws.on(o.statusRequest,M),a.ws.on(o.action,N),x=(async()=>{let o,h;try{if(o=await u({cwd:c,env:d,requiredResources:[`managed-dev`]}),o){if(w){o.close();return}_=o,y=o.onEvent(j),await o.subscribe([`managed-dev`]);let e=await o.acquireManagedDev({env:d});if(v=e.leaseId,E=e.status,w){await o.release(e.leaseId).catch(()=>void 0),v=void 0,y?.(),y=void 0,_=void 0,o.close();return}C=!0;return}let b=await r({cwd:c});if(w)return;if(h=await f({config:b,cwd:c,env:d,onRestart:()=>{l=!0},onFlutterRestart:async()=>{let r=d[s];if(r)try{await e(n.dirname(r),{recursive:!0}),await t(r,`${i()}\n`,{mode:384})}catch(e){let t=e instanceof Error?e.message:String(e);a.config.logger.error(`Coreframe Flutter restart request failed: ${t}`,{error:e instanceof Error?e:void 0})}},onStatusChange:e=>{E=e,k()}}),g=h,E=h.getStatus(),w){g=void 0,await h.close();return}if(await p(c,h),w){g=void 0,await m(c,h);return}C=!0}catch(e){if(o&&_===o&&(y?.(),y=void 0,_=void 0,o.close()),g===h&&(g=void 0),!w){let t=e instanceof Error?e.message:String(e);E={message:t,mode:`error`,warnings:[t]},a.config.logger.error(`Coreframe managed development initialization failed: ${t}`,{error:e instanceof Error?e:void 0}),k()}}})(),a.httpServer?.once(`close`,()=>{a.ws.off(o.statusRequest,M),a.ws.off(o.action,N),D()})},async closeBundle(){await D()}}}async function p(e,t){await h(e,async e=>{let n=e.session;e.session=void 0,await n?.close();try{await t.activate(),e.session=t}catch(e){throw await t.close(),e}})}async function m(e,t){await h(e,async e=>{e.session===t&&(e.session=void 0),await t.close()})}async function h(e,t){let n=d.get(e);n||(n={transition:Promise.resolve()},d.set(e,n));let r=n.transition,i;n.transition=new Promise(e=>{i=()=>e()}),await r;try{await t(n)}finally{i()}}export{f as coreframeManagedDevPlugin};
|
package/dist/plugins/routes.d.ts
CHANGED
|
@@ -15,8 +15,7 @@ type NativeRouteRegistration = {
|
|
|
15
15
|
statusBarForeground?: "automatic" | "light" | "dark";
|
|
16
16
|
} & MobileRouteLayerMetadata;
|
|
17
17
|
type MobileRouteRegistration = {
|
|
18
|
-
/** Opts the ordinary DOM implementation into Flutter-owned physical presentation on mobile. */surface: "flutter-dom"; /**
|
|
19
|
-
keyboardLayout?: "bottom-anchored"; /** Symbolic Flutter shell transition selected when this route is presented. */
|
|
18
|
+
/** Opts the ordinary DOM implementation into Flutter-owned physical presentation on mobile. */surface: "flutter-dom"; /** Symbolic Flutter shell transition selected when this route is presented. */
|
|
20
19
|
transitionKey?: string; /** Optional opaque route backdrop used while platform transitions fade route content. */
|
|
21
20
|
underlayColor?: string; /** Status-bar foreground policy while this route is active. */
|
|
22
21
|
statusBarForeground?: "automatic" | "light" | "dark";
|
|
@@ -48,7 +47,6 @@ type MobileRouteManifestEntry = {
|
|
|
48
47
|
stackRoot: boolean;
|
|
49
48
|
underlayColor: string | null;
|
|
50
49
|
statusBarForeground: "automatic" | "light" | "dark" | null;
|
|
51
|
-
keyboardLayout: "bottom-anchored" | null;
|
|
52
50
|
};
|
|
53
51
|
type MobileStackManifestEntry = {
|
|
54
52
|
id: string;
|
package/dist/plugins/routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getAppDirectory as e,index as t,layout as n,prefix as r,relative as i,route as a}from"@react-router/dev/routes";const o=`__coreframe_flutter_dom__`,s=`platform`,c=Symbol(`coreframe-route-registration`);function l(e,t,n,r){let i=Array.isArray(n)||n===void 0?void 0:n,o=Array.isArray(n)?n:r,s=i===void 0?void 0:{id:i.id,index:i.index,caseSensitive:i.caseSensitive},l=s===void 0?a(e,t,o):a(e,t,s,o);return i?.native!==void 0&&(l.native=i.native,l[c]={authoredControllerPath:i.native.path}),i?.mobile!==void 0&&(l.mobile=i.mobile),l}function u(e,n){return t(e,n)}function d(e,t,r){return Array.isArray(t)?n(e,t):t===void 0?n(e):n(e,t,r)}function f(e,t){return r(e,t)}function p(e){let t=i(e);return{route(e,n,r,i){let a=l(e,n,r,i);return a.file=t.route(null,n).file,a.native!==void 0&&(a.native={path:t.route(null,a.native.path).file}),a},index(e,n){return t.index(e,n)},layout(e,n,r){return Array.isArray(n)?t.layout(e,n):n===void 0?t.layout(e):t.layout(e,n,r)},prefix:f}}function m(e){if(!Array.isArray(e))throw Error(`Coreframe route config must be an array. Await asynchronous route config before compiling it.`);let t=[],n=[],r=new Map,i=new Map;return{routes:e.map((e,a)=>h(e,`/`,`routes[${a}]`,r,i,t,n)),nativeManifest:t,mobileManifest:n,stacks:_(n)}}function h(e,t,n,r,i,a,o){if(typeof e!=`object`||!e||typeof e.file!=`string`)throw Error(`Invalid Coreframe route registration at ${n}: expected a route helper result.`);if(e.id!==void 0){if(e.id.length===0||e.id.trim()!==e.id)throw Error(`Invalid route id ${JSON.stringify(e.id)} at ${n}: IDs must be non-empty and cannot have surrounding whitespace.`);let t=r.get(e.id);if(t!==void 0)throw Error(`Duplicate route id ${JSON.stringify(e.id)} at ${n}; it is already registered at ${t}.`);r.set(e.id,n)}let s=
|
|
1
|
+
import{getAppDirectory as e,index as t,layout as n,prefix as r,relative as i,route as a}from"@react-router/dev/routes";const o=`__coreframe_flutter_dom__`,s=`platform`,c=Symbol(`coreframe-route-registration`);function l(e,t,n,r){let i=Array.isArray(n)||n===void 0?void 0:n,o=Array.isArray(n)?n:r,s=i===void 0?void 0:{id:i.id,index:i.index,caseSensitive:i.caseSensitive},l=s===void 0?a(e,t,o):a(e,t,s,o);return i?.native!==void 0&&(l.native=i.native,l[c]={authoredControllerPath:i.native.path}),i?.mobile!==void 0&&(l.mobile=i.mobile),l}function u(e,n){return t(e,n)}function d(e,t,r){return Array.isArray(t)?n(e,t):t===void 0?n(e):n(e,t,r)}function f(e,t){return r(e,t)}function p(e){let t=i(e);return{route(e,n,r,i){let a=l(e,n,r,i);return a.file=t.route(null,n).file,a.native!==void 0&&(a.native={path:t.route(null,a.native.path).file}),a},index(e,n){return t.index(e,n)},layout(e,n,r){return Array.isArray(n)?t.layout(e,n):n===void 0?t.layout(e):t.layout(e,n,r)},prefix:f}}function m(e){if(!Array.isArray(e))throw Error(`Coreframe route config must be an array. Await asynchronous route config before compiling it.`);let t=[],n=[],r=new Map,i=new Map;return{routes:e.map((e,a)=>h(e,`/`,`routes[${a}]`,r,i,t,n)),nativeManifest:t,mobileManifest:n,stacks:_(n)}}function h(e,t,n,r,i,a,o){if(typeof e!=`object`||!e||typeof e.file!=`string`)throw Error(`Invalid Coreframe route registration at ${n}: expected a route helper result.`);if(e.id!==void 0){if(e.id.length===0||e.id.trim()!==e.id)throw Error(`Invalid route id ${JSON.stringify(e.id)} at ${n}: IDs must be non-empty and cannot have surrounding whitespace.`);let t=r.get(e.id);if(t!==void 0)throw Error(`Duplicate route id ${JSON.stringify(e.id)} at ${n}; it is already registered at ${t}.`);r.set(e.id,n)}let s=C(t,e.path);if(e.mobile!==void 0&&e.native!==void 0)throw Error(`Conflicting mobile surface policy for route ${JSON.stringify(e.id)} at ${n}: use either mobile.surface or native, not both.`);if(e.mobile!==void 0&&e.mobile.surface!==`flutter-dom`)throw Error(`Invalid mobile surface policy for route ${JSON.stringify(e.id)} at ${n}: expected "flutter-dom".`);if((e.mobile!==void 0||e.native!==void 0)&&(S(e,n),b(e.native?.statusBarForeground??e.mobile?.statusBarForeground,n)),e.native!==void 0){x(e,n);let t=v(e,n),r=e.id,c=w(s),l=i.get(c);if(l!==void 0)throw Error(`Ambiguous native route ${JSON.stringify(r)} at ${n}: canonical path ${JSON.stringify(s)} conflicts with native route ${JSON.stringify(l)}.`);i.set(c,r),a.push({routeId:r,canonicalPath:s,caseSensitive:e.caseSensitive===!0,routeModulePath:e.file,controllerModulePath:e.native.path,transitionKey:t}),o.push({routeId:r,canonicalPath:s,caseSensitive:e.caseSensitive===!0,routeModulePath:e.file,surface:`native`,transitionKey:t,underlayColor:null,statusBarForeground:e.native.statusBarForeground??null,...g(e,n)})}else if(e.mobile!==void 0){y(e.mobile.underlayColor,n);let t=v(e,n),r=e.id,a=w(s),c=i.get(a);if(c!==void 0)throw Error(`Ambiguous mobile route ${JSON.stringify(r)} at ${n}: canonical path ${JSON.stringify(s)} conflicts with mobile route ${JSON.stringify(c)}.`);i.set(a,r),o.push({routeId:r,canonicalPath:s,caseSensitive:e.caseSensitive===!0,routeModulePath:e.file,surface:`flutter-dom`,transitionKey:t,underlayColor:e.mobile.underlayColor??null,statusBarForeground:e.mobile.statusBarForeground??null,...g(e,n)})}let c={file:e.file};return`children`in e&&(c.children=e.children?.map((e,t)=>h(e,s,`${n}.children[${t}]`,r,i,a,o))),`path`in e&&(c.path=e.path),`id`in e&&(c.id=e.id),`index`in e&&(c.index=e.index),`caseSensitive`in e&&(c.caseSensitive=e.caseSensitive),c}function g(e,t){let n=e.native??e.mobile;if(n===void 0)return{stackId:null,stackRoot:!1,z:0};let r=n.z??0;if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Invalid mobile route z ${JSON.stringify(r)} for route ${JSON.stringify(e.id)} at ${t}: z must be a finite number.`);let i=n.stack,a=typeof i==`object`?i:void 0,o=typeof i==`string`?i:a?.id,s=a?.root??!1;if(o===void 0&&s)throw Error(`Invalid mobile stack metadata for route ${JSON.stringify(e.id)} at ${t}: stackRoot requires a stack id.`);if(o!==void 0&&(typeof o!=`string`||o.length===0||o.trim()!==o))throw Error(`Invalid mobile stack id ${JSON.stringify(o)} for route ${JSON.stringify(e.id)} at ${t}: IDs must be non-empty and cannot have surrounding whitespace.`);if(typeof s!=`boolean`)throw Error(`Invalid mobile stack root flag for route ${JSON.stringify(e.id)} at ${t}: expected a boolean.`);return{stackId:o??null,stackRoot:s,z:r}}function _(e){let t=new Map;for(let n of e){if(n.stackId===null){if(n.stackRoot)throw Error(`Mobile route ${JSON.stringify(n.routeId)} marks a stack root without a stack.`);continue}let e=t.get(n.stackId)??[];e.push(n),t.set(n.stackId,e)}return[...t.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let n=t.filter(e=>e.stackRoot);if(n.length!==1)throw Error(`Mobile stack ${JSON.stringify(e)} must declare exactly one Flutter DOM root route.`);let r=n[0];if(r.surface!==`flutter-dom`)throw Error(`Mobile stack ${JSON.stringify(e)} root route ${JSON.stringify(r.routeId)} must use the Flutter DOM surface.`);return{id:e,rootRouteId:r.routeId,routeIds:t.map(({routeId:e})=>e).sort((e,t)=>e.localeCompare(t))}})}function v(e,t){let n=e.native?.transitionKey??e.mobile?.transitionKey;if(n===void 0)return s;if(typeof n!=`string`||n.length===0||n.trim()!==n)throw Error(`Invalid mobile transition key ${JSON.stringify(n)} for route ${JSON.stringify(e.id)} at ${t}: keys must be non-empty and cannot have surrounding whitespace.`);return n}function y(e,t){if(e!==void 0&&(typeof e!=`string`||!/^#[0-9A-Fa-f]{6}$/.test(e)))throw Error(`Invalid mobile underlay color ${JSON.stringify(e)} at ${t}: expected a solid #RRGGBB color.`)}function b(e,t){if(e!==void 0&&e!==`automatic`&&e!==`light`&&e!==`dark`)throw Error(`Invalid status bar foreground ${JSON.stringify(e)} at ${t}: expected "automatic", "light", or "dark".`)}function x(e,t){S(e,t);let n=e[c]?.authoredControllerPath??e.native?.path;if(typeof n!=`string`||n.trim()!==n||!n.startsWith(`.`)||n.includes(`\\`)||n.includes(`?`)||n.includes(`#`)||!n.endsWith(`.native.tsx`))throw Error(`Invalid native controller path ${JSON.stringify(n)} for route ${JSON.stringify(e.id)} at ${t}: expected a relative *.native.tsx module path without query, hash, or backslash characters.`)}function S(e,t){if(e.id===void 0)throw Error(`Mobile route at ${t} (${JSON.stringify(e.file)}) requires an explicit stable id.`);if(e.id===`root`)throw Error(`Mobile route at ${t} cannot use React Router's reserved id "root".`);if(e.id===o)throw Error(`Mobile route at ${t} cannot use Coreframe's reserved Flutter-DOM route id ${JSON.stringify(o)}.`);if(e.path===void 0&&e.index!==!0)throw Error(`Mobile route ${JSON.stringify(e.id)} at ${t} must have an addressable path or be an index route.`)}function C(e,t){if(t===void 0||t===``)return e;let n=(t.startsWith(`/`)?t:`${e===`/`?``:e}/${t}`).replace(/\/{2,}/g,`/`);return n.startsWith(`/`)?n:`/${n}`}function w(e){return e.split(`/`).map(e=>e.startsWith(`:`)?`:${e.endsWith(`?`)?`?`:``}`:e).join(`/`).toLowerCase()}export{s as DEFAULT_MOBILE_TRANSITION_KEY,m as compileRouteRegistrations,e as getAppDirectory,u as index,d as layout,f as prefix,p as relative,l as route};
|
package/dist/plugins/shell.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveCoreframeHost as e,resolveCoreframePlatform as t}from"./index.js";import{realpathSync as n}from"node:fs";import{extname as r,isAbsolute as i,relative as a,resolve as o,sep as s}from"node:path";import{parseSync as c}from"vite";const l
|
|
1
|
+
import{resolveCoreframeHost as e,resolveCoreframePlatform as t}from"./index.js";import{realpathSync as n}from"node:fs";import{extname as r,isAbsolute as i,relative as a,resolve as o,sep as s}from"node:path";import{parseSync as c}from"vite";const l={browser:{router:`@coreframe/lib/router`,shell:`@coreframe/lib/shell/dom`},flutter:{router:`@coreframe/flutter-js/router`,shell:`@coreframe/flutter-js/composition`}};function u(){let n=t(),r=n===`ios`||n===`android`?n:void 0,i=e(process.env,n),a=l[i],s=d(a.shell),u=process.cwd();return{name:`coreframe:shell`,enforce:`pre`,config(){return{define:{"import.meta.env.MOBILE_PLATFORM":r===void 0?`undefined`:JSON.stringify(r),"import.meta.env.PLATFORM":JSON.stringify(n)},resolve:{dedupe:[`react`,`react-dom`,`react-router`]},ssr:{noExternal:[`@coreframe/app`,s]}}},configResolved(e){u=e.root},transform(e,t){let n=f(t);if(!_(t,u)||n===void 0)return;let{module:r}=c(t,e,{lang:n});(r.staticImports.some(({moduleRequest:e})=>m(e.value))||r.staticExports.some(({entries:e})=>e.some(({moduleRequest:e})=>m(e?.value)))||r.dynamicImports.some(({moduleRequest:t})=>m(e.slice(t.start,t.end))))&&h(),i===`flutter`&&(r.staticImports.some(({moduleRequest:e})=>e.value===`react-router`)||r.staticExports.some(({entries:e})=>e.some(({moduleRequest:e})=>e?.value===`react-router`))||r.dynamicImports.some(({moduleRequest:t})=>p(e.slice(t.start,t.end))))&&g()},resolveId(e){if(e===`virtual:coreframe-internal/shell`)return this.resolve(a.shell,o(u,`vite.config.ts`),{skipSelf:!0});if(e===`virtual:coreframe-internal/router`)return this.resolve(a.router,o(u,`vite.config.ts`),{skipSelf:!0});if(e===`virtual:coreframe-internal/flutter/application`)return this.resolve(o(u,`src/web/app/flutter-shell/application.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-internal/flutter/native-bridge`)return this.resolve(o(u,`src/web/app/flutter-shell/generated/native-bridge.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-internal/flutter/native-pages`)return this.resolve(o(u,`src/web/app/flutter-shell/generated/native-pages.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-internal/flutter/native-surfaces`)return this.resolve(o(u,`src/web/app/flutter-shell/generated/native-surfaces.ts`),void 0,{skipSelf:!0})}}}function d(e){let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]}function f(e){let t=r(e.split(`?`,1)[0]);if(t===`.jsx`)return`jsx`;if(t===`.ts`||t===`.mts`||t===`.cts`)return`ts`;if(t===`.tsx`)return`tsx`;if(t===`.js`||t===`.mjs`||t===`.cjs`)return`js`}function p(e){return e===`"react-router"`||e===`'react-router'`||e==="`react-router`"}function m(e){return e!==void 0&&/^["'`]?virtual:coreframe/u.test(e)}function h(){throw Error(`Application modules must import Coreframe runtime APIs from "@coreframe/app" package entry points; "virtual:coreframe*" modules are framework-internal.`)}function g(){throw Error(`Flutter application modules must import React Router APIs from ${JSON.stringify(`@coreframe/app/router`)}; direct ${JSON.stringify(`react-router`)} imports bypass the native navigation contract. Importing ${JSON.stringify(`react-router/dom`)} remains supported.`)}function _(e,t){let r=e.split(`?`,1)[0];if(!i(r))return!1;let o=a(n(t),n(r)),c=o.split(s);return o!==``&&o!==`..`&&!o.startsWith(`..${s}`)&&!i(o)&&!c.includes(`node_modules`)&&c[0]!==`.react-router`}export{u as coreframeShellPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "Vite plugins and build integrations for Coreframe apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"obug": "^2.1.3",
|
|
58
58
|
"unplugin": "^2.3.11",
|
|
59
59
|
"vite-plugin-hashed-favicons": "^2.1.1",
|
|
60
|
-
"@coreframe/
|
|
61
|
-
"@coreframe/
|
|
62
|
-
"@coreframe/
|
|
60
|
+
"@coreframe/config": "^0.1.11",
|
|
61
|
+
"@coreframe/assets": "^0.1.14",
|
|
62
|
+
"@coreframe/dashboard": "^0.3.14",
|
|
63
63
|
"@coreframe/dev-contracts": "^0.1.8",
|
|
64
|
-
"@coreframe/
|
|
65
|
-
"@coreframe/flutter-
|
|
66
|
-
"@coreframe/
|
|
67
|
-
"@coreframe/
|
|
64
|
+
"@coreframe/flutter-js": "^0.1.26",
|
|
65
|
+
"@coreframe/flutter-tools": "^0.1.21",
|
|
66
|
+
"@coreframe/lib": "^0.2.14",
|
|
67
|
+
"@coreframe/dev": "^0.1.18"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@tsdown/css": "0.22.3",
|