@stacksjs/desktop-build 0.75.640 → 0.75.647

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
@@ -245,6 +245,7 @@ export declare interface Desktop {
245
245
  // }
246
246
  export declare interface OpenDevWindowOptions {
247
247
  url?: string
248
+ htmlFile?: string
248
249
  title?: string
249
250
  width?: number
250
251
  height?: number
@@ -258,6 +259,7 @@ export declare interface OpenDevWindowOptions {
258
259
  systemTray?: boolean
259
260
  hideDockIcon?: boolean
260
261
  menubarOnly?: boolean
262
+ trayPopover?: boolean
261
263
  }
262
264
  /**
263
265
  * The launcher entrypoint `buddy build:desktop` compiles into the native
package/dist/index.js CHANGED
@@ -36,5 +36,5 @@ ${kept.map(([key,value])=>` <key>${xmlEscape(key)}</key>${plistValue(value," "
36
36
  ${minimumSystem}${highResolution}${transportSecurity}${icon}${extra}
37
37
  </dict>
38
38
  </plist>
39
- `;return{xml,ignored}}export function resolveDevWindowUrl(port,options={}){if(!Number.isInteger(port)||port<1||port>65535)throw new RangeError(`Invalid desktop development port: ${port}`);const configured=options.url||process.env.APP_URL;if(!configured)return`https://stacks.test`;const withProtocol=/^https?:\/\//.test(configured)?configured:`https://${configured}`;return new URL(withProtocol).toString().replace(/\/$/,"")}export function craftDevCommand(port,options={}){const command=[resolveCraftBinary(options.craftBin),resolveDevWindowUrl(port,options),"--title",options.title||"Stacks","--width",String(options.width||1400),"--height",String(options.height||900)];if(options.hotReload!==false)command.push("--hot-reload");if(options.devTools===false)command.push("--no-devtools");if(options.darkMode)command.push("--dark");if(options.systemTray)command.push("--system-tray");if(options.hideDockIcon)command.push("--hide-dock-icon");if(options.menubarOnly)command.push("--menubar-only");return command}export function createUpdateManifestUrl(baseUrl,channel="stable"){if(!/^[a-z0-9-]+$/i.test(channel))throw new Error("Update channel may only contain letters, numbers, and hyphens");return new URL(`/desktop/updates/${channel}.json`,/^https?:\/\//.test(baseUrl)?baseUrl:`https://${baseUrl}`).toString()}async function launchCraft(command){const process=Bun.spawn(command,{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.unref()}export async function openDevWindow(port,options={},launcher=launchCraft){await launcher(craftDevCommand(port,options));return true}export const BUN_EXECUTABLE_MARKER="---- Bun!";const MARKER_SEARCH_BYTES=8*1024*1024;const RUNTIME_SIZE_FLOOR=40*1024*1024;const MACH_O_MAGIC=new Set([4277009102,3472551422,4277009103,3489328638,3405691582,3199925962]);export function isMachO(path){try{const fd=openSync(path,"r");try{const head=Buffer.alloc(4);if(readSync(fd,head,0,4,0)<4)return false;return MACH_O_MAGIC.has(head.readUInt32BE(0))}finally{closeSync(fd)}}catch{return false}}export function bundleDirectoryFor(path){return isMachO(path)?"MacOS":"Resources"}export function desktopAppVersion(options={}){const override=options.override?.trim();if(override)return override;const declared=typeof options.declared==="string"?options.declared.trim():"";return declared||"0.0.0"}export function dmgVolumeName(options){const override=options.override?.trim();if(override)return override;const appName=options.appName.trim();const version=options.version?.trim();return version?`${appName} ${version}`:`${appName} Installer`}export function notarytoolAuthArgs(credentials){return"profile"in credentials?["--keychain-profile",credentials.profile]:["--key",credentials.keyPath,"--key-id",credentials.keyId,"--issuer",credentials.issuerId]}export function notarizationOutcome(report,exitCode){const status=report.match(/status: (\w[\w ]*)/g)?.pop()?.replace("status: ","").trim();const id=report.match(/id: ([0-9a-f-]{36})/)?.[1];return{accepted:exitCode===0&&status==="Accepted",status,id}}export function developerIdProblem(codesignReport){if(/code object is not signed/.test(codesignReport)||/Signature=adhoc/.test(codesignReport))return"it is not signed with a certificate. Pass a Developer ID Application identity with --signing-identity.";const authority=/^Authority=(.+)$/m.exec(codesignReport)?.[1];if(!authority?.startsWith("Developer ID Application:"))return`it is signed by ${authority?`"${authority}"`:"an unknown identity"}, not a Developer ID Application certificate.`;if(!/flags=0x[0-9a-f]+\([^)]*runtime[^)]*\)/.test(codesignReport))return"it is not signed with the hardened runtime.";if(!/^Timestamp=/m.test(codesignReport))return"its signature has no secure timestamp.";return}function resolveNotary(flags,env){const profile=supplied(flags.notaryProfile)??supplied(env.DESKTOP_NOTARY_PROFILE);if(profile)return{profile};const requested=flags.notarize===true||["1","true","yes"].includes(supplied(env.DESKTOP_NOTARIZE)?.toLowerCase()??"");if(!requested)return;const keyId=supplied(flags.apiKeyId)??supplied(env.APP_STORE_CONNECT_API_KEY_ID);const issuerId=supplied(flags.apiIssuerId)??supplied(env.APP_STORE_CONNECT_API_ISSUER_ID);const keyPath=supplied(flags.apiKeyPath)??supplied(env.APP_STORE_CONNECT_API_KEY_PATH);const keyPem=supplied(env.APP_STORE_CONNECT_API_KEY)?.replaceAll("\\n",`
39
+ `;return{xml,ignored}}export function resolveDevWindowUrl(port,options={}){if(!Number.isInteger(port)||port<1||port>65535)throw new RangeError(`Invalid desktop development port: ${port}`);const configured=options.url||process.env.APP_URL;if(!configured)return`https://stacks.test`;const withProtocol=/^https?:\/\//.test(configured)?configured:`https://${configured}`;return new URL(withProtocol).toString().replace(/\/$/,"")}export function craftDevCommand(port,options={}){const command=[resolveCraftBinary(options.craftBin),...options.htmlFile?["--html-file",options.htmlFile]:[resolveDevWindowUrl(port,options)],"--title",options.title||"Stacks","--width",String(options.width||1400),"--height",String(options.height||900)];if(options.hotReload!==false)command.push("--hot-reload");if(options.devTools===false)command.push("--no-devtools");if(options.darkMode)command.push("--dark");if(options.systemTray)command.push("--system-tray");if(options.hideDockIcon)command.push("--hide-dock-icon");if(options.menubarOnly)command.push("--menubar-only");if(options.trayPopover)command.push("--tray-popover");return command}export function createUpdateManifestUrl(baseUrl,channel="stable"){if(!/^[a-z0-9-]+$/i.test(channel))throw new Error("Update channel may only contain letters, numbers, and hyphens");return new URL(`/desktop/updates/${channel}.json`,/^https?:\/\//.test(baseUrl)?baseUrl:`https://${baseUrl}`).toString()}async function launchCraft(command){const process=Bun.spawn(command,{stdin:"inherit",stdout:"inherit",stderr:"inherit"});process.unref()}export async function openDevWindow(port,options={},launcher=launchCraft){await launcher(craftDevCommand(port,options));return true}export const BUN_EXECUTABLE_MARKER="---- Bun!";const MARKER_SEARCH_BYTES=8*1024*1024;const RUNTIME_SIZE_FLOOR=40*1024*1024;const MACH_O_MAGIC=new Set([4277009102,3472551422,4277009103,3489328638,3405691582,3199925962]);export function isMachO(path){try{const fd=openSync(path,"r");try{const head=Buffer.alloc(4);if(readSync(fd,head,0,4,0)<4)return false;return MACH_O_MAGIC.has(head.readUInt32BE(0))}finally{closeSync(fd)}}catch{return false}}export function bundleDirectoryFor(path){return isMachO(path)?"MacOS":"Resources"}export function desktopAppVersion(options={}){const override=options.override?.trim();if(override)return override;const declared=typeof options.declared==="string"?options.declared.trim():"";return declared||"0.0.0"}export function dmgVolumeName(options){const override=options.override?.trim();if(override)return override;const appName=options.appName.trim();const version=options.version?.trim();return version?`${appName} ${version}`:`${appName} Installer`}export function notarytoolAuthArgs(credentials){return"profile"in credentials?["--keychain-profile",credentials.profile]:["--key",credentials.keyPath,"--key-id",credentials.keyId,"--issuer",credentials.issuerId]}export function notarizationOutcome(report,exitCode){const status=report.match(/status: (\w[\w ]*)/g)?.pop()?.replace("status: ","").trim();const id=report.match(/id: ([0-9a-f-]{36})/)?.[1];return{accepted:exitCode===0&&status==="Accepted",status,id}}export function developerIdProblem(codesignReport){if(/code object is not signed/.test(codesignReport)||/Signature=adhoc/.test(codesignReport))return"it is not signed with a certificate. Pass a Developer ID Application identity with --signing-identity.";const authority=/^Authority=(.+)$/m.exec(codesignReport)?.[1];if(!authority?.startsWith("Developer ID Application:"))return`it is signed by ${authority?`"${authority}"`:"an unknown identity"}, not a Developer ID Application certificate.`;if(!/flags=0x[0-9a-f]+\([^)]*runtime[^)]*\)/.test(codesignReport))return"it is not signed with the hardened runtime.";if(!/^Timestamp=/m.test(codesignReport))return"its signature has no secure timestamp.";return}function resolveNotary(flags,env){const profile=supplied(flags.notaryProfile)??supplied(env.DESKTOP_NOTARY_PROFILE);if(profile)return{profile};const requested=flags.notarize===true||["1","true","yes"].includes(supplied(env.DESKTOP_NOTARIZE)?.toLowerCase()??"");if(!requested)return;const keyId=supplied(flags.apiKeyId)??supplied(env.APP_STORE_CONNECT_API_KEY_ID);const issuerId=supplied(flags.apiIssuerId)??supplied(env.APP_STORE_CONNECT_API_ISSUER_ID);const keyPath=supplied(flags.apiKeyPath)??supplied(env.APP_STORE_CONNECT_API_KEY_PATH);const keyPem=supplied(env.APP_STORE_CONNECT_API_KEY)?.replaceAll("\\n",`
40
40
  `);const missing=[!keyId&&"APP_STORE_CONNECT_API_KEY_ID (--api-key-id)",!issuerId&&"APP_STORE_CONNECT_API_ISSUER_ID (--api-issuer-id)",!keyPath&&!keyPem&&"APP_STORE_CONNECT_API_KEY_PATH (--api-key-path) or APP_STORE_CONNECT_API_KEY"].filter(Boolean);if(missing.length||!keyId||!issuerId)throw new Error(`Notarizing needs a keychain profile (--notary-profile or DESKTOP_NOTARY_PROFILE) or an App Store Connect API key. Missing: ${missing.join(", ")}.`);if(keyPath)return{keyId,issuerId,keyPath};if(!keyPem.includes("-----BEGIN PRIVATE KEY-----"))throw new Error("APP_STORE_CONNECT_API_KEY must hold the PEM text of the .p8 key.");return{keyId,issuerId,keyPem}}function supplied(value){if(typeof value!=="string")return;const trimmed=value.trim();return trimmed||undefined}export function resolveDmgPackaging(inputs={}){const flags=inputs.flags??{};const env=inputs.env??{};const appName=supplied(flags.appName)??supplied(env.DESKTOP_APP_NAME)??supplied(inputs.manifestTitle)??supplied(env.APP_NAME)??"Stacks";const version=desktopAppVersion({override:supplied(flags.appVersion)??supplied(env.DESKTOP_APP_VERSION),declared:inputs.declaredVersion});const bundleId=supplied(flags.bundleId)??supplied(env.DESKTOP_BUNDLE_ID)??`sh.stacks.${appName.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`;return{appName,bundleId,version,volumeName:dmgVolumeName({appName,version,override:supplied(flags.volumeName)??supplied(env.DESKTOP_VOLUME_NAME)}),signingIdentity:supplied(flags.signingIdentity)??supplied(env.DESKTOP_SIGNING_IDENTITY),notaryProfile:supplied(flags.notaryProfile)??supplied(env.DESKTOP_NOTARY_PROFILE),notary:resolveNotary(flags,env)}}export function codesignArgs(options){return["codesign","--force",options.identity==="-"?"--timestamp=none":"--timestamp","--options","runtime",...options.entitlements?["--entitlements",options.entitlements]:[],"--sign",options.identity,options.target]}export function looksLikeBunExecutable(path,read=readTail){const file=read(path);if(!file||file.size<RUNTIME_SIZE_FLOOR)return false;return file.tail.includes(BUN_EXECUTABLE_MARKER)}function readTail(path){try{const{size}=statSync(path);if(size<RUNTIME_SIZE_FLOOR)return{size,tail:""};const fd=openSync(path,"r");try{const length=Math.min(MARKER_SEARCH_BYTES,size);const buffer=Buffer.alloc(length);readSync(fd,buffer,0,length,size-length);return{size,tail:buffer.toString("latin1")}}finally{closeSync(fd)}}catch{return null}}export function describeRuntimeDuplication(runtimes){if(runtimes.length<2)return null;const sorted=[...runtimes].sort((a,b)=>b.bytes-a.bytes);const duplicated=sorted.slice(1);const wasted=duplicated.length*RUNTIME_SIZE_FLOOR;const names=sorted.map((r)=>`${r.name} (${(r.bytes/1024/1024).toFixed(1)} MB)`).join(", ");return`This bundle ships ${runtimes.length} Bun-compiled executables: ${names}. `+`Each embeds a full copy of the Bun runtime, so at least ${(wasted/1024/1024).toFixed(0)} MB of the bundle is the same runtime repeated. `+`Compiling one binary that dispatches on a subcommand — \`MyApp agent\`, \`MyApp worker\` — keeps the helpers as separate processes and pays for the runtime once.`}
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.640",
5
+ "version": "0.75.647",
6
6
  "description": "Build and launch Craft desktop applications for Stacks",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -73,17 +73,17 @@
73
73
  "prepublishOnly": "bun run build"
74
74
  },
75
75
  "dependencies": {
76
- "@stacksjs/config": "0.75.640",
77
- "@stacksjs/router": "0.75.640",
78
- "@stacksjs/server": "0.75.640",
79
- "@stacksjs/storage": "0.75.640",
76
+ "@stacksjs/config": "0.75.647",
77
+ "@stacksjs/router": "0.75.647",
78
+ "@stacksjs/server": "0.75.647",
79
+ "@stacksjs/storage": "0.75.647",
80
80
  "craft-native": ">=0.0.505"
81
81
  },
82
82
  "peerDependencies": {
83
- "@stacksjs/config": "0.75.640",
84
- "@stacksjs/router": "0.75.640",
85
- "@stacksjs/server": "0.75.640",
86
- "@stacksjs/storage": "0.75.640"
83
+ "@stacksjs/config": "0.75.647",
84
+ "@stacksjs/router": "0.75.647",
85
+ "@stacksjs/server": "0.75.647",
86
+ "@stacksjs/storage": "0.75.647"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@stacksjs/config": {
@@ -100,7 +100,7 @@
100
100
  }
101
101
  },
102
102
  "devDependencies": {
103
- "@stacksjs/build": "0.75.640",
103
+ "@stacksjs/build": "0.75.647",
104
104
  "better-dx": "^0.2.39"
105
105
  }
106
106
  }