@lunora/vite 1.0.0-alpha.13 → 1.0.0-alpha.131
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/LICENSE.md +6 -0
- package/README.md +15 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +364 -261
- package/dist/index.d.ts +364 -261
- package/dist/index.mjs +3 -155
- package/dist/packem_shared/CLASS_A_WIRING-CHGNvusY.mjs +33 -0
- package/dist/packem_shared/DEV_WORKER_ENV_VALUE-CdVg3e_J.mjs +1 -0
- package/dist/packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-onjC3IB9.mjs +1 -0
- package/dist/packem_shared/WORKER_STARTUP_HINT-Dsm2vG6Q.mjs +5 -0
- package/dist/packem_shared/checkLunoraProxy-n_jVuOU-.mjs +1 -0
- package/dist/packem_shared/codegenPlugin-CAs97KEK.mjs +3 -0
- package/dist/packem_shared/containerLogsPlugin-QOsfYAYL.mjs +1 -0
- package/dist/packem_shared/devStatePlugin-CMRBp9zZ.mjs +1 -0
- package/dist/packem_shared/devVariablesPlugin-0SvpKjRJ.mjs +1 -0
- package/dist/packem_shared/log-DTdeAemA.mjs +1 -0
- package/dist/packem_shared/logStreamPlugin-CFlQAr0R.mjs +3 -0
- package/dist/packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs +1 -0
- package/dist/packem_shared/planViteRemoteBindings-DGYDapgM.mjs +1 -0
- package/dist/packem_shared/server-close-C8zGVydc.mjs +1 -0
- package/dist/packem_shared/wranglerValidatorPlugin-pzoKmqgc.mjs +3 -0
- package/package.json +9 -8
- package/dist/packem_shared/CLASS_A_WIRING-CZVcjgKo.mjs +0 -106
- package/dist/packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs +0 -36
- package/dist/packem_shared/STUDIO_PATH-5ppCdBHa.mjs +0 -210
- package/dist/packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs +0 -81
- package/dist/packem_shared/codegenPlugin-MuvbqAP8.mjs +0 -218
- package/dist/packem_shared/devVariablesPlugin-CDNSnvOP.mjs +0 -19
- package/dist/packem_shared/log-BjO9EWah.mjs +0 -8
- package/dist/packem_shared/logStreamPlugin-CqvZ17kd.mjs +0 -61
- package/dist/packem_shared/planViteRemoteBindings-QN5ncUS1.mjs +0 -50
- package/dist/packem_shared/reconcileWranglerCrons-PxGwfCp_.mjs +0 -29
- package/dist/packem_shared/wranglerValidatorPlugin-CEoJEghS.mjs +0 -66
package/dist/index.mjs
CHANGED
|
@@ -1,155 +1,3 @@
|
|
|
1
|
-
import { cloudflare } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { detectFramework } from '@lunora/config';
|
|
5
|
-
import { l as lunoraLine } from './packem_shared/log-BjO9EWah.mjs';
|
|
6
|
-
import codegenPlugin from './packem_shared/codegenPlugin-MuvbqAP8.mjs';
|
|
7
|
-
import devVariablesPlugin from './packem_shared/devVariablesPlugin-CDNSnvOP.mjs';
|
|
8
|
-
import { createCommandProbe, withDevWorkerEnv } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
|
|
9
|
-
export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
|
|
10
|
-
import { frameworkComposePlugin } from './packem_shared/CLASS_A_WIRING-CZVcjgKo.mjs';
|
|
11
|
-
export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/CLASS_A_WIRING-CZVcjgKo.mjs';
|
|
12
|
-
import logStreamPlugin from './packem_shared/logStreamPlugin-CqvZ17kd.mjs';
|
|
13
|
-
import { planViteRemoteBindings, remoteBindingsCleanupPlugin, withRemoteBindings } from './packem_shared/planViteRemoteBindings-QN5ncUS1.mjs';
|
|
14
|
-
import { studioPlugin } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
|
|
15
|
-
export { STUDIO_PATH, buildStudioUrl } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
|
|
16
|
-
import { withWorkerStartupHint } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
|
|
17
|
-
export { WORKER_STARTUP_HINT, augmentWorkerStartupError, isWorkerEntryEvalError } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
|
|
18
|
-
import { wranglerValidatorPlugin } from './packem_shared/wranglerValidatorPlugin-CEoJEghS.mjs';
|
|
19
|
-
export { reconcileWranglerCrons } from './packem_shared/reconcileWranglerCrons-PxGwfCp_.mjs';
|
|
20
|
-
|
|
21
|
-
const agentRulesHintPlugin = (options) => {
|
|
22
|
-
return {
|
|
23
|
-
apply: "serve",
|
|
24
|
-
configureServer(server) {
|
|
25
|
-
return () => {
|
|
26
|
-
if (detectAgentRules(options.projectRoot).installed || !claimAgentRulesHint()) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
server.config.logger.warn(`
|
|
30
|
-
${lunoraLine(AGENT_RULES_HINT)}
|
|
31
|
-
`);
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
name: "lunora:agent-rules-hint"
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const createPluginContext = () => {
|
|
39
|
-
return {};
|
|
40
|
-
};
|
|
41
|
-
const FRAMEWORK_LABELS = {
|
|
42
|
-
astro: "Astro",
|
|
43
|
-
none: "standalone (SPA / SSR-less)",
|
|
44
|
-
nuxt: "Nuxt",
|
|
45
|
-
"react-router": "React Router",
|
|
46
|
-
"solid-start": "SolidStart",
|
|
47
|
-
sveltekit: "SvelteKit",
|
|
48
|
-
"tanstack-start": "TanStack Start",
|
|
49
|
-
"tanstack-start-solid": "TanStack Start (Solid)"
|
|
50
|
-
};
|
|
51
|
-
const formatFrameworkDetection = (detection) => {
|
|
52
|
-
const label = FRAMEWORK_LABELS[detection.framework];
|
|
53
|
-
if (detection.framework === "none") {
|
|
54
|
-
return lunoraLine("no meta-framework detected — running standalone.");
|
|
55
|
-
}
|
|
56
|
-
if (detection.class === "B") {
|
|
57
|
-
return lunoraLine(`detected ${label} — composition is handled by the framework adapter.`);
|
|
58
|
-
}
|
|
59
|
-
return lunoraLine(`detected ${label} — composing the Lunora worker into one Cloudflare Worker.`);
|
|
60
|
-
};
|
|
61
|
-
const frameworkDetectPlugin = (options, context) => {
|
|
62
|
-
let logged = false;
|
|
63
|
-
const detect = () => {
|
|
64
|
-
context.framework ??= detectFramework(options.projectRoot);
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
config() {
|
|
68
|
-
detect();
|
|
69
|
-
},
|
|
70
|
-
configResolved() {
|
|
71
|
-
detect();
|
|
72
|
-
},
|
|
73
|
-
configureServer() {
|
|
74
|
-
detect();
|
|
75
|
-
if (!logged && context.framework !== void 0) {
|
|
76
|
-
logged = true;
|
|
77
|
-
console.info(formatFrameworkDetection(context.framework));
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
name: "lunora:framework-detect"
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const resolveOptions = (options) => {
|
|
85
|
-
const input = options ?? {};
|
|
86
|
-
const schemaDirectory = input.schemaDir ?? "lunora";
|
|
87
|
-
let cloudflareOption;
|
|
88
|
-
if (input.cloudflare === false) {
|
|
89
|
-
cloudflareOption = false;
|
|
90
|
-
} else if (input.cloudflare === true || input.cloudflare === void 0) {
|
|
91
|
-
cloudflareOption = {};
|
|
92
|
-
} else {
|
|
93
|
-
cloudflareOption = input.cloudflare;
|
|
94
|
-
}
|
|
95
|
-
const overlayDefaults = { forwardedConsoleMethods: ["error", "warn"] };
|
|
96
|
-
let overlayOption;
|
|
97
|
-
if (input.overlay === false) {
|
|
98
|
-
overlayOption = false;
|
|
99
|
-
} else if (input.overlay === true || input.overlay === void 0) {
|
|
100
|
-
overlayOption = { ...overlayDefaults };
|
|
101
|
-
} else {
|
|
102
|
-
overlayOption = { ...overlayDefaults, ...input.overlay };
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
apiSpec: input.apiSpec ?? "openapi",
|
|
106
|
-
cloudflare: cloudflareOption,
|
|
107
|
-
studio: input.studio ?? true,
|
|
108
|
-
generatedDir: input.generatedDir ?? `${schemaDirectory}/_generated`,
|
|
109
|
-
overlay: overlayOption,
|
|
110
|
-
projectRoot: input.projectRoot ?? process.cwd(),
|
|
111
|
-
schemaDir: schemaDirectory,
|
|
112
|
-
validateWrangler: input.validateWrangler ?? true
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
const lunora = (options) => {
|
|
116
|
-
const resolved = resolveOptions(options);
|
|
117
|
-
const context = createPluginContext();
|
|
118
|
-
const { isServe, plugin: commandProbe } = createCommandProbe();
|
|
119
|
-
const plugins = [
|
|
120
|
-
commandProbe,
|
|
121
|
-
frameworkDetectPlugin(resolved, context),
|
|
122
|
-
// Reads the detected framework off `context` and, for a class-A
|
|
123
|
-
// framework (and only when the CF integration is on), resolves the
|
|
124
|
-
// `virtual:lunora/worker` entry to a `composeWorker`-based worker that
|
|
125
|
-
// routes `/_lunora/*` to Lunora and falls through to the framework SSR
|
|
126
|
-
// handler — so the template never hand-wires `createWorker({ httpRouter })`.
|
|
127
|
-
// A strict no-op for class-C and the `cloudflare: false` BYO path.
|
|
128
|
-
frameworkComposePlugin(resolved, context),
|
|
129
|
-
devVariablesPlugin(resolved),
|
|
130
|
-
codegenPlugin(resolved),
|
|
131
|
-
logStreamPlugin(),
|
|
132
|
-
agentRulesHintPlugin(resolved)
|
|
133
|
-
];
|
|
134
|
-
if (resolved.studio) {
|
|
135
|
-
plugins.push(studioPlugin());
|
|
136
|
-
}
|
|
137
|
-
if (resolved.validateWrangler) {
|
|
138
|
-
plugins.push(wranglerValidatorPlugin(resolved));
|
|
139
|
-
}
|
|
140
|
-
if (resolved.overlay !== false) {
|
|
141
|
-
plugins.push(errorOverlayPlugin(resolved.overlay));
|
|
142
|
-
}
|
|
143
|
-
if (resolved.cloudflare !== false) {
|
|
144
|
-
const remotePlan = planViteRemoteBindings({ projectRoot: resolved.projectRoot });
|
|
145
|
-
if (remotePlan.enabled && remotePlan.configPath !== void 0) {
|
|
146
|
-
plugins.push(remoteBindingsCleanupPlugin(remotePlan.cleanup));
|
|
147
|
-
}
|
|
148
|
-
const cloudflareOptions = withRemoteBindings(withDevWorkerEnv(resolved.cloudflare, isServe), isServe, remotePlan);
|
|
149
|
-
plugins.push(...withWorkerStartupHint(cloudflare(cloudflareOptions)));
|
|
150
|
-
}
|
|
151
|
-
return plugins;
|
|
152
|
-
};
|
|
153
|
-
const VERSION = "0.0.0";
|
|
154
|
-
|
|
155
|
-
export { VERSION, codegenPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, planViteRemoteBindings, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
|
1
|
+
import{createRequire as u}from"node:module";import{cloudflare as m}from"@cloudflare/vite-plugin";import{detectAgentRules as d,claimAgentRulesHint as c,AGENT_RULES_HINT as f,detectFramework as p,resolveTargetOrThrow as g}from"@lunora/config";import{detectFramework as lr}from"@lunora/config";import S from"@visulima/vite-overlay";import{g as s}from"./packem_shared/log-DTdeAemA.mjs";import R from"./packem_shared/codegenPlugin-CAs97KEK.mjs";import k from"./packem_shared/containerLogsPlugin-QOsfYAYL.mjs";import h from"./packem_shared/devStatePlugin-CMRBp9zZ.mjs";import v from"./packem_shared/devVariablesPlugin-0SvpKjRJ.mjs";import{createCommandProbe as w,withDevWorkerEnv as P}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 E}from"./packem_shared/CLASS_A_WIRING-CHGNvusY.mjs";import{CLASS_A_WIRING as fr,LUNORA_WORKER_VIRTUAL_ID as pr,buildWorkerEntrySource as gr,isAutoComposable as Sr}from"./packem_shared/CLASS_A_WIRING-CHGNvusY.mjs";import A from"./packem_shared/logStreamPlugin-CFlQAr0R.mjs";import{proxyCheckPlugin as _}from"./packem_shared/checkLunoraProxy-n_jVuOU-.mjs";import{checkLunoraProxy as kr}from"./packem_shared/checkLunoraProxy-n_jVuOU-.mjs";import{planViteRemoteBindings as W,remoteBindingsCleanupPlugin as x,remoteBindingsConfigPlugin as C}from"./packem_shared/planViteRemoteBindings-DGYDapgM.mjs";import{withRemoteBindings as vr}from"./packem_shared/planViteRemoteBindings-DGYDapgM.mjs";import{lunoraSolutionFinders as D}from"./packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs";import{lunoraSolutionFinder as Pr}from"./packem_shared/lunoraSolutionFinder-Dl5pUZK2.mjs";import{studioPlugin as T}from"./packem_shared/STUDIO_PATH-onjC3IB9.mjs";import{STUDIO_PATH as Ar,buildStudioUrl as _r}from"./packem_shared/STUDIO_PATH-onjC3IB9.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-pzoKmqgc.mjs";import{default as Vr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as yr}from"@lunora/config/cloudflare";const y=e=>({apply:"serve",configureServer(r){return()=>{d(e.projectRoot).installed||!c()||r.config.logger.warn(`
|
|
2
|
+
${s(f)}
|
|
3
|
+
`)}},name:"lunora:agent-rules-hint"}),N=()=>({}),O={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=e=>{const r=O[e.framework];return e.framework==="none"?s("no meta-framework detected — running standalone."):e.class==="B"?s(`detected ${r} — composition is handled by the framework adapter.`):s(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},L=(e,r)=>{let t=!1;const o=()=>{r.framework??=p(e.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&r.framework!==void 0&&(t=!0,console.info(U(r.framework)))},name:"lunora:framework-detect"}},b=e=>{if(e===!1)return!1;const r=e===!0||e===void 0?{}:e;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...D,...r.solutionFinders??[]]}},I=e=>{const r=e??{},t=r.schemaDir??"lunora";let o;r.cloudflare===!1?o=!1:r.cloudflare===!0||r.cloudflare===void 0?o={}:o=r.cloudflare;const n=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:o,studio:r.studio??!0,generatedDir:r.generatedDir??`${t}/_generated`,overlay:b(r.overlay),projectRoot:n,schemaDir:t,target:g(n,r.target),validateWrangler:r.validateWrangler??!0}},ar=e=>{const r=I(e),t=N(),{isServe:o,plugin:n}=w(),a=[n,L(r,t),E(r,t),v(r),R(r),A(),h(r),y(r),_()];if(r.studio&&a.push(T()),r.validateWrangler&&a.push($(r)),r.overlay!==!1&&a.push(S(r.overlay)),r.cloudflare!==!1){a.push(k(r));const i=W({projectRoot:r.projectRoot}),l=P(r.cloudflare,o);i.enabled&&(i.configPath!==void 0&&a.push(x(i.cleanup)),a.push(C(l,i))),a.push(...V(m(l)))}return a},nr=u(import.meta.url)("../package.json").version;export{fr as CLASS_A_WIRING,mr as DEV_WORKER_ENV_VALUE,dr as DEV_WORKER_ENV_VAR,Vr as LUNORA_API_UPDATED_EVENT,pr as LUNORA_WORKER_VIRTUAL_ID,Ar as STUDIO_PATH,nr as VERSION,xr as WORKER_STARTUP_HINT,Cr as augmentWorkerStartupError,_r as buildStudioUrl,gr as buildWorkerEntrySource,kr as checkLunoraProxy,R as codegenPlugin,k as containerLogsPlugin,w as createCommandProbe,lr as detectFramework,h as devStatePlugin,v as devVariablesPlugin,E as frameworkComposePlugin,Sr as isAutoComposable,Dr as isWorkerEntryEvalError,A as logStreamPlugin,ar as lunora,Pr as lunoraSolutionFinder,D as lunoraSolutionFinders,W as planViteRemoteBindings,_ as proxyCheckPlugin,yr as reconcileWranglerCrons,x as remoteBindingsCleanupPlugin,C as remoteBindingsConfigPlugin,b as resolveOverlayOption,T as studioPlugin,P 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=/\/$/,d={"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";'}},c=r=>{const e=r.framework;return e?.class==="A"&&d[e.framework]!==void 0},S=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}},O=(r,e,t=!1,s=!1,o=!1)=>{const a=d[r];if(a===void 0)throw new w("INTERNAL",`[lunora] no class-A worker wiring for framework "${r}"`);const n=e.replaceAll("\\","/"),u=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 "${u}";
|
|
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
|
+
`},y=(r,e)=>{const t=k(r.projectRoot,r.generatedDir.replace(R,"")),s=S(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 O(e.framework.framework,t,a,s,r.allowUnauthenticatedShardAccess)}},name:"lunora:framework-compose",resolveId(o){if(o===m&&c(e))return i}}};export{d as CLASS_A_WIRING,m as LUNORA_WORKER_VIRTUAL_ID,i as RESOLVED_LUNORA_WORKER_ID,O as buildWorkerEntrySource,y as frameworkComposePlugin,c 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 H,handleSchemaEditRequest as L,handlePolicyScaffoldRequest as $,SEED_ENDPOINT as b,SCHEMA_EDIT_ENDPOINT as E,POLICY_SCAFFOLD_ENDPOINT as x,transportRejectionReason as I,serveJsonHandler as A,isStandaloneModulePath as P,renderStudioHtml as _,resolveAdminToken as O,headerValue as u,studioAssetsStamp as U,loadStudioAssets as D,readStandaloneAsset as R,assetContentType as j}from"@lunora/config/studio-host";const c="/__lunora",w=`${c}/studio.js`,v=`${c}/styles.css`,N=/^\//,m=/\/$/,T={[x]:$,[E]:L,[b]:H},B=new Set(Object.keys(T)),k=e=>{const t=u(e["sec-fetch-site"]);if(t!==void 0)return t==="same-origin"||t==="same-site"||t==="none"?void 0:"cross-origin request rejected";const s=u(e.origin);if(s===void 0||s==="null")return;let n;try{n=new URL(s).host.toLowerCase()}catch{return"invalid origin header"}const d=u(e.host);return d===void 0||n!==d?"cross-origin request rejected":void 0},q=e=>{const t=e.headers??{},s=k(t);if(s!==void 0)return s;const n=(e.method??"GET").toUpperCase();if(n!=="GET"&&n!=="HEAD"&&!u(t["content-type"])?.startsWith("application/json"))return"content-type must be application/json"},g=(e,t,s)=>{e.statusCode=200,e.setHeader("Content-Type",s),e.end(t)},W=e=>{const t=c.replace(N,"");if(e.resolvedLocal!==void 0&&e.resolvedLocal!=="")return`${e.resolvedLocal.endsWith("/")?e.resolvedLocal.slice(0,-1):e.resolvedLocal}/${t}`;const s=e.base===void 0||e.base==="/"?"":e.base.replace(m,"");if(e.address===void 0||typeof e.address=="string")return`http://localhost:5173${s}/${t}`;const n=e.address.address==="::"||e.address.address==="0.0.0.0"?"localhost":e.address.address;return`http://${n.includes(":")?`[${n}]`:n}:${String(e.address.port)}${s}/${t}`},F=e=>{try{return new URL(e,"http://localhost").pathname.replace(m,"")}catch{return e}},G=(e,t)=>{let s,n,d;const f=e.config.root??process.cwd(),y=(a,i,o)=>{const r=U();if((s===void 0||r!==n)&&(s=D(e.config.logger),n=r),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 p=a===v,l=a.slice(a.lastIndexOf("/")+1),h=r===void 0?void 0:`W/"${l}-${String(r)}"`;if(o.setHeader("Cache-Control","no-cache"),h!==void 0&&(o.setHeader("ETag",h),u(i.headers?.["if-none-match"])===h.toLowerCase())){o.statusCode=304,o.end();return}if(p){g(o,s.styles,"text/css; charset=utf-8");return}const S=R(l);if(S===void 0){o.statusCode=404,o.setHeader("Content-Type","text/plain"),o.end("Not found");return}g(o,S,j(l))};return(a,i,o)=>{const r=F(a.url??"");if(r!==c&&!r.startsWith(`${c}/`)){o();return}if(t||I(a,e.config.logger)!==void 0){i.statusCode=403,i.setHeader("Content-Type","text/plain"),i.end("Lunora studio is only available on loopback hosts in dev.");return}if(B.has(r)){const l=q(a);if(l!==void 0){i.statusCode=403,i.setHeader("Content-Type","application/json; charset=utf-8"),i.end(JSON.stringify({error:l,ok:!1}));return}}const p=T[r];if(p!==void 0){A(a,i,p,f);return}if(r===v||P(r)){y(r,a,i);return}d??=_({adminToken:O(f),basePath:c,dataEditable:!0,rulesInstalled:C(f).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:w,styleHref:v}),g(i,d,"text/html; charset=utf-8")}},V=()=>({apply:"serve",configureServer(e){const t=e.config.server?.host,s=t!==void 0&&t!==!1&&t!=="localhost"&&t!=="127.0.0.1"&&t!=="::1";return e.middlewares.use(G(e,s)),()=>{const n=()=>{const d=W({address:e.httpServer?.address()??void 0,base:e.config.base,resolvedLocal:e.resolvedUrls?.local[0]});e.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${d}\x1B[39m`)};if(typeof e.printUrls=="function"){const d=e.printUrls.bind(e);e.printUrls=()=>{d(),n()}}else e.httpServer?.listening===!0?n():e.httpServer?.once("listening",n)}},name:"lunora:studio"});export{c as STUDIO_PATH,w as STUDIO_SCRIPT_PATH,v as STUDIO_STYLE_PATH,W as buildStudioUrl,V 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 O}from"node:fs";import{join as _,resolve as p,sep as b,basename as L}from"node:path";import{createCodegenProject as M,refreshCodegenProject as A,runCodegen as G,describeErrorLevelFindings as T,CodegenDiagnosticError as B}from"@lunora/codegen";import{LUNORA_CONFIG_FILE as N,inferLunoraBindings as I}from"@lunora/config";import{findWranglerFile as J,readWranglerJsonc as V,WRANGLER_FILES as U,collectWranglerSecretVariables as X,reconcileWranglerBindings as Y,reconcileWranglerCrons as Z,reconcileWranglerCompatibilityDate as q}from"@lunora/config/cloudflare";import{isRunnableDevEnvironment as z}from"vite";import H from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{s as g,A as W}from"./log-DTdeAemA.mjs";import{r as K,a as Q}from"./server-close-C8zGVydc.mjs";const C=(r,o)=>{try{const{parsed:t,text:e}=V(r);return t===void 0?`raw:${e}`:JSON.stringify(o?o(t):t)}catch{return"unreadable"}},ee=r=>{const o={...r},{triggers:t}=o;if(t!==null&&typeof t=="object"){const e={...t};delete e.crons,Object.keys(e).length>0?o.triggers=e:delete o.triggers}return o},S=r=>{const o=J(r),t=o===void 0?"absent":C(o,ee),e=_(r,N),i=O(e)?C(e):"absent";return`${t}\0${i}`},re=100,oe=/[/\\]tsconfig\..+\.json$/u,te=r=>{const o=r.map(e=>` • ${e.kind} "${e.exportName}" — class ${e.className} is not exported by your worker entry.`),t=[...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:",...t].join(`
|
|
2
|
+
`)},ne=async(r,o,t)=>{try{const e=await I({projectRoot:r.projectRoot,schemaDir:r.schemaDir}),i=Y(r.projectRoot,e);i.changed&&o.info?.(`${g} inferred bindings → ${i.added.join(", ")} (written to ${i.wranglerPath??"wrangler.jsonc"})`);for(const s of i.warnings)o.warn(`${g} ${s}`);i.exportGaps.length>0&&t?.(i.exportGaps)}catch(e){const i=e instanceof Error?e.message:String(e);o.warn(`${g} binding inference skipped: ${i}`)}},se=(r,o,t)=>{try{const e=Z(r,o);e.changed&&t.info?.(`${g} synced ${o.length.toFixed(0)} cron trigger(s) into ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const i=e instanceof Error?e.message:String(e);t.warn(`${g} cron trigger sync skipped: ${i}`)}try{const e=q(r);e.changed&&t.info?.(`${g} bumped compatibility_date to ${e.date??"unknown"} (Workers Cache enabled) → ${e.wranglerPath??"wrangler.jsonc"}`)}catch(e){const i=e instanceof Error?e.message:String(e);t.warn(`${g} compatibility date sync skipped: ${i}`)}},ae=r=>{const{advisoryNames:o,platformDiagnosticNames:t}=T(r),e=[...new Set([...o,...t])].toSorted((s,l)=>s.localeCompare(l));if(e.length===0)return;const i=e.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${g} ${String(e.length)} ERROR-level ${i} (${e.join(", ")}) — see the log above for detail.`},x=(r,o,t,e)=>{const i=_(r.projectRoot,r.schemaDir,"schema.ts");if(!O(i))return o.warn(`${g} schema.ts not found at ${i} — codegen skipped`),{};try{const s=G({apiSpec:r.apiSpec,lunoraDirectory:r.schemaDir,project:e,projectRoot:r.projectRoot,target:r.target,wranglerVariables:X(r.projectRoot)});se(r.projectRoot,s.cronTriggers,o);for(const l of s.advisories){const f=W(l.level,l.name,l.detail,l.remediation);l.level==="ERROR"?o.error(f):o.warn(f)}for(const l of s.platformDiagnostics){const f=W(l.level==="error"?"ERROR":"WARN",l.name,l.message,l.remediation);l.level==="error"?o.error(f):o.warn(f)}return{blockingMessage:ae(s),outputDirectory:p(s.outputDirectory)}}catch(s){const l=s instanceof Error?s.message:String(s);return o.error(`${g} codegen failed: ${l}`),t?.onError(s,l),{}}},ie=(r,o,t)=>{let e;for(const[i,s]of Object.entries(r.environments)){if(i==="client"){e=s;continue}z(s)||s.hot.send({path:"*",triggeredBy:o,type:"full-reload"})}if(e===void 0){r.hot.send({type:"full-reload"});return}if(t){e.hot.send({type:"full-reload"});return}e.hot.send({event:H,type:"custom"})},ve=r=>{const o=p(r.projectRoot,r.schemaDir);let t=p(r.projectRoot,r.generatedDir),e;const i=new Map;let s,l=!1,f=!1,E;return{config(n,v){E=v.command},async buildStart(){const n={error:u=>{console.error(u)},info:u=>{console.info(u)},warn:u=>{console.warn(u)}},{blockingMessage:v,outputDirectory:w}=x(r,n);w!==void 0&&(t=w),E==="build"&&v!==void 0&&this.error(v),await ne(r,n,u=>{e?.hot.send({err:{loc:void 0,message:te(u),stack:""},type:"error"})}),e!==void 0&&(s=S(r.projectRoot),l=!0)},configureServer(n){e=n,n.watcher.add(o),s=S(r.projectRoot),l=!1;const v={error:a=>{n.config.logger.error(a)},info:a=>{n.config.logger.info(a)},warn:a=>{n.config.logger.warn(a)}};let w=!1;const u={onError(a,c){w=!0;const d=a instanceof B?{column:a.column,file:a.file,line:a.line}:void 0,j=d===void 0?`[lunora] codegen failed: ${c}
|
|
3
|
+
(see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${c}`;e?.hot.send({err:{loc:d,message:j,stack:a instanceof Error?a.stack??"":""},type:"error"})}},R=(a,c)=>a===c||a.startsWith(c+b);let k=!1,m,h;const P=()=>{for(const a of Object.values(n.environments)){const c=a.moduleGraph;for(const d of c.idToModuleMap.values())d.id&&R(d.id,t)&&c.invalidateModule(d)}},$=a=>{const c=p(a);if(R(c,o)&&!R(c,t)){if(c.endsWith(`${b}tsconfig.json`)||oe.test(c)){h=void 0;return}c.endsWith(".ts")&&(c.includes(`${b}__tests__${b}`)||c.endsWith(".test.ts")||c.endsWith(".spec.ts")||(m&&clearTimeout(m),m=setTimeout(()=>{if(m=void 0,k)return;h===void 0?h=M(o):A(h,o);const{outputDirectory:d}=x(r,v,u,h);if(d===void 0){h=void 0;return}t=d,P(),ie(n,c,w),w=!1},re)))}};n.watcher.on("add",$),n.watcher.on("change",$),n.watcher.on("unlink",$);const D=new Set([...U.map(a=>p(r.projectRoot,a)),p(r.projectRoot,N)]);for(const a of D)n.watcher.add(a);const y=a=>{if(!D.has(p(a))||f)return;const c=S(r.projectRoot);if(!l){s=c;return}if(s===void 0){s=c;return}c!==s&&(s=c,f=!0,n.config.logger.info(`${g} ${L(p(a))} changed — restarting dev server`),Promise.resolve(n.restart()).finally(()=>{f=!1}).catch(d=>{const j=d instanceof Error?d.message:String(d);n.config.logger.error(`${g} dev server restart failed: ${j} — keeping the running server; re-save your config to retry.`),n.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${j}`,stack:""},type:"error"})}))};n.watcher.on("add",y),n.watcher.on("change",y),n.watcher.on("unlink",y);const F=()=>{k||(k=!0,h=void 0,m&&(clearTimeout(m),m=void 0),n.watcher.off("add",$),n.watcher.off("change",$),n.watcher.off("unlink",$),n.watcher.off("add",y),n.watcher.off("change",y),n.watcher.off("unlink",y))};return()=>{Q(n,i,F)}},buildEnd(){K(i,this.environment)},name:"lunora:codegen"}};export{ve 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{readProjectRemotePreference as a}from"@lunora/config";import{resolveRemoteEnabled as c,materializeRemoteWranglerConfig as g}from"@lunora/config/cloudflare";import{g as f}from"./log-DTdeAemA.mjs";const s=()=>{},p=e=>{const o=e.readPreference??a;if(!c({configPreference:o(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:s,enabled:!1};const n=(e.materialize??g)({enabled:!0,projectRoot:e.projectRoot});return{cleanup:n.cleanup,configPath:n.configPath,enabled:!0,reason:n.reason}},d=(e,o)=>!o.enabled||o.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:o.configPath},P=(e,o)=>({config(n,r){if(r.command!=="serve")return;const i=d(e,o),t=e;i.configPath!==void 0&&t.configPath===void 0?t.configPath=i.configPath:o.enabled&&o.configPath===void 0&&o.reason!==void 0&&console.info(f(`remote bindings requested but not applied: ${o.reason}`))},enforce:"pre",name:"lunora:remote-bindings-config"}),h=e=>({buildEnd(){e()},closeBundle(){e()},enforce:"pre",name:"lunora:remote-bindings-cleanup"});export{p as planViteRemoteBindings,h as remoteBindingsCleanupPlugin,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/cloudflare";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:o}=s(r);!(o?.containers??[]).some(n=>typeof n?.image=="string"&&c(n.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 o=["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r}`,"",...e.map(n=>` - ${n}`),""," Update your wrangler.jsonc and restart the dev server."];return new Error(o.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
|
+
`));for(const o of e.report.warnings)console.warn(a(`wrangler validator: ${o}`));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.
|
|
3
|
+
"version": "1.0.0-alpha.131",
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/vite"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
28
|
+
"./dist",
|
|
29
29
|
"__assets__",
|
|
30
30
|
"README.md",
|
|
31
31
|
"LICENSE.md"
|
|
@@ -45,16 +45,17 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@cloudflare/vite-plugin": "1.
|
|
49
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
50
|
-
"@lunora/config": "1.0.0-alpha.
|
|
51
|
-
"@
|
|
48
|
+
"@cloudflare/vite-plugin": "1.47.0",
|
|
49
|
+
"@lunora/codegen": "1.0.0-alpha.102",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.131",
|
|
51
|
+
"@lunora/errors": "1.0.0-alpha.20",
|
|
52
|
+
"@visulima/vite-overlay": "2.0.5",
|
|
52
53
|
"jsonc-parser": "^3.3.1",
|
|
53
54
|
"ts-morph": "^28.0.0"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@lunora/studio": "1.0.0-alpha.
|
|
57
|
-
"vite": "^8.
|
|
57
|
+
"@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0",
|
|
58
|
+
"vite": "^8.1.5"
|
|
58
59
|
},
|
|
59
60
|
"peerDependenciesMeta": {
|
|
60
61
|
"@lunora/studio": {
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { resolve, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
const LUNORA_WORKER_VIRTUAL_ID = "virtual:lunora/worker";
|
|
5
|
-
const RESOLVED_VIRTUAL_PREFIX = "\0";
|
|
6
|
-
const RESOLVED_LUNORA_WORKER_ID = `${RESOLVED_VIRTUAL_PREFIX}${LUNORA_WORKER_VIRTUAL_ID}`;
|
|
7
|
-
const TRAILING_SLASH = /\/$/;
|
|
8
|
-
const CLASS_A_WIRING = {
|
|
9
|
-
"react-router": {
|
|
10
|
-
// `@react-router/dev` provides `virtual:react-router/server-build`; the
|
|
11
|
-
// runtime helper turns it into a `(request) => Promise<Response>`, which
|
|
12
|
-
// is exactly the `httpRouter.fetch` contract. Needs a named import.
|
|
13
|
-
handler: '{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',
|
|
14
|
-
imports: 'import { createRequestHandler } from "react-router";'
|
|
15
|
-
},
|
|
16
|
-
"solid-start": {
|
|
17
|
-
// SolidStart's `cloudflare-module` preset default-exports a fetch
|
|
18
|
-
// handler — structurally an `HttpRouterLike` already.
|
|
19
|
-
handler: "ssrModule.default",
|
|
20
|
-
imports: 'import * as ssrModule from "@solidjs/start/server-handler";'
|
|
21
|
-
},
|
|
22
|
-
"tanstack-start": {
|
|
23
|
-
// TanStack Start's server entry default-exports a `{ fetch }` handler.
|
|
24
|
-
handler: "ssrModule.default",
|
|
25
|
-
imports: 'import * as ssrModule from "@tanstack/react-start/server-entry";'
|
|
26
|
-
},
|
|
27
|
-
"tanstack-start-solid": {
|
|
28
|
-
// TanStack Start (Solid)'s server entry default-exports a `{ fetch }`
|
|
29
|
-
// handler — same shape as the React variant, different package.
|
|
30
|
-
handler: "ssrModule.default",
|
|
31
|
-
imports: 'import * as ssrModule from "@tanstack/solid-start/server-entry";'
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const isAutoComposable = (context) => {
|
|
35
|
-
const detected = context.framework;
|
|
36
|
-
return detected?.class === "A" && CLASS_A_WIRING[detected.framework] !== void 0;
|
|
37
|
-
};
|
|
38
|
-
const isWorkerVirtualActive = (context) => isAutoComposable(context);
|
|
39
|
-
const projectUsesUmbrella = (projectRoot) => {
|
|
40
|
-
try {
|
|
41
|
-
const pkg = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf8"));
|
|
42
|
-
return ["dependencies", "devDependencies", "peerDependencies"].some((field) => pkg[field]?.["lunorash"] !== void 0);
|
|
43
|
-
} catch {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const buildWorkerEntrySource = (framework, generatedImportBase, hasContainers = false, useUmbrella = false) => {
|
|
48
|
-
const wiring = CLASS_A_WIRING[framework];
|
|
49
|
-
if (wiring === void 0) {
|
|
50
|
-
throw new Error(`[lunora] no class-A worker wiring for framework "${framework}"`);
|
|
51
|
-
}
|
|
52
|
-
const runtimeModule = useUmbrella ? "lunorash/runtime" : "@lunora/runtime";
|
|
53
|
-
const containersReexport = hasContainers ? `
|
|
54
|
-
export * from "${generatedImportBase}/containers";
|
|
55
|
-
` : "";
|
|
56
|
-
return `// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
|
|
57
|
-
// Do not edit: emitted from the detected framework (${framework}). Point your
|
|
58
|
-
// wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
|
|
59
|
-
import { composeWorker } from "${runtimeModule}";
|
|
60
|
-
${wiring.imports}
|
|
61
|
-
import { LUNORA_FUNCTIONS } from "${generatedImportBase}/functions";
|
|
62
|
-
import { openApiSpec } from "${generatedImportBase}/openapi";
|
|
63
|
-
import { createShardDO } from "${generatedImportBase}/shard";
|
|
64
|
-
|
|
65
|
-
export const ShardDO = createShardDO();
|
|
66
|
-
${containersReexport}
|
|
67
|
-
|
|
68
|
-
let worker;
|
|
69
|
-
|
|
70
|
-
export default {
|
|
71
|
-
async fetch(request, env, context) {
|
|
72
|
-
worker ??= composeWorker({
|
|
73
|
-
functions: LUNORA_FUNCTIONS,
|
|
74
|
-
httpRouter: ${wiring.handler},
|
|
75
|
-
openApiSpec,
|
|
76
|
-
routes: {},
|
|
77
|
-
shardDO: env.SHARD,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return worker.fetch(request, env, context);
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
`;
|
|
84
|
-
};
|
|
85
|
-
const frameworkComposePlugin = (options, context) => {
|
|
86
|
-
const generatedImportBase = resolve(options.projectRoot, options.generatedDir.replace(TRAILING_SLASH, ""));
|
|
87
|
-
const useUmbrella = projectUsesUmbrella(options.projectRoot);
|
|
88
|
-
return {
|
|
89
|
-
load(id) {
|
|
90
|
-
if (id === RESOLVED_LUNORA_WORKER_ID && isWorkerVirtualActive(context) && context.framework !== void 0) {
|
|
91
|
-
const hasContainers = existsSync(join(generatedImportBase, "containers.ts"));
|
|
92
|
-
return buildWorkerEntrySource(context.framework.framework, generatedImportBase, hasContainers, useUmbrella);
|
|
93
|
-
}
|
|
94
|
-
return void 0;
|
|
95
|
-
},
|
|
96
|
-
name: "lunora:framework-compose",
|
|
97
|
-
resolveId(id) {
|
|
98
|
-
if (id === LUNORA_WORKER_VIRTUAL_ID && isWorkerVirtualActive(context)) {
|
|
99
|
-
return RESOLVED_LUNORA_WORKER_ID;
|
|
100
|
-
}
|
|
101
|
-
return void 0;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
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 };
|