@voltro/cli 0.7.0 → 0.9.0

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 (61) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/THIRD-PARTY-NOTICES.md +2 -2
  3. package/dist/apiBuild-Ba4njm9m.js +2 -0
  4. package/dist/{apiBuild-deIjJKJm.js → apiBuild-eInHm_bJ.js} +2 -2
  5. package/dist/bin.js +2 -2
  6. package/dist/{commands-BHdc71DG.js → commands-Cxs97AFp.js} +1897 -1664
  7. package/dist/{dev-Bqyq62Ak.js → dev-63Ehpw2p.js} +475 -475
  8. package/dist/dev-CXsR8Zgo.js +2 -0
  9. package/dist/index.js +1 -1
  10. package/dist/{inspectMetrics-BLUBAWLb.js → inspectMetrics-DVCKKSPk.js} +819 -510
  11. package/dist/{serveCommand-Dn6--0Bv.js → serveCommand-Cq7BhtpB.js} +3 -3
  12. package/dist/serveEntry.js +3 -3
  13. package/dist/{start-CWZW_4Et.js → start-CYe-7ueh.js} +371 -306
  14. package/dist/startEntry.js +2 -2
  15. package/package.json +18 -17
  16. package/templates/AGENTS.core.md +15 -4
  17. package/templates/AGENTS.md +15 -4
  18. package/templates/agent-docs/authentication.md +7 -4
  19. package/templates/agent-docs/cli.md +84 -5
  20. package/templates/agent-docs/data.md +94 -70
  21. package/templates/agent-docs/database/schema.md +1 -1
  22. package/templates/agent-docs/reference.md +20 -0
  23. package/templates/agent-docs/routing.md +183 -25
  24. package/templates/agent-docs/testing.md +24 -0
  25. package/templates/apps/api-ai/package.json +7 -7
  26. package/templates/apps/api-auth/package.json +8 -8
  27. package/templates/apps/api-backend/package.json +7 -7
  28. package/templates/apps/api-backend-deactivation/package.json +7 -7
  29. package/templates/apps/api-backend-mail/package.json +8 -8
  30. package/templates/apps/api-backend-mariadb/package.json +9 -9
  31. package/templates/apps/api-backend-storage/package.json +8 -8
  32. package/templates/apps/api-data-advanced/package.json +8 -8
  33. package/templates/apps/api-durable/package.json +8 -8
  34. package/templates/apps/api-feature-flags/package.json +9 -9
  35. package/templates/apps/api-governance/package.json +8 -8
  36. package/templates/apps/api-kv/package.json +8 -8
  37. package/templates/apps/api-moderation/package.json +8 -8
  38. package/templates/apps/api-observability/package.json +8 -8
  39. package/templates/apps/api-ratelimit/package.json +8 -8
  40. package/templates/apps/api-rbac/package.json +8 -8
  41. package/templates/apps/api-rest/package.json +7 -7
  42. package/templates/apps/api-saas/package.json +11 -11
  43. package/templates/apps/api-search/package.json +8 -8
  44. package/templates/apps/api-versioning/package.json +8 -8
  45. package/templates/apps/api-webhooks/package.json +8 -8
  46. package/templates/apps/changelog/package.json +6 -6
  47. package/templates/apps/edge-functions/package.json +2 -2
  48. package/templates/apps/frontend-admin/package.json +8 -8
  49. package/templates/apps/frontend-app/package.json +8 -8
  50. package/templates/apps/frontend-blank/package.json +7 -7
  51. package/templates/apps/frontend-contact/package.json +7 -7
  52. package/templates/apps/frontend-dashboard/package.json +7 -7
  53. package/templates/apps/frontend-docs/package.json +7 -7
  54. package/templates/apps/frontend-i18n/package.json +6 -6
  55. package/templates/apps/frontend-landing/package.json +7 -7
  56. package/templates/apps/frontend-spa/package.json +7 -7
  57. package/templates/apps/frontend-ssr/package.json +7 -7
  58. package/templates/apps/frontend-ssr-api/package.json +8 -8
  59. package/templates/apps/frontend-static-blog/package.json +6 -6
  60. package/dist/apiBuild-CSM74oEZ.js +0 -2
  61. package/dist/dev-BYfrYwrT.js +0 -2
@@ -5,18 +5,19 @@ import { NodeContext as l, NodeRuntime as u } from "@effect/platform-node";
5
5
  import { Cause as d, Effect as f, Layer as p } from "effect";
6
6
  import { LoggerLayer as m, addSink as h, createLogger as g, printReadyBlock as _ } from "@voltro/logger";
7
7
  import { closeSync as v, existsSync as y, mkdirSync as b, openSync as x, promises as S, readFileSync as C, readdirSync as w, statSync as T, unlinkSync as E, unwatchFile as ee, watchFile as D, writeSync as te } from "node:fs";
8
- import { currentTraceContext as O, lastWriteProvenance as ne, recordSample as re, resolveSecret as k } from "@voltro/runtime";
9
- import { mkdir as A, writeFile as j } from "node:fs/promises";
10
- import { FRAMEWORK_ENV_CATALOG as M, appEnvEntries as N, checkEnvNaming as ie, formatEnvErrors as ae, installEnvSnapshot as oe, isEnvContract as se, pluginEnvEntries as ce, renderDotEnvExample as P, resolveEnv as le } from "@voltro/env";
11
- import { __installPublicEnv as ue } from "@voltro/env/public";
12
- import { createHash as de } from "node:crypto";
13
- import { spawn as fe } from "node:child_process";
14
- import { timingSafeStringEqual as pe } from "@voltro/protocol/session";
15
- import { homedir as F } from "node:os";
16
- import { createConnection as me } from "node:net";
17
- import { createRequire as he } from "node:module";
8
+ import { currentTraceContext as O, lastWriteProvenance as k, recordSample as A, resolveSecret as j } from "@voltro/runtime";
9
+ import { mkdir as M, writeFile as N } from "node:fs/promises";
10
+ import { FRAMEWORK_ENV_CATALOG as P, appEnvEntries as F, checkEnvNaming as ne, formatEnvErrors as I, installEnvSnapshot as re, isEnvContract as ie, pluginEnvEntries as ae, renderDotEnvExample as L, resolveEnv as oe } from "@voltro/env";
11
+ import { __installPublicEnv as se } from "@voltro/env/public";
12
+ import { createHash as ce } from "node:crypto";
13
+ import { spawn as le } from "node:child_process";
14
+ import { timingSafeStringEqual as ue } from "@voltro/protocol/session";
15
+ import { homedir as de } from "node:os";
16
+ import { createConnection as fe } from "node:net";
17
+ import { createRequire as pe } from "node:module";
18
+ import { PassThrough as me } from "node:stream";
18
19
  //#region src/cliRuntime.ts
