feat: add support for downloading and retaining @napi-rs/system-ocr packages (#9741)

- Implemented downloading of architecture-specific versions of the @napi-rs/system-ocr packages for macOS and Windows platforms in build-npm.js.
- Updated after-pack.js to retain these packages during the packaging process, ensuring compatibility across different architectures.
This commit is contained in:
beyondkmp 2025-09-01 09:59:53 +08:00 committed by GitHub
parent a0fa536926
commit 9df7ac0ac2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -25,6 +25,12 @@ exports.default = async function (context) {
? ['sharp-darwin-arm64', 'sharp-libvips-darwin-arm64']
: ['sharp-darwin-x64', 'sharp-libvips-darwin-x64']
)
keepPackageNodeFiles(
node_modules_path,
'@napi-rs',
arch === Arch.arm64 ? ['system-ocr-darwin-arm64'] : ['system-ocr-darwin-x64']
)
}
if (platform === 'linux') {
@ -59,6 +65,12 @@ exports.default = async function (context) {
? ['sharp-win32-arm64', 'sharp-libvips-win32-arm64']
: ['sharp-win32-x64', 'sharp-libvips-win32-x64']
)
keepPackageNodeFiles(
node_modules_path,
'@napi-rs',
arch === Arch.arm64 ? ['system-ocr-win32-arm64-msvc'] : ['system-ocr-win32-x64-msvc']
)
}
if (platform === 'windows') {

View File

@ -25,6 +25,14 @@ async function downloadNpm(platform) {
'@img/sharp-libvips-darwin-x64',
'https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.0.tgz'
)
downloadNpmPackage(
'@napi-rs/system-ocr-darwin-arm64',
'https://registry.npmjs.org/@napi-rs/system-ocr-darwin-arm64/-/system-ocr-darwin-arm64-1.0.2.tgz'
)
downloadNpmPackage(
'@napi-rs/system-ocr-darwin-x64',
'https://registry.npmjs.org/@napi-rs/system-ocr-darwin-x64/-/system-ocr-darwin-x64-1.0.2.tgz'
)
}
if (!platform || platform === 'linux') {
@ -81,6 +89,15 @@ async function downloadNpm(platform) {
'@img/sharp-win32-x64',
'https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.3.tgz'
)
downloadNpmPackage(
'@napi-rs/system-ocr-win32-arm64-msvc',
'https://registry.npmjs.org/@napi-rs/system-ocr-win32-arm64-msvc/-/system-ocr-win32-arm64-msvc-1.0.2.tgz'
)
downloadNpmPackage(
'@napi-rs/system-ocr-win32-x64-msvc',
'https://registry.npmjs.org/@napi-rs/system-ocr-win32-x64-msvc/-/system-ocr-win32-x64-msvc-1.0.2.tgz'
)
}
}