@coreframe/vite 0.2.22 → 0.2.24
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};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
import { startManagedDevSession } from "@coreframe/dev/managed-dev";
|
|
3
|
+
import { connectExistingDevSupervisor } from "@coreframe/dev/supervisor";
|
|
3
4
|
|
|
4
5
|
//#region plugins/managed-dev.d.ts
|
|
5
6
|
type CoreframeManagedDevPluginOptions = {
|
|
7
|
+
connectSupervisor?: typeof connectExistingDevSupervisor;
|
|
6
8
|
env?: NodeJS.ProcessEnv;
|
|
7
9
|
startSession?: typeof startManagedDevSession;
|
|
8
10
|
};
|
|
9
11
|
declare function coreframeManagedDevPlugin({
|
|
12
|
+
connectSupervisor,
|
|
10
13
|
env,
|
|
11
14
|
startSession
|
|
12
15
|
}?: CoreframeManagedDevPluginOptions): Plugin;
|
|
@@ -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";const
|
|
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};
|
package/dist/plugins/preset.js
CHANGED
|
@@ -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{
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
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/
|
|
65
|
-
"@coreframe/
|
|
66
|
-
"@coreframe/
|
|
67
|
-
"@coreframe/
|
|
68
|
-
"@coreframe/
|
|
69
|
-
"@coreframe/
|
|
70
|
-
"@coreframe/
|
|
71
|
-
"@coreframe/
|
|
64
|
+
"@coreframe/assets": "^0.1.12",
|
|
65
|
+
"@coreframe/config": "^0.1.9",
|
|
66
|
+
"@coreframe/dev-contracts": "^0.1.6",
|
|
67
|
+
"@coreframe/flutter-tools": "^0.1.16",
|
|
68
|
+
"@coreframe/dashboard": "^0.3.10",
|
|
69
|
+
"@coreframe/dev": "^0.1.14",
|
|
70
|
+
"@coreframe/lib": "^0.2.10",
|
|
71
|
+
"@coreframe/flutter-js": "^0.1.21"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@tsdown/css": "0.22.3",
|