@lunora/vite 1.0.0-alpha.366 → 1.0.0-alpha.367
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/README.md +2 -0
- package/dist/index.mjs +4 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -81,6 +81,8 @@ lunora({
|
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
`target` must match the target the CLI resolved for the run. `lunora build` and `lunora deploy` set `LUNORA_BUILD_TARGET`, and a plugin whose target differs fails the build rather than emit an artifact for another host. Set the same target in the plugin options and `lunora.config.*`, or leave it unset to use the project's.
|
|
85
|
+
|
|
84
86
|
`LUNORA_LAZY_FUNCTIONS=1` or `true` enables lazy imports even when
|
|
85
87
|
`lazyFunctions` is `false`, for both dev and production builds.
|
|
86
88
|
`lunora dev --lazy-functions` sets this variable for its bundler child process.
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
${
|
|
3
|
-
`)}},name:"lunora:agent-rules-hint"}),
|
|
1
|
+
import{createRequire as $}from"node:module";import{sep as O,resolve as h,dirname as B,isAbsolute as I,relative as M}from"node:path";import{cloudflare as N}from"@cloudflare/vite-plugin";import{BUNDLE_META_PATH_ENV as U,canonicalPath as k,DEFAULT_BUNDLE_META_PATH as F,resolveDeployDriver as H,startCelldDevSession as j,formatLunoraEvent as V,lunoraLine as G,detectFramework as z,targetRunsOwnDevServer as K,resolveLazyFunctions as q,resolveTargetOrThrow as J,isRunnableTarget as Q,runnableTargetIds as Y,assertBuildTargetMatches as X}from"@lunora/config";import{GENERATED_CLASS_MODULES as Er,detectFramework as Tr}from"@lunora/config";import Z from"@visulima/vite-overlay";import{detectAgentRules as ee,claimAgentRulesHint as re,lunoraLine as m,AGENT_RULES_HINT as te}from"@lunora/config/cli";import{reconcileBindingsSafely as oe,findWranglerFile as ne,readWranglerJsonc as ie,warnCloudflareCliConfigOnce as se,hasCloudflareCredentials as ae,withheldBindings as le,describeWithheld as ce,startLocalHyperdrive as ue}from"@lunora/config/cloudflare";import{reconcileWranglerCrons as Cr}from"@lunora/config/cloudflare";import{mkdirSync as de,writeFileSync as fe,statSync as pe,rmSync as me}from"node:fs";import{r as L,a as D}from"./packem_shared/server-close-DWiO4Vxb.mjs";import ge from"./packem_shared/codegenPlugin-D699-5tq.mjs";import ve from"./packem_shared/containerLogsPlugin-BCqWF6EU.mjs";import he from"./packem_shared/devStatePlugin-CF4GDvBn.mjs";import we from"./packem_shared/devVariablesPlugin-DbD6cSF0.mjs";import{frameworkComposePlugin as ye}from"./packem_shared/CLASS_A_WIRING-DCI5QzA9.mjs";import{CLASS_A_WIRING as Or,LUNORA_WORKER_VIRTUAL_ID as Lr,buildWorkerEntrySource as Dr,isAutoComposable as Wr}from"./packem_shared/CLASS_A_WIRING-DCI5QzA9.mjs";import Se from"./packem_shared/logStreamPlugin-EMXiy6pI.mjs";import{proxyCheckPlugin as Pe}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{checkLunoraProxy as Br}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{remoteBindingsPlugin as be}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{planViteRemoteBindings as Mr,withRemoteBindings as Nr}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{readServiceBindings as ke}from"@lunora/codegen";import{lunoraSolutionFinders as Ae}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Fr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as Re}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{buildStudioUrl as jr}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{withWorkerStartupHint as Ee}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Gr,augmentWorkerStartupError as zr,isWorkerEntryEvalError as Kr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as Te}from"./packem_shared/wranglerValidatorPlugin-BlGHjTXZ.mjs";import{default as Jr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{STUDIO_PATH as Yr}from"@lunora/config/studio-host";const _e=r=>({apply:"serve",configureServer(e){return()=>{ee(r.projectRoot).installed||!re()||e.config.logger.warn(`
|
|
2
|
+
${m(te)}
|
|
3
|
+
`)}},name:"lunora:agent-rules-hint"}),Ce=r=>({async config(e,t){t.isPreview!==!0&&await oe(r,{info:o=>{console.info(o)},warn:o=>{console.warn(o)}})},enforce:"pre",name:"lunora:bindings-provision"}),xe=(r,e=O)=>r.split(e).join("/"),b=(r,e)=>I(e)?xe(M(r,e)):e,w=(r,e,t)=>e.map(o=>({kind:t,path:b(r,o)})),Oe=/[?#]/,A=r=>{try{return pe(r).size}catch{return}},Le=(r,e)=>A(r)??A(r.split(Oe)[0]??r)??Buffer.byteLength(e??""),De=r=>{let e;return{apply:"build",applyToEnvironment:t=>t.config.consumer==="server",name:"lunora:bundle-meta",sharedDuringBuild:!0,generateBundle(t,o){const n={},i={};for(const[u,d]of Object.entries(o)){if(d.type!=="chunk")continue;const f={bytes:Buffer.byteLength(d.code),imports:[...w(r,d.imports,"import-statement"),...w(r,d.dynamicImports,"dynamic-import")],inputs:{}};d.facadeModuleId&&(f.entryPoint=b(r,d.facadeModuleId));for(const[g,y]of Object.entries(d.modules)){const p=b(r,g);if(f.inputs[p]={bytesInOutput:Buffer.byteLength(y.code??"")},!n[p]){const S=this.getModuleInfo(g);n[p]={bytes:Le(g,S?.code),imports:[...w(r,S?.importedIds??[],"import-statement"),...w(r,S?.dynamicallyImportedIds??[],"dynamic-import")]}}}i[u]=f}const a=process.env[U],s=a===void 0||a===""?void 0:h(r,a),l=`${k(h(r,".lunora"))}${O}`,c=s!==void 0&&k(s).startsWith(l)?s:h(r,F);if(e!==void 0&&e!==this.environment.name){me(c,{force:!0}),this.warn(`bundle-meta: environment "${this.environment.name}" built a server bundle after "${e}" wrote one; no bundle-meta.json is written, because the app's own graph cannot be told apart from a service's`);return}e=this.environment.name,de(B(c),{recursive:!0}),fe(c,`${JSON.stringify({inputs:n,outputs:i},void 0,2)}
|
|
4
|
+
`,"utf8")}}},R="/_lunora",We=8787,v=new Map,W=r=>r.command==="serve"&&r.isPreview!==!0,$e=(r,e)=>{let t;return()=>{if(t===void 0)try{H(e).projectConfig?.(r,"dev"),t={runs:!0}}catch(o){t={reason:o instanceof Error?o.message:String(o),runs:!1}}return t}},Be=r=>{const e=ne(r),t=e===void 0?void 0:ie(e).parsed?.dev?.port;return typeof t=="number"?t:We},Ie=(r,e)=>r.map(t=>{const o=t.apply;return{...t,apply:(n,i)=>W(i)&&e()?!1:typeof o=="function"?o(n,i):o===void 0||o===i.command}}),Me=(r,e,{stream:t,tag:o})=>{const n=V(e);n!==void 0?r[n.level](`[lunora] ${n.text}`):t==="stderr"?r.warn(`[${o}] ${e}`):r.info(`[${o}] ${e}`)},Ne=(r,e)=>{const t=Be(r),o=new Map;return{apply:(n,i)=>W(i)&&e(),buildEnd(){D(o,this.environment)},config:n=>{if(n.server?.proxy?.[R]===void 0)return{server:{proxy:{[R]:{changeOrigin:!0,target:`http://127.0.0.1:${String(t)}`,ws:!0}}}}},async configureServer(n){const{logger:i}=n.config;await v.get(r)?.stop(),v.delete(r),i.info(`[lunora] starting the worker on celld at http://127.0.0.1:${String(t)} …`);const a=await j({log:(l,c)=>{Me(i,l,c)},port:t,projectRoot:r});v.set(r,a);const s=l=>{i.error(`[lunora] the worker on celld exited (code ${String(l)}) — restart vite dev to bring it back`)};a.exited.then(s).catch(()=>{}),L(n,o,()=>{v.get(r)===a&&v.delete(r),a.stop().catch(l=>{i.error(`[lunora] stopping celld failed: ${l instanceof Error?l.message:String(l)}`)})})},name:"lunora:celld-dev"}},Ue=r=>({configResolved(e){se(r.projectRoot,t=>{e.logger.warn(G(t))})},name:"lunora:cf-config-warning"}),Fe=()=>({}),He={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)"},je=r=>{const e=He[r.framework];return r.framework==="none"?m("no meta-framework detected — running standalone."):r.class==="B"?m(`detected ${e} — composition is handled by the framework adapter.`):m(`detected ${e} — composing the Lunora worker into one Cloudflare Worker.`)},Ve=(r,e)=>{let t=!1;const o=()=>{e.framework??=z(r.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&e.framework!==void 0&&(t=!0,console.info(je(e.framework)))},name:"lunora:framework-detect"}},E=r=>Array.isArray(r)?r:[],P=new WeakSet,Ge=(r,e={})=>{let t=!1;const o=r.experimental?.newConfig,n=o!==void 0&&o!==!1,i=e.hasCredentials??(()=>ae({projectRoot:e.projectRoot})),a=s=>{const l=(c,...u)=>{const d=typeof s=="function"?s(c,...u):s,f=d===void 0?void 0:{...d},g=t?[...E(c.artifacts),...E(f?.artifacts)]:[],y=t?le({ai:c.ai??f?.ai,artifacts:g},i):[];for(const p of y)Reflect.deleteProperty(c,p.kind),Reflect.deleteProperty(f??{},p.kind),console.warn(m(ce(p)));return f};return P.add(l),l};return{config(s,l){if(t=l.command==="serve"&&l.isPreview!==!0,n)return;const c=r;P.has(c.config)||(c.config=a(c.config)),Array.isArray(c.auxiliaryWorkers)&&(c.auxiliaryWorkers=c.auxiliaryWorkers.map(u=>P.has(u.config)?u:{...u,config:a(u.config)}))},enforce:"pre",name:"lunora:local-ai-binding"}},ze=5e3,Ke=3e4,T=new Map,_=r=>{const e=T.get(r);if(e!==void 0)return e;const t={databases:[],pending:Promise.resolve(),servers:0,stopping:Promise.resolve()};return T.set(r,t),t},qe=async r=>{const e=r.databases.splice(0);await Promise.allSettled(e.map(async t=>t.stop()))},C=(r,e)=>{const t=setTimeout(()=>{r.pending.then(async()=>{r.servers===0&&(r.stopping=qe(r),await r.stopping)}).catch(()=>{})},e);return t.unref(),t},x=({projectRoot:r,start:e=ue,wranglerConfigPath:t})=>{const o=new Map,n=i=>{const a=_(r);let s=!1;a.servers+=1,clearTimeout(a.stopTimer),i(()=>{s||(s=!0,a.servers-=1,a.servers===0&&(a.stopTimer=C(a,ze)))})};return{async config(i,a){if(a.command!=="serve")return;const s=_(r);clearTimeout(s.stopTimer);const l=s.pending,c=(async()=>{await l,await s.stopping;const u=await e({onWarning:d=>{console.warn(m(d))},projectRoot:r,wranglerConfigPath:t});u!==void 0&&s.databases.push(u),u!==void 0&&u.bindings.length>0&&console.info(m(`Hyperdrive ${u.bindings.join(", ")}: embedded Postgres (PGlite), data in .wrangler/state/lunora-pglite.`))})();s.pending=c.catch(()=>{});try{await c}finally{s.servers===0&&(clearTimeout(s.stopTimer),s.stopTimer=C(s,Ke))}},buildEnd(){D(o,this.environment)},configureServer(i){n(a=>{L(i,o,a)})},configurePreviewServer(i){n(a=>{i.httpServer.once("close",a)})},enforce:"pre",name:"lunora:local-hyperdrive"}},Je=(r,e)=>({config(t,o){if(o.command!=="serve")return;const{services:n}=ke(e),i=Array.isArray(r.auxiliaryWorkers)?r.auxiliaryWorkers:[],a=new Set(i.map(l=>l.configPath===void 0?"":h(e,l.configPath))),s=[...new Set(n.map(l=>l.wranglerPath))].filter(l=>!a.has(l)).map(l=>({configPath:l}));s.length>0&&(r.auxiliaryWorkers=[...i,...s])},enforce:"pre",name:"lunora:service-workers"}),Qe=r=>{if(r===!1)return!1;const e=r===!0||r===void 0?{}:r;return{...e,forwardedConsoleMethods:e.forwardedConsoleMethods??["error","warn"],solutionFinders:[...Ae,...e.solutionFinders??[]]}},Ye=(r,e)=>{const t=J(r,e);if(!Q(t)){const o=Y();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: ${o.join(", ")}`)}return X(t,r),t},Xe=r=>{const e=r??{},t=e.schemaDir??"lunora";let o;e.cloudflare===!1?o=!1:e.cloudflare===!0||e.cloudflare===void 0?o={}:o=e.cloudflare;const n=e.projectRoot??process.cwd(),i=Ye(n,e.target);return{allowUnauthenticatedShardAccess:e.allowUnauthenticatedShardAccess??!1,apiSpec:e.apiSpec??"openapi",lazyFunctions:q(e.lazyFunctions),cloudflare:o,studio:e.studio??!0,generatedDir:`${t}/_generated`,overlay:Qe(e.overlay),projectRoot:n,schemaDir:t,shard:e.shard??{},target:i,validateWrangler:e.validateWrangler??!0}},Ze=(r,e)=>{const{configPath:t}=r;return typeof t=="string"&&t!==""?h(e,t):void 0},br=r=>{const e=Xe(r),t=Fe(),o=[Ve(e,t),ye(e,t),we(e),Ce(e),ge(e),De(e.projectRoot),Se(),he(e),_e(e),Ue(e),Pe()];e.studio&&o.push(Re(e)),e.validateWrangler&&o.push(Te(e)),e.overlay!==!1&&o.push(Z(e.overlay)),o.push(ve(e));const n=e.cloudflare===!1?void 0:{...e.cloudflare};if(o.push(be(n,{projectRoot:e.projectRoot})),n===void 0&&o.push(x({projectRoot:e.projectRoot})),n!==void 0){o.push(Je(n,e.projectRoot));const i=K(e.target),a=$e(e.projectRoot,e.target),s=()=>i&&a().runs;o.push(...Ie([x({projectRoot:e.projectRoot,wranglerConfigPath:Ze(n,e.projectRoot)}),Ge(n,{projectRoot:e.projectRoot}),...Ee(N(n))],s)),i&&o.push(Ne(e.projectRoot,s),{apply:(l,c)=>c.command==="serve"&&c.isPreview!==!0&&!s(),configureServer(l){l.config.logger.warn(`[lunora] target "${e.target}": vite dev serves the worker in workerd, not on ${e.target} — ${a().reason??"it cannot run this project"}. \`vite build\` then \`lunora deploy\` ships it to ${e.target}.`)},name:"lunora:target-runtime-notice"})}return o},kr=$(import.meta.url)("../package.json").version;export{Or as CLASS_A_WIRING,Er as GENERATED_CLASS_MODULES,Jr as LUNORA_API_UPDATED_EVENT,Lr as LUNORA_WORKER_VIRTUAL_ID,Yr as STUDIO_PATH,kr as VERSION,Gr as WORKER_STARTUP_HINT,zr as augmentWorkerStartupError,jr as buildStudioUrl,Dr as buildWorkerEntrySource,Br as checkLunoraProxy,ge as codegenPlugin,ve as containerLogsPlugin,Tr as detectFramework,he as devStatePlugin,we as devVariablesPlugin,ye as frameworkComposePlugin,Wr as isAutoComposable,Kr as isWorkerEntryEvalError,Se as logStreamPlugin,br as lunora,Fr as lunoraSolutionFinder,Ae as lunoraSolutionFinders,Mr as planViteRemoteBindings,Pe as proxyCheckPlugin,Cr as reconcileWranglerCrons,be as remoteBindingsPlugin,Qe as resolveOverlayOption,Re as studioPlugin,Nr as withRemoteBindings,Ee as withWorkerStartupHint,Te as wranglerValidatorPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vite",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.367",
|
|
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.63.1",
|
|
49
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
50
|
-
"@lunora/config": "1.0.0-alpha.
|
|
49
|
+
"@lunora/codegen": "1.0.0-alpha.342",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.393",
|
|
51
51
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
52
52
|
"@visulima/vite-overlay": "2.0.41"
|
|
53
53
|
},
|