@powerhousedao/desktop 6.2.3-dev.70 → 6.2.3-dev.71
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 +65 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +19 -2
- package/dist/index.mjs.map +1 -1
- package/dist/runner.d.mts +311 -106
- package/dist/runner.d.mts.map +1 -1
- package/dist/runner.mjs +100 -31
- package/dist/runner.mjs.map +1 -1
- package/dist/{shell-DbRGck6R.mjs → shell-CfgLhSXp.mjs} +284 -21
- package/dist/shell-CfgLhSXp.mjs.map +1 -0
- package/package.json +5 -3
- package/dist/shell-DbRGck6R.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,64 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ChildProcess } from "node:child_process";
|
|
3
|
+
import { PHBackground } from "@powerhousedao/shared/clis";
|
|
3
4
|
//#region src/app-json.d.ts
|
|
4
5
|
export declare const appJsonSchema: z.ZodObject<{
|
|
5
6
|
identifier: z.ZodString;
|
|
6
7
|
productName: z.ZodString;
|
|
7
8
|
icon: z.ZodString;
|
|
9
|
+
background: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
10
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
11
|
+
light: z.ZodString;
|
|
12
|
+
dark: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
}, z.core.$strict>]>>>;
|
|
14
|
+
layers: z.ZodArray<z.ZodObject<{
|
|
15
|
+
src: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
16
|
+
light: z.ZodString;
|
|
17
|
+
dark: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
}, z.core.$strict>]>;
|
|
19
|
+
position: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
20
|
+
top: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
21
|
+
right: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
22
|
+
bottom: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
23
|
+
left: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
24
|
+
}, z.core.$strict>>>;
|
|
25
|
+
width: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
26
|
+
height: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
27
|
+
minWidth: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
28
|
+
minHeight: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
29
|
+
maxWidth: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
30
|
+
maxHeight: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
31
|
+
opacity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
32
|
+
fade: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
33
|
+
top: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
34
|
+
right: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
35
|
+
bottom: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
36
|
+
left: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
37
|
+
}, z.core.$strict>>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
}, z.core.$strict>]>>>;
|
|
40
|
+
splash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
splashDark: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
loading: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
43
|
+
background: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
accent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
dark: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
48
|
+
background: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
accent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
}, z.core.$strict>>>;
|
|
52
|
+
art: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
artDark: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
}, z.core.$strict>>>;
|
|
8
55
|
window: z.ZodOptional<z.ZodObject<{
|
|
9
56
|
title: z.ZodOptional<z.ZodString>;
|
|
10
57
|
width: z.ZodOptional<z.ZodNumber>;
|
|
11
58
|
height: z.ZodOptional<z.ZodNumber>;
|
|
12
59
|
resizable: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
minWidth: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
minHeight: z.ZodOptional<z.ZodNumber>;
|
|
13
62
|
}, z.core.$strict>>;
|
|
14
63
|
fileAssociations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
64
|
ext: z.ZodArray<z.ZodString>;
|
|
@@ -70,6 +119,12 @@ interface BundleStackOptions {
|
|
|
70
119
|
/** Overrides the ph-cli install spec entirely (e.g. a `pnpm pack` tarball
|
|
71
120
|
* path for a not-yet-published build). */
|
|
72
121
|
phCliSpec?: string;
|
|
122
|
+
/** A directory of `pnpm pack` tarballs (env PH_DESKTOP_LOCAL_PACKAGES).
|
|
123
|
+
* Each replaces its package everywhere in the vendored tree: a packed
|
|
124
|
+
* ph-cli alone would still pull its dependencies, at the same version
|
|
125
|
+
* number, from the registry. `pnpm pack:desktop-stack` in the monorepo
|
|
126
|
+
* packs the set ph-cli and host-core need. */
|
|
127
|
+
localPackagesDir?: string;
|
|
73
128
|
/** The connect member's port — written into the stack's shell.json so the
|
|
74
129
|
* shell knows where to probe/navigate with no environment at all. */
|
|
75
130
|
connectPort?: number;
|
|
@@ -138,7 +193,17 @@ interface ScaffoldDesktopShellOptions {
|
|
|
138
193
|
productName: string;
|
|
139
194
|
/** Overwrite an existing app.json (default: refuse, to protect edits). */
|
|
140
195
|
force?: boolean;
|
|
196
|
+
/** The loading page's background, with its paths already relative to the
|
|
197
|
+
* host directory (see `rebaseBackground`); `ph generate desktop-shell`
|
|
198
|
+
* passes Connect's `connect.home.background`. Default: none. */
|
|
199
|
+
background?: PHBackground | null;
|
|
141
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* A background whose project-relative paths are rewritten to be relative to
|
|
203
|
+
* another directory (powerhouse.config.json's root -> hosts/desktop, where
|
|
204
|
+
* app.json resolves them from). URLs and data URIs are left as they are.
|
|
205
|
+
*/
|
|
206
|
+
export declare function rebaseBackground(background: PHBackground, fromDir: string, toDir: string): PHBackground;
|
|
142
207
|
interface ScaffoldResult {
|
|
143
208
|
hostDir: string;
|
|
144
209
|
/** Files created this call (absolute paths). */
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":";;;;qBA8Ja,eAAa,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqBxB,EAAA,KAAA;KAEU,UAAU,EAAE,aAAa;KACzB,qBAAqB,YAAY;;;qBAIhC;qBAEA;;;wBAIG,YAAY,kBAAkB;;;wBA2B9B,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;UCtMZ;EACf;EACA;;;EAGA;;;;;EAKA;;;EAGA;;;;;;EAMA;;;EAGA;;;EAGA;EACA,UAAU;;UAGK;EACf;EACA;;wBA0Hc,YAAY,SAAS,qBAAqB;;;;;;;;;;;;;;;;;qBC/I7C;;qBAEA;UAEI;;EAEf;EACA,KAAK;;;EAGL;;UAGe;EACf;;EAEA;;EAEA;;;;;;;wBAuYc,aAAa,OAAO,oBAAoB;;;;;;;;;UCzavC;;EAEf;;EAEA;;EAEA;;;;EAIA,aAAa;;;;;;;wBAQC,iBACd,YAAY,cACZ,iBACA,gBACC;UAcc;EACf;;EAEA;;EAEA;;;;;wBAMc,SACd,cACA,yCACC;wBAoEa,qBACd,iBACA,SAAS,8BACR;;;;;;;;;;;;;;;UCrHc;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,8 +1,23 @@
|
|
|
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-
|
|
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-CfgLhSXp.mjs";
|
|
2
|
+
import { mapBackgroundImages } from "@powerhousedao/shared/connect";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
5
|
+
import { isPassthroughImageRef } from "@powerhousedao/shared/connect/image-ref";
|
|
4
6
|
import { deflateSync } from "node:zlib";
|
|
5
7
|
//#region src/scaffold.ts
|
|
8
|
+
/**
|
|
9
|
+
* A background whose project-relative paths are rewritten to be relative to
|
|
10
|
+
* another directory (powerhouse.config.json's root -> hosts/desktop, where
|
|
11
|
+
* app.json resolves them from). URLs and data URIs are left as they are.
|
|
12
|
+
*/
|
|
13
|
+
function rebaseBackground(background, fromDir, toDir) {
|
|
14
|
+
const rebase = (ref) => {
|
|
15
|
+
if (isPassthroughImageRef(ref)) return ref;
|
|
16
|
+
const rel = path.relative(toDir, path.resolve(fromDir, ref)).split(path.sep).join("/");
|
|
17
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
18
|
+
};
|
|
19
|
+
return typeof background === "string" ? rebase(background) : mapBackgroundImages(background, rebase);
|
|
20
|
+
}
|
|
6
21
|
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
7
22
|
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
8
23
|
* replaces it with their real 1024×1024 artwork. */
|
|
@@ -85,6 +100,8 @@ function scaffoldDesktopShell(hostDir, options) {
|
|
|
85
100
|
identifier: options.identifier,
|
|
86
101
|
productName: options.productName,
|
|
87
102
|
icon: `./${iconFile}`,
|
|
103
|
+
background: options.background ?? null,
|
|
104
|
+
loading: null,
|
|
88
105
|
window: {
|
|
89
106
|
title: options.productName,
|
|
90
107
|
width: 1440,
|
|
@@ -127,6 +144,6 @@ function scaffoldDesktopShell(hostDir, options) {
|
|
|
127
144
|
};
|
|
128
145
|
}
|
|
129
146
|
//#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 };
|
|
147
|
+
export { APP_JSON_FILE, DEFAULT_SHELL_CRATE_VERSION, ICON_SOURCE, SHELL_DIR, appJsonSchema, appSlug, bundleStack, detectToolchain, fetchNodeSidecar, launchShell, loadAppJson, nodeSidecarTarget, preflightOrThrow, projectShell, rebaseBackground, resolvePhCliEntry, resolveShell, resolveTauriCommand, runTauriIcon, scaffoldDesktopShell, shellEnv, solidPng, tauriBundlesForHost, tauriConfigPatch };
|
|
131
148
|
|
|
132
149
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/scaffold.ts"],"sourcesContent":["import type { PHBackground } from \"@powerhousedao/shared/clis\";\nimport { mapBackgroundImages } from \"@powerhousedao/shared/connect\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\nimport { 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 /** The loading page's background, with its paths already relative to the\n * host directory (see `rebaseBackground`); `ph generate desktop-shell`\n * passes Connect's `connect.home.background`. Default: none. */\n background?: PHBackground | null;\n}\n\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 */\nexport function rebaseBackground(\n background: PHBackground,\n fromDir: string,\n toDir: string,\n): PHBackground {\n const rebase = (ref: string): string => {\n if (isPassthroughImageRef(ref)) return ref;\n const rel = path\n .relative(toDir, path.resolve(fromDir, ref))\n .split(path.sep)\n .join(\"/\");\n return rel.startsWith(\".\") ? rel : `./${rel}`;\n };\n return typeof background === \"string\"\n ? rebase(background)\n : mapBackgroundImages(background, rebase);\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 // The loading page's branding; null = the defaults (see app-json.ts).\n background: options.background ?? null,\n loading: null,\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":";;;;;;;;;;;;AAiCA,SAAgB,iBACd,YACA,SACA,OACc;CACd,MAAM,UAAU,QAAwB;EACtC,IAAI,sBAAsB,GAAG,GAAG,OAAO;EACvC,MAAM,MAAM,KACT,SAAS,OAAO,KAAK,QAAQ,SAAS,GAAG,CAAC,CAAC,CAC3C,MAAM,KAAK,GAAG,CAAC,CACf,KAAK,GAAG;EACX,OAAO,IAAI,WAAW,GAAG,IAAI,MAAM,KAAK;CAC1C;CACA,OAAO,OAAO,eAAe,WACzB,OAAO,UAAU,IACjB,oBAAoB,YAAY,MAAM;AAC5C;;;;AAaA,SAAgB,SACd,MACA,MACQ;CACR,MAAM,CAAC,GAAG,GAAG,GAAG,KAAK;CAErB,MAAM,MAAM,OAAO,MAAM,IAAI,OAAO,CAAC;CACrC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,KAAK;EAC7B,MAAM,IAAI,IAAI,IAAI;EAClB,IAAI,KAAK;EACT,IAAI,IAAI,KAAK;EACb,IAAI,IAAI,KAAK;EACb,IAAI,IAAI,KAAK;CACf;CACA,MAAM,MAAM,OAAO,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,SAAS,GAAG,CAAC;CACjE,MAAM,OAAO,YAAY,GAAG;CAE5B,MAAM,SAAS,MAAc,SAAyB;EACpD,MAAM,MAAM,OAAO,MAAM,CAAC;EAC1B,IAAI,cAAc,KAAK,QAAQ,CAAC;EAChC,MAAM,UAAU,O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