add patch

This commit is contained in:
beyondkmp 2025-09-02 09:15:58 +08:00
parent 5c0b06973c
commit d111b92bd2
2 changed files with 206 additions and 12 deletions

View File

@ -1,13 +1,207 @@
diff --git a/index.js b/index.js
index dc071739e79876dff88e1be06a9168e294222d13..d30e895754cf0cd0ef79ae14cae02adf42eeac8a 100644
index dc071739e79876dff88e1be06a9168e294222d13..95252d03c1d9c4145d64d876e60801340d68ff4d 100644
--- a/index.js
+++ b/index.js
@@ -381,7 +381,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
}
if (!nativeBinding) {
- if (loadErrors.length > 0) {
+ if (process.platform !== 'linux' && loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
@@ -71,6 +71,8 @@ function requireNative() {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
+ return
+ } else if (process.platform === 'win32') {
if (process.arch === 'arm64') {
try {
return require('./system-ocr.android-arm64.node')
@@ -170,190 +172,11 @@ function requireNative() {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
- if (process.arch === 'x64') {
- try {
- return require('./system-ocr.freebsd-x64.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-freebsd-x64')
- } catch (e) {
- loadErrors.push(e)
- }
- } else if (process.arch === 'arm64') {
- try {
- return require('./system-ocr.freebsd-arm64.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-freebsd-arm64')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
- }
+ return
} else if (process.platform === 'linux') {
- if (process.arch === 'x64') {
- if (isMusl()) {
- try {
- return require('./system-ocr.linux-x64-musl.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-x64-musl')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- try {
- return require('./system-ocr.linux-x64-gnu.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-x64-gnu')
- } catch (e) {
- loadErrors.push(e)
- }
- }
- } else if (process.arch === 'arm64') {
- if (isMusl()) {
- try {
- return require('./system-ocr.linux-arm64-musl.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm64-musl')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- try {
- return require('./system-ocr.linux-arm64-gnu.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm64-gnu')
- } catch (e) {
- loadErrors.push(e)
- }
- }
- } else if (process.arch === 'arm') {
- if (isMusl()) {
- try {
- return require('./system-ocr.linux-arm-musleabihf.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm-musleabihf')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- try {
- return require('./system-ocr.linux-arm-gnueabihf.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm-gnueabihf')
- } catch (e) {
- loadErrors.push(e)
- }
- }
- } else if (process.arch === 'riscv64') {
- if (isMusl()) {
- try {
- return require('./system-ocr.linux-riscv64-musl.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-riscv64-musl')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- try {
- return require('./system-ocr.linux-riscv64-gnu.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-riscv64-gnu')
- } catch (e) {
- loadErrors.push(e)
- }
- }
- } else if (process.arch === 'ppc64') {
- try {
- return require('./system-ocr.linux-ppc64-gnu.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-ppc64-gnu')
- } catch (e) {
- loadErrors.push(e)
- }
- } else if (process.arch === 's390x') {
- try {
- return require('./system-ocr.linux-s390x-gnu.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-s390x-gnu')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
- }
+ return
} else if (process.platform === 'openharmony') {
- if (process.arch === 'arm64') {
- try {
- return require('./system-ocr.linux-arm64-ohos.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm64-ohos')
- } catch (e) {
- loadErrors.push(e)
- }
- } else if (process.arch === 'x64') {
- try {
- return require('./system-ocr.linux-x64-ohos.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-x64-ohos')
- } catch (e) {
- loadErrors.push(e)
- }
- } else if (process.arch === 'arm') {
- try {
- return require('./system-ocr.linux-arm-ohos.node')
- } catch (e) {
- loadErrors.push(e)
- }
- try {
- return require('@napi-rs/system-ocr-linux-arm-ohos')
- } catch (e) {
- loadErrors.push(e)
- }
- } else {
- loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
- }
+ return
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}

View File

@ -4784,7 +4784,7 @@ __metadata:
"@napi-rs/system-ocr@patch:@napi-rs/system-ocr@npm%3A1.0.2#~/.yarn/patches/@napi-rs-system-ocr-npm-1.0.2-59e7a78e8b.patch":
version: 1.0.2
resolution: "@napi-rs/system-ocr@patch:@napi-rs/system-ocr@npm%3A1.0.2#~/.yarn/patches/@napi-rs-system-ocr-npm-1.0.2-59e7a78e8b.patch::version=1.0.2&hash=1454af"
resolution: "@napi-rs/system-ocr@patch:@napi-rs/system-ocr@npm%3A1.0.2#~/.yarn/patches/@napi-rs-system-ocr-npm-1.0.2-59e7a78e8b.patch::version=1.0.2&hash=a237c4"
dependencies:
"@napi-rs/system-ocr-darwin-arm64": "npm:1.0.2"
"@napi-rs/system-ocr-darwin-x64": "npm:1.0.2"
@ -4799,7 +4799,7 @@ __metadata:
optional: true
"@napi-rs/system-ocr-win32-x64-msvc":
optional: true
checksum: 10c0/9ee9476893284a4f1ba11357697209232ef87823308a80cff60c7d2cb833c3125ba56bdc424ea591ef636aa1a64cc896ea592e4f48ac5dd1ad449b0eef360c36
checksum: 10c0/c6bebfba31e95f39480c9d93e55cc371e5ae296380829cdf791082895ef93083578c717291fce111464272a99d1b15d22ef005e579fcce9a7f0d7d553b66e079
languageName: node
linkType: hard