@powerhousedao/desktop 6.2.3-dev.60 → 6.2.3-dev.62
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/index.d.mts +166 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +132 -2
- package/dist/index.mjs.map +1 -0
- package/dist/runner.d.mts +20 -13
- package/dist/runner.d.mts.map +1 -1
- package/dist/runner.mjs +137 -20
- package/dist/runner.mjs.map +1 -1
- package/dist/shell-BL61-fyi.mjs +656 -0
- package/dist/shell-BL61-fyi.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/shell-DcBLVLVz.mjs +0 -148
- package/dist/shell-DcBLVLVz.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { ChildProcess } from "node:child_process";
|
|
3
|
+
//#region src/app-json.d.ts
|
|
4
|
+
export declare const appJsonSchema: z.ZodObject<{
|
|
5
|
+
identifier: z.ZodString;
|
|
6
|
+
productName: z.ZodString;
|
|
7
|
+
icon: z.ZodString;
|
|
8
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
title: z.ZodOptional<z.ZodString>;
|
|
10
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
resizable: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strict>>;
|
|
14
|
+
fileAssociations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
ext: z.ZodArray<z.ZodString>;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>>>;
|
|
20
|
+
shell: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
path: z.ZodOptional<z.ZodString>;
|
|
22
|
+
git: z.ZodOptional<z.ZodString>;
|
|
23
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
24
|
+
rev: z.ZodOptional<z.ZodString>;
|
|
25
|
+
version: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
type AppJson = z.infer<typeof appJsonSchema>;
|
|
29
|
+
type AppJsonShellSource = NonNullable<AppJson["shell"]>;
|
|
30
|
+
/** Default crates.io version requirement for the shell crate (D7.b: the flip
|
|
31
|
+
* to crates.io default once published — the crate is live). */
|
|
32
|
+
export declare const DEFAULT_SHELL_CRATE_VERSION = "0.1";
|
|
33
|
+
export declare const APP_JSON_FILE = "app.json";
|
|
34
|
+
/** Read + validate hosts/<host>/app.json. Throws with the field named on a
|
|
35
|
+
* bad value, and a clear message when the file is absent. */
|
|
36
|
+
export declare function loadAppJson(hostDir: string): AppJson;
|
|
37
|
+
/** A filesystem/crate-safe slug of the product name — the generated binary
|
|
38
|
+
* and Cargo package name. Falls back to the identifier's last segment. */
|
|
39
|
+
export declare function appSlug(app: AppJson): string;
|
|
40
|
+
//#endregion
|
|
2
41
|
//#region src/bundle-stack.d.ts
|
|
3
42
|
/**
|
|
4
43
|
* P6.3 — stage the shippable STACK into the shell project: everything the
|
|
@@ -34,6 +73,9 @@ interface BundleStackOptions {
|
|
|
34
73
|
/** The connect member's port — written into the stack's shell.json so the
|
|
35
74
|
* shell knows where to probe/navigate with no environment at all. */
|
|
36
75
|
connectPort?: number;
|
|
76
|
+
/** Absolute paths to skip when staging `hosts/` — in mode 1 the generated
|
|
77
|
+
* shell dir sits under `hosts/` and must not be copied into itself. */
|
|
78
|
+
excludeDirs?: string[];
|
|
37
79
|
logger?: (message: string) => void;
|
|
38
80
|
}
|
|
39
81
|
interface BundleStackResult {
|
|
@@ -42,6 +84,129 @@ interface BundleStackResult {
|
|
|
42
84
|
}
|
|
43
85
|
export declare function bundleStack(options: BundleStackOptions): BundleStackResult;
|
|
44
86
|
//#endregion
|
|
87
|
+
//#region src/shell-project.d.ts
|
|
88
|
+
/**
|
|
89
|
+
* P7.3 — project `hosts/desktop/app.json` into a generated `tauri-shell/`:
|
|
90
|
+
* a STANDALONE tauri crate that depends on the published `ph-desktop-shell`
|
|
91
|
+
* library, carries the builder's identity, and is built/run by the desktop
|
|
92
|
+
* runner's dev/build verbs. The builder never writes Rust.
|
|
93
|
+
*
|
|
94
|
+
* Everything here mirrors the known-good reference app
|
|
95
|
+
* (ph-desktop-shell/apps/powerhouse-desktop): the tauri plumbing (main.rs,
|
|
96
|
+
* build.rs, capabilities, the loading page, externalBin + icon mechanics) is
|
|
97
|
+
* copied verbatim; only identity/port fields are projected from app.json. The
|
|
98
|
+
* projection is idempotent and stale-detected — a file is rewritten only when
|
|
99
|
+
* its content changes, so Cargo.lock, the generated icon set, and tauri-build
|
|
100
|
+
* output are never disturbed by a regen with an unchanged app.json.
|
|
101
|
+
*/
|
|
102
|
+
export declare const SHELL_DIR = "tauri-shell";
|
|
103
|
+
/** The icon source the runner feeds to `tauri icon` (copied from app.icon). */
|
|
104
|
+
export declare const ICON_SOURCE = "app-icon.png";
|
|
105
|
+
interface ProjectShellInput {
|
|
106
|
+
/** hosts/<host>/ — where app.json lives and tauri-shell/ is written. */
|
|
107
|
+
hostDir: string;
|
|
108
|
+
app: AppJson;
|
|
109
|
+
/** The connect member's port — baked into the remote capability so the
|
|
110
|
+
* served Connect origin can reach the shell's launch-queue commands. */
|
|
111
|
+
connectPort: number;
|
|
112
|
+
}
|
|
113
|
+
interface ProjectShellResult {
|
|
114
|
+
shellDir: string;
|
|
115
|
+
/** The crate/bin name (and the built exe stem the runner looks for). */
|
|
116
|
+
binName: string;
|
|
117
|
+
/** True when any projected file was created or changed this call. */
|
|
118
|
+
changed: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Materialize/refresh `<hostDir>/tauri-shell/` from app.json. Idempotent:
|
|
122
|
+
* unchanged app.json rewrites nothing. Does NOT run `tauri icon` or fetch the
|
|
123
|
+
* node binary — those are toolchain steps the runner performs at dev/build.
|
|
124
|
+
*/
|
|
125
|
+
export declare function projectShell(input: ProjectShellInput): ProjectShellResult;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/scaffold.d.ts
|
|
128
|
+
/**
|
|
129
|
+
* P7.5 — scaffold a builder-owned desktop identity: `hosts/desktop/app.json`
|
|
130
|
+
* (the ONE file a builder edits), a placeholder square icon source, and a
|
|
131
|
+
* `.gitignore` for the generated shell. `ph generate desktop-shell` calls
|
|
132
|
+
* this; the runner's dev/build then project app.json into `tauri-shell/`.
|
|
133
|
+
*/
|
|
134
|
+
interface ScaffoldDesktopShellOptions {
|
|
135
|
+
/** Reverse-DNS app identifier (e.g. com.acme.app). */
|
|
136
|
+
identifier: string;
|
|
137
|
+
/** Human product name (the window title + macOS app name). */
|
|
138
|
+
productName: string;
|
|
139
|
+
/** Overwrite an existing app.json (default: refuse, to protect edits). */
|
|
140
|
+
force?: boolean;
|
|
141
|
+
}
|
|
142
|
+
interface ScaffoldResult {
|
|
143
|
+
hostDir: string;
|
|
144
|
+
/** Files created this call (absolute paths). */
|
|
145
|
+
created: string[];
|
|
146
|
+
/** Files already present and left untouched. */
|
|
147
|
+
skipped: string[];
|
|
148
|
+
}
|
|
149
|
+
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
150
|
+
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
151
|
+
* replaces it with their real 1024×1024 artwork. */
|
|
152
|
+
export declare function solidPng(size: number, rgba: [number, number, number, number]): Buffer;
|
|
153
|
+
export declare function scaffoldDesktopShell(hostDir: string, options: ScaffoldDesktopShellOptions): ScaffoldResult;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/shell-toolchain.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* The native toolchain the generated shell (mode 1) needs to build/run, and
|
|
158
|
+
* the provisioning steps around it. `cargo tauri dev|build` compiles the
|
|
159
|
+
* generated crate — but tauri-build validates two things AT COMPILE TIME that
|
|
160
|
+
* must exist first (both confirmed against a live `cargo check`):
|
|
161
|
+
* - the node sidecar `binaries/node-<triple>` (externalBin), and
|
|
162
|
+
* - `icons/icon.ico` on Windows (the app's Win32 resource).
|
|
163
|
+
* So dev/build provision the sidecar + icon set before invoking tauri, and
|
|
164
|
+
* fail with install guidance when cargo or the Tauri CLI is absent — a
|
|
165
|
+
* missing executable must read as a clear instruction, never a deep cargo
|
|
166
|
+
* stack trace.
|
|
167
|
+
*/
|
|
168
|
+
interface NodeTarget {
|
|
169
|
+
triple: string;
|
|
170
|
+
dist: string;
|
|
171
|
+
/** Path within the extracted archive (POSIX) / "node.exe" on Windows. */
|
|
172
|
+
bin: string;
|
|
173
|
+
ext: string;
|
|
174
|
+
}
|
|
175
|
+
/** The Node release triple for a build host — the sidecar filename tauri
|
|
176
|
+
* resolves (`node-<triple>`). Pure, so the mapping is unit-tested. */
|
|
177
|
+
export declare function nodeSidecarTarget(platform: NodeJS.Platform, arch: string): NodeTarget;
|
|
178
|
+
/** Fetch the stock Node the shell ships as its sidecar into `<shellDir>/
|
|
179
|
+
* binaries`, named per target triple. No-op when already present. Ported from
|
|
180
|
+
* the reference repo's fetch-node.mjs (the builder has no such script). */
|
|
181
|
+
export declare function fetchNodeSidecar(shellDir: string, version?: string, platform?: NodeJS.Platform, arch?: string): string;
|
|
182
|
+
/** Default bundle targets for the build host (`cargo tauri build --bundles`).
|
|
183
|
+
* macOS gets app+dmg, Windows nsis, Linux deb+appimage — a host only builds
|
|
184
|
+
* installers it can produce. */
|
|
185
|
+
export declare function tauriBundlesForHost(platform?: NodeJS.Platform): string[];
|
|
186
|
+
interface TauriCommand {
|
|
187
|
+
/** The executable to spawn (e.g. "cargo" or a node path). */
|
|
188
|
+
cmd: string;
|
|
189
|
+
/** Args that precede the tauri subcommand (e.g. ["tauri"] for cargo). */
|
|
190
|
+
prefix: string[];
|
|
191
|
+
/** How the CLI was found — for logging + the preflight message. */
|
|
192
|
+
via: "cargo-tauri" | "node-cli";
|
|
193
|
+
}
|
|
194
|
+
/** Resolve a Tauri CLI: a global `cargo tauri`, else a `@tauri-apps/cli`
|
|
195
|
+
* resolvable from the project. Returns null when neither is available. */
|
|
196
|
+
export declare function resolveTauriCommand(projectRoot: string): TauriCommand | null;
|
|
197
|
+
interface Toolchain {
|
|
198
|
+
cargo: boolean;
|
|
199
|
+
tauri: TauriCommand | null;
|
|
200
|
+
}
|
|
201
|
+
export declare function detectToolchain(projectRoot: string): Toolchain;
|
|
202
|
+
/** Throw a clear, actionable error when the native toolchain is incomplete —
|
|
203
|
+
* the desktop verbs call this before any cargo work so a missing executable
|
|
204
|
+
* is an instruction, not a stack trace. */
|
|
205
|
+
export declare function preflightOrThrow(tc: Toolchain, hostName: string): TauriCommand;
|
|
206
|
+
/** `<tauri> icon <source>` — generates the per-platform icon set (icon.ico +
|
|
207
|
+
* icon.icns + pngs) the bundle references and tauri-build requires. */
|
|
208
|
+
export declare function runTauriIcon(tauri: TauriCommand, shellDir: string, iconSource: string): void;
|
|
209
|
+
//#endregion
|
|
45
210
|
//#region src/shell.d.ts
|
|
46
211
|
/**
|
|
47
212
|
* Shell discovery and launch. The Rust/Tauri shell lives in the
|
|
@@ -80,6 +245,6 @@ export declare function shellEnv(projectRoot: string, connectPort: number, env:
|
|
|
80
245
|
export declare function tauriConfigPatch(options: ShellOptions | undefined): Record<string, unknown> | undefined;
|
|
81
246
|
export declare function launchShell(shell: ResolvedShell, envVars: Record<string, string>, options: ShellOptions | undefined): ChildProcess;
|
|
82
247
|
//#endregion
|
|
83
|
-
export type { BundleStackOptions, BundleStackResult, ResolvedShell, ShellOptions };
|
|
248
|
+
export type { AppJson, AppJsonShellSource, BundleStackOptions, BundleStackResult, NodeTarget, ProjectShellInput, ProjectShellResult, ResolvedShell, ScaffoldDesktopShellOptions, ScaffoldResult, ShellOptions, TauriCommand, Toolchain };
|
|
84
249
|
export {};
|
|
85
250
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/bundle-stack.ts","../src/shell.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/app-json.ts","../src/bundle-stack.ts","../src/shell-project.ts","../src/scaffold.ts","../src/shell-toolchain.ts","../src/shell.ts"],"mappings":";;;qBAuDa,eAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;GASxB,EAAA,KAAA;KAEU,UAAU,EAAE,aAAa;KACzB,qBAAqB,YAAY;;;qBAIhC;qBAEA;;;wBAIG,YAAY,kBAAkB;;;wBA2B9B,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;UCnFZ;EACf;EACA;;;EAGA;;;;;EAKA;;;EAGA;;;EAGA;;;EAGA;EACA,UAAU;;UAGK;EACf;EACA;;wBAwCc,YAAY,SAAS,qBAAqB;;;;;;;;;;;;;;;;;qBC9D7C;;qBAEA;UAEI;;EAEf;EACA,KAAK;;;EAGL;;UAGe;EACf;;EAEA;;EAEA;;;;;;;wBAqPc,aAAa,OAAO,oBAAoB;;;;;;;;;UCnRvC;;EAEf;;EAEA;;EAEA;;UAGe;EACf;;EAEA;;EAEA;;;;;wBAMc,SACd,cACA,yCACC;wBAoEa,qBACd,iBACA,SAAS,8BACR;;;;;;;;;;;;;;;UCvFc;EACf;EACA;;EAEA;EACA;;;;wBAKc,kBACd,UAAU,OAAO,UACjB,eACC;;;;wBAwCa,iBACd,kBACA,kBACA,WAAU,OAAO,UACjB;;;;wBA2Bc,oBACd,WAAU,OAAO;UAYF;;EAEf;;EAEA;;EAEA;;;;wBAuCc,oBAAoB,sBAAsB;UA6BzC;EACf;EACA,OAAO;;wBAGO,gBAAgB,sBAAsB;;;;wBAOtC,iBACd,IAAI,WACJ,mBACC;;;wBA2Ba,aACd,OAAO,cACP,kBACA;;;;;;;;;;UC7Ne;;EAEf;EACA;IAAW;IAAgB;IAAgB;;EAC3C;EACA;;UAGe;EACf;;;EAGA;;wBAGc,aACd,qBACA,SAAS,0BACT,KAAK,qCACJ;;;wBA4Ba,kBAAkB;;;wBAUlB,SACd,qBACA,qBACA,KAAK,qCACJ;;;;wBAaa,iBACd,SAAS,2BACR;wBA2Ba,YACd,OAAO,eACP,SAAS,wBACT,SAAS,2BACR"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,132 @@
|
|
|
1
|
-
import { a as tauriConfigPatch, i as shellEnv, n as resolvePhCliEntry, o as
|
|
2
|
-
|
|
1
|
+
import { S as loadAppJson, _ as bundleStack, a as tauriConfigPatch, b as appJsonSchema, c as nodeSidecarTarget, d as runTauriIcon, f as tauriBundlesForHost, g as projectShell, h as SHELL_DIR, i as shellEnv, l as preflightOrThrow, m as ICON_SOURCE, n as resolvePhCliEntry, o as detectToolchain, r as resolveShell, s as fetchNodeSidecar, t as launchShell, u as resolveTauriCommand, v as APP_JSON_FILE, x as appSlug, y as DEFAULT_SHELL_CRATE_VERSION } from "./shell-BL61-fyi.mjs";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { deflateSync } from "node:zlib";
|
|
5
|
+
//#region src/scaffold.ts
|
|
6
|
+
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
7
|
+
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
8
|
+
* replaces it with their real 1024×1024 artwork. */
|
|
9
|
+
function solidPng(size, rgba) {
|
|
10
|
+
const [r, g, b, a] = rgba;
|
|
11
|
+
const row = Buffer.alloc(1 + size * 4);
|
|
12
|
+
for (let x = 0; x < size; x++) {
|
|
13
|
+
const o = 1 + x * 4;
|
|
14
|
+
row[o] = r;
|
|
15
|
+
row[o + 1] = g;
|
|
16
|
+
row[o + 2] = b;
|
|
17
|
+
row[o + 3] = a;
|
|
18
|
+
}
|
|
19
|
+
const raw = Buffer.concat(Array.from({ length: size }, () => row));
|
|
20
|
+
const idat = deflateSync(raw);
|
|
21
|
+
const chunk = (type, data) => {
|
|
22
|
+
const len = Buffer.alloc(4);
|
|
23
|
+
len.writeUInt32BE(data.length, 0);
|
|
24
|
+
const typeBuf = Buffer.from(type, "ascii");
|
|
25
|
+
const body = Buffer.concat([typeBuf, data]);
|
|
26
|
+
const crc = Buffer.alloc(4);
|
|
27
|
+
crc.writeUInt32BE(crc32(body) >>> 0, 0);
|
|
28
|
+
return Buffer.concat([
|
|
29
|
+
len,
|
|
30
|
+
body,
|
|
31
|
+
crc
|
|
32
|
+
]);
|
|
33
|
+
};
|
|
34
|
+
const ihdr = Buffer.alloc(13);
|
|
35
|
+
ihdr.writeUInt32BE(size, 0);
|
|
36
|
+
ihdr.writeUInt32BE(size, 4);
|
|
37
|
+
ihdr[8] = 8;
|
|
38
|
+
ihdr[9] = 6;
|
|
39
|
+
ihdr[10] = 0;
|
|
40
|
+
ihdr[11] = 0;
|
|
41
|
+
ihdr[12] = 0;
|
|
42
|
+
return Buffer.concat([
|
|
43
|
+
Buffer.from([
|
|
44
|
+
137,
|
|
45
|
+
80,
|
|
46
|
+
78,
|
|
47
|
+
71,
|
|
48
|
+
13,
|
|
49
|
+
10,
|
|
50
|
+
26,
|
|
51
|
+
10
|
|
52
|
+
]),
|
|
53
|
+
chunk("IHDR", ihdr),
|
|
54
|
+
chunk("IDAT", idat),
|
|
55
|
+
chunk("IEND", Buffer.alloc(0))
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
let crcTable;
|
|
59
|
+
function crc32(buf) {
|
|
60
|
+
if (!crcTable) {
|
|
61
|
+
crcTable = [];
|
|
62
|
+
for (let n = 0; n < 256; n++) {
|
|
63
|
+
let c = n;
|
|
64
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
65
|
+
crcTable[n] = c;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let crc = 4294967295;
|
|
69
|
+
for (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;
|
|
70
|
+
return crc ^ 4294967295;
|
|
71
|
+
}
|
|
72
|
+
const GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.
|
|
73
|
+
/tauri-shell/target
|
|
74
|
+
/tauri-shell/gen
|
|
75
|
+
/tauri-shell/icons
|
|
76
|
+
/tauri-shell/dist-stack
|
|
77
|
+
/tauri-shell/binaries
|
|
78
|
+
`;
|
|
79
|
+
function scaffoldDesktopShell(hostDir, options) {
|
|
80
|
+
const created = [];
|
|
81
|
+
const skipped = [];
|
|
82
|
+
fs.mkdirSync(hostDir, { recursive: true });
|
|
83
|
+
const iconFile = "icon.png";
|
|
84
|
+
const app = {
|
|
85
|
+
identifier: options.identifier,
|
|
86
|
+
productName: options.productName,
|
|
87
|
+
icon: `./${iconFile}`,
|
|
88
|
+
window: {
|
|
89
|
+
title: options.productName,
|
|
90
|
+
width: 1440,
|
|
91
|
+
height: 900
|
|
92
|
+
},
|
|
93
|
+
fileAssociations: [{
|
|
94
|
+
ext: ["phd"],
|
|
95
|
+
name: "Powerhouse Document",
|
|
96
|
+
mimeType: "application/vnd.powerhouse.document+zip"
|
|
97
|
+
}]
|
|
98
|
+
};
|
|
99
|
+
appJsonSchema.parse(app);
|
|
100
|
+
const appJsonPath = path.join(hostDir, APP_JSON_FILE);
|
|
101
|
+
if (fs.existsSync(appJsonPath) && !options.force) skipped.push(appJsonPath);
|
|
102
|
+
else {
|
|
103
|
+
fs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\n`);
|
|
104
|
+
created.push(appJsonPath);
|
|
105
|
+
}
|
|
106
|
+
const iconPath = path.join(hostDir, iconFile);
|
|
107
|
+
if (fs.existsSync(iconPath)) skipped.push(iconPath);
|
|
108
|
+
else {
|
|
109
|
+
fs.writeFileSync(iconPath, solidPng(1024, [
|
|
110
|
+
79,
|
|
111
|
+
70,
|
|
112
|
+
229,
|
|
113
|
+
255
|
|
114
|
+
]));
|
|
115
|
+
created.push(iconPath);
|
|
116
|
+
}
|
|
117
|
+
const gitignorePath = path.join(hostDir, ".gitignore");
|
|
118
|
+
if (fs.existsSync(gitignorePath)) skipped.push(gitignorePath);
|
|
119
|
+
else {
|
|
120
|
+
fs.writeFileSync(gitignorePath, GITIGNORE);
|
|
121
|
+
created.push(gitignorePath);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
hostDir,
|
|
125
|
+
created,
|
|
126
|
+
skipped
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { APP_JSON_FILE, DEFAULT_SHELL_CRATE_VERSION, ICON_SOURCE, SHELL_DIR, appJsonSchema, appSlug, bundleStack, detectToolchain, fetchNodeSidecar, launchShell, loadAppJson, nodeSidecarTarget, preflightOrThrow, projectShell, resolvePhCliEntry, resolveShell, resolveTauriCommand, runTauriIcon, scaffoldDesktopShell, shellEnv, solidPng, tauriBundlesForHost, tauriConfigPatch };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/scaffold.ts"],"sourcesContent":["import { deflateSync } from \"node:zlib\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { appJsonSchema, APP_JSON_FILE, type AppJson } from \"./app-json.js\";\n\n/**\n * P7.5 — scaffold a builder-owned desktop identity: `hosts/desktop/app.json`\n * (the ONE file a builder edits), a placeholder square icon source, and a\n * `.gitignore` for the generated shell. `ph generate desktop-shell` calls\n * this; the runner's dev/build then project app.json into `tauri-shell/`.\n */\n\nexport interface ScaffoldDesktopShellOptions {\n /** Reverse-DNS app identifier (e.g. com.acme.app). */\n identifier: string;\n /** Human product name (the window title + macOS app name). */\n productName: string;\n /** Overwrite an existing app.json (default: refuse, to protect edits). */\n force?: boolean;\n}\n\nexport interface ScaffoldResult {\n hostDir: string;\n /** Files created this call (absolute paths). */\n created: string[];\n /** Files already present and left untouched. */\n skipped: string[];\n}\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. */\nexport function solidPng(\n size: number,\n rgba: [number, number, number, number],\n): Buffer {\n const [r, g, b, a] = rgba;\n // raw image: each row is a filter byte (0) + size*4 RGBA bytes\n const row = Buffer.alloc(1 + size * 4);\n for (let x = 0; x < size; x++) {\n const o = 1 + x * 4;\n row[o] = r;\n row[o + 1] = g;\n row[o + 2] = b;\n row[o + 3] = a;\n }\n const raw = Buffer.concat(Array.from({ length: size }, () => row));\n const idat = deflateSync(raw);\n\n const chunk = (type: string, data: Buffer): Buffer => {\n const len = Buffer.alloc(4);\n len.writeUInt32BE(data.length, 0);\n const typeBuf = Buffer.from(type, \"ascii\");\n const body = Buffer.concat([typeBuf, data]);\n const crc = Buffer.alloc(4);\n crc.writeUInt32BE(crc32(body) >>> 0, 0);\n return Buffer.concat([len, body, crc]);\n };\n\n const ihdr = Buffer.alloc(13);\n ihdr.writeUInt32BE(size, 0);\n ihdr.writeUInt32BE(size, 4);\n ihdr[8] = 8; // bit depth\n ihdr[9] = 6; // color type RGBA\n ihdr[10] = 0; // compression\n ihdr[11] = 0; // filter\n ihdr[12] = 0; // interlace\n\n return Buffer.concat([\n Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),\n chunk(\"IHDR\", ihdr),\n chunk(\"IDAT\", idat),\n chunk(\"IEND\", Buffer.alloc(0)),\n ]);\n}\n\nlet crcTable: number[] | undefined;\nfunction crc32(buf: Buffer): number {\n if (!crcTable) {\n crcTable = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n }\n crcTable[n] = c;\n }\n }\n let crc = 0xffffffff;\n for (let i = 0; i < buf.length; i++) {\n crc = crcTable[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8);\n }\n return crc ^ 0xffffffff;\n}\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`;\n\nexport function scaffoldDesktopShell(\n hostDir: string,\n options: ScaffoldDesktopShellOptions,\n): ScaffoldResult {\n const created: string[] = [];\n const skipped: string[] = [];\n fs.mkdirSync(hostDir, { recursive: true });\n\n const iconFile = \"icon.png\";\n const app: AppJson = {\n identifier: options.identifier,\n productName: options.productName,\n icon: `./${iconFile}`,\n window: { title: options.productName, width: 1440, height: 900 },\n fileAssociations: [\n {\n ext: [\"phd\"],\n name: \"Powerhouse Document\",\n mimeType: \"application/vnd.powerhouse.document+zip\",\n },\n ],\n };\n // Fail fast if we ever emit something the loader would reject.\n appJsonSchema.parse(app);\n\n const appJsonPath = path.join(hostDir, APP_JSON_FILE);\n if (fs.existsSync(appJsonPath) && !options.force) {\n skipped.push(appJsonPath);\n } else {\n fs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\\n`);\n created.push(appJsonPath);\n }\n\n const iconPath = path.join(hostDir, iconFile);\n if (fs.existsSync(iconPath)) {\n skipped.push(iconPath);\n } else {\n // 1024² indigo placeholder — a real, square, replaceable source icon.\n fs.writeFileSync(iconPath, solidPng(1024, [79, 70, 229, 255]));\n created.push(iconPath);\n }\n\n const gitignorePath = path.join(hostDir, \".gitignore\");\n if (fs.existsSync(gitignorePath)) {\n skipped.push(gitignorePath);\n } else {\n fs.writeFileSync(gitignorePath, GITIGNORE);\n created.push(gitignorePath);\n }\n\n return { hostDir, created, skipped };\n}\n"],"mappings":"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"}
|
package/dist/runner.d.mts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { HostDefinition, RunnerContext } from "@powerhousedao/host-core";
|
|
2
2
|
//#region src/runner.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* @powerhousedao/desktop/runner
|
|
4
|
+
* @powerhousedao/desktop/runner.
|
|
5
5
|
*
|
|
6
6
|
* - `run`/`serve`: the headless stack — byte-identical delegation to
|
|
7
7
|
* host-core's generic compound (phase-3 semantics unchanged).
|
|
8
|
-
* - `dev`: the NATIVE window
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
8
|
+
* - `dev`: the NATIVE window. Mode 1 (phase 7) is the default — a builder
|
|
9
|
+
* ships under THEIR identity by editing `hosts/<host>/app.json` and never
|
|
10
|
+
* writing Rust: the runner projects app.json into a generated `tauri-shell/`
|
|
11
|
+
* that depends on the published `ph-desktop-shell` crate, provisions the
|
|
12
|
+
* native toolchain's compile-time inputs (node sidecar + icon set), and runs
|
|
13
|
+
* `cargo tauri dev`. An explicit `runner.shell.project` (or PH_DESKTOP_SHELL)
|
|
14
|
+
* still selects a prebuilt/hand-maintained shell instead.
|
|
15
|
+
* - `build`: the PACKAGING verb — members' builds (where exported), then the
|
|
16
|
+
* shippable stack staged into the shell + `cargo tauri build` with
|
|
17
|
+
* host-appropriate installer targets (nsis / app+dmg / deb+appimage).
|
|
18
|
+
*
|
|
19
|
+
* The native toolchain is required ONLY for dev/build; a missing cargo or
|
|
20
|
+
* Tauri CLI fails with install guidance (see shell-toolchain). `ph run <host>`
|
|
21
|
+
* (headless) needs none of it.
|
|
18
22
|
*/
|
|
19
23
|
export declare const kind = "compound";
|
|
20
24
|
export declare const hostSchema: import("zod").ZodObject<{
|
|
@@ -136,14 +140,17 @@ export declare const hostSchema: import("zod").ZodObject<{
|
|
|
136
140
|
}, import("zod/v4/core").$loose>;
|
|
137
141
|
export declare function run(host: HostDefinition, ctx: RunnerContext): Promise<import("@powerhousedao/host-core").RunCompoundResult>;
|
|
138
142
|
export declare const serve: typeof run;
|
|
139
|
-
/** dev = the native window around the live stack, zero manual env. */
|
|
140
143
|
export interface ShellHandle {
|
|
141
144
|
/** Resolves when the shell window exits — the runner's keep-alive. */
|
|
142
145
|
ready: Promise<void>;
|
|
143
146
|
shutdown: () => void;
|
|
144
147
|
}
|
|
148
|
+
/** Which shell backs this host's native window (D7.d source order):
|
|
149
|
+
* an explicit `runner.shell.project`, else the app.json-generated shell,
|
|
150
|
+
* else the PH_DESKTOP_SHELL escape hatch. */
|
|
151
|
+
export declare function shellMode(host: HostDefinition, ctx: RunnerContext): "external-project" | "generated" | "external-env" | "none";
|
|
145
152
|
export declare function dev(host: HostDefinition, ctx: RunnerContext): Promise<ShellHandle>;
|
|
146
|
-
/** build = members' builds
|
|
153
|
+
/** build = members' builds + the shippable stack + the native installer. */
|
|
147
154
|
export declare function build(host: HostDefinition, ctx: RunnerContext): Promise<void>;
|
|
148
155
|
//#endregion
|
|
149
156
|
export {};
|
package/dist/runner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.mts","names":[],"sources":["../src/runner.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.mts","names":[],"sources":["../src/runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;qBAoDa;qBAEA,0BAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAAqB;wBA+CtB,IAAI,MAAM,gBAAgB,KAAK,gBAAa,2CAAA;qBAKrD,cAAK;iBAED;;EAEf,OAAO;EACP;;;;;wBAMc,UACd,MAAM,gBACN,KAAK;wBA6Ce,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;;wBAkGW,MACpB,MAAM,gBACN,KAAK,gBACJ"}
|
package/dist/runner.mjs
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import { i as shellEnv, o as
|
|
1
|
+
import { S as loadAppJson, _ as bundleStack, d as runTauriIcon, f as tauriBundlesForHost, g as projectShell, i as shellEnv, l as preflightOrThrow, m as ICON_SOURCE, o as detectToolchain, p as tauriSpawn, r as resolveShell, s as fetchNodeSidecar, t as launchShell, v as APP_JSON_FILE } from "./shell-BL61-fyi.mjs";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
5
|
import { compoundHostSchema, getVerb, loadHost, resolveRunnerModule, validateHost } from "@powerhousedao/host-core";
|
|
3
6
|
//#region src/runner.ts
|
|
4
7
|
/**
|
|
5
|
-
* @powerhousedao/desktop/runner
|
|
8
|
+
* @powerhousedao/desktop/runner.
|
|
6
9
|
*
|
|
7
10
|
* - `run`/`serve`: the headless stack — byte-identical delegation to
|
|
8
11
|
* host-core's generic compound (phase-3 semantics unchanged).
|
|
9
|
-
* - `dev`: the NATIVE window
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
12
|
+
* - `dev`: the NATIVE window. Mode 1 (phase 7) is the default — a builder
|
|
13
|
+
* ships under THEIR identity by editing `hosts/<host>/app.json` and never
|
|
14
|
+
* writing Rust: the runner projects app.json into a generated `tauri-shell/`
|
|
15
|
+
* that depends on the published `ph-desktop-shell` crate, provisions the
|
|
16
|
+
* native toolchain's compile-time inputs (node sidecar + icon set), and runs
|
|
17
|
+
* `cargo tauri dev`. An explicit `runner.shell.project` (or PH_DESKTOP_SHELL)
|
|
18
|
+
* still selects a prebuilt/hand-maintained shell instead.
|
|
19
|
+
* - `build`: the PACKAGING verb — members' builds (where exported), then the
|
|
20
|
+
* shippable stack staged into the shell + `cargo tauri build` with
|
|
21
|
+
* host-appropriate installer targets (nsis / app+dmg / deb+appimage).
|
|
22
|
+
*
|
|
23
|
+
* The native toolchain is required ONLY for dev/build; a missing cargo or
|
|
24
|
+
* Tauri CLI fails with install guidance (see shell-toolchain). `ph run <host>`
|
|
25
|
+
* (headless) needs none of it.
|
|
19
26
|
*/
|
|
20
27
|
const kind = "compound";
|
|
21
28
|
const hostSchema = compoundHostSchema;
|
|
22
29
|
async function compoundModule() {
|
|
23
30
|
return import("@powerhousedao/host-core/runners/compound");
|
|
24
31
|
}
|
|
32
|
+
/** hosts/<host>/ — where app.json lives and the generated shell is written. */
|
|
33
|
+
function hostDirOf(host, ctx) {
|
|
34
|
+
return path.join(ctx.projectRoot, "hosts", host.name);
|
|
35
|
+
}
|
|
25
36
|
/** The connect member's port — the shell's readiness probe and window URL. */
|
|
26
37
|
async function connectPort(host, ctx) {
|
|
27
38
|
const children = host.children ?? {};
|
|
@@ -37,11 +48,67 @@ async function run(host, ctx) {
|
|
|
37
48
|
return (await compoundModule()).run(host, ctx);
|
|
38
49
|
}
|
|
39
50
|
const serve = run;
|
|
51
|
+
/** Which shell backs this host's native window (D7.d source order):
|
|
52
|
+
* an explicit `runner.shell.project`, else the app.json-generated shell,
|
|
53
|
+
* else the PH_DESKTOP_SHELL escape hatch. */
|
|
54
|
+
function shellMode(host, ctx) {
|
|
55
|
+
if (host.runner.shell?.project) return "external-project";
|
|
56
|
+
if (fs.existsSync(path.join(hostDirOf(host, ctx), "app.json"))) return "generated";
|
|
57
|
+
if (ctx.env.PH_DESKTOP_SHELL) return "external-env";
|
|
58
|
+
return "none";
|
|
59
|
+
}
|
|
60
|
+
/** Fetch the node sidecar + (re)generate the icon set — both are tauri-build
|
|
61
|
+
* COMPILE-TIME inputs (externalBin; icon.ico for the Windows resource),
|
|
62
|
+
* confirmed against a live cargo check. Icon regen only when app-icon.png
|
|
63
|
+
* changed or the set is absent. */
|
|
64
|
+
function provisionShell(shellDir, tauri, iconChanged) {
|
|
65
|
+
fetchNodeSidecar(shellDir);
|
|
66
|
+
const iconIco = path.join(shellDir, "icons", "icon.ico");
|
|
67
|
+
if (iconChanged || !fs.existsSync(iconIco)) runTauriIcon(tauri, shellDir, ICON_SOURCE);
|
|
68
|
+
}
|
|
69
|
+
/** Spawn a `<tauri> <subcommand>` in the generated shell with the uniform-
|
|
70
|
+
* runners env trio wired in. */
|
|
71
|
+
function spawnTauri(tauri, subcommand, shellDir, envVars) {
|
|
72
|
+
const { command, args, shell } = tauriSpawn(tauri, subcommand);
|
|
73
|
+
return spawn(command, args, {
|
|
74
|
+
cwd: shellDir,
|
|
75
|
+
env: {
|
|
76
|
+
...process.env,
|
|
77
|
+
...envVars
|
|
78
|
+
},
|
|
79
|
+
stdio: "inherit",
|
|
80
|
+
shell,
|
|
81
|
+
windowsHide: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
40
84
|
async function dev(host, ctx) {
|
|
41
|
-
const
|
|
42
|
-
|
|
85
|
+
const mode = shellMode(host, ctx);
|
|
86
|
+
if (mode === "none") throw new Error(`hosts/${host.name}: no desktop shell to run — add ${APP_JSON_FILE} (run \`ph generate desktop-shell\`) for a builder-owned identity, set runner.shell.project to a prebuilt shell, or export PH_DESKTOP_SHELL.`);
|
|
43
87
|
const port = await connectPort(host, ctx);
|
|
44
88
|
const envVars = shellEnv(ctx.projectRoot, port, ctx.env);
|
|
89
|
+
if (mode === "generated") {
|
|
90
|
+
const hostDir = hostDirOf(host, ctx);
|
|
91
|
+
const app = loadAppJson(hostDir);
|
|
92
|
+
const { shellDir, binName, changed } = projectShell({
|
|
93
|
+
hostDir,
|
|
94
|
+
app,
|
|
95
|
+
connectPort: port
|
|
96
|
+
});
|
|
97
|
+
const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);
|
|
98
|
+
provisionShell(shellDir, tauri, changed);
|
|
99
|
+
console.log(`[${host.name}] launching the generated desktop shell '${binName}' (${tauri.via}: cargo tauri dev) — stack via ph run ${host.name}, window at http://127.0.0.1:${port}/`);
|
|
100
|
+
const child = spawnTauri(tauri, ["dev"], shellDir, envVars);
|
|
101
|
+
return {
|
|
102
|
+
ready: new Promise((resolve) => child.once("exit", () => resolve())),
|
|
103
|
+
shutdown: () => {
|
|
104
|
+
try {
|
|
105
|
+
child.kill();
|
|
106
|
+
} catch {}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const options = host.runner;
|
|
111
|
+
const shell = resolveShell(ctx.projectRoot, options.shell, ctx.env);
|
|
45
112
|
console.log(`[${host.name}] launching the desktop shell (${shell.exe ? shell.exe : "pnpm tauri dev"}) — stack via ph run ${host.name}, window at http://127.0.0.1:${port}/`);
|
|
46
113
|
const child = launchShell(shell, envVars, options.shell);
|
|
47
114
|
return {
|
|
@@ -53,8 +120,9 @@ async function dev(host, ctx) {
|
|
|
53
120
|
}
|
|
54
121
|
};
|
|
55
122
|
}
|
|
56
|
-
/** build
|
|
57
|
-
|
|
123
|
+
/** Forward `build` to members that export it (packaging builds what is
|
|
124
|
+
* buildable — unlike the generic compound's uniform fail-loud forwarding). */
|
|
125
|
+
async function buildMembers(host, ctx) {
|
|
58
126
|
const children = host.children ?? {};
|
|
59
127
|
for (const [name, wrapper] of Object.entries(children)) {
|
|
60
128
|
const member = await loadHost(ctx.projectRoot, wrapper.host);
|
|
@@ -72,9 +140,47 @@ async function build(host, ctx) {
|
|
|
72
140
|
verb: "build"
|
|
73
141
|
});
|
|
74
142
|
}
|
|
143
|
+
}
|
|
144
|
+
/** build = members' builds + the shippable stack + the native installer. */
|
|
145
|
+
async function build(host, ctx) {
|
|
146
|
+
await buildMembers(host, ctx);
|
|
75
147
|
const runnerOptions = host.runner;
|
|
76
|
-
|
|
77
|
-
|
|
148
|
+
const mode = shellMode(host, ctx);
|
|
149
|
+
const port = await connectPort(host, ctx);
|
|
150
|
+
if (mode === "generated") {
|
|
151
|
+
const hostDir = hostDirOf(host, ctx);
|
|
152
|
+
const app = loadAppJson(hostDir);
|
|
153
|
+
const { shellDir, binName, changed } = projectShell({
|
|
154
|
+
hostDir,
|
|
155
|
+
app,
|
|
156
|
+
connectPort: port
|
|
157
|
+
});
|
|
158
|
+
const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);
|
|
159
|
+
provisionShell(shellDir, tauri, changed);
|
|
160
|
+
console.log(`[${host.name}] staging the stack into ${shellDir}…`);
|
|
161
|
+
const staged = bundleStack({
|
|
162
|
+
projectRoot: ctx.projectRoot,
|
|
163
|
+
shellProjectDir: shellDir,
|
|
164
|
+
vendor: runnerOptions.vendorStack,
|
|
165
|
+
phCliVersion: runnerOptions.phCliVersion,
|
|
166
|
+
phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,
|
|
167
|
+
connectPort: port,
|
|
168
|
+
excludeDirs: [shellDir]
|
|
169
|
+
});
|
|
170
|
+
console.log(`[${host.name}] stack staged at ${staged.stackDir}${staged.vendored ? " (ph-cli vendored)" : ""}.`);
|
|
171
|
+
const bundles = tauriBundlesForHost();
|
|
172
|
+
console.log(`[${host.name}] building '${binName}' (${tauri.via}: cargo tauri build --bundles ${bundles.join(",")})…`);
|
|
173
|
+
const result = spawnSyncTauri(tauri, [
|
|
174
|
+
"build",
|
|
175
|
+
"--bundles",
|
|
176
|
+
bundles.join(",")
|
|
177
|
+
], shellDir);
|
|
178
|
+
if (result !== 0) throw new Error(`hosts/${host.name}: \`cargo tauri build\` failed (exit ${result}).`);
|
|
179
|
+
console.log(`[${host.name}] desktop app built — installers under ${path.join(shellDir, "target", "release", "bundle")}.`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (mode === "none") {
|
|
183
|
+
console.log(`[${host.name}] build: no shell configured — members built; shell packaging skipped (add ${APP_JSON_FILE} or set runner.shell.project).`);
|
|
78
184
|
return;
|
|
79
185
|
}
|
|
80
186
|
const shell = resolveShell(ctx.projectRoot, runnerOptions.shell, ctx.env);
|
|
@@ -85,11 +191,22 @@ async function build(host, ctx) {
|
|
|
85
191
|
vendor: runnerOptions.vendorStack,
|
|
86
192
|
phCliVersion: runnerOptions.phCliVersion,
|
|
87
193
|
phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,
|
|
88
|
-
connectPort:
|
|
194
|
+
connectPort: port
|
|
89
195
|
});
|
|
90
196
|
console.log(`[${host.name}] stack staged at ${result.stackDir}${result.vendored ? " (ph-cli vendored)" : ""} — the shell runs it with no environment (resources fallback).`);
|
|
91
197
|
}
|
|
198
|
+
/** Synchronous `<tauri> <subcommand>` — build blocks until the installer is
|
|
199
|
+
* produced. Returns the exit code. */
|
|
200
|
+
function spawnSyncTauri(tauri, subcommand, shellDir) {
|
|
201
|
+
const { command, args, shell } = tauriSpawn(tauri, subcommand);
|
|
202
|
+
return spawnSync(command, args, {
|
|
203
|
+
cwd: shellDir,
|
|
204
|
+
stdio: "inherit",
|
|
205
|
+
shell,
|
|
206
|
+
windowsHide: true
|
|
207
|
+
}).status ?? 1;
|
|
208
|
+
}
|
|
92
209
|
//#endregion
|
|
93
|
-
export { build, dev, hostSchema, kind, run, serve };
|
|
210
|
+
export { build, dev, hostSchema, kind, run, serve, shellMode };
|
|
94
211
|
|
|
95
212
|
//# sourceMappingURL=runner.mjs.map
|