@lunora/vite 1.0.0-alpha.177 → 1.0.0-alpha.179

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,9 +68,11 @@ With no options, `lunora()` runs codegen on save, validates `wrangler.jsonc`, in
68
68
 
69
69
  ```ts
70
70
  lunora({
71
- schemaDir: "lunora", // dir with schema.ts + function files
72
- generatedDir: "lunora/_generated", // where api.ts/server.ts/dataModel.ts land
71
+ schemaDir: "lunora", // dir with schema.ts + function files (generated output lands in <schemaDir>/_generated)
73
72
  apiSpec: "openapi", // "openapi" | "openrpc" | "both" | "none"
73
+ target: "cloudflare", // deploy target the emitted ctx.* surface is tailored to
74
+ allowUnauthenticatedShardAccess: false, // composed class-A worker: allow a client-named shard / fan-out with no authorizeShard
75
+ shard: { cdc: true, reactiveCache: true }, // class-A only: shard DO config for the composed entry (class B/C set this in their own worker entry)
74
76
  studio: false, // disable the /__lunora studio
75
77
  overlay: false, // disable the runtime error overlay
76
78
  validateWrangler: false, // skip the wrangler.jsonc binding check
package/dist/index.d.mts CHANGED
@@ -15,6 +15,47 @@ type CloudflarePluginOptions = Record<string, unknown>;
15
15
  * `solutionFinders`, `showBallonButton`, `vuePluginName`, …).
16
16
  */
17
17
  type OverlayPluginOptions = NonNullable<Parameters<typeof errorOverlayPlugin>[0]>;
18
+ /**
19
+ * Shard Durable Object configuration for the AUTO-COMPOSED class-A worker.
20
+ *
21
+ * A class-A app (TanStack Start, vinext, React Router, SolidStart) has no
22
+ * hand-written worker entry — that is what makes it class A — so it never calls
23
+ * the generated `defineApp()` builder and never reaches `createShardDO(config)`.
24
+ * The composed entry emitted `createShardDO()` bare, which left `cdc` and the
25
+ * whole reactive query cache unreachable for every class-A template no matter
26
+ * what the app wanted. `vite.config.ts` is the one place such an app configures
27
+ * Lunora, so it is where these land — the same route
28
+ * {@link LunoraPluginOptions.allowUnauthenticatedShardAccess} already takes into
29
+ * the same emitted entry.
30
+ *
31
+ * Deliberately only the PLAIN-DATA half of the generated `ShardDOConfig`. The
32
+ * rest of that type is `(env) => …` factories (`scheduler`, `storage`,
33
+ * `vectors`, …) which cannot be written in a config object and which a class-A
34
+ * app reaches by writing its own entry instead.
35
+ *
36
+ * Ignored for class B/C: those pass their config to `createShardDO` directly (or
37
+ * through `defineApp`), and an explicit argument there is unaffected by this.
38
+ */
39
+ interface LunoraShardConfig {
40
+ /** Opt into change-data-capture: every write records a post-image to `__cdc_log`. Backs streaming export, replay-PITR, and shard-local `defineShape` replication. Off by default. */
41
+ cdc?: boolean;
42
+ /** Ceiling on the join keys one relation-crossing `where` predicate may pre-resolve via semijoin before failing closed. Omit for the engine default. */
43
+ maxRelationKeys?: number;
44
+ /**
45
+ * Enable the per-shard reactive query cache: `true` for the defaults, or an
46
+ * options object to tune the caps. Query results are memoized by
47
+ * `(functionPath, args, identity)` and invalidated by the ctx-db write hooks
48
+ * before the subscription broadcast, so a subscriber never observes a
49
+ * pre-write value. Omitted (or `false`) keeps every dispatch re-running its
50
+ * handler.
51
+ */
52
+ reactiveCache?: boolean | {
53
+ maxBytes?: number;
54
+ maxEntries?: number;
55
+ };
56
+ /** Resolution policy for a relation-crossing `where` whose child is co-located in this shard: `"auto"` (cost-based, the engine default), `"always"` (inline correlated EXISTS) or `"never"` (universal semijoin). All three return identical rows. */
57
+ relationExistsPushDown?: "always" | "auto" | "never";
58
+ }
18
59
  interface LunoraPluginOptions {
19
60
  /**
20
61
  * Allow a client-named NON-default shard / cross-shard fan-out WITHOUT an
@@ -35,8 +76,6 @@ interface LunoraPluginOptions {
35
76
  apiSpec?: CodegenOptions["apiSpec"];
36
77
  /** Pass through to `@cloudflare/vite-plugin`. Pass `false` to opt out. Defaults to `true`. */
37
78
  cloudflare?: boolean | CloudflarePluginOptions;
38
- /** Directory name (relative to `projectRoot`) where generated files are written. Defaults to `"lunora/_generated"`. */
39
- generatedDir?: string;
40
79
  /**
41
80
  * Inject `@visulima/vite-overlay` for runtime errors (dev only). Pass
42
81
  * `false` to opt out, or an options object to forward to the overlay.
@@ -47,6 +86,14 @@ interface LunoraPluginOptions {
47
86
  projectRoot?: string;
48
87
  /** Directory name (relative to `projectRoot`) containing `schema.ts` and function files. Defaults to `"lunora"`. */
49
88
  schemaDir?: string;
89
+ /**
90
+ * Shard DO configuration baked into the auto-composed class-A worker entry —
91
+ * see {@link LunoraShardConfig}. The ONLY way a class-A app can set `cdc` or
92
+ * enable the reactive query cache, since it has no worker entry to call
93
+ * `createShardDO(config)` from. Ignored for class B/C. Defaults to `{}`
94
+ * (byte-identical composed output).
95
+ */
96
+ shard?: LunoraShardConfig;
50
97
  /** Serve the Lunora studio at `/__lunora` during dev. Pass `false` to opt out. Defaults to `true`. */
51
98
  studio?: boolean;
52
99
  /**
@@ -67,10 +114,21 @@ interface ResolvedLunoraPluginOptions {
67
114
  allowUnauthenticatedShardAccess: boolean;
68
115
  apiSpec: NonNullable<CodegenOptions["apiSpec"]>;
69
116
  cloudflare: false | CloudflarePluginOptions;
117
+ /**
118
+ * Where codegen writes `_generated/*`, always `<schemaDir>/_generated`.
119
+ *
120
+ * NOT a user option: codegen hardcodes that path (`run-codegen` joins
121
+ * `lunoraDirectory` with `"_generated"`), so a settable override was a no-op
122
+ * everywhere except `frameworkComposePlugin`, which uses it as the composed
123
+ * class-A worker's import base — where a non-default value pointed the
124
+ * emitted imports at a directory nothing writes and broke class-A dev and
125
+ * build. Derived, so the import base cannot disagree with the emitter.
126
+ */
70
127
  generatedDir: string;
