@voltro/cli 0.13.0 → 0.15.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.
- package/CHANGELOG.md +412 -0
- package/dist/{apiBuild-B6_ehbem.js → apiBuild-CHItlwPO.js} +2 -2
- package/dist/apiBuild-D8juhYsS.js +2 -0
- package/dist/bin.js +3 -3
- package/dist/{commands-DYOuGlEC.js → commands-CPQuQRXh.js} +3967 -2831
- package/dist/{dbCommand-DIOJQwsq.js → dbCommand-B8F29zV0.js} +2 -1
- package/dist/dbCommand-Dt7BtdMd.js +2 -0
- package/dist/{dev-xdijqojc.js → dev-BHLM3RPX.js} +1 -1
- package/dist/{dev-Fb9BmavX.js → dev-C2lCUhYI.js} +1478 -1347
- package/dist/fileConventions-Cu0tM-Bl.js +29 -0
- package/dist/{frameworkTableAssembly-CYlrafoK.js → frameworkTableAssembly-BA2bAmYN.js} +164 -163
- package/dist/frameworkTableAssembly-D1zJSgOU.js +2 -0
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-DOiiII34.js → inspectMetrics-CYDSO3za.js} +955 -945
- package/dist/{serveCommand-CqYxzBZR.js → serveCommand-DBzQcCuv.js} +410 -396
- package/dist/serveEntry.js +2 -2
- package/dist/{start-CjG_0xhR.js → start-BtgatJN3.js} +246 -246
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.core.md +77 -3
- package/templates/AGENTS.md +78 -4
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/_manifest.json +2 -2
- package/templates/agent-docs/authentication.md +34 -2
- package/templates/agent-docs/cli.md +116 -2
- package/templates/agent-docs/data.md +195 -3
- package/templates/agent-docs/database/hosting.md +2 -2
- package/templates/agent-docs/database/migrations.md +77 -3
- package/templates/agent-docs/database/overview.md +11 -0
- package/templates/agent-docs/database/seedsdialects.md +53 -1
- package/templates/agent-docs/internationalization.md +3 -3
- package/templates/agent-docs/introduction.md +133 -2
- package/templates/agent-docs/plugins.md +2 -1
- package/templates/agent-docs/reference.md +4 -4
- package/templates/agent-docs/routing.md +48 -43
- package/templates/agent-docs/schema-driven-ui.md +14 -3
- package/templates/agent-docs/templates/apibackends.md +1 -8
- package/templates/agent-docs/templates/appshells.md +24 -24
- package/templates/agent-docs/testing.md +16 -1
- package/templates/agent-docs/whats-new.md +247 -39
- package/templates/apps/api-ai/database/schema.ts +0 -2
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/database/schema.ts +0 -3
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/database/schema.ts +0 -1
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/database/schema.ts +0 -3
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/database/schema.ts +0 -3
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/database/schema.ts +0 -3
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/database/authors.entity.ts +0 -2
- package/templates/apps/api-data-advanced/database/books.entity.ts +0 -1
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/database/schema.ts +0 -3
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/database/schema.ts +0 -1
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/database/schema.ts +0 -1
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/database/schema.ts +0 -3
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/database/schema.ts +0 -2
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/database/schema.ts +0 -1
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/database/schema.ts +0 -1
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/database/schema.ts +0 -2
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/database/schema.ts +0 -3
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/database/schema.ts +0 -1
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-search/database/schema.ts +0 -1
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/database/schema.ts +0 -1
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/database/schema.ts +0 -1
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/changelog/src/pages/[locale]/{[slug].tsx → [slug].page.tsx} +2 -2
- package/templates/apps/changelog/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/changelog/src/pages/[locale]/mirrors.test.tsx +2 -2
- package/templates/apps/changelog/src/pages/{[slug].test.tsx → [slug].page.test.tsx} +1 -1
- package/templates/apps/changelog/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-admin/src/pages/(marketing)/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-admin/src/pages/(marketing)/{login.test.tsx → login.page.test.tsx} +1 -1
- package/templates/apps/frontend-admin/src/pages/admin/entity.test.tsx +1 -1
- package/templates/apps/frontend-admin/src/pages/admin/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-app/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-app/src/pages/{schema-ui.test.tsx → schema-ui.page.test.tsx} +1 -1
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-blank/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-contact/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/frontend-contact/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-dashboard/src/pages/(marketing)/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-dashboard/src/pages/(marketing)/{login.test.tsx → login.page.test.tsx} +1 -1
- package/templates/apps/frontend-dashboard/src/pages/dashboard/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-dashboard/src/pages/dashboard/{settings.test.tsx → settings.page.test.tsx} +1 -1
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-docs/src/pages/[locale]/docs/{[...slug].tsx → [...slug].page.tsx} +3 -3
- package/templates/apps/frontend-docs/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/frontend-docs/src/pages/[locale]/mirrors.test.tsx +2 -2
- package/templates/apps/frontend-docs/src/pages/docs/{[...slug].test.tsx → [...slug].page.test.tsx} +1 -1
- package/templates/apps/frontend-docs/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-i18n/src/pages/[locale]/{about.tsx → about.page.tsx} +2 -2
- package/templates/apps/frontend-i18n/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/frontend-i18n/src/pages/[locale]/mirrors.test.tsx +2 -2
- package/templates/apps/frontend-i18n/src/pages/{about.test.tsx → about.page.test.tsx} +1 -1
- package/templates/apps/frontend-i18n/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-landing/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/frontend-landing/src/pages/[locale]/mirrors.test.tsx +1 -1
- package/templates/apps/frontend-landing/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-spa/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr/src/pages/{feed-swr.test.tsx → feed-swr.page.test.tsx} +1 -1
- package/templates/apps/frontend-ssr/src/pages/{feed.test.tsx → feed.page.test.tsx} +1 -1
- package/templates/apps/frontend-ssr/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-ssr-api/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/templates/apps/frontend-static-blog/src/pages/[locale]/blog/{[slug].tsx → [slug].page.tsx} +2 -2
- package/templates/apps/frontend-static-blog/src/pages/[locale]/{index.tsx → index.page.tsx} +2 -2
- package/templates/apps/frontend-static-blog/src/pages/[locale]/mirrors.test.tsx +2 -2
- package/templates/apps/frontend-static-blog/src/pages/blog/{[slug].test.tsx → [slug].page.test.tsx} +1 -1
- package/templates/apps/frontend-static-blog/src/pages/{index.test.tsx → index.page.test.tsx} +1 -1
- package/dist/apiBuild-Bzpb383i.js +0 -2
- package/dist/dbCommand-ADD4mrTI.js +0 -2
- package/dist/frameworkTableAssembly-XvKO7wQt.js +0 -2
- /package/templates/apps/changelog/src/pages/{[slug].tsx → [slug].page.tsx} +0 -0
- /package/templates/apps/changelog/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-admin/src/pages/(marketing)/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-admin/src/pages/(marketing)/{login.tsx → login.page.tsx} +0 -0
- /package/templates/apps/frontend-admin/src/pages/admin/{[entity].tsx → [entity].page.tsx} +0 -0
- /package/templates/apps/frontend-admin/src/pages/admin/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-app/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-app/src/pages/{schema-ui.tsx → schema-ui.page.tsx} +0 -0
- /package/templates/apps/frontend-blank/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-contact/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-dashboard/src/pages/(marketing)/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-dashboard/src/pages/(marketing)/{login.tsx → login.page.tsx} +0 -0
- /package/templates/apps/frontend-dashboard/src/pages/dashboard/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-dashboard/src/pages/dashboard/{settings.tsx → settings.page.tsx} +0 -0
- /package/templates/apps/frontend-docs/src/pages/docs/{[...slug].tsx → [...slug].page.tsx} +0 -0
- /package/templates/apps/frontend-docs/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-i18n/src/pages/{about.tsx → about.page.tsx} +0 -0
- /package/templates/apps/frontend-i18n/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-landing/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-spa/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-ssr/src/pages/{feed-swr.tsx → feed-swr.page.tsx} +0 -0
- /package/templates/apps/frontend-ssr/src/pages/{feed.tsx → feed.page.tsx} +0 -0
- /package/templates/apps/frontend-ssr/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-ssr-api/src/pages/{index.tsx → index.page.tsx} +0 -0
- /package/templates/apps/frontend-static-blog/src/pages/blog/{[slug].tsx → [slug].page.tsx} +0 -0
- /package/templates/apps/frontend-static-blog/src/pages/{index.tsx → index.page.tsx} +0 -0
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
1
|
+
import { d as e, u as t, x as n } from "./fileConventions-Cu0tM-Bl.js";
|
|
2
|
+
import { D as r, E as i, T as a, a as o, p as s, w as c } from "./inspect-Dwx0_tUj.js";
|
|
3
|
+
import { basename as l, dirname as u, isAbsolute as d, join as f, relative as p, resolve as m } from "node:path";
|
|
4
|
+
import { fileURLToPath as h, pathToFileURL as g } from "node:url";
|
|
5
|
+
import { FileSystem as _ } from "@effect/platform";
|
|
6
|
+
import { NodeContext as v, NodeRuntime as y } from "@effect/platform-node";
|
|
7
|
+
import { Cause as b, Effect as x, Layer as S } from "effect";
|
|
8
|
+
import { LoggerLayer as C, addSink as w, createLogger as T, printReadyBlock as E } from "@voltro/logger";
|
|
9
|
+
import { closeSync as D, existsSync as O, mkdirSync as k, openSync as A, promises as j, readFileSync as M, readdirSync as N, statSync as P, unlinkSync as ee, unwatchFile as F, watchFile as te, writeSync as I } from "node:fs";
|
|
10
|
+
import { currentTraceContext as L, recordSample as R, resolveSecret as ne } from "@voltro/runtime";
|
|
11
|
+
import { createRequire as re } from "node:module";
|
|
12
|
+
import { homedir as ie } from "node:os";
|
|
13
|
+
import { FRAMEWORK_ENV_CATALOG as ae, appEnvEntries as oe, checkEnvNaming as se, formatEnvErrors as ce, installEnvSnapshot as z, isEnvContract as le, pluginEnvEntries as ue, renderDotEnvExample as de, resolveEnv as fe } from "@voltro/env";
|
|
14
|
+
import { __installPublicEnv as pe } from "@voltro/env/public";
|
|
15
|
+
import { mkdir as B, readFile as me, writeFile as V } from "node:fs/promises";
|
|
16
|
+
import { createHash as he } from "node:crypto";
|
|
17
|
+
import { spawn as ge } from "node:child_process";
|
|
18
|
+
import { createConnection as _e } from "node:net";
|
|
19
|
+
import { PassThrough as ve } from "node:stream";
|
|
19
20
|
//#region src/cliRuntime.ts
|
|
20
|
-
var
|
|
21
|
+
var ye = [
|
|
21
22
|
"severity",
|
|
22
23
|
"code",
|
|
23
24
|
"detail",
|
|
@@ -34,14 +35,14 @@ var _e = [
|
|
|
34
35
|
"file",
|
|
35
36
|
"line",
|
|
36
37
|
"routine"
|
|
37
|
-
],
|
|
38
|
+
], H = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
|
|
38
39
|
if (t > 10 || typeof e != "object" || !e || n.has(e)) return null;
|
|
39
40
|
n.add(e);
|
|
40
41
|
let r = e, i = r.message;
|
|
41
42
|
if (typeof i == "string" && i.length > 0 && i !== "Failed to execute statement") {
|
|
42
43
|
let e = { message: i };
|
|
43
44
|
typeof r.stack == "string" && (e.stack = r.stack);
|
|
44
|
-
for (let t of
|
|
45
|
+
for (let t of ye) r[t] !== void 0 && (e[t] = r[t]);
|
|
45
46
|
return e;
|
|
46
47
|
}
|
|
47
48
|
for (let e of [
|
|
@@ -54,24 +55,24 @@ var _e = [
|
|
|
54
55
|
]) {
|
|
55
56
|
let i = r[e];
|
|
56
57
|
if (i !== void 0) {
|
|
57
|
-
let e =
|
|
58
|
+
let e = H(i, t + 1, n);
|
|
58
59
|
if (e) return e;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
if (Array.isArray(r.failures)) for (let e of r.failures) {
|
|
62
|
-
let r =
|
|
63
|
+
let r = H(e, t + 1, n);
|
|
63
64
|
if (r) return r;
|
|
64
65
|
}
|
|
65
66
|
return null;
|
|
66
|
-
},
|
|
67
|
+
}, U = (e = {}) => S.merge(v.layer, C({
|
|
67
68
|
...e.scope ? { defaultScope: e.scope } : {},
|
|
68
69
|
...e.logger
|
|
69
|
-
})),
|
|
70
|
-
let n = e.pipe(
|
|
71
|
-
return await
|
|
72
|
-
onSuccess: (e) =>
|
|
70
|
+
})), be = async (e, t = {}) => {
|
|
71
|
+
let n = e.pipe(x.provide(U(t)));
|
|
72
|
+
return await x.runPromise(x.matchCauseEffect(n, {
|
|
73
|
+
onSuccess: (e) => x.succeed(e),
|
|
73
74
|
onFailure: (e) => {
|
|
74
|
-
let t = [...
|
|
75
|
+
let t = [...b.defects(e)];
|
|
75
76
|
if (process.env.VOLTRO_CAUSE_DEBUG === "1") for (let [e, n] of t.entries()) {
|
|
76
77
|
let t = Object.getOwnPropertyNames(n);
|
|
77
78
|
process.stderr.write(`[VOLTRO_CAUSE_DEBUG] defect[${e}] ctor=${n?.constructor?.name} props=${JSON.stringify(t)}\n`);
|
|
@@ -83,7 +84,7 @@ var _e = [
|
|
|
83
84
|
}
|
|
84
85
|
let n = null;
|
|
85
86
|
for (let e of t) {
|
|
86
|
-
let t =
|
|
87
|
+
let t = H(e);
|
|
87
88
|
if (t) {
|
|
88
89
|
n = t;
|
|
89
90
|
break;
|
|
@@ -98,55 +99,55 @@ var _e = [
|
|
|
98
99
|
...n.column ? { pgColumn: n.column } : {},
|
|
99
100
|
...n.constraint ? { pgConstraint: n.constraint } : {},
|
|
100
101
|
...n.routine ? { pgRoutine: n.routine } : {},
|
|
101
|
-
causePretty:
|
|
102
|
-
} : { causePretty:
|
|
103
|
-
return
|
|
102
|
+
causePretty: b.pretty(e)
|
|
103
|
+
} : { causePretty: b.pretty(e) };
|
|
104
|
+
return x.zipRight(x.logError("cli command failed", r), x.succeed(1));
|
|
104
105
|
}
|
|
105
|
-
}).pipe(
|
|
106
|
-
},
|
|
107
|
-
let n = e.pipe(
|
|
108
|
-
|
|
109
|
-
}, xe =
|
|
106
|
+
}).pipe(x.provide(C(t.logger ?? {}))));
|
|
107
|
+
}, W = (e, t = {}) => {
|
|
108
|
+
let n = e.pipe(x.provide(U(t)));
|
|
109
|
+
y.runMain(n, { disableErrorReporting: !1 });
|
|
110
|
+
}, xe = u(h(import.meta.url)), G = [m(xe, "..", "templates"), m(xe, "..", "..", "templates")], Se = (e) => ({
|
|
110
111
|
_tag: "TemplateNotFoundError",
|
|
111
112
|
searched: e
|
|
112
|
-
}),
|
|
113
|
+
}), Ce = ["AGENTS.md", "CLAUDE.md"], we = "voltro:agents-md:keep", Te = 2048, Ee = "<!-- VOLTRO:INDEX -->", K = (e, t) => e.exists(t).pipe(x.orElseSucceed(() => !1)), q = (e, t) => e.readFileString(t).pipe(x.orElseSucceed(() => "")), De = (e, t) => e.readFileString(t).pipe(x.map((e) => {
|
|
113
114
|
try {
|
|
114
115
|
return JSON.parse(e).workspaces !== void 0;
|
|
115
116
|
} catch {
|
|
116
117
|
return !1;
|
|
117
118
|
}
|
|
118
|
-
}),
|
|
119
|
-
let t = yield*
|
|
119
|
+
}), x.orElseSucceed(() => !1)), Oe = (e) => x.gen(function* () {
|
|
120
|
+
let t = yield* _.FileSystem, n = m(e);
|
|
120
121
|
for (;;) {
|
|
121
|
-
if ((yield*
|
|
122
|
-
let r =
|
|
123
|
-
if (r === n) return
|
|
122
|
+
if ((yield* K(t, f(n, ".git"))) || (yield* K(t, f(n, "pnpm-workspace.yaml"))) || (yield* De(t, f(n, "package.json")))) return n;
|
|
123
|
+
let r = u(n);
|
|
124
|
+
if (r === n) return m(e);
|
|
124
125
|
n = r;
|
|
125
126
|
}
|
|
126
|
-
}),
|
|
127
|
-
yield* e.makeDirectory(n, { recursive: !0 }).pipe(
|
|
128
|
-
let r = yield* e.readDirectory(t).pipe(
|
|
127
|
+
}), ke = (e, t, n) => x.gen(function* () {
|
|
128
|
+
yield* e.makeDirectory(n, { recursive: !0 }).pipe(x.orElseSucceed(() => void 0));
|
|
129
|
+
let r = yield* e.readDirectory(t).pipe(x.orElseSucceed(() => []));
|
|
129
130
|
for (let i of r) {
|
|
130
|
-
let r =
|
|
131
|
-
(yield* e.stat(r).pipe(
|
|
132
|
-
}
|
|
133
|
-
}),
|
|
134
|
-
let n =
|
|
135
|
-
if (!(yield*
|
|
136
|
-
let r = (yield*
|
|
137
|
-
return !r || r.type && r.type !== "api" ? r?.type === "web" ? [] : null : (r.plugins ?? []).map(
|
|
138
|
-
}),
|
|
139
|
-
let n = [], r = [], i =
|
|
140
|
-
if (!(yield*
|
|
131
|
+
let r = f(t, i), a = f(n, i);
|
|
132
|
+
(yield* e.stat(r).pipe(x.orElseSucceed(() => null)))?.type === "Directory" ? yield* ke(e, r, a) : yield* e.copyFile(r, a).pipe(x.orElseSucceed(() => void 0));
|
|
133
|
+
}
|
|
134
|
+
}), Ae = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, je = (e, t) => x.gen(function* () {
|
|
135
|
+
let n = f(t, "app.config.ts");
|
|
136
|
+
if (!(yield* K(e, n))) return null;
|
|
137
|
+
let r = (yield* x.tryPromise(() => import(g(n).href)).pipe(x.orElseSucceed(() => null)))?.default;
|
|
138
|
+
return !r || r.type && r.type !== "api" ? r?.type === "web" ? [] : null : (r.plugins ?? []).map(Ae).filter((e) => e !== null);
|
|
139
|
+
}), Me = (e, t) => x.gen(function* () {
|
|
140
|
+
let n = [], r = [], i = f(t, "apps");
|
|
141
|
+
if (!(yield* K(e, i))) return {
|
|
141
142
|
apis: n,
|
|
142
143
|
webs: r
|
|
143
144
|
};
|
|
144
|
-
for (let t of yield* e.readDirectory(i).pipe(
|
|
145
|
-
let a =
|
|
146
|
-
if ((yield* e.stat(a).pipe(
|
|
147
|
-
let i =
|
|
148
|
-
if (!(yield*
|
|
149
|
-
let s = yield*
|
|
145
|
+
for (let t of yield* e.readDirectory(i).pipe(x.orElseSucceed(() => []))) {
|
|
146
|
+
let a = f(i, t);
|
|
147
|
+
if ((yield* e.stat(a).pipe(x.orElseSucceed(() => null)))?.type === "Directory") for (let t of yield* e.readDirectory(a).pipe(x.orElseSucceed(() => []))) {
|
|
148
|
+
let i = f(a, t), o = f(i, "app.config.ts");
|
|
149
|
+
if (!(yield* K(e, o))) continue;
|
|
150
|
+
let s = yield* q(e, o);
|
|
150
151
|
/type:\s*['"]web['"]/.test(s) ? r.push(i) : n.push(i);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
@@ -154,7 +155,7 @@ var _e = [
|
|
|
154
155
|
apis: n,
|
|
155
156
|
webs: r
|
|
156
157
|
};
|
|
157
|
-
}),
|
|
158
|
+
}), Ne = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Pe = (e, t, n) => {
|
|
158
159
|
let r = [
|
|
159
160
|
"<!-- voltro agent-docs index — regenerated at seed time -->",
|
|
160
161
|
"## Deep reference (read on demand)",
|
|
@@ -166,17 +167,17 @@ var _e = [
|
|
|
166
167
|
"",
|
|
167
168
|
"| Topic | Open | Summary |",
|
|
168
169
|
"|---|---|---|",
|
|
169
|
-
...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${
|
|
170
|
+
...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Ne(e.description)} |`),
|
|
170
171
|
""
|
|
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\` | ${
|
|
172
|
+
], 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) => {
|
|
172
173
|
let t = i.get(e);
|
|
173
|
-
return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${
|
|
174
|
+
return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Ne(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
|
|
174
175
|
});
|
|
175
176
|
return r.push(`### Plugins${t === null ? "" : " (installed)"}`, "", "| Plugin | Open | Summary |", "|---|---|---|"), r.push(a.length ? a.join("\n") : "| _(none installed)_ | | |", ""), r.join("\n");
|
|
176
|
-
},
|
|
177
|
+
}, Fe = (e, t, n) => {
|
|
177
178
|
let r = t.templates?.[e] ?? t.templates?.[e.replace(/^frontend-/, "")];
|
|
178
179
|
return `\nScaffolded from the \`${e}\` template — see \`${r ? `${n}${r}` : `${n}agent-docs/templates/overview.md`}\`.\n`;
|
|
179
|
-
},
|
|
180
|
+
}, Ie = {
|
|
180
181
|
api: (e, t, n = "") => `# api — agent notes
|
|
181
182
|
|
|
182
183
|
You are in a Voltro **api** app. Server primitives live here: \`queries/\`,
|
|
@@ -216,7 +217,7 @@ You are in a Voltro **web** app. File-based routing under \`src/pages/**\`.
|
|
|
216
217
|
Deep reference (paths from the repo root): \`${e}agent-docs/routing.md\`,
|
|
217
218
|
\`${e}agent-docs/schema-driven-ui.md\`, \`${e}agent-docs/internationalization.md\`.
|
|
218
219
|
${t}`
|
|
219
|
-
},
|
|
220
|
+
}, Le = [
|
|
220
221
|
{
|
|
221
222
|
name: "voltro-schema",
|
|
222
223
|
description: "Define or change a Voltro database table/schema (columns, mixins, indexes, relations).",
|
|
@@ -247,7 +248,7 @@ ${t}`
|
|
|
247
248
|
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
249
|
module: "cli.md"
|
|
249
250
|
}
|
|
250
|
-
],
|
|
251
|
+
], Re = (e, t) => `---
|
|
251
252
|
name: ${e.name}
|
|
252
253
|
description: ${e.description}
|
|
253
254
|
---
|
|
@@ -258,10 +259,10 @@ Open the full reference and follow the patterns there:
|
|
|
258
259
|
|
|
259
260
|
Also read the repo-root \`AGENTS.md\` for the always-true rules (browser/server
|
|
260
261
|
boundary, naming, anti-patterns) before editing.
|
|
261
|
-
`,
|
|
262
|
-
let i = yield*
|
|
262
|
+
`, ze = (e, t, n, r) => x.gen(function* () {
|
|
263
|
+
let i = yield* K(e, t);
|
|
263
264
|
if (i) {
|
|
264
|
-
if ((yield*
|
|
265
|
+
if ((yield* q(e, t)).slice(0, Te).includes("voltro:agents-md:keep")) return {
|
|
265
266
|
path: t,
|
|
266
267
|
action: "protected"
|
|
267
268
|
};
|
|
@@ -270,68 +271,68 @@ boundary, naming, anti-patterns) before editing.
|
|
|
270
271
|
action: "present"
|
|
271
272
|
};
|
|
272
273
|
}
|
|
273
|
-
return yield* e.makeDirectory(
|
|
274
|
+
return yield* e.makeDirectory(u(t), { recursive: !0 }).pipe(x.orElseSucceed(() => void 0)), yield* e.writeFileString(t, n).pipe(x.orDie), {
|
|
274
275
|
path: t,
|
|
275
276
|
action: i ? "overwritten" : "created"
|
|
276
277
|
};
|
|
277
|
-
}),
|
|
278
|
-
let n = yield*
|
|
279
|
-
for (let e of
|
|
278
|
+
}), Be = (e, t = {}) => x.gen(function* () {
|
|
279
|
+
let n = yield* _.FileSystem, r = yield* Oe(e), i = null;
|
|
280
|
+
for (let e of G) if (yield* K(n, f(e, "AGENTS.core.md"))) {
|
|
280
281
|
i = e;
|
|
281
282
|
break;
|
|
282
283
|
}
|
|
283
284
|
if (i === null) {
|
|
284
|
-
for (let e of
|
|
285
|
-
let i = yield*
|
|
286
|
-
for (let e of
|
|
285
|
+
for (let e of G) if (yield* K(n, f(e, "AGENTS.md"))) {
|
|
286
|
+
let i = yield* q(n, f(e, "AGENTS.md")), a = [];
|
|
287
|
+
for (let e of Ce) a.push(yield* ze(n, f(r, e), i, t.force ?? !1));
|
|
287
288
|
return { files: a };
|
|
288
289
|
}
|
|
289
|
-
return yield*
|
|
290
|
+
return yield* x.fail(Se(G.map((e) => f(e, "AGENTS.core.md"))));
|
|
290
291
|
}
|
|
291
|
-
let a = yield*
|
|
292
|
+
let a = yield* q(n, f(i, "AGENTS.core.md")), o = yield* q(n, f(i, "agent-docs", "_manifest.json")), s = o ? JSON.parse(o) : {
|
|
292
293
|
modules: [],
|
|
293
294
|
plugins: []
|
|
294
|
-
}, c = (t.preferPointer ?? !1) || (yield*
|
|
295
|
-
if ((yield*
|
|
295
|
+
}, c = (t.preferPointer ?? !1) || (yield* K(n, f(r, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), l = c ? "node_modules/@voltro/cli/templates/" : "", u = t.force ?? !1, d = Ce.map((e) => f(r, e));
|
|
296
|
+
if ((yield* x.forEach(d, (e) => q(n, e).pipe(x.map((e) => e.slice(0, Te))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: d.map((e) => ({
|
|
296
297
|
path: e,
|
|
297
298
|
action: "protected"
|
|
298
299
|
})) };
|
|
299
|
-
let { apis:
|
|
300
|
-
for (let e of
|
|
301
|
-
let t = yield*
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
for (let e of t)
|
|
300
|
+
let { apis: p, webs: h } = yield* Me(n, r), g = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set(), y = !1;
|
|
301
|
+
for (let e of p) {
|
|
302
|
+
let t = yield* je(n, e);
|
|
303
|
+
if (g.set(e, t), t !== null) {
|
|
304
|
+
y = !0;
|
|
305
|
+
for (let e of t) v.add(e);
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
|
-
let
|
|
308
|
-
for (let e of
|
|
309
|
-
c || (yield*
|
|
310
|
-
let w = new Map((t.appTemplates ?? []).map((e) => [
|
|
311
|
-
let t = w.get(
|
|
312
|
-
return t ?
|
|
313
|
-
}, E = (e, t) =>
|
|
314
|
-
for (let e of
|
|
315
|
-
for (let e of
|
|
316
|
-
for (let e of
|
|
308
|
+
let b = t.plugins ? t.plugins.map(Ae).filter((e) => e !== null) : y ? [...v] : null, S = a.includes(Ee) ? a.replace(Ee, Pe(s, b, l)) : a, C = [];
|
|
309
|
+
for (let e of d) C.push(yield* ze(n, e, S, u));
|
|
310
|
+
c || (yield* ke(n, f(i, "agent-docs"), f(r, "agent-docs")));
|
|
311
|
+
let w = new Map((t.appTemplates ?? []).map((e) => [m(e.dir), e.template])), T = (e) => {
|
|
312
|
+
let t = w.get(m(e));
|
|
313
|
+
return t ? Fe(t, s, l) : "";
|
|
314
|
+
}, E = (e, t) => x.forEach(Ce, (r) => ze(n, f(e, r), t, u));
|
|
315
|
+
for (let e of p) C.push(...yield* E(e, Ie.api(l, g.get(e) ?? null, T(e)))), (yield* K(n, f(e, "database"))) && C.push(...yield* E(f(e, "database"), Ie.database(l)));
|
|
316
|
+
for (let e of h) C.push(...yield* E(e, Ie.web(l, T(e))));
|
|
317
|
+
for (let e of Le) C.push(yield* ze(n, f(r, ".claude", "skills", e.name, "SKILL.md"), Re(e, l), u));
|
|
317
318
|
return { files: C };
|
|
318
|
-
}),
|
|
319
|
+
}), Ve = (e, t = {}) => x.runPromise(Be(e, t).pipe(x.provide(v.layer))), He = async (e) => {
|
|
319
320
|
let t = e.includes("--force"), n = e.find((e) => !e.startsWith("-")) ?? process.cwd();
|
|
320
|
-
return
|
|
321
|
-
let e = yield*
|
|
321
|
+
return be(x.gen(function* () {
|
|
322
|
+
let e = yield* Be(n, { force: t });
|
|
322
323
|
for (let t of e.files) {
|
|
323
|
-
let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${
|
|
324
|
-
yield*
|
|
324
|
+
let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${we}")` : "present (use --force to overwrite)";
|
|
325
|
+
yield* x.logInfo(`${t.path.split("/").slice(-2).join("/")} ${e}`, { action: t.action });
|
|
325
326
|
}
|
|
326
327
|
return 0;
|
|
327
|
-
}).pipe(
|
|
328
|
-
return yield*
|
|
328
|
+
}).pipe(x.catchTag("TemplateNotFoundError", (e) => x.gen(function* () {
|
|
329
|
+
return yield* x.logError("AGENTS.md template not found", { searched: e.searched }), 1;
|
|
329
330
|
}))), { scope: "voltro:agents-md" });
|
|
330
|
-
},
|
|
331
|
+
}, Ue = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), We = (e) => {
|
|
331
332
|
try {
|
|
332
|
-
let t =
|
|
333
|
-
if (!
|
|
334
|
-
let n = JSON.parse(
|
|
333
|
+
let t = f(e, "tsconfig.json");
|
|
334
|
+
if (!O(t)) return [];
|
|
335
|
+
let n = JSON.parse(Ue(M(t, "utf8"))).compilerOptions ?? {}, r = n.paths ?? {}, i = m(e, n.baseUrl ?? "."), a = [];
|
|
335
336
|
for (let [e, t] of Object.entries(r)) {
|
|
336
337
|
let n = t[0];
|
|
337
338
|
if (!n) continue;
|
|
@@ -340,28 +341,28 @@ boundary, naming, anti-patterns) before editing.
|
|
|
340
341
|
let t = e.slice(0, -2).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
341
342
|
a.push({
|
|
342
343
|
find: RegExp(`^${t}/(.*)$`),
|
|
343
|
-
replacement: `${
|
|
344
|
+
replacement: `${f(i, n.slice(0, -2))}/$1`
|
|
344
345
|
});
|
|
345
346
|
} else a.push({
|
|
346
347
|
find: e,
|
|
347
|
-
replacement:
|
|
348
|
+
replacement: f(i, n)
|
|
348
349
|
});
|
|
349
350
|
}
|
|
350
351
|
return a;
|
|
351
352
|
} catch {
|
|
352
353
|
return [];
|
|
353
354
|
}
|
|
354
|
-
},
|
|
355
|
+
}, Ge = (e) => {
|
|
355
356
|
let t = e;
|
|
356
357
|
return t?.code === "ERR_MODULE_NOT_FOUND" || /Cannot find (package|module)/.test(String(t?.message ?? ""));
|
|
357
|
-
},
|
|
358
|
+
}, Ke = async (e, t) => {
|
|
358
359
|
try {
|
|
359
360
|
return await t();
|
|
360
361
|
} catch (t) {
|
|
361
|
-
throw
|
|
362
|
+
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;
|
|
362
363
|
}
|
|
363
|
-
},
|
|
364
|
-
let n =
|
|
364
|
+
}, 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) => {
|
|
365
|
+
let n = Ye(t, () => !0), r = `${qe}
|
|
365
366
|
import '@voltro/env/server'
|
|
366
367
|
|
|
367
368
|
declare module '@voltro/env/server' {
|
|
@@ -370,9 +371,9 @@ ${n.length > 0 ? n : " // (no variables declared)"}
|
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
373
|
`;
|
|
373
|
-
await
|
|
374
|
-
},
|
|
375
|
-
let n =
|
|
374
|
+
await V(f(e, "env.generated.d.ts"), r, "utf8");
|
|
375
|
+
}, Ze = async (e, t) => {
|
|
376
|
+
let n = Ye(t, (e) => e === "public"), r = `${qe}
|
|
376
377
|
import '@voltro/env/public'
|
|
377
378
|
|
|
378
379
|
declare module '@voltro/env/public' {
|
|
@@ -380,10 +381,10 @@ declare module '@voltro/env/public' {
|
|
|
380
381
|
${n.length > 0 ? n : " // (no public variables declared)"}
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
|
-
`, i =
|
|
384
|
-
await
|
|
385
|
-
},
|
|
386
|
-
let n = `${
|
|
384
|
+
`, i = f(e, "src");
|
|
385
|
+
await B(i, { recursive: !0 }), await V(f(i, "voltro-env.d.ts"), r, "utf8");
|
|
386
|
+
}, Qe = async (e, t) => {
|
|
387
|
+
let n = `${qe}
|
|
387
388
|
import { __installPublicEnv } from '@voltro/env/public'
|
|
388
389
|
|
|
389
390
|
export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
|
|
@@ -391,14 +392,14 @@ export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
|
|
|
391
392
|
// Set the browser/SSR-shared global the \`publicEnv\` accessor reads.
|
|
392
393
|
__installPublicEnv(publicEnvValues)
|
|
393
394
|
`;
|
|
394
|
-
await
|
|
395
|
-
},
|
|
396
|
-
let t =
|
|
395
|
+
await B(e, { recursive: !0 }), await V(f(e, "env.public.ts"), n, "utf8");
|
|
396
|
+
}, $e = async (e) => {
|
|
397
|
+
let t = le(e.rawEnv) ? e.rawEnv : void 0, n = await fe({
|
|
397
398
|
contract: t,
|
|
398
|
-
resolveSecret:
|
|
399
|
-
}), r = [...n.errors, ...
|
|
400
|
-
if (r.length > 0) throw Error(
|
|
401
|
-
|
|
399
|
+
resolveSecret: ne
|
|
400
|
+
}), r = [...n.errors, ...se(t, e.appType)];
|
|
401
|
+
if (r.length > 0) throw Error(ce(r));
|
|
402
|
+
z(n.values), e.appType === "web" && pe(n.publicValues);
|
|
402
403
|
let i = t ? Object.keys(t.vars).length : 0;
|
|
403
404
|
if (i > 0) {
|
|
404
405
|
let r = Object.keys(n.publicValues).length;
|
|
@@ -410,20 +411,20 @@ __installPublicEnv(publicEnvValues)
|
|
|
410
411
|
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
412
|
}
|
|
412
413
|
}
|
|
413
|
-
return e.generateTypes && t && (e.appType === "api" ? await
|
|
414
|
+
return e.generateTypes && t && (e.appType === "api" ? await Xe(e.root, t) : await Ze(e.root, t)), {
|
|
414
415
|
resolved: n,
|
|
415
416
|
contract: t
|
|
416
417
|
};
|
|
417
|
-
},
|
|
418
|
-
let t =
|
|
418
|
+
}, et = (e) => {
|
|
419
|
+
let t = oe(e.contract), n = (e.plugins ?? []).flatMap((e) => ue(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : ae, i = /* @__PURE__ */ new Set(), a = [];
|
|
419
420
|
for (let e of [
|
|
420
421
|
...t,
|
|
421
422
|
...n,
|
|
422
423
|
...r
|
|
423
424
|
]) i.has(e.key) || (i.add(e.key), a.push(e));
|
|
424
425
|
return a;
|
|
425
|
-
},
|
|
426
|
-
let r =
|
|
426
|
+
}, tt = (e, t, n = (e) => process.env[e]) => {
|
|
427
|
+
let r = et(t).map((e) => {
|
|
427
428
|
let t = n(e.key) !== void 0;
|
|
428
429
|
return {
|
|
429
430
|
...e,
|
|
@@ -440,13 +441,13 @@ __installPublicEnv(publicEnvValues)
|
|
|
440
441
|
missingRequired: r.filter((e) => e.required && !e.isSet && e.default === void 0).length
|
|
441
442
|
}
|
|
442
443
|
};
|
|
443
|
-
},
|
|
444
|
+
}, nt = (e, t) => de(et({
|
|
444
445
|
...e,
|
|
445
446
|
includeFramework: !1
|
|
446
447
|
}), {
|
|
447
448
|
includeFramework: e.includeFramework !== !1,
|
|
448
449
|
...t ? { header: t } : {}
|
|
449
|
-
}),
|
|
450
|
+
}), rt = () => {
|
|
450
451
|
let e = /* @__PURE__ */ new Map();
|
|
451
452
|
return {
|
|
452
453
|
get(t) {
|
|
@@ -473,7 +474,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
473
474
|
return Array.from(e.entries());
|
|
474
475
|
}
|
|
475
476
|
};
|
|
476
|
-
},
|
|
477
|
+
}, J = (e) => {
|
|
477
478
|
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
|
|
478
479
|
if (typeof e != "string") return null;
|
|
479
480
|
let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
|
|
@@ -482,33 +483,33 @@ __installPublicEnv(publicEnvValues)
|
|
|
482
483
|
if (!Number.isFinite(n) || n <= 0) return null;
|
|
483
484
|
let r = t[2].toLowerCase();
|
|
484
485
|
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;
|
|
485
|
-
},
|
|
486
|
+
}, it = (e, t = {}) => {
|
|
486
487
|
let n = [e];
|
|
487
488
|
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("|");
|
|
488
|
-
},
|
|
489
|
+
}, at = (e, t) => e.expiresAt > t, ot = (e, t) => e.expiresAt <= t && e.servableUntil > t, st = T({ scope: "voltro:cli" }), ct = (e, t) => {
|
|
489
490
|
if (t?.code !== "EACCES") return "";
|
|
490
491
|
if (typeof process.getuid != "function") return " — permission denied";
|
|
491
492
|
try {
|
|
492
|
-
let t =
|
|
493
|
+
let t = P(e);
|
|
493
494
|
return ` — permission denied: the file is owned by uid ${t.uid} (mode ${(t.mode & 511).toString(8)}) and this process is uid ${process.getuid()}. A container running as root with the workspace bind-mounted writes files the host user cannot read; run it as \`--user <your-uid>:<your-gid>\`, or delete the file and let the owning user recreate it.`;
|
|
494
495
|
} catch {
|
|
495
496
|
return " — permission denied (and the file could not be stat-ed either)";
|
|
496
497
|
}
|
|
497
|
-
},
|
|
498
|
-
|
|
499
|
-
let t = e[1] && !e[1].startsWith("-") ? e[1] : void 0, n = t ?
|
|
498
|
+
}, lt = [], ut = (e) => {
|
|
499
|
+
lt.length = 0;
|
|
500
|
+
let t = e[1] && !e[1].startsWith("-") ? e[1] : void 0, n = t ? d(t) ? t : m(process.cwd(), t) : process.cwd(), r = [], i = n;
|
|
500
501
|
for (;;) {
|
|
501
502
|
r.push(i);
|
|
502
|
-
let e =
|
|
503
|
+
let e = u(i);
|
|
503
504
|
if (e === i) break;
|
|
504
505
|
i = e;
|
|
505
506
|
}
|
|
506
507
|
for (let e of r) for (let t of [".env.local", ".env"]) {
|
|
507
|
-
let n =
|
|
508
|
-
if (
|
|
509
|
-
|
|
508
|
+
let n = m(e, t);
|
|
509
|
+
if (O(n)) {
|
|
510
|
+
lt.push(n);
|
|
510
511
|
try {
|
|
511
|
-
let e =
|
|
512
|
+
let e = M(n, "utf8");
|
|
512
513
|
for (let t of e.split(/\r?\n/)) {
|
|
513
514
|
let e = t.trim();
|
|
514
515
|
if (e === "" || e.startsWith("#")) continue;
|
|
@@ -518,15 +519,15 @@ __installPublicEnv(publicEnvValues)
|
|
|
518
519
|
(i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
|
|
519
520
|
}
|
|
520
521
|
} catch (e) {
|
|
521
|
-
|
|
522
|
+
st.warn(`failed to load env file (continuing)${ct(n, e)}`, { path: n }, e);
|
|
522
523
|
}
|
|
523
524
|
}
|
|
524
525
|
}
|
|
525
|
-
},
|
|
526
|
+
}, dt = 500, ft = (e, t, n = {}) => {
|
|
526
527
|
if (e.length === 0) return () => {};
|
|
527
|
-
let r = (e) => n.root ?
|
|
528
|
+
let r = (e) => n.root ? p(n.root, e) : e, i = !1, a = (e) => {
|
|
528
529
|
i || (i = !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(() => {
|
|
529
|
-
let e =
|
|
530
|
+
let e = ge(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
530
531
|
stdio: "inherit",
|
|
531
532
|
env: process.env,
|
|
532
533
|
cwd: n.cwd ?? process.cwd()
|
|
@@ -540,62 +541,62 @@ __installPublicEnv(publicEnvValues)
|
|
|
540
541
|
});
|
|
541
542
|
}));
|
|
542
543
|
};
|
|
543
|
-
for (let t of e)
|
|
544
|
+
for (let t of e) te(t, { interval: dt }, (e, n) => {
|
|
544
545
|
e.mtimeMs !== n.mtimeMs && a(t);
|
|
545
546
|
});
|
|
546
547
|
return t.info("watching .env files for changes", {
|
|
547
548
|
files: e.map(r),
|
|
548
|
-
intervalMs:
|
|
549
|
+
intervalMs: dt
|
|
549
550
|
}), () => {
|
|
550
|
-
for (let t of e)
|
|
551
|
+
for (let t of e) F(t);
|
|
551
552
|
};
|
|
552
|
-
},
|
|
553
|
+
}, pt = T({ scope: "vite" }), mt = /\x1b\[[0-9;]*m/g, ht = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, gt = (e) => e.replace(mt, "").replace(ht, "").trim(), _t = /proxy error/i, vt = [
|
|
553
554
|
"ECONNREFUSED",
|
|
554
555
|
"ECONNRESET",
|
|
555
556
|
"ECONNABORTED",
|
|
556
557
|
"EPIPE",
|
|
557
558
|
"ETIMEDOUT"
|
|
558
|
-
],
|
|
559
|
+
], yt = (e, t = 0) => {
|
|
559
560
|
if (e == null || t > 5) return !1;
|
|
560
561
|
let n = e;
|
|
561
|
-
return typeof n.code == "string" &&
|
|
562
|
-
},
|
|
562
|
+
return typeof n.code == "string" && vt.includes(n.code) || typeof n.message == "string" && vt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => yt(e, t + 1)) ? !0 : yt(n.cause, t + 1);
|
|
563
|
+
}, bt = 4e3, xt = () => {
|
|
563
564
|
let e = /* @__PURE__ */ new Set(), t = 0, n = {
|
|
564
565
|
hasWarned: !1,
|
|
565
566
|
info: (e) => {
|
|
566
|
-
let t =
|
|
567
|
-
t.length !== 0 &&
|
|
567
|
+
let t = gt(e);
|
|
568
|
+
t.length !== 0 && pt.info(t);
|
|
568
569
|
},
|
|
569
570
|
warn: (e) => {
|
|
570
571
|
n.hasWarned = !0;
|
|
571
|
-
let t =
|
|
572
|
-
t.length !== 0 &&
|
|
572
|
+
let t = gt(e);
|
|
573
|
+
t.length !== 0 && pt.warn(t);
|
|
573
574
|
},
|
|
574
575
|
warnOnce: (t) => {
|
|
575
|
-
let r =
|
|
576
|
-
e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 &&
|
|
576
|
+
let r = gt(t);
|
|
577
|
+
e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && pt.warn(r));
|
|
577
578
|
},
|
|
578
579
|
error: (e, n) => {
|
|
579
|
-
let r =
|
|
580
|
+
let r = gt(e), i = n?.error;
|
|
580
581
|
if (r.length !== 0) {
|
|
581
|
-
if (
|
|
582
|
+
if (_t.test(r) && yt(i)) {
|
|
582
583
|
let e = Date.now();
|
|
583
|
-
e - t >
|
|
584
|
+
e - t > bt && (t = e, pt.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
|
|
584
585
|
return;
|
|
585
586
|
}
|
|
586
|
-
|
|
587
|
+
pt.error(r, {}, i);
|
|
587
588
|
}
|
|
588
589
|
},
|
|
589
590
|
clearScreen: () => {},
|
|
590
591
|
hasErrorLogged: (e) => !1
|
|
591
592
|
};
|
|
592
593
|
return n;
|
|
593
|
-
},
|
|
594
|
+
}, St = (e = process.env) => {
|
|
594
595
|
let t = e.VOLTRO_DEV_SSR_COMPILE_CONCURRENCY;
|
|
595
596
|
if (t === void 0 || t.trim() === "") return 4;
|
|
596
597
|
let n = Number(t);
|
|
597
598
|
return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 4;
|
|
598
|
-
},
|
|
599
|
+
}, Ct = (e) => {
|
|
599
600
|
let t = Math.max(1, Math.floor(e)), n = 0, r = [], i = () => n < t ? (n++, Promise.resolve()) : new Promise((e) => r.push(e)), a = () => {
|
|
600
601
|
let e = r.shift();
|
|
601
602
|
e ? e() : n--;
|
|
@@ -613,8 +614,8 @@ __installPublicEnv(publicEnvValues)
|
|
|
613
614
|
return n;
|
|
614
615
|
}
|
|
615
616
|
};
|
|
616
|
-
},
|
|
617
|
-
let t =
|
|
617
|
+
}, wt = (e) => {
|
|
618
|
+
let t = Ct(e.limit), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
618
619
|
return {
|
|
619
620
|
load: (i, a) => {
|
|
620
621
|
if (r.has(i)) return a();
|
|
@@ -639,7 +640,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
639
640
|
return r.size;
|
|
640
641
|
}
|
|
641
642
|
};
|
|
642
|
-
},
|
|
643
|
+
}, Tt = (e) => {
|
|
643
644
|
let t = [];
|
|
644
645
|
for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
|
|
645
646
|
name: n.slice(5, -2),
|
|
@@ -655,12 +656,12 @@ __installPublicEnv(publicEnvValues)
|
|
|
655
656
|
optional: !1
|
|
656
657
|
});
|
|
657
658
|
return t;
|
|
658
|
-
},
|
|
659
|
-
let t =
|
|
659
|
+
}, Et = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), Dt = async (e) => {
|
|
660
|
+
let t = m(e);
|
|
660
661
|
for (let e = 0; e < 4; e++) {
|
|
661
|
-
let e =
|
|
662
|
-
if (
|
|
663
|
-
let n = await
|
|
662
|
+
let e = f(t, "project.json");
|
|
663
|
+
if (O(e)) try {
|
|
664
|
+
let n = await j.readFile(e, "utf8");
|
|
664
665
|
return {
|
|
665
666
|
projectDir: t,
|
|
666
667
|
manifest: JSON.parse(n)
|
|
@@ -668,38 +669,38 @@ __installPublicEnv(publicEnvValues)
|
|
|
668
669
|
} catch {
|
|
669
670
|
return null;
|
|
670
671
|
}
|
|
671
|
-
let n =
|
|
672
|
+
let n = u(t);
|
|
672
673
|
if (n === t) break;
|
|
673
674
|
t = n;
|
|
674
675
|
}
|
|
675
676
|
return null;
|
|
676
|
-
},
|
|
677
|
-
let t = await
|
|
677
|
+
}, Ot = async (e) => {
|
|
678
|
+
let t = await Dt(e);
|
|
678
679
|
if (!t) return [];
|
|
679
|
-
let { projectDir: n, manifest: r } = t, i =
|
|
680
|
+
let { projectDir: n, manifest: r } = t, i = l(e), a = r.apps ?? {}, o = [];
|
|
680
681
|
for (let [e, t] of Object.entries(a)) {
|
|
681
682
|
if (e === i || t.kind !== "web" || typeof t.port != "number") continue;
|
|
682
|
-
let r =
|
|
683
|
-
if (!
|
|
683
|
+
let r = f(f(n, t.path ?? e), "src", "pages");
|
|
684
|
+
if (!O(r)) continue;
|
|
684
685
|
let a;
|
|
685
686
|
try {
|
|
686
687
|
let { pages: e } = await $(r);
|
|
687
688
|
a = e.map((e) => ({
|
|
688
689
|
pattern: e.pattern,
|
|
689
|
-
params:
|
|
690
|
+
params: Tt(e.pattern)
|
|
690
691
|
}));
|
|
691
692
|
} catch {
|
|
692
693
|
continue;
|
|
693
694
|
}
|
|
694
|
-
|
|
695
|
-
key:
|
|
695
|
+
o.push({
|
|
696
|
+
key: Et(e),
|
|
696
697
|
origin: `http://localhost:${t.port}`,
|
|
697
698
|
...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
|
|
698
699
|
routes: a
|
|
699
700
|
});
|
|
700
701
|
}
|
|
701
|
-
return
|
|
702
|
-
},
|
|
702
|
+
return o;
|
|
703
|
+
}, kt = (e) => {
|
|
703
704
|
if (e.params.length === 0) return `'${e.pattern}'`;
|
|
704
705
|
let t = e.pattern;
|
|
705
706
|
for (let n of e.params) {
|
|
@@ -707,21 +708,21 @@ __installPublicEnv(publicEnvValues)
|
|
|
707
708
|
t = t.replace(e, r);
|
|
708
709
|
}
|
|
709
710
|
return "`" + t + "`";
|
|
710
|
-
},
|
|
711
|
+
}, At = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
|
|
711
712
|
let t = "string";
|
|
712
713
|
return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
|
|
713
|
-
}).join("; ")} }`,
|
|
714
|
-
let r =
|
|
714
|
+
}).join("; ")} }`, jt = (e, t, n) => {
|
|
715
|
+
let r = At(e), i = kt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
|
|
715
716
|
return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
|
|
716
|
-
},
|
|
717
|
+
}, Mt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${jt(e, !1)},`).join("\n")}\n}`, Nt = (e, t) => {
|
|
717
718
|
if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
|
|
718
|
-
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)}: ${
|
|
719
|
+
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)}: ${jt(e, !0, i)},`);
|
|
719
720
|
return ` ${e.key}: {\n${a.join("\n")}\n },`;
|
|
720
|
-
},
|
|
721
|
+
}, Pt = async (e) => {
|
|
721
722
|
let t = e.pages.map((e) => ({
|
|
722
723
|
pattern: e.pattern,
|
|
723
|
-
params:
|
|
724
|
-
})), n = await
|
|
724
|
+
params: Tt(e.pattern)
|
|
725
|
+
})), n = await Ot(e.appRoot), r = [
|
|
725
726
|
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
726
727
|
"// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
|
|
727
728
|
"// Type-safe route builders consumed by <Link to={...}>.",
|
|
@@ -730,20 +731,20 @@ __installPublicEnv(publicEnvValues)
|
|
|
730
731
|
"",
|
|
731
732
|
"type EmptyParams = Record<string, never>",
|
|
732
733
|
""
|
|
733
|
-
].join("\n"), i = e.mode ?? "dev", a = `${r}\n${`export const routes = ${
|
|
734
|
-
await
|
|
735
|
-
let
|
|
734
|
+
].join("\n"), i = e.mode ?? "dev", a = `${r}\n${`export const routes = ${Mt(t)} as const\n`}\n${n.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${n.map((e) => Nt(e, i)).join("\n")}\n} as const\n`}`, o = f(e.appRoot, ".framework", "routes.generated.ts");
|
|
735
|
+
await j.mkdir(u(o), { recursive: !0 });
|
|
736
|
+
let s = null;
|
|
736
737
|
try {
|
|
737
|
-
|
|
738
|
+
s = await j.readFile(o, "utf8");
|
|
738
739
|
} catch {}
|
|
739
|
-
return
|
|
740
|
+
return s === a ? {
|
|
740
741
|
path: o,
|
|
741
742
|
wrote: !1
|
|
742
|
-
} : (await
|
|
743
|
+
} : (await j.writeFile(o, a, "utf8"), {
|
|
743
744
|
path: o,
|
|
744
745
|
wrote: !0
|
|
745
746
|
});
|
|
746
|
-
},
|
|
747
|
+
}, Ft = 256, It = (e = Ft) => {
|
|
747
748
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
748
749
|
return {
|
|
749
750
|
emit(r, i) {
|
|
@@ -766,27 +767,27 @@ __installPublicEnv(publicEnvValues)
|
|
|
766
767
|
return t.slice();
|
|
767
768
|
}
|
|
768
769
|
};
|
|
769
|
-
},
|
|
770
|
+
}, Lt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Rt = () => `: keep-alive ${Date.now()}\n\n`, zt = {
|
|
770
771
|
trace: 0,
|
|
771
772
|
debug: 1,
|
|
772
773
|
info: 2,
|
|
773
774
|
warn: 3,
|
|
774
775
|
error: 4,
|
|
775
776
|
fatal: 5
|
|
776
|
-
},
|
|
777
|
+
}, Bt = 2e3, Vt = 200, Ht = class {
|
|
777
778
|
capacity;
|
|
778
779
|
buffer = [];
|
|
779
|
-
constructor(e =
|
|
780
|
+
constructor(e = Bt) {
|
|
780
781
|
this.capacity = e;
|
|
781
782
|
}
|
|
782
783
|
append(e) {
|
|
783
784
|
this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
|
|
784
785
|
}
|
|
785
786
|
query(e = {}) {
|
|
786
|
-
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ??
|
|
787
|
+
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Vt, this.capacity), i = e.minLevel === void 0 ? zt.trace : zt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
|
|
787
788
|
for (let e = this.buffer.length - 1; e >= 0 && l.length < r; e--) {
|
|
788
789
|
let r = this.buffer[e];
|
|
789
|
-
r.ts < t || r.ts > n ||
|
|
790
|
+
r.ts < t || r.ts > n || zt[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
|
|
790
791
|
}
|
|
791
792
|
return l.reverse();
|
|
792
793
|
}
|
|
@@ -799,7 +800,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
799
800
|
clear() {
|
|
800
801
|
this.buffer = [];
|
|
801
802
|
}
|
|
802
|
-
},
|
|
803
|
+
}, Ut = null, Wt = () => (Ut === null && (Ut = new Ht()), Ut), Gt = (e) => {
|
|
803
804
|
if (typeof e == "string") return e;
|
|
804
805
|
if (e instanceof Error) return e.message;
|
|
805
806
|
try {
|
|
@@ -807,18 +808,18 @@ __installPublicEnv(publicEnvValues)
|
|
|
807
808
|
} catch {
|
|
808
809
|
return String(e);
|
|
809
810
|
}
|
|
810
|
-
},
|
|
811
|
+
}, Kt = (e) => {
|
|
811
812
|
let t = {
|
|
812
813
|
log: console.log.bind(console),
|
|
813
814
|
info: console.info.bind(console),
|
|
814
815
|
warn: console.warn.bind(console),
|
|
815
816
|
error: console.error.bind(console),
|
|
816
817
|
debug: console.debug.bind(console)
|
|
817
|
-
}, n =
|
|
818
|
+
}, n = Wt(), r = !1, i = (i) => (...a) => {
|
|
818
819
|
if (t[i](...a), !r) {
|
|
819
820
|
r = !0;
|
|
820
821
|
try {
|
|
821
|
-
let t = a.length > 0 ?
|
|
822
|
+
let t = a.length > 0 ? Gt(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = L();
|
|
822
823
|
e.emit("log", {
|
|
823
824
|
level: i,
|
|
824
825
|
message: r,
|
|
@@ -845,7 +846,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
845
846
|
}
|
|
846
847
|
};
|
|
847
848
|
console.log = i("log"), console.info = i("info"), console.warn = i("warn"), console.error = i("error"), console.debug = i("debug");
|
|
848
|
-
let a =
|
|
849
|
+
let a = w((t) => {
|
|
849
850
|
if (!r) {
|
|
850
851
|
r = !0;
|
|
851
852
|
try {
|
|
@@ -856,7 +857,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
856
857
|
argsCount: 1,
|
|
857
858
|
...t.scope === void 0 ? {} : { scope: t.scope }
|
|
858
859
|
});
|
|
859
|
-
let a =
|
|
860
|
+
let a = L(), o = a !== void 0 && t.fields.traceId === void 0 ? {
|
|
860
861
|
...t.fields,
|
|
861
862
|
traceId: a.traceId
|
|
862
863
|
} : t.fields;
|
|
@@ -876,24 +877,24 @@ __installPublicEnv(publicEnvValues)
|
|
|
876
877
|
return () => {
|
|
877
878
|
console.log = t.log, console.info = t.info, console.warn = t.warn, console.error = t.error, console.debug = t.debug, a();
|
|
878
879
|
};
|
|
879
|
-
},
|
|
880
|
+
}, qt = 2e3, Jt = 8, Yt = 1e3, Xt = 200, Y = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, Zt = (e) => {
|
|
880
881
|
switch (e) {
|
|
881
882
|
case "error": return "error";
|
|
882
883
|
case "warn": return "warn";
|
|
883
884
|
case "debug": return "debug";
|
|
884
885
|
default: return "info";
|
|
885
886
|
}
|
|
886
|
-
},
|
|
887
|
+
}, Qt = T({ scope: "client" }), $t = (e, t) => {
|
|
887
888
|
let n;
|
|
888
889
|
try {
|
|
889
890
|
n = JSON.parse(e);
|
|
890
891
|
} catch {
|
|
891
|
-
return
|
|
892
|
+
return en(400, { error: "invalid JSON body" });
|
|
892
893
|
}
|
|
893
|
-
if (typeof n != "object" || !n) return
|
|
894
|
+
if (typeof n != "object" || !n) return en(400, { error: "body must be a JSON object" });
|
|
894
895
|
let r = n;
|
|
895
|
-
if (!Array.isArray(r.entries)) return
|
|
896
|
-
let i = typeof r.app == "string" ?
|
|
896
|
+
if (!Array.isArray(r.entries)) return en(400, { error: "entries must be an array" });
|
|
897
|
+
let i = typeof r.app == "string" ? Y(r.app, 120) : void 0, a = typeof r.page == "string" ? Y(r.page, 200) : void 0, o = typeof r.ua == "string" ? Y(r.ua, 200) : void 0, s = r.entries.slice(0, Xt), c = 0;
|
|
897
898
|
for (let e of s) {
|
|
898
899
|
if (typeof e != "object" || !e) continue;
|
|
899
900
|
let n = e;
|
|
@@ -904,7 +905,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
904
905
|
"warn",
|
|
905
906
|
"error",
|
|
906
907
|
"debug"
|
|
907
|
-
].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l =
|
|
908
|
+
].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = Y(n.message, qt), u = Array.isArray(n.args) ? n.args.slice(0, Jt).filter((e) => typeof e == "string").map((e) => Y(e, Yt)) : void 0, d = typeof n.stack == "string" ? Y(n.stack, qt) : void 0;
|
|
908
909
|
t.emit("clientLog", {
|
|
909
910
|
ts: s,
|
|
910
911
|
level: r,
|
|
@@ -919,50 +920,50 @@ __installPublicEnv(publicEnvValues)
|
|
|
919
920
|
...i === void 0 ? {} : { app: i },
|
|
920
921
|
...a === void 0 ? {} : { page: a },
|
|
921
922
|
...u !== void 0 && u.length > 0 ? { args: u } : {}
|
|
922
|
-
}, p =
|
|
923
|
-
(p === "error" || p === "warn") && d !== void 0 ?
|
|
923
|
+
}, p = Zt(r);
|
|
924
|
+
(p === "error" || p === "warn") && d !== void 0 ? Qt[p](l, f, { stack: d }) : Qt[p](l, {
|
|
924
925
|
...f,
|
|
925
926
|
...d === void 0 ? {} : { stack: d }
|
|
926
927
|
}), c++;
|
|
927
928
|
}
|
|
928
|
-
return
|
|
929
|
+
return en(202, {
|
|
929
930
|
accepted: c,
|
|
930
931
|
dropped: r.entries.length - c
|
|
931
932
|
});
|
|
932
|
-
},
|
|
933
|
+
}, en = (e, t) => ({
|
|
933
934
|
status: e,
|
|
934
935
|
contentType: "application/json; charset=utf-8",
|
|
935
936
|
body: JSON.stringify(t)
|
|
936
|
-
}),
|
|
937
|
+
}), tn = "/_voltro/inspect/clientLog", nn = [
|
|
937
938
|
"trace",
|
|
938
939
|
"debug",
|
|
939
940
|
"info",
|
|
940
941
|
"warn",
|
|
941
942
|
"error",
|
|
942
943
|
"fatal"
|
|
943
|
-
],
|
|
944
|
+
], rn = {
|
|
944
945
|
trace: "TRACE",
|
|
945
946
|
debug: "DEBUG",
|
|
946
947
|
info: "INFO ",
|
|
947
948
|
warn: "WARN ",
|
|
948
949
|
error: "ERROR",
|
|
949
950
|
fatal: "FATAL"
|
|
950
|
-
},
|
|
951
|
-
if (
|
|
951
|
+
}, an = (e) => nn.includes(e), on = (e, t, n = {}) => {
|
|
952
|
+
if (i()) return {
|
|
952
953
|
status: 503,
|
|
953
954
|
contentType: "application/json",
|
|
954
955
|
body: JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" })
|
|
955
956
|
};
|
|
956
|
-
let
|
|
957
|
-
if (!
|
|
957
|
+
let r = o(n);
|
|
958
|
+
if (!r.ok) return {
|
|
958
959
|
status: 401,
|
|
959
960
|
contentType: "application/json",
|
|
960
961
|
body: JSON.stringify({
|
|
961
962
|
error: "unauthorized",
|
|
962
|
-
reason:
|
|
963
|
+
reason: r.reason
|
|
963
964
|
})
|
|
964
965
|
};
|
|
965
|
-
let
|
|
966
|
+
let a = e.indexOf("?"), s = a === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(a + 1)), c = {}, l = s.get("since");
|
|
966
967
|
if (l !== null) {
|
|
967
968
|
let e = Number(l);
|
|
968
969
|
Number.isFinite(e) && (c.since = e);
|
|
@@ -978,7 +979,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
978
979
|
Number.isFinite(e) && e > 0 && (c.max = Math.floor(e));
|
|
979
980
|
}
|
|
980
981
|
let f = s.get("level");
|
|
981
|
-
f !== null &&
|
|
982
|
+
f !== null && an(f) && (c.minLevel = f);
|
|
982
983
|
let p = s.get("source");
|
|
983
984
|
(p === "server" || p === "client") && (c.source = p);
|
|
984
985
|
let m = s.get("scope");
|
|
@@ -987,16 +988,16 @@ __installPublicEnv(publicEnvValues)
|
|
|
987
988
|
h !== null && h.length > 0 && (c.filter = h);
|
|
988
989
|
let g = s.get("trace");
|
|
989
990
|
g !== null && g.length > 0 && (c.traceId = g);
|
|
990
|
-
let _ =
|
|
991
|
+
let _ = t.query(c);
|
|
991
992
|
if ((s.get("format") ?? "json") === "text") return {
|
|
992
993
|
status: 200,
|
|
993
994
|
contentType: "text/plain; charset=utf-8",
|
|
994
|
-
body: _.map(
|
|
995
|
+
body: _.map(sn).join("\n") + (_.length > 0 ? "\n" : "")
|
|
995
996
|
};
|
|
996
997
|
let v = {
|
|
997
998
|
capturedAt: Date.now(),
|
|
998
|
-
bufferCapacity:
|
|
999
|
-
bufferSize:
|
|
999
|
+
bufferCapacity: t.capacityHint(),
|
|
1000
|
+
bufferSize: t.size(),
|
|
1000
1001
|
returned: _.length,
|
|
1001
1002
|
records: _
|
|
1002
1003
|
};
|
|
@@ -1005,33 +1006,33 @@ __installPublicEnv(publicEnvValues)
|
|
|
1005
1006
|
contentType: "application/json; charset=utf-8",
|
|
1006
1007
|
body: JSON.stringify(v)
|
|
1007
1008
|
};
|
|
1008
|
-
},
|
|
1009
|
-
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 =
|
|
1010
|
-
return `${n}:${r}:${i}.${a} ${
|
|
1011
|
-
},
|
|
1009
|
+
}, sn = (e) => {
|
|
1010
|
+
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 = ln(e.fields);
|
|
1011
|
+
return `${n}:${r}:${i}.${a} ${rn[e.level]} ${o} ${e.message}${s}`;
|
|
1012
|
+
}, cn = 80, ln = (e) => {
|
|
1012
1013
|
let t = Object.entries(e);
|
|
1013
1014
|
if (t.length === 0) return "";
|
|
1014
1015
|
let n = [];
|
|
1015
1016
|
for (let [e, r] of t) {
|
|
1016
1017
|
if (r === void 0) continue;
|
|
1017
|
-
let t =
|
|
1018
|
+
let t = un(r);
|
|
1018
1019
|
n.push(`${e}=${t}`);
|
|
1019
1020
|
}
|
|
1020
1021
|
return n.length > 0 ? " " + n.join(" ") : "";
|
|
1021
|
-
},
|
|
1022
|
+
}, un = (e) => {
|
|
1022
1023
|
if (typeof e == "string") {
|
|
1023
|
-
let t = e.length >
|
|
1024
|
+
let t = e.length > cn ? e.slice(0, cn) + "…" : e;
|
|
1024
1025
|
return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
|
|
1025
1026
|
}
|
|
1026
1027
|
if (e === null) return "null";
|
|
1027
1028
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1028
1029
|
try {
|
|
1029
1030
|
let t = JSON.stringify(e);
|
|
1030
|
-
return t.length >
|
|
1031
|
+
return t.length > cn ? t.slice(0, cn) + "…" : t;
|
|
1031
1032
|
} catch {
|
|
1032
1033
|
return "[unserialisable]";
|
|
1033
1034
|
}
|
|
1034
|
-
},
|
|
1035
|
+
}, dn = "/_voltro/inspect/logs", fn = [{
|
|
1035
1036
|
match: (e) => typeof e == "string" && e.startsWith("[BABEL] Note: The code generator has deoptimised"),
|
|
1036
1037
|
handle: (e, t) => {
|
|
1037
1038
|
let n = e[0], r = n.match(/deoptimised the styling of (.+?) as it exceeds the max of (\d+\w*B)\.?/);
|
|
@@ -1043,13 +1044,13 @@ __installPublicEnv(publicEnvValues)
|
|
|
1043
1044
|
});
|
|
1044
1045
|
} else t.info(n);
|
|
1045
1046
|
}
|
|
1046
|
-
}],
|
|
1047
|
+
}], pn = () => {
|
|
1047
1048
|
let e = {
|
|
1048
1049
|
warn: console.warn.bind(console),
|
|
1049
1050
|
error: console.error.bind(console)
|
|
1050
|
-
}, t =
|
|
1051
|
+
}, t = T({ scope: "babel" }), n = !1, r = (r) => (...i) => {
|
|
1051
1052
|
if (!n) {
|
|
1052
|
-
for (let e of
|
|
1053
|
+
for (let e of fn) if (e.match(i[0])) {
|
|
1053
1054
|
n = !0;
|
|
1054
1055
|
try {
|
|
1055
1056
|
e.handle(i, t);
|
|
@@ -1064,7 +1065,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1064
1065
|
return console.warn = r("warn"), console.error = r("error"), () => {
|
|
1065
1066
|
console.warn = e.warn, console.error = e.error;
|
|
1066
1067
|
};
|
|
1067
|
-
},
|
|
1068
|
+
}, mn = {
|
|
1068
1069
|
loader: "it runs on the server, and the router caches its result per route + params",
|
|
1069
1070
|
renderMode: "it picks the server render strategy",
|
|
1070
1071
|
dynamic: "it picks the server render strategy",
|
|
@@ -1075,7 +1076,7 @@ __installPublicEnv(publicEnvValues)
|
|
|
1075
1076
|
cacheInvalidatesOn: "it wires this page into the ISR cache invalidator",
|
|
1076
1077
|
interactive: "it decides how much client JS the server ships",
|
|
1077
1078
|
tenantAware: "it is part of the server-side cache key"
|
|
1078
|
-
},
|
|
1079
|
+
}, hn = Object.keys(mn), gn = (e) => n.test(e), _n = (e) => e.replace(t, ".page.test.tsx"), vn = (t) => t.endsWith(".tsx") && !e.has(t) && !gn(t), yn = "virtual:voltro-route-refresh", bn = `\0${yn}`, xn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Sn = () => `
|
|
1079
1080
|
// GENERATED by @voltro/cli — the \`voltro dev\` route Fast Refresh runtime.
|
|
1080
1081
|
|
|
1081
1082
|
/** Mirrors react-refresh's own \`isLikelyComponentType\` closely enough for the
|
|
@@ -1104,11 +1105,11 @@ const stableForm = (value) => {
|
|
|
1104
1105
|
* readers (\`build.ts\` prerender, \`webDev.ts\` dev SSR, \`start.ts\`). A change to
|
|
1105
1106
|
* one of THESE cannot be hot-applied: the server already ran with the old
|
|
1106
1107
|
* value. Everything else a page exports is plain client-side data. */
|
|
1107
|
-
const serverRelevantExports = ${JSON.stringify(
|
|
1108
|
+
const serverRelevantExports = ${JSON.stringify(hn)}
|
|
1108
1109
|
|
|
1109
1110
|
/** Name → the server step that already consumed it, so the reload message can
|
|
1110
1111
|
* say WHY rather than just WHAT. Injected from the same single source. */
|
|
1111
|
-
const serverExportEffect = ${JSON.stringify(
|
|
1112
|
+
const serverExportEffect = ${JSON.stringify(mn)}
|
|
1112
1113
|
|
|
1113
1114
|
/** The reason \`name\` forces a reload, for the console line. */
|
|
1114
1115
|
export const serverEffectOf = (name) =>
|
|
@@ -1151,7 +1152,7 @@ export const routeUpdateNeedsReload = (prevExports, nextExports) => {
|
|
|
1151
1152
|
const previousHook = globalThis.__getReactRefreshIgnoredExports
|
|
1152
1153
|
globalThis.__getReactRefreshIgnoredExports = (args) =>
|
|
1153
1154
|
ignoredExports.get(args.id) ?? previousHook?.(args) ?? []
|
|
1154
|
-
`,
|
|
1155
|
+
`, Cn = (e) => `
|
|
1155
1156
|
if (import.meta.hot) {
|
|
1156
1157
|
// Self-import to read our OWN exports, the same technique the react plugin
|
|
1157
1158
|
// uses; the namespace is only complete after evaluation, hence the promise.
|
|
@@ -1178,76 +1179,73 @@ import {
|
|
|
1178
1179
|
registerRouteModule as __voltro_registerRouteModule,
|
|
1179
1180
|
routeUpdateNeedsReload as __voltro_routeUpdateNeedsReload,
|
|
1180
1181
|
serverEffectOf as __voltro_serverEffect,
|
|
1181
|
-
} from '${
|
|
1182
|
-
`,
|
|
1183
|
-
let [
|
|
1184
|
-
if (!
|
|
1185
|
-
let
|
|
1186
|
-
return
|
|
1187
|
-
},
|
|
1182
|
+
} from '${yn}'
|
|
1183
|
+
`, wn = (e) => e.replace(/\\/g, "/"), Tn = (n, r) => {
|
|
1184
|
+
let [i = "", a] = wn(n).split("?");
|
|
1185
|
+
if (!i.endsWith(".tsx") || a !== void 0 && xn.test(a)) return !1;
|
|
1186
|
+
let o = wn(r).replace(/\/$/, "");
|
|
1187
|
+
return i.startsWith(`${o}/`) ? t.test(i) || e.has(i.slice(i.lastIndexOf("/") + 1)) : !1;
|
|
1188
|
+
}, En = (e, t, n) => Tn(t, n) ? `${e}${Cn(wn(t).split("?")[0] ?? t)}` : null, Dn = (e) => ({
|
|
1188
1189
|
name: "voltro:route-fast-refresh",
|
|
1189
1190
|
enforce: "pre",
|
|
1190
|
-
resolveId: (e) => e === "virtual:voltro-route-refresh" ?
|
|
1191
|
-
load: (e) => e ===
|
|
1191
|
+
resolveId: (e) => e === "virtual:voltro-route-refresh" ? bn : void 0,
|
|
1192
|
+
load: (e) => e === bn ? Sn() : void 0,
|
|
1192
1193
|
transform: (t, n, r) => {
|
|
1193
1194
|
if (r?.ssr === !0) return null;
|
|
1194
|
-
let i =
|
|
1195
|
+
let i = En(t, n, e);
|
|
1195
1196
|
return i === null ? null : {
|
|
1196
1197
|
code: i,
|
|
1197
1198
|
map: null
|
|
1198
1199
|
};
|
|
1199
1200
|
}
|
|
1200
|
-
}),
|
|
1201
|
+
}), On = [
|
|
1201
1202
|
"static",
|
|
1202
1203
|
"spa",
|
|
1203
1204
|
"ssr",
|
|
1204
1205
|
"isr"
|
|
1205
|
-
],
|
|
1206
|
+
], kn = (e) => typeof e == "string" && On.includes(e), An = On.map((e) => `'${e}'`).join(" | "), jn = (e, t) => `[voltro] ${e}: unknown renderMode '${t}'.\n Valid values: ${An}.${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)." : ""}`, Mn = class extends Error {
|
|
1206
1207
|
page;
|
|
1207
1208
|
value;
|
|
1208
1209
|
name = "InvalidRenderModeError";
|
|
1209
1210
|
constructor(e, t) {
|
|
1210
|
-
super(
|
|
1211
|
+
super(jn(e, t)), this.page = e, this.value = t;
|
|
1211
1212
|
}
|
|
1212
|
-
},
|
|
1213
|
+
}, Nn = (e, t = "<page>") => {
|
|
1213
1214
|
if (e.renderMode !== void 0 && e.renderMode !== null) {
|
|
1214
|
-
if (!
|
|
1215
|
+
if (!kn(e.renderMode)) throw new Mn(t, String(e.renderMode));
|
|
1215
1216
|
return e.renderMode;
|
|
1216
1217
|
}
|
|
1217
1218
|
return e.dynamic === "force-dynamic" ? "ssr" : (e.dynamic, "static");
|
|
1218
|
-
},
|
|
1219
|
-
renderMode:
|
|
1219
|
+
}, Pn = (e, t = "<page>") => ({
|
|
1220
|
+
renderMode: Nn(e, t),
|
|
1220
1221
|
tenantAware: e.tenantAware === !0,
|
|
1221
|
-
revalidateMs:
|
|
1222
|
-
staleWhileRevalidateMs:
|
|
1222
|
+
revalidateMs: J(e.revalidate),
|
|
1223
|
+
staleWhileRevalidateMs: J(e.staleWhileRevalidate) ?? 0,
|
|
1223
1224
|
cacheInvalidatesOn: Array.isArray(e.cacheInvalidatesOn) ? e.cacheInvalidatesOn : [],
|
|
1224
1225
|
interactive: e.interactive ?? "full",
|
|
1225
1226
|
hasLoader: typeof e.loader == "function",
|
|
1226
1227
|
hasMeta: e.meta != null,
|
|
1227
1228
|
hasGetStaticPaths: typeof e.getStaticPaths == "function"
|
|
1228
|
-
}),
|
|
1229
|
+
}), Fn = /export\s+const\s+renderMode\s*(?::[^=]+)?=\s*['"]([^'"]*)['"]/, In = (e) => Fn.exec(e)?.[1] ?? null, Ln = /export\s+default\b|export\s*\{[^}]*\bas\s+default\b/, Rn = async (e, t) => {
|
|
1229
1230
|
let n = (await Promise.all(t.map(async (t) => {
|
|
1230
1231
|
let n;
|
|
1231
1232
|
try {
|
|
1232
|
-
n = await
|
|
1233
|
+
n = await me(f(e, t.file), "utf8");
|
|
1233
1234
|
} catch {
|
|
1234
1235
|
return null;
|
|
1235
1236
|
}
|
|
1236
|
-
let r =
|
|
1237
|
-
return r
|
|
1238
|
-
file: t.file,
|
|
1239
|
-
value: r
|
|
1240
|
-
};
|
|
1237
|
+
let r = In(n);
|
|
1238
|
+
return r !== null && !kn(r) ? jn(f("src", "pages", t.file), r) : Ln.test(n) ? null : `${f("src", "pages", t.file)} is a route (it ends in .page.tsx) but exports no default.\n\n A page's default export IS its component — the router has nothing to render without it,\n and the failure would otherwise surface only in \`voltro build\`'s prerender as\n "SSR received a descriptor with no Component", long after the file was written.\n\n Fix: \`export default function Page() { … }\`, or — if this file is NOT a route —\n drop the .page suffix. Anything under src/pages/ without it is ordinary code and may\n live beside the page that uses it.`;
|
|
1241
1239
|
}))).filter((e) => e !== null);
|
|
1242
|
-
if (n.length !== 0) throw Error(n.
|
|
1243
|
-
},
|
|
1240
|
+
if (n.length !== 0) throw Error(n.join("\n\n"));
|
|
1241
|
+
}, zn = f(ie(), ".voltro"), Bn = f(zn, "runtime-registry.json"), Vn = 3e4, Hn = () => {
|
|
1244
1242
|
let e = Math.random().toString(36).slice(2, 10);
|
|
1245
|
-
return `${
|
|
1246
|
-
},
|
|
1247
|
-
await
|
|
1248
|
-
},
|
|
1243
|
+
return `${Bn}.${process.pid}.${Date.now()}.${e}.tmp`;
|
|
1244
|
+
}, Un = async () => {
|
|
1245
|
+
await j.mkdir(zn, { recursive: !0 });
|
|
1246
|
+
}, Wn = async () => {
|
|
1249
1247
|
try {
|
|
1250
|
-
let e = await
|
|
1248
|
+
let e = await j.readFile(Bn, "utf8"), t = JSON.parse(e);
|
|
1251
1249
|
return t.version !== 1 || !Array.isArray(t.apps) ? {
|
|
1252
1250
|
version: 1,
|
|
1253
1251
|
apps: []
|
|
@@ -1258,34 +1256,34 @@ import {
|
|
|
1258
1256
|
apps: []
|
|
1259
1257
|
};
|
|
1260
1258
|
}
|
|
1261
|
-
},
|
|
1262
|
-
await
|
|
1263
|
-
let t =
|
|
1259
|
+
}, Gn = async (e) => {
|
|
1260
|
+
await Un();
|
|
1261
|
+
let t = Hn();
|
|
1264
1262
|
try {
|
|
1265
|
-
await
|
|
1263
|
+
await j.writeFile(t, JSON.stringify(e, null, 2), {
|
|
1266
1264
|
encoding: "utf8",
|
|
1267
1265
|
mode: 384
|
|
1268
|
-
}), await
|
|
1266
|
+
}), await j.rename(t, Bn), await j.chmod(Bn, 384).catch(() => {});
|
|
1269
1267
|
} catch (e) {
|
|
1270
1268
|
try {
|
|
1271
|
-
await
|
|
1269
|
+
await j.unlink(t);
|
|
1272
1270
|
} catch {}
|
|
1273
1271
|
throw e;
|
|
1274
1272
|
}
|
|
1275
|
-
},
|
|
1273
|
+
}, Kn = (e) => {
|
|
1276
1274
|
try {
|
|
1277
1275
|
return process.kill(e, 0), !0;
|
|
1278
1276
|
} catch {
|
|
1279
1277
|
return !1;
|
|
1280
1278
|
}
|
|
1281
|
-
},
|
|
1279
|
+
}, qn = (e) => {
|
|
1282
1280
|
let t = Date.now();
|
|
1283
|
-
return e.filter((e) =>
|
|
1284
|
-
},
|
|
1285
|
-
let e = await
|
|
1281
|
+
return e.filter((e) => Kn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < Vn : !1);
|
|
1282
|
+
}, Jn = async () => {
|
|
1283
|
+
let e = await Wn(), t = qn(e.apps);
|
|
1286
1284
|
if (t.length === e.apps.length) return e;
|
|
1287
1285
|
try {
|
|
1288
|
-
await
|
|
1286
|
+
await Gn({
|
|
1289
1287
|
version: 1,
|
|
1290
1288
|
apps: t
|
|
1291
1289
|
});
|
|
@@ -1294,49 +1292,49 @@ import {
|
|
|
1294
1292
|
version: 1,
|
|
1295
1293
|
apps: t
|
|
1296
1294
|
};
|
|
1297
|
-
},
|
|
1298
|
-
let t = await
|
|
1295
|
+
}, Yn = async (e) => {
|
|
1296
|
+
let t = await Wn(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = e.inspectToken ?? process.env.VOLTRO_INSPECT_TOKEN, a = {
|
|
1299
1297
|
...e,
|
|
1300
1298
|
...i !== void 0 && i !== "" ? { inspectToken: i } : {},
|
|
1301
1299
|
registeredAt: r >= 0 ? t.apps[r].registeredAt : n,
|
|
1302
1300
|
heartbeatAt: n
|
|
1303
1301
|
};
|
|
1304
|
-
await
|
|
1302
|
+
await Gn({
|
|
1305
1303
|
version: 1,
|
|
1306
1304
|
apps: r >= 0 ? t.apps.map((e, t) => t === r ? a : e) : [...t.apps, a]
|
|
1307
1305
|
});
|
|
1308
|
-
},
|
|
1306
|
+
}, Xn = async (e) => {
|
|
1309
1307
|
try {
|
|
1310
|
-
let t = await
|
|
1308
|
+
let t = await Wn(), n = t.apps.filter((t) => t.id !== e);
|
|
1311
1309
|
if (n.length === t.apps.length) return;
|
|
1312
|
-
await
|
|
1310
|
+
await Gn({
|
|
1313
1311
|
version: 1,
|
|
1314
1312
|
apps: n
|
|
1315
1313
|
});
|
|
1316
1314
|
} catch {}
|
|
1317
|
-
},
|
|
1315
|
+
}, Zn = (e, t, n) => `${e}:${t}:${n}`, X = f(ie(), ".voltro", "logs"), Qn = () => {
|
|
1318
1316
|
let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
|
|
1319
1317
|
return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
|
|
1320
|
-
},
|
|
1321
|
-
if (
|
|
1322
|
-
|
|
1323
|
-
let e = Date.now() -
|
|
1318
|
+
}, $n = !1, er = () => {
|
|
1319
|
+
if ($n) return;
|
|
1320
|
+
$n = !0;
|
|
1321
|
+
let e = Date.now() - Qn(), t = [];
|
|
1324
1322
|
try {
|
|
1325
|
-
t =
|
|
1323
|
+
t = N(X);
|
|
1326
1324
|
} catch {
|
|
1327
1325
|
return;
|
|
1328
1326
|
}
|
|
1329
1327
|
for (let n of t) {
|
|
1330
1328
|
if (!n.endsWith(".log")) continue;
|
|
1331
|
-
let t =
|
|
1329
|
+
let t = f(X, n);
|
|
1332
1330
|
try {
|
|
1333
|
-
|
|
1331
|
+
P(t).mtimeMs < e && ee(t);
|
|
1334
1332
|
} catch {}
|
|
1335
1333
|
}
|
|
1336
|
-
},
|
|
1337
|
-
let t =
|
|
1334
|
+
}, tr = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), nr = (e, t) => f(X, `${tr(e)}-${t}.log`), rr = (e) => {
|
|
1335
|
+
let t = tr(e), n = [];
|
|
1338
1336
|
try {
|
|
1339
|
-
n =
|
|
1337
|
+
n = N(X);
|
|
1340
1338
|
} catch {
|
|
1341
1339
|
return;
|
|
1342
1340
|
}
|
|
@@ -1344,19 +1342,19 @@ import {
|
|
|
1344
1342
|
if (r.length === 0) return;
|
|
1345
1343
|
let i, a = -1;
|
|
1346
1344
|
for (let e of r) {
|
|
1347
|
-
let t =
|
|
1345
|
+
let t = f(X, e);
|
|
1348
1346
|
try {
|
|
1349
|
-
let e =
|
|
1347
|
+
let e = P(t);
|
|
1350
1348
|
e.mtimeMs > a && (a = e.mtimeMs, i = t);
|
|
1351
1349
|
} catch {}
|
|
1352
1350
|
}
|
|
1353
1351
|
return i;
|
|
1354
|
-
},
|
|
1352
|
+
}, ir = (e) => {
|
|
1355
1353
|
try {
|
|
1356
|
-
|
|
1354
|
+
k(X, { recursive: !0 });
|
|
1357
1355
|
} catch {}
|
|
1358
|
-
|
|
1359
|
-
let t =
|
|
1356
|
+
er();
|
|
1357
|
+
let t = nr(e, process.pid), n = A(t, "w"), r = (e) => {
|
|
1360
1358
|
let t = {
|
|
1361
1359
|
ts: e.ts.getTime(),
|
|
1362
1360
|
level: e.level,
|
|
@@ -1377,15 +1375,15 @@ import {
|
|
|
1377
1375
|
...e.scope === void 0 ? {} : { scope: e.scope }
|
|
1378
1376
|
}) + "\n";
|
|
1379
1377
|
}
|
|
1380
|
-
}, i = !1, a =
|
|
1378
|
+
}, i = !1, a = w((e) => {
|
|
1381
1379
|
if (!i) try {
|
|
1382
|
-
|
|
1380
|
+
I(n, r(e));
|
|
1383
1381
|
} catch {}
|
|
1384
1382
|
}), o = () => {
|
|
1385
1383
|
if (!i) {
|
|
1386
1384
|
i = !0;
|
|
1387
1385
|
try {
|
|
1388
|
-
|
|
1386
|
+
D(n);
|
|
1389
1387
|
} catch {}
|
|
1390
1388
|
}
|
|
1391
1389
|
};
|
|
@@ -1397,10 +1395,10 @@ import {
|
|
|
1397
1395
|
a(), o(), process.off("exit", o), process.off("uncaughtException", s), process.off("unhandledRejection", s);
|
|
1398
1396
|
}
|
|
1399
1397
|
};
|
|
1400
|
-
},
|
|
1398
|
+
}, ar = async (e, t) => {
|
|
1401
1399
|
let n;
|
|
1402
1400
|
try {
|
|
1403
|
-
n = await
|
|
1401
|
+
n = await j.readFile(e, "utf8");
|
|
1404
1402
|
} catch {
|
|
1405
1403
|
return [];
|
|
1406
1404
|
}
|
|
@@ -1411,78 +1409,78 @@ import {
|
|
|
1411
1409
|
i.push(t);
|
|
1412
1410
|
} catch {}
|
|
1413
1411
|
return t?.max !== void 0 && i.length > t.max ? i.slice(i.length - t.max) : i;
|
|
1414
|
-
},
|
|
1412
|
+
}, or = T({ scope: "voltro:dashboard" }), sr = re(import.meta.url), cr = 5179, lr = (e) => {
|
|
1415
1413
|
let t = process.env.VOLTRO_DASHBOARD_PATH;
|
|
1416
|
-
if (t &&
|
|
1414
|
+
if (t && O(f(m(t), "app.config.ts"))) return m(t);
|
|
1417
1415
|
try {
|
|
1418
|
-
let e =
|
|
1419
|
-
if (
|
|
1416
|
+
let e = u(sr.resolve("@voltro/dashboard/package.json"));
|
|
1417
|
+
if (O(f(e, "app.config.ts"))) return e;
|
|
1420
1418
|
} catch {}
|
|
1421
|
-
let n =
|
|
1419
|
+
let n = f("voltro-devtools", "apps", "dashboard"), r = m(e);
|
|
1422
1420
|
for (let e = 0; e < 10; e++) {
|
|
1423
|
-
let e =
|
|
1424
|
-
if (
|
|
1425
|
-
let t =
|
|
1421
|
+
let e = f(r, n);
|
|
1422
|
+
if (O(f(e, "app.config.ts"))) return e;
|
|
1423
|
+
let t = u(r);
|
|
1426
1424
|
if (t === r) break;
|
|
1427
1425
|
r = t;
|
|
1428
1426
|
}
|
|
1429
1427
|
return null;
|
|
1430
|
-
},
|
|
1431
|
-
let i =
|
|
1428
|
+
}, ur = "VOLTRO_IS_DASHBOARD", dr = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
|
|
1429
|
+
let i = _e({
|
|
1432
1430
|
port: e,
|
|
1433
1431
|
host: t
|
|
1434
1432
|
}), a = !1, o = (e) => {
|
|
1435
1433
|
a || (a = !0, i.destroy(), r(e));
|
|
1436
1434
|
};
|
|
1437
1435
|
i.once("connect", () => o(!0)), i.once("error", () => o(!1)), setTimeout(() => o(!1), n);
|
|
1438
|
-
}),
|
|
1436
|
+
}), fr = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), pr = () => process.env[ur] === "1", mr = () => process.stdout.isTTY === !0, hr = f(ie(), ".voltro", "dashboard-launch.lock"), gr = 1e4, _r = async () => {
|
|
1439
1437
|
try {
|
|
1440
|
-
await
|
|
1441
|
-
let e = await
|
|
1438
|
+
await j.mkdir(u(hr), { recursive: !0 });
|
|
1439
|
+
let e = await j.open(hr, "wx");
|
|
1442
1440
|
return await e.write(`${process.pid}\n${Date.now()}\n`), await e.close(), !0;
|
|
1443
1441
|
} catch {
|
|
1444
1442
|
try {
|
|
1445
|
-
let e = await
|
|
1446
|
-
if (Date.now() - e.mtimeMs >
|
|
1443
|
+
let e = await j.stat(hr);
|
|
1444
|
+
if (Date.now() - e.mtimeMs > gr) return await j.unlink(hr).catch(() => void 0), _r();
|
|
1447
1445
|
} catch {}
|
|
1448
1446
|
return !1;
|
|
1449
1447
|
}
|
|
1450
|
-
},
|
|
1448
|
+
}, vr = async () => {
|
|
1451
1449
|
try {
|
|
1452
|
-
await
|
|
1450
|
+
await j.unlink(hr);
|
|
1453
1451
|
} catch {}
|
|
1454
|
-
},
|
|
1452
|
+
}, yr = async (e) => {
|
|
1455
1453
|
let t = e.port ?? 5179;
|
|
1456
|
-
if (
|
|
1454
|
+
if (fr()) return {
|
|
1457
1455
|
status: "skipped",
|
|
1458
1456
|
reason: "disabled by flag/env",
|
|
1459
1457
|
port: t
|
|
1460
1458
|
};
|
|
1461
|
-
if (
|
|
1459
|
+
if (pr()) return {
|
|
1462
1460
|
status: "skipped",
|
|
1463
1461
|
reason: "this process IS the dashboard",
|
|
1464
1462
|
port: t
|
|
1465
1463
|
};
|
|
1466
|
-
if (!
|
|
1464
|
+
if (!mr()) return {
|
|
1467
1465
|
status: "skipped",
|
|
1468
1466
|
reason: "stdout is not a TTY (CI/smoke)",
|
|
1469
1467
|
port: t
|
|
1470
1468
|
};
|
|
1471
|
-
if (!await
|
|
1469
|
+
if (!await _r()) return {
|
|
1472
1470
|
status: "skipped",
|
|
1473
1471
|
reason: "another voltro process is currently launching the dashboard",
|
|
1474
1472
|
port: t
|
|
1475
1473
|
};
|
|
1476
|
-
if (await
|
|
1474
|
+
if (await dr(t)) return await vr(), {
|
|
1477
1475
|
status: "already-running",
|
|
1478
1476
|
port: t
|
|
1479
1477
|
};
|
|
1480
1478
|
let n = e.voltroBin;
|
|
1481
1479
|
if (!n) {
|
|
1482
1480
|
let e = process.argv[1];
|
|
1483
|
-
n = e && e.endsWith("/src/bin.ts") ?
|
|
1481
|
+
n = e && e.endsWith("/src/bin.ts") ? f(u(e), "..", "bin", "voltro.mjs") : e ?? "voltro";
|
|
1484
1482
|
}
|
|
1485
|
-
let r =
|
|
1483
|
+
let r = O(f(e.dashboardAppPath, ".framework", "dist", "index.html")), i = r ? "start" : "dev", a = ge(process.execPath, [
|
|
1486
1484
|
n,
|
|
1487
1485
|
i,
|
|
1488
1486
|
e.dashboardAppPath
|
|
@@ -1490,7 +1488,7 @@ import {
|
|
|
1490
1488
|
stdio: "ignore",
|
|
1491
1489
|
env: {
|
|
1492
1490
|
...process.env,
|
|
1493
|
-
[
|
|
1491
|
+
[ur]: "1",
|
|
1494
1492
|
VOLTRO_DASHBOARD_PORT: String(t)
|
|
1495
1493
|
}
|
|
1496
1494
|
});
|
|
@@ -1498,22 +1496,22 @@ import {
|
|
|
1498
1496
|
if (a.exitCode === null && a.signalCode === null) try {
|
|
1499
1497
|
a.kill("SIGTERM");
|
|
1500
1498
|
} catch {}
|
|
1501
|
-
}),
|
|
1499
|
+
}), or.info(`auto-launching dashboard at http://localhost:${t}`, {
|
|
1502
1500
|
port: t,
|
|
1503
1501
|
mode: i,
|
|
1504
1502
|
prebuilt: r
|
|
1505
|
-
}), r ||
|
|
1506
|
-
|
|
1503
|
+
}), r || or.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), or.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
|
|
1504
|
+
vr();
|
|
1507
1505
|
}, 4e3).unref(), {
|
|
1508
1506
|
status: "launched",
|
|
1509
1507
|
port: t
|
|
1510
1508
|
};
|
|
1511
|
-
},
|
|
1509
|
+
}, br = class extends Error {
|
|
1512
1510
|
_voltroDeferral = !0;
|
|
1513
1511
|
constructor(e) {
|
|
1514
1512
|
super(e), this.name = "DeferralNotSupportedError";
|
|
1515
1513
|
}
|
|
1516
|
-
},
|
|
1514
|
+
}, xr = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Sr = (e) => {
|
|
1517
1515
|
let { helpers: t } = e, n = t.prepareDeferredLoaderData(e.loaderData, "page"), r = {}, i = {}, a = {};
|
|
1518
1516
|
for (let [n, o] of Object.entries(e.segmentLoaderData)) {
|
|
1519
1517
|
let e = Number(n), s = t.prepareDeferredLoaderData(o, e);
|
|
@@ -1528,7 +1526,7 @@ import {
|
|
|
1528
1526
|
...e.layoutShell ? { layoutShell: e.layoutShell } : {}
|
|
1529
1527
|
});
|
|
1530
1528
|
} catch (e) {
|
|
1531
|
-
throw new
|
|
1529
|
+
throw new br(e instanceof Error ? e.message : String(e));
|
|
1532
1530
|
}
|
|
1533
1531
|
return {
|
|
1534
1532
|
loaderData: n.renderData,
|
|
@@ -1544,8 +1542,8 @@ import {
|
|
|
1544
1542
|
...Object.keys(a).length > 0 ? { deferredSegmentIds: a } : {}
|
|
1545
1543
|
}
|
|
1546
1544
|
};
|
|
1547
|
-
},
|
|
1548
|
-
let { helpers: t, renderInput: n } = e, r =
|
|
1545
|
+
}, Cr = (e) => {
|
|
1546
|
+
let { helpers: t, renderInput: n } = e, r = Sr({
|
|
1549
1547
|
helpers: t,
|
|
1550
1548
|
page: e.page,
|
|
1551
1549
|
pathname: n.pathname,
|
|
@@ -1566,42 +1564,42 @@ import {
|
|
|
1566
1564
|
stateScript: t.renderRouterStateScript(r.stateInput),
|
|
1567
1565
|
hasDeferred: r.hasDeferred
|
|
1568
1566
|
};
|
|
1569
|
-
},
|
|
1567
|
+
}, wr = (e) => {
|
|
1570
1568
|
let { html: t, meta: n } = e.helpers.renderPageToHtml(e.prepared.renderInput);
|
|
1571
1569
|
return {
|
|
1572
1570
|
body: t,
|
|
1573
1571
|
meta: n
|
|
1574
1572
|
};
|
|
1575
|
-
},
|
|
1573
|
+
}, Tr = (e) => [
|
|
1576
1574
|
...e.extra ?? [],
|
|
1577
1575
|
e.helpers.renderMetaToHtml(e.meta),
|
|
1578
1576
|
`<meta name="voltro-interactive" content="${e.interactive}" />`,
|
|
1579
1577
|
...e.prepared.hasDeferred ? [e.helpers.renderDeferredRegistryScript()] : [],
|
|
1580
1578
|
e.prepared.stateScript
|
|
1581
|
-
].filter((e) => e.length > 0).join("\n "),
|
|
1582
|
-
let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(
|
|
1583
|
-
let r =
|
|
1579
|
+
].filter((e) => e.length > 0).join("\n "), 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) => {
|
|
1580
|
+
let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(kr, (e) => {
|
|
1581
|
+
let r = Ar.exec(e)?.[1];
|
|
1584
1582
|
return r === void 0 || t(r) ? e : (n.push(r), "");
|
|
1585
1583
|
});
|
|
1586
|
-
e.inlineModuleScriptsAsync && (r = r.replace(
|
|
1587
|
-
let i = r.indexOf(
|
|
1588
|
-
if (i === -1) throw Error(`[voltro] the generated shell has no \`${
|
|
1584
|
+
e.inlineModuleScriptsAsync && (r = r.replace(jr, "<script async$1>"));
|
|
1585
|
+
let i = r.indexOf(Er);
|
|
1586
|
+
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.`);
|
|
1589
1587
|
return {
|
|
1590
|
-
head: `${r.slice(0, i)}${
|
|
1591
|
-
tail: `${
|
|
1588
|
+
head: `${r.slice(0, i)}${Dr}`,
|
|
1589
|
+
tail: `${Or}${r.slice(i + 21)}`,
|
|
1592
1590
|
bootstrapModules: n
|
|
1593
1591
|
};
|
|
1594
|
-
},
|
|
1592
|
+
}, Nr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), Pr = (e) => {
|
|
1595
1593
|
let { res: t, shell: n, htmlLang: r, headInjection: i } = e, a = null, o = !1, s = !1, c = () => {
|
|
1596
1594
|
if (s || !o || a === null) return;
|
|
1597
1595
|
s = !0, t.statusCode = e.statusCode ?? 200;
|
|
1598
1596
|
for (let [n, r] of Object.entries(e.headers ?? {})) t.setHeader(n, r);
|
|
1599
|
-
t.flushHeaders?.(), t.write(
|
|
1597
|
+
t.flushHeaders?.(), t.write(Nr({
|
|
1600
1598
|
head: n.head,
|
|
1601
1599
|
headInjection: i(a.meta),
|
|
1602
1600
|
htmlLang: r
|
|
1603
1601
|
}));
|
|
1604
|
-
let c = new
|
|
1602
|
+
let c = new ve();
|
|
1605
1603
|
c.pipe(t, { end: !1 }), c.on("end", () => {
|
|
1606
1604
|
t.end(n.tail);
|
|
1607
1605
|
}), a.stream.pipe(c);
|
|
@@ -1626,23 +1624,23 @@ import {
|
|
|
1626
1624
|
return;
|
|
1627
1625
|
}
|
|
1628
1626
|
c();
|
|
1629
|
-
}, Z =
|
|
1627
|
+
}, Z = T({ scope: "voltro:dev:web" }), Fr = T({ scope: "vite" }), Ir = await (async () => {
|
|
1630
1628
|
try {
|
|
1631
|
-
let e =
|
|
1629
|
+
let e = f(u(h(import.meta.url)), "..", "package.json"), t = await j.readFile(e, "utf8");
|
|
1632
1630
|
return JSON.parse(t).version ?? "0.0.0";
|
|
1633
1631
|
} catch {
|
|
1634
1632
|
return "0.0.0";
|
|
1635
1633
|
}
|
|
1636
|
-
})(),
|
|
1634
|
+
})(), Lr = async () => {
|
|
1637
1635
|
try {
|
|
1638
|
-
let e =
|
|
1639
|
-
if (
|
|
1640
|
-
let n =
|
|
1641
|
-
return
|
|
1636
|
+
let e = u(h(import.meta.url)), t = m(e, "..", "..", "devtools");
|
|
1637
|
+
if (O(f(t, "package.json"))) return t;
|
|
1638
|
+
let n = m(e, "..", "..", "..", "devtools");
|
|
1639
|
+
return O(f(n, "package.json")) ? n : null;
|
|
1642
1640
|
} catch {
|
|
1643
1641
|
return null;
|
|
1644
1642
|
}
|
|
1645
|
-
},
|
|
1643
|
+
}, Rr = (e, t) => e.disableDevtools || !t ? [] : [
|
|
1646
1644
|
"",
|
|
1647
1645
|
"// Dev-only in-page devtools overlay. The `import.meta.env.DEV` guard is a",
|
|
1648
1646
|
"// compile-time constant, so prod builds strip this whole `if` block — the",
|
|
@@ -1652,82 +1650,87 @@ import {
|
|
|
1652
1650
|
" await import('@voltro/devtools/styles.css')",
|
|
1653
1651
|
" Devtools = (await import('@voltro/devtools')).VoltroDevtools",
|
|
1654
1652
|
"}"
|
|
1655
|
-
],
|
|
1653
|
+
], zr = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], Br = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], Vr = (e) => e.sentry ? [
|
|
1656
1654
|
"",
|
|
1657
1655
|
"// Browser-side Sentry (frontend half of the deep integration). Errors +",
|
|
1658
1656
|
"// browser rpc spans flow to Sentry, sharing the server transactions' trace.",
|
|
1659
1657
|
`await initSentryBrowser(${JSON.stringify(e.sentry)})`
|
|
1660
|
-
] : [],
|
|
1661
|
-
let t = [], n =
|
|
1658
|
+
] : [], Hr = (e) => e.env ? ["import './env.public'"] : [], Ur = (e) => {
|
|
1659
|
+
let t = [], n = m(e);
|
|
1662
1660
|
for (;;) {
|
|
1663
|
-
|
|
1664
|
-
let e =
|
|
1661
|
+
O(f(n, "pnpm-workspace.yaml")) && t.push(n);
|
|
1662
|
+
let e = u(n);
|
|
1665
1663
|
if (e === n) break;
|
|
1666
1664
|
n = e;
|
|
1667
1665
|
}
|
|
1668
1666
|
return t;
|
|
1669
|
-
},
|
|
1670
|
-
"layout.tsx",
|
|
1671
|
-
"error.tsx",
|
|
1672
|
-
"loading.tsx",
|
|
1673
|
-
"not-found.tsx"
|
|
1674
|
-
]), Rr = (e) => /\.(test|spec)\.tsx$/.test(e), zr = (e) => {
|
|
1667
|
+
}, Wr = gn, Gr = (e) => {
|
|
1675
1668
|
if (/\/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(?:react|react-dom|scheduler)\//.test(e)) return "react";
|
|
1676
1669
|
let t = /\/([^/]+)\.island\.tsx?$/.exec(e);
|
|
1677
1670
|
if (t) return `island-${t[1]}`;
|
|
1678
|
-
},
|
|
1679
|
-
let
|
|
1680
|
-
return
|
|
1681
|
-
},
|
|
1682
|
-
let
|
|
1683
|
-
let
|
|
1671
|
+
}, Kr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, qr = (e) => e.startsWith("(") && e.endsWith(")"), Jr = (e) => e.filter((e) => !qr(e)), Yr = (e) => {
|
|
1672
|
+
let n = e.replace(t, "").split("/").filter(Boolean).filter((e) => !qr(e)), r = n.length > 0 && n[n.length - 1] === "index" ? n.slice(0, -1) : n;
|
|
1673
|
+
return r.length === 0 ? "/" : "/" + r.join("/");
|
|
1674
|
+
}, Xr = (e) => `${e.replace(t, "").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 (n) => {
|
|
1675
|
+
let r = [], i = [], a = async (n, o) => {
|
|
1676
|
+
let s = [];
|
|
1684
1677
|
try {
|
|
1685
|
-
|
|
1678
|
+
s = await j.readdir(n, { withFileTypes: !0 });
|
|
1686
1679
|
} catch {
|
|
1687
1680
|
return;
|
|
1688
1681
|
}
|
|
1689
|
-
let
|
|
1690
|
-
if (
|
|
1691
|
-
let t =
|
|
1682
|
+
let c = s.filter((e) => e.isDirectory()).map((e) => e.name).sort(), l = s.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Wr(e.name)).map((e) => e.name).sort(), u = new Set(l), d = o.join("/");
|
|
1683
|
+
if (l.some((t) => e.has(t))) {
|
|
1684
|
+
let t = u.has("layout.tsx"), r = !1;
|
|
1692
1685
|
if (t) try {
|
|
1693
|
-
let
|
|
1694
|
-
r =
|
|
1686
|
+
let e = await j.readFile(f(n, "layout.tsx"), "utf8");
|
|
1687
|
+
r = Kr.test(e);
|
|
1695
1688
|
} catch {}
|
|
1696
|
-
|
|
1697
|
-
dir:
|
|
1698
|
-
chain:
|
|
1699
|
-
contributesToUrl:
|
|
1689
|
+
i.push({
|
|
1690
|
+
dir: d,
|
|
1691
|
+
chain: o,
|
|
1692
|
+
contributesToUrl: o.length === 0 || !qr(o[o.length - 1]),
|
|
1700
1693
|
hasLayout: t,
|
|
1701
1694
|
hasLayoutLoader: r,
|
|
1702
|
-
hasError:
|
|
1703
|
-
hasPending:
|
|
1704
|
-
hasNotFound:
|
|
1695
|
+
hasError: u.has("error.tsx"),
|
|
1696
|
+
hasPending: u.has("loading.tsx"),
|
|
1697
|
+
hasNotFound: u.has("not-found.tsx"),
|
|
1698
|
+
specialFiles: l.filter((t) => e.has(t))
|
|
1705
1699
|
});
|
|
1706
1700
|
}
|
|
1707
|
-
for (let e of
|
|
1708
|
-
if (
|
|
1709
|
-
let n =
|
|
1710
|
-
|
|
1701
|
+
for (let e of l) {
|
|
1702
|
+
if (!t.test(e)) continue;
|
|
1703
|
+
let n = d ? `${d}/${e}` : e;
|
|
1704
|
+
r.push({
|
|
1711
1705
|
file: n,
|
|
1712
|
-
pattern:
|
|
1713
|
-
ident:
|
|
1714
|
-
dirChain:
|
|
1706
|
+
pattern: Yr(n),
|
|
1707
|
+
ident: Xr(n),
|
|
1708
|
+
dirChain: o
|
|
1715
1709
|
});
|
|
1716
1710
|
}
|
|
1717
|
-
for (let
|
|
1711
|
+
for (let e of c) await a(f(n, e), [...o, e]);
|
|
1718
1712
|
};
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1713
|
+
await a(n, []), r.sort((e, t) => e.file < t.file ? -1 : 1);
|
|
1714
|
+
let o = /* @__PURE__ */ new Set();
|
|
1715
|
+
for (let e of r) for (let t = e.dirChain.length; t >= 0; t--) o.add(e.dirChain.slice(0, t).join("/"));
|
|
1716
|
+
let s = [], c = [];
|
|
1717
|
+
for (let { specialFiles: e, ...t } of i) o.has(t.dir) ? s.push(t) : c.push({
|
|
1718
|
+
dir: t.dir,
|
|
1719
|
+
files: e
|
|
1720
|
+
});
|
|
1721
|
+
return {
|
|
1722
|
+
pages: r,
|
|
1723
|
+
dirs: s,
|
|
1724
|
+
orphanedSpecials: c
|
|
1722
1725
|
};
|
|
1723
|
-
},
|
|
1726
|
+
}, Zr = (e, t) => {
|
|
1724
1727
|
let n = [];
|
|
1725
1728
|
for (let r = 0; r <= t.length; r++) {
|
|
1726
1729
|
let i = t.slice(0, r).join("/"), a = e.find((e) => e.dir === i);
|
|
1727
1730
|
a && n.push(a);
|
|
1728
1731
|
}
|
|
1729
1732
|
return n;
|
|
1730
|
-
},
|
|
1733
|
+
}, Qr = async (e) => {
|
|
1731
1734
|
let { entries: t, loadLayout: n, loadError: r, loadPending: i, ctx: a } = e, o = {};
|
|
1732
1735
|
return {
|
|
1733
1736
|
chain: await Promise.all(t.map(async (e, t) => {
|
|
@@ -1749,10 +1752,10 @@ import {
|
|
|
1749
1752
|
})),
|
|
1750
1753
|
segmentLoaderData: o
|
|
1751
1754
|
};
|
|
1752
|
-
},
|
|
1753
|
-
let t =
|
|
1755
|
+
}, $r = (e) => {
|
|
1756
|
+
let t = Jr(e);
|
|
1754
1757
|
return t.length === 0 ? "" : "/" + t.join("/");
|
|
1755
|
-
},
|
|
1758
|
+
}, ei = [
|
|
1756
1759
|
"// Hot-reload bridge: keep SSR-injected <link rel=\"stylesheet\"> tags",
|
|
1757
1760
|
"// in sync with Vite's CSS HMR. Without this, edits to .css files",
|
|
1758
1761
|
"// only update the JS-injected <style> overlay; the underlying <link>",
|
|
@@ -1845,7 +1848,7 @@ import {
|
|
|
1845
1848
|
" _vdtErrorStart('Build error')",
|
|
1846
1849
|
" })",
|
|
1847
1850
|
"}"
|
|
1848
|
-
].join("\n"),
|
|
1851
|
+
].join("\n"), ti = (e) => {
|
|
1849
1852
|
let t = [], n = 0, r = e.split("/").filter(Boolean), i = [];
|
|
1850
1853
|
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, "\\$&"));
|
|
1851
1854
|
let a = i.join("/");
|
|
@@ -1854,8 +1857,8 @@ import {
|
|
|
1854
1857
|
paramNames: t,
|
|
1855
1858
|
priority: n
|
|
1856
1859
|
};
|
|
1857
|
-
},
|
|
1858
|
-
let { regex: t, paramNames: n, priority: r } =
|
|
1860
|
+
}, ni = (e) => e.map((e) => {
|
|
1861
|
+
let { regex: t, paramNames: n, priority: r } = ti(e.pattern);
|
|
1859
1862
|
return {
|
|
1860
1863
|
pattern: e.pattern,
|
|
1861
1864
|
file: e.file,
|
|
@@ -1864,7 +1867,7 @@ import {
|
|
|
1864
1867
|
paramNames: n,
|
|
1865
1868
|
priority: r
|
|
1866
1869
|
};
|
|
1867
|
-
}).slice().sort((e, t) => e.priority - t.priority),
|
|
1870
|
+
}).slice().sort((e, t) => e.priority - t.priority), ri = (e, t) => {
|
|
1868
1871
|
for (let n of t) {
|
|
1869
1872
|
let t = n.regex.exec(e);
|
|
1870
1873
|
if (!t) continue;
|
|
@@ -1876,30 +1879,30 @@ import {
|
|
|
1876
1879
|
};
|
|
1877
1880
|
}
|
|
1878
1881
|
return null;
|
|
1879
|
-
},
|
|
1882
|
+
}, ii = async (e, t) => {
|
|
1880
1883
|
let n = e;
|
|
1881
1884
|
for (;;) {
|
|
1882
|
-
let e =
|
|
1885
|
+
let e = f(n, "node_modules", t);
|
|
1883
1886
|
try {
|
|
1884
|
-
if ((await
|
|
1885
|
-
let t = await
|
|
1887
|
+
if ((await j.stat(e)).isDirectory()) {
|
|
1888
|
+
let t = await j.realpath(e);
|
|
1886
1889
|
return t.includes("/node_modules/") ? null : t;
|
|
1887
1890
|
}
|
|
1888
1891
|
} catch {}
|
|
1889
|
-
let r =
|
|
1892
|
+
let r = u(n);
|
|
1890
1893
|
if (r === n) return null;
|
|
1891
1894
|
n = r;
|
|
1892
1895
|
}
|
|
1893
|
-
},
|
|
1896
|
+
}, ai = async (e) => {
|
|
1894
1897
|
try {
|
|
1895
|
-
let t = await import(
|
|
1898
|
+
let t = await import(g(f(e, "app.config.ts")).href), n = t.default?.port, r = typeof n == "number" ? n : 4e3, i = t.default?.transport?.wsPath, a = typeof i == "string" && i.startsWith("/") ? i : void 0;
|
|
1896
1899
|
return a ? {
|
|
1897
1900
|
port: r,
|
|
1898
1901
|
wsPath: a
|
|
1899
1902
|
} : { port: r };
|
|
1900
1903
|
} catch {}
|
|
1901
1904
|
return { port: 4e3 };
|
|
1902
|
-
},
|
|
1905
|
+
}, oi = (e, t) => ({
|
|
1903
1906
|
name: e,
|
|
1904
1907
|
pkg: t.package,
|
|
1905
1908
|
browserWsUrl: t.url,
|
|
@@ -1907,7 +1910,7 @@ import {
|
|
|
1907
1910
|
...t.serverUrl ? { serverOrigin: t.serverUrl } : {},
|
|
1908
1911
|
...t.headers ? { headers: t.headers } : {},
|
|
1909
1912
|
...t.authHeaders ? { hasAuthHeaders: !0 } : {}
|
|
1910
|
-
}),
|
|
1913
|
+
}), si = (e, t, n) => {
|
|
1911
1914
|
let r = t.transport?.wsPath ?? n.wsPath;
|
|
1912
1915
|
return {
|
|
1913
1916
|
name: e,
|
|
@@ -1919,7 +1922,7 @@ import {
|
|
|
1919
1922
|
...t.headers ? { headers: t.headers } : {},
|
|
1920
1923
|
...t.authHeaders ? { hasAuthHeaders: !0 } : {}
|
|
1921
1924
|
};
|
|
1922
|
-
},
|
|
1925
|
+
}, ci = (e) => {
|
|
1923
1926
|
let t = /* @__PURE__ */ new Map();
|
|
1924
1927
|
for (let n of e) {
|
|
1925
1928
|
if (n.proxyTarget === void 0) continue;
|
|
@@ -1927,43 +1930,43 @@ import {
|
|
|
1927
1930
|
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>.`);
|
|
1928
1931
|
t.set(n.browserWsUrl, n.name);
|
|
1929
1932
|
}
|
|
1930
|
-
},
|
|
1933
|
+
}, li = async (e, t) => {
|
|
1931
1934
|
let n = Object.entries(t.apis ?? {}), r = [];
|
|
1932
1935
|
for (let [t, i] of n) {
|
|
1933
1936
|
if (i.url) {
|
|
1934
|
-
r.push(
|
|
1937
|
+
r.push(oi(t, i));
|
|
1935
1938
|
continue;
|
|
1936
1939
|
}
|
|
1937
|
-
let n = await
|
|
1940
|
+
let n = await ii(e, i.package);
|
|
1938
1941
|
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.`);
|
|
1939
|
-
r.push(
|
|
1942
|
+
r.push(si(t, i, await ai(n)));
|
|
1940
1943
|
}
|
|
1941
|
-
return
|
|
1942
|
-
},
|
|
1944
|
+
return ci(r), r;
|
|
1945
|
+
}, ui = (e) => {
|
|
1943
1946
|
if (!(!/^wss?:\/\//.test(e) && !/^https?:\/\//.test(e))) try {
|
|
1944
1947
|
let t = new URL(e);
|
|
1945
1948
|
return t.protocol = t.protocol === "wss:" || t.protocol === "https:" ? "https:" : "http:", `${t.protocol}//${t.host}`;
|
|
1946
1949
|
} catch {
|
|
1947
1950
|
return;
|
|
1948
1951
|
}
|
|
1949
|
-
},
|
|
1952
|
+
}, di = (e) => `VOLTRO_API_ORIGIN_${e.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, fi = (e) => process.env[di(e)] ?? process.env.VOLTRO_API_ORIGIN, pi = (e, t) => {
|
|
1950
1953
|
if (!e) return;
|
|
1951
|
-
let n =
|
|
1954
|
+
let n = fi(e.name) ?? e.serverOrigin;
|
|
1952
1955
|
if (n) {
|
|
1953
|
-
let e =
|
|
1956
|
+
let e = ui(n);
|
|
1954
1957
|
if (e) return e;
|
|
1955
1958
|
}
|
|
1956
1959
|
if (t?.allowDevProxy && e.proxyTarget) {
|
|
1957
|
-
let t =
|
|
1960
|
+
let t = ui(e.proxyTarget);
|
|
1958
1961
|
if (t) return t;
|
|
1959
1962
|
}
|
|
1960
|
-
if (!e.proxyTarget && /^wss?:\/\//.test(e.browserWsUrl)) return
|
|
1961
|
-
},
|
|
1963
|
+
if (!e.proxyTarget && /^wss?:\/\//.test(e.browserWsUrl)) return ui(e.browserWsUrl);
|
|
1964
|
+
}, mi = (e, t, n) => {
|
|
1962
1965
|
if (!e) {
|
|
1963
1966
|
if (n?.apiName === void 0) return;
|
|
1964
1967
|
let e = n.apiName;
|
|
1965
1968
|
return async () => {
|
|
1966
|
-
throw Error(`[loader.query] api '${e}' has no server-side origin for SSR. In a split web/api deployment the web pod reaches the api by internal DNS, not the browser's relative wsPath — set ${
|
|
1969
|
+
throw Error(`[loader.query] api '${e}' has no server-side origin for SSR. In a split web/api deployment the web pod reaches the api by internal DNS, not the browser's relative wsPath — set ${di(e)} (or VOLTRO_API_ORIGIN, or apis.${e}.serverUrl in app.config.ts) to the api's internal origin, e.g. http://api.<namespace>.svc.cluster.local. The browser transport is unaffected.`);
|
|
1967
1970
|
};
|
|
1968
1971
|
}
|
|
1969
1972
|
return async (r, i) => {
|
|
@@ -1985,7 +1988,7 @@ import {
|
|
|
1985
1988
|
});
|
|
1986
1989
|
} catch (t) {
|
|
1987
1990
|
let i = t?.cause?.code ?? String(t?.message ?? t);
|
|
1988
|
-
throw Error(`[loader.query] ${r}: could not reach the api at ${e}/rpc (${i}). ${n?.apiName ? `Set ${
|
|
1991
|
+
throw Error(`[loader.query] ${r}: could not reach the api at ${e}/rpc (${i}). ${n?.apiName ? `Set ${di(n.apiName)} / VOLTRO_API_ORIGIN` : "Set the api server origin"} to the api's SSR-reachable origin (internal cluster DNS in a split deployment).`, { cause: t });
|
|
1989
1992
|
}
|
|
1990
1993
|
if (!o.ok) throw Error(`[loader.query] ${r}: HTTP ${o.status} ${await o.text()}`);
|
|
1991
1994
|
let s = await o.json();
|
|
@@ -2003,8 +2006,8 @@ import {
|
|
|
2003
2006
|
}
|
|
2004
2007
|
if (u) return l;
|
|
2005
2008
|
};
|
|
2006
|
-
},
|
|
2007
|
-
let i = t.title ?? t.name ?? "app", a = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", o =
|
|
2009
|
+
}, hi = async (e, t, n, r = {}) => {
|
|
2010
|
+
let i = t.title ?? t.name ?? "app", a = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", o = O(f(e, "node_modules", "@voltro", "devtools", "package.json")) || await Lr() !== null, s = t.theme === "system" ? [
|
|
2008
2011
|
" <script>",
|
|
2009
2012
|
" (function () {",
|
|
2010
2013
|
" var root = document.documentElement",
|
|
@@ -2042,34 +2045,35 @@ import {
|
|
|
2042
2045
|
" </body>",
|
|
2043
2046
|
"</html>",
|
|
2044
2047
|
""
|
|
2045
|
-
].join("\n"),
|
|
2046
|
-
await
|
|
2047
|
-
let
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2048
|
+
].join("\n"), l = f(e, "src", "pages"), { pages: u, dirs: d, orphanedSpecials: p } = await $(l);
|
|
2049
|
+
await Rn(l, u);
|
|
2050
|
+
for (let e of p) Z.warn(`src/pages/${e.dir || "."}/ contains ${e.files.join(", ")} but no *.page.tsx at or below it — ${e.files.length > 1 ? "those files are" : "that file is"} inert. A layout/error/loading/not-found file only applies to routes in its own directory tree; if this is an ordinary component, rename it so it does not read as a route boundary.`);
|
|
2051
|
+
let m = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppGroup`, h = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppDescriptors`, g = n.map((e) => `import { appGroup as ${m(e.name)}, appDescriptors as ${h(e.name)} } from '${e.pkg}/rpcGroup'`);
|
|
2052
|
+
n.some((e) => e.hasAuthHeaders) && (g.push("import __voltroAppConfig from '../app.config'"), g.push("const __voltroAuthHeaders = (__voltroAppConfig as { readonly apis?: Record<string, { readonly authHeaders?: () => Record<string, string> | Promise<Record<string, string>> }> }).apis"));
|
|
2053
|
+
let _ = n.map((e) => {
|
|
2054
|
+
let t = [`group: ${m(e.name)}`];
|
|
2055
|
+
return t.push(`descriptors: ${h(e.name)}`), t.push(`wsUrl: ${JSON.stringify(e.browserWsUrl)}`), e.hasAuthHeaders ? t.push(`headers: __voltroAuthHeaders?.[${JSON.stringify(e.name)}]?.authHeaders`) : e.headers && t.push(`headers: ${JSON.stringify(e.headers)}`), ` ${JSON.stringify(e.name)}: { ${t.join(", ")} },`;
|
|
2056
|
+
}), v, y, b;
|
|
2057
|
+
if (u.length > 0) {
|
|
2058
|
+
let e = u.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
|
|
2059
|
+
for (let e of d) {
|
|
2056
2060
|
let t = e.dir === "" ? "../src/pages" : `../src/pages/${e.dir}`;
|
|
2057
2061
|
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'`);
|
|
2058
2062
|
}
|
|
2059
|
-
let r =
|
|
2060
|
-
let t =
|
|
2063
|
+
let r = u.map((e) => {
|
|
2064
|
+
let t = Zr(d, e.dirChain).map((e) => {
|
|
2061
2065
|
let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
|
|
2062
2066
|
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(", ")} }`;
|
|
2063
2067
|
}).join(",\n");
|
|
2064
2068
|
return ` makePageRoute(${JSON.stringify(e.pattern)}, ${t.length > 0 ? `[\n${t},\n ]` : "undefined"}),`;
|
|
2065
|
-
}), i =
|
|
2066
|
-
let t =
|
|
2069
|
+
}), i = d.filter((e) => e.hasNotFound).map((e) => {
|
|
2070
|
+
let t = $r(e.chain), n = Zr(d, e.chain).map((e) => {
|
|
2067
2071
|
let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
|
|
2068
2072
|
return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), ` { ${t.join(", ")} }`;
|
|
2069
2073
|
}).join(",\n"), r = n.length > 0 ? `\n chain: [\n${n},\n ],` : "";
|
|
2070
2074
|
return ` {\n prefix: ${JSON.stringify(t)},\n Component: refs.notFounds[${JSON.stringify(e.dir)}],${r}\n },`;
|
|
2071
|
-
}), a = [], s = [], c = [], l = [],
|
|
2072
|
-
for (let e of
|
|
2075
|
+
}), a = [], s = [], c = [], l = [], f = [], p = [];
|
|
2076
|
+
for (let e of d) {
|
|
2073
2077
|
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`, o = JSON.stringify(e.dir);
|
|
2074
2078
|
e.hasLayout && e.hasLayoutLoader ? (s.push(` ${o}: ${Q(e.dir, "Layout")}Mod.default,`), c.push(` ${o}: ${Q(e.dir, "Layout")}Mod.loader,`), a.push({
|
|
2075
2079
|
relPath: t,
|
|
@@ -2083,7 +2087,7 @@ import {
|
|
|
2083
2087
|
relPath: n,
|
|
2084
2088
|
kind: "error",
|
|
2085
2089
|
slotKey: e.dir
|
|
2086
|
-
})), e.hasPending && (
|
|
2090
|
+
})), e.hasPending && (f.push(` ${o}: ${Q(e.dir, "Pending")},`), a.push({
|
|
2087
2091
|
relPath: r,
|
|
2088
2092
|
kind: "pending",
|
|
2089
2093
|
slotKey: e.dir
|
|
@@ -2093,12 +2097,12 @@ import {
|
|
|
2093
2097
|
slotKey: e.dir
|
|
2094
2098
|
}));
|
|
2095
2099
|
}
|
|
2096
|
-
for (let e of
|
|
2100
|
+
for (let e of u) a.push({
|
|
2097
2101
|
relPath: `../src/pages/${e.file}`,
|
|
2098
2102
|
kind: "page",
|
|
2099
2103
|
slotKey: e.pattern
|
|
2100
2104
|
});
|
|
2101
|
-
let m = a.map((e) => ` ${JSON.stringify(e.relPath)},`),
|
|
2105
|
+
let m = a.map((e) => ` ${JSON.stringify(e.relPath)},`), h = a.map((e, t) => {
|
|
2102
2106
|
let n = JSON.stringify(e.slotKey);
|
|
2103
2107
|
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 }`;
|
|
2104
2108
|
}), x = t.locales ?? [], S = x.length > 0, C = t.defaultLocale ?? x[0] ?? "en";
|
|
@@ -2109,7 +2113,7 @@ import {
|
|
|
2109
2113
|
"import { useServerRequest } from '@voltro/web'",
|
|
2110
2114
|
...x.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
|
|
2111
2115
|
] : [];
|
|
2112
|
-
|
|
2116
|
+
y = [
|
|
2113
2117
|
"// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
|
|
2114
2118
|
"// Routes + per-page chain + not-found scopes assembled from src/pages/.",
|
|
2115
2119
|
"//",
|
|
@@ -2152,7 +2156,7 @@ import {
|
|
|
2152
2156
|
...l,
|
|
2153
2157
|
" },",
|
|
2154
2158
|
" pendings: {",
|
|
2155
|
-
...
|
|
2159
|
+
...f,
|
|
2156
2160
|
" },",
|
|
2157
2161
|
" notFounds: {",
|
|
2158
2162
|
...p,
|
|
@@ -2224,13 +2228,13 @@ import {
|
|
|
2224
2228
|
" ],",
|
|
2225
2229
|
" (newMods: Array<Record<string, unknown> | undefined>) => {",
|
|
2226
2230
|
" let changed = false",
|
|
2227
|
-
...
|
|
2231
|
+
...h,
|
|
2228
2232
|
" if (changed) bump()",
|
|
2229
2233
|
" },",
|
|
2230
2234
|
" )",
|
|
2231
2235
|
"}",
|
|
2232
2236
|
""
|
|
2233
|
-
].join("\n"),
|
|
2237
|
+
].join("\n"), v = [
|
|
2234
2238
|
"// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
|
|
2235
2239
|
"// The app's root component. It exports `App` and NOTHING ELSE: react-refresh",
|
|
2236
2240
|
"// only accepts a module whose every export is a component, and a module it",
|
|
@@ -2296,20 +2300,20 @@ import {
|
|
|
2296
2300
|
] : [" return <Router routes={routes} notFounds={notFounds} />"],
|
|
2297
2301
|
"}",
|
|
2298
2302
|
""
|
|
2299
|
-
].join("\n"),
|
|
2303
|
+
].join("\n"), b = [
|
|
2300
2304
|
"// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
|
|
2301
2305
|
"// Entry: imports the generated App component and calls mount() with the",
|
|
2302
2306
|
"// resolved apis map. Side-effect only — no local component definitions —",
|
|
2303
2307
|
"// so downstream invalidations (user page edits) terminate at app.tsx.",
|
|
2304
2308
|
"",
|
|
2305
|
-
...
|
|
2309
|
+
...Hr(t),
|
|
2306
2310
|
"import { mount } from '@voltro/web'",
|
|
2307
|
-
...
|
|
2311
|
+
...g,
|
|
2308
2312
|
"import { App } from './app'",
|
|
2309
2313
|
"import { preloadCurrentRoute } from './routeTable'",
|
|
2310
|
-
...
|
|
2311
|
-
...
|
|
2312
|
-
...
|
|
2314
|
+
...Br(t),
|
|
2315
|
+
...Rr(t, o),
|
|
2316
|
+
...Vr(t),
|
|
2313
2317
|
"",
|
|
2314
2318
|
"// Preload the current route's page chunk BEFORE hydration so the first",
|
|
2315
2319
|
"// client render matches the SSG/SSR-prerendered HTML. Without it, a lazy",
|
|
@@ -2324,50 +2328,56 @@ import {
|
|
|
2324
2328
|
"",
|
|
2325
2329
|
"mount(App, {",
|
|
2326
2330
|
" apis: {",
|
|
2327
|
-
...
|
|
2331
|
+
..._,
|
|
2328
2332
|
" },",
|
|
2329
|
-
...
|
|
2333
|
+
...zr(t, o),
|
|
2330
2334
|
"})",
|
|
2331
2335
|
"",
|
|
2332
|
-
|
|
2336
|
+
ei
|
|
2333
2337
|
].join("\n");
|
|
2334
|
-
} else
|
|
2338
|
+
} else v = "", y = "", b = [
|
|
2335
2339
|
"// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
|
|
2336
2340
|
"// The user's root component lives at ../src/App.tsx; this file imports it",
|
|
2337
2341
|
"// and calls mount(). Side-effect only, no component definitions, so the",
|
|
2338
2342
|
"// user's component file remains the Fast Refresh boundary.",
|
|
2339
2343
|
"",
|
|
2340
|
-
...
|
|
2344
|
+
...Hr(t),
|
|
2341
2345
|
"import { mount } from '@voltro/web'",
|
|
2342
|
-
...
|
|
2346
|
+
...g,
|
|
2343
2347
|
"import App from '../src/App'",
|
|
2344
|
-
...
|
|
2345
|
-
...
|
|
2346
|
-
...
|
|
2348
|
+
...Br(t),
|
|
2349
|
+
...Rr(t, o),
|
|
2350
|
+
...Vr(t),
|
|
2347
2351
|
"",
|
|
2348
2352
|
"mount(App, {",
|
|
2349
2353
|
" apis: {",
|
|
2350
|
-
...
|
|
2354
|
+
..._,
|
|
2351
2355
|
" },",
|
|
2352
|
-
...
|
|
2356
|
+
...zr(t, o),
|
|
2353
2357
|
"})",
|
|
2354
2358
|
"",
|
|
2355
|
-
|
|
2359
|
+
ei
|
|
2356
2360
|
].join("\n");
|
|
2357
|
-
let
|
|
2358
|
-
await
|
|
2359
|
-
let
|
|
2361
|
+
let x = f(e, ".framework");
|
|
2362
|
+
await j.mkdir(x, { recursive: !0 }), t.env ? await Qe(x, r) : await j.rm(f(x, "env.public.ts"), { force: !0 }), await j.writeFile(f(x, "index.html"), c, "utf8"), await j.writeFile(f(x, "main.tsx"), b, "utf8"), v ? (await j.writeFile(f(x, "app.tsx"), v, "utf8"), await j.writeFile(f(x, "routeTable.ts"), y, "utf8")) : (await j.rm(f(x, "app.tsx"), { force: !0 }), await j.rm(f(x, "routeTable.ts"), { force: !0 }));
|
|
2363
|
+
let S = f(e, ".gitignore"), C = "";
|
|
2360
2364
|
try {
|
|
2361
|
-
|
|
2365
|
+
C = await j.readFile(S, "utf8");
|
|
2362
2366
|
} catch {}
|
|
2363
|
-
let
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
+
let w = ["/.framework/"], T = new Set(C.split("\n").map((e) => e.trim())), E = w.filter((e) => !T.has(e));
|
|
2368
|
+
if (E.length > 0) {
|
|
2369
|
+
let e = C === "" || C.endsWith("\n") ? "" : "\n";
|
|
2370
|
+
try {
|
|
2371
|
+
await j.appendFile(S, `${e}${E.join("\n")}\n`, "utf8");
|
|
2372
|
+
} catch (e) {
|
|
2373
|
+
Z.warn(`could not add ${E.join(", ")} to ${S} — add it by hand so the generated directory stays out of git. The build is unaffected.`, { reason: e?.message ?? String(e) });
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}, gi = async (e, t) => {
|
|
2367
2377
|
try {
|
|
2368
|
-
let n =
|
|
2369
|
-
if (!
|
|
2370
|
-
let r = await
|
|
2378
|
+
let n = f(u(e), "project.json");
|
|
2379
|
+
if (!O(n)) return;
|
|
2380
|
+
let r = await j.readFile(n, "utf8"), i = JSON.parse(r).apps ?? {}, a = e.split("/").filter(Boolean).pop() ?? "", o = [];
|
|
2371
2381
|
for (let [e, n] of Object.entries(i)) e !== a && n.port === t && o.push(e);
|
|
2372
2382
|
if (o.length === 0) return;
|
|
2373
2383
|
Z.warn("sibling app(s) claim the same port — only one boots", {
|
|
@@ -2376,49 +2386,49 @@ import {
|
|
|
2376
2386
|
projectJson: n
|
|
2377
2387
|
});
|
|
2378
2388
|
} catch {}
|
|
2379
|
-
},
|
|
2380
|
-
let t =
|
|
2389
|
+
}, _i = (e) => f(e, ".framework", "dist", "server", "appConfig.js"), vi = async (e) => {
|
|
2390
|
+
let t = _i(e), n = O(t) ? t : f(e, "app.config.ts");
|
|
2381
2391
|
try {
|
|
2382
|
-
let e = (await import(
|
|
2392
|
+
let e = (await import(g(n).href)).default;
|
|
2383
2393
|
return typeof e == "object" && e && "type" in e && e.type === "web" ? e : null;
|
|
2384
2394
|
} catch {
|
|
2385
2395
|
return null;
|
|
2386
2396
|
}
|
|
2387
|
-
},
|
|
2388
|
-
let
|
|
2389
|
-
if (!
|
|
2397
|
+
}, yi = async (e) => {
|
|
2398
|
+
let t = await vi(e);
|
|
2399
|
+
if (!t) return {
|
|
2390
2400
|
ran: !1,
|
|
2391
2401
|
exitCode: 0
|
|
2392
2402
|
};
|
|
2393
|
-
|
|
2394
|
-
let
|
|
2395
|
-
|
|
2396
|
-
let
|
|
2397
|
-
for (let e of
|
|
2403
|
+
pn();
|
|
2404
|
+
let n = It();
|
|
2405
|
+
Kt(n), Z.info("booting voltro dev (web)", { app: t.name ?? "(unnamed)" });
|
|
2406
|
+
let u = await li(e, t);
|
|
2407
|
+
for (let e of u) Z.info("api wired", {
|
|
2398
2408
|
name: e.name,
|
|
2399
2409
|
pkg: e.pkg,
|
|
2400
2410
|
...e.proxyTarget ? { proxyTo: e.proxyTarget } : { directWs: e.browserWsUrl }
|
|
2401
2411
|
});
|
|
2402
|
-
|
|
2412
|
+
Ve(e).then((e) => {
|
|
2403
2413
|
for (let t of e.files) if (t.action === "created") {
|
|
2404
2414
|
let e = t.path.split("/").pop() ?? t.path;
|
|
2405
2415
|
Z.info(`${e} seeded`, { path: t.path });
|
|
2406
2416
|
}
|
|
2407
2417
|
}).catch(() => {});
|
|
2408
|
-
let { resolved:
|
|
2409
|
-
rawEnv:
|
|
2418
|
+
let { resolved: d } = await $e({
|
|
2419
|
+
rawEnv: t.env,
|
|
2410
2420
|
appType: "web",
|
|
2411
|
-
root:
|
|
2421
|
+
root: e,
|
|
2412
2422
|
log: Z,
|
|
2413
2423
|
generateTypes: !0
|
|
2414
|
-
}), h =
|
|
2415
|
-
await
|
|
2424
|
+
}), h = d.publicValues;
|
|
2425
|
+
await hi(e, t, u, h), Z.debug("generated framework entry files", { files: [
|
|
2416
2426
|
"index.html",
|
|
2417
2427
|
".framework/main.tsx",
|
|
2418
|
-
...
|
|
2428
|
+
...t.env ? [".framework/env.public.ts"] : []
|
|
2419
2429
|
] });
|
|
2420
|
-
let g = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) :
|
|
2421
|
-
await
|
|
2430
|
+
let g = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : t.port ?? 5173, _ = t.name ?? "unnamed", v = Zn("web", _, g), y = ir(_);
|
|
2431
|
+
await Yn({
|
|
2422
2432
|
id: v,
|
|
2423
2433
|
name: _,
|
|
2424
2434
|
kind: "web",
|
|
@@ -2426,19 +2436,19 @@ import {
|
|
|
2426
2436
|
pid: process.pid,
|
|
2427
2437
|
status: "booting",
|
|
2428
2438
|
logFile: y.path
|
|
2429
|
-
}).catch(() => {}), await
|
|
2430
|
-
let { pages: b, dirs: x } = await $(
|
|
2439
|
+
}).catch(() => {}), await gi(e, g);
|
|
2440
|
+
let { pages: b, dirs: x } = await $(f(e, "src", "pages")), S = x.map((e) => ({
|
|
2431
2441
|
dir: e.dir,
|
|
2432
2442
|
hasLayout: e.hasLayout,
|
|
2433
2443
|
hasError: e.hasError,
|
|
2434
2444
|
hasPending: e.hasPending,
|
|
2435
2445
|
hasNotFound: e.hasNotFound
|
|
2436
|
-
})),
|
|
2437
|
-
appRoot:
|
|
2446
|
+
})), C = await Pt({
|
|
2447
|
+
appRoot: e,
|
|
2438
2448
|
pages: b
|
|
2439
2449
|
});
|
|
2440
|
-
|
|
2441
|
-
let
|
|
2450
|
+
C.wrote && Z.debug("routes codegen wrote", { path: p(e, C.path) });
|
|
2451
|
+
let w = await Ke("vite", () => import("vite")), T = (await import("@vitejs/plugin-react")).default, D = (await import("@tailwindcss/vite")).default, k = f(e, ".framework"), A = f(e, "src"), M = /* @__PURE__ */ new Set([
|
|
2442
2452
|
".framework",
|
|
2443
2453
|
"node_modules",
|
|
2444
2454
|
"dist",
|
|
@@ -2448,211 +2458,211 @@ import {
|
|
|
2448
2458
|
".cache"
|
|
2449
2459
|
]), N = {
|
|
2450
2460
|
name: "framework:watch-app-sources",
|
|
2451
|
-
async configureServer(
|
|
2461
|
+
async configureServer(t) {
|
|
2452
2462
|
try {
|
|
2453
|
-
let
|
|
2454
|
-
for (let
|
|
2455
|
-
|
|
2463
|
+
let n = (await j.readdir(e, { withFileTypes: !0 })).filter((e) => e.isDirectory() && !M.has(e.name));
|
|
2464
|
+
for (let r of n) t.watcher.add(f(e, r.name));
|
|
2465
|
+
n.length === 0 && t.watcher.add(A);
|
|
2456
2466
|
} catch {
|
|
2457
|
-
|
|
2467
|
+
t.watcher.add(A);
|
|
2458
2468
|
}
|
|
2459
2469
|
try {
|
|
2460
|
-
let
|
|
2461
|
-
...
|
|
2462
|
-
...
|
|
2470
|
+
let n = await j.readFile(f(e, "package.json"), "utf8"), r = JSON.parse(n), i = Object.keys({
|
|
2471
|
+
...r.dependencies,
|
|
2472
|
+
...r.devDependencies
|
|
2463
2473
|
});
|
|
2464
|
-
await Promise.all(
|
|
2465
|
-
let
|
|
2466
|
-
if (!
|
|
2467
|
-
let
|
|
2474
|
+
await Promise.all(i.map(async (n) => {
|
|
2475
|
+
let r = await ii(e, n);
|
|
2476
|
+
if (!r) return;
|
|
2477
|
+
let i = f(r, "src");
|
|
2468
2478
|
try {
|
|
2469
|
-
(await
|
|
2479
|
+
(await j.stat(i)).isDirectory() && t.watcher.add(i);
|
|
2470
2480
|
} catch {}
|
|
2471
2481
|
}));
|
|
2472
2482
|
} catch {}
|
|
2473
2483
|
}
|
|
2474
|
-
}, P =
|
|
2484
|
+
}, P = f(e, "src", "pages"), ee = (e) => e.endsWith(".tsx") && (e === P || e.startsWith(P + "/")), F = (e) => e === P || e.startsWith(P + "/"), te = async (n) => {
|
|
2475
2485
|
try {
|
|
2476
|
-
let
|
|
2477
|
-
await
|
|
2478
|
-
let { pages:
|
|
2479
|
-
await
|
|
2480
|
-
appRoot:
|
|
2481
|
-
pages:
|
|
2486
|
+
let r = Date.now();
|
|
2487
|
+
await hi(e, t, u, h);
|
|
2488
|
+
let { pages: i } = await $(P);
|
|
2489
|
+
await Pt({
|
|
2490
|
+
appRoot: e,
|
|
2491
|
+
pages: i
|
|
2482
2492
|
}), Z.info("page tree regenerated", {
|
|
2483
|
-
reason:
|
|
2484
|
-
ms: Date.now() -
|
|
2493
|
+
reason: n,
|
|
2494
|
+
ms: Date.now() - r
|
|
2485
2495
|
});
|
|
2486
|
-
} catch (
|
|
2487
|
-
Z.error("page tree regen failed", { reason:
|
|
2496
|
+
} catch (e) {
|
|
2497
|
+
Z.error("page tree regen failed", { reason: n }, e);
|
|
2488
2498
|
}
|
|
2489
2499
|
}, I = {
|
|
2490
2500
|
name: "framework:regenerate-on-page-tree-change",
|
|
2491
|
-
configureServer(
|
|
2492
|
-
let
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
let e =
|
|
2496
|
-
|
|
2501
|
+
configureServer(t) {
|
|
2502
|
+
let n = null, r = [], i = (e) => {
|
|
2503
|
+
r.push(e), n && clearTimeout(n), n = setTimeout(() => {
|
|
2504
|
+
n = null;
|
|
2505
|
+
let e = r.length === 1 ? r[0] : `${r.length} events (${r[0]}, …)`;
|
|
2506
|
+
r.length = 0, te(e);
|
|
2497
2507
|
}, 50);
|
|
2498
2508
|
};
|
|
2499
|
-
|
|
2500
|
-
ee(
|
|
2501
|
-
}),
|
|
2502
|
-
ee(
|
|
2503
|
-
}),
|
|
2504
|
-
F(
|
|
2505
|
-
}),
|
|
2506
|
-
F(
|
|
2509
|
+
t.watcher.on("add", (t) => {
|
|
2510
|
+
ee(t) && i(`add ${p(e, t)}`);
|
|
2511
|
+
}), t.watcher.on("unlink", (t) => {
|
|
2512
|
+
ee(t) && i(`unlink ${p(e, t)}`);
|
|
2513
|
+
}), t.watcher.on("addDir", (t) => {
|
|
2514
|
+
F(t) && i(`addDir ${p(e, t)}`);
|
|
2515
|
+
}), t.watcher.on("unlinkDir", (t) => {
|
|
2516
|
+
F(t) && i(`unlinkDir ${p(e, t)}`);
|
|
2507
2517
|
});
|
|
2508
2518
|
}
|
|
2509
|
-
}, L =
|
|
2510
|
-
if (!
|
|
2519
|
+
}, L = f(e, "app.config.ts"), R = (e) => {
|
|
2520
|
+
if (!le(e.env)) return "";
|
|
2511
2521
|
let t = Object.entries(e.env.vars).map(([e, t]) => `${e}:${t.access}`).sort();
|
|
2512
2522
|
return `${String(e.env.publicPrefix)}|${t.join(",")}`;
|
|
2513
2523
|
}, ne = (e, t) => {
|
|
2514
2524
|
let n = [];
|
|
2515
2525
|
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"), R(e) !== R(t) && n.push("env"), n;
|
|
2516
|
-
}, re =
|
|
2526
|
+
}, re = t, ie = m(L), ae = {
|
|
2517
2527
|
name: "framework:watch-app-config",
|
|
2518
|
-
async configureServer(
|
|
2519
|
-
|
|
2520
|
-
let
|
|
2528
|
+
async configureServer(t) {
|
|
2529
|
+
t.watcher.add(L), Z.info("watching app.config.ts for changes", { path: p(e, L) });
|
|
2530
|
+
let n = async () => {
|
|
2521
2531
|
try {
|
|
2522
2532
|
try {
|
|
2523
|
-
let
|
|
2524
|
-
|
|
2533
|
+
let e = t.moduleGraph.getModuleById(L);
|
|
2534
|
+
e && t.moduleGraph.invalidateModule(e);
|
|
2525
2535
|
} catch {}
|
|
2526
|
-
let
|
|
2527
|
-
return typeof
|
|
2536
|
+
let e = (await t.ssrLoadModule(L, { fixStacktrace: !0 })).default;
|
|
2537
|
+
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);
|
|
2528
2538
|
} catch (e) {
|
|
2529
2539
|
return Z.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
|
|
2530
2540
|
}
|
|
2531
|
-
},
|
|
2532
|
-
|
|
2533
|
-
|
|
2541
|
+
}, r = null, i = () => {
|
|
2542
|
+
r && clearTimeout(r), r = setTimeout(() => {
|
|
2543
|
+
r = null, a();
|
|
2534
2544
|
}, 100);
|
|
2535
|
-
},
|
|
2536
|
-
let
|
|
2537
|
-
if (!
|
|
2545
|
+
}, a = async () => {
|
|
2546
|
+
let r = await n();
|
|
2547
|
+
if (!r) {
|
|
2538
2548
|
Z.info("app.config.ts onConfigChange: load returned null — skipping");
|
|
2539
2549
|
return;
|
|
2540
2550
|
}
|
|
2541
2551
|
if (Z.info("app.config.ts onConfigChange: loaded", {
|
|
2542
|
-
theme:
|
|
2543
|
-
port:
|
|
2544
|
-
name:
|
|
2545
|
-
}), JSON.stringify(
|
|
2552
|
+
theme: r.theme,
|
|
2553
|
+
port: r.port,
|
|
2554
|
+
name: r.name
|
|
2555
|
+
}), JSON.stringify(r) === JSON.stringify(re)) {
|
|
2546
2556
|
Z.info("app.config.ts onConfigChange: parsed config unchanged — skipping (no-op edit?)");
|
|
2547
2557
|
return;
|
|
2548
2558
|
}
|
|
2549
|
-
let
|
|
2550
|
-
if (
|
|
2551
|
-
Z.warn("app.config.ts changed — hard restart required", { fields:
|
|
2559
|
+
let i = ne(re, r);
|
|
2560
|
+
if (i.length > 0) {
|
|
2561
|
+
Z.warn("app.config.ts changed — hard restart required", { fields: i });
|
|
2552
2562
|
try {
|
|
2553
|
-
await
|
|
2563
|
+
await t.close();
|
|
2554
2564
|
} catch {}
|
|
2555
|
-
let
|
|
2565
|
+
let e = ge(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
2556
2566
|
stdio: "inherit",
|
|
2557
2567
|
env: process.env,
|
|
2558
2568
|
cwd: process.cwd()
|
|
2559
|
-
}), n = (
|
|
2560
|
-
|
|
2561
|
-
},
|
|
2562
|
-
process.on("SIGINT",
|
|
2563
|
-
process.off("SIGINT",
|
|
2564
|
-
}),
|
|
2569
|
+
}), n = (t) => {
|
|
2570
|
+
e.kill(t);
|
|
2571
|
+
}, r = () => n("SIGINT"), a = () => n("SIGTERM");
|
|
2572
|
+
process.on("SIGINT", r), process.on("SIGTERM", a), e.on("exit", (e, t) => {
|
|
2573
|
+
process.off("SIGINT", r), process.off("SIGTERM", a), t ? process.kill(process.pid, t) : process.exit(e ?? 0);
|
|
2574
|
+
}), e.on("error", (e) => {
|
|
2565
2575
|
Z.error("restart spawn failed", {}, e), process.exit(1);
|
|
2566
2576
|
});
|
|
2567
2577
|
return;
|
|
2568
2578
|
}
|
|
2569
2579
|
try {
|
|
2570
|
-
let
|
|
2571
|
-
await
|
|
2580
|
+
let n = Date.now();
|
|
2581
|
+
await hi(e, r, await li(e, r)), re = r, t.ws && t.ws.send({
|
|
2572
2582
|
type: "full-reload",
|
|
2573
2583
|
path: "*"
|
|
2574
2584
|
}), Z.info("app.config.ts soft-regen", {
|
|
2575
|
-
ms: Date.now() -
|
|
2585
|
+
ms: Date.now() - n,
|
|
2576
2586
|
reload: "full"
|
|
2577
2587
|
});
|
|
2578
2588
|
} catch (e) {
|
|
2579
2589
|
Z.error("app.config.ts soft-regen failed", {}, e);
|
|
2580
2590
|
}
|
|
2581
|
-
},
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
}),
|
|
2585
|
-
|
|
2591
|
+
}, o = (e) => l(e) === "app.config.ts" ? e === L || m(e) === ie : !1;
|
|
2592
|
+
t.watcher.on("change", (e) => {
|
|
2593
|
+
o(e) && (Z.info("app.config.ts change event (chokidar)", { file: e }), i());
|
|
2594
|
+
}), t.watcher.on("add", (e) => {
|
|
2595
|
+
o(e) && (Z.info("app.config.ts add event (chokidar)", { file: e }), i());
|
|
2586
2596
|
});
|
|
2587
2597
|
try {
|
|
2588
2598
|
let { watchFile: e } = await import("node:fs");
|
|
2589
2599
|
e(L, { interval: 500 }, (e, t) => {
|
|
2590
|
-
e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }),
|
|
2600
|
+
e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), i());
|
|
2591
2601
|
}), Z.info("app.config.ts polling watcher attached", { intervalMs: 500 });
|
|
2592
2602
|
} catch (e) {
|
|
2593
2603
|
Z.warn("app.config.ts polling watcher could not attach", {}, e);
|
|
2594
2604
|
}
|
|
2595
|
-
|
|
2596
|
-
root:
|
|
2597
|
-
onBeforeRestart: () =>
|
|
2605
|
+
ft(lt, Z, {
|
|
2606
|
+
root: e,
|
|
2607
|
+
onBeforeRestart: () => t.close()
|
|
2598
2608
|
});
|
|
2599
2609
|
}
|
|
2600
|
-
}, oe = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/,
|
|
2610
|
+
}, oe = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, se = {
|
|
2601
2611
|
name: "framework:suppress-api-hmr",
|
|
2602
2612
|
handleHotUpdate(e) {
|
|
2603
2613
|
if (oe.test(e.file)) return [];
|
|
2604
2614
|
}
|
|
2605
|
-
},
|
|
2615
|
+
}, ce = {
|
|
2606
2616
|
name: "framework:reoptimize-on-rpcgroup-change",
|
|
2607
|
-
async configureServer(
|
|
2608
|
-
let
|
|
2609
|
-
for (let
|
|
2610
|
-
if (!
|
|
2611
|
-
let
|
|
2612
|
-
if (!
|
|
2613
|
-
let
|
|
2617
|
+
async configureServer(t) {
|
|
2618
|
+
let n = /* @__PURE__ */ new Map();
|
|
2619
|
+
for (let r of u) {
|
|
2620
|
+
if (!r.proxyTarget) continue;
|
|
2621
|
+
let i = await ii(e, r.pkg);
|
|
2622
|
+
if (!i) continue;
|
|
2623
|
+
let a = f(i, "rpcGroup.generated.ts");
|
|
2614
2624
|
try {
|
|
2615
|
-
|
|
2625
|
+
n.set(a, await j.readFile(a, "utf8"));
|
|
2616
2626
|
} catch {
|
|
2617
|
-
|
|
2627
|
+
n.set(a, "");
|
|
2618
2628
|
}
|
|
2619
2629
|
try {
|
|
2620
|
-
|
|
2630
|
+
t.watcher.add(a);
|
|
2621
2631
|
} catch {}
|
|
2622
2632
|
}
|
|
2623
|
-
if (
|
|
2624
|
-
let
|
|
2625
|
-
if (
|
|
2626
|
-
let
|
|
2627
|
-
for (let [e,
|
|
2633
|
+
if (n.size === 0) return;
|
|
2634
|
+
let r = null, i = !1, a = async () => {
|
|
2635
|
+
if (i) return;
|
|
2636
|
+
let r = null;
|
|
2637
|
+
for (let [e, t] of n) {
|
|
2628
2638
|
let i;
|
|
2629
2639
|
try {
|
|
2630
|
-
i = await
|
|
2640
|
+
i = await j.readFile(e, "utf8");
|
|
2631
2641
|
} catch {
|
|
2632
2642
|
continue;
|
|
2633
2643
|
}
|
|
2634
|
-
i !==
|
|
2644
|
+
i !== t && (n.set(e, i), r = e);
|
|
2635
2645
|
}
|
|
2636
|
-
if (
|
|
2637
|
-
|
|
2646
|
+
if (r !== null) {
|
|
2647
|
+
i = !0, Z.info(`rpcGroup changed (${p(e, r)}) — re-bundling the api client + reloading (descriptor edits propagate automatically; no manual restart needed)`);
|
|
2638
2648
|
try {
|
|
2639
|
-
await
|
|
2649
|
+
await j.rm(f(k, ".vite", "deps"), {
|
|
2640
2650
|
recursive: !0,
|
|
2641
2651
|
force: !0
|
|
2642
|
-
}), await
|
|
2652
|
+
}), await t.restart(!0);
|
|
2643
2653
|
} catch (e) {
|
|
2644
|
-
|
|
2654
|
+
i = !1, Z.error("rpcGroup re-optimize failed", {}, e);
|
|
2645
2655
|
}
|
|
2646
2656
|
}
|
|
2647
|
-
},
|
|
2648
|
-
|
|
2649
|
-
|
|
2657
|
+
}, o = (e) => {
|
|
2658
|
+
n.has(m(e)) && (r && clearTimeout(r), r = setTimeout(() => {
|
|
2659
|
+
a();
|
|
2650
2660
|
}, 120));
|
|
2651
2661
|
};
|
|
2652
|
-
|
|
2662
|
+
t.watcher.on("change", o), t.watcher.on("add", o);
|
|
2653
2663
|
}
|
|
2654
2664
|
}, z = {};
|
|
2655
|
-
for (let e of
|
|
2665
|
+
for (let e of u) {
|
|
2656
2666
|
if (!e.proxyTarget) continue;
|
|
2657
2667
|
z[e.browserWsUrl] = {
|
|
2658
2668
|
target: e.proxyTarget,
|
|
@@ -2667,225 +2677,225 @@ import {
|
|
|
2667
2677
|
rewrite: (t) => t.replace(RegExp(`^/_voltro/api/${e.name}`), "")
|
|
2668
2678
|
};
|
|
2669
2679
|
}
|
|
2670
|
-
for (let [e,
|
|
2680
|
+
for (let [e, n] of Object.entries(t.proxies ?? {})) {
|
|
2671
2681
|
if (z[e]) {
|
|
2672
2682
|
Z.warn("user proxy ignored — prefix already claimed by an api ws proxy", { prefix: e });
|
|
2673
2683
|
continue;
|
|
2674
2684
|
}
|
|
2675
2685
|
z[e] = {
|
|
2676
|
-
target:
|
|
2677
|
-
changeOrigin:
|
|
2678
|
-
...
|
|
2679
|
-
}, Z.info(`proxy ${e} → ${
|
|
2686
|
+
target: n.target,
|
|
2687
|
+
changeOrigin: n.changeOrigin ?? !0,
|
|
2688
|
+
...n.rewrite === void 0 ? {} : { rewrite: (t) => t.replace(RegExp(`^${e}`), n.rewrite) }
|
|
2689
|
+
}, Z.info(`proxy ${e} → ${n.target}`, {
|
|
2680
2690
|
prefix: e,
|
|
2681
|
-
target:
|
|
2682
|
-
...
|
|
2691
|
+
target: n.target,
|
|
2692
|
+
...n.rewrite === void 0 ? {} : { rewrite: n.rewrite }
|
|
2683
2693
|
});
|
|
2684
2694
|
}
|
|
2685
2695
|
let ue = {
|
|
2686
2696
|
name: "framework:inspect",
|
|
2687
|
-
configureServer(
|
|
2697
|
+
configureServer(l) {
|
|
2688
2698
|
let u = null, d = async () => {
|
|
2689
2699
|
if (u !== null) return u;
|
|
2690
|
-
let
|
|
2691
|
-
for (let
|
|
2692
|
-
let
|
|
2693
|
-
|
|
2694
|
-
pattern:
|
|
2695
|
-
file:
|
|
2696
|
-
dirChain:
|
|
2697
|
-
renderMode:
|
|
2698
|
-
interactive:
|
|
2699
|
-
tenantAware:
|
|
2700
|
-
revalidateMs:
|
|
2701
|
-
staleWhileRevalidateMs:
|
|
2702
|
-
cacheInvalidatesOn: Array.isArray(
|
|
2703
|
-
hasLoader: typeof
|
|
2704
|
-
hasMeta:
|
|
2705
|
-
hasGetStaticPaths: typeof
|
|
2700
|
+
let t = [];
|
|
2701
|
+
for (let n of b) try {
|
|
2702
|
+
let r = await l.ssrLoadModule(f(e, "src", "pages", n.file));
|
|
2703
|
+
t.push({
|
|
2704
|
+
pattern: n.pattern,
|
|
2705
|
+
file: n.file,
|
|
2706
|
+
dirChain: n.dirChain,
|
|
2707
|
+
renderMode: Nn(r, f("src", "pages", n.file)),
|
|
2708
|
+
interactive: r.interactive ?? "full",
|
|
2709
|
+
tenantAware: r.tenantAware === !0,
|
|
2710
|
+
revalidateMs: J(r.revalidate),
|
|
2711
|
+
staleWhileRevalidateMs: J(r.staleWhileRevalidate) ?? 0,
|
|
2712
|
+
cacheInvalidatesOn: Array.isArray(r.cacheInvalidatesOn) ? r.cacheInvalidatesOn : [],
|
|
2713
|
+
hasLoader: typeof r.loader == "function",
|
|
2714
|
+
hasMeta: r.meta != null,
|
|
2715
|
+
hasGetStaticPaths: typeof r.getStaticPaths == "function"
|
|
2706
2716
|
});
|
|
2707
2717
|
} catch (e) {
|
|
2708
|
-
Z.warn("inspect: failed to load page metadata", { pattern:
|
|
2718
|
+
Z.warn("inspect: failed to load page metadata", { pattern: n.pattern }, e);
|
|
2709
2719
|
}
|
|
2710
|
-
return u =
|
|
2720
|
+
return u = t, t;
|
|
2711
2721
|
};
|
|
2712
|
-
|
|
2713
|
-
let
|
|
2714
|
-
if (
|
|
2715
|
-
let
|
|
2722
|
+
l.middlewares.use((e, t, r) => {
|
|
2723
|
+
let i = e.url ?? "/";
|
|
2724
|
+
if (i.startsWith("/_voltro/inspect") || i.startsWith("/api/dashboard/proxy")) return r();
|
|
2725
|
+
let a = Date.now(), o = t.end.bind(t);
|
|
2716
2726
|
t.end = ((...e) => {
|
|
2717
2727
|
try {
|
|
2718
|
-
|
|
2719
|
-
url:
|
|
2728
|
+
n.emit("request", {
|
|
2729
|
+
url: i.split("?")[0],
|
|
2720
2730
|
status: t.statusCode ?? 0,
|
|
2721
|
-
durationMs: Date.now() -
|
|
2731
|
+
durationMs: Date.now() - a
|
|
2722
2732
|
});
|
|
2723
2733
|
} catch {}
|
|
2724
|
-
return
|
|
2725
|
-
}),
|
|
2726
|
-
}),
|
|
2727
|
-
let
|
|
2734
|
+
return o(...e);
|
|
2735
|
+
}), r();
|
|
2736
|
+
}), t.name === "voltroDashboard" && l.middlewares.use(async (e, t, n) => {
|
|
2737
|
+
let i = e.url ?? "", o = i.split("?")[0];
|
|
2728
2738
|
if (o === "/api/dashboard/proxy") {
|
|
2729
|
-
let
|
|
2730
|
-
if (!
|
|
2731
|
-
|
|
2739
|
+
let n = new URL(i, "http://x").searchParams.get("target");
|
|
2740
|
+
if (!n) {
|
|
2741
|
+
t.statusCode = 400, t.end("missing ?target=");
|
|
2732
2742
|
return;
|
|
2733
2743
|
}
|
|
2734
|
-
if (!n
|
|
2735
|
-
|
|
2744
|
+
if (!a(n)) {
|
|
2745
|
+
t.statusCode = 400, t.end("target not allowed: must be loopback or an origin configured in VOLTRO_DASHBOARD_APPS");
|
|
2736
2746
|
return;
|
|
2737
2747
|
}
|
|
2738
2748
|
try {
|
|
2739
|
-
let
|
|
2740
|
-
|
|
2749
|
+
let i = { accept: String(e.headers.accept ?? "application/json") };
|
|
2750
|
+
e.headers.authorization ? i.authorization = String(e.headers.authorization) : r(n) && process.env.VOLTRO_INSPECT_TOKEN && (i.authorization = `Bearer ${process.env.VOLTRO_INSPECT_TOKEN}`);
|
|
2741
2751
|
let a;
|
|
2742
|
-
if (
|
|
2743
|
-
let
|
|
2744
|
-
for await (let n of
|
|
2745
|
-
a = Buffer.concat(
|
|
2746
|
-
let
|
|
2747
|
-
|
|
2752
|
+
if (e.method && e.method !== "GET" && e.method !== "HEAD") {
|
|
2753
|
+
let t = [];
|
|
2754
|
+
for await (let n of e) t.push(n);
|
|
2755
|
+
a = Buffer.concat(t);
|
|
2756
|
+
let n = e.headers["content-type"];
|
|
2757
|
+
n && (i["content-type"] = Array.isArray(n) ? n[0] : String(n));
|
|
2748
2758
|
}
|
|
2749
|
-
let o = await fetch(
|
|
2759
|
+
let o = await fetch(n, {
|
|
2750
2760
|
redirect: "manual",
|
|
2751
|
-
...
|
|
2752
|
-
headers:
|
|
2761
|
+
...e.method ? { method: e.method } : {},
|
|
2762
|
+
headers: i,
|
|
2753
2763
|
...a && a.length ? { body: new Uint8Array(a.buffer, a.byteOffset, a.byteLength) } : {}
|
|
2754
2764
|
}), s = Buffer.from(await o.arrayBuffer());
|
|
2755
|
-
|
|
2765
|
+
t.statusCode = o.status, t.setHeader("content-type", o.headers.get("content-type") ?? "application/octet-stream"), t.setHeader("content-length", String(s.length)), t.end(s);
|
|
2756
2766
|
} catch (e) {
|
|
2757
|
-
|
|
2767
|
+
t.statusCode = 502, t.end(`proxy error: ${e.message}`);
|
|
2758
2768
|
}
|
|
2759
2769
|
return;
|
|
2760
2770
|
}
|
|
2761
2771
|
if (o === "/api/dashboard/proxy/stream") {
|
|
2762
|
-
let
|
|
2763
|
-
if (!
|
|
2764
|
-
|
|
2772
|
+
let n = new URL(i, "http://x").searchParams.get("target");
|
|
2773
|
+
if (!n) {
|
|
2774
|
+
t.statusCode = 400, t.end("missing ?target=");
|
|
2765
2775
|
return;
|
|
2766
2776
|
}
|
|
2767
|
-
if (!n
|
|
2768
|
-
|
|
2777
|
+
if (!a(n)) {
|
|
2778
|
+
t.statusCode = 400, t.end("target not allowed: must be loopback or an origin configured in VOLTRO_DASHBOARD_APPS");
|
|
2769
2779
|
return;
|
|
2770
2780
|
}
|
|
2771
2781
|
let o = new AbortController();
|
|
2772
|
-
|
|
2782
|
+
e.on("close", () => o.abort()), t.on("close", () => o.abort());
|
|
2773
2783
|
try {
|
|
2774
|
-
let
|
|
2784
|
+
let i = await fetch(n, {
|
|
2775
2785
|
redirect: "manual",
|
|
2776
2786
|
method: "GET",
|
|
2777
2787
|
headers: {
|
|
2778
2788
|
accept: "text/event-stream",
|
|
2779
|
-
...
|
|
2789
|
+
...e.headers.authorization ? { authorization: String(e.headers.authorization) } : r(n) && process.env.VOLTRO_INSPECT_TOKEN ? { authorization: `Bearer ${process.env.VOLTRO_INSPECT_TOKEN}` } : {}
|
|
2780
2790
|
},
|
|
2781
2791
|
signal: o.signal
|
|
2782
2792
|
});
|
|
2783
|
-
if (!
|
|
2784
|
-
|
|
2793
|
+
if (!i.ok || !i.body) {
|
|
2794
|
+
t.statusCode = i.status, t.end(`upstream ${i.status}`);
|
|
2785
2795
|
return;
|
|
2786
2796
|
}
|
|
2787
|
-
|
|
2797
|
+
t.writeHead(200, {
|
|
2788
2798
|
"content-type": "text/event-stream; charset=utf-8",
|
|
2789
2799
|
"cache-control": "no-cache, no-transform",
|
|
2790
2800
|
connection: "keep-alive",
|
|
2791
2801
|
"x-accel-buffering": "no"
|
|
2792
2802
|
});
|
|
2793
|
-
let a =
|
|
2803
|
+
let a = i.body.getReader();
|
|
2794
2804
|
try {
|
|
2795
2805
|
for (;;) {
|
|
2796
|
-
let { done: e, value:
|
|
2806
|
+
let { done: e, value: n } = await a.read();
|
|
2797
2807
|
if (e) break;
|
|
2798
|
-
|
|
2808
|
+
n && t.write(Buffer.from(n));
|
|
2799
2809
|
}
|
|
2800
2810
|
} finally {
|
|
2801
|
-
a.releaseLock(),
|
|
2811
|
+
a.releaseLock(), t.end();
|
|
2802
2812
|
}
|
|
2803
2813
|
} catch (e) {
|
|
2804
|
-
e.name !== "AbortError" && (
|
|
2814
|
+
e.name !== "AbortError" && (t.statusCode = 502, t.end(`proxy stream error: ${e.message}`));
|
|
2805
2815
|
}
|
|
2806
2816
|
return;
|
|
2807
2817
|
}
|
|
2808
|
-
|
|
2809
|
-
}),
|
|
2810
|
-
let
|
|
2811
|
-
if (!
|
|
2812
|
-
let
|
|
2813
|
-
for (let [t, n] of Object.entries(e.headers ?? {})) n !== void 0 && (
|
|
2814
|
-
let
|
|
2815
|
-
if (e.method === "GET" && (
|
|
2816
|
-
let e =
|
|
2817
|
-
|
|
2818
|
-
for (let [t,
|
|
2819
|
-
|
|
2818
|
+
n();
|
|
2819
|
+
}), l.middlewares.use(async (e, r, a) => {
|
|
2820
|
+
let l = e.url ?? "";
|
|
2821
|
+
if (!l.startsWith("/_voltro/inspect")) return a();
|
|
2822
|
+
let u = {};
|
|
2823
|
+
for (let [t, n] of Object.entries(e.headers ?? {})) n !== void 0 && (u[String(t).toLowerCase()] = Array.isArray(n) ? n.join(", ") : String(n));
|
|
2824
|
+
let f = l.split("?")[0];
|
|
2825
|
+
if (e.method === "GET" && (f === "/_voltro/inspect/logs" || l.startsWith("/_voltro/inspect/logs?"))) {
|
|
2826
|
+
let e = c(u.origin), t = on(l, Wt(), u);
|
|
2827
|
+
r.statusCode = t.status, r.setHeader("content-type", t.contentType);
|
|
2828
|
+
for (let [t, n] of Object.entries(e)) r.setHeader(t, n);
|
|
2829
|
+
r.end(t.body);
|
|
2820
2830
|
return;
|
|
2821
2831
|
}
|
|
2822
|
-
if (e.method === "POST" &&
|
|
2823
|
-
let
|
|
2824
|
-
if (
|
|
2825
|
-
|
|
2826
|
-
for (let [e,
|
|
2827
|
-
|
|
2832
|
+
if (e.method === "POST" && f === "/_voltro/inspect/clientLog") {
|
|
2833
|
+
let t = c(u.origin);
|
|
2834
|
+
if (i()) {
|
|
2835
|
+
r.statusCode = 503, r.setHeader("content-type", "application/json");
|
|
2836
|
+
for (let [e, n] of Object.entries(t)) r.setHeader(e, n);
|
|
2837
|
+
r.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
|
|
2828
2838
|
return;
|
|
2829
2839
|
}
|
|
2830
|
-
let
|
|
2840
|
+
let a = "";
|
|
2831
2841
|
e.setEncoding("utf-8"), e.on("data", (e) => {
|
|
2832
|
-
|
|
2842
|
+
a += e;
|
|
2833
2843
|
}), e.on("end", () => {
|
|
2834
|
-
let e =
|
|
2835
|
-
|
|
2836
|
-
for (let [e,
|
|
2837
|
-
|
|
2844
|
+
let e = $t(a, n);
|
|
2845
|
+
r.statusCode = e.status, r.setHeader("content-type", e.contentType);
|
|
2846
|
+
for (let [e, n] of Object.entries(t)) r.setHeader(e, n);
|
|
2847
|
+
r.end(e.body);
|
|
2838
2848
|
}), e.on("error", () => {
|
|
2839
|
-
|
|
2849
|
+
r.statusCode = 400, r.setHeader("content-type", "application/json"), r.end(JSON.stringify({ error: "read failed" }));
|
|
2840
2850
|
});
|
|
2841
2851
|
return;
|
|
2842
2852
|
}
|
|
2843
|
-
if (
|
|
2844
|
-
let
|
|
2845
|
-
if (
|
|
2846
|
-
|
|
2847
|
-
for (let [e,
|
|
2848
|
-
|
|
2853
|
+
if (f === "/_voltro/inspect/stream") {
|
|
2854
|
+
let t = c(u.origin);
|
|
2855
|
+
if (i()) {
|
|
2856
|
+
r.statusCode = 503, r.setHeader("content-type", "application/json");
|
|
2857
|
+
for (let [e, n] of Object.entries(t)) r.setHeader(e, n);
|
|
2858
|
+
r.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
|
|
2849
2859
|
return;
|
|
2850
2860
|
}
|
|
2851
|
-
let
|
|
2852
|
-
if (!
|
|
2853
|
-
|
|
2854
|
-
for (let [e,
|
|
2855
|
-
|
|
2861
|
+
let a = o(u);
|
|
2862
|
+
if (!a.ok) {
|
|
2863
|
+
r.statusCode = 401, r.setHeader("content-type", "application/json");
|
|
2864
|
+
for (let [e, n] of Object.entries(t)) r.setHeader(e, n);
|
|
2865
|
+
r.end(JSON.stringify({
|
|
2856
2866
|
error: "unauthorized",
|
|
2857
|
-
reason:
|
|
2867
|
+
reason: a.reason
|
|
2858
2868
|
}));
|
|
2859
2869
|
return;
|
|
2860
2870
|
}
|
|
2861
|
-
|
|
2862
|
-
for (let [e,
|
|
2863
|
-
|
|
2864
|
-
let
|
|
2865
|
-
if (!(
|
|
2866
|
-
let
|
|
2871
|
+
r.statusCode = 200, r.setHeader("content-type", "text/event-stream; charset=utf-8"), r.setHeader("cache-control", "no-cache, no-transform"), r.setHeader("connection", "keep-alive"), r.setHeader("x-accel-buffering", "no");
|
|
2872
|
+
for (let [e, n] of Object.entries(t)) r.setHeader(e, n);
|
|
2873
|
+
r.flushHeaders?.(), r.write("retry: 5000\n\n");
|
|
2874
|
+
let s = l.indexOf("?");
|
|
2875
|
+
if (!(s !== -1 && new URLSearchParams(l.slice(s + 1)).get("live") === "1")) for (let e of n.buffered()) r.write(Lt(e));
|
|
2876
|
+
let d = n.subscribe((e) => {
|
|
2867
2877
|
try {
|
|
2868
|
-
|
|
2878
|
+
r.write(Lt(e));
|
|
2869
2879
|
} catch {}
|
|
2870
|
-
}),
|
|
2880
|
+
}), f = setInterval(() => {
|
|
2871
2881
|
try {
|
|
2872
|
-
|
|
2882
|
+
r.write(Rt());
|
|
2873
2883
|
} catch {}
|
|
2874
2884
|
}, 15e3), p = () => {
|
|
2875
|
-
clearInterval(
|
|
2885
|
+
clearInterval(f), d();
|
|
2876
2886
|
};
|
|
2877
|
-
e.on("close", p),
|
|
2887
|
+
e.on("close", p), r.on("close", p);
|
|
2878
2888
|
return;
|
|
2879
2889
|
}
|
|
2880
2890
|
try {
|
|
2881
|
-
let
|
|
2891
|
+
let n = s(l, {
|
|
2882
2892
|
kind: "web",
|
|
2883
2893
|
meta: {
|
|
2884
|
-
name:
|
|
2885
|
-
voltroVersion:
|
|
2894
|
+
name: t.name ?? "(unnamed)",
|
|
2895
|
+
voltroVersion: Ir,
|
|
2886
2896
|
port: g,
|
|
2887
2897
|
mode: "dev",
|
|
2888
|
-
apis: Object.entries(
|
|
2898
|
+
apis: Object.entries(t.apis ?? {}).map(([e, t]) => {
|
|
2889
2899
|
let n = {
|
|
2890
2900
|
name: e,
|
|
2891
2901
|
package: t.package
|
|
@@ -2900,58 +2910,58 @@ import {
|
|
|
2900
2910
|
size: 0,
|
|
2901
2911
|
entries: []
|
|
2902
2912
|
}),
|
|
2903
|
-
env: () =>
|
|
2904
|
-
},
|
|
2905
|
-
if (
|
|
2906
|
-
|
|
2907
|
-
for (let [e,
|
|
2908
|
-
|
|
2913
|
+
env: () => tt(t.name ?? "app", { contract: le(t.env) ? t.env : void 0 })
|
|
2914
|
+
}, u, { method: e.method ?? "GET" });
|
|
2915
|
+
if (n === null) return a();
|
|
2916
|
+
r.statusCode = n.status, r.setHeader("content-type", n.contentType);
|
|
2917
|
+
for (let [e, t] of Object.entries(n.headers ?? {})) r.setHeader(e, t);
|
|
2918
|
+
r.end(n.body);
|
|
2909
2919
|
} catch (e) {
|
|
2910
|
-
|
|
2920
|
+
r.statusCode = 500, r.setHeader("content-type", "text/plain"), r.end(`inspect handler error: ${e.message}`);
|
|
2911
2921
|
}
|
|
2912
2922
|
});
|
|
2913
2923
|
}
|
|
2914
|
-
}, de =
|
|
2924
|
+
}, de = t.name === "voltroDashboard" ? {
|
|
2915
2925
|
name: "framework:dashboard-registry",
|
|
2916
2926
|
configureServer(e) {
|
|
2917
2927
|
e.middlewares.use(async (e, t, n) => {
|
|
2918
2928
|
if (!(e.url ?? "").startsWith("/api/dashboard/registry")) return n();
|
|
2919
2929
|
try {
|
|
2920
|
-
let e = await
|
|
2930
|
+
let e = await Jn();
|
|
2921
2931
|
t.statusCode = 200, t.setHeader("content-type", "application/json; charset=utf-8"), t.end(JSON.stringify(e));
|
|
2922
2932
|
} catch (e) {
|
|
2923
2933
|
t.statusCode = 500, t.setHeader("content-type", "text/plain"), t.end(`registry read error: ${e.message}`);
|
|
2924
2934
|
}
|
|
2925
2935
|
});
|
|
2926
2936
|
}
|
|
2927
|
-
} : null, fe =
|
|
2928
|
-
limit:
|
|
2937
|
+
} : null, fe = ni(b), pe = /* @__PURE__ */ new Set(), B = St(), me = wt({
|
|
2938
|
+
limit: B,
|
|
2929
2939
|
onColdStart: (e) => Z.debug("ssr cold-compile start", { id: e }),
|
|
2930
2940
|
onColdEnd: (e) => Z.debug("ssr cold-compile end", { id: e })
|
|
2931
2941
|
});
|
|
2932
|
-
Z.debug(`ssr cold-compile concurrency ${
|
|
2933
|
-
let
|
|
2942
|
+
Z.debug(`ssr cold-compile concurrency ${B}`, { concurrency: B });
|
|
2943
|
+
let V = null, _e = async () => (V === null && (V = await j.readFile(f(e, ".framework", "index.html"), "utf8")), V), ve = {
|
|
2934
2944
|
name: "framework:ssr",
|
|
2935
|
-
configureServer(
|
|
2936
|
-
let
|
|
2937
|
-
|
|
2938
|
-
if (
|
|
2939
|
-
let
|
|
2940
|
-
if (c.startsWith("/@") || c.startsWith("/node_modules/") || c.startsWith("/.framework/") || c.startsWith("/_voltro/") || c === "/main.tsx" || c === "/index.html" || c === "/sw.js" || c === "/favicon.ico" || c === "/robots.txt" || /\.[a-z0-9]+$/i.test(c)) return
|
|
2941
|
-
let
|
|
2942
|
-
if (!
|
|
2943
|
-
let d = !
|
|
2944
|
-
d && Z.info(`ssr compiling ${
|
|
2945
|
-
pattern:
|
|
2945
|
+
configureServer(t) {
|
|
2946
|
+
let n = (e) => me.load(e, async () => await t.ssrLoadModule(e));
|
|
2947
|
+
t.middlewares.use(async (r, i, a) => {
|
|
2948
|
+
if (r.method !== "GET" && r.method !== "HEAD") return a();
|
|
2949
|
+
let o = r.url ?? "/", s = o.indexOf("?"), c = (s === -1 ? o : o.slice(0, s)) || "/";
|
|
2950
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules/") || c.startsWith("/.framework/") || c.startsWith("/_voltro/") || c === "/main.tsx" || c === "/index.html" || c === "/sw.js" || c === "/favicon.ico" || c === "/robots.txt" || /\.[a-z0-9]+$/i.test(c)) return a();
|
|
2951
|
+
let l = ri(c, fe);
|
|
2952
|
+
if (!l) return a();
|
|
2953
|
+
let d = !pe.has(l.route.pattern), p = Date.now();
|
|
2954
|
+
d && Z.info(`ssr compiling ${l.route.pattern}`, {
|
|
2955
|
+
pattern: l.route.pattern,
|
|
2946
2956
|
pathname: c
|
|
2947
2957
|
});
|
|
2948
2958
|
let m = {}, h = async (e, t) => {
|
|
2949
2959
|
let n = Date.now(), r = await t();
|
|
2950
2960
|
return m[e] = (m[e] ?? 0) + (Date.now() - n), r;
|
|
2951
|
-
}, g = async (
|
|
2952
|
-
let i = await
|
|
2953
|
-
if (!(!i || n.has(
|
|
2954
|
-
if (n.add(
|
|
2961
|
+
}, g = async (e, n, r) => {
|
|
2962
|
+
let i = await t.moduleGraph.getModuleById(e);
|
|
2963
|
+
if (!(!i || n.has(e))) {
|
|
2964
|
+
if (n.add(e), i.id && /\.(css|sass|scss|less|stylus|pcss|postcss)(\?|$)/.test(i.id)) {
|
|
2955
2965
|
let e = i.url.replace(/\?.*$/, "");
|
|
2956
2966
|
r.includes(e) || r.push(e);
|
|
2957
2967
|
return;
|
|
@@ -2960,97 +2970,97 @@ import {
|
|
|
2960
2970
|
}
|
|
2961
2971
|
};
|
|
2962
2972
|
try {
|
|
2963
|
-
let
|
|
2964
|
-
if (_ !== "ssr" && _ !== "isr" && !y) return
|
|
2973
|
+
let s = await h("loadPage", async () => await n(f(e, "src", "pages", l.route.file))), _ = Nn(s, f("src", "pages", l.route.file)), v = Zr(x, l.route.dirChain), y = _ === "spa" && v.some((e) => e.hasLayout);
|
|
2974
|
+
if (_ !== "ssr" && _ !== "isr" && !y) return a();
|
|
2965
2975
|
let b = {};
|
|
2966
|
-
for (let [e, t] of Object.entries(
|
|
2967
|
-
let S =
|
|
2968
|
-
|
|
2976
|
+
for (let [e, t] of Object.entries(r.headers ?? {})) typeof t == "string" ? b[e] = t : Array.isArray(t) && (b[e] = t.join(", "));
|
|
2977
|
+
let S = mi(pi(u[0], { allowDevProxy: !0 }), b.cookie, { apiName: u[0]?.name }), C = new AbortController(), w = () => C.abort();
|
|
2978
|
+
i.once("close", w);
|
|
2969
2979
|
let T = null, E = [], D = {};
|
|
2970
2980
|
try {
|
|
2971
|
-
({chain: E, segmentLoaderData: D} = await h("loadChain", () =>
|
|
2981
|
+
(await n("@voltro/web/ssr")).beginStoreSeeds(), {chain: E, segmentLoaderData: D} = await h("loadChain", () => Qr({
|
|
2972
2982
|
entries: v,
|
|
2973
|
-
loadLayout: (
|
|
2974
|
-
loadError: (
|
|
2975
|
-
loadPending: (
|
|
2983
|
+
loadLayout: (t) => n(f(e, "src", "pages", t.dir, "layout.tsx")),
|
|
2984
|
+
loadError: (t) => n(f(e, "src", "pages", t.dir, "error.tsx")),
|
|
2985
|
+
loadPending: (t) => n(f(e, "src", "pages", t.dir, "loading.tsx")),
|
|
2976
2986
|
ctx: {
|
|
2977
|
-
params:
|
|
2987
|
+
params: l.params,
|
|
2978
2988
|
pathname: c,
|
|
2979
2989
|
signal: C.signal,
|
|
2980
2990
|
headers: b,
|
|
2981
2991
|
query: S
|
|
2982
2992
|
}
|
|
2983
|
-
}))
|
|
2984
|
-
let
|
|
2985
|
-
typeof
|
|
2986
|
-
params:
|
|
2993
|
+
}));
|
|
2994
|
+
let t = s.loader;
|
|
2995
|
+
typeof t == "function" && !y && (T = await h("loader", () => t({
|
|
2996
|
+
params: l.params,
|
|
2987
2997
|
pathname: c,
|
|
2988
2998
|
signal: C.signal,
|
|
2989
2999
|
headers: b,
|
|
2990
3000
|
query: S
|
|
2991
3001
|
})));
|
|
2992
3002
|
} finally {
|
|
2993
|
-
|
|
3003
|
+
i.off("close", w);
|
|
2994
3004
|
}
|
|
2995
|
-
let O = await h("loadSsrHelpers", async () => await
|
|
2996
|
-
pattern:
|
|
2997
|
-
Component:
|
|
2998
|
-
meta:
|
|
2999
|
-
loader:
|
|
3000
|
-
ErrorBoundary:
|
|
3001
|
-
Pending:
|
|
3005
|
+
let O = await h("loadSsrHelpers", async () => await n("@voltro/web/ssr")), k = {
|
|
3006
|
+
pattern: l.route.pattern,
|
|
3007
|
+
Component: s.default,
|
|
3008
|
+
meta: s.meta,
|
|
3009
|
+
loader: s.loader,
|
|
3010
|
+
ErrorBoundary: s.ErrorBoundary,
|
|
3011
|
+
Pending: s.Pending,
|
|
3002
3012
|
renderMode: _,
|
|
3003
3013
|
chain: E
|
|
3004
3014
|
}, A = {
|
|
3005
3015
|
cookies: O.parseCookieHeader(b.cookie),
|
|
3006
3016
|
headers: b,
|
|
3007
|
-
url:
|
|
3008
|
-
}, j =
|
|
3017
|
+
url: o
|
|
3018
|
+
}, j = s.interactive ?? "full", M = y ? Cr({
|
|
3009
3019
|
helpers: O,
|
|
3010
|
-
page: `src/pages/${
|
|
3020
|
+
page: `src/pages/${l.route.file}`,
|
|
3011
3021
|
interactive: j,
|
|
3012
3022
|
delivery: "stream",
|
|
3013
3023
|
renderInput: {
|
|
3014
3024
|
descriptor: k,
|
|
3015
|
-
params:
|
|
3025
|
+
params: l.params,
|
|
3016
3026
|
pathname: c,
|
|
3017
3027
|
segmentLoaderData: D,
|
|
3018
3028
|
requestContext: A
|
|
3019
3029
|
}
|
|
3020
|
-
}) : null, N = y ? null :
|
|
3030
|
+
}) : null, N = y ? null : Sr({
|
|
3021
3031
|
helpers: O,
|
|
3022
|
-
page: `src/pages/${
|
|
3032
|
+
page: `src/pages/${l.route.file}`,
|
|
3023
3033
|
pathname: c,
|
|
3024
3034
|
renderMode: _,
|
|
3025
3035
|
interactive: j,
|
|
3026
3036
|
loaderData: T,
|
|
3027
3037
|
segmentLoaderData: D,
|
|
3028
|
-
pageLoaderRan: typeof
|
|
3038
|
+
pageLoaderRan: typeof s.loader == "function"
|
|
3029
3039
|
}), P = [];
|
|
3030
3040
|
await h("collectCss", async () => {
|
|
3031
|
-
let
|
|
3032
|
-
|
|
3033
|
-
...v.flatMap((
|
|
3034
|
-
...
|
|
3035
|
-
...
|
|
3036
|
-
...
|
|
3041
|
+
let t = /* @__PURE__ */ new Set(), n = [
|
|
3042
|
+
f(e, "src", "pages", l.route.file),
|
|
3043
|
+
...v.flatMap((t) => [
|
|
3044
|
+
...t.hasLayout ? [f(e, "src", "pages", t.dir, "layout.tsx")] : [],
|
|
3045
|
+
...t.hasError ? [f(e, "src", "pages", t.dir, "error.tsx")] : [],
|
|
3046
|
+
...t.hasPending ? [f(e, "src", "pages", t.dir, "loading.tsx")] : []
|
|
3037
3047
|
]),
|
|
3038
|
-
|
|
3048
|
+
f(e, ".framework", "main.tsx")
|
|
3039
3049
|
];
|
|
3040
|
-
for (let
|
|
3050
|
+
for (let e of n) await g(e, t, P);
|
|
3041
3051
|
});
|
|
3042
|
-
let ee = await h("readShell",
|
|
3052
|
+
let ee = await h("readShell", _e), F = await h("transformShell", () => t.transformIndexHtml(o, ee)), te = P.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), I = A.cookies["voltro:locale"] ?? "en", L = Date.now();
|
|
3043
3053
|
if (M) {
|
|
3044
|
-
let e = (e) =>
|
|
3054
|
+
let e = (e) => Tr({
|
|
3045
3055
|
helpers: O,
|
|
3046
3056
|
prepared: M,
|
|
3047
3057
|
meta: e,
|
|
3048
3058
|
interactive: j,
|
|
3049
3059
|
extra: [te]
|
|
3050
3060
|
});
|
|
3051
|
-
if (M.hasDeferred)
|
|
3052
|
-
res:
|
|
3053
|
-
shell:
|
|
3061
|
+
if (M.hasDeferred) Pr({
|
|
3062
|
+
res: i,
|
|
3063
|
+
shell: Mr({
|
|
3054
3064
|
shell: F,
|
|
3055
3065
|
inlineModuleScriptsAsync: !0
|
|
3056
3066
|
}),
|
|
@@ -3067,16 +3077,16 @@ import {
|
|
|
3067
3077
|
onShellError: (e) => {
|
|
3068
3078
|
Z.warn("spa-shell-dev shell render failed; falling back to SPA shell", {
|
|
3069
3079
|
pathname: c,
|
|
3070
|
-
pattern:
|
|
3071
|
-
}, e),
|
|
3080
|
+
pattern: l.route.pattern
|
|
3081
|
+
}, e), a();
|
|
3072
3082
|
}
|
|
3073
3083
|
});
|
|
3074
3084
|
else {
|
|
3075
|
-
let t =
|
|
3085
|
+
let t = wr({
|
|
3076
3086
|
helpers: O,
|
|
3077
3087
|
prepared: M
|
|
3078
3088
|
}), n = F.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="${I}"`);
|
|
3079
|
-
|
|
3089
|
+
i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "spa-shell-dev"), i.end(n);
|
|
3080
3090
|
}
|
|
3081
3091
|
} else if (N) {
|
|
3082
3092
|
let e = (e) => [
|
|
@@ -3087,15 +3097,15 @@ import {
|
|
|
3087
3097
|
O.renderRouterStateScript(N.stateInput)
|
|
3088
3098
|
].filter((e) => e.length > 0).join("\n "), t = {
|
|
3089
3099
|
descriptor: k,
|
|
3090
|
-
params:
|
|
3100
|
+
params: l.params,
|
|
3091
3101
|
pathname: c,
|
|
3092
3102
|
loaderData: N.loaderData,
|
|
3093
3103
|
segmentLoaderData: N.segmentLoaderData,
|
|
3094
3104
|
requestContext: A
|
|
3095
3105
|
};
|
|
3096
|
-
if (_ === "ssr" && j === "full")
|
|
3097
|
-
res:
|
|
3098
|
-
shell:
|
|
3106
|
+
if (_ === "ssr" && j === "full") Pr({
|
|
3107
|
+
res: i,
|
|
3108
|
+
shell: Mr({
|
|
3099
3109
|
shell: F,
|
|
3100
3110
|
inlineModuleScriptsAsync: !0
|
|
3101
3111
|
}),
|
|
@@ -3112,142 +3122,142 @@ import {
|
|
|
3112
3122
|
onShellError: (e) => {
|
|
3113
3123
|
Z.warn("ssr-dev shell render failed; falling back to SPA shell", {
|
|
3114
3124
|
pathname: c,
|
|
3115
|
-
pattern:
|
|
3116
|
-
}, e),
|
|
3125
|
+
pattern: l.route.pattern
|
|
3126
|
+
}, e), a();
|
|
3117
3127
|
}
|
|
3118
3128
|
});
|
|
3119
3129
|
else {
|
|
3120
|
-
let { html: n, meta:
|
|
3121
|
-
|
|
3130
|
+
let { html: n, meta: r } = O.renderPageToHtml(t), a = F.replace("<div id=\"root\"></div>", `<div id="root">${n}</div>`).replace("</head>", ` ${e(r)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${I}"`);
|
|
3131
|
+
i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "ssr-dev"), i.end(a);
|
|
3122
3132
|
}
|
|
3123
3133
|
}
|
|
3124
3134
|
m.render = Date.now() - L;
|
|
3125
|
-
let R = Date.now() -
|
|
3126
|
-
d ? (
|
|
3127
|
-
pattern:
|
|
3135
|
+
let R = Date.now() - p;
|
|
3136
|
+
d ? (pe.add(l.route.pattern), Z.info(`ssr compiled ${l.route.pattern} in ${R}ms`, {
|
|
3137
|
+
pattern: l.route.pattern,
|
|
3128
3138
|
pathname: c,
|
|
3129
3139
|
elapsedMs: R,
|
|
3130
3140
|
cold: !0,
|
|
3131
3141
|
phases: m
|
|
3132
3142
|
})) : R > 200 && Z.info(`ssr rendered ${c} in ${R}ms`, {
|
|
3133
|
-
pattern:
|
|
3143
|
+
pattern: l.route.pattern,
|
|
3134
3144
|
pathname: c,
|
|
3135
3145
|
elapsedMs: R,
|
|
3136
3146
|
cold: !1,
|
|
3137
3147
|
phases: m
|
|
3138
3148
|
});
|
|
3139
3149
|
} catch (e) {
|
|
3140
|
-
if (
|
|
3150
|
+
if (xr(e)) {
|
|
3141
3151
|
Z.error("ssr-dev render refused", {
|
|
3142
3152
|
pathname: c,
|
|
3143
|
-
pattern:
|
|
3144
|
-
}, e),
|
|
3153
|
+
pattern: l.route.pattern
|
|
3154
|
+
}, e), i.statusCode = 500, i.setHeader("content-type", "text/plain; charset=utf-8"), i.end(e.message);
|
|
3145
3155
|
return;
|
|
3146
3156
|
}
|
|
3147
3157
|
Z.warn("ssr-dev render failed; falling back to SPA shell", {
|
|
3148
3158
|
pathname: c,
|
|
3149
|
-
pattern:
|
|
3150
|
-
}, e),
|
|
3159
|
+
pattern: l.route.pattern
|
|
3160
|
+
}, e), a();
|
|
3151
3161
|
}
|
|
3152
3162
|
});
|
|
3153
3163
|
}
|
|
3154
|
-
},
|
|
3155
|
-
let
|
|
3156
|
-
for (let
|
|
3157
|
-
if (!
|
|
3158
|
-
let
|
|
3159
|
-
if (
|
|
3160
|
-
|
|
3164
|
+
}, ye = Date.now(), H = w.version ?? "?", U = await Lr(), be = f(e, "node_modules", "@voltro", "ui-shadcn"), W = O(f(be, "package.json")) ? be : null, xe = [], G = await (async () => {
|
|
3165
|
+
let t = [];
|
|
3166
|
+
for (let n of u) {
|
|
3167
|
+
if (!n.proxyTarget) continue;
|
|
3168
|
+
let r = await ii(e, n.pkg);
|
|
3169
|
+
if (r) try {
|
|
3170
|
+
t.push(await j.readFile(f(r, "rpcGroup.generated.ts"), "utf8"));
|
|
3161
3171
|
} catch {}
|
|
3162
3172
|
}
|
|
3163
|
-
if (
|
|
3164
|
-
let
|
|
3173
|
+
if (t.length === 0) return !1;
|
|
3174
|
+
let n = he("sha1").update(t.join("\0")).digest("hex"), r = f(k, ".voltro-rpcgroup-optimize"), i = "";
|
|
3165
3175
|
try {
|
|
3166
|
-
|
|
3176
|
+
i = (await j.readFile(r, "utf8")).trim();
|
|
3167
3177
|
} catch {}
|
|
3168
|
-
if (
|
|
3178
|
+
if (i === n) return !1;
|
|
3169
3179
|
try {
|
|
3170
|
-
await
|
|
3180
|
+
await j.writeFile(r, n);
|
|
3171
3181
|
} catch {}
|
|
3172
3182
|
return !0;
|
|
3173
3183
|
})();
|
|
3174
|
-
|
|
3175
|
-
root:
|
|
3184
|
+
G && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await w.createServer({
|
|
3185
|
+
root: k,
|
|
3176
3186
|
envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
|
|
3177
3187
|
ssr: { noExternal: ["react-intl"] },
|
|
3178
3188
|
resolve: {
|
|
3179
3189
|
dedupe: ["react", "react-dom"],
|
|
3180
3190
|
alias: [
|
|
3181
|
-
...
|
|
3191
|
+
...U ? [{
|
|
3182
3192
|
find: "@voltro/devtools/styles.css",
|
|
3183
|
-
replacement:
|
|
3193
|
+
replacement: f(U, "src/styles.css")
|
|
3184
3194
|
}, {
|
|
3185
3195
|
find: "@voltro/devtools",
|
|
3186
|
-
replacement:
|
|
3196
|
+
replacement: f(U, "src/index.ts")
|
|
3187
3197
|
}] : [],
|
|
3188
|
-
...
|
|
3198
|
+
...W ? [
|
|
3189
3199
|
{
|
|
3190
3200
|
find: "@voltro/ui-shadcn/tokens.css",
|
|
3191
|
-
replacement:
|
|
3201
|
+
replacement: f(W, "src/tokens.css")
|
|
3192
3202
|
},
|
|
3193
3203
|
{
|
|
3194
3204
|
find: "@voltro/ui-shadcn/cn",
|
|
3195
|
-
replacement:
|
|
3205
|
+
replacement: f(W, "src/cn.ts")
|
|
3196
3206
|
},
|
|
3197
3207
|
{
|
|
3198
3208
|
find: "@voltro/ui-shadcn/brand",
|
|
3199
|
-
replacement:
|
|
3209
|
+
replacement: f(W, "src/brand/voltroLogo.tsx")
|
|
3200
3210
|
},
|
|
3201
3211
|
{
|
|
3202
3212
|
find: "@voltro/ui-shadcn",
|
|
3203
|
-
replacement:
|
|
3213
|
+
replacement: f(W, "src/index.ts")
|
|
3204
3214
|
}
|
|
3205
3215
|
] : [],
|
|
3206
|
-
...
|
|
3216
|
+
...We(e)
|
|
3207
3217
|
]
|
|
3208
3218
|
},
|
|
3209
3219
|
optimizeDeps: {
|
|
3210
|
-
include: [...
|
|
3211
|
-
force:
|
|
3220
|
+
include: [...u.map((e) => `${e.pkg}/rpcGroup`), ...xe],
|
|
3221
|
+
force: G
|
|
3212
3222
|
},
|
|
3213
|
-
customLogger:
|
|
3223
|
+
customLogger: xt(),
|
|
3214
3224
|
plugins: [
|
|
3215
|
-
|
|
3225
|
+
Dn(f(e, "src", "pages")),
|
|
3226
|
+
T(),
|
|
3216
3227
|
D(),
|
|
3217
|
-
k(),
|
|
3218
3228
|
N,
|
|
3219
3229
|
I,
|
|
3220
3230
|
ae,
|
|
3231
|
+
se,
|
|
3221
3232
|
ce,
|
|
3222
|
-
le,
|
|
3223
3233
|
ue,
|
|
3224
|
-
|
|
3234
|
+
ve,
|
|
3225
3235
|
...de ? [de] : []
|
|
3226
3236
|
],
|
|
3227
3237
|
server: {
|
|
3228
3238
|
port: g,
|
|
3229
3239
|
strictPort: !0,
|
|
3230
3240
|
host: !0,
|
|
3231
|
-
allowedHosts:
|
|
3241
|
+
allowedHosts: t.allowedHosts === !0 || [...t.allowedHosts ?? []],
|
|
3232
3242
|
proxy: z,
|
|
3233
|
-
fs: { allow: [
|
|
3243
|
+
fs: { allow: [e, ...Ur(e)] }
|
|
3234
3244
|
},
|
|
3235
3245
|
appType: "spa",
|
|
3236
|
-
cacheDir:
|
|
3237
|
-
publicDir:
|
|
3238
|
-
})).listen(),
|
|
3239
|
-
version:
|
|
3240
|
-
bootMs: Date.now() -
|
|
3246
|
+
cacheDir: f(k, ".vite"),
|
|
3247
|
+
publicDir: f(e, "public")
|
|
3248
|
+
})).listen(), Fr.info(`v${H} ready in ${Date.now() - ye}ms`, {
|
|
3249
|
+
version: H,
|
|
3250
|
+
bootMs: Date.now() - ye
|
|
3241
3251
|
}), Z.info(`listening on http://localhost:${g}`, {
|
|
3242
3252
|
port: g,
|
|
3243
|
-
app:
|
|
3253
|
+
app: t.name ?? "(unnamed)"
|
|
3244
3254
|
});
|
|
3245
|
-
for (let e of
|
|
3255
|
+
for (let e of u) e.proxyTarget && (Z.info(`proxy /ws/${e.name} → ${e.proxyTarget}`, {
|
|
3246
3256
|
api: e.name,
|
|
3247
3257
|
target: e.proxyTarget
|
|
3248
3258
|
}), Z.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
|
|
3249
3259
|
try {
|
|
3250
|
-
await
|
|
3260
|
+
await Yn({
|
|
3251
3261
|
id: v,
|
|
3252
3262
|
name: _,
|
|
3253
3263
|
kind: "web",
|
|
@@ -3256,13 +3266,13 @@ import {
|
|
|
3256
3266
|
status: "live",
|
|
3257
3267
|
logFile: y.path
|
|
3258
3268
|
});
|
|
3259
|
-
let
|
|
3260
|
-
if (
|
|
3261
|
-
let
|
|
3262
|
-
|
|
3269
|
+
let t = lr(e);
|
|
3270
|
+
if (t) {
|
|
3271
|
+
let e = await yr({ dashboardAppPath: t });
|
|
3272
|
+
e.status === "launched" ? Z.info(`dashboard launched at http://localhost:${e.port}`, { port: e.port }) : e.status === "already-running" && Z.debug(`dashboard already running on :${e.port}`, { port: e.port });
|
|
3263
3273
|
}
|
|
3264
3274
|
setInterval(() => {
|
|
3265
|
-
|
|
3275
|
+
Yn({
|
|
3266
3276
|
id: v,
|
|
3267
3277
|
name: _,
|
|
3268
3278
|
kind: "web",
|
|
@@ -3272,78 +3282,78 @@ import {
|
|
|
3272
3282
|
logFile: y.path
|
|
3273
3283
|
}).catch(() => {});
|
|
3274
3284
|
}, 1e4).unref();
|
|
3275
|
-
let
|
|
3276
|
-
|
|
3285
|
+
let n = () => {
|
|
3286
|
+
Xn(v), y.dispose();
|
|
3277
3287
|
};
|
|
3278
|
-
process.on("SIGINT",
|
|
3288
|
+
process.on("SIGINT", n), process.on("SIGTERM", n);
|
|
3279
3289
|
} catch (e) {
|
|
3280
3290
|
Z.warn("runtime-registry write failed", {}, e);
|
|
3281
3291
|
}
|
|
3282
|
-
return
|
|
3283
|
-
app:
|
|
3292
|
+
return E({
|
|
3293
|
+
app: t.name ?? "unnamed",
|
|
3284
3294
|
kind: "web",
|
|
3285
3295
|
url: `http://localhost:${g}`,
|
|
3286
|
-
bootMs: Date.now() -
|
|
3296
|
+
bootMs: Date.now() - ye
|
|
3287
3297
|
}), new Promise(() => {});
|
|
3288
|
-
},
|
|
3298
|
+
}, bi = async (e) => {
|
|
3289
3299
|
process.env.NODE_ENV || (process.env.NODE_ENV = "production");
|
|
3290
|
-
let t = await
|
|
3300
|
+
let t = await vi(e);
|
|
3291
3301
|
if (!t) return {
|
|
3292
3302
|
ran: !1,
|
|
3293
3303
|
exitCode: 0
|
|
3294
3304
|
};
|
|
3295
3305
|
let n = Date.now(), r = Z.child("serve");
|
|
3296
3306
|
r.info("booting voltro serve (preview)", { app: t.name ?? "(unnamed)" });
|
|
3297
|
-
let i = await
|
|
3307
|
+
let i = await li(e, t);
|
|
3298
3308
|
for (let e of i) r.info("api wired", {
|
|
3299
3309
|
name: e.name,
|
|
3300
3310
|
pkg: e.pkg
|
|
3301
3311
|
});
|
|
3302
|
-
await
|
|
3312
|
+
await hi(e, t, i);
|
|
3303
3313
|
{
|
|
3304
|
-
let { pages: t } = await $(
|
|
3305
|
-
await
|
|
3314
|
+
let { pages: t } = await $(f(e, "src", "pages"));
|
|
3315
|
+
await Pt({
|
|
3306
3316
|
appRoot: e,
|
|
3307
3317
|
pages: t
|
|
3308
3318
|
});
|
|
3309
3319
|
}
|
|
3310
|
-
let a = t.port ?? 5173, o = await
|
|
3320
|
+
let a = t.port ?? 5173, o = await Ke("vite", () => import("vite")), s = (await import("@vitejs/plugin-react")).default, c = f(e, ".framework");
|
|
3311
3321
|
Z.info("running production build"), await o.build({
|
|
3312
3322
|
root: c,
|
|
3313
3323
|
envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
|
|
3314
3324
|
plugins: [s()],
|
|
3315
|
-
customLogger:
|
|
3325
|
+
customLogger: xt(),
|
|
3316
3326
|
resolve: { dedupe: ["react", "react-dom"] },
|
|
3317
3327
|
build: {
|
|
3318
3328
|
outDir: "dist",
|
|
3319
|
-
rollupOptions: { output: { manualChunks:
|
|
3329
|
+
rollupOptions: { output: { manualChunks: Gr } }
|
|
3320
3330
|
},
|
|
3321
|
-
publicDir:
|
|
3331
|
+
publicDir: f(e, "public")
|
|
3322
3332
|
});
|
|
3323
|
-
let
|
|
3333
|
+
let l = (await o.preview({
|
|
3324
3334
|
root: c,
|
|
3325
3335
|
envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
|
|
3326
3336
|
preview: { port: a },
|
|
3327
3337
|
build: { outDir: "dist" }
|
|
3328
|
-
})).resolvedUrls,
|
|
3338
|
+
})).resolvedUrls, u = l?.local[0] ?? `http://localhost:${a}`, d = l?.local.slice(1).map((e) => ({
|
|
3329
3339
|
label: "Local",
|
|
3330
3340
|
url: e
|
|
3331
3341
|
})) ?? [];
|
|
3332
|
-
return
|
|
3342
|
+
return E({
|
|
3333
3343
|
app: t.name ?? "unnamed",
|
|
3334
3344
|
kind: "preview",
|
|
3335
|
-
url:
|
|
3336
|
-
extras:
|
|
3345
|
+
url: u,
|
|
3346
|
+
extras: d,
|
|
3337
3347
|
bootMs: Date.now() - n
|
|
3338
3348
|
}), new Promise(() => {});
|
|
3339
|
-
},
|
|
3349
|
+
}, xi = 5e3, Si = 6e4, Ci = (e, t) => {
|
|
3340
3350
|
if (e.length === 0) return 0;
|
|
3341
3351
|
if (e.length === 1) return e[0];
|
|
3342
3352
|
let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
|
|
3343
3353
|
if (r === i) return e[r];
|
|
3344
3354
|
let a = n - r;
|
|
3345
3355
|
return e[r] * (1 - a) + e[i] * a;
|
|
3346
|
-
},
|
|
3356
|
+
}, wi = (e) => {
|
|
3347
3357
|
if (e.length === 0) return {
|
|
3348
3358
|
p50: 0,
|
|
3349
3359
|
p95: 0,
|
|
@@ -3355,18 +3365,18 @@ import {
|
|
|
3355
3365
|
let t = e.slice().sort((e, t) => e - t), n = 0;
|
|
3356
3366
|
for (let e of t) n += e;
|
|
3357
3367
|
return {
|
|
3358
|
-
p50:
|
|
3359
|
-
p95:
|
|
3360
|
-
p99:
|
|
3368
|
+
p50: Ci(t, .5),
|
|
3369
|
+
p95: Ci(t, .95),
|
|
3370
|
+
p99: Ci(t, .99),
|
|
3361
3371
|
mean: n / t.length,
|
|
3362
3372
|
min: t[0],
|
|
3363
3373
|
max: t[t.length - 1]
|
|
3364
3374
|
};
|
|
3365
|
-
},
|
|
3366
|
-
let t = e.maxSamples ??
|
|
3375
|
+
}, Ti = (e = {}) => {
|
|
3376
|
+
let t = e.maxSamples ?? xi, n = e.defaultWindowMs ?? Si, r = [];
|
|
3367
3377
|
return {
|
|
3368
3378
|
record(e) {
|
|
3369
|
-
|
|
3379
|
+
R(e), r.push({
|
|
3370
3380
|
...e,
|
|
3371
3381
|
ts: Date.now()
|
|
3372
3382
|
}), r.length > t && r.shift();
|
|
@@ -3392,7 +3402,7 @@ import {
|
|
|
3392
3402
|
tag: e.tag,
|
|
3393
3403
|
count: e.samples.length,
|
|
3394
3404
|
errorCount: n,
|
|
3395
|
-
latencyMs:
|
|
3405
|
+
latencyMs: wi(t)
|
|
3396
3406
|
});
|
|
3397
3407
|
}
|
|
3398
3408
|
return c.sort((e, t) => t.count - e.count), {
|
|
@@ -3405,4 +3415,4 @@ import {
|
|
|
3405
3415
|
};
|
|
3406
3416
|
};
|
|
3407
3417
|
//#endregion
|
|
3408
|
-
export {
|
|
3418
|
+
export { ut as $, Xn as A, dn as B, yr as C, ar as D, ir as E, jn as F, Wt as G, tn as H, Nn as I, Rt as J, Lt as K, gn as L, On as M, Pn as N, Zn as O, kn as P, ft as Q, _n as R, cr as S, rr as T, $t as U, on as V, Kt as W, wt as X, Pt as Y, St as Z, Sr as _, Qr as a, J as at, Tr as b, li as c, $e as ct, Gr as d, Ke as dt, lt as et, $ as f, We as ft, xr as g, W as gt, Pr as h, be as ht, mi as i, rt as it, Yn as j, Jn as k, yi as l, Ze as lt, Mr as m, He as mt, Kr as n, at as nt, Zr as o, tt as ot, hi as p, Ve as pt, It as q, pi as r, ot as rt, vi as s, nt as st, Ti as t, it as tt, bi as u, Xe as ut, Cr as v, lr as w, ur as x, wr as y, vn as z };
|