@lunora/vite 1.0.0-alpha.46 → 1.0.0-alpha.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -113,6 +113,8 @@ interface ReconcileResult {
113
113
  * the generated value.
114
114
  */
115
115
  declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
116
+ /** Vite plugin (serve-only) that writes the dev-server state record on listen and clears it on close. */
117
+ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
116
118
  /**
117
119
  * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
118
120
  * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
@@ -445,4 +447,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
445
447
  */
446
448
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
447
449
  declare const VERSION = "0.0.0";
448
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
450
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.d.ts CHANGED
@@ -113,6 +113,8 @@ interface ReconcileResult {
113
113
  * the generated value.
114
114
  */
115
115
  declare const reconcileWranglerCrons: (projectRoot: string, cronTriggers: ReadonlyArray<string>) => ReconcileResult;
116
+ /** Vite plugin (serve-only) that writes the dev-server state record on listen and clears it on close. */
117
+ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
116
118
  /**
117
119
  * Dev-only Vite plugin that prepares `.dev.vars` before the worker boots.
118
120
  * `@cloudflare/vite-plugin` loads `.dev.vars` into the worker's `env`, but the
@@ -445,4 +447,4 @@ declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) =>
445
447
  */
446
448
  declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
447
449
  declare const VERSION = "0.0.0";
448
- export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
450
+ export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
package/dist/index.mjs CHANGED
@@ -5,12 +5,13 @@ export { detectFramework } from '@lunora/config';
5
5
  import { l as lunoraLine } from './packem_shared/log-BjO9EWah.mjs';
6
6
  import codegenPlugin from './packem_shared/codegenPlugin-B_ayaObq.mjs';
7
7
  import containerLogsPlugin from './packem_shared/containerLogsPlugin-DMssU3wb.mjs';
8
+ import devStatePlugin from './packem_shared/devStatePlugin-D7Qc2gKr.mjs';
8
9
  import devVariablesPlugin from './packem_shared/devVariablesPlugin-CDNSnvOP.mjs';
9
10
  import { createCommandProbe, withDevWorkerEnv } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
10
11
  export { DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR } from './packem_shared/DEV_WORKER_ENV_VALUE-Coo6bgVz.mjs';
11
12
  import { frameworkComposePlugin } from './packem_shared/CLASS_A_WIRING-DEw5sPHs.mjs';
12
13
  export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/CLASS_A_WIRING-DEw5sPHs.mjs';
13
- import logStreamPlugin from './packem_shared/logStreamPlugin-CqvZ17kd.mjs';
14
+ import logStreamPlugin from './packem_shared/logStreamPlugin-CVrcDAZ1.mjs';
14
15
  import { planViteRemoteBindings, remoteBindingsCleanupPlugin, withRemoteBindings } from './packem_shared/planViteRemoteBindings-QN5ncUS1.mjs';
15
16
  import { lunoraSolutionFinders } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
16
17
  export { lunoraSolutionFinder } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
@@ -137,6 +138,9 @@ const lunora = (options) => {
137
138
  devVariablesPlugin(resolved),
138
139
  codegenPlugin(resolved),
139
140
  logStreamPlugin(),
141
+ // Registers the running dev server in `.lunora/dev.json` so
142
+ // `lunora dev --background|stop|status|logs` manage Vite projects too.
143
+ devStatePlugin(resolved),
140
144
  agentRulesHintPlugin(resolved)
141
145
  ];
142
146
  if (resolved.studio) {
@@ -161,4 +165,4 @@ const lunora = (options) => {
161
165
  };
162
166
  const VERSION = "0.0.0";
163
167
 
164
- export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
168
+ export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
@@ -0,0 +1,78 @@
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
+
4
+ const TRAILING_SLASH = /\/$/;
5
+ const resolveLocalUrl = (server) => {
6
+ const resolved = server.resolvedUrls?.local[0];
7
+ if (resolved !== void 0) {
8
+ return resolved.replace(TRAILING_SLASH, "");
9
+ }
10
+ const address = server.httpServer?.address();
11
+ if (address !== null && typeof address === "object") {
12
+ return `http://localhost:${String(address.port)}`;
13
+ }
14
+ return void 0;
15
+ };
16
+ const devStatePlugin = (options) => {
17
+ let recorded = false;
18
+ return {
19
+ apply: "serve",
20
+ configureServer(server) {
21
+ const root = options.projectRoot;
22
+ const record = () => {
23
+ if (recorded) {
24
+ return;
25
+ }
26
+ const url = resolveLocalUrl(server);
27
+ if (url === void 0) {
28
+ return;
29
+ }
30
+ const handoffPid = Number(process.env[DEV_HANDOFF_ENV]);
31
+ const claim = claimDevServerState(
32
+ root,
33
+ {
34
+ background: process.env[DEV_DAEMON_ENV] === "1",
35
+ logFile: process.env[DEV_LOG_FILE_ENV],
36
+ mode: "vite",
37
+ pid: process.pid,
38
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
39
+ url
40
+ },
41
+ Number.isInteger(handoffPid) && handoffPid > 0 ? { supersedePid: handoffPid } : void 0
42
+ );
43
+ if (!claim.ok) {
44
+ if (claim.existing !== void 0) {
45
+ server.config.logger.warn(
46
+ lunoraLine(
47
+ `another dev server is already recorded at ${claim.existing.url} (pid ${String(claim.existing.pid)}) — leaving .lunora/dev.json untouched`
48
+ )
49
+ );
50
+ }
51
+ return;
52
+ }
53
+ recorded = true;
54
+ };
55
+ server.httpServer?.once("close", () => {
56
+ if (recorded) {
57
+ clearDevServerState(root, process.pid);
58
+ recorded = false;
59
+ }
60
+ });
61
+ return () => {
62
+ if (typeof server.printUrls === "function") {
63
+ const printUrls = server.printUrls.bind(server);
64
+ server.printUrls = () => {
65
+ printUrls();
66
+ record();
67
+ };
68
+ }
69
+ server.httpServer?.once("listening", () => {
70
+ setTimeout(record, 0);
71
+ });
72
+ };
73
+ },
74
+ name: "lunora:dev-state"
75
+ };
76
+ };
77
+
78
+ export { devStatePlugin as default };
@@ -1,4 +1,4 @@
1
- import { LUNORA_EVENT_SOURCE, formatLunoraEvent } from '@lunora/config';
1
+ import { detectAiAgent, LUNORA_EVENT_SOURCE, formatLunoraEvent } from '@lunora/config';
2
2
 
3
3
  const LUNORA_MARKER = `"source":"${LUNORA_EVENT_SOURCE}"`;
4
4
  const ANSI = {
@@ -35,6 +35,16 @@ const patchStream = (stream) => {
35
35
  stream.write = original;
36
36
  };
37
37
  };
38
+ const wantRawJsonLogs = () => {
39
+ const flag = process.env.LUNORA_LOG_JSON;
40
+ if (flag === "1" || flag === "true") {
41
+ return true;
42
+ }
43
+ if (flag === "0" || flag === "false") {
44
+ return false;
45
+ }
46
+ return detectAiAgent() !== void 0;
47
+ };
38
48
  const logStreamPlugin = () => {
39
49
  let restore;
40
50
  return {
@@ -43,6 +53,9 @@ const logStreamPlugin = () => {
43
53
  if (restore) {
44
54
  return;
45
55
  }
56
+ if (wantRawJsonLogs()) {
57
+ return;
58
+ }
46
59
  const restoreStdout = patchStream(process.stdout);
47
60
  const restoreStderr = patchStream(process.stderr);
48
61
  restore = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vite",
3
- "version": "1.0.0-alpha.46",
3
+ "version": "1.0.0-alpha.47",
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",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@cloudflare/vite-plugin": "1.42.3",
49
49
  "@lunora/codegen": "1.0.0-alpha.29",
50
- "@lunora/config": "1.0.0-alpha.46",
50
+ "@lunora/config": "1.0.0-alpha.47",
51
51
  "@lunora/errors": "1.0.0-alpha.1",
52
52
  "@visulima/vite-overlay": "2.0.0-alpha.35",
53
53
  "jsonc-parser": "^3.3.1",