Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
feat: accept macOS Icon Composer .icon files (#1433)
Adam Siwiec9ebd7e036f95
diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.tsindex 0990d706..5fb6687c 100644--- a/bin/helpers/cli-program.ts+++ b/bin/helpers/cli-program.ts@@ -26,7 +26,11 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with'Application identifier / bundle ID',).hideHelp(),)- .option('--icon <string>', 'Application icon', DEFAULT.icon)+ .option(+ '--icon <string>',+ 'Application icon (.icns / .icon on macOS, .ico on Windows, .png on Linux)',+ DEFAULT.icon,+ ).option('--width <number>','Window width',diff --git a/bin/helpers/icon-composer.ts b/bin/helpers/icon-composer.tsnew file mode 100644index 00000000..3cbcf34a--- /dev/null+++ b/bin/helpers/icon-composer.ts@@ -0,0 +1,295 @@+import path from 'path';+import fsExtra from 'fs-extra';+import { execa, type ExecaError } from 'execa';+import { dir } from 'tmp-promise';++import logger from '@/options/logger';++const ACTOOL_VERSION_ARGS = [+ '--version',+ '--output-format=human-readable-text',+];++const ACTOOL_TIMEOUT_MS = {+ version: 20_000,+ compile: 120_000,+} as const;++export function iconPathExtension(iconPath: string): string {+ return path.extname(iconPath.replace(/[/\\]+$/, '')).toLowerCase();+}++export function isIconComposerUrl(iconUrl: string): boolean {+ try {+ const pathname = new URL(iconUrl).pathname+ .replace(/\/+$/, '')+ .toLowerCase();+ return pathname.endsWith('.icon');+ } catch {+ return iconUrl.replace(/\/+$/, '').toLowerCase().endsWith('.icon');+ }+}++export async function isMacOSIconComposerPackage(+ iconPath: string,+): Promise<boolean> {+ try {+ const stat = await fsExtra.stat(iconPath);+ if (!stat.isDirectory()) {+ return false;+ }+ return await fsExtra.pathExists(path.join(iconPath, 'icon.json'));+ } catch {+ return false;+ }+}++/** Parse `actool --version --output-format=human-readable-text`, matching Tauri. */+export function parseActoolVersion(output: string): string | null {+ for (const rawLine of output.split('\n')) {+ const line = rawLine.trim();+ if (line.startsWith('short-bundle-version:')) {+ const version = line.slice('short-bundle-version:'.length).trim();+ return version || null;+ }+ }+ return null;+}++export function actoolMajorVersion(version: string): number | null {+ const major = Number.parseInt(version.split('.')[0] ?? '', 10);+ return Number.isFinite(major) ? major : null;+}++function isCommandMissing(error: unknown): boolean {+ if (!error || typeof error !== 'object') {+ return false;+ }+ const execaError = error as Partial<ExecaError>;+ return (+ execaError.code === 'ENOENT' ||+ execaError.exitCode === 127 ||+ (typeof execaError.stderr === 'string' &&+ /not found|No such file/i.test(execaError.stderr))+ );+}++async function runActool(args: string[], timeout: number) {+ const options = { stdin: 'ignore' as const, reject: false, timeout };+ const attempts: Array<{ file: string; argv: string[] }> = [+ { file: 'xcrun', argv: ['actool', ...args] },+ { file: 'actool', argv: args },+ ];++ for (const attempt of attempts) {+ try {+ const result = await execa(attempt.file, attempt.argv, options);+ if (isCommandMissing(result)) {+ continue;+ }+ return result;+ } catch (error) {+ if (isCommandMissing(error)) {+ continue;+ }+ throw error;+ }+ }+ return null;+}++export async function getActoolMajorVersion(): Promise<number | null> {+ const result = await runActool(+ ACTOOL_VERSION_ARGS,+ ACTOOL_TIMEOUT_MS.version,+ );+ if (!result) {+ return null;+ }+ const version = parseActoolVersion(`${result.stdout}\n${result.stderr}`);+ return version ? actoolMajorVersion(version) : null;+}++export async function warnIfActoolUnavailable(): Promise<number | null> {+ const major = await getActoolMajorVersion();+ if (major === null) {+ logger.warn(+ '✼ Could not find actool (needs Xcode 26+). Liquid Glass icons will not be compiled; the .icns fallback will be used.',+ );+ return null;+ }+ if (major < 26) {+ logger.warn(+ `✼ actool ${major} is too old for Icon Composer .icon packages (need 26+ / Xcode 26). The .icns fallback will be used.`,+ );+ }+ return major;+}++async function compileAssetsCar(+ iconPackagePath: string,+ destPath: string,+): Promise<boolean> {+ const { path: tempRoot, cleanup } = await dir({ unsafeCleanup: true });+ try {+ const iconDest = path.join(tempRoot, 'Icon.icon');+ const outputPath = path.join(tempRoot, 'out');+ await fsExtra.copy(iconPackagePath, iconDest);+ await fsExtra.ensureDir(outputPath);++ // Flags match tauri-bundler 2.12.4 (crates/tauri-bundler/src/bundle/macos/icon.rs).+ // stdin is closed so we do not inherit Node's fd 0 (tauri-apps/tauri#15315, #15991).+ const args = [+ iconDest,+ '--compile',+ outputPath,+ '--output-format',+ 'human-readable-text',+ '--notices',+ '--warnings',+ '--output-partial-info-plist',+ path.join(outputPath, 'assetcatalog_generated_info.plist'),+ '--app-icon',+ 'Icon',+ '--include-all-app-icons',+ '--accent-color',+ 'AccentColor',+ '--enable-on-demand-resources',+ 'NO',+ '--development-region',+ 'en',+ '--target-device',+ 'mac',+ '--minimum-deployment-target',+ '26.0',+ '--platform',+ 'macosx',+ ];++ await runActool(args, ACTOOL_TIMEOUT_MS.compile);++ const assetsCar = path.join(outputPath, 'Assets.car');+ if (!(await fsExtra.pathExists(assetsCar))) {+ return false;+ }+ // Copy out before the temp directory is removed in `finally`.+ await fsExtra.ensureDir(path.dirname(destPath));+ await fsExtra.copy(assetsCar, destPath);+ return true;+ } finally {+ await cleanup();+ }+}++/**+ * Precompile an Icon Composer package to Assets.car so Tauri's bundler+ * does not have to spawn actool itself (a known hang/crash on Xcode 27).+ * Returns the destination path of Assets.car, or null if compilation failed.+ */+export async function precompileIconComposerAssets(+ iconPackagePath: string,+ destIconsDir: string,+): Promise<string | null> {+ const major = await getActoolMajorVersion();+ if (major === null || major < 26) {+ return null;+ }++ await fsExtra.ensureDir(destIconsDir);+ const dest = path.join(destIconsDir, 'Assets.car');++ if (await compileAssetsCar(iconPackagePath, dest)) {+ return dest;+ }++ // Xcode 27.1+ sometimes leaves ibtoold in a bad state (tauri-apps/tauri#16386).+ logger.warn(+ '✼ actool failed to compile the .icon package; retrying after stopping ibtoold (tauri-apps/tauri#16386).',+ );+ await execa('pkill', ['-x', 'ibtoold'], {+ stdin: 'ignore',+ reject: false,+ });++ if (await compileAssetsCar(iconPackagePath, dest)) {+ return dest;+ }++ logger.warn(+ '✼ Could not precompile Assets.car. The .icon will be passed to Tauri, which may hit the same actool issue (tauri-apps/tauri#15315, #16386). The .icns fallback stays in bundle.icon.',+ );+ return null;+}++export type DarwinIconComposerResult = {+ bundleIcon: string[];+};++/**+ * Copy a valid .icon package (and an .icns fallback) into src-tauri/icons+ * and return the paths to set on tauriConf.bundle.icon.+ */+export async function applyDarwinIconComposerPackage(options: {+ sourceIconPath: string;+ destIconsDir: string;+ safeAppName: string;+ defaultIcnsPath: string;+}): Promise<DarwinIconComposerResult> {+ const { sourceIconPath, destIconsDir, safeAppName, defaultIcnsPath } =+ options;+ await fsExtra.ensureDir(destIconsDir);++ const destIconPackage = path.join(destIconsDir, `${safeAppName}.icon`);+ if (path.resolve(sourceIconPath) !== path.resolve(destIconPackage)) {+ await fsExtra.copy(sourceIconPath, destIconPackage);+ }++ const normalizedSource = sourceIconPath.replace(/[/\\]+$/, '');+ const siblingIcns = path.join(+ path.dirname(normalizedSource),+ `${path.parse(normalizedSource).name}.icns`,+ );+ const destIcns = path.join(destIconsDir, `${safeAppName}.icns`);++ let fallbackSource: string | null = null;+ if (await fsExtra.pathExists(siblingIcns)) {+ const stat = await fsExtra.stat(siblingIcns);+ if (stat.isFile()) {+ fallbackSource = siblingIcns;+ }+ }+ if (!fallbackSource && (await fsExtra.pathExists(defaultIcnsPath))) {+ fallbackSource = defaultIcnsPath;+ }++ let hasIcns = false;+ if (fallbackSource) {+ if (path.resolve(fallbackSource) !== path.resolve(destIcns)) {+ await fsExtra.copy(fallbackSource, destIcns);+ }+ hasIcns = await fsExtra.pathExists(destIcns);+ }+ if (!hasIcns) {+ logger.warn(+ '✼ No .icns fallback found next to the .icon package, and Pake default icon.icns is missing. Older macOS will not have a static icon.',+ );+ }++ await warnIfActoolUnavailable();+ const compiledCar = await precompileIconComposerAssets(+ destIconPackage,+ destIconsDir,+ );++ const bundleIcon: string[] = [];+ if (compiledCar) {+ logger.info('✼ Precompiled Assets.car from the Icon Composer package.');+ bundleIcon.push('icons/Assets.car');+ } else {+ bundleIcon.push(`icons/${safeAppName}.icon`);+ }+ if (hasIcns) {+ bundleIcon.push(`icons/${safeAppName}.icns`);+ }+ return { bundleIcon };+}diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex 426b3153..15965aa5 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -23,6 +23,11 @@ import {} from '@/utils/dir';import { PakeError } from '@/utils/error';import { LINUX_TARGET_TYPES, resolveLinuxBundleTargets } from '@/utils/targets';+import {+ applyDarwinIconComposerPackage,+ iconPathExtension,+ isMacOSIconComposerPackage,+} from '@/helpers/icon-composer';/*** Pure transform from CLI options to the window-config slice that gets@@ -372,7 +377,7 @@ export async function resolveSystemTrayIconPath(}}-async function mergeIcons(+export async function mergeIcons(options: PakeAppOptions,name: string,tauriConf: PakeTauriConfig,@@ -396,7 +401,7 @@ async function mergeIcons(fileExt: '.icns',path: `icons/${safeAppName}.icns`,defaultIcon: 'icons/icon.icns',- message: 'macOS icon must be .icns type.',+ message: 'macOS icon must be .icns or an Icon Composer .icon package.',},};@@ -407,9 +412,34 @@ async function mergeIcons(if (exists) {let updateIconPath = true;- const customIconExt = path.extname(resolvedIconPath).toLowerCase();-- if (customIconExt !== iconInfo.fileExt) {+ let composerIconApplied = false;+ const customIconExt = iconPathExtension(resolvedIconPath);++ if (platform === 'darwin' && customIconExt === '.icon') {+ if (!(await isMacOSIconComposerPackage(resolvedIconPath))) {+ updateIconPath = false;+ logger.warn(+ `✼ macOS .icon must be an Icon Composer package (a directory containing icon.json), but you gave ${resolvedIconPath}`,+ );+ tauriConf.bundle.icon = [iconInfo.defaultIcon];+ } else {+ const destIconsDir = path.join(npmDirectory, 'src-tauri/icons');+ const defaultIcnsPath = path.join(+ npmDirectory,+ 'src-tauri',+ iconInfo.defaultIcon,+ );+ const { bundleIcon } = await applyDarwinIconComposerPackage({+ sourceIconPath: resolvedIconPath,+ destIconsDir,+ safeAppName,+ defaultIcnsPath,+ });+ tauriConf.bundle.icon = bundleIcon;+ tauriConf.bundle.resources = bundleIcon;+ composerIconApplied = true;+ }+ } else if (customIconExt !== iconInfo.fileExt) {updateIconPath = false;logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);tauriConf.bundle.icon = [iconInfo.defaultIcon];@@ -436,10 +466,12 @@ async function mergeIcons(}}- if (updateIconPath) {- tauriConf.bundle.icon = [iconInfo.path];- } else {- logger.warn(`✼ Icon will remain as default.`);+ if (!composerIconApplied) {+ if (updateIconPath) {+ tauriConf.bundle.icon = [iconInfo.path];+ } else {+ logger.warn(`✼ Icon will remain as default.`);+ }}} else {logger.warn(diff --git a/bin/options/icon.ts b/bin/options/icon.tsindex 4eeed823..387aecbb 100644--- a/bin/options/icon.ts+++ b/bin/options/icon.ts@@ -22,6 +22,11 @@ import {buildIcoFromPngBuffers,WIN_STANDARD_ICO_SIZES,} from '@/utils/ico';+import {+ iconPathExtension,+ isIconComposerUrl,+ isMacOSIconComposerPackage,+} from '@/helpers/icon-composer';type PlatformIconConfig = {format: string;@@ -44,6 +49,7 @@ const ICON_CONFIG = {'jpg','webp','icns',+ 'icon','svg',] as const,transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },@@ -360,14 +366,30 @@ async function isLinuxBundleIconReady(iconPath: string): Promise<boolean> {/*** Processes downloaded or local icon for platform-specific format*/-async function processIcon(+export async function processIcon(iconPath: string,appName: string,): Promise<string | null> {if (!iconPath || !appName) return iconPath;+ const ext = iconPathExtension(iconPath);+ if (ext === '.icon') {+ if (!IS_WIN && !IS_LINUX) {+ if (await isMacOSIconComposerPackage(iconPath)) {+ return iconPath;+ }+ logger.warn(+ '✼ --icon .icon must be an Icon Composer package (a directory containing icon.json).',+ );+ return null;+ }+ logger.warn(+ '✼ Icon Composer .icon packages are only used on macOS. This platform will use a converted or default icon.',+ );+ return null;+ }+// Check if already in correct platform format- const ext = path.extname(iconPath).toLowerCase();const isCorrectFormat =(IS_WIN && ext === '.ico') ||(IS_LINUX && (await isLinuxBundleIconReady(iconPath))) ||@@ -446,6 +468,12 @@ export async function handleIcon(// Handle custom icon (local file or remote URL)if (options.icon) {if (options.icon.startsWith('http')) {+ if (isIconComposerUrl(options.icon)) {+ logger.warn(+ '✼ Icon Composer .icon packages cannot be downloaded from a URL; pass a local path. HTTP --icon is for ordinary images and .icns files.',+ );+ return '';+ }const downloadedPath = await downloadIcon(options.icon);if (downloadedPath) {const result = await processIcon(downloadedPath, options.name || '');@@ -456,6 +484,9 @@ export async function handleIcon(// Local file pathconst resolvedPath = path.resolve(options.icon);const result = await processIcon(resolvedPath, options.name || '');+ if (iconPathExtension(resolvedPath) === '.icon' && !result) {+ return '';+ }return result || resolvedPath;}@@ -677,6 +708,15 @@ export async function downloadIcon(showSpinner = true,customTimeout?: number,): Promise<string | null> {+ if (isIconComposerUrl(iconUrl)) {+ if (showSpinner) {+ logger.warn(+ '✼ Icon Composer .icon packages cannot be downloaded from a URL; pass a local path.',+ );+ }+ return null;+ }+const controller = new AbortController();const timeoutId = setTimeout(() => {controller.abort();diff --git a/dist/cli.js b/dist/cli.jsindex 83fc0a3e..3e3e92af 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -78,7 +78,7 @@ var exports$1 = "./dist/cli.js";var license = "GPL-3.0-or-later";var dependencies = {"@tauri-apps/api": "~2.10.1",- "@tauri-apps/cli": "^2.10.0",+ "@tauri-apps/cli": "^2.12.4",chalk: "^5.6.2",commander: "^14.0.3",execa: "^9.6.1",@@ -934,6 +934,233 @@ function resolveLinuxBundleTargets(targets) {return { bundleTargets, hasValidTarget: requested.length > 0 };}+const ACTOOL_VERSION_ARGS = [+ '--version',+ '--output-format=human-readable-text',+];+const ACTOOL_TIMEOUT_MS = {+ version: 20000,+ compile: 120000,+};+function iconPathExtension(iconPath) {+ return path.extname(iconPath.replace(/[/\\]+$/, '')).toLowerCase();+}+function isIconComposerUrl(iconUrl) {+ try {+ const pathname = new URL(iconUrl).pathname+ .replace(/\/+$/, '')+ .toLowerCase();+ return pathname.endsWith('.icon');+ }+ catch {+ return iconUrl.replace(/\/+$/, '').toLowerCase().endsWith('.icon');+ }+}+async function isMacOSIconComposerPackage(iconPath) {+ try {+ const stat = await fsExtra.stat(iconPath);+ if (!stat.isDirectory()) {+ return false;+ }+ return await fsExtra.pathExists(path.join(iconPath, 'icon.json'));+ }+ catch {+ return false;+ }+}+/** Parse `actool --version --output-format=human-readable-text`, matching Tauri. */+function parseActoolVersion(output) {+ for (const rawLine of output.split('\n')) {+ const line = rawLine.trim();+ if (line.startsWith('short-bundle-version:')) {+ const version = line.slice('short-bundle-version:'.length).trim();+ return version || null;+ }+ }+ return null;+}+function actoolMajorVersion(version) {+ const major = Number.parseInt(version.split('.')[0] ?? '', 10);+ return Number.isFinite(major) ? major : null;+}+function isCommandMissing(error) {+ if (!error || typeof error !== 'object') {+ return false;+ }+ const execaError = error;+ return (execaError.code === 'ENOENT' ||+ execaError.exitCode === 127 ||+ (typeof execaError.stderr === 'string' &&+ /not found|No such file/i.test(execaError.stderr)));+}+async function runActool(args, timeout) {+ const options = { stdin: 'ignore', reject: false, timeout };+ const attempts = [+ { file: 'xcrun', argv: ['actool', ...args] },+ { file: 'actool', argv: args },+ ];+ for (const attempt of attempts) {+ try {+ const result = await execa(attempt.file, attempt.argv, options);+ if (isCommandMissing(result)) {+ continue;+ }+ return result;+ }+ catch (error) {+ if (isCommandMissing(error)) {+ continue;+ }+ throw error;+ }+ }+ return null;+}+async function getActoolMajorVersion() {+ const result = await runActool(ACTOOL_VERSION_ARGS, ACTOOL_TIMEOUT_MS.version);+ if (!result) {+ return null;+ }+ const version = parseActoolVersion(`${result.stdout}\n${result.stderr}`);+ return version ? actoolMajorVersion(version) : null;+}+async function warnIfActoolUnavailable() {+ const major = await getActoolMajorVersion();+ if (major === null) {+ logger.warn('✼ Could not find actool (needs Xcode 26+). Liquid Glass icons will not be compiled; the .icns fallback will be used.');+ return null;+ }+ if (major < 26) {+ logger.warn(`✼ actool ${major} is too old for Icon Composer .icon packages (need 26+ / Xcode 26). The .icns fallback will be used.`);+ }+ return major;+}+async function compileAssetsCar(iconPackagePath, destPath) {+ const { path: tempRoot, cleanup } = await dir({ unsafeCleanup: true });+ try {+ const iconDest = path.join(tempRoot, 'Icon.icon');+ const outputPath = path.join(tempRoot, 'out');+ await fsExtra.copy(iconPackagePath, iconDest);+ await fsExtra.ensureDir(outputPath);+ // Flags match tauri-bundler 2.12.4 (crates/tauri-bundler/src/bundle/macos/icon.rs).+ // stdin is closed so we do not inherit Node's fd 0 (tauri-apps/tauri#15315, #15991).+ const args = [+ iconDest,+ '--compile',+ outputPath,+ '--output-format',+ 'human-readable-text',+ '--notices',+ '--warnings',+ '--output-partial-info-plist',+ path.join(outputPath, 'assetcatalog_generated_info.plist'),+ '--app-icon',+ 'Icon',+ '--include-all-app-icons',+ '--accent-color',+ 'AccentColor',+ '--enable-on-demand-resources',+ 'NO',+ '--development-region',+ 'en',+ '--target-device',+ 'mac',+ '--minimum-deployment-target',+ '26.0',+ '--platform',+ 'macosx',+ ];+ await runActool(args, ACTOOL_TIMEOUT_MS.compile);+ const assetsCar = path.join(outputPath, 'Assets.car');+ if (!(await fsExtra.pathExists(assetsCar))) {+ return false;+ }+ // Copy out before the temp directory is removed in `finally`.+ await fsExtra.ensureDir(path.dirname(destPath));+ await fsExtra.copy(assetsCar, destPath);+ return true;+ }+ finally {+ await cleanup();+ }+}+/**+ * Precompile an Icon Composer package to Assets.car so Tauri's bundler+ * does not have to spawn actool itself (a known hang/crash on Xcode 27).+ * Returns the destination path of Assets.car, or null if compilation failed.+ */+async function precompileIconComposerAssets(iconPackagePath, destIconsDir) {+ const major = await getActoolMajorVersion();+ if (major === null || major < 26) {+ return null;+ }+ await fsExtra.ensureDir(destIconsDir);+ const dest = path.join(destIconsDir, 'Assets.car');+ if (await compileAssetsCar(iconPackagePath, dest)) {+ return dest;+ }+ // Xcode 27.1+ sometimes leaves ibtoold in a bad state (tauri-apps/tauri#16386).+ logger.warn('✼ actool failed to compile the .icon package; retrying after stopping ibtoold (tauri-apps/tauri#16386).');+ await execa('pkill', ['-x', 'ibtoold'], {+ stdin: 'ignore',+ reject: false,+ });+ if (await compileAssetsCar(iconPackagePath, dest)) {+ return dest;+ }+ logger.warn('✼ Could not precompile Assets.car. The .icon will be passed to Tauri, which may hit the same actool issue (tauri-apps/tauri#15315, #16386). The .icns fallback stays in bundle.icon.');+ return null;+}+/**+ * Copy a valid .icon package (and an .icns fallback) into src-tauri/icons+ * and return the paths to set on tauriConf.bundle.icon.+ */+async function applyDarwinIconComposerPackage(options) {+ const { sourceIconPath, destIconsDir, safeAppName, defaultIcnsPath } = options;+ await fsExtra.ensureDir(destIconsDir);+ const destIconPackage = path.join(destIconsDir, `${safeAppName}.icon`);+ if (path.resolve(sourceIconPath) !== path.resolve(destIconPackage)) {+ await fsExtra.copy(sourceIconPath, destIconPackage);+ }+ const normalizedSource = sourceIconPath.replace(/[/\\]+$/, '');+ const siblingIcns = path.join(path.dirname(normalizedSource), `${path.parse(normalizedSource).name}.icns`);+ const destIcns = path.join(destIconsDir, `${safeAppName}.icns`);+ let fallbackSource = null;+ if (await fsExtra.pathExists(siblingIcns)) {+ const stat = await fsExtra.stat(siblingIcns);+ if (stat.isFile()) {+ fallbackSource = siblingIcns;+ }+ }+ if (!fallbackSource && (await fsExtra.pathExists(defaultIcnsPath))) {+ fallbackSource = defaultIcnsPath;+ }+ let hasIcns = false;+ if (fallbackSource) {+ if (path.resolve(fallbackSource) !== path.resolve(destIcns)) {+ await fsExtra.copy(fallbackSource, destIcns);+ }+ hasIcns = await fsExtra.pathExists(destIcns);+ }+ if (!hasIcns) {+ logger.warn('✼ No .icns fallback found next to the .icon package, and Pake default icon.icns is missing. Older macOS will not have a static icon.');+ }+ await warnIfActoolUnavailable();+ const compiledCar = await precompileIconComposerAssets(destIconPackage, destIconsDir);+ const bundleIcon = [];+ if (compiledCar) {+ logger.info('✼ Precompiled Assets.car from the Icon Composer package.');+ bundleIcon.push('icons/Assets.car');+ }+ else {+ bundleIcon.push(`icons/${safeAppName}.icon`);+ }+ if (hasIcns) {+ bundleIcon.push(`icons/${safeAppName}.icns`);+ }+ return { bundleIcon };+}+/*** Pure transform from CLI options to the window-config slice that gets* merged into pake.json. Exposed for snapshot testing so option drift@@ -1209,7 +1436,7 @@ async function mergeIcons(options, name, tauriConf, platform, safeAppName) {fileExt: '.icns',path: `icons/${safeAppName}.icns`,defaultIcon: 'icons/icon.icns',- message: 'macOS icon must be .icns type.',+ message: 'macOS icon must be .icns or an Icon Composer .icon package.',},};const iconInfo = platformIconMap[platform];@@ -1217,8 +1444,29 @@ async function mergeIcons(options, name, tauriConf, platform, safeAppName) {const exists = resolvedIconPath && (await fsExtra.pathExists(resolvedIconPath));if (exists) {let updateIconPath = true;- const customIconExt = path.extname(resolvedIconPath).toLowerCase();- if (customIconExt !== iconInfo.fileExt) {+ let composerIconApplied = false;+ const customIconExt = iconPathExtension(resolvedIconPath);+ if (platform === 'darwin' && customIconExt === '.icon') {+ if (!(await isMacOSIconComposerPackage(resolvedIconPath))) {+ updateIconPath = false;+ logger.warn(`✼ macOS .icon must be an Icon Composer package (a directory containing icon.json), but you gave ${resolvedIconPath}`);+ tauriConf.bundle.icon = [iconInfo.defaultIcon];+ }+ else {+ const destIconsDir = path.join(npmDirectory, 'src-tauri/icons');+ const defaultIcnsPath = path.join(npmDirectory, 'src-tauri', iconInfo.defaultIcon);+ const { bundleIcon } = await applyDarwinIconComposerPackage({+ sourceIconPath: resolvedIconPath,+ destIconsDir,+ safeAppName,+ defaultIcnsPath,+ });+ tauriConf.bundle.icon = bundleIcon;+ tauriConf.bundle.resources = bundleIcon;+ composerIconApplied = true;+ }+ }+ else if (customIconExt !== iconInfo.fileExt) {updateIconPath = false;logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);tauriConf.bundle.icon = [iconInfo.defaultIcon];@@ -1239,11 +1487,13 @@ async function mergeIcons(options, name, tauriConf, platform, safeAppName) {}}}- if (updateIconPath) {- tauriConf.bundle.icon = [iconInfo.path];- }- else {- logger.warn(`✼ Icon will remain as default.`);+ if (!composerIconApplied) {+ if (updateIconPath) {+ tauriConf.bundle.icon = [iconInfo.path];+ }+ else {+ logger.warn(`✼ Icon will remain as default.`);+ }}}else {@@ -2863,6 +3113,7 @@ const ICON_CONFIG = {'jpg','webp','icns',+ 'icon','svg',],transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },@@ -3112,8 +3363,19 @@ async function isLinuxBundleIconReady(iconPath) {async function processIcon(iconPath, appName) {if (!iconPath || !appName)return iconPath;+ const ext = iconPathExtension(iconPath);+ if (ext === '.icon') {+ if (!IS_WIN && !IS_LINUX) {+ if (await isMacOSIconComposerPackage(iconPath)) {+ return iconPath;+ }+ logger.warn('✼ --icon .icon must be an Icon Composer package (a directory containing icon.json).');+ return null;+ }+ logger.warn('✼ Icon Composer .icon packages are only used on macOS. This platform will use a converted or default icon.');+ return null;+ }// Check if already in correct platform format- const ext = path.extname(iconPath).toLowerCase();const isCorrectFormat = (IS_WIN && ext === '.ico') ||(IS_LINUX && (await isLinuxBundleIconReady(iconPath))) ||(!IS_WIN && !IS_LINUX && ext === '.icns');@@ -3173,6 +3435,10 @@ async function handleIcon(options, url) {// Handle custom icon (local file or remote URL)if (options.icon) {if (options.icon.startsWith('http')) {+ if (isIconComposerUrl(options.icon)) {+ logger.warn('✼ Icon Composer .icon packages cannot be downloaded from a URL; pass a local path. HTTP --icon is for ordinary images and .icns files.');+ return '';+ }const downloadedPath = await downloadIcon(options.icon);if (downloadedPath) {const result = await processIcon(downloadedPath, options.name || '');@@ -3184,6 +3450,9 @@ async function handleIcon(options, url) {// Local file pathconst resolvedPath = path.resolve(options.icon);const result = await processIcon(resolvedPath, options.name || '');+ if (iconPathExtension(resolvedPath) === '.icon' && !result) {+ return '';+ }return result || resolvedPath;}// Check for existing local icon before downloading@@ -3335,6 +3604,12 @@ async function tryGetFavicon(url, appName) {* Downloads icon from URL*/async function downloadIcon(iconUrl, showSpinner = true, customTimeout) {+ if (isIconComposerUrl(iconUrl)) {+ if (showSpinner) {+ logger.warn('✼ Icon Composer .icon packages cannot be downloaded from a URL; pass a local path.');+ }+ return null;+ }const controller = new AbortController();const timeoutId = setTimeout(() => {controller.abort();@@ -3653,7 +3928,7 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with.argument('[url]', 'The web URL you want to package', validateUrlInput).option('--name <string>', 'Application name').addOption(new Option('--identifier <string>', 'Application identifier / bundle ID').hideHelp())- .option('--icon <string>', 'Application icon', DEFAULT_PAKE_OPTIONS.icon)+ .option('--icon <string>', 'Application icon (.icns / .icon on macOS, .ico on Windows, .png on Linux)', DEFAULT_PAKE_OPTIONS.icon).option('--width <number>', 'Window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width).option('--height <number>', 'Window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height).option('--use-local-file', 'Use local file packaging', DEFAULT_PAKE_OPTIONS.useLocalFile)diff --git a/docs/advanced-usage.md b/docs/advanced-usage.mdindex da7588ca..41e2d35c 100644--- a/docs/advanced-usage.md+++ b/docs/advanced-usage.md@@ -161,7 +161,7 @@ pake https://github.com --name "GitHub Work" --identifier com.example.github.wor│ │ ├── app/ # Core modules (window, menu, shortcuts, etc.)│ │ ├── inject/ # Injected scripts (CSS, JS, event listeners)│ │ └── lib.rs # Application entry point-│ ├── icons/ # macOS icons (.icns)+│ ├── icons/ # macOS icons (.icns, Icon Composer .icon)│ ├── png/ # Windows/Linux icons (.ico, .png)│ ├── pake.json # Runtime configuration template│ └── tauri.*.conf.json # Platform-specific configsdiff --git a/docs/advanced-usage_CN.md b/docs/advanced-usage_CN.mdindex fad00b77..a3cbf27a 100644--- a/docs/advanced-usage_CN.md+++ b/docs/advanced-usage_CN.md@@ -161,7 +161,7 @@ pake https://github.com --name "GitHub Work" --identifier com.example.github.wor│ │ ├── app/ # 核心模块(窗口、菜单、快捷键等)│ │ ├── inject/ # 网页注入脚本(CSS、JS、事件监听)│ │ └── lib.rs # 应用入口-│ ├── icons/ # macOS 图标 (.icns)+│ ├── icons/ # macOS 图标 (.icns、Icon Composer .icon)│ ├── png/ # Windows/Linux 图标 (.ico, .png)│ ├── pake.json # 运行时配置模板│ └── tauri.*.conf.json # 平台特定配置diff --git a/docs/cli-usage.md b/docs/cli-usage.mdindex 625be1f0..a43e7bd2 100644--- a/docs/cli-usage.md+++ b/docs/cli-usage.md@@ -126,10 +126,14 @@ Set the bundle identifier explicitly. By default Pake derives `com.pake.a<hash>`Supports both local and remote files, automatically converts to platform-specific formats:-- macOS: `.icns` format+- macOS: `.icns`, or a local Icon Composer `.icon` package (a directory containing `icon.json`)- Windows: `.ico` format- Linux: `.png` format+If you pass a `.icon`, also put a sibling `.icns` of the same basename for macOS versions before 26. If there isn't one, Pake uses its default `icon.icns`. A `.icon` is a local package, not a URL. Compiling Liquid Glass appearances needs Xcode 26+ (`actool` short version 26 or newer) on the machine that runs `pake`. If `actool` is missing or too old, Pake warns and uses the `.icns` fallback.++On some Xcode 27 setups, Tauri's bundler fails when it runs `actool` (tauri-apps/tauri#15315, #16386). Pake tries to precompile `Assets.car` itself first, with stdin closed, and retries once after stopping `ibtoold`. If that fails, the `.icon` is still passed to Tauri, and the `.icns` fallback stays in `bundle.icon`.+```shell--icon <path>@@ -140,6 +144,7 @@ pake https://github.com --name GitHub# With custom icons--icon ./my-icon.png--icon https://cdn.tw93.fun/pake/weekly.icns # Remote icon (.icns for macOS)+--icon ./AppIcon.icon # Local Icon Composer package (macOS)```#### [width]diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.mdindex 2ea625f0..e82a53ee 100644--- a/docs/cli-usage_CN.md+++ b/docs/cli-usage_CN.md@@ -126,10 +126,14 @@ pake ./dist --name MyTool支持本地或远程文件,自动转换为平台所需格式:-- macOS:`.icns` 格式+- macOS:`.icns` 格式,或本地的 Icon Composer `.icon` 包(目录内需有 `icon.json`)- Windows:`.ico` 格式- Linux:`.png` 格式+传入 `.icon` 时,请在同目录放一个同名的 `.icns`,给 macOS 26 以下的系统做回退;没有的话会用 Pake 自带的默认 `icon.icns`。`.icon` 只能是本地包,不能通过 URL 下载。编译 Liquid Glass 外观需要打包机器上有 Xcode 26+(`actool` 主版本不低于 26);找不到或版本过低时,会给出警告并使用 `.icns` 回退。++在部分 Xcode 27 环境里,Tauri 打包过程调用 `actool` 可能失败(tauri-apps/tauri#15315、#16386)。Pake 会先自行预编译 `Assets.car`(关闭 stdin),失败时停掉 `ibtoold` 再试一次;仍失败就把 `.icon` 交给 Tauri,同时保留 `.icns` 回退。+```shell--icon <path>@@ -140,6 +144,7 @@ pake https://github.com --name GitHub# 使用自定义图标--icon ./my-icon.png--icon https://cdn.tw93.fun/pake/weekly.icns # 远程图标(.icns 适用于 macOS)+--icon ./AppIcon.icon # 本地 Icon Composer 包(macOS)```#### [width]diff --git a/docs/faq.md b/docs/faq.mdindex 2210749a..a1b9d4e3 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -387,13 +387,14 @@ Custom icon doesn't appear or shows default icon.Ensure you're using the correct icon format for your platform:-- **macOS**: `.icns` format+- **macOS**: `.icns`, or a local Icon Composer `.icon` package. If you pass a `.icon`, include a sibling `.icns` of the same basename for macOS versions before 26. Compiling the appearance variants needs Xcode 26+ (`actool`). If `actool` is missing, too old, or fails (see tauri-apps/tauri#15315 and #16386 on Xcode 27), the `.icns` fallback is used.- **Windows**: `.ico` format- **Linux**: `.png` format```bash# macOSpake https://example.com --icon ./icon.icns+pake https://example.com --icon ./AppIcon.icon# Windowspake https://example.com --icon ./icon.ico@@ -402,7 +403,7 @@ pake https://example.com --icon ./icon.icopake https://example.com --icon ./icon.png```-Pake can automatically convert icons, but providing the correct format is more reliable.+Pake can automatically convert ordinary image files, but providing the correct format is more reliable. An Icon Composer `.icon` cannot be converted from a PNG and cannot be downloaded from a URL.### Website Features Not Working (Login, Upload, etc.)diff --git a/docs/faq_CN.md b/docs/faq_CN.mdindex 8b5f4afd..138ec3c3 100644--- a/docs/faq_CN.md+++ b/docs/faq_CN.md@@ -385,13 +385,14 @@ pake https://example.com --width 1200 --height 800确保为你的平台使用正确的图标格式:-- **macOS**:`.icns` 格式+- **macOS**:`.icns` 格式,或本地的 Icon Composer `.icon` 包。传入 `.icon` 时,请同时提供同名的 `.icns`,给 macOS 26 以下的系统做回退。编译外观变体需要 Xcode 26+(`actool`)。如果 `actool` 不存在、版本过低,或在 Xcode 27 上失败(见 tauri-apps/tauri#15315、#16386),会使用 `.icns` 回退。- **Windows**:`.ico` 格式- **Linux**:`.png` 格式```bash# macOSpake https://example.com --icon ./icon.icns+pake https://example.com --icon ./AppIcon.icon# Windowspake https://example.com --icon ./icon.ico@@ -400,7 +401,7 @@ pake https://example.com --icon ./icon.icopake https://example.com --icon ./icon.png```-Pake 可以自动转换图标,但提供正确的格式更可靠。+Pake 可以自动转换普通图片,但提供正确的格式更可靠。Icon Composer 的 `.icon` 不能从 PNG 生成,也不能通过 URL 下载。### 网站功能不工作(登录、上传等)diff --git a/docs/getting-started.md b/docs/getting-started.mdindex 3e2e6c1d..6e75cd32 100644--- a/docs/getting-started.md+++ b/docs/getting-started.md@@ -53,7 +53,7 @@ pake https://excalidraw.com --name Excalidraw --width 1400 --height 900 --hide-t- `--width` and `--height` set the starting window size, 1200 by 780 by default.- `--hide-title-bar` gives an immersive window on macOS, with the page running up to the top edge.-- `--icon` takes a local or remote image when the site icon looks poor; [macOSicons](https://macosicons.com/#/) is a good source.+- `--icon` takes a local or remote image when the site icon looks poor; [macOSicons](https://macosicons.com/#/) is a good source. On macOS it also accepts a local Icon Composer `.icon` package; see the [CLI reference](cli-usage.md#icon).- `--show-system-tray` keeps the app in the menu bar or system tray.Every option, with examples, is in the [CLI reference](cli-usage.md).diff --git a/docs/getting-started_CN.md b/docs/getting-started_CN.mdindex 4a526491..164d404c 100644--- a/docs/getting-started_CN.md+++ b/docs/getting-started_CN.md@@ -53,7 +53,7 @@ pake https://excalidraw.com --name Excalidraw --width 1400 --height 900 --hide-t- `--width` 和 `--height` 设置初始窗口大小,默认是 1200 乘 780。- `--hide-title-bar` 在 macOS 上隐藏标题栏,页面一直铺到窗口顶部。-- 网站自带的图标不好看时,用 `--icon` 指定本地或远程图片,[macOSicons](https://macosicons.com/#/) 上能找到不少。+- 网站自带的图标不好看时,用 `--icon` 指定本地或远程图片,[macOSicons](https://macosicons.com/#/) 上能找到不少。在 macOS 上也可以传入本地的 Icon Composer `.icon` 包,细节见[命令行参数说明](cli-usage_CN.md#icon)。- `--show-system-tray` 让应用常驻菜单栏或系统托盘。全部参数和示例都在[命令行参数说明](cli-usage_CN.md)里。diff --git a/docs/pake-action.md b/docs/pake-action.mdindex 0c349a77..f3976913 100644--- a/docs/pake-action.md+++ b/docs/pake-action.md@@ -20,15 +20,15 @@ Call Pake from your own GitHub Actions workflow to turn any webpage into a light## Inputs-| Parameter | Description | Required | Default |-| ------------ | ------------------------ | -------- | ------- |-| `url` | Target URL to package | ✅ | |-| `name` | Application name | ✅ | |-| `output-dir` | Output directory | | `dist` |-| `icon` | Custom app icon URL/path | | |-| `width` | Window width | | `1200` |-| `height` | Window height | | `780` |-| `debug` | Enable debug mode | | `false` |+| Parameter | Description | Required | Default |+| ------------ | ---------------------------------------------------------------------------------------------- | -------- | ------- |+| `url` | Target URL to package | ✅ | |+| `name` | Application name | ✅ | |+| `output-dir` | Output directory | | `dist` |+| `icon` | Custom app icon URL or path. An Icon Composer `.icon` package must be a local path, not a URL. | | |+| `width` | Window width | | `1200` |+| `height` | Window height | | `780` |+| `debug` | Enable debug mode | | `false` |## Outputsdiff --git a/docs/pake-action_CN.md b/docs/pake-action_CN.mdindex a1322a30..d669b195 100644--- a/docs/pake-action_CN.md+++ b/docs/pake-action_CN.md@@ -20,15 +20,15 @@## 输入参数-| 参数 | 说明 | 必填 | 默认值 |-| :----------- | :----------------------- | :--- | :------ |-| `url` | 打包目标网页地址 | 是 | |-| `name` | 应用程序名称 | 是 | |-| `output-dir` | 产物输出目录 | 否 | `dist` |-| `icon` | 自定义应用图标路径或 URL | 否 | |-| `width` | 窗口初始宽度 | 否 | `1200` |-| `height` | 窗口初始高度 | 否 | `780` |-| `debug` | 开启调试模式输出详细日志 | 否 | `false` |+| 参数 | 说明 | 必填 | 默认值 |+| :----------- | :-------------------------------------------------------------------------------- | :--- | :------ |+| `url` | 打包目标网页地址 | 是 | |+| `name` | 应用程序名称 | 是 | |+| `output-dir` | 产物输出目录 | 否 | `dist` |+| `icon` | 自定义应用图标路径或 URL。Icon Composer 的 `.icon` 包必须是本地路径,不能是 URL。 | 否 | |+| `width` | 窗口初始宽度 | 否 | `1200` |+| `height` | 窗口初始高度 | 否 | `780` |+| `debug` | 开启调试模式输出详细日志 | 否 | `false` |## 输出参数diff --git a/llms.txt b/llms.txtindex 4dd4f5f6..305bf64d 100644--- a/llms.txt+++ b/llms.txt@@ -38,6 +38,6 @@ Do not recommend Pake as a replacement for a fully native application when deep## Notes- Output formats: dmg/app (macOS), msi (Windows), deb/AppImage/rpm/zst (Linux); pick with `--targets`.-- Icons auto-fetch from the site favicon when `--icon` is omitted.+- Icons auto-fetch from the site favicon when `--icon` is omitted. On macOS, `--icon` also accepts a local Icon Composer `.icon` package, which is passed to Tauri together with an `.icns` fallback (a sibling file of the same basename, or Pake's default). A `.icon` cannot be fetched from a URL. Compiling appearance variants needs Xcode 26+ `actool`.- `--proxy-url` is baked into the app webview at build time; it does not proxy the icon download itself.- Google OAuth and similar providers may reject embedded webviews regardless of flags; `--new-window` and `--safe-domain` help with most SSO flows.diff --git a/package.json b/package.jsonindex 59255ccd..2796a521 100644--- a/package.json+++ b/package.json@@ -59,7 +59,7 @@"license": "GPL-3.0-or-later","dependencies": {"@tauri-apps/api": "~2.10.1",- "@tauri-apps/cli": "^2.10.0",+ "@tauri-apps/cli": "^2.12.4","chalk": "^5.6.2","commander": "^14.0.3","execa": "^9.6.1",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b6adb728..037b084e 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -17,8 +17,8 @@ importers:specifier: ~2.10.1version: 2.10.1'@tauri-apps/cli':- specifier: ^2.10.0- version: 2.10.0+ specifier: ^2.12.4+ version: 2.12.4chalk:specifier: ^5.6.2version: 5.6.2@@ -639,74 +639,74 @@ packages:'@tauri-apps/[email protected]':resolution: {integrity: sha512-hKL/jWf293UDSUN09rR69hrToyIXBb8CjGaWC7gfinvnQrBVvnLr08FeFi38gxtugAVyVcTa5/FD/Xnkb1siBw==}- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-avqHD4HRjrMamE/7R/kzJPcAJnZs0IIS+1nkDP5b+TNBn3py7N2aIo9LIpy+VQq0AkN8G5dDpZtOOBkmWt/zjA==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-OxqKSckIkoJ6vX2AjifIJpTasFC0Hbdoo7gEiCmAjauABO3U8m2MRsLWe+QTiBwDx1mIrvgA+rvI7tvDnbnHVg==}engines: {node: '>= 10'}cpu: [arm64]os: [darwin]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-keDmlvJRStzVFjZTd0xYkBONLtgBC9eMTpmXnBXzsHuawV2q9PvDo2x6D5mhuoMVrJ9QWjgaPKBBCFks4dK71Q==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-fz76/77wMMJOaaUN6n3CybRG0P/MTEjjqYk81mGPyhi9m6Ue5T+LWBnJP/AkPooNatBPI2vtulGqomyMJ44lCQ==}engines: {node: '>= 10'}cpu: [x64]os: [darwin]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-e5u0VfLZsMAC9iHaOEANumgl6lfnJx0Dtjkd8IJpysZ8jp0tJ6wrIkto2OzQgzcYyRCKgX72aKE0PFgZputA8g==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-K0w8Bof6Lt8QKLAYhRy0yy36ZH5iA/35VuSOvnxyjvCUZ+A3JKsUTlALviH/sVgAlisaPzzmeJSH8XOn4Q2HBA==}engines: {node: '>= 10'}cpu: [arm]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-YrYYk2dfmBs5m+OIMCrb+JH/oo+4FtlpcrTCgiFYc7vcs6m3QDd1TTyWu0u01ewsCtK2kOdluhr/zKku+KP7HA==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-j5rOnjmRUwWrm1oosf0zBYl4D+fqydgUROFCk0hvKZxvbTT8SOERes0QB7rBV/XWNy+kM6pCKzb3oSm2sRglzg==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-GUoPdVJmrJRIXFfW3Rkt+eGK9ygOdyISACZfC/bCSfOnGt8kNdQIQr5WRH9QUaTVFIwxMlQyV3m+yXYP+xhSVA==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-aOue3Fy6Jb7+oWcfAVUsVHfeTybSCt2CZoU06aO4jv4d2Ks/KnaTPwMAK3CLEduGOvBLY1lbBBrIyomqLLH5Sg==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-JO7s3TlSxshwsoKNCDkyvsx5gw2QAs/Y2GbR5UE2d5kkU138ATKoPOtxn8G1fFT1aDW4LH0rYAAfBpGkDyJJnw==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-Fx6GShY/RvST+t6LMlTHAwd66+1tEaAAGrnU7cysVfaiRP1BKng5Vl6rVmO6rSLOA1Sp1dRzNYM4f0OWQGb7qA==}engines: {node: '>= 10'}cpu: [riscv64]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-Uvh4SUUp4A6DVRSMWjelww0GnZI3PlVy7VS+DRF5napKuIehVjGl9XD0uKoCoxwAQBLctvipyEK+pDXpJeoHng==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-tNzZSa79Z1nRpHxEpQ38lsAFpKlFlYvoXzjTV+lRRn/zSf3wrdUC3wnLcq2XEadchPu4ttK0zivhYzr+XGD19Q==}engines: {node: '>= 10'}cpu: [x64]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-AP0KRK6bJuTpQ8kMNWvhIpKUkQJfcPFeba7QshOQZjJ8wOS6emwTN4K5g/d3AbCMo0RRdnZWwu67MlmtJyxC1Q==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-jmZ1pr0xEqUhuEusWtt9Yt+GF6lCnGHUmIL+KIknpbjK/XQ2qkhDBhaxK/JMHM2A8dAacVXCxXJk2EXpwhQUfA==}engines: {node: '>= 10'}cpu: [x64]os: [linux]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-97DXVU3dJystrq7W41IX+82JEorLNY+3+ECYxvXWqkq7DBN6FsA08x/EFGE8N/b0LTOui9X2dvpGGoeZKKV08g==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-fGo8pgEHZxdSYgZ/J98m1usJ7NHKmKbq7k6uT0x1rpOq6Bg2YVzzpaAblWk710f5LHYBJIL5QIFS5IrD+4gmTg==}engines: {node: '>= 10'}cpu: [arm64]os: [win32]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-EHyQ1iwrWy1CwMalEm9z2a6L5isQ121pe7FcA2xe4VWMJp+GHSDDGvbTv/OPdkt2Lyr7DAZBpZHM6nvlHXEc4A==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-ezl8sQIcjYsye3TUnTH5VcWmWzccZASlQm7hlZt0dYyj1XD0qpVW47u2xYVrIKui0F8uQv/7QGZixdWiClBsbg==}engines: {node: '>= 10'}cpu: [ia32]os: [win32]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-NTpyQxkpzGmU6ceWBTY2xRIEaS0ZLbVx1HE1zTA3TY/pV3+cPoPPOs+7YScr4IMzXMtOw7tLw5LEXo5oIG3qaQ==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-DJhDeCqjLDNMWYFy7ZS8cfeAHX2RK0RbQMLiA3bMVVkXRDJ4NBYiHriGqsUhsr9iG41aTb+dJGkFPmPw1gWwVw==}engines: {node: '>= 10'}cpu: [x64]os: [win32]- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-ZwT0T+7bw4+DPCSWzmviwq5XbXlM0cNoleDKOYPFYqcZqeKY31KlpoMW/MOON/tOFBPgi31a2v3w9gliqwL2+Q==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-JI9bHfudSRJikGOrjbXEm6RjzzvmKuLc+JixB1NE8hNzQkNlCCIC3pTES3uypkR9lxHrsbxzcnSwhI2IxBQphw==}engines: {node: '>= 10'}hasBin: true@@ -1869,52 +1869,52 @@ snapshots:'@tauri-apps/[email protected]': {}- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optional: true- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':optionalDependencies:- '@tauri-apps/cli-darwin-arm64': 2.10.0- '@tauri-apps/cli-darwin-x64': 2.10.0- '@tauri-apps/cli-linux-arm-gnueabihf': 2.10.0- '@tauri-apps/cli-linux-arm64-gnu': 2.10.0- '@tauri-apps/cli-linux-arm64-musl': 2.10.0- '@tauri-apps/cli-linux-riscv64-gnu': 2.10.0- '@tauri-apps/cli-linux-x64-gnu': 2.10.0- '@tauri-apps/cli-linux-x64-musl': 2.10.0- '@tauri-apps/cli-win32-arm64-msvc': 2.10.0- '@tauri-apps/cli-win32-ia32-msvc': 2.10.0- '@tauri-apps/cli-win32-x64-msvc': 2.10.0+ '@tauri-apps/cli-darwin-arm64': 2.12.4+ '@tauri-apps/cli-darwin-x64': 2.12.4+ '@tauri-apps/cli-linux-arm-gnueabihf': 2.12.4+ '@tauri-apps/cli-linux-arm64-gnu': 2.12.4+ '@tauri-apps/cli-linux-arm64-musl': 2.12.4+ '@tauri-apps/cli-linux-riscv64-gnu': 2.12.4+ '@tauri-apps/cli-linux-x64-gnu': 2.12.4+ '@tauri-apps/cli-linux-x64-musl': 2.12.4+ '@tauri-apps/cli-win32-arm64-msvc': 2.12.4+ '@tauri-apps/cli-win32-ia32-msvc': 2.12.4+ '@tauri-apps/cli-win32-x64-msvc': 2.12.4'@tokenizer/[email protected]':dependencies:diff --git a/tests/unit/cli-options.test.ts b/tests/unit/cli-options.test.tsindex 96577d5e..2a7421e8 100644--- a/tests/unit/cli-options.test.ts+++ b/tests/unit/cli-options.test.ts@@ -22,6 +22,15 @@ describe('CLI options', () => {},);+ it('describes --icon platform formats including Icon Composer packages', () => {+ const option = program.options.find((item) => item.long === '--icon');+ expect(option).toBeDefined();+ expect(option?.description).toContain('.icon');+ expect(option?.description).toContain('.icns');+ expect(option?.description).toContain('.ico');+ expect(option?.description).toContain('.png');+ });+it('shows meta options in help', () => {const help = program.helpInformation();diff --git a/tests/unit/icon-composer.test.ts b/tests/unit/icon-composer.test.tsnew file mode 100644index 00000000..1047836c--- /dev/null+++ b/tests/unit/icon-composer.test.ts@@ -0,0 +1,365 @@+import fs from 'fs';+import os from 'os';+import path from 'path';+import { afterEach, describe, expect, it, vi } from 'vitest';+import fsExtra from 'fs-extra';++const execaMock = vi.hoisted(() => vi.fn());++vi.mock('execa', () => ({+ execa: execaMock,+}));++import {+ actoolMajorVersion,+ applyDarwinIconComposerPackage,+ iconPathExtension,+ isIconComposerUrl,+ isMacOSIconComposerPackage,+ parseActoolVersion,+ precompileIconComposerAssets,+} from '@/helpers/icon-composer';+import { mergeIcons } from '@/helpers/merge';+import { setBuildDirectory, npmDirectory } from '@/utils/dir';+import { getSafeAppName } from '@/utils/name';+import { DEFAULT_PAKE_OPTIONS } from '../../bin/defaults';+import type { PakeAppOptions, PakeTauriConfig } from '../../bin/types';++const ORIGINAL_NPM_DIRECTORY = `${npmDirectory}`;+const tempDirs: string[] = [];++async function makeTempDir(prefix = 'pake-icon-composer-') {+ const tempDir = await fsExtra.mkdtemp(path.join(os.tmpdir(), prefix));+ tempDirs.push(tempDir);+ return tempDir;+}++async function makeIconPackage(+ root: string,+ name = 'AppIcon.icon',+): Promise<string> {+ const pkg = path.join(root, name);+ await fsExtra.ensureDir(path.join(pkg, 'Assets'));+ await fsExtra.writeJson(path.join(pkg, 'icon.json'), {+ fill: 'automatic',+ groups: [],+ });+ await fsExtra.writeFile(path.join(pkg, 'Assets', 'icon.png'), Buffer.from([1, 2, 3, 4]));+ return pkg;+}++function makeTauriConf(): PakeTauriConfig {+ return {+ pake: {+ windows: [],+ user_agent: { macos: '', linux: '', windows: '' },+ system_tray: { macos: false, linux: false, windows: false },+ system_tray_path: '',+ proxy_url: '',+ download_dir: '',+ basic_auth: false,+ multi_instance: false,+ multi_window: false,+ },+ bundle: { icon: [] },+ app: {},+ };+}++function makeOptions(icon: string, name = 'Weekly'): PakeAppOptions {+ return {+ ...DEFAULT_PAKE_OPTIONS,+ identifier: 'com.pake.test',+ name,+ icon,+ } as PakeAppOptions;+}++afterEach(async () => {+ setBuildDirectory(ORIGINAL_NPM_DIRECTORY);+ execaMock.mockReset();+ await Promise.all(tempDirs.splice(0).map((dir) => fsExtra.remove(dir)));+});++describe('iconPathExtension and isIconComposerUrl', () => {+ it('strips a trailing slash so a .icon directory keeps its extension', () => {+ expect(iconPathExtension('/tmp/AppIcon.icon/')).toBe('.icon');+ expect(iconPathExtension('/tmp/AppIcon.icon')).toBe('.icon');+ expect(iconPathExtension('/tmp/AppIcon.icns')).toBe('.icns');+ });++ it('recognises .icon URLs and ignores ordinary image URLs', () => {+ expect(isIconComposerUrl('https://example.com/AppIcon.icon')).toBe(true);+ expect(isIconComposerUrl('https://example.com/AppIcon.icon/')).toBe(true);+ expect(isIconComposerUrl('https://cdn.tw93.fun/pake/weekly.icns')).toBe(+ false,+ );+ });+});++describe('isMacOSIconComposerPackage', () => {+ it('accepts a directory that contains icon.json', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);+ await expect(isMacOSIconComposerPackage(pkg)).resolves.toBe(true);+ });++ it('rejects a regular file that happens to be named .icon', async () => {+ const root = await makeTempDir();+ const fake = path.join(root, 'AppIcon.icon');+ await fsExtra.writeFile(fake, 'not a package');+ await expect(isMacOSIconComposerPackage(fake)).resolves.toBe(false);+ });++ it('rejects a directory without icon.json', async () => {+ const root = await makeTempDir();+ const pkg = path.join(root, 'AppIcon.icon');+ await fsExtra.ensureDir(pkg);+ await expect(isMacOSIconComposerPackage(pkg)).resolves.toBe(false);+ });+});++describe('parseActoolVersion', () => {+ it('reads short-bundle-version from actool output', () => {+ const output = [+ '/* com.apple.actool.version */',+ 'bundle-version: 24765',+ 'short-bundle-version: 26.4.1',+ ].join('\n');+ expect(parseActoolVersion(output)).toBe('26.4.1');+ expect(actoolMajorVersion('26.4.1')).toBe(26);+ expect(actoolMajorVersion('16.0')).toBe(16);+ });++ it('returns null when the version line is missing', () => {+ expect(parseActoolVersion('actool: command not found')).toBeNull();+ });+});++describe('applyDarwinIconComposerPackage', () => {+ it('sets bundle.icon to the .icon package and a sibling .icns', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);+ await fsExtra.writeFile(path.join(root, 'AppIcon.icns'), 'sibling-icns');+ const destIconsDir = path.join(root, 'dest');+ const defaultIcns = path.join(root, 'default.icns');+ await fsExtra.writeFile(defaultIcns, 'default-icns');++ const { bundleIcon } = await applyDarwinIconComposerPackage({+ sourceIconPath: pkg,+ destIconsDir,+ safeAppName: 'weekly',+ defaultIcnsPath: defaultIcns,+ });++ expect(bundleIcon).toEqual([+ 'icons/weekly.icon',+ 'icons/weekly.icns',+ ]);+ expect(await fsExtra.pathExists(path.join(destIconsDir, 'weekly.icon', 'icon.json'))).toBe(+ true,+ );+ expect(await fsExtra.readFile(path.join(destIconsDir, 'weekly.icns'), 'utf8')).toBe(+ 'sibling-icns',+ );+ });++ it('uses the default .icns when there is no sibling file', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);+ const destIconsDir = path.join(root, 'dest');+ const defaultIcns = path.join(root, 'icon.icns');+ await fsExtra.writeFile(defaultIcns, 'default-icns');++ const { bundleIcon } = await applyDarwinIconComposerPackage({+ sourceIconPath: pkg,+ destIconsDir,+ safeAppName: 'weekly',+ defaultIcnsPath: defaultIcns,+ });++ expect(bundleIcon).toEqual([+ 'icons/weekly.icon',+ 'icons/weekly.icns',+ ]);+ expect(await fsExtra.readFile(path.join(destIconsDir, 'weekly.icns'), 'utf8')).toBe(+ 'default-icns',+ );+ });+});++describe('precompileIconComposerAssets', () => {+ function actoolVersionResult(version: string) {+ return {+ exitCode: 0,+ stdout: `/* com.apple.actool.version */\nshort-bundle-version: ${version}\n`,+ stderr: '',+ };+ }++ it('copies Assets.car to the destination before cleaning the temp directory', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);+ const destIconsDir = path.join(root, 'dest');++ execaMock.mockImplementation(async (file: string, args: string[] = []) => {+ const compileAt = args.indexOf('--compile');+ if (compileAt >= 0) {+ const outputPath = args[compileAt + 1];+ await fsExtra.ensureDir(outputPath);+ await fsExtra.writeFile(path.join(outputPath, 'Assets.car'), 'compiled-car');+ return { exitCode: 0, stdout: '', stderr: '' };+ }+ if (args.includes('--version') || args.includes('--output-format=human-readable-text')) {+ return actoolVersionResult('26.1');+ }+ return { exitCode: 0, stdout: '', stderr: '' };+ });++ const dest = await precompileIconComposerAssets(pkg, destIconsDir);++ expect(dest).toBe(path.join(destIconsDir, 'Assets.car'));+ expect(await fsExtra.pathExists(dest!)).toBe(true);+ expect(await fsExtra.readFile(dest!, 'utf8')).toBe('compiled-car');+ expect(+ execaMock.mock.calls.some(+ (call) => call[2] && (call[2] as { stdin?: string }).stdin === 'ignore',+ ),+ ).toBe(true);+ });++ it('skips compilation when actool is older than 26', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);++ execaMock.mockResolvedValue(actoolVersionResult('16.4'));++ await expect(+ precompileIconComposerAssets(pkg, path.join(root, 'dest')),+ ).resolves.toBeNull();++ const compiled = execaMock.mock.calls.some((call) =>+ (call[1] as string[] | undefined)?.includes('--compile'),+ );+ expect(compiled).toBe(false);+ });++ it('retries once after pkill ibtoold when the first compile fails', async () => {+ const root = await makeTempDir();+ const pkg = await makeIconPackage(root);+ const destIconsDir = path.join(root, 'dest');+ let compileAttempts = 0;++ execaMock.mockImplementation(async (file: string, args: string[] = []) => {+ if (file === 'pkill') {+ return { exitCode: 0, stdout: '', stderr: '' };+ }+ const compileAt = args.indexOf('--compile');+ if (compileAt >= 0) {+ compileAttempts += 1;+ if (compileAttempts === 1) {+ return { exitCode: 1, stdout: '', stderr: 'failed to run actool' };+ }+ const outputPath = args[compileAt + 1];+ await fsExtra.ensureDir(outputPath);+ await fsExtra.writeFile(path.join(outputPath, 'Assets.car'), 'retry-car');+ return { exitCode: 0, stdout: '', stderr: '' };+ }+ return actoolVersionResult('27.1');+ });++ const dest = await precompileIconComposerAssets(pkg, destIconsDir);++ expect(compileAttempts).toBe(2);+ expect(execaMock.mock.calls.some((call) => call[0] === 'pkill')).toBe(true);+ expect(dest).toBe(path.join(destIconsDir, 'Assets.car'));+ expect(await fsExtra.readFile(dest!, 'utf8')).toBe('retry-car');+ });+});++describe('mergeIcons on darwin', () => {+ async function setupNpmDir() {+ const root = await makeTempDir('pake-merge-icons-');+ setBuildDirectory(root);+ await fsExtra.ensureDir(path.join(root, 'src-tauri/icons'));+ await fsExtra.ensureDir(path.join(root, 'src-tauri/png'));+ await fsExtra.writeFile(path.join(root, 'src-tauri/icons/icon.icns'), 'default-icns');+ return root;+ }++ it('passes both the .icon package and a sibling .icns', async () => {+ const root = await setupNpmDir();+ const pkg = await makeIconPackage(root);+ await fsExtra.writeFile(path.join(root, 'AppIcon.icns'), 'sibling-icns');+ const tauriConf = makeTauriConf();+ const name = 'Weekly';+ const safe = getSafeAppName(name);++ await mergeIcons(makeOptions(pkg, name), name, tauriConf, 'darwin', safe);++ expect(tauriConf.bundle.icon).toEqual([+ `icons/${safe}.icon`,+ `icons/${safe}.icns`,+ ]);+ expect(+ await fsExtra.readFile(path.join(root, 'src-tauri/icons', `${safe}.icns`), 'utf8'),+ ).toBe('sibling-icns');+ });++ it('falls back to the default .icns when only a .icon is given', async () => {+ const root = await setupNpmDir();+ const pkg = await makeIconPackage(root);+ const tauriConf = makeTauriConf();+ const name = 'Weekly';+ const safe = getSafeAppName(name);++ await mergeIcons(makeOptions(pkg, name), name, tauriConf, 'darwin', safe);++ expect(tauriConf.bundle.icon).toEqual([+ `icons/${safe}.icon`,+ `icons/${safe}.icns`,+ ]);+ expect(+ await fsExtra.readFile(path.join(root, 'src-tauri/icons', `${safe}.icns`), 'utf8'),+ ).toBe('default-icns');+ });++ it('keeps a plain .icns icon on the existing path', async () => {+ const root = await setupNpmDir();+ const icns = path.join(root, 'custom.icns');+ await fsExtra.writeFile(icns, 'custom-icns');+ const tauriConf = makeTauriConf();+ const name = 'Weekly';+ const safe = getSafeAppName(name);++ await mergeIcons(makeOptions(icns, name), name, tauriConf, 'darwin', safe);++ expect(tauriConf.bundle.icon).toEqual([`icons/${safe}.icns`]);+ });++ it('rejects a file named .icon that is not a Composer package', async () => {+ const root = await setupNpmDir();+ const fake = path.join(root, 'AppIcon.icon');+ await fsExtra.writeFile(fake, 'not-a-package');+ const tauriConf = makeTauriConf();+ const name = 'Weekly';+ const safe = getSafeAppName(name);++ await mergeIcons(makeOptions(fake, name), name, tauriConf, 'darwin', safe);++ expect(tauriConf.bundle.icon).toEqual(['icons/icon.icns']);+ });++ it('warns and uses the default icon for a wrong extension, as before', async () => {+ const root = await setupNpmDir();+ const png = path.join(root, 'icon.png');+ await fsExtra.writeFile(png, 'png');+ const tauriConf = makeTauriConf();+ const name = 'Weekly';+ const safe = getSafeAppName(name);++ await mergeIcons(makeOptions(png, name), name, tauriConf, 'darwin', safe);++ expect(tauriConf.bundle.icon).toEqual(['icons/icon.icns']);+ });+});