@lunora/vite 1.0.0-alpha.2 → 1.0.0-alpha.20

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
@@ -63,6 +63,23 @@ type LunoraPlugins = Plugin[];
63
63
  * inside the lunora schema directory.
64
64
  */
65
65
  declare const codegenPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
66
+ /**
67
+ * Dev-only plugin that tails the local dev containers' own stdout/stderr in the
68
+ * Vite terminal.
69
+ *
70
+ * `@cloudflare/vite-plugin` builds and runs each declared container locally via
71
+ * Docker (image `cloudflare-dev/<class>:<id>`) but only forwards the *worker's*
72
+ * console — the container process's own output is otherwise invisible. This
73
+ * plugin attaches to those Docker log streams (via `@lunora/config`'s
74
+ * `streamContainerLogs`, which lazy-loads `dockerode`) and prints each line
75
+ * through Vite's logger, branded and tagged `container:<name>`.
76
+ *
77
+ * A no-op when the project declares no containers (the common case): discovery
78
+ * returns an empty list, so `dockerode` is never imported and no Docker work
79
+ * starts. Set `LUNORA_CONTAINER_LOGS=0` to opt out. A missing/stopped Docker
80
+ * engine degrades to a single warning rather than breaking dev.
81
+ */
82
+ declare const containerLogsPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
66
83
  interface ReconcileResult {
67
84
  /** `true` when `wrangler.jsonc` was rewritten. */
68
85
  changed: boolean;
@@ -87,13 +104,20 @@ interface ReconcileResult {
87
104
  */
88
105
  declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
89
106
  /**
90
- * Dev-only Vite plugin that offers to scaffold `.dev.vars` before the worker
91
- * boots. `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`,
92
- * but the file is gitignored — so a fresh clone has none and the worker throws
93
- * on the first required secret (e.g. `AUTH_SECRET is required`). When a
94
- * `.dev.vars.example` exists, we prompt to generate `.dev.vars` from it with
95
- * secrets auto-filled. Identical behaviour to `lunora dev` — both call
96
- * `ensureDevVariables` from `@lunora/config`.
107
+ * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
108
+ * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
109
+ * file is gitignored — so a fresh clone has none and the worker throws on the
110
+ * first required secret (e.g. `AUTH_SECRET is required`). Two steps, both shared
111
+ * with `lunora dev` via `@lunora/config`.
112
+ *
113
+ * First, {@link ensureDevVariables}: when a `.dev.vars.example` exists, prompt
114
+ * to generate `.dev.vars` from it with secrets auto-filled. Second,
115
+ * {@link fillDevSecrets}: fill any empty/placeholder secret already in
116
+ * `.dev.vars` (a `lunora add`-scaffolded project writes secrets blank) and
117
+ * ensure `LUNORA_ADMIN_TOKEN` is present + generated — so the worker boots with
118
+ * working secrets and the Studio authenticates without its login gate. No
119
+ * prompt: it only generates locally-derivable values and never overwrites a real
120
+ * one.
97
121
  *
98
122
  * Runs in `configResolved` (awaited by Vite) so it completes before the
99
123
  * Cloudflare plugin reads the file. Non-interactive runs decline silently.
@@ -198,7 +222,7 @@ declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
198
222
  * virtual module id. Absolute paths are resolved correctly in all environments
199
223
  * (Vite 8 + rolldown 1.x confirmed).
200
224
  */
201
- declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean) => string;
225
+ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean, useUmbrella?: boolean) => string;
202
226
  /**
203
227
  * Vite plugin that auto-composes a detected class-A meta-framework's SSR
204
228
  * handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
@@ -281,6 +305,35 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, isServe: ()
281
305
  * the build/close path). Idempotent cleanup means firing on both is safe.
282
306
  */
283
307
  declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
