Compare commits

...

5 Commits

Author SHA1 Message Date
Nicolás Hatcher
b0ad2848ba FIX remove tests on arm bindings 2025-10-22 02:46:00 +02:00
Nicolás Hatcher
b079d98908 FIX: universal => univeralize 2025-10-22 02:42:17 +02:00
Nicolás Hatcher
1c731e11fd FIX: node 18 is out 2025-10-22 02:33:12 +02:00
Nicolás Hatcher
8e6af0cd74 FIX: Disables armv7 musle for now 2025-10-22 02:09:14 +02:00
Nicolás Hatcher
835137fa30 UPDATE: Update nodejs dependencies 2025-10-22 01:30:28 +02:00
25 changed files with 721 additions and 5578 deletions

View File

@@ -31,38 +31,82 @@ jobs:
- host: ubuntu-latest - host: ubuntu-latest
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: yarn build --target x86_64-unknown-linux-gnu build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
yarn build --target x86_64-unknown-linux-gnu
- host: ubuntu-latest - host: ubuntu-latest
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: yarn build --target x86_64-unknown-linux-musl build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
yarn build --target x86_64-unknown-linux-musl
- host: macos-latest - host: macos-latest
target: aarch64-apple-darwin target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
yarn build --target aarch64-apple-darwin
- host: ubuntu-latest - host: ubuntu-latest
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: yarn build --target aarch64-unknown-linux-gnu build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
rustup target add aarch64-unknown-linux-gnu &&
yarn build --target aarch64-unknown-linux-gnu
- host: ubuntu-latest - host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf target: armv7-unknown-linux-gnueabihf
setup: | setup: |
sudo apt-get update sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
build: yarn build --target armv7-unknown-linux-gnueabihf build: |
- host: ubuntu-latest set -e
target: armv7-unknown-linux-musleabihf rustup toolchain install 1.90.0
build: yarn build --target armv7-unknown-linux-musleabihf rustup default 1.90.0
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export PKG_CONFIG_ALLOW_CROSS=1
yarn build --target armv7-unknown-linux-gnueabihf
# - host: ubuntu-latest
# target: armv7-unknown-linux-musleabihf
# build: |
# set -e
# rustup toolchain install 1.90.0
# rustup default 1.90.0
# # Use Zig as the MUSL cross C toolchain
# export CC_armv7_unknown_linux_musleabihf="zig cc -target armv7-linux-musleabihf -mfpu=vfpv3-d16 -mfloat-abi=hard"
# export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER="zig cc -target armv7-linux-musleabihf -mfpu=vfpv3-d16 -mfloat-abi=hard"
# export AR_armv7_unknown_linux_musleabihf="zig ar"
# export PKG_CONFIG_ALLOW_CROSS=1
# yarn build --target armv7-unknown-linux-musleabihf
- host: ubuntu-latest - host: ubuntu-latest
target: aarch64-linux-android target: aarch64-linux-android
build: yarn build --target aarch64-linux-android build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
yarn build --target aarch64-linux-android
- host: ubuntu-latest - host: ubuntu-latest
target: armv7-linux-androideabi target: armv7-linux-androideabi
build: yarn build --target armv7-linux-androideabi build: |
set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
yarn build --target armv7-linux-androideabi
- host: ubuntu-latest - host: ubuntu-latest
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |- build: |-
set -e && set -e &&
rustup toolchain install 1.90.0 &&
rustup default 1.90.0 &&
rustup target add aarch64-unknown-linux-musl && rustup target add aarch64-unknown-linux-musl &&
yarn build --target aarch64-unknown-linux-musl yarn build --target aarch64-unknown-linux-musl
- host: windows-latest - host: windows-latest
@@ -92,7 +136,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }} if: ${{ !matrix.settings.docker }}
with: with:
toolchain: stable toolchain: 1.90.0
targets: ${{ matrix.settings.target }} targets: ${{ matrix.settings.target }}
- name: Cache cargo - name: Cache cargo
uses: actions/cache@v4 uses: actions/cache@v4
@@ -144,7 +188,6 @@ jobs:
- host: windows-latest - host: windows-latest
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
node: node:
- '18'
- '20' - '20'
runs-on: ${{ matrix.settings.host }} runs-on: ${{ matrix.settings.host }}
defaults: defaults:
@@ -179,7 +222,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
node: node:
- '18'
- '20' - '20'
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
@@ -213,7 +255,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
node: node:
- '18'
- '20' - '20'
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
@@ -249,7 +290,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
node: node:
- '18'
- '20' - '20'
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
@@ -320,48 +360,6 @@ jobs:
run: | run: |
set -e set -e
yarn test yarn test
test-linux-arm-gnueabihf-binding:
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- '18'
- '20'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./bindings/nodejs
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-armv7-unknown-linux-gnueabihf
path: bindings/nodejs/
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm"
yarn install
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-bullseye-slim
options: '--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build/bindings/nodejs'
run: |
set -e
yarn test
ls -la
universal-macOS: universal-macOS:
name: Build universal macOS binary name: Build universal macOS binary
needs: needs:
@@ -410,7 +408,6 @@ jobs:
- test-linux-x64-musl-binding - test-linux-x64-musl-binding
- test-linux-aarch64-gnu-binding - test-linux-aarch64-gnu-binding
- test-linux-aarch64-musl-binding - test-linux-aarch64-musl-binding
- test-linux-arm-gnueabihf-binding
- universal-macOS - universal-macOS
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

