@voltro/cli 0.8.0 → 0.10.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 (60) hide show
  1. package/CHANGELOG.md +329 -7
  2. package/THIRD-PARTY-NOTICES.md +2 -2
  3. package/dist/apiBuild-BbR1nYcE.js +2 -0
  4. package/dist/{apiBuild-OrDkXGFX.js → apiBuild-DTLPSlt9.js} +8 -8
  5. package/dist/bin.js +2 -2
  6. package/dist/{commands-DT4PipBz.js → commands-B0QT8dUY.js} +2080 -1638
  7. package/dist/dev-BJvbwjSz.js +2 -0
  8. package/dist/{dev-Ga65K4jc.js → dev-CK9fbuAM.js} +1433 -1367
  9. package/dist/index.js +1 -1
  10. package/dist/{inspectMetrics-EK0CcHyu.js → inspectMetrics-BeMjgt8x.js} +1239 -957
  11. package/dist/inspectState.d.ts +6 -2
  12. package/dist/{serveCommand-CR5xnYZt.js → serveCommand-YR3mKjvf.js} +367 -384
  13. package/dist/serveEntry.js +3 -3
  14. package/dist/{start-DuyBQxW3.js → start-C_M4fGS2.js} +391 -340
  15. package/dist/startEntry.js +2 -2
  16. package/package.json +18 -17
  17. package/templates/agent-docs/cli.md +94 -18
  18. package/templates/agent-docs/data.md +109 -1
  19. package/templates/agent-docs/database/seedsdialects.md +20 -4
  20. package/templates/agent-docs/routing.md +77 -14
  21. package/templates/agent-docs/scheduling.md +32 -0
  22. package/templates/apps/api-ai/package.json +7 -7
  23. package/templates/apps/api-auth/package.json +8 -8
  24. package/templates/apps/api-backend/package.json +7 -7
  25. package/templates/apps/api-backend-deactivation/package.json +7 -7
  26. package/templates/apps/api-backend-mail/package.json +8 -8
  27. package/templates/apps/api-backend-mariadb/package.json +9 -9
  28. package/templates/apps/api-backend-storage/package.json +8 -8
  29. package/templates/apps/api-data-advanced/package.json +8 -8
  30. package/templates/apps/api-durable/package.json +8 -8
  31. package/templates/apps/api-durable/schedules/nightlyReport.cron.tsx +5 -0
  32. package/templates/apps/api-durable/subscribers/orderChanges.subscribe.ts +8 -2
  33. package/templates/apps/api-feature-flags/package.json +9 -9
  34. package/templates/apps/api-governance/package.json +8 -8
  35. package/templates/apps/api-kv/package.json +8 -8
  36. package/templates/apps/api-moderation/package.json +8 -8
  37. package/templates/apps/api-observability/package.json +8 -8
  38. package/templates/apps/api-ratelimit/package.json +8 -8
  39. package/templates/apps/api-rbac/package.json +8 -8
  40. package/templates/apps/api-rest/package.json +7 -7
  41. package/templates/apps/api-saas/package.json +11 -11
  42. package/templates/apps/api-search/package.json +8 -8
  43. package/templates/apps/api-versioning/package.json +8 -8
  44. package/templates/apps/api-webhooks/package.json +8 -8
  45. package/templates/apps/changelog/package.json +6 -6
  46. package/templates/apps/edge-functions/package.json +2 -2
  47. package/templates/apps/frontend-admin/package.json +8 -8
  48. package/templates/apps/frontend-app/package.json +8 -8
  49. package/templates/apps/frontend-blank/package.json +7 -7
  50. package/templates/apps/frontend-contact/package.json +7 -7
  51. package/templates/apps/frontend-dashboard/package.json +7 -7
  52. package/templates/apps/frontend-docs/package.json +7 -7
  53. package/templates/apps/frontend-i18n/package.json +6 -6
  54. package/templates/apps/frontend-landing/package.json +7 -7
  55. package/templates/apps/frontend-spa/package.json +7 -7
  56. package/templates/apps/frontend-ssr/package.json +7 -7
  57. package/templates/apps/frontend-ssr-api/package.json +8 -8
  58. package/templates/apps/frontend-static-blog/package.json +6 -6
  59. package/dist/apiBuild-CmtI6Ygh.js +0 -2
  60. package/dist/dev-Ca1jdwnt.js +0 -2
@@ -4,20 +4,20 @@ import { FileSystem as c } from "@effect/platform";
4
4
  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
- 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 O } from "node:fs";
8
- import { currentTraceContext as k, lastWriteProvenance as te, recordSample as ne, resolveSecret as A } from "@voltro/runtime";
9
- import { mkdir as re, writeFile as j } from "node:fs/promises";
10
- import { FRAMEWORK_ENV_CATALOG as M, appEnvEntries as ie, checkEnvNaming as ae, formatEnvErrors as N, 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 me } from "node:os";
16
- import { createConnection as he } from "node:net";
17
- import { createRequire as ge } from "node:module";
18
- import { PassThrough as _e } from "node:stream";
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 k, recordSample as A, resolveSecret as j } from "@voltro/runtime";
9
+ import { mkdir as M, readFile as ne, writeFile as N } from "node:fs/promises";
10
+ import { FRAMEWORK_ENV_CATALOG as re, appEnvEntries as P, checkEnvNaming as ie, formatEnvErrors as F, installEnvSnapshot as ae, isEnvContract as oe, pluginEnvEntries as I, renderDotEnvExample as se, resolveEnv as ce } from "@voltro/env";
11
+ import { __installPublicEnv as le } from "@voltro/env/public";
12
+ import { createHash as ue } from "node:crypto";
13
+ import { spawn as de } from "node:child_process";
14
+ import { timingSafeStringEqual as fe } from "@voltro/protocol/session";
15
+ import { homedir as L } from "node:os";
16
+ import { createConnection as pe } from "node:net";
17
+ import { createRequire as me } from "node:module";
18
+ import { PassThrough as he } from "node:stream";
19
19
  //#region src/cliRuntime.ts
20
- var ve = [
20
+ var ge = [
21
21
  "severity",
22
22
  "code",
23
23
  "detail",
@@ -34,14 +34,14 @@ var ve = [
34
34
  "file",
35
35
  "line",
36
36
  "routine"
37
- ], ye = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
37
+ ], R = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
38
38
  if (t > 10 || typeof e != "object" || !e || n.has(e)) return null;
39
39
  n.add(e);
40
40
  let r = e, i = r.message;
41
41
  if (typeof i == "string" && i.length > 0 && i !== "Failed to execute statement") {
42
42
  let e = { message: i };
43
43
  typeof r.stack == "string" && (e.stack = r.stack);
44
- for (let t of ve) r[t] !== void 0 && (e[t] = r[t]);
44
+ for (let t of ge) r[t] !== void 0 && (e[t] = r[t]);
45
45
  return e;
46
46
  }
47
47
  for (let e of [
@@ -54,20 +54,20 @@ var ve = [
54
54
  ]) {
55
55
  let i = r[e];
56
56
  if (i !== void 0) {
57
- let e = ye(i, t + 1, n);
57
+ let e = R(i, t + 1, n);
58
58
  if (e) return e;
59
59
  }
60
60
  }
61
61
  if (Array.isArray(r.failures)) for (let e of r.failures) {
62
- let r = ye(e, t + 1, n);
62
+ let r = R(e, t + 1, n);
63
63
  if (r) return r;
64
64
  }
65
65
  return null;
66
- }, F = (e = {}) => p.merge(l.layer, m({
66
+ }, _e = (e = {}) => p.merge(l.layer, m({
67
67
  ...e.scope ? { defaultScope: e.scope } : {},
68
68
  ...e.logger
69
- })), be = async (e, t = {}) => {
70
- let n = e.pipe(f.provide(F(t)));
69
+ })), ve = async (e, t = {}) => {
70
+ let n = e.pipe(f.provide(_e(t)));
71
71
  return await f.runPromise(f.matchCauseEffect(n, {
72
72
  onSuccess: (e) => f.succeed(e),
73
73
  onFailure: (e) => {
@@ -83,7 +83,7 @@ var ve = [
83
83
  }
84
84
  let n = null;
85
85
  for (let e of t) {
86
- let t = ye(e);
86
+ let t = R(e);
87
87
  if (t) {
88
88
  n = t;
89
89
  break;
@@ -103,41 +103,41 @@ var ve = [
103
103
  return f.zipRight(f.logError("cli command failed", r), f.succeed(1));
104
104
  }
105
105
  }).pipe(f.provide(m(t.logger ?? {}))));
106
- }, I = (e, t = {}) => {
107
- let n = e.pipe(f.provide(F(t)));
106
+ }, ye = (e, t = {}) => {
107
+ let n = e.pipe(f.provide(_e(t)));
108
108
  u.runMain(n, { disableErrorReporting: !1 });
109
- }, xe = t(o(import.meta.url)), L = [a(xe, "..", "templates"), a(xe, "..", "..", "templates")], Se = (e) => ({
109
+ }, z = t(o(import.meta.url)), be = [a(z, "..", "templates"), a(z, "..", "..", "templates")], xe = (e) => ({
110
110
  _tag: "TemplateNotFoundError",
111
111
  searched: e
112
- }), Ce = ["AGENTS.md", "CLAUDE.md"], we = "voltro:agents-md:keep", Te = 2048, Ee = "<!-- VOLTRO:INDEX -->", R = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), z = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), De = (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 -->", B = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), V = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), Ee = (e, t) => e.readFileString(t).pipe(f.map((e) => {
113
113
  try {
114
114
  return JSON.parse(e).workspaces !== void 0;
115
115
  } catch {
116
116
  return !1;
117
117
  }
118
- }), f.orElseSucceed(() => !1)), Oe = (e) => f.gen(function* () {
118
+ }), f.orElseSucceed(() => !1)), De = (e) => f.gen(function* () {
119
119
  let n = yield* c.FileSystem, i = a(e);
120
120
  for (;;) {
121
- if ((yield* R(n, r(i, ".git"))) || (yield* R(n, r(i, "pnpm-workspace.yaml"))) || (yield* De(n, r(i, "package.json")))) return i;
121
+ if ((yield* B(n, r(i, ".git"))) || (yield* B(n, r(i, "pnpm-workspace.yaml"))) || (yield* Ee(n, r(i, "package.json")))) return i;
122
122
  let o = t(i);
123
123
  if (o === i) return a(e);
124
124
  i = o;
125
125
  }
126
- }), ke = (e, t, n) => f.gen(function* () {
126
+ }), Oe = (e, t, n) => f.gen(function* () {
127
127
  yield* e.makeDirectory(n, { recursive: !0 }).pipe(f.orElseSucceed(() => void 0));
128
128
  let i = yield* e.readDirectory(t).pipe(f.orElseSucceed(() => []));
129
129
  for (let a of i) {
130
130
  let i = r(t, a), o = r(n, a);
131
- (yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield* ke(e, i, o) : yield* e.copyFile(i, o).pipe(f.orElseSucceed(() => void 0));
131
+ (yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield* Oe(e, i, o) : yield* e.copyFile(i, o).pipe(f.orElseSucceed(() => void 0));
132
132
  }
133
- }), Ae = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, je = (e, t) => f.gen(function* () {
133
+ }), ke = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, Ae = (e, t) => f.gen(function* () {
134
134
  let n = r(t, "app.config.ts");
135
- if (!(yield* R(e, n))) return null;
135
+ if (!(yield* B(e, n))) return null;
136
136
  let i = (yield* f.tryPromise(() => import(s(n).href)).pipe(f.orElseSucceed(() => null)))?.default;
137
- return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(Ae).filter((e) => e !== null);
138
- }), Me = (e, t) => f.gen(function* () {
137
+ return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(ke).filter((e) => e !== null);
138
+ }), je = (e, t) => f.gen(function* () {
139
139
  let n = [], i = [], a = r(t, "apps");
140
- if (!(yield* R(e, a))) return {
140
+ if (!(yield* B(e, a))) return {
141
141
  apis: n,
142
142
  webs: i
143
143
  };
@@ -145,8 +145,8 @@ var ve = [
145
145
  let o = r(a, t);
146
146
  if ((yield* e.stat(o).pipe(f.orElseSucceed(() => null)))?.type === "Directory") for (let t of yield* e.readDirectory(o).pipe(f.orElseSucceed(() => []))) {
147
147
  let a = r(o, t), s = r(a, "app.config.ts");
148
- if (!(yield* R(e, s))) continue;
149
- let c = yield* z(e, s);
148
+ if (!(yield* B(e, s))) continue;
149
+ let c = yield* V(e, s);
150
150
  /type:\s*['"]web['"]/.test(c) ? i.push(a) : n.push(a);
151
151
  }
152
152
  }
@@ -154,7 +154,7 @@ var ve = [
154
154
  apis: n,
155
155
  webs: i
156
156
  };
157
- }), Ne = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Pe = (e, t, n) => {
157
+ }), Me = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Ne = (e, t, n) => {
158
158
  let r = [
159
159
  "<!-- voltro agent-docs index — regenerated at seed time -->",
160
160
  "## Deep reference (read on demand)",
@@ -166,17 +166,17 @@ var ve = [
166
166
  "",
167
167
  "| Topic | Open | Summary |",
168
168
  "|---|---|---|",
169
- ...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Ne(e.description)} |`),
169
+ ...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Me(e.description)} |`),
170
170
  ""
171
- ], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${Ne(e.description)} |`) : t.map((e) => {
171
+ ], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${Me(e.description)} |`) : t.map((e) => {
172
172
  let t = i.get(e);
173
- return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Ne(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
173
+ return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Me(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
174
174
  });
175
175
  return r.push(`### Plugins${t === null ? "" : " (installed)"}`, "", "| Plugin | Open | Summary |", "|---|---|---|"), r.push(a.length ? a.join("\n") : "| _(none installed)_ | | |", ""), r.join("\n");
176
- }, Fe = (e, t, n) => {
176
+ }, Pe = (e, t, n) => {
177
177
  let r = t.templates?.[e] ?? t.templates?.[e.replace(/^frontend-/, "")];
178
178
  return `\nScaffolded from the \`${e}\` template — see \`${r ? `${n}${r}` : `${n}agent-docs/templates/overview.md`}\`.\n`;
179
- }, Ie = {
179
+ }, Fe = {
180
180
  api: (e, t, n = "") => `# api — agent notes
181
181
 
182
182
  You are in a Voltro **api** app. Server primitives live here: \`queries/\`,
@@ -216,7 +216,7 @@ You are in a Voltro **web** app. File-based routing under \`src/pages/**\`.
216
216
  Deep reference (paths from the repo root): \`${e}agent-docs/routing.md\`,
217
217
  \`${e}agent-docs/schema-driven-ui.md\`, \`${e}agent-docs/internationalization.md\`.
218
218
  ${t}`
219
- }, Le = [
219
+ }, Ie = [
220
220
  {
221
221
  name: "voltro-schema",
222
222
  description: "Define or change a Voltro database table/schema (columns, mixins, indexes, relations).",
@@ -247,7 +247,7 @@ ${t}`
247
247
  description: "Export/import + backup/restore Voltro data & assets, and copy prod→dev/stage SAFELY with fail-closed masking/anonymization (.sensitive()/.safe()) + referential subsetting. Use for data takeout, seeding lower envs, backups, or cross-dialect moves.",
248
248
  module: "cli.md"
249
249
  }
250
- ], Re = (e, t) => `---
250
+ ], Le = (e, t) => `---
251
251
  name: ${e.name}
252
252
  description: ${e.description}
253
253
  ---
@@ -258,10 +258,10 @@ Open the full reference and follow the patterns there:
258
258
 
259
259
  Also read the repo-root \`AGENTS.md\` for the always-true rules (browser/server
260
260
  boundary, naming, anti-patterns) before editing.
261
- `, ze = (e, n, r, i) => f.gen(function* () {
262
- let a = yield* R(e, n);
261
+ `, Re = (e, n, r, i) => f.gen(function* () {
262
+ let a = yield* B(e, n);
263
263
  if (a) {
264
- if ((yield* z(e, n)).slice(0, Te).includes("voltro:agents-md:keep")) return {
264
+ if ((yield* V(e, n)).slice(0, we).includes("voltro:agents-md:keep")) return {
265
265
  path: n,
266
266
  action: "protected"
267
267
  };
@@ -274,64 +274,64 @@ boundary, naming, anti-patterns) before editing.
274
274
  path: n,
275
275
  action: a ? "overwritten" : "created"
276
276
  };
277
- }), Be = (e, t = {}) => f.gen(function* () {
278
- let n = yield* c.FileSystem, i = yield* Oe(e), o = null;
279
- for (let e of L) if (yield* R(n, r(e, "AGENTS.core.md"))) {
277
+ }), ze = (e, t = {}) => f.gen(function* () {
278
+ let n = yield* c.FileSystem, i = yield* De(e), o = null;
279
+ for (let e of be) if (yield* B(n, r(e, "AGENTS.core.md"))) {
280
280
  o = e;
281
281
  break;
282
282
  }
283
283
  if (o === null) {
284
- for (let e of L) if (yield* R(n, r(e, "AGENTS.md"))) {
285
- let a = yield* z(n, r(e, "AGENTS.md")), o = [];
286
- for (let e of Ce) o.push(yield* ze(n, r(i, e), a, t.force ?? !1));
284
+ for (let e of be) if (yield* B(n, r(e, "AGENTS.md"))) {
285
+ let a = yield* V(n, r(e, "AGENTS.md")), o = [];
286
+ for (let e of Se) o.push(yield* Re(n, r(i, e), a, t.force ?? !1));
287
287
  return { files: o };
288
288
  }
289
- return yield* f.fail(Se(L.map((e) => r(e, "AGENTS.core.md"))));
289
+ return yield* f.fail(xe(be.map((e) => r(e, "AGENTS.core.md"))));
290
290
  }
291
- 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* V(n, r(o, "AGENTS.core.md")), l = yield* V(n, r(o, "agent-docs", "_manifest.json")), u = l ? JSON.parse(l) : {
292
292
  modules: [],
293
293
  plugins: []
294
- }, 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 = Ce.map((e) => r(i, e));
295
- if ((yield* f.forEach(h, (e) => z(n, e).pipe(f.map((e) => e.slice(0, Te))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
294
+ }, d = (t.preferPointer ?? !1) || (yield* B(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) => V(n, e).pipe(f.map((e) => e.slice(0, we))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
296
296
  path: e,
297
297
  action: "protected"
298
298
  })) };
299
- let { apis: g, webs: _ } = yield* Me(n, i), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = !1;
299
+ let { apis: g, webs: _ } = yield* je(n, i), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = !1;
300
300
  for (let e of g) {
301
- let t = yield* je(n, e);
301
+ let t = yield* Ae(n, e);
302
302
  if (v.set(e, t), t !== null) {
303
303
  b = !0;
304
304
  for (let e of t) y.add(e);
305
305
  }
306
306
  }
307
- let x = t.plugins ? t.plugins.map(Ae).filter((e) => e !== null) : b ? [...y] : null, S = s.includes(Ee) ? s.replace(Ee, Pe(u, x, p)) : s, C = [];
308
- for (let e of h) C.push(yield* ze(n, e, S, m));
309
- d || (yield* ke(n, r(o, "agent-docs"), r(i, "agent-docs")));
307
+ let x = t.plugins ? t.plugins.map(ke).filter((e) => e !== null) : b ? [...y] : null, S = s.includes(Te) ? s.replace(Te, Ne(u, x, p)) : s, C = [];
308
+ for (let e of h) C.push(yield* Re(n, e, S, m));
309
+ d || (yield* Oe(n, r(o, "agent-docs"), r(i, "agent-docs")));
310
310
  let w = new Map((t.appTemplates ?? []).map((e) => [a(e.dir), e.template])), T = (e) => {
311
311
  let t = w.get(a(e));
312
- return t ? Fe(t, u, p) : "";
313
- }, E = (e, t) => f.forEach(Ce, (i) => ze(n, r(e, i), t, m));
314
- for (let e of g) C.push(...yield* E(e, Ie.api(p, v.get(e) ?? null, T(e)))), (yield* R(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Ie.database(p)));
315
- for (let e of _) C.push(...yield* E(e, Ie.web(p, T(e))));
316
- for (let e of Le) C.push(yield* ze(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Re(e, p), m));
312
+ return t ? Pe(t, u, p) : "";
313
+ }, E = (e, t) => f.forEach(Se, (i) => Re(n, r(e, i), t, m));
314
+ for (let e of g) C.push(...yield* E(e, Fe.api(p, v.get(e) ?? null, T(e)))), (yield* B(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Fe.database(p)));
315
+ for (let e of _) C.push(...yield* E(e, Fe.web(p, T(e))));
316
+ for (let e of Ie) C.push(yield* Re(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Le(e, p), m));
317
317
  return { files: C };
318
- }), Ve = (e, t = {}) => f.runPromise(Be(e, t).pipe(f.provide(l.layer))), He = async (e) => {
318
+ }), Be = (e, t = {}) => f.runPromise(ze(e, t).pipe(f.provide(l.layer))), Ve = async (e) => {
319
319
  let t = e.includes("--force"), n = e.find((e) => !e.startsWith("-")) ?? process.cwd();
320
- return be(f.gen(function* () {
321
- let e = yield* Be(n, { force: t });
320
+ return ve(f.gen(function* () {
321
+ let e = yield* ze(n, { force: t });
322
322
  for (let t of e.files) {
323
- let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${we}")` : "present (use --force to overwrite)";
323
+ let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${Ce}")` : "present (use --force to overwrite)";
324
324
  yield* f.logInfo(`${t.path.split("/").slice(-2).join("/")} ${e}`, { action: t.action });
325
325
  }
326
326
  return 0;
327
327
  }).pipe(f.catchTag("TemplateNotFoundError", (e) => f.gen(function* () {
328
328
  return yield* f.logError("AGENTS.md template not found", { searched: e.searched }), 1;
329
329
  }))), { scope: "voltro:agents-md" });
330
- }, Ue = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), We = (e) => {
330
+ }, He = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), Ue = (e) => {
331
331
  try {
332
332
  let t = r(e, "tsconfig.json");
333
333
  if (!y(t)) return [];
334
- let n = JSON.parse(Ue(C(t, "utf8"))).compilerOptions ?? {}, i = n.paths ?? {}, o = a(e, n.baseUrl ?? "."), s = [];
334
+ let n = JSON.parse(He(C(t, "utf8"))).compilerOptions ?? {}, i = n.paths ?? {}, o = a(e, n.baseUrl ?? "."), s = [];
335
335
  for (let [e, t] of Object.entries(i)) {
336
336
  let n = t[0];
337
337
  if (!n) continue;
@@ -351,17 +351,84 @@ boundary, naming, anti-patterns) before editing.
351
351
  } catch {
352
352
  return [];
353
353
  }
354
- }, Ge = (e) => {
354
+ }, We = (e) => {
355
355
  let t = e;
356
356
  return t?.code === "ERR_MODULE_NOT_FOUND" || /Cannot find (package|module)/.test(String(t?.message ?? ""));
357
- }, Ke = async (e, t) => {
357
+ }, Ge = async (e, t) => {
358
358
  try {
359
359
  return await t();
360
360
  } catch (t) {
361
- throw Ge(t) ? Error(`voltro: the build tool '${e}' is not installed.\n\nIt's an OPTIONAL dependency of @voltro/cli — needed by 'voltro dev' and 'voltro build', but excluded from a serve-only production install (that's how prod images stay lean). If you are building, reinstall WITHOUT '--no-optional' (e.g. 'pnpm install'). A production SERVE container does not need '${e}' — it boots from the precompiled bundle.`) : t;
361
+ throw We(t) ? Error(`voltro: the build tool '${e}' is not installed.\n\nIt's an OPTIONAL dependency of @voltro/cli — needed by 'voltro dev' and 'voltro build', but excluded from a serve-only production install (that's how prod images stay lean). If you are building, reinstall WITHOUT '--no-optional' (e.g. 'pnpm install'). A production SERVE container does not need '${e}' — it boots from the precompiled bundle.`) : t;
362
362
  }
363
- }, qe = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", Je = (e, t) => t ? `${e} | undefined` : e, Ye = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${Je(t.tsType, t.optional)}`).join("\n"), Xe = async (e, t) => {
364
- let n = Ye(t, () => !0), i = `${qe}
363
+ }, Ke = () => {
364
+ let e = /* @__PURE__ */ new Map();
365
+ return {
366
+ get(t) {
367
+ return e.get(t);
368
+ },
369
+ set(t, n) {
370
+ e.set(t, n);
371
+ },
372
+ invalidate(t) {
373
+ e.delete(t);
374
+ },
375
+ invalidateBy(t) {
376
+ let n = 0;
377
+ for (let r of e.keys()) t(r) && (e.delete(r), n++);
378
+ return n;
379
+ },
380
+ clear() {
381
+ e.clear();
382
+ },
383
+ size() {
384
+ return e.size;
385
+ },
386
+ snapshot() {
387
+ return Array.from(e.entries());
388
+ }
389
+ };
390
+ }, qe = (e) => {
391
+ if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
392
+ if (typeof e != "string") return null;
393
+ let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
394
+ if (!t) return null;
395
+ let n = parseInt(t[1], 10);
396
+ if (!Number.isFinite(n) || n <= 0) return null;
397
+ let r = t[2].toLowerCase();
398
+ 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;
399
+ }, Je = (e, t = {}) => {
400
+ let n = [e];
401
+ 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("|");
402
+ }, Ye = (e, t) => e.expiresAt > t, Xe = (e, t) => e.expiresAt <= t && e.servableUntil > t, Ze = [
403
+ "static",
404
+ "spa",
405
+ "ssr",
406
+ "isr"
407
+ ], Qe = (e) => typeof e == "string" && Ze.includes(e), $e = Ze.map((e) => `'${e}'`).join(" | "), et = (e, t) => `[voltro] ${e}: unknown renderMode '${t}'.\n Valid values: ${$e}.${t === "client" || t === "csr" || t === "browser" ? "\n A page that renders only in the browser is 'spa': it is skipped by the prerender and mounts on the client. If its route has a layout, that layout still renders server-side as an SSR shell." : t === "server" || t === "dynamic" ? "\n A page rendered per request is 'ssr'." : t === "ssg" || t === "prerender" ? "\n A page rendered once at build time is 'static' (the default)." : ""}`, tt = class extends Error {
408
+ page;
409
+ value;
410
+ name = "InvalidRenderModeError";
411
+ constructor(e, t) {
412
+ super(et(e, t)), this.page = e, this.value = t;
413
+ }
414
+ }, nt = (e, t = "<page>") => {
415
+ if (e.renderMode !== void 0 && e.renderMode !== null) {
416
+ if (!Qe(e.renderMode)) throw new tt(t, String(e.renderMode));
417
+ return e.renderMode;
418
+ }
419
+ return e.dynamic === "force-dynamic" ? "ssr" : (e.dynamic, "static");
420
+ }, rt = (e, t = "<page>") => ({
421
+ renderMode: nt(e, t),
422
+ tenantAware: e.tenantAware === !0,
423
+ revalidateMs: qe(e.revalidate),
424
+ staleWhileRevalidateMs: qe(e.staleWhileRevalidate) ?? 0,
425
+ cacheInvalidatesOn: Array.isArray(e.cacheInvalidatesOn) ? e.cacheInvalidatesOn : [],
426
+ interactive: e.interactive ?? "full",
427
+ hasLoader: typeof e.loader == "function",
428
+ hasMeta: e.meta != null,
429
+ hasGetStaticPaths: typeof e.getStaticPaths == "function"
430
+ }), it = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", at = (e, t) => t ? `${e} | undefined` : e, ot = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${at(t.tsType, t.optional)}`).join("\n"), st = async (e, t) => {
431
+ let n = ot(t, () => !0), i = `${it}
365
432
  import '@voltro/env/server'
366
433
 
367
434
  declare module '@voltro/env/server' {
@@ -370,9 +437,9 @@ ${n.length > 0 ? n : " // (no variables declared)"}
370
437
  }
371
438
  }
372
439
  `;
373
- await j(r(e, "env.generated.d.ts"), i, "utf8");
374
- }, Ze = async (e, t) => {
375
- let n = Ye(t, (e) => e === "public"), i = `${qe}
440
+ await N(r(e, "env.generated.d.ts"), i, "utf8");
441
+ }, ct = async (e, t) => {
442
+ let n = ot(t, (e) => e === "public"), i = `${it}
376
443
  import '@voltro/env/public'
377
444
 
378
445
  declare module '@voltro/env/public' {
@@ -381,9 +448,9 @@ ${n.length > 0 ? n : " // (no public variables declared)"}
381
448
  }
382
449
  }