71
128
  overlay: false | OverlayPluginOptions;
72
129
  projectRoot: string;
73
130
  schemaDir: string;
131
+ shard: LunoraShardConfig;
74
132
  studio: boolean;
75
133
  target: string;
76
134
  validateWrangler: boolean;
@@ -208,6 +266,16 @@ declare const CLASS_A_WIRING: Readonly<Partial<Record<DetectedFramework, ClassAW
208
266
  * (class B/C, `none`) falls back to the existing flow.
209
267
  */
210
268
  declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
269
+ /**
270
+ * The `_generated/` modules whose exported classes wrangler validates a
271
+ * `class_name` against: container Durable Objects, workflow entrypoints, and
272
+ * agent (workflow) entrypoints — the same three kinds `reconcile-bindings`
273
+ * writes into `wrangler.jsonc`. The composed entry star-re-exports each module
274
+ * the project actually has.
275
+ */
276
+ declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "workflows"];
277
+ /** One {@link GENERATED_CLASS_MODULES} entry. */
278
+ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
211
279
  /**
212
280
  * Build the source of the virtual class-A worker entry. Pure (no fs / no Vite),
213
281
  * so the emitted composition is unit-testable in isolation.
@@ -222,7 +290,7 @@ declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
222
290
  * virtual module id. Absolute paths are resolved correctly in all environments
223
291
  * (Vite 8 + rolldown 1.x confirmed).
224
292
  */
