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

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
@@ -1,50 +0,0 @@
1
- import { discoverContainerInfo, streamContainerLogs } from '@lunora/config';
2
- import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
-
4
- const containerLogsPlugin = (options) => {
5
- let handle;
6
- const closeHandle = () => {
7
- handle?.close();
8
- handle = void 0;
9
- };
10
- return {
11
- apply: "serve",
12
- // Fires on `server.close()` for both the normal and middleware-mode dev
13
- // servers, so the Docker poll loop is torn down even when there is no
14
- // `httpServer` to listen on (middleware mode).
15
- buildEnd() {
16
- closeHandle();
17
- },
18
- configureServer(server) {
19
- if (handle || process.env.LUNORA_CONTAINER_LOGS === "0") {
20
- return;
21
- }
22
- const discovery = discoverContainerInfo(options.projectRoot, options.schemaDir);
23
- const containers = discovery.containers.map((container) => {
24
- return { className: container.className, exportName: container.exportName };
25
- });
26
- if (containers.length === 0) {
27
- return;
28
- }
29
- const { logger } = server.config;
30
- handle = streamContainerLogs({
31
- containers,
32
- onLine: (line) => {
33
- const text = lunoraLine(`container:${line.name} ${line.text}`);
34
- if (line.level === "error") {
35
- logger.warn(text);
36
- } else {
37
- logger.info(text);
38
- }
39
- },
40
- onUnavailable: (message) => {
41
- logger.warn(lunoraLine(`container: Docker engine unreachable — container logs unavailable (${message})`));
42
- }
43
- });
44
- server.httpServer?.once("close", closeHandle);
45
- },
46
- name: "lunora:container-logs"
47
- };
48
- };
49
-
50
- export { containerLogsPlugin as default };
@@ -1,84 +0,0 @@
1
- import { claimDevServerState, DEV_LOG_FILE_ENV, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, clearDevServerState } from '@lunora/config';
2
- import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
- import { r as runPendingClose, a as registerDevServerClose } from './server-close-DKDp7YTU.mjs';
4
-
5
- const TRAILING_SLASH = /\/$/;
6
- const resolveLocalUrl = (server) => {
7
- const resolved = server.resolvedUrls?.local[0];
8
- if (resolved !== void 0) {
9
- return resolved.replace(TRAILING_SLASH, "");
10
- }
11
- const address = server.httpServer?.address();
12
- if (address !== null && typeof address === "object") {
13
- return `http://localhost:${String(address.port)}`;
14
- }
15
- return void 0;
16
- };
17
- const devStatePlugin = (options) => {
18
- let recorded = false;
19
- const pendingMiddlewareClears = /* @__PURE__ */ new Map();
20
- return {
21
- apply: "serve",
22
- configureServer(server) {
23
- const root = options.projectRoot;
24
- const record = () => {
25
- if (recorded) {
26
- return;
27
- }
28
- const url = resolveLocalUrl(server);
29
- if (url === void 0) {
30
- return;
31
- }
32
- const handoffPid = Number(process.env[DEV_HANDOFF_ENV]);
33
- const claim = claimDevServerState(
34
- root,
35
- {
36
- background: process.env[DEV_DAEMON_ENV] === "1",
37
- logFile: process.env[DEV_LOG_FILE_ENV],
38
- mode: "vite",
39
- pid: process.pid,
40
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
41
- url
42
- },
43
- Number.isInteger(handoffPid) && handoffPid > 0 ? { supersedePid: handoffPid } : void 0
44
- );
45
- if (!claim.ok) {
46
- if (claim.existing !== void 0) {
47
- server.config.logger.warn(
48
- lunoraLine(
49
- `another dev server is already recorded at ${claim.existing.url} (pid ${String(claim.existing.pid)}) — leaving .lunora/dev.json untouched`
50
- )
51
- );
52
- }
53
- return;
54
- }
55
- recorded = true;
56
- };
57
- const clearOnClose = () => {
58
- if (recorded) {
59
- clearDevServerState(root, process.pid);
60
- recorded = false;
61
- }
62
- };
63
- registerDevServerClose(server, pendingMiddlewareClears, clearOnClose);
64
- return () => {
65
- if (typeof server.printUrls === "function") {
66
- const printUrls = server.printUrls.bind(server);
67
- server.printUrls = () => {
68
- printUrls();
69
- record();
70
- };
71
- }
72
- server.httpServer?.once("listening", () => {
73
- setTimeout(record, 0);
74
- });
75
- };
76
- },
77
- buildEnd() {
78
- runPendingClose(pendingMiddlewareClears, this.environment);
79
- },
80
- name: "lunora:dev-state"
81
- };
82
- };
83
-
84
- export { devStatePlugin as default };
@@ -1,19 +0,0 @@
1
- import { ensureDevVariables, createConfirm, fillDevSecrets } from '@lunora/config';
2
- import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
-
4
- const devVariablesPlugin = (options) => {
5
- return {
6
- apply: "serve",
7
- async configResolved() {
8
- const info = (message) => {
9
- console.info(lunoraLine(message));
10
- };
11
- await ensureDevVariables({ confirm: createConfirm("[lunora] "), cwd: options.projectRoot, info });
12
- fillDevSecrets({ cwd: options.projectRoot, info });
13
- },
14
- enforce: "pre",
15
- name: "lunora:dev-vars"
16
- };
17
- };
18
-
19
- export { devVariablesPlugin as default };
@@ -1,8 +0,0 @@
1
- import { paintBadge, BADGES } from '@lunora/config';
2
-
3
- const LUNORA_TAG = paintBadge(BADGES.lunora);
4
- const lunoraLine = (message) => `${LUNORA_TAG} ${message}`;
5
- const ADVISORY_BADGE = { ERROR: BADGES.error, INFO: BADGES.info, WARN: BADGES.warn };
6
- const advisoryLine = (level, name, detail, remediation) => `${paintBadge(ADVISORY_BADGE[level])} ${name}: ${detail} — ${remediation}`;
7
-
8
- export { LUNORA_TAG as L, advisoryLine as a, lunoraLine as l };
@@ -1,81 +0,0 @@
1
- import { detectAiAgent, LUNORA_EVENT_SOURCE, formatLunoraEvent } from '@lunora/config';
2
- import { a as registerDevServerClose, r as runPendingClose } from './server-close-DKDp7YTU.mjs';
3
-
4
- const LUNORA_MARKER = `"source":"${LUNORA_EVENT_SOURCE}"`;
5
- const ANSI = {
6
- error: "\x1B[31m",
7
- info: "\x1B[36m",
8
- reset: "\x1B[0m",
9
- warn: "\x1B[33m"
10
- };
11
- const decorate = (text, level, colour) => colour ? `${ANSI[level]}[lunora]${ANSI.reset} ${text}` : `[lunora] ${text}`;
12
- const chunkToText = (chunk) => {
13
- if (typeof chunk === "string") {
14
- return chunk;
15
- }
16
- return Buffer.isBuffer(chunk) ? chunk.toString("utf8") : void 0;
17
- };
18
- const rewriteChunk = (text, colour) => text.split("\n").map((segment) => {
19
- const formatted = formatLunoraEvent(segment);
20
- return formatted ? decorate(formatted.text, formatted.level, colour) : segment;
21
- }).join("\n");
22
- const wrapWrite = (original, colour) => (...args) => {
23
- try {
24
- const text = chunkToText(args[0]);
25
- if (text?.includes(LUNORA_MARKER)) {
26
- return original(rewriteChunk(text, colour), ...args.slice(1));
27
- }
28
- } catch {
29
- }
30
- return original(...args);
31
- };
32
- const patchStream = (stream) => {
33
- const original = stream.write.bind(stream);
34
- const wrapper = wrapWrite(original, stream.isTTY === true);
35
- stream.write = wrapper;
36
- return () => {
37
- if (stream.write === wrapper) {
38
- stream.write = original;
39
- }
40
- };
41
- };
42
- const wantRawJsonLogs = () => {
43
- const flag = process.env.LUNORA_LOG_JSON;
44
- if (flag === "1" || flag === "true") {
45
- return true;
46
- }
47
- if (flag === "0" || flag === "false") {
48
- return false;
49
- }
50
- return detectAiAgent() !== void 0;
51
- };
52
- const logStreamPlugin = () => {
53
- const pendingMiddlewareTeardowns = /* @__PURE__ */ new Map();
54
- let activeRestore;
55
- return {
56
- apply: "serve",
57
- buildEnd() {
58
- runPendingClose(pendingMiddlewareTeardowns, this.environment);
59
- },
60
- configureServer(server) {
61
- if (wantRawJsonLogs()) {
62
- return;
63
- }
64
- activeRestore?.();
65
- const restoreStdout = patchStream(process.stdout);
66
- const restoreStderr = patchStream(process.stderr);
67
- const restore = () => {
68
- restoreStdout();
69
- restoreStderr();
70
- if (activeRestore === restore) {
71
- activeRestore = void 0;
72
- }
73
- };
74
- activeRestore = restore;
75
- registerDevServerClose(server, pendingMiddlewareTeardowns, restore);
76
- },
77
- name: "lunora:log-stream"
78
- };
79
- };
80
-
81
- export { logStreamPlugin as default };
@@ -1,17 +0,0 @@
1
- import { findLunoraSolution } from '@lunora/codegen';
2
-
3
- const lunoraSolutionFinder = {
4
- // Synchronous body wrapped in `Promise.resolve` rather than `async`: the
5
- // overlay's `handle` contract is promise-returning, but `require-await` is on
6
- // for src and there's nothing to await here.
7
- handle: (error) => {
8
- const message = typeof error.message === "string" ? error.message : "";
9
- const solution = findLunoraSolution(message);
10
- return Promise.resolve(solution ? { body: solution.body, header: solution.header } : void 0);
11
- },
12
- name: "lunora",
13
- priority: 100
14
- };
15
- const lunoraSolutionFinders = [lunoraSolutionFinder];
16
-
17
- export { lunoraSolutionFinder, lunoraSolutionFinders };
@@ -1,66 +0,0 @@
1
- import { resolveRemoteEnabled, readProjectRemotePreference, materializeRemoteWranglerConfig } from '@lunora/config';
2
- import { l as lunoraLine } from './log-BjO9EWah.mjs';
3
-
4
- const noopCleanup = () => {
5
- };
6
- const planViteRemoteBindings = (options) => {
7
- const readPreference = options.readPreference ?? readProjectRemotePreference;
8
- const enabled = resolveRemoteEnabled({
9
- configPreference: readPreference(options.projectRoot),
10
- envValue: options.remoteEnv ?? process.env["LUNORA_REMOTE"]
11
- });
12
- if (!enabled) {
13
- return { cleanup: noopCleanup, enabled: false };
14
- }
15
- const materialize = options.materialize ?? materializeRemoteWranglerConfig;
16
- const result = materialize({ enabled: true, projectRoot: options.projectRoot });
17
- return {
18
- // The materializer always returns an idempotent, never-throwing `cleanup`.
19
- cleanup: result.cleanup,
20
- configPath: result.configPath,
21
- enabled: true,
22
- reason: result.reason
23
- };
24
- };
25
- const withRemoteBindings = (options, plan) => {
26
- if (!plan.enabled || plan.configPath === void 0) {
27
- return options;
28
- }
29
- const existing = options;
30
- if (typeof existing.configPath === "string") {
31
- return options;
32
- }
33
- return { ...options, configPath: plan.configPath };
34
- };
35
- const remoteBindingsConfigPlugin = (options, plan) => {
36
- return {
37
- config(_userConfig, env) {
38
- if (env.command !== "serve") {
39
- return;
40
- }
41
- const merged = withRemoteBindings(options, plan);
42
- const target = options;
43
- if (merged.configPath !== void 0 && target.configPath === void 0) {
44
- target.configPath = merged.configPath;
45
- } else if (plan.enabled && plan.configPath === void 0 && plan.reason !== void 0) {
46
- console.info(lunoraLine(`remote bindings requested but not applied: ${plan.reason}`));
47
- }
48
- },
49
- enforce: "pre",
50
- name: "lunora:remote-bindings-config"
51
- };
52
- };
53
- const remoteBindingsCleanupPlugin = (cleanup) => {
54
- return {
55
- buildEnd() {
56
- cleanup();
57
- },
58
- closeBundle() {
59
- cleanup();
60
- },
61
- enforce: "pre",
62
- name: "lunora:remote-bindings-cleanup"
63
- };
64
- };
65
-
66
- export { planViteRemoteBindings, remoteBindingsCleanupPlugin, remoteBindingsConfigPlugin, withRemoteBindings };
@@ -1,16 +0,0 @@
1
- const registerDevServerClose = (server, pending, onClose) => {
2
- if (server.httpServer) {
3
- server.httpServer.once("close", onClose);
4
- } else {
5
- pending.set(server.environments.client, onClose);
6
- }
7
- };
8
- const runPendingClose = (pending, environment) => {
9
- const onClose = pending.get(environment);
10
- if (onClose !== void 0) {
11
- pending.delete(environment);
12
- onClose();
13
- }
14
- };
15
-
16
- export { registerDevServerClose as a, runPendingClose as r };
@@ -1,68 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { validateWranglerProject, readWranglerJsonc } from '@lunora/config';
3
- import { LunoraError } from '@lunora/errors';
4
- import { l as lunoraLine } from './log-BjO9EWah.mjs';
5
-
6
- const isLocalImagePath = (image) => image.startsWith("./") || image.startsWith("../") || image.startsWith("/") || image.includes("Dockerfile");
7
- const probeDocker = () => {
8
- try {
9
- return spawnSync("docker", ["info"], { stdio: "ignore" }).status === 0;
10
- } catch {
11
- return false;
12
- }
13
- };
14
- const warnWhenDockerMissing = (wranglerPath, dockerAvailable = probeDocker) => {
15
- const { parsed } = readWranglerJsonc(wranglerPath);
16
- const needsDocker = (parsed?.containers ?? []).some((entry) => typeof entry?.image === "string" && isLocalImagePath(entry.image));
17
- if (!needsDocker || dockerAvailable()) {
18
- return;
19
- }
20
- console.warn(
21
- lunoraLine(
22
- "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."
23
- )
24
- );
25
- };
26
- const formatError = (wranglerPath, problems) => {
27
- const lines = [
28
- "[lunora] wrangler configuration is missing bindings required by your schema.",
29
- ` file: ${wranglerPath}`,
30
- "",
31
- ...problems.map((problem) => ` - ${problem}`),
32
- "",
33
- " Update your wrangler.jsonc and restart the dev server."
34
- ];
35
- return new Error(lines.join("\n"));
36
- };
37
- const wranglerValidatorPlugin = (options) => {
38
- return {
39
- configResolved() {
40
- const result = validateWranglerProject({
41
- projectRoot: options.projectRoot,
42
- schemaDir: options.schemaDir
43
- });
44
- if (!result.wranglerPath) {
45
- throw new LunoraError(
46
- "INTERNAL",
47
- [
48
- "[lunora] wrangler.jsonc not found.",
49
- ` searched in: ${options.projectRoot}`,
50
- " create a wrangler.jsonc declaring at least the SHARD durable object binding."
51
- ].join("\n")
52
- );
53
- }
54
- if (result.report.warnings.length > 0) {
55
- for (const warning of result.report.warnings) {
56
- console.warn(lunoraLine(`wrangler validator: ${warning}`));
57
- }
58
- }
59
- if (result.problems.length > 0) {
60
- throw formatError(result.wranglerPath, result.problems);
61
- }
62
- warnWhenDockerMissing(result.wranglerPath);
63
- },
64
- name: "lunora:wrangler-validator"
65
- };
66
- };
67
-
68
- export { warnWhenDockerMissing, wranglerValidatorPlugin };