@lunora/vite 1.0.0-alpha.424 → 1.0.0-alpha.426
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.mjs +4 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as $}from"node:module";import{sep as
|
|
2
|
-
${m(
|
|
3
|
-
`)}},name:"lunora:agent-rules-hint"}),Oe=(r,e)=>({async config(t,o){if(e?.clear(),o.isPreview===!0)return;const n=async()=>
|
|
4
|
-
`,"utf8")}}},
|
|
1
|
+
import{createRequire as $}from"node:module";import{sep as D,resolve as h,dirname as B,isAbsolute as F,relative as I}from"node:path";import{cloudflare as M}from"@cloudflare/vite-plugin";import{BUNDLE_META_PATH_ENV as N,canonicalPath as k,DEFAULT_BUNDLE_META_PATH as U,resolveDeployDriver as H,startCelldDevSession as j,formatLunoraEvent as V,lunoraLine as z,detectFramework as G,resolveSchemaDirectory as K,createDiscoveryCache as q,targetRunsOwnDevServer as J,resolveLazyFunctions as Q,resolveTargetOrThrow as Y,isRunnableTarget as X,runnableTargetIds as Z,assertBuildTargetMatches as ee}from"@lunora/config";import{GENERATED_CLASS_MODULES as xr,detectFramework as Dr}from"@lunora/config";import re from"@visulima/vite-overlay";import{detectAgentRules as te,claimAgentRulesHint as oe,lunoraLine as m,AGENT_RULES_HINT as ne}from"@lunora/config/cli";import{reconcileBindingsSafely as ie,findWranglerFile as se,readWranglerJsonc as ae,warnCloudflareCliConfigOnce as ce,hasCloudflareCredentials as le,withheldBindings as ue,describeWithheld as de,startLocalHyperdrive as fe}from"@lunora/config/cloudflare";import{reconcileWranglerCrons as Lr}from"@lunora/config/cloudflare";import{o as pe}from"./packem_shared/build-session-D75JzvIT.mjs";import{mkdirSync as me,writeFileSync as ge,statSync as ve,rmSync as he}from"node:fs";import{r as O,a as L}from"./packem_shared/server-close-DWiO4Vxb.mjs";import we from"./packem_shared/codegenPlugin-2ycHgwJC.mjs";import ye from"./packem_shared/containerLogsPlugin-CWF3LHN3.mjs";import Se from"./packem_shared/devStatePlugin-CF4GDvBn.mjs";import Pe from"./packem_shared/devVariablesPlugin-Bm5X49VR.mjs";import{frameworkComposePlugin as be}from"./packem_shared/CLASS_A_WIRING-CDSSmDqw.mjs";import{CLASS_A_WIRING as $r,LUNORA_WORKER_VIRTUAL_ID as Br,buildWorkerEntrySource as Fr,isAutoComposable as Ir}from"./packem_shared/CLASS_A_WIRING-CDSSmDqw.mjs";import ke from"./packem_shared/logStreamPlugin-EMXiy6pI.mjs";import{proxyCheckPlugin as Ae}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{checkLunoraProxy as Nr}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{remoteBindingsPlugin as Ee}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{planViteRemoteBindings as Hr,withRemoteBindings as jr}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{readDevServiceBindings as Re}from"@lunora/codegen";import{lunoraSolutionFinders as Te}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as zr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _e}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{buildStudioUrl as Kr}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{withWorkerStartupHint as Ce}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Jr,augmentWorkerStartupError as Qr,isWorkerEntryEvalError as Yr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as xe}from"./packem_shared/wranglerValidatorPlugin-CPPKubFC.mjs";import{default as Zr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{STUDIO_PATH as rt}from"@lunora/config/studio-host";const De=r=>({apply:"serve",configureServer(e){return()=>{te(r.projectRoot).installed||!oe()||e.config.logger.warn(`
|
|
2
|
+
${m(ne)}
|
|
3
|
+
`)}},name:"lunora:agent-rules-hint"}),Oe=(r,e)=>({async config(t,o){if(e?.clear(),o.isPreview===!0)return;const n=async()=>ie({...r,cache:e},{info:i=>{console.info(i)},warn:i=>{console.warn(i)}});await(o.command==="build"?pe(r,"provision",n):n())},enforce:"pre",name:"lunora:bindings-provision"}),Le=(r,e=D)=>r.split(e).join("/"),b=(r,e)=>F(e)?Le(I(r,e)):e,w=(r,e,t)=>e.map(o=>({kind:t,path:b(r,o)})),We=/[?#]/,A=r=>{try{return ve(r).size}catch{return}},$e=(r,e)=>A(r)??A(r.split(We)[0]??r)??Buffer.byteLength(e??""),Be=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:$e(g,S?.code),imports:[...w(r,S?.importedIds??[],"import-statement"),...w(r,S?.dynamicallyImportedIds??[],"dynamic-import")]}}}i[u]=f}const a=process.env[N],c=a===void 0||a===""?void 0:h(r,a),s=`${k(h(r,".lunora"))}${D}`,l=c!==void 0&&k(c).startsWith(s)?c:h(r,U);if(e!==void 0&&e!==this.environment.name){he(l,{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,me(B(l),{recursive:!0}),ge(l,`${JSON.stringify({inputs:n,outputs:i},void 0,2)}
|
|
4
|
+
`,"utf8")}}},E="/_lunora",Fe=8787,v=new Map,W=r=>r.command==="serve"&&r.isPreview!==!0,Ie=(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}},Me=r=>{const e=se(r),t=e===void 0?void 0:ae(e).parsed?.dev?.port;return typeof t=="number"?t:Fe},Ne=(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}}),Ue=(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}`)},He=(r,e)=>{const t=Me(r),o=new Map;return{apply:(n,i)=>W(i)&&e(),buildEnd(){L(o,this.environment)},config:n=>{if(n.server?.proxy?.[E]===void 0)return{server:{proxy:{[E]:{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:(s,l)=>{Ue(i,s,l)},port:t,projectRoot:r});v.set(r,a);const c=s=>{i.error(`[lunora] the worker on celld exited (code ${String(s)}) — restart vite dev to bring it back`)};a.exited.then(c).catch(()=>{}),O(n,o,()=>{v.get(r)===a&&v.delete(r),a.stop().catch(s=>{i.error(`[lunora] stopping celld failed: ${s instanceof Error?s.message:String(s)}`)})})},name:"lunora:celld-dev"}},je=r=>({configResolved(e){ce(r.projectRoot,t=>{e.logger.warn(z(t))})},name:"lunora:cf-config-warning"}),Ve=()=>({}),ze={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)"},Ge=r=>{const e=ze[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.`)},Ke=(r,e)=>{let t=!1;const o=()=>{e.framework??=G(r.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&e.framework!==void 0&&(t=!0,console.info(Ge(e.framework)))},name:"lunora:framework-detect"}},R=r=>Array.isArray(r)?r:[],P=new WeakSet,qe=(r,e={})=>{let t=!1;const o=r.experimental?.newConfig,n=o!==void 0&&o!==!1,i=e.hasCredentials??(()=>le({projectRoot:e.projectRoot})),a=c=>{const s=(l,...u)=>{const d=typeof c=="function"?c(l,...u):c,f=d===void 0?void 0:{...d},g=t?[...R(l.artifacts),...R(f?.artifacts)]:[],y=t?ue({ai:l.ai??f?.ai,artifacts:g},i):[];for(const p of y)Reflect.deleteProperty(l,p.kind),Reflect.deleteProperty(f??{},p.kind),console.warn(m(de(p)));return f};return P.add(s),s};return{config(c,s){if(t=s.command==="serve"&&s.isPreview!==!0,n)return;const l=r;P.has(l.config)||(l.config=a(l.config)),Array.isArray(l.auxiliaryWorkers)&&(l.auxiliaryWorkers=l.auxiliaryWorkers.map(u=>P.has(u.config)?u:{...u,config:a(u.config)}))},enforce:"pre",name:"lunora:local-ai-binding"}},Je=5e3,Qe=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},Ye=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=Ye(r),await r.stopping)}).catch(()=>{})},e);return t.unref(),t},x=({projectRoot:r,start:e=fe,wranglerConfigPath:t})=>{const o=new Map,n=i=>{const a=_(r);let c=!1;a.servers+=1,clearTimeout(a.stopTimer),i(()=>{c||(c=!0,a.servers-=1,a.servers===0&&(a.stopTimer=C(a,Je)))})};return{async config(i,a){if(a.command!=="serve")return;const c=_(r);clearTimeout(c.stopTimer);const s=c.pending,l=(async()=>{await s,await c.stopping;const u=await e({onWarning:d=>{console.warn(m(d))},projectRoot:r,wranglerConfigPath:t});u!==void 0&&c.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.`))})();c.pending=l.catch(()=>{});try{await l}finally{c.servers===0&&(clearTimeout(c.stopTimer),c.stopTimer=C(c,Qe))}},buildEnd(){L(o,this.environment)},configureServer(i){n(a=>{O(i,o,a)})},configurePreviewServer(i){n(a=>{i.httpServer.once("close",a)})},enforce:"pre",name:"lunora:local-hyperdrive"}},Xe=(r,e)=>({config(t,o){if(o.command!=="serve")return;const{services:n}=Re(e,K(e)),i=Array.isArray(r.auxiliaryWorkers)?r.auxiliaryWorkers:[],a=new Set(i.map(s=>s.configPath===void 0?"":h(e,s.configPath))),c=[...new Set(n.map(s=>s.wranglerPath))].filter(s=>!a.has(s)).map(s=>({configPath:s}));c.length>0&&(r.auxiliaryWorkers=[...i,...c])},enforce:"pre",name:"lunora:service-workers"}),Ze=r=>{if(r===!1)return!1;const e=r===!0||r===void 0?{}:r;return{...e,forwardedConsoleMethods:e.forwardedConsoleMethods??["error","warn"],solutionFinders:[...Te,...e.solutionFinders??[]]}},er=(r,e)=>{const t=Y(r,e);if(!X(t)){const o=Z();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 ee(t,r),t},rr=r=>{const e=r??{};if(e.lazyFunctions!==void 0)throw new Error("lunora(): the `lazyFunctions` option was removed. Set `codegen: { lazyFunctions: true }` in lunora.config (or pass --lazy-functions for one run).");const 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=er(n,e.target);return{allowUnauthenticatedShardAccess:e.allowUnauthenticatedShardAccess??!1,apiSpec:e.apiSpec??"openapi",lazyFunctions:Q(),cloudflare:o,studio:e.studio??!0,generatedDir:`${t}/_generated`,overlay:Ze(e.overlay),projectRoot:n,schemaDir:t,shard:e.shard??{},target:i,validateWrangler:e.validateWrangler??!0}},tr=(r,e)=>{const{configPath:t}=r;return typeof t=="string"&&t!==""?h(e,t):void 0},Rr=r=>{const e=rr(r),t=Ve(),o=q(),n=[Ke(e,t),be(e,t),Pe(e),Oe(e,o),we(e,o),Be(e.projectRoot),ke(),Se(e),De(e),je(e),Ae()];e.studio&&n.push(_e(e)),e.validateWrangler&&n.push(xe(e,o)),e.overlay!==!1&&n.push(re(e.overlay)),n.push(ye(e,o));const i=e.cloudflare===!1?void 0:{...e.cloudflare};if(n.push(Ee(i,{projectRoot:e.projectRoot})),i===void 0&&n.push(x({projectRoot:e.projectRoot})),i!==void 0){n.push(Xe(i,e.projectRoot));const a=J(e.target),c=Ie(e.projectRoot,e.target),s=()=>a&&c().runs;n.push(...Ne([x({projectRoot:e.projectRoot,wranglerConfigPath:tr(i,e.projectRoot)}),qe(i,{projectRoot:e.projectRoot}),...Ce(M(i))],s)),a&&n.push(He(e.projectRoot,s),{apply:(l,u)=>u.command==="serve"&&u.isPreview!==!0&&!s(),configureServer(l){l.config.logger.warn(`[lunora] target "${e.target}": vite dev serves the worker in workerd, not on ${e.target} — ${c().reason??"it cannot run this project"}. \`vite build\` then \`lunora deploy\` ships it to ${e.target}.`)},name:"lunora:target-runtime-notice"})}return n},Tr=$(import.meta.url)("../package.json").version;export{$r as CLASS_A_WIRING,xr as GENERATED_CLASS_MODULES,Zr as LUNORA_API_UPDATED_EVENT,Br as LUNORA_WORKER_VIRTUAL_ID,rt as STUDIO_PATH,Tr as VERSION,Jr as WORKER_STARTUP_HINT,Qr as augmentWorkerStartupError,Kr as buildStudioUrl,Fr as buildWorkerEntrySource,Nr as checkLunoraProxy,we as codegenPlugin,ye as containerLogsPlugin,Dr as detectFramework,Se as devStatePlugin,Pe as devVariablesPlugin,be as frameworkComposePlugin,Ir as isAutoComposable,Yr as isWorkerEntryEvalError,ke as logStreamPlugin,Rr as lunora,zr as lunoraSolutionFinder,Te as lunoraSolutionFinders,Hr as planViteRemoteBindings,Ae as proxyCheckPlugin,Lr as reconcileWranglerCrons,Ee as remoteBindingsPlugin,Ze as resolveOverlayOption,_e as studioPlugin,jr as withRemoteBindings,Ce as withWorkerStartupHint,xe 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.426",
|
|
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.397",
|
|
50
|
+
"@lunora/config": "^1.0.0-alpha.453",
|
|
51
51
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
52
52
|
"@visulima/vite-overlay": "2.0.41"
|
|
53
53
|
},
|