19
- var ge = [
20
+ var he = [
20
21
  "severity",
21
22
  "code",
22
23
  "detail",
@@ -33,14 +34,14 @@ var ge = [
33
34
  "file",
34
35
  "line",
35
36
  "routine"
36
- ], I = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
37
+ ], ge = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
37
38
  if (t > 10 || typeof e != "object" || !e || n.has(e)) return null;
38
39
  n.add(e);
39
40
  let r = e, i = r.message;
40
41
  if (typeof i == "string" && i.length > 0 && i !== "Failed to execute statement") {
41
42
  let e = { message: i };
42
43
  typeof r.stack == "string" && (e.stack = r.stack);
43
- for (let t of ge) r[t] !== void 0 && (e[t] = r[t]);
44
+ for (let t of he) r[t] !== void 0 && (e[t] = r[t]);
44
45
  return e;
45
46
  }
46
47
  for (let e of [
@@ -53,12 +54,12 @@ var ge = [
53
54
  ]) {
54
55
  let i = r[e];
55
56
  if (i !== void 0) {
56
- let e = I(i, t + 1, n);
57
+ let e = ge(i, t + 1, n);
57
58
  if (e) return e;
58
59
  }
59
60
  }
60
61
  if (Array.isArray(r.failures)) for (let e of r.failures) {
61
- let r = I(e, t + 1, n);
62
+ let r = ge(e, t + 1, n);
62
63
  if (r) return r;
63
64
  }
64
65
  return null;
@@ -82,7 +83,7 @@ var ge = [
82
83
  }
83
84
  let n = null;
84
85
  for (let e of t) {
85
- let t = I(e);
86
+ let t = ge(e);
86
87
  if (t) {
87
88
  n = t;
88
89
  break;
@@ -105,10 +106,10 @@ var ge = [
105
106
  }, ye = (e, t = {}) => {
106
107
  let n = e.pipe(f.provide(_e(t)));
107
108
  u.runMain(n, { disableErrorReporting: !1 });
108
- }, L = t(o(import.meta.url)), be = [a(L, "..", "templates"), a(L, "..", "..", "templates")], xe = (e) => ({
109
+ }, be = t(o(import.meta.url)), R = [a(be, "..", "templates"), a(be, "..", "..", "templates")], xe = (e) => ({
109
110
  _tag: "TemplateNotFoundError",
110
111
  searched: e
111
- }), Se = ["AGENTS.md", "CLAUDE.md"], Ce = "voltro:agents-md:keep", we = 2048, Te = "<!-- VOLTRO:INDEX -->", R = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), z = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), Ee = (e, t) => e.readFileString(t).pipe(f.map((e) => {
112
+ }), Se = ["AGENTS.md", "CLAUDE.md"], Ce = "voltro:agents-md:keep", we = 2048, Te = "<!-- VOLTRO:INDEX -->", z = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), B = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), Ee = (e, t) => e.readFileString(t).pipe(f.map((e) => {
112
113
  try {
113
114
  return JSON.parse(e).workspaces !== void 0;
114
115
  } catch {
@@ -117,7 +118,7 @@ var ge = [
117
118
  }), f.orElseSucceed(() => !1)), De = (e) => f.gen(function* () {
118
119
  let n = yield* c.FileSystem, i = a(e);
119
120
  for (;;) {
120
- if ((yield* R(n, r(i, ".git"))) || (yield* R(n, r(i, "pnpm-workspace.yaml"))) || (yield* Ee(n, r(i, "package.json")))) return i;
121
+ if ((yield* z(n, r(i, ".git"))) || (yield* z(n, r(i, "pnpm-workspace.yaml"))) || (yield* Ee(n, r(i, "package.json")))) return i;
121
122
  let o = t(i);
122
123
  if (o === i) return a(e);
123
124
  i = o;
@@ -131,12 +132,12 @@ var ge = [
131
132
  }
132
133
  }), ke = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, Ae = (e, t) => f.gen(function* () {
133
134
  let n = r(t, "app.config.ts");
134
- if (!(yield* R(e, n))) return null;
135
+ if (!(yield* z(e, n))) return null;
135
136
  let i = (yield* f.tryPromise(() => import(s(n).href)).pipe(f.orElseSucceed(() => null)))?.default;
136
137
  return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(ke).filter((e) => e !== null);
137
138
  }), je = (e, t) => f.gen(function* () {
138
139
  let n = [], i = [], a = r(t, "apps");
139
- if (!(yield* R(e, a))) return {
140
+ if (!(yield* z(e, a))) return {
140
141
  apis: n,
141
142
  webs: i
142
143
  };
@@ -144,8 +145,8 @@ var ge = [
144
145
  let o = r(a, t);
145
146
  if ((yield* e.stat(o).pipe(f.orElseSucceed(() => null)))?.type === "Directory") for (let t of yield* e.readDirectory(o).pipe(f.orElseSucceed(() => []))) {
146
147
  let a = r(o, t), s = r(a, "app.config.ts");
147
- if (!(yield* R(e, s))) continue;
148
- let c = yield* z(e, s);
148
+ if (!(yield* z(e, s))) continue;
149
+ let c = yield* B(e, s);
149
150
  /type:\s*['"]web['"]/.test(c) ? i.push(a) : n.push(a);
150
151
  }
151
152
  }
@@ -258,9 +259,9 @@ Open the full reference and follow the patterns there:
258
259
  Also read the repo-root \`AGENTS.md\` for the always-true rules (browser/server
259
260
  boundary, naming, anti-patterns) before editing.
260
261
  `, Re = (e, n, r, i) => f.gen(function* () {
261
- let a = yield* R(e, n);
262
+ let a = yield* z(e, n);
262
263
  if (a) {
263
- if ((yield* z(e, n)).slice(0, we).includes("voltro:agents-md:keep")) return {
264
+ if ((yield* B(e, n)).slice(0, we).includes("voltro:agents-md:keep")) return {
264
265
  path: n,
265
266
  action: "protected"
266
267
  };
@@ -275,23 +276,23 @@ boundary, naming, anti-patterns) before editing.
275
276
  };
276
277
  }), ze = (e, t = {}) => f.gen(function* () {
277
278
  let n = yield* c.FileSystem, i = yield* De(e), o = null;
278
- for (let e of be) if (yield* R(n, r(e, "AGENTS.core.md"))) {
279
+ for (let e of R) if (yield* z(n, r(e, "AGENTS.core.md"))) {
279
280
  o = e;
280
281
  break;
281
282
  }
282
283
  if (o === null) {
283
- for (let e of be) if (yield* R(n, r(e, "AGENTS.md"))) {
284
- let a = yield* z(n, r(e, "AGENTS.md")), o = [];
284
+ for (let e of R) if (yield* z(n, r(e, "AGENTS.md"))) {
285
+ let a = yield* B(n, r(e, "AGENTS.md")), o = [];
285
286
  for (let e of Se) o.push(yield* Re(n, r(i, e), a, t.force ?? !1));
286
287
  return { files: o };
287
288
  }
288
- return yield* f.fail(xe(be.map((e) => r(e, "AGENTS.core.md"))));
289
+ return yield* f.fail(xe(R.map((e) => r(e, "AGENTS.core.md"))));
289
290
  }
290
- let s = yield* z(n, r(o, "AGENTS.core.md")), l = yield* z(n, r(o, "agent-docs", "_manifest.json")), u = l ? JSON.parse(l) : {
291
+ let s = yield* B(n, r(o, "AGENTS.core.md")), l = yield* B(n, r(o, "agent-docs", "_manifest.json")), u = l ? JSON.parse(l) : {
291
292
  modules: [],
292
293
  plugins: []
293
- }, d = (t.preferPointer ?? !1) || (yield* R(n, r(i, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), p = d ? "node_modules/@voltro/cli/templates/" : "", m = t.force ?? !1, h = Se.map((e) => r(i, e));
294
- if ((yield* f.forEach(h, (e) => z(n, e).pipe(f.map((e) => e.slice(0, we))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
294
+ }, d = (t.preferPointer ?? !1) || (yield* z(n, r(i, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), p = d ? "node_modules/@voltro/cli/templates/" : "", m = t.force ?? !1, h = Se.map((e) => r(i, e));
295
+ if ((yield* f.forEach(h, (e) => B(n, e).pipe(f.map((e) => e.slice(0, we))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
295
296
  path: e,
296
297
  action: "protected"
297
298
  })) };
@@ -310,7 +311,7 @@ boundary, naming, anti-patterns) before editing.
310
311
  let t = w.get(a(e));
311
312
  return t ? Pe(t, u, p) : "";
312
313
  }, E = (e, t) => f.forEach(Se, (i) => Re(n, r(e, i), t, m));
313
- for (let e of g) C.push(...yield* E(e, Fe.api(p, v.get(e) ?? null, T(e)))), (yield* R(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Fe.database(p)));
314
+ for (let e of g) C.push(...yield* E(e, Fe.api(p, v.get(e) ?? null, T(e)))), (yield* z(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Fe.database(p)));
314
315
  for (let e of _) C.push(...yield* E(e, Fe.web(p, T(e))));
315
316
  for (let e of Ie) C.push(yield* Re(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Le(e, p), m));
316
317
  return { files: C };
@@ -369,7 +370,7 @@ ${n.length > 0 ? n : " // (no variables declared)"}
369
370
  }
370
371
  }
371
372
  `;
372
- await j(r(e, "env.generated.d.ts"), i, "utf8");
373
+ await N(r(e, "env.generated.d.ts"), i, "utf8");
373
374
  }, Xe = async (e, t) => {
374
375
  let n = Je(t, (e) => e === "public"), i = `${Ke}
375
376
  import '@voltro/env/public'
@@ -380,7 +381,7 @@ ${n.length > 0 ? n : " // (no public variables declared)"}
380
381
  }
381
382
  }
382
383
  `, a = r(e, "src");
383
- await A(a, { recursive: !0 }), await j(r(a, "voltro-env.d.ts"), i, "utf8");
384
+ await M(a, { recursive: !0 }), await N(r(a, "voltro-env.d.ts"), i, "utf8");
384
385
  }, Ze = async (e, t) => {
385
386
  let n = `${Ke}
386
387
  import { __installPublicEnv } from '@voltro/env/public'
@@ -390,14 +391,14 @@ export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
390
391
  // Set the browser/SSR-shared global the \`publicEnv\` accessor reads.
391
392
  __installPublicEnv(publicEnvValues)
392
393
  `;
393
- await A(e, { recursive: !0 }), await j(r(e, "env.public.ts"), n, "utf8");
394
+ await M(e, { recursive: !0 }), await N(r(e, "env.public.ts"), n, "utf8");
394
395
  }, Qe = async (e) => {
395
- let t = se(e.rawEnv) ? e.rawEnv : void 0, n = await le({
396
+ let t = ie(e.rawEnv) ? e.rawEnv : void 0, n = await oe({
396
397
  contract: t,
397
- resolveSecret: k
398
- }), r = [...n.errors, ...ie(t, e.appType)];
399
- if (r.length > 0) throw Error(ae(r));
400
- oe(n.values), e.appType === "web" && ue(n.publicValues);
398
+ resolveSecret: j
399
+ }), r = [...n.errors, ...ne(t, e.appType)];
400
+ if (r.length > 0) throw Error(I(r));
401
+ re(n.values), e.appType === "web" && se(n.publicValues);
401
402
  let i = t ? Object.keys(t.vars).length : 0;
402
403
  if (i > 0) {
403
404
  let r = Object.keys(n.publicValues).length;
@@ -413,48 +414,97 @@ __installPublicEnv(publicEnvValues)
413
414
  resolved: n,
414
415
  contract: t
415
416
  };
416
- }, B = g({ scope: "vite" }), $e = /\x1b\[[0-9;]*m/g, et = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, tt = (e) => e.replace($e, "").replace(et, "").trim(), nt = /proxy error/i, rt = [
417
+ }, $e = g({ scope: "vite" }), et = /\x1b\[[0-9;]*m/g, tt = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, nt = (e) => e.replace(et, "").replace(tt, "").trim(), rt = /proxy error/i, it = [
417
418
  "ECONNREFUSED",
418
419
  "ECONNRESET",
419
420
  "ECONNABORTED",
420
421
  "EPIPE",
421
422
  "ETIMEDOUT"
422
- ], it = (e, t = 0) => {
423
+ ], at = (e, t = 0) => {
423
424
  if (e == null || t > 5) return !1;
424
425
  let n = e;
425
- return typeof n.code == "string" && rt.includes(n.code) || typeof n.message == "string" && rt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => it(e, t + 1)) ? !0 : it(n.cause, t + 1);
426
- }, at = 4e3, ot = () => {
426
+ return typeof n.code == "string" && it.includes(n.code) || typeof n.message == "string" && it.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => at(e, t + 1)) ? !0 : at(n.cause, t + 1);
427
+ }, ot = 4e3, st = () => {
427
428
  let e = /* @__PURE__ */ new Set(), t = 0, n = {
428
429
  hasWarned: !1,
429
430
  info: (e) => {
430
- let t = tt(e);
431
- t.length !== 0 && B.info(t);
431
+ let t = nt(e);
432
+ t.length !== 0 && $e.info(t);
432
433
  },
433
434
  warn: (e) => {
434
435
  n.hasWarned = !0;
435
- let t = tt(e);
436
- t.length !== 0 && B.warn(t);
436
+ let t = nt(e);
437
+ t.length !== 0 && $e.warn(t);
437
438
  },
438
439
  warnOnce: (t) => {
439
- let r = tt(t);
440
- e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && B.warn(r));
440
+ let r = nt(t);
441
+ e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && $e.warn(r));
441
442
  },
442
443
  error: (e, n) => {
443
- let r = tt(e), i = n?.error;
444
+ let r = nt(e), i = n?.error;
444
445
  if (r.length !== 0) {
445
- if (nt.test(r) && it(i)) {
446
+ if (rt.test(r) && at(i)) {
446
447
  let e = Date.now();
447
- e - t > at && (t = e, B.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
448
+ e - t > ot && (t = e, $e.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
448
449
  return;
449
450
  }
450
- B.error(r, {}, i);
451
+ $e.error(r, {}, i);
451
452
  }
452
453
  },
453
454
  clearScreen: () => {},
454
455
  hasErrorLogged: (e) => !1
455
456
  };
456
457
  return n;
457
- }, st = (e) => {
458
+ }, ct = (e = process.env) => {
459
+ let t = e.VOLTRO_DEV_SSR_COMPILE_CONCURRENCY;
460
+ if (t === void 0 || t.trim() === "") return 4;
461
+ let n = Number(t);
462
+ return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 4;
463
+ }, lt = (e) => {
464
+ let t = Math.max(1, Math.floor(e)), n = 0, r = [], i = () => n < t ? (n++, Promise.resolve()) : new Promise((e) => r.push(e)), a = () => {
465
+ let e = r.shift();
466
+ e ? e() : n--;
467
+ };
468
+ return {
469
+ withPermit: async (e) => {
470
+ await i();
471
+ try {
472
+ return await e();
473
+ } finally {
474
+ a();
475
+ }
476
+ },
477
+ get active() {
478
+ return n;
479
+ }
480
+ };
481
+ }, ut = (e) => {
482
+ let t = lt(e.limit), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
483
+ return {
484
+ load: (i, a) => {
485
+ if (r.has(i)) return a();
486
+ let o = n.get(i);
487
+ if (o) return o;
488
+ let s = t.withPermit(async () => {
489
+ e.onColdStart?.(i);
490
+ try {
491
+ return await a();
492
+ } finally {
493
+ e.onColdEnd?.(i);
494
+ }
495
+ }).then((e) => (r.add(i), e)).finally(() => {
496
+ n.delete(i);
497
+ });
498
+ return n.set(i, s), s;
499
+ },
500
+ get inFlightCount() {
501
+ return n.size;
502
+ },
503
+ get warmCount() {
504
+ return r.size;
505
+ }
506
+ };
507
+ }, dt = (e) => {
458
508
  let t = [];
459
509
  for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
460
510
  name: n.slice(5, -2),
@@ -470,7 +520,7 @@ __installPublicEnv(publicEnvValues)
470
520
  optional: !1
471
521
  });
472
522
  return t;
473
- }, ct = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), lt = async (e) => {
523
+ }, ft = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), pt = async (e) => {
474
524
  let n = a(e);
475
525
  for (let e = 0; e < 4; e++) {
476
526
  let e = r(n, "project.json");
@@ -488,8 +538,8 @@ __installPublicEnv(publicEnvValues)
488
538
  n = i;
489
539
  }
490
540
  return null;
491
- }, ut = async (t) => {
492
- let n = await lt(t);
541
+ }, mt = async (t) => {
542
+ let n = await pt(t);
493
543
  if (!n) return [];
494
544
  let { projectDir: i, manifest: a } = n, o = e(t), s = a.apps ?? {}, c = [];
495
545
  for (let [e, t] of Object.entries(s)) {
@@ -501,20 +551,20 @@ __installPublicEnv(publicEnvValues)
501
551
  let { pages: e } = await $(n);
502
552
  a = e.map((e) => ({
503
553
  pattern: e.pattern,
504
- params: st(e.pattern)
554
+ params: dt(e.pattern)
505
555
  }));
506
556
  } catch {
507
557
  continue;
508
558
  }
509
559
  c.push({
510
- key: ct(e),
560
+ key: ft(e),
511
561
  origin: `http://localhost:${t.port}`,
512
562
  ...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
513
563
  routes: a
514
564
  });
515
565
  }
516
566
  return c;
517
- }, dt = (e) => {
567
+ }, ht = (e) => {
518
568
  if (e.params.length === 0) return `'${e.pattern}'`;
519
569
  let t = e.pattern;
520
570
  for (let n of e.params) {
@@ -522,21 +572,21 @@ __installPublicEnv(publicEnvValues)
522
572
  t = t.replace(e, r);
523
573
  }
524
574
  return "`" + t + "`";
525
- }, ft = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
575
+ }, gt = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
526
576
  let t = "string";
527
577
  return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
528
- }).join("; ")} }`, pt = (e, t, n) => {
529
- let r = ft(e), i = dt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
578
+ }).join("; ")} }`, _t = (e, t, n) => {
579
+ let r = gt(e), i = ht(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
530
580
  return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
531
- }, mt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${pt(e, !1)},`).join("\n")}\n}`, ht = (e, t) => {
581
+ }, vt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${_t(e, !1)},`).join("\n")}\n}`, yt = (e, t) => {
532
582
  if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
533
- let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${pt(e, !0, i)},`);
583
+ let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${_t(e, !0, i)},`);
534
584
  return ` ${e.key}: {\n${a.join("\n")}\n },`;
535
- }, gt = async (e) => {
585
+ }, bt = async (e) => {
536
586
  let n = e.pages.map((e) => ({
537
587
  pattern: e.pattern,
538
- params: st(e.pattern)
539
- })), i = await ut(e.appRoot), a = [
588
+ params: dt(e.pattern)
589
+ })), i = await mt(e.appRoot), a = [
540
590
  "// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
541
591
  "// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
542
592
  "// Type-safe route builders consumed by <Link to={...}>.",
@@ -545,7 +595,7 @@ __installPublicEnv(publicEnvValues)
545
595
  "",
546
596
  "type EmptyParams = Record<string, never>",
547
597
  ""
548
- ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${mt(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => ht(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
598
+ ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${vt(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => yt(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
549
599
  await S.mkdir(t(c), { recursive: !0 });
550
600
  let l = null;
551
601
  try {
@@ -558,16 +608,16 @@ __installPublicEnv(publicEnvValues)
558
608
  path: c,
559
609
  wrote: !0
560
610
  });
561
- }, _t = (e) => {
562
- let t = N(e.contract), n = (e.plugins ?? []).flatMap((e) => ce(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : M, i = /* @__PURE__ */ new Set(), a = [];
611
+ }, xt = (e) => {
612
+ let t = F(e.contract), n = (e.plugins ?? []).flatMap((e) => ae(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : P, i = /* @__PURE__ */ new Set(), a = [];
563
613
  for (let e of [
564
614
  ...t,
565
615
  ...n,
566
616
  ...r
567
617
  ]) i.has(e.key) || (i.add(e.key), a.push(e));
568
618
  return a;
569
- }, vt = (e, t, n = (e) => process.env[e]) => {
570
- let r = _t(t).map((e) => {
619
+ }, St = (e, t, n = (e) => process.env[e]) => {
620
+ let r = xt(t).map((e) => {
571
621
  let t = n(e.key) !== void 0;
572
622
  return {
573
623
  ...e,
@@ -584,7 +634,7 @@ __installPublicEnv(publicEnvValues)
584
634
  missingRequired: r.filter((e) => e.required && !e.isSet && e.default === void 0).length
585
635
  }
586
636
  };
587
- }, yt = (e, t) => P(_t({
637
+ }, Ct = (e, t) => L(xt({
588
638
  ...e,
589
639
  includeFramework: !1
590
640
  }), {
@@ -594,7 +644,7 @@ __installPublicEnv(publicEnvValues)
594
644
  let t = process.env.VOLTRO_INSPECT_TOKEN;
595
645
  if (!t || t.length === 0) return { ok: !0 };
596
646
  let n = e.authorization ?? e.Authorization;
597
- return n ? n.startsWith("Bearer ") ? pe(n.slice(7).trim(), t) ? { ok: !0 } : {
647
+ return n ? n.startsWith("Bearer ") ? ue(n.slice(7).trim(), t) ? { ok: !0 } : {
598
648
  ok: !1,
599
649
  reason: "token mismatch"
600
650
  } : {
@@ -604,7 +654,7 @@ __installPublicEnv(publicEnvValues)
604
654
  ok: !1,
605
655
  reason: "missing Authorization header"
606
656
  };
607
- }, bt = (e) => {
657
+ }, wt = (e) => {
608
658
  if (!Array.isArray(e) || e.length === 0) return;
609
659
  let t = [];
610
660
  for (let n of e) {
@@ -641,10 +691,10 @@ __installPublicEnv(publicEnvValues)
641
691
  }, K = (e) => {
642
692
  let t = e.indexOf("?");
643
693
  return t === -1 ? e : e.slice(0, t);
644
- }, xt = (e) => {
694
+ }, Tt = (e) => {
645
695
  let t = e.indexOf("?");
646
696
  return t === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
647
- }, St = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), Ct = [
697
+ }, Et = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), Dt = [
648
698
  "text",
649
699
  "textarea",
650
700
  "number",
@@ -660,7 +710,7 @@ __installPublicEnv(publicEnvValues)
660
710
  "file",
661
711
  "hidden",
662
712
  "custom"
663
- ], wt = (e, t, n = []) => ({
713
+ ], Ot = (e, t, n = []) => ({
664
714
  version: 2,
665
715
  procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
666
716
  tag: e.tag,
@@ -674,7 +724,7 @@ __installPublicEnv(publicEnvValues)
674
724
  ...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
675
725
  })),
676
726
  workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
677
- widgets: Ct,
727
+ widgets: Dt,
678
728
  tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
679
729
  name: e.name,
680
730
  reactive: e.isReactive,
@@ -687,9 +737,9 @@ __installPublicEnv(publicEnvValues)
687
737
  ...e.oneOf === void 0 ? {} : { enum: e.oneOf }
688
738
  }))
689
739
  }))
690
- }), Tt = (e, t, n = {}, r = {}) => {
740
+ }), kt = (e, t, n = {}, r = {}) => {
691
741
  let i = K(e);
692
- if (!St(i)) return null;
742
+ if (!Et(i)) return null;
693
743
  let a = G(n.origin ?? n.Origin);
694
744
  if ((r.method ?? "GET").toUpperCase() === "OPTIONS") return {
695
745
  status: 204,
@@ -719,7 +769,7 @@ __installPublicEnv(publicEnvValues)
719
769
  if (i === "/_voltro/inspect/manifest") {
720
770
  if (t.kind !== "api") return W(404, { error: "manifest endpoint is api-only" }, a);
721
771
  let e = t.inspectTables?.().tables ?? [];
722
- return W(200, wt(t.rpc, t.workflows, e), a);
772
+ return W(200, Ot(t.rpc, t.workflows, e), a);
723
773
  }
724
774
  return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? W(200, [], a) : W(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? W(200, {
725
775
  subscriptions: [],
@@ -750,7 +800,7 @@ __installPublicEnv(publicEnvValues)
750
800
  error: "unknown inspect endpoint",
751
801
  path: i
752
802
  }, a);
753
- }, Et = async (e, t, n, r = {}) => {
803
+ }, At = async (e, t, n, r = {}) => {
754
804
  let i = G(t.origin ?? t.Origin);
755
805
  if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
756
806
  if ((r.method ?? "POST").toUpperCase() !== "POST") return W(405, {
@@ -784,9 +834,9 @@ __installPublicEnv(publicEnvValues)
784
834
  n !== "cookie" && (u[n] = t);
785
835
  }
786
836
  return W(200, await c(s.input, u), i);
787
- }, Dt = async (e, t, n, r, i = {}) => {
837
+ }, jt = async (e, t, n, r, i = {}) => {
788
838
  let a = K(e);
789
- if (!St(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
839
+ if (!Et(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
790
840
  let o = G(n.origin ?? n.Origin);
791
841
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
792
842
  if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
@@ -842,9 +892,9 @@ __installPublicEnv(publicEnvValues)
842
892
  message: e?.message ?? String(e)
843
893
  }, o);
844
894
  }
845
- }, Ot = async (e, t, n, r, i = {}) => {
895
+ }, Mt = async (e, t, n, r, i = {}) => {
846
896
  let a = K(e);
847
- if (!St(a)) return null;
897
+ if (!Et(a)) return null;
848
898
  let o = G(n.origin ?? n.Origin);
849
899
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
850
900
  if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
@@ -885,7 +935,7 @@ __installPublicEnv(publicEnvValues)
885
935
  message: e?.message ?? String(e)
886
936
  }, o);
887
937
  }
888
- }, kt = async (e, t, n, r = {}) => {
938
+ }, Nt = async (e, t, n, r = {}) => {
889
939
  if (K(e) !== "/_voltro/inspect/data/rows") return null;
890
940
  let i = G(n.origin ?? n.Origin);
891
941
  if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
@@ -927,7 +977,7 @@ __installPublicEnv(publicEnvValues)
927
977
  message: e?.message ?? String(e)
928
978
  }, i);
929
979
  }
930
- }, At = async (e, t, n, r = {}) => {
980
+ }, Pt = async (e, t, n, r = {}) => {
931
981
  if (K(e) !== "/_voltro/inspect/provenance") return null;
932
982
  let i = G(n.origin ?? n.Origin);
933
983
  if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
@@ -955,7 +1005,7 @@ __installPublicEnv(publicEnvValues)
955
1005
  value: c
956
1006
  }
957
1007
  })).rows[0];
958
- return W(200, ne(e, {
1008
+ return W(200, k(e, {
959
1009
  table: s,
960
1010
  id: c,
961
1011
  ...l === void 0 ? {} : { column: l }
@@ -976,7 +1026,7 @@ __installPublicEnv(publicEnvValues)
976
1026
  if (e === null || e === "") return;
977
1027
  let t = Number(e);
978
1028
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
979
- }, jt = async (e, t, n, r = {}) => {
1029
+ }, Ft = async (e, t, n, r = {}) => {
980
1030
  if (K(e) !== "/_voltro/inspect/workflows/runs") return null;
981
1031
  let i = G(n.origin ?? n.Origin);
982
1032
  if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
@@ -1010,7 +1060,7 @@ __installPublicEnv(publicEnvValues)
1010
1060
  message: e?.message ?? String(e)
1011
1061
  }, i);
1012
1062
  }
1013
- }, Mt = async (e, t, n, r, i = {}) => {
1063
+ }, It = async (e, t, n, r, i = {}) => {
1014
1064
  let a = K(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
1015
1065
  if (!a) return null;
1016
1066
  let o = decodeURIComponent(a[1] ?? ""), s = G(n.origin ?? n.Origin);
@@ -1043,7 +1093,7 @@ __installPublicEnv(publicEnvValues)
1043
1093
  message: e?.message ?? String(e)
1044
1094
  }, s);
1045
1095
  }
1046
- }, Nt = async (e, t, n, r = {}) => {
1096
+ }, Lt = async (e, t, n, r = {}) => {
1047
1097
  let i = K(e);
1048
1098
  if (!i.startsWith("/_voltro/inspect/schedules")) return null;
1049
1099
  let a = G(n.origin ?? n.Origin);
@@ -1109,7 +1159,7 @@ __installPublicEnv(publicEnvValues)
1109
1159
  error: "unknown schedules endpoint",
1110
1160
  path: i
1111
1161
  }, a);
1112
- }, Pt = async (e, t, n, r = {}) => {
1162
+ }, Rt = async (e, t, n, r = {}) => {
1113
1163
  if (K(e) !== "/_voltro/inspect/cluster") return null;
1114
1164
  let i = G(n.origin ?? n.Origin);
1115
1165
  if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
@@ -1155,7 +1205,7 @@ __installPublicEnv(publicEnvValues)
1155
1205
  message: e?.message ?? String(e)
1156
1206
  }, i);
1157
1207
  }
1158
- }, Ft = async (e, t, n, r = {}) => {
1208
+ }, zt = async (e, t, n, r = {}) => {
1159
1209
  let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
1160
1210
  if (!i) return null;
1161
1211
  let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
@@ -1179,7 +1229,7 @@ __installPublicEnv(publicEnvValues)
1179
1229
  message: e?.message ?? String(e)
1180
1230
  }, o);
1181
1231
  }
1182
- }, It = async (e, t, n, r = {}) => {
1232
+ }, Bt = async (e, t, n, r = {}) => {
1183
1233
  let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
1184
1234
  if (!i) return null;
1185
1235
  let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
@@ -1203,7 +1253,7 @@ __installPublicEnv(publicEnvValues)
1203
1253
  message: e?.message ?? String(e)
1204
1254
  }, o);
1205
1255
  }
1206
- }, Lt = async (e, t, n, r = {}) => {
1256
+ }, Vt = async (e, t, n, r = {}) => {
1207
1257
  if (K(t) !== "/_voltro/inspect/workflows/events") return null;
1208
1258
  let i = G(n.origin ?? n.Origin);
1209
1259
  if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
@@ -1223,7 +1273,7 @@ __installPublicEnv(publicEnvValues)
1223
1273
  offset: 0,
1224
1274
  limit: 100
1225
1275
  }, i);
1226
- let o = xt(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1276
+ let o = Tt(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1227
1277
  try {
1228
1278
  return W(200, await e.inspectWorkflowDomainEvents({
1229
1279
  ...s !== void 0 && s !== "" ? { name: s } : {},
@@ -1236,7 +1286,7 @@ __installPublicEnv(publicEnvValues)
1236
1286
  message: e?.message ?? String(e)
1237
1287
  }, i);
1238
1288
  }
1239
- }, Rt = async (e, t, n, r = {}) => {
1289
+ }, Ht = async (e, t, n, r = {}) => {
1240
1290
  let i = K(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
1241
1291
  if (!i) return null;
1242
1292
  let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
@@ -1260,7 +1310,7 @@ __installPublicEnv(publicEnvValues)
1260
1310
  message: e?.message ?? String(e)
1261
1311
  }, o);
1262
1312
  }
1263
- }, zt = async (e, t, n, r = {}) => {
1313
+ }, Ut = async (e, t, n, r = {}) => {
1264
1314
  if (K(e) !== "/_voltro/inspect/workflows/children") return null;
1265
1315
  let i = G(n.origin ?? n.Origin);
1266
1316
  if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
@@ -1290,7 +1340,7 @@ __installPublicEnv(publicEnvValues)
1290
1340
  message: e?.message ?? String(e)
1291
1341
  }, i);
1292
1342
  }
1293
- }, Bt = async (e, t, n, r, i = {}) => {
1343
+ }, Wt = async (e, t, n, r, i = {}) => {
1294
1344
  let a = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
1295
1345
  if (!a) return null;
1296
1346
  let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = G(n.origin ?? n.Origin);
@@ -1341,7 +1391,7 @@ __installPublicEnv(publicEnvValues)
1341
1391
  message: e?.message ?? String(e)
1342
1392
  }, c);
1343
1393
  }
1344
- }, Vt = async (e, t, n, r, i = {}) => {
1394
+ }, Gt = async (e, t, n, r, i = {}) => {
1345
1395
  if (K(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
1346
1396
  let a = G(n.origin ?? n.Origin);
1347
1397
  if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
@@ -1372,7 +1422,7 @@ __installPublicEnv(publicEnvValues)
1372
1422
  message: e?.message ?? String(e)
1373
1423
  }, a);
1374
1424
  }
1375
- }, Ht = async (e, t, n, r, i = {}) => {
1425
+ }, Kt = async (e, t, n, r, i = {}) => {
1376
1426
  let a = K(e);
1377
1427
  if (!a.startsWith("/_voltro/inspect/data/rows")) return null;
1378
1428
  let o = (i.method ?? "POST").toUpperCase();
@@ -1452,7 +1502,7 @@ __installPublicEnv(publicEnvValues)
1452
1502
  error: "method not allowed",
1453
1503
  expected: "POST | PATCH | DELETE"
1454
1504
  }, s);
