@powerhousedao/ph-cli 6.3.0-dev.1 → 6.3.0-dev.2
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-CWm9MOFJ.mjs → build-DEARgWyg.mjs} +4 -4
- package/dist/{build-CWm9MOFJ.mjs.map → build-DEARgWyg.mjs.map} +1 -1
- package/dist/build-rj6WVkRW.mjs +4 -0
- package/dist/{check-C9kQub0h.mjs → check-C4kc91Oy.mjs} +4 -4
- package/dist/{check-C9kQub0h.mjs.map → check-C4kc91Oy.mjs.map} +1 -1
- package/dist/{check-BZOXiSys.mjs → check-CklNk7AL.mjs} +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/{connect-build-is3cmf0E.mjs → connect-build-8Y-QmOJ5.mjs} +4 -4
- package/dist/{connect-build-is3cmf0E.mjs.map → connect-build-8Y-QmOJ5.mjs.map} +1 -1
- package/dist/definitions-worker.mjs +1 -1
- package/dist/{generate-desktop-shell-Dh9_bhLa.mjs → generate-desktop-shell-BovoRsR6.mjs} +5 -5
- package/dist/generate-desktop-shell-BovoRsR6.mjs.map +1 -0
- package/dist/{get-version-CrerlHgg.mjs → get-version-DATiLAmB.mjs} +4 -4
- package/dist/{get-version-CrerlHgg.mjs.map → get-version-DATiLAmB.mjs.map} +1 -1
- package/dist/{mcp-DJKiREkL.mjs → mcp-BV_EZ15p.mjs} +4 -4
- package/dist/{mcp-DJKiREkL.mjs.map → mcp-BV_EZ15p.mjs.map} +1 -1
- package/dist/{ph-cli-commands-C6cJJQlA.mjs → ph-cli-commands--2HdnZaA.mjs} +9 -9
- package/dist/{ph-cli-commands-C6cJJQlA.mjs.map → ph-cli-commands--2HdnZaA.mjs.map} +1 -1
- package/dist/ph-cli-commands-BdA9sXDE.mjs +4 -0
- package/dist/runners/connect.mjs +1 -1
- package/dist/runners/switchboard.mjs +1 -1
- package/dist/{verify-CIWOkZZV.mjs → verify-Go5DrPvf.mjs} +4 -4
- package/dist/{verify-CIWOkZZV.mjs.map → verify-Go5DrPvf.mjs.map} +1 -1
- package/package.json +16 -16
- package/dist/build-1BN9BD49.mjs +0 -4
- package/dist/generate-desktop-shell-Dh9_bhLa.mjs.map +0 -1
- package/dist/ph-cli-commands-CCCVUIzM.mjs +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { t as runBuild } from "./build-DEARgWyg.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]="7fffa36f-9dd6-5278-a66a-f0d8dcd6d043")}catch(e){}}();
|
|
4
|
+
//# debugId=7fffa36f-9dd6-5278-a66a-f0d8dcd6d043
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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]="
|
|
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]="9d6e3692-f3d5-5779-98f1-6502fc0903f5")}catch(e){}}();
|
|
3
3
|
import { t as readProjectSubgraphs } from "./subgraphs-7OYWwP-C.mjs";
|
|
4
4
|
import { n as processStreams, r as runModelCommand } from "./run--de_-WAz.mjs";
|
|
5
5
|
import { t as renderCheckReport } from "./render-SVfj3m8A.mjs";
|
|
@@ -59,7 +59,7 @@ async function runModelCheck(args, options = {}) {
|
|
|
59
59
|
*/
|
|
60
60
|
async function runPrepackCheck(json, options) {
|
|
61
61
|
const streams = options.streams ?? processStreams;
|
|
62
|
-
const { renderReleaseDecision, verifyRelease } = await import("./verify-
|
|
62
|
+
const { renderReleaseDecision, verifyRelease } = await import("./verify-Go5DrPvf.mjs");
|
|
63
63
|
let decision;
|
|
64
64
|
try {
|
|
65
65
|
decision = verifyRelease(options.projectRoot ?? process.cwd());
|
|
@@ -77,5 +77,5 @@ async function runPrepackCheck(json, options) {
|
|
|
77
77
|
//#endregion
|
|
78
78
|
export { runModelCheck as n, definitionChecks as t };
|
|
79
79
|
|
|
80
|
-
//# sourceMappingURL=check-
|
|
81
|
-
//# debugId=
|
|
80
|
+
//# sourceMappingURL=check-C4kc91Oy.mjs.map
|
|
81
|
+
//# debugId=9d6e3692-f3d5-5779-98f1-6502fc0903f5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-
|
|
1
|
+
{"version":3,"file":"check-C4kc91Oy.mjs","sources":["../src/services/model/check.ts"],"sourcesContent":["import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport {\n checkProjectDefinitions,\n documentModelChecks,\n type ProjectDefinitions,\n subgraphChecks,\n} from \"document-model/tooling\";\nimport type { ReleaseDecision } from \"../release/approval.js\";\nimport type { ReleaseCheck } from \"../release/evidence.js\";\nimport type { ProjectModules } from \"./project.js\";\nimport { readProjectSubgraphs } from \"./subgraphs.js\";\nimport {\n type ModelRunOptions,\n processStreams,\n runModelCommand,\n} from \"./run.js\";\nimport { renderCheckReport } from \"./render.js\";\n\nasync function subgraphContributions(\n project: ProjectDefinitions,\n modules: ProjectModules,\n) {\n const subgraphs = await readProjectSubgraphs(project, modules);\n if (subgraphs === undefined) return undefined;\n return {\n checks: subgraphChecks,\n input: { subgraphs: subgraphs.input },\n inventory: subgraphs.inventory,\n };\n}\n\n/**\n * The edit and the release profile of the definition check, as `ph model\n * check` runs them and the definitions worker runs them for `ph build`.\n */\nexport const definitionChecks = {\n edit: async (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ): Promise<DefinitionCheckReport> => {\n const contributions = await subgraphContributions(project, modules);\n if (contributions === undefined) return checkProjectDefinitions(project);\n return checkProjectDefinitions(\n { ...project, ...contributions.input },\n {\n checks: [...documentModelChecks, ...contributions.checks],\n definitions: contributions.inventory,\n },\n );\n },\n release: async (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ): Promise<ReleaseCheck> => {\n const contributions = await subgraphContributions(project, modules);\n const { checkForRelease } = await import(\"../release/evidence.js\");\n return await checkForRelease(\n project,\n modules,\n contributions === undefined ? {} : { contributions },\n );\n },\n};\n\n/** `ph model check`. Returns the exit code. */\nexport async function runModelCheck(\n args: {\n readonly json: boolean;\n readonly release?: boolean;\n readonly prepack?: boolean;\n },\n options: ModelRunOptions = {},\n): Promise<number> {\n if (args.prepack) {\n if (args.release) {\n (options.streams ?? processStreams).err(\n \"ph model check could not run: --prepack and --release cannot be combined.\\n\",\n );\n return 2;\n }\n return await runPrepackCheck(args.json, options);\n }\n return await runModelCommand(\n {\n name: \"ph model check\",\n json: args.json,\n read: async (project, modules) =>\n args.release\n ? (await definitionChecks.release(project, modules)).report\n : await definitionChecks.edit(project, modules),\n render: renderCheckReport,\n },\n options,\n );\n}\n\n/**\n * `ph model check --prepack`: 0 when the release approval matches the\n * package, 1 when it does not, 2 when it cannot be checked. Loads none of\n * the package's modules.\n */\nasync function runPrepackCheck(\n json: boolean,\n options: ModelRunOptions,\n): Promise<number> {\n const streams = options.streams ?? processStreams;\n const { renderReleaseDecision, verifyRelease } =\n await import(\"../release/verify.js\");\n let decision: ReleaseDecision;\n try {\n decision = verifyRelease(options.projectRoot ?? process.cwd());\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n streams.err(`ph model check --prepack could not run: ${message}\\n`);\n return 2;\n }\n streams.out(\n `${json ? JSON.stringify({ decision: decision.decision, reasons: decision.reasons }) : renderReleaseDecision(decision)}\\n`,\n );\n return decision.decision === \"approved\" ? 0 : 1;\n}\n"],"names":[],"mappings":";;;;;;;AAkBA,eAAe,sBACb,SACA,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,IAAI;EACF,WAAW,cAAc,QAAQ,eAAe,QAAQ,IAAI,CAAC;CAC/D,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,QAAQ,IAAI,2CAA2C,QAAQ,GAAG;EAClE,OAAO;CACT;CACA,QAAQ,IACN,GAAG,OAAO,KAAK,UAAU;EAAE,UAAU,SAAS;EAAU,SAAS,SAAS;CAAQ,CAAC,IAAI,sBAAsB,QAAQ,EAAE,GACzH;CACA,OAAO,SAAS,aAAa,aAAa,IAAI;AAChD","debug_id":"9d6e3692-f3d5-5779-98f1-6502fc0903f5"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as runModelCheck, t as definitionChecks } from "./check-
|
|
1
|
+
import { n as runModelCheck, t as definitionChecks } from "./check-C4kc91Oy.mjs";
|
|
2
2
|
export { definitionChecks, runModelCheck };
|
|
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]="
|
|
4
|
-
//# debugId=
|
|
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]="5bf9e756-7cca-5a7d-85a1-4f579e78a522")}catch(e){}}();
|
|
4
|
+
//# debugId=5bf9e756-7cca-5a7d-85a1-4f579e78a522
|
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
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]="aa38e5db-5dbe-5933-859e-76cf696ddca8")}catch(e){}}();
|
|
4
|
-
import { t as getVersion } from "./get-version-
|
|
5
|
-
import { t as phCliCommands } from "./ph-cli-commands
|
|
4
|
+
import { t as getVersion } from "./get-version-DATiLAmB.mjs";
|
|
5
|
+
import { t as phCliCommands } from "./ph-cli-commands--2HdnZaA.mjs";
|
|
6
6
|
import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
|
|
7
7
|
import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
|
|
8
8
|
import { run, runSafely, subcommands } from "cmd-ts";
|
|
@@ -114,7 +114,7 @@ async function main() {
|
|
|
114
114
|
});
|
|
115
115
|
let args = process.argv.slice(2);
|
|
116
116
|
const { applyRunSugar, forwardRunnerArgv } = await import("./run-sugar-ByAIbE2x.mjs");
|
|
117
|
-
const { phCliCommands } = await import("./ph-cli-commands-
|
|
117
|
+
const { phCliCommands } = await import("./ph-cli-commands-BdA9sXDE.mjs");
|
|
118
118
|
const sugar = applyRunSugar(args, new Set(Object.keys(phCliCommands)), process.cwd());
|
|
119
119
|
if (sugar.warning) console.warn(sugar.warning);
|
|
120
120
|
args = forwardRunnerArgv(sugar.args);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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]="
|
|
3
|
-
import { t as runBuild } from "./build-
|
|
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]="9e88cdfe-a068-567c-8afe-f88f44b68e53")}catch(e){}}();
|
|
3
|
+
import { t as runBuild } from "./build-DEARgWyg.mjs";
|
|
4
4
|
import { t as buildCliConnectOverride } from "./cli-connect-override-31gBnNxd.mjs";
|
|
5
5
|
import { existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
6
6
|
import { join, resolve } from "node:path";
|
|
@@ -318,5 +318,5 @@ function assertLocalPackagesInstalled(projectPath) {
|
|
|
318
318
|
//#endregion
|
|
319
319
|
export { runConnectBuild };
|
|
320
320
|
|
|
321
|
-
//# sourceMappingURL=connect-build-
|
|
322
|
-
//# debugId=
|
|
321
|
+
//# sourceMappingURL=connect-build-8Y-QmOJ5.mjs.map
|
|
322
|
+
//# debugId=9e88cdfe-a068-567c-8afe-f88f44b68e53
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-build-is3cmf0E.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 release: 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":[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ACJ;EACA,SAAS;EACT;CACF,CAAC,GAEC,QAAQ,KACN,+EACE,SAAS,UAAU,MAAM,SAAS,YAAY,GAC/C,sEACH;AAEJ;;;;;;;AAQA,SAAgB,gBAAgB,MAAc,OAAiB,CAAC,GAAW;CACzE,IAAI,CAAC,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":"65ef61fd-628a-5787-ab8b-1bd88ccbdea7"}
|
|
1
|
+
{"version":3,"file":"connect-build-8Y-QmOJ5.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 release: 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;CAAK,CAAC,EAAA,CAExE,QACE,MACC,EAAE,OAAO,KACT,uBAAuB,MAAM,QAAQ,EAAE,KAAK,SAAS,GAAG,CAAC,CAC7D,CAAC,CACA,KAAK,MAAM,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC;AAC1C;AAEA,eAAe,QAAQ,QAAgB,SAAmC;CACxE,IAAI;EACF,MAAM,CAAC,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,GAAG,KAAK,OAAO,CAAC,CAAC;EAC9D,OAAO,EAAE,WAAW,EAAE;CACxB,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,eAAsB,kBACpB,KAC4B;CAC5B,MAAM,QAAQ,YAAY,IAAI;CAC9B,MAAM,UAAU,MAAM,YAAY,GAAG;CACrC,MAAM,SAA4B;EAChC,OAAO,QAAQ;EACf,SAAS;EACT,SAAS;EACT,YAAY;EACZ,aAAa;EACb,IAAI;CACN;C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AK,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":"9e88cdfe-a068-567c-8afe-f88f44b68e53"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
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]="edf7b6f1-f92c-5c1c-a38c-826e30b54557")}catch(e){}}();
|
|
3
3
|
import { i as readProjectDefinitions } from "./run--de_-WAz.mjs";
|
|
4
|
-
import { t as definitionChecks } from "./check-
|
|
4
|
+
import { t as definitionChecks } from "./check-C4kc91Oy.mjs";
|
|
5
5
|
//#region src/services/model/definitions-worker.ts
|
|
6
6
|
async function check(projectRoot, profile) {
|
|
7
7
|
const read = definitionChecks[profile];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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]="
|
|
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]="4108e7b8-a71a-5214-ad0f-77757e6d1569")}catch(e){}}();
|
|
3
3
|
import { g as union, i as boolean, m as string, p as strictObject, r as array, u as number } from "./schemas-DzgKfQIx.mjs";
|
|
4
4
|
import "node:module";
|
|
5
5
|
import fs from "node:fs";
|
|
@@ -9,7 +9,7 @@ import "node:url";
|
|
|
9
9
|
import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
10
10
|
import { mapBackgroundImages, validateBackground } from "@powerhousedao/shared/connect";
|
|
11
11
|
import { deflateSync } from "node:zlib";
|
|
12
|
-
//#region ../../packages/desktop/dist/
|
|
12
|
+
//#region ../../packages/desktop/dist/shell-FYHRx89Y.mjs
|
|
13
13
|
/**
|
|
14
14
|
* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:
|
|
15
15
|
* the builder ships under THEIR identity without writing Rust). It is the ONE
|
|
@@ -176,6 +176,7 @@ const appJsonSchema = strictObject({
|
|
|
176
176
|
shell: shellSourceSchema
|
|
177
177
|
});
|
|
178
178
|
const APP_JSON_FILE = "app.json";
|
|
179
|
+
path.join("dist", "node", "pieces");
|
|
179
180
|
path.join(".ph", "connect-build", "dist");
|
|
180
181
|
[
|
|
181
182
|
"update_state",
|
|
@@ -183,7 +184,6 @@ path.join(".ph", "connect-build", "dist");
|
|
|
183
184
|
"update_install"
|
|
184
185
|
].map((command) => `allow-${command.replaceAll("_", "-")}`);
|
|
185
186
|
JSON.stringify({ bundle: { createUpdaterArtifacts: false } }, null, 2) + "";
|
|
186
|
-
path.join("dist", "node", "pieces");
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region ../../packages/desktop/dist/index.mjs
|
|
189
189
|
/**
|
|
@@ -368,5 +368,5 @@ function startGenerateDesktopShell(args, cwd) {
|
|
|
368
368
|
//#endregion
|
|
369
369
|
export { startGenerateDesktopShell };
|
|
370
370
|
|
|
371
|
-
//# sourceMappingURL=generate-desktop-shell-
|
|
372
|
-
//# debugId=
|
|
371
|
+
//# sourceMappingURL=generate-desktop-shell-BovoRsR6.mjs.map
|
|
372
|
+
//# debugId=4108e7b8-a71a-5214-ad0f-77757e6d1569
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-desktop-shell-BovoRsR6.mjs","sources":["../../../packages/desktop/dist/shell-FYHRx89Y.mjs","../../../packages/desktop/dist/index.mjs","../src/services/generate-desktop-shell.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { colorVariants, imageVariants, layerStyleText, normalizeBackground, validateBackground } from \"@powerhousedao/shared/connect\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\nimport { execSync, spawn, spawnSync } from \"node:child_process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { normalizePluginEntries } from \"@powerhousedao/host-core\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\n//#region src/release.ts\n/**\n* What a build of an app with updates leaves for its release (app.json\n* `updates`): under `<shell>/target/release/bundle/release/`, every installer\n* it made, under a name no host rewrites, and the feed file that tells the\n* running apps of this system about them. Attach every file in that folder to\n* the release and the apps find it.\n*\n* One feed file per system and processor (`latest-linux-x86_64.json`), not one\n* for the whole release: each system builds in its own job, and a job that\n* fails then costs its own users the update and nobody else's. The app asks\n* for its own file by name (FEED_FILE_TEMPLATE).\n*/\n/** Under the bundle folder: this build's release files. */\nconst RELEASE_DIR = \"release\";\n/** The feed file a build writes for its system and processor. */\nfunction feedFileName(os, arch) {\n\treturn `latest-${os}-${arch}.json`;\n}\n/** That name in a feed address: the updater fills in the running app's own\n* system (linux, darwin, windows) and processor (x86_64, aarch64, …). */\nconst FEED_FILE_TEMPLATE = \"latest-{{target}}-{{arch}}.json\";\n/** The updater's names for the systems and processors Node reports. */\nconst UPDATER_OS = {\n\tlinux: \"linux\",\n\tdarwin: \"darwin\",\n\twin32: \"windows\"\n};\nconst UPDATER_ARCH = {\n\tx64: \"x86_64\",\n\tarm64: \"aarch64\",\n\tia32: \"i686\",\n\tarm: \"armv7\"\n};\nconst ARTIFACTS = {\n\tlinux: [\n\t\t{\n\t\t\tdir: \"deb\",\n\t\t\tsuffix: \".deb\",\n\t\t\tinstaller: \"deb\"\n\t\t},\n\t\t{\n\t\t\tdir: \"rpm\",\n\t\t\tsuffix: \".rpm\",\n\t\t\tinstaller: \"rpm\"\n\t\t},\n\t\t{\n\t\t\tdir: \"appimage\",\n\t\t\tsuffix: \".AppImage\",\n\t\t\tinstaller: \"appimage\"\n\t\t}\n\t],\n\twin32: [{\n\t\tdir: \"nsis\",\n\t\tsuffix: \"-setup.exe\",\n\t\tinstaller: \"nsis\"\n\t}],\n\tdarwin: [{\n\t\tdir: \"dmg\",\n\t\tsuffix: \".dmg\"\n\t}, {\n\t\tdir: \"macos\",\n\t\tsuffix: \".app.tar.gz\",\n\t\tinstaller: \"app\"\n\t}]\n};\n/** A file name every host keeps as it is: GitHub rewrites a space (and most\n* punctuation) in a release file's name to a dot, and a feed that names the\n* file as it was built would then point at nothing. */\nfunction releaseFileName(name) {\n\treturn name.replace(/[^A-Za-z0-9._-]/g, \".\");\n}\n/**\n* Where a release's files are downloaded from: PH_DESKTOP_RELEASE_URL when\n* set, else the GitHub release of app.json's `updates.github` under this\n* build's tag (the tag a workflow runs for, else `v<version>`). null when\n* neither says: the build then writes no feed file.\n*/\nfunction releaseBaseUrl(updates, version, env) {\n\tconst given = env.PH_DESKTOP_RELEASE_URL?.trim();\n\tif (given) {\n\t\tlet url = null;\n\t\ttry {\n\t\t\turl = new URL(given);\n\t\t} catch {}\n\t\tif (url?.protocol !== \"https:\") throw new Error(`PH_DESKTOP_RELEASE_URL must be the https address the release's files are downloaded from, not \"${given}\".`);\n\t\treturn given.replace(/\\/+$/, \"\");\n\t}\n\tif (!updates.github) return null;\n\tconst tag = env.GITHUB_REF_TYPE === \"tag\" && env.GITHUB_REF_NAME ? env.GITHUB_REF_NAME : `v${version ?? \"0.1.0\"}`;\n\treturn `https://github.com/${updates.github}/releases/download/${encodeURIComponent(tag)}`;\n}\n/** A second's slack: some filesystems keep a file's time to the second. */\nconst TIME_SLACK_MS = 1e3;\n/** Gathers this build's release files and writes its feed file. */\nfunction collectRelease(input) {\n\tconst platform = input.platform ?? process.platform;\n\tconst os = UPDATER_OS[platform];\n\tconst arch = UPDATER_ARCH[input.arch ?? process.arch];\n\tconst dir = path.join(input.bundleDir, RELEASE_DIR);\n\tfs.rmSync(dir, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfs.mkdirSync(dir, { recursive: true });\n\tconst result = {\n\t\tdir,\n\t\tfiles: [],\n\t\tfeed: null,\n\t\ttargets: [],\n\t\tunsigned: []\n\t};\n\tif (!os || !arch) return result;\n\tconst fresh = (file) => fs.existsSync(file) && (input.since === void 0 || fs.statSync(file).mtimeMs >= input.since - TIME_SLACK_MS);\n\tconst platforms = {};\n\tfor (const artifact of ARTIFACTS[platform] ?? []) {\n\t\tconst from = path.join(input.bundleDir, artifact.dir);\n\t\tif (!fs.existsSync(from)) continue;\n\t\tconst built = fs.readdirSync(from).filter((name) => name.endsWith(artifact.suffix)).map((name) => path.join(from, name)).filter((file) => fs.statSync(file).isFile() && fresh(file)).sort((a, b) => fs.statSync(a).mtimeMs - fs.statSync(b).mtimeMs);\n\t\tfor (const file of built) {\n\t\t\tconst name = releaseFileName(artifact.installer === \"app\" ? `${input.productName}_${input.version}_${arch}${artifact.suffix}` : path.basename(file));\n\t\t\tfs.copyFileSync(file, path.join(dir, name), fs.constants.COPYFILE_FICLONE);\n\t\t\tresult.files.push(name);\n\t\t\tif (!artifact.installer) continue;\n\t\t\tconst signatureFile = `${file}.sig`;\n\t\t\tif (!fresh(signatureFile)) {\n\t\t\t\tresult.unsigned.push(name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (input.baseUrl === null) continue;\n\t\t\tplatforms[`${os}-${arch}-${artifact.installer}`] = {\n\t\t\t\tsignature: fs.readFileSync(signatureFile, \"utf8\").trim(),\n\t\t\t\turl: `${input.baseUrl}/${name}`\n\t\t\t};\n\t\t}\n\t}\n\tresult.targets = Object.keys(platforms).sort();\n\tif (result.targets.length > 0) {\n\t\tconst feed = feedFileName(os, arch);\n\t\tfs.writeFileSync(path.join(dir, feed), JSON.stringify({\n\t\t\tversion: input.version,\n\t\t\tpub_date: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),\n\t\t\tplatforms\n\t\t}, null, 2) + \"\\n\");\n\t\tresult.feed = feed;\n\t\tresult.files.push(feed);\n\t}\n\treturn result;\n}\n/** What a build says about the release files it gathered. */\nfunction releaseReport(release, releaseUrl) {\n\tif (release.files.length === 0) return [\"no release files: the build made no installer.\"];\n\tconst lines = [`release files in ${release.dir}:`];\n\tfor (const file of release.files) lines.push(` ${file}`);\n\tfor (const file of release.unsigned) lines.push(`${file} has no signature, so the feed does not offer it.`);\n\tif (release.feed) lines.push(`${release.feed} offers ${release.targets.join(\", \")} from ${releaseUrl}: attach every file in that folder to the release there.`);\n\telse if (releaseUrl === null) lines.push(\"no feed file: set PH_DESKTOP_RELEASE_URL to the address the release's files are downloaded from (app.json names its own feed, not a GitHub repository).\");\n\treturn lines;\n}\n//#endregion\n//#region src/app-json.ts\n/**\n* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:\n* the builder ships under THEIR identity without writing Rust). It is the ONE\n* file a builder edits; `shell-project.ts` projects it into a generated\n* `tauri-shell/` that depends on the published `ph-desktop-shell` crate. Every\n* field validates strictly so a typo fails with the field named, not silently.\n*/\nconst identifierSchema = z.string().min(1).regex(/^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)+$/, \"identifier must be reverse-DNS (e.g. com.acme.app): dot-separated alphanumeric segments\");\nconst windowSchema = z.strictObject({\n\ttitle: z.string().min(1).optional(),\n\twidth: z.number().int().positive().optional(),\n\theight: z.number().int().positive().optional(),\n\tresizable: z.boolean().optional(),\n\t/** Smallest size the window can be dragged to (logical pixels). */\n\tminWidth: z.number().int().positive().optional(),\n\tminHeight: z.number().int().positive().optional()\n}).optional();\nconst cssColorSchema = z.string().regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, \"use a hex color (#rgb, #rgba, #rrggbb or #rrggbbaa)\");\n/** The loading page's colors. */\nconst loadingColorsSchema = z.strictObject({\n\t/** Page background (default #0f1115). */\n\tbackground: cssColorSchema.nullable().optional(),\n\t/** Status text color (default #e6e8eb). */\n\tcolor: cssColorSchema.nullable().optional(),\n\t/** The pulsing status dot (default #4ade80). */\n\taccent: cssColorSchema.nullable().optional()\n});\n/** The loading page's look, so the window opens in the app's own colors\n* instead of the default dark page. Every field is optional, and `null`\n* means the default (the scaffold lists the fields that way). */\nconst loadingSchema = loadingColorsSchema.extend({\n\t/** Status line under the art (default \"Starting <productName>…\"). */\n\tmessage: z.string().min(1).nullable().optional(),\n\t/** Colors for `prefers-color-scheme: dark`; without it the page keeps\n\t* the light colors in both schemes. */\n\tdark: loadingColorsSchema.nullable().optional(),\n\t/** Deprecated: a decoration pinned to the bottom-right corner, relative\n\t* to app.json, with `artDark` its dark-scheme counterpart. Superseded by\n\t* the top-level `background`, which ignores these when set. */\n\tart: z.string().min(1).nullable().optional(),\n\tartDark: z.string().min(1).nullable().optional()\n}).nullable().optional();\nconst imageRefSchema = z.string().min(1);\nconst schemedImageSchema = z.union([imageRefSchema, z.strictObject({\n\tlight: imageRefSchema,\n\tdark: imageRefSchema.nullable().optional()\n})]);\nconst lengthSchema = z.union([z.number(), z.string().min(1)]).nullable().optional();\nconst edgesSchema = z.strictObject({\n\ttop: lengthSchema,\n\tright: lengthSchema,\n\tbottom: lengthSchema,\n\tleft: lengthSchema\n}).nullable().optional();\nconst backgroundLayerSchema = z.strictObject({\n\tsrc: schemedImageSchema,\n\tposition: edgesSchema,\n\twidth: lengthSchema,\n\theight: lengthSchema,\n\tminWidth: lengthSchema,\n\tminHeight: lengthSchema,\n\tmaxWidth: lengthSchema,\n\tmaxHeight: lengthSchema,\n\topacity: z.number().min(0).max(1).nullable().optional(),\n\tfade: edgesSchema\n});\nconst backgroundSchema = z.union([imageRefSchema, z.strictObject({\n\tcolor: z.union([z.string().min(1), z.strictObject({\n\t\tlight: z.string().min(1),\n\t\tdark: z.string().min(1).nullable().optional()\n\t})]).nullable().optional(),\n\tlayers: z.array(backgroundLayerSchema)\n})]).superRefine((background, ctx) => {\n\tfor (const problem of validateBackground(background, \"background\")) ctx.addIssue({\n\t\tcode: \"custom\",\n\t\tmessage: problem\n\t});\n}).nullable().optional();\nconst fileAssociationSchema = z.strictObject({\n\t/** Extensions WITHOUT the leading dot (\"phd\", not \".phd\"). */\n\text: z.array(z.string().min(1).regex(/^[^.]/, \"drop the leading dot\")).min(1),\n\tname: z.string().min(1),\n\tdescription: z.string().optional(),\n\tmimeType: z.string().optional()\n});\n/** Where the generated Cargo.toml resolves `ph-desktop-shell` from. Default\n* (omitted) = the published crates.io version. */\nconst shellSourceSchema = z.strictObject({\n\t/** Local checkout for shell development (the lab points here). */\n\tpath: z.string().min(1).optional(),\n\t/** Git source, pinned to a tag/rev, for pre-publication consumption. */\n\tgit: z.string().min(1).optional(),\n\ttag: z.string().min(1).optional(),\n\trev: z.string().min(1).optional(),\n\t/** crates.io version requirement (default DEFAULT_SHELL_CRATE_VERSION). */\n\tversion: z.string().min(1).optional()\n}).refine((s) => !(s.path && s.git), { message: \"shell.source: set path OR git, not both\" }).optional();\n/** What is wrong with a release key, or null. The public half is base64 of a\n* minisign public key, as `tauri signer generate` writes its .pub file; the\n* private half looks alike at a glance and must never land in app.json. */\nfunction pubkeyProblem(value) {\n\tconst text = Buffer.from(value.trim(), \"base64\").toString(\"utf8\");\n\tif (/secret key/i.test(text)) return \"this is the PRIVATE key: put the public one here (the .pub file) and keep the private one in your CI secrets\";\n\tif (!/^untrusted comment: minisign public key/i.test(text)) return \"not an update signing key: paste the content of the .pub file `tauri signer generate` writes\";\n\treturn null;\n}\n/** An update feed's address: https, as a release build asks nothing else. */\nconst feedUrlSchema = z.string().refine((value) => {\n\ttry {\n\t\treturn new URL(value).protocol === \"https:\";\n\t} catch {\n\t\treturn false;\n\t}\n}, \"an update feed must be an https address\");\n/** Updates, for an app that wants them: where it asks for a newer version and\n* the key its releases are signed with. The window then offers each newer\n* release, downloads it, checks its signature and installs it. Omitted or\n* null: the app never asks, and is installed by hand as before. */\nconst updatesSchema = z.strictObject({\n\t/** The GitHub repository whose releases carry the app (\"owner/name\"): the\n\t* app asks its latest release for the feed file a build of its system\n\t* wrote (release.ts). */\n\tgithub: z.string().regex(/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/, \"use \\\"owner/repository\\\"\").optional(),\n\t/** Or the feed's own addresses, asked in order. `{{target}}` and\n\t* `{{arch}}` in one stand for the running app's system and processor,\n\t* as in the feed file's name: `latest-{{target}}-{{arch}}.json`. */\n\tendpoints: z.array(feedUrlSchema).min(1).optional(),\n\t/** The public key the releases are signed with: the content of the .pub\n\t* file `tauri signer generate` writes. The private key signs each build\n\t* (TAURI_SIGNING_PRIVATE_KEY) and stays out of the repository. */\n\tpubkey: z.string().min(1).superRefine((value, ctx) => {\n\t\tconst problem = pubkeyProblem(value);\n\t\tif (problem) ctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tmessage: problem\n\t\t});\n\t})\n}).refine((u) => Boolean(u.github) !== Boolean(u.endpoints), { message: \"updates: set github OR endpoints\" }).nullable().optional();\nconst appJsonSchema = z.strictObject({\n\tidentifier: identifierSchema,\n\tproductName: z.string().min(1),\n\t/** Ask who is using the app before anything runs: the stack then starts for\n\t* that identity, with its own folder and as its admin. Off, the stack starts\n\t* with the window, in one store. */\n\tsignIn: z.boolean().nullable().optional(),\n\t/** Single source image (square PNG, 1024×1024 recommended); the icon set\n\t* for every platform is generated from it via `tauri icon`. */\n\ticon: z.string().min(1),\n\t/** The loading page's background: images positioned and sized over a\n\t* page colour (`{ color, layers }`), or one image pinned bottom-right.\n\t* The status line stays centred above them. `ph generate desktop-shell`\n\t* copies Connect's `connect.branding.homeBackground` here. null or\n\t* omitted: the app icon (or `splash`) above the status line. */\n\tbackground: backgroundSchema,\n\t/** Deprecated in favour of `background`: a wide splash image shown above\n\t* the status line instead of the square icon. Relative to this file. */\n\tsplash: z.string().min(1).nullable().optional(),\n\t/** Deprecated with `splash`: its `prefers-color-scheme: dark` variant. */\n\tsplashDark: z.string().min(1).nullable().optional(),\n\tloading: loadingSchema,\n\twindow: windowSchema,\n\tfileAssociations: z.array(fileAssociationSchema).optional(),\n\tupdates: updatesSchema,\n\tshell: shellSourceSchema\n});\n/** Where an app with updates asks for a newer version. */\nfunction updateEndpoints(updates) {\n\treturn updates.endpoints ?? [`https://github.com/${updates.github}/releases/latest/download/latest-{{target}}-{{arch}}.json`];\n}\n/** Default crates.io version requirement for the shell crate (D7.b: the flip\n* to crates.io default once published — the crate is live). A floor, not just\n* a series: 0.1.0 can't run a stack from ph-run and 0.1.1 has no updater (an\n* app with `updates` would build and never ask), and a Cargo.lock that still\n* holds one of them satisfies \"0.1\", so a builder's lock would keep it\n* forever. The 0.1.x-dev.N releases sort below 0.1.x and never match either. */\nconst DEFAULT_SHELL_CRATE_VERSION = \"0.1.2\";\nconst APP_JSON_FILE = \"app.json\";\n/** Read + validate hosts/<host>/app.json. Throws with the field named on a\n* bad value, and a clear message when the file is absent. */\nfunction loadAppJson(hostDir) {\n\tconst file = path.join(hostDir, APP_JSON_FILE);\n\tif (!fs.existsSync(file)) throw new Error(`No ${APP_JSON_FILE} in ${hostDir} — run \\`ph generate desktop-shell\\` to scaffold the builder identity, or set runner.shell.project to a prebuilt shell.`);\n\tlet raw;\n\ttry {\n\t\traw = JSON.parse(fs.readFileSync(file, \"utf8\"));\n\t} catch (error) {\n\t\tthrow new Error(`${file}: not valid JSON — ${String(error)}`, { cause: error });\n\t}\n\tconst result = appJsonSchema.safeParse(raw);\n\tif (!result.success) {\n\t\tconst issues = result.error.issues.map((i) => ` ${i.path.join(\".\") || \"(root)\"}: ${i.message}`).join(\"\\n\");\n\t\tthrow new Error(`${file} is invalid:\\n${issues}`);\n\t}\n\treturn result.data;\n}\n/** A filesystem/crate-safe slug of the product name — the generated binary\n* and Cargo package name. Falls back to the identifier's last segment. */\nfunction appSlug(app) {\n\tconst fromName = app.productName.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n\tif (fromName) return fromName;\n\treturn (app.identifier.split(\".\").pop() ?? \"app\").toLowerCase().replace(/[^a-z0-9]+/g, \"-\");\n}\n//#endregion\n//#region src/bundle-backend.ts\n/**\n* A packaged stack is a node_modules folder, and Windows installs by the file:\n* tens of thousands of them take as long to install as to uninstall, and a\n* start spends most of a cold disk's time reading them. This folds the stack\n* into a few hundred files with Rolldown, in the staged copy only.\n*\n* What's loaded by name keeps working by name. Each package an add-on, a host\n* file or the project's own build may import stays in node_modules with its\n* \\`exports\\`, and each of those is a Rolldown entry, so an import of\n* \\`document-model\\` from anywhere reaches the one bundled copy. Two copies would\n* break \\`instanceof\\` and shared state, and without an error.\n*\n* What's found by path keeps its path. Chunks and the worker scripts go in one\n* package, so a chunk finds \\`./entry.mjs\\` beside it and the piece worker's walk\n* up to a package.json finds \\`dist/worker-entry.js\\`.\n*/\n/** Holds the chunks. A package, so the piece worker's lookup stops at it. */\nconst CHUNKS_DIR = \".stack\";\n/** Packages reached by name, by something that isn't in the bundle. */\nconst BY_NAME = [\n\t/^@powerhousedao\\//,\n\t/^@renown\\/sdk$/,\n\t/^document-model$/,\n\t/^graphql$/,\n\t/^graphql-tag$/,\n\t/^kysely$/,\n\t/^zod$/\n];\n/**\n* Left as files. PGlite finds its wasm and data beside it. React is what an\n* add-on's editor imports, and a server never calls it. The rest is only loaded\n* on a path a running app never takes, or by a native addon.\n*/\nconst EXTERNAL = [\n\t/\\.node$/,\n\t/^@electric-sql\\/pglite/,\n\t/^pglite-(legacy|tools)/,\n\t/^react($|\\/)/,\n\t/^react-dom($|\\/)/,\n\t/^vite($|\\/)/,\n\t/^@powerhousedao\\/vetra($|\\/)/,\n\t/^@originjs\\//,\n\t/^devcert$/,\n\t/^pg-native$/,\n\t/^bufferutil$/,\n\t/^utf-8-validate$/,\n\t/^@pyroscope\\//\n];\n/** How Rolldown writes a require it can't fold. A plain `require(` in a chunk is\n* text: a package's comments, error messages and generated code. */\nconst REQUIRE_CALL = /\\b__require\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/g;\n/** A package's built workflow pieces, which the piece worker loads by path. */\nconst PIECES_DIR = path.join(\"dist\", \"node\", \"pieces\");\n/** Copied into a kept package as they are, since a path reaches them. */\nconst KEEP_AS_FILES = [PIECES_DIR];\n/** Whether the stack provides a package by name, as one bundled copy. */\nconst loadedByName = (name) => BY_NAME.some((pattern) => pattern.test(name));\n/** What a package exports for a server: node, then import, then default. */\nfunction serverTarget(target) {\n\tif (typeof target === \"string\") return target;\n\tif (target === null || target === void 0) return null;\n\tfor (const condition of [\n\t\t\"node\",\n\t\t\"import\",\n\t\t\"default\"\n\t]) if (condition in target) {\n\t\tconst found = serverTarget(target[condition]);\n\t\tif (found) return found;\n\t}\n\treturn null;\n}\n/** Every subpath a package offers a server, with a wildcard's matches listed. */\nfunction exportedFiles(packageDir, manifest) {\n\tconst files = /* @__PURE__ */ new Map();\n\tconst exports = typeof manifest.exports === \"string\" ? { \".\": manifest.exports } : manifest.exports;\n\tif (!exports) {\n\t\tconst main = manifest.module ?? manifest.main ?? \"index.js\";\n\t\tconst file = [\n\t\t\tmain,\n\t\t\t`${main}.js`,\n\t\t\tpath.join(main, \"index.js\")\n\t\t].find((candidate) => isFile(path.join(packageDir, candidate)));\n\t\tif (file) files.set(\".\", file.replace(/^\\.\\//, \"\"));\n\t\treturn files;\n\t}\n\tfor (const [subpath, target] of Object.entries(exports)) {\n\t\tif (subpath === \"./package.json\") continue;\n\t\tconst file = serverTarget(target);\n\t\tif (!file) continue;\n\t\tif (!subpath.includes(\"*\")) {\n\t\t\tif (isFile(path.join(packageDir, file))) files.set(subpath, file.replace(/^\\.\\//, \"\"));\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const [match, found] of wildcardMatches(packageDir, file)) files.set(subpath.replace(\"*\", match), found);\n\t}\n\treturn files;\n}\nfunction isFile(file) {\n\treturn fs.existsSync(file) && fs.statSync(file).isFile();\n}\nfunction wildcardMatches(packageDir, target) {\n\tconst [before, after = \"\"] = target.replace(/^\\.\\//, \"\").split(\"*\");\n\tconst parent = before.endsWith(\"/\") ? before : path.posix.dirname(before);\n\tconst prefix = before.slice(parent.length).replace(/^\\//, \"\");\n\tconst matches = [];\n\tconst folder = path.join(packageDir, parent);\n\tif (!fs.existsSync(folder)) return matches;\n\tfor (const entry of fs.readdirSync(folder, { withFileTypes: true })) {\n\t\tconst name = entry.name;\n\t\tconst match = after.startsWith(\"/\") ? name : name.endsWith(after) && name.startsWith(prefix) ? name.slice(prefix.length, name.length - after.length) : null;\n\t\tif (!match) continue;\n\t\tconst file = path.posix.join(parent, `${prefix}${match}${after}`);\n\t\tif (isFile(path.join(packageDir, file))) matches.push([match, file]);\n\t}\n\treturn matches;\n}\n/** Where a subpath's entry lands in its package. */\nfunction entryNameOf(pkg, subpath) {\n\treturn `${pkg}/${subpath === \".\" ? \"index\" : subpath.replace(/^\\.\\//, \"\").replaceAll(\"/\", \"__\")}`;\n}\n/** The package.json of a package whose code is now in the bundle. */\nfunction keptManifest(manifest, entries) {\n\tconst { name, version } = manifest;\n\tconst exports = { \"./package.json\": \"./package.json\" };\n\tfor (const [subpath, file] of entries) exports[subpath] = `./${file}`;\n\treturn {\n\t\tname,\n\t\tversion,\n\t\ttype: \"module\",\n\t\texports\n\t};\n}\n/** Nearest install of \\`dependency\\` as seen from \\`from\\`, by node's rules. */\nfunction resolveInLock(lock, from, dependency) {\n\tlet at = from;\n\tfor (;;) {\n\t\tconst candidate = `${at ? `${at}/` : \"\"}node_modules/${dependency}`;\n\t\tif (lock[candidate]) return candidate;\n\t\tif (!at) return null;\n\t\tconst cut = at.lastIndexOf(\"node_modules/\");\n\t\tat = cut <= 0 ? \"\" : at.slice(0, cut - 1);\n\t}\n}\n/** The install paths of `names` and everything they depend on, and with\n* `peers` each peer that is installed, which a package may load by name. */\nfunction closureOf(lock, names, { peers = false } = {}) {\n\tconst kept = /* @__PURE__ */ new Set();\n\tconst queue = [...names].map((name) => `node_modules/${name}`).filter((key) => lock[key]);\n\twhile (queue.length > 0) {\n\t\tconst key = queue.pop();\n\t\tif (kept.has(key)) continue;\n\t\tkept.add(key);\n\t\tconst entry = lock[key];\n\t\tfor (const dependency of Object.keys({\n\t\t\t...entry.dependencies,\n\t\t\t...entry.optionalDependencies,\n\t\t\t...peers ? entry.peerDependencies : {}\n\t\t})) {\n\t\t\tconst target = resolveInLock(lock, key, dependency);\n\t\t\tif (target) queue.push(target);\n\t\t}\n\t}\n\treturn kept;\n}\n/** The package a bare specifier belongs to, or null for a built-in or a path. */\nfunction packageOf$1(specifier) {\n\tif (specifier.startsWith(\".\") || specifier.startsWith(\"/\")) return null;\n\tif (specifier.startsWith(\"node:\") || /^[a-z]+:/i.test(specifier)) return null;\n\tconst parts = specifier.split(\"/\");\n\treturn specifier.startsWith(\"@\") ? parts.slice(0, 2).join(\"/\") : parts[0];\n}\n/** One file of every package's licence, as a bundle can't keep them beside\n* the code. Packages under the same text share it. */\nfunction licencesOf(modules, packages) {\n\tconst byText = /* @__PURE__ */ new Map();\n\tlet count = 0;\n\tfor (const name of packages) {\n\t\tconst dir = path.join(modules, name);\n\t\tif (!fs.existsSync(dir)) continue;\n\t\tconst text = fs.readdirSync(dir).filter((file) => /^(licen[sc]e|copying|notice)/i.test(file) && isFile(path.join(dir, file))).sort().map((file) => fs.readFileSync(path.join(dir, file), \"utf8\").trim()).join(\"\\n\\n\");\n\t\tconst manifest = readJson(path.join(dir, \"package.json\"));\n\t\tconst label = `${name}@${String(manifest.version ?? \"\")}`;\n\t\tconst key = text || `License: ${JSON.stringify(manifest.license ?? \"unknown\")}`;\n\t\tbyText.set(key, [...byText.get(key) ?? [], label]);\n\t\tcount++;\n\t}\n\treturn {\n\t\ttext: [...byText.entries()].map(([text, labels]) => `${labels.join(\"\\n\")}\\n\\n${text}\\n`).join(`\\n${\"-\".repeat(72)}\\n\\n`),\n\t\tpackages: count\n\t};\n}\nfunction dependenciesOf(manifest) {\n\treturn Object.keys({\n\t\t...manifest.dependencies,\n\t\t...manifest.optionalDependencies\n\t});\n}\n/** Whether code names a package in quotes, as an import or a resolve does. */\nfunction namesPackage(code, name) {\n\tconst escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\treturn new RegExp(`[\"'\\`]${escaped}(?:/[^\"'\\`]*)?[\"'\\`]`).test(code);\n}\n/**\n* What a package's pieces load, besides what the stack provides by name: what\n* their manifests name, and those of `dependencies` their code names. A\n* manifest names only what the piece build traced, and to that build a loader\n* the piece resolves at run time is a string.\n*/\nfunction piecesLoad(packageDir, dependencies) {\n\tconst pieces = path.join(packageDir, PIECES_DIR);\n\tif (!fs.existsSync(pieces)) return [];\n\tconst files = fs.readdirSync(pieces, {\n\t\trecursive: true,\n\t\tencoding: \"utf8\"\n\t}).map((file) => path.join(pieces, file)).filter(isFile);\n\tconst declared = files.filter((file) => path.basename(file) === \"package.json\").flatMap((file) => dependenciesOf(readJson(file)));\n\tconst code = files.filter((file) => /\\.[cm]?js$/.test(file)).map((file) => fs.readFileSync(file, \"utf8\"));\n\tconst named = [...dependencies].filter((name) => code.some((text) => namesPackage(text, name)));\n\treturn [.../* @__PURE__ */ new Set([...declared, ...named])].filter((name) => !loadedByName(name));\n}\nfunction readJson(file) {\n\treturn JSON.parse(fs.readFileSync(file, \"utf8\"));\n}\nfunction packagesIn(modules) {\n\tconst names = [];\n\tfor (const entry of fs.readdirSync(modules, { withFileTypes: true })) {\n\t\tif (!entry.isDirectory() || entry.name.startsWith(\".\")) continue;\n\t\tif (!entry.name.startsWith(\"@\")) {\n\t\t\tnames.push(entry.name);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const scoped of fs.readdirSync(path.join(modules, entry.name))) names.push(`${entry.name}/${scoped}`);\n\t}\n\treturn names;\n}\n/** `__dirname` and `require` per chunk, as a banner collides with any code that\n* declares its own. */\nconst nodeGlobals = {\n\tname: \"ph:node-globals\",\n\trenderChunk(code) {\n\t\tconst declared = (name) => new RegExp(`\\\\b(?:const|let|var|function)\\\\s+${name}\\\\b`).test(code);\n\t\tconst used = (name) => new RegExp(`(?<![.\\\\w$])${name}\\\\b`).test(code);\n\t\tconst wanted = [\n\t\t\t\"__filename\",\n\t\t\t\"__dirname\",\n\t\t\t\"require\"\n\t\t].filter((name) => used(name) && !declared(name));\n\t\tif (wanted.length === 0) return null;\n\t\tconst lines = [`import { fileURLToPath as __ph_path } from \"node:url\";`];\n\t\tif (wanted.includes(\"__dirname\")) {\n\t\t\tlines.push(`import { dirname as __ph_dir } from \"node:path\";`);\n\t\t\tlines.push(`const __dirname = __ph_dir(__ph_path(import.meta.url));`);\n\t\t}\n\t\tif (wanted.includes(\"__filename\")) lines.push(`const __filename = __ph_path(import.meta.url);`);\n\t\tif (wanted.includes(\"require\")) {\n\t\t\tlines.push(`import { createRequire as __ph_require } from \"node:module\";`);\n\t\t\tlines.push(`const require = __ph_require(import.meta.url);`);\n\t\t}\n\t\treturn {\n\t\t\tcode: `${lines.join(\"\\n\")}\\n${code}`,\n\t\t\tmap: null\n\t\t};\n\t}\n};\n/** Replaces a staged stack's node_modules with a bundle of it. */\nasync function bundleBackend(options) {\n\tconst log = options.logger ?? (() => void 0);\n\tconst { stackDir } = options;\n\tconst modules = path.join(stackDir, \"node_modules\");\n\tconst output = path.join(stackDir, \".bundle-output\");\n\tfs.rmSync(output, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tconst lock = readJson(path.join(stackDir, \"package-lock.json\")).packages;\n\tconst installed = packagesIn(modules);\n\tconst byName = installed.filter(loadedByName);\n\tconst input = {};\n\tconst entriesOf = /* @__PURE__ */ new Map();\n\tconst kept = /* @__PURE__ */ new Map();\n\tfor (const name of byName) {\n\t\tconst dir = path.join(modules, name);\n\t\tconst manifest = readJson(path.join(dir, \"package.json\"));\n\t\tkept.set(name, manifest);\n\t\tconst entries = /* @__PURE__ */ new Map();\n\t\tfor (const [subpath, file] of exportedFiles(dir, manifest)) {\n\t\t\tif (!/\\.[cm]?js$/.test(file)) continue;\n\t\t\tconst entry = entryNameOf(name, subpath);\n\t\t\tinput[entry] = path.join(dir, file);\n\t\t\tentries.set(subpath, `${path.posix.basename(entry)}.mjs`);\n\t\t}\n\t\tentriesOf.set(name, entries);\n\t}\n\tinput[\"@powerhousedao/ph-run/dist/cli\"] = path.join(modules, \"@powerhousedao/ph-run/dist/cli.mjs\");\n\tinput[`${CHUNKS_DIR}/entry`] = path.join(modules, \"@powerhousedao/reactor-api/dist/src/pglite/worker/entry.mjs\");\n\tinput[`${CHUNKS_DIR}/dist/worker-entry`] = path.join(modules, \"@powerhousedao/reactor-workflow/dist/worker-entry.js\");\n\tfor (const [entry, file] of Object.entries(input)) if (!fs.existsSync(file)) throw new Error(`no entry ${entry} at ${file}`);\n\tlog(` bundling ${Object.keys(input).length} entries of ${byName.length} packages…`);\n\tconst { rolldown } = await import(\"rolldown\");\n\tconst build = await rolldown({\n\t\tcwd: stackDir,\n\t\tinput,\n\t\tplatform: \"node\",\n\t\texternal: EXTERNAL,\n\t\tonLog() {},\n\t\tplugins: [nodeGlobals]\n\t});\n\tconst { output: written } = await build.write({\n\t\tdir: output,\n\t\tformat: \"esm\",\n\t\tentryFileNames: (chunk) => chunk.name === `${CHUNKS_DIR}/dist/worker-entry` ? `${CHUNKS_DIR}/dist/worker-entry.js` : \"[name].mjs\",\n\t\tchunkFileNames: `${CHUNKS_DIR}/[name]-[hash].mjs`,\n\t\tkeepNames: true,\n\t\tsourcemap: false\n\t});\n\tawait build.close();\n\tconst ownFiles = new Set(written.map((file) => file.fileName));\n\tconst reached = /* @__PURE__ */ new Set();\n\tfor (const file of written) {\n\t\tif (file.type !== \"chunk\") continue;\n\t\tfor (const specifier of [...file.imports, ...file.dynamicImports]) {\n\t\t\tconst name = ownFiles.has(specifier) ? null : packageOf$1(specifier);\n\t\t\tif (name) reached.add(name);\n\t\t}\n\t\tfor (const [, specifier] of file.code.matchAll(REQUIRE_CALL)) {\n\t\t\tconst name = packageOf$1(specifier);\n\t\t\tif (name && lock[`node_modules/${name}`]) reached.add(name);\n\t\t}\n\t}\n\tconst pieceRoots = [...piecesLoad(stackDir, dependenciesOf(lock[\"\"])), ...byName.flatMap((name) => piecesLoad(path.join(modules, name), dependenciesOf(kept.get(name))))];\n\tfor (const name of pieceRoots) reached.add(name);\n\tlog(` left as files: ${[...reached].sort().join(\", \")}`);\n\tconst keepInstalled = /* @__PURE__ */ new Set([...closureOf(lock, reached), ...closureOf(lock, pieceRoots, { peers: true })]);\n\tconst bundled = new Set(byName);\n\tconst removed = installed.filter((name) => !keepInstalled.has(`node_modules/${name}`) && !bundled.has(name));\n\tconst licences = licencesOf(modules, [...removed, ...byName]);\n\tfs.writeFileSync(path.join(stackDir, \"THIRD-PARTY-LICENSES.txt\"), licences.text);\n\tfor (const name of byName) {\n\t\tconst dir = path.join(modules, name);\n\t\tconst staged = path.join(output, name);\n\t\tfs.mkdirSync(staged, { recursive: true });\n\t\tfor (const relative of KEEP_AS_FILES) {\n\t\t\tconst from = path.join(dir, relative);\n\t\t\tif (fs.existsSync(from)) fs.cpSync(from, path.join(staged, relative), { recursive: true });\n\t\t}\n\t\tfor (const file of fs.readdirSync(dir)) {\n\t\t\tconst from = path.join(dir, file);\n\t\t\tif (/\\.json$/.test(file) && file !== \"package.json\" && isFile(from)) fs.copyFileSync(from, path.join(staged, file));\n\t\t}\n\t\tconst manifest = kept.get(name) ?? {};\n\t\tconst entries = entriesOf.get(name) ?? /* @__PURE__ */ new Map();\n\t\tfor (const [subpath, file] of exportedFiles(dir, manifest)) {\n\t\t\tif (/\\.[cm]?js$/.test(file)) continue;\n\t\t\tconst target = path.join(staged, file);\n\t\t\tif (!isFile(path.join(dir, file))) continue;\n\t\t\tfs.mkdirSync(path.dirname(target), { recursive: true });\n\t\t\tfs.copyFileSync(path.join(dir, file), target);\n\t\t\tentries.set(subpath, file);\n\t\t}\n\t\tfs.writeFileSync(path.join(staged, \"package.json\"), `${JSON.stringify(keptManifest(manifest, entries), null, 2)}\\n`);\n\t}\n\tfs.writeFileSync(path.join(output, CHUNKS_DIR, \"package.json\"), `${JSON.stringify({\n\t\tname: \"ph-stack-bundle\",\n\t\tprivate: true,\n\t\ttype: \"module\"\n\t})}\\n`);\n\tfor (const name of [...removed, ...byName]) fs.rmSync(path.join(modules, name), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfs.rmSync(path.join(modules, \".bin\"), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfor (const entry of fs.readdirSync(modules, { withFileTypes: true })) {\n\t\tif (!entry.name.startsWith(\"@\") || !entry.isDirectory()) continue;\n\t\tconst scope = path.join(modules, entry.name);\n\t\tif (fs.readdirSync(scope).length === 0) fs.rmdirSync(scope);\n\t}\n\tfs.cpSync(output, modules, { recursive: true });\n\tfs.rmSync(output, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tconst chunks = written.filter((file) => file.type === \"chunk\").length;\n\tlog(` bundled into ${chunks} files; ${removed.length} packages folded in, ${reached.size} left as files, licences of ${licences.packages} written`);\n\treturn {\n\t\tchunks,\n\t\tremovedPackages: removed.length,\n\t\tkeptPackages: keepInstalled.size\n\t};\n}\n//#endregion\n//#region src/bundle-stack.ts\n/**\n* P6.3 — stage the shippable STACK into the shell project: everything the\n* installed app needs to run `ph run desktop` with no environment at all\n* (D6.c). The shell's resources map `../dist-stack` → `stack`, and its\n* uniform-runners mode falls back to `resources/stack` when the env pair is\n* absent. Layout:\n*\n* dist-stack/\n* hosts/ the project's host files\n* agents/ when present\n* powerhouse.config.json\n* package.json minimal, names the project\n* dist/ the package's build (ph build)\n* .ph/connect-build/dist/ the BUILT Connect (ph run connect build)\n* node_modules/ vendored @powerhousedao/ph-run (hoisted,\n* real files — computed-specifier imports and\n* PGlite wasm forbid bundling)\n*/\nconst CONNECT_BUILD_DIR = path.join(\".ph\", \"connect-build\", \"dist\");\nconst BROWSER_ONLY_IN_DIST = [\n\t\"__react__\",\n\t\"__reactor_worker__\",\n\t\"__vendor__\",\n\t\"assets\",\n\t\"browser\"\n];\n/** The package a module specifier belongs to. */\nfunction packageOf(specifier) {\n\treturn specifier.split(\"/\").slice(0, specifier.startsWith(\"@\") ? 2 : 1).join(\"/\");\n}\n/** The packages to ship for a host's plugins. One that doesn't resolve is a\n* browser built-in of Connect's, already in the built app, and resolves no\n* better in the stack (host-core's plugins-resolve). */\nfunction pluginPackagesOf(entries, where, resolves) {\n\treturn normalizePluginEntries(entries, where).filter((entry) => entry.enabled && !entry.module.startsWith(\".\")).filter((entry) => resolves(entry.module)).map((entry) => packageOf(entry.module));\n}\n/** Where a stack keeps the OAuth clients its config names. */\nconst OAUTH_CLIENTS_DIR = \"oauth\";\n/** Where a stack keeps the AI demo key its config names. */\nconst AI_DIR = \"ai\";\n/**\n* The project's config, with its OAuth clients made the app's own. They sit\n* outside the project, so a packaged app would find nothing at those paths. A\n* desktop client ships with the app: it can't keep its secret, so sign-ins\n* always use PKCE. A web client belongs to a server and never leaves the machine.\n*/\nfunction stageConfig(projectRoot, stackDir, log) {\n\tconst source = path.join(projectRoot, \"powerhouse.config.json\");\n\tif (!fs.existsSync(source)) return;\n\tconst config = JSON.parse(fs.readFileSync(source, \"utf8\"));\n\tif (config.ai?.demoKeyFile) {\n\t\tconst from = path.resolve(projectRoot, config.ai.demoKeyFile);\n\t\tdelete config.ai.demoKeyFile;\n\t\tif (fs.existsSync(from)) {\n\t\t\tconst file = path.basename(from);\n\t\t\tfs.mkdirSync(path.join(stackDir, AI_DIR), { recursive: true });\n\t\t\tfs.copyFileSync(from, path.join(stackDir, AI_DIR, file));\n\t\t\tconfig.ai.demoKeyFile = `./${AI_DIR}/${file}`;\n\t\t\tlog(\" AI demo key staged\");\n\t\t} else log(\" no AI demo key: this build won't offer one\");\n\t}\n\tfor (const app of config.workflows?.oauthApps ?? []) {\n\t\tif (!app.clients) continue;\n\t\tconst desktop = app.clients.desktop;\n\t\tconst from = desktop && path.resolve(projectRoot, desktop);\n\t\tapp.clients = {};\n\t\tif (!from || !fs.existsSync(from)) {\n\t\t\tlog(` oauth app ${app.id}: no desktop client, so it can't sign in`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst file = path.basename(from);\n\t\tfs.mkdirSync(path.join(stackDir, OAUTH_CLIENTS_DIR), { recursive: true });\n\t\tfs.copyFileSync(from, path.join(stackDir, OAUTH_CLIENTS_DIR, file));\n\t\tapp.clients.desktop = `./${OAUTH_CLIENTS_DIR}/${file}`;\n\t\tlog(` oauth app ${app.id}: desktop client staged`);\n\t}\n\tfs.writeFileSync(path.join(stackDir, \"powerhouse.config.json\"), `${JSON.stringify(config, null, 2)}\n`);\n}\n/** What runs a stack: `ph run` without the tools that build one, which is\n* most of ph-cli's dependencies. */\nconst RUN_PACKAGE = \"@powerhousedao/ph-run\";\nfunction copyIfExists(from, to) {\n\tif (!fs.existsSync(from)) return false;\n\tfs.cpSync(from, to, { recursive: true });\n\treturn true;\n}\n/** The manifest of a package the project has installed, if it has. */\nfunction installedManifest(projectRoot, pkg) {\n\ttry {\n\t\treturn JSON.parse(fs.readFileSync(path.join(projectRoot, \"node_modules\", pkg, \"package.json\"), \"utf8\"));\n\t} catch {\n\t\treturn {};\n\t}\n}\n/** The version of a package the project has installed, if it has. */\nfunction installedVersion(projectRoot, pkg) {\n\treturn installedManifest(projectRoot, pkg).version;\n}\n/** The ph-run a stack runs: what the project was built and tested with, not\n* whatever a tag points at when the build runs. It comes with ph-cli, at its\n* version. */\nfunction runVersion(options) {\n\treturn options.phCliVersion ?? installedVersion(options.projectRoot, \"@powerhousedao/ph-cli\") ?? \"dev\";\n}\n/**\n* What the project's pieces load from its own dependencies, at the versions it\n* has installed, with the peers each declares among them: a loader often names\n* the engines it loads as peers. The stack provides what it loads by name.\n*/\nfunction pieceDependencies(projectRoot, stackDir, declared) {\n\tconst loads = new Set(piecesLoad(stackDir, Object.keys(declared)).filter((name) => name in declared));\n\tfor (const name of loads) {\n\t\tconst { peerDependencies = {} } = installedManifest(projectRoot, name);\n\t\tfor (const peer of Object.keys(peerDependencies)) if (peer in declared && !loadedByName(peer)) loads.add(peer);\n\t}\n\treturn Object.fromEntries([...loads].sort().map((name) => [name, installedVersion(projectRoot, name) ?? declared[name]]));\n}\n/** What a registry vendoring installs. host-core rides along with ph-run, as\n* host files resolve runner modules (the generic compound) from the stack's\n* own node_modules. Each package comes at the version the project has, and a\n* version the host names is used for all of them. */\nfunction registrySpecs(options) {\n\tconst version = runVersion(options);\n\tconst versionOf = (pkg) => options.phCliVersion ?? installedVersion(options.projectRoot, pkg) ?? version;\n\treturn [options.phCliSpec ?? `${RUN_PACKAGE}@${version}`, ...[\"@powerhousedao/host-core\", ...options.plugins ?? []].map((pkg) => `${pkg}@${versionOf(pkg)}`)];\n}\n/** Stages each project file that exists, at its project path. One outside\n* the project has no place in the stack. */\nfunction stageProjectFiles(projectRoot, stackDir, files) {\n\tlet staged = 0;\n\tfor (const file of new Set(files)) {\n\t\tconst from = path.resolve(projectRoot, file);\n\t\tconst relative = path.relative(projectRoot, from);\n\t\tif (relative.startsWith(\"..\") || path.isAbsolute(relative)) continue;\n\t\tif (!fs.statSync(from, { throwIfNoEntry: false })?.isFile()) continue;\n\t\tconst to = path.join(stackDir, relative);\n\t\tfs.mkdirSync(path.dirname(to), { recursive: true });\n\t\tfs.copyFileSync(from, to);\n\t\tstaged++;\n\t}\n\treturn staged;\n}\n/**\n* Recursively copy `src` → `dest`, skipping any path in `excludes`. Unlike\n* fs.cpSync this tolerates `dest` living INSIDE `src`: in mode 1 the generated\n* shell (and its `dist-stack`) sits under `hosts/<desktop>/`, so staging the\n* project's `hosts/` straight into the shell would be a copy-into-self that\n* cpSync rejects outright. Excluding the shell subtree both avoids that and\n* keeps the crate + node sidecar out of the shippable stack.\n*/\nfunction copyDirFiltered(src, dest, excludes) {\n\tif (!fs.existsSync(src)) return false;\n\tconst skip = new Set(excludes.map((e) => path.resolve(e)));\n\tconst walk = (s, d) => {\n\t\tif (skip.has(path.resolve(s))) return;\n\t\tif (fs.statSync(s).isDirectory()) {\n\t\t\tfs.mkdirSync(d, { recursive: true });\n\t\t\tfor (const entry of fs.readdirSync(s)) walk(path.join(s, entry), path.join(d, entry));\n\t\t} else fs.copyFileSync(s, d);\n\t};\n\twalk(src, dest);\n\treturn true;\n}\n/** The npm spec of each tarball in `dir`, by the package name inside it. */\nfunction readLocalPackages(dir) {\n\tconst root = path.resolve(dir);\n\tconst tarballs = fs.existsSync(root) ? fs.readdirSync(root).filter((f) => f.endsWith(\".tgz\")) : [];\n\tif (tarballs.length === 0) throw new Error(`bundle-stack: no package tarballs (*.tgz) in ${root}`);\n\tconst specs = {};\n\tfor (const file of tarballs.sort()) {\n\t\tconst tarball = path.join(root, file);\n\t\tconst manifest = spawnSync(\"tar\", [\n\t\t\t\"-xzOf\",\n\t\t\tfile,\n\t\t\t\"package/package.json\"\n\t\t], {\n\t\t\tcwd: root,\n\t\t\tencoding: \"utf8\",\n\t\t\twindowsHide: true\n\t\t});\n\t\tif (manifest.status !== 0) throw new Error(`bundle-stack: ${tarball} has no package/package.json: ${manifest.stderr}`);\n\t\tconst { name } = JSON.parse(manifest.stdout);\n\t\tif (specs[name]) throw new Error(`bundle-stack: two tarballs for ${name} in ${root} (a stale pack?): ${specs[name].slice(5)} and ${tarball}`);\n\t\tspecs[name] = `file:${tarball}`;\n\t}\n\treturn specs;\n}\n/**\n* The staged stack's package.json. With local packages, every one is an\n* override (so transitive dependents get it too) and the direct dependencies\n* name the same spec: npm rejects an override that contradicts one.\n*/\nfunction stackManifest(options) {\n\tconst local = options.local ?? {};\n\tconst spec = (pkg, fallback) => local[pkg] ?? fallback;\n\tconst plugins = (options.plugins ?? []).map((pkg) => [pkg, spec(pkg, options.version)]);\n\tconst project = Object.entries(options.dependencies ?? {}).map(([pkg, range]) => [pkg, spec(pkg, range)]);\n\treturn {\n\t\tname: options.name,\n\t\tprivate: true,\n\t\ttype: \"module\",\n\t\tdependencies: {\n\t\t\t...Object.fromEntries(project),\n\t\t\t[RUN_PACKAGE]: spec(RUN_PACKAGE, options.phCliSpec ?? options.version),\n\t\t\t\"@powerhousedao/host-core\": spec(\"@powerhousedao/host-core\", options.version),\n\t\t\t...Object.fromEntries(plugins)\n\t\t},\n\t\t...Object.keys(local).length > 0 ? { overrides: local } : {}\n\t};\n}\n/** A vendored tree installed from local tarballs: the same version numbers\n* as the registry's, so npm would take either for the other. */\nfunction vendoredFromLocal(stackDir) {\n\tconst lock = path.join(stackDir, \"package-lock.json\");\n\treturn fs.existsSync(lock) && fs.readFileSync(lock, \"utf8\").includes(\"\\\"resolved\\\": \\\"file:\");\n}\n/** A tree the backend bundle folded: its packages are chunks under\n* `node_modules/.stack` and stubs npm would take for the installed packages. */\nfunction foldedByBundle(stackDir) {\n\treturn fs.existsSync(path.join(stackDir, \"node_modules\", \".stack\"));\n}\n/** Whether vendoring must drop the tree it finds instead of installing over\n* it. */\nfunction vendorsAfresh(stackDir, local) {\n\treturn local || vendoredFromLocal(stackDir) || foldedByBundle(stackDir);\n}\n/** Types and source maps, which nothing reads at runtime. */\nconst UNREAD_FILE = /\\.(d\\.[cm]?ts|map)$/i;\nconst TEST_FILE = /\\.(test|spec)\\.[cm]?[jt]sx?$/;\n/** Licences stay, as the packages' terms ask. */\nconst PACKAGE_NOTES = /^(readme|changelog|history)(\\..*)?$/i;\n/**\n* Removes what a running app never reads. Windows creates and scans each file\n* on its own, so these, over half the stack, were over half the install.\n*\n* @returns How many files went\n*/\nfunction pruneStack(dir, inPackages = false) {\n\tlet removed = 0;\n\tfor (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n\t\tconst full = path.join(dir, entry.name);\n\t\tif (entry.isDirectory()) {\n\t\t\tif (entry.name === \"__tests__\") {\n\t\t\t\tremoved += fs.readdirSync(full, {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\twithFileTypes: true\n\t\t\t\t}).filter((file) => file.isFile()).length;\n\t\t\t\tfs.rmSync(full, {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tforce: true\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tremoved += pruneStack(full, inPackages || entry.name === \"node_modules\");\n\t\t\tif (fs.readdirSync(full).length === 0) fs.rmdirSync(full);\n\t\t} else if (entry.isFile() && (UNREAD_FILE.test(entry.name) || TEST_FILE.test(entry.name) || inPackages && PACKAGE_NOTES.test(entry.name))) {\n\t\t\tfs.rmSync(full);\n\t\t\tremoved++;\n\t\t}\n\t}\n\treturn removed;\n}\nfunction bundleStack(options) {\n\tconst log = options.logger ?? console.log;\n\tconst stackDir = path.join(options.shellProjectDir, \"dist-stack\");\n\tfor (const entry of [\n\t\t\"hosts\",\n\t\t\"agents\",\n\t\t\"dist\",\n\t\t\".ph\",\n\t\tOAUTH_CLIENTS_DIR,\n\t\tAI_DIR,\n\t\t\"powerhouse.config.json\",\n\t\t\"package.json\"\n\t]) fs.rmSync(path.join(stackDir, entry), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfs.mkdirSync(stackDir, { recursive: true });\n\tlog(` hosts/ ${copyDirFiltered(path.join(options.projectRoot, \"hosts\"), path.join(stackDir, \"hosts\"), options.excludeDirs ?? []) ? \"staged\" : \"absent — skipped\"}`);\n\tconst localKey = fileURLToPath(new URL(\"./local-key/local-key.mjs\", import.meta.url));\n\tif (fs.existsSync(localKey)) fs.copyFileSync(localKey, path.join(stackDir, \"local-key.mjs\"));\n\tfor (const dir of [\n\t\t\"agents\",\n\t\t\"dist\",\n\t\tCONNECT_BUILD_DIR\n\t]) log(` ${dir}/ ${copyIfExists(path.join(options.projectRoot, dir), path.join(stackDir, dir)) ? \"staged\" : \"absent — skipped\"}`);\n\tfor (const dir of BROWSER_ONLY_IN_DIST) fs.rmSync(path.join(stackDir, \"dist\", dir), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tconst stagedDesktopHost = path.join(stackDir, \"hosts\", \"desktop\", \"host.js\");\n\tif (fs.existsSync(stagedDesktopHost)) {\n\t\tconst source = fs.readFileSync(stagedDesktopHost, \"utf8\");\n\t\tif (source.includes(\"@powerhousedao/desktop/runner\")) {\n\t\t\tfs.writeFileSync(stagedDesktopHost, \"// STAGED COPY (bundle-stack): runner.module rewritten to the generic\\n// compound — the packaged shell is the window; there is no nested shell.\\n\" + source.replace(/@powerhousedao\\/desktop\\/runner/g, \"@powerhousedao/host-core/runners/compound\"));\n\t\t\tlog(\" hosts/desktop/host.js: runner rewritten to the generic compound (staged copy)\");\n\t\t}\n\t}\n\tstageConfig(options.projectRoot, stackDir, log);\n\tif (options.projectFiles && options.projectFiles.length > 0) log(` ${stageProjectFiles(options.projectRoot, stackDir, options.projectFiles)} of ${options.projectFiles.length} files the hosts name staged`);\n\tif (typeof options.connectPort === \"number\") {\n\t\tfs.writeFileSync(path.join(stackDir, \"shell.json\"), `${JSON.stringify({ connectPort: options.connectPort }, null, 2)}\\n`);\n\t\tlog(` shell.json: connectPort ${options.connectPort}`);\n\t}\n\tconst sourcePkg = JSON.parse(fs.readFileSync(path.join(options.projectRoot, \"package.json\"), \"utf8\"));\n\tconst version = runVersion(options);\n\tconst name = sourcePkg.name ?? \"powerhouse-desktop-stack\";\n\tconst project = {\n\t\t...sourcePkg.version ? { version: sourcePkg.version } : {},\n\t\t...sourcePkg.exports ? { exports: sourcePkg.exports } : {}\n\t};\n\tconst dependencies = pieceDependencies(options.projectRoot, stackDir, sourcePkg.dependencies ?? {});\n\tconst vendor = options.vendor !== false;\n\tconst local = options.localPackagesDir ? readLocalPackages(options.localPackagesDir) : void 0;\n\tif (vendor && vendorsAfresh(stackDir, local !== void 0)) for (const entry of [\"node_modules\", \"package-lock.json\"]) fs.rmSync(path.join(stackDir, entry), {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tfs.writeFileSync(path.join(stackDir, \"package.json\"), `${JSON.stringify({\n\t\t...local ? stackManifest({\n\t\t\tname,\n\t\t\tversion,\n\t\t\tphCliSpec: options.phCliSpec,\n\t\t\tlocal,\n\t\t\tplugins: options.plugins,\n\t\t\tdependencies\n\t\t}) : {\n\t\t\tname,\n\t\t\tprivate: true,\n\t\t\ttype: \"module\",\n\t\t\tdependencies: {\n\t\t\t\t...dependencies,\n\t\t\t\t[RUN_PACKAGE]: version\n\t\t\t}\n\t\t},\n\t\t...project\n\t}, null, 2)}\\n`);\n\tlet vendored = false;\n\tif (vendor) {\n\t\tconst specs = local ? \"\" : registrySpecs(options).map((spec) => `\"${spec}\"`).join(\" \");\n\t\tlog(local ? ` vendoring ${Object.keys(local).length} local packages from ${options.localPackagesDir} (hoisted, real files)…` : ` vendoring ${specs} (hoisted, real files)…`);\n\t\tconst result = spawnSync(`npm install ${specs} --install-strategy=hoisted --omit=dev --no-audit --no-fund`, {\n\t\t\tcwd: stackDir,\n\t\t\tstdio: \"pipe\",\n\t\t\tshell: true,\n\t\t\twindowsHide: true\n\t\t});\n\t\tif (result.status !== 0) throw new Error(`bundle-stack: vendoring failed (${result.status}):\\n${result.stderr.toString().slice(-800)}`);\n\t\tvendored = true;\n\t} else log(\" vendoring skipped (vendor: false) — existing tree left in place\");\n\tlog(` ${pruneStack(stackDir)} files a running app never reads removed`);\n\treturn {\n\t\tstackDir,\n\t\tvendored\n\t};\n}\n//#endregion\n//#region src/shell-project.ts\n/**\n* P7.3 — project `hosts/desktop/app.json` into a generated `tauri-shell/`:\n* a STANDALONE tauri crate that depends on the published `ph-desktop-shell`\n* library, carries the builder's identity, and is built/run by the desktop\n* runner's dev/build verbs. The builder never writes Rust.\n*\n* Everything here mirrors the known-good reference app\n* (ph-desktop-shell/apps/powerhouse-desktop): the tauri plumbing (main.rs,\n* build.rs, capabilities, the loading page, externalBin + icon mechanics) is\n* copied verbatim; only identity/port fields are projected from app.json. The\n* projection is idempotent and stale-detected — a file is rewritten only when\n* its content changes, so Cargo.lock, the generated icon set, and tauri-build\n* output are never disturbed by a regen with an unchanged app.json.\n*/\nconst SHELL_DIR = \"tauri-shell\";\n/** The icon source the runner feeds to `tauri icon` (copied from app.icon). */\nconst ICON_SOURCE = \"app-icon.png\";\n/** Beside tauri.conf.json in an app with updates: the settings of a build\n* that has no signing key to hand, which cannot be offered as an update. */\nconst UNSIGNED_BUILD_CONF = \"tauri.unsigned.conf.json\";\nconst UPDATE_PERMISSIONS = [\n\t\"update_state\",\n\t\"update_check\",\n\t\"update_install\"\n].map((command) => `allow-${command.replaceAll(\"_\", \"-\")}`);\n/** The version the installers and the macOS bundle carry: the numeric x.y.z\n* of the project's version, as Windows' bundlers take nothing else. */\nfunction bundleVersion(version) {\n\tconst numeric = /^(\\d+)\\.(\\d+)\\.(\\d+)/.exec(version ?? \"\");\n\treturn numeric ? numeric.slice(1).join(\".\") : \"0.1.0\";\n}\n/** `ph-desktop-shell` dependency line for the generated Cargo.toml, from\n* app.json's shell.source (path > git > crates.io version). */\nfunction shellDependency(source) {\n\tif (source?.path) {\n\t\tconst p = source.path.replace(/\\\\/g, \"/\");\n\t\treturn `ph-desktop-shell = { path = ${JSON.stringify(p)} }`;\n\t}\n\tif (source?.git) {\n\t\tconst parts = [`git = ${JSON.stringify(source.git)}`];\n\t\tif (source.tag) parts.push(`tag = ${JSON.stringify(source.tag)}`);\n\t\tif (source.rev) parts.push(`rev = ${JSON.stringify(source.rev)}`);\n\t\treturn `ph-desktop-shell = { ${parts.join(\", \")} }`;\n\t}\n\tconst version = source?.version ?? \"0.1.2\";\n\treturn `ph-desktop-shell = ${JSON.stringify(version)}`;\n}\nfunction cargoToml(app, binName) {\n\treturn `# GENERATED from ../app.json by @powerhousedao/desktop — do not edit by\n# hand; edit app.json and re-run \\`ph run desktop dev|build\\`. Cargo.lock is\n# preserved across regens.\n[package]\nname = ${JSON.stringify(binName)}\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[build-dependencies]\ntauri-build = { version = \"2\", features = [] }\n\n[dependencies]\ntauri = { version = \"2\", features = [\"tray-icon\", \"devtools\"] }\n# Plugins must be DIRECT deps of the app crate: tauri-build only sees\n# permission manifests (shell:allow-spawn etc.) from direct dependencies.\ntauri-plugin-shell = \"2\"\ntauri-plugin-single-instance = \"2\"\n${app.updates ? `# The updater's settings are baked in by tauri::generate_context!, whose\n# output names serde_json in this crate.\nserde_json = \"1\"\n` : \"\"}${shellDependency(app.shell)}\n\n[[bin]]\nname = ${JSON.stringify(binName)}\npath = \"src/main.rs\"\n\n[profile.release]\ncodegen-units = 1\nlto = true\n`;\n}\nconst MAIN_RS = `// GENERATED — identity bakes from tauri.conf.json via generate_context!;\n// behavior is the shared ph-desktop-shell library. Edit ../app.json, not this.\n#![cfg_attr(not(debug_assertions), windows_subsystem = \"windows\")]\n\nfn main() {\n ph_desktop_shell::run(tauri::generate_context!(), Default::default());\n}\n`;\nconst BUILD_RS = `// GENERATED — mirrors the reference shell. Connect is served over\n// http://127.0.0.1 (a remote origin to Tauri), so the launch-queue commands\n// need an explicit ACL; declaring the command manifest here generates the\n// allow-<command> permissions that capabilities/*.json grant.\nfn main() {\n // The icon set is a COMPILE-TIME input (the Windows resource icon here,\n // and the tray/window icon tauri::generate_context! embeds), but\n // tauri-build registers no rerun trigger for it: without this line a\n // regenerated icon set leaves the old icon compiled into the binary.\n println!(\"cargo:rerun-if-changed=icons\");\n tauri_build::try_build(tauri_build::Attributes::new().app_manifest(\n tauri_build::AppManifest::new().commands(&[\n \"take_launch_files\",\n \"read_launch_file\",\n \"log_from_webview\",\n \"open_external\",\n \"desktop_state\",\n \"pick_root\",\n \"save_renown_url\",\n \"local_create\",\n \"local_unlock\",\n \"saved_credential\",\n \"save_profile\",\n \"adopt_old_data\",\n \"start_stack\",\n \"switch_identity\",\n \"update_state\",\n \"update_check\",\n \"update_install\",\n ]),\n ))\n .expect(\"failed to run tauri-build\");\n}\n`;\n/** The sign-in page's script (app.json `signIn`), beside the page. */\nconst SIGN_IN_SCRIPT = \"sign-in.js\";\n/** That script as this package built it (tsdown.config.ts). */\nfunction builtSignInScript() {\n\treturn fs.readFileSync(fileURLToPath(new URL(`./sign-in/${SIGN_IN_SCRIPT}`, import.meta.url)));\n}\n/** The loading page's logo: app.json's icon SOURCE (1024² recommended), copied\n* beside ui/index.html — not one of the downsampled `tauri icon` outputs, so\n* it stays sharp on HiDPI screens. Generated, like the rest of ui/. */\nconst LOADING_LOGO = \"logo.png\";\n/** The loading page's splash (app.json `splash`), copied beside it; shown\n* instead of the square logo when set. Generated, like the rest of ui/. */\nconst LOADING_SPLASH = \"splash.png\";\n/** Dark-scheme splash (app.json `splashDark`), beside the light one. */\nconst LOADING_SPLASH_DARK = \"splash-dark.png\";\n/** CSS size of the logo; the 1024² source keeps it crisp up to 8x DPR. */\nconst LOGO_CSS_PX = 128;\n/** The sign-in page's own look, on the loading page's colours. */\nconst SIGN_IN_CSS = `\n body { overflow: auto; height: auto; min-height: 100vh; }\n #sign-in {\n position: relative; z-index: 1; box-sizing: border-box;\n width: min(420px, calc(100vw - 32px)); margin: 24px 0; padding: 32px;\n display: flex; flex-direction: column; gap: 12px; text-align: left;\n background: color-mix(in srgb, var(--bg) 92%, var(--fg));\n border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);\n border-radius: 14px;\n }\n #sign-in h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.2; font-weight: 600; }\n #sign-in p { margin: 0; }\n #sign-in small { opacity: .7; }\n #sign-in button, #sign-in input {\n font: inherit; color: inherit; border-radius: 8px; padding: 10px 14px;\n border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);\n background: transparent; box-sizing: border-box; width: 100%;\n }\n #sign-in button { cursor: pointer; }\n #sign-in button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }\n #sign-in button.link { width: auto; padding: 0; border: 0; text-decoration: underline; }\n #sign-in label { display: grid; gap: 4px; }\n #sign-in details { font-size: 14px; display: grid; gap: 8px; }\n #sign-in .folder { font-size: 13px; overflow-wrap: anywhere; }\n #sign-in .notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; background: color-mix(in srgb, var(--accent) 16%, transparent); }\n #sign-in .identities { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }\n #sign-in .identity { display: flex; gap: 12px; align-items: center; text-align: left; }\n #sign-in .identity img, #sign-in .initial {\n width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none;\n display: grid; place-items: center; font-weight: 600;\n background: color-mix(in srgb, var(--accent) 30%, transparent);\n }\n #sign-in .identity b, #sign-in .identity small { display: block; }\n #sign-in .busy { display: flex; align-items: center; justify-content: center; }\n #sign-in:has(> .busy) { background: none; border: 0; }`;\nfunction loadingHtml(app, art, signIn = false) {\n\tconst escape = (text) => text.replace(/[<&]/g, (c) => c === \"<\" ? \"<\" : \"&\");\n\tconst name = escape(app.productName);\n\tconst loading = app.loading;\n\tconst message = loading?.message ? escape(loading.message) : `Starting ${name}…`;\n\tconst pageColor = art.background?.color ?? null;\n\tconst background = pageColor?.light ?? loading?.background ?? \"#0f1115\";\n\tconst color = loading?.color ?? \"#e6e8eb\";\n\tconst accent = loading?.accent ?? \"#4ade80\";\n\tconst dark = loading?.dark;\n\tconst darkBackground = pageColor?.dark ?? dark?.background;\n\tconst darkVars = dark || darkBackground ? `\n @media (prefers-color-scheme: dark) {\n :root {\n --bg: ${darkBackground ?? background};\n --fg: ${dark?.color ?? color};\n --accent: ${dark?.accent ?? accent};\n }\n }` : \"\";\n\tconst attr = (text) => text.replace(/&/g, \"&\").replace(/\"/g, \""\");\n\tconst layersTag = art.background && art.background.layers.length > 0 ? `<div class=\"layers\" aria-hidden=\"true\">\n ${art.background.layers.map((layer) => layer.dark ? `<picture>\n <source srcset=\"${attr(layer.dark)}\" media=\"(prefers-color-scheme: dark)\" />\n <img src=\"${attr(layer.light)}\" alt=\"\" style=\"${attr(layer.style)}\" />\n </picture>` : `<img src=\"${attr(layer.light)}\" alt=\"\" style=\"${attr(layer.style)}\" />`).join(\"\\n \")}\n </div>\n ` : \"\";\n\tconst picture = (cls, file, darkFile, attrs = \"\") => darkFile ? `<picture>\n <source srcset=\"./${darkFile}\" media=\"(prefers-color-scheme: dark)\" />\n <img class=\"${cls}\" src=\"./${file}\" alt=\"\"${attrs} />\n </picture>\n ` : `<img class=\"${cls}\" src=\"./${file}\" alt=\"\"${attrs} />\n `;\n\tconst main = art.main;\n\tconst logoTag = main?.kind === \"splash\" ? picture(\"splash\", main.file, main.dark) : main ? picture(\"logo\", main.file, main.dark, ` width=\"${LOGO_CSS_PX}\" height=\"${LOGO_CSS_PX}\"`) : \"\";\n\tconst cornerTag = art.corner ? `<div class=\"corner\" aria-hidden=\"true\">${picture(\"art\", art.corner.file, art.corner.dark)}</div>\n ` : \"\";\n\treturn `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>${name}</title>\n <style>\n :root {\n color-scheme: light dark;\n --bg: ${background}; --fg: ${color}; --accent: ${accent};\n }${darkVars}\n body {\n margin: 0; height: 100vh; overflow: hidden;\n display: flex; align-items: center; justify-content: center;\n font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n background: var(--bg); color: var(--fg);\n }\n .box {\n position: relative; z-index: 1;\n text-align: center;\n display: flex; flex-direction: column; align-items: center; gap: 20px;\n }\n .logo {\n width: ${LOGO_CSS_PX}px; height: ${LOGO_CSS_PX}px;\n object-fit: contain; display: block;\n }\n .splash {\n width: min(720px, 80vw); max-height: 65vh;\n object-fit: contain; display: block;\n }\n .corner {\n position: fixed; right: 0; bottom: 0; z-index: 0;\n width: clamp(220px, 30vw, 520px); line-height: 0; pointer-events: none;\n }\n .layers { position: fixed; inset: 0; z-index: 0; }\n .art { width: 100%; height: auto; display: block; }\n .dot {\n width: 10px; height: 10px; border-radius: 50%;\n background: var(--accent); display: inline-block; margin-right: 8px;\n animation: pulse 1.2s ease-in-out infinite;\n }\n @keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }\n @media (prefers-reduced-motion: reduce) { .dot { animation: none; } }${signIn ? SIGN_IN_CSS : \"\"}\n </style>\n </head>\n <body>\n ${signIn ? `<main id=\"sign-in\"></main>\n <script type=\"module\" src=\"./sign-in.js\"><\\/script>` : `<div class=\"box\">\n ${logoTag}<div><span class=\"dot\"></span>${message}</div>\n </div>`}\n ${layersTag}${cornerTag}</body>\n</html>\n`;\n}\nfunction tauriConf(input) {\n\tconst { app } = input;\n\tconst win = app.window ?? {};\n\tconst fileAssociations = app.fileAssociations && app.fileAssociations.length > 0 ? app.fileAssociations.map((fa) => ({\n\t\text: fa.ext,\n\t\tname: fa.name,\n\t\t...fa.description ? { description: fa.description } : {},\n\t\t...fa.mimeType ? { mimeType: fa.mimeType } : {}\n\t})) : void 0;\n\tconst conf = {\n\t\t$schema: \"https://schema.tauri.app/config/2\",\n\t\tproductName: app.productName,\n\t\tversion: bundleVersion(input.version),\n\t\tidentifier: app.identifier,\n\t\tbuild: { frontendDist: \"./ui\" },\n\t\tapp: {\n\t\t\twindows: [{\n\t\t\t\ttitle: win.title ?? app.productName,\n\t\t\t\twidth: win.width ?? 1440,\n\t\t\t\theight: win.height ?? 900,\n\t\t\t\tresizable: win.resizable ?? true,\n\t\t\t\t...win.minWidth ? { minWidth: win.minWidth } : {},\n\t\t\t\t...win.minHeight ? { minHeight: win.minHeight } : {},\n\t\t\t\tvisible: true,\n\t\t\t\tdragDropEnabled: false,\n\t\t\t\tcreate: false\n\t\t\t}],\n\t\t\tsecurity: { csp: null }\n\t\t},\n\t\tbundle: {\n\t\t\tactive: true,\n\t\t\ttargets: [\n\t\t\t\t\"nsis\",\n\t\t\t\t\"app\",\n\t\t\t\t\"dmg\"\n\t\t\t],\n\t\t\ticon: [\n\t\t\t\t\"icons/32x32.png\",\n\t\t\t\t\"icons/128x128.png\",\n\t\t\t\t\"icons/128x128@2x.png\",\n\t\t\t\t\"icons/icon.icns\",\n\t\t\t\t\"icons/icon.ico\"\n\t\t\t],\n\t\t\t...fileAssociations ? { fileAssociations } : {},\n\t\t\texternalBin: [\"binaries/node\"],\n\t\t\tresources: { \"./dist-stack\": \"stack\" },\n\t\t\tmacOS: {\n\t\t\t\tsigningIdentity: \"-\",\n\t\t\t\thardenedRuntime: false\n\t\t\t},\n\t\t\t...app.updates ? { createUpdaterArtifacts: true } : {}\n\t\t},\n\t\t...app.updates ? { plugins: { updater: {\n\t\t\tpubkey: app.updates.pubkey.trim(),\n\t\t\tendpoints: updateEndpoints(app.updates),\n\t\t\trequireSignedVersion: true\n\t\t} } } : {}\n\t};\n\treturn JSON.stringify(conf, null, 2) + \"\\n\";\n}\n/** Laid over tauri.conf.json for a build without the signing key. */\nconst UNSIGNED_BUILD_CONF_JSON = JSON.stringify({ bundle: { createUpdaterArtifacts: false } }, null, 2) + \"\\n\";\nfunction defaultCapability() {\n\treturn JSON.stringify({\n\t\t$schema: \"../gen/schemas/desktop-schema.json\",\n\t\tidentifier: \"default\",\n\t\tdescription: \"Lets the shell spawn the bundled node sidecar.\",\n\t\twindows: [\"main\"],\n\t\tpermissions: [\n\t\t\t\"core:default\",\n\t\t\t\"allow-take-launch-files\",\n\t\t\t\"allow-read-launch-file\",\n\t\t\t\"allow-log-from-webview\",\n\t\t\t...UPDATE_PERMISSIONS,\n\t\t\t{\n\t\t\t\tidentifier: \"shell:allow-spawn\",\n\t\t\t\tallow: [{\n\t\t\t\t\tname: \"binaries/node\",\n\t\t\t\t\tsidecar: true,\n\t\t\t\t\targs: true\n\t\t\t\t}]\n\t\t\t},\n\t\t\t{\n\t\t\t\tidentifier: \"shell:allow-execute\",\n\t\t\t\tallow: [{\n\t\t\t\t\tname: \"binaries/node\",\n\t\t\t\t\tsidecar: true,\n\t\t\t\t\targs: true\n\t\t\t\t}]\n\t\t\t}\n\t\t]\n\t}, null, 2) + \"\\n\";\n}\nfunction connectCapability(connectPort) {\n\tconst origin = `http://127.0.0.1:${connectPort}`;\n\treturn JSON.stringify({\n\t\t$schema: \"../gen/schemas/desktop-schema.json\",\n\t\tidentifier: \"connect\",\n\t\tdescription: \"Connect is served over http://127.0.0.1 (a remote origin to Tauri); without this the launch-queue commands are rejected before they run.\",\n\t\twindows: [\"main\"],\n\t\tremote: { urls: [origin, `${origin}/*`] },\n\t\tpermissions: [\n\t\t\t\"allow-take-launch-files\",\n\t\t\t\"allow-read-launch-file\",\n\t\t\t\"allow-log-from-webview\",\n\t\t\t\"allow-open-external\",\n\t\t\t\"allow-desktop-state\",\n\t\t\t\"allow-pick-root\",\n\t\t\t\"allow-save-renown-url\",\n\t\t\t\"allow-local-create\",\n\t\t\t\"allow-local-unlock\",\n\t\t\t\"allow-saved-credential\",\n\t\t\t\"allow-save-profile\",\n\t\t\t\"allow-adopt-old-data\",\n\t\t\t\"allow-start-stack\",\n\t\t\t\"allow-switch-identity\",\n\t\t\t...UPDATE_PERMISSIONS\n\t\t]\n\t}, null, 2) + \"\\n\";\n}\nconst GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.\n/target\n/gen\n/icons\n/ui/logo.png\n/ui/splash.png\n/ui/splash-dark.png\n/ui/art.*\n/ui/art-dark.*\n/ui/bg-*\n/ui/sign-in.*\n/dist-stack\n/binaries\n`;\nconst DIST_STACK_README = `This directory is replaced at \\`ph run desktop build\\` with the shippable\nstack (hosts + powerhouse.config.json + built Connect + vendored ph-cli). It\nis bundled as the app's \\`stack\\` resource so the installed app runs with no\nenvironment. Kept as a placeholder so tauri's resource glob resolves in dev.\n`;\n/** Write a file only when its content differs; returns whether it changed. */\nfunction writeIfChanged(file, content) {\n\tif (fs.existsSync(file) && fs.readFileSync(file, \"utf8\") === content) return false;\n\tfs.mkdirSync(path.dirname(file), { recursive: true });\n\tfs.writeFileSync(file, content);\n\treturn true;\n}\n/**\n* Materialize/refresh `<hostDir>/tauri-shell/` from app.json. Idempotent:\n* unchanged app.json rewrites nothing. Does NOT run `tauri icon` or fetch the\n* node binary — those are toolchain steps the runner performs at dev/build.\n*/\nfunction projectShell(input) {\n\tconst { hostDir, app, connectPort } = input;\n\tconst binName = appSlug(app);\n\tconst shellDir = path.join(hostDir, SHELL_DIR);\n\tconst iconSrc = path.resolve(hostDir, app.icon);\n\tconst iconBytes = fs.existsSync(iconSrc) ? fs.readFileSync(iconSrc) : null;\n\tconst readRel = (rel) => {\n\t\tif (!rel) return null;\n\t\tconst abs = path.resolve(hostDir, rel);\n\t\treturn fs.existsSync(abs) ? fs.readFileSync(abs) : null;\n\t};\n\tconst splashBytes = readRel(app.splash);\n\tconst splashDarkBytes = readRel(app.splashDark);\n\tconst artBytes = readRel(app.loading?.art);\n\tconst artDarkBytes = readRel(app.loading?.artDark);\n\tconst artExt = (rel) => rel ? path.extname(rel).toLowerCase() || \".png\" : \".png\";\n\tconst artFile = `art${artExt(app.loading?.art)}`;\n\tconst artDarkFile = `art-dark${artExt(app.loading?.artDark)}`;\n\tconst background = normalizeBackground(app.background);\n\tconst staged = [];\n\tconst stage = (ref, stem) => {\n\t\tif (isPassthroughImageRef(ref)) return ref;\n\t\tconst abs = path.resolve(hostDir, ref);\n\t\tif (!fs.existsSync(abs)) return void 0;\n\t\tconst file = `${stem}${artExt(ref)}`;\n\t\tstaged.push([path.join(shellDir, \"ui\", file), fs.readFileSync(abs)]);\n\t\treturn `./${file}`;\n\t};\n\tconst layers = (background?.layers ?? []).flatMap((layer, index) => {\n\t\tconst variants = imageVariants(layer.src);\n\t\tconst light = stage(variants.light, `bg-${index}`);\n\t\tif (!light) return [];\n\t\tconst dark = variants.dark ? stage(variants.dark, `bg-${index}-dark`) : void 0;\n\t\treturn [{\n\t\t\tlight,\n\t\t\t...dark ? { dark } : {},\n\t\t\tstyle: layerStyleText(layer)\n\t\t}];\n\t});\n\tconst art = {\n\t\tmain: background ? null : splashBytes ? {\n\t\t\tkind: \"splash\",\n\t\t\tfile: LOADING_SPLASH,\n\t\t\t...splashDarkBytes ? { dark: LOADING_SPLASH_DARK } : {}\n\t\t} : iconBytes ? {\n\t\t\tkind: \"logo\",\n\t\t\tfile: LOADING_LOGO\n\t\t} : null,\n\t\tcorner: !background && artBytes ? {\n\t\t\tfile: artFile,\n\t\t\t...artDarkBytes ? { dark: artDarkFile } : {}\n\t\t} : null,\n\t\tbackground: background ? {\n\t\t\tcolor: colorVariants(background.color),\n\t\t\tlayers\n\t\t} : null\n\t};\n\tconst files = [\n\t\t[\"Cargo.toml\", cargoToml(app, binName)],\n\t\t[\"src/main.rs\", MAIN_RS],\n\t\t[\"build.rs\", BUILD_RS],\n\t\t[\"tauri.conf.json\", tauriConf(input)],\n\t\t[\"ui/index.html\", loadingHtml(app, art)],\n\t\t[\"capabilities/default.json\", defaultCapability()],\n\t\t[\"capabilities/connect.json\", connectCapability(connectPort)],\n\t\t[\".gitignore\", GITIGNORE],\n\t\t[\"dist-stack/README.md\", DIST_STACK_README]\n\t];\n\tif (app.signIn) files.push([\"ui/sign-in.html\", loadingHtml(app, art, true)]);\n\tif (app.updates) files.push([UNSIGNED_BUILD_CONF, UNSIGNED_BUILD_CONF_JSON]);\n\tlet changed = false;\n\tfor (const [rel, content] of files) if (writeIfChanged(path.join(shellDir, rel), content)) changed = true;\n\tif (!app.updates) {\n\t\tconst stale = path.join(shellDir, UNSIGNED_BUILD_CONF);\n\t\tif (fs.existsSync(stale)) {\n\t\t\tfs.rmSync(stale);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (!app.signIn) for (const file of [\"sign-in.html\", SIGN_IN_SCRIPT]) {\n\t\tconst stale = path.join(shellDir, \"ui\", file);\n\t\tif (fs.existsSync(stale)) {\n\t\t\tfs.rmSync(stale);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tconst copies = [\n\t\t[path.join(shellDir, \"ui\", SIGN_IN_SCRIPT), app.signIn ? input.signInScript ?? builtSignInScript() : null],\n\t\t[path.join(shellDir, ICON_SOURCE), iconBytes],\n\t\t[path.join(shellDir, \"ui\", LOADING_LOGO), iconBytes],\n\t\t[path.join(shellDir, \"ui\", LOADING_SPLASH), splashBytes],\n\t\t[path.join(shellDir, \"ui\", LOADING_SPLASH_DARK), splashDarkBytes],\n\t\t[path.join(shellDir, \"ui\", artFile), artBytes],\n\t\t[path.join(shellDir, \"ui\", artDarkFile), artDarkBytes],\n\t\t...staged\n\t];\n\tfor (const [dest, bytes] of copies) {\n\t\tif (!bytes) continue;\n\t\tif (!fs.existsSync(dest) || !fs.readFileSync(dest).equals(bytes)) {\n\t\t\tfs.mkdirSync(path.dirname(dest), { recursive: true });\n\t\t\tfs.writeFileSync(dest, bytes);\n\t\t\tchanged = true;\n\t\t}\n\t}\n\treturn {\n\t\tshellDir,\n\t\tbinName,\n\t\tchanged\n\t};\n}\n//#endregion\n//#region src/shell-toolchain.ts\n/** The Node release triple for a build host — the sidecar filename tauri\n* resolves (`node-<triple>`). Pure, so the mapping is unit-tested. */\nfunction nodeSidecarTarget(platform, arch) {\n\tconst target = {\n\t\t\"win32 x64\": {\n\t\t\ttriple: \"x86_64-pc-windows-msvc\",\n\t\t\tdist: \"win-x64\",\n\t\t\tbin: \"node.exe\",\n\t\t\text: \".exe\"\n\t\t},\n\t\t\"darwin arm64\": {\n\t\t\ttriple: \"aarch64-apple-darwin\",\n\t\t\tdist: \"darwin-arm64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t},\n\t\t\"darwin x64\": {\n\t\t\ttriple: \"x86_64-apple-darwin\",\n\t\t\tdist: \"darwin-x64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t},\n\t\t\"linux x64\": {\n\t\t\ttriple: \"x86_64-unknown-linux-gnu\",\n\t\t\tdist: \"linux-x64\",\n\t\t\tbin: \"bin/node\",\n\t\t\text: \"\"\n\t\t}\n\t}[`${platform} ${arch}`];\n\tif (!target) throw new Error(`No Node sidecar mapping for ${platform} ${arch} — the desktop shell supports win32/x64, darwin/arm64, darwin/x64, linux/x64.`);\n\treturn target;\n}\n/** Fetch the stock Node the shell ships as its sidecar into `<shellDir>/\n* binaries`, named per target triple. No-op when already present. Ported from\n* the reference repo's fetch-node.mjs (the builder has no such script). */\nfunction fetchNodeSidecar(shellDir, version = process.versions.node, platform = process.platform, arch = process.arch) {\n\tconst target = nodeSidecarTarget(platform, arch);\n\tconst binariesDir = path.join(shellDir, \"binaries\");\n\tfs.mkdirSync(binariesDir, { recursive: true });\n\tconst dest = path.join(binariesDir, `node-${target.triple}${target.ext}`);\n\tif (fs.existsSync(dest)) return dest;\n\tif (platform === \"win32\") {\n\t\tconst url = `https://nodejs.org/dist/v${version}/win-x64/node.exe`;\n\t\texecSync(`curl -fsSL -o \"${dest}\" \"${url}\"`, { stdio: \"inherit\" });\n\t} else {\n\t\tconst name = `node-v${version}-${target.dist}`;\n\t\tconst url = `https://nodejs.org/dist/v${version}/${name}.tar.gz`;\n\t\texecSync(`curl -fsSL \"${url}\" | tar -xz -C \"${binariesDir}\" --strip-components=2 ${name}/${target.bin}`, {\n\t\t\tstdio: \"inherit\",\n\t\t\tshell: \"/bin/sh\"\n\t\t});\n\t\tfs.renameSync(path.join(binariesDir, \"node\"), dest);\n\t\tfs.chmodSync(dest, 493);\n\t}\n\treturn dest;\n}\n/** Default bundle targets for the build host (`cargo tauri build --bundles`).\n* macOS gets app+dmg, Windows nsis, Linux deb+appimage — a host only builds\n* installers it can produce. */\nfunction tauriBundlesForHost(platform = process.platform) {\n\tswitch (platform) {\n\t\tcase \"darwin\": return [\"app\", \"dmg\"];\n\t\tcase \"win32\": return [\"nsis\"];\n\t\tdefault: return [\"deb\", \"appimage\"];\n\t}\n}\n/** `tauri build`'s arguments. An app with updates signs what it builds, so\n* without the key (`TAURI_SIGNING_PRIVATE_KEY`) the build would fail at its\n* last step: such a build leaves the signatures out instead, laying\n* `unsignedConf` over the configuration, and still makes its installers. */\nfunction tauriBuildArgs(bundles, updates) {\n\tconst args = [\n\t\t\"build\",\n\t\t\"--bundles\",\n\t\tbundles.join(\",\")\n\t];\n\tif (updates.on && !updates.signingKey) args.push(\"--config\", updates.unsignedConf);\n\treturn args;\n}\n/** Spawn parameters that avoid DEP0190 (args array + shell:true): cargo on\n* Windows needs the shell for PATH/.exe + subcommand resolution — pass ONE\n* string, empty args; everything else runs argv directly (shell:false). The\n* joined tokens here are our own constants/paths, never user input. */\nfunction tauriSpawn(tauri, subcommand) {\n\tconst argv = [...tauri.prefix, ...subcommand];\n\tif (tauri.cmd === \"cargo\" && process.platform === \"win32\") return {\n\t\tcommand: [\"cargo\", ...argv].join(\" \"),\n\t\targs: [],\n\t\tshell: true\n\t};\n\treturn {\n\t\tcommand: tauri.cmd,\n\t\targs: argv,\n\t\tshell: false\n\t};\n}\nfunction probe(cmd, args) {\n\tconst onWin = process.platform === \"win32\";\n\ttry {\n\t\treturn spawnSync(onWin ? [cmd, ...args].join(\" \") : cmd, onWin ? [] : args, {\n\t\t\tstdio: \"ignore\",\n\t\t\tshell: onWin\n\t\t}).status === 0;\n\t} catch {\n\t\treturn false;\n\t}\n}\n/** Is a Rust `cargo` on PATH? (needed to compile the shell crate). */\nfunction hasCargo() {\n\treturn probe(\"cargo\", [\"--version\"]);\n}\n/** Resolve a Tauri CLI: a global `cargo tauri`, else a `@tauri-apps/cli`\n* resolvable from the project. Returns null when neither is available. */\nfunction resolveTauriCommand(projectRoot) {\n\tif (probe(\"cargo\", [\"tauri\", \"--version\"])) return {\n\t\tcmd: \"cargo\",\n\t\tprefix: [\"tauri\"],\n\t\tvia: \"cargo-tauri\"\n\t};\n\ttry {\n\t\tconst pkgJson = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href).resolve(\"@tauri-apps/cli/package.json\");\n\t\tconst pkgDir = path.dirname(pkgJson);\n\t\tconst bin = JSON.parse(fs.readFileSync(pkgJson, \"utf8\")).bin;\n\t\tconst rel = typeof bin === \"string\" ? bin : bin?.tauri;\n\t\tif (rel) return {\n\t\t\tcmd: process.execPath,\n\t\t\tprefix: [path.join(pkgDir, rel)],\n\t\t\tvia: \"node-cli\"\n\t\t};\n\t} catch {}\n\treturn null;\n}\nfunction detectToolchain(projectRoot) {\n\treturn {\n\t\tcargo: hasCargo(),\n\t\ttauri: resolveTauriCommand(projectRoot)\n\t};\n}\n/** Throw a clear, actionable error when the native toolchain is incomplete —\n* the desktop verbs call this before any cargo work so a missing executable\n* is an instruction, not a stack trace. */\nfunction preflightOrThrow(tc, hostName) {\n\tconst missing = [];\n\tif (!tc.cargo) missing.push(\" • Rust/cargo — install from https://rustup.rs (then restart your shell)\");\n\tif (!tc.tauri) missing.push(\" • Tauri CLI — `cargo install tauri-cli --version \\\"^2\\\"` (or add @tauri-apps/cli@^2 to your project's devDependencies)\");\n\tif (missing.length > 0 || !tc.tauri) throw new Error(`hosts/${hostName}: the desktop shell needs a native toolchain that is not installed:\\n${missing.join(\"\\n\")}\\nInstall the above, then re-run \\`ph run ${hostName} dev\\` / \\`ph run ${hostName} build\\`. (The headless stack — \\`ph run ${hostName}\\` — needs none of this.)`);\n\treturn tc.tauri;\n}\n/** `<tauri> icon <source>` — generates the per-platform icon set (icon.ico +\n* icon.icns + pngs) the bundle references and tauri-build requires. */\nfunction runTauriIcon(tauri, shellDir, iconSource) {\n\tconst { command, args, shell } = tauriSpawn(tauri, [\"icon\", iconSource]);\n\tconst r = spawnSync(command, args, {\n\t\tcwd: shellDir,\n\t\tstdio: \"inherit\",\n\t\tshell\n\t});\n\tif (r.status !== 0) throw new Error(`\\`tauri icon ${iconSource}\\` failed (exit ${r.status ?? \"?\"}) in ${shellDir} — check that app.icon is a square PNG.`);\n}\n//#endregion\n//#region src/shell.ts\nfunction resolveShell(projectRoot, options, env) {\n\tconst configured = options?.project ?? env.PH_DESKTOP_SHELL;\n\tif (!configured) throw new Error(\"No desktop shell configured: set runner.shell.project in the host file (path to a ph-win-desktop checkout) or the PH_DESKTOP_SHELL environment variable. `ph run desktop` (headless stack) needs neither.\");\n\tconst projectDir = path.resolve(projectRoot, configured);\n\tif (!fs.existsSync(path.join(projectDir, \"src-tauri\"))) throw new Error(`Desktop shell not found at ${projectDir} (no src-tauri/) — check runner.shell.project / PH_DESKTOP_SHELL.`);\n\treturn {\n\t\tprojectDir,\n\t\texe: [\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win.exe\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win.exe\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win\"),\n\t\t\tpath.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win\")\n\t\t].find((c) => fs.existsSync(c))\n\t};\n}\n/** Resolve the project's ph-cli entry from ITS dependency tree — the same\n* resolution `ph run` itself uses. */\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/** The env trio (plus userData) the shell's uniform-runners mode\n* reads — wired by the RUNNER so nobody exports variables by hand. */\nfunction shellEnv(projectRoot, connectPort, env) {\n\treturn {\n\t\tPH_RUN_PROJECT: projectRoot,\n\t\tPH_RUN_CLI: resolvePhCliEntry(projectRoot),\n\t\tPH_WIN_CONNECT_PORT: String(connectPort),\n\t\t...env.PH_USER_DATA_DIR ? { PH_USER_DATA_DIR: env.PH_USER_DATA_DIR } : {}\n\t};\n}\n/** Project host shell options onto a tauri `--config` merge patch (D6.d) —\n* the host file stays the single source for app identity on tauri-cli\n* invocations; a built exe has these baked. */\nfunction tauriConfigPatch(options) {\n\tif (!options) return void 0;\n\tconst patch = {};\n\tif (options.window) patch.app = { windows: [{\n\t\t...options.window.title ? { title: options.window.title } : {},\n\t\t...options.window.width ? { width: options.window.width } : {},\n\t\t...options.window.height ? { height: options.window.height } : {}\n\t}] };\n\tif (options.fileAssociations?.length) patch.bundle = { fileAssociations: [{\n\t\text: options.fileAssociations.map((e) => e.replace(/^\\./, \"\")),\n\t\tname: \"Powerhouse Document\"\n\t}] };\n\treturn Object.keys(patch).length > 0 ? patch : void 0;\n}\nfunction launchShell(shell, envVars, options) {\n\tif (shell.exe) return spawn(shell.exe, [], {\n\t\tcwd: shell.projectDir,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...envVars\n\t\t},\n\t\tstdio: \"inherit\",\n\t\twindowsHide: true\n\t});\n\tconst patch = tauriConfigPatch(options);\n\tconst args = [\"tauri\", \"dev\"];\n\tif (patch) args.push(\"--config\", JSON.stringify(patch));\n\treturn spawn(\"pnpm\", args, {\n\t\tcwd: shell.projectDir,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...envVars\n\t\t},\n\t\tstdio: \"inherit\",\n\t\tshell: true,\n\t\twindowsHide: true\n\t});\n}\n//#endregion\nexport { FEED_FILE_TEMPLATE as A, bundleBackend as C, appSlug as D, appJsonSchema as E, releaseFileName as F, releaseReport as I, collectRelease as M, feedFileName as N, loadAppJson as O, releaseBaseUrl as P, pruneStack as S, DEFAULT_SHELL_CRATE_VERSION as T, UNSIGNED_BUILD_CONF as _, tauriConfigPatch as a, bundleStack as b, nodeSidecarTarget as c, runTauriIcon as d, tauriBuildArgs as f, SHELL_DIR as g, ICON_SOURCE as h, shellEnv as i, RELEASE_DIR as j, updateEndpoints as k, preflightOrThrow as l, tauriSpawn as m, resolvePhCliEntry as n, detectToolchain as o, tauriBundlesForHost as p, resolveShell as r, fetchNodeSidecar as s, launchShell as t, resolveTauriCommand as u, bundleVersion as v, APP_JSON_FILE as w, pluginPackagesOf as x, projectShell as y };\n\n//# sourceMappingURL=shell-FYHRx89Y.mjs.map","import { A as FEED_FILE_TEMPLATE, C as bundleBackend, D as appSlug, E as appJsonSchema, F as releaseFileName, I as releaseReport, M as collectRelease, N as feedFileName, O as loadAppJson, P as releaseBaseUrl, S as pruneStack, T as DEFAULT_SHELL_CRATE_VERSION, _ as UNSIGNED_BUILD_CONF, a as tauriConfigPatch, b as bundleStack, c as nodeSidecarTarget, d as runTauriIcon, f as tauriBuildArgs, g as SHELL_DIR, h as ICON_SOURCE, i as shellEnv, j as RELEASE_DIR, k as updateEndpoints, l as preflightOrThrow, n as resolvePhCliEntry, o as detectToolchain, p as tauriBundlesForHost, r as resolveShell, s as fetchNodeSidecar, t as launchShell, u as resolveTauriCommand, w as APP_JSON_FILE, y as projectShell } from \"./shell-FYHRx89Y.mjs\";\nimport { mapBackgroundImages } from \"@powerhousedao/shared/connect\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport { deflateSync } from \"node:zlib\";\n//#region src/scaffold.ts\n/**\n* A background whose project-relative paths are rewritten to be relative to\n* another directory (powerhouse.config.json's root -> hosts/desktop, where\n* app.json resolves them from). URLs and data URIs are left as they are.\n*/\nfunction rebaseBackground(background, fromDir, toDir) {\n\tconst rebase = (ref) => {\n\t\tif (isPassthroughImageRef(ref)) return ref;\n\t\tconst rel = path.relative(toDir, path.resolve(fromDir, ref)).split(path.sep).join(\"/\");\n\t\treturn rel.startsWith(\".\") ? rel : `./${rel}`;\n\t};\n\treturn typeof background === \"string\" ? rebase(background) : mapBackgroundImages(background, rebase);\n}\n/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid\n* source. Pure Node (zlib); no binary asset ships in the package. The builder\n* replaces it with their real 1024×1024 artwork. */\nfunction solidPng(size, rgba) {\n\tconst [r, g, b, a] = rgba;\n\tconst row = Buffer.alloc(1 + size * 4);\n\tfor (let x = 0; x < size; x++) {\n\t\tconst o = 1 + x * 4;\n\t\trow[o] = r;\n\t\trow[o + 1] = g;\n\t\trow[o + 2] = b;\n\t\trow[o + 3] = a;\n\t}\n\tconst raw = Buffer.concat(Array.from({ length: size }, () => row));\n\tconst idat = deflateSync(raw);\n\tconst chunk = (type, data) => {\n\t\tconst len = Buffer.alloc(4);\n\t\tlen.writeUInt32BE(data.length, 0);\n\t\tconst typeBuf = Buffer.from(type, \"ascii\");\n\t\tconst body = Buffer.concat([typeBuf, data]);\n\t\tconst crc = Buffer.alloc(4);\n\t\tcrc.writeUInt32BE(crc32(body) >>> 0, 0);\n\t\treturn Buffer.concat([\n\t\t\tlen,\n\t\t\tbody,\n\t\t\tcrc\n\t\t]);\n\t};\n\tconst ihdr = Buffer.alloc(13);\n\tihdr.writeUInt32BE(size, 0);\n\tihdr.writeUInt32BE(size, 4);\n\tihdr[8] = 8;\n\tihdr[9] = 6;\n\tihdr[10] = 0;\n\tihdr[11] = 0;\n\tihdr[12] = 0;\n\treturn Buffer.concat([\n\t\tBuffer.from([\n\t\t\t137,\n\t\t\t80,\n\t\t\t78,\n\t\t\t71,\n\t\t\t13,\n\t\t\t10,\n\t\t\t26,\n\t\t\t10\n\t\t]),\n\t\tchunk(\"IHDR\", ihdr),\n\t\tchunk(\"IDAT\", idat),\n\t\tchunk(\"IEND\", Buffer.alloc(0))\n\t]);\n}\nlet crcTable;\nfunction crc32(buf) {\n\tif (!crcTable) {\n\t\tcrcTable = [];\n\t\tfor (let n = 0; n < 256; n++) {\n\t\t\tlet c = n;\n\t\t\tfor (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n\t\t\tcrcTable[n] = c;\n\t\t}\n\t}\n\tlet crc = 4294967295;\n\tfor (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;\n\treturn crc ^ 4294967295;\n}\nconst GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.\n/tauri-shell/target\n/tauri-shell/gen\n/tauri-shell/icons\n/tauri-shell/dist-stack\n/tauri-shell/binaries\n`;\nfunction scaffoldDesktopShell(hostDir, options) {\n\tconst created = [];\n\tconst skipped = [];\n\tfs.mkdirSync(hostDir, { recursive: true });\n\tconst iconFile = \"icon.png\";\n\tconst app = {\n\t\tidentifier: options.identifier,\n\t\tproductName: options.productName,\n\t\ticon: `./${iconFile}`,\n\t\tbackground: options.background ?? null,\n\t\tloading: null,\n\t\twindow: {\n\t\t\ttitle: options.productName,\n\t\t\twidth: 1440,\n\t\t\theight: 900\n\t\t},\n\t\tfileAssociations: [{\n\t\t\text: [\"phd\"],\n\t\t\tname: \"Powerhouse Document\",\n\t\t\tmimeType: \"application/vnd.powerhouse.document+zip\"\n\t\t}],\n\t\tupdates: null\n\t};\n\tappJsonSchema.parse(app);\n\tconst appJsonPath = path.join(hostDir, APP_JSON_FILE);\n\tif (fs.existsSync(appJsonPath) && !options.force) skipped.push(appJsonPath);\n\telse {\n\t\tfs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\\n`);\n\t\tcreated.push(appJsonPath);\n\t}\n\tconst iconPath = path.join(hostDir, iconFile);\n\tif (fs.existsSync(iconPath)) skipped.push(iconPath);\n\telse {\n\t\tfs.writeFileSync(iconPath, solidPng(1024, [\n\t\t\t79,\n\t\t\t70,\n\t\t\t229,\n\t\t\t255\n\t\t]));\n\t\tcreated.push(iconPath);\n\t}\n\tconst gitignorePath = path.join(hostDir, \".gitignore\");\n\tif (fs.existsSync(gitignorePath)) skipped.push(gitignorePath);\n\telse {\n\t\tfs.writeFileSync(gitignorePath, GITIGNORE);\n\t\tcreated.push(gitignorePath);\n\t}\n\treturn {\n\t\thostDir,\n\t\tcreated,\n\t\tskipped\n\t};\n}\n//#endregion\nexport { APP_JSON_FILE, DEFAULT_SHELL_CRATE_VERSION, FEED_FILE_TEMPLATE, ICON_SOURCE, RELEASE_DIR, SHELL_DIR, UNSIGNED_BUILD_CONF, appJsonSchema, appSlug, bundleBackend, bundleStack, collectRelease, detectToolchain, feedFileName, fetchNodeSidecar, launchShell, loadAppJson, nodeSidecarTarget, preflightOrThrow, projectShell, pruneStack, rebaseBackground, releaseBaseUrl, releaseFileName, releaseReport, resolvePhCliEntry, resolveShell, resolveTauriCommand, runTauriIcon, scaffoldDesktopShell, shellEnv, solidPng, tauriBuildArgs, tauriBundlesForHost, tauriConfigPatch, updateEndpoints };\n\n//# sourceMappingURL=index.mjs.map","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { rebaseBackground, scaffoldDesktopShell } from \"@powerhousedao/desktop\";\nimport type { PHBackground } from \"@powerhousedao/shared/clis\";\n\nexport interface GenerateDesktopShellArgs {\n name?: string;\n identifier?: string;\n force?: boolean;\n}\n\n/** A reverse-DNS-safe segment from the project name (drop scope, slugify). */\nfunction projectSlug(pkgName: string | undefined): string {\n const bare = (pkgName ?? \"app\").replace(/^@[^/]+\\//, \"\");\n const seg = bare\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return seg || \"app\";\n}\n\n/** `connect.home.background` of the project's powerhouse.config.json, if\n * any (absent or unreadable config: none). */\nfunction readHomeBackground(cwd: string): PHBackground | null {\n try {\n const config = JSON.parse(\n fs.readFileSync(path.join(cwd, \"powerhouse.config.json\"), \"utf8\"),\n ) as { connect?: { home?: { background?: PHBackground | null } } };\n return config.connect?.home?.background ?? null;\n } catch {\n return null;\n }\n}\n\n/** `ph generate desktop-shell`: write hosts/desktop/app.json + a placeholder\n * icon + .gitignore. Defaults product name / identifier from the project. */\nexport function startGenerateDesktopShell(\n args: GenerateDesktopShellArgs,\n cwd: string,\n): void {\n let pkgName: string | undefined;\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { name?: string };\n pkgName = pkg.name;\n } catch {\n // no package.json — fall back to defaults below\n }\n const slug = projectSlug(pkgName);\n const productName = args.name ?? pkgName?.replace(/^@[^/]+\\//, \"\") ?? \"App\";\n const identifier = args.identifier ?? `inc.powerhouse.desktop.${slug}`;\n\n const hostDir = path.join(cwd, \"hosts\", \"desktop\");\n // The loading page takes Connect's home background, the same layers in\n // the same places, with its paths rebased from the project root to\n // hosts/desktop (app.json resolves them from where it lives).\n const homeBackground = readHomeBackground(cwd);\n const result = scaffoldDesktopShell(hostDir, {\n identifier,\n productName,\n force: args.force,\n background: homeBackground\n ? rebaseBackground(homeBackground, cwd, hostDir)\n : null,\n });\n\n const rel = (p: string) => path.relative(cwd, p).replace(/\\\\/g, \"/\");\n for (const f of result.created) console.log(` created ${rel(f)}`);\n if (homeBackground && result.created.some((f) => f.endsWith(\"app.json\"))) {\n console.log(\n \" copied connect.home.background -> hosts/desktop/app.json background\",\n );\n }\n for (const f of result.skipped) {\n console.log(` skipped ${rel(f)} (exists — pass --force to overwrite)`);\n }\n if (!fs.existsSync(path.join(hostDir, \"host.js\"))) {\n console.log(\n `\\nNote: hosts/desktop/host.js not found. Add a desktop host (see the ` +\n `desktop topology from \\`ph init\\`) so \\`ph run desktop\\` can supervise ` +\n `the stack; app.json then gives it a native window.`,\n );\n }\n console.log(\n `\\nIdentity: ${productName} (${identifier}).\\n` +\n `• Replace hosts/desktop/icon.png with your 1024×1024 icon.\\n` +\n `• \\`ph run desktop dev\\` opens the native window (needs Rust + the Tauri CLI).\\n` +\n `• \\`ph run desktop build\\` produces installers for this OS.`,\n );\n}\n"],"names":["z.string","z.strictObject","z.number","z.boolean","z.union","z.array"],"mappings":";;;;;;;;;;;;;;;;;;;AAiLA,MAAM,mBAAmBA,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,qCAAqC,yFAAyF;AAC/K,MAAM,eAAeC,aAAe;CACnC,OAAOD,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAClC,OAAOE,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC5C,QAAQA,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC7C,WAAWC,QAAU,CAAC,CAAC,SAAS;;CAEhC,UAAUD,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC/C,WAAWA,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AACjD,CAAC,CAAC,CAAC,SAAS;AACZ,MAAM,iBAAiBF,OAAS,CAAC,CAAC,MAAM,yDAAyD,qDAAqD;;AAEtJ,MAAM,sBAAsBC,aAAe;;CAE1C,YAAY,eAAe,SAAS,CAAC,CAAC,SAAS;;CAE/C,OAAO,eAAe,SAAS,CAAC,CAAC,SAAS;;CAE1C,QAAQ,eAAe,SAAS,CAAC,CAAC,SAAS;AAC5C,CAAC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AAG,aAAa,KAAK,KAAK,KAAK,cAAc,GAAG,MAAM,CAE5C,CAAC,CAAC;CAChB,QAAQ,CAER;CACA,MAAM,OAAO,YAAY,OAAO;CAChC,MAAM,cAAc,KAAK,QAAQ,SAAS,QAAQ,aAAa,EAAE,KAAK;CACtE,MAAM,aAAa,KAAK,cAAc,0BAA0B;CAEhE,MAAM,UAAU,KAAK,KAAK,KAAK,SAAS,SAAS;CAIjD,MAAM,iBAAiB,mBAAmB,GAAG;CAC7C,MAAM,SAAS,qBAAqB,SAAS;EAC3C;EACA;EACA,OAAO,KAAK;EACZ,YAAY,iBACR,iBAAiB,gBAAgB,KAAK,OAAO,IAC7C;CACN,CAAC;CAED,MAAM,OAAO,MAAc,KAAK,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ,OAAO,GAAG;CACnE,KAAK,MAAM,KAAK,OAAO,SAAS,QAAQ,IAAI,cAAc,IAAI,CAAC,GAAG;CAClE,IAAI,kBAAkB,OAAO,QAAQ,MAAM,MAAM,EAAE,SAAS,UAAU,CAAC,GACrE,QAAQ,IACN,yEACF;CAEF,KAAK,MAAM,KAAK,OAAO,SACrB,QAAQ,IAAI,cAAc,IAAI,CAAC,EAAE,sCAAsC;CAEzE,IAAI,CAAC,GAAG,WAAW,KAAK,KAAK,SAAS,SAAS,CAAC,GAC9C,QAAQ,IACN,4LAGF;CAEF,QAAQ,IACN,eAAe,YAAY,IAAI,WAAW,4MAI5C;AACF","debug_id":"4108e7b8-a71a-5214-ad0f-77757e6d1569"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/get-version.ts
|
|
2
2
|
|
|
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]="
|
|
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]="8f0d1d4a-fb1f-52b6-ad70-45ad779c2078")}catch(e){}}();
|
|
4
4
|
function getVersion() {
|
|
5
|
-
return "6.3.0-dev.
|
|
5
|
+
return "6.3.0-dev.2";
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getVersion as t };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=get-version-
|
|
11
|
-
//# debugId=
|
|
10
|
+
//# sourceMappingURL=get-version-DATiLAmB.mjs.map
|
|
11
|
+
//# debugId=8f0d1d4a-fb1f-52b6-ad70-45ad779c2078
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-
|
|
1
|
+
{"version":3,"file":"get-version-DATiLAmB.mjs","sources":["../src/get-version.ts"],"sourcesContent":["declare const CLI_VERSION: string | undefined;\ndeclare const CLI_GIT_SHA: string | undefined;\n\nexport function getVersion() {\n if (typeof CLI_VERSION !== \"undefined\") return CLI_VERSION;\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n\nexport function getGitHash() {\n if (typeof CLI_GIT_SHA !== \"undefined\") return CLI_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA || \"unknown\";\n}\n"],"names":[],"mappings":";;;AAGA,SAAgB,aAAa;CACa,OAAA;AAM1C","debug_id":"8f0d1d4a-fb1f-52b6-ad70-45ad779c2078"}
|