308
+ /**
309
+ * A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
310
+ * options type so the shape can't drift from the installed package. The overlay
311
+ * runs every finder it's given (custom finders first, then its built-ins),
312
+ * sorted by `priority` descending, and shows the first non-`undefined` result.
313
+ *
314
+ * Note: this type (and {@link Solution}) is re-exported from `@lunora/vite` and
315
+ * intentionally tracks the installed `@visulima/vite-overlay` — if a future
316
+ * overlay release changes the finder contract, that surfaces here as a compile
317
+ * error rather than a silent drift.
318
+ */
319
+ type SolutionFinder = NonNullable<OverlayPluginOptions["solutionFinders"]>[number];
320
+ /** What a finder may return: a Markdown-rendered `{ header?, body }`, or `undefined` to defer. */
321
+ type Solution = NonNullable<Awaited<ReturnType<SolutionFinder["handle"]>>>;
322
+ /**
323
+ * Lunora's solution finder for the dev error overlay. A single finder that
324
+ * delegates to `@lunora/codegen`'s shared rule table (the same table the
325
+ * standalone `lunora dev` CLI prints to the terminal) and returns the first
326
+ * match — so one `priority` slot covers every Lunora rule and the overlay's
327
+ * built-in finders still run for anything we don't recognize (we return
328
+ * `undefined`).
329
+ *
330
+ * Priority is high so a Lunora-specific hint wins over the overlay's generic
331
+ * finder for the same error; a user's own finder can still outrank it with a
332
+ * higher `priority`.
333
+ */
334
+ declare const lunoraSolutionFinder: SolutionFinder;
335
+ /** The finders Lunora injects into the overlay by default. */
336
+ declare const lunoraSolutionFinders: ReadonlyArray<SolutionFinder>;
284
337
  /** Dev-server path the studio SPA is served from. */
285
338
  declare const STUDIO_PATH = "/__lunora";
286
339
  /** Static asset routes the studio document references. */
@@ -358,6 +411,17 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
358
411
  */
359
412
  declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
360
413
  /**
414
+ * Resolve the `overlay` toggle into the overlay plugin's options — or `false` to
415
+ * skip it. Lunora's solution finders are **prepended** so they run before the
416
+ * overlay's built-ins; a user's own finders are appended and can still win per
417
+ * error via a strictly higher `priority` (equal priority keeps Lunora first,
418
+ * since the overlay sorts stably). Lunora also forwards both `error` AND `warn`
419
+ * console calls by default (the overlay's own default is `["error"]` only) so
420
+ * Lunora's branded `warn` advisories surface in the browser too — the user can
421
+ * override `forwardedConsoleMethods`.
422
+ */
423
+ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
424
+ /**
361
425
  * Lunora Vite plugin. Returns a flat array of Vite plugins that:
362
426
  *
363
427
  * 1. Run `@lunora/codegen` on startup + on schema file changes.
@@ -371,4 +435,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
371
435
  */
372
436
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
373
437
  declare const VERSION = "0.0.0";
374
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
438
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.d.ts CHANGED
@@ -63,6 +63,23 @@ type LunoraPlugins = Plugin[];
63
63
  * inside the lunora schema directory.
64
64
  */
65
65
  declare const codegenPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
66
+ /**
67
+ * Dev-only plugin that tails the local dev containers' own stdout/stderr in the
68
+ * Vite terminal.
69
+ *
70
+ * `@cloudflare/vite-plugin` builds and runs each declared container locally via
71
+ * Docker (image `cloudflare-dev/&lt;class>:&lt;id>`) but only forwards the *worker's*
72
+ * console — the container process's own output is otherwise invisible. This
73
+ * plugin attaches to those Docker log streams (via `@lunora/config`'s
74
+ * `streamContainerLogs`, which lazy-loads `dockerode`) and prints each line
75
+ * through Vite's logger, branded and tagged `container:&lt;name>`.
76
+ *
77
+ * A no-op when the project declares no containers (the common case): discovery
78
+ * returns an empty list, so `dockerode` is never imported and no Docker work
79
+ * starts. Set `LUNORA_CONTAINER_LOGS=0` to opt out. A missing/stopped Docker
80
+ * engine degrades to a single warning rather than breaking dev.
81
+ */
82
+ declare const containerLogsPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
66
83
  interface ReconcileResult {
67
84
  /** `true` when `wrangler.jsonc` was rewritten. */
68
85
  changed: boolean;
@@ -87,13 +104,20 @@ interface ReconcileResult {
87
104
  */
88
105
  declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
89
106
  /**
90
- * Dev-only Vite plugin that offers to scaffold `.dev.vars` before the worker
91
- * boots. `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`,
92
- * but the file is gitignored — so a fresh clone has none and the worker throws
93
- * on the first required secret (e.g. `AUTH_SECRET is required`). When a
94
- * `.dev.vars.example` exists, we prompt to generate `.dev.vars` from it with
95
- * secrets auto-filled. Identical behaviour to `lunora dev` — both call
96
- * `ensureDevVariables` from `@lunora/config`.
107
+ * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
108
+ * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
109
+ * file is gitignored — so a fresh clone has none and the worker throws on the
110
+ * first required secret (e.g. `AUTH_SECRET is required`). Two steps, both shared
111
+ * with `lunora dev` via `@lunora/config`.
112
+ *
113
+ * First, {@link ensureDevVariables}: when a `.dev.vars.example` exists, prompt
114
+ * to generate `.dev.vars` from it with secrets auto-filled. Second,
115
+ * {@link fillDevSecrets}: fill any empty/placeholder secret already in
116
+ * `.dev.vars` (a `lunora add`-scaffolded project writes secrets blank) and
117
+ * ensure `LUNORA_ADMIN_TOKEN` is present + generated — so the worker boots with
118
+ * working secrets and the Studio authenticates without its login gate. No
119
+ * prompt: it only generates locally-derivable values and never overwrites a real
120
+ * one.
97
121
  *
98
122
  * Runs in `configResolved` (awaited by Vite) so it completes before the
99
123
  * Cloudflare plugin reads the file. Non-interactive runs decline silently.
@@ -198,7 +222,7 @@ declare const isAutoComposable: (context: LunoraPluginContext) => boolean;
198
222
  * virtual module id. Absolute paths are resolved correctly in all environments
199
223
  * (Vite 8 + rolldown 1.x confirmed).
200
224
  */
201
- declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean) => string;
225
+ declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, hasContainers?: boolean, useUmbrella?: boolean) => string;
202
226
  /**
203
227
  * Vite plugin that auto-composes a detected class-A meta-framework's SSR
204
228
  * handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
@@ -281,6 +305,35 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, isServe: ()
281
305
  * the build/close path). Idempotent cleanup means firing on both is safe.
282
306
  */
