@powerhousedao/ph-cli 6.2.3-dev.93 → 6.2.3-dev.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-BYl_Uu3s.mjs +4 -0
- package/dist/build-Dfrq_MIX.mjs +2036 -0
- package/dist/build-Dfrq_MIX.mjs.map +1 -0
- package/dist/check-XulH7-hn.mjs +4 -0
- package/dist/check-bEVuToRY.mjs +60 -0
- package/dist/check-bEVuToRY.mjs.map +1 -0
- package/dist/{check-Dmx8U75w.mjs → check-d-VEsSZX.mjs} +4 -4
- package/dist/{check-Dmx8U75w.mjs.map → check-d-VEsSZX.mjs.map} +1 -1
- package/dist/{cli-connect-override-CLHLCeF5.mjs → cli-connect-override-BQr3yjC_.mjs} +4 -4
- package/dist/{cli-connect-override-CLHLCeF5.mjs.map → cli-connect-override-BQr3yjC_.mjs.map} +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/{compound-Cv5yxdLC-DAYAbASE.mjs → compound-DO_mvh0O-D254asEo.mjs} +36 -19
- package/dist/{compound-Cv5yxdLC-DAYAbASE.mjs.map → compound-DO_mvh0O-D254asEo.mjs.map} +1 -1
- package/dist/{connect-build-D20s-YzT.mjs → connect-build-DrKrCMPR.mjs} +8 -7
- package/dist/connect-build-DrKrCMPR.mjs.map +1 -0
- package/dist/{connect-config-CoB5ejxj.mjs → connect-config-DWJf22Ro.mjs} +4 -4
- package/dist/{connect-config-CoB5ejxj.mjs.map → connect-config-DWJf22Ro.mjs.map} +1 -1
- package/dist/{connect-preview-DBcsUnSB.mjs → connect-preview-CdFvlANO.mjs} +5 -4
- package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
- package/dist/{connect-studio-CCjF7Fo2.mjs → connect-studio-DTZEwZ4C.mjs} +3 -3
- package/dist/{connect-studio-DWKRk0Zc.mjs → connect-studio-DWty6fZd.mjs} +4 -4
- package/dist/{connect-studio-DWKRk0Zc.mjs.map → connect-studio-DWty6fZd.mjs.map} +1 -1
- package/dist/definitions-worker.d.mts +96 -0
- package/dist/definitions-worker.d.mts.map +1 -0
- package/dist/definitions-worker.mjs +28 -0
- package/dist/definitions-worker.mjs.map +1 -0
- package/dist/{dist-CF0RfguD.mjs → dist-BOjmQhjX.mjs} +5 -5
- package/dist/dist-BOjmQhjX.mjs.map +1 -0
- package/dist/evidence-BiMKzRLV.mjs +120 -0
- package/dist/evidence-BiMKzRLV.mjs.map +1 -0
- package/dist/{explain-BD6bemOK.mjs → explain-DKS-t7dS.mjs} +5 -5
- package/dist/{explain-BD6bemOK.mjs.map → explain-DKS-t7dS.mjs.map} +1 -1
- package/dist/{export-BiIRQJ7L.mjs → export-DRw3XVfG.mjs} +4 -4
- package/dist/{export-BiIRQJ7L.mjs.map → export-DRw3XVfG.mjs.map} +1 -1
- package/dist/{index-CuWHsoBB.d.mts → external-M25AgDIE.d.mts} +2 -186
- package/dist/external-M25AgDIE.d.mts.map +1 -0
- package/dist/files-D05VjxVj.mjs +350 -0
- package/dist/files-D05VjxVj.mjs.map +1 -0
- package/dist/{generate-all-BWpiTcED.mjs → generate-all-CMpNPpD8.mjs} +4 -4
- package/dist/{generate-all-BWpiTcED.mjs.map → generate-all-CMpNPpD8.mjs.map} +1 -1
- package/dist/{generate-desktop-shell-NeH89X6S.mjs → generate-desktop-shell-B-Rf7ds8.mjs} +4 -4
- package/dist/{generate-desktop-shell-NeH89X6S.mjs.map → generate-desktop-shell-B-Rf7ds8.mjs.map} +1 -1
- package/dist/{generate-document-model-vzFHWp4O.mjs → generate-document-model-DCjzz3Sa.mjs} +4 -4
- package/dist/{generate-document-model-vzFHWp4O.mjs.map → generate-document-model-DCjzz3Sa.mjs.map} +1 -1
- package/dist/{generate-piece-DpFUr1ON.mjs → generate-piece-5Nyr2UZj.mjs} +4 -4
- package/dist/{generate-piece-DpFUr1ON.mjs.map → generate-piece-5Nyr2UZj.mjs.map} +1 -1
- package/dist/{get-version-S4MNTClf.mjs → get-version-qXfoI8qS.mjs} +4 -4
- package/dist/{get-version-S4MNTClf.mjs.map → get-version-qXfoI8qS.mjs.map} +1 -1
- package/dist/index-BdxG1c0H.d.mts +188 -0
- package/dist/index-BdxG1c0H.d.mts.map +1 -0
- package/dist/{inspect-CzjDr590.mjs → inspect-DlRPzee1.mjs} +4 -4
- package/dist/{inspect-CzjDr590.mjs.map → inspect-DlRPzee1.mjs.map} +1 -1
- package/dist/{mcp-TXHDNfgL.mjs → mcp-BSigu-6U.mjs} +4 -4
- package/dist/{mcp-TXHDNfgL.mjs.map → mcp-BSigu-6U.mjs.map} +1 -1
- package/dist/npm-args-g1Tgel4s.mjs +78 -0
- package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
- package/dist/ph-cli-commands-DAqHeYm7.mjs +4 -0
- package/dist/{ph-cli-commands-B2QmvOUS.mjs → ph-cli-commands-XNEhuXzO.mjs} +65 -20
- package/dist/ph-cli-commands-XNEhuXzO.mjs.map +1 -0
- package/dist/render-CTQG4359.mjs +4 -0
- package/dist/{run-C7ExLhAm.mjs → run-DEKE4MJY.mjs} +34 -20
- package/dist/run-DEKE4MJY.mjs.map +1 -0
- package/dist/{run-BiS1kA5W.mjs → run-DP3fNgPv.mjs} +3 -3
- package/dist/{run-sugar-DZjQhZb1.mjs → run-sugar-yf2ggYJ9.mjs} +4 -4
- package/dist/{run-sugar-DZjQhZb1.mjs.map → run-sugar-yf2ggYJ9.mjs.map} +1 -1
- package/dist/runners/connect.d.mts +1 -1
- package/dist/runners/connect.mjs +3 -3
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +1 -1
- package/dist/{schemas-ByfuhvAb.mjs → schemas-ZQiV98u4.mjs} +186 -4
- package/dist/{schemas-ByfuhvAb.mjs.map → schemas-ZQiV98u4.mjs.map} +1 -1
- package/dist/verify-D16BN0dO.mjs +64 -0
- package/dist/verify-D16BN0dO.mjs.map +1 -0
- package/dist/{vetra-s0oeZqMz.mjs → vetra-CdYsxlvS.mjs} +6 -6
- package/dist/{vetra-s0oeZqMz.mjs.map → vetra-CdYsxlvS.mjs.map} +1 -1
- package/package.json +16 -15
- package/dist/build-t5pFQx0f.mjs +0 -304
- package/dist/build-t5pFQx0f.mjs.map +0 -1
- package/dist/build-wvc_NiGr.mjs +0 -4
- package/dist/check-B_uGHUz3.mjs +0 -20
- package/dist/check-B_uGHUz3.mjs.map +0 -1
- package/dist/connect-build-D20s-YzT.mjs.map +0 -1
- package/dist/connect-preview-DBcsUnSB.mjs.map +0 -1
- package/dist/dist-CF0RfguD.mjs.map +0 -1
- package/dist/index-CuWHsoBB.d.mts.map +0 -1
- package/dist/ph-cli-commands-B2QmvOUS.mjs.map +0 -1
- package/dist/ph-cli-commands-B7Lxqvqu.mjs +0 -4
- package/dist/run-C7ExLhAm.mjs.map +0 -1
package/dist/build-t5pFQx0f.mjs
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8bd27820-5036-5c2f-883c-3003ca4a9a6a")}catch(e){}}();
|
|
3
|
-
import { n as OFFERED_ROUTES_MODULE, r as syncProjectConnectRoutes, t as HOST_ROUTES_DIR } from "./sync-connect-routes-t0Slg-P6.mjs";
|
|
4
|
-
import { r as noConnectImports } from "./offered-routes-imports-CalXK9dh.mjs";
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { join, relative, resolve } from "node:path";
|
|
7
|
-
import { execSync } from "node:child_process";
|
|
8
|
-
import { browserEntry, buildBrowserBuildConfig, buildNodeBuildConfig, findBundledSharedDeps } from "@powerhousedao/shared/build-config";
|
|
9
|
-
import { assertPiecesOutDir, buildPieces, createDetectionCache, expandEntryGlobs, externalDependencyVersions, externalDepsPlugin, pieceListPath, planPieces, projectPath, syncDistManifest, undeclaredExternalDependencies } from "@powerhousedao/shared/build-pieces";
|
|
10
|
-
import { localPackageNames, packageStyleEntry, packageStylesheet } from "@powerhousedao/shared/clis/package-style";
|
|
11
|
-
import { EXTERNALIZABLE_SHARED_SPECIFIERS, findSharedImports } from "@powerhousedao/shared/connect";
|
|
12
|
-
import { nodeFileTrace } from "@vercel/nft";
|
|
13
|
-
import { detect, resolveCommand } from "package-manager-detector";
|
|
14
|
-
import { readPackage } from "read-pkg";
|
|
15
|
-
import { build } from "tsdown";
|
|
16
|
-
//#region src/utils/offered-routes-manifest.ts
|
|
17
|
-
function withOfferedRoutes(json, offers) {
|
|
18
|
-
const manifest = JSON.parse(json);
|
|
19
|
-
if (offers ? manifest.connectRoutes === true : !("connectRoutes" in manifest)) return json;
|
|
20
|
-
if (offers) manifest.connectRoutes = true;
|
|
21
|
-
else delete manifest.connectRoutes;
|
|
22
|
-
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
23
|
-
}
|
|
24
|
-
const slashes = (path) => path.replaceAll("\\", "/");
|
|
25
|
-
/** Sets `connectRoutes` in the manifest the package's root module imports,
|
|
26
|
-
* leaving the project's file as it is. */
|
|
27
|
-
function offeredRoutesManifest(projectRoot, offers) {
|
|
28
|
-
const manifestPath = slashes(join(projectRoot, "powerhouse.manifest.json"));
|
|
29
|
-
return {
|
|
30
|
-
name: "ph-offered-routes-manifest",
|
|
31
|
-
transform(code, id) {
|
|
32
|
-
if (slashes(id) !== manifestPath) return null;
|
|
33
|
-
return {
|
|
34
|
-
code: withOfferedRoutes(code, offers),
|
|
35
|
-
map: null
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/** Sets `connectRoutes` in the dist copy of the manifest. */
|
|
41
|
-
function markOfferedRoutes(dir, offers) {
|
|
42
|
-
const manifestPath = join(dir, "powerhouse.manifest.json");
|
|
43
|
-
if (!existsSync(manifestPath)) return;
|
|
44
|
-
const json = readFileSync(manifestPath, "utf-8");
|
|
45
|
-
writeFileSync(manifestPath, withOfferedRoutes(json, offers));
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/services/build.ts
|
|
49
|
-
function createTraceFiles() {
|
|
50
|
-
const cache = {};
|
|
51
|
-
return (file) => traceFile(file, cache);
|
|
52
|
-
}
|
|
53
|
-
async function traceFile(file, cache) {
|
|
54
|
-
const { fileList, reasons } = await nodeFileTrace([file], {
|
|
55
|
-
base: "/",
|
|
56
|
-
cache
|
|
57
|
-
});
|
|
58
|
-
const absolute = (p) => resolve("/", p);
|
|
59
|
-
return {
|
|
60
|
-
fileList: new Set([...fileList].map(absolute)),
|
|
61
|
-
reasons: new Map([...reasons].map(([p, reason]) => [absolute(p), { parents: new Set([...reason.parents].map(absolute)) }]))
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A Powerhouse package's `powerhouse.manifest.json` "name" must match its
|
|
66
|
-
* `package.json` "name" — Connect and the registry resolve installed versions
|
|
67
|
-
* by treating the manifest name as the npm package name, so a mismatch silently
|
|
68
|
-
* breaks resolution. Fail the build early if they diverge. No-op when the
|
|
69
|
-
* project has no manifest (nothing to compare).
|
|
70
|
-
*/
|
|
71
|
-
async function assertManifestNameMatchesPackage(projectPath) {
|
|
72
|
-
const manifestPath = join(projectPath, "powerhouse.manifest.json");
|
|
73
|
-
if (!existsSync(manifestPath)) return;
|
|
74
|
-
const { name: packageName } = await readPackage({ cwd: projectPath });
|
|
75
|
-
let manifestName;
|
|
76
|
-
try {
|
|
77
|
-
manifestName = JSON.parse(readFileSync(manifestPath, "utf-8")).name;
|
|
78
|
-
} catch {
|
|
79
|
-
throw new Error(`Failed to parse "powerhouse.manifest.json" at ${manifestPath}. Make sure it is valid JSON.`);
|
|
80
|
-
}
|
|
81
|
-
if (manifestName !== packageName) throw new Error(`Package name mismatch — "package.json" and "powerhouse.manifest.json" must have the same "name":\n package.json "name": ${JSON.stringify(packageName)}\n powerhouse.manifest.json "name": ${JSON.stringify(manifestName)}\n\nUpdate one so they match, then run the build again.`);
|
|
82
|
-
}
|
|
83
|
-
async function runBuild(args) {
|
|
84
|
-
const { outDir } = args;
|
|
85
|
-
const projectRoot = process.cwd();
|
|
86
|
-
await assertManifestNameMatchesPackage(projectRoot);
|
|
87
|
-
const target = {
|
|
88
|
-
projectRoot,
|
|
89
|
-
outDir,
|
|
90
|
-
pieces: planPieces(projectRoot, outDir)
|
|
91
|
-
};
|
|
92
|
-
assertPiecesOutDir(target);
|
|
93
|
-
const sharedDeps = !args.noSharedDeps;
|
|
94
|
-
const agent = (await detect())?.agent ?? "npm";
|
|
95
|
-
await syncProjectConnectRoutes(projectRoot);
|
|
96
|
-
const offersRoutes = existsSync(join(projectRoot, OFFERED_ROUTES_MODULE));
|
|
97
|
-
const typesOk = emitTypes(agent, outDir, projectRoot);
|
|
98
|
-
if (!typesOk && !args.ignoreTypeErrors) await confirmBuildDespiteTypeErrors();
|
|
99
|
-
const detection = createDetectionCache();
|
|
100
|
-
const trace = createTraceFiles();
|
|
101
|
-
const routesEntry = join(projectRoot, OFFERED_ROUTES_MODULE);
|
|
102
|
-
await build({
|
|
103
|
-
...buildBrowserBuildConfig({
|
|
104
|
-
sharedDeps,
|
|
105
|
-
plugins: [
|
|
106
|
-
externalDepsPlugin(trace, /* @__PURE__ */ new Map(), {
|
|
107
|
-
root: projectRoot,
|
|
108
|
-
browser: true,
|
|
109
|
-
cache: detection
|
|
110
|
-
}),
|
|
111
|
-
offeredRoutesManifest(projectRoot, offersRoutes),
|
|
112
|
-
noConnectImports(routesEntry, join(projectRoot, HOST_ROUTES_DIR))
|
|
113
|
-
]
|
|
114
|
-
}),
|
|
115
|
-
...offersRoutes ? { entry: [...browserEntry, { "connect-routes": routesEntry }] } : {},
|
|
116
|
-
outDir: join(outDir, "browser")
|
|
117
|
-
});
|
|
118
|
-
if (sharedDeps) {
|
|
119
|
-
const imported = findSharedImportsInSources(projectRoot, browserEntry);
|
|
120
|
-
const bundled = findBundledSharedDeps(imported, readDistBrowserFiles(join(outDir, "browser")));
|
|
121
|
-
if (bundled.length > 0) console.warn(`⚠ shared deps bundled instead of externalized: ${bundled.join(", ")} — check your neverBundle config`);
|
|
122
|
-
}
|
|
123
|
-
const external = /* @__PURE__ */ new Map();
|
|
124
|
-
await build({
|
|
125
|
-
...buildNodeBuildConfig({
|
|
126
|
-
sharedDeps,
|
|
127
|
-
plugins: [externalDepsPlugin(trace, external, {
|
|
128
|
-
root: projectRoot,
|
|
129
|
-
ignoreDirs: ["editors"],
|
|
130
|
-
forbidDirs: ["document-models", "scalars"],
|
|
131
|
-
cache: detection
|
|
132
|
-
})]
|
|
133
|
-
}),
|
|
134
|
-
outDir: join(outDir, "node")
|
|
135
|
-
});
|
|
136
|
-
const pkg = await readPackage({ cwd: projectRoot });
|
|
137
|
-
assertExternalDependenciesDeclared(projectRoot, [...external.values()], pkg);
|
|
138
|
-
let built = [];
|
|
139
|
-
if (existsSync(pieceListPath(target))) built = await buildPieces(target, {
|
|
140
|
-
name: pkg.name,
|
|
141
|
-
version: pkg.version,
|
|
142
|
-
license: typeof pkg.license === "string" ? pkg.license : void 0
|
|
143
|
-
}, {
|
|
144
|
-
bundle: build,
|
|
145
|
-
trace,
|
|
146
|
-
cache: detection
|
|
147
|
-
});
|
|
148
|
-
syncDistManifest(target, built, externalDependencyVersions(external.values()));
|
|
149
|
-
markOfferedRoutes(outDir, offersRoutes);
|
|
150
|
-
buildPackageStylesheet(agent, projectRoot, join(outDir, "browser"));
|
|
151
|
-
if (!typesOk) console.warn(`\n${UNSAFE_BUILD_WARNING}`);
|
|
152
|
-
}
|
|
153
|
-
function assertExternalDependenciesDeclared(projectRoot, found, pkg) {
|
|
154
|
-
for (const dep of found) console.log(`${dep.name}@${dep.version} stays external, it needs ${projectPath(projectRoot, dep.file)}`);
|
|
155
|
-
const undeclared = undeclaredExternalDependencies(found, pkg);
|
|
156
|
-
if (undeclared.length === 0) return;
|
|
157
|
-
const lines = undeclared.map((dep) => ` ${dep.name}${dep.importer ? ` (imported by ${projectPath(projectRoot, dep.importer)})` : ""}`);
|
|
158
|
-
throw new Error(`Packages with native addons or WebAssembly modules must be listed in package.json "dependencies", "optionalDependencies" or "peerDependencies":\n${lines.join("\n")}\n\nThey stay external to the build, and installs of this package skip devDependencies.`);
|
|
159
|
-
}
|
|
160
|
-
function declarationsMissing(agent, projectRoot) {
|
|
161
|
-
const showConfig = resolveCommand(agent, "execute-local", ["tsc", "--showConfig"]);
|
|
162
|
-
if (showConfig === null) return false;
|
|
163
|
-
let options;
|
|
164
|
-
try {
|
|
165
|
-
const output = execSync(`${showConfig.command} ${showConfig.args.join(" ")}`, {
|
|
166
|
-
cwd: projectRoot,
|
|
167
|
-
encoding: "utf8",
|
|
168
|
-
stdio: [
|
|
169
|
-
"ignore",
|
|
170
|
-
"pipe",
|
|
171
|
-
"ignore"
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
options = JSON.parse(output).compilerOptions ?? {};
|
|
175
|
-
} catch {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
const dir = options.declarationDir ?? options.outDir;
|
|
179
|
-
if (!dir || !(options.declaration || options.composite)) return false;
|
|
180
|
-
const path = resolve(projectRoot, dir);
|
|
181
|
-
return !existsSync(path) || readdirSync(path).length === 0;
|
|
182
|
-
}
|
|
183
|
-
function emitTypes(agent, outDir, projectRoot) {
|
|
184
|
-
const force = declarationsMissing(agent, projectRoot);
|
|
185
|
-
const tscCommand = resolveCommand(agent, "execute-local", [
|
|
186
|
-
"tsc",
|
|
187
|
-
"--build",
|
|
188
|
-
...force ? ["--force"] : []
|
|
189
|
-
]);
|
|
190
|
-
if (tscCommand === null) {
|
|
191
|
-
console.error("You need to have typescript installed to use the `build` command.");
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
console.log("\n▶ Type-checking and emitting types via tsc...");
|
|
195
|
-
try {
|
|
196
|
-
execSync(`${tscCommand.command} ${tscCommand.args.join(" ")}`, { stdio: "inherit" });
|
|
197
|
-
console.log("✔ Types emitted to", join(outDir, "types"));
|
|
198
|
-
return true;
|
|
199
|
-
} catch {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function buildPackageStylesheet(agent, projectRoot, browserDir) {
|
|
204
|
-
const command = resolveCommand(agent, "execute-local", [
|
|
205
|
-
"tailwindcss",
|
|
206
|
-
"--input",
|
|
207
|
-
"-",
|
|
208
|
-
"--minify"
|
|
209
|
-
]);
|
|
210
|
-
if (command === null) {
|
|
211
|
-
console.error("You need to have tailwindcss installed to use the `build` command.");
|
|
212
|
-
process.exit(1);
|
|
213
|
-
}
|
|
214
|
-
const stylePath = join(projectRoot, "style.css");
|
|
215
|
-
const style = existsSync(stylePath) ? readFileSync(stylePath, "utf-8") : void 0;
|
|
216
|
-
const compiled = execSync(`${command.command} ${command.args.join(" ")}`, {
|
|
217
|
-
cwd: projectRoot,
|
|
218
|
-
input: packageStyleEntry(style, {
|
|
219
|
-
browserDir: sourcePath(projectRoot, browserDir),
|
|
220
|
-
localPackages: localPackageNames(projectRoot)
|
|
221
|
-
}),
|
|
222
|
-
encoding: "utf-8",
|
|
223
|
-
stdio: [
|
|
224
|
-
"pipe",
|
|
225
|
-
"pipe",
|
|
226
|
-
"inherit"
|
|
227
|
-
],
|
|
228
|
-
maxBuffer: 67108864
|
|
229
|
-
});
|
|
230
|
-
mkdirSync(join(projectRoot, "dist"), { recursive: true });
|
|
231
|
-
writeFileSync(join(projectRoot, "dist/style.css"), packageStylesheet(compiled));
|
|
232
|
-
}
|
|
233
|
-
function sourcePath(projectRoot, path) {
|
|
234
|
-
return `./${relative(projectRoot, resolve(projectRoot, path)).replaceAll("\\", "/")}`;
|
|
235
|
-
}
|
|
236
|
-
function isInteractive() {
|
|
237
|
-
return Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
238
|
-
}
|
|
239
|
-
const TYPE_ERROR_RISK = "A package built with type errors can load and still fail at runtime.";
|
|
240
|
-
const UNSAFE_BUILD_WARNING = "⚠ Built despite type errors. " + TYPE_ERROR_RISK + " Fix them before you publish or deploy it.";
|
|
241
|
-
async function confirmBuildDespiteTypeErrors() {
|
|
242
|
-
const hint = "Fix them and build again. --ignore-type-errors skips this check, at the risk of shipping that failure.";
|
|
243
|
-
if (!isInteractive()) {
|
|
244
|
-
console.error(`\n✘ tsc reported the type errors above. ${TYPE_ERROR_RISK}\n${hint}`);
|
|
245
|
-
process.exit(1);
|
|
246
|
-
}
|
|
247
|
-
const enquirer = await import("enquirer");
|
|
248
|
-
let confirmed;
|
|
249
|
-
try {
|
|
250
|
-
confirmed = (await enquirer.default.prompt({
|
|
251
|
-
type: "confirm",
|
|
252
|
-
name: "confirmed",
|
|
253
|
-
message: `tsc reported the type errors above. ${TYPE_ERROR_RISK} Build anyway?`,
|
|
254
|
-
initial: false
|
|
255
|
-
})).confirmed;
|
|
256
|
-
} catch {
|
|
257
|
-
confirmed = false;
|
|
258
|
-
}
|
|
259
|
-
if (!confirmed) {
|
|
260
|
-
console.error(`Build cancelled. ${hint}`);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Every shared specifier imported from the entry sources; the post-build
|
|
266
|
-
* scan compares these against the built output.
|
|
267
|
-
*
|
|
268
|
-
* Scoped to the specifiers the build actually externalizes: a specifier the
|
|
269
|
-
* vendor does not publish (the bare `@powerhousedao/shared` root, an
|
|
270
|
-
* unvendored subpath) is deliberately bundled, so reporting it as "bundled
|
|
271
|
-
* instead of externalized" would be a false alarm.
|
|
272
|
-
*/
|
|
273
|
-
function findSharedImportsInSources(root, globs) {
|
|
274
|
-
const found = /* @__PURE__ */ new Set();
|
|
275
|
-
for (const file of expandEntryGlobs(root, globs)) {
|
|
276
|
-
const src = readFileSync(file, "utf8");
|
|
277
|
-
for (const spec of findSharedImports(src, EXTERNALIZABLE_SHARED_SPECIFIERS)) found.add(spec);
|
|
278
|
-
}
|
|
279
|
-
return [...found].sort();
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* The built JS outputs of a browser build (entry files and chunks).
|
|
283
|
-
*/
|
|
284
|
-
function readDistBrowserFiles(dir) {
|
|
285
|
-
const out = [];
|
|
286
|
-
if (!existsSync(dir)) return out;
|
|
287
|
-
const walk = (d) => {
|
|
288
|
-
for (const e of readdirSync(d, { withFileTypes: true })) {
|
|
289
|
-
const p = join(d, e.name);
|
|
290
|
-
if (e.isDirectory()) walk(p);
|
|
291
|
-
else if (e.isFile() && e.name.endsWith(".js")) out.push({
|
|
292
|
-
path: p,
|
|
293
|
-
content: readFileSync(p, "utf8")
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
walk(dir);
|
|
298
|
-
return out;
|
|
299
|
-
}
|
|
300
|
-
//#endregion
|
|
301
|
-
export { runBuild as i, assertManifestNameMatchesPackage as n, createTraceFiles as r, assertExternalDependenciesDeclared as t };
|
|
302
|
-
|
|
303
|
-
//# sourceMappingURL=build-t5pFQx0f.mjs.map
|
|
304
|
-
//# debugId=8bd27820-5036-5c2f-883c-3003ca4a9a6a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-t5pFQx0f.mjs","sources":["../src/utils/offered-routes-manifest.ts","../src/services/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// The manifest with `connectRoutes` set when the package offers routes; as it\n// is, byte for byte, when the flag is already right.\nfunction withOfferedRoutes(json: string, offers: boolean) {\n const manifest = JSON.parse(json) as { connectRoutes?: boolean };\n if (offers ? manifest.connectRoutes === true : !(\"connectRoutes\" in manifest))\n return json;\n if (offers) manifest.connectRoutes = true;\n else delete manifest.connectRoutes;\n return `${JSON.stringify(manifest, null, 2)}\\n`;\n}\n\nconst slashes = (path: string) => path.replaceAll(\"\\\\\", \"/\");\n\n/** Sets `connectRoutes` in the manifest the package's root module imports,\n * leaving the project's file as it is. */\nexport function offeredRoutesManifest(projectRoot: string, offers: boolean) {\n // Vite's ids use forward slashes on Windows too.\n const manifestPath = slashes(join(projectRoot, \"powerhouse.manifest.json\"));\n return {\n name: \"ph-offered-routes-manifest\",\n transform(code: string, id: string) {\n if (slashes(id) !== manifestPath) return null;\n return { code: withOfferedRoutes(code, offers), map: null };\n },\n };\n}\n\n/** Sets `connectRoutes` in the dist copy of the manifest. */\nexport function markOfferedRoutes(dir: string, offers: boolean) {\n const manifestPath = join(dir, \"powerhouse.manifest.json\");\n if (!existsSync(manifestPath)) return;\n const json = readFileSync(manifestPath, \"utf-8\");\n writeFileSync(manifestPath, withOfferedRoutes(json, offers));\n}\n","import {\n browserEntry,\n buildBrowserBuildConfig,\n buildNodeBuildConfig,\n findBundledSharedDeps,\n} from \"@powerhousedao/shared/build-config\";\nimport type {\n BuiltPiece,\n ExternalDependency,\n TraceFiles,\n} from \"@powerhousedao/shared/build-pieces\";\nimport {\n assertPiecesOutDir,\n buildPieces,\n expandEntryGlobs,\n createDetectionCache,\n externalDependencyVersions,\n projectPath,\n externalDepsPlugin,\n pieceListPath,\n planPieces,\n syncDistManifest,\n undeclaredExternalDependencies,\n} from \"@powerhousedao/shared/build-pieces\";\nimport {\n localPackageNames,\n packageStyleEntry,\n packageStylesheet,\n} from \"@powerhousedao/shared/clis/package-style\";\nimport {\n findSharedImports,\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n} from \"@powerhousedao/shared/connect\";\nimport { execSync } from \"node:child_process\";\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, relative, resolve } from \"node:path\";\nimport { nodeFileTrace } from \"@vercel/nft\";\nimport { detect, resolveCommand, type Agent } from \"package-manager-detector\";\nimport { readPackage } from \"read-pkg\";\nimport { build as tsdownBuild } from \"tsdown\";\nimport type { BuildArgs } from \"../types.js\";\nimport { noConnectImports } from \"../utils/offered-routes-imports.js\";\nimport {\n markOfferedRoutes,\n offeredRoutesManifest,\n} from \"../utils/offered-routes-manifest.js\";\nimport {\n HOST_ROUTES_DIR,\n OFFERED_ROUTES_MODULE,\n syncProjectConnectRoutes,\n} from \"../utils/sync-connect-routes.js\";\n\n// nft reports paths relative to its base; from \"/\" that is every path minus its root.\n// One cache per build: the traces of a project's packages share most files.\nexport function createTraceFiles(): TraceFiles {\n const cache = {};\n return (file) => traceFile(file, cache);\n}\n\nexport const traceFiles: TraceFiles = createTraceFiles();\n\nasync function traceFile(file: string, cache: object) {\n const { fileList, reasons } = await nodeFileTrace([file], {\n base: \"/\",\n cache,\n });\n const absolute = (p: string) => resolve(\"/\", p);\n return {\n fileList: new Set([...fileList].map(absolute)),\n reasons: new Map(\n [...reasons].map(([p, reason]) => [\n absolute(p),\n { parents: new Set([...reason.parents].map(absolute)) },\n ]),\n ),\n };\n}\n\n/**\n * A Powerhouse package's `powerhouse.manifest.json` \"name\" must match its\n * `package.json` \"name\" — Connect and the registry resolve installed versions\n * by treating the manifest name as the npm package name, so a mismatch silently\n * breaks resolution. Fail the build early if they diverge. No-op when the\n * project has no manifest (nothing to compare).\n */\nexport async function assertManifestNameMatchesPackage(projectPath: string) {\n const manifestPath = join(projectPath, \"powerhouse.manifest.json\");\n if (!existsSync(manifestPath)) return;\n\n const { name: packageName } = await readPackage({ cwd: projectPath });\n\n let manifestName: unknown;\n try {\n manifestName = (\n JSON.parse(readFileSync(manifestPath, \"utf-8\")) as { name?: unknown }\n ).name;\n } catch {\n throw new Error(\n `Failed to parse \"powerhouse.manifest.json\" at ${manifestPath}. Make sure it is valid JSON.`,\n );\n }\n\n if (manifestName !== packageName) {\n throw new Error(\n `Package name mismatch — \"package.json\" and \"powerhouse.manifest.json\" must have the same \"name\":\\n` +\n ` package.json \"name\": ${JSON.stringify(packageName)}\\n` +\n ` powerhouse.manifest.json \"name\": ${JSON.stringify(manifestName)}\\n\\n` +\n `Update one so they match, then run the build again.`,\n );\n }\n}\n\nexport async function runBuild(args: BuildArgs) {\n const { outDir } = args;\n const projectRoot = process.cwd();\n\n // Fail fast if the manifest name and package.json name have drifted apart.\n await assertManifestNameMatchesPackage(projectRoot);\n\n const target = {\n projectRoot,\n outDir,\n pieces: planPieces(projectRoot, outDir),\n };\n // Before any bundler runs: an out-dir a host will never read from is worth\n // nothing built, and the failure names what the contract is.\n assertPiecesOutDir(target);\n const sharedDeps = !args.noSharedDeps;\n\n const detectResult = await detect();\n const agent = detectResult?.agent ?? \"npm\";\n\n // Project routes type-check against the tree generated from them.\n await syncProjectConnectRoutes(projectRoot);\n // Connect reads the manifest's flag to load the package's routes.\n const offersRoutes = existsSync(join(projectRoot, OFFERED_ROUTES_MODULE));\n\n // Before any bundler runs, so declining leaves nothing half built.\n const typesOk = emitTypes(agent, outDir, projectRoot);\n if (!typesOk && !args.ignoreTypeErrors) {\n await confirmBuildDespiteTypeErrors();\n }\n\n // Shared by the browser, node and piece builds: nothing is traced twice.\n const detection = createDetectionCache();\n const trace = createTraceFiles();\n const routesEntry = join(projectRoot, OFFERED_ROUTES_MODULE);\n // Everything in the browser build is code Connect can load: native fails it.\n await tsdownBuild({\n ...buildBrowserBuildConfig({\n sharedDeps,\n plugins: [\n externalDepsPlugin(trace, new Map(), {\n root: projectRoot,\n browser: true,\n cache: detection,\n }),\n offeredRoutesManifest(projectRoot, offersRoutes),\n noConnectImports(routesEntry, join(projectRoot, HOST_ROUTES_DIR)),\n ],\n }),\n // The offered routes in the package's build: a module both import is one\n // chunk, which other Connects evaluate once. Absolute: a relative entry\n // is a glob, and globs skip `.ph`.\n ...(offersRoutes\n ? { entry: [...browserEntry, { \"connect-routes\": routesEntry }] }\n : {}),\n outDir: join(outDir, \"browser\"),\n });\n\n // Advisory: a shared dep the source imports but the output no longer\n // references as a bare import was inlined despite the external set.\n if (sharedDeps) {\n const imported = findSharedImportsInSources(projectRoot, browserEntry);\n const bundled = findBundledSharedDeps(\n imported,\n readDistBrowserFiles(join(outDir, \"browser\")),\n );\n if (bundled.length > 0) {\n console.warn(\n `⚠ shared deps bundled instead of externalized: ${bundled.join(\", \")} — check your neverBundle config`,\n );\n }\n }\n\n const external = new Map<string, ExternalDependency>();\n await tsdownBuild({\n ...buildNodeBuildConfig({\n sharedDeps,\n plugins: [\n // Editors never run on a host; document models and scalars run in Connect too.\n externalDepsPlugin(trace, external, {\n root: projectRoot,\n ignoreDirs: [\"editors\"],\n forbidDirs: [\"document-models\", \"scalars\"],\n cache: detection,\n }),\n ],\n }),\n outDir: join(outDir, \"node\"),\n });\n const pkg = await readPackage({ cwd: projectRoot });\n assertExternalDependenciesDeclared(projectRoot, [...external.values()], pkg);\n\n // After the node build: it cleans <outDir>/node, where the pieces land. The\n // built list is the gate, so a `bundle:` entry is validated with no piece dir.\n let built: BuiltPiece[] = [];\n if (existsSync(pieceListPath(target))) {\n built = await buildPieces(\n target,\n {\n name: pkg.name,\n version: pkg.version,\n license: typeof pkg.license === \"string\" ? pkg.license : undefined,\n },\n { bundle: tsdownBuild, trace, cache: detection },\n );\n }\n syncDistManifest(\n target,\n built,\n externalDependencyVersions(external.values()),\n );\n markOfferedRoutes(outDir, offersRoutes);\n\n buildPackageStylesheet(agent, projectRoot, join(outDir, \"browser\"));\n\n // Last, so it is the line a finished build leaves on screen.\n if (!typesOk) console.warn(`\\n${UNSAFE_BUILD_WARNING}`);\n}\n\n// A package with a native addon or WebAssembly module stays external, so the\n// package's consumers must install it: devDependencies are skipped by every install.\nexport function assertExternalDependenciesDeclared(\n projectRoot: string,\n found: ExternalDependency[],\n pkg: Parameters<typeof undeclaredExternalDependencies>[1],\n) {\n for (const dep of found) {\n console.log(\n `${dep.name}@${dep.version} stays external, it needs ${projectPath(projectRoot, dep.file)}`,\n );\n }\n const undeclared = undeclaredExternalDependencies(found, pkg);\n if (undeclared.length === 0) return;\n const lines = undeclared.map(\n (dep) =>\n ` ${dep.name}${dep.importer ? ` (imported by ${projectPath(projectRoot, dep.importer)})` : \"\"}`,\n );\n throw new Error(\n `Packages with native addons or WebAssembly modules must be listed in package.json \"dependencies\", \"optionalDependencies\" or \"peerDependencies\":\\n` +\n `${lines.join(\"\\n\")}\\n\\n` +\n `They stay external to the build, and installs of this package skip devDependencies.`,\n );\n}\n\n// tsc's build info outlives a deleted dist; with the declarations gone, tsc\n// would call the project up to date and emit nothing.\nfunction declarationsMissing(agent: Agent, projectRoot: string): boolean {\n const showConfig = resolveCommand(agent, \"execute-local\", [\n \"tsc\",\n \"--showConfig\",\n ]);\n if (showConfig === null) return false;\n let options: {\n declaration?: boolean;\n composite?: boolean;\n declarationDir?: string;\n outDir?: string;\n };\n try {\n const output = execSync(\n `${showConfig.command} ${showConfig.args.join(\" \")}`,\n {\n cwd: projectRoot,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n },\n );\n options =\n (JSON.parse(output) as { compilerOptions?: typeof options })\n .compilerOptions ?? {};\n } catch {\n return false;\n }\n const dir = options.declarationDir ?? options.outDir;\n if (!dir || !(options.declaration || options.composite)) return false;\n const path = resolve(projectRoot, dir);\n return !existsSync(path) || readdirSync(path).length === 0;\n}\n\n// Runs tsc, which checks the project and writes its declarations either way.\n// Returns whether it reported no type errors.\nfunction emitTypes(agent: Agent, outDir: string, projectRoot: string): boolean {\n const force = declarationsMissing(agent, projectRoot);\n const tscCommand = resolveCommand(agent, \"execute-local\", [\n \"tsc\",\n \"--build\",\n ...(force ? [\"--force\"] : []),\n ]);\n if (tscCommand === null) {\n console.error(\n \"You need to have typescript installed to use the `build` command.\",\n );\n process.exit(1);\n }\n console.log(\"\\n▶ Type-checking and emitting types via tsc...\");\n try {\n execSync(`${tscCommand.command} ${tscCommand.args.join(\" \")}`, {\n stdio: \"inherit\",\n });\n console.log(\"✔ Types emitted to\", join(outDir, \"types\"));\n return true;\n } catch {\n return false;\n }\n}\n\n// The classes the browser build uses, and the package's tokens and rules, against\n// Connect's theme: the Connect that loads it has Tailwind's reset and Connect's classes.\nfunction buildPackageStylesheet(\n agent: Agent,\n projectRoot: string,\n browserDir: string,\n) {\n const command = resolveCommand(agent, \"execute-local\", [\n \"tailwindcss\",\n \"--input\",\n \"-\",\n \"--minify\",\n ]);\n if (command === null) {\n console.error(\n \"You need to have tailwindcss installed to use the `build` command.\",\n );\n process.exit(1);\n }\n const stylePath = join(projectRoot, \"style.css\");\n const style = existsSync(stylePath)\n ? readFileSync(stylePath, \"utf-8\")\n : undefined;\n const compiled = execSync(`${command.command} ${command.args.join(\" \")}`, {\n cwd: projectRoot,\n input: packageStyleEntry(style, {\n browserDir: sourcePath(projectRoot, browserDir),\n localPackages: localPackageNames(projectRoot),\n }),\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"inherit\"],\n // A package that imports large vendor CSS outgrows the 1 MB default.\n maxBuffer: 64 * 1024 * 1024,\n });\n // `ph build` with another out-dir (the switchboard runner's) leaves no dist/.\n mkdirSync(join(projectRoot, \"dist\"), { recursive: true });\n writeFileSync(\n join(projectRoot, \"dist/style.css\"),\n packageStylesheet(compiled),\n );\n}\n\n// A path for `@source`, relative to the project, with forward slashes.\nfunction sourcePath(projectRoot: string, path: string) {\n return `./${relative(projectRoot, resolve(projectRoot, path)).replaceAll(\"\\\\\", \"/\")}`;\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nconst TYPE_ERROR_RISK =\n \"A package built with type errors can load and still fail at runtime.\";\n\nconst UNSAFE_BUILD_WARNING =\n \"⚠ Built despite type errors. \" +\n TYPE_ERROR_RISK +\n \" Fix them before you publish or deploy it.\";\n\nasync function confirmBuildDespiteTypeErrors(): Promise<void> {\n const hint =\n \"Fix them and build again. --ignore-type-errors skips this check, at the risk of shipping that failure.\";\n if (!isInteractive()) {\n console.error(\n `\\n✘ tsc reported the type errors above. ${TYPE_ERROR_RISK}\\n${hint}`,\n );\n process.exit(1);\n }\n const enquirer = await import(\"enquirer\");\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `tsc reported the type errors above. ${TYPE_ERROR_RISK} Build anyway?`,\n initial: false,\n });\n confirmed = answer.confirmed;\n } catch {\n // Ctrl-C at the prompt is a decline.\n confirmed = false;\n }\n if (!confirmed) {\n console.error(`Build cancelled. ${hint}`);\n process.exit(1);\n }\n}\n\n/**\n * Every shared specifier imported from the entry sources; the post-build\n * scan compares these against the built output.\n *\n * Scoped to the specifiers the build actually externalizes: a specifier the\n * vendor does not publish (the bare `@powerhousedao/shared` root, an\n * unvendored subpath) is deliberately bundled, so reporting it as \"bundled\n * instead of externalized\" would be a false alarm.\n */\nfunction findSharedImportsInSources(root: string, globs: string[]): string[] {\n const found = new Set<string>();\n for (const file of expandEntryGlobs(root, globs)) {\n const src = readFileSync(file, \"utf8\");\n for (const spec of findSharedImports(\n src,\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n )) {\n found.add(spec);\n }\n }\n return [...found].sort();\n}\n\n/**\n * The built JS outputs of a browser build (entry files and chunks).\n */\nfunction readDistBrowserFiles(\n dir: string,\n): { path: string; content: string }[] {\n const out: { path: string; content: string }[] = [];\n if (!existsSync(dir)) return out;\n const walk = (d: string) => {\n for (const e of readdirSync(d, { withFileTypes: true })) {\n const p = join(d, e.name);\n if (e.isDirectory()) walk(p);\n else if (e.isFile() && e.name.endsWith(\".js\")) {\n out.push({ path: p, content: readFileSync(p, \"utf8\") });\n }\n }\n };\n walk(dir);\n return out;\n}\n"],"names":["tsdownBuild"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAS,kBAAkB,MAAc,QAAiB;CACxD,MAAM,WAAW,KAAK,MAAM,IAAI;CAChC,IAAI,SAAS,SAAS,kBAAkB,OAAO,EAAE,mBAAmB,WAClE,OAAO;CACT,IAAI,QAAQ,SAAS,gBAAgB;MAChC,OAAO,SAAS;CACrB,OAAO,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,EAAE;AAC9C;AAEA,MAAM,WAAW,SA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AC,EAAA,CACkB;CACrB,QAAQ;EAEN,YAAY;CACd;CACA,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,oBAAoB,MAAM;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF;;;;;;;;;;AAWA,SAAS,2BAA2B,MAAc,OAA2B;CAC3E,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,QAAQ,iBAAiB,MAAM,KAAK,GAAG;EAChD,MAAM,MAAM,aAAa,MAAM,MAAM;EACrC,KAAK,MAAM,QAAQ,kBACjB,KACA,gCACF,GACE,MAAM,IAAI,IAAI;CAElB;CACA,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACzB;;;;AAKA,SAAS,qBACP,KACqC;CACrC,MAAM,MAA2C,CAAC;CAClD,IAAI,CAAC,WAAW,GAAG,GAAG,OAAO;CAC7B,MAAM,QAAQ,MAAc;EAC1B,KAAK,MAAM,KAAK,YAAY,GAAG,EAAE,eAAe,KAAK,CAAC,GAAG;GACvD,MAAM,IAAI,KAAK,GAAG,EAAE,IAAI;GACxB,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC;QACtB,IAAI,EAAE,OAAO,KAAK,EAAE,KAAK,SAAS,KAAK,GAC1C,IAAI,KAAK;IAAE,MAAM;IAAG,SAAS,aAAa,GAAG,MAAM;GAAE,CAAC;EAE1D;CACF;CACA,KAAK,GAAG;CACR,OAAO;AACT","debug_id":"8bd27820-5036-5c2f-883c-3003ca4a9a6a"}
|
package/dist/build-wvc_NiGr.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { i as runBuild } from "./build-t5pFQx0f.mjs";
|
|
2
|
-
export { runBuild };
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="038f88af-54f1-5864-b8de-0247a10a30d4")}catch(e){}}();
|
|
4
|
-
//# debugId=038f88af-54f1-5864-b8de-0247a10a30d4
|
package/dist/check-B_uGHUz3.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ebd73b92-66e0-59b5-80a7-aa90bf4c2976")}catch(e){}}();
|
|
3
|
-
import { r as runModelCommand } from "./run-C7ExLhAm.mjs";
|
|
4
|
-
import { t as renderCheckReport } from "./render-BinrNDU0.mjs";
|
|
5
|
-
import { checkProjectDefinitions } from "document-model/tooling";
|
|
6
|
-
//#region src/services/model/check.ts
|
|
7
|
-
/** `ph model check`. Returns the exit code. */
|
|
8
|
-
async function runModelCheck(args, options = {}) {
|
|
9
|
-
return await runModelCommand({
|
|
10
|
-
name: "ph model check",
|
|
11
|
-
json: args.json,
|
|
12
|
-
read: (project) => checkProjectDefinitions(project),
|
|
13
|
-
render: renderCheckReport
|
|
14
|
-
}, options);
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { runModelCheck };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=check-B_uGHUz3.mjs.map
|
|
20
|
-
//# debugId=ebd73b92-66e0-59b5-80a7-aa90bf4c2976
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check-B_uGHUz3.mjs","sources":["../src/services/model/check.ts"],"sourcesContent":["import { checkProjectDefinitions } from \"document-model/tooling\";\nimport { type ModelRunOptions, runModelCommand } from \"./run.js\";\nimport { renderCheckReport } from \"./render.js\";\n\n/** `ph model check`. Returns the exit code. */\nexport async function runModelCheck(\n args: { readonly json: boolean },\n options: ModelRunOptions = {},\n): Promise<number> {\n return await runModelCommand(\n {\n name: \"ph model check\",\n json: args.json,\n read: (project) => checkProjectDefinitions(project),\n render: renderCheckReport,\n },\n options,\n );\n}\n"],"names":[],"mappings":";;;;;;;AAKA,eAAsB,cACpB,MACA,UAA2B,CAAC,GACX;CACjB,OAAO,MAAM,gBACX;EACE,MAAM;EACN,MAAM,KAAK;EACX,OAAO,YAAY,wBAAwB,OAAO;EAClD,QAAQ;CACV,GACA,OACF;AACF","debug_id":"ebd73b92-66e0-59b5-80a7-aa90bf4c2976"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-build-D20s-YzT.mjs","sources":["../src/utils/precompress.ts","../src/services/connect-build.ts"],"sourcesContent":["import { PRECOMPRESS_EXTENSIONS } from \"@powerhousedao/ph-run/connect-serve\";\nimport { createHash } from \"node:crypto\";\nimport { readdir, readFile, rm, stat, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nconst gzipAsync = promisify(gzip);\n\nexport { PRECOMPRESS_EXTENSIONS };\n\n/** A sibling is written only when it is at most this fraction of the source. */\nconst MAX_RATIO = 0.9;\n\nexport type PrecompressResult = {\n files: number;\n written: number;\n skipped: number;\n inputBytes: number;\n outputBytes: number;\n ms: number;\n};\n\nasync function findTargets(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { recursive: true, withFileTypes: true });\n return entries\n .filter(\n (e) =>\n e.isFile() &&\n PRECOMPRESS_EXTENSIONS.some((ext) => e.name.endsWith(ext)),\n )\n .map((e) => join(e.parentPath, e.name));\n}\n\nasync function isFresh(source: string, sibling: string): Promise<boolean> {\n try {\n const [s, c] = await Promise.all([stat(source), stat(sibling)]);\n return c.mtimeMs >= s.mtimeMs;\n } catch {\n return false;\n }\n}\n\n/** Write gzip siblings for every `.wasm`/`.data` under `dir`. */\nexport async function precompressAssets(\n dir: string,\n): Promise<PrecompressResult> {\n const start = performance.now();\n const targets = await findTargets(dir);\n const result: PrecompressResult = {\n files: targets.length,\n written: 0,\n skipped: 0,\n inputBytes: 0,\n outputBytes: 0,\n ms: 0,\n };\n // Vendor and worker copies share content: compress each distinct file once.\n const byHash = new Map<string, Promise<Buffer | null>>();\n\n await Promise.all(\n targets.map(async (file) => {\n const sibling = file + \".gz\";\n if (await isFresh(file, sibling)) {\n result.skipped += 1;\n return;\n }\n const source = await readFile(file);\n result.inputBytes += source.length;\n const hash = createHash(\"sha256\").update(source).digest(\"hex\");\n let compressed = byHash.get(hash);\n if (!compressed) {\n compressed = gzipAsync(source, { level: 9 }).then((out) =>\n out.length <= source.length * MAX_RATIO ? out : null,\n );\n byHash.set(hash, compressed);\n }\n const out = await compressed;\n if (!out) {\n await rm(sibling, { force: true });\n result.skipped += 1;\n return;\n }\n await writeFile(sibling, out);\n result.written += 1;\n result.outputBytes += out.length;\n }),\n );\n\n result.ms = Math.round(performance.now() - start);\n return result;\n}\n\n/** On by default; PH_CONNECT_PRECOMPRESS=0|false disables it. */\nexport function isPrecompressEnabled(\n env: NodeJS.ProcessEnv = process.env,\n): boolean {\n const raw = env.PH_CONNECT_PRECOMPRESS ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n","import {\n DEFAULT_VENDOR_INCLUDE,\n DYNAMIC_BASE_PLACEHOLDER,\n directoryContentDigest,\n findPackageRoot,\n getConnectBaseViteConfig,\n missingVendorEntries,\n prebuildConnectVendor,\n ownProjectPackage,\n prebuildReactorWorker,\n prebuildWorkerPackages,\n resolveReactorWorkerSource,\n type PrebuiltReactorWorker,\n type PrebuiltVendor,\n} from \"@powerhousedao/builder-tools\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport {\n deepMerge,\n normalizeBasePath,\n SHARED_DEP_SPECIFIERS,\n SHARED_SUBPATHS,\n} from \"@powerhousedao/shared/connect\";\nimport { existsSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type { InlineConfig } from \"vite\";\nimport { build, mergeConfig } from \"vite\";\nimport type { ConnectBuildArgs } from \"../types.js\";\nimport { buildCliConnectOverride } from \"../utils/cli-connect-override.js\";\nimport {\n isPrecompressEnabled,\n precompressAssets,\n} from \"../utils/precompress.js\";\nimport { runBuild } from \"./build.js\";\n\nexport async function runConnectBuild(\n args: ConnectBuildArgs,\n callerOverride?: PHConnectRuntimeConfig,\n { routes }: { routes?: string | false } = {},\n) {\n const { outDir, debug, dynamicBase, favicon } = args;\n\n const mode = \"production\";\n const dirname = process.cwd();\n\n // Build has no read mode; a bare positional `<key>` is a user error. The\n // 2-positional `<key> <value>` form is handled inside buildCliConnectOverride\n // so it layers on top of --json + flags like any other override input.\n if (args.keyPositional !== undefined && args.valuePositional === undefined) {\n throw new Error(\n \"ph connect build: positional override requires both <key> and <value> (e.g. `ph connect build connect.renown.url https://renown.staging`). To read a value, use `ph connect config <key>`.\",\n );\n }\n\n // Fail fast if any package marked as provider: \"local\" is missing from\n // node_modules — the Vite plugin that bundles them needs them on disk.\n assertLocalPackagesInstalled(dirname);\n\n // Build the CLI override layers (--json + individual flags + positional)\n // once here so a bad payload fails before we waste a build.\n // `--packages-registry` lands at the top-level `packageRegistryUrl`\n // (mirrors source-config shape); every other flag feeds the connect-block\n // precedence ladder.\n const cli = buildCliConnectOverride(args);\n const { packageRegistryUrl } = cli;\n // A runner's host config sits under the CLI's flags.\n const connectOverride = callerOverride\n ? deepMerge(callerOverride, cli.connectOverride ?? {})\n : cli.connectOverride;\n\n await runBuild({\n outDir: \"dist\",\n debug,\n // Local packages built for Connect share deps with the app vendor, same\n // as a plain `ph build`.\n noSharedDeps: false,\n ignoreTypeErrors: false,\n });\n\n // Production shared-dependency vendor: prebuilt into <outDir>/__vendor__\n // before the app build. On by default; PH_CONNECT_VENDOR=0|false disables\n // it. A failed prebuild fails the build — production must not ship import\n // map entries pointing at a vendor that was never built (the dev server\n // keeps its own soft fallback in the dev plugin).\n const outDirAbs = resolve(dirname, outDir);\n let vendor: PrebuiltVendor | null = null;\n // The deploy base the vendor's import-map addresses are written against.\n // Only meaningful when the vendor is built; \"/\" is the inert default.\n let appBase = \"/\";\n // The prebuild out dirs' parent must exist before the prebuilds: their\n // build locks are siblings of the out dirs, and the package build\n // (runBuild) writes to a different out dir, so nothing else creates it yet.\n mkdirSync(outDirAbs, { recursive: true });\n if (isVendorEnabled()) {\n const errorRef: { message?: string } = {};\n // The same base string the app build uses below: the dynamic-base\n // placeholder, or the normalized deploy base (CLI override wins over the\n // source config). The vendor worker appends its own segment.\n const phConfig = getConfig(join(dirname, \"powerhouse.config.json\"));\n const connectBasePath =\n connectOverride?.app?.basePath ?? phConfig.connect?.app?.basePath;\n appBase = dynamicBase\n ? DYNAMIC_BASE_PLACEHOLDER\n : connectBasePath\n ? normalizeBasePath(connectBasePath)\n : \"/\";\n vendor = await prebuildConnectVendor({\n dirname,\n include: productionVendorInclude(),\n vendorDir: join(outDirAbs, \"__vendor__\"),\n base: appBase,\n nodeEnv: \"production\",\n errorRef,\n ...connectOwnVendorDeps(dirname),\n });\n if (!vendor) {\n console.error(\n `ph connect build: the shared-dependency vendor failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }`,\n );\n throw new Error(\"shared-dependency vendor prebuild failed\");\n }\n }\n\n // Reactor SharedWorker bundle: the dist worker is a library artifact whose\n // bare imports no worker can resolve (import maps do not apply to workers),\n // so the deployable form is prebuilt here. With a vendor, its shared deps\n // are externalized onto ../__vendor__/ so page and worker share one cache\n // entry per dep; without one it is fully self-contained.\n const reactorWorker = await prebuildReactorWorkerBundle(\n dirname,\n outDirAbs,\n vendor,\n connectOverride,\n );\n\n // Local project models the worker cannot get from the registry, built into\n // the worker bundle's own directory so they share its vendor.\n if (reactorWorker) {\n await prebuildLocalWorkerPackages(\n dirname,\n outDirAbs,\n vendor,\n reactorWorker.vendorImports,\n );\n }\n\n const keepDirs = [\n ...(vendor ? [\"__vendor__\"] : []),\n ...(reactorWorker ? [\"__reactor_worker__\"] : []),\n ];\n // Stale top-level output goes, the prebuilt dirs stay: the app build below\n // runs with emptyOutDir: false and must not wipe them.\n if (keepDirs.length > 0) {\n cleanDistExcept(outDirAbs, keepDirs);\n }\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n cliConnectOverride: connectOverride,\n cliPackageRegistryUrl: packageRegistryUrl,\n dynamicBase,\n favicon,\n routes,\n // Vendor import-map entries are relative (leading slash stripped) so\n // they resolve against the page URL under any deploy base — root or\n // subpath, dynamic or concrete.\n vendor: vendor\n ? {\n imports: vendorImportMapEntries(vendor.imports, appBase),\n versions: vendor.versions,\n sharedDeps: vendorImportMapEntries(\n { sharedDeps: vendor.sharedDeps },\n appBase,\n ).sharedDeps,\n }\n : undefined,\n reactorWorkerVersion: reactorWorker\n ? directoryContentDigest(join(outDirAbs, \"__reactor_worker__\"))\n : undefined,\n });\n\n const buildConfig: InlineConfig = {\n build: {\n outDir,\n // The vendor / worker dirs were prebuilt into the out dir above; the\n // build must not empty them.\n ...(keepDirs.length > 0 ? { emptyOutDir: false } : {}),\n },\n };\n\n const config = mergeConfig(baseConfig, buildConfig);\n\n await build(config);\n\n // Last word on the shipped artifact: every specifier the page's import map\n // publishes must have a file next to it. The prebuild verifies its own\n // output, but it can return a cache hit it never rebuilt, and both the\n // stale-output clean and the app build run afterwards. An entry with no\n // file behind it ships as a URL that 404s, and a SPA answers that with\n // index.html — so the browser reports only an opaque MIME-type error with\n // no filename. Fail here instead, naming the entries.\n if (vendor) {\n const unbacked = missingVendorEntries(\n join(outDirAbs, \"__vendor__\"),\n vendor.imports,\n );\n if (unbacked.length > 0) {\n throw new Error(\n `ph connect build: the shared-dependency vendor is missing ` +\n `${unbacked.length} of the ${Object.keys(vendor.imports).length} ` +\n `entries its import map publishes:\\n` +\n unbacked.map((e) => ` ${e.spec} -> ${e.url}`).join(\"\\n\"),\n );\n }\n }\n\n // Runs after the PWA plugin, so the siblings never enter the precache list.\n if (isPrecompressEnabled()) {\n const r = await precompressAssets(outDirAbs);\n console.log(\n `ph connect build: precompressed ${r.files} wasm/data files ` +\n `(${r.written} .gz written, ${(r.outputBytes / 1e6).toFixed(1)} MB) in ${(r.ms / 1000).toFixed(1)}s`,\n );\n }\n}\n\n/**\n * The specifier set the production vendor bundles: the dev-proven heavy set\n * ∪ the package-shared set — everything the app and loaded packages\n * externalize onto the vendor.\n *\n * Two specifiers are deliberately dropped:\n *\n * - `@powerhousedao/connect`. It is in DEFAULT_VENDOR_INCLUDE because the dev\n * server vendors the app to keep rebuilds cheap, but in a production build\n * the app *is* Connect: `SHARED_DEP_SPECIFIERS` omits it, so the app build\n * never externalizes it and nothing would ever resolve its import-map\n * entry. Vendoring it is not merely dead weight — bundling Connect's dist\n * for the browser pulls in its node-only `@powerhousedao/config/node`\n * import, and so `read-pkg` -> `unicorn-magic`, whose browser entry has no\n * `toPath`. That fails the vendor build, and a failed prebuild fails\n * `ph connect build`.\n * - the bare `@powerhousedao/shared` root, whose barrel likewise reaches\n * node-only modules. Its browser-safe subpaths (SHARED_SUBPATHS) are\n * listed instead; a package importing the bare root bundles its own copy.\n */\nexport function productionVendorInclude(): string[] {\n return [\n ...new Set([\n ...DEFAULT_VENDOR_INCLUDE.filter((s) => s !== \"@powerhousedao/connect\"),\n ...SHARED_DEP_SPECIFIERS.filter((s) => s !== \"@powerhousedao/shared\"),\n ...SHARED_SUBPATHS.map((s) => `@powerhousedao/shared/${s}`),\n // Connect imports these roots too; unvendored, the app re-bundles their shared chunks.\n \"@powerhousedao/design-system\",\n \"@powerhousedao/reactor\",\n ]),\n ];\n}\n\n/** Connect's own deps that vendored packages also bundle; projects don't install them. */\nexport const CONNECT_OWN_VENDOR_DEPS = [\n \"kysely\",\n \"tailwind-merge\",\n \"@renown/sdk\",\n \"@renown/sdk/crypto\",\n \"@renown/sdk/trust\",\n \"@powerhousedao/reactor-attachments/client\",\n // One core and router for Connect and packages; the route tree, config and\n // embedded subpaths stay with the app.\n \"@powerhousedao/connect-core\",\n \"@powerhousedao/connect-core/router\",\n \"@powerhousedao/connect-core/plugins\",\n \"@powerhousedao/connect-core/runtime\",\n \"@powerhousedao/connect-core/views\",\n \"@tanstack/react-router\",\n];\n\nexport function connectOwnVendorDeps(dirname: string): {\n ownDeps?: { specs: string[]; from: string };\n} {\n const from = findPackageRoot(dirname, \"@powerhousedao/connect\");\n return from ? { ownDeps: { specs: CONNECT_OWN_VENDOR_DEPS, from } } : {};\n}\n\n/**\n * Turn the vendor's base-less URLs (`/__vendor__/x.js`) into the addresses\n * the page's import map ships, by prefixing the deploy base.\n *\n * An import map *address* must be a URL or begin with `/`, `./` or `../`;\n * anything else is a bare specifier, which the browser rejects — it drops the\n * entry, resolves the specifier to null, and every shared import then fails\n * with \"blocked by a null value\". So the base is applied rather than the\n * leading slash stripped: a root-relative address is both valid and correct\n * under a subpath deploy, and a dynamic-base build keeps its placeholder for\n * the serving proxy to substitute (the dynamic-base plugin leaves HTML\n * tokens alone by design).\n */\nexport function vendorImportMapEntries(\n imports: Record<string, string>,\n appBase: string,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(imports).map(([spec, url]) => [\n spec,\n `${appBase}/${url}`.replace(/\\/{2,}/g, \"/\"),\n ]),\n );\n}\n\n/**\n * The production vendor prebuild runs on every `ph connect build` unless\n * disabled with PH_CONNECT_VENDOR=0 or false.\n */\nexport function isVendorEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n const raw = env.PH_CONNECT_VENDOR ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n\n/**\n * The reactor worker bundle prebuild runs on every `ph connect build` unless\n * disabled with PH_CONNECT_REACTOR_WORKER=0 or false. It is built even when\n * `connect.instance.reactorWorker` is off, because the `?reactorWorker=true`\n * runtime override can enable the feature on a flag-off deployment.\n */\nexport function isReactorWorkerBundleEnabled(\n env: NodeJS.ProcessEnv = process.env,\n): boolean {\n const raw = env.PH_CONNECT_REACTOR_WORKER ?? \"1\";\n return raw !== \"0\" && raw !== \"false\";\n}\n\n/**\n * Prebuild the reactor SharedWorker bundle into `<dist>/__reactor_worker__`.\n * Returns null when the prebuild is disabled, the installed Connect ships no\n * worker entry, or the build fails. A failure only fails `ph connect build`\n * when the project explicitly enables `connect.instance.reactorWorker` —\n * otherwise the feature degrades to unavailable and the build goes on.\n */\nasync function prebuildReactorWorkerBundle(\n dirname: string,\n outDirAbs: string,\n vendor: PrebuiltVendor | null,\n connectOverride: PHConnectRuntimeConfig | undefined,\n): Promise<PrebuiltReactorWorker | null> {\n if (!isReactorWorkerBundleEnabled()) return null;\n if (!resolveReactorWorkerSource(dirname)) return null;\n\n const errorRef: { message?: string } = {};\n const bundle = await prebuildReactorWorker({\n dirname,\n outDir: join(outDirAbs, \"__reactor_worker__\"),\n vendor: vendor\n ? { imports: vendor.imports, dir: join(outDirAbs, \"__vendor__\") }\n : undefined,\n nodeEnv: \"production\",\n errorRef,\n });\n if (bundle) return bundle;\n\n const message = `ph connect build: the reactor worker bundle failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }`;\n const phConfig = getConfig(join(dirname, \"powerhouse.config.json\"));\n const required =\n connectOverride?.instance?.reactorWorker ??\n phConfig.connect?.instance?.reactorWorker ??\n false;\n if (required) {\n throw new Error(message);\n }\n console.warn(\n `${message}\\nThe reactorWorker feature will be unavailable in this build.`,\n );\n return null;\n}\n\n/**\n * Build the project's `provider: \"local\"` packages into worker-loadable model\n * bundles beside the worker. A failure is a warning, not a build failure: the\n * worker still runs, and documents of registry types still work - only the\n * project's own types would be unavailable in worker mode.\n */\nasync function prebuildLocalWorkerPackages(\n dirname: string,\n outDirAbs: string,\n vendor: PrebuiltVendor | null,\n safeVendorImports: Record<string, string>,\n): Promise<void> {\n const config = getConfig(join(dirname, \"powerhouse.config.json\"));\n const configured = (config.packages ?? [])\n .filter((p) => p.provider === \"local\")\n .map((p) => p.packageName);\n // The project itself is a local package in all but name: a vetra project\n // declares no entry for itself, and its models are the ones the worker\n // cannot otherwise get.\n const own = ownProjectPackage(dirname);\n const localPackages = [...new Set([...configured, ...(own ? [own] : [])])];\n\n const errorRef: { message?: string } = {};\n const built = await prebuildWorkerPackages({\n dirname,\n packages: localPackages,\n outDir: join(outDirAbs, \"__reactor_worker__\", \"packages\"),\n vendor: vendor\n ? { imports: vendor.imports, dir: join(outDirAbs, \"__vendor__\") }\n : undefined,\n safeVendorImports,\n nodeEnv: \"production\",\n errorRef,\n });\n if (!built) {\n console.warn(\n `ph connect build: the reactor worker's local package bundles failed to build${\n errorRef.message ? `:\\n${errorRef.message}` : \"\"\n }\\nDocuments of this project's own types will not load in worker mode.`,\n );\n }\n}\n\n/**\n * Remove every top-level entry of `dist` except the kept names. Used between\n * the vendor prebuild and the app build so stale app output goes but the\n * just-built vendor stays (the build then runs with emptyOutDir: false).\n * Returns the number of entries removed.\n */\nexport function cleanDistExcept(dist: string, keep: string[] = []): number {\n if (!existsSync(dist)) return 0;\n let removed = 0;\n for (const entry of readdirSync(dist)) {\n if (keep.includes(entry)) continue;\n rmSync(join(dist, entry), { recursive: true, force: true });\n removed += 1;\n }\n return removed;\n}\n\nfunction assertLocalPackagesInstalled(projectPath: string) {\n const config = getConfig(join(projectPath, \"powerhouse.config.json\"));\n const localPackages = (config.packages ?? []).filter(\n (p) => p.provider === \"local\",\n );\n if (localPackages.length === 0) return;\n\n const missing = localPackages.filter(\n (p) =>\n !existsSync(\n join(projectPath, \"node_modules\", p.packageName, \"package.json\"),\n ),\n );\n if (missing.length === 0) return;\n\n const names = missing.map((p) => p.packageName);\n throw new Error(\n `ph connect build requires these packages to be installed in node_modules (they are declared with provider: \"local\" in powerhouse.config.json):\\n` +\n names.map((n) => ` - ${n}`).join(\"\\n\") +\n `\\n\\nInstall them with:\\n ph install --local ${names.join(\" \")}`,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAM,YAAY,UAAU,IAAI;;AAKhC,MAAM,YAAY;AAWlB,eAAe,YAAY,KAAgC;CAEzD,QAAO,MADe,QAAQ,KAAK;EAAE,WAAW;EAAM,eAAe;CAA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AAC,WAAW,IAAI,GAAG,OAAO;CAC9B,IAAI,UAAU;CACd,KAAK,MAAM,SAAS,YAAY,IAAI,GAAG;EACrC,IAAI,KAAK,SAAS,KAAK,GAAG;EAC1B,OAAO,KAAK,MAAM,KAAK,GAAG;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAC1D,WAAW;CACb;CACA,OAAO;AACT;AAEA,SAAS,6BAA6B,aAAqB;CAEzD,MAAM,iBADS,UAAU,KAAK,aAAa,wBAAwB,CACvC,CAAC,CAAC,YAAY,CAAC,EAAA,CAAG,QAC3C,MAAM,EAAE,aAAa,OACxB;CACA,IAAI,cAAc,WAAW,GAAG;CAEhC,MAAM,UAAU,cAAc,QAC3B,MACC,CAAC,WACC,KAAK,aAAa,gBAAgB,EAAE,aAAa,cAAc,CACjE,CACJ;CACA,IAAI,QAAQ,WAAW,GAAG;CAE1B,MAAM,QAAQ,QAAQ,KAAK,MAAM,EAAE,WAAW;CAC9C,MAAM,IAAI,MACR,qJACE,MAAM,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,IACtC,gDAAgD,MAAM,KAAK,GAAG,GAClE;AACF","debug_id":"c26a44e9-f651-5e8f-961c-d957b900d28e"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect-preview-DBcsUnSB.mjs","sources":["../src/services/connect-preview.ts"],"sourcesContent":["import {\n cacheHeaders,\n connectBaseOf,\n overrideFromEnv,\n precompressedAssets,\n serveOverrideStep,\n shellSwapFor,\n type ConnectMiddleware,\n type ConnectServeOverride,\n} from \"@powerhousedao/ph-run/connect-serve\";\nimport path from \"node:path\";\nimport type { InlineConfig, Plugin } from \"vite\";\nimport type { ConnectPreviewArgs } from \"../types.js\";\nimport { switchboardProxy } from \"../utils/switchboard-proxy.js\";\n\nexport * from \"@powerhousedao/ph-run/connect-serve\";\n\nexport async function runConnectPreview(\n args: ConnectPreviewArgs,\n serveOverride?: ConnectServeOverride,\n dirname = process.cwd(),\n {\n proxy,\n }: {\n /** The switchboard origin whose paths this server proxies (runner.proxy). */\n proxy?: string;\n } = {},\n) {\n // A supervisor can drive the preview via env when no explicit override is\n // passed (the classic `ph connect preview` command path).\n serveOverride ??= overrideFromEnv();\n const {\n outDir,\n port,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n } = args;\n\n const mode = \"production\";\n\n const outDirAbs = path.resolve(dirname, outDir);\n const base = connectBaseOf(args, outDirAbs, dirname);\n\n // Build tooling, so only here: a packaged app doesn't have it.\n const { preview } = await import(\"vite\");\n const previewPlugin = (name: string, step: ConnectMiddleware): Plugin => ({\n name,\n configurePreviewServer(server) {\n server.middlewares.use(step);\n },\n });\n\n const previewConfig: InlineConfig = {\n configFile: false,\n mode,\n base,\n build: {\n outDir: outDirAbs,\n },\n preview: {\n cors,\n port,\n strictPort,\n host,\n open,\n ...(proxy ? { proxy: switchboardProxy(proxy) } : {}),\n },\n plugins: [\n previewPlugin(\"ph:preview-cache-headers\", cacheHeaders(outDirAbs, base)),\n previewPlugin(\n \"ph:precompressed-assets\",\n precompressedAssets(outDirAbs, base),\n ),\n ...(serveOverride\n ? [\n previewPlugin(\n \"ph:serve-override\",\n serveOverrideStep(\n outDirAbs,\n serveOverride,\n base,\n shellSwapFor(outDirAbs, serveOverride, base),\n proxy !== undefined,\n ),\n ),\n ]\n : []),\n ],\n };\n\n const server = await preview(previewConfig);\n\n if (printUrls) server.printUrls();\n if (bindCLIShortcuts) server.bindCLIShortcuts({ print: true });\n return server;\n}\n"],"names":[],"mappings":";;;;;;;AAiBA,eAAsB,kBACpB,MACA,eACA,UAAU,QAAQ,IAAI,GACtB,EACE,UAIE,CAAC,GACL;CAGA,kBAAkB,gBAAgB;CAClC,MAAM,EACJ,QACA,MACA,MACA,MACA,MACA,YACA,WACA,qBACE;CAEJ,MAAM,OAAO;CAEb,MAAM,YAAY,KAAK,QAAQ,SAAS,MAAM;CAC9C,MAAM,OAAO,cAAc,MAAM,WAAW,OAAO;CAGnD,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,iBAAiB,MAAc,UAAqC;EACxE;EACA,uBAAuB,QAAQ;GAC7B,OAAO,YAAY,IAAI,IAAI;EAC7B;CACF;CAwCA,MAAM,SAAS,MAAM,QAAQ;EArC3B,YAAY;EACZ;EACA;EACA,OAAO,EACL,QAAQ,UACV;EACA,SAAS;GACP;GACA;GACA;GACA;GACA;GACA,GAAI,QAAQ,EAAE,OAAO,iBAAiB,KAAK,EAAE,IAAI,CAAC;EACpD;EACA,SAAS;GACP,cAAc,4BAA4B,aAAa,WAAW,IAAI,CAAC;GACvE,cACE,2BACA,oBAAoB,WAAW,IAAI,CACrC;GACA,GAAI,gBACA,CACE,cACE,qBACA,kBACE,WACA,eACA,MACA,aAAa,WAAW,eAAe,IAAI,GAC3C,UAAU,KAAA,CACZ,CACF,CACF,IACA,CAAC;EACP;CAGuC,CAAC;CAE1C,IAAI,WAAW,OAAO,UAAU;CAChC,IAAI,kBAAkB,OAAO,iBAAiB,EAAE,OAAO,KAAK,CAAC;CAC7D,OAAO;AACT","debug_id":"bfe82542-f227-5ecc-b96f-cf4d673a64bf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-CF0RfguD.mjs","sources":["../../../packages/host-core/dist/index.mjs"],"sourcesContent":["import { $ as describeMapElements, $t as drivesSchema, A as describeHostOutputs, An as resolveOrder, At as connectReactorIssues, B as CONNECT_RUNNER, Bt as placementKeyIssues, C as readRunRecord, Cn as hostTypeSatisfies, Ct as HOST_NAME_MAX_LENGTH, D as HostLoadError, Dn as pluginEntryObjectSchema, Dt as childrenSchema, E as runRecordSchema, En as normalizePluginEntry, Et as childWrapperSchema, F as loadHost, Ft as emittedHostSchemas, G as isSchemaLike, Gt as reactorProtocolSchema, H as RunnerError, Ht as reactorBackendKindSchema, I as probeHostsFolder, It as genericCompoundHostSchema, J as listVerbs, Jt as refineStartOrder, K as kindShapeIssues, Kt as reactorSchema, L as readOutputsFileHash, Lt as hostNameSchema, M as lintHostImportGraph, Mn as runObserveHookSequential, Mt as declaredHostSchemas, N as lintHostImports, Nn as runProvideHook, Nt as defineHostSchemas, O as OUTPUTS_FILE, On as pluginEntrySchema, Ot as compoundHostSchema, P as lintOutputsFile, Pn as runTransformHook, Pt as emitHostJsonSchema, Q as TokenResolutionError, Qt as driveDeclarationSchema, R as scanHostImports, Rt as makeHostSchemas, S as readProjectName, Sn as entryActiveForVerb, St as CONNECT_PRIMARY_MESSAGE, T as runRecordMemberSchema, Tn as normalizePluginEntries, Tt as HOST_NAME_PATTERN, U as getVerb, Ut as reactorBackendSchema, V as ONE_SHOT_VERBS, Vt as profileSchema, W as hostSchemaIssues, Wt as reactorHostSchema, X as validateDeclaredHost, Xt as runnerKindSchema, Y as resolveRunnerModule, Yt as runnerBaseSchema, Z as validateHost, Zt as buildDriveDeclarationSchema, _ as applyChildWrapper, _n as CONNECT_PLUGIN_OWNED_SLICES, _t as describeToken, an as envTokenable, at as BUILTIN_ENV_NAMES, b as listRunRecords, bn as resolvePluginContributions, bt as renderTokens, c as toStartedHandle, cn as isToken, ct as findRemovedForms, d as processResolveEnv, dn as mapTokenSchema, dt as envSitesOf, en as projectDriveIdWith, et as resolveHostOutputs, f as producerOutputsSchemas, fn as outputTokenSchema, ft as outputRefsOf, g as resolveUserDataPlaceholders, gn as tokenable, gt as collectTokenSites, h as defaultUserDataDir, hn as tokenSchema, ht as schemaAtPath, i as runCompound, in as envTokenSchema, it as planCompound, j as findNonStaticValue, jn as runObserveHook, jt as declaredGenericCompoundHostSchema, k as computeOutputsHash, kn as registerHostType, kt as compoundWiringSchema, l as compoundOutputSource, ln as itemTokenSchema, lt as checkOutputPaths, m as runnerOutputsSchema, mn as tokenKeyOf, mt as refKey, n as memberVerbOf, nn as TOKEN_KEYS, nt as PlanError, o as takesCspRegistrySync, on as findToken, ot as isBuiltinEnvName, p as runRecordOutputSource, pn as ref, pt as outputSitesOf, q as knownVerbIssues, qt as refineConnectReactor, r as prepareMember, rn as concatTokenSchema, rt as memberForRef, s as runnerHandleSchema, sn as forbidRef, st as substituteBuiltinEnv, t as compoundStartVerb, tn as TOKEN_ESCAPE_KEY, tt as unsetEnvMessage, u as loadProducers, un as keyTokenSchema, ut as checkTokenSites, v as clearRunRecord, vn as findDeadConnectConfig, vt as formatPath, w as writeRunRecord, wn as mergeContributions, wt as HOST_NAME_MESSAGE, x as probeRun, xn as PluginError, xt as unwrapEscapes, y as isPidAlive, yn as resolveHostPlugins, yt as isPlainObject, z as stripComments, zt as originOrUrlSchema } from \"./compound-Cv5yxdLC.mjs\";\nimport { createRequire } from \"node:module\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\nimport { driveAddressMessage, switchboardOfDrive, switchboardOfDrive as switchboardOfDrive$1 } from \"@powerhousedao/shared/host-tokens\";\nimport { ORIGIN_PLACEHOLDER, SWITCHBOARD_PROXY_PATHS, isHtmlNavigation, isOriginPlaceholderUrl, isSwitchboardProxyPath, resolveOriginPlaceholders, toOriginPlaceholder, withOriginPlaceholders } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { spawn } from \"node:child_process\";\nimport { DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_SWITCHBOARD_PORT } from \"@powerhousedao/shared/clis/constants\";\nimport { DRIVE_ICON_MAX_BYTES, resolveImageRef } from \"@powerhousedao/shared/connect/image-ref\";\n//#region src/spawn-host.ts\nvar SpawnHostError = class extends Error {\n\tphase;\n\toutputTail;\n\texit;\n\tconstructor(message, phase, outputTail, exit) {\n\t\tsuper(outputTail ? `${message}\\n--- output tail ---\\n${outputTail}` : message);\n\t\tthis.phase = phase;\n\t\tthis.outputTail = outputTail;\n\t\tthis.exit = exit;\n\t\tthis.name = \"SpawnHostError\";\n\t}\n};\nconst READY_TIMEOUT_MS = 12e4;\nconst STOP_TIMEOUT_MS = 3e4;\nconst POLL_MS = 100;\nconst CLOSE_WAIT_MS = 1e3;\nconst BASE_ENV_KEYS = [\n\t\"PATH\",\n\t\"HOME\",\n\t\"TMPDIR\"\n];\nconst WIN32_ENV_KEYS = [\n\t\"SystemRoot\",\n\t\"USERPROFILE\",\n\t\"APPDATA\",\n\t\"LOCALAPPDATA\",\n\t\"TEMP\",\n\t\"TMP\",\n\t\"ComSpec\",\n\t\"PATHEXT\"\n];\n/** The child's whole env: no other `process.env` key reaches it. */\nfunction childEnv(dataDir, env = {}) {\n\tif (\"PH_USER_DATA_DIR\" in env) throw new Error(\"spawnHost: set the data dir with `dataDir`, not env.PH_USER_DATA_DIR.\");\n\tconst keys = process.platform === \"win32\" ? [...BASE_ENV_KEYS, ...WIN32_ENV_KEYS] : BASE_ENV_KEYS;\n\tconst base = {};\n\tfor (const key of keys) {\n\t\tconst value = process.env[key];\n\t\tif (value !== void 0) base[key] = value;\n\t}\n\treturn {\n\t\t...base,\n\t\tFEATURE_UNIFORM_RUNNERS_ENABLED: \"1\",\n\t\tPH_USER_DATA_DIR: dataDir,\n\t\tPH_NO_TELEMETRY: \"1\",\n\t\tPH_NO_DOTENV: \"1\",\n\t\t...env\n\t};\n}\nfunction resolvePhCliEntry(projectRoot) {\n\tconst pkgPath = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href).resolve(\"@powerhousedao/ph-cli/package.json\");\n\treturn path.join(path.dirname(pkgPath), \"dist\", \"cli.mjs\");\n}\n/** Readiness waits for a record; refuse a host/verb that writes none. */\nasync function assertWritesRecord(projectRoot, host, verb) {\n\tif (verb !== void 0 && ONE_SHOT_VERBS.has(verb)) throw new Error(`spawnHost: \"${verb}\" is a one-shot verb; it writes no run record to wait for.`);\n\tconst loaded = await loadHost(projectRoot, host);\n\tconst specifier = loaded.host.runner.module;\n\tconst runner = await resolveRunnerModule(projectRoot, specifier);\n\tif (runner.kind === \"compound\") {\n\t\tif (loaded.host.config?.runtimeRecord === false) throw new Error(`spawnHost: hosts/${host} sets config.runtimeRecord: false, so it writes no run record to wait for.`);\n\t\treturn;\n\t}\n\tif (!isSchemaLike(runner.outputsSchema)) throw new Error(`spawnHost: hosts/${host} runs \"${specifier}\", which exports no outputsSchema, so it writes no run record to wait for.`);\n}\nconst sleep = (ms) => new Promise((resolve) => {\n\tsetTimeout(resolve, ms).unref();\n});\nconst live = /* @__PURE__ */ new Set();\nlet exitHookInstalled = false;\nfunction track(child) {\n\tlive.add(child);\n\tchild.once(\"exit\", () => live.delete(child));\n\tif (exitHookInstalled) return;\n\texitHookInstalled = true;\n\tprocess.once(\"exit\", () => {\n\t\tfor (const running of live) running.kill(\"SIGTERM\");\n\t});\n}\n/**\n* `ph run <host> [verb]` as a child; ready when its run record appears.\n*\n* The child shares this process's group, so a terminal Ctrl-C reaches both.\n* It runs the project's own ph-cli: one older than PH_NO_DOTENV reads the\n* project's `.env` anyway.\n*/\nasync function spawnHost(options) {\n\tconst projectRoot = path.resolve(options.projectRoot);\n\tconst dataDir = path.resolve(options.dataDir);\n\tconst env = childEnv(dataDir, options.env);\n\tconst readerEnv = { PH_USER_DATA_DIR: dataDir };\n\tconst readyTimeoutMs = options.readyTimeoutMs ?? READY_TIMEOUT_MS;\n\tconst stopTimeoutMs = options.stopTimeoutMs ?? STOP_TIMEOUT_MS;\n\tconst { signal } = options;\n\tif (signal?.aborted) throw new SpawnHostError(\"spawnHost: aborted before start.\", \"aborted\", \"\");\n\tawait assertWritesRecord(projectRoot, options.host, options.verb);\n\tconst cli = options.cli ?? resolvePhCliEntry(projectRoot);\n\tfs.mkdirSync(dataDir, { recursive: true });\n\tconst log = options.logFile ? fs.createWriteStream(options.logFile, { flags: \"a\" }) : void 0;\n\tlet tail = \"\";\n\tlog?.on(\"error\", (error) => {\n\t\ttail = (tail + `logFile: ${error.message}\\n`).slice(-8192);\n\t});\n\tconst args = [\n\t\tcli,\n\t\t\"run\",\n\t\toptions.host\n\t];\n\tif (options.verb !== void 0) args.push(options.verb);\n\tconst child = spawn(process.execPath, args, {\n\t\tcwd: projectRoot,\n\t\tenv,\n\t\tstdio: [\n\t\t\t\"ignore\",\n\t\t\t\"pipe\",\n\t\t\t\"pipe\"\n\t\t],\n\t\twindowsHide: true\n\t});\n\ttrack(child);\n\tconst onChunk = (stream) => (chunk) => {\n\t\ttail = (tail + chunk).slice(-8192);\n\t\tlog?.write(chunk);\n\t\ttry {\n\t\t\toptions.onOutput?.(stream, chunk);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\ttail = (tail + `onOutput: ${message}\\n`).slice(-8192);\n\t\t}\n\t};\n\tchild.stdout.setEncoding(\"utf8\").on(\"data\", onChunk(\"stdout\"));\n\tchild.stderr.setEncoding(\"utf8\").on(\"data\", onChunk(\"stderr\"));\n\tlet forced = false;\n\tlet exit;\n\tconst exited = new Promise((resolve) => {\n\t\tconst done = (code, sig) => {\n\t\t\tif (exit) return;\n\t\t\texit = {\n\t\t\t\tcode,\n\t\t\t\tsignal: sig,\n\t\t\t\tforced\n\t\t\t};\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(exit);\n\t\t};\n\t\tchild.once(\"exit\", done);\n\t\tchild.once(\"error\", (error) => {\n\t\t\ttail = (tail + `${error.message}\\n`).slice(-8192);\n\t\t\tif (child.pid === void 0) done(null, null);\n\t\t});\n\t});\n\tconst closed = new Promise((resolve) => {\n\t\tchild.once(\"close\", () => {\n\t\t\tlog?.end();\n\t\t\tresolve();\n\t\t});\n\t});\n\tconst pid = child.pid;\n\tconst ownRecords = () => pid === void 0 ? [] : listRunRecords(projectRoot, readerEnv).filter((r) => r.pid === pid);\n\tconst kill = (sig) => {\n\t\tif (pid === void 0) return;\n\t\ttry {\n\t\t\tprocess.kill(pid, sig);\n\t\t} catch {}\n\t};\n\tconst clearOwnRecords = () => {\n\t\tfor (const record of ownRecords()) clearRunRecord(projectRoot, record.host, readerEnv);\n\t};\n\tlet stopping;\n\tconst stop = () => {\n\t\tstopping ??= (async () => {\n\t\t\tif (!exit) {\n\t\t\t\tkill(\"SIGTERM\");\n\t\t\t\tlet timer;\n\t\t\t\tconst timedOut = await Promise.race([exited.then(() => false), new Promise((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => resolve(true), stopTimeoutMs);\n\t\t\t\t})]);\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tforced = true;\n\t\t\t\t\tkill(\"SIGKILL\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst result = await exited;\n\t\t\tclearOwnRecords();\n\t\t\treturn result;\n\t\t})();\n\t\treturn stopping;\n\t};\n\tfunction onAbort() {\n\t\tstop();\n\t}\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tconst deadline = Date.now() + readyTimeoutMs;\n\tfor (;;) {\n\t\tconst aborted = signal?.aborted ?? false;\n\t\tif (exit && !aborted) {\n\t\t\tclearOwnRecords();\n\t\t\tlet timer;\n\t\t\tawait Promise.race([closed, new Promise((resolve) => {\n\t\t\t\ttimer = setTimeout(resolve, CLOSE_WAIT_MS);\n\t\t\t})]);\n\t\t\tclearTimeout(timer);\n\t\t\tconst how = exit.signal !== null ? `signal ${exit.signal}` : `code ${exit.code}`;\n\t\t\tthrow new SpawnHostError(`spawnHost: ph run ${options.host} exited (${how}) before writing its run record.`, \"exited\", tail, exit);\n\t\t}\n\t\tconst record = aborted ? void 0 : ownRecords().at(0);\n\t\tif (record) return {\n\t\t\tpid: record.pid,\n\t\t\tdataDir,\n\t\t\trecord,\n\t\t\toutputs: record.outputs,\n\t\t\tmembers: record.members,\n\t\t\texited,\n\t\t\tstop\n\t\t};\n\t\tif (aborted || Date.now() >= deadline) {\n\t\t\tconst phase = aborted ? \"aborted\" : \"timeout\";\n\t\t\tconst stopped = await stop();\n\t\t\tthrow new SpawnHostError(phase === \"aborted\" ? `spawnHost: aborted before ph run ${options.host} was ready.` : `spawnHost: ph run ${options.host} wrote no run record within ${readyTimeoutMs} ms.`, phase, tail, stopped);\n\t\t}\n\t\tawait Promise.race([sleep(POLL_MS), exited]);\n\t}\n}\n//#endregion\n//#region src/check-host.ts\n/** The `ph run` pipeline up to the verb, collecting every issue; starts nothing. */\nasync function checkHost(name, options) {\n\tconst result = {\n\t\tissues: [],\n\t\twarnings: [],\n\t\tdeferred: []\n\t};\n\tconst file = `hosts/${name}/host.js`;\n\tconst issue = issuer(result, file);\n\tconst verb = options.verb ?? \"run\";\n\tlet host;\n\tlet runner;\n\ttry {\n\t\thost = (await loadHost(options.projectRoot, name)).host;\n\t\trunner = await resolveRunnerModule(options.projectRoot, host.runner.module);\n\t} catch (error) {\n\t\tissue(\"load\", \"\", error);\n\t\treturn result;\n\t}\n\tconst specifier = host.runner.module;\n\tif (runner.kind === \"compound\") {\n\t\tawait checkCompound(result, options, {\n\t\t\tfile,\n\t\t\thost,\n\t\t\trunner,\n\t\t\tspecifier,\n\t\t\tverb\n\t\t});\n\t\treturn result;\n\t}\n\tconst refs = outputRefsOf(host);\n\tconst producers = await loadProducers(options.projectRoot, refs);\n\tawait checkSubject(result, options, {\n\t\tfile,\n\t\thost,\n\t\trunner,\n\t\tspecifier,\n\t\tverb,\n\t\toutputsSchemaOf: producerOutputsSchemas(producers),\n\t\tself: \"outputs\"\n\t});\n\treturn result;\n}\n/** Declared validation; returns whether its tokens and its shape passed. */\nfunction checkDeclared(result, subject, outputsSchemaOf) {\n\tconst issue = issuer(result, subject.file);\n\tconst { host, runner, specifier } = subject;\n\ttry {\n\t\tgetVerb(runner, specifier, subject.verb);\n\t} catch (error) {\n\t\tissue(\"declared\", \"\", error);\n\t}\n\tconst tokenIssues = [\n\t\t...findRemovedForms(host),\n\t\t...checkTokenSites(host),\n\t\t...outputsSchemaOf ? checkOutputPaths(host, outputsSchemaOf) : []\n\t];\n\tfor (const i of tokenIssues) issue(\"declared\", i);\n\tconst shapeIssues = runner.declaredHostSchema ? schemaIssuesOf(runner, runner.declaredHostSchema, specifier, host, true) : kindShapeIssues(runner.kind, specifier, host);\n\tfor (const i of shapeIssues) issue(\"declared\", i);\n\treturn {\n\t\ttokens: tokenIssues.length === 0,\n\t\tshape: shapeIssues.length === 0\n\t};\n}\nfunction schemaIssuesOf(runner, schema, specifier, host, allowTokens) {\n\tconst checked = hostSchemaIssues(runner, schema, specifier, host, { tokens: allowTokens ? \"allow\" : \"forbid\" });\n\treturn [...checked.issues, ...checked.schemaIssues ?? []];\n}\nasync function checkSubject(result, options, subject) {\n\tconst issue = issuer(result, subject.file);\n\tconst { runner, specifier, file } = subject;\n\tconst declared = checkDeclared(result, subject, subject.outputsSchemaOf);\n\tconst resolveEnv = processResolveEnv(options.projectRoot, options.env);\n\tconst patch = subject.patch ?? ((host) => host);\n\tif (ONE_SHOT_VERBS.has(subject.verb)) {\n\t\tif (!declared.tokens || !declared.shape) return;\n\t\tconst host = patch(substituteBuiltinEnv(subject.host, resolveEnv.builtins ?? {}));\n\t\tconst schema = runner.declaredHostSchema ?? runner.hostSchema;\n\t\tfor (const i of schemaIssuesOf(runner, schema, specifier, host, true)) issue(\"resolved\", i);\n\t\treturn;\n\t}\n\tconst unset = envSitesOf(subject.host).filter((site) => !site.optional && !isBuiltinEnvName(site.name) && options.env[site.name] === void 0);\n\tfor (const site of unset) issue(\"resolve\", {\n\t\tpath: site.path,\n\t\tmessage: unsetEnvMessage(site.name)\n\t});\n\tif (!declared.tokens || unset.length > 0) return;\n\tlet resolved;\n\tlet deferred = [];\n\ttry {\n\t\tif (options.outputs) resolved = resolveHostOutputs(subject.host, {\n\t\t\toutputs: options.outputs,\n\t\t\t...resolveEnv\n\t\t});\n\t\telse {\n\t\t\tconst partial = resolveHostOutputs(subject.host, resolveEnv, { deferSelf: subject.self });\n\t\t\tresolved = partial.host;\n\t\t\tdeferred = partial.deferred;\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof TokenResolutionError && error.detail) issue(\"resolve\", {\n\t\t\tpath: error.detail.path,\n\t\t\tmessage: error.detail.reason\n\t\t});\n\t\telse issue(\"resolve\", \"\", error);\n\t\treturn;\n\t}\n\tresult.deferred.push(...deferred.map((d) => ({\n\t\t...d,\n\t\tfile\n\t})));\n\tif (!declared.shape) return;\n\tconst allow = deferred.length > 0;\n\tconst schema = allow ? runner.declaredHostSchema ?? runner.hostSchema : runner.hostSchema;\n\tconst checked = hostSchemaIssues(runner, schema, specifier, patch(resolved), { tokens: allow ? \"allow\" : \"forbid\" });\n\tconst resolvedIssues = [...checked.issues, ...checked.schemaIssues ?? []];\n\tfor (const i of resolvedIssues) issue(\"resolved\", i);\n\tif (resolvedIssues.length > 0 || !runner.checkBoot) return;\n\ttry {\n\t\tconst boot = await runner.checkBoot(checked.data, {\n\t\t\tprojectRoot: options.projectRoot,\n\t\t\tverb: subject.verb,\n\t\t\tenv: options.env,\n\t\t\tfile\n\t\t});\n\t\tfor (const i of boot) issue(\"boot\", {\n\t\t\t...i,\n\t\t\tpath: i.path ?? \"\"\n\t\t});\n\t} catch (error) {\n\t\tissue(\"boot\", \"\", error);\n\t}\n}\nasync function checkCompound(result, options, subject) {\n\tconst issue = issuer(result, subject.file);\n\tconst { host, runner, specifier } = subject;\n\tconst declared = checkDeclared(result, subject);\n\tif (!declared.tokens || !declared.shape) return;\n\tif (!runner.declaredHostSchema) {\n\t\tconst own = schemaIssuesOf(runner, runner.hostSchema, specifier, host, true);\n\t\tfor (const i of own) issue(\"resolved\", i);\n\t\tif (own.length > 0) return;\n\t}\n\tconst children = isPlainObject(host.children) ? host.children : {};\n\tconst wiring = isPlainObject(host.config) ? host.config : {};\n\tconst verb = compoundStartVerb(subject.verb, host.runner);\n\tconst prepared = [];\n\tfor (const [key, member] of Object.entries(children)) try {\n\t\tprepared.push(await prepareMember(options.projectRoot, key, member));\n\t} catch (error) {\n\t\tissuer(result, `hosts/${member.host}/host.js`)(\"load\", \"\", error);\n\t}\n\tconst members = Object.entries(children).map(([key, m]) => ({\n\t\tkey,\n\t\thost: m.host\n\t}));\n\tif (prepared.length === members.length) try {\n\t\tplanCompound(prepared.map((m) => ({\n\t\t\tkey: m.key,\n\t\t\thost: m.member.host,\n\t\t\trefs: outputSitesOf(m.draft).map(({ ref, path }) => ({\n\t\t\t\tref,\n\t\t\t\tpath\n\t\t\t}))\n\t\t})), wiring.startOrder);\n\t} catch (error) {\n\t\tissue(\"declared\", \"\", error);\n\t}\n\tresult.warnings.push(...sharedPortWarnings(subject.file, prepared));\n\tconst byKey = new Map(prepared.map((m) => [m.key, m]));\n\tconst outputsSchemaOf = (ref) => {\n\t\tconst target = memberForRef(ref, members);\n\t\tif (\"error\" in target) return { error: target.error };\n\t\tconst producer = byKey.get(target.key);\n\t\treturn producer ? runnerOutputsSchema(producer.runner, producer.specifier, `member \"${target.key}\"`) : { error: `names member \"${target.key}\", which was not prepared.` };\n\t};\n\tfor (const m of prepared) {\n\t\tconst csp = wiring.cspRegistrySync === true && takesCspRegistrySync(m);\n\t\tawait checkSubject(result, options, {\n\t\t\tfile: m.file,\n\t\t\thost: m.draft,\n\t\t\trunner: m.runner,\n\t\t\tspecifier: m.specifier,\n\t\t\tverb: memberVerbOf(verb, m.draft.runner),\n\t\t\toutputsSchemaOf,\n\t\t\tself: { members },\n\t\t\t...csp ? { patch: (resolved) => ({\n\t\t\t\t...resolved,\n\t\t\t\trunner: {\n\t\t\t\t\t...resolved.runner,\n\t\t\t\t\tcspRegistrySync: true\n\t\t\t\t}\n\t\t\t}) } : {}\n\t\t});\n\t}\n}\nconst SWITCHBOARD_RUNNER = \"@powerhousedao/ph-cli/runners/switchboard\";\n/** The port a member binds: its own literal, else its ph-cli runner's default. */\nfunction boundPortOf(m) {\n\tconst port = m.draft.runner.port;\n\tif (port === void 0) {\n\t\tif (m.specifier === \"@powerhousedao/ph-cli/runners/connect\") return DEFAULT_CONNECT_STUDIO_PORT;\n\t\tif (m.specifier === SWITCHBOARD_RUNNER) return DEFAULT_SWITCHBOARD_PORT;\n\t\treturn;\n\t}\n\treturn typeof port === \"number\" && Number.isInteger(port) && port > 0 ? port : void 0;\n}\n/** Members binding one port: under `ph run` the later one moves or fails. */\nfunction sharedPortWarnings(file, prepared) {\n\tconst owners = /* @__PURE__ */ new Map();\n\tconst warnings = [];\n\tfor (const m of prepared) {\n\t\tconst port = boundPortOf(m);\n\t\tif (port === void 0) continue;\n\t\tconst other = owners.get(port);\n\t\tif (!other) {\n\t\t\towners.set(port, m);\n\t\t\tcontinue;\n\t\t}\n\t\tconst connects = m.specifier === \"@powerhousedao/ph-cli/runners/connect\" && other.specifier === \"@powerhousedao/ph-cli/runners/connect\";\n\t\twarnings.push({\n\t\t\tstage: \"declared\",\n\t\t\tfile,\n\t\t\tpath: `children.${m.key}.runner.port`,\n\t\t\tmessage: connects ? `${other.key} and ${m.key} both use port ${port}. One will move to the next free port and lose its browser data.` : `${other.key} and ${m.key} both use port ${port}. One will move to the next free port or fail to start.`\n\t\t});\n\t}\n\treturn warnings;\n}\nfunction issuer(result, file) {\n\treturn (stage, found, error) => {\n\t\tif (typeof found !== \"string\") {\n\t\t\tconst { path, message, hint } = found;\n\t\t\tresult.issues.push({\n\t\t\t\tstage,\n\t\t\t\tfile,\n\t\t\t\tpath,\n\t\t\t\tmessage,\n\t\t\t\t...hint ? { hint } : {}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst [message, hint] = (error instanceof Error ? error.message : String(error)).split(\"\\n Hint: \");\n\t\tresult.issues.push({\n\t\t\tstage,\n\t\t\tfile,\n\t\t\tpath: found,\n\t\t\tmessage,\n\t\t\t...hint ? { hint } : {}\n\t\t});\n\t};\n}\n//#endregion\n//#region src/host-export-schema.ts\nfunction isRecord$1(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction childFolders$1(host) {\n\tif (!isRecord$1(host) || !isRecord$1(host.children)) return [];\n\treturn Object.entries(host.children).flatMap(([key, child]) => isRecord$1(child) && typeof child.host === \"string\" ? [[key, child.host]] : []);\n}\nconst declaredHostSchema = z.custom().superRefine((host, ctx) => {\n\tconst result = (isRecord$1(host) && \"children\" in host ? declaredHostSchemas.compoundHostSchema : declaredHostSchemas.reactorHostSchema).safeParse(host);\n\tif (result.success) return;\n\tfor (const issue of result.error.issues) ctx.addIssue({\n\t\tcode: \"custom\",\n\t\tmessage: issue.message,\n\t\tpath: issue.path\n\t});\n});\n/** `ph host export`: a declared host plus its members, keyed by folder. */\nconst hostExportSchema = z.strictObject({\n\tformat: z.literal(\"ph-host-export\"),\n\tversion: z.literal(1),\n\tproject: z.strictObject({\n\t\tname: z.string().min(1),\n\t\troot: z.string().min(1)\n\t}),\n\tname: z.string().min(1),\n\thost: declaredHostSchema,\n\tmembers: z.record(z.string(), declaredHostSchema)\n}).superRefine((value, ctx) => {\n\tconst reached = /* @__PURE__ */ new Set();\n\tconst pending = [[[\"host\"], value.host]];\n\tfor (let next = pending.shift(); next; next = pending.shift()) {\n\t\tconst [at, host] = next;\n\t\tfor (const [key, folder] of childFolders$1(host)) {\n\t\t\tif (!(folder in value.members)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [\n\t\t\t\t\t\t...at,\n\t\t\t\t\t\t\"children\",\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\"host\"\n\t\t\t\t\t],\n\t\t\t\t\tmessage: `Member folder \"${folder}\" is missing from members.`\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (reached.has(folder)) continue;\n\t\t\treached.add(folder);\n\t\t\tpending.push([[\"members\", folder], value.members[folder]]);\n\t\t}\n\t}\n\tfor (const folder of Object.keys(value.members)) {\n\t\tif (reached.has(folder)) continue;\n\t\tctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath: [\"members\", folder],\n\t\t\tmessage: `Member \"${folder}\" is not reached from the host's children.`\n\t\t});\n\t}\n});\n//#endregion\n//#region src/host-export.ts\nfunction checkHint(name) {\n\treturn `Run \\`ph host check ${name}\\`.`;\n}\nfunction childFolders(host, name) {\n\tif (!(\"children\" in host)) return [];\n\tconst parsed = declaredHostSchemas.childrenSchema.safeParse(host.children);\n\tif (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: invalid \\`children\\`:\\n${z.prettifyError(parsed.error)}`, checkHint(name));\n\treturn Object.values(parsed.data).map((child) => child.host);\n}\n/** A host as declared and every member it reaches, raw `loadHost` bodies. */\nasync function exportHost(projectRoot, name) {\n\tconst root = path.resolve(projectRoot);\n\tconst { host } = await loadHost(root, name);\n\tconst members = {};\n\tconst visit = async (folders) => {\n\t\tfor (const folder of folders) {\n\t\t\tif (folder in members) continue;\n\t\t\tconst member = (await loadHost(root, folder)).host;\n\t\t\tmembers[folder] = member;\n\t\t\tawait visit(childFolders(member, folder));\n\t\t}\n\t};\n\tawait visit(childFolders(host, name));\n\tconst envelope = {\n\t\tformat: \"ph-host-export\",\n\t\tversion: 1,\n\t\tproject: {\n\t\t\tname: readProjectName(root),\n\t\t\troot\n\t\t},\n\t\tname,\n\t\thost,\n\t\tmembers\n\t};\n\tconst parsed = hostExportSchema.safeParse(JSON.parse(JSON.stringify(envelope)));\n\tif (!parsed.success) throw new HostLoadError(`hosts/${name}/host.js: the export is not a valid host export:\\n${z.prettifyError(parsed.error)}`, checkHint(name));\n\treturn envelope;\n}\n//#endregion\n//#region src/drives.ts\nconst sha256Hex = (input) => crypto.createHash(\"sha256\").update(input).digest(\"hex\");\nfunction projectDriveId(projectRoot, slug) {\n\treturn projectDriveIdWith(sha256Hex, projectRoot, slug);\n}\nfunction resolveDriveDeclaration(projectRoot, decl) {\n\tconst id = decl.projectHash ? projectDriveId(projectRoot, decl.slug) : decl.id;\n\tconst slug = decl.projectHash === true ? id : decl.slug;\n\tif (decl.remote) return {\n\t\tkind: \"remote\",\n\t\tid,\n\t\tslug,\n\t\tname: decl.name ?? decl.slug,\n\t\tremoteUrl: decl.remote.url,\n\t\tsharingType: decl.sharingType ?? \"public\",\n\t\tavailableOffline: decl.availableOffline ?? true\n\t};\n\treturn {\n\t\tkind: \"local\",\n\t\tid,\n\t\tslug,\n\t\tdocumentType: decl.documentType,\n\t\tname: decl.name ?? decl.slug,\n\t\ticon: resolveImageRef(projectRoot, decl.icon, {\n\t\t\tmaxBytes: DRIVE_ICON_MAX_BYTES,\n\t\t\twarn: (m) => console.warn(m)\n\t\t}),\n\t\tpreferredEditor: decl.preferredEditor,\n\t\tsharingType: decl.sharingType ?? \"public\",\n\t\tavailableOffline: decl.availableOffline ?? true\n\t};\n}\n/** Idempotent, slug-keyed: an existing slug is left untouched (never\n* recreated, never mutated — preserveStrategy refinements live here later). */\nasync function seedDrives(client, drives) {\n\tconst result = {\n\t\tcreated: [],\n\t\texisting: [],\n\t\tattached: []\n\t};\n\tfor (const drive of drives) {\n\t\tif (drive.kind === \"remote\") {\n\t\t\tawait client.attachRemoteDrive(drive.remoteUrl);\n\t\t\tresult.attached.push(drive.slug);\n\t\t\tcontinue;\n\t\t}\n\t\tif (await client.findDriveBySlug(drive.slug) !== void 0) {\n\t\t\tresult.existing.push(drive.slug);\n\t\t\tcontinue;\n\t\t}\n\t\tawait client.createDrive(drive);\n\t\tresult.created.push(drive.slug);\n\t}\n\treturn result;\n}\n/** Merge host-declared drives with plugin contributions, slug-keyed — the\n* host file wins on conflicts (it is the most explicit source). */\nfunction mergeDrivePlan(projectRoot, hostDeclared, contributed) {\n\tconst plan = /* @__PURE__ */ new Map();\n\tfor (const { declaration, source } of contributed) {\n\t\tconst drive = resolveDriveDeclaration(projectRoot, declaration);\n\t\tplan.set(drive.slug, {\n\t\t\tdrive,\n\t\t\tsource\n\t\t});\n\t}\n\tfor (const declaration of hostDeclared) {\n\t\tconst drive = resolveDriveDeclaration(projectRoot, declaration);\n\t\tplan.set(drive.slug, {\n\t\t\tdrive,\n\t\t\tsource: \"host\"\n\t\t});\n\t}\n\treturn [...plan.values()];\n}\nfunction explainDrivePlan(plan) {\n\tif (plan.length === 0) return \"(no drives declared)\";\n\treturn [\"drives:\", ...plan.map(({ drive, source }) => {\n\t\tconst kind = drive.kind === \"remote\" ? `remote ${drive.remoteUrl}` : \"local\";\n\t\tconst editor = drive.preferredEditor ? ` editor=${drive.preferredEditor}` : \"\";\n\t\tconst id = drive.id ?? \"generated\";\n\t\treturn ` ${drive.slug} (${kind}, id=${id}${editor}) [${source}]`;\n\t})].join(\"\\n\");\n}\n//#endregion\n//#region src/backend-projection.ts\nfunction projectStorage(name, storage) {\n\tswitch (storage.kind) {\n\t\tcase \"idb\": return { kind: \"idb\" };\n\t\tcase \"memory\": return { kind: \"memory\" };\n\t\tcase \"path\":\n\t\t\tif (!storage.dataDir) throw new Error(`Backend \"${name}\": storage kind \"path\" requires dataDir.`);\n\t\t\treturn {\n\t\t\t\tkind: \"path\",\n\t\t\t\tdataDir: storage.dataDir\n\t\t\t};\n\t\tcase \"postgres\": throw new Error(`Backend \"${name}\": storage kind \"postgres\" is server-side only — a provisioned (in-process/worker) reactor cannot use it. Point a \"remote\" backend at the switchboard that owns that database instead.`);\n\t}\n}\n/** One backend → one descriptor. The protocol's featureFlags ride every\n* descriptor (they are fleet consensus, not per-backend). A remote backend\n* must carry remote.url — provision() requires it. */\nfunction backendToDescriptor(name, backend, protocol) {\n\tconst descriptor = {\n\t\tkind: backend.kind,\n\t\tname\n\t};\n\tif (descriptor.kind === \"remote\") {\n\t\tconst url = backend.remote?.url;\n\t\tif (!url) throw new Error(`Backend \"${name}\" is kind \"remote\" but has no remote.url — a remote descriptor attaches to an already-running reactor by URL.`);\n\t\tdescriptor.remote = { url };\n\t\treturn descriptor;\n\t}\n\tif (backend.storage) descriptor.storage = projectStorage(name, backend.storage);\n\tif (backend.packages) descriptor.packages = backend.packages;\n\tif (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n\treturn descriptor;\n}\n/** All named backends, in placement-primary-first order (the order a\n* createReactorClients step would provision them). */\nfunction backendsToDescriptors(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return [];\n\tconst names = Object.keys(backends);\n\tconst primary = reactor.placement?.primary;\n\treturn (primary && names.includes(primary) ? [primary, ...names.filter((n) => n !== primary)] : names).map((name) => backendToDescriptor(name, backends[name], reactor.protocol));\n}\nconst LOCAL_KINDS = /* @__PURE__ */ new Set([\"in-process\", \"worker\"]);\n/**\n* Structural multi-reactor (phase 4): true when the block names BOTH a local\n* backend (in-process/worker — the tab's own reactor) and a remote one. This\n* is the shape Connect's routing client serves; a lone remote backend is an\n* attach-only host (assistant/agent shape), not a routed tab.\n*/\nfunction isStructuralMultiReactor(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return false;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\treturn kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\");\n}\n/** The remote backends' drive addresses, placement order. */\nfunction remoteBackendUrls(reactor) {\n\treturn backendsToDescriptors(reactor).filter((d) => d.kind === \"remote\").map((d) => d.remote?.url).filter((u) => typeof u === \"string\");\n}\n/**\n* The remote backends by host key, placement order, each with the\n* connection settings it sets. A url that is not a string yet (an output\n* token, unresolved when a host builds) is skipped, as in remoteBackendUrls.\n*/\nfunction remoteBackends(reactor) {\n\treturn backendsToDescriptors(reactor).flatMap((d) => {\n\t\tconst remote = reactor?.backends?.[d.name]?.remote;\n\t\tif (d.kind !== \"remote\" || typeof d.remote?.url !== \"string\" || !remote) return [];\n\t\tconst { requestTimeoutMs, breaker, realtime } = remote;\n\t\treturn [{\n\t\t\tname: d.name,\n\t\t\turl: d.remote.url,\n\t\t\t...requestTimeoutMs !== void 0 ? { requestTimeoutMs } : {},\n\t\t\t...breaker !== void 0 ? { breaker } : {},\n\t\t\t...realtime !== void 0 ? { realtime } : {}\n\t\t}];\n\t});\n}\n//#endregion\n//#region src/reactor-config.ts\n/**\n* The shared `reactor` host-config block and its projections onto the\n* Switchboard config / Connect runtime config. Phase 2 of uniform-runners: makes\n* the reactor block live through the bridge runners, BEFORE track R replaces\n* the projection with reactor-monitor's provision(). The headline is\n* single-sourced `reactor.protocol` — both projections read the same block, so\n* client and server cannot diverge, and a contradicting pre-set env fails boot.\n*/\n/** A switchboard host's own store. Prefers placement.primary, else\n* \"main\"/\"local\", else the first. Connect refuses placement.primary: its\n* reactor is {@link browserBackend}. */\nfunction primaryBackend(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst names = Object.keys(backends);\n\tif (names.length === 0) return void 0;\n\treturn backends[reactor.placement?.primary ?? (names.includes(\"main\") ? \"main\" : names.includes(\"local\") ? \"local\" : names[0])];\n}\nconst FLAG_ENV = {\n\tdocumentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n\tauthEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n\tauthGroups: \"REACTOR_AUTH_GROUPS\",\n\tauthConditions: \"REACTOR_AUTH_CONDITIONS\",\n\tundoV3: \"REACTOR_UNDO_V3\"\n};\n/** The env vars a protocol block maps onto, with their string values. Only\n* keys the block actually sets appear. */\nfunction protocolEnv(protocol) {\n\tconst env = {};\n\tif (!protocol) return env;\n\tfor (const [key, varName] of Object.entries(FLAG_ENV)) {\n\t\tconst value = protocol.featureFlags?.[key];\n\t\tif (value !== void 0) env[varName] = value ? \"true\" : \"false\";\n\t}\n\tif (protocol.createSignaturePolicy !== void 0) env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n\tif (protocol.unsupportedStoredDocuments !== void 0) env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS = protocol.unsupportedStoredDocuments;\n\treturn env;\n}\n/** The reactor block as a switchboard config layer. The reactor store and the\n* read model are separate fields: `readModel.url` never moves the reactor. */\nfunction reactorBlockToSwitchboardConfig(reactor) {\n\tconst layer = {};\n\tconst backend = primaryBackend(reactor);\n\tconst storage = backend?.storage;\n\tconst reactorUrl = storage?.kind === \"postgres\" ? storage.url : storage?.dataDir;\n\tconst readModelUrl = backend?.readModel?.url;\n\tif (reactorUrl || readModelUrl) layer.storage = {\n\t\t...reactorUrl ? { reactor: { url: reactorUrl } } : {},\n\t\t...readModelUrl ? { readModel: { url: readModelUrl } } : {}\n\t};\n\tif (reactor?.protocol) layer.protocol = reactor.protocol;\n\tif (backend?.packages?.dynamic) layer.packages = { dynamic: true };\n\tif (reactor?.workflows !== void 0) layer.features = { workflows: reactor.workflows };\n\treturn layer;\n}\nconst LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set([\"in-process\", \"worker\"]);\n/** Connect's browser reactor: its first in-process or worker backend. */\nfunction browserBackend(reactor) {\n\tconst entry = Object.entries(reactor?.backends ?? {}).find(([, backend]) => LOCAL_BACKEND_KINDS.has(backend.kind));\n\treturn entry ? {\n\t\t...entry[1],\n\t\tname: entry[0]\n\t} : void 0;\n}\n/**\n* Which reactor client the backend topology asks for:\n* - local (in-process/worker) AND remote backends -> `router`\n* - remote backend(s) only -> `remote`\n* - a worker backend -> `worker`\n* - anything else local -> `in-process`\n* `undefined` when no backends are declared — the caller then keeps the\n* legacy reactorWorker/multiReactor behaviour untouched.\n*/\nfunction reactorClientMode(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\tif (kinds.length === 0) return void 0;\n\tconst hasLocal = kinds.some((k) => LOCAL_BACKEND_KINDS.has(k));\n\tconst hasRemote = kinds.some((k) => k === \"remote\");\n\tif (hasLocal && hasRemote) return \"router\";\n\tif (hasRemote) return \"remote\";\n\treturn browserBackend(reactor)?.kind === \"worker\" ? \"worker\" : \"in-process\";\n}\n/** Served only when `newDrives` names a served remote backend: a local one\n* is the default, and Connect refuses one it has no address for. */\nfunction connectRouterSettings(reactor, served) {\n\tconst newDrives = reactor?.placement?.newDrives;\n\tconst { probeTimeoutMs, provisionalRouteMs } = reactor?.router ?? {};\n\tconst router = {\n\t\t...newDrives !== void 0 && served.some((remote) => remote.name === newDrives) ? { newDrives } : {},\n\t\t...probeTimeoutMs !== void 0 ? { probeTimeoutMs } : {},\n\t\t...provisionalRouteMs !== void 0 ? { provisionalRouteMs } : {}\n\t};\n\treturn Object.keys(router).length > 0 ? router : void 0;\n}\n/** Project the reactor block onto the Connect runtime config: protocol →\n* connect.reactor (same shape), backend topology → instance.reactorWorker\n* (the browser reactor's kind), instance.reactorClient, and with a\n* switchboard instance.remoteBackends and instance.router, workflows →\n* app.workflowsEnabled. */\nfunction projectReactorToConnect(reactor) {\n\tconst connect = {};\n\tif (reactor?.protocol) connect.reactor = reactor.protocol;\n\tconst mode = reactorClientMode(reactor);\n\tif (mode !== void 0) {\n\t\tconst routed = mode === \"router\" || mode === \"remote\";\n\t\tconst served = routed ? remoteBackends(reactor) : [];\n\t\tconst router = routed ? connectRouterSettings(reactor, served) : void 0;\n\t\tconnect.instance = {\n\t\t\treactorWorker: browserBackend(reactor)?.kind === \"worker\",\n\t\t\treactorClient: mode,\n\t\t\t...routed ? { remoteBackends: served } : {},\n\t\t\t...router ? { router } : {}\n\t\t};\n\t}\n\tif (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };\n\treturn { connect };\n}\n/** Whether an env value means what the host's value does. The switchboard\n* reads REACTOR_UNDO_V3 as on unless it is exactly \"false\". */\nfunction protocolEnvAgrees(varName, envValue, hostValue) {\n\tif (varName === FLAG_ENV.undoV3) return envValue !== \"false\" === (hostValue === \"true\");\n\treturn envValue === hostValue;\n}\n/** Each pre-set env var that CONTRADICTS the host's protocol block, as a\n* message naming the var, the host value and the env value. An env var that\n* merely matches, or is unset, is fine. */\nfunction protocolConflicts(protocol, env, hostFile = \"the host file\") {\n\tif (!protocol) return [];\n\treturn Object.entries(protocolEnv(protocol)).flatMap(([varName, hostValue]) => {\n\t\tconst envValue = env[varName];\n\t\tif (envValue === void 0 || protocolEnvAgrees(varName, envValue, hostValue)) return [];\n\t\treturn [`reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — a mismatch would diverge replay. Remove the env override or align the host.`];\n\t});\n}\n/**\n* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n* the host's protocol block, fail loudly naming the var, the host value, and\n* the env value (phase-2 transition keeps an operator's explicit env as an\n* escape hatch unless it disagrees with the protocol — see the WBS\n* precedence note).\n*/\nfunction assertProtocolConsistency(protocol, env, hostFile = \"the host file\") {\n\tconst conflict = protocolConflicts(protocol, env, hostFile).at(0);\n\tif (conflict) throw new Error(conflict);\n}\n//#endregion\n//#region src/connect-projection.ts\n/**\n* Instance-fact projection for compound hosts: the drives a compound's\n* reactor member created, projected into the Connect member's runtime-config\n* override. Pure functions, moved from ph-cli's vetra service so the generic\n* compound and the classic path share one implementation.\n*/\nfunction isLocalDrive(drive) {\n\treturn \"local\" in drive;\n}\nconst driveKey = (drive) => isLocalDrive(drive) ? `local:${drive.id}` : drive.url;\n/**\n* Concatenate groups of `connect.drives.defaultDrives` in the order given,\n* de-duplicating by drive identity (URL for remote entries, id for local\n* ones). The first occurrence of a drive wins, so earlier groups keep their\n* position and metadata — e.g. the Vetra drive `ph vetra` starts stays first\n* even when the project's `powerhouse.config.json` lists the same drive.\n*/\nfunction mergeDefaultDrives(...groups) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst out = [];\n\tfor (const group of groups) for (const drive of group) {\n\t\tconst key = driveKey(drive);\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tout.push(drive);\n\t}\n\treturn out;\n}\n/**\n* Rebase a local drive URL onto a public base: keeps the /d/<slug> path,\n* swaps the loopback origin for the public base. Browser clients behind a\n* reverse proxy can't reach http://localhost:<port>. Non-loopback URLs\n* (e.g. a remote drive) are already public and pass through unchanged, as do\n* unparseable ones.\n*/\nfunction rebaseDriveUrl(driveUrl, publicBase) {\n\tlet url;\n\ttry {\n\t\turl = new URL(driveUrl);\n\t} catch {\n\t\treturn driveUrl;\n\t}\n\tif (![\n\t\t\"localhost\",\n\t\t\"127.0.0.1\",\n\t\t\"[::1]\"\n\t].includes(url.hostname)) return driveUrl;\n\treturn `${publicBase.replace(/\\/+$/, \"\")}${url.pathname}`;\n}\n/**\n* The compound's drives projection: created drives first (rebased onto the\n* public base when given), then the project's configured drives, de-duplicated\n* — and `preserve-all`, because compound-injected drive lists change per\n* launch context and must never detach drives the user added by hand.\n*/\nfunction projectDrivesIntoConnect(input) {\n\treturn { drives: {\n\t\tdefaultDrives: mergeDefaultDrives(input.createdDriveUrls.filter((url) => typeof url === \"string\" && url.length > 0).map((url) => ({\n\t\t\turl: input.publicBase ? rebaseDriveUrl(url, input.publicBase) : url,\n\t\t\tname: null,\n\t\t\ticon: null\n\t\t})), input.configuredDefaultDrives ?? []),\n\t\tpreserveStrategy: \"preserve-all\"\n\t} };\n}\n/** A served slug names a declared one as is, or hashed (`<slug>-<8 hex>`). */\nfunction servesSlug(declared, served) {\n\treturn served === declared || served.startsWith(`${declared}-`) && /^[0-9a-f]{8}$/.test(served.slice(declared.length + 1));\n}\n/** Annotates remote default drives with their backend (`sync: false` when placed on it); other remote placements become collections. */\nfunction placeConnectDrives(reactor, defaultDrives) {\n\tconst remotes = remoteBackends(reactor).flatMap(({ name, url }) => {\n\t\tconst at = switchboardOfDrive$1(url);\n\t\treturn at ? [{\n\t\t\tname,\n\t\t\tbase: at.base\n\t\t}] : [];\n\t});\n\tif (remotes.length === 0) return { defaultDrives: [...defaultDrives] };\n\tconst placement = Object.entries(reactor?.placement?.drives ?? {});\n\tconst matched = /* @__PURE__ */ new Set();\n\tconst placed = defaultDrives.map((drive) => {\n\t\tif (!(\"url\" in drive)) return drive;\n\t\tconst at = switchboardOfDrive$1(drive.url);\n\t\tconst backend = remotes.find((remote) => remote.base === at?.base)?.name;\n\t\tif (!at || !backend) return drive;\n\t\tconst entry = placement.find(([slug]) => servesSlug(slug, at.slug));\n\t\tif (entry) matched.add(entry[0]);\n\t\treturn entry?.[1] === backend ? {\n\t\t\t...drive,\n\t\t\tbackend,\n\t\t\tsync: false\n\t\t} : {\n\t\t\t...drive,\n\t\t\tbackend\n\t\t};\n\t});\n\tconst names = new Set(remotes.map((remote) => remote.name));\n\tconst collections = Object.fromEntries(placement.filter(([slug, backend]) => !matched.has(slug) && names.has(backend)).map(([slug, backend]) => [slug, {\n\t\tbackend,\n\t\tsync: false\n\t}]));\n\treturn Object.keys(collections).length > 0 ? {\n\t\tdefaultDrives: placed,\n\t\tcollections\n\t} : { defaultDrives: placed };\n}\n//#endregion\n//#region src/expect-host.ts\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction runnerOf(host) {\n\treturn isRecord(host.runner) ? host.runner : {};\n}\nfunction defaultVerbOf(host) {\n\tconst verb = runnerOf(host).defaultVerb;\n\treturn typeof verb === \"string\" ? verb : void 0;\n}\n/** At compound verb \"run\" each member runs its own defaultVerb; any other\n* compound verb is forwarded uniformly (compound.ts `memberVerbOf`). */\nfunction memberVerb(compoundVerb, member) {\n\treturn compoundVerb === \"run\" ? defaultVerbOf(member) ?? \"run\" : compoundVerb;\n}\n/** Backend names, placement-primary first (`backendsToDescriptors` order). */\nfunction orderedBackends(reactor) {\n\tconst backends = Object.entries(reactor.backends ?? {});\n\tconst primary = reactor.placement?.primary;\n\treturn [...backends.filter(([name]) => name === primary), ...backends.filter(([name]) => name !== primary)];\n}\nfunction expectBackend(name, backend, reactor) {\n\tconst out = {\n\t\tname,\n\t\tkind: backend.kind\n\t};\n\tif (backend.storage) out.storage = backend.storage.kind;\n\tif (typeof backend.storage?.dataDir === \"string\") out.dataDir = backend.storage.dataDir;\n\ttry {\n\t\tbackendToDescriptor(name, backend, reactor.protocol);\n\t} catch (error) {\n\t\tout.provisionError = error instanceof Error ? error.message : String(error);\n\t}\n\treturn out;\n}\nfunction expectDrive(declaration, source) {\n\tif (typeof declaration.slug !== \"string\") return void 0;\n\tconst remote = isRecord(declaration.remote) ? declaration.remote : void 0;\n\tconst drive = {\n\t\tslug: declaration.slug,\n\t\tkind: remote ? \"remote\" : \"local\",\n\t\tsource\n\t};\n\tif (remote && typeof remote.url === \"string\") drive.url = remote.url;\n\tif (typeof declaration.id === \"string\") drive.id = declaration.id;\n\tconst projectHash = declaration.projectHash;\n\tif (typeof projectHash === \"boolean\" || projectHash === \"id\") drive.projectHash = projectHash;\n\treturn drive;\n}\n/** The key `mergeDrivePlan` merges on: the SERVED slug, which for\n* `projectHash: true` is the hashed id (never equal to a plain slug). */\nfunction servedSlugKey(drive) {\n\treturn drive.projectHash === true ? `${drive.slug}\\0hashed` : drive.slug;\n}\n/** Contributions first, then host declarations; keyed by served slug, the\n* host wins (and keeps the contribution's position), like `mergeDrivePlan`. */\nfunction drivePlan(reactor, contributed) {\n\tconst plan = /* @__PURE__ */ new Map();\n\tfor (const { declaration, source } of contributed) {\n\t\tconst drive = expectDrive(declaration, source);\n\t\tif (drive) plan.set(servedSlugKey(drive), drive);\n\t}\n\tfor (const declaration of reactor?.drives ?? []) {\n\t\tconst drive = expectDrive(declaration, \"host\");\n\t\tif (drive) plan.set(servedSlugKey(drive), drive);\n\t}\n\treturn [...plan.values()];\n}\n/** Token facts of the host's OWN fields (a compound's `children` are its\n* members' own). */\nfunction tokenFacts(declared, kind) {\n\tconst own = kind === \"compound\" ? Object.fromEntries(Object.entries(declared).filter(([key]) => key !== \"children\")) : declared;\n\tconst sites = outputSitesOf(own);\n\tconst consumes = sites.map(({ path, ref, outputPath }) => ({\n\t\tat: path,\n\t\thost: ref.host,\n\t\t...ref.member !== void 0 ? { member: ref.member } : {},\n\t\tpath: outputPath\n\t}));\n\treturn {\n\t\tdependsOn: [...new Set(sites.map(({ ref }) => refKey(ref)))].sort(),\n\t\tconsumes,\n\t\tenv: [...new Set(envSitesOf(own).map(({ name }) => name))].sort()\n\t};\n}\nfunction expectOwn(input, verb) {\n\tconst resolved = input.resolved ?? input.declared;\n\tconst expectation = {\n\t\tname: typeof resolved.name === \"string\" ? resolved.name : \"\",\n\t\tkind: input.kind,\n\t\tverb,\n\t\t...tokenFacts(input.declared, input.kind)\n\t};\n\tif (input.kind !== \"reactor\") return expectation;\n\tconst reactor = isRecord(resolved.reactor) ? resolved.reactor : void 0;\n\tconst mode = reactorClientMode(reactor);\n\tif (mode !== void 0) expectation.clientMode = mode;\n\texpectation.multiReactor = isStructuralMultiReactor(reactor);\n\tconst backends = reactor ? orderedBackends(reactor) : [];\n\tif (reactor && backends.length > 0) {\n\t\texpectation.backends = backends.map(([name, backend]) => expectBackend(name, backend, reactor));\n\t\texpectation.remotes = backends.flatMap(([, backend]) => backend.kind === \"remote\" && typeof backend.remote?.url === \"string\" ? [backend.remote.url] : []);\n\t}\n\texpectation.drives = drivePlan(reactor, input.contributed ?? []);\n\treturn expectation;\n}\n/**\n* The expectation for one host. A reactor host's comes from its resolved\n* reactor block and contributed drives; a compound's lists its members in\n* plan order, each with the verb it runs at under the compound's own verb\n* and the members it starts after.\n*/\nfunction expectHost(input) {\n\tconst verb = defaultVerbOf(input.declared) ?? \"run\";\n\tconst expectation = expectOwn(input, verb);\n\tif (input.kind !== \"compound\" || !input.members) return expectation;\n\tconst order = input.plan?.order ?? input.members.map((m) => m.key);\n\tconst edges = input.plan?.edges ?? [];\n\tconst byKey = new Map(input.members.map((m) => [m.key, m]));\n\tconst members = {};\n\tfor (const key of order) {\n\t\tconst member = byKey.get(key);\n\t\tif (!member) continue;\n\t\tmembers[key] = {\n\t\t\thost: member.host,\n\t\t\t...expectOwn(member, memberVerb(verb, member.declared)),\n\t\t\tafter: [...new Set(edges.filter((e) => e.consumer === key).map((e) => e.producer))].sort()\n\t\t};\n\t}\n\texpectation.startOrder = order.filter((key) => byKey.has(key));\n\texpectation.members = members;\n\treturn expectation;\n}\n//#endregion\nexport { BUILTIN_ENV_NAMES, CONNECT_PLUGIN_OWNED_SLICES, CONNECT_PRIMARY_MESSAGE, CONNECT_RUNNER, HOST_NAME_MAX_LENGTH, HOST_NAME_MESSAGE, HOST_NAME_PATTERN, HostLoadError, ONE_SHOT_VERBS, ORIGIN_PLACEHOLDER, OUTPUTS_FILE, PlanError, PluginError, RunnerError, SWITCHBOARD_PROXY_PATHS, SpawnHostError, TOKEN_ESCAPE_KEY, TOKEN_KEYS, TokenResolutionError, applyChildWrapper, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, browserBackend, buildDriveDeclarationSchema, checkHost, checkOutputPaths, checkTokenSites, childWrapperSchema, childrenSchema, clearRunRecord, collectTokenSites, compoundHostSchema, compoundOutputSource, compoundWiringSchema, computeOutputsHash, concatTokenSchema, connectReactorIssues, declaredGenericCompoundHostSchema, declaredHostSchemas, defaultUserDataDir, defineHostSchemas, describeHostOutputs, describeMapElements, describeToken, driveAddressMessage, driveDeclarationSchema, drivesSchema, emitHostJsonSchema, emittedHostSchemas, entryActiveForVerb, envSitesOf, envTokenSchema, envTokenable, expectHost, explainDrivePlan, exportHost, findDeadConnectConfig, findNonStaticValue, findRemovedForms, findToken, forbidRef, formatPath, genericCompoundHostSchema, getVerb, hostExportSchema, hostNameSchema, hostSchemaIssues, hostTypeSatisfies, isBuiltinEnvName, isHtmlNavigation, isOriginPlaceholderUrl, isPidAlive, isSchemaLike, isStructuralMultiReactor, isSwitchboardProxyPath, isToken, itemTokenSchema, keyTokenSchema, kindShapeIssues, knownVerbIssues, lintHostImportGraph, lintHostImports, lintOutputsFile, listRunRecords, listVerbs, loadHost, loadProducers, makeHostSchemas, mapTokenSchema, memberForRef, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, originOrUrlSchema, outputRefsOf, outputSitesOf, outputTokenSchema, placeConnectDrives, placementKeyIssues, planCompound, pluginEntryObjectSchema, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, processResolveEnv, producerOutputsSchemas, profileSchema, projectDriveId, projectDriveIdWith, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, protocolEnvAgrees, reactorBackendKindSchema, reactorBackendSchema, reactorBlockToSwitchboardConfig, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readOutputsFileHash, readProjectName, readRunRecord, rebaseDriveUrl, ref, refKey, refineConnectReactor, refineStartOrder, registerHostType, remoteBackendUrls, remoteBackends, renderTokens, resolveDriveDeclaration, resolveHostOutputs, resolveHostPlugins, resolveOrder, resolveOriginPlaceholders, resolvePluginContributions, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runRecordMemberSchema, runRecordOutputSource, runRecordSchema, runTransformHook, runnerBaseSchema, runnerHandleSchema, runnerKindSchema, runnerOutputsSchema, scanHostImports, schemaAtPath, seedDrives, spawnHost, stripComments, substituteBuiltinEnv, switchboardOfDrive, toOriginPlaceholder, toStartedHandle, tokenKeyOf, tokenSchema, tokenable, unwrapEscapes, validateDeclaredHost, validateHost, withOriginPlaceholders, writeRunRecord };\n\n//# sourceMappingURL=index.mjs.map"],"names":["z.custom","z.strictObject","z.literal","z.string","z.record","z.prettifyError"],"mappings":";;;;;;;;;;;;;;;;AAgPA,eAAe,UAAU,MAAM,SAAS;CACvC,MAAM,SAAS;EACd,QAAQ,CAAC;EACT,UAAU,CAAC;EACX,UAAU,CAAC;CACZ;CACA,MAAM,OAAO,SAAS,KAAK;CAC3B,MAAM,QAAQ,OAAO,QAAQ,IAAI;CACjC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI;CACJ,IAAI;CACJ,IAAI;EACH,QAAQ,MAAM,SAAS,QAAQ,aAAa,IAAI,EAAA,CAAG;EACnD,SAAS,MAAM,oBAAoB,QAAQ,aAAa,KAAK,OAAO,MAAM;CAC3E,SAAS,OAAO;EACf,MAAM,QAAQ,IAAI,KAAK;EACvB,OAAO;CACR;CACA,MAAM,YAAY,KAAK,OAAO;CAC9B,IAAI,OAAO,SAAS,YAAY;EAC/B,MAAM,cAAc,QAAQ,SAAS;GACpC;GACA;GACA;GACA;GACA;EACD,CAAC;EACD,OAAO;CACR;CACA,MAAM,OAAO,aAAa,IAAI;CAC9B,MAAM,YAAY,MAAM,cAAc,QAAQ,aAAa,IAAI;CAC/D,MAAM,aAAa,QAAQ,SAAS;EACnC;EACA;EACA;EACA;EACA;EACA,iBAAiB,uBAAuB,SAAS;E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