@lunora/vite 1.0.0-alpha.277 → 1.0.0-alpha.278

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/dist/index.d.mts CHANGED
@@ -167,8 +167,8 @@ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
167
167
  * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
168
168
  * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
169
169
  * file is gitignored — so a fresh clone has none and the worker throws on the
170
- * first required secret (e.g. `AUTH_SECRET is required`). Three steps, the first
171
- * two shared with `lunora dev` via `@lunora/config`.
170
+ * first required secret (e.g. `AUTH_SECRET is required`). All three steps live in
171
+ * `@lunora/config`, shared with `lunora dev` and `@lunora/rspack`.
172
172
  *
173
173
  * First, {@link ensureDevVariables}: when a `.dev.vars.example` exists, prompt
174
174
  * to generate `.dev.vars` from it with secrets auto-filled. Second,
package/dist/index.d.ts CHANGED
@@ -167,8 +167,8 @@ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
167
167
  * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
168
168
  * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
169
169
  * file is gitignored — so a fresh clone has none and the worker throws on the
170
- * first required secret (e.g. `AUTH_SECRET is required`). Three steps, the first
171
- * two shared with `lunora dev` via `@lunora/config`.
170
+ * first required secret (e.g. `AUTH_SECRET is required`). All three steps live in
171
+ * `@lunora/config`, shared with `lunora dev` and `@lunora/rspack`.
172
172
  *
173
173
  * First, {@link ensureDevVariables}: when a `.dev.vars.example` exists, prompt