283
307
  declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
308
+ /**
309
+ * A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
310
+ * options type so the shape can't drift from the installed package. The overlay
311
+ * runs every finder it's given (custom finders first, then its built-ins),
312
+ * sorted by `priority` descending, and shows the first non-`undefined` result.
313
+ *
314
+ * Note: this type (and {@link Solution}) is re-exported from `@lunora/vite` and
315
+ * intentionally tracks the installed `@visulima/vite-overlay` — if a future
316
+ * overlay release changes the finder contract, that surfaces here as a compile
317
+ * error rather than a silent drift.
318
+ */
319
+ type SolutionFinder = NonNullable<OverlayPluginOptions["solutionFinders"]>[number];
320
+ /** What a finder may return: a Markdown-rendered `{ header?, body }`, or `undefined` to defer. */
321
+ type Solution = NonNullable<Awaited<ReturnType<SolutionFinder["handle"]>>>;
322
+ /**
323
+ * Lunora's solution finder for the dev error overlay. A single finder that
324
+ * delegates to `@lunora/codegen`'s shared rule table (the same table the
325
+ * standalone `lunora dev` CLI prints to the terminal) and returns the first
326
+ * match — so one `priority` slot covers every Lunora rule and the overlay's
327
+ * built-in finders still run for anything we don't recognize (we return
328
+ * `undefined`).
329
+ *
330
+ * Priority is high so a Lunora-specific hint wins over the overlay's generic
331
+ * finder for the same error; a user's own finder can still outrank it with a
332
+ * higher `priority`.
333
+ */
334
+ declare const lunoraSolutionFinder: SolutionFinder;
335
+ /** The finders Lunora injects into the overlay by default. */
336
+ declare const lunoraSolutionFinders: ReadonlyArray<SolutionFinder>;
284
337
  /** Dev-server path the studio SPA is served from. */
285
338
  declare const STUDIO_PATH = "/__lunora";
286
339
  /** Static asset routes the studio document references. */
@@ -358,6 +411,17 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
358
411
  */
359
412
  declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
360
413
  /**
414
+ * Resolve the `overlay` toggle into the overlay plugin's options — or `false` to
415
+ * skip it. Lunora's solution finders are **prepended** so they run before the
416
+ * overlay's built-ins; a user's own finders are appended and can still win per
417
+ * error via a strictly higher `priority` (equal priority keeps Lunora first,
418
+ * since the overlay sorts stably). Lunora also forwards both `error` AND `warn`
419
+ * console calls by default (the overlay's own default is `["error"]` only) so
420
+ * Lunora's branded `warn` advisories surface in the browser too — the user can
421
+ * override `forwardedConsoleMethods`.
422
+ */
423
+ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
424
+ /**
361
425
  * Lunora Vite plugin. Returns a flat array of Vite plugins that:
362
426
  *
363
427
  * 1. Run `@lunora/codegen` on startup + on schema file changes.
@@ -371,4 +435,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
371
435
  */