225
- declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean, useUmbrella?: boolean, allowUnauthenticatedShardAccess?: boolean) => string;
293
+ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>, useUmbrella?: boolean, allowUnauthenticatedShardAccess?: boolean, shard?: LunoraShardConfig) => string;
226
294
  /**
227
295
  * Vite plugin that auto-composes a detected class-A meta-framework's SSR
228
296
  * handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
@@ -481,4 +549,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
481
549
  */
482
550
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
483
551
  declare const VERSION: string;
484
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -15,6 +15,47 @@ type CloudflarePluginOptions = Record<string, unknown>;
15
15
  * `solutionFinders`, `showBallonButton`, `vuePluginName`, …).
16
16
  */
17
17
  type OverlayPluginOptions = NonNullable<Parameters<typeof errorOverlayPlugin>[0]>;
18
+ /**
19
+ * Shard Durable Object configuration for the AUTO-COMPOSED class-A worker.
20
+ *
21
+ * A class-A app (TanStack Start, vinext, React Router, SolidStart) has no
22
+ * hand-written worker entry — that is what makes it class A — so it never calls
23
+ * the generated `defineApp()` builder and never reaches `createShardDO(config)`.
24
+ * The composed entry emitted `createShardDO()` bare, which left `cdc` and the
25
+ * whole reactive query cache unreachable for every class-A template no matter
26
+ * what the app wanted. `vite.config.ts` is the one place such an app configures
27
+ * Lunora, so it is where these land — the same route
28
+ * {@link LunoraPluginOptions.allowUnauthenticatedShardAccess} already takes into
29
+ * the same emitted entry.
30
+ *
31
+ * Deliberately only the PLAIN-DATA half of the generated `ShardDOConfig`. The
32
+ * rest of that type is `(env) => …` factories (`scheduler`, `storage`,
33
+ * `vectors`, …) which cannot be written in a config object and which a class-A
34
+ * app reaches by writing its own entry instead.
35
+ *
36
+ * Ignored for class B/C: those pass their config to `createShardDO` directly (or
37
+ * through `defineApp`), and an explicit argument there is unaffected by this.
38
+ */
39
+ interface LunoraShardConfig {
40
+ /** Opt into change-data-capture: every write records a post-image to `__cdc_log`. Backs streaming export, replay-PITR, and shard-local `defineShape` replication. Off by default. */
41
+ cdc?: boolean;
42
+ /** Ceiling on the join keys one relation-crossing `where` predicate may pre-resolve via semijoin before failing closed. Omit for the engine default. */
43
+ maxRelationKeys?: number;
44
+ /**
45
+ * Enable the per-shard reactive query cache: `true` for the defaults, or an
46
+ * options object to tune the caps. Query results are memoized by
47
+ * `(functionPath, args, identity)` and invalidated by the ctx-db write hooks
48
+ * before the subscription broadcast, so a subscriber never observes a
49
+ * pre-write value. Omitted (or `false`) keeps every dispatch re-running its
50
+ * handler.
51
+ */
52
+ reactiveCache?: boolean | {
53
+ maxBytes?: number;
54
+ maxEntries?: number;
55
+ };
56
+ /** Resolution policy for a relation-crossing `where` whose child is co-located in this shard: `"auto"` (cost-based, the engine default), `"always"` (inline correlated EXISTS) or `"never"` (universal semijoin). All three return identical rows. */
57
+ relationExistsPushDown?: "always" | "auto" | "never";
58
+ }
18
59
  interface LunoraPluginOptions {
19
60
  /**
20
61
  * Allow a client-named NON-default shard / cross-shard fan-out WITHOUT an
@@ -35,8 +76,6 @@ interface LunoraPluginOptions {
35
76
  apiSpec?: CodegenOptions["apiSpec"];
36
77
  /** Pass through to `@cloudflare/vite-plugin`. Pass `false` to opt out. Defaults to `true`. */
37
78
  cloudflare?: boolean | CloudflarePluginOptions;
38
- /** Directory name (relative to `projectRoot`) where generated files are written. Defaults to `"lunora/_generated"`. */
39
- generatedDir?: string;
40
79
  /**
41
80
  * Inject `@visulima/vite-overlay` for runtime errors (dev only). Pass
42
81
  * `false` to opt out, or an options object to forward to the overlay.
@@ -47,6 +86,14 @@ interface LunoraPluginOptions {
47
86
  projectRoot?: string;
48
87
  /** Directory name (relative to `projectRoot`) containing `schema.ts` and function files. Defaults to `"lunora"`. */
49
88
  schemaDir?: string;
89
+ /**
90
+ * Shard DO configuration baked into the auto-composed class-A worker entry —
91
+ * see {@link LunoraShardConfig}. The ONLY way a class-A app can set `cdc` or
92
+ * enable the reactive query cache, since it has no worker entry to call
93
+ * `createShardDO(config)` from. Ignored for class B/C. Defaults to `{}`
94
+ * (byte-identical composed output).
95
+ */
96
+ shard?: LunoraShardConfig;
50
97
  /** Serve the Lunora studio at `/__lunora` during dev. Pass `false` to opt out. Defaults to `true`. */
51
98
  studio?: boolean;
52
99
  /**
@@ -67,10 +114,21 @@ interface ResolvedLunoraPluginOptions {
67
114
  allowUnauthenticatedShardAccess: boolean;
68
115
  apiSpec: NonNullable<CodegenOptions["apiSpec"]>;
69
116
  cloudflare: false | CloudflarePluginOptions;
117
+ /**
118
+ * Where codegen writes `_generated/*`, always `<schemaDir>/_generated`.
119
+ *
120
+ * NOT a user option: codegen hardcodes that path (`run-codegen` joins
121
+ * `lunoraDirectory` with `"_generated"`), so a settable override was a no-op
122
+ * everywhere except `frameworkComposePlugin`, which uses it as the composed
123
+ * class-A worker's import base — where a non-default value pointed the
124
+ * emitted imports at a directory nothing writes and broke class-A dev and
125
+ * build. Derived, so the import base cannot disagree with the emitter.
126
+ */
70
127
  generatedDir: string;
71
128
  overlay: false | OverlayPluginOptions;
72
129
  projectRoot: string;
73
130
  schemaDir: string;
131
+ shard: LunoraShardConfig;
74
132
  studio: boolean;
75
133
  target: string;
76
134
  validateWrangler: boolean;
@@ -208,6 +266,16 @@ declare const CLASS_A_WIRING: Readonly<Partial<Record<DetectedFramework, ClassAW
208
266
  * (class B/C, `none`) falls back to the existing flow.
209
267
  */
210
268
  declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
269
+ /**
270
+ * The `_generated/` modules whose exported classes wrangler validates a
271
+ * `class_name` against: container Durable Objects, workflow entrypoints, and
272
+ * agent (workflow) entrypoints — the same three kinds `reconcile-bindings`
273
+ * writes into `wrangler.jsonc`. The composed entry star-re-exports each module
274
+ * the project actually has.
275
+ */
276
+ declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "workflows"];
277
+ /** One {@link GENERATED_CLASS_MODULES} entry. */
278
+ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
211
279
  /**
212
280
  * Build the source of the virtual class-A worker entry. Pure (no fs / no Vite),
213
281
  * so the emitted composition is unit-testable in isolation.
@@ -222,7 +290,7 @@ declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
222
290
  * virtual module id. Absolute paths are resolved correctly in all environments
223
291
  * (Vite 8 + rolldown 1.x confirmed).
224
292
  */
