@lunora/vite 1.0.0-alpha.184 → 1.0.0-alpha.186

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,53 +167,25 @@ 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`). Two steps, both shared
171
- * with `lunora dev` via `@lunora/config`.
170
+ * first required secret (e.g. `AUTH_SECRET is required`). Three steps, the first
171
+ * two shared with `lunora dev` via `@lunora/config`.
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,
175
175
  * {@link fillDevSecrets}: fill any empty/placeholder secret already in
176
- * `.dev.vars` (a `lunora add`-scaffolded project writes secrets blank) and
177
- * ensure `LUNORA_ADMIN_TOKEN` is present + generated — so the worker boots with
178
- * working secrets and the Studio authenticates without its login gate. No
179
- * prompt: it only generates locally-derivable values and never overwrites a real
180
- * one.
176
+ * `.dev.vars` that Lunora can mint locally (a `lunora add`-scaffolded project
177
+ * writes secrets blank) and ensure `LUNORA_ADMIN_TOKEN` is present + generated —
178
+ * so the worker boots with working secrets and the Studio authenticates without
179
+ * its login gate. No prompt: it only generates locally-derivable values and
180
+ * never overwrites a real one. Third, {@link ensureDevWorkerEnv}.
181
181
  *
182
182
  * Runs in `configResolved` (awaited by Vite) so it completes before the
183
183
  * Cloudflare plugin reads the file. Non-interactive runs decline silently.
184
+ * Skipped under `vite preview`, which resolves with `command: "serve"` and so
185
+ * runs `apply: "serve"` plugins too — previewing a built app must not prompt to
186
+ * scaffold, or write, a dev secrets file.
184
187
  */
185
188
  declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
186
- /**
187
- * Worker env var the dev tooling sets so the Lunora runtime recognises a
188
- * development deployment (`@lunora/do`'s `isDevEnvironment`) and therefore
189
- * streams every RPC dispatch summary to the terminal by default — the
190
- * `lunora dev` CLI sets the same var via `wrangler dev --var`.
191
- *
192
- * It is injected ONLY during `vite` serve, never a production `vite build`, so
193
- * it can never leak into a deployed worker. A `WORKER_ENV` the user already
194
- * declares (in `wrangler.jsonc` `[vars]` or `.dev.vars`) takes precedence, so
195
- * this only fills the gap when none is set.
196
- */
197
- declare const DEV_WORKER_ENV_VAR = "WORKER_ENV";
198
- declare const DEV_WORKER_ENV_VALUE = "development";
199
- /**
200
- * Wrap the cloudflare-plugin options so the dev worker's `vars` gain a
201
- * `WORKER_ENV` of `development` when — and only when — `isServe()` reports a
202
- * `vite` serve. Any `config` customizer the caller already supplied is
203
- * preserved and applied first; an existing `WORKER_ENV` wins, so a user
204
- * override is never clobbered.
205
- */
206
- declare const withDevWorkerEnv: (options: CloudflarePluginOptions, isServe: () => boolean) => CloudflarePluginOptions;
207
- /**
208
- * A Vite plugin that captures the resolved command (`serve` vs `build`) so
209
- * {@link withDevWorkerEnv} injects the dev var only during `vite`, plus an
210
- * `isServe` probe sharing the same closure. `enforce: "pre"` so the command is
211
- * captured before the cloudflare plugin resolves its worker config.
212
- */
213
- declare const createCommandProbe: () => {
214
- isServe: () => boolean;
215
- plugin: Plugin;
216
- };
217
189
  /**
218
190
  * Mutable, plugin-shared context. The `lunora()` factory creates one instance
219
191
  * and threads it through every Lunora sub-plugin, so detection runs once and
@@ -309,7 +281,9 @@ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedIm
309
281
  * resolves/loads nothing. `cloudflare: false` does NOT disable the virtual
310
282
  * entry — it only means "don't add the Cloudflare Vite plugin a second time"
311
283
  * (the user supplied it themselves); the composed worker must still be
312
- * resolvable so the user-supplied CF plugin can find the wrangler `main`.
284
+ * resolvable so the user-supplied CF plugin can find the wrangler `main`. The
285
+ * vinext template depends on exactly that, so making this plugin honour the
286
+ * option would break it.
313
287
  */
314
288
  declare const frameworkComposePlugin: (options: ResolvedLunoraPluginOptions, context: LunoraPluginContext) => Plugin;
315
289
  /**
@@ -413,8 +387,13 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
413
387
  * When remote mode was requested but nothing materialized (no eligible binding,
414
388
  * no wrangler file, …), the plan's `reason` is logged so the degradation isn't
415
389
  * silent.
390
+ *
391
+ * `options` is `undefined` on the BYO path (`cloudflare: false`), where the
392
+ * project constructs `cloudflare()` itself and Lunora has no options object to
393
+ * inject into: the materialized path is printed with what to do with it, rather
394
+ * than leaving `LUNORA_REMOTE` looking like it took effect.
416
395
  */
417
- declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions, plan: ViteRemotePlan) => Plugin;
396
+ declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions | undefined, plan: ViteRemotePlan) => Plugin;
418
397
  /**
419
398
  * A tiny Vite plugin that runs the remote temp-config disposer when the dev
420
399
  * server tears down (`buildEnd` fires on close in serve; `closeBundle` covers
@@ -472,7 +451,7 @@ declare const buildStudioUrl: (input: {
472
451
  * `lunora dev` and on a plain `vite` with no per-project files. The studio
473
452
  * is served as a prebuilt static bundle, independent of the host app.
474
453
  */
475
- declare const studioPlugin: () => Plugin;
454
+ declare const studioPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
476
455
  /**
477
456
  * When a module under `lunora/` throws while the Worker entry is first
478
457
  * evaluated, `@cloudflare/vite-plugin` surfaces the failure from deep inside
@@ -522,6 +501,18 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
522
501
  * missing requirements during `configResolved`. Delegates the parsing /
523
502
  * validation logic to `@lunora/config` so the rules stay in lockstep with
524
503
  * the CLI (`lunora deploy`).
504
+ *
505
+ * It provisions before it validates, which is the order `lunora dev` uses
506
+ * (infer → reconcile, no validation pass): the bindings this check requires are
507
+ * the ones Lunora writes itself, and its reconcile lives in the codegen plugin's
508
+ * `buildStart` — a hook Vite only reaches once `configResolved` has SUCCEEDED.
509
+ * Validating first therefore killed the dev server over a binding the very next
510
+ * hook would have added, the first time a project declared a `.global()` table
511
+ * or a container. The reconcile is idempotent, so the `buildStart` one then
512
+ * finds nothing to change.
513
+ *
514
+ * Skipped under `vite preview`, which resolves with `command: "serve"` and so
515
+ * runs `apply: "serve"` plugins: previewing a built app must not probe Docker.
525
516
  */
526
517
  declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
527
518
  /**
@@ -549,4 +540,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
549
540
  */
550
541
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
551
542
  declare const VERSION: string;
552
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, GENERATED_CLASS_MODULES, type GeneratedClassModule, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
543
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, GENERATED_CLASS_MODULES, type GeneratedClassModule, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.d.ts CHANGED
@@ -167,53 +167,25 @@ 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`). Two steps, both shared
171
- * with `lunora dev` via `@lunora/config`.
170
+ * first required secret (e.g. `AUTH_SECRET is required`). Three steps, the first
171
+ * two shared with `lunora dev` via `@lunora/config`.
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,
175
175
  * {@link fillDevSecrets}: fill any empty/placeholder secret already in
176
- * `.dev.vars` (a `lunora add`-scaffolded project writes secrets blank) and
177
- * ensure `LUNORA_ADMIN_TOKEN` is present + generated — so the worker boots with
178
- * working secrets and the Studio authenticates without its login gate. No
179
- * prompt: it only generates locally-derivable values and never overwrites a real
180
- * one.
176
+ * `.dev.vars` that Lunora can mint locally (a `lunora add`-scaffolded project
177
+ * writes secrets blank) and ensure `LUNORA_ADMIN_TOKEN` is present + generated —
178
+ * so the worker boots with working secrets and the Studio authenticates without
179
+ * its login gate. No prompt: it only generates locally-derivable values and
180
+ * never overwrites a real one. Third, {@link ensureDevWorkerEnv}.
181
181
  *
