@lunora/vite 1.0.0-alpha.348 → 1.0.0-alpha.349
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 +5 -0
- package/dist/index.d.mts +6 -15
- package/dist/index.d.ts +6 -15
- package/dist/index.mjs +3 -3
- package/dist/packem_shared/buildStudioUrl-B9K0wAjC.mjs +1 -0
- package/dist/packem_shared/codegenPlugin-B9ggEipn.mjs +3 -0
- package/dist/packem_shared/planViteRemoteBindings-DYUUW67d.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/buildStudioUrl-DMMWpguZ.mjs +0 -1
- package/dist/packem_shared/codegenPlugin-BsLFhhzx.mjs +0 -3
- package/dist/packem_shared/planViteRemoteBindings-CNz2theU.mjs +0 -1
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ With no options, `lunora()` runs codegen on save, validates `wrangler.jsonc`, in
|
|
|
70
70
|
lunora({
|
|
71
71
|
schemaDir: "lunora", // dir with schema.ts + function files (generated output lands in <schemaDir>/_generated)
|
|
72
72
|
apiSpec: "openapi", // "openapi" | "openrpc" | "both" | "none"
|
|
73
|
+
lazyFunctions: true, // optional per-module lazy function imports; lunora prepare/build/deploy regenerate with their own --lazy-functions flag
|
|
73
74
|
target: "cloudflare", // deploy target the emitted ctx.* surface is tailored to
|
|
74
75
|
allowUnauthenticatedShardAccess: false, // composed class-A worker: allow a client-named shard / fan-out with no authorizeShard
|
|
75
76
|
shard: { cdc: true, reactiveCache: true }, // class-A only: shard DO config for the composed entry (class B/C set this in their own worker entry)
|
|
@@ -80,6 +81,10 @@ lunora({
|
|
|
80
81
|
});
|
|
81
82
|
```
|
|
82
83
|
|
|
84
|
+
`LUNORA_LAZY_FUNCTIONS=1` or `true` enables lazy imports even when
|
|
85
|
+
`lazyFunctions` is `false`, for both dev and production builds.
|
|
86
|
+
`lunora dev --lazy-functions` sets this variable for its bundler child process.
|
|
87
|
+
|
|
83
88
|
`lunora()` returns a flat `Plugin[]`; Vite flattens nested plugin arrays, so `plugins: [lunora()]` works without spreading.
|
|
84
89
|
|
|
85
90
|
### Error overlay
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import errorOverlayPlugin from '@visulima/vite-overlay';
|
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
import { FrameworkDetection, DetectedFramework, GeneratedClassModule, readProjectRemotePreference } from '@lunora/config';
|
|
5
5
|
export { type DetectedFramework, type FrameworkClass, type FrameworkDetection, GENERATED_CLASS_MODULES, type GeneratedClassModule, detectFramework } from '@lunora/config';
|
|
6
|
-
import { materializeDevWranglerConfig } from '@lunora/config/cloudflare';
|
|
6
|
+
import { materializeDevWranglerConfig, WithheldBinding } from '@lunora/config/cloudflare';
|
|
7
7
|
export { type ReconcileCronsResult as ReconcileResult, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
8
8
|
import { AddressInfo } from 'node:net';
|
|
9
9
|
export { STUDIO_PATH } from '@lunora/config/studio-host';
|
|
@@ -77,6 +77,8 @@ interface LunoraPluginOptions {
|
|
|
77
77
|
apiSpec?: CodegenOptions["apiSpec"];
|
|
78
78
|
/** Pass through to `@cloudflare/vite-plugin`. Pass `false` to opt out. Defaults to `true`. */
|
|
79
79
|
cloudflare?: boolean | CloudflarePluginOptions;
|
|
80
|
+
/** Emit a per-module lazy function registry; omitted keeps the eager registry. */
|
|
81
|
+
lazyFunctions?: CodegenOptions["lazyFunctions"];
|
|
80
82
|
/**
|
|
81
83
|
* Inject `@visulima/vite-overlay` for runtime errors (dev only). Pass
|
|
82
84
|
* `false` to opt out, or an options object to forward to the overlay.
|
|
@@ -126,6 +128,7 @@ interface ResolvedLunoraPluginOptions {
|
|
|
126
128
|
* build. Derived, so the import base cannot disagree with the emitter.
|
|
127
129
|
*/
|
|
128
130
|
generatedDir: string;
|
|
131
|
+
lazyFunctions: boolean;
|
|
129
132
|
overlay: false | OverlayPluginOptions;
|
|
130
133
|
projectRoot: string;
|
|
131
134
|
schemaDir: string;
|
|
@@ -342,8 +345,8 @@ interface ViteRemotePlan {
|
|
|
342
345
|
enabled: boolean;
|
|
343
346
|
/** Why remote mode didn't take effect despite being requested, for logging. */
|
|
344
347
|
reason?: string;
|
|
345
|
-
/** `ai`
|
|
346
|
-
withheld:
|
|
348
|
+
/** Remote-only bindings (`ai`, `artifacts`) left out for lack of Cloudflare credentials, for the dev warning. */
|
|
349
|
+
withheld: WithheldBinding[];
|
|
347
350
|
}
|
|
348
351
|
/** Inputs to the Vite remote-binding decision — injectable so tests don't touch the env/fs. */
|
|
349
352
|
interface PlanViteRemoteOptions {
|
|
@@ -548,18 +551,6 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
|
|
|
548
551
|
* override `forwardedConsoleMethods`.
|
|
549
552
|
*/
|
|
550
553
|
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
551
|
-
/**
|
|
552
|
-
* Lunora Vite plugin. Returns a flat array of Vite plugins that:
|
|
553
|
-
*
|
|
554
|
-
* 1. Run `@lunora/codegen` on startup + on schema file changes.
|
|
555
|
-
* 2. Validate the project's `wrangler.jsonc` against the schema's implied bindings.
|
|
556
|
-
* 3. Inject `@visulima/vite-overlay` for runtime error overlays (unless `overlay: false`).
|
|
557
|
-
* 4. Include `@cloudflare/vite-plugin` so users get one-import setup (unless `cloudflare: false`).
|
|
558
|
-
*
|
|
559
|
-
* `@cloudflare/vite-plugin` and `@visulima/vite-overlay` are direct dependencies,
|
|
560
|
-
* so they're imported statically — opt out per-feature via the options rather
|
|
561
|
-
* than relying on whether they're installed.
|
|
562
|
-
*/
|
|
563
554
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
564
555
|
declare const VERSION: string;
|
|
565
556
|
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, type WorkerEntryComposition, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import errorOverlayPlugin from '@visulima/vite-overlay';
|
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
import { FrameworkDetection, DetectedFramework, GeneratedClassModule, readProjectRemotePreference } from '@lunora/config';
|
|
5
5
|
export { type DetectedFramework, type FrameworkClass, type FrameworkDetection, GENERATED_CLASS_MODULES, type GeneratedClassModule, detectFramework } from '@lunora/config';
|
|
6
|
-
import { materializeDevWranglerConfig } from '@lunora/config/cloudflare';
|
|
6
|
+
import { materializeDevWranglerConfig, WithheldBinding } from '@lunora/config/cloudflare';
|
|
7
7
|
export { type ReconcileCronsResult as ReconcileResult, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
8
8
|
import { AddressInfo } from 'node:net';
|
|
9
9
|
export { STUDIO_PATH } from '@lunora/config/studio-host';
|
|
@@ -77,6 +77,8 @@ interface LunoraPluginOptions {
|
|
|
77
77
|
apiSpec?: CodegenOptions["apiSpec"];
|
|
78
78
|
/** Pass through to `@cloudflare/vite-plugin`. Pass `false` to opt out. Defaults to `true`. */
|
|
79
79
|
cloudflare?: boolean | CloudflarePluginOptions;
|
|
80
|
+
/** Emit a per-module lazy function registry; omitted keeps the eager registry. */
|
|
81
|
+
lazyFunctions?: CodegenOptions["lazyFunctions"];
|
|
80
82
|
/**
|
|
81
83
|
* Inject `@visulima/vite-overlay` for runtime errors (dev only). Pass
|
|
82
84
|
* `false` to opt out, or an options object to forward to the overlay.
|
|
@@ -126,6 +128,7 @@ interface ResolvedLunoraPluginOptions {
|
|
|
126
128
|
* build. Derived, so the import base cannot disagree with the emitter.
|
|
127
129
|
*/
|
|
128
130
|
generatedDir: string;
|
|
131
|
+
lazyFunctions: boolean;
|
|
129
132
|
overlay: false | OverlayPluginOptions;
|
|
130
133
|
projectRoot: string;
|
|
131
134
|
schemaDir: string;
|
|
@@ -342,8 +345,8 @@ interface ViteRemotePlan {
|
|
|
342
345
|
enabled: boolean;
|
|
343
346
|
/** Why remote mode didn't take effect despite being requested, for logging. */
|
|
344
347
|
reason?: string;
|
|
345
|
-
/** `ai`
|
|
346
|
-
withheld:
|
|
348
|
+
/** Remote-only bindings (`ai`, `artifacts`) left out for lack of Cloudflare credentials, for the dev warning. */
|
|
349
|
+
withheld: WithheldBinding[];
|
|
347
350
|
}
|
|
348
351
|
/** Inputs to the Vite remote-binding decision — injectable so tests don't touch the env/fs. */
|
|
349
352
|
interface PlanViteRemoteOptions {
|
|
@@ -548,18 +551,6 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
|
|
|
548
551
|
* override `forwardedConsoleMethods`.
|
|
549
552
|
*/
|
|
550
553
|
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
551
|
-
/**
|
|
552
|
-
* Lunora Vite plugin. Returns a flat array of Vite plugins that:
|
|
553
|
-
*
|
|
554
|
-
* 1. Run `@lunora/codegen` on startup + on schema file changes.
|
|
555
|
-
* 2. Validate the project's `wrangler.jsonc` against the schema's implied bindings.
|
|
556
|
-
* 3. Inject `@visulima/vite-overlay` for runtime error overlays (unless `overlay: false`).
|
|
557
|
-
* 4. Include `@cloudflare/vite-plugin` so users get one-import setup (unless `cloudflare: false`).
|
|
558
|
-
*
|
|
559
|
-
* `@cloudflare/vite-plugin` and `@visulima/vite-overlay` are direct dependencies,
|
|
560
|
-
* so they're imported statically — opt out per-feature via the options rather
|
|
561
|
-
* than relying on whether they're installed.
|
|
562
|
-
*/
|
|
563
554
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
564
555
|
declare const VERSION: string;
|
|
565
556
|
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, type WorkerEntryComposition, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
${
|
|
3
|
-
`)}},name:"lunora:agent-rules-hint"}),
|
|
1
|
+
import{createRequire as E}from"node:module";import{resolve as k}from"node:path";import{cloudflare as b}from"@cloudflare/vite-plugin";import{resolveDeployDriver as W,startCelldDevSession as O,formatLunoraEvent as D,lunoraLine as L,detectFramework as $,targetRunsOwnDevServer as j,resolveLazyFunctions as F,resolveTargetOrThrow as U,isRunnableTarget as N,runnableTargetIds as I}from"@lunora/config";import{GENERATED_CLASS_MODULES as ir,detectFramework as ar}from"@lunora/config";import M from"@visulima/vite-overlay";import{detectAgentRules as B,claimAgentRulesHint as H,lunoraLine as d,AGENT_RULES_HINT as V}from"@lunora/config/cli";import{reconcileBindingsSafely as G,findWranglerFile as K,readWranglerJsonc as z,warnCloudflareCliConfigOnce as q,hasCloudflareCredentials as J,withheldBindings as Q,describeWithheld as X,startLocalHyperdrive as Y}from"@lunora/config/cloudflare";import{reconcileWranglerCrons as lr}from"@lunora/config/cloudflare";import{r as A,a as C}from"./packem_shared/server-close-DWiO4Vxb.mjs";import Z from"./packem_shared/codegenPlugin-B9ggEipn.mjs";import ee from"./packem_shared/containerLogsPlugin-BCqWF6EU.mjs";import re from"./packem_shared/devStatePlugin-CF4GDvBn.mjs";import oe from"./packem_shared/devVariablesPlugin-DbD6cSF0.mjs";import{frameworkComposePlugin as te}from"./packem_shared/CLASS_A_WIRING-DCI5QzA9.mjs";import{CLASS_A_WIRING as ur,LUNORA_WORKER_VIRTUAL_ID as dr,buildWorkerEntrySource as fr,isAutoComposable as pr}from"./packem_shared/CLASS_A_WIRING-DCI5QzA9.mjs";import ne from"./packem_shared/logStreamPlugin-EMXiy6pI.mjs";import{proxyCheckPlugin as ie}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{checkLunoraProxy as mr}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{remoteBindingsPlugin as ae}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{planViteRemoteBindings as hr,withRemoteBindings as wr}from"./packem_shared/planViteRemoteBindings-DYUUW67d.mjs";import{readServiceBindings as se}from"@lunora/codegen";import{lunoraSolutionFinders as le}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as yr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as ce}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{buildStudioUrl as Rr}from"./packem_shared/buildStudioUrl-B9K0wAjC.mjs";import{withWorkerStartupHint as ue}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Ar,augmentWorkerStartupError as Cr,isWorkerEntryEvalError as xr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as de}from"./packem_shared/wranglerValidatorPlugin-BlGHjTXZ.mjs";import{default as _r}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{STUDIO_PATH as br}from"@lunora/config/studio-host";const fe=r=>({apply:"serve",configureServer(e){return()=>{B(r.projectRoot).installed||!H()||e.config.logger.warn(`
|
|
2
|
+
${d(V)}
|
|
3
|
+
`)}},name:"lunora:agent-rules-hint"}),pe=r=>({async config(e,o){o.isPreview!==!0&&await G(r,{info:t=>{console.info(t)},warn:t=>{console.warn(t)}})},enforce:"pre",name:"lunora:bindings-provision"}),h="/_lunora",ge=8787,f=new Map,x=r=>r.command==="serve"&&r.isPreview!==!0,me=(r,e)=>{let o;return()=>{if(o===void 0)try{W(e).projectConfig?.(r,"dev"),o={runs:!0}}catch(t){o={reason:t instanceof Error?t.message:String(t),runs:!1}}return o}},ve=r=>{const e=K(r),o=e===void 0?void 0:z(e).parsed?.dev?.port;return typeof o=="number"?o:ge},he=(r,e)=>r.map(o=>{const t=o.apply;return{...o,apply:(n,i)=>x(i)&&e()?!1:typeof t=="function"?t(n,i):t===void 0||t===i.command}}),we=(r,e,{stream:o,tag:t})=>{const n=D(e);n!==void 0?r[n.level](`[lunora] ${n.text}`):o==="stderr"?r.warn(`[${t}] ${e}`):r.info(`[${t}] ${e}`)},Se=(r,e)=>{const o=ve(r),t=new Map;return{apply:(n,i)=>x(i)&&e(),buildEnd(){C(t,this.environment)},config:n=>{if(n.server?.proxy?.[h]===void 0)return{server:{proxy:{[h]:{changeOrigin:!0,target:`http://127.0.0.1:${String(o)}`,ws:!0}}}}},async configureServer(n){const{logger:i}=n.config;await f.get(r)?.stop(),f.delete(r),i.info(`[lunora] starting the worker on celld at http://127.0.0.1:${String(o)} …`);const l=await O({log:(a,c)=>{we(i,a,c)},port:o,projectRoot:r});f.set(r,l);const s=a=>{i.error(`[lunora] the worker on celld exited (code ${String(a)}) — restart vite dev to bring it back`)};l.exited.then(s).catch(()=>{}),A(n,t,()=>{f.get(r)===l&&f.delete(r),l.stop().catch(a=>{i.error(`[lunora] stopping celld failed: ${a instanceof Error?a.message:String(a)}`)})})},name:"lunora:celld-dev"}},ye=r=>({configResolved(e){q(r.projectRoot,o=>{e.logger.warn(L(o))})},name:"lunora:cf-config-warning"}),Pe=()=>({}),Re={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)"},ke=r=>{const e=Re[r.framework];return r.framework==="none"?d("no meta-framework detected — running standalone."):r.class==="B"?d(`detected ${e} — composition is handled by the framework adapter.`):d(`detected ${e} — composing the Lunora worker into one Cloudflare Worker.`)},Ae=(r,e)=>{let o=!1;const t=()=>{e.framework??=$(r.projectRoot)};return{config(){t()},configResolved(){t()},configureServer(){t(),!o&&e.framework!==void 0&&(o=!0,console.info(ke(e.framework)))},name:"lunora:framework-detect"}},w=r=>Array.isArray(r)?r:[],v=new WeakSet,Ce=(r,e={})=>{let o=!1;const t=r.experimental?.newConfig,n=t!==void 0&&t!==!1,i=e.hasCredentials??(()=>J({projectRoot:e.projectRoot})),l=s=>{const a=(c,...u)=>{const p=typeof s=="function"?s(c,...u):s,g=p===void 0?void 0:{...p},T=o?[...w(c.artifacts),...w(g?.artifacts)]:[],_=o?Q({ai:c.ai??g?.ai,artifacts:T},i):[];for(const m of _)Reflect.deleteProperty(c,m.kind),Reflect.deleteProperty(g??{},m.kind),console.warn(d(X(m)));return g};return v.add(a),a};return{config(s,a){if(o=a.command==="serve"&&a.isPreview!==!0,n)return;const c=r;v.has(c.config)||(c.config=l(c.config)),Array.isArray(c.auxiliaryWorkers)&&(c.auxiliaryWorkers=c.auxiliaryWorkers.map(u=>v.has(u.config)?u:{...u,config:l(u.config)}))},enforce:"pre",name:"lunora:local-ai-binding"}},xe=5e3,Te=3e4,S=new Map,y=r=>{const e=S.get(r);if(e!==void 0)return e;const o={databases:[],pending:Promise.resolve(),servers:0,stopping:Promise.resolve()};return S.set(r,o),o},_e=async r=>{const e=r.databases.splice(0);await Promise.allSettled(e.map(async o=>o.stop()))},P=(r,e)=>{const o=setTimeout(()=>{r.pending.then(async()=>{r.servers===0&&(r.stopping=_e(r),await r.stopping)}).catch(()=>{})},e);return o.unref(),o},R=({projectRoot:r,start:e=Y,wranglerConfigPath:o})=>{const t=new Map,n=i=>{const l=y(r);let s=!1;l.servers+=1,clearTimeout(l.stopTimer),i(()=>{s||(s=!0,l.servers-=1,l.servers===0&&(l.stopTimer=P(l,xe)))})};return{async config(i,l){if(l.command!=="serve")return;const s=y(r);clearTimeout(s.stopTimer);const a=s.pending,c=(async()=>{await a,await s.stopping;const u=await e({onWarning:p=>{console.warn(d(p))},projectRoot:r,wranglerConfigPath:o});u!==void 0&&s.databases.push(u),u!==void 0&&u.bindings.length>0&&console.info(d(`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=P(s,Te))}},buildEnd(){C(t,this.environment)},configureServer(i){n(l=>{A(i,t,l)})},configurePreviewServer(i){n(l=>{i.httpServer.once("close",l)})},enforce:"pre",name:"lunora:local-hyperdrive"}},Ee=(r,e)=>({config(o,t){if(t.command!=="serve")return;const{services:n}=se(e),i=Array.isArray(r.auxiliaryWorkers)?r.auxiliaryWorkers:[],l=new Set(i.map(a=>a.configPath===void 0?"":k(e,a.configPath))),s=[...new Set(n.map(a=>a.wranglerPath))].filter(a=>!l.has(a)).map(a=>({configPath:a}));s.length>0&&(r.auxiliaryWorkers=[...i,...s])},enforce:"pre",name:"lunora:service-workers"}),be=r=>{if(r===!1)return!1;const e=r===!0||r===void 0?{}:r;return{...e,forwardedConsoleMethods:e.forwardedConsoleMethods??["error","warn"],solutionFinders:[...le,...e.solutionFinders??[]]}},We=(r,e)=>{const o=U(r,e);if(!N(o)){const t=I();throw new Error(`target "${o}" has no command-line toolchain, so the Lunora Vite plugin cannot build or serve it — it can only generate for it (\`lunora codegen --target ${o}\`). Buildable targets: ${t.join(", ")}`)}return o},Oe=r=>{const e=r??{},o=e.schemaDir??"lunora";let t;e.cloudflare===!1?t=!1:e.cloudflare===!0||e.cloudflare===void 0?t={}:t=e.cloudflare;const n=e.projectRoot??process.cwd(),i=We(n,e.target);return{allowUnauthenticatedShardAccess:e.allowUnauthenticatedShardAccess??!1,apiSpec:e.apiSpec??"openapi",lazyFunctions:F(e.lazyFunctions),cloudflare:t,studio:e.studio??!0,generatedDir:`${o}/_generated`,overlay:be(e.overlay),projectRoot:n,schemaDir:o,shard:e.shard??{},target:i,validateWrangler:e.validateWrangler??!0}},De=(r,e)=>{const{configPath:o}=r;return typeof o=="string"&&o!==""?k(e,o):void 0},rr=r=>{const e=Oe(r),o=Pe(),t=[Ae(e,o),te(e,o),oe(e),pe(e),Z(e),ne(),re(e),fe(e),ye(e),ie()];e.studio&&t.push(ce(e)),e.validateWrangler&&t.push(de(e)),e.overlay!==!1&&t.push(M(e.overlay)),t.push(ee(e));const n=e.cloudflare===!1?void 0:{...e.cloudflare};if(t.push(ae(n,{projectRoot:e.projectRoot})),n===void 0&&t.push(R({projectRoot:e.projectRoot})),n!==void 0){t.push(Ee(n,e.projectRoot));const i=j(e.target),l=me(e.projectRoot,e.target),s=()=>i&&l().runs;t.push(...he([R({projectRoot:e.projectRoot,wranglerConfigPath:De(n,e.projectRoot)}),Ce(n,{projectRoot:e.projectRoot}),...ue(b(n))],s)),i&&t.push(Se(e.projectRoot,s),{apply:(a,c)=>c.command==="serve"&&c.isPreview!==!0&&!s(),configureServer(a){a.config.logger.warn(`[lunora] target "${e.target}": vite dev serves the worker in workerd, not on ${e.target} — ${l().reason??"it cannot run this project"}. \`vite build\` then \`lunora deploy\` ships it to ${e.target}.`)},name:"lunora:target-runtime-notice"})}return t},or=E(import.meta.url)("../package.json").version;export{ur as CLASS_A_WIRING,ir as GENERATED_CLASS_MODULES,_r as LUNORA_API_UPDATED_EVENT,dr as LUNORA_WORKER_VIRTUAL_ID,br as STUDIO_PATH,or as VERSION,Ar as WORKER_STARTUP_HINT,Cr as augmentWorkerStartupError,Rr as buildStudioUrl,fr as buildWorkerEntrySource,mr as checkLunoraProxy,Z as codegenPlugin,ee as containerLogsPlugin,ar as detectFramework,re as devStatePlugin,oe as devVariablesPlugin,te as frameworkComposePlugin,pr as isAutoComposable,xr as isWorkerEntryEvalError,ne as logStreamPlugin,rr as lunora,yr as lunoraSolutionFinder,le as lunoraSolutionFinders,hr as planViteRemoteBindings,ie as proxyCheckPlugin,lr as reconcileWranglerCrons,ae as remoteBindingsPlugin,be as resolveOverlayOption,ce as studioPlugin,wr as withRemoteBindings,ue as withWorkerStartupHint,de as wranglerValidatorPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{STUDIO_PATH as d,studioMountPath as a,isNonLoopbackHost as c,createStudioMiddleware as n}from"@lunora/config/studio-host";import{STUDIO_PATH as p}from"@lunora/config/studio-host";const l=/\/$/,i=e=>{if(e.resolvedLocal!==void 0&&e.resolvedLocal!=="")return`${e.resolvedLocal.replace(l,"")}${d}`;const o=a(e.base);if(e.address===void 0||typeof e.address=="string")return`http://localhost:5173${o}`;const s=e.address.address==="::"||e.address.address==="0.0.0.0"?"localhost":e.address.address;return`http://${s.includes(":")?`[${s}]`:s}:${String(e.address.port)}${o}`},f=e=>({apply:"serve",configureServer(o){const s=c(o.config.server?.host);return o.middlewares.use(n({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o.config.base,isNonLoopbackBind:s,logger:o.config.logger,projectRoot:e.projectRoot,schemaDirectory:e.schemaDir})),()=>{const t=()=>{const r=i({address:o.httpServer?.address()??void 0,base:o.config.base,resolvedLocal:o.resolvedUrls?.local[0]});o.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${r}\x1B[39m`)};if(typeof o.printUrls=="function"){const r=o.printUrls.bind(o);o.printUrls=()=>{r(),t()}}else o.httpServer?.listening===!0?t():o.httpServer?.once("listening",t)}},name:"lunora:studio"});export{p as STUDIO_PATH,i as buildStudioUrl,f as studioPlugin};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{readFileSync as K,existsSync as X}from"node:fs";import{resolve as h,dirname as q,sep as k,basename as Q,join as Y,relative as Z}from"node:path";import{findProjectConfigFile as z,readServiceBindings as ee,PROJECT_CONFIG_FILENAMES as ne,runCodegen as te,findTsconfig as re,isTestPath as oe,fingerprintSchemaSources as A,createCodegenProject as ie,refreshCodegenProject as ce,CodegenDiagnosticError as ae}from"@lunora/codegen";import{LUNORA_TAG as m,isCodegenDisabled as se,CODEGEN_ENV as I,runPostCodegenHook as G,reportCodegenFindings as le,blockingFindingsMessage as de}from"@lunora/config";import{findWranglerFile as fe,readWranglerJsonc as ge,WRANGLER_FILES as ue,reconcileBindingsSafely as he,wranglerCodegenInputs as me,reconcileWranglerExtras as pe}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as we}from"vite";import{createHash as ye}from"node:crypto";import ve from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{a as Se,r as Ee}from"./server-close-DWiO4Vxb.mjs";const Re=(e,t)=>{try{const{parsed:i,text:r}=ge(e);return i===void 0?`raw:${r}`:JSON.stringify(t?t(i):i)}catch{return"unreadable"}},$e=e=>{const t={...e},{triggers:i}=t;if(i!==null&&typeof i=="object"){const r={...i};delete r.crons,Object.keys(r).length>0?t.triggers=r:delete t.triggers}return t},F=e=>{const t=fe(e),i=t===void 0?"absent":Re(t,$e),r=z(e);let l="absent";try{r!==void 0&&(l=ye("sha256").update(K(r)).digest("hex"))}catch{}return`${i}\0${l}`},ke=100,U=300,L=2,Ce=e=>{let t,i,r=0;const l=()=>{t&&(clearTimeout(t),t=void 0)},a=(g,f)=>{i&&clearTimeout(i),i=setTimeout(()=>{if(i=void 0,e.fingerprint()!==g){if(r+=1,r>L){e.logger.warn(`${m} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(L)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${m} schema changed while \`postcodegen\` was running — regenerating`),f()}},U)},d=g=>{e.regenerate(g,f=>{a(f,()=>{d(g)})})};return{cancelPending:l,dispose:()=>{l(),i&&(clearTimeout(i),i=void 0)},onSave:g=>{l(),r=0,t=setTimeout(()=>{t=void 0,d(g)},ke)}}},W=/[/\\]tsconfig\..+\.json$/u,be=/(?:\.[cm]?[jt]sx?|(?:^|[/\\])tsconfig(?:\..+)?\.json)$/u,je=e=>{const t=e.map(r=>` • ${r.kind} "${r.exportName}" — class ${r.className} is not exported by your worker entry.`),i=[...new Set(e.map(r=>r.module))].map(r=>` export * from "./lunora/_generated/${r}";`);return[`[lunora] ${String(e.length)} declared ${e.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...t,"","Add to your worker entry:",...i].join(`
|
|
2
|
+
`)},De=(e,t,i)=>{if(t.warn(`${m} schema.ts not found at ${e} — codegen skipped`),i!==void 0){const r=`schema.ts not found at ${e} — generated output is now stale`;i.onError(new Error(r),r)}},M=(e,t,i,r)=>{const l=Y(e.projectRoot,e.schemaDir,"schema.ts");if(!X(l))return De(l,t,i),{};try{const a=te({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,lunoraDirectory:e.schemaDir,project:r,projectRoot:e.projectRoot,target:e.target,...me(e.projectRoot)});return pe(e.projectRoot,a.cronTriggers,t),le(a,t),{blockingMessage:de(a),outputDirectory:h(a.outputDirectory)}}catch(a){const d=a instanceof Error?a.message:String(a);return t.error(`${m} codegen failed: ${d}`),i?.onError(a,d),{failure:`${m} codegen failed: ${d}`}}},Te=(e,t,i)=>{let r;for(const[l,a]of Object.entries(e.environments)){if(l==="client"){r=a;continue}we(a)||a.hot.send({path:"*",triggeredBy:t,type:"full-reload"})}if(r===void 0){e.hot.send({type:"full-reload"});return}if(i){r.hot.send({type:"full-reload"});return}r.hot.send({event:ve,type:"custom"})},b={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},Ge=e=>{const t=h(e.projectRoot,e.schemaDir),i=se(process.env[I]);let r=h(e.projectRoot,e.generatedDir),l=0,a=!1,d;const g=new Map;let f,j=!1,D=!1,S,T;return{config(o,y){S=y.command},configResolved(){S!=="build"&&i||(T=M(e,b))},async buildStart(){const o=S!=="build"&&i,{blockingMessage:y,failure:v,outputDirectory:E}=T??(o?{}:M(e,b));if(T=void 0,S==="build"&&v!==void 0&&this.error(v),E!==void 0){r=E,a=!0;let p;try{p=await G({cwd:e.projectRoot,logger:b})}finally{a=!1}p.ran&&(l=Date.now()),S==="build"&&p.error!==void 0&&this.error(p.error)}S==="build"&&y!==void 0&&this.error(y),await he(e,b,p=>{d?.hot.send({err:{loc:void 0,message:je(p),stack:""},type:"error"})}),d!==void 0&&(f=F(e.projectRoot),j=!0)},configureServer(o){d=o,o.watcher.add(t);const y=ee(e.projectRoot).services.filter(n=>n.rpcEntrypoint!==void 0).map(n=>q(n.wranglerPath));o.watcher.add(y),f=F(e.projectRoot),j=!1;const v={error:n=>{o.config.logger.error(n)},info:n=>{o.config.logger.info(n)},warn:n=>{o.config.logger.warn(n)}};let E=!1;const p={onError(n,c){E=!0;const s=n instanceof ae?{column:n.column,file:n.file,line:n.line}:void 0,w=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:w,stack:n instanceof Error?n.stack??"":""},type:"error"})}},C=(n,c)=>n===c||n.startsWith(c+k);let _=!1,u;const B=()=>{for(const n of Object.values(o.environments)){const c=n.moduleGraph;for(const s of c.idToModuleMap.values())s.id&&C(s.id,r)&&c.invalidateModule(s)}},J=async(n,c)=>{try{if(_)return;u===void 0?u=ie(t):ce(u,t);const{outputDirectory:s}=M(e,v,p,u);if(s===void 0){u=void 0;return}r=s;const w=A(t);a=!0;let O;try{O=await G({cwd:e.projectRoot,logger:v})}finally{a=!1}if(O.ran&&(l=Date.now(),c(w)),O.error!==void 0)return;B(),Te(o,n,E),E=!1}catch(s){v.error(`${m} codegen watch: ${s instanceof Error?s.message:String(s)}`)}},P=Ce({fingerprint:()=>A(t),logger:v,regenerate:(n,c)=>{J(n,c)}}),V=n=>W.test(n)||n.endsWith(`${k}tsconfig.json`)&&n===re(t)?(u=void 0,!1):!(!C(n,t)||C(n,r)||!n.endsWith(".ts")||oe(Z(t,n).split(k).join("/"))),R=n=>{const c=h(n);if(!(!(be.test(c)&&!c.includes(`${k}node_modules${k}`)&&y.some(w=>C(c,w)))&&!V(c))){if(a||Date.now()-l<U){P.cancelPending();return}P.onSave(c)}},N=n=>{const c=h(n);(c.endsWith(`${k}tsconfig.json`)||W.test(c))&&(u=void 0)};i?o.config.logger.info(`${m} codegen watch disabled (${I}) — _generated/ is written only by an explicit \`lunora codegen\``):(o.watcher.on("add",R),o.watcher.on("change",R),o.watcher.on("unlink",R),o.watcher.on("unlink",N));const x=new Set([...ue.map(n=>h(e.projectRoot,n)),...ne.map(n=>h(e.projectRoot,n))]);for(const n of x)o.watcher.add(n);const $=n=>{if(!x.has(h(n))||D)return;const c=F(e.projectRoot);if(!j){f=c;return}if(f===void 0){f=c;return}c!==f&&(f=c,D=!0,o.config.logger.info(`${m} ${Q(h(n))} changed — restarting dev server`),Promise.resolve(o.restart()).finally(()=>{D=!1}).catch(s=>{const w=s instanceof Error?s.message:String(s);o.config.logger.error(`${m} dev server restart failed: ${w} — keeping the running server; re-save your config to retry.`),o.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${w}`,stack:""},type:"error"})}))};o.watcher.on("add",$),o.watcher.on("change",$),o.watcher.on("unlink",$);const H=()=>{_||(_=!0,u=void 0,P.dispose(),o.watcher.off("add",R),o.watcher.off("change",R),o.watcher.off("unlink",R),o.watcher.off("unlink",N),o.watcher.off("add",$),o.watcher.off("change",$),o.watcher.off("unlink",$))};return()=>{Ee(o,g,H)}},buildEnd(){Se(g,this.environment)},name:"lunora:codegen"}};export{Ge as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readProjectRemotePreference as s,lunoraLine as c}from"@lunora/config";import{resolveRemoteEnabled as g,materializeDevWranglerConfig as h,describeWithheld as u}from"@lunora/config/cloudflare";const l=()=>{},m=e=>{const t=e.readPreference??s;if(!g({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1,withheld:[]};const i=(e.materialize??h)({projectRoot:e.projectRoot,remote:!0});return{cleanup:i.cleanup,configPath:i.configPath,enabled:!0,reason:i.reason,withheld:i.withheld}},P=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},R=(e,t)=>{let n={cleanup:l,enabled:!1,withheld:[]},o;const i=()=>{n.cleanup()};return{buildEnd:i,closeBundle:i,config(b,d){if(d.command!=="serve")return;n.cleanup(),n=m(t);for(const f of n.withheld)console.warn(c(u(f)));if(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;o!==void 0&&r.configPath===o&&delete r.configPath;const a=P(e,n);a.configPath!==void 0&&r.configPath===void 0?(r.configPath=a.configPath,o=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{m as planViteRemoteBindings,R as remoteBindingsPlugin,P as withRemoteBindings};
|
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.349",
|
|
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.326",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.375",
|
|
51
51
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
52
52
|
"@visulima/vite-overlay": "2.0.41"
|
|
53
53
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{STUDIO_PATH as d,studioMountPath as a,isNonLoopbackHost as c,createStudioMiddleware as n}from"@lunora/config/studio-host";import{STUDIO_PATH as u}from"@lunora/config/studio-host";const l=/\/$/,i=e=>{if(e.resolvedLocal!==void 0&&e.resolvedLocal!=="")return`${e.resolvedLocal.replace(l,"")}${d}`;const o=a(e.base);if(e.address===void 0||typeof e.address=="string")return`http://localhost:5173${o}`;const s=e.address.address==="::"||e.address.address==="0.0.0.0"?"localhost":e.address.address;return`http://${s.includes(":")?`[${s}]`:s}:${String(e.address.port)}${o}`},f=e=>({apply:"serve",configureServer(o){const s=c(o.config.server?.host);return o.middlewares.use(n({apiSpec:e.apiSpec,base:o.config.base,isNonLoopbackBind:s,logger:o.config.logger,projectRoot:e.projectRoot,schemaDirectory:e.schemaDir})),()=>{const t=()=>{const r=i({address:o.httpServer?.address()??void 0,base:o.config.base,resolvedLocal:o.resolvedUrls?.local[0]});o.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${r}\x1B[39m`)};if(typeof o.printUrls=="function"){const r=o.printUrls.bind(o);o.printUrls=()=>{r(),t()}}else o.httpServer?.listening===!0?t():o.httpServer?.once("listening",t)}},name:"lunora:studio"});export{u as STUDIO_PATH,i as buildStudioUrl,f as studioPlugin};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{readFileSync as K,existsSync as X}from"node:fs";import{resolve as h,dirname as q,sep as k,basename as Q,join as Y,relative as Z}from"node:path";import{findProjectConfigFile as z,readServiceBindings as ee,PROJECT_CONFIG_FILENAMES as te,runCodegen as ne,findTsconfig as re,isTestPath as oe,fingerprintSchemaSources as A,createCodegenProject as ie,refreshCodegenProject as ce,CodegenDiagnosticError as ae}from"@lunora/codegen";import{LUNORA_TAG as m,isCodegenDisabled as se,CODEGEN_ENV as I,runPostCodegenHook as G,reportCodegenFindings as le,blockingFindingsMessage as de}from"@lunora/config";import{findWranglerFile as fe,readWranglerJsonc as ge,WRANGLER_FILES as ue,reconcileBindingsSafely as he,wranglerCodegenInputs as me,reconcileWranglerExtras as pe}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as we}from"vite";import{createHash as ye}from"node:crypto";import ve from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{a as Se,r as Ee}from"./server-close-DWiO4Vxb.mjs";const Re=(e,n)=>{try{const{parsed:i,text:r}=ge(e);return i===void 0?`raw:${r}`:JSON.stringify(n?n(i):i)}catch{return"unreadable"}},$e=e=>{const n={...e},{triggers:i}=n;if(i!==null&&typeof i=="object"){const r={...i};delete r.crons,Object.keys(r).length>0?n.triggers=r:delete n.triggers}return n},M=e=>{const n=fe(e),i=n===void 0?"absent":Re(n,$e),r=z(e);let l="absent";try{r!==void 0&&(l=ye("sha256").update(K(r)).digest("hex"))}catch{}return`${i}\0${l}`},ke=100,U=300,L=2,Ce=e=>{let n,i,r=0;const l=()=>{n&&(clearTimeout(n),n=void 0)},a=(g,f)=>{i&&clearTimeout(i),i=setTimeout(()=>{if(i=void 0,e.fingerprint()!==g){if(r+=1,r>L){e.logger.warn(`${m} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(L)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${m} schema changed while \`postcodegen\` was running — regenerating`),f()}},U)},d=g=>{e.regenerate(g,f=>{a(f,()=>{d(g)})})};return{cancelPending:l,dispose:()=>{l(),i&&(clearTimeout(i),i=void 0)},onSave:g=>{l(),r=0,n=setTimeout(()=>{n=void 0,d(g)},ke)}}},W=/[/\\]tsconfig\..+\.json$/u,be=/(?:\.[cm]?[jt]sx?|(?:^|[/\\])tsconfig(?:\..+)?\.json)$/u,je=e=>{const n=e.map(r=>` • ${r.kind} "${r.exportName}" — class ${r.className} is not exported by your worker entry.`),i=[...new Set(e.map(r=>r.module))].map(r=>` export * from "./lunora/_generated/${r}";`);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:",...i].join(`
|
|
2
|
-
`)},De=(e,n,i)=>{if(n.warn(`${m} schema.ts not found at ${e} — codegen skipped`),i!==void 0){const r=`schema.ts not found at ${e} — generated output is now stale`;i.onError(new Error(r),r)}},N=(e,n,i,r)=>{const l=Y(e.projectRoot,e.schemaDir,"schema.ts");if(!X(l))return De(l,n,i),{};try{const a=ne({apiSpec:e.apiSpec,lunoraDirectory:e.schemaDir,project:r,projectRoot:e.projectRoot,target:e.target,...me(e.projectRoot)});return pe(e.projectRoot,a.cronTriggers,n),le(a,n),{blockingMessage:de(a),outputDirectory:h(a.outputDirectory)}}catch(a){const d=a instanceof Error?a.message:String(a);return n.error(`${m} codegen failed: ${d}`),i?.onError(a,d),{failure:`${m} codegen failed: ${d}`}}},Te=(e,n,i)=>{let r;for(const[l,a]of Object.entries(e.environments)){if(l==="client"){r=a;continue}we(a)||a.hot.send({path:"*",triggeredBy:n,type:"full-reload"})}if(r===void 0){e.hot.send({type:"full-reload"});return}if(i){r.hot.send({type:"full-reload"});return}r.hot.send({event:ve,type:"custom"})},b={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},Ge=e=>{const n=h(e.projectRoot,e.schemaDir),i=se(process.env[I]);let r=h(e.projectRoot,e.generatedDir),l=0,a=!1,d;const g=new Map;let f,j=!1,D=!1,S,T;return{config(o,y){S=y.command},configResolved(){S!=="build"&&i||(T=N(e,b))},async buildStart(){const o=S!=="build"&&i,{blockingMessage:y,failure:v,outputDirectory:E}=T??(o?{}:N(e,b));if(T=void 0,S==="build"&&v!==void 0&&this.error(v),E!==void 0){r=E,a=!0;let p;try{p=await G({cwd:e.projectRoot,logger:b})}finally{a=!1}p.ran&&(l=Date.now()),S==="build"&&p.error!==void 0&&this.error(p.error)}S==="build"&&y!==void 0&&this.error(y),await he(e,b,p=>{d?.hot.send({err:{loc:void 0,message:je(p),stack:""},type:"error"})}),d!==void 0&&(f=M(e.projectRoot),j=!0)},configureServer(o){d=o,o.watcher.add(n);const y=ee(e.projectRoot).services.filter(t=>t.rpcEntrypoint!==void 0).map(t=>q(t.wranglerPath));o.watcher.add(y),f=M(e.projectRoot),j=!1;const v={error:t=>{o.config.logger.error(t)},info:t=>{o.config.logger.info(t)},warn:t=>{o.config.logger.warn(t)}};let E=!1;const p={onError(t,c){E=!0;const s=t instanceof ae?{column:t.column,file:t.file,line:t.line}:void 0,w=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:w,stack:t instanceof Error?t.stack??"":""},type:"error"})}},C=(t,c)=>t===c||t.startsWith(c+k);let _=!1,u;const B=()=>{for(const t of Object.values(o.environments)){const c=t.moduleGraph;for(const s of c.idToModuleMap.values())s.id&&C(s.id,r)&&c.invalidateModule(s)}},J=async(t,c)=>{try{if(_)return;u===void 0?u=ie(n):ce(u,n);const{outputDirectory:s}=N(e,v,p,u);if(s===void 0){u=void 0;return}r=s;const w=A(n);a=!0;let O;try{O=await G({cwd:e.projectRoot,logger:v})}finally{a=!1}if(O.ran&&(l=Date.now(),c(w)),O.error!==void 0)return;B(),Te(o,t,E),E=!1}catch(s){v.error(`${m} codegen watch: ${s instanceof Error?s.message:String(s)}`)}},P=Ce({fingerprint:()=>A(n),logger:v,regenerate:(t,c)=>{J(t,c)}}),V=t=>W.test(t)||t.endsWith(`${k}tsconfig.json`)&&t===re(n)?(u=void 0,!1):!(!C(t,n)||C(t,r)||!t.endsWith(".ts")||oe(Z(n,t).split(k).join("/"))),R=t=>{const c=h(t);if(!(!(be.test(c)&&!c.includes(`${k}node_modules${k}`)&&y.some(w=>C(c,w)))&&!V(c))){if(a||Date.now()-l<U){P.cancelPending();return}P.onSave(c)}},F=t=>{const c=h(t);(c.endsWith(`${k}tsconfig.json`)||W.test(c))&&(u=void 0)};i?o.config.logger.info(`${m} codegen watch disabled (${I}) — _generated/ is written only by an explicit \`lunora codegen\``):(o.watcher.on("add",R),o.watcher.on("change",R),o.watcher.on("unlink",R),o.watcher.on("unlink",F));const x=new Set([...ue.map(t=>h(e.projectRoot,t)),...te.map(t=>h(e.projectRoot,t))]);for(const t of x)o.watcher.add(t);const $=t=>{if(!x.has(h(t))||D)return;const c=M(e.projectRoot);if(!j){f=c;return}if(f===void 0){f=c;return}c!==f&&(f=c,D=!0,o.config.logger.info(`${m} ${Q(h(t))} changed — restarting dev server`),Promise.resolve(o.restart()).finally(()=>{D=!1}).catch(s=>{const w=s instanceof Error?s.message:String(s);o.config.logger.error(`${m} dev server restart failed: ${w} — keeping the running server; re-save your config to retry.`),o.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${w}`,stack:""},type:"error"})}))};o.watcher.on("add",$),o.watcher.on("change",$),o.watcher.on("unlink",$);const H=()=>{_||(_=!0,u=void 0,P.dispose(),o.watcher.off("add",R),o.watcher.off("change",R),o.watcher.off("unlink",R),o.watcher.off("unlink",F),o.watcher.off("add",$),o.watcher.off("change",$),o.watcher.off("unlink",$))};return()=>{Ee(o,g,H)}},buildEnd(){Se(g,this.environment)},name:"lunora:codegen"}};export{Ge as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readProjectRemotePreference as s,lunoraLine as c}from"@lunora/config";import{resolveRemoteEnabled as g,materializeDevWranglerConfig as h,describeWithheldWorkersAi as u}from"@lunora/config/cloudflare";const l=()=>{},m=e=>{const t=e.readPreference??s;if(!g({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1,withheld:[]};const i=(e.materialize??h)({projectRoot:e.projectRoot,remote:!0});return{cleanup:i.cleanup,configPath:i.configPath,enabled:!0,reason:i.reason,withheld:i.withheld}},P=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},R=(e,t)=>{let n={cleanup:l,enabled:!1,withheld:[]},o;const i=()=>{n.cleanup()};return{buildEnd:i,closeBundle:i,config(b,d){if(d.command!=="serve")return;n.cleanup(),n=m(t);for(const f of n.withheld)console.warn(c(u(f)));if(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;o!==void 0&&r.configPath===o&&delete r.configPath;const a=P(e,n);a.configPath!==void 0&&r.configPath===void 0?(r.configPath=a.configPath,o=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{m as planViteRemoteBindings,R as remoteBindingsPlugin,P as withRemoteBindings};
|