225
- declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean, useUmbrella?: boolean, allowUnauthenticatedShardAccess?: boolean) => string;
293
+ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>, useUmbrella?: boolean, allowUnauthenticatedShardAccess?: boolean, shard?: LunoraShardConfig) => string;
226
294
  /**
227
295
  * Vite plugin that auto-composes a detected class-A meta-framework's SSR
228
296
  * handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
@@ -481,4 +549,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
481
549
  */
482
550
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
483
551
  declare const VERSION: string;
484
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, 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 };
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 };
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}from"@lunora/config";import{detectFramework as sr}from"@lunora/config";import R from"@visulima/vite-overlay";import{l}from"./packem_shared/log-DE48L4Oz.mjs";import S from"./packem_shared/codegenPlugin-BIAKVRnd.mjs";import v from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import k from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import h from"./packem_shared/devVariablesPlugin-DDvQh3l6.mjs";import{createCommandProbe as w,withDevWorkerEnv as P}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{DEV_WORKER_ENV_VALUE as cr,DEV_WORKER_ENV_VAR as mr}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{frameworkComposePlugin as E}from"./packem_shared/CLASS_A_WIRING-CBEvhsXt.mjs";import{CLASS_A_WIRING as dr,LUNORA_WORKER_VIRTUAL_ID as pr,buildWorkerEntrySource as gr,isAutoComposable as Rr}from"./packem_shared/CLASS_A_WIRING-CBEvhsXt.mjs";import A from"./packem_shared/logStreamPlugin-DFdSz0AO.mjs";import{proxyCheckPlugin as _}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as vr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{planViteRemoteBindings as x,remoteBindingsCleanupPlugin as O,remoteBindingsConfigPlugin as W}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{withRemoteBindings as hr}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{lunoraSolutionFinders as D}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Pr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as T}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{STUDIO_PATH as Ar,buildStudioUrl as _r}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{withWorkerStartupHint as V}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Or,augmentWorkerStartupError as Wr,isWorkerEntryEvalError as Dr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as C}from"./packem_shared/wranglerValidatorPlugin-Dma0xUy2.mjs";import{default as Vr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as Lr}from"@lunora/config/cloudflare";const L=e=>({apply:"serve",configureServer(r){return()=>{m(e.projectRoot).installed||!f()||r.config.logger.warn(`
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}from"@lunora/config";import{detectFramework as sr}from"@lunora/config";import S from"@visulima/vite-overlay";import{l}from"./packem_shared/log-DE48L4Oz.mjs";import R from"./packem_shared/codegenPlugin-BIAKVRnd.mjs";import v from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import h from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import k from"./packem_shared/devVariablesPlugin-DDvQh3l6.mjs";import{createCommandProbe as E,withDevWorkerEnv as w}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{DEV_WORKER_ENV_VALUE as cr,DEV_WORKER_ENV_VAR as mr}from"./packem_shared/DEV_WORKER_ENV_VALUE-CaO3rUSk.mjs";import{frameworkComposePlugin as P}from"./packem_shared/CLASS_A_WIRING-N5ktvdUV.mjs";import{CLASS_A_WIRING as dr,GENERATED_CLASS_MODULES as pr,LUNORA_WORKER_VIRTUAL_ID as gr,buildWorkerEntrySource as Sr,isAutoComposable as Rr}from"./packem_shared/CLASS_A_WIRING-N5ktvdUV.mjs";import A from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as _}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as hr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{planViteRemoteBindings as x,remoteBindingsCleanupPlugin as O,remoteBindingsConfigPlugin as W}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{withRemoteBindings as Er}from"./packem_shared/planViteRemoteBindings-BKGgYFk4.mjs";import{lunoraSolutionFinders as D}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Pr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as T}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{STUDIO_PATH as _r,buildStudioUrl as xr}from"./packem_shared/STUDIO_PATH-xwt4m9UW.mjs";import{withWorkerStartupHint as L}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Wr,augmentWorkerStartupError as Dr,isWorkerEntryEvalError as Tr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as C}from"./packem_shared/wranglerValidatorPlugin-Dma0xUy2.mjs";import{default as Cr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as Vr}from"@lunora/config/cloudflare";const N=e=>({apply:"serve",configureServer(r){return()=>{m(e.projectRoot).installed||!f()||r.config.logger.warn(`
2
2
  ${l(d)}
3
- `)}},name:"lunora:agent-rules-hint"}),N=()=>({}),y={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)"},U=e=>{const r=y[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.`)},b=(e,r)=>{let t=!1;const o=()=>{r.framework??=p(e.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&r.framework!==void 0&&(t=!0,console.info(U(r.framework)))},name:"lunora:framework-detect"}},I=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??[]]}},j=e=>{const r=e??{},t=r.schemaDir??"lunora";let o;r.cloudflare===!1?o=!1:r.cloudflare===!0||r.cloudflare===void 0?o={}:o=r.cloudflare;const a=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:o,studio:r.studio??!0,generatedDir:r.generatedDir??`${t}/_generated`,overlay:I(r.overlay),projectRoot:a,schemaDir:t,target:g(a,r.target),validateWrangler:r.validateWrangler??!0}},nr=e=>{const r=j(e),t=N(),{isServe:o,plugin:a}=w(),n=[a,b(r,t),E(r,t),h(r),S(r),A(),k(r),L(r),_()];if(r.studio&&n.push(T()),r.validateWrangler&&n.push(C(r)),r.overlay!==!1&&n.push(R(r.overlay)),r.cloudflare!==!1){n.push(v(r));const i=x({projectRoot:r.projectRoot}),s=P(r.cloudflare,o);i.enabled&&(i.configPath!==void 0&&n.push(O(i.cleanup)),n.push(W(s,i))),n.push(...V(c(s)))}return n},ar=u(import.meta.url)("../package.json").version;export{dr as CLASS_A_WIRING,cr as DEV_WORKER_ENV_VALUE,mr as DEV_WORKER_ENV_VAR,Vr as LUNORA_API_UPDATED_EVENT,pr as LUNORA_WORKER_VIRTUAL_ID,Ar as STUDIO_PATH,ar as VERSION,Or as WORKER_STARTUP_HINT,Wr as augmentWorkerStartupError,_r as buildStudioUrl,gr as buildWorkerEntrySource,vr as checkLunoraProxy,S as codegenPlugin,v as containerLogsPlugin,w as createCommandProbe,sr as detectFramework,k as devStatePlugin,h as devVariablesPlugin,E as frameworkComposePlugin,Rr as isAutoComposable,Dr as isWorkerEntryEvalError,A as logStreamPlugin,nr as lunora,Pr as lunoraSolutionFinder,D as lunoraSolutionFinders,x as planViteRemoteBindings,_ as proxyCheckPlugin,Lr as reconcileWranglerCrons,O as remoteBindingsCleanupPlugin,W as remoteBindingsConfigPlugin,I as resolveOverlayOption,T as studioPlugin,P as withDevWorkerEnv,hr as withRemoteBindings,V as withWorkerStartupHint,C as wranglerValidatorPlugin};
3
+ `)}},name:"lunora:agent-rules-hint"}),V=()=>({}),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)"},y=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.`)},b=(e,r)=>{let t=!1;const o=()=>{r.framework??=p(e.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&r.framework!==void 0&&(t=!0,console.info(y(r.framework)))},name:"lunora:framework-detect"}},I=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??[]]}},j=e=>{const r=e??{},t=r.schemaDir??"lunora";let o;r.cloudflare===!1?o=!1:r.cloudflare===!0||r.cloudflare===void 0?o={}:o=r.cloudflare;const a=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:o,studio:r.studio??!0,generatedDir:`${t}/_generated`,overlay:I(r.overlay),projectRoot:a,schemaDir:t,shard:r.shard??{},target:g(a,r.target),validateWrangler:r.validateWrangler??!0}},nr=e=>{const r=j(e),t=V(),{isServe:o,plugin:a}=E(),n=[a,b(r,t),P(r,t),k(r),R(r),A(),h(r),N(r),_()];if(r.studio&&n.push(T()),r.validateWrangler&&n.push(C(r)),r.overlay!==!1&&n.push(S(r.overlay)),r.cloudflare!==!1){n.push(v(r));const i=x({projectRoot:r.projectRoot}),s=w(r.cloudflare,o);i.enabled&&(i.configPath!==void 0&&n.push(O(i.cleanup)),n.push(W(s,i))),n.push(...L(c(s)))}return n},ar=u(import.meta.url)("../package.json").version;export{dr as CLASS_A_WIRING,cr as DEV_WORKER_ENV_VALUE,mr as DEV_WORKER_ENV_VAR,pr as GENERATED_CLASS_MODULES,Cr as LUNORA_API_UPDATED_EVENT,gr as LUNORA_WORKER_VIRTUAL_ID,_r as STUDIO_PATH,ar as VERSION,Wr as WORKER_STARTUP_HINT,Dr as augmentWorkerStartupError,xr as buildStudioUrl,Sr as buildWorkerEntrySource,hr as checkLunoraProxy,R as codegenPlugin,v as containerLogsPlugin,E as createCommandProbe,sr as detectFramework,h as devStatePlugin,k as devVariablesPlugin,P as frameworkComposePlugin,Rr as isAutoComposable,Tr as isWorkerEntryEvalError,A as logStreamPlugin,nr as lunora,Pr as lunoraSolutionFinder,D as lunoraSolutionFinders,x as planViteRemoteBindings,_ as proxyCheckPlugin,Vr as reconcileWranglerCrons,O as remoteBindingsCleanupPlugin,W as remoteBindingsConfigPlugin,I as resolveOverlayOption,T as studioPlugin,w as withDevWorkerEnv,Er as withRemoteBindings,L as withWorkerStartupHint,C as wranglerValidatorPlugin};
@@ -0,0 +1,33 @@
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};
@@ -0,0 +1,3 @@
1
+ import{detectAiAgent as u,LUNORA_EVENT_SOURCE as a,formatLunoraEvent as f}from"@lunora/config";import{a as l,r as d}from"./server-close-Qoh4i6Ay.mjs";const p=`"source":"${a}"`,i={error:"\x1B[31m",info:"\x1B[36m",reset:"\x1B[0m",warn:"\x1B[33m"},w=(r,t,e)=>e?`${i[t]}[lunora]${i.reset} ${r}`:`[lunora] ${r}`,v=r=>typeof r=="string"?r:Buffer.isBuffer(r)?r.toString("utf8"):void 0,m=(r,t)=>r.split(`
2
+ `).map(e=>{const n=f(e);return n?w(n.text,n.level,t):e}).join(`
3
+ `),S=(r,t)=>(...e)=>{try{const n=v(e[0]);if(n?.includes(p))return r(m(n,t),...e.slice(1))}catch{}return r(...e)},c=r=>{const t=r.write.bind(r),e=S(t,r.isTTY===!0);return r.write=e,()=>{r.write===e&&(r.write=t)}},g=()=>{const r=process.env.LUNORA_LOG_JSON;return r==="1"||r==="true"?!0:r==="0"||r==="false"?!1:u()!==void 0};let o;const A=()=>{const r=new Map;return{apply:"serve",buildEnd(){d(r,this.environment)},configureServer(t){if(g())return;o?.();const e=c(process.stdout),n=c(process.stderr),s=()=>{e(),n(),o===s&&(o=void 0)};o=s,l(t,r,s)},name:"lunora:log-stream"}};export{A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.177",
3
+ "version": "1.0.0-alpha.179",
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.143",
50
- "@lunora/config": "1.0.0-alpha.177",
49
+ "@lunora/codegen": "1.0.0-alpha.145",
50
+ "@lunora/config": "1.0.0-alpha.179",
51
51
  "@lunora/errors": "1.0.0-alpha.26",
52
52
  "@visulima/vite-overlay": "2.0.12"
53
53
  },