182
182
  * Runs in `configResolved` (awaited by Vite) so it completes before the
183
183
  * Cloudflare plugin reads the file. Non-interactive runs decline silently.
184
+ * Skipped under `vite preview`, which resolves with `command: "serve"` and so
185
+ * runs `apply: "serve"` plugins too — previewing a built app must not prompt to
186
+ * scaffold, or write, a dev secrets file.
184
187
  */
185
188
  declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
186
- /**
187
- * Worker env var the dev tooling sets so the Lunora runtime recognises a
188
- * development deployment (`@lunora/do`'s `isDevEnvironment`) and therefore
189
- * streams every RPC dispatch summary to the terminal by default — the
190
- * `lunora dev` CLI sets the same var via `wrangler dev --var`.
191
- *
192
- * It is injected ONLY during `vite` serve, never a production `vite build`, so
193
- * it can never leak into a deployed worker. A `WORKER_ENV` the user already
194
- * declares (in `wrangler.jsonc` `[vars]` or `.dev.vars`) takes precedence, so
195
- * this only fills the gap when none is set.
196
- */
197
- declare const DEV_WORKER_ENV_VAR = "WORKER_ENV";
198
- declare const DEV_WORKER_ENV_VALUE = "development";
199
- /**
200
- * Wrap the cloudflare-plugin options so the dev worker's `vars` gain a
201
- * `WORKER_ENV` of `development` when — and only when — `isServe()` reports a
202
- * `vite` serve. Any `config` customizer the caller already supplied is
203
- * preserved and applied first; an existing `WORKER_ENV` wins, so a user
204
- * override is never clobbered.
205
- */
206
- declare const withDevWorkerEnv: (options: CloudflarePluginOptions, isServe: () => boolean) => CloudflarePluginOptions;
207
- /**
208
- * A Vite plugin that captures the resolved command (`serve` vs `build`) so
209
- * {@link withDevWorkerEnv} injects the dev var only during `vite`, plus an
210
- * `isServe` probe sharing the same closure. `enforce: "pre"` so the command is
211
- * captured before the cloudflare plugin resolves its worker config.
212
- */
213
- declare const createCommandProbe: () => {
214
- isServe: () => boolean;
215
- plugin: Plugin;
216
- };
217
189
  /**
218
190
  * Mutable, plugin-shared context. The `lunora()` factory creates one instance
219
191
  * and threads it through every Lunora sub-plugin, so detection runs once and
@@ -309,7 +281,9 @@ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedIm
309
281
  * resolves/loads nothing. `cloudflare: false` does NOT disable the virtual
310
282
  * entry — it only means "don't add the Cloudflare Vite plugin a second time"
311
283
  * (the user supplied it themselves); the composed worker must still be
312
- * resolvable so the user-supplied CF plugin can find the wrangler `main`.
284
+ * resolvable so the user-supplied CF plugin can find the wrangler `main`. The
285
+ * vinext template depends on exactly that, so making this plugin honour the
286
+ * option would break it.
313
287
  */
314
288
  declare const frameworkComposePlugin: (options: ResolvedLunoraPluginOptions, context: LunoraPluginContext) => Plugin;
315
289
  /**
@@ -413,8 +387,13 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
413
387
  * When remote mode was requested but nothing materialized (no eligible binding,
414
388
  * no wrangler file, …), the plan's `reason` is logged so the degradation isn't
415
389
  * silent.
390
+ *
391
+ * `options` is `undefined` on the BYO path (`cloudflare: false`), where the
392
+ * project constructs `cloudflare()` itself and Lunora has no options object to
393
+ * inject into: the materialized path is printed with what to do with it, rather
394
+ * than leaving `LUNORA_REMOTE` looking like it took effect.
416
395
  */
417
- declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions, plan: ViteRemotePlan) => Plugin;
396
+ declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions | undefined, plan: ViteRemotePlan) => Plugin;
418
397
  /**
419
398
  * A tiny Vite plugin that runs the remote temp-config disposer when the dev
420
399
  * server tears down (`buildEnd` fires on close in serve; `closeBundle` covers
@@ -472,7 +451,7 @@ declare const buildStudioUrl: (input: {
472
451
  * `lunora dev` and on a plain `vite` with no per-project files. The studio
473
452
  * is served as a prebuilt static bundle, independent of the host app.
474
453
  */
475
- declare const studioPlugin: () => Plugin;
454
+ declare const studioPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
476
455
  /**
477
456
  * When a module under `lunora/` throws while the Worker entry is first
478
457
  * evaluated, `@cloudflare/vite-plugin` surfaces the failure from deep inside
@@ -522,6 +501,18 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
522
501
  * missing requirements during `configResolved`. Delegates the parsing /
523
502
  * validation logic to `@lunora/config` so the rules stay in lockstep with
524
503
  * the CLI (`lunora deploy`).
504
+ *
505
+ * It provisions before it validates, which is the order `lunora dev` uses
506
+ * (infer → reconcile, no validation pass): the bindings this check requires are
507
+ * the ones Lunora writes itself, and its reconcile lives in the codegen plugin's
508
+ * `buildStart` — a hook Vite only reaches once `configResolved` has SUCCEEDED.
509
+ * Validating first therefore killed the dev server over a binding the very next
510
+ * hook would have added, the first time a project declared a `.global()` table
511
+ * or a container. The reconcile is idempotent, so the `buildStart` one then
512
+ * finds nothing to change.
513
+ *
514
+ * Skipped under `vite preview`, which resolves with `command: "serve"` and so
515
+ * runs `apply: "serve"` plugins: previewing a built app must not probe Docker.
525
516
  */
526
517
  declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
527
518
  /**
@@ -549,4 +540,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
549
540
  */
550
541
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
551
542
  declare const VERSION: string;
