@powerhousedao/desktop 6.2.3-dev.56 → 6.2.3-dev.58
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-DcBLVLVz.mjs","names":[],"sources":["../src/bundle-stack.ts","../src/shell.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\r\nimport fs from \"node:fs\";\r\nimport path from \"node:path\";\r\n\r\n/**\r\n * P6.3 — stage the shippable STACK into the shell project: everything the\r\n * installed app needs to run `ph run desktop` with no environment at all\r\n * (D6.c). The shell's resources map `../dist-stack` → `stack`, and its\r\n * uniform-runners mode falls back to `resources/stack` when the env pair is\r\n * absent. Layout:\r\n *\r\n * dist-stack/\r\n * hosts/ the project's host files\r\n * agents/ when present\r\n * powerhouse.config.json\r\n * package.json minimal, names the project\r\n * dist/ the BUILT Connect (ph run connect build)\r\n * node_modules/ vendored @powerhousedao/ph-cli (hoisted,\r\n * real files — computed-specifier imports and\r\n * PGlite wasm forbid bundling)\r\n */\r\nexport interface BundleStackOptions {\r\n projectRoot: string;\r\n shellProjectDir: string;\r\n /** Vendor the runtime packages (slow). Skipped when false — an existing\r\n * vendored tree is left in place. */\r\n vendor?: boolean;\r\n /** The ph-cli version/tag to vendor. Default: \"dev\". NOTE: the vendored\r\n * ph-cli must carry the `run` command — registry tags published before\r\n * uniform-runners landed cannot run a stack; until a nightly catches up,\r\n * pass `phCliSpec` with a locally packed tarball instead. */\r\n phCliVersion?: string;\r\n /** Overrides the ph-cli install spec entirely (e.g. a `pnpm pack` tarball\r\n * path for a not-yet-published build). */\r\n phCliSpec?: string;\r\n /** The connect member's port — written into the stack's shell.json so the\r\n * shell knows where to probe/navigate with no environment at all. */\r\n connectPort?: number;\r\n logger?: (message: string) => void;\r\n}\r\n\r\nexport interface BundleStackResult {\r\n stackDir: string;\r\n vendored: boolean;\r\n}\r\n\r\nfunction copyIfExists(from: string, to: string): boolean {\r\n if (!fs.existsSync(from)) return false;\r\n fs.cpSync(from, to, { recursive: true });\r\n return true;\r\n}\r\n\r\nexport function bundleStack(options: BundleStackOptions): BundleStackResult {\r\n const log = options.logger ?? console.log;\r\n const stackDir = path.join(options.shellProjectDir, \"dist-stack\");\r\n\r\n // Fresh staging for project files; the vendored node_modules survives\r\n // unless re-vendoring (it is by far the slowest part).\r\n for (const entry of [\r\n \"hosts\",\r\n \"agents\",\r\n \"dist\",\r\n \"powerhouse.config.json\",\r\n \"package.json\",\r\n ]) {\r\n fs.rmSync(path.join(stackDir, entry), { recursive: true, force: true });\r\n }\r\n fs.mkdirSync(stackDir, { recursive: true });\r\n\r\n for (const dir of [\"hosts\", \"agents\", \"dist\"]) {\r\n const copied = copyIfExists(\r\n path.join(options.projectRoot, dir),\r\n path.join(stackDir, dir),\r\n );\r\n log(` ${dir}/ ${copied ? \"staged\" : \"absent — skipped\"}`);\r\n }\r\n\r\n // Inside the package there is no nested shell — the shell IS the window —\r\n // so the staged desktop host runs on the generic compound. Rewrite the\r\n // runner.module projection in the STAGED copy only.\r\n const stagedDesktopHost = path.join(stackDir, \"hosts\", \"desktop\", \"host.js\");\r\n if (fs.existsSync(stagedDesktopHost)) {\r\n const source = fs.readFileSync(stagedDesktopHost, \"utf8\");\r\n if (source.includes(\"@powerhousedao/desktop/runner\")) {\r\n fs.writeFileSync(\r\n stagedDesktopHost,\r\n \"// STAGED COPY (bundle-stack): runner.module rewritten to the generic\\n\" +\r\n \"// compound — the packaged shell is the window; there is no nested shell.\\n\" +\r\n source.replace(\r\n /@powerhousedao\\/desktop\\/runner/g,\r\n \"@powerhousedao/host-core/runners/compound\",\r\n ),\r\n );\r\n log(\" hosts/desktop/host.js: runner rewritten to the generic compound (staged copy)\");\r\n }\r\n }\r\n copyIfExists(\r\n path.join(options.projectRoot, \"powerhouse.config.json\"),\r\n path.join(stackDir, \"powerhouse.config.json\"),\r\n );\r\n\r\n // shell.json: the stack's contract with the shell. The no-env (packaged)\r\n // path has nobody to set PH_WIN_CONNECT_PORT, so the shell reads the probe\r\n // and window port from here.\r\n if (typeof options.connectPort === \"number\") {\r\n fs.writeFileSync(\r\n path.join(stackDir, \"shell.json\"),\r\n `${JSON.stringify({ connectPort: options.connectPort }, null, 2)}\\n`,\r\n );\r\n log(` shell.json: connectPort ${options.connectPort}`);\r\n }\r\n\r\n // A minimal manifest: names the project (lock identity) and depends on\r\n // ph-cli so the vendored tree resolves exactly like a real install.\r\n const sourcePkg = JSON.parse(\r\n fs.readFileSync(path.join(options.projectRoot, \"package.json\"), \"utf8\"),\r\n ) as { name?: string };\r\n const version = options.phCliVersion ?? \"dev\";\r\n fs.writeFileSync(\r\n path.join(stackDir, \"package.json\"),\r\n `${JSON.stringify(\r\n {\r\n name: sourcePkg.name ?? \"powerhouse-desktop-stack\",\r\n private: true,\r\n type: \"module\",\r\n dependencies: { \"@powerhousedao/ph-cli\": version },\r\n },\r\n null,\r\n 2,\r\n )}\\n`,\r\n );\r\n\r\n let vendored = false;\r\n if (options.vendor !== false) {\r\n const phCliSpec = options.phCliSpec ?? `@powerhousedao/ph-cli@${version}`;\r\n // host-core rides along: host files resolve runner modules (the generic\r\n // compound) from the STACK's own node_modules.\r\n const specs = `\"${phCliSpec}\" \"@powerhousedao/host-core@${version}\"`;\r\n log(` vendoring ${specs} (hoisted, real files)…`);\r\n // One command string: shell:true with an args ARRAY concatenates without\r\n // escaping (DEP0190 warns); the spec values are our own constants/paths.\r\n const result = spawnSync(\r\n `npm install ${specs} --install-strategy=hoisted --omit=dev --no-audit --no-fund`,\r\n { cwd: stackDir, stdio: \"pipe\", shell: true, windowsHide: true },\r\n );\r\n if (result.status !== 0) {\r\n throw new Error(\r\n `bundle-stack: vendoring failed (${result.status}):\\n` +\r\n `${result.stderr.toString().slice(-800)}`,\r\n );\r\n }\r\n vendored = true;\r\n } else {\r\n log(\" vendoring skipped (vendor: false) — existing tree left in place\");\r\n }\r\n\r\n return { stackDir, vendored };\r\n}\r\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Shell discovery and launch. The Rust/Tauri shell lives in the\n * ph-win-desktop repo (cargo cannot ride an npm package); the runner locates\n * a checkout via `runner.shell.project` or PH_DESKTOP_SHELL and prefers its\n * BUILT exe (dev config like window title is baked into a build — the\n * `--config` projection below applies to tauri-cli invocations only).\n */\n\nexport interface ShellOptions {\n /** Path to a ph-win-desktop checkout (absolute or project-relative). */\n project?: string;\n window?: { title?: string; width?: number; height?: number };\n tray?: boolean;\n fileAssociations?: string[];\n}\n\nexport interface ResolvedShell {\n projectDir: string;\n /** A built exe when one exists (debug preferred for dev), else undefined →\n * fall back to `pnpm tauri dev`. */\n exe?: string;\n}\n\nexport function resolveShell(\n projectRoot: string,\n options: ShellOptions | undefined,\n env: Record<string, string | undefined>,\n): ResolvedShell {\n const configured = options?.project ?? env.PH_DESKTOP_SHELL;\n if (!configured) {\n throw new Error(\n \"No desktop shell configured: set runner.shell.project in the host file \" +\n \"(path to a ph-win-desktop checkout) or the PH_DESKTOP_SHELL \" +\n \"environment variable. `ph run desktop` (headless stack) needs neither.\",\n );\n }\n const projectDir = path.resolve(projectRoot, configured);\n if (!fs.existsSync(path.join(projectDir, \"src-tauri\"))) {\n throw new Error(\n `Desktop shell not found at ${projectDir} (no src-tauri/) — check ` +\n `runner.shell.project / PH_DESKTOP_SHELL.`,\n );\n }\n const candidates = [\n path.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win.exe\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win.exe\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win\"),\n ];\n const exe = candidates.find((c) => fs.existsSync(c));\n return { projectDir, exe };\n}\n\n/** Resolve the project's ph-cli entry from ITS dependency tree — the same\n * resolution `ph run` itself uses. */\nexport function resolvePhCliEntry(projectRoot: string): string {\n const require_ = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n const pkgPath = require_.resolve(\"@powerhousedao/ph-cli/package.json\");\n return path.join(path.dirname(pkgPath), \"dist\", \"cli.mjs\");\n}\n\n/** The env trio (plus flag and userData) the shell's uniform-runners mode\n * reads — wired by the RUNNER so nobody exports variables by hand. */\nexport function shellEnv(\n projectRoot: string,\n connectPort: number,\n env: Record<string, string | undefined>,\n): Record<string, string> {\n return {\n FEATURE_UNIFORM_RUNNERS_ENABLED: \"1\",\n PH_RUN_PROJECT: projectRoot,\n PH_RUN_CLI: resolvePhCliEntry(projectRoot),\n PH_WIN_CONNECT_PORT: String(connectPort),\n ...(env.PH_USER_DATA_DIR ? { PH_USER_DATA_DIR: env.PH_USER_DATA_DIR } : {}),\n };\n}\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. */\nexport function tauriConfigPatch(\n options: ShellOptions | undefined,\n): Record<string, unknown> | undefined {\n if (!options) return undefined;\n const patch: Record<string, unknown> = {};\n if (options.window) {\n patch.app = {\n windows: [\n {\n ...(options.window.title ? { title: options.window.title } : {}),\n ...(options.window.width ? { width: options.window.width } : {}),\n ...(options.window.height ? { height: options.window.height } : {}),\n },\n ],\n };\n }\n if (options.fileAssociations?.length) {\n patch.bundle = {\n fileAssociations: [\n {\n ext: options.fileAssociations.map((e) => e.replace(/^\\./, \"\")),\n name: \"Powerhouse Document\",\n },\n ],\n };\n }\n return Object.keys(patch).length > 0 ? patch : undefined;\n}\n\nexport function launchShell(\n shell: ResolvedShell,\n envVars: Record<string, string>,\n options: ShellOptions | undefined,\n): ChildProcess {\n if (shell.exe) {\n return spawn(shell.exe, [], {\n cwd: shell.projectDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n windowsHide: true,\n });\n }\n // tauri dev (needs cargo); config projection applies here.\n const patch = tauriConfigPatch(options);\n const args = [\"tauri\", \"dev\"];\n if (patch) args.push(\"--config\", JSON.stringify(patch));\n return spawn(\"pnpm\", args, {\n cwd: shell.projectDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n}\n"],"mappings":";;;;;;AA8CA,SAAS,aAAa,MAAc,IAAqB;CACvD,IAAI,CAAC,GAAG,WAAW,IAAI,GAAG,OAAO;CACjC,GAAG,OAAO,MAAM,IAAI,EAAE,WAAW,KAAK,CAAC;CACvC,OAAO;AACT;AAEA,SAAgB,YAAY,SAAgD;CAC1E,MAAM,MAAM,QAAQ,UAAU,QAAQ;CACtC,MAAM,WAAW,KAAK,KAAK,QAAQ,iBAAiB,YAAY;CAIhE,KAAK,MAAM,SAAS;EAClB;EACA;EACA;EACA;EACA;CACF,GACE,GAAG,OAAO,KAAK,KAAK,UAAU,KAAK,GAAG;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAExE,GAAG,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAE1C,KAAK,MAAM,OAAO;EAAC;EAAS;EAAU;CAAM,GAK1C,IAAI,KAAK,IAAI,IAJE,aACb,KAAK,KAAK,QAAQ,aAAa,GAAG,GAClC,KAAK,KAAK,UAAU,GAAG,CAEH,IAAI,WAAW,oBAAoB;CAM3D,MAAM,oBAAoB,KAAK,KAAK,UAAU,SAAS,WAAW,SAAS;CAC3E,IAAI,GAAG,WAAW,iBAAiB,GAAG;EACpC,MAAM,SAAS,GAAG,aAAa,mBAAmB,MAAM;EACxD,IAAI,OAAO,SAAS,+BAA+B,GAAG;GACpD,GAAG,cACD,mBACA,uJAEE,OAAO,QACL,oCACA,2CACF,CACJ;GACA,IAAI,iFAAiF;EACvF;CACF;CACA,aACE,KAAK,KAAK,QAAQ,aAAa,wBAAwB,GACvD,KAAK,KAAK,UAAU,wBAAwB,CAC9C;CAKA,IAAI,OAAO,QAAQ,gBAAgB,UAAU;EAC3C,GAAG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AAC,SAAS,IAAI,QAAQ,KAAA;AACjD;AAEA,SAAgB,YACd,OACA,SACA,SACc;CACd,IAAI,MAAM,KACR,OAAO,MAAM,MAAM,KAAK,CAAC,GAAG;EAC1B,KAAK,MAAM;EACX,KAAK;GAAE,GAAG,QAAQ;GAAK,GAAG;EAAQ;EAClC,OAAO;EACP,aAAa;CACf,CAAC;CAGH,MAAM,QAAQ,iBAAiB,OAAO;CACtC,MAAM,OAAO,CAAC,SAAS,KAAK;CAC5B,IAAI,OAAO,KAAK,KAAK,YAAY,KAAK,UAAU,KAAK,CAAC;CACtD,OAAO,MAAM,QAAQ,MAAM;EACzB,KAAK,MAAM;EACX,KAAK;GAAE,GAAG,QAAQ;GAAK,GAAG;EAAQ;EAClC,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"shell-DcBLVLVz.mjs","names":[],"sources":["../src/bundle-stack.ts","../src/shell.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\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 BUILT Connect (ph run connect build)\n * node_modules/ vendored @powerhousedao/ph-cli (hoisted,\n * real files — computed-specifier imports and\n * PGlite wasm forbid bundling)\n */\nexport interface BundleStackOptions {\n projectRoot: string;\n shellProjectDir: string;\n /** Vendor the runtime packages (slow). Skipped when false — an existing\n * vendored tree is left in place. */\n vendor?: boolean;\n /** The ph-cli version/tag to vendor. Default: \"dev\". NOTE: the vendored\n * ph-cli must carry the `run` command — registry tags published before\n * uniform-runners landed cannot run a stack; until a nightly catches up,\n * pass `phCliSpec` with a locally packed tarball instead. */\n phCliVersion?: string;\n /** Overrides the ph-cli install spec entirely (e.g. a `pnpm pack` tarball\n * path for a not-yet-published build). */\n phCliSpec?: string;\n /** The connect member's port — written into the stack's shell.json so the\n * shell knows where to probe/navigate with no environment at all. */\n connectPort?: number;\n logger?: (message: string) => void;\n}\n\nexport interface BundleStackResult {\n stackDir: string;\n vendored: boolean;\n}\n\nfunction copyIfExists(from: string, to: string): boolean {\n if (!fs.existsSync(from)) return false;\n fs.cpSync(from, to, { recursive: true });\n return true;\n}\n\nexport function bundleStack(options: BundleStackOptions): BundleStackResult {\n const log = options.logger ?? console.log;\n const stackDir = path.join(options.shellProjectDir, \"dist-stack\");\n\n // Fresh staging for project files; the vendored node_modules survives\n // unless re-vendoring (it is by far the slowest part).\n for (const entry of [\n \"hosts\",\n \"agents\",\n \"dist\",\n \"powerhouse.config.json\",\n \"package.json\",\n ]) {\n fs.rmSync(path.join(stackDir, entry), { recursive: true, force: true });\n }\n fs.mkdirSync(stackDir, { recursive: true });\n\n for (const dir of [\"hosts\", \"agents\", \"dist\"]) {\n const copied = copyIfExists(\n path.join(options.projectRoot, dir),\n path.join(stackDir, dir),\n );\n log(` ${dir}/ ${copied ? \"staged\" : \"absent — skipped\"}`);\n }\n\n // Inside the package there is no nested shell — the shell IS the window —\n // so the staged desktop host runs on the generic compound. Rewrite the\n // runner.module projection in the STAGED copy only.\n const stagedDesktopHost = path.join(stackDir, \"hosts\", \"desktop\", \"host.js\");\n if (fs.existsSync(stagedDesktopHost)) {\n const source = fs.readFileSync(stagedDesktopHost, \"utf8\");\n if (source.includes(\"@powerhousedao/desktop/runner\")) {\n fs.writeFileSync(\n stagedDesktopHost,\n \"// STAGED COPY (bundle-stack): runner.module rewritten to the generic\\n\" +\n \"// compound — the packaged shell is the window; there is no nested shell.\\n\" +\n source.replace(\n /@powerhousedao\\/desktop\\/runner/g,\n \"@powerhousedao/host-core/runners/compound\",\n ),\n );\n log(\n \" hosts/desktop/host.js: runner rewritten to the generic compound (staged copy)\",\n );\n }\n }\n copyIfExists(\n path.join(options.projectRoot, \"powerhouse.config.json\"),\n path.join(stackDir, \"powerhouse.config.json\"),\n );\n\n // shell.json: the stack's contract with the shell. The no-env (packaged)\n // path has nobody to set PH_WIN_CONNECT_PORT, so the shell reads the probe\n // and window port from here.\n if (typeof options.connectPort === \"number\") {\n fs.writeFileSync(\n path.join(stackDir, \"shell.json\"),\n `${JSON.stringify({ connectPort: options.connectPort }, null, 2)}\\n`,\n );\n log(` shell.json: connectPort ${options.connectPort}`);\n }\n\n // A minimal manifest: names the project (lock identity) and depends on\n // ph-cli so the vendored tree resolves exactly like a real install.\n const sourcePkg = JSON.parse(\n fs.readFileSync(path.join(options.projectRoot, \"package.json\"), \"utf8\"),\n ) as { name?: string };\n const version = options.phCliVersion ?? \"dev\";\n fs.writeFileSync(\n path.join(stackDir, \"package.json\"),\n `${JSON.stringify(\n {\n name: sourcePkg.name ?? \"powerhouse-desktop-stack\",\n private: true,\n type: \"module\",\n dependencies: { \"@powerhousedao/ph-cli\": version },\n },\n null,\n 2,\n )}\\n`,\n );\n\n let vendored = false;\n if (options.vendor !== false) {\n const phCliSpec = options.phCliSpec ?? `@powerhousedao/ph-cli@${version}`;\n // host-core rides along: host files resolve runner modules (the generic\n // compound) from the STACK's own node_modules.\n const specs = `\"${phCliSpec}\" \"@powerhousedao/host-core@${version}\"`;\n log(` vendoring ${specs} (hoisted, real files)…`);\n // One command string: shell:true with an args ARRAY concatenates without\n // escaping (DEP0190 warns); the spec values are our own constants/paths.\n const result = spawnSync(\n `npm install ${specs} --install-strategy=hoisted --omit=dev --no-audit --no-fund`,\n { cwd: stackDir, stdio: \"pipe\", shell: true, windowsHide: true },\n );\n if (result.status !== 0) {\n throw new Error(\n `bundle-stack: vendoring failed (${result.status}):\\n` +\n `${result.stderr.toString().slice(-800)}`,\n );\n }\n vendored = true;\n } else {\n log(\" vendoring skipped (vendor: false) — existing tree left in place\");\n }\n\n return { stackDir, vendored };\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Shell discovery and launch. The Rust/Tauri shell lives in the\n * ph-win-desktop repo (cargo cannot ride an npm package); the runner locates\n * a checkout via `runner.shell.project` or PH_DESKTOP_SHELL and prefers its\n * BUILT exe (dev config like window title is baked into a build — the\n * `--config` projection below applies to tauri-cli invocations only).\n */\n\nexport interface ShellOptions {\n /** Path to a ph-win-desktop checkout (absolute or project-relative). */\n project?: string;\n window?: { title?: string; width?: number; height?: number };\n tray?: boolean;\n fileAssociations?: string[];\n}\n\nexport interface ResolvedShell {\n projectDir: string;\n /** A built exe when one exists (debug preferred for dev), else undefined →\n * fall back to `pnpm tauri dev`. */\n exe?: string;\n}\n\nexport function resolveShell(\n projectRoot: string,\n options: ShellOptions | undefined,\n env: Record<string, string | undefined>,\n): ResolvedShell {\n const configured = options?.project ?? env.PH_DESKTOP_SHELL;\n if (!configured) {\n throw new Error(\n \"No desktop shell configured: set runner.shell.project in the host file \" +\n \"(path to a ph-win-desktop checkout) or the PH_DESKTOP_SHELL \" +\n \"environment variable. `ph run desktop` (headless stack) needs neither.\",\n );\n }\n const projectDir = path.resolve(projectRoot, configured);\n if (!fs.existsSync(path.join(projectDir, \"src-tauri\"))) {\n throw new Error(\n `Desktop shell not found at ${projectDir} (no src-tauri/) — check ` +\n `runner.shell.project / PH_DESKTOP_SHELL.`,\n );\n }\n const candidates = [\n path.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win.exe\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win.exe\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"debug\", \"ph-win\"),\n path.join(projectDir, \"src-tauri\", \"target\", \"release\", \"ph-win\"),\n ];\n const exe = candidates.find((c) => fs.existsSync(c));\n return { projectDir, exe };\n}\n\n/** Resolve the project's ph-cli entry from ITS dependency tree — the same\n * resolution `ph run` itself uses. */\nexport function resolvePhCliEntry(projectRoot: string): string {\n const require_ = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n const pkgPath = require_.resolve(\"@powerhousedao/ph-cli/package.json\");\n return path.join(path.dirname(pkgPath), \"dist\", \"cli.mjs\");\n}\n\n/** The env trio (plus flag and userData) the shell's uniform-runners mode\n * reads — wired by the RUNNER so nobody exports variables by hand. */\nexport function shellEnv(\n projectRoot: string,\n connectPort: number,\n env: Record<string, string | undefined>,\n): Record<string, string> {\n return {\n FEATURE_UNIFORM_RUNNERS_ENABLED: \"1\",\n PH_RUN_PROJECT: projectRoot,\n PH_RUN_CLI: resolvePhCliEntry(projectRoot),\n PH_WIN_CONNECT_PORT: String(connectPort),\n ...(env.PH_USER_DATA_DIR ? { PH_USER_DATA_DIR: env.PH_USER_DATA_DIR } : {}),\n };\n}\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. */\nexport function tauriConfigPatch(\n options: ShellOptions | undefined,\n): Record<string, unknown> | undefined {\n if (!options) return undefined;\n const patch: Record<string, unknown> = {};\n if (options.window) {\n patch.app = {\n windows: [\n {\n ...(options.window.title ? { title: options.window.title } : {}),\n ...(options.window.width ? { width: options.window.width } : {}),\n ...(options.window.height ? { height: options.window.height } : {}),\n },\n ],\n };\n }\n if (options.fileAssociations?.length) {\n patch.bundle = {\n fileAssociations: [\n {\n ext: options.fileAssociations.map((e) => e.replace(/^\\./, \"\")),\n name: \"Powerhouse Document\",\n },\n ],\n };\n }\n return Object.keys(patch).length > 0 ? patch : undefined;\n}\n\nexport function launchShell(\n shell: ResolvedShell,\n envVars: Record<string, string>,\n options: ShellOptions | undefined,\n): ChildProcess {\n if (shell.exe) {\n return spawn(shell.exe, [], {\n cwd: shell.projectDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n windowsHide: true,\n });\n }\n // tauri dev (needs cargo); config projection applies here.\n const patch = tauriConfigPatch(options);\n const args = [\"tauri\", \"dev\"];\n if (patch) args.push(\"--config\", JSON.stringify(patch));\n return spawn(\"pnpm\", args, {\n cwd: shell.projectDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n}\n"],"mappings":";;;;;;AA8CA,SAAS,aAAa,MAAc,IAAqB;CACvD,IAAI,CAAC,GAAG,WAAW,IAAI,GAAG,OAAO;CACjC,GAAG,OAAO,MAAM,IAAI,EAAE,WAAW,KAAK,CAAC;CACvC,OAAO;AACT;AAEA,SAAgB,YAAY,SAAgD;CAC1E,MAAM,MAAM,QAAQ,UAAU,QAAQ;CACtC,MAAM,WAAW,KAAK,KAAK,QAAQ,iBAAiB,YAAY;CAIhE,KAAK,MAAM,SAAS;EAClB;EACA;EACA;EACA;EACA;CACF,GACE,GAAG,OAAO,KAAK,KAAK,UAAU,KAAK,GAAG;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAExE,GAAG,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAE1C,KAAK,MAAM,OAAO;EAAC;EAAS;EAAU;CAAM,GAK1C,IAAI,KAAK,IAAI,IAJE,aACb,KAAK,KAAK,QAAQ,aAAa,GAAG,GAClC,KAAK,KAAK,UAAU,GAAG,CAEH,IAAI,WAAW,oBAAoB;CAM3D,MAAM,oBAAoB,KAAK,KAAK,UAAU,SAAS,WAAW,SAAS;CAC3E,IAAI,GAAG,WAAW,iBAAiB,GAAG;EACpC,MAAM,SAAS,GAAG,aAAa,mBAAmB,MAAM;EACxD,IAAI,OAAO,SAAS,+BAA+B,GAAG;GACpD,GAAG,cACD,mBACA,uJAEE,OAAO,QACL,oCACA,2CACF,CACJ;GACA,IACE,iFACF;EACF;CACF;CACA,aACE,KAAK,KAAK,QAAQ,aAAa,wBAAwB,GACvD,KAAK,KAAK,UAAU,wBAAwB,CAC9C;CAKA,IAAI,OAAO,QAAQ,gBAAgB,UAAU;EAC3C,GAAG,cACD,KAAK,KA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I,QAAQ,KAAA;AACjD;AAEA,SAAgB,YACd,OACA,SACA,SACc;CACd,IAAI,MAAM,KACR,OAAO,MAAM,MAAM,KAAK,CAAC,GAAG;EAC1B,KAAK,MAAM;EACX,KAAK;GAAE,GAAG,QAAQ;GAAK,GAAG;EAAQ;EAClC,OAAO;EACP,aAAa;CACf,CAAC;CAGH,MAAM,QAAQ,iBAAiB,OAAO;CACtC,MAAM,OAAO,CAAC,SAAS,KAAK;CAC5B,IAAI,OAAO,KAAK,KAAK,YAAY,KAAK,UAAU,KAAK,CAAC;CACtD,OAAO,MAAM,QAAQ,MAAM;EACzB,KAAK,MAAM;EACX,KAAK;GAAE,GAAG,QAAQ;GAAK,GAAG;EAAQ;EAClC,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/desktop",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.58",
|
|
4
4
|
"description": "The desktop runner for uniform-runners hosts: the generic compound stack wrapped in a native shell — dev opens the window, build stages the shippable stack.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/powerhouse-inc/powerhouse",
|
|
8
|
+
"directory": "packages/desktop"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"publishConfig": {
|
|
7
12
|
"access": "public"
|
|
@@ -21,10 +26,11 @@
|
|
|
21
26
|
"types": "./dist/runner.d.mts",
|
|
22
27
|
"import": "./dist/runner.mjs",
|
|
23
28
|
"default": "./dist/runner.mjs"
|
|
24
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
25
31
|
},
|
|
26
32
|
"dependencies": {
|
|
27
|
-
"@powerhousedao/host-core": "6.2.3-dev.
|
|
33
|
+
"@powerhousedao/host-core": "6.2.3-dev.58",
|
|
28
34
|
"zod": "4.3.6"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|