@lunora/vite 1.0.0-alpha.189 → 1.0.0-alpha.190

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
@@ -356,6 +356,9 @@ interface PlanViteRemoteOptions {
356
356
  *
357
357
  * There is no `--remote` flag on the Vite path (Vite has no Lunora CLI flags),
358
358
  * so the precedence reduces to `LUNORA_REMOTE` env > `lunora.json` `remote`.
359
+ *
360
+ * Call this from a `config` hook, never at plugin-factory time — see
361
+ * {@link remoteBindingsPlugin} for the two defects that timing caused.
359
362
  */
360
363
  declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRemotePlan;
361
364
  /**
@@ -365,24 +368,42 @@ declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRe
365
368
  * wins (their explicit choice).
366
369
  *
367
370
  * Pure decision only — the serve-vs-build gate lives in
368
- * {@link remoteBindingsConfigPlugin}'s `config` hook, because the resolved Vite
369
- * `command` is unknown at plugin-factory time (when this runs). An eager serve
370
- * check here would always read `command` as undefined and strip `configPath`.
371
+ * {@link remoteBindingsPlugin}'s `config` hook, because the resolved Vite
372
+ * `command` is unknown at plugin-factory time. An eager serve check there would
373
+ * always read `command` as undefined and strip `configPath`.
371
374
  */
372
375
  declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteRemotePlan) => CloudflarePluginOptions;
373
376
  /**
374
- * A `enforce: "pre"` plugin whose `config` hook injects the materialized remote
375
- * temp config into the cloudflare plugin's `configPath` — but only on a `vite`
376
- * serve, never a production build (so the deployed worker is never affected).
377
- *
378
- * The deferral is the whole point: at plugin-factory time Vite has not yet told
379
- * us `serve` vs `build`, so the check must run in a `config` hook (where
380
- * `env.command` is known). It mutates the SAME options object handed to
381
- * `cloudflare()` in place — the cloudflare plugin reads `pluginConfig.configPath`
382
- * lazily inside its own `config` hook, which runs after this `enforce: "pre"`
383
- * one, so the injection takes effect. An eager factory-time serve check (the old
384
- * behaviour) always saw `command` undefined and silently dropped the path, so
385
- * remote bindings never activated on `vite dev`.
377
+ * A `enforce: "pre"` plugin that materializes the remote temp wrangler config
378
+ * and injects it into the cloudflare plugin's `configPath` — but only on a
379
+ * `vite` serve, never a production build (so the deployed worker is never
380
+ * affected) — then disposes the temp file when the dev server tears down.
381
+ *
382
+ * Both halves are deferred into the `config` hook, and each deferral closes a
383
+ * defect of its own.
384
+ *
385
+ * The command check: at plugin-factory time Vite has not yet resolved `serve`
386
+ * vs `build`, so it has to run here. An eager factory-time check always read
387
+ * `command` as undefined and stripped `configPath`, so remote bindings never
388
+ * activated on `vite dev` at all.
389
+ *
390
+ * The materialization: the temp config is a COPY of `wrangler.jsonc`, and
391
+ * Lunora provisions the bindings the project's code implies from
392
+ * `wranglerValidatorPlugin`'s own `config` hook — earlier in this same phase,
393
+ * since both are `enforce: "pre"` and that plugin is registered first. Copying
394
+ * the file at factory time therefore snapshotted it BEFORE that write, and the
395
+ * dev worker booted against a config missing the binding Lunora had just added:
396
+ * a `vite dev` that logged `inferred bindings → AI (Workers AI)`, passed
397
+ * validation, and served a worker with no `env.AI`. That is the remote twin of
398
+ * the local defect the reconcile's move into `config` fixed.
399
+ *
400
+ * The injection mutates the SAME options object handed to `cloudflare()` in
401
+ * place — the cloudflare plugin reads `pluginConfig.configPath` lazily inside
402
+ * its own `config` hook, which runs after this `enforce: "pre"` one, so the
403
+ * injection takes effect.
404
+ *
405
+ * The disposer reads the CURRENT plan rather than a factory-time capture,
406
+ * because no plan exists until `config` has run.
386
407
  *
387
408
  * When remote mode was requested but nothing materialized (no eligible binding,
388
409
  * no wrangler file, …), the plan's `reason` is logged so the degradation isn't
@@ -393,13 +414,7 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
393
414
  * inject into: the materialized path is printed with what to do with it, rather
394
415
  * than leaving `LUNORA_REMOTE` looking like it took effect.
395
416
  */