552
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, GENERATED_CLASS_MODULES, type GeneratedClassModule, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
543
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, GENERATED_CLASS_MODULES, type GeneratedClassModule, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{createRequire as u}from"node:module";import{cloudflare as c}from"@cloudflare/vite-plugin";import{detectAgentRules as m,claimAgentRulesHint as f,AGENT_RULES_HINT as d,detectFramework as p,resolveTargetOrThrow as g,isRunnableTarget as R,runnableTargetIds as S}from"@lunora/config";import{detectFramework as mr}from"@lunora/config";import h from"@visulima/vite-overlay";import{l}from"./packem_shared/log-DE48L4Oz.mjs";import v from"./packem_shared/codegenPlugin-D-6YxM60.mjs";import w from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import k from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import E from"./packem_shared/devVariablesPlugin-DDvQh3l6.mjs";import{createCommandProbe as P,withDevWorkerEnv as A}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{DEV_WORKER_ENV_VALUE as dr,DEV_WORKER_ENV_VAR as pr}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{frameworkComposePlugin as _}from"./packem_shared/CLASS_A_WIRING-N5ktvdUV.mjs";import{CLASS_A_WIRING as Rr,GENERATED_CLASS_MODULES as Sr,LUNORA_WORKER_VIRTUAL_ID as hr,buildWorkerEntrySource as vr,isAutoComposable as wr}from"./packem_shared/CLASS_A_WIRING-N5ktvdUV.mjs";import O from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as T}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as Er}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{planViteRemoteBindings as x,remoteBindingsCleanupPlugin as W,remoteBindingsConfigPlugin as b}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{withRemoteBindings as Ar}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{lunoraSolutionFinders as D}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Or}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as L}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{STUDIO_PATH as xr,buildStudioUrl as Wr}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{withWorkerStartupHint as V}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Dr,augmentWorkerStartupError as Lr,isWorkerEntryEvalError as Vr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as C}from"./packem_shared/wranglerValidatorPlugin-Dma0xUy2.mjs";import{default as Nr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as Ur}from"@lunora/config/cloudflare";const N=e=>({apply:"serve",configureServer(r){return()=>{m(e.projectRoot).installed||!f()||r.config.logger.warn(`
2
- ${l(d)}
3
- `)}},name:"lunora:agent-rules-hint"}),y=()=>({}),U={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)"},I=e=>{const r=U[e.framework];return e.framework==="none"?l("no meta-framework detected — running standalone."):e.class==="B"?l(`detected ${r} — composition is handled by the framework adapter.`):l(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},j=(e,r)=>{let o=!1;const t=()=>{r.framework??=p(e.projectRoot)};return{config(){t()},configResolved(){t()},configureServer(){t(),!o&&r.framework!==void 0&&(o=!0,console.info(I(r.framework)))},name:"lunora:framework-detect"}},F=e=>{if(e===!1)return!1;const r=e===!0||e===void 0?{}:e;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...D,...r.solutionFinders??[]]}},B=(e,r)=>{const o=g(e,r);if(!R(o)){const t=S();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},$=e=>{const r=e??{},o=r.schemaDir??"lunora";let t;r.cloudflare===!1?t=!1:r.cloudflare===!0||r.cloudflare===void 0?t={}:t=r.cloudflare;const a=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:t,studio:r.studio??!0,generatedDir:`${o}/_generated`,overlay:F(r.overlay),projectRoot:a,schemaDir:o,shard:r.shard??{},target:B(a,r.target),validateWrangler:r.validateWrangler??!0}},lr=e=>{const r=$(e),o=y(),{isServe:t,plugin:a}=P(),n=[a,j(r,o),_(r,o),E(r),v(r),O(),k(r),N(r),T()];if(r.studio&&n.push(L()),r.validateWrangler&&n.push(C(r)),r.overlay!==!1&&n.push(h(r.overlay)),r.cloudflare!==!1){n.push(w(r));const i=x({projectRoot:r.projectRoot}),s=A(r.cloudflare,t);i.enabled&&(i.configPath!==void 0&&n.push(W(i.cleanup)),n.push(b(s,i))),n.push(...V(c(s)))}return n},sr=u(import.meta.url)("../package.json").version;export{Rr as CLASS_A_WIRING,dr as DEV_WORKER_ENV_VALUE,pr as DEV_WORKER_ENV_VAR,Sr as GENERATED_CLASS_MODULES,Nr as LUNORA_API_UPDATED_EVENT,hr as LUNORA_WORKER_VIRTUAL_ID,xr as STUDIO_PATH,sr as VERSION,Dr as WORKER_STARTUP_HINT,Lr as augmentWorkerStartupError,Wr as buildStudioUrl,vr as buildWorkerEntrySource,Er as checkLunoraProxy,v as codegenPlugin,w as containerLogsPlugin,P as createCommandProbe,mr as detectFramework,k as devStatePlugin,E as devVariablesPlugin,_ as frameworkComposePlugin,wr as isAutoComposable,Vr as isWorkerEntryEvalError,O as logStreamPlugin,lr as lunora,Or as lunoraSolutionFinder,D as lunoraSolutionFinders,x as planViteRemoteBindings,T as proxyCheckPlugin,Ur as reconcileWranglerCrons,W as remoteBindingsCleanupPlugin,b as remoteBindingsConfigPlugin,F as resolveOverlayOption,L as studioPlugin,A as withDevWorkerEnv,Ar as withRemoteBindings,V as withWorkerStartupHint,C as wranglerValidatorPlugin};
1
+ import{createRequire as l}from"node:module";import{cloudflare as s}from"@cloudflare/vite-plugin";import{detectAgentRules as u,claimAgentRulesHint as c,AGENT_RULES_HINT as d,detectFramework as f,resolveTargetOrThrow as m,isRunnableTarget as p,runnableTargetIds as g}from"@lunora/config";import{detectFramework as ir}from"@lunora/config";import S from"@visulima/vite-overlay";import{l as a}from"./packem_shared/log-DE48L4Oz.mjs";import{codegenPlugin as h}from"./packem_shared/codegenPlugin-DVaxvj10.mjs";import R from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import v from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import w from"./packem_shared/devVariablesPlugin-DY_bJXsX.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-CEzeqjr2.mjs";import{CLASS_A_WIRING as sr,GENERATED_CLASS_MODULES as ur,LUNORA_WORKER_VIRTUAL_ID as cr,buildWorkerEntrySource as dr,isAutoComposable as fr}from"./packem_shared/CLASS_A_WIRING-CEzeqjr2.mjs";import P from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as A}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as pr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{planViteRemoteBindings as E,remoteBindingsCleanupPlugin as T,remoteBindingsConfigPlugin as x}from"./packem_shared/planViteRemoteBindings-BtMtSmTC.mjs";import{withRemoteBindings as Sr}from"./packem_shared/planViteRemoteBindings-BtMtSmTC.mjs";import{lunoraSolutionFinders as O}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Rr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{STUDIO_PATH as wr,buildStudioUrl as kr}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{withWorkerStartupHint as b}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 L}from"./packem_shared/wranglerValidatorPlugin-D59YqFdy.mjs";import{default as Or}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as br}from"@lunora/config/cloudflare";const W=o=>({apply:"serve",configureServer(r){return()=>{u(o.projectRoot).installed||!c()||r.config.logger.warn(`
2
+ ${a(d)}
3
+ `)}},name:"lunora:agent-rules-hint"}),y=()=>({}),C={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=C[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.`)},N=(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"}},U=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...O,...r.solutionFinders??[]]}},I=(o,r)=>{const t=m(o,r);if(!p(t)){const e=g();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},j=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:U(r.overlay),projectRoot:n,schemaDir:t,shard:r.shard??{},target:I(n,r.target),validateWrangler:r.validateWrangler??!0}},or=o=>{const r=j(o),t=y(),e=[N(r,t),k(r,t),w(r),h(r),P(),v(r),W(r),A()];r.studio&&e.push(_(r)),r.validateWrangler&&e.push(L(r)),r.overlay!==!1&&e.push(S(r.overlay)),e.push(R(r));const n=E({projectRoot:r.projectRoot});n.enabled&&n.configPath!==void 0&&e.push(T(n.cleanup));const i=r.cloudflare===!1?void 0:{...r.cloudflare};return n.enabled&&e.push(x(i,n)),i!==void 0&&e.push(...b(s(i))),e},tr=l(import.meta.url)("../package.json").version;export{sr as CLASS_A_WIRING,ur as GENERATED_CLASS_MODULES,Or as LUNORA_API_UPDATED_EVENT,cr as LUNORA_WORKER_VIRTUAL_ID,wr as STUDIO_PATH,tr as VERSION,Ar as WORKER_STARTUP_HINT,Er as augmentWorkerStartupError,kr as buildStudioUrl,dr as buildWorkerEntrySource,pr as checkLunoraProxy,h as codegenPlugin,R as containerLogsPlugin,ir as detectFramework,v as devStatePlugin,w as devVariablesPlugin,k as frameworkComposePlugin,fr as isAutoComposable,Tr as isWorkerEntryEvalError,P as logStreamPlugin,or as lunora,Rr as lunoraSolutionFinder,O as lunoraSolutionFinders,E as planViteRemoteBindings,A as proxyCheckPlugin,br as reconcileWranglerCrons,T as remoteBindingsCleanupPlugin,x as remoteBindingsConfigPlugin,U as resolveOverlayOption,_ as studioPlugin,Sr as withRemoteBindings,b as withWorkerStartupHint,L as wranglerValidatorPlugin};
@@ -0,0 +1,33 @@
1
+ import{existsSync as w}from"node:fs";import{resolve as A,join as k}from"node:path";import{projectUsesUmbrella as S}from"@lunora/config";import{LunoraError as O}from"@lunora/errors";const u="virtual:lunora/worker",E="\0",m=`${E}${u}`,L=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
2
+ export default {};
3
+ `,_=/\/$/,p={"react-router":{handler:'{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',imports:'import { createRequestHandler } from "react-router";'},"solid-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@solidjs/start/server-handler";'},"tanstack-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/react-start/server-entry";'},"tanstack-start-solid":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/solid-start/server-entry";'},vinext:{handler:"ssrModule.default",imports:'import * as ssrModule from "vinext/server/fetch-handler";'}},d=r=>{const e=r.framework;return e?.class==="A"&&p[e.framework]!==void 0},$=["agents","containers","workflows"],N=(r,e,s=[],a=!1,t=!1,i={})=>{const o=p[r];if(o===void 0)throw new O("INTERNAL",`[lunora] no class-A worker wiring for framework "${r}"`);const n=e.replaceAll("\\","/"),f=a?"lunorash/runtime":"@lunora/runtime",h=s.map(l=>`
4
+ export * from "${n}/${l}";
5
+ `).join(""),c=JSON.stringify(Object.fromEntries(Object.entries(i).toSorted(([l],[v])=>l.localeCompare(v)))),R=c==="{}"?"":c;return`// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
6
+ // Do not edit: emitted from the detected framework (${r}). Point your
7
+ // wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
8
+ import { composeWorker } from "${f}";
9
+ ${o.imports}
10
+ import { LUNORA_FUNCTIONS } from "${n}/functions";
11
+ import { openApiSpec } from "${n}/openapi";
12
+ import { createShardDO } from "${n}/shard";
13
+
14
+ export const ShardDO = createShardDO(${R});
15
+ ${h}
16
+
17
+ let worker;
18
+
19
+ export default {
20
+ async fetch(request, env, context) {
21
+ worker ??= composeWorker({${t?`
22
+ allowUnauthenticatedShardAccess: true,`:""}
23
+ functions: LUNORA_FUNCTIONS,
24
+ httpRouter: ${o.handler},
25
+ openApiSpec,
26
+ routes: {},
27
+ shardDO: env.SHARD,
28
+ });
29
+
30
+ return worker.fetch(request, env, context);
31
+ },
32
+ };
33
+ `},g=(r,e)=>{const s=A(r.projectRoot,r.generatedDir.replace(_,"")),a=S(r.projectRoot);return{load(t){if(t===m&&d(e)&&e.framework!==void 0){if(this.environment.name==="client")return L;const i=$.filter(o=>w(k(s,`${o}.ts`)));return N(e.framework.framework,s,i,a,r.allowUnauthenticatedShardAccess,r.shard)}},name:"lunora:framework-compose",resolveId(t){if(t===u&&d(e))return m}}};export{p as CLASS_A_WIRING,$ as GENERATED_CLASS_MODULES,u as LUNORA_WORKER_VIRTUAL_ID,m as RESOLVED_LUNORA_WORKER_ID,N as buildWorkerEntrySource,g as frameworkComposePlugin,d as isAutoComposable};
@@ -0,0 +1 @@
1
+ import{detectAgentRules as A}from"@lunora/config";import{transportRejectionReason as H,serveJsonHandler as p,handleSeedRequest as I,handleSchemaEditRequest as _,handlePolicyScaffoldRequest as D,isStandaloneModulePath as N,renderStudioHtml as P,resolveAdminToken as v,sendStudioDocument as C,SEED_ENDPOINT as E,SCHEMA_EDIT_ENDPOINT as $,POLICY_SCAFFOLD_ENDPOINT as x,studioAssetsStamp as O,loadStudioAssets as R,applyStudioAssetCache as U,readStandaloneAsset as B,assetContentType as k}from"@lunora/config/studio-host";const f="/__lunora",j=`${f}/studio.js`,m=`${f}/styles.css`,W=/^\//,g=/\/$/,w={[x]:D,[$]:_,[E]:I},y=(t,e,s)=>{t.statusCode=200,t.setHeader("Content-Type",s),t.end(e)},F=t=>{const e=f.replace(W,"");if(t.resolvedLocal!==void 0&&t.resolvedLocal!=="")return`${t.resolvedLocal.endsWith("/")?t.resolvedLocal.slice(0,-1):t.resolvedLocal}/${e}`;const s=t.base===void 0||t.base==="/"?"":t.base.replace(g,"");if(t.address===void 0||typeof t.address=="string")return`http://localhost:5173${s}/${e}`;const a=t.address.address==="::"||t.address.address==="0.0.0.0"?"localhost":t.address.address;return`http://${a.includes(":")?`[${a}]`:a}:${String(t.address.port)}${s}/${e}`},G=t=>{try{return new URL(t,"http://localhost").pathname.replace(g,"")}catch{return t}},J=(t,e,s)=>{let a,c,r;const{projectRoot:S}=s,T=t.config.base??"/",h=T==="/"?"":T.replace(g,""),L=(n,d,o)=>{const i=O();if((a===void 0||i!==c)&&(a=R(t.config.logger),c=i),a===void 0){o.statusCode=501,o.setHeader("Content-Type","text/plain"),o.end("Lunora studio assets not found — install and build @lunora/studio.");return}const l=n===m,u=n.slice(n.lastIndexOf("/")+1);if(U(d,o,u,i))return;if(l){y(o,a.styles,"text/css; charset=utf-8");return}const b=B(u);if(b===void 0){o.statusCode=404,o.setHeader("Content-Type","text/plain"),o.end("Not found");return}y(o,b,k(u))};return(n,d,o)=>{const i=G(n.url??""),l=h!==""&&i.startsWith(h)?i.slice(h.length):i;if(l!==f&&!l.startsWith(`${f}/`)){o();return}if(e||H(n,t.config.logger)!==void 0){d.statusCode=403,d.setHeader("Content-Type","text/plain"),d.end("Lunora studio is only available on loopback hosts in dev.");return}const u=w[l];if(u!==void 0){p(n,d,u,S,{apiSpec:s.apiSpec,schemaDirectory:s.schemaDir});return}if(l===m||N(l)){L(l,n,d);return}r??=P({adminToken:v(S),basePath:f,dataEditable:!0,rulesInstalled:A(S).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:j,styleHref:m}),C(d,r)}},q=t=>({apply:"serve",configureServer(e){const s=e.config.server?.host,a=s!==void 0&&s!==!1&&s!=="localhost"&&s!=="127.0.0.1"&&s!=="::1";return e.middlewares.use(J(e,a,t)),()=>{const c=()=>{const r=F({address:e.httpServer?.address()??void 0,base:e.config.base,resolvedLocal:e.resolvedUrls?.local[0]});e.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${r}\x1B[39m`)};if(typeof e.printUrls=="function"){const r=e.printUrls.bind(e);e.printUrls=()=>{r(),c()}}else e.httpServer?.listening===!0?c():e.httpServer?.once("listening",c)}},name:"lunora:studio"});export{f as STUDIO_PATH,j as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,F as buildStudioUrl,q as studioPlugin};
@@ -0,0 +1,3 @@
1
+ import{existsSync as j,readFileSync as K}from"node:fs";import{join as N,resolve as p,sep as R,basename as X}from"node:path";import{listLunoraSourceFiles as q,findTsconfig as Q,runCodegen as Y,describeErrorLevelFindings as Z,createCodegenProject as ee,refreshCodegenProject as ne,CodegenDiagnosticError as re}from"@lunora/codegen";import{LUNORA_CONFIG_FILE as U,isCodegenDisabled as te,CODEGEN_ENV as x,runPostCodegenHook as A,inferLunoraBindings as oe}from"@lunora/config";import{findWranglerFile as ie,readWranglerJsonc as ae,WRANGLER_FILES as ce,reconcileWranglerBindings as se,collectWranglerSecretVariables as le,reconcileWranglerCrons as de,reconcileWranglerCompatibilityDate as fe}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as ge}from"vite";import ue from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{L as f,a as F}from"./log-DE48L4Oz.mjs";import{createHash as he}from"node:crypto";import{r as me,a as pe}from"./server-close-Qoh4i6Ay.mjs";const L=(n,r)=>{try{const{parsed:t,text:e}=ae(n);return t===void 0?`raw:${e}`:JSON.stringify(r?r(t):t)}catch{return"unreadable"}},we=n=>{const r={...n},{triggers:t}=r;if(t!==null&&typeof t=="object"){const e={...t};delete e.crons,Object.keys(e).length>0?r.triggers=e:delete r.triggers}return r},T=n=>{const r=ie(n),t=r===void 0?"absent":L(r,we),e=N(n,U),i=j(e)?L(e):"absent";return`${t}\0${i}`},ye=100,V=300,M=2,$e=n=>{let r,t,e=0;const i=()=>{r&&(clearTimeout(r),r=void 0)},s=(u,h)=>{t&&clearTimeout(t),t=setTimeout(()=>{if(t=void 0,n.fingerprint()!==u){if(e+=1,e>M){n.logger.warn(`${f} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(M)} reruns. Make the hook idempotent or move it off the schema directory.`);return}n.logger.info(`${f} schema changed while \`postcodegen\` was running — regenerating`),h()}},V)},l=u=>{n.regenerate(u,h=>{s(h,()=>{l(u)})})};return{cancelPending:i,dispose:()=>{i(),t&&(clearTimeout(t),t=void 0)},onSave:u=>{i(),e=0,r=setTimeout(()=>{r=void 0,l(u)},ye)}}},G=n=>{if(!j(n))return"unreadable";const r=q(n),t=N(n,"schema.ts");j(t)&&r.push(t);const e=he("sha256");for(const i of r.toSorted((s,l)=>s.localeCompare(l)))try{e.update(i).update("\0").update(K(i))}catch{}return e.digest("hex")},I=/[/\\]tsconfig\..+\.json$/u,ve=n=>{const r=n.map(e=>` • ${e.kind} "${e.exportName}" — class ${e.className} is not exported by your worker entry.`),t=[...new Set(n.map(e=>e.module))].map(e=>` export * from "./lunora/_generated/${e}";`);return[`[lunora] ${String(n.length)} declared ${n.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
+ `)},Se=async(n,r,t)=>{try{const e=await oe({projectRoot:n.projectRoot,schemaDir:n.schemaDir}),i=se(n.projectRoot,e);i.changed&&r.info?.(`${f} inferred bindings → ${i.added.join(", ")} (written to ${i.wranglerPath??"wrangler.jsonc"})`);for(const s of i.warnings)r.warn(`${f} ${s}`);i.exportGaps.length>0&&t?.(i.exportGaps)}catch(e){const i=e instanceof Error?e.message:String(e);r.warn(`${f} binding inference skipped: ${i}`)}},Ee=(n,r,t)=>{try{const e=de(n,r);e.changed&&t.info?.(`${f} synced ${r.length.toFixed(0)} cron trigger(s) into ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const i=e instanceof Error?e.message:String(e);t.warn(`${f} cron trigger sync skipped: ${i}`)}try{const e=fe(n);e.changed&&t.info?.(`${f} bumped compatibility_date to ${e.date??"unknown"} (Workers Cache enabled) → ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const i=e instanceof Error?e.message:String(e);t.warn(`${f} compatibility date sync skipped: ${i}`)}},be=n=>{const{advisoryNames:r,platformDiagnosticNames:t}=Z(n),e=[...new Set([...r,...t])].toSorted((s,l)=>s.localeCompare(l));if(e.length===0)return;const i=e.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${f} ${String(e.length)} ERROR-level ${i} (${e.join(", ")}) — see the log above for detail.`},Re=(n,r,t)=>{if(r.warn(`${f} schema.ts not found at ${n} — codegen skipped`),t!==void 0){const e=`schema.ts not found at ${n} — generated output is now stale`;t.onError(new Error(e),e)}},B=(n,r,t,e)=>{const i=N(n.projectRoot,n.schemaDir,"schema.ts");if(!j(i))return Re(i,r,t),{};try{const s=Y({apiSpec:n.apiSpec,lunoraDirectory:n.schemaDir,project:e,projectRoot:n.projectRoot,target:n.target,wranglerVariables:le(n.projectRoot)});Ee(n.projectRoot,s.cronTriggers,r);for(const l of s.advisories){const u=F(l.level,l.name,l.detail,l.remediation);l.level==="ERROR"?r.error(u):r.warn(u)}for(const l of s.platformDiagnostics){const u=F(l.level==="error"?"ERROR":"WARN",l.name,l.message,l.remediation);l.level==="error"?r.error(u):r.warn(u)}return{blockingMessage:be(s),outputDirectory:p(s.outputDirectory)}}catch(s){const l=s instanceof Error?s.message:String(s);return r.error(`${f} codegen failed: ${l}`),t?.onError(s,l),{failure:`${f} codegen failed: ${l}`}}},ke=(n,r,t)=>{let e;for(const[i,s]of Object.entries(n.environments)){if(i==="client"){e=s;continue}ge(s)||s.hot.send({path:"*",triggeredBy:r,type:"full-reload"})}if(e===void 0){n.hot.send({type:"full-reload"});return}if(t){e.hot.send({type:"full-reload"});return}e.hot.send({event:ue,type:"custom"})},Ae=n=>{const r=p(n.projectRoot,n.schemaDir),t=te(process.env[x]);let e=p(n.projectRoot,n.generatedDir),i=0,s=!1,l;const u=new Map;let h,C=!1,D=!1,b;return{config(o,w){b=w.command},async buildStart(){const o={error:g=>{console.error(g)},info:g=>{console.info(g)},warn:g=>{console.warn(g)}},w=b!=="build"&&t,{blockingMessage:y,failure:k,outputDirectory:$}=w?{}:B(n,o);if(b==="build"&&k!==void 0&&this.error(k),$!==void 0){e=$,s=!0;let g;try{g=await A({cwd:n.projectRoot,logger:o})}finally{s=!1}g.ran&&(i=Date.now()),b==="build"&&g.error!==void 0&&this.error(g.error)}b==="build"&&y!==void 0&&this.error(y),await Se(n,o,g=>{l?.hot.send({err:{loc:void 0,message:ve(g),stack:""},type:"error"})}),l!==void 0&&(h=T(n.projectRoot),C=!0)},configureServer(o){l=o,o.watcher.add(r),h=T(n.projectRoot),C=!1;const w={error:a=>{o.config.logger.error(a)},info:a=>{o.config.logger.info(a)},warn:a=>{o.config.logger.warn(a)}};let y=!1;const k={onError(a,c){y=!0;const d=a instanceof re?{column:a.column,file:a.file,line:a.line}:void 0,E=d===void 0?`[lunora] codegen failed: ${c}
3
+ (see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${c}`;l?.hot.send({err:{loc:d,message:E,stack:a instanceof Error?a.stack??"":""},type:"error"})}},$=(a,c)=>a===c||a.startsWith(c+R);let g=!1,m;const H=()=>{for(const a of Object.values(o.environments)){const c=a.moduleGraph;for(const d of c.idToModuleMap.values())d.id&&$(d.id,e)&&c.invalidateModule(d)}},J=async(a,c)=>{try{if(g)return;m===void 0?m=ee(r):ne(m,r);const{outputDirectory:d}=B(n,w,k,m);if(d===void 0){m=void 0;return}e=d;const E=G(r);s=!0;let P;try{P=await A({cwd:n.projectRoot,logger:w})}finally{s=!1}if(P.ran&&(i=Date.now(),c(E)),P.error!==void 0)return;H(),ke(o,a,y),y=!1}catch(d){w.error(`${f} codegen watch: ${d instanceof Error?d.message:String(d)}`)}},_=$e({fingerprint:()=>G(r),logger:w,regenerate:(a,c)=>{J(a,c)}}),v=a=>{const c=p(a);if(I.test(c)){m=void 0;return}if(c.endsWith(`${R}tsconfig.json`)&&c===Q(r)){m=void 0;return}if($(c,r)&&!$(c,e)&&c.endsWith(".ts")&&!(c.includes(`${R}__tests__${R}`)||c.endsWith(".test.ts")||c.endsWith(".spec.ts"))){if(s||Date.now()-i<V){_.cancelPending();return}_.onSave(c)}},O=a=>{const c=p(a);(c.endsWith(`${R}tsconfig.json`)||I.test(c))&&(m=void 0)};t?o.config.logger.info(`${f} codegen watch disabled (${x}) — _generated/ is written only by an explicit \`lunora codegen\``):(o.watcher.on("add",v),o.watcher.on("change",v),o.watcher.on("unlink",v),o.watcher.on("unlink",O));const W=new Set([...ce.map(a=>p(n.projectRoot,a)),p(n.projectRoot,U)]);for(const a of W)o.watcher.add(a);const S=a=>{if(!W.has(p(a))||D)return;const c=T(n.projectRoot);if(!C){h=c;return}if(h===void 0){h=c;return}c!==h&&(h=c,D=!0,o.config.logger.info(`${f} ${X(p(a))} changed — restarting dev server`),Promise.resolve(o.restart()).finally(()=>{D=!1}).catch(d=>{const E=d instanceof Error?d.message:String(d);o.config.logger.error(`${f} dev server restart failed: ${E} — keeping the running server; re-save your config to retry.`),o.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${E}`,stack:""},type:"error"})}))};o.watcher.on("add",S),o.watcher.on("change",S),o.watcher.on("unlink",S);const z=()=>{g||(g=!0,m=void 0,_.dispose(),o.watcher.off("add",v),o.watcher.off("change",v),o.watcher.off("unlink",v),o.watcher.off("unlink",O),o.watcher.off("add",S),o.watcher.off("change",S),o.watcher.off("unlink",S))};return()=>{pe(o,u,z)}},buildEnd(){me(u,this.environment)},name:"lunora:codegen"}};export{Ae as codegenPlugin,Se as reconcileBindingsSafely};
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
1
+ import{readProjectRemotePreference as c}from"@lunora/config";import{resolveRemoteEnabled as f,materializeRemoteWranglerConfig as s}from"@lunora/config/cloudflare";import{l as a}from"./log-DE48L4Oz.mjs";const d=()=>{},P=e=>{const n=e.readPreference??c;if(!f({configPreference:n(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:d,enabled:!1};const r=(e.materialize??s)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:r.cleanup,configPath:r.configPath,enabled:!0,reason:r.reason}},g=(e,n)=>!n.enabled||n.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:n.configPath},h=(e,n)=>({config(t,o){if(o.command!=="serve")return;if(e===void 0){n.enabled&&n.configPath!==void 0&&console.info(a(`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=g(e,n),i=e;r.configPath!==void 0&&i.configPath===void 0?i.configPath=r.configPath:n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(a(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings-config"}),b=e=>({buildEnd(){e()},closeBundle(){e()},enforce:"pre",name:"lunora:remote-bindings-cleanup"});export{P as planViteRemoteBindings,b as remoteBindingsCleanupPlugin,h as remoteBindingsConfigPlugin,g as withRemoteBindings};
@@ -0,0 +1,3 @@
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{reconcileBindingsSafely as g}from"./codegenPlugin-DVaxvj10.mjs";import{l as a}from"./log-DE48L4Oz.mjs";const f=r=>r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"),w=()=>{try{return i("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},u=(r,o=w)=>{const{parsed:e}=c(r);!(e?.containers??[]).some(t=>typeof t?.image=="string"&&f(t.image))||o()||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,o)=>{const e=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...o.map(n=>` - ${n}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(e.join(`
2
+ `))},D=r=>{let o=!1;return{config(e,n){o=n.isPreview===!0},async configResolved(){if(o)return;await g(r,{info:n=>{console.info(n)},warn:n=>{console.warn(n)}});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 n of e.report.warnings)console.warn(a(`wrangler validator: ${n}`));if(e.problems.length>0)throw d(e.wranglerPath,e.problems);u(e.wranglerPath)},name:"lunora:wrangler-validator"}};export{u as warnWhenDockerMissing,D as wranglerValidatorPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.184",
3
+ "version": "1.0.0-alpha.186",
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,9 +46,9 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@cloudflare/vite-plugin": "1.51.2",
49
- "@lunora/codegen": "1.0.0-alpha.150",
50
- "@lunora/config": "1.0.0-alpha.184",
51
- "@lunora/errors": "1.0.0-alpha.29",
49
+ "@lunora/codegen": "1.0.0-alpha.152",
50
+ "@lunora/config": "1.0.0-alpha.186",
51
+ "@lunora/errors": "1.0.0-alpha.30",
52
52
  "@visulima/vite-overlay": "2.0.12"
53
53
  },
54
54
  "peerDependencies": {
@@ -1,33 +0,0 @@
1
- import{existsSync as S,readFileSync as w}from"node:fs";import{resolve as A,join as m}from"node:path";import{LunoraError as O}from"@lunora/errors";const p="virtual:lunora/worker",E="\0",d=`${E}${p}`,L=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
2
- export default {};
3
- `,N=/\/$/,f={"react-router":{handler:'{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',imports:'import { createRequestHandler } from "react-router";'},"solid-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@solidjs/start/server-handler";'},"tanstack-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/react-start/server-entry";'},"tanstack-start-solid":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/solid-start/server-entry";'},vinext:{handler:"ssrModule.default",imports:'import * as ssrModule from "vinext/server/fetch-handler";'}},u=e=>{const r=e.framework;return r?.class==="A"&&f[r.framework]!==void 0},_=e=>{try{const r=JSON.parse(w(m(e,"package.json"),"utf8"));return["dependencies","devDependencies","peerDependencies"].some(t=>r[t]?.lunorash!==void 0)}catch{return!1}},$=["agents","containers","workflows"],D=(e,r,t=[],a=!1,o=!1,i={})=>{const s=f[e];if(s===void 0)throw new O("INTERNAL",`[lunora] no class-A worker wiring for framework "${e}"`);const n=r.replaceAll("\\","/"),h=a?"lunorash/runtime":"@lunora/runtime",v=t.map(c=>`
4
- export * from "${n}/${c}";
5
- `).join(""),l=JSON.stringify(Object.fromEntries(Object.entries(i).toSorted(([c],[R])=>c.localeCompare(R)))),k=l==="{}"?"":l;return`// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
6
- // Do not edit: emitted from the detected framework (${e}). Point your
7
- // wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
8
- import { composeWorker } from "${h}";
9
- ${s.imports}
10
- import { LUNORA_FUNCTIONS } from "${n}/functions";
11
- import { openApiSpec } from "${n}/openapi";
12
- import { createShardDO } from "${n}/shard";
13
-
14
- export const ShardDO = createShardDO(${k});
15
- ${v}
16
-
17
- let worker;
18
-
19
- export default {
20
- async fetch(request, env, context) {
21
- worker ??= composeWorker({${o?`
22
- allowUnauthenticatedShardAccess: true,`:""}
23
- functions: LUNORA_FUNCTIONS,
24
- httpRouter: ${s.handler},
25
- openApiSpec,
26
- routes: {},
27
- shardDO: env.SHARD,
28
- });
29
-
30
- return worker.fetch(request, env, context);
31
- },
32
- };
33
- `},M=(e,r)=>{const t=A(e.projectRoot,e.generatedDir.replace(N,"")),a=_(e.projectRoot);return{load(o){if(o===d&&u(r)&&r.framework!==void 0){if(this.environment.name==="client")return L;const i=$.filter(s=>S(m(t,`${s}.ts`)));return D(r.framework.framework,t,i,a,e.allowUnauthenticatedShardAccess,e.shard)}},name:"lunora:framework-compose",resolveId(o){if(o===p&&u(r))return d}}};export{f as CLASS_A_WIRING,$ as GENERATED_CLASS_MODULES,p as LUNORA_WORKER_VIRTUAL_ID,d as RESOLVED_LUNORA_WORKER_ID,D as buildWorkerEntrySource,M as frameworkComposePlugin,u as isAutoComposable};
@@ -1 +0,0 @@
1
- const o="WORKER_ENV",a="development",r=(n,t)=>{const e=n.config;return{...n,config:c=>{if(typeof e=="function"){const s=e(c);s&&Object.assign(c,s)}else e&&Object.assign(c,e);t()&&(c.vars={[o]:a,...c.vars})}}},i=()=>{let n;return{isServe:()=>n==="serve",plugin:{config(t,e){n=e.command},enforce:"pre",name:"lunora:command-probe"}}};export{a as DEV_WORKER_ENV_VALUE,o as DEV_WORKER_ENV_VAR,i as createCommandProbe,r as withDevWorkerEnv};
@@ -1 +0,0 @@
1
- import{detectAgentRules as L}from"@lunora/config";import{transportRejectionReason as b,serveJsonHandler as y,handleSeedRequest as A,handleSchemaEditRequest as H,handlePolicyScaffoldRequest as I,isStandaloneModulePath as _,renderStudioHtml as N,resolveAdminToken as p,sendStudioDocument as v,SEED_ENDPOINT as C,SCHEMA_EDIT_ENDPOINT as E,POLICY_SCAFFOLD_ENDPOINT as $,studioAssetsStamp as D,loadStudioAssets as O,applyStudioAssetCache as P,readStandaloneAsset as x,assetContentType as R}from"@lunora/config/studio-host";const i="/__lunora",U=`${i}/studio.js`,S=`${i}/styles.css`,k=/^\//,g=/\/$/,B={[$]:I,[E]:H,[C]:A},m=(t,e,o)=>{t.statusCode=200,t.setHeader("Content-Type",o),t.end(e)},j=t=>{const e=i.replace(k,"");if(t.resolvedLocal!==void 0&&t.resolvedLocal!=="")return`${t.resolvedLocal.endsWith("/")?t.resolvedLocal.slice(0,-1):t.resolvedLocal}/${e}`;const o=t.base===void 0||t.base==="/"?"":t.base.replace(g,"");if(t.address===void 0||typeof t.address=="string")return`http://localhost:5173${o}/${e}`;const n=t.address.address==="::"||t.address.address==="0.0.0.0"?"localhost":t.address.address;return`http://${n.includes(":")?`[${n}]`:n}:${String(t.address.port)}${o}/${e}`},w=t=>{try{return new URL(t,"http://localhost").pathname.replace(g,"")}catch{return t}},F=(t,e)=>{let o,n,r;const c=t.config.root??process.cwd(),T=(d,l,s)=>{const a=D();if((o===void 0||a!==n)&&(o=O(t.config.logger),n=a),o===void 0){s.statusCode=501,s.setHeader("Content-Type","text/plain"),s.end("Lunora studio assets not found — install and build @lunora/studio.");return}const u=d===S,f=d.slice(d.lastIndexOf("/")+1);if(P(l,s,f,a))return;if(u){m(s,o.styles,"text/css; charset=utf-8");return}const h=x(f);if(h===void 0){s.statusCode=404,s.setHeader("Content-Type","text/plain"),s.end("Not found");return}m(s,h,R(f))};return(d,l,s)=>{const a=w(d.url??"");if(a!==i&&!a.startsWith(`${i}/`)){s();return}if(e||b(d,t.config.logger)!==void 0){l.statusCode=403,l.setHeader("Content-Type","text/plain"),l.end("Lunora studio is only available on loopback hosts in dev.");return}const u=B[a];if(u!==void 0){y(d,l,u,c);return}if(a===S||_(a)){T(a,d,l);return}r??=N({adminToken:p(c),basePath:i,dataEditable:!0,rulesInstalled:L(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:U,styleHref:S}),v(l,r)}},M=()=>({apply:"serve",configureServer(t){const e=t.config.server?.host,o=e!==void 0&&e!==!1&&e!=="localhost"&&e!=="127.0.0.1"&&e!=="::1";return t.middlewares.use(F(t,o)),()=>{const n=()=>{const r=j({address:t.httpServer?.address()??void 0,base:t.config.base,resolvedLocal:t.resolvedUrls?.local[0]});t.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${r}\x1B[39m`)};if(typeof t.printUrls=="function"){const r=t.printUrls.bind(t);t.printUrls=()=>{r(),n()}}else t.httpServer?.listening===!0?n():t.httpServer?.once("listening",n)}},name:"lunora:studio"});export{i as STUDIO_PATH,U as STUDIO_SCRIPT_PATH,S as STUDIO_STYLE_PATH,j as buildStudioUrl,M as studioPlugin};
@@ -1,3 +0,0 @@
1
- import{createHash as X}from"node:crypto";import{existsSync as H,readdirSync as q,readFileSync as Q}from"node:fs";import{join as O,resolve as p,sep as k,basename as Y}from"node:path";import{findTsconfig as Z,runCodegen as ee,createCodegenProject as re,refreshCodegenProject as ne,describeErrorLevelFindings as te,CodegenDiagnosticError as oe}from"@lunora/codegen";import{LUNORA_CONFIG_FILE as J,isCodegenDisabled as ie,CODEGEN_ENV as F,runPostCodegenHook as A,inferLunoraBindings as ae}from"@lunora/config";import{findWranglerFile as ce,readWranglerJsonc as se,WRANGLER_FILES as le,collectWranglerSecretVariables as de,reconcileWranglerBindings as fe,reconcileWranglerCrons as ge,reconcileWranglerCompatibilityDate as ue}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as me}from"vite";import he from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{L as f,a as M}from"./log-DE48L4Oz.mjs";import{r as pe,a as we}from"./server-close-Qoh4i6Ay.mjs";const L=(r,n)=>{try{const{parsed:o,text:e}=se(r);return o===void 0?`raw:${e}`:JSON.stringify(n?n(o):o)}catch{return"unreadable"}},ye=r=>{const n={...r},{triggers:o}=n;if(o!==null&&typeof o=="object"){const e={...o};delete e.crons,Object.keys(e).length>0?n.triggers=e:delete n.triggers}return n},N=r=>{const n=ce(r),o=n===void 0?"absent":L(n,ye),e=O(r,J),s=H(e)?L(e):"absent";return`${o}\0${s}`},$e=100,G=300,I=2,B=(r,n)=>{let o;try{o=q(r,{recursive:!0,withFileTypes:!0})}catch{return"unreadable"}const e=X("sha256"),s=o.filter(t=>t.isFile()&&t.name.endsWith(".ts")).map(t=>O(t.parentPath,t.name)).filter(t=>!(t===n||t.startsWith(n+k))).toSorted((t,l)=>t.localeCompare(l));for(const t of s)try{e.update(t).update("\0").update(Q(t))}catch{}return e.digest("hex")},U=/[/\\]tsconfig\..+\.json$/u,ve=r=>{const n=r.map(e=>` • ${e.kind} "${e.exportName}" — class ${e.className} is not exported by your worker entry.`),o=[...new Set(r.map(e=>e.module))].map(e=>` export * from "./lunora/_generated/${e}";`);return[`[lunora] ${String(r.length)} declared ${r.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=async(r,n,o)=>{try{const e=await ae({projectRoot:r.projectRoot,schemaDir:r.schemaDir}),s=fe(r.projectRoot,e);s.changed&&n.info?.(`${f} inferred bindings → ${s.added.join(", ")} (written to ${s.wranglerPath??"wrangler.jsonc"})`);for(const t of s.warnings)n.warn(`${f} ${t}`);s.exportGaps.length>0&&o?.(s.exportGaps)}catch(e){const s=e instanceof Error?e.message:String(e);n.warn(`${f} binding inference skipped: ${s}`)}},be=(r,n,o)=>{try{const e=ge(r,n);e.changed&&o.info?.(`${f} synced ${n.length.toFixed(0)} cron trigger(s) into ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const s=e instanceof Error?e.message:String(e);o.warn(`${f} cron trigger sync skipped: ${s}`)}try{const e=ue(r);e.changed&&o.info?.(`${f} bumped compatibility_date to ${e.date??"unknown"} (Workers Cache enabled) → ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const s=e instanceof Error?e.message:String(e);o.warn(`${f} compatibility date sync skipped: ${s}`)}},Se=r=>{const{advisoryNames:n,platformDiagnosticNames:o}=te(r),e=[...new Set([...n,...o])].toSorted((t,l)=>t.localeCompare(l));if(e.length===0)return;const s=e.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${f} ${String(e.length)} ERROR-level ${s} (${e.join(", ")}) — see the log above for detail.`},Re=(r,n,o)=>{if(n.warn(`${f} schema.ts not found at ${r} — codegen skipped`),o!==void 0){const e=`schema.ts not found at ${r} — generated output is now stale`;o.onError(new Error(e),e)}},V=(r,n,o,e)=>{const s=O(r.projectRoot,r.schemaDir,"schema.ts");if(!H(s))return Re(s,n,o),{};try{const t=ee({apiSpec:r.apiSpec,lunoraDirectory:r.schemaDir,project:e,projectRoot:r.projectRoot,target:r.target,wranglerVariables:de(r.projectRoot)});be(r.projectRoot,t.cronTriggers,n);for(const l of t.advisories){const w=M(l.level,l.name,l.detail,l.remediation);l.level==="ERROR"?n.error(w):n.warn(w)}for(const l of t.platformDiagnostics){const w=M(l.level==="error"?"ERROR":"WARN",l.name,l.message,l.remediation);l.level==="error"?n.error(w):n.warn(w)}return{blockingMessage:Se(t),outputDirectory:p(t.outputDirectory)}}catch(t){const l=t instanceof Error?t.message:String(t);return n.error(`${f} codegen failed: ${l}`),o?.onError(t,l),{failure:`${f} codegen failed: ${l}`}}},ke=(r,n,o)=>{let e;for(const[s,t]of Object.entries(r.environments)){if(s==="client"){e=t;continue}me(t)||t.hot.send({path:"*",triggeredBy:n,type:"full-reload"})}if(e===void 0){r.hot.send({type:"full-reload"});return}if(o){e.hot.send({type:"full-reload"});return}e.hot.send({event:he,type:"custom"})},Fe=r=>{const n=p(r.projectRoot,r.schemaDir),o=ie(process.env[F]);let e=p(r.projectRoot,r.generatedDir),s=0,t=!1,l;const w=new Map;let $,D=!1,T=!1,j;return{config(a,m){j=m.command},async buildStart(){const a={error:d=>{console.error(d)},info:d=>{console.info(d)},warn:d=>{console.warn(d)}},m=j!=="build"&&o,{blockingMessage:E,failure:C,outputDirectory:b}=m?{}:V(r,a);if(j==="build"&&C!==void 0&&this.error(C),b!==void 0){e=b,t=!0;let d;try{d=await A({cwd:r.projectRoot,logger:a})}finally{t=!1}d.ran&&(s=Date.now()),j==="build"&&d.error!==void 0&&this.error(d.error)}j==="build"&&E!==void 0&&this.error(E),await Ee(r,a,d=>{l?.hot.send({err:{loc:void 0,message:ve(d),stack:""},type:"error"})}),l!==void 0&&($=N(r.projectRoot),D=!0)},configureServer(a){l=a,a.watcher.add(n),$=N(r.projectRoot),D=!1;const m={error:c=>{a.config.logger.error(c)},info:c=>{a.config.logger.info(c)},warn:c=>{a.config.logger.warn(c)}};let E=!1;const C={onError(c,i){E=!0;const g=c instanceof oe?{column:c.column,file:c.file,line:c.line}:void 0,y=g===void 0?`[lunora] codegen failed: ${i}
3
- (see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${i}`;l?.hot.send({err:{loc:g,message:y,stack:c instanceof Error?c.stack??"":""},type:"error"})}},b=(c,i)=>c===i||c.startsWith(i+k);let d=!1,u,v,_=0,h;const z=()=>{for(const c of Object.values(a.environments)){const i=c.moduleGraph;for(const g of i.idToModuleMap.values())g.id&&b(g.id,e)&&i.invalidateModule(g)}},W=async c=>{try{if(d)return;h===void 0?h=re(n):ne(h,n);const{outputDirectory:i}=V(r,m,C,h);if(i===void 0){h=void 0;return}e=i;const g=B(n,e);t=!0;let y;try{y=await A({cwd:r.projectRoot,logger:m})}finally{t=!1}if(y.ran&&(s=Date.now(),v&&clearTimeout(v),v=setTimeout(()=>{if(v=void 0,!(d||B(n,e)===g)){if(_+=1,_>I){m.warn(`${f} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(I)} reruns. Make the hook idempotent or move it off the schema directory.`);return}m.info(`${f} schema changed while \`postcodegen\` was running — regenerating`),W(c)}},G)),y.error!==void 0)return;z(),ke(a,c,E),E=!1}catch(i){m.error(`${f} codegen watch: ${i instanceof Error?i.message:String(i)}`)}},S=c=>{const i=p(c);if(U.test(i)){h=void 0;return}if(i.endsWith(`${k}tsconfig.json`)&&i===Z(n)){h=void 0;return}if(b(i,n)&&!b(i,e)&&i.endsWith(".ts")&&!(i.includes(`${k}__tests__${k}`)||i.endsWith(".test.ts")||i.endsWith(".spec.ts"))){if(t||Date.now()-s<G){u&&(clearTimeout(u),u=void 0);return}u&&clearTimeout(u),_=0,u=setTimeout(()=>{u=void 0,W(i)},$e)}},P=c=>{const i=p(c);(i.endsWith(`${k}tsconfig.json`)||U.test(i))&&(h=void 0)};o?a.config.logger.info(`${f} codegen watch disabled (${F}) — _generated/ is written only by an explicit \`lunora codegen\``):(a.watcher.on("add",S),a.watcher.on("change",S),a.watcher.on("unlink",S),a.watcher.on("unlink",P));const x=new Set([...le.map(c=>p(r.projectRoot,c)),p(r.projectRoot,J)]);for(const c of x)a.watcher.add(c);const R=c=>{if(!x.has(p(c))||T)return;const i=N(r.projectRoot);if(!D){$=i;return}if($===void 0){$=i;return}i!==$&&($=i,T=!0,a.config.logger.info(`${f} ${Y(p(c))} changed — restarting dev server`),Promise.resolve(a.restart()).finally(()=>{T=!1}).catch(g=>{const y=g instanceof Error?g.message:String(g);a.config.logger.error(`${f} dev server restart failed: ${y} — keeping the running server; re-save your config to retry.`),a.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${y}`,stack:""},type:"error"})}))};a.watcher.on("add",R),a.watcher.on("change",R),a.watcher.on("unlink",R);const K=()=>{d||(d=!0,h=void 0,u&&(clearTimeout(u),u=void 0),v&&(clearTimeout(v),v=void 0),a.watcher.off("add",S),a.watcher.off("change",S),a.watcher.off("unlink",S),a.watcher.off("unlink",P),a.watcher.off("add",R),a.watcher.off("change",R),a.watcher.off("unlink",R))};return()=>{we(a,w,K)}},buildEnd(){pe(w,this.environment)},name:"lunora:codegen"}};export{Fe as default};
@@ -1 +0,0 @@
1
- import{ensureDevVariables as a,createConfirm as n,fillDevSecrets as c}from"@lunora/config";import{l}from"./log-DE48L4Oz.mjs";const s=e=>({apply:"serve",async configResolved(){const o=r=>{console.info(l(r))};await a({confirm:n("[lunora] "),cwd:e.projectRoot,info:o}),c({cwd:e.projectRoot,info:o})},enforce:"pre",name:"lunora:dev-vars"});export{s as default};
@@ -1 +0,0 @@
1
- import{readProjectRemotePreference as a}from"@lunora/config";import{resolveRemoteEnabled as c,materializeRemoteWranglerConfig as f}from"@lunora/config/cloudflare";import{l as g}from"./log-DE48L4Oz.mjs";const d=()=>{},P=e=>{const n=e.readPreference??a;if(!c({configPreference:n(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:d,enabled:!1};const r=(e.materialize??f)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:r.cleanup,configPath:r.configPath,enabled:!0,reason:r.reason}},s=(e,n)=>!n.enabled||n.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:n.configPath},b=(e,n)=>({config(o,t){if(t.command!=="serve")return;const r=s(e,n),i=e;r.configPath!==void 0&&i.configPath===void 0?i.configPath=r.configPath:n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(g(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings-config"}),h=e=>({buildEnd(){e()},closeBundle(){e()},enforce:"pre",name:"lunora:remote-bindings-cleanup"});export{P as planViteRemoteBindings,h as remoteBindingsCleanupPlugin,b as remoteBindingsConfigPlugin,s as withRemoteBindings};
@@ -1,3 +0,0 @@
1
- import{spawnSync as s}from"node:child_process";import{validateWranglerProject as i,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"),d=()=>{try{return s("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},u=(r,e=d)=>{const{parsed:n}=c(r);!(n?.containers??[]).some(t=>typeof t?.image=="string"&&g(t.image))||e()||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."))},f=(r,e)=>{const n=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...e.map(o=>` - ${o}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(n.join(`
2
- `))},b=r=>({configResolved(){const e=i({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 n of e.report.warnings)console.warn(a(`wrangler validator: ${n}`));if(e.problems.length>0)throw f(e.wranglerPath,e.problems);u(e.wranglerPath)},name:"lunora:wrangler-validator"});export{u as warnWhenDockerMissing,b as wranglerValidatorPlugin};