@powerhousedao/ph-cli 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/{build-skPHsKkL.mjs → build-BM-zayLm.mjs} +7 -3
- package/dist/build-BM-zayLm.mjs.map +1 -0
- package/dist/build-BZGpUn8f.mjs +4 -0
- package/dist/{cli-connect-override-65mFEDEB.mjs → cli-connect-override-DP5vRA7N.mjs} +4 -4
- package/dist/{cli-connect-override-65mFEDEB.mjs.map → cli-connect-override-DP5vRA7N.mjs.map} +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/{connect-build-D9zrBKG4.mjs → connect-build-xRrXk9-p.mjs} +31 -10
- package/dist/connect-build-xRrXk9-p.mjs.map +1 -0
- package/dist/{connect-config-C1tf7DqD.mjs → connect-config-BvS0chVq.mjs} +4 -4
- package/dist/{connect-config-C1tf7DqD.mjs.map → connect-config-BvS0chVq.mjs.map} +1 -1
- package/dist/{connect-preview-Clue7SVp.mjs → connect-preview-BW6XnRtj.mjs} +42 -11
- package/dist/connect-preview-BW6XnRtj.mjs.map +1 -0
- package/dist/{connect-studio-Q93rzqnC.mjs → connect-studio-8EyDblpG.mjs} +4 -4
- package/dist/{connect-studio-Q93rzqnC.mjs.map → connect-studio-8EyDblpG.mjs.map} +1 -1
- package/dist/{connect-studio-BbsQuED_.mjs → connect-studio-NxCVdXDv.mjs} +3 -3
- package/dist/{dist-D-CZUgtS.mjs → dist-BqeDFgEy.mjs} +5 -4
- package/dist/{dist-D-CZUgtS.mjs.map → dist-BqeDFgEy.mjs.map} +1 -1
- package/dist/{explain-BHB_4rJ3.mjs → explain-D6gLYBd0.mjs} +4 -4
- package/dist/{explain-BHB_4rJ3.mjs.map → explain-D6gLYBd0.mjs.map} +1 -1
- package/dist/generate-desktop-shell-itIzf77U.mjs +212 -0
- package/dist/generate-desktop-shell-itIzf77U.mjs.map +1 -0
- package/dist/{host-schemas-CL_wFpY7-DOvIjrBA.mjs → host-schemas-CL_wFpY7-B_pY14Jy.mjs} +5 -4
- package/dist/{host-schemas-CL_wFpY7-DOvIjrBA.mjs.map → host-schemas-CL_wFpY7-B_pY14Jy.mjs.map} +1 -1
- package/dist/{index-CApW1xbO.d.mts → index-CspiP73o.d.mts} +840 -297
- package/dist/index-CspiP73o.d.mts.map +1 -0
- package/dist/{ph-cli-commands-DGOKk392.mjs → ph-cli-commands-CLJP7yKV.mjs} +44 -12
- package/dist/ph-cli-commands-CLJP7yKV.mjs.map +1 -0
- package/dist/ph-cli-commands-NHDoX5i7.mjs +4 -0
- package/dist/plugins-CHVv4qup.mjs +91 -0
- package/dist/plugins-CHVv4qup.mjs.map +1 -0
- package/dist/{reactor-env-DHBr4V4W.mjs → reactor-env-BbR86_Li.mjs} +4 -4
- package/dist/{reactor-env-DHBr4V4W.mjs.map → reactor-env-BbR86_Li.mjs.map} +1 -1
- package/dist/reactor-env-D_EvBtLB.mjs +4 -0
- package/dist/{run-sugar-Dq3ZrLL_.mjs → run-sugar-DveBlJqh.mjs} +4 -4
- package/dist/{run-sugar-Dq3ZrLL_.mjs.map → run-sugar-DveBlJqh.mjs.map} +1 -1
- package/dist/runners/compound.d.mts +1 -1
- package/dist/runners/compound.mjs +4 -4
- package/dist/runners/connect.d.mts +1 -1
- package/dist/runners/connect.mjs +9 -8
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +9 -8
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/{plugins-DtJUVtyg.mjs → schemas-BQSPev1x.mjs} +2546 -1055
- package/dist/schemas-BQSPev1x.mjs.map +1 -0
- package/dist/{start-run-DsZRHbM1.mjs → start-run-CASbiOWI.mjs} +4 -4
- package/dist/{start-run-DsZRHbM1.mjs.map → start-run-CASbiOWI.mjs.map} +1 -1
- package/dist/{vetra-BNJZ5LHN.mjs → vetra-BV5F0YeG.mjs} +6 -6
- package/dist/{vetra-BNJZ5LHN.mjs.map → vetra-BV5F0YeG.mjs.map} +1 -1
- package/package.json +14 -13
- package/dist/build-DmqwT-PR.mjs +0 -4
- package/dist/build-skPHsKkL.mjs.map +0 -1
- package/dist/connect-build-D9zrBKG4.mjs.map +0 -1
- package/dist/connect-preview-Clue7SVp.mjs.map +0 -1
- package/dist/index-CApW1xbO.d.mts.map +0 -1
- package/dist/ph-cli-commands-BxKtXZgb.mjs +0 -4
- package/dist/ph-cli-commands-DGOKk392.mjs.map +0 -1
- package/dist/plugins-DtJUVtyg.mjs.map +0 -1
- package/dist/reactor-env-CchCHhA0.mjs +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
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]="1f75ea05-dcf8-565f-8c31-f2612019dbea")}catch(e){}}();
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { deepMerge } from "@powerhousedao/shared/connect";
|
|
5
|
+
import { deepMerge, normalizeBasePath } from "@powerhousedao/shared/connect";
|
|
6
6
|
import { getConnectBaseViteConfig } from "@powerhousedao/builder-tools";
|
|
7
7
|
import { mergeConfig, preview } from "vite";
|
|
8
8
|
//#region src/services/connect-preview.ts
|
|
@@ -57,12 +57,41 @@ function patchCspScriptSrc(html, registryUrl) {
|
|
|
57
57
|
return open + policy.replace(/script-src\s+([^;]*)/i, (_directive, sources) => `script-src ${sources.trim()} ${registryUrl}`).replace(/&/g, "&").replace(/'/g, "'") + close;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function resolvePreviewBase(argBase, outDirAbs) {
|
|
61
|
+
if (argBase && argBase !== "/") return normalizeBasePath(argBase);
|
|
62
|
+
try {
|
|
63
|
+
const basePath = JSON.parse(readFileSync(path.join(outDirAbs, "powerhouse.config.json"), "utf8")).connect?.app?.basePath;
|
|
64
|
+
if (typeof basePath === "string" && basePath) return normalizeBasePath(basePath);
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
function stripBase(pathname, base) {
|
|
68
|
+
return base !== "/" && pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;
|
|
69
|
+
}
|
|
70
|
+
const IMMUTABLE = "public, max-age=31536000, immutable";
|
|
71
|
+
function previewCacheControl(pathname, search) {
|
|
72
|
+
if (pathname.startsWith("/__vendor__/")) return /\/(shared-deps|import-map)\.js(on)?$/.test(pathname) ? "no-cache" : IMMUTABLE;
|
|
73
|
+
if (pathname.startsWith("/__react__/")) return IMMUTABLE;
|
|
74
|
+
if (pathname.startsWith("/__reactor_worker__/")) return new URLSearchParams(search).has("v") ? IMMUTABLE : "no-cache";
|
|
75
|
+
}
|
|
76
|
+
function previewCacheHeadersPlugin(base) {
|
|
77
|
+
return {
|
|
78
|
+
name: "ph:preview-cache-headers",
|
|
79
|
+
configurePreviewServer(server) {
|
|
80
|
+
server.middlewares.use((req, res, next) => {
|
|
81
|
+
const [rawPath, search = ""] = (req.url ?? "/").split("?");
|
|
82
|
+
const value = previewCacheControl(stripBase(rawPath, base), search);
|
|
83
|
+
if (value) res.setHeader("Cache-Control", value);
|
|
84
|
+
next();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function serveOverridePlugin(outDir, override, base = "/") {
|
|
61
90
|
return {
|
|
62
91
|
name: "ph:serve-override",
|
|
63
92
|
configurePreviewServer(server) {
|
|
64
93
|
server.middlewares.use((req, res, next) => {
|
|
65
|
-
const urlPath = (req.url ?? "/").split("?")[0];
|
|
94
|
+
const urlPath = stripBase((req.url ?? "/").split("?")[0], base);
|
|
66
95
|
if (urlPath === "/powerhouse.config.json") {
|
|
67
96
|
res.writeHead(200, {
|
|
68
97
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -90,16 +119,17 @@ function serveOverridePlugin(outDir, override) {
|
|
|
90
119
|
}
|
|
91
120
|
};
|
|
92
121
|
}
|
|
93
|
-
async function runConnectPreview(args, serveOverride) {
|
|
122
|
+
async function runConnectPreview(args, serveOverride, dirname = process.cwd()) {
|
|
94
123
|
serveOverride ??= overrideFromEnv();
|
|
95
124
|
const { outDir, port, host, open, cors, strictPort, printUrls, bindCLIShortcuts } = args;
|
|
96
|
-
const mode = "production";
|
|
97
|
-
const dirname = process.cwd();
|
|
98
125
|
const baseConfig = getConnectBaseViteConfig({
|
|
99
|
-
mode,
|
|
126
|
+
mode: "production",
|
|
100
127
|
dirname
|
|
101
128
|
});
|
|
129
|
+
const outDirAbs = path.resolve(dirname, outDir);
|
|
130
|
+
const base = resolvePreviewBase(args.connectBasePath, outDirAbs) ?? baseConfig.base ?? "/";
|
|
102
131
|
const previewConfig = {
|
|
132
|
+
base,
|
|
103
133
|
build: { outDir },
|
|
104
134
|
preview: {
|
|
105
135
|
cors,
|
|
@@ -108,15 +138,16 @@ async function runConnectPreview(args, serveOverride) {
|
|
|
108
138
|
host,
|
|
109
139
|
open
|
|
110
140
|
},
|
|
111
|
-
...serveOverride ?
|
|
141
|
+
plugins: [previewCacheHeadersPlugin(base), ...serveOverride ? [serveOverridePlugin(outDirAbs, serveOverride, base)] : []]
|
|
112
142
|
};
|
|
113
143
|
const config = mergeConfig(baseConfig, previewConfig);
|
|
114
144
|
const server = await preview(config);
|
|
115
145
|
if (printUrls) server.printUrls();
|
|
116
146
|
if (bindCLIShortcuts) server.bindCLIShortcuts({ print: true });
|
|
147
|
+
return server;
|
|
117
148
|
}
|
|
118
149
|
//#endregion
|
|
119
150
|
export { runConnectPreview };
|
|
120
151
|
|
|
121
|
-
//# sourceMappingURL=connect-preview-
|
|
122
|
-
//# debugId=
|
|
152
|
+
//# sourceMappingURL=connect-preview-BW6XnRtj.mjs.map
|
|
153
|
+
//# debugId=1f75ea05-dcf8-565f-8c31-f2612019dbea
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-preview-BW6XnRtj.mjs","sources":["../src/services/connect-preview.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport { deepMerge, normalizeBasePath } from \"@powerhousedao/shared/connect\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { InlineConfig, Plugin } from \"vite\";\nimport { mergeConfig, preview } from \"vite\";\nimport type { ConnectPreviewArgs } from \"../types.js\";\n\n/**\n * Runtime shaping for a served (built) Connect, desktop shape: the compound\n * projects the live switchboard's drive into the connect member's config, and\n * this override makes the STATIC dist serve it — the built\n * powerhouse.config.json is baked, so without this the drive injection never\n * reaches the SPA. `cspRegistrySync` additionally patches the baked CSP's\n * script-src with the runtime registry (the build bakes the CSP for the\n * registry it was built against; setting the registry at run time breaks that\n * coupling and every package import gets blocked otherwise).\n */\nexport interface ConnectServeOverride {\n connect?: PHConnectRuntimeConfig;\n cspRegistrySync?: boolean;\n /** Overrides the baked top-level packageRegistryUrl in the served config. */\n packageRegistryUrl?: string;\n}\n\n/**\n * The env contract a supervisor can drive the preview with — the same\n * variables the Docker entrypoint and clint's service manager already speak:\n * PH_CONNECT_DEFAULT_DRIVES_URL (comma-separated drive urls, injected into\n * drives.defaultDrives), PH_CONNECT_DRIVES_PRESERVE_STRATEGY, and\n * PH_CONNECT_PACKAGES_REGISTRY (runtime registry: served config + baked-CSP\n * patch). Lets `ph connect preview` replace hand-rolled static servers\n * (clint's connect-server, the ph-win sidecar) without losing injection.\n */\nexport function overrideFromEnv(\n env: Record<string, string | undefined> = process.env,\n): ConnectServeOverride | undefined {\n const drivesUrl = env.PH_CONNECT_DEFAULT_DRIVES_URL;\n const registry = env.PH_CONNECT_PACKAGES_REGISTRY;\n if (!drivesUrl && !registry) return undefined;\n const override: ConnectServeOverride = {};\n if (drivesUrl) {\n override.connect = {\n drives: {\n defaultDrives: drivesUrl\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((url) => ({ url, name: null, icon: null })),\n preserveStrategy:\n env.PH_CONNECT_DRIVES_PRESERVE_STRATEGY ?? \"preserve-all\",\n },\n } as PHConnectRuntimeConfig;\n }\n if (registry) {\n override.packageRegistryUrl = registry;\n override.cspRegistrySync = true;\n }\n return override;\n}\n\nfunction mergedConfigBody(\n outDir: string,\n override: ConnectServeOverride,\n): string {\n const file = path.join(outDir, \"powerhouse.config.json\");\n const baked = existsSync(file)\n ? (JSON.parse(readFileSync(file, \"utf8\")) as Record<string, unknown>)\n : {};\n const connect = override.connect\n ? deepMerge(\n (baked.connect ?? {}) as PHConnectRuntimeConfig,\n override.connect,\n )\n : baked.connect;\n return JSON.stringify({\n ...baked,\n connect,\n ...(override.packageRegistryUrl\n ? { packageRegistryUrl: override.packageRegistryUrl }\n : {}),\n });\n}\n\n/**\n * Append the registry origin to the baked CSP's script-src. The attribute\n * value is HTML-escaped (every CSP keyword is `'`-quoted, which contains a\n * semicolon), so decode before touching directives and re-escape after —\n * ported from the ph-win-desktop sidecar, which this path replaces.\n */\nexport function patchCspScriptSrc(html: string, registryUrl: string): string {\n return html.replace(\n /(<meta\\s+http-equiv=\"Content-Security-Policy\"\\s+content=\")([^\"]*)(\")/i,\n (_match, open: string, escaped: string, close: string) => {\n const policy = escaped.replace(/&/g, \"&\").replace(/'/g, \"'\");\n if (policy.includes(registryUrl)) return open + escaped + close;\n const patched = policy.replace(\n /script-src\\s+([^;]*)/i,\n (_directive, sources: string) =>\n `script-src ${sources.trim()} ${registryUrl}`,\n );\n const reEscaped = patched.replace(/&/g, \"&\").replace(/'/g, \"'\");\n return open + reEscaped + close;\n },\n );\n}\n\n// The serve base: an explicit `--base`, else the basePath the dist was built with.\nexport function resolvePreviewBase(\n argBase: string | undefined,\n outDirAbs: string,\n): string | undefined {\n if (argBase && argBase !== \"/\") return normalizeBasePath(argBase);\n try {\n const built = JSON.parse(\n readFileSync(path.join(outDirAbs, \"powerhouse.config.json\"), \"utf8\"),\n ) as { connect?: { app?: { basePath?: unknown } } };\n const basePath = built.connect?.app?.basePath;\n if (typeof basePath === \"string\" && basePath) {\n return normalizeBasePath(basePath);\n }\n } catch {\n // no readable dist config\n }\n return undefined;\n}\n\n// `pathname` relative to the deploy base (\"/\" + rest), or itself when outside it.\nexport function stripBase(pathname: string, base: string): string {\n return base !== \"/\" && pathname.startsWith(base)\n ? `/${pathname.slice(base.length)}`\n : pathname;\n}\n\nconst IMMUTABLE = \"public, max-age=31536000, immutable\";\n\n// The prebuilt dirs are content-addressed: hashed names, or a `v` query on the worker's.\nexport function previewCacheControl(\n pathname: string,\n search: string,\n): string | undefined {\n if (pathname.startsWith(\"/__vendor__/\")) {\n return /\\/(shared-deps|import-map)\\.js(on)?$/.test(pathname)\n ? \"no-cache\"\n : IMMUTABLE;\n }\n if (pathname.startsWith(\"/__react__/\")) return IMMUTABLE;\n if (pathname.startsWith(\"/__reactor_worker__/\")) {\n return new URLSearchParams(search).has(\"v\") ? IMMUTABLE : \"no-cache\";\n }\n return undefined;\n}\n\nfunction previewCacheHeadersPlugin(base: string): Plugin {\n return {\n name: \"ph:preview-cache-headers\",\n configurePreviewServer(server) {\n server.middlewares.use((req, res, next) => {\n const [rawPath, search = \"\"] = (req.url ?? \"/\").split(\"?\");\n const value = previewCacheControl(stripBase(rawPath, base), search);\n if (value) res.setHeader(\"Cache-Control\", value);\n next();\n });\n },\n };\n}\n\nfunction serveOverridePlugin(\n outDir: string,\n override: ConnectServeOverride,\n base = \"/\",\n): Plugin {\n return {\n name: \"ph:serve-override\",\n configurePreviewServer(server) {\n server.middlewares.use((req, res, next) => {\n const urlPath = stripBase((req.url ?? \"/\").split(\"?\")[0], base);\n if (urlPath === \"/powerhouse.config.json\") {\n res.writeHead(200, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(mergedConfigBody(outDir, override));\n return;\n }\n // index.html and extensionless SPA routes get the CSP patch.\n const isHtml =\n urlPath === \"/\" ||\n urlPath.endsWith(\"/index.html\") ||\n !path.extname(urlPath);\n if (override.cspRegistrySync && isHtml) {\n const file = path.join(outDir, \"index.html\");\n if (existsSync(file)) {\n const merged = JSON.parse(mergedConfigBody(outDir, override)) as {\n packageRegistryUrl?: string;\n };\n const registry = merged.packageRegistryUrl;\n const html = readFileSync(file, \"utf8\");\n res.writeHead(200, {\n \"content-type\": \"text/html; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n res.end(registry ? patchCspScriptSrc(html, registry) : html);\n return;\n }\n }\n next();\n });\n },\n };\n}\n\nexport async function runConnectPreview(\n args: ConnectPreviewArgs,\n serveOverride?: ConnectServeOverride,\n dirname = process.cwd(),\n) {\n // A supervisor can drive the preview via env when no explicit override is\n // passed (the classic `ph connect preview` command path).\n serveOverride ??= overrideFromEnv();\n const {\n outDir,\n port,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n } = args;\n\n const mode = \"production\";\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n });\n\n const outDirAbs = path.resolve(dirname, outDir);\n const base =\n resolvePreviewBase(args.connectBasePath, outDirAbs) ??\n baseConfig.base ??\n \"/\";\n\n const previewConfig: InlineConfig = {\n base,\n build: {\n outDir,\n },\n preview: {\n cors,\n port,\n strictPort,\n host,\n open,\n },\n plugins: [\n previewCacheHeadersPlugin(base),\n ...(serveOverride\n ? [serveOverridePlugin(outDirAbs, serveOverride, base)]\n : []),\n ],\n };\n\n const config = mergeConfig(baseConfig, previewConfig);\n\n const server = await preview(config);\n\n if (printUrls) server.printUrls();\n if (bindCLIShortcuts) server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M,SAAS,MAAM,QAAQ,MAAM;CAEnC,IAAI,WAAW,OAAO,UAAU;CAChC,IAAI,kBAAkB,OAAO,iBAAiB,EAAE,OAAO,KAAK,CAAC;CAC7D,OAAO;AACT","debug_id":"1f75ea05-dcf8-565f-8c31-f2612019dbea"}
|
|
@@ -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 { r as buildStudioConnectOverride } from "./cli-connect-override-
|
|
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]="a0d7f5da-37c0-5c82-be49-0c883514fcba")}catch(e){}}();
|
|
3
|
+
import { r as buildStudioConnectOverride } from "./cli-connect-override-DP5vRA7N.mjs";
|
|
4
4
|
import { getConnectBaseViteConfig } from "@powerhousedao/builder-tools";
|
|
5
5
|
import { createServer, mergeConfig } from "vite";
|
|
6
6
|
//#region src/services/connect-studio.ts
|
|
@@ -32,5 +32,5 @@ async function runConnectStudio(args, customLogger, callerOverride) {
|
|
|
32
32
|
//#endregion
|
|
33
33
|
export { runConnectStudio as t };
|
|
34
34
|
|
|
35
|
-
//# sourceMappingURL=connect-studio-
|
|
36
|
-
//# debugId=
|
|
35
|
+
//# sourceMappingURL=connect-studio-8EyDblpG.mjs.map
|
|
36
|
+
//# debugId=a0d7f5da-37c0-5c82-be49-0c883514fcba
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-studio-
|
|
1
|
+
{"version":3,"file":"connect-studio-8EyDblpG.mjs","sources":["../src/services/connect-studio.ts"],"sourcesContent":["import { getConnectBaseViteConfig } from \"@powerhousedao/builder-tools\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport type { InlineConfig, Logger } from \"vite\";\nimport { createServer, mergeConfig } from \"vite\";\nimport type { ConnectStudioArgs } from \"../types.js\";\nimport { buildStudioConnectOverride } from \"../utils/cli-connect-override.js\";\n\nexport async function runConnectStudio(\n args: ConnectStudioArgs,\n customLogger?: Logger,\n callerOverride?: PHConnectRuntimeConfig,\n) {\n const { port, host, open, cors, strictPort, printUrls, bindCLIShortcuts } =\n args;\n const mode = \"development\";\n\n const dirname = process.cwd();\n\n const cliConnectOverride = buildStudioConnectOverride(args, callerOverride);\n\n const baseConfig = getConnectBaseViteConfig({\n mode,\n dirname,\n cliConnectOverride,\n });\n\n const devServerConfig: InlineConfig = {\n server: { port, host, open, cors, strictPort },\n customLogger,\n };\n\n const config = mergeConfig(baseConfig, devServerConfig);\n\n const server = await createServer(config);\n\n await server.listen();\n\n if (printUrls) server.printUrls();\n if (bindCLIShortcuts) server.bindCLIShortcuts({ print: true });\n}\n"],"names":[],"mappings":";;;;;;AAOA,eAAsB,iBACpB,MACA,cACA,gBACA;CACA,MAAM,EAAE,MAAM,MAAM,MAAM,MAAM,YAAY,WAAW,qBACrD;CACF,MAAM,OAAO;CAEb,MAAM,UAAU,QAAQ,IAAI;CAE5B,MAAM,qBAAqB,2BAA2B,MAAM,cAAc;CAE1E,MAAM,aAAa,yBAAyB;EAC1C;EACA;EACA;CACF,CAAC;CAOD,MAAM,SAAS,YAAY,YAAY;EAJrC,QAAQ;GAAE;GAAM;GAAM;GAAM;GAAM;EAAW;EAC7C;CAGmD,CAAC;CAEtD,MAAM,SAAS,MAAM,aAAa,MAAM;CAExC,MAAM,OAAO,OAAO;CAEpB,IAAI,WAAW,OAAO,UAAU;CAChC,IAAI,kBAAkB,OAAO,iBAAiB,EAAE,OAAO,KAAK,CAAC;AAC/D","debug_id":"a0d7f5da-37c0-5c82-be49-0c883514fcba"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as runConnectStudio } from "./connect-studio-
|
|
1
|
+
import { t as runConnectStudio } from "./connect-studio-8EyDblpG.mjs";
|
|
2
2
|
export { runConnectStudio };
|
|
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]="3c824362-e057-5e7d-a2f0-6ed7a89c44fb")}catch(e){}}();
|
|
4
|
+
//# debugId=3c824362-e057-5e7d-a2f0-6ed7a89c44fb
|
|
@@ -1,6 +1,7 @@
|
|
|
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 {
|
|
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]="6a51a0f6-c572-5ca9-b96b-b353caf0bc75")}catch(e){}}();
|
|
3
|
+
import { f as prettifyError } from "./schemas-BQSPev1x.mjs";
|
|
4
|
+
import { i as normalizePluginEntries, n as entryActiveForVerb, r as hostTypeSatisfies, t as PluginError } from "./plugins-CHVv4qup.mjs";
|
|
4
5
|
import { createRequire } from "node:module";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { pathToFileURL } from "node:url";
|
|
@@ -218,5 +219,5 @@ async function resolveHostPlugins(projectRoot, hostType, verb, entries, where) {
|
|
|
218
219
|
//#endregion
|
|
219
220
|
export { projectReactorToSwitchboard as a, projectReactorToConnect as i, isStructuralMultiReactor as n, remoteBackendUrls as o, primaryBackend as r, resolveHostPlugins as s, assertProtocolConsistency as t };
|
|
220
221
|
|
|
221
|
-
//# sourceMappingURL=dist-
|
|
222
|
-
//# debugId=
|
|
222
|
+
//# sourceMappingURL=dist-BqeDFgEy.mjs.map
|
|
223
|
+
//# debugId=6a51a0f6-c572-5ca9-b96b-b353caf0bc75
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist-D-CZUgtS.mjs","sources":["../../../packages/host-core/dist/index.mjs"],"sourcesContent":["import { A as HostLoadError, C as readRunRecord, D as listVerbs, E as getVerb, F as mergeDefaultDrives, I as projectDrivesIntoConnect, L as rebaseDriveUrl, M as lintHostImports, N as loadHost, O as resolveRunnerModule, P as probeHostsFolder, S as probeRun, T as RunnerError, _ as runCompound, a as reactorBackendSchema, b as clearRunRecord, c as reactorSchema, d as drivesSchema, f as explainDrivePlan, g as seedDrives, h as resolveDriveDeclaration, i as profileSchema, j as findNonStaticValue, k as validateHost, l as runnerBaseSchema, m as projectDriveId, n as compoundHostSchema, o as reactorHostSchema, p as mergeDrivePlan, r as emittedHostSchemas, s as reactorProtocolSchema, t as childrenSchema, u as driveDeclarationSchema, v as defaultUserDataDir, w as writeRunRecord, x as isPidAlive, y as resolveUserDataPlaceholders } from \"./host-schemas-CL_wFpY7.mjs\";\nimport { PluginError, entryActiveForVerb, hostTypeSatisfies, mergeContributions, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, registerHostType, resolveOrder, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook } from \"./plugins.mjs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\n//#region src/backend-projection.ts\nfunction projectStorage(name, storage) {\n\tswitch (storage.kind) {\n\t\tcase \"idb\": return { kind: \"idb\" };\n\t\tcase \"memory\": return { kind: \"memory\" };\n\t\tcase \"path\":\n\t\t\tif (!storage.dataDir) throw new Error(`Backend \"${name}\": storage kind \"path\" requires dataDir.`);\n\t\t\treturn {\n\t\t\t\tkind: \"path\",\n\t\t\t\tdataDir: storage.dataDir\n\t\t\t};\n\t\tcase \"postgres\": throw new Error(`Backend \"${name}\": storage kind \"postgres\" is server-side only — a provisioned (in-process/worker) reactor cannot use it. Point a \"remote\" backend at the switchboard that owns that database instead.`);\n\t}\n}\n/** One backend → one descriptor. The protocol's featureFlags ride every\n* descriptor (they are fleet consensus, not per-backend). A remote backend\n* must carry remote.url — provision() requires it. */\nfunction backendToDescriptor(name, backend, protocol) {\n\tconst descriptor = {\n\t\tkind: backend.kind ?? \"in-process\",\n\t\tname\n\t};\n\tif (descriptor.kind === \"remote\") {\n\t\tconst url = backend.remote?.url;\n\t\tif (!url) throw new Error(`Backend \"${name}\" is kind \"remote\" but has no remote.url — a remote descriptor attaches to an already-running reactor by URL.`);\n\t\tdescriptor.remote = { url };\n\t\treturn descriptor;\n\t}\n\tif (backend.storage) descriptor.storage = projectStorage(name, backend.storage);\n\tif (backend.packages) descriptor.packages = backend.packages;\n\tif (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n\treturn descriptor;\n}\n/** All named backends, in placement-primary-first order (the order a\n* createReactorClients step would provision them). */\nfunction backendsToDescriptors(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return [];\n\tconst names = Object.keys(backends);\n\tconst primary = reactor.placement?.primary;\n\treturn (primary && names.includes(primary) ? [primary, ...names.filter((n) => n !== primary)] : names).map((name) => backendToDescriptor(name, backends[name], reactor.protocol));\n}\nconst LOCAL_KINDS = /* @__PURE__ */ new Set([\n\t\"in-process\",\n\t\"worker\",\n\tvoid 0\n]);\n/**\n* Structural multi-reactor (phase 4): true when the block names BOTH a local\n* backend (in-process/worker — the tab's own reactor) and a remote one. This\n* is the shape Connect's routing client serves; a lone remote backend is an\n* attach-only host (assistant/agent shape), not a routed tab.\n*/\nfunction isStructuralMultiReactor(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return false;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\treturn kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\");\n}\n/** The remote backends' urls, placement order — what the routing client dials. */\nfunction remoteBackendUrls(reactor) {\n\treturn backendsToDescriptors(reactor).filter((d) => d.kind === \"remote\").map((d) => d.remote?.url).filter((u) => typeof u === \"string\");\n}\n//#endregion\n//#region src/reactor-config.ts\n/** The single primary backend for phase-2 projection (multi-backend routing is\n* track R). Prefers placement.primary, else \"main\"/\"local\", else the first. */\nfunction primaryBackend(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst names = Object.keys(backends);\n\tif (names.length === 0) return void 0;\n\treturn backends[reactor.placement?.primary ?? (names.includes(\"main\") ? \"main\" : names.includes(\"local\") ? \"local\" : names[0])];\n}\nconst FLAG_ENV = {\n\tdocumentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n\tauthEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n\tauthGroups: \"REACTOR_AUTH_GROUPS\",\n\tauthConditions: \"REACTOR_AUTH_CONDITIONS\"\n};\n/** The env vars a protocol block maps onto, with their string values. Only\n* keys the block actually sets appear. */\nfunction protocolEnv(protocol) {\n\tconst env = {};\n\tif (!protocol) return env;\n\tfor (const [key, varName] of Object.entries(FLAG_ENV)) {\n\t\tconst value = protocol.featureFlags?.[key];\n\t\tif (value !== void 0) env[varName] = value ? \"true\" : \"false\";\n\t}\n\tif (protocol.createSignaturePolicy !== void 0) env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n\tif (protocol.unsupportedStoredDocuments !== void 0) env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS = protocol.unsupportedStoredDocuments;\n\treturn env;\n}\n/** Project the reactor block onto the switchboard's env + options. */\nfunction projectReactorToSwitchboard(reactor) {\n\tconst env = protocolEnv(reactor?.protocol);\n\tconst backend = primaryBackend(reactor);\n\tconst options = {};\n\tif (backend?.storage) {\n\t\tconst s = backend.storage;\n\t\tconst dbUrl = s.kind === \"postgres\" ? s.url : s.dataDir;\n\t\tif (dbUrl) env.PH_REACTOR_DATABASE_URL = dbUrl;\n\t}\n\tif (backend?.readModel?.url) options.dbPath = backend.readModel.url;\n\tif (backend?.packages?.dynamic) env.DYNAMIC_MODEL_LOADING = \"true\";\n\tif (reactor?.workflows !== void 0) env.PH_WORKFLOWS_ENABLED = reactor.workflows ? \"1\" : \"0\";\n\treturn {\n\t\tenv,\n\t\toptions\n\t};\n}\nconst LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set([\n\t\"in-process\",\n\t\"worker\",\n\tvoid 0\n]);\n/**\n* Which reactor client the backend topology asks for:\n* - local (in-process/worker) AND remote backends -> `router`\n* - remote backend(s) only -> `remote`\n* - a worker backend -> `worker`\n* - anything else local -> `in-process`\n* `undefined` when no backends are declared — the caller then keeps the\n* legacy reactorWorker/multiReactor behaviour untouched.\n*/\nfunction reactorClientMode(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\tif (kinds.length === 0) return void 0;\n\tconst hasLocal = kinds.some((k) => LOCAL_BACKEND_KINDS.has(k));\n\tconst hasRemote = kinds.some((k) => k === \"remote\");\n\tif (hasLocal && hasRemote) return \"router\";\n\tif (hasRemote) return \"remote\";\n\treturn primaryBackend(reactor)?.kind === \"worker\" ? \"worker\" : \"in-process\";\n}\n/** Project the reactor block onto the Connect runtime config: protocol →\n* connect.reactor (same shape), backend topology → instance.reactorWorker\n* (legacy) + instance.reactorClient (the explicit 4-way selector),\n* workflows → app.workflowsEnabled. */\nfunction projectReactorToConnect(reactor) {\n\tconst connect = {};\n\tif (reactor?.protocol) connect.reactor = reactor.protocol;\n\tconst backend = primaryBackend(reactor);\n\tconst mode = reactorClientMode(reactor);\n\tif (backend?.kind !== void 0 || mode !== void 0) connect.instance = {\n\t\t...backend?.kind !== void 0 ? { reactorWorker: backend.kind === \"worker\" } : {},\n\t\t...mode !== void 0 ? { reactorClient: mode } : {}\n\t};\n\tif (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };\n\treturn { connect };\n}\n/**\n* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n* the host's protocol block, fail loudly naming the var, the host value, and\n* the env value. An env var that merely matches, or is unset, is fine (phase-2\n* transition keeps an operator's explicit env as an escape hatch unless it\n* disagrees with the protocol — see the WBS precedence note).\n*/\nfunction assertProtocolConsistency(protocol, env, hostFile = \"the host file\") {\n\tif (!protocol) return;\n\tconst expected = protocolEnv(protocol);\n\tfor (const [varName, hostValue] of Object.entries(expected)) {\n\t\tconst envValue = env[varName];\n\t\tif (envValue !== void 0 && envValue !== hostValue) throw new Error(`reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — a mismatch would diverge replay. Remove the env override or align the host.`);\n\t}\n}\n//#endregion\n//#region src/plugins-resolve.ts\n/**\n* NODE-ONLY plugin resolution (split from plugins.ts so the pure runner core\n* stays browser-safe for ConnectCore — R3). Resolves host.js entries from the\n* PROJECT dependency tree, exactly like runner modules.\n*/\nfunction isHostPluginShape(value) {\n\treturn value !== null && typeof value === \"object\" && typeof value.name === \"string\";\n}\n/**\n* Resolve host.js plugin entries into live plugins for one host boot:\n* verb-filter → module resolution from the project tree (default condition,\n* like runners) → factory/object contract → config validation → appliesTo.\n*/\nasync function resolveHostPlugins(projectRoot, hostType, verb, entries, where) {\n\tconst normalized = normalizePluginEntries(entries, where);\n\tconst projectRequire = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href);\n\tconst resolved = [];\n\tfor (const entry of normalized) {\n\t\tif (!entryActiveForVerb(entry, verb)) continue;\n\t\tlet file;\n\t\ttry {\n\t\t\tfile = projectRequire.resolve(entry.module);\n\t\t} catch {\n\t\t\tthrow new PluginError(`${where}: cannot resolve plugin \"${entry.module}\" from ${projectRoot}.`, \"Plugins resolve from the project dependency tree, exactly like runner modules.\");\n\t\t}\n\t\tconst exported = (await import(pathToFileURL(file).href)).default;\n\t\tlet plugin;\n\t\tif (typeof exported === \"function\") plugin = exported(entry.config);\n\t\telse if (isHostPluginShape(exported)) {\n\t\t\tif (Object.keys(entry.config).length > 0 && !exported.configSchema) throw new PluginError(`${where}: plugin \"${entry.module}\" takes no config, but the entry passes one.`);\n\t\t\tplugin = exported;\n\t\t} else throw new PluginError(`${where}: \"${entry.module}\" does not default-export a plugin object or factory.`, \"Export `{ name, hooks?, contributions? }` or `(config) => plugin`.\");\n\t\tif (plugin.configSchema) {\n\t\t\tconst parsed = plugin.configSchema.safeParse(entry.config);\n\t\t\tif (!parsed.success) throw new PluginError(`${where}: config for plugin \"${plugin.name}\" is invalid:\\n` + z.prettifyError(parsed.error));\n\t\t}\n\t\tconst appliesTo = plugin.appliesTo ?? \"reactor\";\n\t\tif (!hostTypeSatisfies(hostType, appliesTo)) throw new PluginError(`${where}: plugin \"${plugin.name}\" applies to \"${appliesTo}\" hosts, but this host is \"${hostType}\".`);\n\t\tresolved.push({\n\t\t\tentry,\n\t\t\tplugin,\n\t\t\tprovenance: \"dependency\"\n\t\t});\n\t}\n\treturn resolved;\n}\n//#endregion\nexport { HostLoadError, PluginError, RunnerError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, childrenSchema, clearRunRecord, compoundHostSchema, defaultUserDataDir, driveDeclarationSchema, drivesSchema, emittedHostSchemas, entryActiveForVerb, explainDrivePlan, findNonStaticValue, getVerb, hostTypeSatisfies, isPidAlive, isStructuralMultiReactor, lintHostImports, listVerbs, loadHost, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, profileSchema, projectDriveId, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendSchema, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readRunRecord, rebaseDriveUrl, registerHostType, remoteBackendUrls, resolveDriveDeclaration, resolveHostPlugins, resolveOrder, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook, runnerBaseSchema, seedDrives, validateHost, writeRunRecord };\n\n//# sourceMappingURL=index.mjs.map"],"names":["z.prettifyError"],"mappings":";;;;;;;AAOA,SAAS,eAAe,MAAM,SAAS;CACtC,QAAQ,QAAQ,MAAhB;EACC,KAAK,OAAO,OAAO,EAAE,MAAM,MAAM;EACjC,KAAK,UAAU,OAAO,EAAE,MAAM,SAAS;EACvC,KAAK;GACJ,IAAI,CAAC,QAAQ,SAAS,MAAM,IAAI,MAAM,YAAY,KAAK,yCAAyC;GAChG,OAAO;IACN,MAAM;IACN,SAAS,QAAQ;GAClB;EACD,KAAK,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,uLAAuL;CAC1O;AACD;;;;AAIA,SAAS,oBAAoB,MAAM,SAAS,UAAU;CACrD,MAAM,aAAa;EAClB,MAAM,QAAQ,QAAQ;EACtB;CACD;CACA,IAAI,WAAW,SAAS,UAAU;EACjC,MAAM,MAAM,QAAQ,QAAQ;EAC5B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,YAAY,KAAK,8GAA8G;EACzJ,WAAW,SAAS,EAAE,IAAI;EAC1B,OAAO;CACR;CACA,IAAI,QAAQ,SAAS,WAAW,UAAU,eAAe,MAAM,QAAQ,OAAO;CAC9E,IAAI,QAAQ,UAAU,WAAW,WAAW,QAAQ;CACpD,IAAI,UAAU,cAAc,WAAW,eAAe,SAAS;CAC/D,OAAO;AACR;;;AAGA,SAAS,sBAAsB,SAAS;CACvC,MAAM,WAAW,SAAS;CAC1B,IAAI,CAAC,UAAU,OAAO,CAAC;CACvB,MAAM,QA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AAQ,MAAM,MAAM;EAC3C,QAAQ;GACP,MAAM,IAAI,YAAY,GAAG,MAAM,2BAA2B,MAAM,OAAO,SAAS,YAAY,IAAI,gFAAgF;EACjL;EACA,MAAM,YAAY,MAAM,OAAO,cAAc,IAAI,CAAC,CAAC,MAAA,CAAO;EAC1D,IAAI;EACJ,IAAI,OAAO,aAAa,YAAY,SAAS,SAAS,MAAM,MAAM;OAC7D,IAAI,kBAAkB,QAAQ,GAAG;GACrC,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,SAAS,cAAc,MAAM,IAAI,YAAY,GAAG,MAAM,YAAY,MAAM,OAAO,6CAA6C;GACzK,SAAS;EACV,OAAO,MAAM,IAAI,YAAY,GAAG,MAAM,KAAK,MAAM,OAAO,wDAAwD,oEAAoE;EACpL,IAAI,OAAO,cAAc;GACxB,MAAM,SAAS,OAAO,aAAa,UAAU,MAAM,MAAM;GACzD,IAAI,CAAC,OAAO,SAAS,MAAM,IAAI,YAAY,GAAG,MAAM,uBAAuB,OAAO,KAAK,mBAAmBA,cAAgB,OAAO,KAAK,CAAC;EACxI;EACA,MAAM,YAAY,OAAO,aAAa;EACtC,IAAI,CAAC,kBAAkB,UAAU,SAAS,GAAG,MAAM,IAAI,YAAY,GAAG,MAAM,YAAY,OAAO,KAAK,gBAAgB,UAAU,6BAA6B,SAAS,GAAG;EACvK,SAAS,KAAK;GACb;GACA;GACA,YAAY;EACb,CAAC;CACF;CACA,OAAO;AACR","debug_id":"270c172e-fe28-5652-9953-cd92d169a1e9"}
|
|
1
|
+
{"version":3,"file":"dist-BqeDFgEy.mjs","sources":["../../../packages/host-core/dist/index.mjs"],"sourcesContent":["import { A as HostLoadError, C as readRunRecord, D as listVerbs, E as getVerb, F as mergeDefaultDrives, I as projectDrivesIntoConnect, L as rebaseDriveUrl, M as lintHostImports, N as loadHost, O as resolveRunnerModule, P as probeHostsFolder, S as probeRun, T as RunnerError, _ as runCompound, a as reactorBackendSchema, b as clearRunRecord, c as reactorSchema, d as drivesSchema, f as explainDrivePlan, g as seedDrives, h as resolveDriveDeclaration, i as profileSchema, j as findNonStaticValue, k as validateHost, l as runnerBaseSchema, m as projectDriveId, n as compoundHostSchema, o as reactorHostSchema, p as mergeDrivePlan, r as emittedHostSchemas, s as reactorProtocolSchema, t as childrenSchema, u as driveDeclarationSchema, v as defaultUserDataDir, w as writeRunRecord, x as isPidAlive, y as resolveUserDataPlaceholders } from \"./host-schemas-CL_wFpY7.mjs\";\nimport { PluginError, entryActiveForVerb, hostTypeSatisfies, mergeContributions, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, registerHostType, resolveOrder, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook } from \"./plugins.mjs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { z } from \"zod\";\n//#region src/backend-projection.ts\nfunction projectStorage(name, storage) {\n\tswitch (storage.kind) {\n\t\tcase \"idb\": return { kind: \"idb\" };\n\t\tcase \"memory\": return { kind: \"memory\" };\n\t\tcase \"path\":\n\t\t\tif (!storage.dataDir) throw new Error(`Backend \"${name}\": storage kind \"path\" requires dataDir.`);\n\t\t\treturn {\n\t\t\t\tkind: \"path\",\n\t\t\t\tdataDir: storage.dataDir\n\t\t\t};\n\t\tcase \"postgres\": throw new Error(`Backend \"${name}\": storage kind \"postgres\" is server-side only — a provisioned (in-process/worker) reactor cannot use it. Point a \"remote\" backend at the switchboard that owns that database instead.`);\n\t}\n}\n/** One backend → one descriptor. The protocol's featureFlags ride every\n* descriptor (they are fleet consensus, not per-backend). A remote backend\n* must carry remote.url — provision() requires it. */\nfunction backendToDescriptor(name, backend, protocol) {\n\tconst descriptor = {\n\t\tkind: backend.kind ?? \"in-process\",\n\t\tname\n\t};\n\tif (descriptor.kind === \"remote\") {\n\t\tconst url = backend.remote?.url;\n\t\tif (!url) throw new Error(`Backend \"${name}\" is kind \"remote\" but has no remote.url — a remote descriptor attaches to an already-running reactor by URL.`);\n\t\tdescriptor.remote = { url };\n\t\treturn descriptor;\n\t}\n\tif (backend.storage) descriptor.storage = projectStorage(name, backend.storage);\n\tif (backend.packages) descriptor.packages = backend.packages;\n\tif (protocol?.featureFlags) descriptor.featureFlags = protocol.featureFlags;\n\treturn descriptor;\n}\n/** All named backends, in placement-primary-first order (the order a\n* createReactorClients step would provision them). */\nfunction backendsToDescriptors(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return [];\n\tconst names = Object.keys(backends);\n\tconst primary = reactor.placement?.primary;\n\treturn (primary && names.includes(primary) ? [primary, ...names.filter((n) => n !== primary)] : names).map((name) => backendToDescriptor(name, backends[name], reactor.protocol));\n}\nconst LOCAL_KINDS = /* @__PURE__ */ new Set([\n\t\"in-process\",\n\t\"worker\",\n\tvoid 0\n]);\n/**\n* Structural multi-reactor (phase 4): true when the block names BOTH a local\n* backend (in-process/worker — the tab's own reactor) and a remote one. This\n* is the shape Connect's routing client serves; a lone remote backend is an\n* attach-only host (assistant/agent shape), not a routed tab.\n*/\nfunction isStructuralMultiReactor(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return false;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\treturn kinds.some((k) => LOCAL_KINDS.has(k)) && kinds.some((k) => k === \"remote\");\n}\n/** The remote backends' urls, placement order — what the routing client dials. */\nfunction remoteBackendUrls(reactor) {\n\treturn backendsToDescriptors(reactor).filter((d) => d.kind === \"remote\").map((d) => d.remote?.url).filter((u) => typeof u === \"string\");\n}\n//#endregion\n//#region src/reactor-config.ts\n/** The single primary backend for phase-2 projection (multi-backend routing is\n* track R). Prefers placement.primary, else \"main\"/\"local\", else the first. */\nfunction primaryBackend(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst names = Object.keys(backends);\n\tif (names.length === 0) return void 0;\n\treturn backends[reactor.placement?.primary ?? (names.includes(\"main\") ? \"main\" : names.includes(\"local\") ? \"local\" : names[0])];\n}\nconst FLAG_ENV = {\n\tdocumentDecisions: \"REACTOR_DOCUMENT_DECISIONS\",\n\tauthEnforcement: \"REACTOR_AUTH_ENFORCEMENT\",\n\tauthGroups: \"REACTOR_AUTH_GROUPS\",\n\tauthConditions: \"REACTOR_AUTH_CONDITIONS\"\n};\n/** The env vars a protocol block maps onto, with their string values. Only\n* keys the block actually sets appear. */\nfunction protocolEnv(protocol) {\n\tconst env = {};\n\tif (!protocol) return env;\n\tfor (const [key, varName] of Object.entries(FLAG_ENV)) {\n\t\tconst value = protocol.featureFlags?.[key];\n\t\tif (value !== void 0) env[varName] = value ? \"true\" : \"false\";\n\t}\n\tif (protocol.createSignaturePolicy !== void 0) env.CREATE_SIGNATURE_POLICY = protocol.createSignaturePolicy;\n\tif (protocol.unsupportedStoredDocuments !== void 0) env.REACTOR_UNSUPPORTED_STORED_DOCUMENTS = protocol.unsupportedStoredDocuments;\n\treturn env;\n}\n/** Project the reactor block onto the switchboard's env + options. */\nfunction projectReactorToSwitchboard(reactor) {\n\tconst env = protocolEnv(reactor?.protocol);\n\tconst backend = primaryBackend(reactor);\n\tconst options = {};\n\tif (backend?.storage) {\n\t\tconst s = backend.storage;\n\t\tconst dbUrl = s.kind === \"postgres\" ? s.url : s.dataDir;\n\t\tif (dbUrl) env.PH_REACTOR_DATABASE_URL = dbUrl;\n\t}\n\tif (backend?.readModel?.url) options.dbPath = backend.readModel.url;\n\tif (backend?.packages?.dynamic) env.DYNAMIC_MODEL_LOADING = \"true\";\n\tif (reactor?.workflows !== void 0) env.PH_WORKFLOWS_ENABLED = reactor.workflows ? \"1\" : \"0\";\n\treturn {\n\t\tenv,\n\t\toptions\n\t};\n}\nconst LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set([\n\t\"in-process\",\n\t\"worker\",\n\tvoid 0\n]);\n/**\n* Which reactor client the backend topology asks for:\n* - local (in-process/worker) AND remote backends -> `router`\n* - remote backend(s) only -> `remote`\n* - a worker backend -> `worker`\n* - anything else local -> `in-process`\n* `undefined` when no backends are declared — the caller then keeps the\n* legacy reactorWorker/multiReactor behaviour untouched.\n*/\nfunction reactorClientMode(reactor) {\n\tconst backends = reactor?.backends;\n\tif (!backends) return void 0;\n\tconst kinds = Object.values(backends).map((b) => b.kind);\n\tif (kinds.length === 0) return void 0;\n\tconst hasLocal = kinds.some((k) => LOCAL_BACKEND_KINDS.has(k));\n\tconst hasRemote = kinds.some((k) => k === \"remote\");\n\tif (hasLocal && hasRemote) return \"router\";\n\tif (hasRemote) return \"remote\";\n\treturn primaryBackend(reactor)?.kind === \"worker\" ? \"worker\" : \"in-process\";\n}\n/** Project the reactor block onto the Connect runtime config: protocol →\n* connect.reactor (same shape), backend topology → instance.reactorWorker\n* (legacy) + instance.reactorClient (the explicit 4-way selector),\n* workflows → app.workflowsEnabled. */\nfunction projectReactorToConnect(reactor) {\n\tconst connect = {};\n\tif (reactor?.protocol) connect.reactor = reactor.protocol;\n\tconst backend = primaryBackend(reactor);\n\tconst mode = reactorClientMode(reactor);\n\tif (backend?.kind !== void 0 || mode !== void 0) connect.instance = {\n\t\t...backend?.kind !== void 0 ? { reactorWorker: backend.kind === \"worker\" } : {},\n\t\t...mode !== void 0 ? { reactorClient: mode } : {}\n\t};\n\tif (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };\n\treturn { connect };\n}\n/**\n* The enforcement teeth of single-sourcing: if a pre-set env var CONTRADICTS\n* the host's protocol block, fail loudly naming the var, the host value, and\n* the env value. An env var that merely matches, or is unset, is fine (phase-2\n* transition keeps an operator's explicit env as an escape hatch unless it\n* disagrees with the protocol — see the WBS precedence note).\n*/\nfunction assertProtocolConsistency(protocol, env, hostFile = \"the host file\") {\n\tif (!protocol) return;\n\tconst expected = protocolEnv(protocol);\n\tfor (const [varName, hostValue] of Object.entries(expected)) {\n\t\tconst envValue = env[varName];\n\t\tif (envValue !== void 0 && envValue !== hostValue) throw new Error(`reactor.protocol conflict: ${varName} is \"${envValue}\" in the environment but \"${hostValue}\" in ${hostFile}. These are fleet-consensus settings — a mismatch would diverge replay. Remove the env override or align the host.`);\n\t}\n}\n//#endregion\n//#region src/plugins-resolve.ts\n/**\n* NODE-ONLY plugin resolution (split from plugins.ts so the pure runner core\n* stays browser-safe for ConnectCore — R3). Resolves host.js entries from the\n* PROJECT dependency tree, exactly like runner modules.\n*/\nfunction isHostPluginShape(value) {\n\treturn value !== null && typeof value === \"object\" && typeof value.name === \"string\";\n}\n/**\n* Resolve host.js plugin entries into live plugins for one host boot:\n* verb-filter → module resolution from the project tree (default condition,\n* like runners) → factory/object contract → config validation → appliesTo.\n*/\nasync function resolveHostPlugins(projectRoot, hostType, verb, entries, where) {\n\tconst normalized = normalizePluginEntries(entries, where);\n\tconst projectRequire = createRequire(pathToFileURL(path.join(projectRoot, \"package.json\")).href);\n\tconst resolved = [];\n\tfor (const entry of normalized) {\n\t\tif (!entryActiveForVerb(entry, verb)) continue;\n\t\tlet file;\n\t\ttry {\n\t\t\tfile = projectRequire.resolve(entry.module);\n\t\t} catch {\n\t\t\tthrow new PluginError(`${where}: cannot resolve plugin \"${entry.module}\" from ${projectRoot}.`, \"Plugins resolve from the project dependency tree, exactly like runner modules.\");\n\t\t}\n\t\tconst exported = (await import(pathToFileURL(file).href)).default;\n\t\tlet plugin;\n\t\tif (typeof exported === \"function\") plugin = exported(entry.config);\n\t\telse if (isHostPluginShape(exported)) {\n\t\t\tif (Object.keys(entry.config).length > 0 && !exported.configSchema) throw new PluginError(`${where}: plugin \"${entry.module}\" takes no config, but the entry passes one.`);\n\t\t\tplugin = exported;\n\t\t} else throw new PluginError(`${where}: \"${entry.module}\" does not default-export a plugin object or factory.`, \"Export `{ name, hooks?, contributions? }` or `(config) => plugin`.\");\n\t\tif (plugin.configSchema) {\n\t\t\tconst parsed = plugin.configSchema.safeParse(entry.config);\n\t\t\tif (!parsed.success) throw new PluginError(`${where}: config for plugin \"${plugin.name}\" is invalid:\\n` + z.prettifyError(parsed.error));\n\t\t}\n\t\tconst appliesTo = plugin.appliesTo ?? \"reactor\";\n\t\tif (!hostTypeSatisfies(hostType, appliesTo)) throw new PluginError(`${where}: plugin \"${plugin.name}\" applies to \"${appliesTo}\" hosts, but this host is \"${hostType}\".`);\n\t\tresolved.push({\n\t\t\tentry,\n\t\t\tplugin,\n\t\t\tprovenance: \"dependency\"\n\t\t});\n\t}\n\treturn resolved;\n}\n//#endregion\nexport { HostLoadError, PluginError, RunnerError, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, childrenSchema, clearRunRecord, compoundHostSchema, defaultUserDataDir, driveDeclarationSchema, drivesSchema, emittedHostSchemas, entryActiveForVerb, explainDrivePlan, findNonStaticValue, getVerb, hostTypeSatisfies, isPidAlive, isStructuralMultiReactor, lintHostImports, listVerbs, loadHost, mergeContributions, mergeDefaultDrives, mergeDrivePlan, normalizePluginEntries, normalizePluginEntry, pluginEntrySchema, primaryBackend, probeHostsFolder, probeRun, profileSchema, projectDriveId, projectDrivesIntoConnect, projectReactorToConnect, projectReactorToSwitchboard, protocolEnv, reactorBackendSchema, reactorClientMode, reactorHostSchema, reactorProtocolSchema, reactorSchema, readRunRecord, rebaseDriveUrl, registerHostType, remoteBackendUrls, resolveDriveDeclaration, resolveHostPlugins, resolveOrder, resolveRunnerModule, resolveUserDataPlaceholders, runCompound, runObserveHook, runObserveHookSequential, runProvideHook, runTransformHook, runnerBaseSchema, seedDrives, validateHost, writeRunRecord };\n\n//# sourceMappingURL=index.mjs.map"],"names":["z.prettifyError"],"mappings":";;;;;;;;AAOA,SAAS,eAAe,MAAM,SAAS;CACtC,QAAQ,QAAQ,MAAhB;EACC,KAAK,OAAO,OAAO,EAAE,MAAM,MAAM;EACjC,KAAK,UAAU,OAAO,EAAE,MAAM,SAAS;EACvC,KAAK;GACJ,IAAI,CAAC,QAAQ,SAAS,MAAM,IAAI,MAAM,YAAY,KAAK,yCAAyC;GAChG,OAAO;IACN,MAAM;IACN,SAAS,QAAQ;GAClB;EACD,KAAK,YAAY,MAAM,IAAI,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,OAAO,KAAK,mBAAmBA,cAAgB,OAAO,KAAK,CAAC;EACxI;EACA,MAAM,YAAY,OAAO,aAAa;EACtC,IAAI,CAAC,kBAAkB,UAAU,SAAS,GAAG,MAAM,IAAI,YAAY,GAAG,MAAM,YAAY,OAAO,KAAK,gBAAgB,UAAU,6BAA6B,SAAS,GAAG;EACvK,SAAS,KAAK;GACb;GACA;GACA,YAAY;EACb,CAAC;CACF;CACA,OAAO;AACR","debug_id":"6a51a0f6-c572-5ca9-b96b-b353caf0bc75"}
|
|
@@ -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 { i as loadHost, n as explainDrivePlan, o as mergeDrivePlan } from "./host-schemas-CL_wFpY7-
|
|
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]="789ae972-d2bc-5c3a-9ad5-3492a9af885a")}catch(e){}}();
|
|
3
|
+
import { i as loadHost, n as explainDrivePlan, o as mergeDrivePlan } from "./host-schemas-CL_wFpY7-B_pY14Jy.mjs";
|
|
4
4
|
//#region src/services/run/explain.ts
|
|
5
5
|
async function explainHost(options) {
|
|
6
6
|
if (options.topic !== "drives") throw new Error(`Unknown --explain topic "${options.topic}" (supported: drives).`);
|
|
@@ -23,5 +23,5 @@ async function explainHost(options) {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { explainHost };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=explain-
|
|
27
|
-
//# debugId=
|
|
26
|
+
//# sourceMappingURL=explain-D6gLYBd0.mjs.map
|
|
27
|
+
//# debugId=789ae972-d2bc-5c3a-9ad5-3492a9af885a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explain-
|
|
1
|
+
{"version":3,"file":"explain-D6gLYBd0.mjs","sources":["../src/services/run/explain.ts"],"sourcesContent":["import {\n explainDrivePlan,\n loadHost,\n mergeDrivePlan,\n type DriveDeclaration,\n} from \"@powerhousedao/host-core\";\n\n/**\n * `ph run <host> --explain drives` (R1): print the merged drive plan with\n * provenance instead of running. Host-declared drives only for now — plugin\n * contributions join the merge when the pipelines land (R2+); the renderer\n * and provenance labels already carry them.\n */\n\ninterface ExplainOptions {\n host: string;\n topic: string;\n}\n\ninterface ReactorSection {\n drives?: DriveDeclaration[];\n}\n\ninterface ChildWrapper {\n host: string;\n reactor?: ReactorSection;\n}\n\nexport async function explainHost(options: ExplainOptions): Promise<void> {\n if (options.topic !== \"drives\") {\n throw new Error(\n `Unknown --explain topic \"${options.topic}\" (supported: drives).`,\n );\n }\n const projectRoot = process.cwd();\n const loaded = await loadHost(projectRoot, options.host);\n const host = loaded.host;\n\n if (host.children !== undefined) {\n // Compound: one plan per member, with the wrapper's full-statement\n // semantics (wrapper reactor replaces the member's when present).\n const children = host.children as Record<string, ChildWrapper>;\n for (const [name, wrapper] of Object.entries(children)) {\n const member = await loadHost(projectRoot, wrapper.host);\n const reactor = (wrapper.reactor ??\n member.host.reactor ??\n {}) as ReactorSection;\n console.log(`[${options.host} › ${name} (${wrapper.host})]`);\n console.log(\n explainDrivePlan(mergeDrivePlan(projectRoot, reactor.drives ?? [], [])),\n );\n }\n return;\n }\n\n const reactor = (host.reactor ?? {}) as ReactorSection;\n console.log(`[${options.host}]`);\n console.log(\n explainDrivePlan(mergeDrivePlan(projectRoot, reactor.drives ?? [], [])),\n );\n}\n"],"names":[],"mappings":";;;;AA4BA,eAAsB,YAAY,SAAwC;CACxE,IAAI,QAAQ,UAAU,UACpB,MAAM,IAAI,MACR,4BAA4B,QAAQ,MAAM,uBAC5C;CAEF,MAAM,cAAc,QAAQ,IAAI;CAEhC,MAAM,QAAO,MADQ,SAAS,aAAa,QAAQ,IAAI,EAAA,CACnC;CAEpB,IAAI,KAAK,aAAa,KAAA,GAAW;EAG/B,MAAM,WAAW,KAAK;EACtB,KAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,QAAQ,GAAG;GACtD,MAAM,SAAS,MAAM,SAAS,aAAa,QAAQ,IAAI;GACvD,MAAM,UAAW,QAAQ,WACvB,OAAO,KAAK,WACZ,CAAC;GACH,QAAQ,IAAI,IAAI,QAAQ,KAAK,KAAK,KAAK,IAAI,QAAQ,KAAK,GAAG;GAC3D,QAAQ,IACN,iBAAiB,eAAe,aAAa,QAAQ,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACxE;EACF;EACA;CACF;CAEA,MAAM,UAAW,KAAK,WAAW,CAAC;CAClC,QAAQ,IAAI,IAAI,QAAQ,KAAK,EAAE;CAC/B,QAAQ,IACN,iBAAiB,eAAe,aAAa,QAAQ,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACxE;AACF","debug_id":"789ae972-d2bc-5c3a-9ad5-3492a9af885a"}
|
|
@@ -0,0 +1,212 @@
|
|
|
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]="0143deec-f1bb-5f26-a0fa-873d3d704206")}catch(e){}}();
|
|
3
|
+
import { c as strictObject, l as string, n as array, o as number, r as boolean } from "./schemas-BQSPev1x.mjs";
|
|
4
|
+
import "node:module";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import "node:child_process";
|
|
8
|
+
import "node:url";
|
|
9
|
+
import { deflateSync } from "node:zlib";
|
|
10
|
+
//#region ../../packages/desktop/dist/shell-BL61-fyi.mjs
|
|
11
|
+
/**
|
|
12
|
+
* `hosts/desktop/app.json` — the builder's desktop identity (phase 7, mode 1:
|
|
13
|
+
* the builder ships under THEIR identity without writing Rust). It is the ONE
|
|
14
|
+
* file a builder edits; `shell-project.ts` projects it into a generated
|
|
15
|
+
* `tauri-shell/` that depends on the published `ph-desktop-shell` crate. Every
|
|
16
|
+
* field validates strictly so a typo fails with the field named, not silently.
|
|
17
|
+
*/
|
|
18
|
+
const identifierSchema = 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");
|
|
19
|
+
const windowSchema = strictObject({
|
|
20
|
+
title: string().min(1).optional(),
|
|
21
|
+
width: number().int().positive().optional(),
|
|
22
|
+
height: number().int().positive().optional(),
|
|
23
|
+
resizable: boolean().optional()
|
|
24
|
+
}).optional();
|
|
25
|
+
const fileAssociationSchema = strictObject({
|
|
26
|
+
/** Extensions WITHOUT the leading dot ("phd", not ".phd"). */
|
|
27
|
+
ext: array(string().min(1).regex(/^[^.]/, "drop the leading dot")).min(1),
|
|
28
|
+
name: string().min(1),
|
|
29
|
+
description: string().optional(),
|
|
30
|
+
mimeType: string().optional()
|
|
31
|
+
});
|
|
32
|
+
/** Where the generated Cargo.toml resolves `ph-desktop-shell` from. Default
|
|
33
|
+
* (omitted) = the published crates.io version. */
|
|
34
|
+
const shellSourceSchema = strictObject({
|
|
35
|
+
/** Local checkout for shell development (the lab points here). */
|
|
36
|
+
path: string().min(1).optional(),
|
|
37
|
+
/** Git source, pinned to a tag/rev, for pre-publication consumption. */
|
|
38
|
+
git: string().min(1).optional(),
|
|
39
|
+
tag: string().min(1).optional(),
|
|
40
|
+
rev: string().min(1).optional(),
|
|
41
|
+
/** crates.io version requirement (default DEFAULT_SHELL_CRATE_VERSION). */
|
|
42
|
+
version: string().min(1).optional()
|
|
43
|
+
}).refine((s) => !(s.path && s.git), { message: "shell.source: set path OR git, not both" }).optional();
|
|
44
|
+
const appJsonSchema = strictObject({
|
|
45
|
+
identifier: identifierSchema,
|
|
46
|
+
productName: string().min(1),
|
|
47
|
+
/** Single source image (square PNG, 1024×1024 recommended); the icon set
|
|
48
|
+
* for every platform is generated from it via `tauri icon`. */
|
|
49
|
+
icon: string().min(1),
|
|
50
|
+
window: windowSchema,
|
|
51
|
+
fileAssociations: array(fileAssociationSchema).optional(),
|
|
52
|
+
shell: shellSourceSchema
|
|
53
|
+
});
|
|
54
|
+
const APP_JSON_FILE = "app.json";
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region ../../packages/desktop/dist/index.mjs
|
|
57
|
+
/** Minimal PNG encoder — a solid square so `tauri icon` always has a valid
|
|
58
|
+
* source. Pure Node (zlib); no binary asset ships in the package. The builder
|
|
59
|
+
* replaces it with their real 1024×1024 artwork. */
|
|
60
|
+
function solidPng(size, rgba) {
|
|
61
|
+
const [r, g, b, a] = rgba;
|
|
62
|
+
const row = Buffer.alloc(1 + size * 4);
|
|
63
|
+
for (let x = 0; x < size; x++) {
|
|
64
|
+
const o = 1 + x * 4;
|
|
65
|
+
row[o] = r;
|
|
66
|
+
row[o + 1] = g;
|
|
67
|
+
row[o + 2] = b;
|
|
68
|
+
row[o + 3] = a;
|
|
69
|
+
}
|
|
70
|
+
const raw = Buffer.concat(Array.from({ length: size }, () => row));
|
|
71
|
+
const idat = deflateSync(raw);
|
|
72
|
+
const chunk = (type, data) => {
|
|
73
|
+
const len = Buffer.alloc(4);
|
|
74
|
+
len.writeUInt32BE(data.length, 0);
|
|
75
|
+
const typeBuf = Buffer.from(type, "ascii");
|
|
76
|
+
const body = Buffer.concat([typeBuf, data]);
|
|
77
|
+
const crc = Buffer.alloc(4);
|
|
78
|
+
crc.writeUInt32BE(crc32(body) >>> 0, 0);
|
|
79
|
+
return Buffer.concat([
|
|
80
|
+
len,
|
|
81
|
+
body,
|
|
82
|
+
crc
|
|
83
|
+
]);
|
|
84
|
+
};
|
|
85
|
+
const ihdr = Buffer.alloc(13);
|
|
86
|
+
ihdr.writeUInt32BE(size, 0);
|
|
87
|
+
ihdr.writeUInt32BE(size, 4);
|
|
88
|
+
ihdr[8] = 8;
|
|
89
|
+
ihdr[9] = 6;
|
|
90
|
+
ihdr[10] = 0;
|
|
91
|
+
ihdr[11] = 0;
|
|
92
|
+
ihdr[12] = 0;
|
|
93
|
+
return Buffer.concat([
|
|
94
|
+
Buffer.from([
|
|
95
|
+
137,
|
|
96
|
+
80,
|
|
97
|
+
78,
|
|
98
|
+
71,
|
|
99
|
+
13,
|
|
100
|
+
10,
|
|
101
|
+
26,
|
|
102
|
+
10
|
|
103
|
+
]),
|
|
104
|
+
chunk("IHDR", ihdr),
|
|
105
|
+
chunk("IDAT", idat),
|
|
106
|
+
chunk("IEND", Buffer.alloc(0))
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
let crcTable;
|
|
110
|
+
function crc32(buf) {
|
|
111
|
+
if (!crcTable) {
|
|
112
|
+
crcTable = [];
|
|
113
|
+
for (let n = 0; n < 256; n++) {
|
|
114
|
+
let c = n;
|
|
115
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
116
|
+
crcTable[n] = c;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
let crc = 4294967295;
|
|
120
|
+
for (let i = 0; i < buf.length; i++) crc = crcTable[(crc ^ buf[i]) & 255] ^ crc >>> 8;
|
|
121
|
+
return crc ^ 4294967295;
|
|
122
|
+
}
|
|
123
|
+
const GITIGNORE = `# Generated tauri shell — only Cargo.lock and app-icon.png are tracked.
|
|
124
|
+
/tauri-shell/target
|
|
125
|
+
/tauri-shell/gen
|
|
126
|
+
/tauri-shell/icons
|
|
127
|
+
/tauri-shell/dist-stack
|
|
128
|
+
/tauri-shell/binaries
|
|
129
|
+
`;
|
|
130
|
+
function scaffoldDesktopShell(hostDir, options) {
|
|
131
|
+
const created = [];
|
|
132
|
+
const skipped = [];
|
|
133
|
+
fs.mkdirSync(hostDir, { recursive: true });
|
|
134
|
+
const iconFile = "icon.png";
|
|
135
|
+
const app = {
|
|
136
|
+
identifier: options.identifier,
|
|
137
|
+
productName: options.productName,
|
|
138
|
+
icon: `./${iconFile}`,
|
|
139
|
+
window: {
|
|
140
|
+
title: options.productName,
|
|
141
|
+
width: 1440,
|
|
142
|
+
height: 900
|
|
143
|
+
},
|
|
144
|
+
fileAssociations: [{
|
|
145
|
+
ext: ["phd"],
|
|
146
|
+
name: "Powerhouse Document",
|
|
147
|
+
mimeType: "application/vnd.powerhouse.document+zip"
|
|
148
|
+
}]
|
|
149
|
+
};
|
|
150
|
+
appJsonSchema.parse(app);
|
|
151
|
+
const appJsonPath = path.join(hostDir, APP_JSON_FILE);
|
|
152
|
+
if (fs.existsSync(appJsonPath) && !options.force) skipped.push(appJsonPath);
|
|
153
|
+
else {
|
|
154
|
+
fs.writeFileSync(appJsonPath, `${JSON.stringify(app, null, 2)}\n`);
|
|
155
|
+
created.push(appJsonPath);
|
|
156
|
+
}
|
|
157
|
+
const iconPath = path.join(hostDir, iconFile);
|
|
158
|
+
if (fs.existsSync(iconPath)) skipped.push(iconPath);
|
|
159
|
+
else {
|
|
160
|
+
fs.writeFileSync(iconPath, solidPng(1024, [
|
|
161
|
+
79,
|
|
162
|
+
70,
|
|
163
|
+
229,
|
|
164
|
+
255
|
|
165
|
+
]));
|
|
166
|
+
created.push(iconPath);
|
|
167
|
+
}
|
|
168
|
+
const gitignorePath = path.join(hostDir, ".gitignore");
|
|
169
|
+
if (fs.existsSync(gitignorePath)) skipped.push(gitignorePath);
|
|
170
|
+
else {
|
|
171
|
+
fs.writeFileSync(gitignorePath, GITIGNORE);
|
|
172
|
+
created.push(gitignorePath);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
hostDir,
|
|
176
|
+
created,
|
|
177
|
+
skipped
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/services/generate-desktop-shell.ts
|
|
182
|
+
/** A reverse-DNS-safe segment from the project name (drop scope, slugify). */
|
|
183
|
+
function projectSlug(pkgName) {
|
|
184
|
+
return (pkgName ?? "app").replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "app";
|
|
185
|
+
}
|
|
186
|
+
/** `ph generate desktop-shell`: write hosts/desktop/app.json + a placeholder
|
|
187
|
+
* icon + .gitignore. Defaults product name / identifier from the project. */
|
|
188
|
+
function startGenerateDesktopShell(args, cwd) {
|
|
189
|
+
let pkgName;
|
|
190
|
+
try {
|
|
191
|
+
pkgName = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8")).name;
|
|
192
|
+
} catch {}
|
|
193
|
+
const slug = projectSlug(pkgName);
|
|
194
|
+
const productName = args.name ?? pkgName?.replace(/^@[^/]+\//, "") ?? "App";
|
|
195
|
+
const identifier = args.identifier ?? `inc.powerhouse.desktop.${slug}`;
|
|
196
|
+
const hostDir = path.join(cwd, "hosts", "desktop");
|
|
197
|
+
const result = scaffoldDesktopShell(hostDir, {
|
|
198
|
+
identifier,
|
|
199
|
+
productName,
|
|
200
|
+
force: args.force
|
|
201
|
+
});
|
|
202
|
+
const rel = (p) => path.relative(cwd, p).replace(/\\/g, "/");
|
|
203
|
+
for (const f of result.created) console.log(` created ${rel(f)}`);
|
|
204
|
+
for (const f of result.skipped) console.log(` skipped ${rel(f)} (exists — pass --force to overwrite)`);
|
|
205
|
+
if (!fs.existsSync(path.join(hostDir, "host.js"))) console.log("\nNote: hosts/desktop/host.js not found. Add a desktop host (see the desktop topology from `ph init`) so `ph run desktop` can supervise the stack; app.json then gives it a native window.");
|
|
206
|
+
console.log(`\nIdentity: ${productName} (${identifier}).\n• Replace hosts/desktop/icon.png with your 1024×1024 icon.\n• \`ph run desktop dev\` opens the native window (needs Rust + the Tauri CLI).\n• \`ph run desktop build\` produces installers for this OS.`);
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { startGenerateDesktopShell };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=generate-desktop-shell-itIzf77U.mjs.map
|
|
212
|
+
//# debugId=0143deec-f1bb-5f26-a0fa-873d3d704206
|