174
174
  * to generate `.dev.vars` from it with secrets auto-filled. Second,
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{createRequire as i}from"node:module";import{cloudflare as l}from"@cloudflare/vite-plugin";import{detectAgentRules as s,claimAgentRulesHint as u,AGENT_RULES_HINT as c,detectFramework as f,resolveTargetOrThrow as d,isRunnableTarget as m,runnableTargetIds as p}from"@lunora/config";import{GENERATED_CLASS_MODULES as ar,detectFramework as ir}from"@lunora/config";import g from"@visulima/vite-overlay";import{l as a}from"./packem_shared/log-DE48L4Oz.mjs";import{r as S,c as v}from"./packem_shared/codegen-plugin-BqoP2XfZ.mjs";import w from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import R from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import h from"./packem_shared/devVariablesPlugin-DY_bJXsX.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-B4-x5Aws.mjs";import{CLASS_A_WIRING as sr,LUNORA_WORKER_VIRTUAL_ID as ur,buildWorkerEntrySource as cr,isAutoComposable as fr}from"./packem_shared/CLASS_A_WIRING-B4-x5Aws.mjs";import P from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as A}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as mr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{remoteBindingsPlugin as E}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{planViteRemoteBindings as gr,withRemoteBindings as Sr}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{lunoraSolutionFinders as T}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as wr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{STUDIO_PATH as hr,buildStudioUrl as kr}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{withWorkerStartupHint as x}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Ar,augmentWorkerStartupError as Er,isWorkerEntryEvalError as Tr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as O}from"./packem_shared/wranglerValidatorPlugin-BdKLAEoq.mjs";import{default as xr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as br}from"@lunora/config/cloudflare";const b=o=>({apply:"serve",configureServer(r){return()=>{s(o.projectRoot).installed||!u()||r.config.logger.warn(`
1
+ import{createRequire as i}from"node:module";import{cloudflare as l}from"@cloudflare/vite-plugin";import{detectAgentRules as s,claimAgentRulesHint as u,lunoraLine as a,AGENT_RULES_HINT as c,detectFramework as f,resolveTargetOrThrow as d,isRunnableTarget as m,runnableTargetIds as p}from"@lunora/config";import{GENERATED_CLASS_MODULES as ar,detectFramework as ir}from"@lunora/config";import g from"@visulima/vite-overlay";import{reconcileBindingsSafely as S}from"@lunora/config/cloudflare";import{reconcileWranglerCrons as sr}from"@lunora/config/cloudflare";import v from"./packem_shared/codegenPlugin-CV_h92v2.mjs";import w from"./packem_shared/containerLogsPlugin-67PZ8zmb.mjs";import R from"./packem_shared/devStatePlugin-CCWf9AFZ.mjs";import h from"./packem_shared/devVariablesPlugin-DbD6cSF0.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-B4-x5Aws.mjs";import{CLASS_A_WIRING as cr,LUNORA_WORKER_VIRTUAL_ID as fr,buildWorkerEntrySource as dr,isAutoComposable as mr}from"./packem_shared/CLASS_A_WIRING-B4-x5Aws.mjs";import P from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as A}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{checkLunoraProxy as gr}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{remoteBindingsPlugin as E}from"./packem_shared/planViteRemoteBindings-ByOliZuE.mjs";import{planViteRemoteBindings as vr,withRemoteBindings as wr}from"./packem_shared/planViteRemoteBindings-ByOliZuE.mjs";import{lunoraSolutionFinders as T}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as hr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{STUDIO_PATH as Pr,buildStudioUrl as Ar}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{withWorkerStartupHint as x}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Tr,augmentWorkerStartupError as _r,isWorkerEntryEvalError as xr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as O}from"./packem_shared/wranglerValidatorPlugin-BlGHjTXZ.mjs";import{default as br}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";const b=o=>({apply:"serve",configureServer(r){return()=>{s(o.projectRoot).installed||!u()||r.config.logger.warn(`
2
2
  ${a(c)}
3
- `)}},name:"lunora:agent-rules-hint"}),y=o=>({async config(r,t){t.isPreview!==!0&&await S(o,{info:e=>{console.info(e)},warn:e=>{console.warn(e)}})},enforce:"pre",name:"lunora:bindings-provision"}),L=()=>({}),W={astro:"Astro",none:"standalone (SPA / SSR-less)",nuxt:"Nuxt","react-router":"React Router","solid-start":"SolidStart",sveltekit:"SvelteKit","tanstack-start":"TanStack Start","tanstack-start-solid":"TanStack Start (Solid)",vinext:"Next.js on Vite (vinext)"},D=o=>{const r=W[o.framework];return o.framework==="none"?a("no meta-framework detected — running standalone."):o.class==="B"?a(`detected ${r} — composition is handled by the framework adapter.`):a(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},C=(o,r)=>{let t=!1;const e=()=>{r.framework??=f(o.projectRoot)};return{config(){e()},configResolved(){e()},configureServer(){e(),!t&&r.framework!==void 0&&(t=!0,console.info(D(r.framework)))},name:"lunora:framework-detect"}},N=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...T,...r.solutionFinders??[]]}},U=(o,r)=>{const t=d(o,r);if(!m(t)){const e=p();throw new Error(`target "${t}" has no command-line toolchain, so the Lunora Vite plugin cannot build or serve it — it can only generate for it (\`lunora codegen --target ${t}\`). Buildable targets: ${e.join(", ")}`)}return t},I=o=>{const r=o??{},t=r.schemaDir??"lunora";let e;r.cloudflare===!1?e=!1:r.cloudflare===!0||r.cloudflare===void 0?e={}:e=r.cloudflare;const n=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:e,studio:r.studio??!0,generatedDir:`${t}/_generated`,overlay:N(r.overlay),projectRoot:n,schemaDir:t,shard:r.shard??{},target:U(n,r.target),validateWrangler:r.validateWrangler??!0}},er=o=>{const r=I(o),t=L(),e=[C(r,t),k(r,t),h(r),y(r),v(r),P(),R(r),b(r),A()];r.studio&&e.push(_(r)),r.validateWrangler&&e.push(O(r)),r.overlay!==!1&&e.push(g(r.overlay)),e.push(w(r));const n=r.cloudflare===!1?void 0:{...r.cloudflare};return e.push(E(n,{projectRoot:r.projectRoot})),n!==void 0&&e.push(...x(l(n))),e},or=i(import.meta.url)("../package.json").version;export{sr as CLASS_A_WIRING,ar as GENERATED_CLASS_MODULES,xr as LUNORA_API_UPDATED_EVENT,ur as LUNORA_WORKER_VIRTUAL_ID,hr as STUDIO_PATH,or as VERSION,Ar as WORKER_STARTUP_HINT,Er as augmentWorkerStartupError,kr as buildStudioUrl,cr as buildWorkerEntrySource,mr as checkLunoraProxy,v as codegenPlugin,w as containerLogsPlugin,ir as detectFramework,R as devStatePlugin,h as devVariablesPlugin,k as frameworkComposePlugin,fr as isAutoComposable,Tr as isWorkerEntryEvalError,P as logStreamPlugin,er as lunora,wr as lunoraSolutionFinder,T as lunoraSolutionFinders,gr as planViteRemoteBindings,A as proxyCheckPlugin,br as reconcileWranglerCrons,E as remoteBindingsPlugin,N as resolveOverlayOption,_ as studioPlugin,Sr as withRemoteBindings,x as withWorkerStartupHint,O as wranglerValidatorPlugin};
3
+ `)}},name:"lunora:agent-rules-hint"}),y=o=>({async config(r,t){t.isPreview!==!0&&await S(o,{info:e=>{console.info(e)},warn:e=>{console.warn(e)}})},enforce:"pre",name:"lunora:bindings-provision"}),L=()=>({}),W={astro:"Astro",none:"standalone (SPA / SSR-less)",nuxt:"Nuxt","react-router":"React Router","solid-start":"SolidStart",sveltekit:"SvelteKit","tanstack-start":"TanStack Start","tanstack-start-solid":"TanStack Start (Solid)",vinext:"Next.js on Vite (vinext)"},D=o=>{const r=W[o.framework];return o.framework==="none"?a("no meta-framework detected — running standalone."):o.class==="B"?a(`detected ${r} — composition is handled by the framework adapter.`):a(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},C=(o,r)=>{let t=!1;const e=()=>{r.framework??=f(o.projectRoot)};return{config(){e()},configResolved(){e()},configureServer(){e(),!t&&r.framework!==void 0&&(t=!0,console.info(D(r.framework)))},name:"lunora:framework-detect"}},N=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...T,...r.solutionFinders??[]]}},U=(o,r)=>{const t=d(o,r);if(!m(t)){const e=p();throw new Error(`target "${t}" has no command-line toolchain, so the Lunora Vite plugin cannot build or serve it — it can only generate for it (\`lunora codegen --target ${t}\`). Buildable targets: ${e.join(", ")}`)}return t},I=o=>{const r=o??{},t=r.schemaDir??"lunora";let e;r.cloudflare===!1?e=!1:r.cloudflare===!0||r.cloudflare===void 0?e={}:e=r.cloudflare;const n=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:e,studio:r.studio??!0,generatedDir:`${t}/_generated`,overlay:N(r.overlay),projectRoot:n,schemaDir:t,shard:r.shard??{},target:U(n,r.target),validateWrangler:r.validateWrangler??!0}},er=o=>{const r=I(o),t=L(),e=[C(r,t),k(r,t),h(r),y(r),v(r),P(),R(r),b(r),A()];r.studio&&e.push(_(r)),r.validateWrangler&&e.push(O(r)),r.overlay!==!1&&e.push(g(r.overlay)),e.push(w(r));const n=r.cloudflare===!1?void 0:{...r.cloudflare};return e.push(E(n,{projectRoot:r.projectRoot})),n!==void 0&&e.push(...x(l(n))),e},or=i(import.meta.url)("../package.json").version;export{cr as CLASS_A_WIRING,ar as GENERATED_CLASS_MODULES,br as LUNORA_API_UPDATED_EVENT,fr as LUNORA_WORKER_VIRTUAL_ID,Pr as STUDIO_PATH,or as VERSION,Tr as WORKER_STARTUP_HINT,_r as augmentWorkerStartupError,Ar as buildStudioUrl,dr as buildWorkerEntrySource,gr as checkLunoraProxy,v as codegenPlugin,w as containerLogsPlugin,ir as detectFramework,R as devStatePlugin,h as devVariablesPlugin,k as frameworkComposePlugin,mr as isAutoComposable,xr as isWorkerEntryEvalError,P as logStreamPlugin,er as lunora,hr as lunoraSolutionFinder,T as lunoraSolutionFinders,vr as planViteRemoteBindings,A as proxyCheckPlugin,sr as reconcileWranglerCrons,E as remoteBindingsPlugin,N as resolveOverlayOption,_ as studioPlugin,wr as withRemoteBindings,x as withWorkerStartupHint,O as wranglerValidatorPlugin};
@@ -0,0 +1 @@
1
+ import{lunoraLine as a}from"@lunora/config";const c=["/_lunora"],u="/_lunora/ws",h=e=>{if(e.startsWith("^"))try{return new RegExp(e,"u").test(u)}catch{return!1}return c.some(r=>e.startsWith(r)||r.startsWith(e))},i=(e,r)=>{if(!e)return[];const t=[];for(const[s,o]of Object.entries(e)){if(!h(s))continue;if(typeof o=="string"){t.push(`${r}.proxy["${s}"] uses the string shorthand, which does not proxy WebSocket upgrades. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work. Use the object form: { target: "${o}", ws: true }.`);continue}if(typeof o!="object"||o===null)continue;const n=o;n.ws!==!0&&t.push(`${r}.proxy["${s}"] is missing \`ws: true\`, so WebSocket upgrades are not proxied. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work.`),n.changeOrigin===!0&&t.push(`${r}.proxy["${s}"] sets \`changeOrigin: true\`, so the worker sees a different origin than the browser sends. Loopback-to-loopback is trusted by default; for any other dev host add the dev-server origin to the worker's \`security.csrf.trustedOrigins\` or the cookie-bearing WebSocket upgrade is rejected with FORBIDDEN_ORIGIN.`)}return t},g=()=>({apply:"serve",configResolved(e){const r=[...i(e.server.proxy,"server"),...i(e.preview.proxy,"preview")];for(const t of r)e.logger.warn(a(t))},name:"lunora:proxy-check"});export{i as checkLunoraProxy,g as proxyCheckPlugin};
@@ -0,0 +1,3 @@
1
+ import{readFileSync as J,existsSync as H}from"node:fs";import{resolve as p,sep as b,basename as z,join as K}from"node:path";import{findProjectConfigFile as X,PROJECT_CONFIG_FILENAMES as q,findTsconfig as Q,runCodegen as Y,fingerprintSchemaSources as A,createCodegenProject as Z,refreshCodegenProject as ee,CodegenDiagnosticError as ne}from"@lunora/codegen";import{LUNORA_TAG as w,isCodegenDisabled as te,CODEGEN_ENV as x,runPostCodegenHook as W,reportCodegenFindings as re,blockingFindingsMessage as oe}from"@lunora/config";import{findWranglerFile as ie,readWranglerJsonc as ce,WRANGLER_FILES as ae,reconcileBindingsSafely as se,collectWranglerSecretVariables as le,reconcileWranglerExtras as de}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as fe}from"vite";import{createHash as ge}from"node:crypto";import ue from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{r as he,a as me}from"./server-close-Qoh4i6Ay.mjs";const pe=(e,n)=>{try{const{parsed:o,text:t}=ce(e);return o===void 0?`raw:${t}`:JSON.stringify(n?n(o):o)}catch{return"unreadable"}},we=e=>{const n={...e},{triggers:o}=n;if(o!==null&&typeof o=="object"){const t={...o};delete t.crons,Object.keys(t).length>0?n.triggers=t:delete n.triggers}return n},O=e=>{const n=ie(e),o=n===void 0?"absent":pe(n,we),t=X(e);let l="absent";try{t!==void 0&&(l=ge("sha256").update(J(t)).digest("hex"))}catch{}return`${o}\0${l}`},ye=100,I=300,G=2,ve=e=>{let n,o,t=0;const l=()=>{n&&(clearTimeout(n),n=void 0)},a=(u,f)=>{o&&clearTimeout(o),o=setTimeout(()=>{if(o=void 0,e.fingerprint()!==u){if(t+=1,t>G){e.logger.warn(`${w} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(G)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${w} schema changed while \`postcodegen\` was running — regenerating`),f()}},I)},d=u=>{e.regenerate(u,f=>{a(f,()=>{d(u)})})};return{cancelPending:l,dispose:()=>{l(),o&&(clearTimeout(o),o=void 0)},onSave:u=>{l(),t=0,n=setTimeout(()=>{n=void 0,d(u)},ye)}}},L=/[/\\]tsconfig\..+\.json$/u,Se=e=>{const n=e.map(t=>` • ${t.kind} "${t.exportName}" — class ${t.className} is not exported by your worker entry.`),o=[...new Set(e.map(t=>t.module))].map(t=>` export * from "./lunora/_generated/${t}";`);return[`[lunora] ${String(e.length)} declared ${e.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...n,"","Add to your worker entry:",...o].join(`
2
+ `)},Ee=(e,n,o)=>{if(n.warn(`${w} schema.ts not found at ${e} — codegen skipped`),o!==void 0){const t=`schema.ts not found at ${e} — generated output is now stale`;o.onError(new Error(t),t)}},M=(e,n,o,t)=>{const l=K(e.projectRoot,e.schemaDir,"schema.ts");if(!H(l))return Ee(l,n,o),{};try{const a=Y({apiSpec:e.apiSpec,lunoraDirectory:e.schemaDir,project:t,projectRoot:e.projectRoot,target:e.target,wranglerVariables:le(e.projectRoot)});return de(e.projectRoot,a.cronTriggers,n),re(a,n),{blockingMessage:oe(a),outputDirectory:p(a.outputDirectory)}}catch(a){const d=a instanceof Error?a.message:String(a);return n.error(`${w} codegen failed: ${d}`),o?.onError(a,d),{failure:`${w} codegen failed: ${d}`}}},$e=(e,n,o)=>{let t;for(const[l,a]of Object.entries(e.environments)){if(l==="client"){t=a;continue}fe(a)||a.hot.send({path:"*",triggeredBy:n,type:"full-reload"})}if(t===void 0){e.hot.send({type:"full-reload"});return}if(o){t.hot.send({type:"full-reload"});return}t.hot.send({event:ue,type:"custom"})},R={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},Oe=e=>{const n=p(e.projectRoot,e.schemaDir),o=te(process.env[x]);let t=p(e.projectRoot,e.generatedDir),l=0,a=!1,d;const u=new Map;let f,C=!1,j=!1,y,D;return{config(i,h){y=h.command},configResolved(){y!=="build"&&o||(D=M(e,R))},async buildStart(){const i=y!=="build"&&o,{blockingMessage:h,failure:v,outputDirectory:k}=D??(i?{}:M(e,R));if(D=void 0,y==="build"&&v!==void 0&&this.error(v),k!==void 0){t=k,a=!0;let g;try{g=await W({cwd:e.projectRoot,logger:R})}finally{a=!1}g.ran&&(l=Date.now()),y==="build"&&g.error!==void 0&&this.error(g.error)}y==="build"&&h!==void 0&&this.error(h),await se(e,R,g=>{d?.hot.send({err:{loc:void 0,message:Se(g),stack:""},type:"error"})}),d!==void 0&&(f=O(e.projectRoot),C=!0)},configureServer(i){d=i,i.watcher.add(n),f=O(e.projectRoot),C=!1;const h={error:r=>{i.config.logger.error(r)},info:r=>{i.config.logger.info(r)},warn:r=>{i.config.logger.warn(r)}};let v=!1;const k={onError(r,c){v=!0;const s=r instanceof ne?{column:r.column,file:r.file,line:r.line}:void 0,$=s===void 0?`[lunora] codegen failed: ${c}
3
+ (see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${c}`;d?.hot.send({err:{loc:s,message:$,stack:r instanceof Error?r.stack??"":""},type:"error"})}},g=(r,c)=>r===c||r.startsWith(c+b);let T=!1,m;const U=()=>{for(const r of Object.values(i.environments)){const c=r.moduleGraph;for(const s of c.idToModuleMap.values())s.id&&g(s.id,t)&&c.invalidateModule(s)}},V=async(r,c)=>{try{if(T)return;m===void 0?m=Z(n):ee(m,n);const{outputDirectory:s}=M(e,h,k,m);if(s===void 0){m=void 0;return}t=s;const $=A(n);a=!0;let P;try{P=await W({cwd:e.projectRoot,logger:h})}finally{a=!1}if(P.ran&&(l=Date.now(),c($)),P.error!==void 0)return;U(),$e(i,r,v),v=!1}catch(s){h.error(`${w} codegen watch: ${s instanceof Error?s.message:String(s)}`)}},_=ve({fingerprint:()=>A(n),logger:h,regenerate:(r,c)=>{V(r,c)}}),S=r=>{const c=p(r);if(L.test(c)){m=void 0;return}if(c.endsWith(`${b}tsconfig.json`)&&c===Q(n)){m=void 0;return}if(g(c,n)&&!g(c,t)&&c.endsWith(".ts")&&!(c.includes(`${b}__tests__${b}`)||c.endsWith(".test.ts")||c.endsWith(".spec.ts"))){if(a||Date.now()-l<I){_.cancelPending();return}_.onSave(c)}},N=r=>{const c=p(r);(c.endsWith(`${b}tsconfig.json`)||L.test(c))&&(m=void 0)};o?i.config.logger.info(`${w} codegen watch disabled (${x}) — _generated/ is written only by an explicit \`lunora codegen\``):(i.watcher.on("add",S),i.watcher.on("change",S),i.watcher.on("unlink",S),i.watcher.on("unlink",N));const F=new Set([...ae.map(r=>p(e.projectRoot,r)),...q.map(r=>p(e.projectRoot,r))]);for(const r of F)i.watcher.add(r);const E=r=>{if(!F.has(p(r))||j)return;const c=O(e.projectRoot);if(!C){f=c;return}if(f===void 0){f=c;return}c!==f&&(f=c,j=!0,i.config.logger.info(`${w} ${z(p(r))} changed — restarting dev server`),Promise.resolve(i.restart()).finally(()=>{j=!1}).catch(s=>{const $=s instanceof Error?s.message:String(s);i.config.logger.error(`${w} dev server restart failed: ${$} — keeping the running server; re-save your config to retry.`),i.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${$}`,stack:""},type:"error"})}))};i.watcher.on("add",E),i.watcher.on("change",E),i.watcher.on("unlink",E);const B=()=>{T||(T=!0,m=void 0,_.dispose(),i.watcher.off("add",S),i.watcher.off("change",S),i.watcher.off("unlink",S),i.watcher.off("unlink",N),i.watcher.off("add",E),i.watcher.off("change",E),i.watcher.off("unlink",E))};return()=>{me(i,u,B)}},buildEnd(){he(u,this.environment)},name:"lunora:codegen"}};export{Oe as default};
@@ -0,0 +1 @@
1
+ import{discoverContainerInfo as l,streamContainerLogs as u,lunoraLine as i}from"@lunora/config";const v=r=>{let n;const a=()=>{n?.close(),n=void 0};return{apply:"serve",buildEnd(){a()},configureServer(t){if(n||process.env.LUNORA_CONTAINER_LOGS==="0")return;const c=l(r.projectRoot,r.schemaDir).containers.map(e=>({className:e.className,exportName:e.exportName}));if(c.length===0)return;const{logger:o}=t.config;n=u({containers:c,onLine:e=>{const s=i(`container:${e.name} ${e.text}`);e.level==="error"?o.warn(s):o.info(s)},onUnavailable:e=>{o.warn(i(`container: Docker engine unreachable — container logs unavailable (${e})`))}}),t.httpServer?.once("close",a)},name:"lunora:container-logs"}};export{v as default};
@@ -0,0 +1 @@
1
+ import{DEV_HANDOFF_ENV as a,claimDevServerState as c,DEV_LOG_FILE_ENV as p,DEV_DAEMON_ENV as u,lunoraLine as v,clearDevServerState as f}from"@lunora/config";import{r as g,a as S}from"./server-close-Qoh4i6Ay.mjs";const m=/\/$/,D=n=>{const r=n.resolvedUrls?.local[0];if(r!==void 0)return r.replace(m,"");const t=n.httpServer?.address();if(t!==null&&typeof t=="object")return`http://localhost:${String(t.port)}`},_=n=>{let r=!1;const t=new Map;return{apply:"serve",configureServer(e){const l=n.projectRoot,d=()=>{if(r)return;const o=D(e);if(o===void 0)return;const s=Number(process.env[a]),i=c(l,{background:process.env[u]==="1",logFile:process.env[p],mode:"vite",pid:process.pid,readyAt:new Date().toISOString(),startedAt:new Date().toISOString(),url:o},Number.isInteger(s)&&s>0?{supersedePid:s}:void 0);if(!i.ok){i.existing!==void 0&&e.config.logger.warn(v(`another dev server is already recorded at ${i.existing.url} (pid ${String(i.existing.pid)}) — leaving .lunora/dev.json untouched`));return}r=!0};return S(e,t,()=>{r&&(f(l,process.pid),r=!1)}),()=>{if(typeof e.printUrls=="function"){const o=e.printUrls.bind(e);e.printUrls=()=>{o(),d()}}e.httpServer?.once("listening",()=>{setTimeout(d,0)})}},buildEnd(){g(t,this.environment)},name:"lunora:dev-state"}};export{_ as default};
@@ -0,0 +1 @@
1
+ import{ensureDevVariables as a,createConfirm as i,fillDevSecrets as t,ensureDevWorkerEnv as c,lunoraLine as s}from"@lunora/config";const f=r=>{let n=!1;return{apply:"serve",config(e,o){n=o.isPreview===!0},async configResolved(){if(n)return;const e=o=>{console.info(s(o))};await a({confirm:i("[lunora] "),cwd:r.projectRoot,info:e}),t({cwd:r.projectRoot,info:e}),c(r.projectRoot,e)},enforce:"pre",name:"lunora:dev-vars"}};export{f as default};
@@ -0,0 +1 @@
1
+ import{readProjectRemotePreference as d,lunoraLine as c}from"@lunora/config";import{resolveRemoteEnabled as s,materializeRemoteWranglerConfig as g}from"@lunora/config/cloudflare";const l=()=>{},u=e=>{const t=e.readPreference??d;if(!s({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1};const o=(e.materialize??g)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:o.cleanup,configPath:o.configPath,enabled:!0,reason:o.reason}},m=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},p=(e,t)=>{let n={cleanup:l,enabled:!1},i;const o=()=>{n.cleanup()};return{buildEnd:o,closeBundle:o,config(P,f){if(f.command!=="serve")return;if(n.cleanup(),n=u(t),e===void 0){n.enabled&&n.configPath!==void 0&&console.info(c(`remote bindings are materialized at ${n.configPath} — this project adds @cloudflare/vite-plugin itself (\`cloudflare: false\`), so pass that path as its \`configPath\` to use them.`));return}const a=e;i!==void 0&&a.configPath===i&&delete a.configPath;const r=m(e,n);r.configPath!==void 0&&a.configPath===void 0?(a.configPath=r.configPath,i=r.configPath):n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(c(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings"}};export{u as planViteRemoteBindings,p as remoteBindingsPlugin,m as withRemoteBindings};
@@ -0,0 +1 @@
1
+ import{spawnSync as a}from"node:child_process";import{lunoraLine as s}from"@lunora/config";import{assertWranglerSatisfiesSchema as i,findWranglerFile as c,readWranglerJsonc as l}from"@lunora/config/cloudflare";const f=r=>r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"),d=()=>{try{return a("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},g=(r,n=d)=>{const{parsed:e}=l(r);!(e?.containers??[]).some(t=>typeof t?.image=="string"&&f(t.image))||n()||console.warn(s("wrangler.jsonc declares containers built from a local Dockerfile, but no Docker-compatible engine is running. Start Docker (or Colima) before `vite dev`, or the container instances will fail to start."))},p=r=>{let n=!1;return{config(e,o){n=o.isPreview===!0},configResolved(){if(n)return;i(r,o=>{console.warn(o)},"Update your wrangler.jsonc and restart the dev server.");const e=c(r.projectRoot);e!==void 0&&g(e)},enforce:"pre",name:"lunora:wrangler-validator"}};export{g as warnWhenDockerMissing,p as wranglerValidatorPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.277",
3
+ "version": "1.0.0-alpha.278",
4
4
  "description": "The Lunora Vite plugin: codegen, type sync, wrangler validation, and an error overlay over @cloudflare/vite-plugin",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@cloudflare/vite-plugin": "1.54.4",
49
- "@lunora/codegen": "1.0.0-alpha.235",
50
- "@lunora/config": "1.0.0-alpha.279",
49
+ "@lunora/codegen": "1.0.0-alpha.236",
50
+ "@lunora/config": "1.0.0-alpha.280",
51
51
  "@lunora/errors": "1.0.0-alpha.47",
52
52
  "@visulima/vite-overlay": "2.0.20"
53
53
  },
@@ -1 +0,0 @@
1
- import{l as a}from"./log-DE48L4Oz.mjs";const c=["/_lunora"],u="/_lunora/ws",h=e=>{if(e.startsWith("^"))try{return new RegExp(e,"u").test(u)}catch{return!1}return c.some(r=>e.startsWith(r)||r.startsWith(e))},i=(e,r)=>{if(!e)return[];const t=[];for(const[s,o]of Object.entries(e)){if(!h(s))continue;if(typeof o=="string"){t.push(`${r}.proxy["${s}"] uses the string shorthand, which does not proxy WebSocket upgrades. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work. Use the object form: { target: "${o}", ws: true }.`);continue}if(typeof o!="object"||o===null)continue;const n=o;n.ws!==!0&&t.push(`${r}.proxy["${s}"] is missing \`ws: true\`, so WebSocket upgrades are not proxied. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work.`),n.changeOrigin===!0&&t.push(`${r}.proxy["${s}"] sets \`changeOrigin: true\`, so the worker sees a different origin than the browser sends. Loopback-to-loopback is trusted by default; for any other dev host add the dev-server origin to the worker's \`security.csrf.trustedOrigins\` or the cookie-bearing WebSocket upgrade is rejected with FORBIDDEN_ORIGIN.`)}return t},g=()=>({apply:"serve",configResolved(e){const r=[...i(e.server.proxy,"server"),...i(e.preview.proxy,"preview")];for(const t of r)e.logger.warn(a(t))},name:"lunora:proxy-check"});export{i as checkLunoraProxy,g as proxyCheckPlugin};
@@ -1,3 +0,0 @@
1
- import{readFileSync as V,existsSync as W}from"node:fs";import{join as J,resolve as w,sep as E,basename as Q}from"node:path";import{findProjectConfigFile as Y,listLunoraSourceFiles as Z,PROJECT_CONFIG_FILENAMES as ee,findTsconfig as ne,runCodegen as re,describeErrorLevelFindings as te,createCodegenProject as oe,refreshCodegenProject as ie,CodegenDiagnosticError as ae}from"@lunora/codegen";import{inferLunoraBindings as ce,isCodegenDisabled as se,CODEGEN_ENV as F,runPostCodegenHook as A}from"@lunora/config";import{findWranglerFile as de,readWranglerJsonc as le,reconcileWranglerBindings as fe,reconcileWranglerCrons as ge,describePreservedCrons as ue,reconcileWranglerCompatibilityDate as he,WRANGLER_FILES as me,collectWranglerSecretVariables as pe}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as we}from"vite";import{createHash as H}from"node:crypto";import ye from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{L as l,a as L}from"./log-DE48L4Oz.mjs";import{r as $e,a as ve}from"./server-close-Qoh4i6Ay.mjs";const Se=(e,r)=>{try{const{parsed:t,text:n}=le(e);return t===void 0?`raw:${n}`:JSON.stringify(r?r(t):t)}catch{return"unreadable"}},be=e=>{const r={...e},{triggers:t}=r;if(t!==null&&typeof t=="object"){const n={...t};delete n.crons,Object.keys(n).length>0?r.triggers=n:delete r.triggers}return r},N=e=>{const r=de(e),t=r===void 0?"absent":Se(r,be),n=Y(e);let o="absent";try{n!==void 0&&(o=H("sha256").update(V(n)).digest("hex"))}catch{}return`${t}\0${o}`},Ee=async(e,r,t)=>{try{const n=await ce({projectRoot:e.projectRoot,schemaDir:e.schemaDir}),o=fe(e.projectRoot,n),a=o.wranglerPath??"wrangler.jsonc";o.added.length>0&&r.info?.(`${l} inferred bindings → ${o.added.join(", ")} (written to ${a})`),o.updated.length>0&&r.info?.(`${l} updated bindings → ${o.updated.join(", ")} (written to ${a})`);for(const c of o.warnings)r.warn(`${l} ${c}`);o.exportGaps.length>0&&t?.(o.exportGaps)}catch(n){const o=n instanceof Error?n.message:String(n);r.warn(`${l} binding inference skipped: ${o}`)}},G=new Map,Re=(e,r,t)=>{try{const n=ge(e,r);n.changed&&t.info?.(`${l} synced ${r.length.toFixed(0)} cron trigger(s) into ${n.wranglerPath??"wrangler.jsonc"}`);for(const c of n.warnings)t.warn(`${l} ${c}`);const o=n.preserved.join("\0"),a=ue(n.preserved);a!==void 0&&(n.changed||G.get(e)!==o)&&t.info?.(`${l} ${a}`),G.set(e,o)}catch(n){const o=n instanceof Error?n.message:String(n);t.warn(`${l} cron trigger sync skipped: ${o}`)}try{const n=he(e);n.changed&&t.info?.(`${l} bumped compatibility_date to ${n.date??"unknown"} (Workers Cache enabled) → ${n.wranglerPath??"wrangler.jsonc"}`)}catch(n){const o=n instanceof Error?n.message:String(n);t.warn(`${l} compatibility date sync skipped: ${o}`)}},ke=100,z=300,I=2,je=e=>{let r,t,n=0;const o=()=>{r&&(clearTimeout(r),r=void 0)},a=(g,u)=>{t&&clearTimeout(t),t=setTimeout(()=>{if(t=void 0,e.fingerprint()!==g){if(n+=1,n>I){e.logger.warn(`${l} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(I)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${l} schema changed while \`postcodegen\` was running — regenerating`),u()}},z)},c=g=>{e.regenerate(g,u=>{a(u,()=>{c(g)})})};return{cancelPending:o,dispose:()=>{o(),t&&(clearTimeout(t),t=void 0)},onSave:g=>{o(),n=0,r=setTimeout(()=>{r=void 0,c(g)},ke)}}},B=e=>{if(!W(e))return"unreadable";const r=Z(e),t=J(e,"schema.ts");W(t)&&r.push(t);const n=H("sha256");for(const o of r.toSorted((a,c)=>a.localeCompare(c)))try{n.update(o).update("\0").update(V(o))}catch{}return n.digest("hex")},U=/[/\\]tsconfig\..+\.json$/u,Ce=e=>{const r=e.map(n=>` • ${n.kind} "${n.exportName}" — class ${n.className} is not exported by your worker entry.`),t=[...new Set(e.map(n=>n.module))].map(n=>` export * from "./lunora/_generated/${n}";`);return[`[lunora] ${String(e.length)} declared ${e.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...r,"","Add to your worker entry:",...t].join(`
2
- `)},De=e=>{const{advisoryNames:r,platformDiagnosticNames:t}=te(e),n=[...new Set([...r,...t])].toSorted((a,c)=>a.localeCompare(c));if(n.length===0)return;const o=n.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${l} ${String(n.length)} ERROR-level ${o} (${n.join(", ")}) — see the log above for detail.`},Pe=(e,r,t)=>{if(r.warn(`${l} schema.ts not found at ${e} — codegen skipped`),t!==void 0){const n=`schema.ts not found at ${e} — generated output is now stale`;t.onError(new Error(n),n)}},O=(e,r,t,n)=>{const o=J(e.projectRoot,e.schemaDir,"schema.ts");if(!W(o))return Pe(o,r,t),{};try{const a=re({apiSpec:e.apiSpec,lunoraDirectory:e.schemaDir,project:n,projectRoot:e.projectRoot,target:e.target,wranglerVariables:pe(e.projectRoot)});Re(e.projectRoot,a.cronTriggers,r);for(const c of a.advisories){const g=L(c.level,c.name,c.detail,c.remediation);c.level==="ERROR"?r.error(g):r.warn(g)}for(const c of a.platformDiagnostics){const g=L(c.level==="error"?"ERROR":"WARN",c.name,c.message,c.remediation);c.level==="error"?r.error(g):r.warn(g)}return{blockingMessage:De(a),outputDirectory:w(a.outputDirectory)}}catch(a){const c=a instanceof Error?a.message:String(a);return r.error(`${l} codegen failed: ${c}`),t?.onError(a,c),{failure:`${l} codegen failed: ${c}`}}},_e=(e,r,t)=>{let n;for(const[o,a]of Object.entries(e.environments)){if(o==="client"){n=a;continue}we(a)||a.hot.send({path:"*",triggeredBy:r,type:"full-reload"})}if(n===void 0){e.hot.send({type:"full-reload"});return}if(t){n.hot.send({type:"full-reload"});return}n.hot.send({event:ye,type:"custom"})},k={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},Ie=e=>{const r=w(e.projectRoot,e.schemaDir),t=se(process.env[F]);let n=w(e.projectRoot,e.generatedDir),o=0,a=!1,c;const g=new Map;let u,j=!1,C=!1,y,D;return{config(s,m){y=m.command},configResolved(){y!=="build"&&t||(D=O(e,k))},async buildStart(){const s=y!=="build"&&t,{blockingMessage:m,failure:$,outputDirectory:R}=D??(s?{}:O(e,k));if(D=void 0,y==="build"&&$!==void 0&&this.error($),R!==void 0){n=R,a=!0;let h;try{h=await A({cwd:e.projectRoot,logger:k})}finally{a=!1}h.ran&&(o=Date.now()),y==="build"&&h.error!==void 0&&this.error(h.error)}y==="build"&&m!==void 0&&this.error(m),await Ee(e,k,h=>{c?.hot.send({err:{loc:void 0,message:Ce(h),stack:""},type:"error"})}),c!==void 0&&(u=N(e.projectRoot),j=!0)},configureServer(s){c=s,s.watcher.add(r),u=N(e.projectRoot),j=!1;const m={error:i=>{s.config.logger.error(i)},info:i=>{s.config.logger.info(i)},warn:i=>{s.config.logger.warn(i)}};let $=!1;const R={onError(i,d){$=!0;const f=i instanceof ae?{column:i.column,file:i.file,line:i.line}:void 0,b=f===void 0?`[lunora] codegen failed: ${d}
3
- (see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${d}`;c?.hot.send({err:{loc:f,message:b,stack:i instanceof Error?i.stack??"":""},type:"error"})}},h=(i,d)=>i===d||i.startsWith(d+E);let P=!1,p;const K=()=>{for(const i of Object.values(s.environments)){const d=i.moduleGraph;for(const f of d.idToModuleMap.values())f.id&&h(f.id,n)&&d.invalidateModule(f)}},X=async(i,d)=>{try{if(P)return;p===void 0?p=oe(r):ie(p,r);const{outputDirectory:f}=O(e,m,R,p);if(f===void 0){p=void 0;return}n=f;const b=B(r);a=!0;let T;try{T=await A({cwd:e.projectRoot,logger:m})}finally{a=!1}if(T.ran&&(o=Date.now(),d(b)),T.error!==void 0)return;K(),_e(s,i,$),$=!1}catch(f){m.error(`${l} codegen watch: ${f instanceof Error?f.message:String(f)}`)}},_=je({fingerprint:()=>B(r),logger:m,regenerate:(i,d)=>{X(i,d)}}),v=i=>{const d=w(i);if(U.test(d)){p=void 0;return}if(d.endsWith(`${E}tsconfig.json`)&&d===ne(r)){p=void 0;return}if(h(d,r)&&!h(d,n)&&d.endsWith(".ts")&&!(d.includes(`${E}__tests__${E}`)||d.endsWith(".test.ts")||d.endsWith(".spec.ts"))){if(a||Date.now()-o<z){_.cancelPending();return}_.onSave(d)}},x=i=>{const d=w(i);(d.endsWith(`${E}tsconfig.json`)||U.test(d))&&(p=void 0)};t?s.config.logger.info(`${l} codegen watch disabled (${F}) — _generated/ is written only by an explicit \`lunora codegen\``):(s.watcher.on("add",v),s.watcher.on("change",v),s.watcher.on("unlink",v),s.watcher.on("unlink",x));const M=new Set([...me.map(i=>w(e.projectRoot,i)),...ee.map(i=>w(e.projectRoot,i))]);for(const i of M)s.watcher.add(i);const S=i=>{if(!M.has(w(i))||C)return;const d=N(e.projectRoot);if(!j){u=d;return}if(u===void 0){u=d;return}d!==u&&(u=d,C=!0,s.config.logger.info(`${l} ${Q(w(i))} changed — restarting dev server`),Promise.resolve(s.restart()).finally(()=>{C=!1}).catch(f=>{const b=f instanceof Error?f.message:String(f);s.config.logger.error(`${l} dev server restart failed: ${b} — keeping the running server; re-save your config to retry.`),s.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${b}`,stack:""},type:"error"})}))};s.watcher.on("add",S),s.watcher.on("change",S),s.watcher.on("unlink",S);const q=()=>{P||(P=!0,p=void 0,_.dispose(),s.watcher.off("add",v),s.watcher.off("change",v),s.watcher.off("unlink",v),s.watcher.off("unlink",x),s.watcher.off("add",S),s.watcher.off("change",S),s.watcher.off("unlink",S))};return()=>{ve(s,g,q)}},buildEnd(){$e(g,this.environment)},name:"lunora:codegen"}};export{Ie as c,Ee as r};
@@ -1 +0,0 @@
1
- import{c as i}from"./codegen-plugin-BqoP2XfZ.mjs";import"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import"./log-DE48L4Oz.mjs";import"./server-close-Qoh4i6Ay.mjs";export{i as default};
@@ -1 +0,0 @@
1
- import{discoverContainerInfo as l,streamContainerLogs as m}from"@lunora/config";import{l as i}from"./log-DE48L4Oz.mjs";const p=r=>{let n;const a=()=>{n?.close(),n=void 0};return{apply:"serve",buildEnd(){a()},configureServer(t){if(n||process.env.LUNORA_CONTAINER_LOGS==="0")return;const c=l(r.projectRoot,r.schemaDir).containers.map(e=>({className:e.className,exportName:e.exportName}));if(c.length===0)return;const{logger:o}=t.config;n=m({containers:c,onLine:e=>{const s=i(`container:${e.name} ${e.text}`);e.level==="error"?o.warn(s):o.info(s)},onUnavailable:e=>{o.warn(i(`container: Docker engine unreachable — container logs unavailable (${e})`))}}),t.httpServer?.once("close",a)},name:"lunora:container-logs"}};export{p as default};
@@ -1 +0,0 @@
1
- import{DEV_HANDOFF_ENV as d,claimDevServerState as c,DEV_LOG_FILE_ENV as p,DEV_DAEMON_ENV as u,clearDevServerState as f}from"@lunora/config";import{l as v}from"./log-DE48L4Oz.mjs";import{r as g,a as S}from"./server-close-Qoh4i6Ay.mjs";const m=/\/$/,D=o=>{const r=o.resolvedUrls?.local[0];if(r!==void 0)return r.replace(m,"");const t=o.httpServer?.address();if(t!==null&&typeof t=="object")return`http://localhost:${String(t.port)}`},O=o=>{let r=!1;const t=new Map;return{apply:"serve",configureServer(e){const l=o.projectRoot,a=()=>{if(r)return;const n=D(e);if(n===void 0)return;const s=Number(process.env[d]),i=c(l,{background:process.env[u]==="1",logFile:process.env[p],mode:"vite",pid:process.pid,readyAt:new Date().toISOString(),startedAt:new Date().toISOString(),url:n},Number.isInteger(s)&&s>0?{supersedePid:s}:void 0);if(!i.ok){i.existing!==void 0&&e.config.logger.warn(v(`another dev server is already recorded at ${i.existing.url} (pid ${String(i.existing.pid)}) — leaving .lunora/dev.json untouched`));return}r=!0};return S(e,t,()=>{r&&(f(l,process.pid),r=!1)}),()=>{if(typeof e.printUrls=="function"){const n=e.printUrls.bind(e);e.printUrls=()=>{n(),a()}}e.httpServer?.once("listening",()=>{setTimeout(a,0)})}},buildEnd(){g(t,this.environment)},name:"lunora:dev-state"}};export{O as default};
@@ -1 +0,0 @@
1
- import{readFileSync as l}from"node:fs";import{join as c}from"node:path";import{ensureDevVariables as f,createConfirm as v,fillDevSecrets as m,DEV_VARS_FILE as i,parseDevVariableEntries as u,writeDevVariablesFileAtomically as d,upsertDevVariableLine as p}from"@lunora/config";import{findWranglerFile as V,readWranglerJsonc as E}from"@lunora/config/cloudflare";import{l as R}from"./log-DE48L4Oz.mjs";const t="WORKER_ENV",a="development",_=e=>{const r=V(e);return r===void 0?{}:E(r).parsed?.vars??{}},w=(e,r)=>{const n=c(e,i);let o;try{o=l(n,"utf8")}catch{return}u(o).some(s=>s.key===t)||t in _(e)||(d(n,p(o,t,a)),r(`set ${t}=${a} in ${i} so the dev worker runs in development mode`))},h=e=>{let r=!1;return{apply:"serve",config(n,o){r=o.isPreview===!0},async configResolved(){if(r)return;const n=o=>{console.info(R(o))};await f({confirm:v("[lunora] "),cwd:e.projectRoot,info:n}),m({cwd:e.projectRoot,info:n}),w(e.projectRoot,n)},enforce:"pre",name:"lunora:dev-vars"}};export{h as default};
@@ -1 +0,0 @@
1
- import{paintBadge as a,BADGES as o}from"@lunora/config";const i=a(o.lunora),$=n=>`${i} ${n}`,A={ERROR:o.error,INFO:o.info,WARN:o.warn},e=(n,r,s,t)=>`${a(A[n])} ${r}: ${s} — ${t}`;export{i as L,e as a,$ as l};
@@ -1 +0,0 @@
1
- import{readProjectRemotePreference as d}from"@lunora/config";import{resolveRemoteEnabled as s,materializeRemoteWranglerConfig as g}from"@lunora/config/cloudflare";import{l as c}from"./log-DE48L4Oz.mjs";const l=()=>{},u=e=>{const t=e.readPreference??d;if(!s({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1};const o=(e.materialize??g)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:o.cleanup,configPath:o.configPath,enabled:!0,reason:o.reason}},m=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},v=(e,t)=>{let n={cleanup:l,enabled:!1},i;const o=()=>{n.cleanup()};return{buildEnd:o,closeBundle:o,config(P,f){if(f.command!=="serve")return;if(n.cleanup(),n=u(t),e===void 0){n.enabled&&n.configPath!==void 0&&console.info(c(`remote bindings are materialized at ${n.configPath} — this project adds @cloudflare/vite-plugin itself (\`cloudflare: false\`), so pass that path as its \`configPath\` to use them.`));return}const r=e;i!==void 0&&r.configPath===i&&delete r.configPath;const a=m(e,n);a.configPath!==void 0&&r.configPath===void 0?(r.configPath=a.configPath,i=a.configPath):n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(c(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings"}};export{u as planViteRemoteBindings,v as remoteBindingsPlugin,m as withRemoteBindings};
@@ -1,3 +0,0 @@
1
- import{spawnSync as i}from"node:child_process";import{validateWranglerProject as s,readWranglerJsonc as c}from"@lunora/config/cloudflare";import{LunoraError as l}from"@lunora/errors";import{l as a}from"./log-DE48L4Oz.mjs";const g=r=>r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"),f=()=>{try{return i("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},u=(r,n=f)=>{const{parsed:e}=c(r);!(e?.containers??[]).some(t=>typeof t?.image=="string"&&g(t.image))||n()||console.warn(a("wrangler.jsonc declares containers built from a local Dockerfile, but no Docker-compatible engine is running. Start Docker (or Colima) before `vite dev`, or the container instances will fail to start."))},d=(r,n)=>{const e=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...n.map(o=>` - ${o}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(e.join(`
2
- `))},b=r=>{let n=!1;return{config(e,o){n=o.isPreview===!0},configResolved(){if(n)return;const e=s({projectRoot:r.projectRoot,schemaDir:r.schemaDir});if(!e.wranglerPath)throw new l("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${r.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
3
- `));for(const o of e.report.warnings)console.warn(a(`wrangler validator: ${o}`));if(e.problems.length>0)throw d(e.wranglerPath,e.problems);u(e.wranglerPath)},enforce:"pre",name:"lunora:wrangler-validator"}};export{u as warnWhenDockerMissing,b as wranglerValidatorPlugin};