@coreframe/vite 0.2.21 → 0.2.23

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.
@@ -0,0 +1,23 @@
1
+ import { Plugin } from "vite";
2
+
3
+ //#region plugins/dev-jobs.d.ts
4
+ type DevJobsResponse = {
5
+ body: string;
6
+ statusCode: number;
7
+ };
8
+ type CoreframeDevJobsPluginOptions = {
9
+ env?: NodeJS.ProcessEnv;
10
+ post?: (input: {
11
+ port: number;
12
+ secure: boolean;
13
+ token: string;
14
+ }) => Promise<DevJobsResponse>;
15
+ wait?: (milliseconds: number) => Promise<void>;
16
+ };
17
+ declare function coreframeDevJobsPlugin({
18
+ env,
19
+ post,
20
+ wait
21
+ }?: CoreframeDevJobsPluginOptions): Plugin;
22
+ //#endregion
23
+ export { CoreframeDevJobsPluginOptions, coreframeDevJobsPlugin };
@@ -0,0 +1 @@
1
+ import{request as e}from"node:http";import{request as t}from"node:https";import{devJobsEnv as n,devJobsPath as r,devJobsTokenHeader as i}from"@coreframe/dev-contracts/dev-jobs";function a({env:e=process.env,post:t=s,wait:r=c}={}){let i=e[n];return{apply:`serve`,name:`coreframe:dev-jobs`,configureServer(e){if(!i)return;let n=!1;e.httpServer?.once(`listening`,()=>{let a=e.httpServer?.address();if(!a||typeof a==`string`){e.config.logger.warn(`Coreframe dev jobs could not determine the Vite server port.`);return}o({logger:e.config.logger,port:a.port,post:t,secure:!!e.config.server.https,token:i,wait:r,isClosed:()=>n})}),e.httpServer?.once(`close`,()=>{n=!0})}}}async function o({isClosed:e,logger:t,port:n,post:r,secure:i,token:a,wait:o}){for(let s=1;s<=20;s+=1){if(e())return;try{let e=await r({port:n,secure:i,token:a});if(e.statusCode>=200&&e.statusCode<300){t.info(`Coreframe development jobs checked.`);return}if(e.statusCode!==404&&e.statusCode!==502&&e.statusCode!==503){t.warn(`Coreframe development jobs failed with HTTP ${e.statusCode}.`);return}}catch(e){if(s===20){let n=e instanceof Error?e.message:String(e);t.warn(`Coreframe development jobs could not start: ${n}`);return}}await o(250)}t.warn(`Coreframe development jobs did not become available.`)}function s({port:n,secure:a,token:o}){return new Promise((s,c)=>{let l=(a?t:e)({hostname:`127.0.0.1`,method:`POST`,path:r,port:n,...a?{rejectUnauthorized:!1}:void 0,headers:{[i]:o,"content-length":`0`}},e=>{let t=``;e.setEncoding(`utf8`),e.on(`data`,e=>{t+=e}),e.on(`end`,()=>{s({body:t,statusCode:e.statusCode??500})})});l.on(`error`,c),l.end()})}function c(e){return new Promise(t=>setTimeout(t,e))}export{a as coreframeDevJobsPlugin};
@@ -2,7 +2,7 @@ import { ConfigEnv, PluginOption } from "vite";
2
2
  import { ShellPlatform } from "@coreframe/lib/shell";
3
3
 
4
4
  //#region plugins/index.d.ts
5
- type CoreframeHost = "browser" | "flutter" | "tauri";
5
+ type CoreframeHost = "browser" | "flutter";
6
6
  type CoreframePlatform = ShellPlatform;
7
7
  type CoreframeRunner = "vite" | "vitest" | "react-router-prerender";
