diff --git a/apps/electron-backend/project.json b/apps/electron-backend/project.json index ab1a2486b..d96fb3678 100644 --- a/apps/electron-backend/project.json +++ b/apps/electron-backend/project.json @@ -132,22 +132,6 @@ "frontendProject": "web", "sourcePath": "dist/apps", "outputPath": "dist/packages", - "files": [ - { - "from": "electron-backend/native", - "to": "electron-backend/native", - "filter": ["**/*"] - } - ], - "asarUnpack": [ - "**/better-sqlite3/**", - "**/bindings/**", - "**/file-uri-to-path/**", - "electron-backend/native/**", - "**/electron-backend/native/**", - "**/*.node", - "**/*.dylib" - ], "prepackageOnly": true } }, @@ -158,23 +142,7 @@ "name": "electron-backend", "frontendProject": "web", "sourcePath": "dist/apps", - "outputPath": "dist/executables", - "files": [ - { - "from": "electron-backend/native", - "to": "electron-backend/native", - "filter": ["**/*"] - } - ], - "asarUnpack": [ - "**/better-sqlite3/**", - "**/bindings/**", - "**/file-uri-to-path/**", - "electron-backend/native/**", - "**/electron-backend/native/**", - "**/*.node", - "**/*.dylib" - ] + "outputPath": "dist/executables" } }, "lint": { diff --git a/docs/architecture/embedded-mpv-native.md b/docs/architecture/embedded-mpv-native.md index 9566f2398..aa60b5d52 100644 --- a/docs/architecture/embedded-mpv-native.md +++ b/docs/architecture/embedded-mpv-native.md @@ -76,7 +76,8 @@ Current development behavior: - The staged runtime must contain `include/mpv/client.h`, `lib/*.dylib`, and `runtime-manifest.json`. - The compiled `.node` addon is copied into `dist/apps/electron-backend/native/embedded_mpv.node`. - Bundled runtime files are copied into `dist/apps/electron-backend/native/lib/`. Most are `.dylib` files, but some Homebrew-linked runtimes expose non-`.dylib` Mach-O files such as a framework `Python` binary. -- `electron-builder` includes `dist/apps/electron-backend/native/` in the app package and unpacks `electron-backend/native/**` from ASAR so the addon, manifest, dylibs, and non-`.dylib` Mach-O runtime files are filesystem-addressable. +- macOS `afterPack` copies `dist/apps/electron-backend/native/` into `app.asar.unpacked/electron-backend/native/` so the addon, manifest, dylibs, and non-`.dylib` Mach-O runtime files are filesystem-addressable. +- Linux and Windows packaging do not include the Embedded MPV native directory. Current release caveat: diff --git a/electron-builder.json b/electron-builder.json index fd7fbd8b5..3cfaefd57 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -12,11 +12,6 @@ "to": "remote-control-web", "filter": ["**/*"] }, - { - "from": "dist/apps/electron-backend/native", - "to": "electron-backend/native", - "filter": ["**/*"] - }, "electron-backend/**/*", "web/**/*", "!**/*.map" @@ -25,8 +20,6 @@ "**/better-sqlite3/**", "**/bindings/**", "**/file-uri-to-path/**", - "electron-backend/native/**", - "**/electron-backend/native/**", "**/*.node", "**/*.dylib" ], diff --git a/tools/embedded-mpv/README.md b/tools/embedded-mpv/README.md index da4296dc7..bad05eb1c 100644 --- a/tools/embedded-mpv/README.md +++ b/tools/embedded-mpv/README.md @@ -70,7 +70,7 @@ The build manifest records source URLs, downloaded archive SHA-256 values where `apps/electron-backend/build-embedded-mpv.js` links the native addon against the staged runtime, copies dylibs into `apps/electron-backend/native/build/Release/lib/`, rewrites Mach-O paths to `@loader_path`, and writes `embedded-mpv-runtime.json`. -The Electron builder and Nx package/make targets package `dist/apps/electron-backend/native/` into `electron-backend/native/` and unpack that whole native directory from ASAR so the addon, runtime manifest, dylibs, and non-`.dylib` Mach-O runtime files are available as real files. +The macOS `afterPack` hook copies `dist/apps/electron-backend/native/` into `app.asar.unpacked/electron-backend/native/` so the addon, runtime manifest, dylibs, and non-`.dylib` Mach-O runtime files are available as real files. Linux and Windows artifacts do not include that native directory. During release packaging, `tools/packaging/electron-after-pack.cjs` verifies that the packaged app uses a `vendored-lgpl` runtime and has no `/opt/homebrew` or `/usr/local` dynamic links for embedded MPV. diff --git a/tools/packaging/electron-after-pack.cjs b/tools/packaging/electron-after-pack.cjs index a20bf781b..496f1291e 100644 --- a/tools/packaging/electron-after-pack.cjs +++ b/tools/packaging/electron-after-pack.cjs @@ -17,6 +17,30 @@ function isTruthy(value) { ); } +function copyEmbeddedMpvNativeOutput(resourceDir, projectDir) { + const sourceDir = path.join( + projectDir, + 'dist', + 'apps', + 'electron-backend', + 'native' + ); + + if (!fs.existsSync(sourceDir)) { + return; + } + + const destinationDir = path.join( + resourceDir, + 'app.asar.unpacked', + 'electron-backend', + 'native' + ); + + fs.rmSync(destinationDir, { recursive: true, force: true }); + fs.cpSync(sourceDir, destinationDir, { recursive: true }); +} + async function afterPackHook(params) { await linuxAfterPack(params); @@ -46,6 +70,12 @@ async function afterPackHook(params) { 'Resources' ) : params.appOutDir; + + copyEmbeddedMpvNativeOutput( + resourceDir, + params.packager.projectDir ?? process.cwd() + ); + const errors = validatePackagedEmbeddedMpv(resourceDir, { required: requireEmbeddedMpv, });