383
450
  `, a = r(e, "src");
384
- await re(a, { recursive: !0 }), await j(r(a, "voltro-env.d.ts"), i, "utf8");
385
- }, Qe = async (e, t) => {
386
- let n = `${qe}
451
+ await M(a, { recursive: !0 }), await N(r(a, "voltro-env.d.ts"), i, "utf8");
452
+ }, lt = async (e, t) => {
453
+ let n = `${it}
387
454
  import { __installPublicEnv } from '@voltro/env/public'
388
455
 
389
456
  export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
@@ -391,14 +458,14 @@ export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
391
458
  // Set the browser/SSR-shared global the \`publicEnv\` accessor reads.
392
459
  __installPublicEnv(publicEnvValues)
393
460
  `;
394
- await re(e, { recursive: !0 }), await j(r(e, "env.public.ts"), n, "utf8");
395
- }, $e = async (e) => {
396
- let t = se(e.rawEnv) ? e.rawEnv : void 0, n = await le({
461
+ await M(e, { recursive: !0 }), await N(r(e, "env.public.ts"), n, "utf8");
462
+ }, ut = async (e) => {
463
+ let t = oe(e.rawEnv) ? e.rawEnv : void 0, n = await ce({
397
464
  contract: t,
398
- resolveSecret: A
399
- }), r = [...n.errors, ...ae(t, e.appType)];
400
- if (r.length > 0) throw Error(N(r));
401
- oe(n.values), e.appType === "web" && ue(n.publicValues);
465
+ resolveSecret: j
466
+ }), r = [...n.errors, ...ie(t, e.appType)];
467
+ if (r.length > 0) throw Error(F(r));
468
+ ae(n.values), e.appType === "web" && le(n.publicValues);
402
469
  let i = t ? Object.keys(t.vars).length : 0;
403
470
  if (i > 0) {
404
471
  let r = Object.keys(n.publicValues).length;
@@ -410,52 +477,101 @@ __installPublicEnv(publicEnvValues)
410
477
  n.length > 0 && e.log.warn(`env: ${n.length} secret var(s) declared on a web app — secrets are reachable only from server-side render code and are NEVER bundled. Prefer declaring secrets on the api.`, { keys: n });
411
478
  }
412
479
  }
413
- return e.generateTypes && t && (e.appType === "api" ? await Xe(e.root, t) : await Ze(e.root, t)), {
480
+ return e.generateTypes && t && (e.appType === "api" ? await st(e.root, t) : await ct(e.root, t)), {
414
481
  resolved: n,
415
482
  contract: t
416
483
  };
417
- }, et = g({ scope: "vite" }), tt = /\x1b\[[0-9;]*m/g, nt = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, rt = (e) => e.replace(tt, "").replace(nt, "").trim(), it = /proxy error/i, at = [
484
+ }, dt = g({ scope: "vite" }), ft = /\x1b\[[0-9;]*m/g, pt = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, mt = (e) => e.replace(ft, "").replace(pt, "").trim(), ht = /proxy error/i, gt = [
418
485
  "ECONNREFUSED",
419
486
  "ECONNRESET",
420
487
  "ECONNABORTED",
421
488
  "EPIPE",
422
489
  "ETIMEDOUT"
423
- ], ot = (e, t = 0) => {
490
+ ], _t = (e, t = 0) => {
424
491
  if (e == null || t > 5) return !1;
425
492
  let n = e;
426
- return typeof n.code == "string" && at.includes(n.code) || typeof n.message == "string" && at.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => ot(e, t + 1)) ? !0 : ot(n.cause, t + 1);
427
- }, st = 4e3, ct = () => {
493
+ return typeof n.code == "string" && gt.includes(n.code) || typeof n.message == "string" && gt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => _t(e, t + 1)) ? !0 : _t(n.cause, t + 1);
494
+ }, vt = 4e3, yt = () => {
428
495
  let e = /* @__PURE__ */ new Set(), t = 0, n = {
429
496
  hasWarned: !1,
430
497
  info: (e) => {
431
- let t = rt(e);
432
- t.length !== 0 && et.info(t);
498
+ let t = mt(e);
499
+ t.length !== 0 && dt.info(t);
433
500
  },
434
501
  warn: (e) => {
435
502
  n.hasWarned = !0;
436
- let t = rt(e);
437
- t.length !== 0 && et.warn(t);
503
+ let t = mt(e);
504
+ t.length !== 0 && dt.warn(t);
438
505
  },
439
506
  warnOnce: (t) => {
440
- let r = rt(t);
441
- e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && et.warn(r));
507
+ let r = mt(t);
508
+ e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && dt.warn(r));
442
509
  },
443
510
  error: (e, n) => {
444
- let r = rt(e), i = n?.error;
511
+ let r = mt(e), i = n?.error;
445
512
  if (r.length !== 0) {
446
- if (it.test(r) && ot(i)) {
513
+ if (ht.test(r) && _t(i)) {
447
514
  let e = Date.now();
448
- e - t > st && (t = e, et.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
515
+ e - t > vt && (t = e, dt.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
449
516
  return;
450
517
  }
451
- et.error(r, {}, i);
518
+ dt.error(r, {}, i);
452
519
  }
453
520
  },
454
521
  clearScreen: () => {},
455
522
  hasErrorLogged: (e) => !1
456
523
  };
457
524
  return n;
458
- }, lt = (e) => {
525
+ }, bt = (e = process.env) => {
526
+ let t = e.VOLTRO_DEV_SSR_COMPILE_CONCURRENCY;
527
+ if (t === void 0 || t.trim() === "") return 4;
528
+ let n = Number(t);
529
+ return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 4;
530
+ }, xt = (e) => {
531
+ let t = Math.max(1, Math.floor(e)), n = 0, r = [], i = () => n < t ? (n++, Promise.resolve()) : new Promise((e) => r.push(e)), a = () => {
532
+ let e = r.shift();
533
+ e ? e() : n--;
534
+ };
535
+ return {
536
+ withPermit: async (e) => {
537
+ await i();
538
+ try {
539
+ return await e();
540
+ } finally {
541
+ a();
542
+ }
543
+ },
544
+ get active() {
545
+ return n;
546
+ }
547
+ };
548
+ }, St = (e) => {
549
+ let t = xt(e.limit), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
550
+ return {
551
+ load: (i, a) => {
552
+ if (r.has(i)) return a();
553
+ let o = n.get(i);
554
+ if (o) return o;
555
+ let s = t.withPermit(async () => {
556
+ e.onColdStart?.(i);
557
+ try {
558
+ return await a();
559
+ } finally {
560
+ e.onColdEnd?.(i);
561
+ }
562
+ }).then((e) => (r.add(i), e)).finally(() => {
563
+ n.delete(i);
564
+ });
565
+ return n.set(i, s), s;
566
+ },
567
+ get inFlightCount() {
568
+ return n.size;
569
+ },
570
+ get warmCount() {
571
+ return r.size;
572
+ }
573
+ };
574
+ }, Ct = (e) => {
459
575
  let t = [];
460
576
  for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
461
577
  name: n.slice(5, -2),
@@ -471,7 +587,7 @@ __installPublicEnv(publicEnvValues)
471
587
  optional: !1
472
588
  });
473
589
  return t;
474
- }, ut = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), dt = async (e) => {
590
+ }, wt = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), Tt = async (e) => {
475
591
  let n = a(e);
476
592
  for (let e = 0; e < 4; e++) {
477
593
  let e = r(n, "project.json");
@@ -489,8 +605,8 @@ __installPublicEnv(publicEnvValues)
489
605
  n = i;
490
606
  }
491
607
  return null;
492
- }, ft = async (t) => {
493
- let n = await dt(t);
608
+ }, Et = async (t) => {
609
+ let n = await Tt(t);
494
610
  if (!n) return [];
495
611
  let { projectDir: i, manifest: a } = n, o = e(t), s = a.apps ?? {}, c = [];
496
612
  for (let [e, t] of Object.entries(s)) {
@@ -499,23 +615,23 @@ __installPublicEnv(publicEnvValues)
499
615
  if (!y(n)) continue;
500
616
  let a;
501
617
  try {
502
- let { pages: e } = await $(n);
618
+ let { pages: e } = await gi(n);
503
619
  a = e.map((e) => ({
504
620
  pattern: e.pattern,
505
- params: lt(e.pattern)
621
+ params: Ct(e.pattern)
506
622
  }));
507
623
  } catch {
508
624
  continue;
509
625
  }
510
626
  c.push({
511
- key: ut(e),
627
+ key: wt(e),
512
628
  origin: `http://localhost:${t.port}`,
513
629
  ...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
514
630
  routes: a
515
631
  });
516
632
  }
517
633
  return c;
518
- }, pt = (e) => {
634
+ }, Dt = (e) => {
519
635
  if (e.params.length === 0) return `'${e.pattern}'`;
520
636
  let t = e.pattern;
521
637
  for (let n of e.params) {
@@ -523,21 +639,21 @@ __installPublicEnv(publicEnvValues)
523
639
  t = t.replace(e, r);
524
640
  }
525
641
  return "`" + t + "`";
526
- }, mt = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
642
+ }, Ot = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
527
643
  let t = "string";
528
644
  return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
529
- }).join("; ")} }`, ht = (e, t, n) => {
530
- let r = mt(e), i = pt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
645
+ }).join("; ")} }`, kt = (e, t, n) => {
646
+ let r = Ot(e), i = Dt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
531
647
  return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
532
- }, gt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${ht(e, !1)},`).join("\n")}\n}`, _t = (e, t) => {
648
+ }, At = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${kt(e, !1)},`).join("\n")}\n}`, jt = (e, t) => {
533
649
  if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
534
- 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)}: ${ht(e, !0, i)},`);
650
+ 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)}: ${kt(e, !0, i)},`);
535
651
  return ` ${e.key}: {\n${a.join("\n")}\n },`;