8
8
  type CoreframeConfigEnv = ConfigEnv & {
@@ -1 +1 @@
1
- function e(e,i=process.env){let a=r(i);return{...e,host:t(i,a),platform:a,runner:n(i)}}function t(e=process.env,t=r(e)){return e.TAURI_ENV_PLATFORM===void 0?t===`web`?`browser`:`flutter`:`tauri`}function n(e=process.env){return e.VITEST===`true`?`vitest`:e.IS_RR_BUILD_REQUEST===`yes`?`react-router-prerender`:`vite`}function r(e=process.env){let t=e.COREFRAME_PLATFORM??e.TAURI_ENV_PLATFORM??`web`,n=t===`darwin`?`macos`:t===`win32`?`windows`:t;if(n!==`web`&&n!==`ios`&&n!==`android`&&n!==`macos`&&n!==`windows`&&n!==`linux`)throw Error(`Unsupported Coreframe platform: ${JSON.stringify(t)}.`);return n}function i(e,t){return t.map(t=>u(e,t))}function a(e,t){return n=>e(n)?u(n,t):null}function o(e){return a(e=>e.command===`build`,e)}function s(e){return a(e=>e.command===`serve`,e)}function c(e,t){return a(t=>d(e,t.runner),t)}function l(e,t){return a(t=>!d(e,t.runner),t)}function u(e,t){return typeof t==`function`?t(e):t}function d(e,t){return(typeof e==`string`?[e]:e).includes(t)}export{a as apply,o as buildOnly,s as devOnly,l as exceptRunner,e as extendConfigEnv,t as resolveCoreframeHost,r as resolveCoreframePlatform,n as resolveCoreframeRunner,c as runnerOnly,i as selectPlugins};
1
+ function e(e,i=process.env){let a=r(i);return{...e,host:t(i,a),platform:a,runner:n(i)}}function t(e=process.env,t=r(e)){return t===`web`?`browser`:`flutter`}function n(e=process.env){return e.VITEST===`true`?`vitest`:e.IS_RR_BUILD_REQUEST===`yes`?`react-router-prerender`:`vite`}function r(e=process.env){let t=e.COREFRAME_PLATFORM??`web`,n=t===`darwin`?`macos`:t===`win32`?`windows`:t;if(n!==`web`&&n!==`ios`&&n!==`android`&&n!==`macos`&&n!==`windows`&&n!==`linux`)throw Error(`Unsupported Coreframe platform: ${JSON.stringify(t)}.`);return n}function i(e,t){return t.map(t=>u(e,t))}function a(e,t){return n=>e(n)?u(n,t):null}function o(e){return a(e=>e.command===`build`,e)}function s(e){return a(e=>e.command===`serve`,e)}function c(e,t){return a(t=>d(e,t.runner),t)}function l(e,t){return a(t=>!d(e,t.runner),t)}function u(e,t){return typeof t==`function`?t(e):t}function d(e,t){return(typeof e==`string`?[e]:e).includes(t)}export{a as apply,o as buildOnly,s as devOnly,l as exceptRunner,e as extendConfigEnv,t as resolveCoreframeHost,r as resolveCoreframePlatform,n as resolveCoreframeRunner,c as runnerOnly,i as selectPlugins};
@@ -1 +1 @@
1
- import{coreframeAssetsPlugin as e}from"./assets.js";import{coreframeCodexTaskPlugin as t}from"./codex-task.js";import{coreframeDashboardPlugin as n}from"./dashboard.js";import{coreframeDevelopmentControlsPlugin as r}from"./development-controls.js";import{coreframeFaviconPlugin as i}from"./favicon.js";import{t as a}from"../icons-vb_lG-av.js";import{coreframeManagedDevPlugin as o}from"./managed-dev.js";import{coreframePreviewPlugin as s}from"./preview.js";import{coreframeStartupTimingPlugin as c}from"./startup-timing.js";import{t as l}from"../worktree-head-BZrhW1-Q.js";function u(u={}){return[c(),s(u.config??{}),e(),...a(),r(),o(),t(),l(),n(),...i(u.webManifest===void 0?void 0:{webManifest:u.webManifest})]}export{u as coreframeVitePreset};
1
+ import{coreframeAssetsPlugin as e}from"./assets.js";import{coreframeCodexTaskPlugin as t}from"./codex-task.js";import{coreframeDashboardPlugin as n}from"./dashboard.js";import{coreframeDevJobsPlugin as r}from"./dev-jobs.js";import{coreframeDevelopmentControlsPlugin as i}from"./development-controls.js";import{coreframeFaviconPlugin as a}from"./favicon.js";import{t as o}from"../icons-vb_lG-av.js";import{coreframeManagedDevPlugin as s}from"./managed-dev.js";import{coreframePreviewPlugin as c}from"./preview.js";import{coreframeStartupTimingPlugin as l}from"./startup-timing.js";import{t as u}from"../worktree-head-BZrhW1-Q.js";function d(d={}){return[l(),c(d.config??{}),e(),...o(),i(),r(),s(),t(),u(),n(),...a(d.webManifest===void 0?void 0:{webManifest:d.webManifest})]}export{d as coreframeVitePreset};
@@ -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`},tauri:{auth:`./src/api/client/tauri-auth.ts`,router:`react-router`,shell:`@coreframe/lib/shell/dom`}};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/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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/vite",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "description": "Vite plugins and build integrations for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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.8",
65
- "@coreframe/dev": "^0.1.11",
66
- "@coreframe/assets": "^0.1.10",
67
- "@coreframe/config": "^0.1.7",
68
- "@coreframe/dev-contracts": "^0.1.5",
69
- "@coreframe/flutter-tools": "^0.1.14",
70
- "@coreframe/lib": "^0.2.9",
71
- "@coreframe/flutter-js": "^0.1.19"
64
+ "@coreframe/assets": "^0.1.12",
65
+ "@coreframe/dashboard": "^0.3.10",
66
+ "@coreframe/dev": "^0.1.13",
67
+ "@coreframe/dev-contracts": "^0.1.6",
68
+ "@coreframe/flutter-js": "^0.1.21",
69
+ "@coreframe/flutter-tools": "^0.1.16",
70
+ "@coreframe/config": "^0.1.9",
71
+ "@coreframe/lib": "^0.2.10"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@tsdown/css": "0.22.3",