372
436
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
373
437
  declare const VERSION = "0.0.0";
374
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
438
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.mjs CHANGED
@@ -2,19 +2,23 @@ import { cloudflare } from '@cloudflare/vite-plugin';
2
2
  import errorOverlayPlugin from '@visulima/vite-overlay';
3
3
  import { detectAgentRules, claimAgentRulesHint, AGENT_RULES_HINT, detectFramework } from '@lunora/config';
4
4
  export { detectFramework } from '@lunora/config';
5
- import codegenPlugin from './packem_shared/codegenPlugin-BAyt6iWS.mjs';
6
- import devVariablesPlugin from './packem_shared/devVariablesPlugin-BRWbWHhq.mjs';
7
- import { createCommandProbe, withDevWorkerEnv } from './packem_shared/createCommandProbe-Coo6bgVz.mjs';
8
- export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR } from './packem_shared/createCommandProbe-Coo6bgVz.mjs';
9
- import { frameworkComposePlugin } from './packem_shared/frameworkComposePlugin-Cja0SF6x.mjs';
10
- export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/frameworkComposePlugin-Cja0SF6x.mjs';
5
+ import { l as lunoraLine } from './packem_shared/log-BjO9EWah.mjs';
6
+ import codegenPlugin from './packem_shared/codegenPlugin-B_ayaObq.mjs';
7
+ import containerLogsPlugin from './packem_shared/containerLogsPlugin-DMssU3wb.mjs';
8
+ import devVariablesPlugin from './packem_shared/devVariablesPlugin-CDNSnvOP.mjs';
9
+ import { createCommandProbe, withDevWorkerEnv } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
10
+ export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
11
+ import { frameworkComposePlugin } from './packem_shared/CLASS_A_WIRING-DpX_WcOK.mjs';
12
+ export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/CLASS_A_WIRING-DpX_WcOK.mjs';
11
13
  import logStreamPlugin from './packem_shared/logStreamPlugin-CqvZ17kd.mjs';
12
14
  import { planViteRemoteBindings, remoteBindingsCleanupPlugin, withRemoteBindings } from './packem_shared/planViteRemoteBindings-QN5ncUS1.mjs';
13
- import { studioPlugin } from './packem_shared/buildStudioUrl-5ppCdBHa.mjs';
14
- export { STUDIO_PATH, buildStudioUrl } from './packem_shared/buildStudioUrl-5ppCdBHa.mjs';
15
- import { withWorkerStartupHint } from './packem_shared/augmentWorkerStartupError-DhsXUW8k.mjs';
16
- export { WORKER_STARTUP_HINT, augmentWorkerStartupError, isWorkerEntryEvalError } from './packem_shared/augmentWorkerStartupError-DhsXUW8k.mjs';
17
- import { wranglerValidatorPlugin } from './packem_shared/wranglerValidatorPlugin-Cf0nLP7-.mjs';
15
+ import { lunoraSolutionFinders } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
16
+ export { lunoraSolutionFinder } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
17
+ import { studioPlugin } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
18
+ export { STUDIO_PATH, buildStudioUrl } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
19
+ import { withWorkerStartupHint } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
20
+ export { WORKER_STARTUP_HINT, augmentWorkerStartupError, isWorkerEntryEvalError } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
21
+ import { wranglerValidatorPlugin } from './packem_shared/wranglerValidatorPlugin-CEoJEghS.mjs';
18
22
  export { reconcileWranglerCrons } from './packem_shared/reconcileWranglerCrons-PxGwfCp_.mjs';
19
23
 
20
24
  const agentRulesHintPlugin = (options) => {
@@ -26,7 +30,7 @@ const agentRulesHintPlugin = (options) => {
26
30
  return;
27
31
  }
28
32
  server.config.logger.warn(`
29
- [lunora] ${AGENT_RULES_HINT}
33
+ ${lunoraLine(AGENT_RULES_HINT)}
30
34
  `);
31
35
  };
32
36
  },
