@coreframe/vite 0.1.41 → 0.2.1

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{FLUTTER_DOM_ROUTE_ID as e}from"@coreframe/lib/shell";import{getAppDirectory as t,index as n,layout as r,prefix as i,relative as a,route as o}from"@react-router/dev/routes";const s=`platform`,c=Symbol(`coreframe-route-registration`);function l(e,t,n,r){let i=Array.isArray(n)||n===void 0?void 0:n,a=Array.isArray(n)?n:r,s=i===void 0?void 0:{id:i.id,index:i.index,caseSensitive:i.caseSensitive},l=s===void 0?o(e,t,a):o(e,t,s,a);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,t){return n(e,t)}function d(e,t,n){return Array.isArray(t)?r(e,t):t===void 0?r(e):r(e,t,n)}function f(e,t){return i(e,t)}function p(e){let t=a(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=S(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)&&x(e,n),e.native!==void 0){b(e,n);let t=v(e,n),r=e.id,c=C(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,...g(e,n)})}else if(e.mobile!==void 0){y(e.mobile.underlayColor,n);let t=v(e,n),r=e.id,a=C(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,...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){x(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(`#`)||!/\.native-page\.(?:ts|tsx)$/.test(n))throw Error(`Invalid native controller path ${JSON.stringify(n)} for route ${JSON.stringify(e.id)} at ${t}: expected a relative *.native-page.ts or *.native-page.tsx module path without query, hash, or backslash characters.`)}function x(t,n){if(t.id===void 0)throw Error(`Mobile route at ${n} (${JSON.stringify(t.file)}) requires an explicit stable id.`);if(t.id===`root`)throw Error(`Mobile route at ${n} cannot use React Router's reserved id "root".`);if(t.id===e)throw Error(`Mobile route at ${n} cannot use Coreframe's reserved Flutter-DOM route id ${JSON.stringify(e)}.`);if(t.path===void 0&&t.index!==!0)throw Error(`Mobile route ${JSON.stringify(t.id)} at ${n} must have an addressable path or be an index route.`)}function S(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 C(e){return e.split(`/`).map(e=>e.startsWith(`:`)?`:${e.endsWith(`?`)?`?`:``}`:e).join(`/`).toLowerCase()}export{s as DEFAULT_MOBILE_TRANSITION_KEY,m as compileRouteRegistrations,t as getAppDirectory,u as index,d as layout,f as prefix,p as relative,l as route};
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=S(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)&&x(e,n),e.native!==void 0){b(e,n);let t=v(e,n),r=e.id,c=C(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,...g(e,n)})}else if(e.mobile!==void 0){y(e.mobile.underlayColor,n);let t=v(e,n),r=e.id,a=C(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,...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){x(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(`#`)||!/\.native-page\.(?:ts|tsx)$/.test(n))throw Error(`Invalid native controller path ${JSON.stringify(n)} for route ${JSON.stringify(e.id)} at ${t}: expected a relative *.native-page.ts or *.native-page.tsx module path without query, hash, or backslash characters.`)}function x(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 S(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 C(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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@coreframe/vite",
3
- "version": "0.1.41",
3
+ "version": "0.2.1",
4
+ "description": "Vite plugins and build integrations for Coreframe apps",
4
5
  "repository": {
5
6
  "type": "git",
6
7
  "url": "git+https://github.com/airlock-labs/coreframe.git",
@@ -54,14 +55,14 @@
54
55
  "obug": "^2.1.3",
55
56
  "unplugin": "^2.3.11",
56
57
  "vite-plugin-hashed-favicons": "^2.1.1",
57
- "@coreframe/assets": "^0.1.0",
58
- "@coreframe/config": "^0.1.0",
59
- "@coreframe/dev": "^0.1.0",
58
+ "@coreframe/config": "^0.1.1",
60
59
  "@coreframe/dev-contracts": "^0.1.0",
61
- "@coreframe/flutter-js": "^0.1.0",
62
- "@coreframe/flutter-tools": "^0.1.0",
63
- "@coreframe/dashboard": "^0.2.28",
64
- "@coreframe/lib": "^0.1.18"
60
+ "@coreframe/dashboard": "^0.3.1",
61
+ "@coreframe/flutter-tools": "^0.1.2",
62
+ "@coreframe/flutter-js": "^0.1.2",
63
+ "@coreframe/lib": "^0.2.0",
64
+ "@coreframe/assets": "^0.1.2",
65
+ "@coreframe/dev": "^0.1.1"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@tsdown/css": "0.22.3",