@lunora/vite 1.0.0-alpha.81 → 1.0.0-alpha.82

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.
Files changed (35) hide show
  1. package/dist/index.d.mts +11 -1
  2. package/dist/index.d.ts +11 -1
  3. package/dist/index.mjs +3 -173
  4. package/dist/packem_shared/CLASS_A_WIRING-QlSvg7Ku.mjs +33 -0
  5. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-CdVg3e_J.mjs +1 -0
  6. package/dist/packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs +1 -0
  7. package/dist/packem_shared/STUDIO_PATH-CCACdfgp.mjs +1 -0
  8. package/dist/packem_shared/WORKER_STARTUP_HINT-Dsm2vG6Q.mjs +5 -0
  9. package/dist/packem_shared/checkLunoraProxy-n_jVuOU-.mjs +1 -0
  10. package/dist/packem_shared/codegenPlugin-Cw1lSUC0.mjs +3 -0
  11. package/dist/packem_shared/containerLogsPlugin-QOsfYAYL.mjs +1 -0
  12. package/dist/packem_shared/devStatePlugin-CMRBp9zZ.mjs +1 -0
  13. package/dist/packem_shared/devVariablesPlugin-0SvpKjRJ.mjs +1 -0
  14. package/dist/packem_shared/log-DTdeAemA.mjs +1 -0
  15. package/dist/packem_shared/logStreamPlugin-CFlQAr0R.mjs +3 -0
  16. package/dist/packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs +1 -0
  17. package/dist/packem_shared/planViteRemoteBindings-BDAdqq6D.mjs +1 -0
  18. package/dist/packem_shared/server-close-C8zGVydc.mjs +1 -0
  19. package/dist/packem_shared/wranglerValidatorPlugin-CHmNBKbO.mjs +3 -0
  20. package/package.json +3 -3
  21. package/dist/packem_shared/CLASS_A_WIRING-T1RohRZQ.mjs +0 -120
  22. package/dist/packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs +0 -36
  23. package/dist/packem_shared/LUNORA_API_UPDATED_EVENT-BrkWk3rr.mjs +0 -3
  24. package/dist/packem_shared/STUDIO_PATH-U0eIaW1t.mjs +0 -236
  25. package/dist/packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs +0 -81
  26. package/dist/packem_shared/codegenPlugin-B8c38rky.mjs +0 -347
  27. package/dist/packem_shared/containerLogsPlugin-DMssU3wb.mjs +0 -50
  28. package/dist/packem_shared/devStatePlugin-DdjfMrhx.mjs +0 -84
  29. package/dist/packem_shared/devVariablesPlugin-CDNSnvOP.mjs +0 -19
  30. package/dist/packem_shared/log-BjO9EWah.mjs +0 -8
  31. package/dist/packem_shared/logStreamPlugin-DeFzd_pC.mjs +0 -81
  32. package/dist/packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs +0 -17
  33. package/dist/packem_shared/planViteRemoteBindings-CRU90Bip.mjs +0 -66
  34. package/dist/packem_shared/server-close-DKDp7YTU.mjs +0 -16
  35. package/dist/packem_shared/wranglerValidatorPlugin-C5VWOD7N.mjs +0 -68
package/dist/index.d.mts CHANGED
@@ -258,6 +258,16 @@ declare const LUNORA_API_UPDATED_EVENT = "lunora:api-updated";
258
258
  * and restores them when that server closes.
259
259
  */
260
260
  declare const logStreamPlugin: () => Plugin;
261
+ /**
262
+ * Warnings for one proxy table. Pure + exported so the behavior is unit-testable
263
+ * without booting a dev server.
264
+ */
265
+ declare const checkLunoraProxy: (proxy: Record<string, unknown> | undefined, label: string) => string[];
266
+ /**
267
+ * Warn when a dev/preview proxy routes `/_lunora/*` without `ws: true` (or with an
268
+ * origin-rewriting `changeOrigin`). See the module docs.
269
+ */
270
+ declare const proxyCheckPlugin: () => Plugin;
261
271
  /** The decision a {@link planViteRemoteBindings} call returns. */
262
272
  interface ViteRemotePlan {
263
273
  /** Idempotent disposer for the temp config; always present + safe to call. */
@@ -458,4 +468,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
458
468
  */
459
469
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
460
470
  declare const VERSION: string;
461
- 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, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
471
+ 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 };
package/dist/index.d.ts CHANGED
@@ -258,6 +258,16 @@ declare const LUNORA_API_UPDATED_EVENT = "lunora:api-updated";
258
258
  * and restores them when that server closes.
259
259
  */
260
260
  declare const logStreamPlugin: () => Plugin;
261
+ /**
262
+ * Warnings for one proxy table. Pure + exported so the behavior is unit-testable
263
+ * without booting a dev server.
264
+ */
265
+ declare const checkLunoraProxy: (proxy: Record<string, unknown> | undefined, label: string) => string[];
266
+ /**
267
+ * Warn when a dev/preview proxy routes `/_lunora/*` without `ws: true` (or with an
268
+ * origin-rewriting `changeOrigin`). See the module docs.
269
+ */
270
+ declare const proxyCheckPlugin: () => Plugin;
261
271
  /** The decision a {@link planViteRemoteBindings} call returns. */
