diff --git a/Cargo.toml b/Cargo.toml index b5fafd7f..b2db288f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["./crates/alloc", "./packages/argon2", "./packages/bcrypt", "./packa resolver = "2" [workspace.dependencies] - argon2 = { version = "0.5", features = ["rand"] } + argon2 = { version = "0.5", features = ["rand", "std"] } base64 = { version = "0.22" } bcrypt = "0.17" blowfish = { version = "0.9", features = ["bcrypt"] } @@ -20,7 +20,7 @@ resolver = "2" once_cell = "1" quickcheck = "1.0" rand = "0.9" - rand_core = { version = "0.9", features = ["getrandom"] } + rand_core = { version = "0.9", features = ["os_rng"] } serde = "1.0" serde_json = "1.0" xxhash-rust = { version = "0.8", features = ["xxh32", "const_xxh32", "xxh64", "const_xxh64", "xxh3", "const_xxh3"] } diff --git a/package.json b/package.json index fadf4184..2f35aac6 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "postinstall": "husky install" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "@napi-rs/wasm-runtime": "^0.2.5", "@taplo/cli": "^0.7.0", "@tybys/wasm-util": "^0.10.0", diff --git a/packages/argon2/Cargo.toml b/packages/argon2/Cargo.toml index 810b6407..e433358b 100644 --- a/packages/argon2/Cargo.toml +++ b/packages/argon2/Cargo.toml @@ -11,7 +11,7 @@ argon2 = { workspace = true } global_alloc = { workspace = true } napi = { workspace = true, features = ["napi3"] } napi-derive = { workspace = true, default-features = false, features = ["type-def"] } -rand_core = { workspace = true } +rand_core = { version = "0.6", features = ["getrandom"] } [build-dependencies] napi-build = { workspace = true } diff --git a/packages/argon2/argon2.wasi-browser.js b/packages/argon2/argon2.wasi-browser.js index 83058ec7..0496cc10 100644 --- a/packages/argon2/argon2.wasi-browser.js +++ b/packages/argon2/argon2.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './argon2.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./argon2.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,24 +45,14 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__Algorithm_0']?.() - __napiInstance.exports['__napi_register__Version_1']?.() - __napiInstance.exports['__napi_register__Options_struct_2']?.() - __napiInstance.exports['__napi_register__HashTask_impl_3']?.() - __napiInstance.exports['__napi_register__hash_4']?.() - __napiInstance.exports['__napi_register__hash_sync_5']?.() - __napiInstance.exports['__napi_register__RawHashTask_impl_6']?.() - __napiInstance.exports['__napi_register__hash_raw_7']?.() - __napiInstance.exports['__napi_register__hash_raw_sync_8']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_9']?.() - __napiInstance.exports['__napi_register__verify_10']?.() - __napiInstance.exports['__napi_register__verify_sync_11']?.() -} +export default __napiModule.exports export const Algorithm = __napiModule.exports.Algorithm export const hash = __napiModule.exports.hash export const hashRaw = __napiModule.exports.hashRaw diff --git a/packages/argon2/argon2.wasi.cjs b/packages/argon2/argon2.wasi.cjs index 3fc8ddad..09dc5170 100644 --- a/packages/argon2/argon2.wasi.cjs +++ b/packages/argon2/argon2.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,24 +100,14 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__Algorithm_0']?.() - __napiInstance.exports['__napi_register__Version_1']?.() - __napiInstance.exports['__napi_register__Options_struct_2']?.() - __napiInstance.exports['__napi_register__HashTask_impl_3']?.() - __napiInstance.exports['__napi_register__hash_4']?.() - __napiInstance.exports['__napi_register__hash_sync_5']?.() - __napiInstance.exports['__napi_register__RawHashTask_impl_6']?.() - __napiInstance.exports['__napi_register__hash_raw_7']?.() - __napiInstance.exports['__napi_register__hash_raw_sync_8']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_9']?.() - __napiInstance.exports['__napi_register__verify_10']?.() - __napiInstance.exports['__napi_register__verify_sync_11']?.() -} +module.exports = __napiModule.exports module.exports.Algorithm = __napiModule.exports.Algorithm module.exports.hash = __napiModule.exports.hash module.exports.hashRaw = __napiModule.exports.hashRaw diff --git a/packages/argon2/index.js b/packages/argon2/index.js index 1b66a833..11410f55 100644 --- a/packages/argon2/index.js +++ b/packages/argon2/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./argon2.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-android-arm64') + const binding = require('@node-rs/argon2-android-arm64') + const bindingPackageVersion = require('@node-rs/argon2-android-arm64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./argon2.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-android-arm-eabi') + const binding = require('@node-rs/argon2-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/argon2-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./argon2.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/argon2-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./argon2.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-win32-x64-msvc') + const binding = require('@node-rs/argon2-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/argon2-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./argon2.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-win32-ia32-msvc') + const binding = require('@node-rs/argon2-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/argon2-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./argon2.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-win32-arm64-msvc') + const binding = require('@node-rs/argon2-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/argon2-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./argon2.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./argon2.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-darwin-universal') + const bindingPackageVersion = require('@node-rs/argon2-darwin-universal/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./argon2.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-darwin-x64') + const binding = require('@node-rs/argon2-darwin-x64') + const bindingPackageVersion = require('@node-rs/argon2-darwin-x64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./argon2.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-darwin-arm64') + const binding = require('@node-rs/argon2-darwin-arm64') + const bindingPackageVersion = require('@node-rs/argon2-darwin-arm64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-freebsd-x64') + const binding = require('@node-rs/argon2-freebsd-x64') + const bindingPackageVersion = require('@node-rs/argon2-freebsd-x64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./argon2.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/argon2-freebsd-arm64') + const binding = require('@node-rs/argon2-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/argon2-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./argon2.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./argon2.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/argon2-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./argon2.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./argon2.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./argon2.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./argon2.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/argon2-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./argon2.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./argon2.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./argon2.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/argon2-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./argon2.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/argon2-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./argon2.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/argon2-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./argon2.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/argon2-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./argon2.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./argon2.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/argon2-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./argon2.linux-arm-gnueabihf.node') + return require('./argon2.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/argon2-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./argon2.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-linux-arm-gnueabihf') + const binding = require('@node-rs/argon2-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./argon2.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./argon2.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-linux-riscv64-musl') + const binding = require('@node-rs/argon2-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/argon2-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./argon2.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./argon2.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-linux-riscv64-gnu') + const binding = require('@node-rs/argon2-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/argon2-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./argon2.linux-ppc64-gnu.node') + return require('./argon2.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-linux-ppc64-gnu') + const binding = require('@node-rs/argon2-openharmony-x64') + const bindingPackageVersion = require('@node-rs/argon2-openharmony-x64/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./argon2.linux-s390x-gnu.node') + return require('./argon2.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/argon2-linux-s390x-gnu') + const binding = require('@node-rs/argon2-openharmony-arm') + const bindingPackageVersion = require('@node-rs/argon2-openharmony-arm/package.json').version + if (bindingPackageVersion !== '2.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,35 +526,52 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./argon2.wasi.cjs') + wasiBinding = require('./argon2.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/argon2-wasm32-wasi') + wasiBinding = require('@node-rs/argon2-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.Algorithm = nativeBinding.Algorithm module.exports.hash = nativeBinding.hash module.exports.hashRaw = nativeBinding.hashRaw diff --git a/packages/argon2/package.json b/packages/argon2/package.json index f597c501..09d844ef 100644 --- a/packages/argon2/package.json +++ b/packages/argon2/package.json @@ -62,7 +62,7 @@ "version": "napi version" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "argon2": "^0.44.0", "cross-env": "^7.0.3", "tinybench": "^3.0.0" diff --git a/packages/bcrypt/bcrypt.wasi-browser.js b/packages/bcrypt/bcrypt.wasi-browser.js index dcb3a9a4..3a483db0 100644 --- a/packages/bcrypt/bcrypt.wasi-browser.js +++ b/packages/bcrypt/bcrypt.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './bcrypt.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./bcrypt.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,22 +45,14 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__HashTask_impl_0']?.() - __napiInstance.exports['__napi_register__SaltTask_impl_1']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_2']?.() - __napiInstance.exports['__napi_register__DEFAULT_COST_3']?.() - __napiInstance.exports['__napi_register__gen_salt_sync_4']?.() - __napiInstance.exports['__napi_register__gen_salt_js_5']?.() - __napiInstance.exports['__napi_register__hash_sync_6']?.() - __napiInstance.exports['__napi_register__hash_7']?.() - __napiInstance.exports['__napi_register__verify_sync_8']?.() - __napiInstance.exports['__napi_register__verify_9']?.() -} +export default __napiModule.exports export const DEFAULT_COST = __napiModule.exports.DEFAULT_COST export const genSalt = __napiModule.exports.genSalt export const genSaltSync = __napiModule.exports.genSaltSync diff --git a/packages/bcrypt/bcrypt.wasi.cjs b/packages/bcrypt/bcrypt.wasi.cjs index 275da8b8..d2530c0d 100644 --- a/packages/bcrypt/bcrypt.wasi.cjs +++ b/packages/bcrypt/bcrypt.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,22 +100,14 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__HashTask_impl_0']?.() - __napiInstance.exports['__napi_register__SaltTask_impl_1']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_2']?.() - __napiInstance.exports['__napi_register__DEFAULT_COST_3']?.() - __napiInstance.exports['__napi_register__gen_salt_sync_4']?.() - __napiInstance.exports['__napi_register__gen_salt_js_5']?.() - __napiInstance.exports['__napi_register__hash_sync_6']?.() - __napiInstance.exports['__napi_register__hash_7']?.() - __napiInstance.exports['__napi_register__verify_sync_8']?.() - __napiInstance.exports['__napi_register__verify_9']?.() -} +module.exports = __napiModule.exports module.exports.DEFAULT_COST = __napiModule.exports.DEFAULT_COST module.exports.genSalt = __napiModule.exports.genSalt module.exports.genSaltSync = __napiModule.exports.genSaltSync diff --git a/packages/bcrypt/binding.js b/packages/bcrypt/binding.js index a923392b..c80e8c00 100644 --- a/packages/bcrypt/binding.js +++ b/packages/bcrypt/binding.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./bcrypt.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-android-arm64') + const binding = require('@node-rs/bcrypt-android-arm64') + const bindingPackageVersion = require('@node-rs/bcrypt-android-arm64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./bcrypt.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-android-arm-eabi') + const binding = require('@node-rs/bcrypt-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/bcrypt-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./bcrypt.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/bcrypt-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./bcrypt.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-win32-x64-msvc') + const binding = require('@node-rs/bcrypt-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/bcrypt-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./bcrypt.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-win32-ia32-msvc') + const binding = require('@node-rs/bcrypt-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/bcrypt-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./bcrypt.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-win32-arm64-msvc') + const binding = require('@node-rs/bcrypt-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/bcrypt-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./bcrypt.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./bcrypt.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-darwin-universal') + const bindingPackageVersion = require('@node-rs/bcrypt-darwin-universal/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./bcrypt.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-darwin-x64') + const binding = require('@node-rs/bcrypt-darwin-x64') + const bindingPackageVersion = require('@node-rs/bcrypt-darwin-x64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./bcrypt.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-darwin-arm64') + const binding = require('@node-rs/bcrypt-darwin-arm64') + const bindingPackageVersion = require('@node-rs/bcrypt-darwin-arm64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-freebsd-x64') + const binding = require('@node-rs/bcrypt-freebsd-x64') + const bindingPackageVersion = require('@node-rs/bcrypt-freebsd-x64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./bcrypt.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-freebsd-arm64') + const binding = require('@node-rs/bcrypt-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/bcrypt-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./bcrypt.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./bcrypt.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./bcrypt.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./bcrypt.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./bcrypt.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./bcrypt.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./bcrypt.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./bcrypt.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./bcrypt.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/bcrypt-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./bcrypt.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./bcrypt.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./bcrypt.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./bcrypt.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./bcrypt.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./bcrypt.linux-arm-gnueabihf.node') + return require('./bcrypt.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/bcrypt-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./bcrypt.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-linux-arm-gnueabihf') + const binding = require('@node-rs/bcrypt-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./bcrypt.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./bcrypt.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-linux-riscv64-musl') + const binding = require('@node-rs/bcrypt-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/bcrypt-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./bcrypt.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./bcrypt.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-linux-riscv64-gnu') + const binding = require('@node-rs/bcrypt-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/bcrypt-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./bcrypt.linux-ppc64-gnu.node') + return require('./bcrypt.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-linux-ppc64-gnu') + const binding = require('@node-rs/bcrypt-openharmony-x64') + const bindingPackageVersion = require('@node-rs/bcrypt-openharmony-x64/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./bcrypt.linux-s390x-gnu.node') + return require('./bcrypt.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/bcrypt-linux-s390x-gnu') + const binding = require('@node-rs/bcrypt-openharmony-arm') + const bindingPackageVersion = require('@node-rs/bcrypt-openharmony-arm/package.json').version + if (bindingPackageVersion !== '1.10.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,35 +526,52 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./bcrypt.wasi.cjs') + wasiBinding = require('./bcrypt.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/bcrypt-wasm32-wasi') + wasiBinding = require('@node-rs/bcrypt-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.DEFAULT_COST = nativeBinding.DEFAULT_COST module.exports.genSalt = nativeBinding.genSalt module.exports.genSaltSync = nativeBinding.genSaltSync diff --git a/packages/bcrypt/package.json b/packages/bcrypt/package.json index 2277244b..9b3a87bc 100644 --- a/packages/bcrypt/package.json +++ b/packages/bcrypt/package.json @@ -72,7 +72,7 @@ "devDependencies": { "@cwasm/openbsd-bcrypt": "^0.1.0", "@cwasm/openwall-bcrypt": "^0.1.0", - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "@types/bcrypt": "^5.0.2", "@types/bcryptjs": "^2.4.6", "bcrypt": "^5.1.1", diff --git a/packages/crc32/benchmark/crc32.ts b/packages/crc32/benchmark/crc32.ts index b8a462ce..30aa2293 100644 --- a/packages/crc32/benchmark/crc32.ts +++ b/packages/crc32/benchmark/crc32.ts @@ -1,6 +1,7 @@ import { Bench } from 'tinybench' import { crc32 as crc32Node } from 'crc' import Sse4Crc32 from 'sse4_crc32' +import { crc32 as crc32NodeZlib } from 'node:zlib' import { crc32c, crc32 } from '../index.js' @@ -24,6 +25,7 @@ const initialCrc32c = Sse4Crc32.calculate(TEST_BUFFER) console.assert(crc32(TEST_BUFFER) === initialCrc32) console.assert(crc32c(TEST_BUFFER) === initialCrc32c) +console.assert(crc32NodeZlib(TEST_BUFFER) === initialCrc32) const suite = new Bench({ name: 'crc32c without initial crc', @@ -88,3 +90,35 @@ suite4 await suite4.run() console.table(suite4.table()) + +const suite5 = new Bench({ + name: 'node:zlib crc32 without initial crc', +}) + +suite5 + .add('@node/rs crc32', () => { + crc32(TEST_BUFFER) + }) + .add('node:zlib crc32', () => { + crc32NodeZlib(TEST_BUFFER) + }) + +await suite5.run() + +console.table(suite5.table()) + +const suite6 = new Bench({ + name: 'node:zlib crc32 with initial crc', +}) + +suite6 + .add('@node/rs crc32', () => { + crc32(TEST_BUFFER, initialCrc32) + }) + .add('node:zlib crc32', () => { + crc32NodeZlib(TEST_BUFFER, initialCrc32) + }) + +await suite6.run() + +console.table(suite6.table()) diff --git a/packages/crc32/crc32.wasi-browser.js b/packages/crc32/crc32.wasi-browser.js index de6f5471..edfc8da7 100644 --- a/packages/crc32/crc32.wasi-browser.js +++ b/packages/crc32/crc32.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './crc32.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./crc32.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,13 +45,13 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__crc32c_0']?.() - __napiInstance.exports['__napi_register__crc32_1']?.() -} +export default __napiModule.exports export const crc32 = __napiModule.exports.crc32 export const crc32c = __napiModule.exports.crc32c diff --git a/packages/crc32/crc32.wasi.cjs b/packages/crc32/crc32.wasi.cjs index 56ab2e75..781c88c2 100644 --- a/packages/crc32/crc32.wasi.cjs +++ b/packages/crc32/crc32.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,13 +100,13 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__crc32c_0']?.() - __napiInstance.exports['__napi_register__crc32_1']?.() -} +module.exports = __napiModule.exports module.exports.crc32 = __napiModule.exports.crc32 module.exports.crc32c = __napiModule.exports.crc32c diff --git a/packages/crc32/index.d.ts b/packages/crc32/index.d.ts index 0f05745b..30549161 100644 --- a/packages/crc32/index.d.ts +++ b/packages/crc32/index.d.ts @@ -1,5 +1,5 @@ /* auto-generated by NAPI-RS */ /* eslint-disable */ -export declare function crc32(input: string | Uint8Array, initialState?: number | undefined | null): number +export declare function crc32(input: Uint8Array | string, initialState?: number | undefined | null): number -export declare function crc32c(input: string | Uint8Array, initialState?: number | undefined | null): number +export declare function crc32c(input: Uint8Array | string, initialState?: number | undefined | null): number diff --git a/packages/crc32/index.js b/packages/crc32/index.js index 2af6189e..65e98f0d 100644 --- a/packages/crc32/index.js +++ b/packages/crc32/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./crc32.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-android-arm64') + const binding = require('@node-rs/crc32-android-arm64') + const bindingPackageVersion = require('@node-rs/crc32-android-arm64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./crc32.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-android-arm-eabi') + const binding = require('@node-rs/crc32-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/crc32-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./crc32.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/crc32-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./crc32.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-win32-x64-msvc') + const binding = require('@node-rs/crc32-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/crc32-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./crc32.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-win32-ia32-msvc') + const binding = require('@node-rs/crc32-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/crc32-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./crc32.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-win32-arm64-msvc') + const binding = require('@node-rs/crc32-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/crc32-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./crc32.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./crc32.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-darwin-universal') + const bindingPackageVersion = require('@node-rs/crc32-darwin-universal/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./crc32.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-darwin-x64') + const binding = require('@node-rs/crc32-darwin-x64') + const bindingPackageVersion = require('@node-rs/crc32-darwin-x64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./crc32.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-darwin-arm64') + const binding = require('@node-rs/crc32-darwin-arm64') + const bindingPackageVersion = require('@node-rs/crc32-darwin-arm64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-freebsd-x64') + const binding = require('@node-rs/crc32-freebsd-x64') + const bindingPackageVersion = require('@node-rs/crc32-freebsd-x64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./crc32.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/crc32-freebsd-arm64') + const binding = require('@node-rs/crc32-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/crc32-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./crc32.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./crc32.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/crc32-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./crc32.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./crc32.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./crc32.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./crc32.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/crc32-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./crc32.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./crc32.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./crc32.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/crc32-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./crc32.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/crc32-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./crc32.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/crc32-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./crc32.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/crc32-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./crc32.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./crc32.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/crc32-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./crc32.linux-arm-gnueabihf.node') + return require('./crc32.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/crc32-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./crc32.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-linux-arm-gnueabihf') + const binding = require('@node-rs/crc32-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./crc32.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./crc32.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-linux-riscv64-musl') + const binding = require('@node-rs/crc32-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/crc32-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./crc32.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./crc32.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-linux-riscv64-gnu') + const binding = require('@node-rs/crc32-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/crc32-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./crc32.linux-ppc64-gnu.node') + return require('./crc32.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-linux-ppc64-gnu') + const binding = require('@node-rs/crc32-openharmony-x64') + const bindingPackageVersion = require('@node-rs/crc32-openharmony-x64/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./crc32.linux-s390x-gnu.node') + return require('./crc32.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/crc32-linux-s390x-gnu') + const binding = require('@node-rs/crc32-openharmony-arm') + const bindingPackageVersion = require('@node-rs/crc32-openharmony-arm/package.json').version + if (bindingPackageVersion !== '1.10.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.10.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,34 +526,51 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./crc32.wasi.cjs') + wasiBinding = require('./crc32.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/crc32-wasm32-wasi') + wasiBinding = require('@node-rs/crc32-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.crc32 = nativeBinding.crc32 module.exports.crc32c = nativeBinding.crc32c diff --git a/packages/crc32/package.json b/packages/crc32/package.json index 4ec73726..3b74bb46 100644 --- a/packages/crc32/package.json +++ b/packages/crc32/package.json @@ -64,7 +64,7 @@ "url": "https://github.com/napi-rs/node-rs/issues" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "@types/crc": "^4.0.0", "@types/sse4_crc32": "^7.0.3", "buffer": "^6.0.3", diff --git a/packages/jieba/index.js b/packages/jieba/index.js index 4dc0d3c0..05ca7e17 100644 --- a/packages/jieba/index.js +++ b/packages/jieba/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./jieba.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-android-arm64') + const binding = require('@node-rs/jieba-android-arm64') + const bindingPackageVersion = require('@node-rs/jieba-android-arm64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./jieba.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-android-arm-eabi') + const binding = require('@node-rs/jieba-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/jieba-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./jieba.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/jieba-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./jieba.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-win32-x64-msvc') + const binding = require('@node-rs/jieba-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/jieba-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./jieba.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-win32-ia32-msvc') + const binding = require('@node-rs/jieba-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/jieba-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jieba.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-win32-arm64-msvc') + const binding = require('@node-rs/jieba-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/jieba-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./jieba.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./jieba.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-darwin-universal') + const bindingPackageVersion = require('@node-rs/jieba-darwin-universal/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./jieba.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-darwin-x64') + const binding = require('@node-rs/jieba-darwin-x64') + const bindingPackageVersion = require('@node-rs/jieba-darwin-x64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jieba.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-darwin-arm64') + const binding = require('@node-rs/jieba-darwin-arm64') + const bindingPackageVersion = require('@node-rs/jieba-darwin-arm64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-freebsd-x64') + const binding = require('@node-rs/jieba-freebsd-x64') + const bindingPackageVersion = require('@node-rs/jieba-freebsd-x64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jieba.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jieba-freebsd-arm64') + const binding = require('@node-rs/jieba-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/jieba-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./jieba.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./jieba.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/jieba-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jieba.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./jieba.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./jieba.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./jieba.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/jieba-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jieba.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./jieba.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./jieba.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jieba-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./jieba.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/jieba-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./jieba.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/jieba-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./jieba.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/jieba-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./jieba.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./jieba.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/jieba-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jieba.linux-arm-gnueabihf.node') + return require('./jieba.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jieba-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./jieba.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-linux-arm-gnueabihf') + const binding = require('@node-rs/jieba-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./jieba.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./jieba.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-linux-riscv64-musl') + const binding = require('@node-rs/jieba-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/jieba-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./jieba.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./jieba.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-linux-riscv64-gnu') + const binding = require('@node-rs/jieba-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/jieba-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./jieba.linux-ppc64-gnu.node') + return require('./jieba.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-linux-ppc64-gnu') + const binding = require('@node-rs/jieba-openharmony-x64') + const bindingPackageVersion = require('@node-rs/jieba-openharmony-x64/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./jieba.linux-s390x-gnu.node') + return require('./jieba.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jieba-linux-s390x-gnu') + const binding = require('@node-rs/jieba-openharmony-arm') + const bindingPackageVersion = require('@node-rs/jieba-openharmony-arm/package.json').version + if (bindingPackageVersion !== '2.0.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,34 +526,51 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./jieba.wasi.cjs') + wasiBinding = require('./jieba.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/jieba-wasm32-wasi') + wasiBinding = require('@node-rs/jieba-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.Jieba = nativeBinding.Jieba module.exports.TfIdf = nativeBinding.TfIdf diff --git a/packages/jieba/jieba.wasi-browser.js b/packages/jieba/jieba.wasi-browser.js index bc9ce22f..117cca38 100644 --- a/packages/jieba/jieba.wasi-browser.js +++ b/packages/jieba/jieba.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './jieba.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./jieba.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,19 +45,13 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__TaggedWord_struct_0']?.() - __napiInstance.exports['__napi_register__Keyword_struct_1']?.() - __napiInstance.exports['__napi_register__KeywordExtractConfig_struct_2']?.() - __napiInstance.exports['__napi_register__TfIdf_struct_3']?.() - __napiInstance.exports['__napi_register__TfIdf_impl_9']?.() - __napiInstance.exports['__napi_register__Jieba_struct_10']?.() - __napiInstance.exports['__napi_register__Jieba_impl_19']?.() - __napiInstance.exports['__napi_register__CutTask_impl_20']?.() -} +export default __napiModule.exports export const Jieba = __napiModule.exports.Jieba export const TfIdf = __napiModule.exports.TfIdf diff --git a/packages/jieba/jieba.wasi.cjs b/packages/jieba/jieba.wasi.cjs index a9e12546..b6e69666 100644 --- a/packages/jieba/jieba.wasi.cjs +++ b/packages/jieba/jieba.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,19 +100,13 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__TaggedWord_struct_0']?.() - __napiInstance.exports['__napi_register__Keyword_struct_1']?.() - __napiInstance.exports['__napi_register__KeywordExtractConfig_struct_2']?.() - __napiInstance.exports['__napi_register__TfIdf_struct_3']?.() - __napiInstance.exports['__napi_register__TfIdf_impl_9']?.() - __napiInstance.exports['__napi_register__Jieba_struct_10']?.() - __napiInstance.exports['__napi_register__Jieba_impl_19']?.() - __napiInstance.exports['__napi_register__CutTask_impl_20']?.() -} +module.exports = __napiModule.exports module.exports.Jieba = __napiModule.exports.Jieba module.exports.TfIdf = __napiModule.exports.TfIdf diff --git a/packages/jieba/package.json b/packages/jieba/package.json index 67d1878f..aef70c82 100644 --- a/packages/jieba/package.json +++ b/packages/jieba/package.json @@ -68,7 +68,7 @@ "url": "https://github.com/napi-rs/node-rs/issues" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "cross-env": "^7.0.3", "nodejieba": "^3.0.0", "tinybench": "^3.0.0" diff --git a/packages/jieba/src/lib.rs b/packages/jieba/src/lib.rs index 84e97222..a16b9c8a 100644 --- a/packages/jieba/src/lib.rs +++ b/packages/jieba/src/lib.rs @@ -29,19 +29,19 @@ pub struct Keyword { /// Creates a KeywordExtractConfig state that contains filter criteria as /// well as segmentation configuration for use by keyword extraction /// implementations. -pub struct KeywordExtractConfig { +pub struct KeywordExtractConfig<'a> { #[napi(ts_type = "Set | undefined")] - pub stop_words: Option, + pub stop_words: Option>, /// Any segments less than this length will not be considered a Keyword pub min_keyword_length: Option, /// If true, fall back to hmm model if segment cannot be found in the dictionary pub use_hmm: Option, } -impl TryFrom for jieba_rs::KeywordExtractConfig { +impl TryFrom> for jieba_rs::KeywordExtractConfig { type Error = Error; - fn try_from(config: KeywordExtractConfig) -> Result { + fn try_from(config: KeywordExtractConfig<'_>) -> Result { let mut stop_words = BTreeSet::new(); if let Some(sw) = config.stop_words.as_ref() { let iter_func: Function<'_, (), Object> = sw.get_named_property_unchecked("values")?; diff --git a/packages/jsonwebtoken/index.js b/packages/jsonwebtoken/index.js index 96e6cf08..1a91a46a 100644 --- a/packages/jsonwebtoken/index.js +++ b/packages/jsonwebtoken/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./jsonwebtoken.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-android-arm64') + const binding = require('@node-rs/jsonwebtoken-android-arm64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-android-arm64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./jsonwebtoken.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-android-arm-eabi') + const binding = require('@node-rs/jsonwebtoken-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./jsonwebtoken.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/jsonwebtoken-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./jsonwebtoken.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-win32-x64-msvc') + const binding = require('@node-rs/jsonwebtoken-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./jsonwebtoken.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-win32-ia32-msvc') + const binding = require('@node-rs/jsonwebtoken-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jsonwebtoken.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-win32-arm64-msvc') + const binding = require('@node-rs/jsonwebtoken-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./jsonwebtoken.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./jsonwebtoken.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-darwin-universal') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-darwin-universal/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./jsonwebtoken.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-darwin-x64') + const binding = require('@node-rs/jsonwebtoken-darwin-x64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-darwin-x64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jsonwebtoken.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-darwin-arm64') + const binding = require('@node-rs/jsonwebtoken-darwin-arm64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-darwin-arm64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-freebsd-x64') + const binding = require('@node-rs/jsonwebtoken-freebsd-x64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-freebsd-x64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./jsonwebtoken.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-freebsd-arm64') + const binding = require('@node-rs/jsonwebtoken-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./jsonwebtoken.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./jsonwebtoken.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jsonwebtoken.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./jsonwebtoken.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./jsonwebtoken.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./jsonwebtoken.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jsonwebtoken.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./jsonwebtoken.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./jsonwebtoken.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/jsonwebtoken-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./jsonwebtoken.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./jsonwebtoken.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./jsonwebtoken.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./jsonwebtoken.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./jsonwebtoken.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./jsonwebtoken.linux-arm-gnueabihf.node') + return require('./jsonwebtoken.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/jsonwebtoken-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./jsonwebtoken.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-linux-arm-gnueabihf') + const binding = require('@node-rs/jsonwebtoken-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./jsonwebtoken.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./jsonwebtoken.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-linux-riscv64-musl') + const binding = require('@node-rs/jsonwebtoken-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./jsonwebtoken.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./jsonwebtoken.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-linux-riscv64-gnu') + const binding = require('@node-rs/jsonwebtoken-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./jsonwebtoken.linux-ppc64-gnu.node') + return require('./jsonwebtoken.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-linux-ppc64-gnu') + const binding = require('@node-rs/jsonwebtoken-openharmony-x64') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-openharmony-x64/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./jsonwebtoken.linux-s390x-gnu.node') + return require('./jsonwebtoken.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/jsonwebtoken-linux-s390x-gnu') + const binding = require('@node-rs/jsonwebtoken-openharmony-arm') + const bindingPackageVersion = require('@node-rs/jsonwebtoken-openharmony-arm/package.json').version + if (bindingPackageVersion !== '0.5.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.5.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,35 +526,52 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./jsonwebtoken.wasi.cjs') + wasiBinding = require('./jsonwebtoken.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/jsonwebtoken-wasm32-wasi') + wasiBinding = require('@node-rs/jsonwebtoken-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.Algorithm = nativeBinding.Algorithm module.exports.decodeHeader = nativeBinding.decodeHeader module.exports.sign = nativeBinding.sign diff --git a/packages/jsonwebtoken/jsonwebtoken.wasi-browser.js b/packages/jsonwebtoken/jsonwebtoken.wasi-browser.js index a060f255..0bde969f 100644 --- a/packages/jsonwebtoken/jsonwebtoken.wasi-browser.js +++ b/packages/jsonwebtoken/jsonwebtoken.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './jsonwebtoken.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./jsonwebtoken.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,22 +45,14 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__Algorithm_0']?.() - __napiInstance.exports['__napi_register__decode_header_1']?.() - __napiInstance.exports['__napi_register__Header_struct_2']?.() - __napiInstance.exports['__napi_register__SignTask_impl_3']?.() - __napiInstance.exports['__napi_register__sign_4']?.() - __napiInstance.exports['__napi_register__sign_sync_5']?.() - __napiInstance.exports['__napi_register__Validation_struct_6']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_7']?.() - __napiInstance.exports['__napi_register__verify_8']?.() - __napiInstance.exports['__napi_register__verify_sync_9']?.() -} +export default __napiModule.exports export const Algorithm = __napiModule.exports.Algorithm export const decodeHeader = __napiModule.exports.decodeHeader export const sign = __napiModule.exports.sign diff --git a/packages/jsonwebtoken/jsonwebtoken.wasi.cjs b/packages/jsonwebtoken/jsonwebtoken.wasi.cjs index 9df70a23..97fe8b60 100644 --- a/packages/jsonwebtoken/jsonwebtoken.wasi.cjs +++ b/packages/jsonwebtoken/jsonwebtoken.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,22 +100,14 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__Algorithm_0']?.() - __napiInstance.exports['__napi_register__decode_header_1']?.() - __napiInstance.exports['__napi_register__Header_struct_2']?.() - __napiInstance.exports['__napi_register__SignTask_impl_3']?.() - __napiInstance.exports['__napi_register__sign_4']?.() - __napiInstance.exports['__napi_register__sign_sync_5']?.() - __napiInstance.exports['__napi_register__Validation_struct_6']?.() - __napiInstance.exports['__napi_register__VerifyTask_impl_7']?.() - __napiInstance.exports['__napi_register__verify_8']?.() - __napiInstance.exports['__napi_register__verify_sync_9']?.() -} +module.exports = __napiModule.exports module.exports.Algorithm = __napiModule.exports.Algorithm module.exports.decodeHeader = __napiModule.exports.decodeHeader module.exports.sign = __napiModule.exports.sign diff --git a/packages/jsonwebtoken/package.json b/packages/jsonwebtoken/package.json index c777ad9e..4419946e 100644 --- a/packages/jsonwebtoken/package.json +++ b/packages/jsonwebtoken/package.json @@ -64,7 +64,7 @@ "node": ">= 10" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "@oxc-node/core": "^0.0.34", "@types/jsonwebtoken": "^9.0.6", "cross-env": "^7.0.3", diff --git a/packages/xxhash/index.js b/packages/xxhash/index.js index 651a7469..cdee44af 100644 --- a/packages/xxhash/index.js +++ b/packages/xxhash/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -35,7 +32,11 @@ const isMuslFromFilesystem = () => { } const isMuslFromReport = () => { - const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + let report = null + if (typeof process.report?.getReport === 'function') { + process.report.excludeNetwork = true + report = process.report.getReport() + } if (!report) { return null } @@ -60,7 +61,13 @@ const isMuslFromChildProcess = () => { } function requireNative() { - if (process.platform === 'android') { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err) + } + } else if (process.platform === 'android') { if (process.arch === 'arm64') { try { return require('./xxhash.android-arm64.node') @@ -68,11 +75,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-android-arm64') + const binding = require('@node-rs/xxhash-android-arm64') + const bindingPackageVersion = require('@node-rs/xxhash-android-arm64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm') { try { return require('./xxhash.android-arm-eabi.node') @@ -80,27 +91,53 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-android-arm-eabi') + const binding = require('@node-rs/xxhash-android-arm-eabi') + const bindingPackageVersion = require('@node-rs/xxhash-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./xxhash.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@node-rs/xxhash-win32-x64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./xxhash.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-win32-x64-msvc') + const binding = require('@node-rs/xxhash-win32-x64-msvc') + const bindingPackageVersion = require('@node-rs/xxhash-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - + } } else if (process.arch === 'ia32') { try { return require('./xxhash.win32-ia32-msvc.node') @@ -108,11 +145,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-win32-ia32-msvc') + const binding = require('@node-rs/xxhash-win32-ia32-msvc') + const bindingPackageVersion = require('@node-rs/xxhash-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./xxhash.win32-arm64-msvc.node') @@ -120,26 +161,34 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-win32-arm64-msvc') + const binding = require('@node-rs/xxhash-win32-arm64-msvc') + const bindingPackageVersion = require('@node-rs/xxhash-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) } } else if (process.platform === 'darwin') { try { - return require('./xxhash.darwin-universal.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-darwin-universal') - } catch (e) { - loadErrors.push(e) - } - + return require('./xxhash.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-darwin-universal') + const bindingPackageVersion = require('@node-rs/xxhash-darwin-universal/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } if (process.arch === 'x64') { try { return require('./xxhash.darwin-x64.node') @@ -147,11 +196,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-darwin-x64') + const binding = require('@node-rs/xxhash-darwin-x64') + const bindingPackageVersion = require('@node-rs/xxhash-darwin-x64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./xxhash.darwin-arm64.node') @@ -159,11 +212,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-darwin-arm64') + const binding = require('@node-rs/xxhash-darwin-arm64') + const bindingPackageVersion = require('@node-rs/xxhash-darwin-arm64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) } @@ -175,11 +232,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-freebsd-x64') + const binding = require('@node-rs/xxhash-freebsd-x64') + const bindingPackageVersion = require('@node-rs/xxhash-freebsd-x64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else if (process.arch === 'arm64') { try { return require('./xxhash.freebsd-arm64.node') @@ -187,11 +248,15 @@ function requireNative() { loadErrors.push(e) } try { - return require('@node-rs/xxhash-freebsd-arm64') + const binding = require('@node-rs/xxhash-freebsd-arm64') + const bindingPackageVersion = require('@node-rs/xxhash-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) } @@ -199,133 +264,259 @@ function requireNative() { if (process.arch === 'x64') { if (isMusl()) { try { - return require('./xxhash.linux-x64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-linux-x64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./xxhash.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-x64-musl') + const bindingPackageVersion = require('@node-rs/xxhash-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./xxhash.linux-x64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-linux-x64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./xxhash.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-x64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm64') { if (isMusl()) { try { - return require('./xxhash.linux-arm64-musl.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-linux-arm64-musl') - } catch (e) { - loadErrors.push(e) - } - + return require('./xxhash.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-arm64-musl') + const bindingPackageVersion = require('@node-rs/xxhash-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./xxhash.linux-arm64-gnu.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-linux-arm64-gnu') - } catch (e) { - loadErrors.push(e) - } - + return require('./xxhash.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-arm64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } } else if (process.arch === 'arm') { if (isMusl()) { try { - return require('./xxhash.linux-arm-musleabihf.node') - } catch (e) { - loadErrors.push(e) - } - try { - return require('@node-rs/xxhash-linux-arm-musleabihf') - } catch (e) { - loadErrors.push(e) + return require('./xxhash.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-arm-musleabihf') + const bindingPackageVersion = require('@node-rs/xxhash-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./xxhash.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-arm-gnueabihf') + const bindingPackageVersion = require('@node-rs/xxhash-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./xxhash.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-loong64-musl') + const bindingPackageVersion = require('@node-rs/xxhash-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./xxhash.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-loong64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } - + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./xxhash.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-riscv64-musl') + const bindingPackageVersion = require('@node-rs/xxhash-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else { try { - return require('./xxhash.linux-arm-gnueabihf.node') + return require('./xxhash.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@node-rs/xxhash-linux-riscv64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'ppc64') { + try { + return require('./xxhash.linux-ppc64-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-linux-arm-gnueabihf') + const binding = require('@node-rs/xxhash-linux-ppc64-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'riscv64') { - if (isMusl()) { - try { - return require('./xxhash.linux-riscv64-musl.node') + } else if (process.arch === 's390x') { + try { + return require('./xxhash.linux-s390x-gnu.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-linux-riscv64-musl') + const binding = require('@node-rs/xxhash-linux-s390x-gnu') + const bindingPackageVersion = require('@node-rs/xxhash-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else { - try { - return require('./xxhash.linux-riscv64-gnu.node') + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else if (process.platform === 'openharmony') { + if (process.arch === 'arm64') { + try { + return require('./xxhash.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-linux-riscv64-gnu') + const binding = require('@node-rs/xxhash-openharmony-arm64') + const bindingPackageVersion = require('@node-rs/xxhash-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } - } else if (process.arch === 'ppc64') { + } else if (process.arch === 'x64') { try { - return require('./xxhash.linux-ppc64-gnu.node') + return require('./xxhash.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-linux-ppc64-gnu') + const binding = require('@node-rs/xxhash-openharmony-x64') + const bindingPackageVersion = require('@node-rs/xxhash-openharmony-x64/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - - } else if (process.arch === 's390x') { + } else if (process.arch === 'arm') { try { - return require('./xxhash.linux-s390x-gnu.node') + return require('./xxhash.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@node-rs/xxhash-linux-s390x-gnu') + const binding = require('@node-rs/xxhash-openharmony-arm') + const bindingPackageVersion = require('@node-rs/xxhash-openharmony-arm/package.json').version + if (bindingPackageVersion !== '1.7.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.7.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } - } else { - loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)) } } else { loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) @@ -335,35 +526,52 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./xxhash.wasi.cjs') + wasiBinding = require('./xxhash.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } if (!nativeBinding) { try { - nativeBinding = require('@node-rs/xxhash-wasm32-wasi') + wasiBinding = require('@node-rs/xxhash-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + wasiBindingError.cause = err loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { if (loadErrors.length > 0) { - // TODO Link to documentation with potential fixes - // - The package owner could build/publish bindings for this arch - // - The user may need to bundle the correct files - // - The user may need to re-install node_modules to get new packages - throw new Error('Failed to load native binding', { cause: loadErrors }) + throw new Error( + `Cannot find native binding. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, + ) } throw new Error(`Failed to load native binding`) } +module.exports = nativeBinding module.exports.Xxh32 = nativeBinding.Xxh32 module.exports.Xxh64 = nativeBinding.Xxh64 module.exports.xxh32 = nativeBinding.xxh32 diff --git a/packages/xxhash/package.json b/packages/xxhash/package.json index 240df0e4..0b7a2e3b 100644 --- a/packages/xxhash/package.json +++ b/packages/xxhash/package.json @@ -66,7 +66,7 @@ "url": "https://github.com/napi-rs/node-rs/issues" }, "devDependencies": { - "@napi-rs/cli": "^3.0.0-alpha.64", + "@napi-rs/cli": "^3.5.0", "@oxc-node/core": "^0.0.34", "@types/xxhashjs": "^0.2.4", "cross-env": "^7.0.3", diff --git a/packages/xxhash/xxhash.wasi-browser.js b/packages/xxhash/xxhash.wasi-browser.js index 3848370b..3400f643 100644 --- a/packages/xxhash/xxhash.wasi-browser.js +++ b/packages/xxhash/xxhash.wasi-browser.js @@ -1,16 +1,15 @@ import { - instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, + createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, + instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, WASI as __WASI, - createOnMessage as __wasmCreateOnMessageForFsProxy, } from '@napi-rs/wasm-runtime' -import __wasmUrl from './xxhash.wasm32-wasi.wasm?url' - const __wasi = new __WASI({ version: 'preview1', }) +const __wasmUrl = new URL('./xxhash.wasm32-wasi.wasm', import.meta.url).href const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ @@ -46,24 +45,14 @@ const { return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__xxh32_0']?.() - __napiInstance.exports['__napi_register__Xxh32_struct_1']?.() - __napiInstance.exports['__napi_register__Xxh32_impl_6']?.() - __napiInstance.exports['__napi_register__xxh64_7']?.() - __napiInstance.exports['__napi_register__Xxh64_struct_8']?.() - __napiInstance.exports['__napi_register__Xxh64_impl_13']?.() - __napiInstance.exports['__napi_register__xxh64_14']?.() - __napiInstance.exports['__napi_register__xxh64_with_secret_15']?.() - __napiInstance.exports['__napi_register__xxh128_16']?.() - __napiInstance.exports['__napi_register__xxh128_with_secret_17']?.() - __napiInstance.exports['__napi_register__Xxh3_struct_18']?.() - __napiInstance.exports['__napi_register__Xxh3_impl_24']?.() -} +export default __napiModule.exports export const Xxh32 = __napiModule.exports.Xxh32 export const Xxh64 = __napiModule.exports.Xxh64 export const xxh32 = __napiModule.exports.xxh32 diff --git a/packages/xxhash/xxhash.wasi.cjs b/packages/xxhash/xxhash.wasi.cjs index 360d3b2d..3a97c50a 100644 --- a/packages/xxhash/xxhash.wasi.cjs +++ b/packages/xxhash/xxhash.wasi.cjs @@ -9,9 +9,9 @@ const { WASI: __nodeWASI } = require('node:wasi') const { Worker } = require('node:worker_threads') const { - instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, - getDefaultContext: __emnapiGetDefaultContext, createOnMessage: __wasmCreateOnMessageForFsProxy, + getDefaultContext: __emnapiGetDefaultContext, + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, } = require('@napi-rs/wasm-runtime') const __rootDir = __nodePath.parse(process.cwd()).root @@ -56,15 +56,38 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return 4 } })(), + reuseWorker: true, wasi: __wasi, onCreateWorker() { const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { env: process.env, - execArgv: ['--experimental-wasi-unstable-preview1'], }) worker.onmessage = ({ data }) => { __wasmCreateOnMessageForFsProxy(__nodeFs)(data) } + + // The main thread of Node.js waits for all the active handles before exiting. + // But Rust threads are never waited without `thread::join`. + // So here we hack the code of Node.js to prevent the workers from being referenced (active). + // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415, + // a worker is consist of two handles: kPublicPort and kHandle. + { + const kPublicPort = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kPublicPort") + ); + if (kPublicPort) { + worker[kPublicPort].ref = () => {}; + } + + const kHandle = Object.getOwnPropertySymbols(worker).find(s => + s.toString().includes("kHandle") + ); + if (kHandle) { + worker[kHandle].ref = () => {}; + } + + worker.unref(); + } return worker }, overwriteImports(importObject) { @@ -77,24 +100,14 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule return importObject }, beforeInit({ instance }) { - __napi_rs_initialize_modules(instance) - } + for (const name of Object.keys(instance.exports)) { + if (name.startsWith('__napi_register__')) { + instance.exports[name]() + } + } + }, }) - -function __napi_rs_initialize_modules(__napiInstance) { - __napiInstance.exports['__napi_register__xxh32_0']?.() - __napiInstance.exports['__napi_register__Xxh32_struct_1']?.() - __napiInstance.exports['__napi_register__Xxh32_impl_6']?.() - __napiInstance.exports['__napi_register__xxh64_7']?.() - __napiInstance.exports['__napi_register__Xxh64_struct_8']?.() - __napiInstance.exports['__napi_register__Xxh64_impl_13']?.() - __napiInstance.exports['__napi_register__xxh64_14']?.() - __napiInstance.exports['__napi_register__xxh64_with_secret_15']?.() - __napiInstance.exports['__napi_register__xxh128_16']?.() - __napiInstance.exports['__napi_register__xxh128_with_secret_17']?.() - __napiInstance.exports['__napi_register__Xxh3_struct_18']?.() - __napiInstance.exports['__napi_register__Xxh3_impl_24']?.() -} +module.exports = __napiModule.exports module.exports.Xxh32 = __napiModule.exports.Xxh32 module.exports.Xxh64 = __napiModule.exports.Xxh64 module.exports.xxh32 = __napiModule.exports.xxh32 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5f3ff177..ab40f4f4 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.82.0" +channel = "1.88.0" profile = "default" diff --git a/yarn.lock b/yarn.lock index a1515186..431e3a2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -47,7 +47,7 @@ __metadata: languageName: node linkType: hard -"@emnapi/core@npm:^1.5.0": +"@emnapi/core@npm:^1.5.0, @emnapi/core@npm:^1.7.1": version: 1.7.1 resolution: "@emnapi/core@npm:1.7.1" dependencies: @@ -66,7 +66,7 @@ __metadata: languageName: node linkType: hard -"@emnapi/runtime@npm:^1.5.0": +"@emnapi/runtime@npm:^1.5.0, @emnapi/runtime@npm:^1.7.1": version: 1.7.1 resolution: "@emnapi/runtime@npm:1.7.1" dependencies: @@ -107,188 +107,244 @@ __metadata: languageName: node linkType: hard -"@inquirer/checkbox@npm:^4.0.6": - version: 4.0.6 - resolution: "@inquirer/checkbox@npm:4.0.6" +"@inquirer/ansi@npm:^2.0.2": + version: 2.0.2 + resolution: "@inquirer/ansi@npm:2.0.2" + checksum: 10c0/dd51378cbe358fb968fb5a686e88bede90930cf17ee75ea158f410dbef4ff2a108026159ee38699489c2247b29bedb8100d1f6081a8b63213aaba2ffc6ff2287 + languageName: node + linkType: hard + +"@inquirer/checkbox@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/checkbox@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/figures": "npm:^1.0.9" - "@inquirer/type": "npm:^3.0.2" - ansi-escapes: "npm:^4.3.2" - yoctocolors-cjs: "npm:^2.1.2" + "@inquirer/ansi": "npm:^2.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/figures": "npm:^2.0.2" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/919e3c5d652f1ccd9d5e8e9678e63981a968ba4a0dffe9d9409d94a1951b398218f7dfb05e57aefcb3c3c1d61ac2333160e370b0ff4632ada7a92ebe07a2ca72 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/39e2fa0c9dad1fa1166d6d75a850c752232a7021c1d1872f8c6ce650c523eff076b4282c0d56aa2628361ae57e329e8192ff34637a6f89ec4e490ef1110baf10 languageName: node linkType: hard -"@inquirer/confirm@npm:^5.1.3": - version: 5.1.3 - resolution: "@inquirer/confirm@npm:5.1.3" +"@inquirer/confirm@npm:^6.0.3": + version: 6.0.3 + resolution: "@inquirer/confirm@npm:6.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/ddbca429ebb3a8bf1d10928f4ab0c8eedbf3f74f85ed64c6b26a830f0fbbab5fa964b9ef2eb2c57a10b9afc9ca3921a12e4659f5a83069078cd1a7ce3d0d126d + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/b563bba492f971306be66acefbabde9f1b1efaa70e5e54b673b08e0efa0ac80f0438e769cd36d7fa7357310d1d4b6e021820efe7eba67be5170f8df2112da956 languageName: node linkType: hard -"@inquirer/core@npm:^10.1.4": - version: 10.1.4 - resolution: "@inquirer/core@npm:10.1.4" +"@inquirer/core@npm:^11.1.0": + version: 11.1.0 + resolution: "@inquirer/core@npm:11.1.0" dependencies: - "@inquirer/figures": "npm:^1.0.9" - "@inquirer/type": "npm:^3.0.2" - ansi-escapes: "npm:^4.3.2" + "@inquirer/ansi": "npm:^2.0.2" + "@inquirer/figures": "npm:^2.0.2" + "@inquirer/type": "npm:^4.0.2" cli-width: "npm:^4.1.0" - mute-stream: "npm:^2.0.0" + mute-stream: "npm:^3.0.0" signal-exit: "npm:^4.1.0" - strip-ansi: "npm:^6.0.1" - wrap-ansi: "npm:^6.2.0" - yoctocolors-cjs: "npm:^2.1.2" - checksum: 10c0/4e6c51713c79a0b22381a08a2d11c37f2d696597d01bdecd7b3482889e53e4ac279c55d663a365798ad52becc37052b571bc3ec85ee8a10054c681d9248b88d3 + wrap-ansi: "npm:^9.0.2" + peerDependencies: + "@types/node": ">=18" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/5bd50d751c0f0714e8ff666f6ef888c321cfbfb459cca31030f930081fb2f44833609183feaac9f25f986fd75b2cf7b87313a20f28ac040ab91936daeb8a8161 languageName: node linkType: hard -"@inquirer/editor@npm:^4.2.3": - version: 4.2.3 - resolution: "@inquirer/editor@npm:4.2.3" +"@inquirer/editor@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/editor@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" - external-editor: "npm:^3.1.0" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/external-editor": "npm:^2.0.2" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/0194a660b33e38781c35a6ab531f76beca998e5e30ebc90bb94e2140fd943e0dfcff4f9c650f4f79f74df7dac04c82db254ff8c2d9ef0b55c491523f859a8c2b + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/392f6b4341d29e2f833c4774474bdaeb5447678f9f410fa5d0473f18fb0998ee9fea177abf09e7e4b6132bb24290d71ac306c3770d254c569f722d34c52a367a languageName: node linkType: hard -"@inquirer/expand@npm:^4.0.6": - version: 4.0.6 - resolution: "@inquirer/expand@npm:4.0.6" +"@inquirer/expand@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/expand@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" - yoctocolors-cjs: "npm:^2.1.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/2a4990744edf17528c5cf894b9a7a04f202740fb9e2123fb8ced1e623f5bf9716976b037e1b23e88cfce826a85b6052d49784ac2294644e353767b51a0a2f877 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/97dc7cac0c69b50ef3be0c4a385184ae55777c1523d4c266375ad0cc5ebee7cd27a3172cadd73d7f6229d0c6361f4c55993969ba89f7b7dc0c0dcda4b172a858 languageName: node linkType: hard -"@inquirer/figures@npm:^1.0.9": - version: 1.0.9 - resolution: "@inquirer/figures@npm:1.0.9" - checksum: 10c0/21e1a7c902b2b77f126617b501e0fe0d703fae680a9df472afdae18a3e079756aee85690cef595a14e91d18630118f4a3893aab6832b9232fefc6ab31c804a68 +"@inquirer/external-editor@npm:^2.0.2": + version: 2.0.2 + resolution: "@inquirer/external-editor@npm:2.0.2" + dependencies: + chardet: "npm:^2.1.1" + iconv-lite: "npm:^0.7.0" + peerDependencies: + "@types/node": ">=18" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/f1f0eea821cd10ff602394f71a3ad77f31959cb86dc35716b6a9f94052f70692ed8402fc8288970c5499b5fba2cb1094c6a75d0c098fdc03afb60a3766a7a625 languageName: node linkType: hard -"@inquirer/input@npm:^4.1.3": - version: 4.1.3 - resolution: "@inquirer/input@npm:4.1.3" +"@inquirer/figures@npm:^2.0.2": + version: 2.0.2 + resolution: "@inquirer/figures@npm:2.0.2" + checksum: 10c0/12353dc765c001bc7df4d4570eaa25dba53af4553d02d231e69104e289918327ca3af3626a29885616d35e5d397fc3bfd4bbcc3e2c8d668d3064dd30c3fdf43b + languageName: node + linkType: hard + +"@inquirer/input@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/input@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/251468b9596fcbff286d0817da7408f2a78230c1f84de23361e6362a8a91e5bf4c42c04f4971a8fe751eb0afc4ab1cef0d3766742fd4e693b4b0cbcc72aa8d97 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/24f0445f951faff23fb011a4036fbeb33c279edb5965922c69f164406f719f34d9de4e70bfc74a3ec34f7cc74e341571592ff0bcf80a5dd59a6c0f0058ab95cd languageName: node linkType: hard -"@inquirer/number@npm:^3.0.6": - version: 3.0.6 - resolution: "@inquirer/number@npm:3.0.6" +"@inquirer/number@npm:^4.0.3": + version: 4.0.3 + resolution: "@inquirer/number@npm:4.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/26c030735bdc94053dfca50db1e75c7e325b8dcc009f3f9e6f572d89b67d7b23cfb3920ed2fa6fa34c312b5ebb6b86ba5b4e77c277ce463720eba45052c0d253 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/939f3ba543c2abf006d804d08b0ec1f305a700a00f15c93bbbdcdca28ba07095469b3008a42504d43d8697d07aec334558918e2fcb05b9d361b6c230c9e2f50c languageName: node linkType: hard -"@inquirer/password@npm:^4.0.6": - version: 4.0.6 - resolution: "@inquirer/password@npm:4.0.6" +"@inquirer/password@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/password@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" - ansi-escapes: "npm:^4.3.2" + "@inquirer/ansi": "npm:^2.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/c36f675d350c38156efe255d9b3a052271faff2bfcebf626f5f02092e9110ef8f87a6985e96dd0c2351fa79723d0847bacaa86ae10c1d24526434de96af5503e + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/92102807addbeab0ba10c01f4cd9d6ef66d4f7cabbca294acae03153322663cdcb8b80250d21ec8c9b6996719bccb0a0aea41d03b4829a2ffc182a85ffc19180 languageName: node linkType: hard -"@inquirer/prompts@npm:^7.0.0": - version: 7.2.3 - resolution: "@inquirer/prompts@npm:7.2.3" - dependencies: - "@inquirer/checkbox": "npm:^4.0.6" - "@inquirer/confirm": "npm:^5.1.3" - "@inquirer/editor": "npm:^4.2.3" - "@inquirer/expand": "npm:^4.0.6" - "@inquirer/input": "npm:^4.1.3" - "@inquirer/number": "npm:^3.0.6" - "@inquirer/password": "npm:^4.0.6" - "@inquirer/rawlist": "npm:^4.0.6" - "@inquirer/search": "npm:^3.0.6" - "@inquirer/select": "npm:^4.0.6" +"@inquirer/prompts@npm:^8.0.0": + version: 8.1.0 + resolution: "@inquirer/prompts@npm:8.1.0" + dependencies: + "@inquirer/checkbox": "npm:^5.0.3" + "@inquirer/confirm": "npm:^6.0.3" + "@inquirer/editor": "npm:^5.0.3" + "@inquirer/expand": "npm:^5.0.3" + "@inquirer/input": "npm:^5.0.3" + "@inquirer/number": "npm:^4.0.3" + "@inquirer/password": "npm:^5.0.3" + "@inquirer/rawlist": "npm:^5.1.0" + "@inquirer/search": "npm:^4.0.3" + "@inquirer/select": "npm:^5.0.3" peerDependencies: "@types/node": ">=18" - checksum: 10c0/52c2e1fd8a4e98bc5fd6a79acf9c7d7e1ecc534013d7c018412a6ed34d15be69a2d10791b539740fed8e538485e359e1cacbec98ca3d04e24c5e9fa9480d7bc6 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/37744d17565c8f01109153dd5c741d8b5fbdb6bd477a714732c08e77bbeab483b36946fe79e1288fd577cfd93156c0b125d7259bd43cda0ddd811fc8e496d6ba languageName: node linkType: hard -"@inquirer/rawlist@npm:^4.0.6": - version: 4.0.6 - resolution: "@inquirer/rawlist@npm:4.0.6" +"@inquirer/rawlist@npm:^5.1.0": + version: 5.1.0 + resolution: "@inquirer/rawlist@npm:5.1.0" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/type": "npm:^3.0.2" - yoctocolors-cjs: "npm:^2.1.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/c79f0ddd5cf7eae8db27a7080e277c32809d7bd58619f470d8b1598d1aff36f6aac276535ef35801a1dae97bb3763fd248e1067800e6eccd49276206d6cdb945 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/e5233746488b03a342713374248e8c14032eee5df7bf02ce87e1714eed4647b865a894bc045cc7541e1778c27b2f6f424ed2a1340047987ad86d161abe70cf1e languageName: node linkType: hard -"@inquirer/search@npm:^3.0.6": - version: 3.0.6 - resolution: "@inquirer/search@npm:3.0.6" +"@inquirer/search@npm:^4.0.3": + version: 4.0.3 + resolution: "@inquirer/search@npm:4.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/figures": "npm:^1.0.9" - "@inquirer/type": "npm:^3.0.2" - yoctocolors-cjs: "npm:^2.1.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/figures": "npm:^2.0.2" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/27afe9105b9fd26b5985847f75c82f59156158b6366e35896764cd08ee7bb76e3d9c7110c6ed50ab4d7e13466ea3f0e60492a644e0eb6a0d8c30701b07221ad9 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/22b4b680ef2864604f4eec1b5060973340c3a644eed494ce78c7336f209412936ec2c2c4e0fa7f713f73689111a33a7b8e1582d574fc2e62f31bea2dd5bc14ce languageName: node linkType: hard -"@inquirer/select@npm:^4.0.6": - version: 4.0.6 - resolution: "@inquirer/select@npm:4.0.6" +"@inquirer/select@npm:^5.0.3": + version: 5.0.3 + resolution: "@inquirer/select@npm:5.0.3" dependencies: - "@inquirer/core": "npm:^10.1.4" - "@inquirer/figures": "npm:^1.0.9" - "@inquirer/type": "npm:^3.0.2" - ansi-escapes: "npm:^4.3.2" - yoctocolors-cjs: "npm:^2.1.2" + "@inquirer/ansi": "npm:^2.0.2" + "@inquirer/core": "npm:^11.1.0" + "@inquirer/figures": "npm:^2.0.2" + "@inquirer/type": "npm:^4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/5346007a5f62ff88f36c219b625d6031ba12fea6849b38aab1d3ed1219387004bf1c3a44aeec47a3988c9aeb1934a8a06509fe9e00f39135fa22113a01e1cc37 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/cc2bd79ac09d1693a962b661ab07db49809a9ef280ce2f26f5fc2fe037a423837b9e7ce2b014048959d9c9c1500ec22d52267857ddbea53a84da09e2d4fbd755 languageName: node linkType: hard -"@inquirer/type@npm:^3.0.2": - version: 3.0.2 - resolution: "@inquirer/type@npm:3.0.2" +"@inquirer/type@npm:^4.0.2": + version: 4.0.2 + resolution: "@inquirer/type@npm:4.0.2" peerDependencies: "@types/node": ">=18" - checksum: 10c0/fe348db2977fff92cad0ade05b36ec40714326fccd4a174be31663f8923729b4276f1736d892a449627d7fb03235ff44e8aac5aa72b09036d993593b813ef313 + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10c0/cebf454dbed948809025d64807e60e333df6b9c8eac1090a1c4c07e51a9a03ffbe295ebb723ce1029cf28e66a1c6822e8290702dec006170cce4ff39264316f5 languageName: node linkType: hard @@ -498,212 +554,219 @@ __metadata: languageName: node linkType: hard -"@napi-rs/cli@npm:^3.0.0-alpha.64": - version: 3.0.0-alpha.68 - resolution: "@napi-rs/cli@npm:3.0.0-alpha.68" +"@napi-rs/cli@npm:^3.5.0": + version: 3.5.0 + resolution: "@napi-rs/cli@npm:3.5.0" dependencies: - "@inquirer/prompts": "npm:^7.0.0" - "@napi-rs/cross-toolchain": "npm:^0.0.19" - "@napi-rs/wasm-tools": "npm:^0.0.2" - "@octokit/rest": "npm:^21.0.2" - clipanion: "npm:^3.2.1" + "@inquirer/prompts": "npm:^8.0.0" + "@napi-rs/cross-toolchain": "npm:^1.0.3" + "@napi-rs/wasm-tools": "npm:^1.0.1" + "@octokit/rest": "npm:^22.0.1" + clipanion: "npm:^4.0.0-rc.4" colorette: "npm:^2.0.20" - debug: "npm:^4.3.7" - emnapi: "npm:^1.3.1" + emnapi: "npm:^1.7.1" + es-toolkit: "npm:^1.41.0" js-yaml: "npm:^4.1.0" - lodash-es: "npm:^4.17.21" - semver: "npm:^7.6.3" - toml: "npm:^3.0.0" + obug: "npm:^2.0.0" + semver: "npm:^7.7.3" typanion: "npm:^3.14.0" - wasm-sjlj: "npm:^1.0.5" peerDependencies: - "@emnapi/runtime": ^1.1.0 - emnapi: ^1.1.0 + "@emnapi/runtime": ^1.7.1 peerDependenciesMeta: "@emnapi/runtime": optional: true - emnapi: - optional: true bin: - napi: ./dist/cli.js - napi-raw: ./cli.mjs - checksum: 10c0/db4fe575c7d91348741ea04fe6d3d48fc5dd1a960e30b51bb5645c50a486a0b372b61ca3db3579ef47f4f8523d96771f35460d634f1ea25ed40d1c35d20693f6 + napi: dist/cli.js + napi-raw: cli.mjs + checksum: 10c0/e1556cb547ba2a2df6fbe585d32f9eaf0c857bb727673950c9e6574dce8fd63c8dfd37600313ed86a317895eaf52fca90872a8e7a348f8abab7ab7d6f817336d languageName: node linkType: hard -"@napi-rs/cross-toolchain@npm:^0.0.19": - version: 0.0.19 - resolution: "@napi-rs/cross-toolchain@npm:0.0.19" +"@napi-rs/cross-toolchain@npm:^1.0.3": + version: 1.0.3 + resolution: "@napi-rs/cross-toolchain@npm:1.0.3" dependencies: - "@napi-rs/lzma": "npm:^1.4.1" - "@napi-rs/tar": "npm:^0.1.4" - debug: "npm:^4.4.0" + "@napi-rs/lzma": "npm:^1.4.5" + "@napi-rs/tar": "npm:^1.1.0" + debug: "npm:^4.4.1" peerDependencies: - "@napi-rs/cross-toolchain-arm64-target-aarch64": ^0.0.19 - "@napi-rs/cross-toolchain-arm64-target-armv7": ^0.0.19 - "@napi-rs/cross-toolchain-arm64-target-x86_64": ^0.0.19 - "@napi-rs/cross-toolchain-x64-target-aarch64": ^0.0.19 - "@napi-rs/cross-toolchain-x64-target-armv7": ^0.0.19 - "@napi-rs/cross-toolchain-x64-target-x86_64": ^0.0.19 + "@napi-rs/cross-toolchain-arm64-target-aarch64": ^1.0.3 + "@napi-rs/cross-toolchain-arm64-target-armv7": ^1.0.3 + "@napi-rs/cross-toolchain-arm64-target-ppc64le": ^1.0.3 + "@napi-rs/cross-toolchain-arm64-target-s390x": ^1.0.3 + "@napi-rs/cross-toolchain-arm64-target-x86_64": ^1.0.3 + "@napi-rs/cross-toolchain-x64-target-aarch64": ^1.0.3 + "@napi-rs/cross-toolchain-x64-target-armv7": ^1.0.3 + "@napi-rs/cross-toolchain-x64-target-ppc64le": ^1.0.3 + "@napi-rs/cross-toolchain-x64-target-s390x": ^1.0.3 + "@napi-rs/cross-toolchain-x64-target-x86_64": ^1.0.3 peerDependenciesMeta: "@napi-rs/cross-toolchain-arm64-target-aarch64": optional: true "@napi-rs/cross-toolchain-arm64-target-armv7": optional: true + "@napi-rs/cross-toolchain-arm64-target-ppc64le": + optional: true + "@napi-rs/cross-toolchain-arm64-target-s390x": + optional: true "@napi-rs/cross-toolchain-arm64-target-x86_64": optional: true "@napi-rs/cross-toolchain-x64-target-aarch64": optional: true "@napi-rs/cross-toolchain-x64-target-armv7": optional: true + "@napi-rs/cross-toolchain-x64-target-ppc64le": + optional: true + "@napi-rs/cross-toolchain-x64-target-s390x": + optional: true "@napi-rs/cross-toolchain-x64-target-x86_64": optional: true - checksum: 10c0/6084567d9d86a818bf600d354aefa88aebad6bd0d76de3e41b50b652dc47cdb2056e7482a68870665ecc9e74dd67fcf9fbc9c02057cec9aa17510b4adbabb326 + checksum: 10c0/fcc7877c1e47ba6bf4801a4154240d3130703524b1fed17e736126ce58b53960872b9933f8434e3e86b4635e4c7fe881228be0d237210dd96c2087244523750f languageName: node linkType: hard -"@napi-rs/lzma-android-arm-eabi@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-android-arm-eabi@npm:1.4.1" +"@napi-rs/lzma-android-arm-eabi@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-android-arm-eabi@npm:1.4.5" conditions: os=android & cpu=arm languageName: node linkType: hard -"@napi-rs/lzma-android-arm64@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-android-arm64@npm:1.4.1" +"@napi-rs/lzma-android-arm64@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-android-arm64@npm:1.4.5" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@napi-rs/lzma-darwin-arm64@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-darwin-arm64@npm:1.4.1" +"@napi-rs/lzma-darwin-arm64@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-darwin-arm64@npm:1.4.5" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@napi-rs/lzma-darwin-x64@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-darwin-x64@npm:1.4.1" +"@napi-rs/lzma-darwin-x64@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-darwin-x64@npm:1.4.5" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@napi-rs/lzma-freebsd-x64@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-freebsd-x64@npm:1.4.1" +"@napi-rs/lzma-freebsd-x64@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-freebsd-x64@npm:1.4.5" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@napi-rs/lzma-linux-arm-gnueabihf@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-arm-gnueabihf@npm:1.4.1" +"@napi-rs/lzma-linux-arm-gnueabihf@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-arm-gnueabihf@npm:1.4.5" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@napi-rs/lzma-linux-arm64-gnu@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-arm64-gnu@npm:1.4.1" +"@napi-rs/lzma-linux-arm64-gnu@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-arm64-gnu@npm:1.4.5" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@napi-rs/lzma-linux-arm64-musl@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-arm64-musl@npm:1.4.1" +"@napi-rs/lzma-linux-arm64-musl@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-arm64-musl@npm:1.4.5" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@napi-rs/lzma-linux-ppc64-gnu@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-ppc64-gnu@npm:1.4.1" +"@napi-rs/lzma-linux-ppc64-gnu@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-ppc64-gnu@npm:1.4.5" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@napi-rs/lzma-linux-riscv64-gnu@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-riscv64-gnu@npm:1.4.1" +"@napi-rs/lzma-linux-riscv64-gnu@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-riscv64-gnu@npm:1.4.5" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@napi-rs/lzma-linux-s390x-gnu@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-s390x-gnu@npm:1.4.1" +"@napi-rs/lzma-linux-s390x-gnu@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-s390x-gnu@npm:1.4.5" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@napi-rs/lzma-linux-x64-gnu@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-x64-gnu@npm:1.4.1" +"@napi-rs/lzma-linux-x64-gnu@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-x64-gnu@npm:1.4.5" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@napi-rs/lzma-linux-x64-musl@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-linux-x64-musl@npm:1.4.1" +"@napi-rs/lzma-linux-x64-musl@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-linux-x64-musl@npm:1.4.5" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@napi-rs/lzma-wasm32-wasi@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-wasm32-wasi@npm:1.4.1" +"@napi-rs/lzma-wasm32-wasi@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-wasm32-wasi@npm:1.4.5" dependencies: - "@napi-rs/wasm-runtime": "npm:^0.2.4" + "@napi-rs/wasm-runtime": "npm:^1.0.3" conditions: cpu=wasm32 languageName: node linkType: hard -"@napi-rs/lzma-win32-arm64-msvc@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-win32-arm64-msvc@npm:1.4.1" +"@napi-rs/lzma-win32-arm64-msvc@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-win32-arm64-msvc@npm:1.4.5" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@napi-rs/lzma-win32-ia32-msvc@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-win32-ia32-msvc@npm:1.4.1" +"@napi-rs/lzma-win32-ia32-msvc@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-win32-ia32-msvc@npm:1.4.5" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@napi-rs/lzma-win32-x64-msvc@npm:1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma-win32-x64-msvc@npm:1.4.1" +"@napi-rs/lzma-win32-x64-msvc@npm:1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma-win32-x64-msvc@npm:1.4.5" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@napi-rs/lzma@npm:^1.4.1": - version: 1.4.1 - resolution: "@napi-rs/lzma@npm:1.4.1" - dependencies: - "@napi-rs/lzma-android-arm-eabi": "npm:1.4.1" - "@napi-rs/lzma-android-arm64": "npm:1.4.1" - "@napi-rs/lzma-darwin-arm64": "npm:1.4.1" - "@napi-rs/lzma-darwin-x64": "npm:1.4.1" - "@napi-rs/lzma-freebsd-x64": "npm:1.4.1" - "@napi-rs/lzma-linux-arm-gnueabihf": "npm:1.4.1" - "@napi-rs/lzma-linux-arm64-gnu": "npm:1.4.1" - "@napi-rs/lzma-linux-arm64-musl": "npm:1.4.1" - "@napi-rs/lzma-linux-ppc64-gnu": "npm:1.4.1" - "@napi-rs/lzma-linux-riscv64-gnu": "npm:1.4.1" - "@napi-rs/lzma-linux-s390x-gnu": "npm:1.4.1" - "@napi-rs/lzma-linux-x64-gnu": "npm:1.4.1" - "@napi-rs/lzma-linux-x64-musl": "npm:1.4.1" - "@napi-rs/lzma-wasm32-wasi": "npm:1.4.1" - "@napi-rs/lzma-win32-arm64-msvc": "npm:1.4.1" - "@napi-rs/lzma-win32-ia32-msvc": "npm:1.4.1" - "@napi-rs/lzma-win32-x64-msvc": "npm:1.4.1" +"@napi-rs/lzma@npm:^1.4.5": + version: 1.4.5 + resolution: "@napi-rs/lzma@npm:1.4.5" + dependencies: + "@napi-rs/lzma-android-arm-eabi": "npm:1.4.5" + "@napi-rs/lzma-android-arm64": "npm:1.4.5" + "@napi-rs/lzma-darwin-arm64": "npm:1.4.5" + "@napi-rs/lzma-darwin-x64": "npm:1.4.5" + "@napi-rs/lzma-freebsd-x64": "npm:1.4.5" + "@napi-rs/lzma-linux-arm-gnueabihf": "npm:1.4.5" + "@napi-rs/lzma-linux-arm64-gnu": "npm:1.4.5" + "@napi-rs/lzma-linux-arm64-musl": "npm:1.4.5" + "@napi-rs/lzma-linux-ppc64-gnu": "npm:1.4.5" + "@napi-rs/lzma-linux-riscv64-gnu": "npm:1.4.5" + "@napi-rs/lzma-linux-s390x-gnu": "npm:1.4.5" + "@napi-rs/lzma-linux-x64-gnu": "npm:1.4.5" + "@napi-rs/lzma-linux-x64-musl": "npm:1.4.5" + "@napi-rs/lzma-wasm32-wasi": "npm:1.4.5" + "@napi-rs/lzma-win32-arm64-msvc": "npm:1.4.5" + "@napi-rs/lzma-win32-ia32-msvc": "npm:1.4.5" + "@napi-rs/lzma-win32-x64-msvc": "npm:1.4.5" dependenciesMeta: "@napi-rs/lzma-android-arm-eabi": optional: true @@ -739,144 +802,144 @@ __metadata: optional: true "@napi-rs/lzma-win32-x64-msvc": optional: true - checksum: 10c0/b50aa8160eef163caed8c8c2e998f2fc677f4e9f9e0aa1e1e8b21b83a1999c7faece12842df41392f6a3a30a655d934dba56f3fdf1c6a7fff996691c878a1ae8 + checksum: 10c0/df098c99f904b54541e3a34feeb5878c98a4abf1ababf1d301d903b99d98402fff5eda49e1dd103bb4bf44a9217a5e1b17fb30b74044416561f8fe02ca098ee3 languageName: node linkType: hard -"@napi-rs/tar-android-arm-eabi@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-android-arm-eabi@npm:0.1.4" +"@napi-rs/tar-android-arm-eabi@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-android-arm-eabi@npm:1.1.0" conditions: os=android & cpu=arm languageName: node linkType: hard -"@napi-rs/tar-android-arm64@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-android-arm64@npm:0.1.4" +"@napi-rs/tar-android-arm64@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-android-arm64@npm:1.1.0" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@napi-rs/tar-darwin-arm64@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-darwin-arm64@npm:0.1.4" +"@napi-rs/tar-darwin-arm64@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-darwin-arm64@npm:1.1.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@napi-rs/tar-darwin-x64@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-darwin-x64@npm:0.1.4" +"@napi-rs/tar-darwin-x64@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-darwin-x64@npm:1.1.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@napi-rs/tar-freebsd-x64@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-freebsd-x64@npm:0.1.4" +"@napi-rs/tar-freebsd-x64@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-freebsd-x64@npm:1.1.0" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@napi-rs/tar-linux-arm-gnueabihf@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-arm-gnueabihf@npm:0.1.4" +"@napi-rs/tar-linux-arm-gnueabihf@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-arm-gnueabihf@npm:1.1.0" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@napi-rs/tar-linux-arm64-gnu@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-arm64-gnu@npm:0.1.4" +"@napi-rs/tar-linux-arm64-gnu@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-arm64-gnu@npm:1.1.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@napi-rs/tar-linux-arm64-musl@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-arm64-musl@npm:0.1.4" +"@napi-rs/tar-linux-arm64-musl@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-arm64-musl@npm:1.1.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@napi-rs/tar-linux-ppc64-gnu@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-ppc64-gnu@npm:0.1.4" +"@napi-rs/tar-linux-ppc64-gnu@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-ppc64-gnu@npm:1.1.0" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@napi-rs/tar-linux-s390x-gnu@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-s390x-gnu@npm:0.1.4" +"@napi-rs/tar-linux-s390x-gnu@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-s390x-gnu@npm:1.1.0" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@napi-rs/tar-linux-x64-gnu@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-x64-gnu@npm:0.1.4" +"@napi-rs/tar-linux-x64-gnu@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-x64-gnu@npm:1.1.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@napi-rs/tar-linux-x64-musl@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-linux-x64-musl@npm:0.1.4" +"@napi-rs/tar-linux-x64-musl@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-linux-x64-musl@npm:1.1.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@napi-rs/tar-wasm32-wasi@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-wasm32-wasi@npm:0.1.4" +"@napi-rs/tar-wasm32-wasi@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-wasm32-wasi@npm:1.1.0" dependencies: - "@napi-rs/wasm-runtime": "npm:^0.2.4" + "@napi-rs/wasm-runtime": "npm:^1.0.3" conditions: cpu=wasm32 languageName: node linkType: hard -"@napi-rs/tar-win32-arm64-msvc@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-win32-arm64-msvc@npm:0.1.4" +"@napi-rs/tar-win32-arm64-msvc@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-win32-arm64-msvc@npm:1.1.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@napi-rs/tar-win32-ia32-msvc@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-win32-ia32-msvc@npm:0.1.4" +"@napi-rs/tar-win32-ia32-msvc@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-win32-ia32-msvc@npm:1.1.0" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@napi-rs/tar-win32-x64-msvc@npm:0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar-win32-x64-msvc@npm:0.1.4" +"@napi-rs/tar-win32-x64-msvc@npm:1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar-win32-x64-msvc@npm:1.1.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@napi-rs/tar@npm:^0.1.4": - version: 0.1.4 - resolution: "@napi-rs/tar@npm:0.1.4" - dependencies: - "@napi-rs/tar-android-arm-eabi": "npm:0.1.4" - "@napi-rs/tar-android-arm64": "npm:0.1.4" - "@napi-rs/tar-darwin-arm64": "npm:0.1.4" - "@napi-rs/tar-darwin-x64": "npm:0.1.4" - "@napi-rs/tar-freebsd-x64": "npm:0.1.4" - "@napi-rs/tar-linux-arm-gnueabihf": "npm:0.1.4" - "@napi-rs/tar-linux-arm64-gnu": "npm:0.1.4" - "@napi-rs/tar-linux-arm64-musl": "npm:0.1.4" - "@napi-rs/tar-linux-ppc64-gnu": "npm:0.1.4" - "@napi-rs/tar-linux-s390x-gnu": "npm:0.1.4" - "@napi-rs/tar-linux-x64-gnu": "npm:0.1.4" - "@napi-rs/tar-linux-x64-musl": "npm:0.1.4" - "@napi-rs/tar-wasm32-wasi": "npm:0.1.4" - "@napi-rs/tar-win32-arm64-msvc": "npm:0.1.4" - "@napi-rs/tar-win32-ia32-msvc": "npm:0.1.4" - "@napi-rs/tar-win32-x64-msvc": "npm:0.1.4" +"@napi-rs/tar@npm:^1.1.0": + version: 1.1.0 + resolution: "@napi-rs/tar@npm:1.1.0" + dependencies: + "@napi-rs/tar-android-arm-eabi": "npm:1.1.0" + "@napi-rs/tar-android-arm64": "npm:1.1.0" + "@napi-rs/tar-darwin-arm64": "npm:1.1.0" + "@napi-rs/tar-darwin-x64": "npm:1.1.0" + "@napi-rs/tar-freebsd-x64": "npm:1.1.0" + "@napi-rs/tar-linux-arm-gnueabihf": "npm:1.1.0" + "@napi-rs/tar-linux-arm64-gnu": "npm:1.1.0" + "@napi-rs/tar-linux-arm64-musl": "npm:1.1.0" + "@napi-rs/tar-linux-ppc64-gnu": "npm:1.1.0" + "@napi-rs/tar-linux-s390x-gnu": "npm:1.1.0" + "@napi-rs/tar-linux-x64-gnu": "npm:1.1.0" + "@napi-rs/tar-linux-x64-musl": "npm:1.1.0" + "@napi-rs/tar-wasm32-wasi": "npm:1.1.0" + "@napi-rs/tar-win32-arm64-msvc": "npm:1.1.0" + "@napi-rs/tar-win32-ia32-msvc": "npm:1.1.0" + "@napi-rs/tar-win32-x64-msvc": "npm:1.1.0" dependenciesMeta: "@napi-rs/tar-android-arm-eabi": optional: true @@ -910,7 +973,7 @@ __metadata: optional: true "@napi-rs/tar-win32-x64-msvc": optional: true - checksum: 10c0/9b81dc4bb4f2fe67951bbcf9d7c68737d20cc04904852968837545a1347e3767b83485b00218745e5138f4567711bcf5975860686228279121fd30a88fc333c5 + checksum: 10c0/88a0ab081eacfa235266f14a0bc408b7581058b1f7e18b118c6f8e7012cca0dd91c5baf5de84e1d2eb8070386a7380aa4d8dedfc6f81e24ae9d0287ff50ae153 languageName: node linkType: hard @@ -932,7 +995,7 @@ __metadata: languageName: node linkType: hard -"@napi-rs/wasm-runtime@npm:^0.2.3, @napi-rs/wasm-runtime@npm:^0.2.4, @napi-rs/wasm-runtime@npm:^0.2.5": +"@napi-rs/wasm-runtime@npm:^0.2.5": version: 0.2.6 resolution: "@napi-rs/wasm-runtime@npm:0.2.6" dependencies: @@ -943,6 +1006,17 @@ __metadata: languageName: node linkType: hard +"@napi-rs/wasm-runtime@npm:^1.0.3": + version: 1.1.0 + resolution: "@napi-rs/wasm-runtime@npm:1.1.0" + dependencies: + "@emnapi/core": "npm:^1.7.1" + "@emnapi/runtime": "npm:^1.7.1" + "@tybys/wasm-util": "npm:^0.10.1" + checksum: 10c0/ee351052123bfc635c4cef03ac273a686522394ccd513b1e5b7b3823cecd6abb4a31f23a3a962933192b87eb7b7c3eb3def7748bd410edc66f932d90cf44e9ab + languageName: node + linkType: hard + "@napi-rs/wasm-runtime@npm:^1.0.7": version: 1.0.7 resolution: "@napi-rs/wasm-runtime@npm:1.0.7" @@ -954,116 +1028,116 @@ __metadata: languageName: node linkType: hard -"@napi-rs/wasm-tools-android-arm-eabi@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-android-arm-eabi@npm:0.0.2" +"@napi-rs/wasm-tools-android-arm-eabi@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-android-arm-eabi@npm:1.0.1" conditions: os=android & cpu=arm languageName: node linkType: hard -"@napi-rs/wasm-tools-android-arm64@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-android-arm64@npm:0.0.2" +"@napi-rs/wasm-tools-android-arm64@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-android-arm64@npm:1.0.1" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@napi-rs/wasm-tools-darwin-arm64@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-darwin-arm64@npm:0.0.2" +"@napi-rs/wasm-tools-darwin-arm64@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-darwin-arm64@npm:1.0.1" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@napi-rs/wasm-tools-darwin-x64@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-darwin-x64@npm:0.0.2" +"@napi-rs/wasm-tools-darwin-x64@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-darwin-x64@npm:1.0.1" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@napi-rs/wasm-tools-freebsd-x64@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-freebsd-x64@npm:0.0.2" +"@napi-rs/wasm-tools-freebsd-x64@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-freebsd-x64@npm:1.0.1" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@napi-rs/wasm-tools-linux-arm64-gnu@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-linux-arm64-gnu@npm:0.0.2" +"@napi-rs/wasm-tools-linux-arm64-gnu@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-linux-arm64-gnu@npm:1.0.1" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@napi-rs/wasm-tools-linux-arm64-musl@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-linux-arm64-musl@npm:0.0.2" +"@napi-rs/wasm-tools-linux-arm64-musl@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-linux-arm64-musl@npm:1.0.1" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@napi-rs/wasm-tools-linux-x64-gnu@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-linux-x64-gnu@npm:0.0.2" +"@napi-rs/wasm-tools-linux-x64-gnu@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-linux-x64-gnu@npm:1.0.1" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@napi-rs/wasm-tools-linux-x64-musl@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-linux-x64-musl@npm:0.0.2" +"@napi-rs/wasm-tools-linux-x64-musl@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-linux-x64-musl@npm:1.0.1" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@napi-rs/wasm-tools-wasm32-wasi@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-wasm32-wasi@npm:0.0.2" +"@napi-rs/wasm-tools-wasm32-wasi@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-wasm32-wasi@npm:1.0.1" dependencies: - "@napi-rs/wasm-runtime": "npm:^0.2.3" + "@napi-rs/wasm-runtime": "npm:^1.0.3" conditions: cpu=wasm32 languageName: node linkType: hard -"@napi-rs/wasm-tools-win32-arm64-msvc@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-win32-arm64-msvc@npm:0.0.2" +"@napi-rs/wasm-tools-win32-arm64-msvc@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-win32-arm64-msvc@npm:1.0.1" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@napi-rs/wasm-tools-win32-ia32-msvc@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-win32-ia32-msvc@npm:0.0.2" +"@napi-rs/wasm-tools-win32-ia32-msvc@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-win32-ia32-msvc@npm:1.0.1" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@napi-rs/wasm-tools-win32-x64-msvc@npm:0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools-win32-x64-msvc@npm:0.0.2" +"@napi-rs/wasm-tools-win32-x64-msvc@npm:1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools-win32-x64-msvc@npm:1.0.1" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@napi-rs/wasm-tools@npm:^0.0.2": - version: 0.0.2 - resolution: "@napi-rs/wasm-tools@npm:0.0.2" - dependencies: - "@napi-rs/wasm-tools-android-arm-eabi": "npm:0.0.2" - "@napi-rs/wasm-tools-android-arm64": "npm:0.0.2" - "@napi-rs/wasm-tools-darwin-arm64": "npm:0.0.2" - "@napi-rs/wasm-tools-darwin-x64": "npm:0.0.2" - "@napi-rs/wasm-tools-freebsd-x64": "npm:0.0.2" - "@napi-rs/wasm-tools-linux-arm64-gnu": "npm:0.0.2" - "@napi-rs/wasm-tools-linux-arm64-musl": "npm:0.0.2" - "@napi-rs/wasm-tools-linux-x64-gnu": "npm:0.0.2" - "@napi-rs/wasm-tools-linux-x64-musl": "npm:0.0.2" - "@napi-rs/wasm-tools-wasm32-wasi": "npm:0.0.2" - "@napi-rs/wasm-tools-win32-arm64-msvc": "npm:0.0.2" - "@napi-rs/wasm-tools-win32-ia32-msvc": "npm:0.0.2" - "@napi-rs/wasm-tools-win32-x64-msvc": "npm:0.0.2" +"@napi-rs/wasm-tools@npm:^1.0.1": + version: 1.0.1 + resolution: "@napi-rs/wasm-tools@npm:1.0.1" + dependencies: + "@napi-rs/wasm-tools-android-arm-eabi": "npm:1.0.1" + "@napi-rs/wasm-tools-android-arm64": "npm:1.0.1" + "@napi-rs/wasm-tools-darwin-arm64": "npm:1.0.1" + "@napi-rs/wasm-tools-darwin-x64": "npm:1.0.1" + "@napi-rs/wasm-tools-freebsd-x64": "npm:1.0.1" + "@napi-rs/wasm-tools-linux-arm64-gnu": "npm:1.0.1" + "@napi-rs/wasm-tools-linux-arm64-musl": "npm:1.0.1" + "@napi-rs/wasm-tools-linux-x64-gnu": "npm:1.0.1" + "@napi-rs/wasm-tools-linux-x64-musl": "npm:1.0.1" + "@napi-rs/wasm-tools-wasm32-wasi": "npm:1.0.1" + "@napi-rs/wasm-tools-win32-arm64-msvc": "npm:1.0.1" + "@napi-rs/wasm-tools-win32-ia32-msvc": "npm:1.0.1" + "@napi-rs/wasm-tools-win32-x64-msvc": "npm:1.0.1" dependenciesMeta: "@napi-rs/wasm-tools-android-arm-eabi": optional: true @@ -1091,7 +1165,7 @@ __metadata: optional: true "@napi-rs/wasm-tools-win32-x64-msvc": optional: true - checksum: 10c0/001ee9e9d9ea66f9ac41128d6062d48da1eeed7d53e8fe7d28b8829cfcfb10581151a55a759ee56427cc56b499bfc032c49540fc92c8c008c7a615860159815f + checksum: 10c0/bee9258e0b16a2415acc57d9aa281fa50402b38f631aea28e3a8ecd16415cdfffade63313bca777e85c3a73b80cce899ac3dd35eba9104951d7da1eb28913122 languageName: node linkType: hard @@ -1099,7 +1173,7 @@ __metadata: version: 0.0.0-use.local resolution: "@node-rs/argon2@workspace:packages/argon2" dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" argon2: "npm:^0.44.0" cross-env: "npm:^7.0.3" tinybench: "npm:^3.0.0" @@ -1112,7 +1186,7 @@ __metadata: dependencies: "@cwasm/openbsd-bcrypt": "npm:^0.1.0" "@cwasm/openwall-bcrypt": "npm:^0.1.0" - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" "@types/bcrypt": "npm:^5.0.2" "@types/bcryptjs": "npm:^2.4.6" bcrypt: "npm:^5.1.1" @@ -1126,7 +1200,7 @@ __metadata: version: 0.0.0-use.local resolution: "@node-rs/crc32@workspace:packages/crc32" dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" "@types/crc": "npm:^4.0.0" "@types/sse4_crc32": "npm:^7.0.3" buffer: "npm:^6.0.3" @@ -1149,7 +1223,7 @@ __metadata: version: 0.0.0-use.local resolution: "@node-rs/jieba@workspace:packages/jieba" dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" cross-env: "npm:^7.0.3" nodejieba: "npm:^3.0.0" tinybench: "npm:^3.0.0" @@ -1160,7 +1234,7 @@ __metadata: version: 0.0.0-use.local resolution: "@node-rs/jsonwebtoken@workspace:packages/jsonwebtoken" dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" "@oxc-node/core": "npm:^0.0.34" "@types/jsonwebtoken": "npm:^9.0.6" cross-env: "npm:^7.0.3" @@ -1173,7 +1247,7 @@ __metadata: version: 0.0.0-use.local resolution: "@node-rs/xxhash@workspace:packages/xxhash" dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" "@oxc-node/core": "npm:^0.0.34" "@types/xxhashjs": "npm:^0.2.4" cross-env: "npm:^7.0.3" @@ -1532,10 +1606,10 @@ __metadata: languageName: node linkType: hard -"@octokit/auth-token@npm:^5.0.0": - version: 5.1.1 - resolution: "@octokit/auth-token@npm:5.1.1" - checksum: 10c0/1e6117c5170de9a5532ffb85e0bda153f4dffdd66871c42de952828eddd9029fe5161a2a8bf20b57f0d45c80f8fb9ddc69aa639e0fa6b776829efb1b0881b154 +"@octokit/auth-token@npm:^6.0.0": + version: 6.0.0 + resolution: "@octokit/auth-token@npm:6.0.0" + checksum: 10c0/32ecc904c5f6f4e5d090bfcc679d70318690c0a0b5040cd9a25811ad9dcd44c33f2cf96b6dbee1cd56cf58fde28fb1819c01b58718aa5c971f79c822357cb5c0 languageName: node linkType: hard @@ -1554,28 +1628,28 @@ __metadata: languageName: node linkType: hard -"@octokit/core@npm:^6.1.3": - version: 6.1.3 - resolution: "@octokit/core@npm:6.1.3" - dependencies: - "@octokit/auth-token": "npm:^5.0.0" - "@octokit/graphql": "npm:^8.1.2" - "@octokit/request": "npm:^9.1.4" - "@octokit/request-error": "npm:^6.1.6" - "@octokit/types": "npm:^13.6.2" - before-after-hook: "npm:^3.0.2" +"@octokit/core@npm:^7.0.6": + version: 7.0.6 + resolution: "@octokit/core@npm:7.0.6" + dependencies: + "@octokit/auth-token": "npm:^6.0.0" + "@octokit/graphql": "npm:^9.0.3" + "@octokit/request": "npm:^10.0.6" + "@octokit/request-error": "npm:^7.0.2" + "@octokit/types": "npm:^16.0.0" + before-after-hook: "npm:^4.0.0" universal-user-agent: "npm:^7.0.0" - checksum: 10c0/d02506dfb2771b18d0ee620b92deb75f0458cbf92b975b04c9ad3e50b06813d4c98a598bf1a1cae5757d31166c52a1ef55c30b17f2359f30309731e264ea20d0 + checksum: 10c0/95a328ff7c7223d9eb4aa778c63171828514ae0e0f588d33beb81a4dc03bbeae055382f6060ce23c979ab46272409942ff2cf3172109999e48429c47055b1fbe languageName: node linkType: hard -"@octokit/endpoint@npm:^10.0.0": - version: 10.1.2 - resolution: "@octokit/endpoint@npm:10.1.2" +"@octokit/endpoint@npm:^11.0.2": + version: 11.0.2 + resolution: "@octokit/endpoint@npm:11.0.2" dependencies: - "@octokit/types": "npm:^13.6.2" + "@octokit/types": "npm:^16.0.0" universal-user-agent: "npm:^7.0.2" - checksum: 10c0/36335c46137c401ffaf949a49c268559076600bc4a6a92b9737b748b554c5fa9c7cd275a4ab0d580f4b877bd1ed36095e6132d979c5ab49002b61f0a94ac16e9 + checksum: 10c0/878ac12fbccff772968689b4744590677c5a3f12bebe31544832c84761bf1c6be521e8a3af07abffc9455a74dd4d1f350d714fc46fd7ce14a0a2b5f2d4e3a84c languageName: node linkType: hard @@ -1601,14 +1675,14 @@ __metadata: languageName: node linkType: hard -"@octokit/graphql@npm:^8.1.2": - version: 8.1.2 - resolution: "@octokit/graphql@npm:8.1.2" +"@octokit/graphql@npm:^9.0.3": + version: 9.0.3 + resolution: "@octokit/graphql@npm:9.0.3" dependencies: - "@octokit/request": "npm:^9.1.4" - "@octokit/types": "npm:^13.6.2" + "@octokit/request": "npm:^10.0.6" + "@octokit/types": "npm:^16.0.0" universal-user-agent: "npm:^7.0.0" - checksum: 10c0/58f08ddbb85e334b5dc07c75ca746781484cb63e0d64edfa8205cd69a2d99c87a9279251a2d24bbdf9a3d45708474eb8d834858cd8f4959da726dbffe96e9e4e + checksum: 10c0/58588d3fb2834f64244fa5376ca7922a30117b001b621e141fab0d52806370803ab0c046ac99b120fa5f45b770f52a815157fb6ffc147fc6c1da4047c1f1af49 languageName: node linkType: hard @@ -1619,10 +1693,10 @@ __metadata: languageName: node linkType: hard -"@octokit/openapi-types@npm:^23.0.1": - version: 23.0.1 - resolution: "@octokit/openapi-types@npm:23.0.1" - checksum: 10c0/ab734ceb26343d9f051a59503b8cb5bdc7fec9ca044b60511b227179bec73141dd9144a6b2d68bcd737741881b136c1b7d5392da89ae2e35e39acc489e5eb4c1 +"@octokit/openapi-types@npm:^27.0.0": + version: 27.0.0 + resolution: "@octokit/openapi-types@npm:27.0.0" + checksum: 10c0/602d1de033da180a2e982cdbd3646bd5b2e16ecf36b9955a0f23e37ae9e6cb086abb48ff2ae6f2de000fce03e8ae9051794611ae4a95a8f5f6fb63276e7b8e31 languageName: node linkType: hard @@ -1633,14 +1707,14 @@ __metadata: languageName: node linkType: hard -"@octokit/plugin-paginate-rest@npm:^11.4.0": - version: 11.4.0 - resolution: "@octokit/plugin-paginate-rest@npm:11.4.0" +"@octokit/plugin-paginate-rest@npm:^14.0.0": + version: 14.0.0 + resolution: "@octokit/plugin-paginate-rest@npm:14.0.0" dependencies: - "@octokit/types": "npm:^13.7.0" + "@octokit/types": "npm:^16.0.0" peerDependencies: "@octokit/core": ">=6" - checksum: 10c0/b211f2491ddb941dfe6ae0b8fa752c617c74a1bb3086a9e2e23e77430682d30863ed8ccc6180dd12d4f6f0e0c7af4489863dd63804e2cc9f3fab12c1f04f8dd2 + checksum: 10c0/841d79d4ccfe18fc809a4a67529b75c1dcdda13399bf4bf5b48ce7559c8b4b2cd422e3204bad4cbdea31c0cf0943521067415268e5bcfc615a3b813e058cad6b languageName: node linkType: hard @@ -1665,23 +1739,23 @@ __metadata: languageName: node linkType: hard -"@octokit/plugin-request-log@npm:^5.3.1": - version: 5.3.1 - resolution: "@octokit/plugin-request-log@npm:5.3.1" +"@octokit/plugin-request-log@npm:^6.0.0": + version: 6.0.0 + resolution: "@octokit/plugin-request-log@npm:6.0.0" peerDependencies: "@octokit/core": ">=6" - checksum: 10c0/2f959934b8285cf39a1d1d0b92ec881b3ae171ae74738225f87b89381afd72a32bc7ea9c04d2dcee74f74ad24c22cce0c5f3e5b4333d531ea67b985e4ee90cb0 + checksum: 10c0/40e46ad0c77235742d0bf698ab4e17df1ae06e0d7824ffc5867ed71e27de860875adb73d89629b823fe8647459a8f262c26ed1aa6ee374873fa94095f37df0bb languageName: node linkType: hard -"@octokit/plugin-rest-endpoint-methods@npm:^13.3.0": - version: 13.3.0 - resolution: "@octokit/plugin-rest-endpoint-methods@npm:13.3.0" +"@octokit/plugin-rest-endpoint-methods@npm:^17.0.0": + version: 17.0.0 + resolution: "@octokit/plugin-rest-endpoint-methods@npm:17.0.0" dependencies: - "@octokit/types": "npm:^13.7.0" + "@octokit/types": "npm:^16.0.0" peerDependencies: "@octokit/core": ">=6" - checksum: 10c0/f3c7a69cdc8c3d8d2a1ba492e528fa97e836822357cca57a47f3ecbc2a04f661ea479e9debf44e063e1cdbf4ea1f4c0d5dc8295be9ce3086422c4779eba473d5 + checksum: 10c0/cf9984d7cf6a36ff7ff1b86078ae45fe246e3df10fcef0bccf20c8cfd27bf5e7d98dcb9cf5a7b56332b9c6fa30be28d159c2987d272a4758f77056903d94402f languageName: node linkType: hard @@ -1707,12 +1781,25 @@ __metadata: languageName: node linkType: hard -"@octokit/request-error@npm:^6.0.1, @octokit/request-error@npm:^6.1.6": - version: 6.1.6 - resolution: "@octokit/request-error@npm:6.1.6" +"@octokit/request-error@npm:^7.0.2": + version: 7.1.0 + resolution: "@octokit/request-error@npm:7.1.0" + dependencies: + "@octokit/types": "npm:^16.0.0" + checksum: 10c0/62b90a54545c36a30b5ffdda42e302c751be184d85b68ffc7f1242c51d7ca54dbd185b7d0027b491991776923a910c85c9c51269fe0d86111bac187507a5abc4 + languageName: node + linkType: hard + +"@octokit/request@npm:^10.0.6": + version: 10.0.7 + resolution: "@octokit/request@npm:10.0.7" dependencies: - "@octokit/types": "npm:^13.6.2" - checksum: 10c0/cbbed77ddd1d40a1bed36224667c2fac4c20ce375a78d4648745ad1fedc8c2b1d01343b5908979d5b6557736245637eb58efc65d0cd1ef047ea6be74b46c47d2 + "@octokit/endpoint": "npm:^11.0.2" + "@octokit/request-error": "npm:^7.0.2" + "@octokit/types": "npm:^16.0.0" + fast-content-type-parse: "npm:^3.0.0" + universal-user-agent: "npm:^7.0.2" + checksum: 10c0/f789a75bf681b204ccd3d538921db662e148ed980005158d80ec4f16811e9ab73f375d4f30ef697852abd748a62f025060ea1b0c5198ec9c2e8d04e355064390 languageName: node linkType: hard @@ -1730,19 +1817,6 @@ __metadata: languageName: node linkType: hard -"@octokit/request@npm:^9.1.4": - version: 9.2.0 - resolution: "@octokit/request@npm:9.2.0" - dependencies: - "@octokit/endpoint": "npm:^10.0.0" - "@octokit/request-error": "npm:^6.0.1" - "@octokit/types": "npm:^13.6.2" - fast-content-type-parse: "npm:^2.0.0" - universal-user-agent: "npm:^7.0.2" - checksum: 10c0/025bcb0a1abf1290d5131919e5c7db9cee3df3a271524efd43ac6b9a66abb00d5893fa25ad11cb0546bd3f80096a58dca99fa7b6a06c23c9811bc644d3eb6fa2 - languageName: node - linkType: hard - "@octokit/rest@npm:19.0.11": version: 19.0.11 resolution: "@octokit/rest@npm:19.0.11" @@ -1755,15 +1829,15 @@ __metadata: languageName: node linkType: hard -"@octokit/rest@npm:^21.0.2": - version: 21.1.0 - resolution: "@octokit/rest@npm:21.1.0" +"@octokit/rest@npm:^22.0.1": + version: 22.0.1 + resolution: "@octokit/rest@npm:22.0.1" dependencies: - "@octokit/core": "npm:^6.1.3" - "@octokit/plugin-paginate-rest": "npm:^11.4.0" - "@octokit/plugin-request-log": "npm:^5.3.1" - "@octokit/plugin-rest-endpoint-methods": "npm:^13.3.0" - checksum: 10c0/98d00f5be3e7ccee9486738664650e37be6251face1afc17e4733795a4b986645f33f64602aabf98dbde4c710d1448fb9ea7dfaf0f99824f37deb326aa2a224b + "@octokit/core": "npm:^7.0.6" + "@octokit/plugin-paginate-rest": "npm:^14.0.0" + "@octokit/plugin-request-log": "npm:^6.0.0" + "@octokit/plugin-rest-endpoint-methods": "npm:^17.0.0" + checksum: 10c0/f3abd84e887cc837973214ce70720a9bba53f5575f40601c6122aa25206e9055d859c0388437f0a137f6cd0e4ff405e1b46b903475b0db32a17bada0c6513d5b languageName: node linkType: hard @@ -1783,12 +1857,12 @@ __metadata: languageName: node linkType: hard -"@octokit/types@npm:^13.6.2, @octokit/types@npm:^13.7.0": - version: 13.7.0 - resolution: "@octokit/types@npm:13.7.0" +"@octokit/types@npm:^16.0.0": + version: 16.0.0 + resolution: "@octokit/types@npm:16.0.0" dependencies: - "@octokit/openapi-types": "npm:^23.0.1" - checksum: 10c0/62ed4f00304360cc31e99a9dc97ac4f48075d1d5c09a272f09b1fd3dfcc7a6169b7fab109030319ef121b0cd880c85bdb20363f4992104e07a98bd8323beeeb5 + "@octokit/openapi-types": "npm:^27.0.0" + checksum: 10c0/b8d41098ba6fc194d13d641f9441347e3a3b96c0efabac0e14f57319340a2d4d1c8676e4cb37ab3062c5c323c617e790b0126916e9bf7b201b0cced0826f8ae2 languageName: node linkType: hard @@ -2676,7 +2750,7 @@ __metadata: languageName: node linkType: hard -"ansi-escapes@npm:^4.2.1, ansi-escapes@npm:^4.3.2": +"ansi-escapes@npm:^4.2.1": version: 4.3.2 resolution: "ansi-escapes@npm:4.3.2" dependencies: @@ -2958,10 +3032,10 @@ __metadata: languageName: node linkType: hard -"before-after-hook@npm:^3.0.2": - version: 3.0.2 - resolution: "before-after-hook@npm:3.0.2" - checksum: 10c0/dea640f9e88a1085372c9bcc974b7bf379267490693da92ec102a7d8b515dd1e95f00ef575a146b83ca638104c57406c3427d37bdf082f602dde4b56d05bba14 +"before-after-hook@npm:^4.0.0": + version: 4.0.0 + resolution: "before-after-hook@npm:4.0.0" + checksum: 10c0/9f8ae8d1b06142bcfb9ef6625226b5e50348bb11210f266660eddcf9734e0db6f9afc4cb48397ee3f5ac0a3728f3ae401cdeea88413f7bed748a71db84657be2 languageName: node linkType: hard @@ -3209,6 +3283,13 @@ __metadata: languageName: node linkType: hard +"chardet@npm:^2.1.1": + version: 2.1.1 + resolution: "chardet@npm:2.1.1" + checksum: 10c0/d8391dd412338442b3de0d3a488aa9327f8bcf74b62b8723d6bd0b85c4084d50b731320e0a7c710edb1d44de75969995d2784b80e4c13b004a6c7a0db4c6e793 + languageName: node + linkType: hard + "chownr@npm:^2.0.0": version: 2.0.0 resolution: "chownr@npm:2.0.0" @@ -3321,14 +3402,14 @@ __metadata: languageName: node linkType: hard -"clipanion@npm:^3.2.1": - version: 3.2.1 - resolution: "clipanion@npm:3.2.1" +"clipanion@npm:^4.0.0-rc.4": + version: 4.0.0-rc.4 + resolution: "clipanion@npm:4.0.0-rc.4" dependencies: typanion: "npm:^3.8.0" peerDependencies: typanion: "*" - checksum: 10c0/6c148bd01ae645031aeb6e9a1a16f3ce07eb754cd9981c91edcab82b09e063b805ac41e4f36039d07602334b6dbba036b030d1807c12acd7f90778a696b7ac6e + checksum: 10c0/047b415b59a5e9777d00690fba563ccc850eca6bf27790a88d1deea3ecc8a89840ae9aed554ff284cc698a9f3f20256e43c25ff4a7c4c90a71e5e7d9dca61dd1 languageName: node linkType: hard @@ -3746,7 +3827,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:^4.3.4, debug@npm:^4.3.7, debug@npm:^4.4.0, debug@npm:~4.4.0": +"debug@npm:4, debug@npm:^4.3.4, debug@npm:^4.3.7, debug@npm:~4.4.0": version: 4.4.0 resolution: "debug@npm:4.4.0" dependencies: @@ -3758,6 +3839,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.4.1": + version: 4.4.3 + resolution: "debug@npm:4.4.3" + dependencies: + ms: "npm:^2.1.3" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10c0/d79136ec6c83ecbefd0f6a5593da6a9c91ec4d7ddc4b54c883d6e71ec9accb5f67a1a5e96d00a328196b5b5c86d365e98d8a3a70856aaf16b4e7b1985e67f5a6 + languageName: node + linkType: hard + "decamelize-keys@npm:^1.1.0": version: 1.1.1 resolution: "decamelize-keys@npm:1.1.1" @@ -3927,15 +4020,15 @@ __metadata: languageName: node linkType: hard -"emnapi@npm:^1.3.1": - version: 1.3.1 - resolution: "emnapi@npm:1.3.1" +"emnapi@npm:^1.7.1": + version: 1.7.1 + resolution: "emnapi@npm:1.7.1" peerDependencies: node-addon-api: ">= 6.1.0" peerDependenciesMeta: node-addon-api: optional: true - checksum: 10c0/db471d8ef056f6735a109367068d27d2f2c45d0cf1edc3efcc360485a585ce71130e43012b4d4936302780edbb68e3a23932fe3715114f2ce4229dc7ee0f5f2c + checksum: 10c0/e3b223cb75bed94a8d11a3fa4c1b621bf32556e3c31239c589593fc275df80630af1a113fb2598436c2b08d7d8fd0099d9d24a3fc08cabddca5b0aa044a14cf2 languageName: node linkType: hard @@ -4043,6 +4136,18 @@ __metadata: languageName: node linkType: hard +"es-toolkit@npm:^1.41.0": + version: 1.43.0 + resolution: "es-toolkit@npm:1.43.0" + dependenciesMeta: + "@trivago/prettier-plugin-sort-imports@4.3.0": + unplugged: true + prettier-plugin-sort-re-exports@0.0.1: + unplugged: true + checksum: 10c0/bbff0b591fd01be9f37a34dad7964b590e4952fc594c1230140771687f05136caa6ab21962a6e9cde7c4b529a149171ed5179d6379d4a8e656dbf7e8d126999c + languageName: node + linkType: hard + "escalade@npm:^3.1.1, escalade@npm:^3.2.0": version: 3.2.0 resolution: "escalade@npm:3.2.0" @@ -4190,7 +4295,7 @@ __metadata: languageName: node linkType: hard -"external-editor@npm:^3.0.3, external-editor@npm:^3.1.0": +"external-editor@npm:^3.0.3": version: 3.1.0 resolution: "external-editor@npm:3.1.0" dependencies: @@ -4201,10 +4306,10 @@ __metadata: languageName: node linkType: hard -"fast-content-type-parse@npm:^2.0.0": - version: 2.0.1 - resolution: "fast-content-type-parse@npm:2.0.1" - checksum: 10c0/e5ff87d75a35ae4cf377df1dca46ec49e7abbdc8513689676ecdef548b94900b50e66e516e64470035d79b9f7010ef15d98c24d8ae803a881363cc59e0715e19 +"fast-content-type-parse@npm:^3.0.0": + version: 3.0.0 + resolution: "fast-content-type-parse@npm:3.0.0" + checksum: 10c0/06251880c83b7118af3a5e66e8bcee60d44f48b39396fc60acc2b4630bd5f3e77552b999b5c8e943d45a818854360e5e97164c374ec4b562b4df96a2cdf2e188 languageName: node linkType: hard @@ -4815,6 +4920,15 @@ __metadata: languageName: node linkType: hard +"iconv-lite@npm:^0.7.0": + version: 0.7.1 + resolution: "iconv-lite@npm:0.7.1" + dependencies: + safer-buffer: "npm:>= 2.1.2 < 3.0.0" + checksum: 10c0/f5c9e2bddd7101a71b07a381ace44ebdc65ca76a10be0e9e64d372b511132acc4ee41b830962f438840d492cd6f9e08c237289f760d6a7fed754e61cffcb6757 + languageName: node + linkType: hard + "ieee754@npm:^1.1.13, ieee754@npm:^1.2.1": version: 1.2.1 resolution: "ieee754@npm:1.2.1" @@ -5679,13 +5793,6 @@ __metadata: languageName: node linkType: hard -"lodash-es@npm:^4.17.21": - version: 4.17.21 - resolution: "lodash-es@npm:4.17.21" - checksum: 10c0/fb407355f7e6cd523a9383e76e6b455321f0f153a6c9625e21a8827d10c54c2a2341bd2ae8d034358b60e07325e1330c14c224ff582d04612a46a4f0479ff2f2 - languageName: node - linkType: hard - "lodash.includes@npm:^4.3.0": version: 4.3.0 resolution: "lodash.includes@npm:4.3.0" @@ -6237,10 +6344,10 @@ __metadata: languageName: node linkType: hard -"mute-stream@npm:^2.0.0": - version: 2.0.0 - resolution: "mute-stream@npm:2.0.0" - checksum: 10c0/2cf48a2087175c60c8dcdbc619908b49c07f7adcfc37d29236b0c5c612d6204f789104c98cc44d38acab7b3c96f4a3ec2cfdc4934d0738d876dbefa2a12c69f4 +"mute-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "mute-stream@npm:3.0.0" + checksum: 10c0/12cdb36a101694c7a6b296632e6d93a30b74401873cf7507c88861441a090c71c77a58f213acadad03bc0c8fa186639dec99d68a14497773a8744320c136e701 languageName: node linkType: hard @@ -6407,7 +6514,7 @@ __metadata: version: 0.0.0-use.local resolution: "node-rs@workspace:." dependencies: - "@napi-rs/cli": "npm:^3.0.0-alpha.64" + "@napi-rs/cli": "npm:^3.5.0" "@napi-rs/wasm-runtime": "npm:^0.2.5" "@taplo/cli": "npm:^0.7.0" "@tybys/wasm-util": "npm:^0.10.0" @@ -6745,6 +6852,13 @@ __metadata: languageName: node linkType: hard +"obug@npm:^2.0.0": + version: 2.1.1 + resolution: "obug@npm:2.1.1" + checksum: 10c0/59dccd7de72a047e08f8649e94c1015ec72f94eefb6ddb57fb4812c4b425a813bc7e7cd30c9aca20db3c59abc3c85cc7a62bb656a968741d770f4e8e02bc2e78 + languageName: node + linkType: hard + "once@npm:^1.3.0, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0" @@ -7764,7 +7878,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3": +"semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4": version: 7.6.3 resolution: "semver@npm:7.6.3" bin: @@ -7773,6 +7887,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.7.3": + version: 7.7.3 + resolution: "semver@npm:7.7.3" + bin: + semver: bin/semver.js + checksum: 10c0/4afe5c986567db82f44c8c6faef8fe9df2a9b1d98098fc1721f57c696c4c21cebd572f297fc21002f81889492345b8470473bc6f4aff5fb032a6ea59ea2bc45e + languageName: node + linkType: hard + "serialize-error@npm:^7.0.1": version: 7.0.1 resolution: "serialize-error@npm:7.0.1" @@ -8374,13 +8497,6 @@ __metadata: languageName: node linkType: hard -"toml@npm:^3.0.0": - version: 3.0.0 - resolution: "toml@npm:3.0.0" - checksum: 10c0/8d7ed3e700ca602e5419fca343e1c595eb7aa177745141f0761a5b20874b58ee5c878cd045c408da9d130cb2b611c639912210ba96ce2f78e443569aa8060c18 - languageName: node - linkType: hard - "tr46@npm:~0.0.3": version: 0.0.3 resolution: "tr46@npm:0.0.3" @@ -8657,13 +8773,6 @@ __metadata: languageName: node linkType: hard -"wasm-sjlj@npm:^1.0.5": - version: 1.0.6 - resolution: "wasm-sjlj@npm:1.0.6" - checksum: 10c0/e1172736ca02af383e838ce396b6cc7fc8814d7cc313b30b721c513a79140313cebadb094b9e76d13e27cc679cde72df4e660dbdc5033e8cf66cf0bd176024dd - languageName: node - linkType: hard - "watchpack@npm:^2.4.1": version: 2.4.2 resolution: "watchpack@npm:2.4.2" @@ -8810,7 +8919,7 @@ __metadata: languageName: node linkType: hard -"wrap-ansi@npm:^6.0.1, wrap-ansi@npm:^6.2.0": +"wrap-ansi@npm:^6.0.1": version: 6.2.0 resolution: "wrap-ansi@npm:6.2.0" dependencies: @@ -8843,6 +8952,17 @@ __metadata: languageName: node linkType: hard +"wrap-ansi@npm:^9.0.2": + version: 9.0.2 + resolution: "wrap-ansi@npm:9.0.2" + dependencies: + ansi-styles: "npm:^6.2.1" + string-width: "npm:^7.0.0" + strip-ansi: "npm:^7.1.0" + checksum: 10c0/3305839b9a0d6fb930cb63a52f34d3936013d8b0682ff3ec133c9826512620f213800ffa19ea22904876d5b7e9a3c1f40682f03597d986a4ca881fa7b033688c + languageName: node + linkType: hard + "wrappy@npm:1": version: 1.0.2 resolution: "wrappy@npm:1.0.2" @@ -9014,10 +9134,3 @@ __metadata: checksum: 10c0/b1dbfefa679848442454b60053a6c95d62f2d2e21dd28def92b647587f415969173c6e99a0f3bab4f1b67ee8283bf735ebe3544013f09491186ba9e8a9a2b651 languageName: node linkType: hard - -"yoctocolors-cjs@npm:^2.1.2": - version: 2.1.2 - resolution: "yoctocolors-cjs@npm:2.1.2" - checksum: 10c0/a0e36eb88fea2c7981eab22d1ba45e15d8d268626e6c4143305e2c1628fa17ebfaa40cd306161a8ce04c0a60ee0262058eab12567493d5eb1409780853454c6f - languageName: node - linkType: hard