@stacksjs/desktop-build 0.75.10 → 0.75.12

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.ts CHANGED
@@ -52,12 +52,26 @@ export declare function resolveDevWindowUrl(port: number, options?: OpenDevWindo
52
52
  export declare function craftDevCommand(port: number, options?: OpenDevWindowOptions): string[];
53
53
  export declare function createUpdateManifestUrl(baseUrl: string, channel?: string): string;
54
54
  export declare function openDevWindow(port: number, options?: OpenDevWindowOptions, launcher?: CraftLauncher): Promise<boolean>;
55
+ /** Whether `path` is a Mach-O executable, by its first four bytes. */
56
+ export declare function isMachO(path: string): boolean;
55
57
  /**
56
- * Whether a file is a Bun standalone executable.
58
+ * Where a file `build:desktop` emitted belongs inside a `.app`.
57
59
  *
58
- * Size first because it is a `stat`, then the marker, so the expensive check
59
- * only runs on the handful of files large enough to be a runtime at all.
60
+ * `codesign` treats everything in `Contents/MacOS` as code. The manifest,
61
+ * provenance and checksums used to sit there beside the launcher, so signing
62
+ * the launcher or the bundle failed with "code object is not signed at all.
63
+ * In subcomponent: .../Contents/MacOS/desktop.json" - no bundle this produced
64
+ * could ever be signed, which went unnoticed because nothing had signed one.
65
+ * Executables go in MacOS; everything else in Resources.
60
66
  */
67
+ export declare function bundleDirectoryFor(path: string): 'MacOS' | 'Resources';
68
+ /**
69
+ * The `codesign` invocation for one target in a distributable bundle:
70
+ * hardened runtime (notarization rejects anything without it) and a secure
71
+ * timestamp (notarization also rejects "The signature does not include a
72
+ * secure timestamp"). Ad-hoc signing (`-`) cannot be timestamped.
73
+ */
74
+ export declare function codesignArgs(options: CodesignOptions): string[];
61
75
  export declare function looksLikeBunExecutable(path: string, read?: (path: string) => { size: number, tail: string } | null): boolean;
62
76
  /**
63
77
  * What a bundle is paying to ship more than one Bun-compiled executable.
@@ -159,6 +173,11 @@ export declare interface BundledRuntime {
159
173
  name: string
160
174
  bytes: number
161
175
  }
176
+ export declare interface CodesignOptions {
177
+ identity: string
178
+ target: string
179
+ entitlements?: string
180
+ }
162
181
  export type CraftLauncher = (command: string[]) => void | Promise<void>;
163
182
  export type CraftBinaryLocator = (binary: string) => string | null;
164
183
  export * from './invites';
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{closeSync as P,existsSync as p,openSync as M,readSync as O,statSync as F}from"fs";import{dirname as T,join as a}from"path";import o from"process";import{fileURLToPath as z}from"url";import{craftBinaryNotFoundMessage as N,resolveCraftBinary as K}from"craft-native";function v(e,t,r={}){if(!t.trim())throw Error("Invite token is required");let n=new URL("/invite",/^https?:\/\//.test(e)?e:`https://${e}`);if(n.searchParams.set("token",t),r.email)n.searchParams.set("email",r.email);if(r.team)n.searchParams.set("team",r.team);if(r.role)n.searchParams.set("role",r.role);if(r.expiresAt){let s=r.expiresAt instanceof Date?r.expiresAt:new Date(r.expiresAt);if(Number.isNaN(s.valueOf()))throw Error("Invite expiration must be a valid date");n.searchParams.set("expires",s.toISOString())}return n.toString()}async function G(e,t){return Promise.all(e.map(async(r)=>{let n=typeof r==="string"?{email:r}:r;try{x(n.email);let s=await t.createToken(n),i=v(t.baseUrl,s,{email:n.email,team:n.team,role:n.role,expiresAt:t.expiresAt});return await t.send({recipient:n,url:i}),{recipient:n,url:i,delivered:!0}}catch(s){return{recipient:n,url:"",delivered:!1,error:s instanceof Error?s.message:String(s)}}}))}function x(e){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))throw Error(`Invalid invite email: ${e}`)}import{createHash as D,createPublicKey as E,verify as R}from"crypto";import{mkdir as I,rename as S,writeFile as U}from"fs/promises";import{dirname as A}from"path";async function ee(e){k(e.manifestUrl);let t=await(e.fetcher||fetch)(e.manifestUrl,{headers:{Accept:"application/json"}});if(!t.ok)throw Error(`Desktop update check failed with HTTP ${t.status}`);let r=h(await t.json());return m(r,e.trustedKeys),L(r.version,e.currentVersion)>0?r:null}async function te(e,t,r=fetch,n){if(h(e),!n)throw Error("Desktop update staging requires trusted signing keys");m(e,n),k(e.url);let s=await r(e.url);if(!s.ok)throw Error(`Desktop update download failed with HTTP ${s.status}`);let i=new Uint8Array(await s.arrayBuffer());if(i.byteLength!==e.size)throw Error(`Desktop update size mismatch: expected ${e.size}, received ${i.byteLength}`);if(D("sha256").update(i).digest("hex")!==e.sha256.toLowerCase())throw Error("Desktop update checksum mismatch");await I(A(t),{recursive:!0});let f=`${t}.download-${crypto.randomUUID()}`;return await U(f,i,{mode:448}),await S(f,t),{manifest:e,path:t,bytes:i.byteLength}}function L(e,t){let r=c(e),n=c(t);for(let s=0;s<3;s++){let i=r[s]-n[s];if(i!==0)return Math.sign(i)}return 0}function h(e){if(!e||typeof e!=="object")throw Error("Desktop update manifest must be an object");let t=e;if(c(t.version||""),typeof t.url!=="string")throw Error("Desktop update manifest requires a URL");if(typeof t.sha256!=="string"||!/^[a-f0-9]{64}$/i.test(t.sha256))throw Error("Desktop update manifest requires a SHA-256 checksum");if(!Number.isInteger(t.size)||t.size<0)throw Error("Desktop update manifest requires a non-negative integer size");if(typeof t.sourceRevision!=="string"||!/^[0-9a-f]{40}$/.test(t.sourceRevision))throw Error("Desktop update manifest requires a full source revision");if(typeof t.platform!=="string"||!["darwin","linux","win32"].includes(t.platform))throw Error("Desktop update manifest requires a supported platform identifier");if(typeof t.architecture!=="string"||!/^[a-z0-9_-]+$/.test(t.architecture))throw Error("Desktop update manifest requires an architecture");if(typeof t.signingKeyId!=="string"||!/^[a-zA-Z0-9._-]+$/.test(t.signingKeyId))throw Error("Desktop update manifest requires a signing key ID");if(typeof t.signature!=="string"||!/^[A-Za-z0-9_-]+$/.test(t.signature))throw Error("Desktop update manifest requires an Ed25519 signature");return t}function B(e){return Buffer.from(JSON.stringify({version:e.version,url:e.url,sha256:e.sha256.toLowerCase(),size:e.size,sourceRevision:e.sourceRevision,platform:e.platform,architecture:e.architecture,signingKeyId:e.signingKeyId,publishedAt:e.publishedAt||null,notes:e.notes||null}),"utf8")}function m(e,t){let r=t[e.signingKeyId];if(!r)throw Error(`Desktop update signing key is not trusted: ${e.signingKeyId}`);let n="ed25519-public:";if(!r.startsWith(n))throw Error("Desktop update signing key has an invalid encoding");try{let s=E({key:Buffer.from(r.slice(n.length),"base64url"),format:"der",type:"spki"}),i=Buffer.from(e.signature,"base64url");if(s.asymmetricKeyType!=="ed25519"||i.length!==64||!R(null,B(e),s,i))throw Error("invalid")}catch{throw Error("Desktop update manifest signature verification failed")}}function c(e){let t=e.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?$/);if(!t)throw Error(`Invalid semantic version: ${e}`);return[Number(t[1]),Number(t[2]),Number(t[3])]}function k(e){let t=new URL(e),r=["localhost","127.0.0.1","::1"].includes(t.hostname);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&r))throw Error("Desktop updates require HTTPS outside loopback development")}var j=[{platform:"darwin",architecture:"arm64",status:"experimental",osVersions:["macOS 15 runner"],packageFormat:"DMG + PKG",signing:"pending",notarization:"pending",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["Lifecycle fixtures are unsigned while platform identities remain unprovisioned.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"darwin",architecture:"x64",status:"experimental",osVersions:["macOS 15 Intel runner"],packageFormat:"DMG + PKG",signing:"pending",notarization:"pending",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["Lifecycle fixtures are unsigned while platform identities remain unprovisioned.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"linux",architecture:"x64",status:"experimental",osVersions:["Ubuntu 24.04 runner"],packageFormat:"DEB",signing:"pending",notarization:"not-applicable",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["The lifecycle fixture is unsigned and no package repository support policy is published.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"win32",architecture:"x64",status:"experimental",osVersions:["Windows Server 2025 runner"],packageFormat:"MSI + ZIP",signing:"pending",notarization:"not-applicable",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["The lifecycle fixture is not Authenticode-signed.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]}];function C(e=process.platform,t=process.arch){return j.find((r)=>r.platform===e&&r.architecture===t)}function ne(e,t=process.platform,r=process.arch){let n=C(t,r);if(!n)throw Error(`Desktop target ${t}/${r} is unsupported`);if(e==="stable"&&(n.status!=="stable"||n.signing!=="enforced"||n.platform==="darwin"&&n.notarization!=="enforced"||!n.installLaunchEvidence||!n.updateRollbackEvidence))throw Error(`Desktop target ${t}/${r} cannot be released as stable; complete stacksjs/stacks#2059, #2062, and #2063 first`);return n}function w(e=o.env.CRAFT_BIN){return K(e)}function ue(e=o.env.CRAFT_BIN,t=(r)=>Bun.which(r)){let r=w(e);if(r!=="craft")return r;let n=t(r);if(!n)throw Error(N(r));return n}var y="app/Desktop/launcher.ts";function le(e=o.cwd()){return p(a(e,y))}function de(e){return["build","--compile",...e.minify===!1?[]:["--minify"],"--no-compile-autoload-bunfig","--no-compile-autoload-dotenv",e.entry,"--outfile",e.outfile]}function ge(e=o.cwd()){let t=a(e,y);if(p(t))return t;let r=T(z(import.meta.url)),s=[a(r,"launcher.ts"),a(r,"launcher.js")].find((i)=>p(i));if(!s)throw Error("Desktop launcher entrypoint not found. Reinstall @stacksjs/desktop - the package must ship dist/launcher.js.");return s}var b=new Set(["CFBundleName","CFBundleDisplayName","CFBundleIdentifier","CFBundleVersion","CFBundleShortVersionString","CFBundleExecutable","CFBundlePackageType","CFBundleInfoDictionaryVersion","CFBundleIconFile"]);function u(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function l(e,t=""){if(typeof e==="string")return`<string>${u(e)}</string>`;if(typeof e==="boolean")return e?"<true/>":"<false/>";if(typeof e==="number"){if(!Number.isFinite(e))throw Error(`Unsupported Info.plist number: ${e}`);return Number.isInteger(e)?`<integer>${e}</integer>`:`<real>${e}</real>`}if(Array.isArray(e)){if(e.length===0)return"<array/>";return`<array>
2
+ import{closeSync as w,existsSync as u,openSync as y,readSync as x,statSync as P}from"fs";import{dirname as T,join as a}from"path";import o from"process";import{fileURLToPath as z}from"url";import{craftBinaryNotFoundMessage as N,resolveCraftBinary as _}from"craft-native";function E(e,t,r={}){if(!t.trim())throw Error("Invite token is required");let n=new URL("/invite",/^https?:\/\//.test(e)?e:`https://${e}`);if(n.searchParams.set("token",t),r.email)n.searchParams.set("email",r.email);if(r.team)n.searchParams.set("team",r.team);if(r.role)n.searchParams.set("role",r.role);if(r.expiresAt){let s=r.expiresAt instanceof Date?r.expiresAt:new Date(r.expiresAt);if(Number.isNaN(s.valueOf()))throw Error("Invite expiration must be a valid date");n.searchParams.set("expires",s.toISOString())}return n.toString()}async function Y(e,t){return Promise.all(e.map(async(r)=>{let n=typeof r==="string"?{email:r}:r;try{R(n.email);let s=await t.createToken(n),i=E(t.baseUrl,s,{email:n.email,team:n.team,role:n.role,expiresAt:t.expiresAt});return await t.send({recipient:n,url:i}),{recipient:n,url:i,delivered:!0}}catch(s){return{recipient:n,url:"",delivered:!1,error:s instanceof Error?s.message:String(s)}}}))}function R(e){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))throw Error(`Invalid invite email: ${e}`)}import{createHash as S,createPublicKey as I,verify as A}from"crypto";import{mkdir as C,rename as B,writeFile as U}from"fs/promises";import{dirname as F}from"path";async function re(e){k(e.manifestUrl);let t=await(e.fetcher||fetch)(e.manifestUrl,{headers:{Accept:"application/json"}});if(!t.ok)throw Error(`Desktop update check failed with HTTP ${t.status}`);let r=m(await t.json());return h(r,e.trustedKeys),L(r.version,e.currentVersion)>0?r:null}async function ne(e,t,r=fetch,n){if(m(e),!n)throw Error("Desktop update staging requires trusted signing keys");h(e,n),k(e.url);let s=await r(e.url);if(!s.ok)throw Error(`Desktop update download failed with HTTP ${s.status}`);let i=new Uint8Array(await s.arrayBuffer());if(i.byteLength!==e.size)throw Error(`Desktop update size mismatch: expected ${e.size}, received ${i.byteLength}`);if(S("sha256").update(i).digest("hex")!==e.sha256.toLowerCase())throw Error("Desktop update checksum mismatch");await C(F(t),{recursive:!0});let f=`${t}.download-${crypto.randomUUID()}`;return await U(f,i,{mode:448}),await B(f,t),{manifest:e,path:t,bytes:i.byteLength}}function L(e,t){let r=c(e),n=c(t);for(let s=0;s<3;s++){let i=r[s]-n[s];if(i!==0)return Math.sign(i)}return 0}function m(e){if(!e||typeof e!=="object")throw Error("Desktop update manifest must be an object");let t=e;if(c(t.version||""),typeof t.url!=="string")throw Error("Desktop update manifest requires a URL");if(typeof t.sha256!=="string"||!/^[a-f0-9]{64}$/i.test(t.sha256))throw Error("Desktop update manifest requires a SHA-256 checksum");if(!Number.isInteger(t.size)||t.size<0)throw Error("Desktop update manifest requires a non-negative integer size");if(typeof t.sourceRevision!=="string"||!/^[0-9a-f]{40}$/.test(t.sourceRevision))throw Error("Desktop update manifest requires a full source revision");if(typeof t.platform!=="string"||!["darwin","linux","win32"].includes(t.platform))throw Error("Desktop update manifest requires a supported platform identifier");if(typeof t.architecture!=="string"||!/^[a-z0-9_-]+$/.test(t.architecture))throw Error("Desktop update manifest requires an architecture");if(typeof t.signingKeyId!=="string"||!/^[a-zA-Z0-9._-]+$/.test(t.signingKeyId))throw Error("Desktop update manifest requires a signing key ID");if(typeof t.signature!=="string"||!/^[A-Za-z0-9_-]+$/.test(t.signature))throw Error("Desktop update manifest requires an Ed25519 signature");return t}function j(e){return Buffer.from(JSON.stringify({version:e.version,url:e.url,sha256:e.sha256.toLowerCase(),size:e.size,sourceRevision:e.sourceRevision,platform:e.platform,architecture:e.architecture,signingKeyId:e.signingKeyId,publishedAt:e.publishedAt||null,notes:e.notes||null}),"utf8")}function h(e,t){let r=t[e.signingKeyId];if(!r)throw Error(`Desktop update signing key is not trusted: ${e.signingKeyId}`);let n="ed25519-public:";if(!r.startsWith(n))throw Error("Desktop update signing key has an invalid encoding");try{let s=I({key:Buffer.from(r.slice(n.length),"base64url"),format:"der",type:"spki"}),i=Buffer.from(e.signature,"base64url");if(s.asymmetricKeyType!=="ed25519"||i.length!==64||!A(null,j(e),s,i))throw Error("invalid")}catch{throw Error("Desktop update manifest signature verification failed")}}function c(e){let t=e.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?$/);if(!t)throw Error(`Invalid semantic version: ${e}`);return[Number(t[1]),Number(t[2]),Number(t[3])]}function k(e){let t=new URL(e),r=["localhost","127.0.0.1","::1"].includes(t.hostname);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&r))throw Error("Desktop updates require HTTPS outside loopback development")}var O=[{platform:"darwin",architecture:"arm64",status:"experimental",osVersions:["macOS 15 runner"],packageFormat:"DMG + PKG",signing:"pending",notarization:"pending",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["Lifecycle fixtures are unsigned while platform identities remain unprovisioned.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"darwin",architecture:"x64",status:"experimental",osVersions:["macOS 15 Intel runner"],packageFormat:"DMG + PKG",signing:"pending",notarization:"pending",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["Lifecycle fixtures are unsigned while platform identities remain unprovisioned.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"linux",architecture:"x64",status:"experimental",osVersions:["Ubuntu 24.04 runner"],packageFormat:"DEB",signing:"pending",notarization:"not-applicable",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["The lifecycle fixture is unsigned and no package repository support policy is published.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]},{platform:"win32",architecture:"x64",status:"experimental",osVersions:["Windows Server 2025 runner"],packageFormat:"MSI + ZIP",signing:"pending",notarization:"not-applicable",installLaunchEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",updateRollbackEvidence:"https://github.com/stacksjs/stacks/actions/runs/29890804159",packagingEvidence:"https://github.com/stacksjs/protocol/blob/main/evidence/craft.json",blockingIssues:["https://github.com/stacksjs/stacks/issues/2062","https://github.com/home-lang/craft/issues/11"],limitations:["The lifecycle fixture is not Authenticode-signed.","Craft v0.0.48 is source-tagged, but its upstream release workflow is blocked by repository Actions policy."]}];function M(e=process.platform,t=process.arch){return O.find((r)=>r.platform===e&&r.architecture===t)}function ie(e,t=process.platform,r=process.arch){let n=M(t,r);if(!n)throw Error(`Desktop target ${t}/${r} is unsupported`);if(e==="stable"&&(n.status!=="stable"||n.signing!=="enforced"||n.platform==="darwin"&&n.notarization!=="enforced"||!n.installLaunchEvidence||!n.updateRollbackEvidence))throw Error(`Desktop target ${t}/${r} cannot be released as stable; complete stacksjs/stacks#2059, #2062, and #2063 first`);return n}function v(e=o.env.CRAFT_BIN){return _(e)}function de(e=o.env.CRAFT_BIN,t=(r)=>Bun.which(r)){let r=v(e);if(r!=="craft")return r;let n=t(r);if(!n)throw Error(N(r));return n}var D="app/Desktop/launcher.ts";function ge(e=o.cwd()){return u(a(e,D))}function fe(e){return["build","--compile",...e.minify===!1?[]:["--minify"],"--no-compile-autoload-bunfig","--no-compile-autoload-dotenv",e.entry,"--outfile",e.outfile]}function me(e=o.cwd()){let t=a(e,D);if(u(t))return t;let r=T(z(import.meta.url)),s=[a(r,"launcher.ts"),a(r,"launcher.js")].find((i)=>u(i));if(!s)throw Error("Desktop launcher entrypoint not found. Reinstall @stacksjs/desktop - the package must ship dist/launcher.js.");return s}var b=new Set(["CFBundleName","CFBundleDisplayName","CFBundleIdentifier","CFBundleVersion","CFBundleShortVersionString","CFBundleExecutable","CFBundlePackageType","CFBundleInfoDictionaryVersion","CFBundleIconFile"]);function p(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function l(e,t=""){if(typeof e==="string")return`<string>${p(e)}</string>`;if(typeof e==="boolean")return e?"<true/>":"<false/>";if(typeof e==="number"){if(!Number.isFinite(e))throw Error(`Unsupported Info.plist number: ${e}`);return Number.isInteger(e)?`<integer>${e}</integer>`:`<real>${e}</real>`}if(Array.isArray(e)){if(e.length===0)return"<array/>";return`<array>
3
3
  ${e.map((n)=>`${t} ${l(n,`${t} `)}`).join(`
4
4
  `)}
5
5
  ${t}</array>`}if(e&&typeof e==="object"){let r=Object.entries(e);if(r.length===0)return"<dict/>";return`<dict>
6
- ${r.map(([s,i])=>`${t} <key>${u(s)}</key>${l(i,`${t} `)}`).join(`
6
+ ${r.map(([s,i])=>`${t} <key>${p(s)}</key>${l(i,`${t} `)}`).join(`
7
7
  `)}
8
- ${t}</dict>`}throw Error(`Unsupported Info.plist value: ${JSON.stringify(e)??String(e)}`)}function fe(e){let t=Object.keys(e).filter((s)=>b.has(s)),r=Object.entries(e).filter(([s])=>!b.has(s));if(r.length===0)return{xml:"",ignored:t};return{xml:`
9
- ${r.map(([s,i])=>` <key>${u(s)}</key>${l(i," ")}`).join(`
10
- `)}`,ignored:t}}function _(e,t={}){if(!Number.isInteger(e)||e<1||e>65535)throw RangeError(`Invalid desktop development port: ${e}`);let r=t.url||o.env.APP_URL;if(!r)return"https://stacks.test";let n=/^https?:\/\//.test(r)?r:`https://${r}`;return new URL(n).toString().replace(/\/$/,"")}function q(e,t={}){let r=[w(t.craftBin),_(e,t),"--title",t.title||"Stacks","--width",String(t.width||1400),"--height",String(t.height||900)];if(t.hotReload!==!1)r.push("--hot-reload");if(t.devTools===!1)r.push("--no-devtools");if(t.darkMode)r.push("--dark");if(t.systemTray)r.push("--system-tray");if(t.hideDockIcon)r.push("--hide-dock-icon");if(t.menubarOnly)r.push("--menubar-only");return r}function he(e,t="stable"){if(!/^[a-z0-9-]+$/i.test(t))throw Error("Update channel may only contain letters, numbers, and hyphens");return new URL(`/desktop/updates/${t}.json`,/^https?:\/\//.test(e)?e:`https://${e}`).toString()}async function V(e){Bun.spawn(e,{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).unref()}async function me(e,t={},r=V){return await r(q(e,t)),!0}var W="---- Bun!",H=8388608,d=41943040;function ke(e,t=Z){let r=t(e);if(!r||r.size<d)return!1;return r.tail.includes(W)}function Z(e){try{let{size:t}=F(e);if(t<d)return{size:t,tail:""};let r=M(e,"r");try{let n=Math.min(H,t),s=Buffer.alloc(n);return O(r,s,0,n,t-n),{size:t,tail:s.toString("latin1")}}finally{P(r)}}catch{return null}}function be(e){if(e.length<2)return null;let t=[...e].sort((i,g)=>g.bytes-i.bytes),n=t.slice(1).length*d,s=t.map((i)=>`${i.name} (${(i.bytes/1024/1024).toFixed(1)} MB)`).join(", ");return`This bundle ships ${e.length} Bun-compiled executables: ${s}. Each embeds a full copy of the Bun runtime, so at least ${(n/1024/1024).toFixed(0)} MB of the bundle is the same runtime repeated. `+"Compiling one binary that dispatches on a subcommand \u2014 `MyApp agent`, `MyApp worker` \u2014 keeps the helpers as separate processes and pays for the runtime once."}export{W as BUN_EXECUTABLE_MARKER,b as RESERVED_PLIST_KEYS,y as USERLAND_LAUNCHER,ne as assertDesktopReleaseChannel,ee as checkForDesktopUpdate,L as compareVersions,q as craftDevCommand,v as createInviteLink,he as createUpdateManifestUrl,be as describeRuntimeDuplication,de as desktopLauncherCompileArgs,C as desktopSupport,j as desktopSupportMatrix,le as hasUserlandDesktopLauncher,ke as looksLikeBunExecutable,me as openDevWindow,l as plistValue,fe as renderUserlandPlistEntries,w as resolveCraftBinary,ue as resolveCraftExecutable,ge as resolveDesktopLauncher,_ as resolveDevWindowUrl,G as sendDesktopInvites,te as stageDesktopUpdate,B as updateManifestPayload,h as validateUpdateManifest,m as verifyUpdateManifestSignature,u as xmlEscape};
8
+ ${t}</dict>`}throw Error(`Unsupported Info.plist value: ${JSON.stringify(e)??String(e)}`)}function he(e){let t=Object.keys(e).filter((s)=>b.has(s)),r=Object.entries(e).filter(([s])=>!b.has(s));if(r.length===0)return{xml:"",ignored:t};return{xml:`
9
+ ${r.map(([s,i])=>` <key>${p(s)}</key>${l(i," ")}`).join(`
10
+ `)}`,ignored:t}}function K(e,t={}){if(!Number.isInteger(e)||e<1||e>65535)throw RangeError(`Invalid desktop development port: ${e}`);let r=t.url||o.env.APP_URL;if(!r)return"https://stacks.test";let n=/^https?:\/\//.test(r)?r:`https://${r}`;return new URL(n).toString().replace(/\/$/,"")}function q(e,t={}){let r=[v(t.craftBin),K(e,t),"--title",t.title||"Stacks","--width",String(t.width||1400),"--height",String(t.height||900)];if(t.hotReload!==!1)r.push("--hot-reload");if(t.devTools===!1)r.push("--no-devtools");if(t.darkMode)r.push("--dark");if(t.systemTray)r.push("--system-tray");if(t.hideDockIcon)r.push("--hide-dock-icon");if(t.menubarOnly)r.push("--menubar-only");return r}function ke(e,t="stable"){if(!/^[a-z0-9-]+$/i.test(t))throw Error("Update channel may only contain letters, numbers, and hyphens");return new URL(`/desktop/updates/${t}.json`,/^https?:\/\//.test(e)?e:`https://${e}`).toString()}async function V(e){Bun.spawn(e,{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).unref()}async function be(e,t={},r=V){return await r(q(e,t)),!0}var W="---- Bun!",H=8388608,d=41943040,G=new Set([4277009102,3472551422,4277009103,3489328638,3405691582,3199925962]);function Z(e){try{let t=y(e,"r");try{let r=Buffer.alloc(4);if(x(t,r,0,4,0)<4)return!1;return G.has(r.readUInt32BE(0))}finally{w(t)}}catch{return!1}}function we(e){return Z(e)?"MacOS":"Resources"}function ye(e){return["codesign","--force",e.identity==="-"?"--timestamp=none":"--timestamp","--options","runtime",...e.entitlements?["--entitlements",e.entitlements]:[],"--sign",e.identity,e.target]}function xe(e,t=J){let r=t(e);if(!r||r.size<d)return!1;return r.tail.includes(W)}function J(e){try{let{size:t}=P(e);if(t<d)return{size:t,tail:""};let r=y(e,"r");try{let n=Math.min(H,t),s=Buffer.alloc(n);return x(r,s,0,n,t-n),{size:t,tail:s.toString("latin1")}}finally{w(r)}}catch{return null}}function ve(e){if(e.length<2)return null;let t=[...e].sort((i,g)=>g.bytes-i.bytes),n=t.slice(1).length*d,s=t.map((i)=>`${i.name} (${(i.bytes/1024/1024).toFixed(1)} MB)`).join(", ");return`This bundle ships ${e.length} Bun-compiled executables: ${s}. Each embeds a full copy of the Bun runtime, so at least ${(n/1024/1024).toFixed(0)} MB of the bundle is the same runtime repeated. `+"Compiling one binary that dispatches on a subcommand \u2014 `MyApp agent`, `MyApp worker` \u2014 keeps the helpers as separate processes and pays for the runtime once."}export{W as BUN_EXECUTABLE_MARKER,b as RESERVED_PLIST_KEYS,D as USERLAND_LAUNCHER,ie as assertDesktopReleaseChannel,we as bundleDirectoryFor,re as checkForDesktopUpdate,ye as codesignArgs,L as compareVersions,q as craftDevCommand,E as createInviteLink,ke as createUpdateManifestUrl,ve as describeRuntimeDuplication,fe as desktopLauncherCompileArgs,M as desktopSupport,O as desktopSupportMatrix,ge as hasUserlandDesktopLauncher,Z as isMachO,xe as looksLikeBunExecutable,be as openDevWindow,l as plistValue,he as renderUserlandPlistEntries,v as resolveCraftBinary,de as resolveCraftExecutable,me as resolveDesktopLauncher,K as resolveDevWindowUrl,Y as sendDesktopInvites,ne as stageDesktopUpdate,j as updateManifestPayload,m as validateUpdateManifest,h as verifyUpdateManifestSignature,p as xmlEscape};
package/dist/launcher.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{existsSync as o,readFileSync as a}from"fs";import{dirname as d,join as r}from"path";var s=d(process.execPath),i=r(s,"desktop.json"),n=r(s,process.platform==="win32"?"craft-runtime.exe":"craft-runtime");if(!o(i))throw Error(`Desktop manifest not found: ${i}`);if(!o(n))throw Error(`Craft runtime not found: ${n}`);var t=JSON.parse(a(i,"utf8")),e=[n,t.url,"--title",t.title,"--width",String(t.width),"--height",String(t.height),"--no-devtools"];if(t.darkMode)e.push("--dark");if(t.systemTray)e.push("--system-tray");if(t.hideDockIcon)e.push("--hide-dock-icon");var c=Bun.spawn(e,{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.exit(await c.exited);
2
+ import{existsSync as s,readFileSync as d}from"fs";import{dirname as c,join as e}from"path";var o=c(process.execPath),n=[e(o,"..","Resources","desktop.json"),e(o,"desktop.json")].find((a)=>s(a))??e(o,"desktop.json"),r=e(o,process.platform==="win32"?"craft-runtime.exe":"craft-runtime");if(!s(n))throw Error(`Desktop manifest not found: ${n}`);if(!s(r))throw Error(`Craft runtime not found: ${r}`);var t=JSON.parse(d(n,"utf8")),i=[r,t.url,"--title",t.title,"--width",String(t.width),"--height",String(t.height),"--no-devtools"];if(t.darkMode)i.push("--dark");if(t.systemTray)i.push("--system-tray");if(t.hideDockIcon)i.push("--hide-dock-icon");var h=Bun.spawn(i,{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.exit(await h.exited);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/desktop-build",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.10",
5
+ "version": "0.75.12",
6
6
  "description": "Build and launch Craft desktop applications for Stacks",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -70,8 +70,8 @@
70
70
  "craft-native": ">=0.0.55"
71
71
  },
72
72
  "devDependencies": {
73
- "@stacksjs/build": "0.75.10",
73
+ "@stacksjs/build": "0.75.12",
74
74
  "better-dx": "^0.2.24",
75
- "@stacksjs/server": "0.75.10"
75
+ "@stacksjs/server": "0.75.12"
76
76
  }
77
77
  }