@@ -50,12 +54,12 @@ const FRAMEWORK_LABELS = {
50
54
  const formatFrameworkDetection = (detection) => {
51
55
  const label = FRAMEWORK_LABELS[detection.framework];
52
56
  if (detection.framework === "none") {
53
- return "[lunora] no meta-framework detected — running standalone (class C).";
57
+ return lunoraLine("no meta-framework detected — running standalone.");
54
58
  }
55
59
  if (detection.class === "B") {
56
- return `[lunora] detected ${label} (class B) hook-injection composition is handled by the framework adapter (not yet wired here).`;
60
+ return lunoraLine(`detected ${label} — composition is handled by the framework adapter.`);
57
61
  }
58
- return `[lunora] detected ${label} (class ${detection.class}) — composing the Lunora worker into one Cloudflare Worker.`;
62
+ return lunoraLine(`detected ${label} — composing the Lunora worker into one Cloudflare Worker.`);
59
63
  };
60
64
  const frameworkDetectPlugin = (options, context) => {
61
65
  let logged = false;
@@ -80,6 +84,19 @@ const frameworkDetectPlugin = (options, context) => {
80
84
  };
81
85
  };
82
86
 
87
+ const resolveOverlayOption = (overlay) => {
88
+ if (overlay === false) {
89
+ return false;
90
+ }
91
+ const userOverlay = overlay === true || overlay === void 0 ? {} : overlay;
92
+ return {
93
+ ...userOverlay,
94
+ // After the spread + nullish-coalesce so an explicit `undefined` from the
95
+ // user doesn't erase Lunora's default (the spread would otherwise win).
96
+ forwardedConsoleMethods: userOverlay.forwardedConsoleMethods ?? ["error", "warn"],
97
+ solutionFinders: [...lunoraSolutionFinders, ...userOverlay.solutionFinders ?? []]
98
+ };
99
+ };
83
100
  const resolveOptions = (options) => {
84
101
  const input = options ?? {};
85
102
  const schemaDirectory = input.schemaDir ?? "lunora";
@@ -91,20 +108,12 @@ const resolveOptions = (options) => {
91
108
  } else {
92
109
  cloudflareOption = input.cloudflare;
93
110
  }
94
- let overlayOption;
95
- if (input.overlay === false) {
96
- overlayOption = false;
97
- } else if (input.overlay === true || input.overlay === void 0) {
98
- overlayOption = {};
99
- } else {
100
- overlayOption = input.overlay;
101
- }
102
111
  return {
103
112
  apiSpec: input.apiSpec ?? "openapi",
104
113
  cloudflare: cloudflareOption,
105
114
  studio: input.studio ?? true,
106
115
  generatedDir: input.generatedDir ?? `${schemaDirectory}/_generated`,
107
- overlay: overlayOption,
116
+ overlay: resolveOverlayOption(input.overlay),
108
117
  projectRoot: input.projectRoot ?? process.cwd(),
109
118
  schemaDir: schemaDirectory,
110
119
  validateWrangler: input.validateWrangler ?? true
@@ -139,6 +148,7 @@ const lunora = (options) => {
139
148
  plugins.push(errorOverlayPlugin(resolved.overlay));
140
149
  }
141
150
  if (resolved.cloudflare !== false) {
151
+ plugins.push(containerLogsPlugin(resolved));
142
152
  const remotePlan = planViteRemoteBindings({ projectRoot: resolved.projectRoot });
143
153
  if (remotePlan.enabled && remotePlan.configPath !== void 0) {
144
154
  plugins.push(remoteBindingsCleanupPlugin(remotePlan.cleanup));
@@ -150,4 +160,4 @@ const lunora = (options) => {
150
160
  };
151
161
  const VERSION = "0.0.0";
152
162
 
153
- export { VERSION, codegenPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, planViteRemoteBindings, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
163
+ export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
@@ -1,9 +1,12 @@
1
- import { existsSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { resolve, join } from 'node:path';
3
3
 
4
4
  const LUNORA_WORKER_VIRTUAL_ID = "virtual:lunora/worker";
5
5
  const RESOLVED_VIRTUAL_PREFIX = "\0";
6
6
  const RESOLVED_LUNORA_WORKER_ID = `${RESOLVED_VIRTUAL_PREFIX}${LUNORA_WORKER_VIRTUAL_ID}`;
7
+ const CLIENT_WORKER_STUB = `// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
8
+ export default {};
9
+ `;
7
10
  const TRAILING_SLASH = /\/$/;
8
11
  const CLASS_A_WIRING = {
9
12
  "react-router": {
@@ -36,18 +39,27 @@ const isAutoComposable = (context) => {
36
39
  return detected?.class === "A" && CLASS_A_WIRING[detected.framework] !== void 0;
37
40
  };
38
41
  const isWorkerVirtualActive = (context) => isAutoComposable(context);
39
- const buildWorkerEntrySource = (framework, generatedImportBase, hasContainers = false) => {
42
+ const projectUsesUmbrella = (projectRoot) => {
43
+ try {
44
+ const pkg = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf8"));
45
+ return ["dependencies", "devDependencies", "peerDependencies"].some((field) => pkg[field]?.["lunorash"] !== void 0);
46
+ } catch {
47
+ return false;
48
+ }
49
+ };
50
+ const buildWorkerEntrySource = (framework, generatedImportBase, hasContainers = false, useUmbrella = false) => {
40
51
  const wiring = CLASS_A_WIRING[framework];
41
52
  if (wiring === void 0) {
42
53
  throw new Error(`[lunora] no class-A worker wiring for framework "${framework}"`);
43
54
  }
55
+ const runtimeModule = useUmbrella ? "lunorash/runtime" : "@lunora/runtime";
44
56
  const containersReexport = hasContainers ? `
45
57
  export * from "${generatedImportBase}/containers";
46
58
  ` : "";
47
59
  return `// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
48
60
  // Do not edit: emitted from the detected framework (${framework}). Point your
49
61
  // wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
50
- import { composeWorker } from "@lunora/runtime";
62
+ import { composeWorker } from "${runtimeModule}";
51
63
  ${wiring.imports}
52
64
  import { LUNORA_FUNCTIONS } from "${generatedImportBase}/functions";
53
65
  import { openApiSpec } from "${generatedImportBase}/openapi";
@@ -75,11 +87,15 @@ export default {
75
87
  };
76
88
  const frameworkComposePlugin = (options, context) => {
77
89
  const generatedImportBase = resolve(options.projectRoot, options.generatedDir.replace(TRAILING_SLASH, ""));
90
+ const useUmbrella = projectUsesUmbrella(options.projectRoot);
78
91
  return {
79
92
  load(id) {
80
93
  if (id === RESOLVED_LUNORA_WORKER_ID && isWorkerVirtualActive(context) && context.framework !== void 0) {
94
+ if (this.environment.name === "client") {
95
+ return CLIENT_WORKER_STUB;
96
+ }
81
97
  const hasContainers = existsSync(join(generatedImportBase, "containers.ts"));
82
- return buildWorkerEntrySource(context.framework.framework, generatedImportBase, hasContainers);
98
+ return buildWorkerEntrySource(context.framework.framework, generatedImportBase, hasContainers, useUmbrella);
83
99
  }
84
100
  return void 0;
85
101
  },
@@ -3,6 +3,7 @@ import { resolve, sep, join } from 'node:path';
3
3
  import { createCodegenProject, refreshCodegenProject, runCodegen, CodegenDiagnosticError } from '@lunora/codegen';
4
4
  import { inferLunoraBindings, reconcileWranglerBindings } from '@lunora/config';
5
5
  import { reconcileWranglerCrons } from './reconcileWranglerCrons-PxGwfCp_.mjs';
6
+ import { L as LUNORA_TAG, a as advisoryLine } from './log-BjO9EWah.mjs';
6
7
 
7
8
  const DEBOUNCE_MS = 100;
8
9
  const TSCONFIG_VARIANT_RE = /[/\\]tsconfig\..+\.json$/u;
@@ -22,23 +23,23 @@ const reconcileBindingsSafely = async (options, logger, onExportGaps) => {
22
23
  const inferred = await inferLunoraBindings({ projectRoot: options.projectRoot, schemaDir: options.schemaDir });
23
24
  const reconciled = reconcileWranglerBindings(options.projectRoot, inferred);
24
25
  if (reconciled.changed) {
25
- logger.info?.(`[lunora] inferred bindings → ${reconciled.added.join(", ")} (written to ${reconciled.wranglerPath ?? "wrangler.jsonc"})`);
26
+ logger.info?.(`${LUNORA_TAG} inferred bindings → ${reconciled.added.join(", ")} (written to ${reconciled.wranglerPath ?? "wrangler.jsonc"})`);
26
27
  }
27
28
  for (const warning of reconciled.warnings) {
28
- logger.warn(`[lunora] ${warning}`);
29
+ logger.warn(`${LUNORA_TAG} ${warning}`);
29
30
  }
30
31
  if (reconciled.exportGaps.length > 0) {
31
32
  onExportGaps?.(reconciled.exportGaps);
32
33
  }
33
34
  } catch (error) {
34
35
  const message = error instanceof Error ? error.message : String(error);
35
- logger.warn(`[lunora] binding inference skipped: ${message}`);
36
+ logger.warn(`${LUNORA_TAG} binding inference skipped: ${message}`);
36
37
  }
37
38
  };
38
39
  const runCodegenSafely = (options, logger, overlay, project) => {
39
40
  const schemaPath = join(options.projectRoot, options.schemaDir, "schema.ts");
40
41
  if (!existsSync(schemaPath)) {
41
- logger.warn(`[lunora] schema.ts not found at ${schemaPath} — codegen skipped`);
42
+ logger.warn(`${LUNORA_TAG} schema.ts not found at ${schemaPath} — codegen skipped`);
42
43
  return void 0;
43
44
  }
44
45
  try {
@@ -46,19 +47,26 @@ const runCodegenSafely = (options, logger, overlay, project) => {
46
47
  try {
47
48
  const reconciled = reconcileWranglerCrons(options.projectRoot, result.cronTriggers);
48
49
  if (reconciled.changed) {
49
- logger.info?.(`[lunora] synced ${result.cronTriggers.length.toFixed(0)} cron trigger(s) into ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
50
+ logger.info?.(
51
+ `${LUNORA_TAG} synced ${result.cronTriggers.length.toFixed(0)} cron trigger(s) into ${reconciled.wranglerPath ?? "wrangler.jsonc"}`
52
+ );
50
53
  }
51
54
  } catch (cronError) {
52
55
  const message = cronError instanceof Error ? cronError.message : String(cronError);
53
- logger.warn(`[lunora] cron trigger sync skipped: ${message}`);
56
+ logger.warn(`${LUNORA_TAG} cron trigger sync skipped: ${message}`);
54
57
  }
55
58
  for (const advisory of result.advisories) {
56
- logger.warn(`[lunora] schema advisory [${advisory.level}] ${advisory.name}: ${advisory.detail} — ${advisory.remediation}`);
59
+ const line = advisoryLine(advisory.level, advisory.name, advisory.detail, advisory.remediation);
60
+ if (advisory.level === "ERROR") {
61
+ logger.error(line);
62
+ } else {
63
+ logger.warn(line);
64
+ }
57
65
  }
58
66
  return resolve(result.outputDirectory);
59
67
  } catch (error) {
60
68
  const message = error instanceof Error ? error.message : String(error);
61
- logger.error(`[lunora] codegen failed: ${message}`);
69
+ logger.error(`${LUNORA_TAG} codegen failed: ${message}`);
62
70
  overlay?.onError(error, message);
63
71
  return void 0;
64
72
  }
@@ -125,19 +133,8 @@ const codegenPlugin = (options) => {
125
133
  let closed = false;
126
134
  let cachedProject;
127
135
  const invalidateGenerated = () => {
128
- const environments = server.environments;
129
- const graphs = [];
130
- if (environments !== void 0) {
131
- for (const environment of Object.values(environments)) {
132
- if (environment.moduleGraph !== void 0) {
133
- graphs.push(environment.moduleGraph);
134
- }
135
- }
136
- }
137
- if (graphs.length === 0) {
138
- graphs.push(server.moduleGraph);
139
- }
140
- for (const graph of graphs) {
136
+ for (const environment of Object.values(server.environments)) {
137
+ const graph = environment.moduleGraph;
141
138
  for (const moduleEntry of graph.idToModuleMap.values()) {
142
139
  if (moduleEntry.id && isInside(moduleEntry.id, absoluteGeneratedDirectory)) {
143
140
  graph.invalidateModule(moduleEntry);
@@ -0,0 +1,50 @@
1
+ import { discoverContainerInfo, streamContainerLogs } from '@lunora/config';
2
+ import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
+
4
+ const containerLogsPlugin = (options) => {
5
+ let handle;
6
+ const closeHandle = () => {
7
+ handle?.close();
8
+ handle = void 0;
9
+ };
10
+ return {
11
+ apply: "serve",
12
+ // Fires on `server.close()` for both the normal and middleware-mode dev
13
+ // servers, so the Docker poll loop is torn down even when there is no
14
+ // `httpServer` to listen on (middleware mode).
15
+ buildEnd() {
16
+ closeHandle();
17
+ },
18
+ configureServer(server) {
19
+ if (handle || process.env.LUNORA_CONTAINER_LOGS === "0") {
20
+ return;
21
+ }
22
+ const discovery = discoverContainerInfo(options.projectRoot, options.schemaDir);
23
+ const containers = discovery.containers.map((container) => {
24
+ return { className: container.className, exportName: container.exportName };
25
+ });
26
+ if (containers.length === 0) {
27
+ return;
28
+ }
29
+ const { logger } = server.config;
30
+ handle = streamContainerLogs({
31
+ containers,
32
+ onLine: (line) => {
33
+ const text = lunoraLine(`container:${line.name} ${line.text}`);
34
+ if (line.level === "error") {
35
+ logger.warn(text);
36
+ } else {
37
+ logger.info(text);
38
+ }
39
+ },
40
+ onUnavailable: (message) => {
41
+ logger.warn(lunoraLine(`container: Docker engine unreachable — container logs unavailable (${message})`));
42
+ }
43
+ });
44
+ server.httpServer?.once("close", closeHandle);
45
+ },
46
+ name: "lunora:container-logs"
47
+ };
48
+ };
49
+
50
+ export { containerLogsPlugin as default };
@@ -0,0 +1,19 @@
1
+ import { ensureDevVariables, createConfirm, fillDevSecrets } from '@lunora/config';
2
+ import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
+
4
+ const devVariablesPlugin = (options) => {
5
+ return {
6
+ apply: "serve",
7
+ async configResolved() {
8
+ const info = (message) => {
9
+ console.info(lunoraLine(message));
10
+ };
11
+ await ensureDevVariables({ confirm: createConfirm("[lunora] "), cwd: options.projectRoot, info });
12
+ fillDevSecrets({ cwd: options.projectRoot, info });
13
+ },
14
+ enforce: "pre",
15
+ name: "lunora:dev-vars"
16
+ };
17
+ };
18
+
19
+ export { devVariablesPlugin as default };
@@ -0,0 +1,8 @@
1
+ import { paintBadge, BADGES } from '@lunora/config';
2
+
3
+ const LUNORA_TAG = paintBadge(BADGES.lunora);
4
+ const lunoraLine = (message) => `${LUNORA_TAG} ${message}`;
5
+ const ADVISORY_BADGE = { ERROR: BADGES.error, INFO: BADGES.info, WARN: BADGES.warn };
6
+ const advisoryLine = (level, name, detail, remediation) => `${paintBadge(ADVISORY_BADGE[level])} ${name}: ${detail} — ${remediation}`;
7
+
8
+ export { LUNORA_TAG as L, advisoryLine as a, lunoraLine as l };
@@ -0,0 +1,17 @@
1
+ import { findLunoraSolution } from '@lunora/codegen';
2
+
3
+ const lunoraSolutionFinder = {
4
+ // Synchronous body wrapped in `Promise.resolve` rather than `async`: the
5
+ // overlay's `handle` contract is promise-returning, but `require-await` is on
6
+ // for src and there's nothing to await here.
7
+ handle: (error) => {
8
+ const message = typeof error.message === "string" ? error.message : "";
9
+ const solution = findLunoraSolution(message);
10
+ return Promise.resolve(solution ? { body: solution.body, header: solution.header } : void 0);
11
+ },
12
+ name: "lunora",
13
+ priority: 100
14
+ };
15
+ const lunoraSolutionFinders = [lunoraSolutionFinder];
16
+
17
+ export { lunoraSolutionFinder, lunoraSolutionFinders };
@@ -1,5 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { validateWranglerProject, readWranglerJsonc } from '@lunora/config';
3
+ import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
4
 
4
5
  const isLocalImagePath = (image) => image.startsWith("./") || image.startsWith("../") || image.startsWith("/") || image.includes("Dockerfile");
5
6
  const probeDocker = () => {
@@ -16,7 +17,9 @@ const warnWhenDockerMissing = (wranglerPath, dockerAvailable = probeDocker) => {
16
17
  return;
17
18
  }
18
19
  console.warn(
19
- "[lunora] 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."
20
+ lunoraLine(
21
+ "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."
22
+ )
20
23
  );
21
24
  };
22
25
  const formatError = (wranglerPath, problems) => {
@@ -48,7 +51,7 @@ const wranglerValidatorPlugin = (options) => {
48
51
  }
49
52
  if (result.report.warnings.length > 0) {
50
53
  for (const warning of result.report.warnings) {
51
- console.warn(`[lunora] wrangler validator: ${warning}`);
54
+ console.warn(lunoraLine(`wrangler validator: ${warning}`));
52
55
  }
53
56
  }
54
57
  if (result.problems.length > 0) {