| 61 | } |
| 62 | |
| 63 | function requireNative() { |
| 64 | if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { |
| 65 | try { |
| 66 | return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); |
| 67 | } catch (err) { |
| 68 | loadErrors.push(err) |
| 69 | } |
| 70 | } else if (process.platform === 'android') { |
| 71 | if (process.arch === 'arm64') { |
| 72 | try { |
| 73 | return require('./impit-node.android-arm64.node') |
| 74 | } catch (e) { |
| 75 | loadErrors.push(e) |
| 76 | } |
| 77 | try { |
| 78 | const binding = require('impit-android-arm64') |
| 79 | const bindingPackageVersion = require('impit-android-arm64/package.json').version |
| 80 | if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { |
| 81 | throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) |
| 82 | } |
| 83 | return binding |
| 84 | } catch (e) { |
| 85 | loadErrors.push(e) |
| 86 | } |
| 87 | } else if (process.arch === 'arm') { |
| 88 | try { |
| 89 | return require('./impit-node.android-arm-eabi.node') |
| 90 | } catch (e) { |
| 91 | loadErrors.push(e) |
| 92 | } |
| 93 | try { |
| 94 | const binding = require('impit-android-arm-eabi') |
| 95 | const bindingPackageVersion = require('impit-android-arm-eabi/package.json').version |
| 96 | if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { |
| 97 | throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) |
| 98 | } |
| 99 | return binding |
| 100 | } catch (e) { |
| 101 | loadErrors.push(e) |
| 102 | } |
| 103 | } else { |
| 104 | loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) |
| 105 | } |
| 106 | } else if (process.platform === 'win32') { |
| 107 | if (process.arch === 'x64') { |
| 108 | if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { |
| 109 | try { |
| 110 | return require('./impit-node.win32-x64-gnu.node') |
| 111 | } catch (e) { |
| 112 | loadErrors.push(e) |
| 113 | } |
| 114 | try { |
| 115 | const binding = require('impit-win32-x64-gnu') |
| 116 | const bindingPackageVersion = require('impit-win32-x64-gnu/package.json').version |
| 117 | if (bindingPackageVersion !== '0.10.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { |
| 118 | throw new Error(`Native binding package version mismatch, expected 0.10.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) |
| 119 | } |
| 120 | return binding |