74
Cargo.lock generated
View File

@@ -218,9 +218,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.6.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f"
dependencies = [ dependencies = [
"unicode-segmentation", "unicode-segmentation",
] ]
@@ -288,14 +288,20 @@ dependencies = [
[[package]] [[package]]
name = "ctor" name = "ctor"
version = "0.2.9" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" checksum = "67773048316103656a637612c4a62477603b777d91d9c62ff2290f9cde178fdb"
dependencies = [ dependencies = [
"quote", "ctor-proc-macro",
"syn", "dtor",
] ]
[[package]]
name = "ctor-proc-macro"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2931af7e13dc045d8e9d26afccc6fa115d64e115c9c84b1166288b46f6782c2"
[[package]] [[package]]
name = "deranged" name = "deranged"
version = "0.3.11" version = "0.3.11"
@@ -316,6 +322,21 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "dtor"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e58a0764cddb55ab28955347b45be00ade43d4d6f3ba4bf3dc354e4ec9432934"
dependencies = [
"dtor-proc-macro",
]
[[package]]
name = "dtor-proc-macro"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5"
[[package]] [[package]]
name = "either" name = "either"
version = "1.10.0" version = "1.10.0"
@@ -537,33 +558,34 @@ dependencies = [
[[package]] [[package]]
name = "napi" name = "napi"
version = "2.16.13" version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "214f07a80874bb96a8433b3cdfc84980d56c7b02e1a0d7ba4ba0db5cef785e2b" checksum = "f1b74e3dce5230795bb4d2821b941706dee733c7308752507254b0497f39cad7"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"ctor", "ctor",
"napi-derive", "napi-build",
"napi-sys", "napi-sys",
"once_cell", "nohash-hasher",
"rustc-hash",
"serde", "serde",
"serde_json", "serde_json",
] ]
[[package]] [[package]]
name = "napi-build" name = "napi-build"
version = "2.1.4" version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db836caddef23662b94e16bf1f26c40eceb09d6aee5d5b06a7ac199320b69b19" checksum = "dcae8ad5609d14afb3a3b91dee88c757016261b151e9dcecabf1b2a31a6cab14"
[[package]] [[package]]
name = "napi-derive" name = "napi-derive"
version = "2.16.13" version = "3.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cbe2585d8ac223f7d34f13701434b9d5f4eb9c332cccce8dee57ea18ab8ab0c" checksum = "7552d5a579b834614bbd496db5109f1b9f1c758f08224b0dee1e408333adf0d0"
dependencies = [ dependencies = [
"cfg-if",
"convert_case", "convert_case",
"ctor",
"napi-derive-backend", "napi-derive-backend",
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -572,28 +594,32 @@ dependencies = [
[[package]] [[package]]
name = "napi-derive-backend" name = "napi-derive-backend"
version = "1.0.75" version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1639aaa9eeb76e91c6ae66da8ce3e89e921cd3885e99ec85f4abacae72fc91bf" checksum = "5f6a81ac7486b70f2532a289603340862c06eea5a1e650c1ffeda2ce1238516a"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex",
"semver", "semver",
"syn", "syn",
] ]
[[package]] [[package]]
name = "napi-sys" name = "napi-sys"
version = "2.4.0" version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427802e8ec3a734331fec1035594a210ce1ff4dc5bc1950530920ab717964ea3" checksum = "3e4e7135a8f97aa0f1509cce21a8a1f9dcec1b50d8dee006b48a5adb69a9d64d"
dependencies = [ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "nohash-hasher"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]] [[package]]
name = "num-conv" name = "num-conv"
version = "0.1.0" version = "0.1.0"
@@ -871,6 +897,12 @@ version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f"
[[package]]
name = "rustc-hash"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.21" version = "1.0.21"

