@coreframe/vite 0.2.25 → 0.2.26

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.
@@ -3,9 +3,11 @@ import { Plugin } from "vite";
3
3
  //#region plugins/development-controls.d.ts
4
4
  type CoreframeDevelopmentControlsPluginOptions = {
5
5
  enabled?: boolean;
6
+ env?: NodeJS.ProcessEnv;
6
7
  };
7
8
  declare function coreframeDevelopmentControlsPlugin({
8
- enabled
9
+ enabled,
10
+ env
9
11
  }?: CoreframeDevelopmentControlsPluginOptions): Plugin;
10
12
  //#endregion
11
13
  export { CoreframeDevelopmentControlsPluginOptions, coreframeDevelopmentControlsPlugin };
@@ -1 +1 @@
1
- import{developmentControlsEvents as e}from"@coreframe/dev-contracts/development-controls";function t({enabled:t=!0}={}){return{name:`coreframe:development-controls`,apply:`serve`,configureServer(n){if(!t)return;let r=!1,i=async(t,i)=>{if(r){i.send(e.actionResult,{error:`A Vite restart is already in progress.`,requestId:t.requestId,state:`error`});return}r=!0,i.send(e.actionResult,{requestId:t.requestId,state:`busy`});try{await n.restart(),r=!1,i.send(e.actionResult,{requestId:t.requestId,state:`complete`})}catch(a){r=!1;let o=a instanceof Error?a.message:String(a);n.config.logger.error(`Coreframe Vite restart failed: ${o}`,{error:a instanceof Error?a:void 0}),i.send(e.actionResult,{error:o,requestId:t.requestId,state:`error`})}};n.ws.on(e.action,i),n.httpServer?.once(`close`,()=>{n.ws.off(e.action,i)})}}}export{t as coreframeDevelopmentControlsPlugin};
1
+ import{mkdir as e,writeFile as t}from"node:fs/promises";import n from"node:path";import{randomUUID as r}from"node:crypto";import{developmentControlsEvents as i}from"@coreframe/dev-contracts/development-controls";import{managedDevFlutterRestartFileEnv as a}from"@coreframe/dev-contracts/managed-dev";function o({enabled:o=!0,env:s=process.env}={}){return{name:`coreframe:development-controls`,apply:`serve`,configureServer(c){if(!o)return;let l=!1,u=async(o,u)=>{if(l){u.send(i.actionResult,{error:o.action.type===`restart-flutter`?`A Flutter restart is already in progress.`:`A Vite restart is already in progress.`,requestId:o.requestId,state:`error`});return}l=!0,u.send(i.actionResult,{requestId:o.requestId,state:`busy`});try{if(o.action.type===`restart-flutter`){let i=s[a];if(!i)throw Error(`Flutter restart is unavailable for this development server.`);await e(n.dirname(i),{recursive:!0}),await t(i,`${r()}\n`,{mode:384})}else await c.restart();l=!1,u.send(i.actionResult,{requestId:o.requestId,state:`complete`})}catch(e){l=!1;let t=e instanceof Error?e.message:String(e),n=o.action.type===`restart-flutter`?`Flutter`:`Vite`;c.config.logger.error(`Coreframe ${n} restart failed: ${t}`,{error:e instanceof Error?e:void 0}),u.send(i.actionResult,{error:t,requestId:o.requestId,state:`error`})}};c.ws.on(i.action,u),c.httpServer?.once(`close`,()=>{c.ws.off(i.action,u)})}}}export{o as coreframeDevelopmentControlsPlugin};
@@ -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=`virtual:coreframe-shell`,u=`\0${l}`,d=`virtual:coreframe-shell/composition`,f=`virtual:coreframe-shell/auth`,p=`\0${f}`,m=`virtual:coreframe-shell/auth-composition`,h=`virtual:coreframe-router`,g=`\0${h}`,_=`virtual:coreframe-router/composition`,v={browser:{auth:`@coreframe/lib/auth-transport/browser`,router:`react-router`,shell:`@coreframe/lib/shell/dom`},flutter:{auth:`@coreframe/flutter-js/client`,router:`@coreframe/flutter-js/router`,shell:`@coreframe/flutter-js/composition`}};function y(){let n=t(),r=n===`ios`||n===`android`?n:void 0,i=e(process.env,n),a=v[i],s=b(a.shell),y=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)},ssr:{noExternal:[s]}}},configResolved(e){y=e.root},transform(e,t){let n=x(t);if(i!==`flutter`||!w(t,y)||n===void 0)return;let{module:r}=c(t,e,{lang:n});(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})=>S(e.slice(t.start,t.end))))&&C()},resolveId(e){if(e===l)return u;if(e===f)return p;if(e===h)return g;if(e===d)return this.resolve(a.shell,o(y,`vite.config.ts`),{skipSelf:!0});if(e===m)return this.resolve(a.auth,o(y,`vite.config.ts`),{skipSelf:!0});if(e===_)return this.resolve(a.router,o(y,`vite.config.ts`),{skipSelf:!0});if(e===`virtual:coreframe-flutter/application`)return this.resolve(o(y,`src/web/app/flutter-shell/application.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-bridge`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-bridge.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-pages`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-pages.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-surfaces`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-surfaces.ts`),void 0,{skipSelf:!0})},load(e){if(e===u)return`export * from ${JSON.stringify(d)};`;if(e===p)return`export { createAuthenticatedFetch, createAuthClient } from ${JSON.stringify(m)};`;if(e===g)return`export * from ${JSON.stringify(_)};`}}}function b(e){let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]}function x(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 S(e){return e===`"react-router"`||e===`'react-router'`||e==="`react-router`"}function C(){throw Error(`Flutter application modules must import React Router APIs from ${JSON.stringify(h)}; direct ${JSON.stringify(`react-router`)} imports bypass the native navigation contract. Importing ${JSON.stringify(`react-router/dom`)} remains supported.`)}function w(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{y as coreframeShellPlugin};
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=`virtual:coreframe-shell`,u=`\0${l}`,d=`virtual:coreframe-shell/composition`,f=`virtual:coreframe-shell/auth`,p=`\0${f}`,m=`virtual:coreframe-shell/auth-composition`,h=`virtual:coreframe-router`,g=`\0${h}`,_=`virtual:coreframe-router/composition`,v={browser:{auth:`@coreframe/lib/auth-transport/browser`,router:`react-router`,shell:`@coreframe/lib/shell/dom`},flutter:{auth:`@coreframe/lib/auth-transport/browser`,router:`@coreframe/flutter-js/router`,shell:`@coreframe/flutter-js/composition`}};function y(){let n=t(),r=n===`ios`||n===`android`?n:void 0,i=e(process.env,n),a=v[i],s=b(a.shell),y=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)},ssr:{noExternal:[s]}}},configResolved(e){y=e.root},transform(e,t){let n=x(t);if(i!==`flutter`||!w(t,y)||n===void 0)return;let{module:r}=c(t,e,{lang:n});(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})=>S(e.slice(t.start,t.end))))&&C()},resolveId(e){if(e===l)return u;if(e===f)return p;if(e===h)return g;if(e===d)return this.resolve(a.shell,o(y,`vite.config.ts`),{skipSelf:!0});if(e===m)return this.resolve(a.auth,o(y,`vite.config.ts`),{skipSelf:!0});if(e===_)return this.resolve(a.router,o(y,`vite.config.ts`),{skipSelf:!0});if(e===`virtual:coreframe-flutter/application`)return this.resolve(o(y,`src/web/app/flutter-shell/application.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-bridge`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-bridge.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-pages`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-pages.ts`),void 0,{skipSelf:!0});if(e===`virtual:coreframe-flutter/native-surfaces`)return this.resolve(o(y,`src/web/app/flutter-shell/generated/native-surfaces.ts`),void 0,{skipSelf:!0})},load(e){if(e===u)return`export * from ${JSON.stringify(d)};`;if(e===p)return`export { createAuthenticatedFetch, createAuthClient } from ${JSON.stringify(m)};`;if(e===g)return`export * from ${JSON.stringify(_)};`}}}function b(e){let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]}function x(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 S(e){return e===`"react-router"`||e===`'react-router'`||e==="`react-router`"}function C(){throw Error(`Flutter application modules must import React Router APIs from ${JSON.stringify(h)}; direct ${JSON.stringify(`react-router`)} imports bypass the native navigation contract. Importing ${JSON.stringify(`react-router/dom`)} remains supported.`)}function w(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{y as coreframeShellPlugin};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@coreframe/vite",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "Vite plugins and build integrations for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/airlock-labs/coreframe.git",
7
+ "url": "git+https://github.com/coreframe-js/coreframe.git",
8
8
  "directory": "node/vite"
9
9
  },
10
10
  "files": [
@@ -61,14 +61,14 @@
61
61
  "obug": "^2.1.3",
62
62
  "unplugin": "^2.3.11",
63
63
  "vite-plugin-hashed-favicons": "^2.1.1",
64
- "@coreframe/dashboard": "^0.3.10",
65
- "@coreframe/dev-contracts": "^0.1.6",
66
- "@coreframe/flutter-js": "^0.1.22",
64
+ "@coreframe/dashboard": "^0.3.11",
67
65
  "@coreframe/config": "^0.1.9",
68
- "@coreframe/dev": "^0.1.15",
69
- "@coreframe/flutter-tools": "^0.1.17",
66
+ "@coreframe/dev": "^0.1.16",
67
+ "@coreframe/dev-contracts": "^0.1.7",
68
+ "@coreframe/assets": "^0.1.12",
70
69
  "@coreframe/lib": "^0.2.11",
71
- "@coreframe/assets": "^0.1.12"
70
+ "@coreframe/flutter-js": "^0.1.23",
71
+ "@coreframe/flutter-tools": "^0.1.18"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@tsdown/css": "0.22.3",