536
- }, vt = async (e) => {
652
+ }, Mt = async (e) => {
537
653
  let n = e.pages.map((e) => ({
538
654
  pattern: e.pattern,
539
- params: lt(e.pattern)
540
- })), i = await ft(e.appRoot), a = [
655
+ params: Ct(e.pattern)
656
+ })), i = await Et(e.appRoot), a = [
541
657
  "// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
542
658
  "// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
543
659
  "// Type-safe route builders consumed by <Link to={...}>.",
@@ -546,7 +662,7 @@ __installPublicEnv(publicEnvValues)
546
662
  "",
547
663
  "type EmptyParams = Record<string, never>",
548
664
  ""
549
- ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${gt(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => _t(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
665
+ ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${At(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => jt(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
550
666
  await S.mkdir(t(c), { recursive: !0 });
551
667
  let l = null;
552
668
  try {
@@ -559,16 +675,16 @@ __installPublicEnv(publicEnvValues)
559
675
  path: c,
560
676
  wrote: !0
561
677
  });
562
- }, yt = (e) => {
563
- let t = ie(e.contract), n = (e.plugins ?? []).flatMap((e) => ce(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : M, i = /* @__PURE__ */ new Set(), a = [];
678
+ }, Nt = (e) => {
679
+ let t = P(e.contract), n = (e.plugins ?? []).flatMap((e) => I(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : re, i = /* @__PURE__ */ new Set(), a = [];
564
680
  for (let e of [
565
681
  ...t,
566
682
  ...n,
567
683
  ...r
568
684
  ]) i.has(e.key) || (i.add(e.key), a.push(e));
569
685
  return a;
570
- }, bt = (e, t, n = (e) => process.env[e]) => {
571
- let r = yt(t).map((e) => {
686
+ }, Pt = (e, t, n = (e) => process.env[e]) => {
687
+ let r = Nt(t).map((e) => {
572
688
  let t = n(e.key) !== void 0;
573
689
  return {
574
690
  ...e,
@@ -585,17 +701,17 @@ __installPublicEnv(publicEnvValues)
585
701
  missingRequired: r.filter((e) => e.required && !e.isSet && e.default === void 0).length
586
702
  }
587
703
  };
588
- }, xt = (e, t) => P(yt({
704
+ }, Ft = (e, t) => se(Nt({
589
705
  ...e,
590
706
  includeFramework: !1
591
707
  }), {
592
708
  includeFramework: e.includeFramework !== !1,
593
709
  ...t ? { header: t } : {}
594
- }), B = "/_voltro/inspect", V = () => process.env.VOLTRO_INSPECT === "off", H = (e) => {
710
+ }), H = "/_voltro/inspect", U = () => process.env.VOLTRO_INSPECT === "off", W = (e) => {
595
711
  let t = process.env.VOLTRO_INSPECT_TOKEN;
596
712
  if (!t || t.length === 0) return { ok: !0 };
597
713
  let n = e.authorization ?? e.Authorization;
598
- return n ? n.startsWith("Bearer ") ? pe(n.slice(7).trim(), t) ? { ok: !0 } : {
714
+ return n ? n.startsWith("Bearer ") ? fe(n.slice(7).trim(), t) ? { ok: !0 } : {
599
715
  ok: !1,
600
716
  reason: "token mismatch"
601
717
  } : {
@@ -605,7 +721,7 @@ __installPublicEnv(publicEnvValues)
605
721
  ok: !1,
606
722
  reason: "missing Authorization header"
607
723
  };
608
- }, St = (e) => {
724
+ }, It = (e) => {
609
725
  if (!Array.isArray(e) || e.length === 0) return;
610
726
  let t = [];
611
727
  for (let n of e) {
@@ -627,25 +743,25 @@ __installPublicEnv(publicEnvValues)
627
743
  });
628
744
  }
629
745
  return t.length > 0 ? t : void 0;
630
- }, U = (e, t, n = {}) => ({
746
+ }, G = (e, t, n = {}) => ({
631
747
  status: e,
632
748
  contentType: "application/json; charset=utf-8",
633
749
  body: JSON.stringify(t),
634
750
  headers: n
635
- }), W = (e) => !e || e.length === 0 ? {} : {
751
+ }), K = (e) => !e || e.length === 0 ? {} : {
636
752
  "access-control-allow-origin": e,
637
753
  "access-control-allow-credentials": "true",
638
754
  "access-control-allow-methods": "GET, POST, OPTIONS",
639
755
  "access-control-allow-headers": "authorization, content-type, accept",
640
756
  "access-control-expose-headers": "content-type, content-length",
641
757
  vary: "Origin"
642
- }, G = (e) => {
758
+ }, q = (e) => {
643
759
  let t = e.indexOf("?");
644
760
  return t === -1 ? e : e.slice(0, t);
645
- }, Ct = (e) => {
761
+ }, Lt = (e) => {
646
762
  let t = e.indexOf("?");
647
763
  return t === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
648
- }, wt = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), Tt = [
764
+ }, Rt = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), zt = [
649
765
  "text",
650
766
  "textarea",
651
767
  "number",
@@ -661,7 +777,7 @@ __installPublicEnv(publicEnvValues)
661
777
  "file",
662
778
  "hidden",
663
779
  "custom"
664
- ], Et = (e, t, n = []) => ({
780
+ ], Bt = (e, t, n = []) => ({
665
781
  version: 2,
666
782
  procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
667
783
  tag: e.tag,
@@ -675,7 +791,7 @@ __installPublicEnv(publicEnvValues)
675
791
  ...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
676
792
  })),
677
793
  workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
678
- widgets: Tt,
794
+ widgets: zt,
679
795
  tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
680
796
  name: e.name,
681
797
  reactive: e.isReactive,
@@ -688,58 +804,58 @@ __installPublicEnv(publicEnvValues)
688
804
  ...e.oneOf === void 0 ? {} : { enum: e.oneOf }
689
805
  }))
690
806
  }))
691
- }), Dt = (e, t, n = {}, r = {}) => {
692
- let i = G(e);
693
- if (!wt(i)) return null;
694
- let a = W(n.origin ?? n.Origin);
807
+ }), Vt = (e, t, n = {}, r = {}) => {
808
+ let i = q(e);
809
+ if (!Rt(i)) return null;
810
+ let a = K(n.origin ?? n.Origin);
695
811
  if ((r.method ?? "GET").toUpperCase() === "OPTIONS") return {
696
812
  status: 204,
697
813
  contentType: "text/plain",
698
814
  body: "",
699
815
  headers: a
700
816
  };
701
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
702
- let o = (r.authResolver ?? H)(n);
703
- if (!o.ok) return U(401, {
817
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
818
+ let o = (r.authResolver ?? W)(n);
819
+ if (!o.ok) return G(401, {
704
820
  error: "unauthorized",
705
821
  reason: o.reason
706
822
  }, a);
707
- if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return U(200, {
823
+ if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return G(200, {
708
824
  kind: t.kind,
709
825
  ...t.meta
710
826
  }, a);
711
- if (i === "/_voltro/inspect/routes") return t.kind === "web" ? U(200, {
827
+ if (i === "/_voltro/inspect/routes") return t.kind === "web" ? G(200, {
712
828
  pages: t.routes,
713
829
  dirs: t.dirs
714
- }, a) : U(404, { error: "routes endpoint is web-only" }, a);
715
- if (i === "/_voltro/inspect/cache") return t.kind === "web" ? U(200, t.cache(), a) : U(404, { error: "cache endpoint is web-only" }, a);
716
- if (i === "/_voltro/inspect/rpc") return t.kind === "api" ? U(200, {
830
+ }, a) : G(404, { error: "routes endpoint is web-only" }, a);
831
+ if (i === "/_voltro/inspect/cache") return t.kind === "web" ? G(200, t.cache(), a) : G(404, { error: "cache endpoint is web-only" }, a);
832
+ if (i === "/_voltro/inspect/rpc") return t.kind === "api" ? G(200, {
717
833
  procedures: t.rpc,
718
834
  workflows: t.workflows
719
- }, a) : U(404, { error: "rpc endpoint is api-only" }, a);
835
+ }, a) : G(404, { error: "rpc endpoint is api-only" }, a);
720
836
  if (i === "/_voltro/inspect/manifest") {
721
- if (t.kind !== "api") return U(404, { error: "manifest endpoint is api-only" }, a);
837
+ if (t.kind !== "api") return G(404, { error: "manifest endpoint is api-only" }, a);
722
838
  let e = t.inspectTables?.().tables ?? [];
723
- return U(200, Et(t.rpc, t.workflows, e), a);
839
+ return G(200, Bt(t.rpc, t.workflows, e), a);
724
840
  }
725
- return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? U(200, [], a) : U(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? U(200, {
841
+ return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? G(200, [], a) : G(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? G(200, {
726
842
  subscriptions: [],
727
843
  matcherStats: [],
728
844
  capturedAt: Date.now()
729
- }, a) : U(200, t.subscriptions(), a) : U(404, { error: "subscriptions endpoint is api-only" }, a) : i === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? U(200, {
845
+ }, a) : G(200, t.subscriptions(), a) : G(404, { error: "subscriptions endpoint is api-only" }, a) : i === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? G(200, {
730
846
  backend: "memory",
731
847
  engine: "memory",
732
848
  driver: "resp",
733
849
  hits: 0,
734
850
  misses: 0,
735
851
  hitRate: 0
736
- }, a) : U(200, t.dataCache(), a) : U(404, { error: "data-cache endpoint is api-only" }, a) : i === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? U(200, {
852
+ }, a) : G(200, t.dataCache(), a) : G(404, { error: "data-cache endpoint is api-only" }, a) : i === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? G(200, {
737
853
  migrations: [],
738
854
  seeds: []
739
- }, a) : U(200, t.database(), a) : U(404, { error: "database endpoint is api-only" }, a) : i === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? U(200, {
855
+ }, a) : G(200, t.database(), a) : G(404, { error: "database endpoint is api-only" }, a) : i === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? G(200, {
740
856
  plugins: [],
741
857
  capturedAt: Date.now()
742
- }, a) : U(200, t.plugins(), a) : U(404, { error: "plugins endpoint is api-only" }, a) : i === "/_voltro/inspect/env" ? t.env === void 0 ? U(200, {
858
+ }, a) : G(200, t.plugins(), a) : G(404, { error: "plugins endpoint is api-only" }, a) : i === "/_voltro/inspect/env" ? t.env === void 0 ? G(200, {
743
859
  app: t.meta.name ?? "app",
744
860
  entries: [],
745
861
  summary: {
@@ -747,34 +863,34 @@ __installPublicEnv(publicEnvValues)
747
863
  set: 0,
748
864
  missingRequired: 0
749
865
  }
750
- }, a) : U(200, t.env(), a) : i === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? U(200, { tables: [] }, a) : U(200, t.inspectTables(), a) : U(404, { error: "data viewer is api-only" }, a) : i === "/_voltro/inspect/invoke" ? U(404, { error: "invoke not enabled here — use POST handler" }, a) : U(404, {
866
+ }, a) : G(200, t.env(), a) : i === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? G(200, { tables: [] }, a) : G(200, t.inspectTables(), a) : G(404, { error: "data viewer is api-only" }, a) : i === "/_voltro/inspect/invoke" ? G(404, { error: "invoke not enabled here — use POST handler" }, a) : G(404, {
751
867
  error: "unknown inspect endpoint",
752
868
  path: i
753
869
  }, a);
754
- }, Ot = async (e, t, n, r = {}) => {
755
- let i = W(t.origin ?? t.Origin);
756
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
757
- if ((r.method ?? "POST").toUpperCase() !== "POST") return U(405, {
870
+ }, Ht = async (e, t, n, r = {}) => {
871
+ let i = K(t.origin ?? t.Origin);
872
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
873
+ if ((r.method ?? "POST").toUpperCase() !== "POST") return G(405, {
758
874
  error: "method not allowed",
759
875
  expected: "POST"
760
876
  }, i);
761
- let a = (r.authResolver ?? H)(t);
762
- if (!a.ok) return U(401, {
877
+ let a = (r.authResolver ?? W)(t);
878
+ if (!a.ok) return G(401, {
763
879
  error: "unauthorized",
764
880
  reason: a.reason
765
881
  }, i);
766
- if (e.kind !== "api") return U(404, { error: "invoke endpoint is api-only" }, i);
767
- if (!e.invokers || e.invokers.size === 0) return U(404, { error: "invoke not configured" }, i);
882
+ if (e.kind !== "api") return G(404, { error: "invoke endpoint is api-only" }, i);
883
+ if (!e.invokers || e.invokers.size === 0) return G(404, { error: "invoke not configured" }, i);
768
884
  let o;
769
885
  try {
770
886
  o = JSON.parse(n || "{}");
771
887
  } catch {
772
- return U(400, { error: "body must be JSON" }, i);
888
+ return G(400, { error: "body must be JSON" }, i);
773
889
  }
774
890
  let s = o;
775
- if (typeof s.tag != "string") return U(400, { error: "body.tag must be a string" }, i);
891
+ if (typeof s.tag != "string") return G(400, { error: "body.tag must be a string" }, i);
776
892
  let c = e.invokers.get(s.tag);
777
- if (!c) return U(404, {
893
+ if (!c) return G(404, {
778
894
  error: "unknown tag",
779
895
  tag: s.tag
780
896
  }, i);
@@ -784,167 +900,167 @@ __installPublicEnv(publicEnvValues)
784
900
  let n = e.toLowerCase();
785
901
  n !== "cookie" && (u[n] = t);
786
902
  }
787
- return U(200, await c(s.input, u), i);
788
- }, kt = async (e, t, n, r, i = {}) => {
789
- let a = G(e);
790
- if (!wt(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
791
- let o = W(n.origin ?? n.Origin);
903
+ return G(200, await c(s.input, u), i);
904
+ }, Ut = async (e, t, n, r, i = {}) => {
905
+ let a = q(e);
906
+ if (!Rt(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
907
+ let o = K(n.origin ?? n.Origin);
792
908
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
793
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
794
- let s = (i.authResolver ?? H)(n);
795
- if (!s.ok) return U(401, {
909
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
910
+ let s = (i.authResolver ?? W)(n);
911
+ if (!s.ok) return G(401, {
796
912
  error: "unauthorized",
797
913
  reason: s.reason
798
914
  }, o);
799
- if (t.kind !== "api") return U(404, { error: "webhook actions are api-only" }, o);
800
- if (!t.webhookActions) return U(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, o);
915
+ if (t.kind !== "api") return G(404, { error: "webhook actions are api-only" }, o);
916
+ if (!t.webhookActions) return G(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, o);
801
917
  let c;
802
918
  try {
803
919
  c = JSON.parse(r || "{}");
804
920
  } catch {
805
- return U(400, { error: "body must be JSON" }, o);
921
+ return G(400, { error: "body must be JSON" }, o);
806
922
  }
807
- let l = a.slice(`${B}/webhooks/`.length);
923
+ let l = a.slice(`${H}/webhooks/`.length);
808
924
  try {
809
925
  switch (l) {
810
926
  case "subscribe": {
811
927
  let e = c;
812
- return typeof e.event != "string" || e.event.length === 0 ? U(400, { error: "event required" }, o) : typeof e.url != "string" || e.url.length === 0 ? U(400, { error: "url required" }, o) : U(200, await t.webhookActions.subscribe(e), o);
928
+ return typeof e.event != "string" || e.event.length === 0 ? G(400, { error: "event required" }, o) : typeof e.url != "string" || e.url.length === 0 ? G(400, { error: "url required" }, o) : G(200, await t.webhookActions.subscribe(e), o);
813
929
  }
814
930
  case "pause": {
815
931
  let e = c.targetId;
816
- return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.pause(e), U(200, { ok: !0 }, o));
932
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "targetId required" }, o) : (await t.webhookActions.pause(e), G(200, { ok: !0 }, o));
817
933
  }
818
934
  case "resume": {
819
935
  let e = c.targetId;
820
- return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.resume(e), U(200, { ok: !0 }, o));
936
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "targetId required" }, o) : (await t.webhookActions.resume(e), G(200, { ok: !0 }, o));
821
937
  }
822
938
  case "delete": {
823
939
  let e = c.targetId;
824
- return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.delete(e), U(200, { ok: !0 }, o));
940
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "targetId required" }, o) : (await t.webhookActions.delete(e), G(200, { ok: !0 }, o));
825
941
  }
826
942
  case "rotateSecret": {
827
943
  let e = c.targetId;
828
- return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : U(200, await t.webhookActions.rotateSecret(e), o);
944
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "targetId required" }, o) : G(200, await t.webhookActions.rotateSecret(e), o);
829
945
  }
830
946
  case "replay": {
831
947
  let e = c.deliveryId;
832
- return typeof e != "string" || e.length === 0 ? U(400, { error: "deliveryId required" }, o) : (await t.webhookActions.replay(e), U(200, { ok: !0 }, o));
948
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "deliveryId required" }, o) : (await t.webhookActions.replay(e), G(200, { ok: !0 }, o));
833
949
  }
834
950
  case "repinVersion": {
835
951
  let e = c.targetId, n = c.version;
836
- return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? U(400, { error: "version must be a positive integer" }, o) : (await t.webhookActions.updateTargetPayloadVersion(e, n), U(200, { ok: !0 }, o));
952
+ return typeof e != "string" || e.length === 0 ? G(400, { error: "targetId required" }, o) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? G(400, { error: "version must be a positive integer" }, o) : (await t.webhookActions.updateTargetPayloadVersion(e, n), G(200, { ok: !0 }, o));
837
953
  }
838
- default: return U(404, { error: `unknown webhook action: ${l}` }, o);
954
+ default: return G(404, { error: `unknown webhook action: ${l}` }, o);
839
955
  }
840
956
  } catch (e) {
841
- return U(500, {
957
+ return G(500, {
842
958
  error: "webhook action failed",
843
959
  message: e?.message ?? String(e)
844
960
  }, o);
845
961
  }
846
- }, At = async (e, t, n, r, i = {}) => {
847
- let a = G(e);
848
- if (!wt(a)) return null;
849
- let o = W(n.origin ?? n.Origin);
962
+ }, Wt = async (e, t, n, r, i = {}) => {
963
+ let a = q(e);
964
+ if (!Rt(a)) return null;
965
+ let o = K(n.origin ?? n.Origin);
850
966
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
851
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
852
- let s = (i.authResolver ?? H)(n);
853
- if (!s.ok) return U(401, {
967
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
968
+ let s = (i.authResolver ?? W)(n);
969
+ if (!s.ok) return G(401, {
854
970
  error: "unauthorized",
855
971
  reason: s.reason
856
972
  }, o);
857
- if (t.kind !== "api") return U(404, { error: "framework-action endpoints are api-only" }, o);
858
- let c = `${B}/seeds/run`, l = `${B}/migrations/rollback`, u = `${B}/migrations/squash`, d = `${B}/migrations/restore-snapshot`;
973
+ if (t.kind !== "api") return G(404, { error: "framework-action endpoints are api-only" }, o);
974
+ let c = `${H}/seeds/run`, l = `${H}/migrations/rollback`, u = `${H}/migrations/squash`, d = `${H}/migrations/restore-snapshot`;
859
975
  if (a !== c && a !== l && a !== u && a !== d && a !== "/_voltro/inspect/migrations/compare-env") return null;
860
976
  let f;
861
977
  try {
862
978
  f = JSON.parse(r || "{}");
863
979
  } catch {
864
- return U(400, { error: "body must be JSON" }, o);
980
+ return G(400, { error: "body must be JSON" }, o);
865
981
  }
866
982
  try {
867
- if (a === c) return typeof f.id != "string" || f.id.length === 0 ? U(400, { error: "body.id must be a non-empty string" }, o) : t.runSeed ? U(200, await t.runSeed(f.id), o) : U(404, { error: "runSeed not configured" }, o);
868
- if (a === l) return typeof f.id != "string" || f.id.length === 0 ? U(400, { error: "body.id must be a non-empty string" }, o) : t.rollbackMigration ? U(200, await t.rollbackMigration(f.id), o) : U(404, { error: "rollbackMigration not configured" }, o);
983
+ if (a === c) return typeof f.id != "string" || f.id.length === 0 ? G(400, { error: "body.id must be a non-empty string" }, o) : t.runSeed ? G(200, await t.runSeed(f.id), o) : G(404, { error: "runSeed not configured" }, o);
984
+ if (a === l) return typeof f.id != "string" || f.id.length === 0 ? G(400, { error: "body.id must be a non-empty string" }, o) : t.rollbackMigration ? G(200, await t.rollbackMigration(f.id), o) : G(404, { error: "rollbackMigration not configured" }, o);
869
985
  if (a === u) {
870
- if (typeof f.before != "string" || f.before.length === 0) return U(400, { error: "body.before must be a non-empty ISO date string" }, o);
871
- if (!t.squashMigrationHistory) return U(404, { error: "squashMigrationHistory not configured" }, o);
986
+ if (typeof f.before != "string" || f.before.length === 0) return G(400, { error: "body.before must be a non-empty ISO date string" }, o);
987
+ if (!t.squashMigrationHistory) return G(404, { error: "squashMigrationHistory not configured" }, o);
872
988
  let e = typeof f.note == "string" ? f.note : void 0;
873
- return U(200, await t.squashMigrationHistory({
989
+ return G(200, await t.squashMigrationHistory({
874
990
  before: f.before,
875
991
  note: e
876
992
  }), o);
877
993
  }
878
- return a === d ? typeof f.planId != "string" || f.planId.length === 0 ? U(400, { error: "body.planId must be a non-empty string" }, o) : t.restoreSnapshot ? U(200, await t.restoreSnapshot({ planId: f.planId }), o) : U(404, { error: "restoreSnapshot not configured" }, o) : typeof f.url != "string" || f.url.length === 0 ? U(400, { error: "body.url must be a non-empty URL string" }, o) : t.compareCrossEnv ? (await t.compareCrossEnv({
994
+ return a === d ? typeof f.planId != "string" || f.planId.length === 0 ? G(400, { error: "body.planId must be a non-empty string" }, o) : t.restoreSnapshot ? G(200, await t.restoreSnapshot({ planId: f.planId }), o) : G(404, { error: "restoreSnapshot not configured" }, o) : typeof f.url != "string" || f.url.length === 0 ? G(400, { error: "body.url must be a non-empty URL string" }, o) : t.compareCrossEnv ? (await t.compareCrossEnv({
879
995
  url: f.url,
880
996
  label: typeof f.label == "string" ? f.label : void 0,
881
997
  token: typeof f.token == "string" ? f.token : void 0
882
- }), U(200, { ok: !0 }, o)) : U(404, { error: "compareCrossEnv not configured" }, o);
998
+ }), G(200, { ok: !0 }, o)) : G(404, { error: "compareCrossEnv not configured" }, o);
883
999
  } catch (e) {
884
- return U(500, {
1000
+ return G(500, {
885
1001
  error: "framework action failed",
886
1002
  message: e?.message ?? String(e)
887
1003
  }, o);
888
1004
  }
889
- }, jt = async (e, t, n, r = {}) => {
890
- if (G(e) !== "/_voltro/inspect/data/rows") return null;
891
- let i = W(n.origin ?? n.Origin);
892
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1005
+ }, Gt = async (e, t, n, r = {}) => {
1006
+ if (q(e) !== "/_voltro/inspect/data/rows") return null;
1007
+ let i = K(n.origin ?? n.Origin);
1008
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
893
1009
  error: "method not allowed",
894
1010
  expected: "GET"
895
1011
  }, i);
896
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
897
- let a = (r.authResolver ?? H)(n);
898
- if (!a.ok) return U(401, {
1012
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1013
+ let a = (r.authResolver ?? W)(n);
1014
+ if (!a.ok) return G(401, {
899
1015
  error: "unauthorized",
900
1016
  reason: a.reason
901
1017
  }, i);
902
- if (t.kind !== "api") return U(404, { error: "data viewer is api-only" }, i);
903
- if (t.inspectRows === void 0) return U(404, { error: "inspectRows not configured" }, i);
904
- let o = K(e), s = o.get("table");
905
- if (!s) return U(400, { error: "query.table is required" }, i);
906
- let c = q(o.get("offset")) ?? 0, l = q(o.get("limit")) ?? 50, u = {}, d = o.get("q");
1018
+ if (t.kind !== "api") return G(404, { error: "data viewer is api-only" }, i);
1019
+ if (t.inspectRows === void 0) return G(404, { error: "inspectRows not configured" }, i);
1020
+ let o = J(e), s = o.get("table");
1021
+ if (!s) return G(400, { error: "query.table is required" }, i);
1022
+ let c = Y(o.get("offset")) ?? 0, l = Y(o.get("limit")) ?? 50, u = {}, d = o.get("q");
907
1023
  if (d) {
908
- if (d.length > 8192) return U(400, { error: "query.q too large" }, i);
1024
+ if (d.length > 8192) return G(400, { error: "query.q too large" }, i);
909
1025
  try {
910
1026
  u = JSON.parse(Buffer.from(d, "base64url").toString("utf8"));
911
1027
  } catch {
912
- return U(400, { error: "query.q is not valid base64url JSON" }, i);
1028
+ return G(400, { error: "query.q is not valid base64url JSON" }, i);
913
1029
  }
914
1030
  }
915
1031
  try {
916
- return U(200, await t.inspectRows({
1032
+ return G(200, await t.inspectRows({
917
1033
  table: s,
918
1034
  offset: c,
919
1035
  limit: l,
920
1036
  ...u
921
1037
  }), i);
922
1038
  } catch (e) {
923
- return e?.name === "InspectQueryError" ? U(400, {
1039
+ return e?.name === "InspectQueryError" ? G(400, {
924
1040
  error: "invalid query",
925
1041
  message: e.message
926
- }, i) : U(500, {
1042
+ }, i) : G(500, {
927
1043
  error: "data-rows query failed",
928
1044
  message: e?.message ?? String(e)
929
1045
  }, i);
930
1046
  }
931
- }, Mt = async (e, t, n, r = {}) => {
932
- if (G(e) !== "/_voltro/inspect/provenance") return null;
933
- let i = W(n.origin ?? n.Origin);
934
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1047
+ }, Kt = async (e, t, n, r = {}) => {
1048
+ if (q(e) !== "/_voltro/inspect/provenance") return null;
1049
+ let i = K(n.origin ?? n.Origin);
1050
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
935
1051
  error: "method not allowed",
936
1052
  expected: "GET"
937
1053
  }, i);
938
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
939
- let a = (r.authResolver ?? H)(n);
940
- if (!a.ok) return U(401, {
1054
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1055
+ let a = (r.authResolver ?? W)(n);
1056
+ if (!a.ok) return G(401, {
941
1057
  error: "unauthorized",
942
1058
  reason: a.reason
943
1059
  }, i);
944
- if (t.kind !== "api") return U(404, { error: "provenance is api-only" }, i);
945
- if (t.inspectRows === void 0) return U(404, { error: "inspectRows not configured" }, i);
946
- let o = K(e), s = o.get("table"), c = o.get("id"), l = o.get("column") ?? void 0;
947
- if (!s || !c) return U(400, { error: "query.table and query.id are required" }, i);
1060
+ if (t.kind !== "api") return G(404, { error: "provenance is api-only" }, i);
1061
+ if (t.inspectRows === void 0) return G(404, { error: "inspectRows not configured" }, i);
1062
+ let o = J(e), s = o.get("table"), c = o.get("id"), l = o.get("column") ?? void 0;
1063
+ if (!s || !c) return G(400, { error: "query.table and query.id are required" }, i);
948
1064
  try {
949
1065
  let e = (await t.inspectRows({
950
1066
  table: s,
@@ -956,175 +1072,175 @@ __installPublicEnv(publicEnvValues)
956
1072
  value: c
957
1073
  }
958
1074
  })).rows[0];
959
- return U(200, te(e, {
1075
+ return G(200, k(e, {
960
1076
  table: s,
961
1077
  id: c,
962
1078
  ...l === void 0 ? {} : { column: l }
963
1079
  }), i);
964
1080
  } catch (e) {
965
- return e?.name === "InspectQueryError" ? U(400, {
1081
+ return e?.name === "InspectQueryError" ? G(400, {
966
1082
  error: "invalid query",
967
1083
  message: e.message
968
- }, i) : U(500, {
1084
+ }, i) : G(500, {
969
1085
  error: "provenance query failed",
970
1086
  message: e?.message ?? String(e)
971
1087
  }, i);
972
1088
  }
973
- }, K = (e) => {
1089
+ }, J = (e) => {
974
1090
  let t = e.indexOf("?");
975
1091
  return t < 0 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
976
- }, q = (e) => {
1092
+ }, Y = (e) => {
977
1093
  if (e === null || e === "") return;
978
1094
  let t = Number(e);
979
1095
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
980
- }, Nt = async (e, t, n, r = {}) => {
981
- if (G(e) !== "/_voltro/inspect/workflows/runs") return null;
982
- let i = W(n.origin ?? n.Origin);
983
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1096
+ }, qt = async (e, t, n, r = {}) => {
1097
+ if (q(e) !== "/_voltro/inspect/workflows/runs") return null;
1098
+ let i = K(n.origin ?? n.Origin);
1099
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
984
1100
  error: "method not allowed",
985
1101
  expected: "GET"
986
1102
  }, i);
987
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
988
- let a = (r.authResolver ?? H)(n);
989
- if (!a.ok) return U(401, {
1103
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1104
+ let a = (r.authResolver ?? W)(n);
1105
+ if (!a.ok) return G(401, {
990
1106
  error: "unauthorized",
991
1107
  reason: a.reason
992
1108
  }, i);
993
- if (t.kind !== "api") return U(404, { error: "workflows endpoint is api-only" }, i);
994
- if (t.inspectWorkflowRuns === void 0) return U(200, {
1109
+ if (t.kind !== "api") return G(404, { error: "workflows endpoint is api-only" }, i);
1110
+ if (t.inspectWorkflowRuns === void 0) return G(200, {
995
1111
  runs: [],
996
1112
  total: 0,
997
1113
  offset: 0,
998
1114
  limit: 50
999
1115
  }, i);
1000
- let o = K(e);
1116
+ let o = J(e);
1001
1117
  try {
1002
- return U(200, await t.inspectWorkflowRuns({
1118
+ return G(200, await t.inspectWorkflowRuns({
1003
1119
  ...o.get("tag") === null ? {} : { tag: o.get("tag") },
1004
1120
  ...o.get("status") === null ? {} : { status: o.get("status") },
1005
- offset: q(o.get("offset")) ?? 0,
1006
- limit: q(o.get("limit")) ?? 50
1121
+ offset: Y(o.get("offset")) ?? 0,
1122
+ limit: Y(o.get("limit")) ?? 50
1007
1123
  }), i);
1008
1124
  } catch (e) {
1009
- return U(500, {
1125
+ return G(500, {
1010
1126
  error: "workflow-runs query failed",
1011
1127
  message: e?.message ?? String(e)
1012
1128
  }, i);
1013
1129
  }
1014
- }, Pt = async (e, t, n, r, i = {}) => {
1015
- let a = G(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
1130
+ }, Jt = async (e, t, n, r, i = {}) => {
1131
+ let a = q(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
1016
1132
  if (!a) return null;
1017
- let o = decodeURIComponent(a[1] ?? ""), s = W(n.origin ?? n.Origin);
1018
- if ((i.method ?? "POST").toUpperCase() !== "POST") return U(405, {
1133
+ let o = decodeURIComponent(a[1] ?? ""), s = K(n.origin ?? n.Origin);
1134
+ if ((i.method ?? "POST").toUpperCase() !== "POST") return G(405, {
1019
1135
  error: "method not allowed",
1020
1136
  expected: "POST"
1021
1137
  }, s);
1022
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1023
- let c = (i.authResolver ?? H)(n);
1024
- if (!c.ok) return U(401, {
1138
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1139
+ let c = (i.authResolver ?? W)(n);
1140
+ if (!c.ok) return G(401, {
1025
1141
  error: "unauthorized",
1026
1142
  reason: c.reason
1027
1143
  }, s);
1028
- if (t.kind !== "api") return U(404, { error: "workflow start is api-only" }, s);
1029
- if (t.inspectStartWorkflow === void 0) return U(404, { error: "inspectStartWorkflow not configured" }, s);
1144
+ if (t.kind !== "api") return G(404, { error: "workflow start is api-only" }, s);
1145
+ if (t.inspectStartWorkflow === void 0) return G(404, { error: "inspectStartWorkflow not configured" }, s);
1030
1146
  let l = {};
1031
1147
  if (r.length > 0) try {
1032
1148
  l = JSON.parse(r).payload ?? {};
1033
1149
  } catch {
1034
- return U(400, { error: "start requires JSON body `{ payload?: unknown }`" }, s);
1150
+ return G(400, { error: "start requires JSON body `{ payload?: unknown }`" }, s);
1035
1151
  }
1036
1152
  try {
1037
- return U(200, await t.inspectStartWorkflow({
1153
+ return G(200, await t.inspectStartWorkflow({
1038
1154
  name: o,
1039
1155
  payload: l
1040
1156
  }), s);
1041
1157
  } catch (e) {
1042
- return U(500, {
1158
+ return G(500, {
1043
1159
  error: "workflow start failed",
1044
1160
  message: e?.message ?? String(e)
1045
1161
  }, s);
1046
1162
  }
1047
- }, Ft = async (e, t, n, r = {}) => {
1048
- let i = G(e);
1163
+ }, Yt = async (e, t, n, r = {}) => {
1164
+ let i = q(e);
1049
1165
  if (!i.startsWith("/_voltro/inspect/schedules")) return null;
1050
- let a = W(n.origin ?? n.Origin);
1051
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1052
- let o = (r.authResolver ?? H)(n);
1053
- if (!o.ok) return U(401, {
1166
+ let a = K(n.origin ?? n.Origin);
1167
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1168
+ let o = (r.authResolver ?? W)(n);
1169
+ if (!o.ok) return G(401, {
1054
1170
  error: "unauthorized",
1055
1171
  reason: o.reason
1056
1172
  }, a);
1057
- if (t.kind !== "api") return U(404, { error: "schedules are api-only" }, a);
1173
+ if (t.kind !== "api") return G(404, { error: "schedules are api-only" }, a);
1058
1174
  let s = (r.method ?? "GET").toUpperCase(), c = i.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/fire$/);
1059
1175
  if (c) {
1060
- if (s !== "POST") return U(405, {
1176
+ if (s !== "POST") return G(405, {
1061
1177
  error: "method not allowed",
1062
1178
  expected: "POST"
1063
1179
  }, a);
1064
- if (!t.inspectFireSchedule) return U(404, { error: "inspectFireSchedule not configured" }, a);
1065
- let n = decodeURIComponent(c[1] ?? ""), r = K(e).get("trigger") === "external" ? "external" : "manual";
1180
+ if (!t.inspectFireSchedule) return G(404, { error: "inspectFireSchedule not configured" }, a);
1181
+ let n = decodeURIComponent(c[1] ?? ""), r = J(e).get("trigger") === "external" ? "external" : "manual";
1066
1182
  try {
1067
- return U(200, await t.inspectFireSchedule({
1183
+ return G(200, await t.inspectFireSchedule({
1068
1184
  name: n,
1069
1185
  trigger: r
1070
1186
  }), a);
1071
1187
  } catch (e) {
1072
- return U(500, {
1188
+ return G(500, {
1073
1189
  error: "fire failed",
1074
1190
  message: e?.message ?? String(e)
1075
1191
  }, a);
1076
1192
  }
1077
1193
  }
1078
1194
  if (i === "/_voltro/inspect/schedules/runs") {
1079
- if (s !== "GET") return U(405, {
1195
+ if (s !== "GET") return G(405, {
1080
1196
  error: "method not allowed",
1081
1197
  expected: "GET"
1082
1198
  }, a);
1083
- if (!t.inspectScheduleRuns) return U(200, {
1199
+ if (!t.inspectScheduleRuns) return G(200, {
1084
1200
  runs: [],
1085
1201
  total: 0,
1086
1202
  offset: 0,
1087
1203
  limit: 50
1088
1204
  }, a);
1089
- let n = K(e);
1205
+ let n = J(e);
1090
1206
  try {
1091
- return U(200, await t.inspectScheduleRuns({
1207
+ return G(200, await t.inspectScheduleRuns({
1092
1208
  ...n.get("name") === null ? {} : { name: n.get("name") },
1093
- offset: q(n.get("offset")) ?? 0,
1094
- limit: q(n.get("limit")) ?? 50
1209
+ offset: Y(n.get("offset")) ?? 0,
1210
+ limit: Y(n.get("limit")) ?? 50
1095
1211
  }), a);
1096
1212
  } catch (e) {
1097
- return U(500, {
1213
+ return G(500, {
1098
1214
  error: "schedule-runs query failed",
1099
1215
  message: e?.message ?? String(e)
1100
1216
  }, a);
1101
1217
  }
1102
1218
  }
1103
- return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ? U(200, t.inspectSchedules(), a) : U(200, {
1219
+ return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ? G(200, t.inspectSchedules(), a) : G(200, {
1104
1220
  schedules: [],
1105
1221
  coordination: "single"
1106
- }, a) : U(405, {
1222
+ }, a) : G(405, {
1107
1223
  error: "method not allowed",
1108
1224
  expected: "GET"
1109
- }, a) : U(404, {
1225
+ }, a) : G(404, {
1110
1226
  error: "unknown schedules endpoint",
1111
1227
  path: i
1112
1228
  }, a);
1113
- }, It = async (e, t, n, r = {}) => {
1114
- if (G(e) !== "/_voltro/inspect/cluster") return null;
1115
- let i = W(n.origin ?? n.Origin);
1116
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1117
- let a = (r.authResolver ?? H)(n);
1118
- if (!a.ok) return U(401, {
1229
+ }, Xt = async (e, t, n, r = {}) => {
1230
+ if (q(e) !== "/_voltro/inspect/cluster") return null;
1231
+ let i = K(n.origin ?? n.Origin);
1232
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1233
+ let a = (r.authResolver ?? W)(n);
1234
+ if (!a.ok) return G(401, {
1119
1235
  error: "unauthorized",
1120
1236
  reason: a.reason
1121
1237
  }, i);
1122
- if (t.kind !== "api") return U(404, { error: "cluster is api-only" }, i);
1123
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1238
+ if (t.kind !== "api") return G(404, { error: "cluster is api-only" }, i);
1239
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1124
1240
  error: "method not allowed",
1125
1241
  expected: "GET"
1126
1242
  }, i);
1127
- if (!t.cluster) return U(200, {
1243
+ if (!t.cluster) return G(200, {
1128
1244
  instance: {
1129
1245
  replicaId: process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`,
1130
1246
  dialect: "memory",
@@ -1149,163 +1265,163 @@ __installPublicEnv(publicEnvValues)
1149
1265
  capturedAt: Date.now()
1150
1266
  }, i);
1151
1267
  try {
1152
- return U(200, await t.cluster(), i);
1268
+ return G(200, await t.cluster(), i);
1153
1269
  } catch (e) {
1154
- return U(500, {
1270
+ return G(500, {
1155
1271
  error: "cluster snapshot failed",
1156
1272
  message: e?.message ?? String(e)
1157
1273
  }, i);
1158
1274
  }
1159
- }, Lt = async (e, t, n, r = {}) => {
1160
- let i = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
1275
+ }, Zt = async (e, t, n, r = {}) => {
1276
+ let i = q(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
1161
1277
  if (!i) return null;
1162
- let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1163
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1278
+ let a = decodeURIComponent(i[1] ?? ""), o = K(n.origin ?? n.Origin);
1279
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1164
1280
  error: "method not allowed",
1165
1281
  expected: "GET"
1166
1282
  }, o);
1167
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1168
- let s = (r.authResolver ?? H)(n);
1169
- if (!s.ok) return U(401, {
1283
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1284
+ let s = (r.authResolver ?? W)(n);
1285
+ if (!s.ok) return G(401, {
1170
1286
  error: "unauthorized",
1171
1287
  reason: s.reason
1172
1288
  }, o);
1173
- if (t.kind !== "api") return U(404, { error: "workflow steps are api-only" }, o);
1174
- if (t.inspectWorkflowRunSteps === void 0) return U(200, { steps: [] }, o);
1289
+ if (t.kind !== "api") return G(404, { error: "workflow steps are api-only" }, o);
1290
+ if (t.inspectWorkflowRunSteps === void 0) return G(200, { steps: [] }, o);
1175
1291
  try {
1176
- return U(200, await t.inspectWorkflowRunSteps({ runId: a }), o);
1292
+ return G(200, await t.inspectWorkflowRunSteps({ runId: a }), o);
1177
1293
  } catch (e) {
1178
- return U(500, {
1294
+ return G(500, {
1179
1295
  error: "steps query failed",
1180
1296
  message: e?.message ?? String(e)
1181
1297
  }, o);
1182
1298
  }
1183
- }, Rt = async (e, t, n, r = {}) => {
1184
- let i = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
1299
+ }, Qt = async (e, t, n, r = {}) => {
1300
+ let i = q(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
1185
1301
  if (!i) return null;
1186
- let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1187
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1302
+ let a = decodeURIComponent(i[1] ?? ""), o = K(n.origin ?? n.Origin);
1303
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1188
1304
  error: "method not allowed",
1189
1305
  expected: "GET"
1190
1306
  }, o);
1191
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1192
- let s = (r.authResolver ?? H)(n);
1193
- if (!s.ok) return U(401, {
1307
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1308
+ let s = (r.authResolver ?? W)(n);
1309
+ if (!s.ok) return G(401, {
1194
1310
  error: "unauthorized",
1195
1311
  reason: s.reason
1196
1312
  }, o);
1197
- if (t.kind !== "api") return U(404, { error: "workflow events are api-only" }, o);
1198
- if (t.inspectWorkflowRunEvents === void 0) return U(200, { events: [] }, o);
1313
+ if (t.kind !== "api") return G(404, { error: "workflow events are api-only" }, o);
1314
+ if (t.inspectWorkflowRunEvents === void 0) return G(200, { events: [] }, o);
1199
1315
  try {
1200
- return U(200, await t.inspectWorkflowRunEvents({ runId: a }), o);
1316
+ return G(200, await t.inspectWorkflowRunEvents({ runId: a }), o);
1201
1317
  } catch (e) {
1202
- return U(500, {
1318
+ return G(500, {
1203
1319
  error: "events query failed",
1204
1320
  message: e?.message ?? String(e)
1205
1321
  }, o);
1206
1322
  }
1207
- }, zt = async (e, t, n, r = {}) => {
1208
- if (G(t) !== "/_voltro/inspect/workflows/events") return null;
1209
- let i = W(n.origin ?? n.Origin);
1210
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1323
+ }, $t = async (e, t, n, r = {}) => {
1324
+ if (q(t) !== "/_voltro/inspect/workflows/events") return null;
1325
+ let i = K(n.origin ?? n.Origin);
1326
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1211
1327
  error: "method not allowed",
1212
1328
  expected: "GET"
1213
1329
  }, i);
1214
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1215
- let a = (r.authResolver ?? H)(n);
1216
- if (!a.ok) return U(401, {
1330
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1331
+ let a = (r.authResolver ?? W)(n);
1332
+ if (!a.ok) return G(401, {
1217
1333
  error: "unauthorized",
1218
1334
  reason: a.reason
1219
1335
  }, i);
1220
- if (e.kind !== "api") return U(404, { error: "workflow domain events are api-only" }, i);
1221
- if (e.inspectWorkflowDomainEvents === void 0) return U(200, {
1336
+ if (e.kind !== "api") return G(404, { error: "workflow domain events are api-only" }, i);
1337
+ if (e.inspectWorkflowDomainEvents === void 0) return G(200, {
1222
1338
  events: [],
1223
1339
  total: 0,
1224
1340
  offset: 0,
1225
1341
  limit: 100
1226
1342
  }, i);
1227
- let o = Ct(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1343
+ let o = Lt(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1228
1344
  try {
1229
- return U(200, await e.inspectWorkflowDomainEvents({
1345
+ return G(200, await e.inspectWorkflowDomainEvents({
1230
1346
  ...s !== void 0 && s !== "" ? { name: s } : {},
1231
1347
  offset: Number.isFinite(c) ? c : 0,
1232
1348
  limit: Number.isFinite(l) ? l : 100
1233
1349
  }), i);
1234
1350
  } catch (e) {
1235
- return U(500, {
1351
+ return G(500, {
1236
1352
  error: "workflow domain events query failed",
1237
1353
  message: e?.message ?? String(e)
1238
1354
  }, i);
1239
1355
  }
1240
- }, Bt = async (e, t, n, r = {}) => {
1241
- let i = G(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
1356
+ }, en = async (e, t, n, r = {}) => {
1357
+ let i = q(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
1242
1358
  if (!i) return null;
1243
- let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1244
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1359
+ let a = decodeURIComponent(i[1] ?? ""), o = K(n.origin ?? n.Origin);
1360
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1245
1361
  error: "method not allowed",
1246
1362
  expected: "GET"
1247
1363
  }, o);
1248
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1249
- let s = (r.authResolver ?? H)(n);
1250
- if (!s.ok) return U(401, {
1364
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1365
+ let s = (r.authResolver ?? W)(n);
1366
+ if (!s.ok) return G(401, {
1251
1367
  error: "unauthorized",
1252
1368
  reason: s.reason
1253
1369
  }, o);
1254
- if (e.kind !== "api") return U(404, { error: "workflow event deliveries are api-only" }, o);
1255
- if (e.inspectWorkflowEventDeliveries === void 0) return U(200, { deliveries: [] }, o);
1370
+ if (e.kind !== "api") return G(404, { error: "workflow event deliveries are api-only" }, o);
1371
+ if (e.inspectWorkflowEventDeliveries === void 0) return G(200, { deliveries: [] }, o);
1256
1372
  try {
1257
- return U(200, await e.inspectWorkflowEventDeliveries({ eventId: a }), o);
1373
+ return G(200, await e.inspectWorkflowEventDeliveries({ eventId: a }), o);
1258
1374
  } catch (e) {
1259
- return U(500, {
1375
+ return G(500, {
1260
1376
  error: "workflow event deliveries query failed",
1261
1377
  message: e?.message ?? String(e)
1262
1378
  }, o);
1263
1379
  }
1264
- }, Vt = async (e, t, n, r = {}) => {
1265
- if (G(e) !== "/_voltro/inspect/workflows/children") return null;
1266
- let i = W(n.origin ?? n.Origin);
1267
- if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1380
+ }, tn = async (e, t, n, r = {}) => {
1381
+ if (q(e) !== "/_voltro/inspect/workflows/children") return null;
1382
+ let i = K(n.origin ?? n.Origin);
1383
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return G(405, {
1268
1384
  error: "method not allowed",
1269
1385
  expected: "GET"
1270
1386
  }, i);
1271
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1272
- let a = (r.authResolver ?? H)(n);
1273
- if (!a.ok) return U(401, {
1387
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1388
+ let a = (r.authResolver ?? W)(n);
1389
+ if (!a.ok) return G(401, {
1274
1390
  error: "unauthorized",
1275
1391
  reason: a.reason
1276
1392
  }, i);
1277
- if (t.kind !== "api") return U(404, { error: "workflow children are api-only" }, i);
1278
- let o = K(e).get("parentExecutionId");
1279
- if (o === null || o === "") return U(400, { error: "parentExecutionId query param required" }, i);
1280
- if (t.inspectWorkflowChildren === void 0) return U(200, {
1393
+ if (t.kind !== "api") return G(404, { error: "workflow children are api-only" }, i);
1394
+ let o = J(e).get("parentExecutionId");
1395
+ if (o === null || o === "") return G(400, { error: "parentExecutionId query param required" }, i);
1396
+ if (t.inspectWorkflowChildren === void 0) return G(200, {
1281
1397
  runs: [],
1282
1398
  total: 0,
1283
1399
  offset: 0,
1284
1400
  limit: 200
1285
1401
  }, i);
1286
1402
  try {
1287
- return U(200, await t.inspectWorkflowChildren({ parentExecutionId: o }), i);
1403
+ return G(200, await t.inspectWorkflowChildren({ parentExecutionId: o }), i);
1288
1404
  } catch (e) {
1289
- return U(500, {
1405
+ return G(500, {
1290
1406
  error: "children query failed",
1291
1407
  message: e?.message ?? String(e)
1292
1408
  }, i);
1293
1409
  }
1294
- }, Ht = async (e, t, n, r, i = {}) => {
1295
- let a = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
1410
+ }, nn = async (e, t, n, r, i = {}) => {
1411
+ let a = q(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
1296
1412
  if (!a) return null;
1297
- let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = W(n.origin ?? n.Origin);
1298
- if ((i.method ?? "POST").toUpperCase() !== "POST") return U(405, {
1413
+ let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = K(n.origin ?? n.Origin);
1414
+ if ((i.method ?? "POST").toUpperCase() !== "POST") return G(405, {
1299
1415
  error: "method not allowed",
1300
1416
  expected: "POST"
1301
1417
  }, c);
1302
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, c);
1303
- let l = (i.authResolver ?? H)(n);
1304
- if (!l.ok) return U(401, {
1418
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, c);
1419
+ let l = (i.authResolver ?? W)(n);
1420
+ if (!l.ok) return G(401, {
1305
1421
  error: "unauthorized",
1306
1422
  reason: l.reason
1307
1423
  }, c);
1308
- if (t.kind !== "api") return U(404, { error: "workflow actions are api-only" }, c);
1424
+ if (t.kind !== "api") return G(404, { error: "workflow actions are api-only" }, c);
1309
1425
  let u = {
1310
1426
  cancel: t.inspectCancelWorkflowRun,
1311
1427
  retry: t.inspectRetryWorkflowRun,
@@ -1314,16 +1430,16 @@ __installPublicEnv(publicEnvValues)
1314
1430
  signal: t.inspectSignalWorkflowRun,
1315
1431
  update: t.inspectUpdateWorkflowRun
1316
1432
  }[s];
1317
- if (!u) return U(404, { error: `inspect${s[0]?.toUpperCase() ?? ""}${s.slice(1)}WorkflowRun not configured` }, c);
1433
+ if (!u) return G(404, { error: `inspect${s[0]?.toUpperCase() ?? ""}${s.slice(1)}WorkflowRun not configured` }, c);
1318
1434
  let d, f, p, m, h, g;
1319
1435
  if (r.length > 0) try {
1320
1436
  let e = JSON.parse(r);
1321
1437
  s === "retry" && (d = e.payloadOverride), s === "signal" && (typeof e.signalName == "string" && e.signalName.length > 0 && (f = e.signalName), p = e.payload), s === "update" && (typeof e.updateName == "string" && e.updateName.length > 0 && (m = e.updateName), h = e.payload, typeof e.timeoutMs == "number" && Number.isFinite(e.timeoutMs) && (g = e.timeoutMs));
1322
1438
  } catch {}
1323
- if (s === "signal" && f === void 0) return U(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, c);
1324
- if (s === "update" && m === void 0) return U(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, c);
1439
+ if (s === "signal" && f === void 0) return G(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, c);
1440
+ if (s === "update" && m === void 0) return G(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, c);
1325
1441
  try {
1326
- return U(200, s === "retry" && d !== void 0 ? await u({
1442
+ return G(200, s === "retry" && d !== void 0 ? await u({
1327
1443
  runId: o,
1328
1444
  payloadOverride: d
1329
1445
  }) : s === "signal" ? await u({
@@ -1337,71 +1453,71 @@ __installPublicEnv(publicEnvValues)
1337
1453
  ...g === void 0 ? {} : { timeoutMs: g }
1338
1454
  }) : await u({ runId: o }), c);
1339
1455
  } catch (e) {
1340
- return U(500, {
1456
+ return G(500, {
1341
1457
  error: `${s} failed`,
1342
1458
  message: e?.message ?? String(e)
1343
1459
  }, c);
1344
1460
  }
1345
- }, Ut = async (e, t, n, r, i = {}) => {
1346
- if (G(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
1347
- let a = W(n.origin ?? n.Origin);
1348
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1349
- let o = (i.authResolver ?? H)(n);
1350
- if (!o.ok) return U(401, {
1461
+ }, rn = async (e, t, n, r, i = {}) => {
1462
+ if (q(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
1463
+ let a = K(n.origin ?? n.Origin);
1464
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1465
+ let o = (i.authResolver ?? W)(n);
1466
+ if (!o.ok) return G(401, {
1351
1467
  error: "unauthorized",
1352
1468
  reason: o.reason
1353
1469
  }, a);
1354
- if (t.kind !== "api") return U(404, { error: "data import is api-only" }, a);
1355
- if (!t.inspectImport) return U(404, { error: "inspectImport not configured" }, a);
1470
+ if (t.kind !== "api") return G(404, { error: "data import is api-only" }, a);
1471
+ if (!t.inspectImport) return G(404, { error: "inspectImport not configured" }, a);
1356
1472
  let s;
1357
1473
  try {
1358
1474
  s = JSON.parse(r || "{}");
1359
1475
  } catch {
1360
- return U(400, { error: "body must be JSON" }, a);
1476
+ return G(400, { error: "body must be JSON" }, a);
1361
1477
  }
1362
- if (typeof s.bundleDir != "string" || !s.bundleDir) return U(400, { error: "body.bundleDir (string) is required" }, a);
1478
+ if (typeof s.bundleDir != "string" || !s.bundleDir) return G(400, { error: "body.bundleDir (string) is required" }, a);
1363
1479
  try {
1364
- return U(200, await t.inspectImport({
1480
+ return G(200, await t.inspectImport({
1365
1481
  bundleDir: s.bundleDir,
1366
1482
  ...s.mode === "upsert" || s.mode === "append" || s.mode === "replace" ? { mode: s.mode } : {},
1367
1483
  ...s.onConflict === "skip" || s.onConflict === "fail" ? { onConflict: s.onConflict } : {},
1368
1484
  ...typeof s.atomic == "boolean" ? { atomic: s.atomic } : {}
1369
1485
  }), a);
1370
1486
  } catch (e) {
1371
- return U(500, {
1487
+ return G(500, {
1372
1488
  error: "import failed",
1373
1489
  message: e?.message ?? String(e)
1374
1490
  }, a);
1375
1491
  }
1376
- }, Wt = async (e, t, n, r, i = {}) => {
1377
- let a = G(e);
1492
+ }, an = async (e, t, n, r, i = {}) => {
1493
+ let a = q(e);
1378
1494
  if (!a.startsWith("/_voltro/inspect/data/rows")) return null;
1379
1495
  let o = (i.method ?? "POST").toUpperCase();
1380
1496
  if (o === "GET" && a === "/_voltro/inspect/data/rows") return null;
1381
- let s = W(n.origin ?? n.Origin);
1382
- if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1383
- let c = (i.authResolver ?? H)(n);
1384
- if (!c.ok) return U(401, {
1497
+ let s = K(n.origin ?? n.Origin);
1498
+ if (U()) return G(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1499
+ let c = (i.authResolver ?? W)(n);
1500
+ if (!c.ok) return G(401, {
1385
1501
  error: "unauthorized",
1386
1502
  reason: c.reason
1387
1503
  }, s);
1388
- if (t.kind !== "api") return U(404, { error: "data viewer is api-only" }, s);
1504
+ if (t.kind !== "api") return G(404, { error: "data viewer is api-only" }, s);
1389
1505
  if (o === "POST" && a === "/_voltro/inspect/data/rows") {
1390
- if (!t.inspectInsertRow) return U(404, { error: "inspectInsertRow not configured" }, s);
1506
+ if (!t.inspectInsertRow) return G(404, { error: "inspectInsertRow not configured" }, s);
1391
1507
  let e;
1392
1508
  try {
1393
1509
  e = JSON.parse(r || "{}");
1394
1510
  } catch {
1395
- return U(400, { error: "body must be JSON" }, s);
1511
+ return G(400, { error: "body must be JSON" }, s);
1396
1512
  }
1397
- if (typeof e.table != "string" || !e.row || typeof e.row != "object") return U(400, { error: "body must be { table: string, row: object }" }, s);
1513
+ if (typeof e.table != "string" || !e.row || typeof e.row != "object") return G(400, { error: "body must be { table: string, row: object }" }, s);
1398
1514
  try {
1399
- return U(200, await t.inspectInsertRow({
1515
+ return G(200, await t.inspectInsertRow({
1400
1516
  table: e.table,
1401
1517
  row: e.row
1402
1518
  }), s);
1403
1519
  } catch (e) {
1404
- return U(500, {
1520
+ return G(500, {
1405
1521
  error: "insert failed",
1406
1522
  message: e?.message ?? String(e)
1407
1523
  }, s);
@@ -1410,50 +1526,50 @@ __installPublicEnv(publicEnvValues)
1410
1526
  let l = a.match(/^\/_voltro\/inspect\/data\/rows\/([^/]+)$/);
1411
1527
  if (!l) return null;
1412
1528
  let u = decodeURIComponent(l[1] ?? "");
1413
- if (!u) return U(400, { error: "row id is required in URL" }, s);
1414
- let d = K(e).get("table") ?? "";
1415
- if (!d) return U(400, { error: "query.table is required" }, s);
1529
+ if (!u) return G(400, { error: "row id is required in URL" }, s);
1530
+ let d = J(e).get("table") ?? "";
1531
+ if (!d) return G(400, { error: "query.table is required" }, s);
1416
1532
  if (o === "PATCH") {
1417
- if (!t.inspectUpdateRow) return U(404, { error: "inspectUpdateRow not configured" }, s);
1533
+ if (!t.inspectUpdateRow) return G(404, { error: "inspectUpdateRow not configured" }, s);
1418
1534
  let e;
1419
1535
  try {
1420
1536
  e = JSON.parse(r || "{}");
1421
1537
  } catch {
1422
- return U(400, { error: "body must be JSON" }, s);
1538
+ return G(400, { error: "body must be JSON" }, s);
1423
1539
  }
1424
- if (!e.patch || typeof e.patch != "object") return U(400, { error: "body.patch must be an object" }, s);
1540
+ if (!e.patch || typeof e.patch != "object") return G(400, { error: "body.patch must be an object" }, s);
1425
1541
  try {
1426
- return U(200, await t.inspectUpdateRow({
1542
+ return G(200, await t.inspectUpdateRow({
1427
1543
  table: d,
1428
1544
  id: u,
1429
1545
  patch: e.patch
1430
1546
  }), s);
1431
1547
  } catch (e) {
1432
- return U(500, {
1548
+ return G(500, {
1433
1549
  error: "update failed",
1434
1550
  message: e?.message ?? String(e)
1435
1551
  }, s);
1436
1552
  }
1437
1553
  }
1438
1554
  if (o === "DELETE") {
1439
- if (!t.inspectDeleteRow) return U(404, { error: "inspectDeleteRow not configured" }, s);
1555
+ if (!t.inspectDeleteRow) return G(404, { error: "inspectDeleteRow not configured" }, s);
1440
1556
  try {
1441
- return U(200, await t.inspectDeleteRow({
1557
+ return G(200, await t.inspectDeleteRow({
1442
1558
  table: d,
1443
1559
  id: u
1444
1560
  }), s);
1445
1561
  } catch (e) {
1446
- return U(500, {
1562
+ return G(500, {
1447
1563
  error: "delete failed",
1448
1564
  message: e?.message ?? String(e)
1449
1565
  }, s);
1450
1566
  }
1451
1567
  }
1452
- return U(405, {
1568
+ return G(405, {
1453
1569
  error: "method not allowed",
1454
1570
  expected: "POST | PATCH | DELETE"
1455
1571
  }, s);
1456
- }, Gt = 256, Kt = (e = Gt) => {
1572
+ }, on = 256, sn = (e = on) => {
1457
1573
  let t = [], n = /* @__PURE__ */ new Set();
1458
1574
  return {
1459
1575
  emit(r, i) {
@@ -1476,27 +1592,27 @@ __installPublicEnv(publicEnvValues)
1476
1592
  return t.slice();
1477
1593
  }
1478
1594
  };
1479
- }, qt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Jt = () => `: keep-alive ${Date.now()}\n\n`, Yt = {
1595
+ }, cn = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, ln = () => `: keep-alive ${Date.now()}\n\n`, un = {
1480
1596
  trace: 0,
1481
1597
  debug: 1,
1482
1598
  info: 2,
1483
1599
  warn: 3,
1484
1600
  error: 4,
1485
1601
  fatal: 5
1486
- }, Xt = 2e3, Zt = 200, Qt = class {
1602
+ }, dn = 2e3, fn = 200, pn = class {
1487
1603
  capacity;
1488
1604
  buffer = [];
1489
- constructor(e = Xt) {
1605
+ constructor(e = dn) {
1490
1606
  this.capacity = e;
1491
1607
  }
1492
1608
  append(e) {
1493
1609
  this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
1494
1610
  }
1495
1611
  query(e = {}) {
1496
- let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Zt, this.capacity), i = e.minLevel === void 0 ? Yt.trace : Yt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1612
+ let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? fn, this.capacity), i = e.minLevel === void 0 ? un.trace : un[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1497
1613
  for (let e = this.buffer.length - 1; e >= 0 && l.length < r; e--) {
1498
1614
  let r = this.buffer[e];
1499
- r.ts < t || r.ts > n || Yt[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);
1615
+ r.ts < t || r.ts > n || un[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);
1500
1616
  }
1501
1617
  return l.reverse();
1502
1618
  }
@@ -1509,7 +1625,7 @@ __installPublicEnv(publicEnvValues)
1509
1625
  clear() {
1510
1626
  this.buffer = [];
1511
1627
  }
1512
- }, $t = null, en = () => ($t === null && ($t = new Qt()), $t), tn = (e) => {
1628
+ }, mn = null, hn = () => (mn === null && (mn = new pn()), mn), gn = (e) => {
1513
1629
  if (typeof e == "string") return e;
1514
1630
  if (e instanceof Error) return e.message;
1515
1631
  try {
@@ -1517,18 +1633,18 @@ __installPublicEnv(publicEnvValues)
1517
1633
  } catch {
1518
1634
  return String(e);
1519
1635
  }
1520
- }, nn = (e) => {
1636
+ }, _n = (e) => {
1521
1637
  let t = {
1522
1638
  log: console.log.bind(console),
1523
1639
  info: console.info.bind(console),
1524
1640
  warn: console.warn.bind(console),
1525
1641
  error: console.error.bind(console),
1526
1642
  debug: console.debug.bind(console)
1527
- }, n = en(), r = !1, i = (i) => (...a) => {
1643
+ }, n = hn(), r = !1, i = (i) => (...a) => {
1528
1644
  if (t[i](...a), !r) {
1529
1645
  r = !0;
1530
1646
  try {
1531
- let t = a.length > 0 ? tn(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = k();
1647
+ let t = a.length > 0 ? gn(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = O();
1532
1648
  e.emit("log", {
1533
1649
  level: i,
1534
1650
  message: r,
@@ -1566,7 +1682,7 @@ __installPublicEnv(publicEnvValues)
1566
1682
  argsCount: 1,
1567
1683
  ...t.scope === void 0 ? {} : { scope: t.scope }
1568
1684
  });
1569
- let a = k(), o = a !== void 0 && t.fields.traceId === void 0 ? {
1685
+ let a = O(), o = a !== void 0 && t.fields.traceId === void 0 ? {
1570
1686
  ...t.fields,
1571
1687
  traceId: a.traceId
1572
1688
  } : t.fields;
@@ -1586,24 +1702,24 @@ __installPublicEnv(publicEnvValues)
1586
1702
  return () => {
1587
1703
  console.log = t.log, console.info = t.info, console.warn = t.warn, console.error = t.error, console.debug = t.debug, a();
1588
1704
  };
1589
- }, rn = 2e3, an = 8, on = 1e3, sn = 200, J = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, cn = (e) => {
1705
+ }, vn = 2e3, yn = 8, bn = 1e3, xn = 200, X = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, Sn = (e) => {
1590
1706
  switch (e) {
1591
1707
  case "error": return "error";
1592
1708
  case "warn": return "warn";
1593
1709
  case "debug": return "debug";
1594
1710
  default: return "info";
1595
1711
  }
1596
- }, ln = g({ scope: "client" }), un = (e, t) => {
1712
+ }, Cn = g({ scope: "client" }), wn = (e, t) => {
1597
1713
  let n;
1598
1714
  try {
1599
1715
  n = JSON.parse(e);
1600
1716
  } catch {
1601
- return dn(400, { error: "invalid JSON body" });
1717
+ return Tn(400, { error: "invalid JSON body" });
1602
1718
  }
1603
- if (typeof n != "object" || !n) return dn(400, { error: "body must be a JSON object" });
1719
+ if (typeof n != "object" || !n) return Tn(400, { error: "body must be a JSON object" });
1604
1720
  let r = n;
1605
- if (!Array.isArray(r.entries)) return dn(400, { error: "entries must be an array" });
1606
- let i = typeof r.app == "string" ? J(r.app, 120) : void 0, a = typeof r.page == "string" ? J(r.page, 200) : void 0, o = typeof r.ua == "string" ? J(r.ua, 200) : void 0, s = r.entries.slice(0, sn), c = 0;
1721
+ if (!Array.isArray(r.entries)) return Tn(400, { error: "entries must be an array" });
1722
+ let i = typeof r.app == "string" ? X(r.app, 120) : void 0, a = typeof r.page == "string" ? X(r.page, 200) : void 0, o = typeof r.ua == "string" ? X(r.ua, 200) : void 0, s = r.entries.slice(0, xn), c = 0;
1607
1723
  for (let e of s) {
1608
1724
  if (typeof e != "object" || !e) continue;
1609
1725
  let n = e;
@@ -1614,7 +1730,7 @@ __installPublicEnv(publicEnvValues)
1614
1730
  "warn",
1615
1731
  "error",
1616
1732
  "debug"
1617
- ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = J(n.message, rn), u = Array.isArray(n.args) ? n.args.slice(0, an).filter((e) => typeof e == "string").map((e) => J(e, on)) : void 0, d = typeof n.stack == "string" ? J(n.stack, rn) : void 0;
1733
+ ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = X(n.message, vn), u = Array.isArray(n.args) ? n.args.slice(0, yn).filter((e) => typeof e == "string").map((e) => X(e, bn)) : void 0, d = typeof n.stack == "string" ? X(n.stack, vn) : void 0;
1618
1734
  t.emit("clientLog", {
1619
1735
  ts: s,
1620
1736
  level: r,
@@ -1629,35 +1745,35 @@ __installPublicEnv(publicEnvValues)
1629
1745
  ...i === void 0 ? {} : { app: i },
1630
1746
  ...a === void 0 ? {} : { page: a },
1631
1747
  ...u !== void 0 && u.length > 0 ? { args: u } : {}
1632
- }, p = cn(r);
1633
- (p === "error" || p === "warn") && d !== void 0 ? ln[p](l, f, { stack: d }) : ln[p](l, {
1748
+ }, p = Sn(r);
1749
+ (p === "error" || p === "warn") && d !== void 0 ? Cn[p](l, f, { stack: d }) : Cn[p](l, {
1634
1750
  ...f,
1635
1751
  ...d === void 0 ? {} : { stack: d }
1636
1752
  }), c++;
1637
1753
  }
1638
- return dn(202, {
1754
+ return Tn(202, {
1639
1755
  accepted: c,
1640
1756
  dropped: r.entries.length - c
1641
1757
  });
1642
- }, dn = (e, t) => ({
1758
+ }, Tn = (e, t) => ({
1643
1759
  status: e,
1644
1760
  contentType: "application/json; charset=utf-8",
1645
1761
  body: JSON.stringify(t)
1646
- }), fn = "/_voltro/inspect/clientLog", pn = [
1762
+ }), En = "/_voltro/inspect/clientLog", Dn = [
1647
1763
  "trace",
1648
1764
  "debug",
1649
1765
  "info",
1650
1766
  "warn",
1651
1767
  "error",
1652
1768
  "fatal"
1653
- ], mn = {
1769
+ ], On = {
1654
1770
  trace: "TRACE",
1655
1771
  debug: "DEBUG",
1656
1772
  info: "INFO ",
1657
1773
  warn: "WARN ",
1658
1774
  error: "ERROR",
1659
1775
  fatal: "FATAL"
1660
- }, hn = (e) => pn.includes(e), gn = (e, t) => {
1776
+ }, kn = (e) => Dn.includes(e), An = (e, t) => {
1661
1777
  let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = {}, a = r.get("since");
1662
1778
  if (a !== null) {
1663
1779
  let e = Number(a);
@@ -1674,7 +1790,7 @@ __installPublicEnv(publicEnvValues)
1674
1790
  Number.isFinite(e) && e > 0 && (i.max = Math.floor(e));
1675
1791
  }
1676
1792
  let c = r.get("level");
1677
- c !== null && hn(c) && (i.minLevel = c);
1793
+ c !== null && kn(c) && (i.minLevel = c);
1678
1794
  let l = r.get("source");
1679
1795
  (l === "server" || l === "client") && (i.source = l);
1680
1796
  let u = r.get("scope");
@@ -1687,7 +1803,7 @@ __installPublicEnv(publicEnvValues)
1687
1803
  if ((r.get("format") ?? "json") === "text") return {
1688
1804
  status: 200,
1689
1805
  contentType: "text/plain; charset=utf-8",
1690
- body: p.map(_n).join("\n") + (p.length > 0 ? "\n" : "")
1806
+ body: p.map(jn).join("\n") + (p.length > 0 ? "\n" : "")
1691
1807
  };
1692
1808
  let m = {
1693
1809
  capturedAt: Date.now(),
@@ -1701,34 +1817,34 @@ __installPublicEnv(publicEnvValues)
1701
1817
  contentType: "application/json; charset=utf-8",
1702
1818
  body: JSON.stringify(m)
1703
1819
  };
1704
- }, _n = (e) => {
1705
- 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 = yn(e.fields);
1706
- return `${n}:${r}:${i}.${a} ${mn[e.level]} ${o} ${e.message}${s}`;
1707
- }, vn = 80, yn = (e) => {
1820
+ }, jn = (e) => {
1821
+ 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 = Nn(e.fields);
1822
+ return `${n}:${r}:${i}.${a} ${On[e.level]} ${o} ${e.message}${s}`;
1823
+ }, Mn = 80, Nn = (e) => {
1708
1824
  let t = Object.entries(e);
1709
1825
  if (t.length === 0) return "";
1710
1826
  let n = [];
1711
1827
  for (let [e, r] of t) {
1712
1828
  if (r === void 0) continue;
1713
- let t = bn(r);
1829
+ let t = Pn(r);
1714
1830
  n.push(`${e}=${t}`);
1715
1831
  }
1716
1832
  return n.length > 0 ? " " + n.join(" ") : "";
1717
- }, bn = (e) => {
1833
+ }, Pn = (e) => {
1718
1834
  if (typeof e == "string") {
1719
- let t = e.length > vn ? e.slice(0, vn) + "…" : e;
1835
+ let t = e.length > Mn ? e.slice(0, Mn) + "…" : e;
1720
1836
  return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
1721
1837
  }
1722
1838
  if (e === null) return "null";
1723
1839
  if (typeof e == "number" || typeof e == "boolean") return String(e);
1724
1840
  try {
1725
1841
  let t = JSON.stringify(e);
1726
- return t.length > vn ? t.slice(0, vn) + "…" : t;
1842
+ return t.length > Mn ? t.slice(0, Mn) + "…" : t;
1727
1843
  } catch {
1728
1844
  return "[unserialisable]";
1729
1845
  }
1730
- }, xn = "/_voltro/inspect/logs", Sn = g({ scope: "voltro:cli" }), Cn = [], wn = (e) => {
1731
- Cn.length = 0;
1846
+ }, Fn = "/_voltro/inspect/logs", In = g({ scope: "voltro:cli" }), Ln = [], Rn = (e) => {
1847
+ Ln.length = 0;
1732
1848
  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;
1733
1849
  for (;;) {
1734
1850
  o.push(s);
@@ -1739,7 +1855,7 @@ __installPublicEnv(publicEnvValues)
1739
1855
  for (let e of o) for (let t of [".env.local", ".env"]) {
1740
1856
  let n = a(e, t);
1741
1857
  if (y(n)) {
1742
- Cn.push(n);
1858
+ Ln.push(n);
1743
1859
  try {
1744
1860
  let e = C(n, "utf8");
1745
1861
  for (let t of e.split(/\r?\n/)) {
@@ -1751,15 +1867,15 @@ __installPublicEnv(publicEnvValues)
1751
1867
  (i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
1752
1868
  }
1753
1869
  } catch (e) {
1754
- Sn.warn("failed to load env file (continuing)", { path: n }, e);
1870
+ In.warn("failed to load env file (continuing)", { path: n }, e);
1755
1871
  }
1756
1872
  }
1757
1873
  }
1758
- }, Tn = 500, En = (e, t, n = {}) => {
1874
+ }, zn = 500, Bn = (e, t, n = {}) => {
1759
1875
  if (e.length === 0) return () => {};
1760
1876
  let r = (e) => n.root ? i(n.root, e) : e, a = !1, o = (e) => {
1761
1877
  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(() => {
1762
- let e = fe(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
1878
+ let e = de(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
1763
1879
  stdio: "inherit",
1764
1880
  env: process.env,
1765
1881
  cwd: n.cwd ?? process.cwd()
@@ -1773,16 +1889,16 @@ __installPublicEnv(publicEnvValues)
1773
1889
  });
1774
1890
  }));
1775
1891
  };
1776
- for (let t of e) D(t, { interval: Tn }, (e, n) => {
1892
+ for (let t of e) D(t, { interval: zn }, (e, n) => {
1777
1893
  e.mtimeMs !== n.mtimeMs && o(t);
1778
1894
  });
1779
1895
  return t.info("watching .env files for changes", {
1780
1896
  files: e.map(r),
1781
- intervalMs: Tn
1897
+ intervalMs: zn
1782
1898
  }), () => {
1783
1899
  for (let t of e) ee(t);
1784
1900
  };
1785
- }, Dn = [{
1901
+ }, Vn = [{
1786
1902
  match: (e) => typeof e == "string" && e.startsWith("[BABEL] Note: The code generator has deoptimised"),
1787
1903
  handle: (e, t) => {
1788
1904
  let n = e[0], r = n.match(/deoptimised the styling of (.+?) as it exceeds the max of (\d+\w*B)\.?/);
@@ -1794,13 +1910,13 @@ __installPublicEnv(publicEnvValues)
1794
1910
  });
1795
1911
  } else t.info(n);
1796
1912
  }
1797
- }], On = () => {
1913
+ }], Hn = () => {
1798
1914
  let e = {
1799
1915
  warn: console.warn.bind(console),
1800
1916
  error: console.error.bind(console)
1801
1917
  }, t = g({ scope: "babel" }), n = !1, r = (r) => (...i) => {
1802
1918
  if (!n) {
1803
- for (let e of Dn) if (e.match(i[0])) {
1919
+ for (let e of Vn) if (e.match(i[0])) {
1804
1920
  n = !0;
1805
1921
  try {
1806
1922
  e.handle(i, t);
@@ -1815,7 +1931,94 @@ __installPublicEnv(publicEnvValues)
1815
1931
  return console.warn = r("warn"), console.error = r("error"), () => {
1816
1932
  console.warn = e.warn, console.error = e.error;
1817
1933
  };
1818
- }, kn = "virtual:voltro-route-refresh", An = `\0${kn}`, jn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Mn = () => "\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", Nn = (e) => `
1934
+ }, Un = {
1935
+ loader: "it runs on the server, and the router caches its result per route + params",
1936
+ renderMode: "it picks the server render strategy",
1937
+ dynamic: "it picks the server render strategy",
1938
+ meta: "the server rendered it into <head>",
1939
+ getStaticPaths: "it enumerates which paths get prerendered",
1940
+ revalidate: "it sets the ISR cache window",
1941
+ staleWhileRevalidate: "it sets the ISR stale-while-revalidate window",
1942
+ cacheInvalidatesOn: "it wires this page into the ISR cache invalidator",
1943
+ interactive: "it decides how much client JS the server ships",
1944
+ tenantAware: "it is part of the server-side cache key"
1945
+ }, Wn = Object.keys(Un), Gn = "virtual:voltro-route-refresh", Kn = `\0${Gn}`, qn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Jn = () => `
1946
+ // GENERATED by @voltro/cli — the \`voltro dev\` route Fast Refresh runtime.
1947
+
1948
+ /** Mirrors react-refresh's own \`isLikelyComponentType\` closely enough for the
1949
+ * decision we make with it: an uppercase-named function, or a React element
1950
+ * type object (memo / forwardRef / lazy carry \`$$typeof\`). */
1951
+ const isComponentLike = (value) => {
1952
+ if (typeof value === 'function') {
1953
+ const name = value.displayName ?? value.name
1954
+ return typeof name === 'string' && /^[A-Z]/.test(name)
1955
+ }
1956
+ return typeof value === 'object' && value !== null && '$$typeof' in value
1957
+ }
1958
+
1959
+ /** Value identity that survives module re-evaluation. A function is compared by
1960
+ * SOURCE TEXT — a re-evaluated but unedited \`loader\` is a brand-new object
1961
+ * with identical text — and everything else by its JSON form, so a \`meta\`
1962
+ * object literal does not read as changed on every edit. */
1963
+ const stableForm = (value) => {
1964
+ if (typeof value === 'function') return 'fn:' + String(value)
1965
+ try { return 'js:' + JSON.stringify(value) } catch { return 'st:' + String(value) }
1966
+ }
1967
+
1968
+ /** The route-module exports the SERVER reads to produce the HTML — injected
1969
+ * from \`SERVER_RELEVANT_ROUTE_EXPORTS\`, which is derived from
1970
+ * \`computeRouteMetadata\`'s own parameter type so it cannot drift from the
1971
+ * readers (\`build.ts\` prerender, \`webDev.ts\` dev SSR, \`start.ts\`). A change to
1972
+ * one of THESE cannot be hot-applied: the server already ran with the old
1973
+ * value. Everything else a page exports is plain client-side data. */
1974
+ const serverRelevantExports = ${JSON.stringify(Wn)}
1975
+
1976
+ /** Name → the server step that already consumed it, so the reload message can
1977
+ * say WHY rather than just WHAT. Injected from the same single source. */
1978
+ const serverExportEffect = ${JSON.stringify(Un)}
1979
+
1980
+ /** The reason \`name\` forces a reload, for the console line. */
1981
+ export const serverEffectOf = (name) =>
1982
+ serverExportEffect[name] ?? 'the server reads it off the route module'
1983
+
1984
+ /** id (absolute file path, as react-refresh spells it) → export names that
1985
+ * react-refresh must NOT judge. */
1986
+ const ignoredExports = new Map()
1987
+
1988
+ export const registerRouteModule = (id, moduleExports) => {
1989
+ const names = []
1990
+ for (const key of Object.keys(moduleExports)) {
1991
+ if (key === 'default') continue
1992
+ if (isComponentLike(moduleExports[key])) continue
1993
+ names.push(key)
1994
+ }
1995
+ ignoredExports.set(id, names)
1996
+ }
1997
+
1998
+ /** The name of the first SERVER-RELEVANT export whose VALUE changed, or null
1999
+ * when this update is one Fast Refresh can apply in place — a component edit,
2000
+ * or a change to a page-local value the server never read.
2001
+ *
2002
+ * Only the server-relevant names are inspected. A plain value export
2003
+ * (\`const COLUMNS = [...]\`) changing is NOT a reason to throw the page away:
2004
+ * the module re-evaluates, the component renders with the new value, and any
2005
+ * other importer is Vite's own graph propagation to resolve. */
2006
+ export const routeUpdateNeedsReload = (prevExports, nextExports) => {
2007
+ for (const key of serverRelevantExports) {
2008
+ if (stableForm(prevExports[key]) !== stableForm(nextExports[key])) return key
2009
+ }
2010
+ return null
2011
+ }
2012
+
2013
+ // \`globalThis\`, not \`window\`: identical in the browser (which is the only place
2014
+ // this module is ever loaded) and it keeps the runtime evaluatable by the unit
2015
+ // test, which is what lets the test read the REAL source instead of a copy.
2016
+ // Chained rather than overwritten — another plugin may own the hook for its own
2017
+ // modules, and ours only answers for ids it registered.
2018
+ const previousHook = globalThis.__getReactRefreshIgnoredExports
2019
+ globalThis.__getReactRefreshIgnoredExports = (args) =>
2020
+ ignoredExports.get(args.id) ?? previousHook?.(args) ?? []
2021
+ `, Yn = (e) => `
1819
2022
  if (import.meta.hot) {
1820
2023
  // Self-import to read our OWN exports, the same technique the react plugin
1821
2024
  // uses; the namespace is only complete after evaluation, hence the promise.
@@ -1829,8 +2032,10 @@ if (import.meta.hot) {
1829
2032
  return
1830
2033
  }
1831
2034
  console.info(
1832
- '[voltro] full reload: non-component export \`' + changed + '\` changed in ' +
1833
- ${JSON.stringify(e)} + ' (a loader runs on the server too, so its result must be re-rendered)',
2035
+ '[voltro] full reload: \`' + changed + '\` changed in ' + ${JSON.stringify(e)} +
2036
+ ' the server READS that export (' + __voltro_serverEffect(changed) +
2037
+ '), and the page in front of you was produced from the old value, so it ' +
2038
+ 'must be re-rendered. Other exports of this module hot-update in place.',
1834
2039
  )
1835
2040
  window.location.reload()
1836
2041
  })
@@ -1839,72 +2044,49 @@ if (import.meta.hot) {
1839
2044
  import {
1840
2045
  registerRouteModule as __voltro_registerRouteModule,
1841
2046
  routeUpdateNeedsReload as __voltro_routeUpdateNeedsReload,
1842
- } from '${kn}'
1843
- `, Pn = (e) => e.replace(/\\/g, "/"), Fn = (e, t) => {
1844
- let [n = "", r] = Pn(e).split("?");
1845
- if (!n.endsWith(".tsx") || r !== void 0 && jn.test(r)) return !1;
1846
- let i = Pn(t).replace(/\/$/, "");
2047
+ serverEffectOf as __voltro_serverEffect,
2048
+ } from '${Gn}'
2049
+ `, Xn = (e) => e.replace(/\\/g, "/"), Zn = (e, t) => {
2050
+ let [n = "", r] = Xn(e).split("?");
2051
+ if (!n.endsWith(".tsx") || r !== void 0 && qn.test(r)) return !1;
2052
+ let i = Xn(t).replace(/\/$/, "");
1847
2053
  return n.startsWith(`${i}/`);
1848
- }, In = (e, t, n) => Fn(t, n) ? `${e}${Nn(Pn(t).split("?")[0] ?? t)}` : null, Ln = (e) => ({
2054
+ }, Qn = (e, t, n) => Zn(t, n) ? `${e}${Yn(Xn(t).split("?")[0] ?? t)}` : null, $n = (e) => ({
1849
2055
  name: "voltro:route-fast-refresh",
1850
2056
  enforce: "pre",
1851
- resolveId: (e) => e === "virtual:voltro-route-refresh" ? An : void 0,
1852
- load: (e) => e === An ? Mn() : void 0,
2057
+ resolveId: (e) => e === "virtual:voltro-route-refresh" ? Kn : void 0,
2058
+ load: (e) => e === Kn ? Jn() : void 0,
1853
2059
  transform: (t, n, r) => {
1854
2060
  if (r?.ssr === !0) return null;
1855
- let i = In(t, n, e);
2061
+ let i = Qn(t, n, e);
1856
2062
  return i === null ? null : {
1857
2063
  code: i,
1858
2064
  map: null
1859
2065
  };
1860
2066
  }
1861
- }), Rn = () => {
1862
- let e = /* @__PURE__ */ new Map();
1863
- return {
1864
- get(t) {
1865
- return e.get(t);
1866
- },
1867
- set(t, n) {
1868
- e.set(t, n);
1869
- },
1870
- invalidate(t) {
1871
- e.delete(t);
1872
- },
1873
- invalidateBy(t) {
1874
- let n = 0;
1875
- for (let r of e.keys()) t(r) && (e.delete(r), n++);
1876
- return n;
1877
- },
1878
- clear() {
1879
- e.clear();
1880
- },
1881
- size() {
1882
- return e.size;
1883
- },
1884
- snapshot() {
1885
- return Array.from(e.entries());
2067
+ }), er = /export\s+const\s+renderMode\s*(?::[^=]+)?=\s*['"]([^'"]*)['"]/, tr = (e) => er.exec(e)?.[1] ?? null, nr = async (e, t) => {
2068
+ let n = (await Promise.all(t.map(async (t) => {
2069
+ let n;
2070
+ try {
2071
+ n = await ne(r(e, t.file), "utf8");
2072
+ } catch {
2073
+ return null;
1886
2074
  }
1887
- };
1888
- }, zn = (e) => {
1889
- if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
1890
- if (typeof e != "string") return null;
1891
- let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
1892
- if (!t) return null;
1893
- let n = parseInt(t[1], 10);
1894
- if (!Number.isFinite(n) || n <= 0) return null;
1895
- let r = t[2].toLowerCase();
1896
- 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;
1897
- }, Bn = (e, t = {}) => {
1898
- let n = [e];
1899
- 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("|");
1900
- }, Vn = (e, t) => e.expiresAt > t, Hn = (e, t) => e.expiresAt <= t && e.servableUntil > t, Un = r(me(), ".voltro"), Wn = r(Un, "runtime-registry.json"), Gn = 3e4, Kn = () => {
2075
+ let i = tr(n);
2076
+ return i === null || Qe(i) ? null : {
2077
+ file: t.file,
2078
+ value: i
2079
+ };
2080
+ }))).filter((e) => e !== null);
2081
+ if (n.length !== 0) throw Error(n.map((e) => et(r("src", "pages", e.file), e.value)).join("\n\n"));
2082
+ }, rr = r(L(), ".voltro"), ir = r(rr, "runtime-registry.json"), ar = 3e4, or = () => {
1901
2083
  let e = Math.random().toString(36).slice(2, 10);
1902
- return `${Wn}.${process.pid}.${Date.now()}.${e}.tmp`;
1903
- }, qn = async () => {
1904
- await S.mkdir(Un, { recursive: !0 });
1905
- }, Jn = async () => {
2084
+ return `${ir}.${process.pid}.${Date.now()}.${e}.tmp`;
2085
+ }, sr = async () => {
2086
+ await S.mkdir(rr, { recursive: !0 });
2087
+ }, cr = async () => {
1906
2088
  try {
1907
- let e = await S.readFile(Wn, "utf8"), t = JSON.parse(e);
2089
+ let e = await S.readFile(ir, "utf8"), t = JSON.parse(e);
1908
2090
  return t.version !== 1 || !Array.isArray(t.apps) ? {
1909
2091
  version: 1,
1910
2092
  apps: []
@@ -1915,31 +2097,31 @@ import {
1915
2097
  apps: []
1916
2098
  };
1917
2099
  }
1918
- }, Yn = async (e) => {
1919
- await qn();
1920
- let t = Kn();
2100
+ }, lr = async (e) => {
2101
+ await sr();
2102
+ let t = or();
1921
2103
  try {
1922
- await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, Wn);
2104
+ await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, ir);
1923
2105
  } catch (e) {
1924
2106
  try {
1925
2107
  await S.unlink(t);
1926
2108
  } catch {}
1927
2109
  throw e;
1928
2110
  }
1929
- }, Xn = (e) => {
2111
+ }, ur = (e) => {
1930
2112
  try {
1931
2113
  return process.kill(e, 0), !0;
1932
2114
  } catch {
1933
2115
  return !1;
1934
2116
  }
1935
- }, Zn = (e) => {
2117
+ }, dr = (e) => {
1936
2118
  let t = Date.now();
1937
- return e.filter((e) => Xn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < Gn : !1);
1938
- }, Qn = async () => {
1939
- let e = await Jn(), t = Zn(e.apps);
2119
+ return e.filter((e) => ur(e.pid) ? t - new Date(e.heartbeatAt).getTime() < ar : !1);
2120
+ }, fr = async () => {
2121
+ let e = await cr(), t = dr(e.apps);
1940
2122
  if (t.length === e.apps.length) return e;
1941
2123
  try {
1942
- await Yn({
2124
+ await lr({
1943
2125
  version: 1,
1944
2126
  apps: t
1945
2127
  });
@@ -1948,48 +2130,48 @@ import {
1948
2130
  version: 1,
1949
2131
  apps: t
1950
2132
  };
1951
- }, $n = async (e) => {
1952
- let t = await Jn(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
2133
+ }, pr = async (e) => {
2134
+ let t = await cr(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
1953
2135
  ...e,
1954
2136
  registeredAt: r >= 0 ? t.apps[r].registeredAt : n,
1955
2137
  heartbeatAt: n
1956
2138
  };
1957
- await Yn({
2139
+ await lr({
1958
2140
  version: 1,
1959
2141
  apps: r >= 0 ? t.apps.map((e, t) => t === r ? i : e) : [...t.apps, i]
1960
2142
  });
1961
- }, er = async (e) => {
2143
+ }, mr = async (e) => {
1962
2144
  try {
1963
- let t = await Jn(), n = t.apps.filter((t) => t.id !== e);
2145
+ let t = await cr(), n = t.apps.filter((t) => t.id !== e);
1964
2146
  if (n.length === t.apps.length) return;
1965
- await Yn({
2147
+ await lr({
1966
2148
  version: 1,
1967
2149
  apps: n
1968
2150
  });
1969
2151
  } catch {}
1970
- }, tr = (e, t, n) => `${e}:${t}:${n}`, Y = r(me(), ".voltro", "logs"), nr = () => {
2152
+ }, hr = (e, t, n) => `${e}:${t}:${n}`, Z = r(L(), ".voltro", "logs"), gr = () => {
1971
2153
  let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
1972
2154
  return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
1973
- }, rr = !1, ir = () => {
1974
- if (rr) return;
1975
- rr = !0;
1976
- let e = Date.now() - nr(), t = [];
2155
+ }, _r = !1, vr = () => {
2156
+ if (_r) return;
2157
+ _r = !0;
2158
+ let e = Date.now() - gr(), t = [];
1977
2159
  try {
1978
- t = w(Y);
2160
+ t = w(Z);
1979
2161
  } catch {
1980
2162
  return;
1981
2163
  }
1982
2164
  for (let n of t) {
1983
2165
  if (!n.endsWith(".log")) continue;
1984
- let t = r(Y, n);
2166
+ let t = r(Z, n);
1985
2167
  try {
1986
2168
  T(t).mtimeMs < e && E(t);
1987
2169
  } catch {}
1988
2170
  }
1989
- }, ar = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), or = (e, t) => r(Y, `${ar(e)}-${t}.log`), sr = (e) => {
1990
- let t = ar(e), n = [];
2171
+ }, yr = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), br = (e, t) => r(Z, `${yr(e)}-${t}.log`), xr = (e) => {
2172
+ let t = yr(e), n = [];
1991
2173
  try {
1992
- n = w(Y);
2174
+ n = w(Z);
1993
2175
  } catch {
1994
2176
  return;
1995
2177
  }
@@ -1997,19 +2179,19 @@ import {
1997
2179
  if (i.length === 0) return;
1998
2180
  let a, o = -1;
1999
2181
  for (let e of i) {
2000
- let t = r(Y, e);
2182
+ let t = r(Z, e);
2001
2183
  try {
2002
2184
  let e = T(t);
2003
2185
  e.mtimeMs > o && (o = e.mtimeMs, a = t);
2004
2186
  } catch {}
2005
2187
  }
2006
2188
  return a;
2007
- }, cr = (e) => {
2189
+ }, Sr = (e) => {
2008
2190
  try {
2009
- b(Y, { recursive: !0 });
2191
+ b(Z, { recursive: !0 });
2010
2192
  } catch {}
2011
- ir();
2012
- let t = or(e, process.pid), n = x(t, "w"), r = (e) => {
2193
+ vr();
2194
+ let t = br(e, process.pid), n = x(t, "w"), r = (e) => {
2013
2195
  let t = {
2014
2196
  ts: e.ts.getTime(),
2015
2197
  level: e.level,
@@ -2032,7 +2214,7 @@ import {
2032
2214
  }
2033
2215
  }, i = !1, a = h((e) => {
2034
2216
  if (!i) try {
2035
- O(n, r(e));
2217
+ te(n, r(e));
2036
2218
  } catch {}
2037
2219
  }), o = () => {
2038
2220
  if (!i) {
@@ -2050,7 +2232,7 @@ import {
2050
2232
  a(), o(), process.off("exit", o), process.off("uncaughtException", s), process.off("unhandledRejection", s);
2051
2233
  }
2052
2234
  };
2053
- }, lr = async (e, t) => {
2235
+ }, Cr = async (e, t) => {
2054
2236
  let n;
2055
2237
  try {
2056
2238
  n = await S.readFile(e, "utf8");
@@ -2064,11 +2246,11 @@ import {
2064
2246
  i.push(t);
2065
2247
  } catch {}
2066
2248
  return t?.max !== void 0 && i.length > t.max ? i.slice(i.length - t.max) : i;
2067
- }, ur = g({ scope: "voltro:dashboard" }), dr = ge(import.meta.url), fr = 5179, pr = (e) => {
2249
+ }, wr = g({ scope: "voltro:dashboard" }), Tr = me(import.meta.url), Er = 5179, Dr = (e) => {
2068
2250
  let n = process.env.VOLTRO_DASHBOARD_PATH;
2069
2251
  if (n && y(r(a(n), "app.config.ts"))) return a(n);
2070
2252
  try {
2071
- let e = t(dr.resolve("@voltro/dashboard/package.json"));
2253
+ let e = t(Tr.resolve("@voltro/dashboard/package.json"));
2072
2254
  if (y(r(e, "app.config.ts"))) return e;
2073
2255
  } catch {}
2074
2256
  let i = r("voltro-devtools", "apps", "dashboard"), o = a(e);
@@ -2080,53 +2262,53 @@ import {
2080
2262
  o = n;
2081
2263
  }
2082
2264
  return null;
2083
- }, mr = "VOLTRO_IS_DASHBOARD", hr = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2084
- let i = he({
2265
+ }, Or = "VOLTRO_IS_DASHBOARD", kr = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2266
+ let i = pe({
2085
2267
  port: e,
2086
2268
  host: t
2087
2269
  }), a = !1, o = (e) => {
2088
2270
  a || (a = !0, i.destroy(), r(e));
2089
2271
  };
2090
2272
  i.once("connect", () => o(!0)), i.once("error", () => o(!1)), setTimeout(() => o(!1), n);
2091
- }), gr = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), _r = () => process.env[mr] === "1", vr = () => process.stdout.isTTY === !0, X = r(me(), ".voltro", "dashboard-launch.lock"), yr = 1e4, br = async () => {
2273
+ }), Ar = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), jr = () => process.env[Or] === "1", Mr = () => process.stdout.isTTY === !0, Nr = r(L(), ".voltro", "dashboard-launch.lock"), Pr = 1e4, Fr = async () => {
2092
2274
  try {
2093
- await S.mkdir(t(X), { recursive: !0 });
2094
- let e = await S.open(X, "wx");
2275
+ await S.mkdir(t(Nr), { recursive: !0 });
2276
+ let e = await S.open(Nr, "wx");
2095
2277
  return await e.write(`${process.pid}\n${Date.now()}\n`), await e.close(), !0;
2096
2278
  } catch {
2097
2279
  try {
2098
- let e = await S.stat(X);
2099
- if (Date.now() - e.mtimeMs > yr) return await S.unlink(X).catch(() => void 0), br();
2280
+ let e = await S.stat(Nr);
2281
+ if (Date.now() - e.mtimeMs > Pr) return await S.unlink(Nr).catch(() => void 0), Fr();
2100
2282
  } catch {}
2101
2283
  return !1;
2102
2284
  }
2103
- }, xr = async () => {
2285
+ }, Ir = async () => {
2104
2286
  try {
2105
- await S.unlink(X);
2287
+ await S.unlink(Nr);
2106
2288
  } catch {}
2107
- }, Sr = async (e) => {
2289
+ }, Lr = async (e) => {
2108
2290
  let n = e.port ?? 5179;
2109
- if (gr()) return {
2291
+ if (Ar()) return {
2110
2292
  status: "skipped",
2111
2293
  reason: "disabled by flag/env",
2112
2294
  port: n
2113
2295
  };
2114
- if (_r()) return {
2296
+ if (jr()) return {
2115
2297
  status: "skipped",
2116
2298
  reason: "this process IS the dashboard",
2117
2299
  port: n
2118
2300
  };
2119
- if (!vr()) return {
2301
+ if (!Mr()) return {
2120
2302
  status: "skipped",
2121
2303
  reason: "stdout is not a TTY (CI/smoke)",
2122
2304
  port: n
2123
2305
  };
2124
- if (!await br()) return {
2306
+ if (!await Fr()) return {
2125
2307
  status: "skipped",
2126
2308
  reason: "another voltro process is currently launching the dashboard",
2127
2309
  port: n
2128
2310
  };
2129
- if (await hr(n)) return await xr(), {
2311
+ if (await kr(n)) return await Ir(), {
2130
2312
  status: "already-running",
2131
2313
  port: n
2132
2314
  };
@@ -2135,7 +2317,7 @@ import {
2135
2317
  let e = process.argv[1];
2136
2318
  i = e && e.endsWith("/src/bin.ts") ? r(t(e), "..", "bin", "voltro.mjs") : e ?? "voltro";
2137
2319
  }
2138
- let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s = fe(process.execPath, [
2320
+ let a = y(r(e.dashboardAppPath, ".framework", "dist", "index.html")), o = a ? "start" : "dev", s = de(process.execPath, [
2139
2321
  i,
2140
2322
  o,
2141
2323
  e.dashboardAppPath
@@ -2143,7 +2325,7 @@ import {
2143
2325
  stdio: "ignore",
2144
2326
  env: {
2145
2327
  ...process.env,
2146
- [mr]: "1",
2328
+ [Or]: "1",
2147
2329
  VOLTRO_DASHBOARD_PORT: String(n)
2148
2330
  }
2149
2331
  });
@@ -2151,22 +2333,22 @@ import {
2151
2333
  if (s.exitCode === null && s.signalCode === null) try {
2152
2334
  s.kill("SIGTERM");
2153
2335
  } catch {}
2154
- }), ur.info(`auto-launching dashboard at http://localhost:${n}`, {
2336
+ }), wr.info(`auto-launching dashboard at http://localhost:${n}`, {
2155
2337
  port: n,
2156
2338
  mode: o,
2157
2339
  prebuilt: a
2158
- }), a || ur.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), ur.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2159
- xr();
2340
+ }), a || wr.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), wr.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2341
+ Ir();
2160
2342
  }, 4e3).unref(), {
2161
2343
  status: "launched",
2162
2344
  port: n
2163
2345
  };
2164
- }, Cr = class extends Error {
2346
+ }, Rr = class extends Error {
2165
2347
  _voltroDeferral = !0;
2166
2348
  constructor(e) {
2167
2349
  super(e), this.name = "DeferralNotSupportedError";
2168
2350
  }
2169
- }, wr = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Tr = (e) => {
2351
+ }, zr = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Br = (e) => {
2170
2352
  let { helpers: t } = e, n = t.prepareDeferredLoaderData(e.loaderData, "page"), r = {}, i = {}, a = {};
2171
2353
  for (let [n, o] of Object.entries(e.segmentLoaderData)) {
2172
2354
  let e = Number(n), s = t.prepareDeferredLoaderData(o, e);
@@ -2177,47 +2359,84 @@ import {
2177
2359
  t.assertDeferralSupported({
2178
2360
  page: e.page,
2179
2361
  renderMode: e.renderMode,
2180
- interactive: e.interactive
2362
+ interactive: e.interactive,
2363
+ ...e.layoutShell ? { layoutShell: e.layoutShell } : {}
2181
2364
  });
2182
2365
  } catch (e) {
2183
- throw new Cr(e instanceof Error ? e.message : String(e));
2366
+ throw new Rr(e instanceof Error ? e.message : String(e));
2184
2367
  }
2185
2368
  return {
2186
2369
  loaderData: n.renderData,
2187
2370
  segmentLoaderData: r,
2188
2371
  hasDeferred: o,
2189
2372
  stateInput: {
2373
+ path: e.pathname,
2190
2374
  loaderData: n.stateData,
2191
2375
  segmentLoaderData: i,
2192
2376
  pageLoaderRan: e.pageLoaderRan,
2377
+ ...e.layoutShell ? { pageClientOnly: !0 } : {},
2193
2378
  ...n.deferredIds ? { deferredPageIds: n.deferredIds } : {},
2194
2379
  ...Object.keys(a).length > 0 ? { deferredSegmentIds: a } : {}
2195
2380
  }
2196
2381
  };
2197
- }, Er = "<div id=\"root\"></div>", Dr = "<div id=\"root\">", Or = "</div>", kr = /<script\b[^>]*\btype=["']module["'][^>]*><\/script>[ \t]*\n?/gi, Ar = /\bsrc=["']([^"']+)["']/i, jr = /<script(?![^>]*\basync\b)([^>]*\btype=["']module["'][^>]*)>/gi, Mr = (e) => {
2198
- let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(kr, (e) => {
2199
- let r = Ar.exec(e)?.[1];
2382
+ }, Vr = (e) => {
2383
+ let { helpers: t, renderInput: n } = e, r = Br({
2384
+ helpers: t,
2385
+ page: e.page,
2386
+ pathname: n.pathname,
2387
+ renderMode: "spa",
2388
+ interactive: e.interactive,
2389
+ loaderData: null,
2390
+ segmentLoaderData: n.segmentLoaderData ?? {},
2391
+ pageLoaderRan: !1,
2392
+ layoutShell: e.delivery
2393
+ });
2394
+ return {
2395
+ renderInput: {
2396
+ ...n,
2397
+ pageSlot: !0,
2398
+ loaderData: null,
2399
+ segmentLoaderData: r.segmentLoaderData
2400
+ },
2401
+ stateScript: t.renderRouterStateScript(r.stateInput),
2402
+ hasDeferred: r.hasDeferred
2403
+ };
2404
+ }, Hr = (e) => {
2405
+ let { html: t, meta: n } = e.helpers.renderPageToHtml(e.prepared.renderInput);
2406
+ return {
2407
+ body: t,
2408
+ meta: n
2409
+ };
2410
+ }, Ur = (e) => [
2411
+ ...e.extra ?? [],
2412
+ e.helpers.renderMetaToHtml(e.meta),
2413
+ `<meta name="voltro-interactive" content="${e.interactive}" />`,
2414
+ ...e.prepared.hasDeferred ? [e.helpers.renderDeferredRegistryScript()] : [],
2415
+ e.prepared.stateScript
2416
+ ].filter((e) => e.length > 0).join("\n "), Wr = "<div id=\"root\"></div>", Gr = "<div id=\"root\">", Kr = "</div>", qr = /<script\b[^>]*\btype=["']module["'][^>]*><\/script>[ \t]*\n?/gi, Jr = /\bsrc=["']([^"']+)["']/i, Yr = /<script(?![^>]*\basync\b)([^>]*\btype=["']module["'][^>]*)>/gi, Xr = (e) => {
2417
+ let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(qr, (e) => {
2418
+ let r = Jr.exec(e)?.[1];
2200
2419
  return r === void 0 || t(r) ? e : (n.push(r), "");
2201
2420
  });
2202
- e.inlineModuleScriptsAsync && (r = r.replace(jr, "<script async$1>"));
2203
- let i = r.indexOf(Er);
2204
- if (i === -1) throw Error(`[voltro] the generated shell has no \`${Er}\` 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.`);
2421
+ e.inlineModuleScriptsAsync && (r = r.replace(Yr, "<script async$1>"));
2422
+ let i = r.indexOf(Wr);
2423
+ if (i === -1) throw Error(`[voltro] the generated shell has no \`${Wr}\` 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.`);
2205
2424
  return {
2206
- head: `${r.slice(0, i)}${Dr}`,
2207
- tail: `${Or}${r.slice(i + 21)}`,
2425
+ head: `${r.slice(0, i)}${Gr}`,
2426
+ tail: `${Kr}${r.slice(i + 21)}`,
2208
2427
  bootstrapModules: n
2209
2428
  };
2210
- }, Nr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), Pr = (e) => {
2429
+ }, Zr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), Qr = (e) => {
2211
2430
  let { res: t, shell: n, htmlLang: r, headInjection: i } = e, a = null, o = !1, s = !1, c = () => {
2212
2431
  if (s || !o || a === null) return;
2213
2432
  s = !0, t.statusCode = e.statusCode ?? 200;
2214
2433
  for (let [n, r] of Object.entries(e.headers ?? {})) t.setHeader(n, r);
2215
- t.flushHeaders?.(), t.write(Nr({
2434
+ t.flushHeaders?.(), t.write(Zr({
2216
2435
  head: n.head,
2217
2436
  headInjection: i(a.meta),
2218
2437
  htmlLang: r
2219
2438
  }));
2220
- let c = new _e();
2439
+ let c = new he();
2221
2440
  c.pipe(t, { end: !1 }), c.on("end", () => {
2222
2441
  t.end(n.tail);
2223
2442
  }), a.stream.pipe(c);
@@ -2242,14 +2461,14 @@ import {
2242
2461
  return;
2243
2462
  }
2244
2463
  c();
2245
- }, Z = g({ scope: "voltro:dev:web" }), Fr = g({ scope: "vite" }), Ir = await (async () => {
2464
+ }, Q = g({ scope: "voltro:dev:web" }), $r = g({ scope: "vite" }), ei = await (async () => {
2246
2465
  try {
2247
2466
  let e = r(t(o(import.meta.url)), "..", "package.json"), n = await S.readFile(e, "utf8");
2248
2467
  return JSON.parse(n).version ?? "0.0.0";
2249
2468
  } catch {
2250
2469
  return "0.0.0";
2251
2470
  }
2252
- })(), Lr = async () => {
2471
+ })(), ti = async () => {
2253
2472
  try {
2254
2473
  let e = t(o(import.meta.url)), n = a(e, "..", "..", "devtools");
2255
2474
  if (y(r(n, "package.json"))) return n;
@@ -2258,7 +2477,7 @@ import {
2258
2477
  } catch {
2259
2478
  return null;
2260
2479
  }
2261
- }, Rr = (e, t) => e.disableDevtools || !t ? [] : [
2480
+ }, ni = (e, t) => e.disableDevtools || !t ? [] : [
2262
2481
  "",
2263
2482
  "// Dev-only in-page devtools overlay. The `import.meta.env.DEV` guard is a",
2264
2483
  "// compile-time constant, so prod builds strip this whole `if` block — the",
@@ -2268,12 +2487,12 @@ import {
2268
2487
  " await import('@voltro/devtools/styles.css')",
2269
2488
  " Devtools = (await import('@voltro/devtools')).VoltroDevtools",
2270
2489
  "}"
2271
- ], zr = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], Br = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], Vr = (e) => e.sentry ? [
2490
+ ], ri = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], ii = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], ai = (e) => e.sentry ? [
2272
2491
  "",
2273
2492
  "// Browser-side Sentry (frontend half of the deep integration). Errors +",
2274
2493
  "// browser rpc spans flow to Sentry, sharing the server transactions' trace.",
2275
2494
  `await initSentryBrowser(${JSON.stringify(e.sentry)})`
2276
- ] : [], Hr = (e) => e.env ? ["import './env.public'"] : [], Ur = (e) => {
2495
+ ] : [], oi = (e) => e.env ? ["import './env.public'"] : [], si = (e) => {
2277
2496
  let n = [], i = a(e);
2278
2497
  for (;;) {
2279
2498
  y(r(i, "pnpm-workspace.yaml")) && n.push(i);
@@ -2282,19 +2501,19 @@ import {
2282
2501
  i = e;
2283
2502
  }
2284
2503
  return n;
2285
- }, Wr = /* @__PURE__ */ new Set([
2504
+ }, ci = /* @__PURE__ */ new Set([
2286
2505
  "layout.tsx",
2287
2506
  "error.tsx",
2288
2507
  "loading.tsx",
2289
2508
  "not-found.tsx"
2290
- ]), Gr = (e) => /\.(test|spec)\.tsx$/.test(e), Kr = (e) => {
2509
+ ]), li = (e) => /\.(test|spec)\.tsx$/.test(e), ui = (e) => {
2291
2510
  if (/\/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(?:react|react-dom|scheduler)\//.test(e)) return "react";
2292
2511
  let t = /\/([^/]+)\.island\.tsx?$/.exec(e);
2293
2512
  if (t) return `island-${t[1]}`;
2294
- }, qr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, Jr = (e) => e.startsWith("(") && e.endsWith(")"), Yr = (e) => e.filter((e) => !Jr(e)), Xr = (e) => {
2295
- let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !Jr(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2513
+ }, di = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, fi = (e) => e.startsWith("(") && e.endsWith(")"), pi = (e) => e.filter((e) => !fi(e)), mi = (e) => {
2514
+ let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !fi(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2296
2515
  return n.length === 0 ? "/" : "/" + n.join("/");
2297
- }, Zr = (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) => {
2516
+ }, hi = (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`, $ = (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}`, gi = async (e) => {
2298
2517
  let t = [], n = [], i = async (e, a) => {
2299
2518
  let o = [];
2300
2519
  try {
@@ -2302,17 +2521,17 @@ import {
2302
2521
  } catch {
2303
2522
  return;
2304
2523
  }
2305
- let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Gr(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2306
- if (c.some((e) => Wr.has(e))) {
2524
+ let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !li(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2525
+ if (c.some((e) => ci.has(e))) {
2307
2526
  let t = l.has("layout.tsx"), i = !1;
2308
2527
  if (t) try {
2309
2528
  let t = await S.readFile(r(e, "layout.tsx"), "utf8");
2310
- i = qr.test(t);
2529
+ i = di.test(t);
2311
2530
  } catch {}
2312
2531
  n.push({
2313
2532
  dir: u,
2314
2533
  chain: a,
2315
- contributesToUrl: a.length === 0 || !Jr(a[a.length - 1]),
2534
+ contributesToUrl: a.length === 0 || !fi(a[a.length - 1]),
2316
2535
  hasLayout: t,
2317
2536
  hasLayoutLoader: i,
2318
2537
  hasError: l.has("error.tsx"),
@@ -2321,12 +2540,12 @@ import {
2321
2540
  });
2322
2541
  }
2323
2542
  for (let e of c) {
2324
- if (Wr.has(e)) continue;
2543
+ if (ci.has(e)) continue;
2325
2544
  let n = u ? `${u}/${e}` : e;
2326
2545
  t.push({
2327
2546
  file: n,
2328
- pattern: Xr(n),
2329
- ident: Zr(n),
2547
+ pattern: mi(n),
2548
+ ident: hi(n),
2330
2549
  dirChain: a
2331
2550
  });
2332
2551
  }
@@ -2336,14 +2555,14 @@ import {
2336
2555
  pages: t,
2337
2556
  dirs: n
2338
2557
  };
2339
- }, Qr = (e, t) => {
2558
+ }, _i = (e, t) => {
2340
2559
  let n = [];
2341
2560
  for (let r = 0; r <= t.length; r++) {
2342
2561
  let i = t.slice(0, r).join("/"), a = e.find((e) => e.dir === i);
2343
2562
  a && n.push(a);
2344
2563
  }
2345
2564
  return n;
2346
- }, $r = async (e) => {
2565
+ }, vi = async (e) => {
2347
2566
  let { entries: t, loadLayout: n, loadError: r, loadPending: i, ctx: a } = e, o = {};
2348
2567
  return {
2349
2568
  chain: await Promise.all(t.map(async (e, t) => {
@@ -2365,10 +2584,10 @@ import {
2365
2584
  })),
2366
2585
  segmentLoaderData: o
2367
2586
  };
2368
- }, ei = (e) => {
2369
- let t = Yr(e);
2587
+ }, yi = (e) => {
2588
+ let t = pi(e);
2370
2589
  return t.length === 0 ? "" : "/" + t.join("/");
2371
- }, ti = [
2590
+ }, bi = [
2372
2591
  "// Hot-reload bridge: keep SSR-injected <link rel=\"stylesheet\"> tags",
2373
2592
  "// in sync with Vite's CSS HMR. Without this, edits to .css files",
2374
2593
  "// only update the JS-injected <style> overlay; the underlying <link>",
@@ -2461,7 +2680,7 @@ import {
2461
2680
  " _vdtErrorStart('Build error')",
2462
2681
  " })",
2463
2682
  "}"
2464
- ].join("\n"), ni = (e) => {
2683
+ ].join("\n"), xi = (e) => {
2465
2684
  let t = [], n = 0, r = e.split("/").filter(Boolean), i = [];
2466
2685
  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, "\\$&"));
2467
2686
  let a = i.join("/");
@@ -2470,8 +2689,8 @@ import {
2470
2689
  paramNames: t,
2471
2690
  priority: n
2472
2691
  };
2473
- }, ri = (e) => e.map((e) => {
2474
- let { regex: t, paramNames: n, priority: r } = ni(e.pattern);
2692
+ }, Si = (e) => e.map((e) => {
2693
+ let { regex: t, paramNames: n, priority: r } = xi(e.pattern);
2475
2694
  return {
2476
2695
  pattern: e.pattern,
2477
2696
  file: e.file,
@@ -2480,7 +2699,7 @@ import {
2480
2699
  paramNames: n,
2481
2700
  priority: r
2482
2701
  };
2483
- }).slice().sort((e, t) => e.priority - t.priority), ii = (e, t) => {
2702
+ }).slice().sort((e, t) => e.priority - t.priority), Ci = (e, t) => {
2484
2703
  for (let n of t) {
2485
2704
  let t = n.regex.exec(e);
2486
2705
  if (!t) continue;
@@ -2492,7 +2711,7 @@ import {
2492
2711
  };
2493
2712
  }
2494
2713
  return null;
2495
- }, ai = async (e, n) => {
2714
+ }, wi = async (e, n) => {
2496
2715
  let i = e;
2497
2716
  for (;;) {
2498
2717
  let e = r(i, "node_modules", n);
@@ -2506,7 +2725,7 @@ import {
2506
2725
  if (a === i) return null;
2507
2726
  i = a;
2508
2727
  }
2509
- }, oi = async (e) => {
2728
+ }, Ti = async (e) => {
2510
2729
  try {
2511
2730
  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;
2512
2731
  return o ? {
@@ -2515,13 +2734,13 @@ import {
2515
2734
  } : { port: i };
2516
2735
  } catch {}
2517
2736
  return { port: 4e3 };
2518
- }, si = (e, t) => ({
2737
+ }, Ei = (e, t) => ({
2519
2738
  name: e,
2520
2739
  pkg: t.package,
2521
2740
  browserWsUrl: t.url,
2522
2741
  proxyTarget: void 0,
2523
2742
  ...t.headers ? { headers: t.headers } : {}
2524
- }), ci = (e, t, n) => {
2743
+ }), Di = (e, t, n) => {
2525
2744
  let r = t.transport?.wsPath ?? n.wsPath;
2526
2745
  return {
2527
2746
  name: e,
@@ -2531,7 +2750,7 @@ import {
2531
2750
  ...r ? { wsPath: r } : {},
2532
2751
  ...t.headers ? { headers: t.headers } : {}
2533
2752
  };
2534
- }, li = (e) => {
2753
+ }, Oi = (e) => {
2535
2754
  let t = /* @__PURE__ */ new Map();
2536
2755
  for (let n of e) {
2537
2756
  if (n.proxyTarget === void 0) continue;
@@ -2539,19 +2758,19 @@ import {
2539
2758
  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>.`);
2540
2759
  t.set(n.browserWsUrl, n.name);
2541
2760
  }
2542
- }, ui = async (e, t) => {
2761
+ }, ki = async (e, t) => {
2543
2762
  let n = Object.entries(t.apis ?? {}), r = [];
2544
2763
  for (let [t, i] of n) {
2545
2764
  if (i.url) {
2546
- r.push(si(t, i));
2765
+ r.push(Ei(t, i));
2547
2766
  continue;
2548
2767
  }
2549
- let n = await ai(e, i.package);
2768
+ let n = await wi(e, i.package);
2550
2769
  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.`);
2551
- r.push(ci(t, i, await oi(n)));
2770
+ r.push(Di(t, i, await Ti(n)));
2552
2771
  }
2553
- return li(r), r;
2554
- }, di = (e) => {
2772
+ return Oi(r), r;
2773
+ }, Ai = (e) => {
2555
2774
  if (!e) return;
2556
2775
  let t = e.proxyTarget ?? e.browserWsUrl;
2557
2776
  if (t && !(!/^wss?:\/\//.test(t) && !/^https?:\/\//.test(t))) try {
@@ -2560,7 +2779,7 @@ import {
2560
2779
  } catch {
2561
2780
  return;
2562
2781
  }
2563
- }, fi = (e, t) => {
2782
+ }, ji = (e, t) => {
2564
2783
  if (e) return async (n, r) => {
2565
2784
  let i = {
2566
2785
  _tag: "Request",
@@ -2592,8 +2811,8 @@ import {
2592
2811
  }
2593
2812
  if (l) return c;
2594
2813
  };
2595
- }, pi = async (e, t, n, i = {}) => {
2596
- 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 Lr() !== null, c = t.theme === "system" ? [
2814
+ }, Mi = async (e, t, n, i = {}) => {
2815
+ 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 ti() !== null, c = t.theme === "system" ? [
2597
2816
  " <script>",
2598
2817
  " (function () {",
2599
2818
  " var root = document.documentElement",
@@ -2631,59 +2850,61 @@ import {
2631
2850
  " </body>",
2632
2851
  "</html>",
2633
2852
  ""
2634
- ].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) => {
2635
- let t = [`group: ${f(e.name)}`];
2636
- 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(", ")} },`;
2637
- }), g, _, v;
2638
- if (u.length > 0) {
2639
- let e = u.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
2640
- for (let e of d) {
2853
+ ].join("\n"), u = r(e, "src", "pages"), { pages: d, dirs: f } = await gi(u);
2854
+ await nr(u, d);
2855
+ let p = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppGroup`, m = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppDescriptors`, h = n.map((e) => `import { appGroup as ${p(e.name)}, appDescriptors as ${m(e.name)} } from '${e.pkg}/rpcGroup'`), g = n.map((e) => {
2856
+ let t = [`group: ${p(e.name)}`];
2857
+ return t.push(`descriptors: ${m(e.name)}`), t.push(`wsUrl: ${JSON.stringify(e.browserWsUrl)}`), e.headers && t.push(`headers: ${JSON.stringify(e.headers)}`), ` ${JSON.stringify(e.name)}: { ${t.join(", ")} },`;
2858
+ }), _, v, b;
2859
+ if (d.length > 0) {
2860
+ let e = d.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
2861
+ for (let e of f) {
2641
2862
  let t = e.dir === "" ? "../src/pages" : `../src/pages/${e.dir}`;
2642
- 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'`);
2863
+ e.hasLayout && e.hasLayoutLoader ? n.push(`import * as ${$(e.dir, "Layout")}Mod from '${t}/layout.tsx'`) : e.hasLayout && n.push(`import ${$(e.dir, "Layout")} from '${t}/layout.tsx'`), e.hasError && n.push(`import ${$(e.dir, "Error")} from '${t}/error.tsx'`), e.hasPending && n.push(`import ${$(e.dir, "Pending")} from '${t}/loading.tsx'`), e.hasNotFound && n.push(`import ${$(e.dir, "NotFound")} from '${t}/not-found.tsx'`);
2643
2864
  }
2644
- let r = u.map((e) => {
2645
- let t = Qr(d, e.dirChain).map((e) => {
2865
+ let r = d.map((e) => {
2866
+ let t = _i(f, e.dirChain).map((e) => {
2646
2867
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2647
2868
  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(", ")} }`;
2648
2869
  }).join(",\n");
2649
2870
  return ` makePageRoute(${JSON.stringify(e.pattern)}, ${t.length > 0 ? `[\n${t},\n ]` : "undefined"}),`;
2650
- }), i = d.filter((e) => e.hasNotFound).map((e) => {
2651
- let t = ei(e.chain), n = Qr(d, e.chain).map((e) => {
2871
+ }), i = f.filter((e) => e.hasNotFound).map((e) => {
2872
+ let t = yi(e.chain), n = _i(f, e.chain).map((e) => {
2652
2873
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2653
2874
  return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), ` { ${t.join(", ")} }`;
2654
2875
  }).join(",\n"), r = n.length > 0 ? `\n chain: [\n${n},\n ],` : "";
2655
2876
  return ` {\n prefix: ${JSON.stringify(t)},\n Component: refs.notFounds[${JSON.stringify(e.dir)}],${r}\n },`;
2656
- }), a = [], o = [], c = [], l = [], f = [], p = [];
2657
- for (let e of d) {
2877
+ }), a = [], o = [], c = [], l = [], u = [], p = [];
2878
+ for (let e of f) {
2658
2879
  let t = e.dir === "" ? "../src/pages/layout.tsx" : `../src/pages/${e.dir}/layout.tsx`, n = e.dir === "" ? "../src/pages/error.tsx" : `../src/pages/${e.dir}/error.tsx`, r = e.dir === "" ? "../src/pages/loading.tsx" : `../src/pages/${e.dir}/loading.tsx`, i = e.dir === "" ? "../src/pages/not-found.tsx" : `../src/pages/${e.dir}/not-found.tsx`, s = JSON.stringify(e.dir);
2659
- e.hasLayout && e.hasLayoutLoader ? (o.push(` ${s}: ${Q(e.dir, "Layout")}Mod.default,`), c.push(` ${s}: ${Q(e.dir, "Layout")}Mod.loader,`), a.push({
2880
+ e.hasLayout && e.hasLayoutLoader ? (o.push(` ${s}: ${$(e.dir, "Layout")}Mod.default,`), c.push(` ${s}: ${$(e.dir, "Layout")}Mod.loader,`), a.push({
2660
2881
  relPath: t,
2661
2882
  kind: "layout",
2662
2883
  slotKey: e.dir
2663
- })) : e.hasLayout && (o.push(` ${s}: ${Q(e.dir, "Layout")},`), a.push({
2884
+ })) : e.hasLayout && (o.push(` ${s}: ${$(e.dir, "Layout")},`), a.push({
2664
2885
  relPath: t,
2665
2886
  kind: "layout",
2666
2887
  slotKey: e.dir
2667
- })), e.hasError && (l.push(` ${s}: ${Q(e.dir, "Error")},`), a.push({
2888
+ })), e.hasError && (l.push(` ${s}: ${$(e.dir, "Error")},`), a.push({
2668
2889
  relPath: n,
2669
2890
  kind: "error",
2670
2891
  slotKey: e.dir
2671
- })), e.hasPending && (f.push(` ${s}: ${Q(e.dir, "Pending")},`), a.push({
2892
+ })), e.hasPending && (u.push(` ${s}: ${$(e.dir, "Pending")},`), a.push({
2672
2893
  relPath: r,
2673
2894
  kind: "pending",
2674
2895
  slotKey: e.dir
2675
- })), e.hasNotFound && (p.push(` ${s}: ${Q(e.dir, "NotFound")},`), a.push({
2896
+ })), e.hasNotFound && (p.push(` ${s}: ${$(e.dir, "NotFound")},`), a.push({
2676
2897
  relPath: i,
2677
2898
  kind: "notFound",
2678
2899
  slotKey: e.dir
2679
2900
  }));
2680
2901
  }
2681
- for (let e of u) a.push({
2902
+ for (let e of d) a.push({
2682
2903
  relPath: `../src/pages/${e.file}`,
2683
2904
  kind: "page",
2684
2905
  slotKey: e.pattern
2685
2906
  });
2686
- let y = a.map((e) => ` ${JSON.stringify(e.relPath)},`), b = a.map((e, t) => {
2907
+ let m = a.map((e) => ` ${JSON.stringify(e.relPath)},`), y = a.map((e, t) => {
2687
2908
  let n = JSON.stringify(e.slotKey);
2688
2909
  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 }`;
2689
2910
  }), x = t.locales ?? [], S = x.length > 0, C = t.defaultLocale ?? x[0] ?? "en";
@@ -2694,7 +2915,7 @@ import {
2694
2915
  "import { useServerRequest } from '@voltro/web'",
2695
2916
  ...x.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
2696
2917
  ] : [];
2697
- _ = [
2918
+ v = [
2698
2919
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2699
2920
  "// Routes + per-page chain + not-found scopes assembled from src/pages/.",
2700
2921
  "//",
@@ -2737,7 +2958,7 @@ import {
2737
2958
  ...l,
2738
2959
  " },",
2739
2960
  " pendings: {",
2740
- ...f,
2961
+ ...u,
2741
2962
  " },",
2742
2963
  " notFounds: {",
2743
2964
  ...p,
@@ -2805,17 +3026,17 @@ import {
2805
3026
  "if (import.meta.hot) {",
2806
3027
  " import.meta.hot.accept(",
2807
3028
  " [",
2808
- ...y,
3029
+ ...m,
2809
3030
  " ],",
2810
3031
  " (newMods: Array<Record<string, unknown> | undefined>) => {",
2811
3032
  " let changed = false",
2812
- ...b,
3033
+ ...y,
2813
3034
  " if (changed) bump()",
2814
3035
  " },",
2815
3036
  " )",
2816
3037
  "}",
2817
3038
  ""
2818
- ].join("\n"), g = [
3039
+ ].join("\n"), _ = [
2819
3040
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2820
3041
  "// The app's root component. It exports `App` and NOTHING ELSE: react-refresh",
2821
3042
  "// only accepts a module whose every export is a component, and a module it",
@@ -2881,20 +3102,20 @@ import {
2881
3102
  ] : [" return <Router routes={routes} notFounds={notFounds} />"],
2882
3103
  "}",
2883
3104
  ""
2884
- ].join("\n"), v = [
3105
+ ].join("\n"), b = [
2885
3106
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2886
3107
  "// Entry: imports the generated App component and calls mount() with the",
2887
3108
  "// resolved apis map. Side-effect only — no local component definitions —",
2888
3109
  "// so downstream invalidations (user page edits) terminate at app.tsx.",
2889
3110
  "",
2890
- ...Hr(t),
3111
+ ...oi(t),
2891
3112
  "import { mount } from '@voltro/web'",
2892
- ...m,
3113
+ ...h,
2893
3114
  "import { App } from './app'",
2894
3115
  "import { preloadCurrentRoute } from './routeTable'",
2895
- ...Br(t),
2896
- ...Rr(t, s),
2897
- ...Vr(t),
3116
+ ...ii(t),
3117
+ ...ni(t, s),
3118
+ ...ai(t),
2898
3119
  "",
2899
3120
  "// Preload the current route's page chunk BEFORE hydration so the first",
2900
3121
  "// client render matches the SSG/SSR-prerendered HTML. Without it, a lazy",
@@ -2909,101 +3130,101 @@ import {
2909
3130
  "",
2910
3131
  "mount(App, {",
2911
3132
  " apis: {",
2912
- ...h,
3133
+ ...g,
2913
3134
  " },",
2914
- ...zr(t, s),
3135
+ ...ri(t, s),
2915
3136
  "})",
2916
3137
  "",
2917
- ti
3138
+ bi
2918
3139
  ].join("\n");
2919
- } else g = "", _ = "", v = [
3140
+ } else _ = "", v = "", b = [
2920
3141
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2921
3142
  "// The user's root component lives at ../src/App.tsx; this file imports it",
2922
3143
  "// and calls mount(). Side-effect only, no component definitions, so the",
2923
3144
  "// user's component file remains the Fast Refresh boundary.",
2924
3145
  "",
2925
- ...Hr(t),
3146
+ ...oi(t),
2926
3147
  "import { mount } from '@voltro/web'",
2927
- ...m,
3148
+ ...h,
2928
3149
  "import App from '../src/App'",
2929
- ...Br(t),
2930
- ...Rr(t, s),
2931
- ...Vr(t),
3150
+ ...ii(t),
3151
+ ...ni(t, s),
3152
+ ...ai(t),
2932
3153
  "",
2933
3154
  "mount(App, {",
2934
3155
  " apis: {",
2935
- ...h,
3156
+ ...g,
2936
3157
  " },",
2937
- ...zr(t, s),
3158
+ ...ri(t, s),
2938
3159
  "})",
2939
3160
  "",
2940
- ti
3161
+ bi
2941
3162
  ].join("\n");
2942
- let b = r(e, ".framework");
2943
- await S.mkdir(b, { recursive: !0 }), t.env ? await Qe(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 }));
2944
- let x = r(e, ".gitignore"), C = "";
3163
+ let x = r(e, ".framework");
3164
+ await S.mkdir(x, { recursive: !0 }), t.env ? await lt(x, i) : await S.rm(r(x, "env.public.ts"), { force: !0 }), await S.writeFile(r(x, "index.html"), l, "utf8"), await S.writeFile(r(x, "main.tsx"), b, "utf8"), _ ? (await S.writeFile(r(x, "app.tsx"), _, "utf8"), await S.writeFile(r(x, "routeTable.ts"), v, "utf8")) : (await S.rm(r(x, "app.tsx"), { force: !0 }), await S.rm(r(x, "routeTable.ts"), { force: !0 }));
3165
+ let C = r(e, ".gitignore"), w = "";
2945
3166
  try {
2946
- C = await S.readFile(x, "utf8");
3167
+ w = await S.readFile(C, "utf8");
2947
3168
  } catch {}
2948
- let w = ["/.framework/"], T = C.split("\n").filter((e) => e.trim() !== "");
2949
- for (let e of w) T.includes(e) || T.push(e);
2950
- await S.writeFile(x, T.join("\n") + "\n", "utf8");
2951
- }, mi = async (e, n) => {
3169
+ let T = ["/.framework/"], E = w.split("\n").filter((e) => e.trim() !== "");
3170
+ for (let e of T) E.includes(e) || E.push(e);
3171
+ await S.writeFile(C, E.join("\n") + "\n", "utf8");
3172
+ }, Ni = async (e, n) => {
2952
3173
  try {
2953
3174
  let i = r(t(e), "project.json");
2954
3175
  if (!y(i)) return;
2955
3176
  let a = await S.readFile(i, "utf8"), o = JSON.parse(a).apps ?? {}, s = e.split("/").filter(Boolean).pop() ?? "", c = [];
2956
3177
  for (let [e, t] of Object.entries(o)) e !== s && t.port === n && c.push(e);
2957
3178
  if (c.length === 0) return;
2958
- Z.warn("sibling app(s) claim the same port — only one boots", {
3179
+ Q.warn("sibling app(s) claim the same port — only one boots", {
2959
3180
  port: n,
2960
3181
  conflicts: c,
2961
3182
  projectJson: i
2962
3183
  });
2963
3184
  } catch {}
2964
- }, hi = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), gi = async (e) => {
2965
- let t = hi(e), n = y(t) ? t : r(e, "app.config.ts");
3185
+ }, Pi = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), Fi = async (e) => {
3186
+ let t = Pi(e), n = y(t) ? t : r(e, "app.config.ts");
2966
3187
  try {
2967
3188
  let e = (await import(s(n).href)).default;
2968
3189
  return typeof e == "object" && e && "type" in e && e.type === "web" ? e : null;
2969
3190
  } catch {
2970
3191
  return null;
2971
3192
  }
2972
- }, _i = async (t) => {
2973
- let n = await gi(t);
3193
+ }, Ii = async (t) => {
3194
+ let n = await Fi(t);
2974
3195
  if (!n) return {
2975
3196
  ran: !1,
2976
3197
  exitCode: 0
2977
3198
  };
2978
- On();
2979
- let o = Kt();
2980
- nn(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
2981
- let s = await ui(t, n);
2982
- for (let e of s) Z.info("api wired", {
3199
+ Hn();
3200
+ let o = sn();
3201
+ _n(o), Q.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
3202
+ let s = await ki(t, n);
3203
+ for (let e of s) Q.info("api wired", {
2983
3204
  name: e.name,
2984
3205
  pkg: e.pkg,
2985
3206
  ...e.proxyTarget ? { proxyTo: e.proxyTarget } : { directWs: e.browserWsUrl }
2986
3207
  });
2987
- Ve(t).then((e) => {
3208
+ Be(t).then((e) => {
2988
3209
  for (let t of e.files) if (t.action === "created") {
2989
3210
  let e = t.path.split("/").pop() ?? t.path;
2990
- Z.info(`${e} seeded`, { path: t.path });
3211
+ Q.info(`${e} seeded`, { path: t.path });
2991
3212
  }
2992
3213
  }).catch(() => {});
2993
- let { resolved: c } = await $e({
3214
+ let { resolved: c } = await ut({
2994
3215
  rawEnv: n.env,
2995
3216
  appType: "web",
2996
3217
  root: t,
2997
- log: Z,
3218
+ log: Q,
2998
3219
  generateTypes: !0
2999
3220
  }), l = c.publicValues;
3000
- await pi(t, n, s, l), Z.debug("generated framework entry files", { files: [
3221
+ await Mi(t, n, s, l), Q.debug("generated framework entry files", { files: [
3001
3222
  "index.html",
3002
3223
  ".framework/main.tsx",
3003
3224
  ...n.env ? [".framework/env.public.ts"] : []
3004
3225
  ] });
3005
- 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 = tr("web", d, u), p = cr(d);
3006
- await $n({
3226
+ 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 = hr("web", d, u), p = Sr(d);
3227
+ await pr({
3007
3228
  id: f,
3008
3229
  name: d,
3009
3230
  kind: "web",
@@ -3011,19 +3232,19 @@ import {
3011
3232
  pid: process.pid,
3012
3233
  status: "booting",
3013
3234
  logFile: p.path
3014
- }).catch(() => {}), await mi(t, u);
3015
- let { pages: m, dirs: h } = await $(r(t, "src", "pages")), g = h.map((e) => ({
3235
+ }).catch(() => {}), await Ni(t, u);
3236
+ let { pages: m, dirs: h } = await gi(r(t, "src", "pages")), g = h.map((e) => ({
3016
3237
  dir: e.dir,
3017
3238
  hasLayout: e.hasLayout,
3018
3239
  hasError: e.hasError,
3019
3240
  hasPending: e.hasPending,
3020
3241
  hasNotFound: e.hasNotFound
3021
- })), v = await vt({
3242
+ })), v = await Mt({
3022
3243
  appRoot: t,
3023
3244
  pages: m
3024
3245
  });
3025
- v.wrote && Z.debug("routes codegen wrote", { path: i(t, v.path) });
3026
- let b = await Ke("vite", () => import("vite")), x = (await import("@vitejs/plugin-react")).default, C = (await import("@tailwindcss/vite")).default, w = r(t, ".framework"), T = r(t, "src"), E = /* @__PURE__ */ new Set([
3246
+ v.wrote && Q.debug("routes codegen wrote", { path: i(t, v.path) });
3247
+ let b = await Ge("vite", () => import("vite")), x = (await import("@vitejs/plugin-react")).default, C = (await import("@tailwindcss/vite")).default, w = r(t, ".framework"), T = r(t, "src"), E = /* @__PURE__ */ new Set([
3027
3248
  ".framework",
3028
3249
  "node_modules",
3029
3250
  "dist",
@@ -3047,7 +3268,7 @@ import {
3047
3268
  ...i.devDependencies
3048
3269
  });
3049
3270
  await Promise.all(a.map(async (n) => {
3050
- let i = await ai(t, n);
3271
+ let i = await wi(t, n);
3051
3272
  if (!i) return;
3052
3273
  let a = r(i, "src");
3053
3274
  try {
@@ -3056,62 +3277,62 @@ import {
3056
3277
  }));
3057
3278
  } catch {}
3058
3279
  }
3059
- }, D = r(t, "src", "pages"), O = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), k = (e) => e === D || e.startsWith(D + "/"), te = async (e) => {
3280
+ }, 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) => {
3060
3281
  try {
3061
3282
  let r = Date.now();
3062
- await pi(t, n, s, l);
3063
- let { pages: i } = await $(D);
3064
- await vt({
3283
+ await Mi(t, n, s, l);
3284
+ let { pages: i } = await gi(D);
3285
+ await Mt({
3065
3286
  appRoot: t,
3066
3287
  pages: i
3067
- }), Z.info("page tree regenerated", {
3288
+ }), Q.info("page tree regenerated", {
3068
3289
  reason: e,
3069
3290
  ms: Date.now() - r
3070
3291
  });
3071
3292
  } catch (t) {
3072
- Z.error("page tree regen failed", { reason: e }, t);
3293
+ Q.error("page tree regen failed", { reason: e }, t);
3073
3294
  }
3074
- }, ne = {
3295
+ }, A = {
3075
3296
  name: "framework:regenerate-on-page-tree-change",
3076
3297
  configureServer(e) {
3077
3298
  let n = null, r = [], a = (e) => {
3078
3299
  r.push(e), n && clearTimeout(n), n = setTimeout(() => {
3079
3300
  n = null;
3080
3301
  let e = r.length === 1 ? r[0] : `${r.length} events (${r[0]}, …)`;
3081
- r.length = 0, te(e);
3302
+ r.length = 0, k(e);
3082
3303
  }, 50);
3083
3304
  };
3084
3305
  e.watcher.on("add", (e) => {
3085
- O(e) && a(`add ${i(t, e)}`);
3306
+ te(e) && a(`add ${i(t, e)}`);
3086
3307
  }), e.watcher.on("unlink", (e) => {
3087
- O(e) && a(`unlink ${i(t, e)}`);
3308
+ te(e) && a(`unlink ${i(t, e)}`);
3088
3309
  }), e.watcher.on("addDir", (e) => {
3089
- k(e) && a(`addDir ${i(t, e)}`);
3310
+ O(e) && a(`addDir ${i(t, e)}`);
3090
3311
  }), e.watcher.on("unlinkDir", (e) => {
3091
- k(e) && a(`unlinkDir ${i(t, e)}`);
3312
+ O(e) && a(`unlinkDir ${i(t, e)}`);
3092
3313
  });
3093
3314
  }
3094
- }, A = r(t, "app.config.ts"), re = (e) => {
3095
- if (!se(e.env)) return "";
3315
+ }, j = r(t, "app.config.ts"), M = (e) => {
3316
+ if (!oe(e.env)) return "";
3096
3317
  let t = Object.entries(e.env.vars).map(([e, t]) => `${e}:${t.access}`).sort();
3097
3318
  return `${String(e.env.publicPrefix)}|${t.join(",")}`;
3098
- }, j = (e, t) => {
3319
+ }, ne = (e, t) => {
3099
3320
  let n = [];
3100
- 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"), re(e) !== re(t) && n.push("env"), n;
3101
- }, M = n, ie = a(A), ae = {
3321
+ 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;
3322
+ }, N = n, re = a(j), P = {
3102
3323
  name: "framework:watch-app-config",
3103
3324
  async configureServer(n) {
3104
- n.watcher.add(A), Z.info("watching app.config.ts for changes", { path: i(t, A) });
3325
+ n.watcher.add(j), Q.info("watching app.config.ts for changes", { path: i(t, j) });
3105
3326
  let r = async () => {
3106
3327
  try {
3107
3328
  try {
3108
- let e = n.moduleGraph.getModuleById(A);
3329
+ let e = n.moduleGraph.getModuleById(j);
3109
3330
  e && n.moduleGraph.invalidateModule(e);
3110
3331
  } catch {}
3111
- let e = (await n.ssrLoadModule(A, { fixStacktrace: !0 })).default;
3112
- 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);
3332
+ let e = (await n.ssrLoadModule(j, { fixStacktrace: !0 })).default;
3333
+ return typeof e == "object" && e && "type" in e && e.type === "web" ? e : (Q.warn("app.config.ts re-load returned wrong shape", { hasDefault: e !== void 0 }), null);
3113
3334
  } catch (e) {
3114
- return Z.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
3335
+ return Q.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
3115
3336
  }
3116
3337
  }, o = null, s = () => {
3117
3338
  o && clearTimeout(o), o = setTimeout(() => {
@@ -3120,24 +3341,24 @@ import {
3120
3341
  }, c = async () => {
3121
3342
  let e = await r();
3122
3343
  if (!e) {
3123
- Z.info("app.config.ts onConfigChange: load returned null — skipping");
3344
+ Q.info("app.config.ts onConfigChange: load returned null — skipping");
3124
3345
  return;
3125
3346
  }
3126
- if (Z.info("app.config.ts onConfigChange: loaded", {
3347
+ if (Q.info("app.config.ts onConfigChange: loaded", {
3127
3348
  theme: e.theme,
3128
3349
  port: e.port,
3129
3350
  name: e.name
3130
- }), JSON.stringify(e) === JSON.stringify(M)) {
3131
- Z.info("app.config.ts onConfigChange: parsed config unchanged — skipping (no-op edit?)");
3351
+ }), JSON.stringify(e) === JSON.stringify(N)) {
3352
+ Q.info("app.config.ts onConfigChange: parsed config unchanged — skipping (no-op edit?)");
3132
3353
  return;
3133
3354
  }
3134
- let i = j(M, e);
3355
+ let i = ne(N, e);
3135
3356
  if (i.length > 0) {
3136
- Z.warn("app.config.ts changed — hard restart required", { fields: i });
3357
+ Q.warn("app.config.ts changed — hard restart required", { fields: i });
3137
3358
  try {
3138
3359
  await n.close();
3139
3360
  } catch {}
3140
- let e = fe(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
3361
+ let e = de(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
3141
3362
  stdio: "inherit",
3142
3363
  env: process.env,
3143
3364
  cwd: process.cwd()
@@ -3147,53 +3368,53 @@ import {
3147
3368
  process.on("SIGINT", r), process.on("SIGTERM", a), e.on("exit", (e, t) => {
3148
3369
  process.off("SIGINT", r), process.off("SIGTERM", a), t ? process.kill(process.pid, t) : process.exit(e ?? 0);
3149
3370
  }), e.on("error", (e) => {
3150
- Z.error("restart spawn failed", {}, e), process.exit(1);
3371
+ Q.error("restart spawn failed", {}, e), process.exit(1);
3151
3372
  });
3152
3373
  return;
3153
3374
  }
3154
3375
  try {
3155
3376
  let r = Date.now();
3156
- await pi(t, e, await ui(t, e)), M = e, n.ws && n.ws.send({
3377
+ await Mi(t, e, await ki(t, e)), N = e, n.ws && n.ws.send({
3157
3378
  type: "full-reload",
3158
3379
  path: "*"
3159
- }), Z.info("app.config.ts soft-regen", {
3380
+ }), Q.info("app.config.ts soft-regen", {
3160
3381
  ms: Date.now() - r,
3161
3382
  reload: "full"
3162
3383
  });
3163
3384
  } catch (e) {
3164
- Z.error("app.config.ts soft-regen failed", {}, e);
3385
+ Q.error("app.config.ts soft-regen failed", {}, e);
3165
3386
  }
3166
- }, l = (t) => e(t) === "app.config.ts" ? t === A || a(t) === ie : !1;
3387
+ }, l = (t) => e(t) === "app.config.ts" ? t === j || a(t) === re : !1;
3167
3388
  n.watcher.on("change", (e) => {
3168
- l(e) && (Z.info("app.config.ts change event (chokidar)", { file: e }), s());
3389
+ l(e) && (Q.info("app.config.ts change event (chokidar)", { file: e }), s());
3169
3390
  }), n.watcher.on("add", (e) => {
3170
- l(e) && (Z.info("app.config.ts add event (chokidar)", { file: e }), s());
3391
+ l(e) && (Q.info("app.config.ts add event (chokidar)", { file: e }), s());
3171
3392
  });
3172
3393
  try {
3173
3394
  let { watchFile: e } = await import("node:fs");
3174
- e(A, { interval: 500 }, (e, t) => {
3175
- e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), s());
3176
- }), Z.info("app.config.ts polling watcher attached", { intervalMs: 500 });
3395
+ e(j, { interval: 500 }, (e, t) => {
3396
+ e.mtimeMs !== t.mtimeMs && (Q.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), s());
3397
+ }), Q.info("app.config.ts polling watcher attached", { intervalMs: 500 });
3177
3398
  } catch (e) {
3178
- Z.warn("app.config.ts polling watcher could not attach", {}, e);
3399
+ Q.warn("app.config.ts polling watcher could not attach", {}, e);
3179
3400
  }
3180
- En(Cn, Z, {
3401
+ Bn(Ln, Q, {
3181
3402
  root: t,
3182
3403
  onBeforeRestart: () => n.close()
3183
3404
  });
3184
3405
  }
3185
- }, N = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, oe = {
3406
+ }, ie = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, F = {
3186
3407
  name: "framework:suppress-api-hmr",
3187
3408
  handleHotUpdate(e) {
3188
- if (N.test(e.file)) return [];
3409
+ if (ie.test(e.file)) return [];
3189
3410
  }
3190
- }, ce = {
3411
+ }, ae = {
3191
3412
  name: "framework:reoptimize-on-rpcgroup-change",
3192
3413
  async configureServer(e) {
3193
3414
  let n = /* @__PURE__ */ new Map();
3194
3415
  for (let i of s) {
3195
3416
  if (!i.proxyTarget) continue;
3196
- let a = await ai(t, i.pkg);
3417
+ let a = await wi(t, i.pkg);
3197
3418
  if (!a) continue;
3198
3419
  let o = r(a, "rpcGroup.generated.ts");
3199
3420
  try {
@@ -3219,14 +3440,14 @@ import {
3219
3440
  r !== t && (n.set(e, r), a = e);
3220
3441
  }
3221
3442
  if (a !== null) {
3222
- c = !0, Z.info(`rpcGroup changed (${i(t, a)}) — re-bundling the api client + reloading (descriptor edits propagate automatically; no manual restart needed)`);
3443
+ c = !0, Q.info(`rpcGroup changed (${i(t, a)}) — re-bundling the api client + reloading (descriptor edits propagate automatically; no manual restart needed)`);
3223
3444
  try {
3224
3445
  await S.rm(r(w, ".vite", "deps"), {
3225
3446
  recursive: !0,
3226
3447
  force: !0
3227
3448
  }), await e.restart(!0);
3228
3449
  } catch (e) {
3229
- c = !1, Z.error("rpcGroup re-optimize failed", {}, e);
3450
+ c = !1, Q.error("rpcGroup re-optimize failed", {}, e);
3230
3451
  }
3231
3452
  }
3232
3453
  }, u = (e) => {
@@ -3236,38 +3457,38 @@ import {
3236
3457
  };
3237
3458
  e.watcher.on("change", u), e.watcher.on("add", u);
3238
3459
  }
3239
- }, P = {};
3460
+ }, I = {};
3240
3461
  for (let e of s) {
3241
3462
  if (!e.proxyTarget) continue;
3242
- P[e.browserWsUrl] = {
3463
+ I[e.browserWsUrl] = {
3243
3464
  target: e.proxyTarget,
3244
3465
  ws: !0,
3245
3466
  changeOrigin: !0,
3246
3467
  ...e.wsPath ? {} : { rewrite: () => "/ws" }
3247
3468
  };
3248
3469
  let t = e.proxyTarget.replace(/^ws/, "http");
3249
- P[`/_voltro/api/${e.name}`] = {
3470
+ I[`/_voltro/api/${e.name}`] = {
3250
3471
  target: t,
3251
3472
  changeOrigin: !0,
3252
3473
  rewrite: (t) => t.replace(RegExp(`^/_voltro/api/${e.name}`), "")
3253
3474
  };
3254
3475
  }
3255
3476
  for (let [e, t] of Object.entries(n.proxies ?? {})) {
3256
- if (P[e]) {
3257
- Z.warn("user proxy ignored — prefix already claimed by an api ws proxy", { prefix: e });
3477
+ if (I[e]) {
3478
+ Q.warn("user proxy ignored — prefix already claimed by an api ws proxy", { prefix: e });
3258
3479
  continue;
3259
3480
  }
3260
- P[e] = {
3481
+ I[e] = {
3261
3482
  target: t.target,
3262
3483
  changeOrigin: t.changeOrigin ?? !0,
3263
3484
  ...t.rewrite === void 0 ? {} : { rewrite: (n) => n.replace(RegExp(`^${e}`), t.rewrite) }
3264
- }, Z.info(`proxy ${e} → ${t.target}`, {
3485
+ }, Q.info(`proxy ${e} → ${t.target}`, {
3265
3486
  prefix: e,
3266
3487
  target: t.target,
3267
3488
  ...t.rewrite === void 0 ? {} : { rewrite: t.rewrite }
3268
3489
  });
3269
3490
  }
3270
- let le = {
3491
+ let se = {
3271
3492
  name: "framework:inspect",
3272
3493
  configureServer(e) {
3273
3494
  let i = null, a = async () => {
@@ -3279,18 +3500,18 @@ import {
3279
3500
  pattern: i.pattern,
3280
3501
  file: i.file,
3281
3502
  dirChain: i.dirChain,
3282
- renderMode: a.renderMode ?? "static",
3503
+ renderMode: nt(a, r("src", "pages", i.file)),
3283
3504
  interactive: a.interactive ?? "full",
3284
3505
  tenantAware: a.tenantAware === !0,
3285
- revalidateMs: zn(a.revalidate),
3286
- staleWhileRevalidateMs: zn(a.staleWhileRevalidate) ?? 0,
3506
+ revalidateMs: qe(a.revalidate),
3507
+ staleWhileRevalidateMs: qe(a.staleWhileRevalidate) ?? 0,
3287
3508
  cacheInvalidatesOn: Array.isArray(a.cacheInvalidatesOn) ? a.cacheInvalidatesOn : [],
3288
3509
  hasLoader: typeof a.loader == "function",
3289
3510
  hasMeta: a.meta != null,
3290
3511
  hasGetStaticPaths: typeof a.getStaticPaths == "function"
3291
3512
  });
3292
3513
  } catch (e) {
3293
- Z.warn("inspect: failed to load page metadata", { pattern: i.pattern }, e);
3514
+ Q.warn("inspect: failed to load page metadata", { pattern: i.pattern }, e);
3294
3515
  }
3295
3516
  return i = n, n;
3296
3517
  };
@@ -3388,22 +3609,22 @@ import {
3388
3609
  for (let [t, n] of Object.entries(e.headers ?? {})) n !== void 0 && (s[String(t).toLowerCase()] = Array.isArray(n) ? n.join(", ") : String(n));
3389
3610
  let c = i.split("?")[0];
3390
3611
  if (e.method === "GET" && (c === "/_voltro/inspect/logs" || i.startsWith("/_voltro/inspect/logs?"))) {
3391
- let e = W(s.origin);
3392
- if (V()) {
3612
+ let e = K(s.origin);
3613
+ if (U()) {
3393
3614
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3394
3615
  for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
3395
3616
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
3396
3617
  return;
3397
3618
  }
3398
- let n = gn(i, en());
3619
+ let n = An(i, hn());
3399
3620
  t.statusCode = n.status, t.setHeader("content-type", n.contentType);
3400
3621
  for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
3401
3622
  t.end(n.body);
3402
3623
  return;
3403
3624
  }
3404
3625
  if (e.method === "POST" && c === "/_voltro/inspect/clientLog") {
3405
- let n = W(s.origin);
3406
- if (V()) {
3626
+ let n = K(s.origin);
3627
+ if (U()) {
3407
3628
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3408
3629
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3409
3630
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
@@ -3413,7 +3634,7 @@ import {
3413
3634
  e.setEncoding("utf-8"), e.on("data", (e) => {
3414
3635
  r += e;
3415
3636
  }), e.on("end", () => {
3416
- let e = un(r, o);
3637
+ let e = wn(r, o);
3417
3638
  t.statusCode = e.status, t.setHeader("content-type", e.contentType);
3418
3639
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3419
3640
  t.end(e.body);
@@ -3423,14 +3644,14 @@ import {
3423
3644
  return;
3424
3645
  }
3425
3646
  if (c === "/_voltro/inspect/stream") {
3426
- let n = W(s.origin);
3427
- if (V()) {
3647
+ let n = K(s.origin);
3648
+ if (U()) {
3428
3649
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3429
3650
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3430
3651
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
3431
3652
  return;
3432
3653
  }
3433
- let r = H(s);
3654
+ let r = W(s);
3434
3655
  if (!r.ok) {
3435
3656
  t.statusCode = 401, t.setHeader("content-type", "application/json");
3436
3657
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
@@ -3444,14 +3665,14 @@ import {
3444
3665
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3445
3666
  t.flushHeaders?.(), t.write("retry: 5000\n\n");
3446
3667
  let a = i.indexOf("?");
3447
- if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(qt(e));
3668
+ if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(cn(e));
3448
3669
  let c = o.subscribe((e) => {
3449
3670
  try {
3450
- t.write(qt(e));
3671
+ t.write(cn(e));
3451
3672
  } catch {}
3452
3673
  }), l = setInterval(() => {
3453
3674
  try {
3454
- t.write(Jt());
3675
+ t.write(ln());
3455
3676
  } catch {}
3456
3677
  }, 15e3), u = () => {
3457
3678
  clearInterval(l), c();
@@ -3460,11 +3681,11 @@ import {
3460
3681
  return;
3461
3682
  }
3462
3683
  try {
3463
- let o = Dt(i, {
3684
+ let o = Vt(i, {
3464
3685
  kind: "web",
3465
3686
  meta: {
3466
3687
  name: n.name ?? "(unnamed)",
3467
- voltroVersion: Ir,
3688
+ voltroVersion: ei,
3468
3689
  port: u,
3469
3690
  mode: "dev",
3470
3691
  apis: Object.entries(n.apis ?? {}).map(([e, t]) => {
@@ -3482,7 +3703,7 @@ import {
3482
3703
  size: 0,
3483
3704
  entries: []
3484
3705
  }),
3485
- env: () => bt(n.name ?? "app", { contract: se(n.env) ? n.env : void 0 })
3706
+ env: () => Pt(n.name ?? "app", { contract: oe(n.env) ? n.env : void 0 })
3486
3707
  }, s, { method: e.method ?? "GET" });
3487
3708
  if (o === null) return r();
3488
3709
  t.statusCode = o.status, t.setHeader("content-type", o.contentType);
@@ -3493,37 +3714,44 @@ import {
3493
3714
  }
3494
3715
  });
3495
3716
  }
3496
- }, ue = n.name === "voltroDashboard" ? {
3717
+ }, ce = n.name === "voltroDashboard" ? {
3497
3718
  name: "framework:dashboard-registry",
3498
3719
  configureServer(e) {
3499
3720
  e.middlewares.use(async (e, t, n) => {
3500
3721
  if (!(e.url ?? "").startsWith("/api/dashboard/registry")) return n();
3501
3722
  try {
3502
- let e = await Qn();
3723
+ let e = await fr();
3503
3724
  t.statusCode = 200, t.setHeader("content-type", "application/json; charset=utf-8"), t.end(JSON.stringify(e));
3504
3725
  } catch (e) {
3505
3726
  t.statusCode = 500, t.setHeader("content-type", "text/plain"), t.end(`registry read error: ${e.message}`);
3506
3727
  }
3507
3728
  });
3508
3729
  }
3509
- } : null, pe = ri(m), me = /* @__PURE__ */ new Set(), he = null, ge = async () => (he === null && (he = await S.readFile(r(t, ".framework", "index.html"), "utf8")), he), _e = {
3730
+ } : null, le = Si(m), fe = /* @__PURE__ */ new Set(), L = bt(), pe = St({
3731
+ limit: L,
3732
+ onColdStart: (e) => Q.debug("ssr cold-compile start", { id: e }),
3733
+ onColdEnd: (e) => Q.debug("ssr cold-compile end", { id: e })
3734
+ });
3735
+ Q.debug(`ssr cold-compile concurrency ${L}`, { concurrency: L });
3736
+ let me = null, he = async () => (me === null && (me = await S.readFile(r(t, ".framework", "index.html"), "utf8")), me), ge = {
3510
3737
  name: "framework:ssr",
3511
3738
  configureServer(e) {
3512
- e.middlewares.use(async (n, i, a) => {
3513
- if (n.method !== "GET" && n.method !== "HEAD") return a();
3514
- let o = n.url ?? "/", c = o.indexOf("?"), l = (c === -1 ? o : o.slice(0, c)) || "/";
3515
- 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();
3516
- let u = ii(l, pe);
3517
- if (!u) return a();
3518
- let d = !me.has(u.route.pattern), f = Date.now();
3519
- d && Z.info(`ssr compiling ${u.route.pattern}`, {
3520
- pattern: u.route.pattern,
3521
- pathname: l
3739
+ let n = (t) => pe.load(t, async () => await e.ssrLoadModule(t));
3740
+ e.middlewares.use(async (i, a, o) => {
3741
+ if (i.method !== "GET" && i.method !== "HEAD") return o();
3742
+ let c = i.url ?? "/", l = c.indexOf("?"), u = (l === -1 ? c : c.slice(0, l)) || "/";
3743
+ 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();
3744
+ let d = Ci(u, le);
3745
+ if (!d) return o();
3746
+ let f = !fe.has(d.route.pattern), p = Date.now();
3747
+ f && Q.info(`ssr compiling ${d.route.pattern}`, {
3748
+ pattern: d.route.pattern,
3749
+ pathname: u
3522
3750
  });
3523
- let p = {}, m = async (e, t) => {
3751
+ let m = {}, g = async (e, t) => {
3524
3752
  let n = Date.now(), r = await t();
3525
- return p[e] = (p[e] ?? 0) + (Date.now() - n), r;
3526
- }, g = async (t, n, r) => {
3753
+ return m[e] = (m[e] ?? 0) + (Date.now() - n), r;
3754
+ }, _ = async (t, n, r) => {
3527
3755
  let i = await e.moduleGraph.getModuleById(t);
3528
3756
  if (!(!i || n.has(t))) {
3529
3757
  if (n.add(t), i.id && /\.(css|sass|scss|less|stylus|pcss|postcss)(\?|$)/.test(i.id)) {
@@ -3531,158 +3759,212 @@ import {
3531
3759
  r.includes(e) || r.push(e);
3532
3760
  return;
3533
3761
  }
3534
- for (let e of i.importedModules ?? []) e.id && await g(e.id, n, r);
3762
+ for (let e of i.importedModules ?? []) e.id && await _(e.id, n, r);
3535
3763
  }
3536
3764
  };
3537
3765
  try {
3538
- let c = await m("loadPage", async () => await e.ssrLoadModule(r(t, "src", "pages", u.route.file))), _ = c.renderMode ?? "static";
3539
- if (_ !== "ssr" && _ !== "isr") return a();
3540
- let v = {};
3541
- for (let [e, t] of Object.entries(n.headers ?? {})) typeof t == "string" ? v[e] = t : Array.isArray(t) && (v[e] = t.join(", "));
3542
- let y = fi(di(s[0]), v.cookie), b = new AbortController(), x = () => b.abort();
3543
- i.once("close", x);
3544
- let S = null, C = [], w = {}, T = Qr(h, u.route.dirChain);
3766
+ let l = await g("loadPage", async () => await n(r(t, "src", "pages", d.route.file))), v = nt(l, r("src", "pages", d.route.file)), y = _i(h, d.route.dirChain), b = v === "spa" && y.some((e) => e.hasLayout);
3767
+ if (v !== "ssr" && v !== "isr" && !b) return o();
3768
+ let x = {};
3769
+ for (let [e, t] of Object.entries(i.headers ?? {})) typeof t == "string" ? x[e] = t : Array.isArray(t) && (x[e] = t.join(", "));
3770
+ let S = ji(Ai(s[0]), x.cookie), C = new AbortController(), w = () => C.abort();
3771
+ a.once("close", w);
3772
+ let T = null, E = [], ee = {};
3545
3773
  try {
3546
- ({chain: C, segmentLoaderData: w} = await m("loadChain", () => $r({
3547
- entries: T,
3548
- loadLayout: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "layout.tsx")),
3549
- loadError: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "error.tsx")),
3550
- loadPending: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "loading.tsx")),
3774
+ ({chain: E, segmentLoaderData: ee} = await g("loadChain", () => vi({
3775
+ entries: y,
3776
+ loadLayout: (e) => n(r(t, "src", "pages", e.dir, "layout.tsx")),
3777
+ loadError: (e) => n(r(t, "src", "pages", e.dir, "error.tsx")),
3778
+ loadPending: (e) => n(r(t, "src", "pages", e.dir, "loading.tsx")),
3551
3779
  ctx: {
3552
- params: u.params,
3553
- pathname: l,
3554
- signal: b.signal,
3555
- headers: v,
3556
- query: y
3780
+ params: d.params,
3781
+ pathname: u,
3782
+ signal: C.signal,
3783
+ headers: x,
3784
+ query: S
3557
3785
  }
3558
3786
  })));
3559
- let n = c.loader;
3560
- typeof n == "function" && (S = await m("loader", () => n({
3561
- params: u.params,
3562
- pathname: l,
3563
- signal: b.signal,
3564
- headers: v,
3565
- query: y
3787
+ let e = l.loader;
3788
+ typeof e == "function" && !b && (T = await g("loader", () => e({
3789
+ params: d.params,
3790
+ pathname: u,
3791
+ signal: C.signal,
3792
+ headers: x,
3793
+ query: S
3566
3794
  })));
3567
3795
  } finally {
3568
- i.off("close", x);
3796
+ a.off("close", w);
3569
3797
  }
3570
- let E = await m("loadSsrHelpers", async () => await e.ssrLoadModule("@voltro/web/ssr")), ee = {
3571
- pattern: u.route.pattern,
3572
- Component: c.default,
3573
- meta: c.meta,
3574
- loader: c.loader,
3575
- ErrorBoundary: c.ErrorBoundary,
3576
- Pending: c.Pending,
3577
- renderMode: _,
3578
- chain: C
3579
- }, D = {
3580
- cookies: E.parseCookieHeader(v.cookie),
3581
- headers: v,
3582
- url: o
3583
- }, O = c.interactive ?? "full", k = Tr({
3584
- helpers: E,
3585
- page: `src/pages/${u.route.file}`,
3586
- renderMode: _,
3587
- interactive: O,
3588
- loaderData: S,
3589
- segmentLoaderData: w,
3590
- pageLoaderRan: typeof c.loader == "function"
3591
- }), te = [];
3592
- await m("collectCss", async () => {
3798
+ let D = await g("loadSsrHelpers", async () => await n("@voltro/web/ssr")), te = {
3799
+ pattern: d.route.pattern,
3800
+ Component: l.default,
3801
+ meta: l.meta,
3802
+ loader: l.loader,
3803
+ ErrorBoundary: l.ErrorBoundary,
3804
+ Pending: l.Pending,
3805
+ renderMode: v,
3806
+ chain: E
3807
+ }, O = {
3808
+ cookies: D.parseCookieHeader(x.cookie),
3809
+ headers: x,
3810
+ url: c
3811
+ }, k = l.interactive ?? "full", A = b ? Vr({
3812
+ helpers: D,
3813
+ page: `src/pages/${d.route.file}`,
3814
+ interactive: k,
3815
+ delivery: "stream",
3816
+ renderInput: {
3817
+ descriptor: te,
3818
+ params: d.params,
3819
+ pathname: u,
3820
+ segmentLoaderData: ee,
3821
+ requestContext: O
3822
+ }
3823
+ }) : null, j = b ? null : Br({
3824
+ helpers: D,
3825
+ page: `src/pages/${d.route.file}`,
3826
+ pathname: u,
3827
+ renderMode: v,
3828
+ interactive: k,
3829
+ loaderData: T,
3830
+ segmentLoaderData: ee,
3831
+ pageLoaderRan: typeof l.loader == "function"
3832
+ }), M = [];
3833
+ await g("collectCss", async () => {
3593
3834
  let e = /* @__PURE__ */ new Set(), n = [
3594
- r(t, "src", "pages", u.route.file),
3595
- ...T.flatMap((e) => [
3835
+ r(t, "src", "pages", d.route.file),
3836
+ ...y.flatMap((e) => [
3596
3837
  ...e.hasLayout ? [r(t, "src", "pages", e.dir, "layout.tsx")] : [],
3597
3838
  ...e.hasError ? [r(t, "src", "pages", e.dir, "error.tsx")] : [],
3598
3839
  ...e.hasPending ? [r(t, "src", "pages", e.dir, "loading.tsx")] : []
3599
3840
  ]),
3600
3841
  r(t, ".framework", "main.tsx")
3601
3842
  ];
3602
- for (let t of n) await g(t, e, te);
3843
+ for (let t of n) await _(t, e, M);
3603
3844
  });
3604
- let ne = await m("readShell", ge), A = await m("transformShell", () => e.transformIndexHtml(o, ne)), re = te.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), j = (e) => [
3605
- re,
3606
- E.renderMetaToHtml(e),
3607
- `<meta name="voltro-interactive" content="${O}" />`,
3608
- ...k.hasDeferred ? [E.renderDeferredRegistryScript()] : [],
3609
- E.renderRouterStateScript(k.stateInput)
3610
- ].filter((e) => e.length > 0).join("\n "), M = D.cookies["voltro:locale"] ?? "en", ie = Date.now(), ae = {
3611
- descriptor: ee,
3612
- params: u.params,
3613
- pathname: l,
3614
- loaderData: k.loaderData,
3615
- segmentLoaderData: k.segmentLoaderData,
3616
- requestContext: D
3617
- };
3618
- if (_ === "ssr" && O === "full") Pr({
3619
- res: i,
3620
- shell: Mr({
3621
- shell: A,
3622
- inlineModuleScriptsAsync: !0
3623
- }),
3624
- htmlLang: M,
3625
- headers: {
3626
- "content-type": "text/html; charset=utf-8",
3627
- "x-voltro-rendered-by": "ssr-dev"
3628
- },
3629
- headInjection: j,
3630
- render: (e) => E.renderPageToStream({
3631
- ...ae,
3632
- ...e
3633
- }),
3634
- onShellError: (e) => {
3635
- Z.warn("ssr-dev shell render failed; falling back to SPA shell", {
3636
- pathname: l,
3637
- pattern: u.route.pattern
3638
- }, e), a();
3845
+ let ne = await g("readShell", he), N = await g("transformShell", () => e.transformIndexHtml(c, ne)), re = M.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), P = O.cookies["voltro:locale"] ?? "en", ie = Date.now();
3846
+ if (A) {
3847
+ let e = (e) => Ur({
3848
+ helpers: D,
3849
+ prepared: A,
3850
+ meta: e,
3851
+ interactive: k,
3852
+ extra: [re]
3853
+ });
3854
+ if (A.hasDeferred) Qr({
3855
+ res: a,
3856
+ shell: Xr({
3857
+ shell: N,
3858
+ inlineModuleScriptsAsync: !0
3859
+ }),
3860
+ htmlLang: P,
3861
+ headers: {
3862
+ "content-type": "text/html; charset=utf-8",
3863
+ "x-voltro-rendered-by": "spa-shell-dev"
3864
+ },
3865
+ headInjection: e,
3866
+ render: (e) => D.renderPageToStream({
3867
+ ...A.renderInput,
3868
+ ...e
3869
+ }),
3870
+ onShellError: (e) => {
3871
+ Q.warn("spa-shell-dev shell render failed; falling back to SPA shell", {
3872
+ pathname: u,
3873
+ pattern: d.route.pattern
3874
+ }, e), o();
3875
+ }
3876
+ });
3877
+ else {
3878
+ let t = Hr({
3879
+ helpers: D,
3880
+ prepared: A
3881
+ }), n = N.replace("<div id=\"root\"></div>", `<div id="root">${t.body}</div>`).replace("</head>", ` ${e(t.meta)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${P}"`);
3882
+ a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "spa-shell-dev"), a.end(n);
3883
+ }
3884
+ } else if (j) {
3885
+ let e = (e) => [
3886
+ re,
3887
+ D.renderMetaToHtml(e),
3888
+ `<meta name="voltro-interactive" content="${k}" />`,
3889
+ ...j.hasDeferred ? [D.renderDeferredRegistryScript()] : [],
3890
+ D.renderRouterStateScript(j.stateInput)
3891
+ ].filter((e) => e.length > 0).join("\n "), t = {
3892
+ descriptor: te,
3893
+ params: d.params,
3894
+ pathname: u,
3895
+ loaderData: j.loaderData,
3896
+ segmentLoaderData: j.segmentLoaderData,
3897
+ requestContext: O
3898
+ };
3899
+ if (v === "ssr" && k === "full") Qr({
3900
+ res: a,
3901
+ shell: Xr({
3902
+ shell: N,
3903
+ inlineModuleScriptsAsync: !0
3904
+ }),
3905
+ htmlLang: P,
3906
+ headers: {
3907
+ "content-type": "text/html; charset=utf-8",
3908
+ "x-voltro-rendered-by": "ssr-dev"
3909
+ },
3910
+ headInjection: e,
3911
+ render: (e) => D.renderPageToStream({
3912
+ ...t,
3913
+ ...e
3914
+ }),
3915
+ onShellError: (e) => {
3916
+ Q.warn("ssr-dev shell render failed; falling back to SPA shell", {
3917
+ pathname: u,
3918
+ pattern: d.route.pattern
3919
+ }, e), o();
3920
+ }
3921
+ });
3922
+ else {
3923
+ 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="${P}"`);
3924
+ a.statusCode = 200, a.setHeader("content-type", "text/html; charset=utf-8"), a.setHeader("x-voltro-rendered-by", "ssr-dev"), a.end(i);
3639
3925
  }
3640
- });
3641
- else {
3642
- let { html: e, meta: t } = E.renderPageToHtml(ae), n = A.replace("<div id=\"root\"></div>", `<div id="root">${e}</div>`).replace("</head>", ` ${j(t)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${M}"`);
3643
- i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "ssr-dev"), i.end(n);
3644
3926
  }
3645
- p.render = Date.now() - ie;
3646
- let N = Date.now() - f;
3647
- d ? (me.add(u.route.pattern), Z.info(`ssr compiled ${u.route.pattern} in ${N}ms`, {
3648
- pattern: u.route.pattern,
3649
- pathname: l,
3650
- elapsedMs: N,
3927
+ m.render = Date.now() - ie;
3928
+ let F = Date.now() - p;
3929
+ f ? (fe.add(d.route.pattern), Q.info(`ssr compiled ${d.route.pattern} in ${F}ms`, {
3930
+ pattern: d.route.pattern,
3931
+ pathname: u,
3932
+ elapsedMs: F,
3651
3933
  cold: !0,
3652
- phases: p
3653
- })) : N > 200 && Z.info(`ssr rendered ${l} in ${N}ms`, {
3654
- pattern: u.route.pattern,
3655
- pathname: l,
3656
- elapsedMs: N,
3934
+ phases: m
3935
+ })) : F > 200 && Q.info(`ssr rendered ${u} in ${F}ms`, {
3936
+ pattern: d.route.pattern,
3937
+ pathname: u,
3938
+ elapsedMs: F,
3657
3939
  cold: !1,
3658
- phases: p
3940
+ phases: m
3659
3941
  });
3660
3942
  } catch (e) {
3661
- if (wr(e)) {
3662
- Z.error("ssr-dev render refused", {
3663
- pathname: l,
3664
- pattern: u.route.pattern
3665
- }, e), i.statusCode = 500, i.setHeader("content-type", "text/plain; charset=utf-8"), i.end(e.message);
3943
+ if (zr(e)) {
3944
+ Q.error("ssr-dev render refused", {
3945
+ pathname: u,
3946
+ pattern: d.route.pattern
3947
+ }, e), a.statusCode = 500, a.setHeader("content-type", "text/plain; charset=utf-8"), a.end(e.message);
3666
3948
  return;
3667
3949
  }
3668
- Z.warn("ssr-dev render failed; falling back to SPA shell", {
3669
- pathname: l,
3670
- pattern: u.route.pattern
3671
- }, e), a();
3950
+ Q.warn("ssr-dev render failed; falling back to SPA shell", {
3951
+ pathname: u,
3952
+ pattern: d.route.pattern
3953
+ }, e), o();
3672
3954
  }
3673
3955
  });
3674
3956
  }
3675
- }, ve = Date.now(), ye = b.version ?? "?", F = await Lr(), be = r(t, "node_modules", "@voltro", "ui-shadcn"), I = y(r(be, "package.json")) ? be : null, xe = [], L = await (async () => {
3957
+ }, R = Date.now(), _e = b.version ?? "?", ve = await ti(), ye = r(t, "node_modules", "@voltro", "ui-shadcn"), z = y(r(ye, "package.json")) ? ye : null, be = [], xe = await (async () => {
3676
3958
  let e = [];
3677
3959
  for (let n of s) {
3678
3960
  if (!n.proxyTarget) continue;
3679
- let i = await ai(t, n.pkg);
3961
+ let i = await wi(t, n.pkg);
3680
3962
  if (i) try {
3681
3963
  e.push(await S.readFile(r(i, "rpcGroup.generated.ts"), "utf8"));
3682
3964
  } catch {}
3683
3965
  }
3684
3966
  if (e.length === 0) return !1;
3685
- let n = de("sha1").update(e.join("\0")).digest("hex"), i = r(w, ".voltro-rpcgroup-optimize"), a = "";
3967
+ let n = ue("sha1").update(e.join("\0")).digest("hex"), i = r(w, ".voltro-rpcgroup-optimize"), a = "";
3686
3968
  try {
3687
3969
  a = (await S.readFile(i, "utf8")).trim();
3688
3970
  } catch {}
@@ -3692,83 +3974,83 @@ import {
3692
3974
  } catch {}
3693
3975
  return !0;
3694
3976
  })();
3695
- L && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3977
+ xe && Q.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3696
3978
  root: w,
3697
3979
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3698
3980
  ssr: { noExternal: ["react-intl"] },
3699
3981
  resolve: {
3700
3982
  dedupe: ["react", "react-dom"],
3701
3983
  alias: [
3702
- ...F ? [{
3984
+ ...ve ? [{
3703
3985
  find: "@voltro/devtools/styles.css",
3704
- replacement: r(F, "src/styles.css")
3986
+ replacement: r(ve, "src/styles.css")
3705
3987
  }, {
3706
3988
  find: "@voltro/devtools",
3707
- replacement: r(F, "src/index.ts")
3989
+ replacement: r(ve, "src/index.ts")
3708
3990
  }] : [],
3709
- ...I ? [
3991
+ ...z ? [
3710
3992
  {
3711
3993
  find: "@voltro/ui-shadcn/tokens.css",
3712
- replacement: r(I, "src/tokens.css")
3994
+ replacement: r(z, "src/tokens.css")
3713
3995
  },
3714
3996
  {
3715
3997
  find: "@voltro/ui-shadcn/cn",
3716
- replacement: r(I, "src/cn.ts")
3998
+ replacement: r(z, "src/cn.ts")
3717
3999
  },
3718
4000
  {
3719
4001
  find: "@voltro/ui-shadcn/brand",
3720
- replacement: r(I, "src/brand/voltroLogo.tsx")
4002
+ replacement: r(z, "src/brand/voltroLogo.tsx")
3721
4003
  },
3722
4004
  {
3723
4005
  find: "@voltro/ui-shadcn",
3724
- replacement: r(I, "src/index.ts")
4006
+ replacement: r(z, "src/index.ts")
3725
4007
  }
3726
4008
  ] : [],
3727
- ...We(t)
4009
+ ...Ue(t)
3728
4010
  ]
3729
4011
  },
3730
4012
  optimizeDeps: {
3731
- include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...xe],
3732
- force: L
4013
+ include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...be],
4014
+ force: xe
3733
4015
  },
3734
- customLogger: ct(),
4016
+ customLogger: yt(),
3735
4017
  plugins: [
3736
- Ln(r(t, "src", "pages")),
4018
+ $n(r(t, "src", "pages")),
3737
4019
  x(),
3738
4020
  C(),
3739
4021
  ee,
3740
- ne,
4022
+ A,
4023
+ P,
4024
+ F,
3741
4025
  ae,
3742
- oe,
3743
- ce,
3744
- le,
3745
- _e,
3746
- ...ue ? [ue] : []
4026
+ se,
4027
+ ge,
4028
+ ...ce ? [ce] : []
3747
4029
  ],
3748
4030
  server: {
3749
4031
  port: u,
3750
4032
  strictPort: !0,
3751
4033
  host: !0,
3752
4034
  allowedHosts: n.allowedHosts === !0 || [...n.allowedHosts ?? []],
3753
- proxy: P,
3754
- fs: { allow: [t, ...Ur(t)] }
4035
+ proxy: I,
4036
+ fs: { allow: [t, ...si(t)] }
3755
4037
  },
3756
4038
  appType: "spa",
3757
4039
  cacheDir: r(w, ".vite"),
3758
4040
  publicDir: r(t, "public")
3759
- })).listen(), Fr.info(`v${ye} ready in ${Date.now() - ve}ms`, {
3760
- version: ye,
3761
- bootMs: Date.now() - ve
3762
- }), Z.info(`listening on http://localhost:${u}`, {
4041
+ })).listen(), $r.info(`v${_e} ready in ${Date.now() - R}ms`, {
4042
+ version: _e,
4043
+ bootMs: Date.now() - R
4044
+ }), Q.info(`listening on http://localhost:${u}`, {
3763
4045
  port: u,
3764
4046
  app: n.name ?? "(unnamed)"
3765
4047
  });
3766
- for (let e of s) e.proxyTarget && (Z.info(`proxy /ws/${e.name} → ${e.proxyTarget}`, {
4048
+ for (let e of s) e.proxyTarget && (Q.info(`proxy /ws/${e.name} → ${e.proxyTarget}`, {
3767
4049
  api: e.name,
3768
4050
  target: e.proxyTarget
3769
- }), Z.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
4051
+ }), Q.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
3770
4052
  try {
3771
- await $n({
4053
+ await pr({
3772
4054
  id: f,
3773
4055
  name: d,
3774
4056
  kind: "web",
@@ -3777,13 +4059,13 @@ import {
3777
4059
  status: "live",
3778
4060
  logFile: p.path
3779
4061
  });
3780
- let e = pr(t);
4062
+ let e = Dr(t);
3781
4063
  if (e) {
3782
- let t = await Sr({ dashboardAppPath: e });
3783
- 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 });
4064
+ let t = await Lr({ dashboardAppPath: e });
4065
+ t.status === "launched" ? Q.info(`dashboard launched at http://localhost:${t.port}`, { port: t.port }) : t.status === "already-running" && Q.debug(`dashboard already running on :${t.port}`, { port: t.port });
3784
4066
  }
3785
4067
  setInterval(() => {
3786
- $n({
4068
+ pr({
3787
4069
  id: f,
3788
4070
  name: d,
3789
4071
  kind: "web",
@@ -3794,50 +4076,50 @@ import {
3794
4076
  }).catch(() => {});
3795
4077
  }, 1e4).unref();
3796
4078
  let n = () => {
3797
- er(f), p.dispose();
4079
+ mr(f), p.dispose();
3798
4080
  };
3799
4081
  process.on("SIGINT", n), process.on("SIGTERM", n);
3800
4082
  } catch (e) {
3801
- Z.warn("runtime-registry write failed", {}, e);
4083
+ Q.warn("runtime-registry write failed", {}, e);
3802
4084
  }
3803
4085
  return _({
3804
4086
  app: n.name ?? "unnamed",
3805
4087
  kind: "web",
3806
4088
  url: `http://localhost:${u}`,
3807
- bootMs: Date.now() - ve
4089
+ bootMs: Date.now() - R
3808
4090
  }), new Promise(() => {});
3809
- }, vi = async (e) => {
4091
+ }, Li = async (e) => {
3810
4092
  process.env.NODE_ENV || (process.env.NODE_ENV = "production");
3811
- let t = await gi(e);
4093
+ let t = await Fi(e);
3812
4094
  if (!t) return {
3813
4095
  ran: !1,
3814
4096
  exitCode: 0
3815
4097
  };
3816
- let n = Date.now(), i = Z.child("serve");
4098
+ let n = Date.now(), i = Q.child("serve");
3817
4099
  i.info("booting voltro serve (preview)", { app: t.name ?? "(unnamed)" });
3818
- let a = await ui(e, t);
4100
+ let a = await ki(e, t);
3819
4101
  for (let e of a) i.info("api wired", {
3820
4102
  name: e.name,
3821
4103
  pkg: e.pkg
3822
4104
  });
3823
- await pi(e, t, a);
4105
+ await Mi(e, t, a);
3824
4106
  {
3825
- let { pages: t } = await $(r(e, "src", "pages"));
3826
- await vt({
4107
+ let { pages: t } = await gi(r(e, "src", "pages"));
4108
+ await Mt({
3827
4109
  appRoot: e,
3828
4110
  pages: t
3829
4111
  });
3830
4112
  }
3831
- let o = t.port ?? 5173, s = await Ke("vite", () => import("vite")), c = (await import("@vitejs/plugin-react")).default, l = r(e, ".framework");
3832
- Z.info("running production build"), await s.build({
4113
+ let o = t.port ?? 5173, s = await Ge("vite", () => import("vite")), c = (await import("@vitejs/plugin-react")).default, l = r(e, ".framework");
4114
+ Q.info("running production build"), await s.build({
3833
4115
  root: l,
3834
4116
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3835
4117
  plugins: [c()],
3836
- customLogger: ct(),
4118
+ customLogger: yt(),
3837
4119
  resolve: { dedupe: ["react", "react-dom"] },
3838
4120
  build: {
3839
4121
  outDir: "dist",
3840
- rollupOptions: { output: { manualChunks: Kr } }
4122
+ rollupOptions: { output: { manualChunks: ui } }
3841
4123
  },
3842
4124
  publicDir: r(e, "public")
3843
4125
  });
@@ -3857,14 +4139,14 @@ import {
3857
4139
  extras: f,
3858
4140
  bootMs: Date.now() - n
3859
4141
  }), new Promise(() => {});
3860
- }, yi = 5e3, bi = 6e4, xi = (e, t) => {
4142
+ }, Ri = 5e3, zi = 6e4, Bi = (e, t) => {
3861
4143
  if (e.length === 0) return 0;
3862
4144
  if (e.length === 1) return e[0];
3863
4145
  let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
3864
4146
  if (r === i) return e[r];
3865
4147
  let a = n - r;
3866
4148
  return e[r] * (1 - a) + e[i] * a;
3867
- }, Si = (e) => {
4149
+ }, Vi = (e) => {
3868
4150
  if (e.length === 0) return {
3869
4151
  p50: 0,
3870
4152
  p95: 0,
@@ -3876,18 +4158,18 @@ import {
3876
4158
  let t = e.slice().sort((e, t) => e - t), n = 0;
3877
4159
  for (let e of t) n += e;
3878
4160
  return {
3879
- p50: xi(t, .5),
3880
- p95: xi(t, .95),
3881
- p99: xi(t, .99),
4161
+ p50: Bi(t, .5),
4162
+ p95: Bi(t, .95),
4163
+ p99: Bi(t, .99),
3882
4164
  mean: n / t.length,
3883
4165
  min: t[0],
3884
4166
  max: t[t.length - 1]
3885
4167
  };
3886
- }, Ci = (e = {}) => {
3887
- let t = e.maxSamples ?? yi, n = e.defaultWindowMs ?? bi, r = [];
4168
+ }, Hi = (e = {}) => {
4169
+ let t = e.maxSamples ?? Ri, n = e.defaultWindowMs ?? zi, r = [];
3888
4170
  return {
3889
4171
  record(e) {
3890
- ne(e), r.push({
4172
+ A(e), r.push({
3891
4173
  ...e,
3892
4174
  ts: Date.now()
3893
4175
  }), r.length > t && r.shift();
@@ -3913,7 +4195,7 @@ import {
3913
4195
  tag: e.tag,
3914
4196
  count: e.samples.length,
3915
4197
  errorCount: n,
3916
- latencyMs: Si(t)
4198
+ latencyMs: Vi(t)
3917
4199
  });
3918
4200
  }
3919
4201
  return c.sort((e, t) => t.count - e.count), {
@@ -3926,4 +4208,4 @@ import {
3926
4208
  };
3927
4209
  };
3928
4210
  //#endregion
3929
- export { Ot as $, Hn as A, nn as B, lr as C, Ve as Ct, $n as D, er as E, I as Et, Cn as F, B as G, qt as H, xn as I, It as J, Et as K, gn as L, zn as M, En as N, Bn as O, wn as P, At as Q, fn as R, cr as S, We as St, Qn as T, be as Tt, Kt as U, en as V, Jt as W, jt as X, Ut as Y, Wt as Z, mr as _, vt as _t, Qr as a, Vt as at, pr as b, Xe as bt, _i as c, Rt as ct, $ as d, Pt as dt, Mt as et, pi as f, W as ft, Tr as g, xt as gt, wr as h, bt as ht, $r as i, Ht as it, Rn as j, Vn as k, vi as l, Lt as lt, Pr as m, St as mt, di as n, Ft as nt, gi as o, zt as ot, Mr as p, V as pt, H as q, fi as r, kt as rt, ui as s, Bt as st, Ci as t, Dt as tt, Kr as u, Nt as ut, fr as v, $e as vt, tr as w, He as wt, sr as x, Ke as xt, Sr as y, Ze as yt, un as z };
4211
+ export { Kt as $, mr as A, Ke as At, hn as B, Lr as C, rt as Ct, Cr as D, Je as Dt, Sr as E, nt as Et, Fn as F, Ve as Ft, Bt as G, sn as H, An as I, ve as It, rn as J, W as K, En as L, ye as Lt, Bn as M, Ge as Mt, Rn as N, Ue as Nt, hr as O, Ye as Ot, Ln as P, Be as Pt, Ht as Q, wn as R, Er as S, Ze as St, xr as T, et as Tt, ln as U, cn as V, H as W, an as X, Gt as Y, Wt as Z, Br as _, St as _t, vi as a, $t as at, Ur as b, ct as bt, ki as c, Zt as ct, ui as d, K as dt, Vt as et, gi as f, U as ft, zr as g, Mt as gt, Qr as h, Ft as ht, ji as i, tn as it, pr as j, qe as jt, fr as k, Xe as kt, Ii as l, qt as lt, Xr as m, Pt as mt, di as n, Ut as nt, _i as o, en as ot, Mi as p, It as pt, Xt as q, Ai as r, nn as rt, Fi as s, Qt as st, Hi as t, Yt as tt, Li as u, Jt as ut, Vr as v, bt as vt, Dr as w, Qe as wt, Or as x, st as xt, Hr as y, ut as yt, _n as z };