View File

@@ -8,8 +8,8 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4", "serde-json"] } napi = { version = "3.3", default-features = false, features = ["napi4", "serde-json"] }
napi-derive = "2.12.2" napi-derive = "3.2"
ironcalc = { path = "../../xlsx", version = "0.6.0" } ironcalc = { path = "../../xlsx", version = "0.6.0" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }

View File

@@ -1,8 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */ /* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Model { export declare class Model {
constructor(name: string, locale: string, timezone: string) constructor(name: string, locale: string, timezone: string)
static fromXlsx(filePath: string, locale: string, tz: string): Model static fromXlsx(filePath: string, locale: string, tz: string): Model
@@ -39,8 +36,10 @@ export declare class Model {
newDefinedName(name: string, scope: number | undefined | null, formula: string): void newDefinedName(name: string, scope: number | undefined | null, formula: string): void
updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void
deleteDefinedName(name: string, scope?: number | undefined | null): void deleteDefinedName(name: string, scope?: number | undefined | null): void
testPanic(): void moveColumn(sheet: number, column: number, delta: number): void
moveRow(sheet: number, row: number, delta: number): void
} }
export declare class UserModel { export declare class UserModel {
constructor(name: string, locale: string, timezone: string) constructor(name: string, locale: string, timezone: string)
static fromBytes(bytes: Uint8Array): UserModel static fromBytes(bytes: Uint8Array): UserModel
@@ -59,12 +58,13 @@ export declare class UserModel {
setSheetColor(sheet: number, color: string): void setSheetColor(sheet: number, color: string): void
rangeClearAll(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void rangeClearAll(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void
rangeClearContents(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void rangeClearContents(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void
rangeClearFormatting(sheet: number, startRow: number, startColumn: number, endRow: number, endColumn: number): void
insertRows(sheet: number, row: number, rowCount: number): void insertRows(sheet: number, row: number, rowCount: number): void
insertColumns(sheet: number, column: number, columnCount: number): void insertColumns(sheet: number, column: number, columnCount: number): void
deleteRows(sheet: number, row: number, rowCount: number): void deleteRows(sheet: number, row: number, rowCount: number): void
deleteColumns(sheet: number, column: number, columnCount: number): void deleteColumns(sheet: number, column: number, columnCount: number): void
setRowHeight(sheet: number, row: number, height: number): void setRowsHeight(sheet: number, rowStart: number, rowEnd: number, height: number): void
setColumnWidth(sheet: number, column: number, width: number): void setColumnsWidth(sheet: number, columnStart: number, columnEnd: number, width: number): void
getRowHeight(sheet: number, row: number): number getRowHeight(sheet: number, row: number): number
getColumnWidth(sheet: number, column: number): number getColumnWidth(sheet: number, column: number): number
setUserInput(sheet: number, row: number, column: number, input: string): void setUserInput(sheet: number, row: number, column: number, input: string): void
@@ -112,4 +112,6 @@ export declare class UserModel {
newDefinedName(name: string, scope: number | undefined | null, formula: string): void newDefinedName(name: string, scope: number | undefined | null, formula: string): void
updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void updateDefinedName(name: string, scope: number | undefined | null, newName: string, newScope: number | undefined | null, newFormula: string): void
deleteDefinedName(name: string, scope?: number | undefined | null): void deleteDefinedName(name: string, scope?: number | undefined | null): void
moveColumn(sheet: number, column: number, delta: number): void
moveRow(sheet: number, row: number, delta: number): void
} }

View File

@@ -1,316 +1,579 @@
/* tslint:disable */ // prettier-ignore
/* eslint-disable */ /* eslint-disable */
/* prettier-ignore */ // @ts-nocheck
/* auto-generated by NAPI-RS */ /* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs') const { createRequire } = require('node:module')
const { join } = require('path') require = createRequire(__filename)
const { platform, arch } = process
const { readFileSync } = require('node:fs')
let nativeBinding = null let nativeBinding = null
let localFileExisted = false const loadErrors = []
let loadError = null
function isMusl() { const isMusl = () => {
// For Node 10 let musl = false
if (!process.report || typeof process.report.getReport !== 'function') { if (process.platform === 'linux') {
try { musl = isMuslFromFilesystem()
const lddPath = require('child_process').execSync('which ldd').toString().trim() if (musl === null) {
return readFileSync(lddPath, 'utf8').includes('musl') musl = isMuslFromReport()
} catch (e) {
return true
} }
} else { if (musl === null) {
const { glibcVersionRuntime } = process.report.getReport().header musl = isMuslFromChildProcess()
return !glibcVersionRuntime }
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
} }
} }
switch (platform) { const isMuslFromReport = () => {
case 'android': let report = null
switch (arch) { if (typeof process.report?.getReport === 'function') {
case 'arm64': process.report.excludeNetwork = true
localFileExisted = existsSync(join(__dirname, 'nodejs.android-arm64.node')) report = process.report.getReport()
try {
if (localFileExisted) {
nativeBinding = require('./nodejs.android-arm64.node')
} else {
nativeBinding = require('@ironcalc/nodejs-android-arm64')
} }
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) { } catch (e) {
loadError = e // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
} }
break }
case 'arm':
localFileExisted = existsSync(join(__dirname, 'nodejs.android-arm-eabi.node')) function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try { try {
if (localFileExisted) { return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
nativeBinding = require('./nodejs.android-arm-eabi.node') } catch (err) {
} else { loadErrors.push(err)
nativeBinding = require('@ironcalc/nodejs-android-arm-eabi')
} }
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./nodejs.android-arm64.node')
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break
default:
throw new Error(`Unsupported architecture on Android ${arch}`)
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'nodejs.win32-x64-msvc.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-android-arm64')
nativeBinding = require('./nodejs.win32-x64-msvc.node') const bindingPackageVersion = require('@ironcalc/nodejs-android-arm64/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-win32-x64-msvc') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break } else if (process.arch === 'arm') {
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'nodejs.win32-ia32-msvc.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.android-arm-eabi.node')
nativeBinding = require('./nodejs.win32-ia32-msvc.node')
} else {
nativeBinding = require('@ironcalc/nodejs-win32-ia32-msvc')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'nodejs.win32-arm64-msvc.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-android-arm-eabi')
nativeBinding = require('./nodejs.win32-arm64-msvc.node') const bindingPackageVersion = require('@ironcalc/nodejs-android-arm-eabi/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-win32-arm64-msvc') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'nodejs.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./nodejs.darwin-universal.node')
} else { } else {
nativeBinding = require('@ironcalc/nodejs-darwin-universal') loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
} }
break } else if (process.platform === 'win32') {
} catch {} if (process.arch === 'x64') {
switch (arch) { if (process.report?.getReport?.()?.header?.osName?.startsWith?.('MINGW')) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'nodejs.darwin-x64.node'))
try { try {
if (localFileExisted) { return require('./nodejs.win32-x64-gnu.node')
nativeBinding = require('./nodejs.darwin-x64.node')
} else {
nativeBinding = require('@ironcalc/nodejs-darwin-x64')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'nodejs.darwin-arm64.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-win32-x64-gnu')
nativeBinding = require('./nodejs.darwin-arm64.node') const bindingPackageVersion = require('@ironcalc/nodejs-win32-x64-gnu/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-darwin-arm64') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break } else {
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'nodejs.freebsd-x64.node'))
try { try {
if (localFileExisted) { return require('./nodejs.win32-x64-msvc.node')
nativeBinding = require('./nodejs.freebsd-x64.node')
} else {
nativeBinding = require('@ironcalc/nodejs-freebsd-x64')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break try {
case 'linux': const binding = require('@ironcalc/nodejs-win32-x64-msvc')
switch (arch) { const bindingPackageVersion = require('@ironcalc/nodejs-win32-x64-msvc/package.json').version
case 'x64': if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-win32-ia32-msvc')
const bindingPackageVersion = require('@ironcalc/nodejs-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-win32-arm64-msvc')
const bindingPackageVersion = require('@ironcalc/nodejs-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-darwin-universal')
const bindingPackageVersion = require('@ironcalc/nodejs-darwin-universal/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-darwin-x64')
const bindingPackageVersion = require('@ironcalc/nodejs-darwin-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-darwin-arm64')
const bindingPackageVersion = require('@ironcalc/nodejs-darwin-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./nodejs.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-freebsd-x64')
const bindingPackageVersion = require('@ironcalc/nodejs-freebsd-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-freebsd-arm64')
const bindingPackageVersion = require('@ironcalc/nodejs-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) { if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-x64-musl.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.linux-x64-musl.node')
nativeBinding = require('./nodejs.linux-x64-musl.node')
} else {
nativeBinding = require('@ironcalc/nodejs-linux-x64-musl')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
} else {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-x64-gnu.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-linux-x64-musl')
nativeBinding = require('./nodejs.linux-x64-gnu.node') const bindingPackageVersion = require('@ironcalc/nodejs-linux-x64-musl/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-linux-x64-gnu') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
}
} else {
try {
return require('./nodejs.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-x64-gnu')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
} }
} }
break } else if (process.arch === 'arm64') {
case 'arm64':
if (isMusl()) { if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-arm64-musl.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.linux-arm64-musl.node')
nativeBinding = require('./nodejs.linux-arm64-musl.node')
} else {
nativeBinding = require('@ironcalc/nodejs-linux-arm64-musl')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
} else {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-arm64-gnu.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-linux-arm64-musl')
nativeBinding = require('./nodejs.linux-arm64-gnu.node') const bindingPackageVersion = require('@ironcalc/nodejs-linux-arm64-musl/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-linux-arm64-gnu') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
}
} else {
try {
return require('./nodejs.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-arm64-gnu')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
} }
} }
break } else if (process.arch === 'arm') {
case 'arm':
if (isMusl()) { if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-arm-musleabihf.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.linux-arm-musleabihf.node')
nativeBinding = require('./nodejs.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@ironcalc/nodejs-linux-arm-musleabihf')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
} else {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-arm-gnueabihf.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-linux-arm-musleabihf')
nativeBinding = require('./nodejs.linux-arm-gnueabihf.node') const bindingPackageVersion = require('@ironcalc/nodejs-linux-arm-musleabihf/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-linux-arm-gnueabihf') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
}
} else {
try {
return require('./nodejs.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-arm-gnueabihf')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
} }
} }
break } else if (process.arch === 'loong64') {
case 'riscv64':
if (isMusl()) { if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-riscv64-musl.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.linux-loong64-musl.node')
nativeBinding = require('./nodejs.linux-riscv64-musl.node')
} else {
nativeBinding = require('@ironcalc/nodejs-linux-riscv64-musl')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
} else {
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-riscv64-gnu.node')
)
try { try {
if (localFileExisted) { const binding = require('@ironcalc/nodejs-linux-loong64-musl')
nativeBinding = require('./nodejs.linux-riscv64-gnu.node') const bindingPackageVersion = require('@ironcalc/nodejs-linux-loong64-musl/package.json').version
} else { if (bindingPackageVersion !== '0.6.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
nativeBinding = require('@ironcalc/nodejs-linux-riscv64-gnu') throw new Error(`Native binding package version mismatch, expected 0.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
} }
return binding
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
} } else {
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'nodejs.linux-s390x-gnu.node')
)
try { try {
if (localFileExisted) { return require('./nodejs.linux-loong64-gnu.node')
nativeBinding = require('./nodejs.linux-s390x-gnu.node')
} else {
nativeBinding = require('@ironcalc/nodejs-linux-s390x-gnu')
}
} catch (e) { } catch (e) {
loadError = e loadErrors.push(e)
} }
break try {
default: const binding = require('@ironcalc/nodejs-linux-loong64-gnu')
throw new Error(`Unsupported architecture on Linux: ${arch}`) const bindingPackageVersion = require('@ironcalc/nodejs-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-riscv64-musl')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./nodejs.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-riscv64-gnu')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-ppc64-gnu')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./nodejs.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-linux-s390x-gnu')
const bindingPackageVersion = require('@ironcalc/nodejs-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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}`))
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./nodejs.openharmony-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-openharmony-arm64')
const bindingPackageVersion = require('@ironcalc/nodejs-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./nodejs.openharmony-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-openharmony-x64')
const bindingPackageVersion = require('@ironcalc/nodejs-openharmony-x64/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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('./nodejs.openharmony-arm.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ironcalc/nodejs-openharmony-arm')
const bindingPackageVersion = require('@ironcalc/nodejs-openharmony-arm/package.json').version
if (bindingPackageVersion !== '0.6.0' && 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.6.0 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 OpenHarmony: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
let wasiBinding = null
let wasiBindingError = null
try {
wasiBinding = require('./nodejs.wasi.cjs')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError = err
}
}
if (!nativeBinding) {
try {
wasiBinding = require('@ironcalc/nodejs-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
} }
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
} }
if (!nativeBinding) { if (!nativeBinding) {
if (loadError) { if (loadErrors.length > 0) {
throw loadError 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`) throw new Error(`Failed to load native binding`)
} }
const { Model, UserModel } = nativeBinding module.exports = nativeBinding
module.exports.Model = nativeBinding.Model
module.exports.Model = Model module.exports.UserModel = nativeBinding.UserModel
module.exports.UserModel = UserModel

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-android-arm-eabi", "name": "@ironcalc/nodejs-android-arm-eabi",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"android" "android"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-android-arm64", "name": "@ironcalc/nodejs-android-arm64",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"android" "android"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-darwin-arm64", "name": "@ironcalc/nodejs-darwin-arm64",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"darwin" "darwin"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-darwin-universal", "name": "@ironcalc/nodejs-darwin-universal",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"darwin" "darwin"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-darwin-x64", "name": "@ironcalc/nodejs-darwin-x64",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"darwin" "darwin"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-arm-gnueabihf", "name": "@ironcalc/nodejs-linux-arm-gnueabihf",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-arm-musleabihf", "name": "@ironcalc/nodejs-linux-arm-musleabihf",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-arm64-gnu", "name": "@ironcalc/nodejs-linux-arm64-gnu",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-arm64-musl", "name": "@ironcalc/nodejs-linux-arm64-musl",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-riscv64-gnu", "name": "@ironcalc/nodejs-linux-riscv64-gnu",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-x64-gnu", "name": "@ironcalc/nodejs-linux-x64-gnu",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-linux-x64-musl", "name": "@ironcalc/nodejs-linux-x64-musl",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"linux" "linux"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-win32-arm64-msvc", "name": "@ironcalc/nodejs-win32-arm64-msvc",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"win32" "win32"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ironcalc/nodejs-win32-x64-msvc", "name": "@ironcalc/nodejs-win32-x64-msvc",
"version": "0.2.0", "version": "0.6.0",
"os": [ "os": [
"win32" "win32"
], ],

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,11 @@
{ {
"name": "@ironcalc/nodejs", "name": "@ironcalc/nodejs",
"version": "0.5.1", "version": "0.6.0",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",
"napi": { "napi": {
"name": "nodejs", "binaryName": "nodejs",
"triples": { "targets": [
"additional": [
"aarch64-apple-darwin", "aarch64-apple-darwin",
"aarch64-linux-android", "aarch64-linux-android",
"aarch64-unknown-linux-gnu", "aarch64-unknown-linux-gnu",
@@ -19,11 +18,10 @@
"universal-apple-darwin", "universal-apple-darwin",
"riscv64gc-unknown-linux-gnu" "riscv64gc-unknown-linux-gnu"
] ]
}
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@napi-rs/cli": "^2.18.4", "@napi-rs/cli": "^3.3",
"ava": "^6.0.1" "ava": "^6.0.1"
}, },
"ava": { "ava": {
@@ -38,7 +36,7 @@
"build:debug": "napi build --platform", "build:debug": "napi build --platform",
"prepublishOnly": "napi prepublish -t npm", "prepublishOnly": "napi prepublish -t npm",
"test": "ava", "test": "ava",
"universal": "napi universal", "universal": "napi universalize",
"version": "napi version" "version": "napi version"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#![deny(clippy::all)] #![deny(clippy::all)]
use napi::{self, bindgen_prelude::*, JsUnknown, Result}; use napi::{self, bindgen_prelude::*, Result, Unknown};
use serde::Serialize; use serde::Serialize;
use ironcalc::{ use ironcalc::{
@@ -127,7 +127,7 @@ impl Model {
sheet: u32, sheet: u32,
row: i32, row: i32,
column: i32, column: i32,
style: JsUnknown, style: Unknown,
) -> Result<()> { ) -> Result<()> {
let style: Style = env let style: Style = env
.from_js_value(style) .from_js_value(style)
@@ -140,12 +140,12 @@ impl Model {
#[napi(js_name = "getCellStyle")] #[napi(js_name = "getCellStyle")]
pub fn get_cell_style( pub fn get_cell_style(
&mut self, &'_ self,
env: Env, env: Env,
sheet: u32, sheet: u32,
row: i32, row: i32,
column: i32, column: i32,
) -> Result<JsUnknown> { ) -> Result<Unknown<'_>> {
let style = self let style = self
.model .model
.get_style_for_cell(sheet, row, column) .get_style_for_cell(sheet, row, column)
@@ -246,11 +246,11 @@ impl Model {
.map_err(to_js_error) .map_err(to_js_error)
} }
// I don't _think_ serializing to JsUnknown can't fail // I don't _think_ serializing to Unknown can't fail
// FIXME: Remove this clippy directive // FIXME: Remove this clippy directive
#[napi(js_name = "getWorksheetsProperties")] #[napi(js_name = "getWorksheetsProperties")]
#[allow(clippy::unwrap_used)] #[allow(clippy::unwrap_used)]
pub fn get_worksheets_properties(&self, env: Env) -> JsUnknown { pub fn get_worksheets_properties(&'_ self, env: Env) -> Unknown<'_> {
env env
.to_js_value(&self.model.get_worksheets_properties()) .to_js_value(&self.model.get_worksheets_properties())
.unwrap() .unwrap()
@@ -288,7 +288,7 @@ impl Model {
} }
#[napi(js_name = "getDefinedNameList")] #[napi(js_name = "getDefinedNameList")]
pub fn get_defined_name_list(&self, env: Env) -> Result<JsUnknown> { pub fn get_defined_name_list(&'_ self, env: Env) -> Result<Unknown<'_>> {
let data: Vec<DefinedName> = self let data: Vec<DefinedName> = self
.model .model
.workbook .workbook

View File

@@ -2,7 +2,7 @@
use serde::Serialize; use serde::Serialize;
use napi::{self, bindgen_prelude::*, JsUnknown, Result}; use napi::{self, bindgen_prelude::*, Result, Unknown};
use ironcalc::base::{ use ironcalc::base::{
expressions::types::Area, expressions::types::Area,
@@ -305,7 +305,7 @@ impl UserModel {
pub fn update_range_style( pub fn update_range_style(
&mut self, &mut self,
env: Env, env: Env,
range: JsUnknown, range: Unknown,
style_path: String, style_path: String,
value: String, value: String,
) -> Result<()> { ) -> Result<()> {
@@ -320,12 +320,12 @@ impl UserModel {
#[napi(js_name = "getCellStyle")] #[napi(js_name = "getCellStyle")]
pub fn get_cell_style( pub fn get_cell_style(
&mut self, &'_ mut self,
env: Env, env: Env,
sheet: u32, sheet: u32,
row: i32, row: i32,
column: i32, column: i32,
) -> Result<JsUnknown> { ) -> Result<Unknown<'_>> {
let style = self let style = self
.model .model
.get_cell_style(sheet, row, column) .get_cell_style(sheet, row, column)
@@ -337,7 +337,7 @@ impl UserModel {
} }
#[napi(js_name = "onPasteStyles")] #[napi(js_name = "onPasteStyles")]
pub fn on_paste_styles(&mut self, env: Env, styles: JsUnknown) -> Result<()> { pub fn on_paste_styles(&mut self, env: Env, styles: Unknown) -> Result<()> {
let styles: &Vec<Vec<Style>> = &env let styles: &Vec<Vec<Style>> = &env
.from_js_value(styles) .from_js_value(styles)
.map_err(|e| to_js_error(e.to_string()))?; .map_err(|e| to_js_error(e.to_string()))?;
@@ -362,11 +362,11 @@ impl UserModel {
) )
} }
// I don't _think_ serializing to JsUnknown can't fail // I don't _think_ serializing to Unknown can't fail
// FIXME: Remove this clippy directive // FIXME: Remove this clippy directive
#[napi(js_name = "getWorksheetsProperties")] #[napi(js_name = "getWorksheetsProperties")]
#[allow(clippy::unwrap_used)] #[allow(clippy::unwrap_used)]
pub fn get_worksheets_properties(&self, env: Env) -> JsUnknown { pub fn get_worksheets_properties(&'_ self, env: Env) -> Unknown<'_> {
env env
.to_js_value(&self.model.get_worksheets_properties()) .to_js_value(&self.model.get_worksheets_properties())
.unwrap() .unwrap()
@@ -383,11 +383,11 @@ impl UserModel {
vec![sheet as i32, row, column] vec![sheet as i32, row, column]
} }
// I don't _think_ serializing to JsUnknown can't fail // I don't _think_ serializing to Unknown can't fail
// FIXME: Remove this clippy directive // FIXME: Remove this clippy directive
#[napi(js_name = "getSelectedView")] #[napi(js_name = "getSelectedView")]
#[allow(clippy::unwrap_used)] #[allow(clippy::unwrap_used)]
pub fn get_selected_view(&self, env: Env) -> JsUnknown { pub fn get_selected_view(&'_ self, env: Env) -> Unknown<'_> {
env.to_js_value(&self.model.get_selected_view()).unwrap() env.to_js_value(&self.model.get_selected_view()).unwrap()
} }
@@ -440,7 +440,7 @@ impl UserModel {
} }
#[napi(js_name = "autoFillRows")] #[napi(js_name = "autoFillRows")]
pub fn auto_fill_rows(&mut self, env: Env, source_area: JsUnknown, to_row: i32) -> Result<()> { pub fn auto_fill_rows(&mut self, env: Env, source_area: Unknown, to_row: i32) -> Result<()> {
let area: Area = env let area: Area = env
.from_js_value(source_area) .from_js_value(source_area)
.map_err(|e| to_js_error(e.to_string()))?; .map_err(|e| to_js_error(e.to_string()))?;
@@ -454,7 +454,7 @@ impl UserModel {
pub fn auto_fill_columns( pub fn auto_fill_columns(
&mut self, &mut self,
env: Env, env: Env,
source_area: JsUnknown, source_area: Unknown,
to_column: i32, to_column: i32,
) -> Result<()> { ) -> Result<()> {
let area: Area = env let area: Area = env
@@ -536,8 +536,8 @@ impl UserModel {
pub fn set_area_with_border( pub fn set_area_with_border(
&mut self, &mut self,
env: Env, env: Env,
area: JsUnknown, area: Unknown,
border_area: JsUnknown, border_area: Unknown,
) -> Result<()> { ) -> Result<()> {
let range: Area = env let range: Area = env
.from_js_value(area) .from_js_value(area)
@@ -568,7 +568,7 @@ impl UserModel {
} }
#[napi(js_name = "copyToClipboard")] #[napi(js_name = "copyToClipboard")]
pub fn copy_to_clipboard(&self, env: Env) -> Result<JsUnknown> { pub fn copy_to_clipboard(&'_ self, env: Env) -> Result<Unknown<'_>> {
let data = self let data = self
.model .model
.copy_to_clipboard() .copy_to_clipboard()
@@ -584,8 +584,8 @@ impl UserModel {
&mut self, &mut self,
env: Env, env: Env,
source_sheet: u32, source_sheet: u32,
source_range: JsUnknown, source_range: Unknown,
clipboard: JsUnknown, clipboard: Unknown,
is_cut: bool, is_cut: bool,
) -> Result<()> { ) -> Result<()> {
let source_range: (i32, i32, i32, i32) = env let source_range: (i32, i32, i32, i32) = env
@@ -601,7 +601,7 @@ impl UserModel {
} }
#[napi(js_name = "pasteCsvText")] #[napi(js_name = "pasteCsvText")]
pub fn paste_csv_string(&mut self, env: Env, area: JsUnknown, csv: String) -> Result<()> { pub fn paste_csv_string(&mut self, env: Env, area: Unknown, csv: String) -> Result<()> {
let range: Area = env let range: Area = env
.from_js_value(area) .from_js_value(area)
.map_err(|e| to_js_error(e.to_string()))?; .map_err(|e| to_js_error(e.to_string()))?;
@@ -612,7 +612,7 @@ impl UserModel {
} }
#[napi(js_name = "getDefinedNameList")] #[napi(js_name = "getDefinedNameList")]
pub fn get_defined_name_list(&self, env: Env) -> Result<JsUnknown> { pub fn get_defined_name_list(&'_ self, env: Env) -> Result<Unknown<'_>> {
let data: Vec<DefinedName> = self let data: Vec<DefinedName> = self
.model .model
.get_defined_name_list() .get_defined_name_list()

File diff suppressed because it is too large Load Diff