396
- declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions | undefined, plan: ViteRemotePlan) => Plugin;
397
- /**
398
- * A tiny Vite plugin that runs the remote temp-config disposer when the dev
399
- * server tears down (`buildEnd` fires on close in serve; `closeBundle` covers
400
- * the build/close path). Idempotent cleanup means firing on both is safe.
401
- */
402
- declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
417
+ declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions) => Plugin;
403
418
  /**
404
419
  * A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
405
420
  * options type so the shape can't drift from the installed package. The overlay
@@ -502,14 +517,13 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
502
517
  * validation logic to `@lunora/config` so the rules stay in lockstep with
503
518
  * the CLI (`lunora deploy`).
504
519
  *
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.
520
+ * Provisioning runs BEFORE this, in `bindingsProvisionPlugin`'s `config` hook,
521
+ * which is the order `lunora dev` uses (infer → reconcile, no validation pass):
522
+ * the bindings this check requires are the ones Lunora writes itself, so
523
+ * validating first killed the dev server the first time a project declared a
524
+ * `.global()` table or a container. That plugin is registered unconditionally and
525
+ * ahead of this one — the write is not optional the way the check is, and it must
526
+ * land in `config` to reach the worker at all (see its docblock).
513
527
  *
514
528
  * Skipped under `vite preview`, which resolves with `command: "serve"` and so
515
529
  * runs `apply: "serve"` plugins: previewing a built app must not probe Docker.
@@ -540,4 +554,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
540
554
  */
541
555
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
542
556
  declare const VERSION: string;
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 };
557
+ 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, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.d.ts CHANGED
@@ -356,6 +356,9 @@ interface PlanViteRemoteOptions {
356
356
  *
357
357
  * There is no `--remote` flag on the Vite path (Vite has no Lunora CLI flags),
358
358
  * so the precedence reduces to `LUNORA_REMOTE` env > `lunora.json` `remote`.
359
+ *
360
+ * Call this from a `config` hook, never at plugin-factory time — see
361
+ * {@link remoteBindingsPlugin} for the two defects that timing caused.
359
362
  */
360
363
  declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRemotePlan;
361
364
  /**
@@ -365,24 +368,42 @@ declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRe
365
368
  * wins (their explicit choice).
366
369
  *
367
370
  * Pure decision only — the serve-vs-build gate lives in
368
- * {@link remoteBindingsConfigPlugin}'s `config` hook, because the resolved Vite
369
- * `command` is unknown at plugin-factory time (when this runs). An eager serve
370
- * check here would always read `command` as undefined and strip `configPath`.
371
+ * {@link remoteBindingsPlugin}'s `config` hook, because the resolved Vite
372
+ * `command` is unknown at plugin-factory time. An eager serve check there would
373
+ * always read `command` as undefined and strip `configPath`.
371
374
  */
372
375
  declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteRemotePlan) => CloudflarePluginOptions;
