@lunora/vite 1.0.0-alpha.6 → 1.0.0-alpha.61
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 +106 -9
- package/dist/index.d.ts +106 -9
- package/dist/index.mjs +33 -18
- package/dist/packem_shared/{CLASS_A_WIRING-CZVcjgKo.mjs → CLASS_A_WIRING-DEw5sPHs.mjs} +17 -4
- package/dist/packem_shared/LUNORA_API_UPDATED_EVENT-BrkWk3rr.mjs +3 -0
- package/dist/packem_shared/{STUDIO_PATH-5ppCdBHa.mjs → STUDIO_PATH-DYspAN3z.mjs} +28 -6
- package/dist/packem_shared/codegenPlugin-DEfMflEi.mjs +348 -0
- package/dist/packem_shared/containerLogsPlugin-DMssU3wb.mjs +50 -0
- package/dist/packem_shared/devStatePlugin-DdjfMrhx.mjs +84 -0
- package/dist/packem_shared/devVariablesPlugin-CDNSnvOP.mjs +19 -0
- package/dist/packem_shared/{logStreamPlugin-CqvZ17kd.mjs → logStreamPlugin-CVrcDAZ1.mjs} +14 -1
- package/dist/packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs +17 -0
- package/dist/packem_shared/server-close-DKDp7YTU.mjs +16 -0
- package/dist/packem_shared/{wranglerValidatorPlugin-CEoJEghS.mjs → wranglerValidatorPlugin-C5VWOD7N.mjs} +3 -1
- package/package.json +9 -8
- package/dist/packem_shared/codegenPlugin-MuvbqAP8.mjs +0 -218
- package/dist/packem_shared/devVariablesPlugin-CVjkQay7.mjs +0 -21
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { resolve, sep, join } from 'node:path';
|
|
3
|
-
import { createCodegenProject, refreshCodegenProject, runCodegen, CodegenDiagnosticError } from '@lunora/codegen';
|
|
4
|
-
import { inferLunoraBindings, reconcileWranglerBindings } from '@lunora/config';
|
|
5
|
-
import { reconcileWranglerCrons } from './reconcileWranglerCrons-PxGwfCp_.mjs';
|
|
6
|
-
import { L as LUNORA_TAG, a as advisoryLine } from './log-BjO9EWah.mjs';
|
|
7
|
-
|
|
8
|
-
const DEBOUNCE_MS = 100;
|
|
9
|
-
const TSCONFIG_VARIANT_RE = /[/\\]tsconfig\..+\.json$/u;
|
|
10
|
-
const formatExportGapOverlay = (gaps) => {
|
|
11
|
-
const lines = gaps.map((gap) => ` • ${gap.kind} "${gap.exportName}" — class ${gap.className} is not exported by your worker entry.`);
|
|
12
|
-
const hints = [...new Set(gaps.map((gap) => gap.module))].map((module) => ` export * from "./lunora/_generated/${module}";`);
|
|
13
|
-
return [
|
|
14
|
-
`[lunora] ${String(gaps.length)} declared ${gaps.length === 1 ? "binding is" : "bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,
|
|
15
|
-
...lines,
|
|
16
|
-
"",
|
|
17
|
-
"Add to your worker entry:",
|
|
18
|
-
...hints
|
|
19
|
-
].join("\n");
|
|
20
|
-
};
|
|
21
|
-
const reconcileBindingsSafely = async (options, logger, onExportGaps) => {
|
|
22
|
-
try {
|
|
23
|
-
const inferred = await inferLunoraBindings({ projectRoot: options.projectRoot, schemaDir: options.schemaDir });
|
|
24
|
-
const reconciled = reconcileWranglerBindings(options.projectRoot, inferred);
|
|
25
|
-
if (reconciled.changed) {
|
|
26
|
-
logger.info?.(`${LUNORA_TAG} inferred bindings → ${reconciled.added.join(", ")} (written to ${reconciled.wranglerPath ?? "wrangler.jsonc"})`);
|
|
27
|
-
}
|
|
28
|
-
for (const warning of reconciled.warnings) {
|
|
29
|
-
logger.warn(`${LUNORA_TAG} ${warning}`);
|
|
30
|
-
}
|
|
31
|
-
if (reconciled.exportGaps.length > 0) {
|
|
32
|
-
onExportGaps?.(reconciled.exportGaps);
|
|
33
|
-
}
|
|
34
|
-
} catch (error) {
|
|
35
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
-
logger.warn(`${LUNORA_TAG} binding inference skipped: ${message}`);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const runCodegenSafely = (options, logger, overlay, project) => {
|
|
40
|
-
const schemaPath = join(options.projectRoot, options.schemaDir, "schema.ts");
|
|
41
|
-
if (!existsSync(schemaPath)) {
|
|
42
|
-
logger.warn(`${LUNORA_TAG} schema.ts not found at ${schemaPath} — codegen skipped`);
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const result = runCodegen({ apiSpec: options.apiSpec, lunoraDirectory: options.schemaDir, project, projectRoot: options.projectRoot });
|
|
47
|
-
try {
|
|
48
|
-
const reconciled = reconcileWranglerCrons(options.projectRoot, result.cronTriggers);
|
|
49
|
-
if (reconciled.changed) {
|
|
50
|
-
logger.info?.(
|
|
51
|
-
`${LUNORA_TAG} synced ${result.cronTriggers.length.toFixed(0)} cron trigger(s) into ${reconciled.wranglerPath ?? "wrangler.jsonc"}`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
} catch (cronError) {
|
|
55
|
-
const message = cronError instanceof Error ? cronError.message : String(cronError);
|
|
56
|
-
logger.warn(`${LUNORA_TAG} cron trigger sync skipped: ${message}`);
|
|
57
|
-
}
|
|
58
|
-
for (const advisory of result.advisories) {
|
|
59
|
-
const line = advisoryLine(advisory.level, advisory.name, advisory.detail, advisory.remediation);
|
|
60
|
-
if (advisory.level === "ERROR") {
|
|
61
|
-
logger.error(line);
|
|
62
|
-
} else {
|
|
63
|
-
logger.warn(line);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return resolve(result.outputDirectory);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
-
logger.error(`${LUNORA_TAG} codegen failed: ${message}`);
|
|
70
|
-
overlay?.onError(error, message);
|
|
71
|
-
return void 0;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const codegenPlugin = (options) => {
|
|
75
|
-
const absoluteSchemaDirectory = resolve(options.projectRoot, options.schemaDir);
|
|
76
|
-
let absoluteGeneratedDirectory = resolve(options.projectRoot, options.generatedDir);
|
|
77
|
-
let debounceTimer;
|
|
78
|
-
let devServer;
|
|
79
|
-
return {
|
|
80
|
-
async buildStart() {
|
|
81
|
-
const logger = {
|
|
82
|
-
error: (message) => {
|
|
83
|
-
console.error(message);
|
|
84
|
-
},
|
|
85
|
-
info: (message) => {
|
|
86
|
-
console.info(message);
|
|
87
|
-
},
|
|
88
|
-
warn: (message) => {
|
|
89
|
-
console.warn(message);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const outputDirectory = runCodegenSafely(options, logger);
|
|
93
|
-
if (outputDirectory !== void 0) {
|
|
94
|
-
absoluteGeneratedDirectory = outputDirectory;
|
|
95
|
-
}
|
|
96
|
-
await reconcileBindingsSafely(options, logger, (gaps) => {
|
|
97
|
-
devServer?.hot.send({
|
|
98
|
-
err: { loc: void 0, message: formatExportGapOverlay(gaps), stack: "" },
|
|
99
|
-
type: "error"
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
configureServer(server) {
|
|
104
|
-
devServer = server;
|
|
105
|
-
server.watcher.add(absoluteSchemaDirectory);
|
|
106
|
-
const serverLogger = {
|
|
107
|
-
error: (message) => {
|
|
108
|
-
server.config.logger.error(message);
|
|
109
|
-
},
|
|
110
|
-
info: (message) => {
|
|
111
|
-
server.config.logger.info(message);
|
|
112
|
-
},
|
|
113
|
-
warn: (message) => {
|
|
114
|
-
server.config.logger.warn(message);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const overlay = {
|
|
118
|
-
onError(error, message) {
|
|
119
|
-
const loc = error instanceof CodegenDiagnosticError ? { column: error.column, file: error.file, line: error.line } : void 0;
|
|
120
|
-
const overlayMessage = loc === void 0 ? `[lunora] codegen failed: ${message}
|
|
121
|
-
(see terminal for full stack trace and file location)` : `[lunora] codegen failed: ${message}`;
|
|
122
|
-
devServer?.hot.send({
|
|
123
|
-
err: {
|
|
124
|
-
loc,
|
|
125
|
-
message: overlayMessage,
|
|
126
|
-
stack: error instanceof Error ? error.stack ?? "" : ""
|
|
127
|
-
},
|
|
128
|
-
type: "error"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const isInside = (path, directory) => path === directory || path.startsWith(directory + sep);
|
|
133
|
-
let closed = false;
|
|
134
|
-
let cachedProject;
|
|
135
|
-
const invalidateGenerated = () => {
|
|
136
|
-
const environments = server.environments;
|
|
137
|
-
const graphs = [];
|
|
138
|
-
if (environments !== void 0) {
|
|
139
|
-
for (const environment of Object.values(environments)) {
|
|
140
|
-
if (environment.moduleGraph !== void 0) {
|
|
141
|
-
graphs.push(environment.moduleGraph);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (graphs.length === 0) {
|
|
146
|
-
graphs.push(server.moduleGraph);
|
|
147
|
-
}
|
|
148
|
-
for (const graph of graphs) {
|
|
149
|
-
for (const moduleEntry of graph.idToModuleMap.values()) {
|
|
150
|
-
if (moduleEntry.id && isInside(moduleEntry.id, absoluteGeneratedDirectory)) {
|
|
151
|
-
graph.invalidateModule(moduleEntry);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
const onChange = (file) => {
|
|
157
|
-
const normalized = resolve(file);
|
|
158
|
-
if (!isInside(normalized, absoluteSchemaDirectory)) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (isInside(normalized, absoluteGeneratedDirectory)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (normalized.endsWith(`${sep}tsconfig.json`) || TSCONFIG_VARIANT_RE.test(normalized)) {
|
|
165
|
-
cachedProject = void 0;
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (!normalized.endsWith(".ts")) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (normalized.includes(`${sep}__tests__${sep}`) || normalized.endsWith(".test.ts") || normalized.endsWith(".spec.ts")) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (debounceTimer) {
|
|
175
|
-
clearTimeout(debounceTimer);
|
|
176
|
-
}
|
|
177
|
-
debounceTimer = setTimeout(() => {
|
|
178
|
-
debounceTimer = void 0;
|
|
179
|
-
if (closed) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (cachedProject === void 0) {
|
|
183
|
-
cachedProject = createCodegenProject(absoluteSchemaDirectory);
|
|
184
|
-
} else {
|
|
185
|
-
refreshCodegenProject(cachedProject, absoluteSchemaDirectory);
|
|
186
|
-
}
|
|
187
|
-
const outputDirectory = runCodegenSafely(options, serverLogger, overlay, cachedProject);
|
|
188
|
-
if (outputDirectory === void 0) {
|
|
189
|
-
cachedProject = void 0;
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
absoluteGeneratedDirectory = outputDirectory;
|
|
193
|
-
invalidateGenerated();
|
|
194
|
-
server.hot.send({ type: "full-reload" });
|
|
195
|
-
}, DEBOUNCE_MS);
|
|
196
|
-
};
|
|
197
|
-
server.watcher.on("add", onChange);
|
|
198
|
-
server.watcher.on("change", onChange);
|
|
199
|
-
server.watcher.on("unlink", onChange);
|
|
200
|
-
return () => {
|
|
201
|
-
server.httpServer?.once("close", () => {
|
|
202
|
-
closed = true;
|
|
203
|
-
cachedProject = void 0;
|
|
204
|
-
if (debounceTimer) {
|
|
205
|
-
clearTimeout(debounceTimer);
|
|
206
|
-
debounceTimer = void 0;
|
|
207
|
-
}
|
|
208
|
-
server.watcher.off("add", onChange);
|
|
209
|
-
server.watcher.off("change", onChange);
|
|
210
|
-
server.watcher.off("unlink", onChange);
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
name: "lunora:codegen"
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export { codegenPlugin as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ensureDevVariables, createConfirm } from '@lunora/config';
|
|
2
|
-
import { l as lunoraLine } from './log-BjO9EWah.mjs';
|
|
3
|
-
|
|
4
|
-
const devVariablesPlugin = (options) => {
|
|
5
|
-
return {
|
|
6
|
-
apply: "serve",
|
|
7
|
-
async configResolved() {
|
|
8
|
-
await ensureDevVariables({
|
|
9
|
-
confirm: createConfirm("[lunora] "),
|
|
10
|
-
cwd: options.projectRoot,
|
|
11
|
-
info: (message) => {
|
|
12
|
-
console.info(lunoraLine(message));
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
enforce: "pre",
|
|
17
|
-
name: "lunora:dev-vars"
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { devVariablesPlugin as default };
|