@@ -1,33 +0,0 @@
1
- import{existsSync as f,readFileSync as h}from"node:fs";import{resolve as v,join as l}from"node:path";import{LunoraError as k}from"@lunora/errors";const d="virtual:lunora/worker",R="\0",i=`${R}${d}`,w=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
2
- export default {};
3
- `,A=/\/$/,u={"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";'}},c=e=>{const r=e.framework;return r?.class==="A"&&u[r.framework]!==void 0},S=e=>{try{const r=JSON.parse(h(l(e,"package.json"),"utf8"));return["dependencies","devDependencies","peerDependencies"].some(t=>r[t]?.lunorash!==void 0)}catch{return!1}},O=(e,r,t=!1,a=!1,o=!1)=>{const n=u[e];if(n===void 0)throw new k("INTERNAL",`[lunora] no class-A worker wiring for framework "${e}"`);const s=r.replaceAll("\\","/"),m=a?"lunorash/runtime":"@lunora/runtime",p=t?`
4
- export * from "${s}/containers";
5
- `:"";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 "${m}";
9
- ${n.imports}
10
- import { LUNORA_FUNCTIONS } from "${s}/functions";
11
- import { openApiSpec } from "${s}/openapi";
12
- import { createShardDO } from "${s}/shard";
13
-
14
- export const ShardDO = createShardDO();
15
- ${p}
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: ${n.handler},
25
- openApiSpec,
26
- routes: {},
27
- shardDO: env.SHARD,
28
- });
29
-
30
- return worker.fetch(request, env, context);
31
- },
32
- };
33
- `},_=(e,r)=>{const t=v(e.projectRoot,e.generatedDir.replace(A,"")),a=S(e.projectRoot);return{load(o){if(o===i&&c(r)&&r.framework!==void 0){if(this.environment.name==="client")return w;const n=f(l(t,"containers.ts"));return O(r.framework.framework,t,n,a,e.allowUnauthenticatedShardAccess)}},name:"lunora:framework-compose",resolveId(o){if(o===d&&c(r))return i}}};export{u as CLASS_A_WIRING,d as LUNORA_WORKER_VIRTUAL_ID,i as RESOLVED_LUNORA_WORKER_ID,O as buildWorkerEntrySource,_ as frameworkComposePlugin,c as isAutoComposable};
@@ -1,3 +0,0 @@
1
- import{detectAiAgent as u,LUNORA_EVENT_SOURCE as a,formatLunoraEvent as f}from"@lunora/config";import{a as l,r as d}from"./server-close-Qoh4i6Ay.mjs";const p=`"source":"${a}"`,s={error:"\x1B[31m",info:"\x1B[36m",reset:"\x1B[0m",warn:"\x1B[33m"},w=(r,e,t)=>t?`${s[e]}[lunora]${s.reset} ${r}`:`[lunora] ${r}`,v=r=>typeof r=="string"?r:Buffer.isBuffer(r)?r.toString("utf8"):void 0,m=(r,e)=>r.split(`
2
- `).map(t=>{const n=f(t);return n?w(n.text,n.level,e):t}).join(`
3
- `),S=(r,e)=>(...t)=>{try{const n=v(t[0]);if(n?.includes(p))return r(m(n,e),...t.slice(1))}catch{}return r(...t)},i=r=>{const e=r.write.bind(r),t=S(e,r.isTTY===!0);return r.write=t,()=>{r.write===t&&(r.write=e)}},g=()=>{const r=process.env.LUNORA_LOG_JSON;return r==="1"||r==="true"?!0:r==="0"||r==="false"?!1:u()!==void 0},A=()=>{const r=new Map;let e;return{apply:"serve",buildEnd(){d(r,this.environment)},configureServer(t){if(g())return;e?.();const n=i(process.stdout),c=i(process.stderr),o=()=>{n(),c(),e===o&&(e=void 0)};e=o,l(t,r,o)},name:"lunora:log-stream"}};export{A as default};