373
376
  /**
374
- * A `enforce: "pre"` plugin whose `config` hook injects the materialized remote
375
- * temp config into the cloudflare plugin's `configPath` — but only on a `vite`
376
- * serve, never a production build (so the deployed worker is never affected).
377
- *
378
- * The deferral is the whole point: at plugin-factory time Vite has not yet told
379
- * us `serve` vs `build`, so the check must run in a `config` hook (where
380
- * `env.command` is known). It mutates the SAME options object handed to
381
- * `cloudflare()` in place — the cloudflare plugin reads `pluginConfig.configPath`
382
- * lazily inside its own `config` hook, which runs after this `enforce: "pre"`
383
- * one, so the injection takes effect. An eager factory-time serve check (the old
384
- * behaviour) always saw `command` undefined and silently dropped the path, so
385
- * remote bindings never activated on `vite dev`.
377
+ * A `enforce: "pre"` plugin that materializes the remote temp wrangler config
378
+ * and injects it into the cloudflare plugin's `configPath` — but only on a
379
+ * `vite` serve, never a production build (so the deployed worker is never
380
+ * affected) — then disposes the temp file when the dev server tears down.
381
+ *
382
+ * Both halves are deferred into the `config` hook, and each deferral closes a
383
+ * defect of its own.
384
+ *
385
+ * The command check: at plugin-factory time Vite has not yet resolved `serve`
386
+ * vs `build`, so it has to run here. An eager factory-time check always read
387
+ * `command` as undefined and stripped `configPath`, so remote bindings never
388
+ * activated on `vite dev` at all.
389
+ *
390
+ * The materialization: the temp config is a COPY of `wrangler.jsonc`, and
391
+ * Lunora provisions the bindings the project's code implies from
392
+ * `wranglerValidatorPlugin`'s own `config` hook — earlier in this same phase,
393
+ * since both are `enforce: "pre"` and that plugin is registered first. Copying
394
+ * the file at factory time therefore snapshotted it BEFORE that write, and the
395
+ * dev worker booted against a config missing the binding Lunora had just added:
396
+ * a `vite dev` that logged `inferred bindings → AI (Workers AI)`, passed
397
+ * validation, and served a worker with no `env.AI`. That is the remote twin of
398
+ * the local defect the reconcile's move into `config` fixed.
399
+ *
400
+ * The injection mutates the SAME options object handed to `cloudflare()` in
401
+ * place — the cloudflare plugin reads `pluginConfig.configPath` lazily inside
402
+ * its own `config` hook, which runs after this `enforce: "pre"` one, so the
403
+ * injection takes effect.
404
+ *
405
+ * The disposer reads the CURRENT plan rather than a factory-time capture,
406
+ * because no plan exists until `config` has run.
386
407
  *
387
408
  * When remote mode was requested but nothing materialized (no eligible binding,
388
409
  * no wrangler file, …), the plan's `reason` is logged so the degradation isn't
@@ -393,13 +414,7 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
393
414
  * inject into: the materialized path is printed with what to do with it, rather
394
415
  * than leaving `LUNORA_REMOTE` looking like it took effect.
395
416
  */
396
- declare const remoteBindingsConfigPlugin: (options: CloudflarePluginOptions | undefined, plan: ViteRemotePlan) => Plugin;
397
- /**
398
- * A tiny Vite plugin that runs the remote temp-config disposer when the dev
399
- * server tears down (`buildEnd` fires on close in serve; `closeBundle` covers
400
- * the build/close path). Idempotent cleanup means firing on both is safe.
401
- */
402
- declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
417
+ declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions) => Plugin;
403
418
  /**
404
419
  * A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
405
420
  * options type so the shape can't drift from the installed package. The overlay
@@ -502,14 +517,13 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
502
517
  * validation logic to `@lunora/config` so the rules stay in lockstep with
503
518
  * the CLI (`lunora deploy`).
504
519
  *
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.
520
+ * Provisioning runs BEFORE this, in `bindingsProvisionPlugin`'s `config` hook,
521
+ * which is the order `lunora dev` uses (infer → reconcile, no validation pass):
522
+ * the bindings this check requires are the ones Lunora writes itself, so
523
+ * validating first killed the dev server the first time a project declared a
524
+ * `.global()` table or a container. That plugin is registered unconditionally and
525
+ * ahead of this one — the write is not optional the way the check is, and it must
526
+ * land in `config` to reach the worker at all (see its docblock).
513
527
  *
514
528
  * Skipped under `vite preview`, which resolves with `command: "serve"` and so
515
529
  * runs `apply: "serve"` plugins: previewing a built app must not probe Docker.
@@ -540,4 +554,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
540
554
  */
