mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-29 12:55:16 -07:00
fix: ensure macOS mpv window helper is built and bundled correctly (#93)
This commit is contained in:
@@ -1,7 +1,24 @@
|
||||
const fs = require('node:fs/promises');
|
||||
const fsSync = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const LINUX_FFMPEG_LIBRARY = 'libffmpeg.so';
|
||||
const MACOS_WINDOW_HELPER = 'get-mpv-window-macos';
|
||||
const DEFAULT_MACOS_APP_BUNDLE = 'SubMiner.app';
|
||||
|
||||
function resolveMacOSAppBundlePath(context) {
|
||||
if (context.appOutDir.endsWith('.app')) {
|
||||
return context.appOutDir;
|
||||
}
|
||||
|
||||
const productFilename = context.packager?.appInfo?.productFilename;
|
||||
const bundleName =
|
||||
typeof productFilename === 'string' && productFilename.trim()
|
||||
? `${productFilename.trim()}.app`
|
||||
: DEFAULT_MACOS_APP_BUNDLE;
|
||||
|
||||
return path.join(context.appOutDir, bundleName);
|
||||
}
|
||||
|
||||
async function stageLinuxAppImageSharedLibrary(
|
||||
context,
|
||||
@@ -35,12 +52,50 @@ async function stageLinuxAppImageSharedLibrary(
|
||||
return true;
|
||||
}
|
||||
|
||||
async function verifyMacOSWindowHelper(
|
||||
context,
|
||||
deps = {
|
||||
access: (filePath, mode) => fs.access(filePath, mode),
|
||||
},
|
||||
) {
|
||||
if (context.electronPlatformName !== 'darwin') return false;
|
||||
|
||||
const appBundlePath = resolveMacOSAppBundlePath(context);
|
||||
const helperPath = path.join(
|
||||
appBundlePath,
|
||||
'Contents',
|
||||
'Resources',
|
||||
'scripts',
|
||||
MACOS_WINDOW_HELPER,
|
||||
);
|
||||
|
||||
try {
|
||||
await deps.access(helperPath, fsSync.constants.X_OK);
|
||||
} catch (error) {
|
||||
if (error && typeof error === 'object' && error.code === 'ENOENT') {
|
||||
throw new Error(
|
||||
`macOS packaging requires ${MACOS_WINDOW_HELPER} at ${helperPath}. Run bun run build:assets on macOS with swiftc available before packaging.`,
|
||||
);
|
||||
}
|
||||
if (error && typeof error === 'object' && error.code === 'EACCES') {
|
||||
throw new Error(`macOS window helper is not executable: ${helperPath}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function afterPack(context) {
|
||||
await stageLinuxAppImageSharedLibrary(context);
|
||||
await verifyMacOSWindowHelper(context);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
LINUX_FFMPEG_LIBRARY,
|
||||
MACOS_WINDOW_HELPER,
|
||||
resolveMacOSAppBundlePath,
|
||||
stageLinuxAppImageSharedLibrary,
|
||||
verifyMacOSWindowHelper,
|
||||
default: afterPack,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user