1455
- }, Ut = 256, Wt = (e = Ut) => {
1505
+ }, qt = 256, Jt = (e = qt) => {
1456
1506
  let t = [], n = /* @__PURE__ */ new Set();
1457
1507
  return {
1458
1508
  emit(r, i) {
@@ -1475,27 +1525,27 @@ __installPublicEnv(publicEnvValues)
1475
1525
  return t.slice();
1476
1526
  }
1477
1527
  };
1478
- }, Gt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Kt = () => `: keep-alive ${Date.now()}\n\n`, qt = {
1528
+ }, Yt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Xt = () => `: keep-alive ${Date.now()}\n\n`, Zt = {
1479
1529
  trace: 0,
1480
1530
  debug: 1,
1481
1531
  info: 2,
1482
1532
  warn: 3,
1483
1533
  error: 4,
1484
1534
  fatal: 5
1485
- }, Jt = 2e3, Yt = 200, Xt = class {
1535
+ }, Qt = 2e3, $t = 200, en = class {
1486
1536
  capacity;
1487
1537
  buffer = [];
1488
- constructor(e = Jt) {
1538
+ constructor(e = Qt) {
1489
1539
  this.capacity = e;
1490
1540
  }
1491
1541
  append(e) {
1492
1542
  this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
1493
1543
  }
1494
1544
  query(e = {}) {
1495
- let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Yt, this.capacity), i = e.minLevel === void 0 ? qt.trace : qt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1545
+ let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? $t, this.capacity), i = e.minLevel === void 0 ? Zt.trace : Zt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1496
1546
  for (let e = this.buffer.length - 1; e >= 0 && l.length < r; e--) {
1497
1547
  let r = this.buffer[e];
1498
- r.ts < t || r.ts > n || qt[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
1548
+ r.ts < t || r.ts > n || Zt[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
1499
1549
  }
1500
1550
  return l.reverse();
1501
1551
  }
@@ -1508,7 +1558,7 @@ __installPublicEnv(publicEnvValues)
1508
1558
  clear() {
1509
1559
  this.buffer = [];
1510
1560
  }
1511
- }, Zt = null, Qt = () => (Zt === null && (Zt = new Xt()), Zt), $t = (e) => {
1561
+ }, tn = null, nn = () => (tn === null && (tn = new en()), tn), rn = (e) => {
1512
1562
  if (typeof e == "string") return e;
1513
1563
  if (e instanceof Error) return e.message;
1514
1564
  try {
@@ -1516,18 +1566,18 @@ __installPublicEnv(publicEnvValues)
1516
1566
  } catch {
1517
1567
  return String(e);
1518
1568
  }
1519
- }, en = (e) => {
1569
+ }, an = (e) => {
1520
1570
  let t = {
1521
1571
  log: console.log.bind(console),
1522
1572
  info: console.info.bind(console),
1523
1573
  warn: console.warn.bind(console),
1524
1574
  error: console.error.bind(console),
1525
1575
  debug: console.debug.bind(console)
1526
- }, n = Qt(), r = !1, i = (i) => (...a) => {
1576
+ }, n = nn(), r = !1, i = (i) => (...a) => {
1527
1577
  if (t[i](...a), !r) {
1528
1578
  r = !0;
1529
1579
  try {
1530
- let t = a.length > 0 ? $t(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = O();
1580
+ let t = a.length > 0 ? rn(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = O();
1531
1581
  e.emit("log", {
1532
1582
  level: i,
1533
1583
  message: r,
@@ -1585,24 +1635,24 @@ __installPublicEnv(publicEnvValues)
1585
1635
  return () => {
1586
1636
  console.log = t.log, console.info = t.info, console.warn = t.warn, console.error = t.error, console.debug = t.debug, a();
1587
1637
  };
1588
- }, tn = 2e3, nn = 8, rn = 1e3, an = 200, Y = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, on = (e) => {
1638
+ }, on = 2e3, sn = 8, cn = 1e3, ln = 200, Y = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, un = (e) => {
1589
1639
  switch (e) {
1590
1640
  case "error": return "error";
1591
1641
  case "warn": return "warn";
1592
1642
  case "debug": return "debug";
1593
1643
  default: return "info";
1594
1644
  }
1595
- }, sn = g({ scope: "client" }), cn = (e, t) => {
1645
+ }, dn = g({ scope: "client" }), fn = (e, t) => {
1596
1646
  let n;
1597
1647
  try {
1598
1648
  n = JSON.parse(e);
1599
1649
  } catch {
1600
- return ln(400, { error: "invalid JSON body" });
1650
+ return pn(400, { error: "invalid JSON body" });
1601
1651
  }
1602
- if (typeof n != "object" || !n) return ln(400, { error: "body must be a JSON object" });
1652
+ if (typeof n != "object" || !n) return pn(400, { error: "body must be a JSON object" });
1603
1653
  let r = n;
1604
- if (!Array.isArray(r.entries)) return ln(400, { error: "entries must be an array" });
1605
- let i = typeof r.app == "string" ? Y(r.app, 120) : void 0, a = typeof r.page == "string" ? Y(r.page, 200) : void 0, o = typeof r.ua == "string" ? Y(r.ua, 200) : void 0, s = r.entries.slice(0, an), c = 0;
1654
+ if (!Array.isArray(r.entries)) return pn(400, { error: "entries must be an array" });
1655
+ let i = typeof r.app == "string" ? Y(r.app, 120) : void 0, a = typeof r.page == "string" ? Y(r.page, 200) : void 0, o = typeof r.ua == "string" ? Y(r.ua, 200) : void 0, s = r.entries.slice(0, ln), c = 0;
1606
1656
  for (let e of s) {
1607
1657
  if (typeof e != "object" || !e) continue;
1608
1658
  let n = e;
@@ -1613,7 +1663,7 @@ __installPublicEnv(publicEnvValues)
1613
1663
  "warn",
1614
1664
  "error",
1615
1665
  "debug"
1616
- ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = Y(n.message, tn), u = Array.isArray(n.args) ? n.args.slice(0, nn).filter((e) => typeof e == "string").map((e) => Y(e, rn)) : void 0, d = typeof n.stack == "string" ? Y(n.stack, tn) : void 0;
1666
+ ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = Y(n.message, on), u = Array.isArray(n.args) ? n.args.slice(0, sn).filter((e) => typeof e == "string").map((e) => Y(e, cn)) : void 0, d = typeof n.stack == "string" ? Y(n.stack, on) : void 0;
1617
1667
  t.emit("clientLog", {
1618
1668
  ts: s,
1619
1669
  level: r,
@@ -1628,35 +1678,35 @@ __installPublicEnv(publicEnvValues)
1628
1678
  ...i === void 0 ? {} : { app: i },
1629
1679
  ...a === void 0 ? {} : { page: a },
1630
1680
  ...u !== void 0 && u.length > 0 ? { args: u } : {}
1631
- }, p = on(r);
1632
- (p === "error" || p === "warn") && d !== void 0 ? sn[p](l, f, { stack: d }) : sn[p](l, {
1681
+ }, p = un(r);
1682
+ (p === "error" || p === "warn") && d !== void 0 ? dn[p](l, f, { stack: d }) : dn[p](l, {
1633
1683
  ...f,
1634
1684
  ...d === void 0 ? {} : { stack: d }
1635
1685
  }), c++;
1636
1686
  }
1637
- return ln(202, {
1687
+ return pn(202, {
1638
1688
  accepted: c,
1639
1689
  dropped: r.entries.length - c
1640
1690
  });
1641
- }, ln = (e, t) => ({
1691
+ }, pn = (e, t) => ({
1642
1692
  status: e,
1643
1693
  contentType: "application/json; charset=utf-8",
1644
1694
  body: JSON.stringify(t)
1645
- }), un = "/_voltro/inspect/clientLog", dn = [
1695
+ }), mn = "/_voltro/inspect/clientLog", hn = [
1646
1696
  "trace",
1647
1697
  "debug",
1648
1698
  "info",
1649
1699
  "warn",
1650
1700
  "error",
1651
1701
  "fatal"
1652
- ], fn = {
1702
+ ], gn = {
1653
1703
  trace: "TRACE",
1654
1704
  debug: "DEBUG",
1655
1705
  info: "INFO ",
1656
1706
  warn: "WARN ",
1657
1707
  error: "ERROR",
1658
1708
  fatal: "FATAL"
1659
- }, pn = (e) => dn.includes(e), mn = (e, t) => {
1709
+ }, _n = (e) => hn.includes(e), vn = (e, t) => {
1660
1710
  let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = {}, a = r.get("since");
1661
1711
  if (a !== null) {
1662
1712
  let e = Number(a);
@@ -1673,7 +1723,7 @@ __installPublicEnv(publicEnvValues)
1673
1723
  Number.isFinite(e) && e > 0 && (i.max = Math.floor(e));
1674
1724
  }
1675
1725
  let c = r.get("level");
1676
- c !== null && pn(c) && (i.minLevel = c);
1726
+ c !== null && _n(c) && (i.minLevel = c);
1677
1727
  let l = r.get("source");
1678
1728
  (l === "server" || l === "client") && (i.source = l);
1679
1729
  let u = r.get("scope");
@@ -1686,7 +1736,7 @@ __installPublicEnv(publicEnvValues)
1686
1736
  if ((r.get("format") ?? "json") === "text") return {
1687
1737
  status: 200,
1688
1738
  contentType: "text/plain; charset=utf-8",
1689
- body: p.map(hn).join("\n") + (p.length > 0 ? "\n" : "")
1739
+ body: p.map(yn).join("\n") + (p.length > 0 ? "\n" : "")
1690
1740
  };
1691
1741
  let m = {
1692
1742
  capturedAt: Date.now(),
@@ -1700,34 +1750,34 @@ __installPublicEnv(publicEnvValues)
1700
1750
  contentType: "application/json; charset=utf-8",
1701
1751
  body: JSON.stringify(m)
1702
1752
  };
1703
- }, hn = (e) => {
1704
- let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s = _n(e.fields);
1705
- return `${n}:${r}:${i}.${a} ${fn[e.level]} ${o} ${e.message}${s}`;
1706
- }, gn = 80, _n = (e) => {
1753
+ }, yn = (e) => {
1754
+ let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s = xn(e.fields);
1755
+ return `${n}:${r}:${i}.${a} ${gn[e.level]} ${o} ${e.message}${s}`;
1756
+ }, bn = 80, xn = (e) => {
1707
1757
  let t = Object.entries(e);
1708
1758
  if (t.length === 0) return "";
1709
1759
  let n = [];
1710
1760
  for (let [e, r] of t) {
1711
1761
  if (r === void 0) continue;
1712
- let t = vn(r);
1762
+ let t = Sn(r);
1713
1763
  n.push(`${e}=${t}`);
1714
1764
  }
1715
1765
  return n.length > 0 ? " " + n.join(" ") : "";
1716
- }, vn = (e) => {
1766
+ }, Sn = (e) => {
1717
1767
  if (typeof e == "string") {
1718
- let t = e.length > gn ? e.slice(0, gn) + "…" : e;
1768
+ let t = e.length > bn ? e.slice(0, bn) + "…" : e;
1719
1769
  return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
1720
1770
  }
1721
1771
  if (e === null) return "null";
1722
1772
  if (typeof e == "number" || typeof e == "boolean") return String(e);
1723
1773
  try {
1724
1774
  let t = JSON.stringify(e);
1725
- return t.length > gn ? t.slice(0, gn) + "…" : t;
1775
+ return t.length > bn ? t.slice(0, bn) + "…" : t;
1726
1776
  } catch {
1727
1777
  return "[unserialisable]";
1728
1778
  }
1729
- }, yn = "/_voltro/inspect/logs", bn = g({ scope: "voltro:cli" }), xn = [], Sn = (e) => {
1730
- xn.length = 0;
1779
+ }, Cn = "/_voltro/inspect/logs", wn = g({ scope: "voltro:cli" }), Tn = [], En = (e) => {
1780
+ Tn.length = 0;
1731
1781
  let r = e[1] && !e[1].startsWith("-") ? e[1] : void 0, i = r ? n(r) ? r : a(process.cwd(), r) : process.cwd(), o = [], s = i;
1732
1782
  for (;;) {
1733
1783
  o.push(s);
@@ -1738,7 +1788,7 @@ __installPublicEnv(publicEnvValues)
1738
1788
  for (let e of o) for (let t of [".env.local", ".env"]) {
1739
1789
  let n = a(e, t);
1740
1790
  if (y(n)) {
1741
- xn.push(n);
1791
+ Tn.push(n);
1742
1792
  try {
1743
1793
  let e = C(n, "utf8");
1744
1794
  for (let t of e.split(/\r?\n/)) {
@@ -1750,15 +1800,15 @@ __installPublicEnv(publicEnvValues)
1750
1800
  (i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
1751
1801
  }
1752
1802
  } catch (e) {
1753
- bn.warn("failed to load env file (continuing)", { path: n }, e);
1803
+ wn.warn("failed to load env file (continuing)", { path: n }, e);
1754
1804
  }
1755
1805
  }
1756
1806
  }
1757
- }, Cn = 500, wn = (e, t, n = {}) => {
1807
+ }, Dn = 500, On = (e, t, n = {}) => {
1758
1808
  if (e.length === 0) return () => {};
1759
1809
  let r = (e) => n.root ? i(n.root, e) : e, a = !1, o = (e) => {
1760
1810
  a || (a = !0, t.warn(`.env changed (${r(e)}) — hard-restarting: process.env is read once at boot, a reload would keep stale values`, { file: r(e) }), Promise.resolve().then(() => n.onBeforeRestart?.()).catch((e) => t.warn(".env restart: onBeforeRestart failed (continuing)", {}, e)).finally(() => {
1761
- let e = fe(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
1811
+ let e = le(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
1762
1812
  stdio: "inherit",
1763
1813
  env: process.env,
1764
1814
  cwd: n.cwd ?? process.cwd()
@@ -1772,16 +1822,16 @@ __installPublicEnv(publicEnvValues)
1772
1822
  });
1773
1823
  }));
1774
1824
  };
1775
- for (let t of e) D(t, { interval: Cn }, (e, n) => {
1825
+ for (let t of e) D(t, { interval: Dn }, (e, n) => {
1776
1826
  e.mtimeMs !== n.mtimeMs && o(t);
1777
1827
  });
1778
1828
  return t.info("watching .env files for changes", {
1779
1829
  files: e.map(r),
1780
- intervalMs: Cn
1830
+ intervalMs: Dn
1781
1831
  }), () => {
1782
1832
  for (let t of e) ee(t);
1783
1833
  };
1784
- }, Tn = [{
1834
+ }, kn = [{
1785
1835
  match: (e) => typeof e == "string" && e.startsWith("[BABEL] Note: The code generator has deoptimised"),
1786
1836
  handle: (e, t) => {
1787
1837
  let n = e[0], r = n.match(/deoptimised the styling of (.+?) as it exceeds the max of (\d+\w*B)\.?/);
@@ -1793,13 +1843,13 @@ __installPublicEnv(publicEnvValues)
1793
1843
  });
1794
1844
  } else t.info(n);
1795
1845
  }
1796
- }], En = () => {
1846
+ }], An = () => {
1797
1847
  let e = {
1798
1848
  warn: console.warn.bind(console),
1799
1849
  error: console.error.bind(console)
1800
1850
  }, t = g({ scope: "babel" }), n = !1, r = (r) => (...i) => {
1801
1851
  if (!n) {
1802
- for (let e of Tn) if (e.match(i[0])) {
1852
+ for (let e of kn) if (e.match(i[0])) {
1803
1853
  n = !0;
1804
1854
  try {
1805
1855
  e.handle(i, t);
@@ -1814,7 +1864,50 @@ __installPublicEnv(publicEnvValues)
1814
1864
  return console.warn = r("warn"), console.error = r("error"), () => {
1815
1865
  console.warn = e.warn, console.error = e.error;
1816
1866
  };
1817
- }, Dn = () => {
1867
+ }, jn = "virtual:voltro-route-refresh", Mn = `\0${jn}`, Nn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Pn = () => "\n// GENERATED by @voltro/cli — the `voltro dev` route Fast Refresh runtime.\n\n/** Mirrors react-refresh's own `isLikelyComponentType` closely enough for the\n * decision we make with it: an uppercase-named function, or a React element\n * type object (memo / forwardRef / lazy carry `$$typeof`). */\nconst isComponentLike = (value) => {\n if (typeof value === 'function') {\n const name = value.displayName ?? value.name\n return typeof name === 'string' && /^[A-Z]/.test(name)\n }\n return typeof value === 'object' && value !== null && '$$typeof' in value\n}\n\n/** Value identity that survives module re-evaluation. A function is compared by\n * SOURCE TEXT — a re-evaluated but unedited `loader` is a brand-new object\n * with identical text — and everything else by its JSON form, so a `meta`\n * object literal does not read as changed on every edit. */\nconst stableForm = (value) => {\n if (typeof value === 'function') return 'fn:' + String(value)\n try { return 'js:' + JSON.stringify(value) } catch { return 'st:' + String(value) }\n}\n\n/** id (absolute file path, as react-refresh spells it) → export names that\n * react-refresh must NOT judge. */\nconst ignoredExports = new Map()\n\nexport const registerRouteModule = (id, moduleExports) => {\n const names = []\n for (const key of Object.keys(moduleExports)) {\n if (key === 'default') continue\n if (isComponentLike(moduleExports[key])) continue\n names.push(key)\n }\n ignoredExports.set(id, names)\n}\n\n/** The name of the first non-component export whose VALUE changed, or null when\n * this update is a pure component edit that Fast Refresh can apply in place. */\nexport const routeUpdateNeedsReload = (prevExports, nextExports) => {\n const keys = new Set([...Object.keys(prevExports), ...Object.keys(nextExports)])\n for (const key of keys) {\n if (key === 'default') continue\n const prev = prevExports[key]\n const next = nextExports[key]\n if (isComponentLike(prev) && isComponentLike(next)) continue\n if (stableForm(prev) !== stableForm(next)) return key\n }\n return null\n}\n\n// `globalThis`, not `window`: identical in the browser (which is the only place\n// this module is ever loaded) and it keeps the runtime evaluatable by the unit\n// test, which is what lets the test read the REAL source instead of a copy.\n// Chained rather than overwritten — another plugin may own the hook for its own\n// modules, and ours only answers for ids it registered.\nconst previousHook = globalThis.__getReactRefreshIgnoredExports\nglobalThis.__getReactRefreshIgnoredExports = (args) =>\n ignoredExports.get(args.id) ?? previousHook?.(args) ?? []\n", Fn = (e) => `
1868
+ if (import.meta.hot) {
1869
+ // Self-import to read our OWN exports, the same technique the react plugin
1870
+ // uses; the namespace is only complete after evaluation, hence the promise.
1871
+ import(/* @vite-ignore */ import.meta.url).then((__voltro_exports) => {
1872
+ __voltro_registerRouteModule(${JSON.stringify(e)}, __voltro_exports)
1873
+ import.meta.hot.accept((__voltro_next) => {
1874
+ if (!__voltro_next) return
1875
+ const changed = __voltro_routeUpdateNeedsReload(__voltro_exports, __voltro_next)
1876
+ if (changed === null) {
1877
+ __voltro_registerRouteModule(${JSON.stringify(e)}, __voltro_next)
1878
+ return
1879
+ }
1880
+ console.info(
1881
+ '[voltro] full reload: non-component export \`' + changed + '\` changed in ' +
1882
+ ${JSON.stringify(e)} + ' (a loader runs on the server too, so its result must be re-rendered)',
1883
+ )
1884
+ window.location.reload()
1885
+ })
1886
+ })
1887
+ }
1888
+ import {
1889
+ registerRouteModule as __voltro_registerRouteModule,
1890
+ routeUpdateNeedsReload as __voltro_routeUpdateNeedsReload,
1891
+ } from '${jn}'
1892
+ `, In = (e) => e.replace(/\\/g, "/"), Ln = (e, t) => {
1893
+ let [n = "", r] = In(e).split("?");
1894
+ if (!n.endsWith(".tsx") || r !== void 0 && Nn.test(r)) return !1;
1895
+ let i = In(t).replace(/\/$/, "");
1896
+ return n.startsWith(`${i}/`);
1897
+ }, Rn = (e, t, n) => Ln(t, n) ? `${e}${Fn(In(t).split("?")[0] ?? t)}` : null, zn = (e) => ({
1898
+ name: "voltro:route-fast-refresh",
1899
+ enforce: "pre",
1900
+ resolveId: (e) => e === "virtual:voltro-route-refresh" ? Mn : void 0,
1901
+ load: (e) => e === Mn ? Pn() : void 0,
1902
+ transform: (t, n, r) => {
1903
+ if (r?.ssr === !0) return null;
1904
+ let i = Rn(t, n, e);
1905
+ return i === null ? null : {
1906
+ code: i,
1907
+ map: null
1908
+ };
1909
+ }
1910
+ }), Bn = () => {
1818
1911
  let e = /* @__PURE__ */ new Map();
1819
1912
  return {
1820
1913
  get(t) {
@@ -1841,7 +1934,7 @@ __installPublicEnv(publicEnvValues)
1841
1934
  return Array.from(e.entries());
1842
1935
  }
1843
1936
  };
1844
- }, On = (e) => {
1937
+ }, Vn = (e) => {
1845
1938
  if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
1846
1939
  if (typeof e != "string") return null;
1847
1940
  let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
@@ -1850,17 +1943,17 @@ __installPublicEnv(publicEnvValues)
1850
1943
  if (!Number.isFinite(n) || n <= 0) return null;
1851
1944
  let r = t[2].toLowerCase();
1852
1945
  return r === "s" || r.startsWith("second") ? n * 1e3 : r === "m" || r.startsWith("minute") ? n * 6e4 : r === "h" || r.startsWith("hour") ? n * 36e5 : r === "d" || r.startsWith("day") ? n * 864e5 : null;
1853
- }, kn = (e, t = {}) => {
1946
+ }, Hn = (e, t = {}) => {
1854
1947
  let n = [e];
1855
1948
  return t.tenant !== void 0 && t.tenant !== "" && n.push(`tenant=${t.tenant}`), t.locale !== void 0 && t.locale !== "" && n.push(`lang=${t.locale}`), n.join("|");
1856
- }, An = (e, t) => e.expiresAt > t, jn = (e, t) => e.expiresAt <= t && e.servableUntil > t, Mn = r(F(), ".voltro"), Nn = r(Mn, "runtime-registry.json"), Pn = 3e4, Fn = () => {
1949
+ }, Un = (e, t) => e.expiresAt > t, Wn = (e, t) => e.expiresAt <= t && e.servableUntil > t, Gn = r(de(), ".voltro"), Kn = r(Gn, "runtime-registry.json"), qn = 3e4, Jn = () => {
1857
1950
  let e = Math.random().toString(36).slice(2, 10);
1858
- return `${Nn}.${process.pid}.${Date.now()}.${e}.tmp`;
1859
- }, In = async () => {
1860
- await S.mkdir(Mn, { recursive: !0 });
1861
- }, Ln = async () => {
1951
+ return `${Kn}.${process.pid}.${Date.now()}.${e}.tmp`;
1952
+ }, Yn = async () => {
1953
+ await S.mkdir(Gn, { recursive: !0 });
1954
+ }, Xn = async () => {
1862
1955
  try {
1863
- let e = await S.readFile(Nn, "utf8"), t = JSON.parse(e);
1956
+ let e = await S.readFile(Kn, "utf8"), t = JSON.parse(e);
1864
1957
  return t.version !== 1 || !Array.isArray(t.apps) ? {
1865
1958
  version: 1,
1866
1959
  apps: []
@@ -1871,31 +1964,31 @@ __installPublicEnv(publicEnvValues)
1871
1964
  apps: []
1872
1965
  };
1873
1966
  }
1874
- }, Rn = async (e) => {
1875
- await In();
1876
- let t = Fn();
1967
+ }, Zn = async (e) => {
1968
+ await Yn();
1969
+ let t = Jn();
1877
1970
  try {
1878
- await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, Nn);
1971
+ await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, Kn);
1879
1972
  } catch (e) {
1880
1973
  try {
1881
1974
  await S.unlink(t);
1882
1975
  } catch {}
1883
1976
  throw e;
1884
1977
  }
1885
- }, zn = (e) => {
1978
+ }, Qn = (e) => {
1886
1979
  try {
1887
1980
  return process.kill(e, 0), !0;
1888
1981
  } catch {
1889
1982
  return !1;
1890
1983
  }
1891
- }, Bn = (e) => {
1984
+ }, $n = (e) => {
1892
1985
  let t = Date.now();
1893
- return e.filter((e) => zn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < Pn : !1);
1894
- }, Vn = async () => {
1895
- let e = await Ln(), t = Bn(e.apps);
1986
+ return e.filter((e) => Qn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < qn : !1);
1987
+ }, er = async () => {
1988
+ let e = await Xn(), t = $n(e.apps);
1896
1989
  if (t.length === e.apps.length) return e;
1897
1990
  try {
1898
- await Rn({
1991
+ await Zn({
1899
1992
  version: 1,
1900
1993
  apps: t
1901
1994
  });
@@ -1904,32 +1997,32 @@ __installPublicEnv(publicEnvValues)
1904
1997
  version: 1,
1905
1998
  apps: t
1906
1999
  };
1907
- }, Hn = async (e) => {
1908
- let t = await Ln(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
2000
+ }, tr = async (e) => {
2001
+ let t = await Xn(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
1909
2002
  ...e,
1910
2003
  registeredAt: r >= 0 ? t.apps[r].registeredAt : n,
1911
2004
  heartbeatAt: n
1912
2005
  };
1913
- await Rn({
2006
+ await Zn({
1914
2007
  version: 1,
1915
2008
  apps: r >= 0 ? t.apps.map((e, t) => t === r ? i : e) : [...t.apps, i]
1916
2009
  });
1917
- }, Un = async (e) => {
2010
+ }, nr = async (e) => {
1918
2011
  try {
1919
- let t = await Ln(), n = t.apps.filter((t) => t.id !== e);
2012
+ let t = await Xn(), n = t.apps.filter((t) => t.id !== e);
1920
2013
  if (n.length === t.apps.length) return;
1921
- await Rn({
2014
+ await Zn({
1922
2015
  version: 1,
1923
2016
  apps: n
1924
2017
  });
1925
2018
  } catch {}
1926
- }, Wn = (e, t, n) => `${e}:${t}:${n}`, X = r(F(), ".voltro", "logs"), Gn = () => {
2019
+ }, rr = (e, t, n) => `${e}:${t}:${n}`, X = r(de(), ".voltro", "logs"), ir = () => {
1927
2020
  let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
1928
2021
  return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
1929
- }, Kn = !1, qn = () => {
1930
- if (Kn) return;
1931
- Kn = !0;
1932
- let e = Date.now() - Gn(), t = [];
2022
+ }, ar = !1, or = () => {
2023
+ if (ar) return;
2024
+ ar = !0;
2025
+ let e = Date.now() - ir(), t = [];
1933
2026
  try {
1934
2027
  t = w(X);
1935
2028
  } catch {
@@ -1942,8 +2035,8 @@ __installPublicEnv(publicEnvValues)
1942
2035
  T(t).mtimeMs < e && E(t);
1943
2036
  } catch {}
1944
2037
  }
1945
- }, Jn = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), Yn = (e, t) => r(X, `${Jn(e)}-${t}.log`), Xn = (e) => {
1946
- let t = Jn(e), n = [];
2038
+ }, sr = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), cr = (e, t) => r(X, `${sr(e)}-${t}.log`), lr = (e) => {
2039
+ let t = sr(e), n = [];
1947
2040
  try {
1948
2041
  n = w(X);
1949
2042
  } catch {
@@ -1960,12 +2053,12 @@ __installPublicEnv(publicEnvValues)
1960
2053
  } catch {}
1961
2054
  }
1962
2055
  return a;
1963
- }, Zn = (e) => {
2056
+ }, ur = (e) => {
1964
2057
  try {
1965
2058
  b(X, { recursive: !0 });
1966
2059
  } catch {}
1967
- qn();
1968
- let t = Yn(e, process.pid), n = x(t, "w"), r = (e) => {
2060
+ or();
2061
+ let t = cr(e, process.pid), n = x(t, "w"), r = (e) => {
1969
2062
  let t = {
1970
2063
  ts: e.ts.getTime(),
1971
2064
  level: e.level,
@@ -2006,7 +2099,7 @@ __installPublicEnv(publicEnvValues)
2006
2099
  a(), o(), process.off("exit", o), process.off("uncaughtException", s), process.off("unhandledRejection", s);
2007
2100
  }
2008
2101
  };
2009
- }, Qn = async (e, t) => {
2102
+ }, dr = async (e, t) => {
2010
2103
  let n;
2011
2104
  try {
2012
2105
  n = await S.readFile(e, "utf8");
@@ -2020,11 +2113,11 @@ __installPublicEnv(publicEnvValues)
2020
2113
  i.push(t);
2021
2114
  } catch {}
2022
2115
  return t?.max !== void 0 && i.length > t.max ? i.slice(i.length - t.max) : i;
2023
- }, $n = g({ scope: "voltro:dashboard" }), er = he(import.meta.url), tr = 5179, nr = (e) => {
2116
+ }, fr = g({ scope: "voltro:dashboard" }), pr = pe(import.meta.url), mr = 5179, hr = (e) => {
2024
2117
  let n = process.env.VOLTRO_DASHBOARD_PATH;
2025
2118
  if (n && y(r(a(n), "app.config.ts"))) return a(n);
2026
2119
  try {
2027
- let e = t(er.resolve("@voltro/dashboard/package.json"));
2120
+ let e = t(pr.resolve("@voltro/dashboard/package.json"));
2028
2121
  if (y(r(e, "app.config.ts"))) return e;
2029
2122
  } catch {}
2030
2123
  let i = r("voltro-devtools", "apps", "dashboard"), o = a(e);
@@ -2036,53 +2129,53 @@ __installPublicEnv(publicEnvValues)
2036
2129
  o = n;
2037
2130
  }
2038
2131
  return null;
2039
- }, rr = "VOLTRO_IS_DASHBOARD", ir = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2040
- let i = me({
2132
+ }, gr = "VOLTRO_IS_DASHBOARD", _r = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2133
+ let i = fe({
2041
2134
  port: e,
2042
2135
  host: t
2043
2136
  }), a = !1, o = (e) => {
2044
2137
  a || (a = !0, i.destroy(), r(e));
2045
2138
  };
2046
2139
  i.once("connect", () => o(!0)), i.once("error", () => o(!1)), setTimeout(() => o(!1), n);
2047
- }), ar = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), or = () => process.env[rr] === "1", sr = () => process.stdout.isTTY === !0, cr = r(F(), ".voltro", "dashboard-launch.lock"), lr = 1e4, ur = async () => {
2140
+ }), vr = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), yr = () => process.env[gr] === "1", br = () => process.stdout.isTTY === !0, xr = r(de(), ".voltro", "dashboard-launch.lock"), Sr = 1e4, Cr = async () => {
2048
2141
  try {
2049
- await S.mkdir(t(cr), { recursive: !0 });
2050
- let e = await S.open(cr, "wx");
2142
+ await S.mkdir(t(xr), { recursive: !0 });
2143
+ let e = await S.open(xr, "wx");
2051
2144
  return await e.write(`${process.pid}\n${Date.now()}\n`), await e.close(), !0;
2052
2145
  } catch {
2053
2146
  try {
2054
- let e = await S.stat(cr);
2055
- if (Date.now() - e.mtimeMs > lr) return await S.unlink(cr).catch(() => void 0), ur();
2147
+ let e = await S.stat(xr);
2148
+ if (Date.now() - e.mtimeMs > Sr) return await S.unlink(xr).catch(() => void 0), Cr();
2056
2149
  } catch {}
2057
2150
  return !1;
2058
2151
  }
2059
- }, dr = async () => {
2152
+ }, wr = async () => {
2060
2153
  try {
2061
- await S.unlink(cr);
2154
+ await S.unlink(xr);
2062
2155
  } catch {}
2063
- }, fr = async (e) => {
2156
+ }, Tr = async (e) => {
2064
2157
  let n = e.port ?? 5179;
2065
- if (ar()) return {
2158
+ if (vr()) return {
2066
2159
  status: "skipped",
2067
2160
  reason: "disabled by flag/env",
2068
2161
  port: n
2069
2162
  };
2070
- if (or()) return {
2163
+ if (yr()) return {
2071
2164
  status: "skipped",
2072
2165
  reason: "this process IS the dashboard",
2073
2166
  port: n
2074
2167
  };
2075
- if (!sr()) return {
2168
+ if (!br()) return {
2076
2169
  status: "skipped",
2077
2170
  reason: "stdout is not a TTY (CI/smoke)",
2078
2171
  port: n
2079
2172
  };
2080
- if (!await ur()) return {
2173
+ if (!await Cr()) return {
2081
2174
  status: "skipped",
2082
2175
  reason: "another voltro process is currently launching the dashboard",
2083
2176
  port: n
2084
2177
  };
2085
- if (await ir(n)) return await dr(), {
2178
+ if (await _r(n)) return await wr(), {
2086
2179
  status: "already-running",
2087
2180
  port: n
2088
2181
  };
@@ -2091,7 +2184,7 @@ __installPublicEnv(publicEnvValues)
2091
2184
  let e = process.argv[1];
2092
2185
  i = e && e.endsWith("/src/bin.ts") ? r(t(e), "..", "bin", "voltro.mjs") : e ?? "voltro";
2093
2186
  }
2094
- let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s = fe(process.execPath, [
2187
+ let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s = le(process.execPath, [
2095
2188
  i,
2096
2189
  o,
2097
2190
  e.dashboardAppPath
@@ -2099,7 +2192,7 @@ __installPublicEnv(publicEnvValues)
2099
2192
  stdio: "ignore",
2100
2193
  env: {
2101
2194
  ...process.env,
2102
- [rr]: "1",
2195
+ [gr]: "1",
2103
2196
  VOLTRO_DASHBOARD_PORT: String(n)
2104
2197
  }
2105
2198
  });
@@ -2107,24 +2200,120 @@ __installPublicEnv(publicEnvValues)
2107
2200
  if (s.exitCode === null && s.signalCode === null) try {
2108
2201
  s.kill("SIGTERM");
2109
2202
  } catch {}
2110
- }), $n.info(`auto-launching dashboard at http://localhost:${n}`, {
2203
+ }), fr.info(`auto-launching dashboard at http://localhost:${n}`, {
2111
2204
  port: n,
2112
2205
  mode: o,
2113
2206
  prebuilt: a
2114
- }), a || $n.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), $n.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2115
- dr();
2207
+ }), a || fr.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), fr.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2208
+ wr();
2116
2209
  }, 4e3).unref(), {
2117
2210
  status: "launched",
2118
2211
  port: n
2119
2212
  };
2120
- }, Z = g({ scope: "voltro:dev:web" }), pr = g({ scope: "vite" }), mr = await (async () => {
2213
+ }, Er = class extends Error {
2214
+ _voltroDeferral = !0;
2215
+ constructor(e) {
2216
+ super(e), this.name = "DeferralNotSupportedError";
2217
+ }
2218
+ }, Dr = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Or = (e) => {
2219
+ let { helpers: t } = e, n = t.prepareDeferredLoaderData(e.loaderData, "page"), r = {}, i = {}, a = {};
2220
+ for (let [n, o] of Object.entries(e.segmentLoaderData)) {
2221
+ let e = Number(n), s = t.prepareDeferredLoaderData(o, e);
2222
+ r[e] = s.renderData, i[e] = s.stateData, s.deferredIds && (a[e] = s.deferredIds);
2223
+ }
2224
+ let o = n.deferredIds !== void 0 || Object.keys(a).length > 0;
2225
+ if (o) try {
2226
+ t.assertDeferralSupported({
2227
+ page: e.page,
2228
+ renderMode: e.renderMode,
2229
+ interactive: e.interactive
2230
+ });
2231
+ } catch (e) {
2232
+ throw new Er(e instanceof Error ? e.message : String(e));
2233
+ }
2234
+ return {
2235
+ loaderData: n.renderData,
2236
+ segmentLoaderData: r,
2237
+ hasDeferred: o,
2238
+ stateInput: {
2239
+ loaderData: n.stateData,
2240
+ segmentLoaderData: i,
2241
+ pageLoaderRan: e.pageLoaderRan,
2242
+ ...n.deferredIds ? { deferredPageIds: n.deferredIds } : {},
2243
+ ...Object.keys(a).length > 0 ? { deferredSegmentIds: a } : {}
2244
+ }
2245
+ };
2246
+ }, kr = (e) => {
2247
+ let { helpers: t, renderInput: n } = e, { html: r, meta: i } = t.renderPageToHtml({
2248
+ ...n,
2249
+ pageSlot: !0
2250
+ });
2251
+ return {
2252
+ body: r,
2253
+ meta: i,
2254
+ stateScript: t.renderRouterStateScript({
2255
+ loaderData: null,
2256
+ segmentLoaderData: n.segmentLoaderData ?? {},
2257
+ pageLoaderRan: !1,
2258
+ pageClientOnly: !0
2259
+ })
2260
+ };
2261
+ }, Ar = "<div id=\"root\"></div>", jr = "<div id=\"root\">", Mr = "</div>", Nr = /<script\b[^>]*\btype=["']module["'][^>]*><\/script>[ \t]*\n?/gi, Pr = /\bsrc=["']([^"']+)["']/i, Fr = /<script(?![^>]*\basync\b)([^>]*\btype=["']module["'][^>]*)>/gi, Ir = (e) => {
2262
+ let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(Nr, (e) => {
2263
+ let r = Pr.exec(e)?.[1];
2264
+ return r === void 0 || t(r) ? e : (n.push(r), "");
2265
+ });
2266
+ e.inlineModuleScriptsAsync && (r = r.replace(Fr, "<script async$1>"));
2267
+ let i = r.indexOf(Ar);
2268
+ if (i === -1) throw Error(`[voltro] the generated shell has no \`${Ar}\` element, so a streamed response cannot be split around the page body. This is a framework bug unless the app overrode \`.framework/index.html\` by hand.`);
2269
+ return {
2270
+ head: `${r.slice(0, i)}${jr}`,
2271
+ tail: `${Mr}${r.slice(i + 21)}`,
2272
+ bootstrapModules: n
2273
+ };
2274
+ }, Lr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), Rr = (e) => {
2275
+ let { res: t, shell: n, htmlLang: r, headInjection: i } = e, a = null, o = !1, s = !1, c = () => {
2276
+ if (s || !o || a === null) return;
2277
+ s = !0, t.statusCode = e.statusCode ?? 200;
2278
+ for (let [n, r] of Object.entries(e.headers ?? {})) t.setHeader(n, r);
2279
+ t.flushHeaders?.(), t.write(Lr({
2280
+ head: n.head,
2281
+ headInjection: i(a.meta),
2282
+ htmlLang: r
2283
+ }));
2284
+ let c = new me();
2285
+ c.pipe(t, { end: !1 }), c.on("end", () => {
2286
+ t.end(n.tail);
2287
+ }), a.stream.pipe(c);
2288
+ }, l = () => {
2289
+ a?.stream.abort();
2290
+ };
2291
+ t.once("close", l), t.once("finish", () => {
2292
+ t.off("close", l);
2293
+ });
2294
+ try {
2295
+ a = e.render({
2296
+ bootstrapModules: n.bootstrapModules,
2297
+ onShellReady: () => {
2298
+ o = !0, c();
2299
+ },
2300
+ onShellError: (t) => {
2301
+ s || e.onShellError(t);
2302
+ }
2303
+ });
2304
+ } catch (t) {
2305
+ e.onShellError(t);
2306
+ return;
2307
+ }
2308
+ c();
2309
+ }, Z = g({ scope: "voltro:dev:web" }), zr = g({ scope: "vite" }), Br = await (async () => {
2121
2310
  try {
2122
2311
  let e = r(t(o(import.meta.url)), "..", "package.json"), n = await S.readFile(e, "utf8");
2123
2312
  return JSON.parse(n).version ?? "0.0.0";
2124
2313
  } catch {
2125
2314
  return "0.0.0";
2126
2315
  }
2127
- })(), hr = async () => {
2316
+ })(), Vr = async () => {
2128
2317
  try {
2129
2318
  let e = t(o(import.meta.url)), n = a(e, "..", "..", "devtools");
2130
2319
  if (y(r(n, "package.json"))) return n;
@@ -2133,7 +2322,7 @@ __installPublicEnv(publicEnvValues)
2133
2322
  } catch {
2134
2323
  return null;
2135
2324
  }
2136
- }, gr = (e, t) => e.disableDevtools || !t ? [] : [
2325
+ }, Hr = (e, t) => e.disableDevtools || !t ? [] : [
2137
2326
  "",
2138
2327
  "// Dev-only in-page devtools overlay. The `import.meta.env.DEV` guard is a",
2139
2328
  "// compile-time constant, so prod builds strip this whole `if` block — the",
@@ -2143,12 +2332,12 @@ __installPublicEnv(publicEnvValues)
2143
2332
  " await import('@voltro/devtools/styles.css')",
2144
2333
  " Devtools = (await import('@voltro/devtools')).VoltroDevtools",
2145
2334
  "}"
2146
- ], _r = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], vr = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], yr = (e) => e.sentry ? [
2335
+ ], Ur = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], Wr = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], Gr = (e) => e.sentry ? [
2147
2336
  "",
2148
2337
  "// Browser-side Sentry (frontend half of the deep integration). Errors +",
2149
2338
  "// browser rpc spans flow to Sentry, sharing the server transactions' trace.",
2150
2339
  `await initSentryBrowser(${JSON.stringify(e.sentry)})`
2151
- ] : [], br = (e) => e.env ? ["import './env.public'"] : [], xr = (e) => {
2340
+ ] : [], Kr = (e) => e.env ? ["import './env.public'"] : [], qr = (e) => {
2152
2341
  let n = [], i = a(e);
2153
2342
  for (;;) {
2154
2343
  y(r(i, "pnpm-workspace.yaml")) && n.push(i);
@@ -2157,19 +2346,19 @@ __installPublicEnv(publicEnvValues)
2157
2346
  i = e;
2158
2347
  }
2159
2348
  return n;
2160
- }, Sr = /* @__PURE__ */ new Set([
2349
+ }, Jr = /* @__PURE__ */ new Set([
2161
2350
  "layout.tsx",
2162
2351
  "error.tsx",
2163
2352
  "loading.tsx",
2164
2353
  "not-found.tsx"
2165
- ]), Cr = (e) => /\.(test|spec)\.tsx$/.test(e), wr = (e) => {
2354
+ ]), Yr = (e) => /\.(test|spec)\.tsx$/.test(e), Xr = (e) => {
2166
2355
  if (/\/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(?:react|react-dom|scheduler)\//.test(e)) return "react";
2167
2356
  let t = /\/([^/]+)\.island\.tsx?$/.exec(e);
2168
2357
  if (t) return `island-${t[1]}`;
2169
- }, Tr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, Er = (e) => e.startsWith("(") && e.endsWith(")"), Dr = (e) => e.filter((e) => !Er(e)), Or = (e) => {
2170
- let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !Er(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2358
+ }, Zr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, Qr = (e) => e.startsWith("(") && e.endsWith(")"), $r = (e) => e.filter((e) => !Qr(e)), ei = (e) => {
2359
+ let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !Qr(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2171
2360
  return n.length === 0 ? "/" : "/" + n.join("/");
2172
- }, kr = (e) => `${e.replace(/\.tsx$/, "").split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Index"}Page`, Q = (e, t) => e === "" ? `Root${t}` : `${e.split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Root"}${t}`, $ = async (e) => {
2361
+ }, ti = (e) => `${e.replace(/\.tsx$/, "").split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Index"}Page`, Q = (e, t) => e === "" ? `Root${t}` : `${e.split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Root"}${t}`, $ = async (e) => {
2173
2362
  let t = [], n = [], i = async (e, a) => {
2174
2363
  let o = [];
2175
2364
  try {
@@ -2177,17 +2366,17 @@ __installPublicEnv(publicEnvValues)
2177
2366
  } catch {
2178
2367
  return;
2179
2368
  }
2180
- let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Cr(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2181
- if (c.some((e) => Sr.has(e))) {
2369
+ let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Yr(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2370
+ if (c.some((e) => Jr.has(e))) {
2182
2371
  let t = l.has("layout.tsx"), i = !1;
2183
2372
  if (t) try {
2184
2373
  let t = await S.readFile(r(e, "layout.tsx"), "utf8");
2185
- i = Tr.test(t);
2374
+ i = Zr.test(t);
2186
2375
  } catch {}
2187
2376
  n.push({
2188
2377
  dir: u,
2189
2378
  chain: a,
2190
- contributesToUrl: a.length === 0 || !Er(a[a.length - 1]),
2379
+ contributesToUrl: a.length === 0 || !Qr(a[a.length - 1]),
2191
2380
  hasLayout: t,
2192
2381
  hasLayoutLoader: i,
2193
2382
  hasError: l.has("error.tsx"),
@@ -2196,12 +2385,12 @@ __installPublicEnv(publicEnvValues)
2196
2385
  });
2197
2386
  }
2198
2387
  for (let e of c) {
2199
- if (Sr.has(e)) continue;
2388
+ if (Jr.has(e)) continue;
2200
2389
  let n = u ? `${u}/${e}` : e;
2201
2390
  t.push({
2202
2391
  file: n,
2203
- pattern: Or(n),
2204
- ident: kr(n),
2392
+ pattern: ei(n),
2393
+ ident: ti(n),
2205
2394
  dirChain: a
2206
2395
  });
2207
2396
  }
@@ -2211,17 +2400,39 @@ __installPublicEnv(publicEnvValues)
2211
2400
  pages: t,
2212
2401
  dirs: n
2213
2402
  };
2214
- }, Ar = (e, t) => {
2403
+ }, ni = (e, t) => {
2215
2404
  let n = [];
2216
2405
  for (let r = 0; r <= t.length; r++) {
2217
2406
  let i = t.slice(0, r).join("/"), a = e.find((e) => e.dir === i);
2218
2407
  a && n.push(a);
2219
2408
  }
2220
2409
  return n;
2221
- }, jr = (e) => {
2222
- let t = Dr(e);
2410
+ }, ri = async (e) => {
2411
+ let { entries: t, loadLayout: n, loadError: r, loadPending: i, ctx: a } = e, o = {};
2412
+ return {
2413
+ chain: await Promise.all(t.map(async (e, t) => {
2414
+ let s = {};
2415
+ if (e.hasLayout) {
2416
+ let r = await n(e);
2417
+ s.Layout = r.default, typeof r.loader == "function" && (s.loader = r.loader, o[t] = await r.loader({
2418
+ params: a.params,
2419
+ pathname: a.pathname,
2420
+ signal: a.signal,
2421
+ headers: a.headers,
2422
+ query: a.query
2423
+ }));
2424
+ }
2425
+ return e.hasError && (s.Error = (await r(e)).default), e.hasPending && (s.Pending = (await i(e)).default), {
2426
+ id: e.dir || "/",
2427
+ ...s
2428
+ };
2429
+ })),
2430
+ segmentLoaderData: o
2431
+ };
2432
+ }, ii = (e) => {
2433
+ let t = $r(e);
2223
2434
  return t.length === 0 ? "" : "/" + t.join("/");
2224
- }, Mr = [
2435
+ }, ai = [
2225
2436
  "// Hot-reload bridge: keep SSR-injected <link rel=\"stylesheet\"> tags",
2226
2437
  "// in sync with Vite's CSS HMR. Without this, edits to .css files",
2227
2438
  "// only update the JS-injected <style> overlay; the underlying <link>",
@@ -2314,7 +2525,7 @@ __installPublicEnv(publicEnvValues)
2314
2525
  " _vdtErrorStart('Build error')",
2315
2526
  " })",
2316
2527
  "}"
2317
- ].join("\n"), Nr = (e) => {
2528
+ ].join("\n"), oi = (e) => {
2318
2529
  let t = [], n = 0, r = e.split("/").filter(Boolean), i = [];
2319
2530
  for (let e of r) e.startsWith("[[...") && e.endsWith("]]") ? (i.push("(.*)"), t.push(e.slice(5, -2)), n += 2) : e.startsWith("[...") && e.endsWith("]") ? (i.push("(.+)"), t.push(e.slice(4, -1)), n += 3) : e.startsWith("[") && e.endsWith("]") ? (i.push("([^/]+)"), t.push(e.slice(1, -1)), n += 1) : i.push(e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
2320
2531
  let a = i.join("/");
@@ -2323,8 +2534,8 @@ __installPublicEnv(publicEnvValues)
2323
2534
  paramNames: t,
2324
2535
  priority: n
2325
2536
  };
2326
- }, Pr = (e) => e.map((e) => {
2327
- let { regex: t, paramNames: n, priority: r } = Nr(e.pattern);
2537
+ }, si = (e) => e.map((e) => {
2538
+ let { regex: t, paramNames: n, priority: r } = oi(e.pattern);
2328
2539
  return {
2329
2540
  pattern: e.pattern,
2330
2541
  file: e.file,
@@ -2333,7 +2544,7 @@ __installPublicEnv(publicEnvValues)
2333
2544
  paramNames: n,
2334
2545
  priority: r
2335
2546
  };
2336
- }).slice().sort((e, t) => e.priority - t.priority), Fr = (e, t) => {
2547
+ }).slice().sort((e, t) => e.priority - t.priority), ci = (e, t) => {
2337
2548
  for (let n of t) {
2338
2549
  let t = n.regex.exec(e);
2339
2550
  if (!t) continue;
@@ -2345,7 +2556,7 @@ __installPublicEnv(publicEnvValues)
2345
2556
  };
2346
2557
  }
2347
2558
  return null;
2348
- }, Ir = async (e, n) => {
2559
+ }, li = async (e, n) => {
2349
2560
  let i = e;
2350
2561
  for (;;) {
2351
2562
  let e = r(i, "node_modules", n);
@@ -2359,7 +2570,7 @@ __installPublicEnv(publicEnvValues)
2359
2570
  if (a === i) return null;
2360
2571
  i = a;
2361
2572
  }
2362
- }, Lr = async (e) => {
2573
+ }, ui = async (e) => {
2363
2574
  try {
2364
2575
  let t = await import(s(r(e, "app.config.ts")).href), n = t.default?.port, i = typeof n == "number" ? n : 4e3, a = t.default?.transport?.wsPath, o = typeof a == "string" && a.startsWith("/") ? a : void 0;
2365
2576
  return o ? {
@@ -2368,13 +2579,13 @@ __installPublicEnv(publicEnvValues)
2368
2579
  } : { port: i };
2369
2580
  } catch {}
2370
2581
  return { port: 4e3 };
2371
- }, Rr = (e, t) => ({
2582
+ }, di = (e, t) => ({
2372
2583
  name: e,
2373
2584
  pkg: t.package,
2374
2585
  browserWsUrl: t.url,
2375
2586
  proxyTarget: void 0,
2376
2587
  ...t.headers ? { headers: t.headers } : {}
2377
- }), zr = (e, t, n) => {
2588
+ }), fi = (e, t, n) => {
2378
2589
  let r = t.transport?.wsPath ?? n.wsPath;
2379
2590
  return {
2380
2591
  name: e,
@@ -2384,7 +2595,7 @@ __installPublicEnv(publicEnvValues)
2384
2595
  ...r ? { wsPath: r } : {},
2385
2596
  ...t.headers ? { headers: t.headers } : {}
2386
2597
  };
2387
- }, Br = (e) => {
2598
+ }, pi = (e) => {
2388
2599
  let t = /* @__PURE__ */ new Map();
2389
2600
  for (let n of e) {
2390
2601
  if (n.proxyTarget === void 0) continue;
@@ -2392,19 +2603,19 @@ __installPublicEnv(publicEnvValues)
2392
2603
  if (e) throw Error(`[voltro] api ${JSON.stringify(n.name)} and ${JSON.stringify(e)} both resolve the same-origin WS path ${JSON.stringify(n.browserWsUrl)}. A custom transport.wsPath must be unique per origin (one api per origin may use a fixed path). Give each a distinct wsPath, or drop the override to use the default /ws/<name>.`);
2393
2604
  t.set(n.browserWsUrl, n.name);
2394
2605
  }
2395
- }, Vr = async (e, t) => {
2606
+ }, mi = async (e, t) => {
2396
2607
  let n = Object.entries(t.apis ?? {}), r = [];
2397
2608
  for (let [t, i] of n) {
2398
2609
  if (i.url) {
2399
- r.push(Rr(t, i));
2610
+ r.push(di(t, i));
2400
2611
  continue;
2401
2612
  }
2402
- let n = await Ir(e, i.package);
2613
+ let n = await li(e, i.package);
2403
2614
  if (!n) throw Error(`[voltro dev] api ${JSON.stringify(t)} (package ${JSON.stringify(i.package)}) is not a workspace dep and has no \`url\` set in app.config.ts. External apis need an explicit \`url\` because the framework can't discover their dev port.`);
2404
- r.push(zr(t, i, await Lr(n)));
2615
+ r.push(fi(t, i, await ui(n)));
2405
2616
  }
2406
- return Br(r), r;
2407
- }, Hr = (e) => {
2617
+ return pi(r), r;
2618
+ }, hi = (e) => {
2408
2619
  if (!e) return;
2409
2620
  let t = e.proxyTarget ?? e.browserWsUrl;
2410
2621
  if (t && !(!/^wss?:\/\//.test(t) && !/^https?:\/\//.test(t))) try {
@@ -2413,7 +2624,7 @@ __installPublicEnv(publicEnvValues)
2413
2624
  } catch {
2414
2625
  return;
2415
2626
  }
2416
- }, Ur = (e, t) => {
2627
+ }, gi = (e, t) => {
2417
2628
  if (e) return async (n, r) => {
2418
2629
  let i = {
2419
2630
  _tag: "Request",
@@ -2445,8 +2656,8 @@ __installPublicEnv(publicEnvValues)
2445
2656
  }
2446
2657
  if (l) return c;
2447
2658
  };
2448
- }, Wr = async (e, t, n, i = {}) => {
2449
- let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await hr() !== null, c = t.theme === "system" ? [
2659
+ }, _i = async (e, t, n, i = {}) => {
2660
+ let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await Vr() !== null, c = t.theme === "system" ? [
2450
2661
  " <script>",
2451
2662
  " (function () {",
2452
2663
  " var root = document.documentElement",
@@ -2487,7 +2698,7 @@ __installPublicEnv(publicEnvValues)
2487
2698
  ].join("\n"), { pages: u, dirs: d } = await $(r(e, "src", "pages")), f = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppGroup`, p = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppDescriptors`, m = n.map((e) => `import { appGroup as ${f(e.name)}, appDescriptors as ${p(e.name)} } from '${e.pkg}/rpcGroup'`), h = n.map((e) => {
2488
2699
  let t = [`group: ${f(e.name)}`];
2489
2700
  return t.push(`descriptors: ${p(e.name)}`), t.push(`wsUrl: ${JSON.stringify(e.browserWsUrl)}`), e.headers && t.push(`headers: ${JSON.stringify(e.headers)}`), ` ${JSON.stringify(e.name)}: { ${t.join(", ")} },`;
2490
- }), g, _;
2701
+ }), g, _, v;
2491
2702
  if (u.length > 0) {
2492
2703
  let e = u.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
2493
2704
  for (let e of d) {
@@ -2495,13 +2706,13 @@ __installPublicEnv(publicEnvValues)
2495
2706
  e.hasLayout && e.hasLayoutLoader ? n.push(`import * as ${Q(e.dir, "Layout")}Mod from '${t}/layout.tsx'`) : e.hasLayout && n.push(`import ${Q(e.dir, "Layout")} from '${t}/layout.tsx'`), e.hasError && n.push(`import ${Q(e.dir, "Error")} from '${t}/error.tsx'`), e.hasPending && n.push(`import ${Q(e.dir, "Pending")} from '${t}/loading.tsx'`), e.hasNotFound && n.push(`import ${Q(e.dir, "NotFound")} from '${t}/not-found.tsx'`);
2496
2707
  }
2497
2708
  let r = u.map((e) => {
2498
- let t = Ar(d, e.dirChain).map((e) => {
2709
+ let t = ni(d, e.dirChain).map((e) => {
2499
2710
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2500
2711
  return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasLayoutLoader && t.push(`loader: refs.layoutLoaders[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), e.hasPending && t.push(`Pending: refs.pendings[${n}]`), ` { ${t.join(", ")} }`;
2501
2712
  }).join(",\n");
2502
2713
  return ` makePageRoute(${JSON.stringify(e.pattern)}, ${t.length > 0 ? `[\n${t},\n ]` : "undefined"}),`;
2503
2714
  }), i = d.filter((e) => e.hasNotFound).map((e) => {
2504
- let t = jr(e.chain), n = Ar(d, e.chain).map((e) => {
2715
+ let t = ii(e.chain), n = ni(d, e.chain).map((e) => {
2505
2716
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2506
2717
  return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), ` { ${t.join(", ")} }`;
2507
2718
  }).join(",\n"), r = n.length > 0 ? `\n chain: [\n${n},\n ],` : "";
@@ -2536,35 +2747,38 @@ __installPublicEnv(publicEnvValues)
2536
2747
  kind: "page",
2537
2748
  slotKey: e.pattern
2538
2749
  });
2539
- let v = a.map((e) => ` ${JSON.stringify(e.relPath)},`), y = a.map((e, t) => {
2750
+ let y = a.map((e) => ` ${JSON.stringify(e.relPath)},`), b = a.map((e, t) => {
2540
2751
  let n = JSON.stringify(e.slotKey);
2541
2752
  return e.kind === "page" ? ` if (newMods[${t}] && refs.pages[${n}] !== undefined) { refs.pages[${n}] = newMods[${t}]; changed = true }` : ` if (newMods[${t}]?.default) { refs.${e.kind === "layout" ? "layouts" : e.kind === "error" ? "errors" : e.kind === "pending" ? "pendings" : "notFounds"}[${n}] = newMods[${t}].default;${e.kind === "layout" ? ` refs.layoutLoaders[${n}] = newMods[${t}].loader;` : ""} changed = true }`;
2542
- }), b = t.locales ?? [], x = b.length > 0, S = t.defaultLocale ?? b[0] ?? "en";
2543
- if (x && !b.includes(S)) throw Error(`[voltro dev] app.config.ts: defaultLocale '${S}' must be one of locales [${b.join(", ")}]`);
2544
- g = [
2753
+ }), x = t.locales ?? [], S = x.length > 0, C = t.defaultLocale ?? x[0] ?? "en";
2754
+ if (S && !x.includes(C)) throw Error(`[voltro dev] app.config.ts: defaultLocale '${C}' must be one of locales [${x.join(", ")}]`);
2755
+ let w = S ? [
2756
+ "import { I18nProvider } from '@voltro/i18n'",
2757
+ "import { resolveLocale } from '@voltro/i18n/server'",
2758
+ "import { useServerRequest } from '@voltro/web'",
2759
+ ...x.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
2760
+ ] : [];
2761
+ _ = [
2545
2762
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2546
2763
  "// Routes + per-page chain + not-found scopes assembled from src/pages/.",
2547
- "// Exported as a single React component so vite-plugin-react treats this file",
2548
- "// as a clean HMR boundary.",
2549
2764
  "//",
2550
- "// HMR architecture (option C server-pushed re-render with living React tree):",
2551
- "// Page + layout module references live in the `refs` registry below. The",
2552
- "// generated route array reads from `refs` on every `buildRoutes()` call",
2553
- "// never from the static imports directly. On HMR Vite delivers the new",
2554
- "// module to the multi-dep `accept` callback below, which patches the",
2555
- "// matching slot in `refs` and bumps the version counter. The `App`'s",
2556
- "// `useSyncExternalStore` subscription picks up the bump `useMemo`",
2557
- "// rebuilds the routes array Router rebuilds its compiled match → React",
2558
- "// renders with the new module without unmounting the surrounding tree.",
2765
+ "// This is a plain `.ts` module on purpose: it declares NO component, so",
2766
+ "// react-refresh never treats it as a boundary and never re-executes it on a",
2767
+ "// component edit. The mutable `refs` registry therefore OUTLIVES a refresh",
2768
+ "// of `app.tsx` a refreshed `App` keeps every already-loaded page module.",
2769
+ "//",
2770
+ "// HMR architecture (server-pushed re-render with a living React tree):",
2771
+ "// page + layout module references live in the `refs` registry below, and",
2772
+ "// the generated route array reads from `refs` on every `buildRoutes()`",
2773
+ "// call never from the static imports directly. When a route module is",
2774
+ "// NOT a valid react-refresh boundary Vite delivers the new module to the",
2775
+ "// multi-dep `accept` callback below, which patches the matching slot in",
2776
+ "// `refs` and bumps the version counter; `App`'s `useSyncExternalStore`",
2777
+ "// subscription picks up the bump → `useMemo` rebuilds the routes array →",
2778
+ "// the Router rebuilds its compiled match → React renders the new module",
2779
+ "// without unmounting the surrounding tree.",
2559
2780
  "",
2560
- "import { useMemo, useSyncExternalStore } from 'react'",
2561
- "import { Router, pageRoute, lazyPageRoute, preloadRouteModule, type PageDescriptor, type NotFoundDescriptor } from '@voltro/web'",
2562
- ...x ? [
2563
- "import { I18nProvider } from '@voltro/i18n'",
2564
- "import { resolveLocale } from '@voltro/i18n/server'",
2565
- "import { useServerRequest } from '@voltro/web'",
2566
- ...b.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
2567
- ] : [],
2781
+ "import { pageRoute, lazyPageRoute, preloadRouteModule, type PageDescriptor, type NotFoundDescriptor } from '@voltro/web'",
2568
2782
  ...n,
2569
2783
  "",
2570
2784
  "// Mutable module registry. Initial values come from the static",
@@ -2603,11 +2817,11 @@ __installPublicEnv(publicEnvValues)
2603
2817
  "",
2604
2818
  "let version = 0",
2605
2819
  "const listeners = new Set<() => void>()",
2606
- "const subscribe = (cb: () => void): (() => void) => {",
2820
+ "export const subscribe = (cb: () => void): (() => void) => {",
2607
2821
  " listeners.add(cb)",
2608
2822
  " return () => { listeners.delete(cb) }",
2609
2823
  "}",
2610
- "const getVersion = (): number => version",
2824
+ "export const getVersion = (): number => version",
2611
2825
  "const bump = (): void => {",
2612
2826
  " version++",
2613
2827
  " for (const cb of listeners) cb()",
@@ -2631,7 +2845,7 @@ __installPublicEnv(publicEnvValues)
2631
2845
  " return mod",
2632
2846
  " }, { chain })",
2633
2847
  "",
2634
- "const buildRoutes = (): PageDescriptor[] => [",
2848
+ "export const buildRoutes = (): PageDescriptor[] => [",
2635
2849
  ...r,
2636
2850
  "]",
2637
2851
  "",
@@ -2639,22 +2853,53 @@ __installPublicEnv(publicEnvValues)
2639
2853
  "// this pre-mount so the lazy page module is in `refs.pages` (→ an EAGER",
2640
2854
  "// route) for the first client render — matching the SSG/SSR-prerendered",
2641
2855
  "// HTML instead of a null leaf that would trip a hydration mismatch.",
2856
+ "//",
2857
+ "// Lives HERE and not in app.tsx: app.tsx must export the `App` component",
2858
+ "// and nothing else, or react-refresh rejects it as a boundary and every",
2859
+ "// edit in the app ends in a full page reload.",
2642
2860
  "export const preloadCurrentRoute = async (): Promise<void> => {",
2643
2861
  " if (typeof window === 'undefined') return",
2644
2862
  " await preloadRouteModule(buildRoutes(), window.location.pathname)",
2645
2863
  "}",
2646
2864
  "",
2647
- "const buildNotFounds = (): NotFoundDescriptor[] => [",
2865
+ "export const buildNotFounds = (): NotFoundDescriptor[] => [",
2648
2866
  ...i,
2649
2867
  "]",
2650
2868
  "",
2651
- ...x ? [
2652
- `// i18n auto-wiring (config.locales = [${b.map((e) => JSON.stringify(e)).join(", ")}]).`,
2869
+ "if (import.meta.hot) {",
2870
+ " import.meta.hot.accept(",
2871
+ " [",
2872
+ ...y,
2873
+ " ],",
2874
+ " (newMods: Array<Record<string, unknown> | undefined>) => {",
2875
+ " let changed = false",
2876
+ ...b,
2877
+ " if (changed) bump()",
2878
+ " },",
2879
+ " )",
2880
+ "}",
2881
+ ""
2882
+ ].join("\n"), g = [
2883
+ "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2884
+ "// The app's root component. It exports `App` and NOTHING ELSE: react-refresh",
2885
+ "// only accepts a module whose every export is a component, and a module it",
2886
+ "// rejects invalidates upward until something accepts — which for this graph",
2887
+ "// means main.tsx, which accepts nothing, i.e. a FULL PAGE RELOAD.",
2888
+ "// The route table (and the mutable module registry HMR patches) lives in",
2889
+ "// ./routeTable so that a refresh of THIS file cannot reset it.",
2890
+ "",
2891
+ "import { useMemo, useSyncExternalStore } from 'react'",
2892
+ "import { Router } from '@voltro/web'",
2893
+ ...w,
2894
+ "import { subscribe, getVersion, buildRoutes, buildNotFounds } from './routeTable'",
2895
+ "",
2896
+ ...S ? [
2897
+ `// i18n auto-wiring (config.locales = [${x.map((e) => JSON.stringify(e)).join(", ")}]).`,
2653
2898
  "const I18N_CATALOGS: Record<string, import('@voltro/i18n').MessageCatalog> = {",
2654
- ...b.map((e) => ` ${JSON.stringify(e)}: i18nCatalog_${e},`),
2899
+ ...x.map((e) => ` ${JSON.stringify(e)}: i18nCatalog_${e},`),
2655
2900
  "}",
2656
- `const I18N_SUPPORTED: ReadonlyArray<string> = [${b.map((e) => JSON.stringify(e)).join(", ")}]`,
2657
- `const I18N_DEFAULT = ${JSON.stringify(S)}`,
2901
+ `const I18N_SUPPORTED: ReadonlyArray<string> = [${x.map((e) => JSON.stringify(e)).join(", ")}]`,
2902
+ `const I18N_DEFAULT = ${JSON.stringify(C)}`,
2658
2903
  "",
2659
2904
  "const pickI18nLocale = (ssr: ReturnType<typeof useServerRequest>): string => {",
2660
2905
  " if (ssr) {",
@@ -2688,7 +2933,7 @@ __installPublicEnv(publicEnvValues)
2688
2933
  " const v = useSyncExternalStore(subscribe, getVersion, getVersion)",
2689
2934
  " const routes = useMemo(() => buildRoutes(), [v])",
2690
2935
  " const notFounds = useMemo(() => buildNotFounds(), [v])",
2691
- ...x ? [
2936
+ ...S ? [
2692
2937
  " const ssr = useServerRequest()",
2693
2938
  " const locale = pickI18nLocale(ssr)",
2694
2939
  " const messages = I18N_CATALOGS[locale] ?? I18N_CATALOGS[I18N_DEFAULT]!",
@@ -2699,33 +2944,21 @@ __installPublicEnv(publicEnvValues)
2699
2944
  " )"
2700
2945
  ] : [" return <Router routes={routes} notFounds={notFounds} />"],
2701
2946
  "}",
2702
- "",
2703
- "if (import.meta.hot) {",
2704
- " import.meta.hot.accept(",
2705
- " [",
2706
- ...v,
2707
- " ],",
2708
- " (newMods: Array<Record<string, unknown> | undefined>) => {",
2709
- " let changed = false",
2710
- ...y,
2711
- " if (changed) bump()",
2712
- " },",
2713
- " )",
2714
- "}",
2715
2947
  ""
2716
- ].join("\n"), _ = [
2948
+ ].join("\n"), v = [
2717
2949
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2718
2950
  "// Entry: imports the generated App component and calls mount() with the",
2719
2951
  "// resolved apis map. Side-effect only — no local component definitions —",
2720
2952
  "// so downstream invalidations (user page edits) terminate at app.tsx.",
2721
2953
  "",
2722
- ...br(t),
2954
+ ...Kr(t),
2723
2955
  "import { mount } from '@voltro/web'",
2724
2956
  ...m,
2725
- "import { App, preloadCurrentRoute } from './app'",
2726
- ...vr(t),
2727
- ...gr(t, s),
2728
- ...yr(t),
2957
+ "import { App } from './app'",
2958
+ "import { preloadCurrentRoute } from './routeTable'",
2959
+ ...Wr(t),
2960
+ ...Hr(t, s),
2961
+ ...Gr(t),
2729
2962
  "",
2730
2963
  "// Preload the current route's page chunk BEFORE hydration so the first",
2731
2964
  "// client render matches the SSG/SSR-prerendered HTML. Without it, a lazy",
@@ -2742,44 +2975,44 @@ __installPublicEnv(publicEnvValues)
2742
2975
  " apis: {",
2743
2976
  ...h,
2744
2977
  " },",
2745
- ..._r(t, s),
2978
+ ...Ur(t, s),
2746
2979
  "})",
2747
2980
  "",
2748
- Mr
2981
+ ai
2749
2982
  ].join("\n");
2750
- } else g = "", _ = [
2983
+ } else g = "", _ = "", v = [
2751
2984
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2752
2985
  "// The user's root component lives at ../src/App.tsx; this file imports it",
2753
2986
  "// and calls mount(). Side-effect only, no component definitions, so the",
2754
2987
  "// user's component file remains the Fast Refresh boundary.",
2755
2988
  "",
2756
- ...br(t),
2989
+ ...Kr(t),
2757
2990
  "import { mount } from '@voltro/web'",
2758
2991
  ...m,
2759
2992
  "import App from '../src/App'",
2760
- ...vr(t),
2761
- ...gr(t, s),
2762
- ...yr(t),
2993
+ ...Wr(t),
2994
+ ...Hr(t, s),
2995
+ ...Gr(t),
2763
2996
  "",
2764
2997
  "mount(App, {",
2765
2998
  " apis: {",
2766
2999
  ...h,
2767
3000
  " },",
2768
- ..._r(t, s),
3001
+ ...Ur(t, s),
2769
3002
  "})",
2770
3003
  "",
2771
- Mr
3004
+ ai
2772
3005
  ].join("\n");
2773
- let v = r(e, ".framework");
2774
- await S.mkdir(v, { recursive: !0 }), t.env ? await Ze(v, i) : await S.rm(r(v, "env.public.ts"), { force: !0 }), await S.writeFile(r(v, "index.html"), l, "utf8"), await S.writeFile(r(v, "main.tsx"), _, "utf8"), g ? await S.writeFile(r(v, "app.tsx"), g, "utf8") : await S.rm(r(v, "app.tsx"), { force: !0 });
2775
- let b = r(e, ".gitignore"), x = "";
3006
+ let b = r(e, ".framework");
3007
+ await S.mkdir(b, { recursive: !0 }), t.env ? await Ze(b, i) : await S.rm(r(b, "env.public.ts"), { force: !0 }), await S.writeFile(r(b, "index.html"), l, "utf8"), await S.writeFile(r(b, "main.tsx"), v, "utf8"), g ? (await S.writeFile(r(b, "app.tsx"), g, "utf8"), await S.writeFile(r(b, "routeTable.ts"), _, "utf8")) : (await S.rm(r(b, "app.tsx"), { force: !0 }), await S.rm(r(b, "routeTable.ts"), { force: !0 }));
3008
+ let x = r(e, ".gitignore"), C = "";
2776
3009
  try {
2777
- x = await S.readFile(b, "utf8");
3010
+ C = await S.readFile(x, "utf8");
2778
3011
  } catch {}
2779
- let C = ["/.framework/"], w = x.split("\n").filter((e) => e.trim() !== "");
2780
- for (let e of C) w.includes(e) || w.push(e);
2781
- await S.writeFile(b, w.join("\n") + "\n", "utf8");
2782
- }, Gr = async (e, n) => {
3012
+ let w = ["/.framework/"], T = C.split("\n").filter((e) => e.trim() !== "");
3013
+ for (let e of w) T.includes(e) || T.push(e);
3014
+ await S.writeFile(x, T.join("\n") + "\n", "utf8");
3015
+ }, vi = async (e, n) => {
2783
3016
  try {
2784
3017
  let i = r(t(e), "project.json");
2785
3018
  if (!y(i)) return;
@@ -2792,24 +3025,24 @@ __installPublicEnv(publicEnvValues)
2792
3025
  projectJson: i
2793
3026
  });
2794
3027
  } catch {}
2795
- }, Kr = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), qr = async (e) => {
2796
- let t = Kr(e), n = y(t) ? t : r(e, "app.config.ts");
3028
+ }, yi = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), bi = async (e) => {
3029
+ let t = yi(e), n = y(t) ? t : r(e, "app.config.ts");
2797
3030
  try {
2798
3031
  let e = (await import(s(n).href)).default;
2799
3032
  return typeof e == "object" && e && "type" in e && e.type === "web" ? e : null;
2800
3033
  } catch {
2801
3034
  return null;
2802
3035
  }
2803
- }, Jr = async (t) => {
2804
- let n = await qr(t);
3036
+ }, xi = async (t) => {
3037
+ let n = await bi(t);
2805
3038
  if (!n) return {
2806
3039
  ran: !1,
2807
3040
  exitCode: 0
2808
3041
  };
2809
- En();
2810
- let o = Wt();
2811
- en(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
2812
- let s = await Vr(t, n);
3042
+ An();
3043
+ let o = Jt();
3044
+ an(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
3045
+ let s = await mi(t, n);
2813
3046
  for (let e of s) Z.info("api wired", {
2814
3047
  name: e.name,
2815
3048
  pkg: e.pkg,
@@ -2828,13 +3061,13 @@ __installPublicEnv(publicEnvValues)
2828
3061
  log: Z,
2829
3062
  generateTypes: !0
2830
3063
  }), l = c.publicValues;
2831
- await Wr(t, n, s, l), Z.debug("generated framework entry files", { files: [
3064
+ await _i(t, n, s, l), Z.debug("generated framework entry files", { files: [
2832
3065
  "index.html",
2833
3066
  ".framework/main.tsx",
2834
3067
  ...n.env ? [".framework/env.public.ts"] : []
2835
3068
  ] });
2836
- let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f = Wn("web", d, u), p = Zn(d);
2837
- await Hn({
3069
+ let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f = rr("web", d, u), p = ur(d);
3070
+ await tr({
2838
3071
  id: f,
2839
3072
  name: d,
2840
3073
  kind: "web",
@@ -2842,14 +3075,14 @@ __installPublicEnv(publicEnvValues)
2842
3075
  pid: process.pid,
2843
3076
  status: "booting",
2844
3077
  logFile: p.path
2845
- }).catch(() => {}), await Gr(t, u);
3078
+ }).catch(() => {}), await vi(t, u);
2846
3079
  let { pages: m, dirs: h } = await $(r(t, "src", "pages")), g = h.map((e) => ({
2847
3080
  dir: e.dir,
2848
3081
  hasLayout: e.hasLayout,
2849
3082
  hasError: e.hasError,
2850
3083
  hasPending: e.hasPending,
2851
3084
  hasNotFound: e.hasNotFound
2852
- })), v = await gt({
3085
+ })), v = await bt({
2853
3086
  appRoot: t,
2854
3087
  pages: m
2855
3088
  });
@@ -2878,7 +3111,7 @@ __installPublicEnv(publicEnvValues)
2878
3111
  ...i.devDependencies
2879
3112
  });
2880
3113
  await Promise.all(a.map(async (n) => {
2881
- let i = await Ir(t, n);
3114
+ let i = await li(t, n);
2882
3115
  if (!i) return;
2883
3116
  let a = r(i, "src");
2884
3117
  try {
@@ -2887,12 +3120,12 @@ __installPublicEnv(publicEnvValues)
2887
3120
  }));
2888
3121
  } catch {}
2889
3122
  }
2890
- }, D = r(t, "src", "pages"), te = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), O = (e) => e === D || e.startsWith(D + "/"), ne = async (e) => {
3123
+ }, D = r(t, "src", "pages"), te = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), O = (e) => e === D || e.startsWith(D + "/"), k = async (e) => {
2891
3124
  try {
2892
3125
  let r = Date.now();
2893
- await Wr(t, n, s, l);
3126
+ await _i(t, n, s, l);
2894
3127
  let { pages: i } = await $(D);
2895
- await gt({
3128
+ await bt({
2896
3129
  appRoot: t,
2897
3130
  pages: i
2898
3131
  }), Z.info("page tree regenerated", {
@@ -2902,14 +3135,14 @@ __installPublicEnv(publicEnvValues)
2902
3135
  } catch (t) {
2903
3136
  Z.error("page tree regen failed", { reason: e }, t);
2904
3137
  }
2905
- }, re = {
3138
+ }, A = {
2906
3139
  name: "framework:regenerate-on-page-tree-change",
2907
3140
  configureServer(e) {
2908
3141
  let n = null, r = [], a = (e) => {
2909
3142
  r.push(e), n && clearTimeout(n), n = setTimeout(() => {
2910
3143
  n = null;
2911
3144
  let e = r.length === 1 ? r[0] : `${r.length} events (${r[0]}, …)`;
2912
- r.length = 0, ne(e);
3145
+ r.length = 0, k(e);
2913
3146
  }, 50);
2914
3147
  };
2915
3148
  e.watcher.on("add", (e) => {
@@ -2922,24 +3155,24 @@ __installPublicEnv(publicEnvValues)
2922
3155
  O(e) && a(`unlinkDir ${i(t, e)}`);
2923
3156
  });
2924
3157
  }
2925
- }, k = r(t, "app.config.ts"), A = (e) => {
2926
- if (!se(e.env)) return "";
3158
+ }, j = r(t, "app.config.ts"), M = (e) => {
3159
+ if (!ie(e.env)) return "";
2927
3160
  let t = Object.entries(e.env.vars).map(([e, t]) => `${e}:${t.access}`).sort();
2928
3161
  return `${String(e.env.publicPrefix)}|${t.join(",")}`;
2929
- }, j = (e, t) => {
3162
+ }, N = (e, t) => {
2930
3163
  let n = [];
2931
- return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"), A(e) !== A(t) && n.push("env"), n;
2932
- }, M = n, N = a(k), ie = {
3164
+ return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"), M(e) !== M(t) && n.push("env"), n;
3165
+ }, P = n, F = a(j), ne = {
2933
3166
  name: "framework:watch-app-config",
2934
3167
  async configureServer(n) {
2935
- n.watcher.add(k), Z.info("watching app.config.ts for changes", { path: i(t, k) });
3168
+ n.watcher.add(j), Z.info("watching app.config.ts for changes", { path: i(t, j) });
2936
3169
  let r = async () => {
2937
3170
  try {
2938
3171
  try {
2939
- let e = n.moduleGraph.getModuleById(k);
3172
+ let e = n.moduleGraph.getModuleById(j);
2940
3173
  e && n.moduleGraph.invalidateModule(e);
2941
3174
  } catch {}
2942
- let e = (await n.ssrLoadModule(k, { fixStacktrace: !0 })).default;
3175
+ let e = (await n.ssrLoadModule(j, { fixStacktrace: !0 })).default;
2943
3176
  return typeof e == "object" && e && "type" in e && e.type === "web" ? e : (Z.warn("app.config.ts re-load returned wrong shape", { hasDefault: e !== void 0 }), null);
2944
3177
  } catch (e) {
2945
3178
  return Z.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
@@ -2958,17 +3191,17 @@ __installPublicEnv(publicEnvValues)
2958
3191
  theme: e.theme,
2959
3192
  port: e.port,
2960
3193
  name: e.name
2961
- }), JSON.stringify(e) === JSON.stringify(M)) {
3194
+ }), JSON.stringify(e) === JSON.stringify(P)) {
2962
3195
  Z.info("app.config.ts onConfigChange: parsed config unchanged — skipping (no-op edit?)");
2963
3196
  return;
2964
3197
  }
2965
- let i = j(M, e);
3198
+ let i = N(P, e);
2966
3199
  if (i.length > 0) {
2967
3200
  Z.warn("app.config.ts changed — hard restart required", { fields: i });
2968
3201
  try {
2969
3202
  await n.close();
2970
3203
  } catch {}
2971
- let e = fe(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
3204
+ let e = le(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
2972
3205
  stdio: "inherit",
2973
3206
  env: process.env,
2974
3207
  cwd: process.cwd()
@@ -2984,7 +3217,7 @@ __installPublicEnv(publicEnvValues)
2984
3217
  }
2985
3218
  try {
2986
3219
  let r = Date.now();
2987
- await Wr(t, e, await Vr(t, e)), M = e, n.ws && n.ws.send({
3220
+ await _i(t, e, await mi(t, e)), P = e, n.ws && n.ws.send({
2988
3221
  type: "full-reload",
2989
3222
  path: "*"
2990
3223
  }), Z.info("app.config.ts soft-regen", {
@@ -2994,7 +3227,7 @@ __installPublicEnv(publicEnvValues)
2994
3227
  } catch (e) {
2995
3228
  Z.error("app.config.ts soft-regen failed", {}, e);
2996
3229
  }
2997
- }, l = (t) => e(t) === "app.config.ts" ? t === k || a(t) === N : !1;
3230
+ }, l = (t) => e(t) === "app.config.ts" ? t === j || a(t) === F : !1;
2998
3231
  n.watcher.on("change", (e) => {
2999
3232
  l(e) && (Z.info("app.config.ts change event (chokidar)", { file: e }), s());
3000
3233
  }), n.watcher.on("add", (e) => {
@@ -3002,29 +3235,29 @@ __installPublicEnv(publicEnvValues)
3002
3235
  });
3003
3236
  try {
3004
3237
  let { watchFile: e } = await import("node:fs");
3005
- e(k, { interval: 500 }, (e, t) => {
3238
+ e(j, { interval: 500 }, (e, t) => {
3006
3239
  e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), s());
3007
3240
  }), Z.info("app.config.ts polling watcher attached", { intervalMs: 500 });
3008
3241
  } catch (e) {
3009
3242
  Z.warn("app.config.ts polling watcher could not attach", {}, e);
3010
3243
  }
3011
- wn(xn, Z, {
3244
+ On(Tn, Z, {
3012
3245
  root: t,
3013
3246
  onBeforeRestart: () => n.close()
3014
3247
  });
3015
3248
  }
3016
- }, ae = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, oe = {
3249
+ }, I = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, re = {
3017
3250
  name: "framework:suppress-api-hmr",
3018
3251
  handleHotUpdate(e) {
3019
- if (ae.test(e.file)) return [];
3252
+ if (I.test(e.file)) return [];
3020
3253
  }
3021
- }, ce = {
3254
+ }, ae = {
3022
3255
  name: "framework:reoptimize-on-rpcgroup-change",
3023
3256
  async configureServer(e) {
3024
3257
  let n = /* @__PURE__ */ new Map();
3025
3258
  for (let i of s) {
3026
3259
  if (!i.proxyTarget) continue;
3027
- let a = await Ir(t, i.pkg);
3260
+ let a = await li(t, i.pkg);
3028
3261
  if (!a) continue;
3029
3262
  let o = r(a, "rpcGroup.generated.ts");
3030
3263
  try {
@@ -3067,28 +3300,28 @@ __installPublicEnv(publicEnvValues)
3067
3300
  };
3068
3301
  e.watcher.on("change", u), e.watcher.on("add", u);
3069
3302
  }
3070
- }, P = {};
3303
+ }, L = {};
3071
3304
  for (let e of s) {
3072
3305
  if (!e.proxyTarget) continue;
3073
- P[e.browserWsUrl] = {
3306
+ L[e.browserWsUrl] = {
3074
3307
  target: e.proxyTarget,
3075
3308
  ws: !0,
3076
3309
  changeOrigin: !0,
3077
3310
  ...e.wsPath ? {} : { rewrite: () => "/ws" }
3078
3311
  };
3079
3312
  let t = e.proxyTarget.replace(/^ws/, "http");
3080
- P[`/_voltro/api/${e.name}`] = {
3313
+ L[`/_voltro/api/${e.name}`] = {
3081
3314
  target: t,
3082
3315
  changeOrigin: !0,
3083
3316
  rewrite: (t) => t.replace(RegExp(`^/_voltro/api/${e.name}`), "")
3084
3317
  };
3085
3318
  }
3086
3319
  for (let [e, t] of Object.entries(n.proxies ?? {})) {
3087
- if (P[e]) {
3320
+ if (L[e]) {
3088
3321
  Z.warn("user proxy ignored — prefix already claimed by an api ws proxy", { prefix: e });
3089
3322
  continue;
3090
3323
  }
3091
- P[e] = {
3324
+ L[e] = {
3092
3325
  target: t.target,
3093
3326
  changeOrigin: t.changeOrigin ?? !0,
3094
3327
  ...t.rewrite === void 0 ? {} : { rewrite: (n) => n.replace(RegExp(`^${e}`), t.rewrite) }
@@ -3098,7 +3331,7 @@ __installPublicEnv(publicEnvValues)
3098
3331
  ...t.rewrite === void 0 ? {} : { rewrite: t.rewrite }
3099
3332
  });
3100
3333
  }
3101
- let le = {
3334
+ let oe = {
3102
3335
  name: "framework:inspect",
3103
3336
  configureServer(e) {
3104
3337
  let i = null, a = async () => {
@@ -3113,8 +3346,8 @@ __installPublicEnv(publicEnvValues)
3113
3346
  renderMode: a.renderMode ?? "static",
3114
3347
  interactive: a.interactive ?? "full",
3115
3348
  tenantAware: a.tenantAware === !0,
3116
- revalidateMs: On(a.revalidate),
3117
- staleWhileRevalidateMs: On(a.staleWhileRevalidate) ?? 0,
3349
+ revalidateMs: Vn(a.revalidate),
3350
+ staleWhileRevalidateMs: Vn(a.staleWhileRevalidate) ?? 0,
3118
3351
  cacheInvalidatesOn: Array.isArray(a.cacheInvalidatesOn) ? a.cacheInvalidatesOn : [],
3119
3352
  hasLoader: typeof a.loader == "function",
3120
3353
  hasMeta: a.meta != null,
@@ -3226,7 +3459,7 @@ __installPublicEnv(publicEnvValues)
3226
3459
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
3227
3460
  return;
3228
3461
  }
3229
- let n = mn(i, Qt());
3462
+ let n = vn(i, nn());
3230
3463
  t.statusCode = n.status, t.setHeader("content-type", n.contentType);
3231
3464
  for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
3232
3465
  t.end(n.body);
@@ -3244,7 +3477,7 @@ __installPublicEnv(publicEnvValues)
3244
3477
  e.setEncoding("utf-8"), e.on("data", (e) => {
3245
3478
  r += e;
3246
3479
  }), e.on("end", () => {
3247
- let e = cn(r, o);
3480
+ let e = fn(r, o);
3248
3481
  t.statusCode = e.status, t.setHeader("content-type", e.contentType);
3249
3482
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3250
3483
  t.end(e.body);
@@ -3275,14 +3508,14 @@ __installPublicEnv(publicEnvValues)
3275
3508
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3276
3509
  t.flushHeaders?.(), t.write("retry: 5000\n\n");
3277
3510
  let a = i.indexOf("?");
3278
- if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(Gt(e));
3511
+ if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(Yt(e));
3279
3512
  let c = o.subscribe((e) => {
3280
3513
  try {
3281
- t.write(Gt(e));
3514
+ t.write(Yt(e));
3282
3515
  } catch {}
3283
3516
  }), l = setInterval(() => {
3284
3517
  try {
3285
- t.write(Kt());
3518
+ t.write(Xt());
3286
3519
  } catch {}
3287
3520
  }, 15e3), u = () => {
3288
3521
  clearInterval(l), c();
@@ -3291,11 +3524,11 @@ __installPublicEnv(publicEnvValues)
3291
3524
  return;
3292
3525
  }
3293
3526
  try {
3294
- let o = Tt(i, {
3527
+ let o = kt(i, {
3295
3528
  kind: "web",
3296
3529
  meta: {
3297
3530
  name: n.name ?? "(unnamed)",
3298
- voltroVersion: mr,
3531
+ voltroVersion: Br,
3299
3532
  port: u,
3300
3533
  mode: "dev",
3301
3534
  apis: Object.entries(n.apis ?? {}).map(([e, t]) => {
@@ -3313,7 +3546,7 @@ __installPublicEnv(publicEnvValues)
3313
3546
  size: 0,
3314
3547
  entries: []
3315
3548
  }),
3316
- env: () => vt(n.name ?? "app", { contract: se(n.env) ? n.env : void 0 })
3549
+ env: () => St(n.name ?? "app", { contract: ie(n.env) ? n.env : void 0 })
3317
3550
  }, s, { method: e.method ?? "GET" });
3318
3551
  if (o === null) return r();
3319
3552
  t.statusCode = o.status, t.setHeader("content-type", o.contentType);
@@ -3324,37 +3557,44 @@ __installPublicEnv(publicEnvValues)
3324
3557
  }
3325
3558
  });
3326
3559
  }
3327
- }, ue = n.name === "voltroDashboard" ? {
3560
+ }, se = n.name === "voltroDashboard" ? {
3328
3561
  name: "framework:dashboard-registry",
3329
3562
  configureServer(e) {
3330
3563
  e.middlewares.use(async (e, t, n) => {
3331
3564
  if (!(e.url ?? "").startsWith("/api/dashboard/registry")) return n();
3332
3565
  try {
3333
- let e = await Vn();
3566
+ let e = await er();
3334
3567
  t.statusCode = 200, t.setHeader("content-type", "application/json; charset=utf-8"), t.end(JSON.stringify(e));
3335
3568
  } catch (e) {
3336
3569
  t.statusCode = 500, t.setHeader("content-type", "text/plain"), t.end(`registry read error: ${e.message}`);
3337
3570
  }
3338
3571
  });
3339
3572
  }
3340
- } : null, pe = Pr(m), F = /* @__PURE__ */ new Set(), me = null, he = async () => (me === null && (me = await S.readFile(r(t, ".framework", "index.html"), "utf8")), me), ge = {
3573
+ } : null, ue = si(m), de = /* @__PURE__ */ new Set(), fe = ct(), pe = ut({
3574
+ limit: fe,
3575
+ onColdStart: (e) => Z.debug("ssr cold-compile start", { id: e }),
3576
+ onColdEnd: (e) => Z.debug("ssr cold-compile end", { id: e })
3577
+ });
3578
+ Z.debug(`ssr cold-compile concurrency ${fe}`, { concurrency: fe });
3579
+ let me = null, he = async () => (me === null && (me = await S.readFile(r(t, ".framework", "index.html"), "utf8")), me), ge = {
3341
3580
  name: "framework:ssr",
3342
3581
  configureServer(e) {
3343
- e.middlewares.use(async (n, i, a) => {
3344
- if (n.method !== "GET" && n.method !== "HEAD") return a();
3345
- let o = n.url ?? "/", c = o.indexOf("?"), l = (c === -1 ? o : o.slice(0, c)) || "/";
3346
- if (l.startsWith("/@") || l.startsWith("/node_modules/") || l.startsWith("/.framework/") || l.startsWith("/_voltro/") || l === "/main.tsx" || l === "/index.html" || l === "/sw.js" || l === "/favicon.ico" || l === "/robots.txt" || /\.[a-z0-9]+$/i.test(l)) return a();
3347
- let u = Fr(l, pe);
3348
- if (!u) return a();
3349
- let d = !F.has(u.route.pattern), f = Date.now();
3350
- d && Z.info(`ssr compiling ${u.route.pattern}`, {
3351
- pattern: u.route.pattern,
3352
- pathname: l
3582
+ let n = (t) => pe.load(t, async () => await e.ssrLoadModule(t));
3583
+ e.middlewares.use(async (i, a, o) => {
3584
+ if (i.method !== "GET" && i.method !== "HEAD") return o();
3585
+ let c = i.url ?? "/", l = c.indexOf("?"), u = (l === -1 ? c : c.slice(0, l)) || "/";
3586
+ if (u.startsWith("/@") || u.startsWith("/node_modules/") || u.startsWith("/.framework/") || u.startsWith("/_voltro/") || u === "/main.tsx" || u === "/index.html" || u === "/sw.js" || u === "/favicon.ico" || u === "/robots.txt" || /\.[a-z0-9]+$/i.test(u)) return o();
3587
+ let d = ci(u, ue);
3588
+ if (!d) return o();
3589
+ let f = !de.has(d.route.pattern), p = Date.now();
3590
+ f && Z.info(`ssr compiling ${d.route.pattern}`, {
3591
+ pattern: d.route.pattern,
3592
+ pathname: u
3353
3593
  });
3354
- let p = {}, m = async (e, t) => {
3594
+ let m = {}, g = async (e, t) => {
3355
3595
  let n = Date.now(), r = await t();
3356
- return p[e] = (p[e] ?? 0) + (Date.now() - n), r;
3357
- }, g = async (t, n, r) => {
3596
+ return m[e] = (m[e] ?? 0) + (Date.now() - n), r;
3597
+ }, _ = async (t, n, r) => {
3358
3598
  let i = await e.moduleGraph.getModuleById(t);
3359
3599
  if (!(!i || n.has(t))) {
3360
3600
  if (n.add(t), i.id && /\.(css|sass|scss|less|stylus|pcss|postcss)(\?|$)/.test(i.id)) {
@@ -3362,110 +3602,178 @@ __installPublicEnv(publicEnvValues)
3362
3602
  r.includes(e) || r.push(e);
3363
3603
  return;
3364
3604
  }
3365
- for (let e of i.importedModules ?? []) e.id && await g(e.id, n, r);
3605
+ for (let e of i.importedModules ?? []) e.id && await _(e.id, n, r);
3366
3606
  }
3367
3607
  };
3368
3608
  try {
3369
- let c = await m("loadPage", async () => await e.ssrLoadModule(r(t, "src", "pages", u.route.file))), _ = c.renderMode ?? "static";
3370
- if (_ !== "ssr" && _ !== "isr") return a();
3371
- let v = Ar(h, u.route.dirChain), y = await m("loadChain", () => Promise.all(v.map(async (n) => {
3372
- let i = {};
3373
- return n.hasLayout && (i.Layout = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "layout.tsx"))).default), n.hasError && (i.Error = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "error.tsx"))).default), n.hasPending && (i.Pending = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "loading.tsx"))).default), {
3374
- id: n.dir || "/",
3375
- ...i
3376
- };
3377
- }))), b = {};
3378
- for (let [e, t] of Object.entries(n.headers ?? {})) typeof t == "string" ? b[e] = t : Array.isArray(t) && (b[e] = t.join(", "));
3379
- let x = Ur(Hr(s[0]), b.cookie), S = null, C = c.loader;
3380
- if (typeof C == "function") {
3381
- let e = new AbortController(), t = () => e.abort();
3382
- i.once("close", t);
3383
- try {
3384
- S = await m("loader", () => C({
3385
- params: u.params,
3386
- pathname: l,
3387
- signal: e.signal,
3388
- headers: b,
3389
- query: x
3390
- }));
3391
- } finally {
3392
- i.off("close", t);
3393
- }
3609
+ let l = await g("loadPage", async () => await n(r(t, "src", "pages", d.route.file))), v = l.renderMode ?? "static", y = ni(h, d.route.dirChain), b = v === "spa" && y.some((e) => e.hasLayout);
3610
+ if (v !== "ssr" && v !== "isr" && !b) return o();
3611
+ let x = {};
3612
+ for (let [e, t] of Object.entries(i.headers ?? {})) typeof t == "string" ? x[e] = t : Array.isArray(t) && (x[e] = t.join(", "));
3613
+ let S = gi(hi(s[0]), x.cookie), C = new AbortController(), w = () => C.abort();
3614
+ a.once("close", w);
3615
+ let T = null, E = [], ee = {};
3616
+ try {
3617
+ ({chain: E, segmentLoaderData: ee} = await g("loadChain", () => ri({
3618
+ entries: y,
3619
+ loadLayout: (e) => n(r(t, "src", "pages", e.dir, "layout.tsx")),
3620
+ loadError: (e) => n(r(t, "src", "pages", e.dir, "error.tsx")),
3621
+ loadPending: (e) => n(r(t, "src", "pages", e.dir, "loading.tsx")),
3622
+ ctx: {
3623
+ params: d.params,
3624
+ pathname: u,
3625
+ signal: C.signal,
3626
+ headers: x,
3627
+ query: S
3628
+ }
3629
+ })));
3630
+ let e = l.loader;
3631
+ typeof e == "function" && !b && (T = await g("loader", () => e({
3632
+ params: d.params,
3633
+ pathname: u,
3634
+ signal: C.signal,
3635
+ headers: x,
3636
+ query: S
3637
+ })));
3638
+ } finally {
3639
+ a.off("close", w);
3394
3640
  }
3395
- let w = await m("loadSsrHelpers", async () => await e.ssrLoadModule("@voltro/web/ssr")), T = {
3396
- pattern: u.route.pattern,
3397
- Component: c.default,
3398
- meta: c.meta,
3399
- loader: c.loader,
3400
- ErrorBoundary: c.ErrorBoundary,
3401
- Pending: c.Pending,
3402
- renderMode: _,
3403
- chain: y
3404
- }, E = {
3405
- cookies: w.parseCookieHeader(b.cookie),
3406
- headers: b,
3407
- url: o
3408
- }, ee = Date.now(), { html: D, meta: te } = w.renderPageToHtml({
3409
- descriptor: T,
3410
- params: u.params,
3411
- pathname: l,
3412
- loaderData: S,
3413
- requestContext: E
3414
- });
3415
- p.render = Date.now() - ee;
3416
- let O = c.interactive ?? "full", ne = [];
3417
- await m("collectCss", async () => {
3641
+ let D = await g("loadSsrHelpers", async () => await n("@voltro/web/ssr")), te = {
3642
+ pattern: d.route.pattern,
3643
+ Component: l.default,
3644
+ meta: l.meta,
3645
+ loader: l.loader,
3646
+ ErrorBoundary: l.ErrorBoundary,
3647
+ Pending: l.Pending,
3648
+ renderMode: v,
3649
+ chain: E
3650
+ }, O = {
3651
+ cookies: D.parseCookieHeader(x.cookie),
3652
+ headers: x,
3653
+ url: c
3654
+ }, k = l.interactive ?? "full", A = b ? null : Or({
3655
+ helpers: D,
3656
+ page: `src/pages/${d.route.file}`,
3657
+ renderMode: v,
3658
+ interactive: k,
3659
+ loaderData: T,
3660
+ segmentLoaderData: ee,
3661
+ pageLoaderRan: typeof l.loader == "function"
3662
+ }), j = [];
3663
+ await g("collectCss", async () => {
3418
3664
  let e = /* @__PURE__ */ new Set(), n = [
3419
- r(t, "src", "pages", u.route.file),
3420
- ...v.flatMap((e) => [
3665
+ r(t, "src", "pages", d.route.file),
3666
+ ...y.flatMap((e) => [
3421
3667
  ...e.hasLayout ? [r(t, "src", "pages", e.dir, "layout.tsx")] : [],
3422
3668
  ...e.hasError ? [r(t, "src", "pages", e.dir, "error.tsx")] : [],
3423
3669
  ...e.hasPending ? [r(t, "src", "pages", e.dir, "loading.tsx")] : []
3424
3670
  ]),
3425
3671
  r(t, ".framework", "main.tsx")
3426
3672
  ];
3427
- for (let t of n) await g(t, e, ne);
3673
+ for (let t of n) await _(t, e, j);
3428
3674
  });
3429
- let re = await m("readShell", he), k = await m("transformShell", () => e.transformIndexHtml(o, re)), A = [
3430
- ne.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "),
3431
- w.renderMetaToHtml(te),
3432
- `<meta name="voltro-interactive" content="${O}" />`,
3433
- `<script type="application/json" id="__voltro_state__">${w.serialiseStateForInlining(S)}<\/script>`
3434
- ].filter((e) => e.length > 0).join("\n "), j = E.cookies["voltro:locale"], M = k.replace("<div id=\"root\"></div>", `<div id="root">${D}</div>`).replace("</head>", ` ${A}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, j ? `<html lang="${j}"` : "<html lang=\"en\"");
3435
- i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "ssr-dev"), i.end(M);
3436
- let N = Date.now() - f;
3437
- d ? (F.add(u.route.pattern), Z.info(`ssr compiled ${u.route.pattern} in ${N}ms`, {
3438
- pattern: u.route.pattern,
3439
- pathname: l,
3440
- elapsedMs: N,
3675
+ let M = await g("readShell", he), N = await g("transformShell", () => e.transformIndexHtml(c, M)), P = j.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), F = O.cookies["voltro:locale"] ?? "en", ne = Date.now();
3676
+ if (b) {
3677
+ let e = kr({
3678
+ helpers: D,
3679
+ renderInput: {
3680
+ descriptor: te,
3681
+ params: d.params,
3682
+ pathname: u,
3683
+ segmentLoaderData: ee,
3684
+ requestContext: O
3685
+ }
3686
+ }), t = [
3687
+ P,
3688
+ D.renderMetaToHtml(e.meta),
3689
+ `<meta name="voltro-interactive" content="${k}" />`,
3690
+ e.stateScript
3691
+ ].filter((e) => e.length > 0).join("\n "), n = N.replace("<div id=\"root\"></div>", `<div id="root">${e.body}</div>`).replace("</head>", ` ${t}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${F}"`);
3692
+ a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "spa-shell-dev"), a.end(n);
3693
+ } else if (A) {
3694
+ let e = (e) => [
3695
+ P,
3696
+ D.renderMetaToHtml(e),
3697
+ `<meta name="voltro-interactive" content="${k}" />`,
3698
+ ...A.hasDeferred ? [D.renderDeferredRegistryScript()] : [],
3699
+ D.renderRouterStateScript(A.stateInput)
3700
+ ].filter((e) => e.length > 0).join("\n "), t = {
3701
+ descriptor: te,
3702
+ params: d.params,
3703
+ pathname: u,
3704
+ loaderData: A.loaderData,
3705
+ segmentLoaderData: A.segmentLoaderData,
3706
+ requestContext: O
3707
+ };
3708
+ if (v === "ssr" && k === "full") Rr({
3709
+ res: a,
3710
+ shell: Ir({
3711
+ shell: N,
3712
+ inlineModuleScriptsAsync: !0
3713
+ }),
3714
+ htmlLang: F,
3715
+ headers: {
3716
+ "content-type": "text/html; charset=utf-8",
3717
+ "x-voltro-rendered-by": "ssr-dev"
3718
+ },
3719
+ headInjection: e,
3720
+ render: (e) => D.renderPageToStream({
3721
+ ...t,
3722
+ ...e
3723
+ }),
3724
+ onShellError: (e) => {
3725
+ Z.warn("ssr-dev shell render failed; falling back to SPA shell", {
3726
+ pathname: u,
3727
+ pattern: d.route.pattern
3728
+ }, e), o();
3729
+ }
3730
+ });
3731
+ else {
3732
+ let { html: n, meta: r } = D.renderPageToHtml(t), i = N.replace("<div id=\"root\"></div>", `<div id="root">${n}</div>`).replace("</head>", ` ${e(r)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${F}"`);
3733
+ a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "ssr-dev"), a.end(i);
3734
+ }
3735
+ }
3736
+ m.render = Date.now() - ne;
3737
+ let I = Date.now() - p;
3738
+ f ? (de.add(d.route.pattern), Z.info(`ssr compiled ${d.route.pattern} in ${I}ms`, {
3739
+ pattern: d.route.pattern,
3740
+ pathname: u,
3741
+ elapsedMs: I,
3441
3742
  cold: !0,
3442
- phases: p
3443
- })) : N > 200 && Z.info(`ssr rendered ${l} in ${N}ms`, {
3444
- pattern: u.route.pattern,
3445
- pathname: l,
3446
- elapsedMs: N,
3743
+ phases: m
3744
+ })) : I > 200 && Z.info(`ssr rendered ${u} in ${I}ms`, {
3745
+ pattern: d.route.pattern,
3746
+ pathname: u,
3747
+ elapsedMs: I,
3447
3748
  cold: !1,
3448
- phases: p
3749
+ phases: m
3449
3750
  });
3450
3751
  } catch (e) {
3752
+ if (Dr(e)) {
3753
+ Z.error("ssr-dev render refused", {
3754
+ pathname: u,
3755
+ pattern: d.route.pattern
3756
+ }, e), a.statusCode = 500, a.setHeader("content-type", "text/plain; charset=utf-8"), a.end(e.message);
3757
+ return;
3758
+ }
3451
3759
  Z.warn("ssr-dev render failed; falling back to SPA shell", {
3452
- pathname: l,
3453
- pattern: u.route.pattern
3454
- }, e), a();
3760
+ pathname: u,
3761
+ pattern: d.route.pattern
3762
+ }, e), o();
3455
3763
  }
3456
3764
  });
3457
3765
  }
3458
- }, I = Date.now(), _e = b.version ?? "?", ve = await hr(), ye = r(t, "node_modules", "@voltro", "ui-shadcn"), L = y(r(ye, "package.json")) ? ye : null, be = [], xe = await (async () => {
3766
+ }, _e = Date.now(), ve = b.version ?? "?", ye = await Vr(), be = r(t, "node_modules", "@voltro", "ui-shadcn"), R = y(r(be, "package.json")) ? be : null, xe = [], Se = await (async () => {
3459
3767
  let e = [];
3460
3768
  for (let n of s) {
3461
3769
  if (!n.proxyTarget) continue;
3462
- let i = await Ir(t, n.pkg);
3770
+ let i = await li(t, n.pkg);
3463
3771
  if (i) try {
3464
3772
  e.push(await S.readFile(r(i, "rpcGroup.generated.ts"), "utf8"));
3465
3773
  } catch {}
3466
3774
  }
3467
3775
  if (e.length === 0) return !1;
3468
- let n = de("sha1").update(e.join("\0")).digest("hex"), i = r(w, ".voltro-rpcgroup-optimize"), a = "";
3776
+ let n = ce("sha1").update(e.join("\0")).digest("hex"), i = r(w, ".voltro-rpcgroup-optimize"), a = "";
3469
3777
  try {
3470
3778
  a = (await S.readFile(i, "utf8")).trim();
3471
3779
  } catch {}
@@ -3475,72 +3783,73 @@ __installPublicEnv(publicEnvValues)
3475
3783
  } catch {}
3476
3784
  return !0;
3477
3785
  })();
3478
- xe && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3786
+ Se && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3479
3787
  root: w,
3480
3788
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3481
3789
  ssr: { noExternal: ["react-intl"] },
3482
3790
  resolve: {
3483
3791
  dedupe: ["react", "react-dom"],
3484
3792
  alias: [
3485
- ...ve ? [{
3793
+ ...ye ? [{
3486
3794
  find: "@voltro/devtools/styles.css",
3487
- replacement: r(ve, "src/styles.css")
3795
+ replacement: r(ye, "src/styles.css")
3488
3796
  }, {
3489
3797
  find: "@voltro/devtools",
3490
- replacement: r(ve, "src/index.ts")
3798
+ replacement: r(ye, "src/index.ts")
3491
3799
  }] : [],
3492
- ...L ? [
3800
+ ...R ? [
3493
3801
  {
3494
3802
  find: "@voltro/ui-shadcn/tokens.css",
3495
- replacement: r(L, "src/tokens.css")
3803
+ replacement: r(R, "src/tokens.css")
3496
3804
  },
3497
3805
  {
3498
3806
  find: "@voltro/ui-shadcn/cn",
3499
- replacement: r(L, "src/cn.ts")
3807
+ replacement: r(R, "src/cn.ts")
3500
3808
  },
3501
3809
  {
3502
3810
  find: "@voltro/ui-shadcn/brand",
3503
- replacement: r(L, "src/brand/voltroLogo.tsx")
3811
+ replacement: r(R, "src/brand/voltroLogo.tsx")
3504
3812
  },
3505
3813
  {
3506
3814
  find: "@voltro/ui-shadcn",
3507
- replacement: r(L, "src/index.ts")
3815
+ replacement: r(R, "src/index.ts")
3508
3816
  }
3509
3817
  ] : [],
3510
3818
  ...Ue(t)
3511
3819
  ]
3512
3820
  },
3513
3821
  optimizeDeps: {
3514
- include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...be],
3515
- force: xe
3822
+ include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...xe],
3823
+ force: Se
3516
3824
  },
3517
- customLogger: ot(),
3825
+ customLogger: st(),
3518
3826
  plugins: [
3827
+ zn(r(t, "src", "pages")),
3519
3828
  x(),
3520
3829
  C(),
3521
3830
  ee,
3831
+ A,
3832
+ ne,
3522
3833
  re,
3523
- ie,
3834
+ ae,
3524
3835
  oe,
3525
- ce,
3526
- le,
3527
3836
  ge,
3528
- ...ue ? [ue] : []
3837
+ ...se ? [se] : []
3529
3838
  ],
3530
3839
  server: {
3531
3840
  port: u,
3532
3841
  strictPort: !0,
3533
3842
  host: !0,
3534
3843
  allowedHosts: n.allowedHosts === !0 || [...n.allowedHosts ?? []],
3535
- proxy: P,
3536
- fs: { allow: [t, ...xr(t)] }
3844
+ proxy: L,
3845
+ fs: { allow: [t, ...qr(t)] }
3537
3846
  },
3538
3847
  appType: "spa",
3539
3848
  cacheDir: r(w, ".vite"),
3540
3849
  publicDir: r(t, "public")
3541
- })).listen(), pr.info(`v${_e} ready in ${Date.now() - I}ms`, {
3542
- version: _e,
3543
- bootMs: Date.now() - I
3850
+ })).listen(), zr.info(`v${ve} ready in ${Date.now() - _e}ms`, {
3851
+ version: ve,
3852
+ bootMs: Date.now() - _e
3544
3853
  }), Z.info(`listening on http://localhost:${u}`, {
3545
3854
  port: u,
3546
3855
  app: n.name ?? "(unnamed)"
@@ -3550,7 +3859,7 @@ __installPublicEnv(publicEnvValues)
3550
3859
  target: e.proxyTarget
3551
3860
  }), Z.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
3552
3861
  try {
3553
- await Hn({
3862
+ await tr({
3554
3863
  id: f,
3555
3864
  name: d,
3556
3865
  kind: "web",
@@ -3559,13 +3868,13 @@ __installPublicEnv(publicEnvValues)
3559
3868
  status: "live",
3560
3869
  logFile: p.path
3561
3870
  });
3562
- let e = nr(t);
3871
+ let e = hr(t);
3563
3872
  if (e) {
3564
- let t = await fr({ dashboardAppPath: e });
3873
+ let t = await Tr({ dashboardAppPath: e });
3565
3874
  t.status === "launched" ? Z.info(`dashboard launched at http://localhost:${t.port}`, { port: t.port }) : t.status === "already-running" && Z.debug(`dashboard already running on :${t.port}`, { port: t.port });
3566
3875
  }
3567
3876
  setInterval(() => {
3568
- Hn({
3877
+ tr({
3569
3878
  id: f,
3570
3879
  name: d,
3571
3880
  kind: "web",
@@ -3576,7 +3885,7 @@ __installPublicEnv(publicEnvValues)
3576
3885
  }).catch(() => {});
3577
3886
  }, 1e4).unref();
3578
3887
  let n = () => {
3579
- Un(f), p.dispose();
3888
+ nr(f), p.dispose();
3580
3889
  };
3581
3890
  process.on("SIGINT", n), process.on("SIGTERM", n);
3582
3891
  } catch (e) {
@@ -3586,26 +3895,26 @@ __installPublicEnv(publicEnvValues)
3586
3895
  app: n.name ?? "unnamed",
3587
3896
  kind: "web",
3588
3897
  url: `http://localhost:${u}`,
3589
- bootMs: Date.now() - I
3898
+ bootMs: Date.now() - _e
3590
3899
  }), new Promise(() => {});
3591
- }, Yr = async (e) => {
3900
+ }, Si = async (e) => {
3592
3901
  process.env.NODE_ENV || (process.env.NODE_ENV = "production");
3593
- let t = await qr(e);
3902
+ let t = await bi(e);
3594
3903
  if (!t) return {
3595
3904
  ran: !1,
3596
3905
  exitCode: 0
3597
3906
  };
3598
3907
  let n = Date.now(), i = Z.child("serve");
3599
3908
  i.info("booting voltro serve (preview)", { app: t.name ?? "(unnamed)" });
3600
- let a = await Vr(e, t);
3909
+ let a = await mi(e, t);
3601
3910
  for (let e of a) i.info("api wired", {
3602
3911
  name: e.name,
3603
3912
  pkg: e.pkg
3604
3913
  });
3605
- await Wr(e, t, a);
3914
+ await _i(e, t, a);
3606
3915
  {
3607
3916
  let { pages: t } = await $(r(e, "src", "pages"));
3608
- await gt({
3917
+ await bt({
3609
3918
  appRoot: e,
3610
3919
  pages: t
3611
3920
  });
@@ -3615,11 +3924,11 @@ __installPublicEnv(publicEnvValues)
3615
3924
  root: l,
3616
3925
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3617
3926
  plugins: [c()],
3618
- customLogger: ot(),
3927
+ customLogger: st(),
3619
3928
  resolve: { dedupe: ["react", "react-dom"] },
3620
3929
  build: {
3621
3930
  outDir: "dist",
3622
- rollupOptions: { output: { manualChunks: wr } }
3931
+ rollupOptions: { output: { manualChunks: Xr } }
3623
3932
  },
3624
3933
  publicDir: r(e, "public")
3625
3934
  });
@@ -3639,14 +3948,14 @@ __installPublicEnv(publicEnvValues)
3639
3948
  extras: f,
3640
3949
  bootMs: Date.now() - n
3641
3950
  }), new Promise(() => {});
3642
- }, Xr = 5e3, Zr = 6e4, Qr = (e, t) => {
3951
+ }, Ci = 5e3, wi = 6e4, Ti = (e, t) => {
3643
3952
  if (e.length === 0) return 0;
3644
3953
  if (e.length === 1) return e[0];
3645
3954
  let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
3646
3955
  if (r === i) return e[r];
3647
3956
  let a = n - r;
3648
3957
  return e[r] * (1 - a) + e[i] * a;
3649
- }, $r = (e) => {
3958
+ }, Ei = (e) => {
3650
3959
  if (e.length === 0) return {
3651
3960
  p50: 0,
3652
3961
  p95: 0,
@@ -3658,18 +3967,18 @@ __installPublicEnv(publicEnvValues)
3658
3967
  let t = e.slice().sort((e, t) => e - t), n = 0;
3659
3968
  for (let e of t) n += e;
3660
3969
  return {
3661
- p50: Qr(t, .5),
3662
- p95: Qr(t, .95),
3663
- p99: Qr(t, .99),
3970
+ p50: Ti(t, .5),
3971
+ p95: Ti(t, .95),
3972
+ p99: Ti(t, .99),
3664
3973
  mean: n / t.length,
3665
3974
  min: t[0],
3666
3975
  max: t[t.length - 1]
3667
3976
  };
3668
- }, ei = (e = {}) => {
3669
- let t = e.maxSamples ?? Xr, n = e.defaultWindowMs ?? Zr, r = [];
3977
+ }, Di = (e = {}) => {
3978
+ let t = e.maxSamples ?? Ci, n = e.defaultWindowMs ?? wi, r = [];
3670
3979
  return {
3671
3980
  record(e) {
3672
- re(e), r.push({
3981
+ A(e), r.push({
3673
3982
  ...e,
3674
3983
  ts: Date.now()
3675
3984
  }), r.length > t && r.shift();
@@ -3695,7 +4004,7 @@ __installPublicEnv(publicEnvValues)
3695
4004
  tag: e.tag,
3696
4005
  count: e.samples.length,
3697
4006
  errorCount: n,
3698
- latencyMs: $r(t)
4007
+ latencyMs: Ei(t)
3699
4008
  });
3700
4009
  }
3701
4010
  return c.sort((e, t) => t.count - e.count), {
@@ -3708,4 +4017,4 @@ __installPublicEnv(publicEnvValues)
3708
4017
  };
3709
4018
  };
3710
4019
  //#endregion
3711
- export { Bt as $, xn as A, V as B, kn as C, On as D, Dn as E, en as F, kt as G, U as H, Qt as I, Et as J, Ht as K, Gt as L, mn as M, un as N, wn as O, cn as P, Dt as Q, Wt as R, Hn as S, jn as T, Pt as U, wt as V, Vt as W, Tt as X, At as Y, Nt as Z, Zn as _, Ue as _t, qr as a, jt as at, Vn as b, ve as bt, Yr as c, H as ct, Wr as d, yt as dt, zt as et, rr as f, gt as ft, Xn as g, Ge as gt, nr as h, Ye as ht, Ar as i, Ft as it, yn as j, Sn as k, wr as l, bt as lt, fr as m, Xe as mt, Hr as n, Rt as nt, Vr as o, Mt as ot, tr as p, Qe as pt, Ot as q, Ur as r, It as rt, Jr as s, G as st, ei as t, Lt as tt, $ as u, vt as ut, Qn as v, Be as vt, An as w, Un as x, ye as xt, Wn as y, Ve as yt, Kt as z };
4020
+ export { Kt as $, Hn as A, ye as At, mn as B, lr as C, Xe as Ct, er as D, Be as Dt, rr as E, Ue as Et, On as F, Jt as G, an as H, En as I, Ot as J, Xt as K, Tn as L, Wn as M, Bn as N, nr as O, Ve as Ot, Vn as P, Nt as Q, Cn as R, hr as S, Qe as St, dr as T, Ge as Tt, nn as U, fn as V, Yt as W, Rt as X, U as Y, Gt as Z, Or as _, St as _t, ri as a, jt as at, mr as b, ut as bt, mi as c, Vt as ct, Xr as d, zt as dt, Mt as et, $ as f, Ft as ft, Dr as g, wt as gt, Rr as h, H as ht, gi as i, Lt as it, Un as j, tr as k, ve as kt, xi as l, Ht as lt, Ir as m, G as mt, Zr as n, Pt as nt, ni as o, Wt as ot, _i as p, It as pt, V as q, hi as r, kt as rt, bi as s, Ut as st, Di as t, At as tt, Si as u, Bt as ut, kr as v, Ct as vt, ur as w, Ye as wt, Tr as x, ct as xt, gr as y, bt as yt, vn as z };