541
555
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
542
556
  declare const VERSION: string;
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 };
557
+ 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, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
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};
1
+ import{createRequire as i}from"node:module";import{cloudflare as l}from"@cloudflare/vite-plugin";import{detectAgentRules as s,claimAgentRulesHint as u,AGENT_RULES_HINT as c,detectFramework as f,resolveTargetOrThrow as d,isRunnableTarget as m,runnableTargetIds as p}from"@lunora/config";import{detectFramework as ar}from"@lunora/config";import g from"@visulima/vite-overlay";import{l as a}from"./packem_shared/log-DE48L4Oz.mjs";import{reconcileBindingsSafely as S,codegenPlugin as v}from"./packem_shared/codegenPlugin-DVaxvj10.mjs";import w from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import R from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import h from"./packem_shared/devVariablesPlugin-DY_bJXsX.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-CEzeqjr2.mjs";import{CLASS_A_WIRING as lr,GENERATED_CLASS_MODULES as sr,LUNORA_WORKER_VIRTUAL_ID as ur,buildWorkerEntrySource as cr,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 mr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{remoteBindingsPlugin as E}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{planViteRemoteBindings as gr,withRemoteBindings as Sr}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{lunoraSolutionFinders as T}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as wr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{STUDIO_PATH as hr,buildStudioUrl as kr}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{withWorkerStartupHint as x}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Ar,augmentWorkerStartupError as Er,isWorkerEntryEvalError as Tr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as O}from"./packem_shared/wranglerValidatorPlugin-BdKLAEoq.mjs";import{default as xr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as br}from"@lunora/config/cloudflare";const b=o=>({apply:"serve",configureServer(r){return()=>{s(o.projectRoot).installed||!u()||r.config.logger.warn(`
2
+ ${a(c)}
3
+ `)}},name:"lunora:agent-rules-hint"}),y=o=>({async config(r,t){t.isPreview!==!0&&await S(o,{info:e=>{console.info(e)},warn:e=>{console.warn(e)}})},enforce:"pre",name:"lunora:bindings-provision"}),L=()=>({}),W={astro:"Astro",none:"standalone (SPA / SSR-less)",nuxt:"Nuxt","react-router":"React Router","solid-start":"SolidStart",sveltekit:"SvelteKit","tanstack-start":"TanStack Start","tanstack-start-solid":"TanStack Start (Solid)",vinext:"Next.js on Vite (vinext)"},D=o=>{const r=W[o.framework];return o.framework==="none"?a("no meta-framework detected — running standalone."):o.class==="B"?a(`detected ${r} — composition is handled by the framework adapter.`):a(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},C=(o,r)=>{let t=!1;const e=()=>{r.framework??=f(o.projectRoot)};return{config(){e()},configResolved(){e()},configureServer(){e(),!t&&r.framework!==void 0&&(t=!0,console.info(D(r.framework)))},name:"lunora:framework-detect"}},N=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...T,...r.solutionFinders??[]]}},U=(o,r)=>{const t=d(o,r);if(!m(t)){const e=p();throw new Error(`target "${t}" has no command-line toolchain, so the Lunora Vite plugin cannot build or serve it — it can only generate for it (\`lunora codegen --target ${t}\`). Buildable targets: ${e.join(", ")}`)}return t},I=o=>{const r=o??{},t=r.schemaDir??"lunora";let e;r.cloudflare===!1?e=!1:r.cloudflare===!0||r.cloudflare===void 0?e={}:e=r.cloudflare;const n=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:e,studio:r.studio??!0,generatedDir:`${t}/_generated`,overlay:N(r.overlay),projectRoot:n,schemaDir:t,shard:r.shard??{},target:U(n,r.target),validateWrangler:r.validateWrangler??!0}},er=o=>{const r=I(o),t=L(),e=[C(r,t),k(r,t),h(r),y(r),v(r),P(),R(r),b(r),A()];r.studio&&e.push(_(r)),r.validateWrangler&&e.push(O(r)),r.overlay!==!1&&e.push(g(r.overlay)),e.push(w(r));const n=r.cloudflare===!1?void 0:{...r.cloudflare};return e.push(E(n,{projectRoot:r.projectRoot})),n!==void 0&&e.push(...x(l(n))),e},or=i(import.meta.url)("../package.json").version;export{lr as CLASS_A_WIRING,sr as GENERATED_CLASS_MODULES,xr as LUNORA_API_UPDATED_EVENT,ur as LUNORA_WORKER_VIRTUAL_ID,hr as STUDIO_PATH,or as VERSION,Ar as WORKER_STARTUP_HINT,Er as augmentWorkerStartupError,kr as buildStudioUrl,cr as buildWorkerEntrySource,mr as checkLunoraProxy,v as codegenPlugin,w as containerLogsPlugin,ar as detectFramework,R as devStatePlugin,h as devVariablesPlugin,k as frameworkComposePlugin,fr as isAutoComposable,Tr as isWorkerEntryEvalError,P as logStreamPlugin,er as lunora,wr as lunoraSolutionFinder,T as lunoraSolutionFinders,gr as planViteRemoteBindings,A as proxyCheckPlugin,br as reconcileWranglerCrons,E as remoteBindingsPlugin,N as resolveOverlayOption,_ as studioPlugin,Sr as withRemoteBindings,x as withWorkerStartupHint,O as wranglerValidatorPlugin};
@@ -0,0 +1 @@
1
+ import{readProjectRemotePreference as d}from"@lunora/config";import{resolveRemoteEnabled as s,materializeRemoteWranglerConfig as g}from"@lunora/config/cloudflare";import{l as c}from"./log-DE48L4Oz.mjs";const l=()=>{},u=e=>{const t=e.readPreference??d;if(!s({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1};const o=(e.materialize??g)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:o.cleanup,configPath:o.configPath,enabled:!0,reason:o.reason}},m=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},v=(e,t)=>{let n={cleanup:l,enabled:!1},i;const o=()=>{n.cleanup()};return{buildEnd:o,closeBundle:o,config(P,f){if(f.command!=="serve")return;if(n.cleanup(),n=u(t),e===void 0){n.enabled&&n.configPath!==void 0&&console.info(c(`remote bindings are materialized at ${n.configPath} — this project adds @cloudflare/vite-plugin itself (\`cloudflare: false\`), so pass that path as its \`configPath\` to use them.`));return}const r=e;i!==void 0&&r.configPath===i&&delete r.configPath;const a=m(e,n);a.configPath!==void 0&&r.configPath===void 0?(r.configPath=a.configPath,i=a.configPath):n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(c(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings"}};export{u as planViteRemoteBindings,v as remoteBindingsPlugin,m as withRemoteBindings};
@@ -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{l as a}from"./log-DE48L4Oz.mjs";const g=r=>r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"),f=()=>{try{return i("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},u=(r,n=f)=>{const{parsed:e}=c(r);!(e?.containers??[]).some(t=>typeof t?.image=="string"&&g(t.image))||n()||console.warn(a("wrangler.jsonc declares containers built from a local Dockerfile, but no Docker-compatible engine is running. Start Docker (or Colima) before `vite dev`, or the container instances will fail to start."))},d=(r,n)=>{const e=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...n.map(o=>` - ${o}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(e.join(`
2
+ `))},b=r=>{let n=!1;return{config(e,o){n=o.isPreview===!0},configResolved(){if(n)return;const e=s({projectRoot:r.projectRoot,schemaDir:r.schemaDir});if(!e.wranglerPath)throw new l("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${r.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
3
+ `));for(const o of e.report.warnings)console.warn(a(`wrangler validator: ${o}`));if(e.problems.length>0)throw d(e.wranglerPath,e.problems);u(e.wranglerPath)},enforce:"pre",name:"lunora:wrangler-validator"}};export{u as warnWhenDockerMissing,b as wranglerValidatorPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.189",
3
+ "version": "1.0.0-alpha.190",
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.51.2",
49
- "@lunora/codegen": "1.0.0-alpha.156",
50
- "@lunora/config": "1.0.0-alpha.189",
49
+ "@lunora/codegen": "1.0.0-alpha.157",
50
+ "@lunora/config": "1.0.0-alpha.190",
51
51
  "@lunora/errors": "1.0.0-alpha.31",
52
52
  "@visulima/vite-overlay": "2.0.12"
53
53
  },
@@ -1 +0,0 @@
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};
@@ -1,3 +0,0 @@
1
- import{spawnSync as i}from"node:child_process";import{validateWranglerProject as s,readWranglerJsonc as c}from"@lunora/config/cloudflare";import{LunoraError as l}from"@lunora/errors";import{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};