262
272
  interface ViteRemotePlan {
263
273
  /** Idempotent disposer for the temp config; always present + safe to call. */
@@ -458,4 +468,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
458
468
  */
459
469
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
460
470
  declare const VERSION: string;
461
- 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, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
471
+ 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 };
package/dist/index.mjs CHANGED
@@ -1,173 +1,3 @@
1
- import { createRequire } from 'node:module';
2
- import { cloudflare } from '@cloudflare/vite-plugin';
3
- import errorOverlayPlugin from '@visulima/vite-overlay';
4
- import { detectAgentRules, claimAgentRulesHint, AGENT_RULES_HINT, detectFramework } from '@lunora/config';
5
- export { detectFramework, reconcileWranglerCrons } from '@lunora/config';
6
- import { l as lunoraLine } from './packem_shared/log-BjO9EWah.mjs';
7
- import codegenPlugin from './packem_shared/codegenPlugin-B8c38rky.mjs';
8
- import containerLogsPlugin from './packem_shared/containerLogsPlugin-DMssU3wb.mjs';
9
- import devStatePlugin from './packem_shared/devStatePlugin-DdjfMrhx.mjs';
10
- import devVariablesPlugin from './packem_shared/devVariablesPlugin-CDNSnvOP.mjs';
11
- import { createCommandProbe, withDevWorkerEnv } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
12
- export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
13
- import { frameworkComposePlugin } from './packem_shared/CLASS_A_WIRING-T1RohRZQ.mjs';
14
- export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/CLASS_A_WIRING-T1RohRZQ.mjs';
15
- import logStreamPlugin from './packem_shared/logStreamPlugin-DeFzd_pC.mjs';
16
- import { planViteRemoteBindings, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin } from './packem_shared/planViteRemoteBindings-CRU90Bip.mjs';
17
- export { withRemoteBindings } from './packem_shared/planViteRemoteBindings-CRU90Bip.mjs';
18
- import { lunoraSolutionFinders } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
19
- export { lunoraSolutionFinder } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
20
- import { studioPlugin } from './packem_shared/STUDIO_PATH-U0eIaW1t.mjs';
21
- export { STUDIO_PATH, buildStudioUrl } from './packem_shared/STUDIO_PATH-U0eIaW1t.mjs';
22
- import { withWorkerStartupHint } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
23
- export { WORKER_STARTUP_HINT, augmentWorkerStartupError, isWorkerEntryEvalError } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
24
- import { wranglerValidatorPlugin } from './packem_shared/wranglerValidatorPlugin-C5VWOD7N.mjs';
25
- export { default as LUNORA_API_UPDATED_EVENT } from './packem_shared/LUNORA_API_UPDATED_EVENT-BrkWk3rr.mjs';
26
-
27
- const agentRulesHintPlugin = (options) => {
28
- return {
29
- apply: "serve",
30
- configureServer(server) {
31
- return () => {
32
- if (detectAgentRules(options.projectRoot).installed || !claimAgentRulesHint()) {
33
- return;
34
- }
35
- server.config.logger.warn(`
36
- ${lunoraLine(AGENT_RULES_HINT)}
37
- `);
38
- };
39
- },
40
- name: "lunora:agent-rules-hint"
41
- };
42
- };
43
-
44
- const createPluginContext = () => {
45
- return {};
46
- };
47
- const FRAMEWORK_LABELS = {
48
- astro: "Astro",
49
- none: "standalone (SPA / SSR-less)",
50
- nuxt: "Nuxt",
51
- "react-router": "React Router",
52
- "solid-start": "SolidStart",
53
- sveltekit: "SvelteKit",
54
- "tanstack-start": "TanStack Start",
55
- "tanstack-start-solid": "TanStack Start (Solid)"
56
- };
57
- const formatFrameworkDetection = (detection) => {
58
- const label = FRAMEWORK_LABELS[detection.framework];
59
- if (detection.framework === "none") {
60
- return lunoraLine("no meta-framework detected — running standalone.");
61
- }
62
- if (detection.class === "B") {
63
- return lunoraLine(`detected ${label} — composition is handled by the framework adapter.`);
64
- }
65
- return lunoraLine(`detected ${label} — composing the Lunora worker into one Cloudflare Worker.`);
66
- };
67
- const frameworkDetectPlugin = (options, context) => {
68
- let logged = false;
69
- const detect = () => {
70
- context.framework ??= detectFramework(options.projectRoot);
71
- };
72
- return {
73
- config() {
74
- detect();
75
- },
76
- configResolved() {
77
- detect();
78
- },
79
- configureServer() {
80
- detect();
81
- if (!logged && context.framework !== void 0) {
82
- logged = true;
83
- console.info(formatFrameworkDetection(context.framework));
84
- }
85
- },
86
- name: "lunora:framework-detect"
87
- };
88
- };
89
-
90
- const resolveOverlayOption = (overlay) => {
91
- if (overlay === false) {
92
- return false;
93
- }
94
- const userOverlay = overlay === true || overlay === void 0 ? {} : overlay;
95
- return {
96
- ...userOverlay,
97
- // After the spread + nullish-coalesce so an explicit `undefined` from the
98
- // user doesn't erase Lunora's default (the spread would otherwise win).
99
- forwardedConsoleMethods: userOverlay.forwardedConsoleMethods ?? ["error", "warn"],
100
- solutionFinders: [...lunoraSolutionFinders, ...userOverlay.solutionFinders ?? []]
101
- };
102
- };
103
- const resolveOptions = (options) => {
104
- const input = options ?? {};
105
- const schemaDirectory = input.schemaDir ?? "lunora";
106
- let cloudflareOption;
107
- if (input.cloudflare === false) {
108
- cloudflareOption = false;
109
- } else if (input.cloudflare === true || input.cloudflare === void 0) {
110
- cloudflareOption = {};
111
- } else {
112
- cloudflareOption = input.cloudflare;
113
- }
114
- return {
115
- allowUnauthenticatedShardAccess: input.allowUnauthenticatedShardAccess ?? false,
116
- apiSpec: input.apiSpec ?? "openapi",
117
- cloudflare: cloudflareOption,
118
- studio: input.studio ?? true,
119
- generatedDir: input.generatedDir ?? `${schemaDirectory}/_generated`,
120
- overlay: resolveOverlayOption(input.overlay),
121
- projectRoot: input.projectRoot ?? process.cwd(),
122
- schemaDir: schemaDirectory,
123
- validateWrangler: input.validateWrangler ?? true
124
- };
125
- };
126
- const lunora = (options) => {
127
- const resolved = resolveOptions(options);
128
- const context = createPluginContext();
129
- const { isServe, plugin: commandProbe } = createCommandProbe();
130
- const plugins = [
131
- commandProbe,
132
- frameworkDetectPlugin(resolved, context),
133
- // Reads the detected framework off `context` and, for a class-A
134
- // framework (and only when the CF integration is on), resolves the
135
- // `virtual:lunora/worker` entry to a `composeWorker`-based worker that
136
- // routes `/_lunora/*` to Lunora and falls through to the framework SSR
137
- // handler — so the template never hand-wires `createWorker({ httpRouter })`.
138
- // A strict no-op for class-C and the `cloudflare: false` BYO path.
139
- frameworkComposePlugin(resolved, context),
140
- devVariablesPlugin(resolved),
141
- codegenPlugin(resolved),
142
- logStreamPlugin(),
143
- // Registers the running dev server in `.lunora/dev.json` so
144
- // `lunora dev --background|stop|status|logs` manage Vite projects too.
145
- devStatePlugin(resolved),
146
- agentRulesHintPlugin(resolved)
147
- ];
148
- if (resolved.studio) {
149
- plugins.push(studioPlugin());
150
- }
151
- if (resolved.validateWrangler) {
152
- plugins.push(wranglerValidatorPlugin(resolved));
153
- }
154
- if (resolved.overlay !== false) {
155
- plugins.push(errorOverlayPlugin(resolved.overlay));
156
- }
157
- if (resolved.cloudflare !== false) {
158
- plugins.push(containerLogsPlugin(resolved));
159
- const remotePlan = planViteRemoteBindings({ projectRoot: resolved.projectRoot });
160
- const cloudflareOptions = withDevWorkerEnv(resolved.cloudflare, isServe);
161
- if (remotePlan.enabled) {
162
- if (remotePlan.configPath !== void 0) {
163
- plugins.push(remoteBindingsCleanupPlugin(remotePlan.cleanup));
164
- }
165
- plugins.push(remoteBindingsConfigPlugin(cloudflareOptions, remotePlan));
166
- }
167
- plugins.push(...withWorkerStartupHint(cloudflare(cloudflareOptions)));
168
- }
169
- return plugins;
170
- };
171
- const VERSION = createRequire(import.meta.url)("../package.json").version;
172
-
173
- export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withWorkerStartupHint, wranglerValidatorPlugin };
1
+ import{createRequire as u}from"node:module";import{cloudflare as m}from"@cloudflare/vite-plugin";import d from"@visulima/vite-overlay";import{detectAgentRules as c,claimAgentRulesHint as p,AGENT_RULES_HINT as f,detectFramework as g}from"@lunora/config";import{detectFramework as sr,reconcileWranglerCrons as lr}from"@lunora/config";import{g as i}from"./packem_shared/log-DTdeAemA.mjs";import S from"./packem_shared/codegenPlugin-Cw1lSUC0.mjs";import R from"./packem_shared/containerLogsPlugin-QOsfYAYL.mjs";import k from"./packem_shared/devStatePlugin-CMRBp9zZ.mjs";import h from"./packem_shared/devVariablesPlugin-0SvpKjRJ.mjs";import{createCommandProbe as v,withDevWorkerEnv as w}from"./packem_shared/DEV_WORKER_ENV_VALUE-CdVg3e_J.mjs";import{DEV_WORKER_ENV_VALUE as mr,DEV_WORKER_ENV_VAR as dr}from"./packem_shared/DEV_WORKER_ENV_VALUE-CdVg3e_J.mjs";import{frameworkComposePlugin as P}from"./packem_shared/CLASS_A_WIRING-QlSvg7Ku.mjs";import{CLASS_A_WIRING as pr,LUNORA_WORKER_VIRTUAL_ID as fr,buildWorkerEntrySource as gr,isAutoComposable as Sr}from"./packem_shared/CLASS_A_WIRING-QlSvg7Ku.mjs";import E from"./packem_shared/logStreamPlugin-CFlQAr0R.mjs";import{proxyCheckPlugin as A}from"./packem_shared/checkLunoraProxy-n_jVuOU-.mjs";import{checkLunoraProxy as kr}from"./packem_shared/checkLunoraProxy-n_jVuOU-.mjs";import{planViteRemoteBindings as _,remoteBindingsCleanupPlugin as W,remoteBindingsConfigPlugin as x}from"./packem_shared/planViteRemoteBindings-BDAdqq6D.mjs";import{withRemoteBindings as vr}from"./packem_shared/planViteRemoteBindings-BDAdqq6D.mjs";import{lunoraSolutionFinders as C}from"./packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs";import{lunoraSolutionFinder as Pr}from"./packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs";import{studioPlugin as D}from"./packem_shared/STUDIO_PATH-CCACdfgp.mjs";import{STUDIO_PATH as Ar,buildStudioUrl as _r}from"./packem_shared/STUDIO_PATH-CCACdfgp.mjs";import{withWorkerStartupHint as V}from"./packem_shared/WORKER_STARTUP_HINT-Dsm2vG6Q.mjs";import{WORKER_STARTUP_HINT as xr,augmentWorkerStartupError as Cr,isWorkerEntryEvalError as Dr}from"./packem_shared/WORKER_STARTUP_HINT-Dsm2vG6Q.mjs";import{wranglerValidatorPlugin as $}from"./packem_shared/wranglerValidatorPlugin-CHmNBKbO.mjs";import{default as $r}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";const y=o=>({apply:"serve",configureServer(r){return()=>{c(o.projectRoot).installed||!p()||r.config.logger.warn(`
2
+ ${i(f)}
3
+ `)}},name:"lunora:agent-rules-hint"}),T=()=>({}),N={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)"},U=o=>{const r=N[o.framework];return o.framework==="none"?i("no meta-framework detected — running standalone."):o.class==="B"?i(`detected ${r} — composition is handled by the framework adapter.`):i(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},L=(o,r)=>{let t=!1;const e=()=>{r.framework??=g(o.projectRoot)};return{config(){e()},configResolved(){e()},configureServer(){e(),!t&&r.framework!==void 0&&(t=!0,console.info(U(r.framework)))},name:"lunora:framework-detect"}},O=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...C,...r.solutionFinders??[]]}},I=o=>{const r=o??{},t=r.schemaDir??"lunora";let e;return r.cloudflare===!1?e=!1:r.cloudflare===!0||r.cloudflare===void 0?e={}:e=r.cloudflare,{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:e,studio:r.studio??!0,generatedDir:r.generatedDir??`${t}/_generated`,overlay:O(r.overlay),projectRoot:r.projectRoot??process.cwd(),schemaDir:t,validateWrangler:r.validateWrangler??!0}},tr=o=>{const r=I(o),t=T(),{isServe:e,plugin:l}=v(),a=[l,L(r,t),P(r,t),h(r),S(r),E(),k(r),y(r),A()];if(r.studio&&a.push(D()),r.validateWrangler&&a.push($(r)),r.overlay!==!1&&a.push(d(r.overlay)),r.cloudflare!==!1){a.push(R(r));const n=_({projectRoot:r.projectRoot}),s=w(r.cloudflare,e);n.enabled&&(n.configPath!==void 0&&a.push(W(n.cleanup)),a.push(x(s,n))),a.push(...V(m(s)))}return a},ar=u(import.meta.url)("../package.json").version;export{pr as CLASS_A_WIRING,mr as DEV_WORKER_ENV_VALUE,dr as DEV_WORKER_ENV_VAR,$r as LUNORA_API_UPDATED_EVENT,fr as LUNORA_WORKER_VIRTUAL_ID,Ar as STUDIO_PATH,ar as VERSION,xr as WORKER_STARTUP_HINT,Cr as augmentWorkerStartupError,_r as buildStudioUrl,gr as buildWorkerEntrySource,kr as checkLunoraProxy,S as codegenPlugin,R as containerLogsPlugin,v as createCommandProbe,sr as detectFramework,k as devStatePlugin,h as devVariablesPlugin,P as frameworkComposePlugin,Sr as isAutoComposable,Dr as isWorkerEntryEvalError,E as logStreamPlugin,tr as lunora,Pr as lunoraSolutionFinder,C as lunoraSolutionFinders,_ as planViteRemoteBindings,A as proxyCheckPlugin,lr as reconcileWranglerCrons,W as remoteBindingsCleanupPlugin,x as remoteBindingsConfigPlugin,O as resolveOverlayOption,D as studioPlugin,w as withDevWorkerEnv,vr as withRemoteBindings,V as withWorkerStartupHint,$ as wranglerValidatorPlugin};
@@ -0,0 +1,33 @@
1
+ import{existsSync as f,readFileSync as h}from"node:fs";import{resolve as k,join as l}from"node:path";import{LunoraError as w}from"@lunora/errors";const m="virtual:lunora/worker",v="\0",i=`${v}${m}`,A=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
2
+ export default {};
3
+ `,R=/\/$/,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";'}},S=r=>{const e=r.framework;return e?.class==="A"&&u[e.framework]!==void 0},c=r=>S(r),O=r=>{try{const e=JSON.parse(h(l(r,"package.json"),"utf8"));return["dependencies","devDependencies","peerDependencies"].some(t=>e[t]?.lunorash!==void 0)}catch{return!1}},$=(r,e,t=!1,s=!1,o=!1)=>{const a=u[r];if(a===void 0)throw new w("INTERNAL",`[lunora] no class-A worker wiring for framework "${r}"`);const n=e.replaceAll("\\","/"),d=s?"lunorash/runtime":"@lunora/runtime",p=t?`
4
+ export * from "${n}/containers";
5
+ `:"";return`// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
6
+ // Do not edit: emitted from the detected framework (${r}). Point your
7
+ // wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
8
+ import { composeWorker } from "${d}";
9
+ ${a.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();
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: ${a.handler},
25
+ openApiSpec,
26
+ routes: {},
27
+ shardDO: env.SHARD,
28
+ });
29
+
30
+ return worker.fetch(request, env, context);
31
+ },
32
+ };
33
+ `},L=(r,e)=>{const t=k(r.projectRoot,r.generatedDir.replace(R,"")),s=O(r.projectRoot);return{load(o){if(o===i&&c(e)&&e.framework!==void 0){if(this.environment.name==="client")return A;const a=f(l(t,"containers.ts"));return $(e.framework.framework,t,a,s,r.allowUnauthenticatedShardAccess)}},name:"lunora:framework-compose",resolveId(o){if(o===m&&c(e))return i}}};export{u as CLASS_A_WIRING,m as LUNORA_WORKER_VIRTUAL_ID,i as RESOLVED_LUNORA_WORKER_ID,$ as buildWorkerEntrySource,L as frameworkComposePlugin,S as isAutoComposable};
@@ -0,0 +1 @@
1
+ const a="WORKER_ENV",t="development",c=(n,r)=>{const e=n.config;return{...n,config:o=>{if(typeof e=="function"){const s=e(o);s&&Object.assign(o,s)}else e&&Object.assign(o,e);r()&&(o.vars={[a]:t,...o.vars})}}},E=()=>{let n;return{isServe:()=>n==="serve",plugin:{config(r,e){n=e.command},enforce:"pre",name:"lunora:command-probe"}}};export{t as DEV_WORKER_ENV_VALUE,a as DEV_WORKER_ENV_VAR,E as createCommandProbe,c as withDevWorkerEnv};
@@ -0,0 +1 @@
1
+ const a="lunora:api-updated";export{a as default};
@@ -0,0 +1 @@
1
+ import{detectAgentRules as C}from"@lunora/config";import{handleSeedRequest as L,handleSchemaEditRequest as x,handlePolicyScaffoldRequest as b,SEED_ENDPOINT as A,SCHEMA_EDIT_ENDPOINT as H,POLICY_SCAFFOLD_ENDPOINT as $,serveJsonHandler as w,isStandaloneModulePath as E,renderStudioHtml as O,resolveAdminToken as I,studioAssetsStamp as P,loadStudioAssets as U,readStandaloneAsset as _,assetContentType as D}from"@lunora/config/studio-host";const c="/__lunora",j=`${c}/studio.js`,v=`${c}/styles.css`,k=/^\//,g=/\/$/,y={[$]:b,[H]:x,[A]:L},N=new Set(Object.keys(y)),u=t=>{const e=Array.isArray(t)?t[0]:t;return typeof e=="string"?e.trim().toLowerCase():void 0},W=t=>{if(t===void 0||t==="")return!0;const e=t.toLowerCase(),s=e.startsWith("::ffff:")?e.slice(7):e;return s==="::1"?!0:s.startsWith("127.")},B=t=>{if(t===void 0)return;if(t.startsWith("[")){const s=t.indexOf("]");return s===-1?t.slice(1):t.slice(1,s)}const e=t.indexOf(":");return e===-1?t:t.slice(0,e)},R=new Set(["0.0.0.0","127.0.0.1","::1","localhost"]),q=t=>{if(!W(t.socket?.remoteAddress??void 0))return"Lunora studio is only available on loopback connections in dev.";const e=B(u(t.headers?.host));if(e!==void 0&&!R.has(e))return"Lunora studio rejects a non-localhost Host header in dev.";if(["x-forwarded-for","x-forwarded-host","x-forwarded-proto","forwarded"].some(s=>t.headers?.[s]!==void 0))return"Lunora studio refuses a proxied (X-Forwarded-*) request in dev."},F=t=>{const e=u(t["sec-fetch-site"]);if(e!==void 0)return e==="same-origin"||e==="same-site"||e==="none"?void 0:"cross-origin request rejected";const s=u(t.origin);if(s===void 0||s==="null")return;let r;try{r=new URL(s).host.toLowerCase()}catch{return"invalid origin header"}const a=u(t.host);return a===void 0||r!==a?"cross-origin request rejected":void 0},G=t=>{const e=t.headers??{},s=F(e);if(s!==void 0)return s;const r=(t.method??"GET").toUpperCase();if(r!=="GET"&&r!=="HEAD"&&!u(e["content-type"])?.startsWith("application/json"))return"content-type must be application/json"},m=(t,e,s)=>{t.statusCode=200,t.setHeader("Content-Type",s),t.end(e)},J=t=>{const e=c.replace(k,"");if(t.resolvedLocal!==void 0&&t.resolvedLocal!=="")return`${t.resolvedLocal.endsWith("/")?t.resolvedLocal.slice(0,-1):t.resolvedLocal}/${e}`;const s=t.base===void 0||t.base==="/"?"":t.base.replace(g,"");if(t.address===void 0||typeof t.address=="string")return`http://localhost:5173${s}/${e}`;const r=t.address.address==="::"||t.address.address==="0.0.0.0"?"localhost":t.address.address;return`http://${r.includes(":")?`[${r}]`:r}:${String(t.address.port)}${s}/${e}`},M=t=>{try{return new URL(t,"http://localhost").pathname.replace(g,"")}catch{return t}},Y=(t,e)=>{let s,r,a;const h=t.config.root??process.cwd(),T=(i,d,o)=>{const n=P();if((s===void 0||n!==r)&&(s=U(t.config.logger),r=n),s===void 0){o.statusCode=501,o.setHeader("Content-Type","text/plain"),o.end("Lunora studio assets not found — install and build @lunora/studio.");return}const f=i===v,l=i.slice(i.lastIndexOf("/")+1),p=n===void 0?void 0:`W/"${l}-${String(n)}"`;if(o.setHeader("Cache-Control","no-cache"),p!==void 0&&(o.setHeader("ETag",p),u(d.headers?.["if-none-match"])===p.toLowerCase())){o.statusCode=304,o.end();return}if(f){m(o,s.styles,"text/css; charset=utf-8");return}const S=_(l);if(S===void 0){o.statusCode=404,o.setHeader("Content-Type","text/plain"),o.end("Not found");return}m(o,S,D(l))};return(i,d,o)=>{const n=M(i.url??"");if(n!==c&&!n.startsWith(`${c}/`)){o();return}if(e||q(i)!==void 0){d.statusCode=403,d.setHeader("Content-Type","text/plain"),d.end("Lunora studio is only available on loopback hosts in dev.");return}if(N.has(n)){const l=G(i);if(l!==void 0){d.statusCode=403,d.setHeader("Content-Type","application/json; charset=utf-8"),d.end(JSON.stringify({error:l,ok:!1}));return}}const f=y[n];if(f!==void 0){w(i,d,f,h);return}if(n===v||E(n)){T(n,i,d);return}a??=O({adminToken:I(h),basePath:c,dataEditable:!0,rulesInstalled:C(h).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:j,styleHref:v}),m(d,a,"text/html; charset=utf-8")}},X=()=>({apply:"serve",configureServer(t){const e=t.config.server?.host,s=e!==void 0&&e!==!1&&e!=="localhost"&&e!=="127.0.0.1"&&e!=="::1";return t.middlewares.use(Y(t,s)),()=>{const r=()=>{const a=J({address:t.httpServer?.address()??void 0,base:t.config.base,resolvedLocal:t.resolvedUrls?.local[0]});t.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${a}\x1B[39m`)};if(typeof t.printUrls=="function"){const a=t.printUrls.bind(t);t.printUrls=()=>{a(),r()}}else t.httpServer?.listening===!0?r():t.httpServer?.once("listening",r)}},name:"lunora:studio"});export{c as STUDIO_PATH,j as STUDIO_SCRIPT_PATH,v as STUDIO_STYLE_PATH,J as buildStudioUrl,X as studioPlugin};
@@ -0,0 +1,5 @@
1
+ const n=[""," ┌─ Lunora ──────────────────────────────────────────────────────────────"," │ Your Worker entry threw while loading, so the dev server couldn't read"," │ its exports. The TypeError above comes from inside the Cloudflare"," │ runtime and hides the file that actually failed. It is almost always:"," │"," │ • A circular import in lunora/. A query/mutation/action module ran at"," │ the top level before `v`/`query`/`mutation` finished initializing,"," │ so they were `undefined` (hence `reading 'string'`/`'id'`/…)."," │ → Import `v`/`query`/`mutation` only from `lunora/_generated/server`,"," │ and don't import one lunora/ function module from another at the"," │ top level."," │"," │ • Stale or missing generated files."," │ → Re-run `lunora codegen`, then restart the dev server."," │"," │ Tip: check the lunora/ files you edited most recently — the throw is at"," │ their module top level."," └───────────────────────────────────────────────────────────────────────"].join(`
2
+ `),l=/runner-worker[/\\]index\.js/u,u=/getWorkerEntryExportTypes/u,d=e=>{if(!(e instanceof Error))return!1;const r=`${e.stack??""}
3
+ ${e.message}`;return l.test(r)||u.test(r)},i=Symbol.for("lunora.workerStartupHintApplied"),c=e=>{if(!d(e))return e;const r=e;return r[i]||Object.isFrozen(r)||Object.isSealed(r)||(r[i]=!0,r.message=`${r.message}
4
+ ${n}`,typeof r.stack=="string"&&(r.stack=`${r.stack}
5
+ ${n}`)),e},s=e=>async(...r)=>{try{return await e(...r)}catch(t){throw c(t)}},h=e=>typeof e=="function"?s(e):e!==null&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"?{...e,handler:s(e.handler)}:e,f=["configureServer","buildStart"],m=e=>e.map(r=>{let t=r;for(const o of f){const a=r[o];a!==void 0&&(t={...t,[o]:h(a)})}return t});export{n as WORKER_STARTUP_HINT,c as augmentWorkerStartupError,d as isWorkerEntryEvalError,m as withWorkerStartupHint};
@@ -0,0 +1 @@
1
+ import{g as a}from"./log-DTdeAemA.mjs";const c=["/_lunora"],h="/_lunora/ws",p=e=>{if(e.startsWith("^"))try{return new RegExp(e,"u").test(h)}catch{return!1}return c.some(r=>e.startsWith(r)||r.startsWith(e))},i=(e,r)=>{if(!e)return[];const t=[];for(const[s,o]of Object.entries(e)){if(!p(s))continue;if(typeof o=="string"){t.push(`${r}.proxy["${s}"] uses the string shorthand, which does not proxy WebSocket upgrades. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work. Use the object form: { target: "${o}", ws: true }.`);continue}if(typeof o!="object"||o===null)continue;const n=o;n.ws!==!0&&t.push(`${r}.proxy["${s}"] is missing \`ws: true\`, so WebSocket upgrades are not proxied. Live queries and shapes will never connect (the app hangs on its loading state) while HTTP RPC appears to work.`),n.changeOrigin===!0&&t.push(`${r}.proxy["${s}"] sets \`changeOrigin: true\`, so the worker sees a different origin than the browser sends. Loopback-to-loopback is trusted by default; for any other dev host add the dev-server origin to the worker's \`security.csrf.trustedOrigins\` or the cookie-bearing WebSocket upgrade is rejected with FORBIDDEN_ORIGIN.`)}return t},g=()=>({apply:"serve",configResolved(e){const r=[...i(e.server.proxy,"server"),...i(e.preview.proxy,"preview")];for(const t of r)e.logger.warn(a(t))},name:"lunora:proxy-check"});export{i as checkLunoraProxy,g as proxyCheckPlugin};
@@ -0,0 +1,3 @@
1
+ import{existsSync as W}from"node:fs";import{join as C,resolve as p,sep as j,basename as N}from"node:path";import{createCodegenProject as F,refreshCodegenProject as G,runCodegen as L,CodegenDiagnosticError as T}from"@lunora/codegen";import{findWranglerFile as A,LUNORA_CONFIG_FILE as x,readWranglerJsonc as M,WRANGLER_FILES as B,collectWranglerSecretVariables as I,inferLunoraBindings as J,reconcileWranglerBindings as V,reconcileWranglerCrons as K,reconcileWranglerCompatibilityDate as Q}from"@lunora/config";import{isRunnableDevEnvironment as U}from"vite";import X from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{s as g,A as Y}from"./log-DTdeAemA.mjs";import{r as Z,a as q}from"./server-close-C8zGVydc.mjs";const E=(r,o)=>{try{const{parsed:n,text:e}=M(r);return n===void 0?`raw:${e}`:JSON.stringify(o?o(n):n)}catch{return"unreadable"}},z=r=>{const o={...r},{triggers:n}=o;if(n!==null&&typeof n=="object"){const e={...n};delete e.crons,Object.keys(e).length>0?o.triggers=e:delete o.triggers}return o},k=r=>{const o=A(r),n=o===void 0?"absent":E(o,z),e=C(r,x),a=W(e)?E(e):"absent";return`${n}\0${a}`},H=100,ee=/[/\\]tsconfig\..+\.json$/u,re=r=>{const o=r.map(e=>` • ${e.kind} "${e.exportName}" — class ${e.className} is not exported by your worker entry.`),n=[...new Set(r.map(e=>e.module))].map(e=>` export * from "./lunora/_generated/${e}";`);return[`[lunora] ${String(r.length)} declared ${r.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...o,"","Add to your worker entry:",...n].join(`
2
+ `)},oe=async(r,o,n)=>{try{const e=await J({projectRoot:r.projectRoot,schemaDir:r.schemaDir}),a=V(r.projectRoot,e);a.changed&&o.info?.(`${g} inferred bindings → ${a.added.join(", ")} (written to ${a.wranglerPath??"wrangler.jsonc"})`);for(const c of a.warnings)o.warn(`${g} ${c}`);a.exportGaps.length>0&&n?.(a.exportGaps)}catch(e){const a=e instanceof Error?e.message:String(e);o.warn(`${g} binding inference skipped: ${a}`)}},te=(r,o,n)=>{try{const e=K(r,o);e.changed&&n.info?.(`${g} synced ${o.length.toFixed(0)} cron trigger(s) into ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const a=e instanceof Error?e.message:String(e);n.warn(`${g} cron trigger sync skipped: ${a}`)}try{const e=Q(r);e.changed&&n.info?.(`${g} bumped compatibility_date to ${e.date??"unknown"} (Workers Cache enabled) → ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const a=e instanceof Error?e.message:String(e);n.warn(`${g} compatibility date sync skipped: ${a}`)}},D=(r,o,n,e)=>{const a=C(r.projectRoot,r.schemaDir,"schema.ts");if(!W(a)){o.warn(`${g} schema.ts not found at ${a} — codegen skipped`);return}try{const c=L({apiSpec:r.apiSpec,lunoraDirectory:r.schemaDir,project:e,projectRoot:r.projectRoot,wranglerVariables:I(r.projectRoot)});te(r.projectRoot,c.cronTriggers,o);for(const d of c.advisories){const m=Y(d.level,d.name,d.detail,d.remediation);d.level==="ERROR"?o.error(m):o.warn(m)}return p(c.outputDirectory)}catch(c){const d=c instanceof Error?c.message:String(c);o.error(`${g} codegen failed: ${d}`),n?.onError(c,d);return}},ne=(r,o,n)=>{let e;for(const[a,c]of Object.entries(r.environments)){if(a==="client"){e=c;continue}U(c)||c.hot.send({path:"*",triggeredBy:o,type:"full-reload"})}if(e===void 0){r.hot.send({type:"full-reload"});return}if(n){e.hot.send({type:"full-reload"});return}e.hot.send({event:X,type:"custom"})},pe=r=>{const o=p(r.projectRoot,r.schemaDir);let n=p(r.projectRoot,r.generatedDir),e;const a=new Map;let c,d=!1,m=!1;return{async buildStart(){const t={error:f=>{console.error(f)},info:f=>{console.info(f)},warn:f=>{console.warn(f)}},v=D(r,t);v!==void 0&&(n=v),await oe(r,t,f=>{e?.hot.send({err:{loc:void 0,message:re(f),stack:""},type:"error"})}),e!==void 0&&(c=k(r.projectRoot),d=!0)},configureServer(t){e=t,t.watcher.add(o),c=k(r.projectRoot),d=!1;const v={error:s=>{t.config.logger.error(s)},info:s=>{t.config.logger.info(s)},warn:s=>{t.config.logger.warn(s)}};let f=!1;const _={onError(s,i){f=!0;const l=s instanceof T?{column:s.column,file:s.file,line:s.line}:void 0,y=l===void 0?`[lunora] codegen failed: ${i}
3
+ (see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${i}`;e?.hot.send({err:{loc:l,message:y,stack:s instanceof Error?s.stack??"":""},type:"error"})}},b=(s,i)=>s===i||s.startsWith(i+j);let R=!1,u,h;const P=()=>{for(const s of Object.values(t.environments)){const i=s.moduleGraph;for(const l of i.idToModuleMap.values())l.id&&b(l.id,n)&&i.invalidateModule(l)}},w=s=>{const i=p(s);if(b(i,o)&&!b(i,n)){if(i.endsWith(`${j}tsconfig.json`)||ee.test(i)){h=void 0;return}i.endsWith(".ts")&&(i.includes(`${j}__tests__${j}`)||i.endsWith(".test.ts")||i.endsWith(".spec.ts")||(u&&clearTimeout(u),u=setTimeout(()=>{if(u=void 0,R)return;h===void 0?h=F(o):G(h,o);const l=D(r,v,_,h);if(l===void 0){h=void 0;return}n=l,P(),ne(t,i,f),f=!1},H)))}};t.watcher.on("add",w),t.watcher.on("change",w),t.watcher.on("unlink",w);const S=new Set([...B.map(s=>p(r.projectRoot,s)),p(r.projectRoot,x)]);for(const s of S)t.watcher.add(s);const $=s=>{if(!S.has(p(s))||m)return;const i=k(r.projectRoot);if(!d){c=i;return}if(c===void 0){c=i;return}i!==c&&(c=i,m=!0,t.config.logger.info(`${g} ${N(p(s))} changed — restarting dev server`),Promise.resolve(t.restart()).finally(()=>{m=!1}).catch(l=>{const y=l instanceof Error?l.message:String(l);t.config.logger.error(`${g} dev server restart failed: ${y} — keeping the running server; re-save your config to retry.`),t.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${y}`,stack:""},type:"error"})}))};t.watcher.on("add",$),t.watcher.on("change",$),t.watcher.on("unlink",$);const O=()=>{R||(R=!0,h=void 0,u&&(clearTimeout(u),u=void 0),t.watcher.off("add",w),t.watcher.off("change",w),t.watcher.off("unlink",w),t.watcher.off("add",$),t.watcher.off("change",$),t.watcher.off("unlink",$))};return()=>{q(t,a,O)}},buildEnd(){Z(a,this.environment)},name:"lunora:codegen"}};export{pe as default};
@@ -0,0 +1 @@
1
+ import{discoverContainerInfo as l,streamContainerLogs as m}from"@lunora/config";import{g as s}from"./log-DTdeAemA.mjs";const u=r=>{let n;const a=()=>{n?.close(),n=void 0};return{apply:"serve",buildEnd(){a()},configureServer(t){if(n||process.env.LUNORA_CONTAINER_LOGS==="0")return;const c=l(r.projectRoot,r.schemaDir).containers.map(e=>({className:e.className,exportName:e.exportName}));if(c.length===0)return;const{logger:o}=t.config;n=m({containers:c,onLine:e=>{const i=s(`container:${e.name} ${e.text}`);e.level==="error"?o.warn(i):o.info(i)},onUnavailable:e=>{o.warn(s(`container: Docker engine unreachable — container logs unavailable (${e})`))}}),t.httpServer?.once("close",a)},name:"lunora:container-logs"}};export{u as default};
@@ -0,0 +1 @@
1
+ import{claimDevServerState as d,DEV_LOG_FILE_ENV as p,DEV_DAEMON_ENV as c,DEV_HANDOFF_ENV as u,clearDevServerState as v}from"@lunora/config";import{g}from"./log-DTdeAemA.mjs";import{r as f,a as m}from"./server-close-C8zGVydc.mjs";const S=/\/$/,D=n=>{const r=n.resolvedUrls?.local[0];if(r!==void 0)return r.replace(S,"");const t=n.httpServer?.address();if(t!==null&&typeof t=="object")return`http://localhost:${String(t.port)}`},_=n=>{let r=!1;const t=new Map;return{apply:"serve",configureServer(e){const l=n.projectRoot,a=()=>{if(r)return;const o=D(e);if(o===void 0)return;const s=Number(process.env[u]),i=d(l,{background:process.env[c]==="1",logFile:process.env[p],mode:"vite",pid:process.pid,startedAt:new Date().toISOString(),url:o},Number.isInteger(s)&&s>0?{supersedePid:s}:void 0);if(!i.ok){i.existing!==void 0&&e.config.logger.warn(g(`another dev server is already recorded at ${i.existing.url} (pid ${String(i.existing.pid)}) — leaving .lunora/dev.json untouched`));return}r=!0};return m(e,t,()=>{r&&(v(l,process.pid),r=!1)}),()=>{if(typeof e.printUrls=="function"){const o=e.printUrls.bind(e);e.printUrls=()=>{o(),a()}}e.httpServer?.once("listening",()=>{setTimeout(a,0)})}},buildEnd(){f(t,this.environment)},name:"lunora:dev-state"}};export{_ as default};
@@ -0,0 +1 @@
1
+ import{ensureDevVariables as n,createConfirm as a,fillDevSecrets as c}from"@lunora/config";import{g as t}from"./log-DTdeAemA.mjs";const s=o=>({apply:"serve",async configResolved(){const e=r=>{console.info(t(r))};await n({confirm:a("[lunora] "),cwd:o.projectRoot,info:e}),c({cwd:o.projectRoot,info:e})},enforce:"pre",name:"lunora:dev-vars"});export{s as default};
@@ -0,0 +1 @@
1
+ import{paintBadge as $,BADGES as r}from"@lunora/config";const R=$(r.lunora),p=o=>`${R} ${o}`,e={ERROR:r.error,INFO:r.info,WARN:r.warn},A=(o,a,n,t)=>`${$(e[o])} ${a}: ${n} — ${t}`;export{A,p as g,R as s};
@@ -0,0 +1,3 @@
1
+ import{detectAiAgent as a,LUNORA_EVENT_SOURCE as c,formatLunoraEvent as l}from"@lunora/config";import{a as f,r as m}from"./server-close-C8zGVydc.mjs";const p=`"source":"${c}"`,s={error:"\x1B[31m",info:"\x1B[36m",reset:"\x1B[0m",warn:"\x1B[33m"},d=(r,t,e)=>e?`${s[t]}[lunora]${s.reset} ${r}`:`[lunora] ${r}`,v=r=>typeof r=="string"?r:Buffer.isBuffer(r)?r.toString("utf8"):void 0,g=(r,t)=>r.split(`
2
+ `).map(e=>{const n=l(e);return n?d(n.text,n.level,t):e}).join(`
3
+ `),w=(r,t)=>(...e)=>{try{const n=v(e[0]);if(n?.includes(p))return r(g(n,t),...e.slice(1))}catch{}return r(...e)},i=r=>{const t=r.write.bind(r),e=w(t,r.isTTY===!0);return r.write=e,()=>{r.write===e&&(r.write=t)}},x=()=>{const r=process.env.LUNORA_LOG_JSON;return r==="1"||r==="true"?!0:r==="0"||r==="false"?!1:a()!==void 0},L=()=>{const r=new Map;let t;return{apply:"serve",buildEnd(){m(r,this.environment)},configureServer(e){if(x())return;t?.();const n=i(process.stdout),u=i(process.stderr),o=()=>{n(),u(),t===o&&(t=void 0)};t=o,f(e,r,o)},name:"lunora:log-stream"}};export{L as default};
@@ -0,0 +1 @@
1
+ import{findLunoraSolution as n}from"@lunora/codegen";const a={handle:r=>{const e=typeof r.message=="string"?r.message:"",o=n(e);return Promise.resolve(o?{body:o.body,header:o.header}:void 0)},name:"lunora",priority:100},s=[a];export{a as lunoraSolutionFinder,s as lunoraSolutionFinders};
@@ -0,0 +1 @@
1
+ import{resolveRemoteEnabled as a,materializeRemoteWranglerConfig as c,readProjectRemotePreference as g}from"@lunora/config";import{g as s}from"./log-DTdeAemA.mjs";const f=()=>{},u=e=>{const n=e.readPreference??g;if(!a({configPreference:n(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:f,enabled:!1};const o=(e.materialize??c)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:o.cleanup,configPath:o.configPath,enabled:!0,reason:o.reason}},d=(e,n)=>!n.enabled||n.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:n.configPath},p=(e,n)=>({config(o,r){if(r.command!=="serve")return;const i=d(e,n),t=e;i.configPath!==void 0&&t.configPath===void 0?t.configPath=i.configPath:n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(s(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings-config"}),P=e=>({buildEnd(){e()},closeBundle(){e()},enforce:"pre",name:"lunora:remote-bindings-cleanup"});export{u as planViteRemoteBindings,P as remoteBindingsCleanupPlugin,p as remoteBindingsConfigPlugin,d as withRemoteBindings};
@@ -0,0 +1 @@
1
+ const s=(e,r,t)=>{e.httpServer?e.httpServer.once("close",t):r.set(e.environments.client,t)},n=(e,r)=>{const t=e.get(r);t!==void 0&&(e.delete(r),t())};export{s as a,n as r};
@@ -0,0 +1,3 @@
1
+ import{spawnSync as t}from"node:child_process";import{validateWranglerProject as i,readWranglerJsonc as s}from"@lunora/config";import{LunoraError as l}from"@lunora/errors";import{g as a}from"./log-DTdeAemA.mjs";const c=r=>r.startsWith("./")||r.startsWith("../")||r.startsWith("/")||r.includes("Dockerfile"),g=()=>{try{return t("docker",["info"],{stdio:"ignore"}).status===0}catch{return!1}},d=(r,e=g)=>{const{parsed:n}=s(r);!(n?.containers??[]).some(o=>typeof o?.image=="string"&&c(o.image))||e()||console.warn(a("wrangler.jsonc declares containers built from a local Dockerfile, but no Docker-compatible engine is running. Start Docker (or Colima) before `vite dev`, or the container instances will fail to start."))},m=(r,e)=>{const n=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...e.map(o=>` - ${o}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(n.join(`
2
+ `))},p=r=>({configResolved(){const e=i({projectRoot:r.projectRoot,schemaDir:r.schemaDir});if(!e.wranglerPath)throw new l("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${r.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
3
+ `));if(e.report.warnings.length>0)for(const n of e.report.warnings)console.warn(a(`wrangler validator: ${n}`));if(e.problems.length>0)throw m(e.wranglerPath,e.problems);d(e.wranglerPath)},name:"lunora:wrangler-validator"});export{d as warnWhenDockerMissing,p as wranglerValidatorPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.81",
3
+ "version": "1.0.0-alpha.82",
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.45.1",
49
- "@lunora/codegen": "1.0.0-alpha.55",
50
- "@lunora/config": "1.0.0-alpha.81",
49
+ "@lunora/codegen": "1.0.0-alpha.56",
50
+ "@lunora/config": "1.0.0-alpha.82",
51
51
  "@lunora/errors": "1.0.0-alpha.8",
52
52
  "@visulima/vite-overlay": "2.0.4",
53
53
  "jsonc-parser": "^3.3.1",
@@ -1,120 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { resolve, join } from 'node:path';
3
- import { LunoraError } from '@lunora/errors';
4
-
5
- const LUNORA_WORKER_VIRTUAL_ID = "virtual:lunora/worker";
6
- const RESOLVED_VIRTUAL_PREFIX = "\0";
7
- const RESOLVED_LUNORA_WORKER_ID = `${RESOLVED_VIRTUAL_PREFIX}${LUNORA_WORKER_VIRTUAL_ID}`;
8
- const CLIENT_WORKER_STUB = `// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
9
- export default {};
10
- `;
11
- const TRAILING_SLASH = /\/$/;
12
- const CLASS_A_WIRING = {
13
- "react-router": {
14
- // `@react-router/dev` provides `virtual:react-router/server-build`; the
15
- // runtime helper turns it into a `(request) => Promise<Response>`, which
16
- // is exactly the `httpRouter.fetch` contract. Needs a named import.
17
- handler: '{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',
18
- imports: 'import { createRequestHandler } from "react-router";'
19
- },
20
- "solid-start": {
21
- // SolidStart's `cloudflare-module` preset default-exports a fetch
22
- // handler — structurally an `HttpRouterLike` already.
23
- handler: "ssrModule.default",
24
- imports: 'import * as ssrModule from "@solidjs/start/server-handler";'
25
- },
26
- "tanstack-start": {
27
- // TanStack Start's server entry default-exports a `{ fetch }` handler.
28
- handler: "ssrModule.default",
29
- imports: 'import * as ssrModule from "@tanstack/react-start/server-entry";'
30
- },
31
- "tanstack-start-solid": {
32
- // TanStack Start (Solid)'s server entry default-exports a `{ fetch }`
33
- // handler — same shape as the React variant, different package.
34
- handler: "ssrModule.default",
35
- imports: 'import * as ssrModule from "@tanstack/solid-start/server-entry";'
36
- }
37
- };
38
- const isAutoComposable = (context) => {
39
- const detected = context.framework;
40
- return detected?.class === "A" && CLASS_A_WIRING[detected.framework] !== void 0;
41
- };
42
- const isWorkerVirtualActive = (context) => isAutoComposable(context);
43
- const projectUsesUmbrella = (projectRoot) => {
44
- try {
45
- const pkg = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf8"));
46
- return ["dependencies", "devDependencies", "peerDependencies"].some((field) => pkg[field]?.["lunorash"] !== void 0);
47
- } catch {
48
- return false;
49
- }
50
- };
51
- const buildWorkerEntrySource = (framework, generatedImportBase, hasContainers = false, useUmbrella = false, allowUnauthenticatedShardAccess = false) => {
52
- const wiring = CLASS_A_WIRING[framework];
53
- if (wiring === void 0) {
54
- throw new LunoraError("INTERNAL", `[lunora] no class-A worker wiring for framework "${framework}"`);
55
- }
56
- const base = generatedImportBase.replaceAll("\\", "/");
57
- const runtimeModule = useUmbrella ? "lunorash/runtime" : "@lunora/runtime";
58
- const containersReexport = hasContainers ? `
59
- export * from "${base}/containers";
60
- ` : "";
61
- return `// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
62
- // Do not edit: emitted from the detected framework (${framework}). Point your
63
- // wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
64
- import { composeWorker } from "${runtimeModule}";
65
- ${wiring.imports}
66
- import { LUNORA_FUNCTIONS } from "${base}/functions";
67
- import { openApiSpec } from "${base}/openapi";
68
- import { createShardDO } from "${base}/shard";
69
-
70
- export const ShardDO = createShardDO();
71
- ${containersReexport}
72
-
73
- let worker;
74
-
75
- export default {
76
- async fetch(request, env, context) {
77
- worker ??= composeWorker({${allowUnauthenticatedShardAccess ? "\n allowUnauthenticatedShardAccess: true," : ""}
78
- functions: LUNORA_FUNCTIONS,
79
- httpRouter: ${wiring.handler},
80
- openApiSpec,
81
- routes: {},
82
- shardDO: env.SHARD,
83
- });
84
-
85
- return worker.fetch(request, env, context);
86
- },
87
- };
88
- `;
89
- };
90
- const frameworkComposePlugin = (options, context) => {
91
- const generatedImportBase = resolve(options.projectRoot, options.generatedDir.replace(TRAILING_SLASH, ""));
92
- const useUmbrella = projectUsesUmbrella(options.projectRoot);
93
- return {
94
- load(id) {
95
- if (id === RESOLVED_LUNORA_WORKER_ID && isWorkerVirtualActive(context) && context.framework !== void 0) {
96
- if (this.environment.name === "client") {
97
- return CLIENT_WORKER_STUB;
98
- }
99
- const hasContainers = existsSync(join(generatedImportBase, "containers.ts"));
100
- return buildWorkerEntrySource(
101
- context.framework.framework,
102
- generatedImportBase,
103
- hasContainers,
104
- useUmbrella,
105
- options.allowUnauthenticatedShardAccess
106
- );
107
- }
108
- return void 0;
109
- },
110
- name: "lunora:framework-compose",
111
- resolveId(id) {
112
- if (id === LUNORA_WORKER_VIRTUAL_ID && isWorkerVirtualActive(context)) {
113
- return RESOLVED_LUNORA_WORKER_ID;
114
- }
115
- return void 0;
116
- }
117
- };
118
- };
119
-
120
- export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, RESOLVED_LUNORA_WORKER_ID, buildWorkerEntrySource, frameworkComposePlugin, isAutoComposable };
@@ -1,36 +0,0 @@
1
- const DEV_WORKER_ENV_VAR = "WORKER_ENV";
2
- const DEV_WORKER_ENV_VALUE = "development";
3
- const withDevWorkerEnv = (options, isServe) => {
4
- const userConfig = options.config;
5
- return {
6
- ...options,
7
- config: (workerConfig) => {
8
- if (typeof userConfig === "function") {
9
- const partial = userConfig(workerConfig);
10
- if (partial) {
11
- Object.assign(workerConfig, partial);
12
- }
13
- } else if (userConfig) {
14
- Object.assign(workerConfig, userConfig);
15
- }
16
- if (isServe()) {
17
- workerConfig.vars = { [DEV_WORKER_ENV_VAR]: DEV_WORKER_ENV_VALUE, ...workerConfig.vars };
18
- }
19
- }
20
- };
21
- };
22
- const createCommandProbe = () => {
23
- let command;
24
- return {
25
- isServe: () => command === "serve",
26
- plugin: {
27
- config(_userConfig, env) {
28
- command = env.command;
29
- },
30
- enforce: "pre",
31
- name: "lunora:command-probe"
32
- }
33
- };
34
- };
35
-
36
- export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, createCommandProbe, withDevWorkerEnv };
@@ -1,3 +0,0 @@
1
- const LUNORA_API_UPDATED_EVENT = "lunora:api-updated";
2
-
3
- export { LUNORA_API_UPDATED_EVENT as default };