@d0paminedriven/xlsxdown 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/browser.js +1 -0
- package/index.d.ts +142 -0
- package/index.js +781 -0
- package/package.json +116 -4
package/README.md
CHANGED
package/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@d0paminedriven/xlsxdown-wasm32-wasi'
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* auto-generated by @d0paminedriven/xlsxdown */
|
|
2
|
+
/**
|
|
3
|
+
* Which binding artifact the generated loader actually loaded: `'native'` for
|
|
4
|
+
* a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
|
|
5
|
+
* flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
|
|
6
|
+
* can point the loader at a WASI artifact this package does not build itself.
|
|
7
|
+
*/
|
|
8
|
+
export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A parsed workbook. Parsing happens once, in the constructor or in `openAsync`; every method
|
|
12
|
+
* reads from the parsed workbook.
|
|
13
|
+
*/
|
|
14
|
+
export declare class XlsxDown {
|
|
15
|
+
/**
|
|
16
|
+
* Parse a workbook from the bytes of an `.xlsx` file. Throws `unsupported format: …` for a
|
|
17
|
+
* package that is not a plain workbook, `limit exceeded: …` for one past the size limits and
|
|
18
|
+
* `malformed workbook: …` for anything else that cannot be read.
|
|
19
|
+
*/
|
|
20
|
+
constructor(buffer: Buffer)
|
|
21
|
+
/**
|
|
22
|
+
* Parse a workbook off the JavaScript thread; resolves to an `XlsxDown`, or rejects with the
|
|
23
|
+
* errors the constructor throws.
|
|
24
|
+
*/
|
|
25
|
+
static openAsync(buffer: Buffer): Promise<XlsxDown>
|
|
26
|
+
/** The cells of the selected sheets, typed, with their display text, formulas and geometry. */
|
|
27
|
+
spreadsheetCells(opts?: SpreadsheetOptions | undefined | null): Array<SheetCells>
|
|
28
|
+
/** `spreadsheetCells` on a worker thread. */
|
|
29
|
+
spreadsheetCellsAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetCells>>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A rectangle in the sheet frame: points, y up, with A1's top-left corner at `(0, height)`. */
|
|
33
|
+
export interface CellBox {
|
|
34
|
+
x0: number
|
|
35
|
+
y0: number
|
|
36
|
+
x1: number
|
|
37
|
+
y1: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether a Number cell's value is a whole number JavaScript can hold exactly, or a fraction.
|
|
42
|
+
* A percentage is a fraction (50% is 0.5); the subtype is about the value, not the format.
|
|
43
|
+
*/
|
|
44
|
+
export type NumberSubtype = 'Integer' | 'Float'
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* One cell of a worksheet: a discriminated union on `type` whose typed value is `value`
|
|
48
|
+
* (none for `Blank`). A Number carries the full double plus its `subtype` and the
|
|
49
|
+
* `currencySymbol` its format names. A Date carries an ISO date (`YYYY-MM-DD`) or date-time
|
|
50
|
+
* (`YYYY-MM-DDTHH:MM:SS`) and a Time a clock (`HH:MM:SS`), all 24-hour and with no time
|
|
51
|
+
* zone, because a workbook records none.
|
|
52
|
+
*
|
|
53
|
+
* `text` is the display text and `raw` the stored spelling (the serial for dates and
|
|
54
|
+
* times). `format` is the cell's number-format code; `formatSupported` says whether `text`
|
|
55
|
+
* was rendered from it, and when false `text` is the stored spelling.
|
|
56
|
+
*
|
|
57
|
+
* `formula` is the cell's formula without the leading `=`. On a cell that follows a shared
|
|
58
|
+
* formula it is the master's formula with its relative references moved to this cell, and
|
|
59
|
+
* `sharedFormula` names the master. `cached` says whether a result was stored.
|
|
60
|
+
*
|
|
61
|
+
* `merge` is the range this cell anchors, `hidden` whether its row or column is hidden, and
|
|
62
|
+
* `box` its rectangle in the sheet frame (a merged anchor spans its range).
|
|
63
|
+
*/
|
|
64
|
+
export type SheetCell =
|
|
65
|
+
| { type: 'Text'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: string }
|
|
66
|
+
| { type: 'Number'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: number; subtype: NumberSubtype; currencySymbol?: string }
|
|
67
|
+
| { type: 'Boolean'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: boolean }
|
|
68
|
+
| { type: 'Error'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: string }
|
|
69
|
+
| { type: 'Date'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: string }
|
|
70
|
+
| { type: 'Time'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox; value: string }
|
|
71
|
+
| { type: 'Blank'; ref: string; row: number; col: number; text: string; raw: string; format?: string; formatSupported: boolean; formula?: string; sharedFormula?: string; cached: boolean; merge?: string; hidden: boolean; box: CellBox }
|
|
72
|
+
|
|
73
|
+
/** One selected worksheet's cells, with the sheet facts a reader needs beside them. */
|
|
74
|
+
export interface SheetCells {
|
|
75
|
+
sheet: string
|
|
76
|
+
/** Position in the workbook, 0-based. */
|
|
77
|
+
index: number
|
|
78
|
+
hidden: boolean
|
|
79
|
+
/** The declared `<dimension>`, which a producer may overstate. */
|
|
80
|
+
dimension?: string
|
|
81
|
+
printArea?: string
|
|
82
|
+
/** Merged ranges in A1 form. */
|
|
83
|
+
merges: Array<string>
|
|
84
|
+
/**
|
|
85
|
+
* The sheet frame's size in points: A1 to the last non-empty cell or merged range, with hidden
|
|
86
|
+
* rows and columns counted or not per `hiddenCells`.
|
|
87
|
+
*/
|
|
88
|
+
width: number
|
|
89
|
+
height: number
|
|
90
|
+
/** Points; what a column or row absent from `columns` / `rows` measures. */
|
|
91
|
+
defaultColumnWidth: number
|
|
92
|
+
defaultRowHeight: number
|
|
93
|
+
/** Only the columns and rows that differ from the default or are hidden. */
|
|
94
|
+
columns: Array<SheetColumn>
|
|
95
|
+
rows: Array<SheetRow>
|
|
96
|
+
warnings: Array<string>
|
|
97
|
+
cells: Array<SheetCell>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** A column whose width differs from the sheet default, or that is hidden. 0-based. */
|
|
101
|
+
export interface SheetColumn {
|
|
102
|
+
index: number
|
|
103
|
+
/** Points; zero for a hidden column when hidden cells are excluded. */
|
|
104
|
+
width: number
|
|
105
|
+
hidden: boolean
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A row whose height differs from the sheet default (auto-fit growth included), or that is
|
|
110
|
+
* hidden. 0-based.
|
|
111
|
+
*/
|
|
112
|
+
export interface SheetRow {
|
|
113
|
+
index: number
|
|
114
|
+
/** Points; zero for a hidden row when hidden cells are excluded. */
|
|
115
|
+
height: number
|
|
116
|
+
hidden: boolean
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The cells of a workbook buffer's selected sheets. Parses the buffer for this call; hold an
|
|
121
|
+
* `XlsxDown` to read the same workbook more than once.
|
|
122
|
+
*/
|
|
123
|
+
export declare function spreadsheetCells(buffer: Buffer, opts?: SpreadsheetOptions | undefined | null): Array<SheetCells>
|
|
124
|
+
|
|
125
|
+
/** `spreadsheetCells` on a worker thread: the buffer is copied, then parsed and read there. */
|
|
126
|
+
export declare function spreadsheetCellsAsync(buffer: Buffer, opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetCells>>
|
|
127
|
+
|
|
128
|
+
/** Which sheets and cells a reader returns. */
|
|
129
|
+
export interface SpreadsheetOptions {
|
|
130
|
+
/**
|
|
131
|
+
* Sheet names to include, returned in workbook order; default: every visible sheet. A sheet
|
|
132
|
+
* asked for by name is included even when it is hidden.
|
|
133
|
+
*/
|
|
134
|
+
sheets?: Array<string>
|
|
135
|
+
/** Include hidden sheets (default false). */
|
|
136
|
+
hiddenSheets?: boolean
|
|
137
|
+
/**
|
|
138
|
+
* Cells in hidden rows and columns (default true): they are listed with `hidden: true`. With
|
|
139
|
+
* false they are left out, and their rows and columns have no extent.
|
|
140
|
+
*/
|
|
141
|
+
hiddenCells?: boolean
|
|
142
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/* auto-generated by NAPI-RS */
|
|
4
|
+
|
|
5
|
+
import { createRequire } from 'module'
|
|
6
|
+
const require = createRequire(import.meta.url)
|
|
7
|
+
|
|
8
|
+
const { readFileSync } = require('fs')
|
|
9
|
+
let nativeBinding = null
|
|
10
|
+
// Which artifact actually loaded. The WASI fallback chain overwrites it with
|
|
11
|
+
// the flavor it resolved; the late native retry below leaves it alone because
|
|
12
|
+
// it only runs while no WASI candidate has been loaded. The take-over check
|
|
13
|
+
// after the load-failure block can also set it.
|
|
14
|
+
let __napiLoadedBindingTarget = 'native'
|
|
15
|
+
// What this loader's own `requireNative()` calls returned. The check after
|
|
16
|
+
// the load-failure block compares it with `nativeBinding` to tell a binding
|
|
17
|
+
// this loader loaded from one that code outside it put in its place.
|
|
18
|
+
let __napiRequiredNativeBinding = null
|
|
19
|
+
const loadErrors = []
|
|
20
|
+
|
|
21
|
+
const isMusl = () => {
|
|
22
|
+
let musl = false
|
|
23
|
+
if (process.platform === 'linux') {
|
|
24
|
+
musl = isMuslFromFilesystem()
|
|
25
|
+
if (musl === null) {
|
|
26
|
+
musl = isMuslFromReport()
|
|
27
|
+
}
|
|
28
|
+
if (musl === null) {
|
|
29
|
+
musl = isMuslFromChildProcess()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return musl
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
36
|
+
|
|
37
|
+
const isMuslFromFilesystem = () => {
|
|
38
|
+
try {
|
|
39
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
40
|
+
} catch {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const isMuslFromReport = () => {
|
|
46
|
+
let report = null
|
|
47
|
+
if (process.report && typeof process.report.getReport === 'function') {
|
|
48
|
+
process.report.excludeNetwork = true
|
|
49
|
+
report = process.report.getReport()
|
|
50
|
+
}
|
|
51
|
+
if (!report) {
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
58
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const isMuslFromChildProcess = () => {
|
|
66
|
+
try {
|
|
67
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function requireNative() {
|
|
75
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
76
|
+
try {
|
|
77
|
+
const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
78
|
+
// The override may be a generated WASI loader, which already reports its
|
|
79
|
+
// own flavor. Adopt it: `module.exports` aliases this object, so claiming
|
|
80
|
+
// 'native' would both misreport the artifact and overwrite the loader's
|
|
81
|
+
// marker through the alias.
|
|
82
|
+
__napiLoadedBindingTarget =
|
|
83
|
+
overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
|
|
84
|
+
? overrideBinding.__napiBindingTarget
|
|
85
|
+
: 'native'
|
|
86
|
+
return overrideBinding
|
|
87
|
+
} catch (err) {
|
|
88
|
+
loadErrors.push(err)
|
|
89
|
+
}
|
|
90
|
+
} else if (process.platform === 'android') {
|
|
91
|
+
if (process.arch === 'arm64') {
|
|
92
|
+
try {
|
|
93
|
+
return require('./xlsxdown-node.android-arm64.node')
|
|
94
|
+
} catch (e) {
|
|
95
|
+
loadErrors.push(e)
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const binding = require('@d0paminedriven/xlsxdown-android-arm64')
|
|
99
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-android-arm64/package.json').version
|
|
100
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
|
+
}
|
|
103
|
+
return binding
|
|
104
|
+
} catch (e) {
|
|
105
|
+
loadErrors.push(e)
|
|
106
|
+
}
|
|
107
|
+
} else if (process.arch === 'arm') {
|
|
108
|
+
try {
|
|
109
|
+
return require('./xlsxdown-node.android-arm-eabi.node')
|
|
110
|
+
} catch (e) {
|
|
111
|
+
loadErrors.push(e)
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const binding = require('@d0paminedriven/xlsxdown-android-arm-eabi')
|
|
115
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-android-arm-eabi/package.json').version
|
|
116
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
117
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
118
|
+
}
|
|
119
|
+
return binding
|
|
120
|
+
} catch (e) {
|
|
121
|
+
loadErrors.push(e)
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
125
|
+
}
|
|
126
|
+
} else if (process.platform === 'win32') {
|
|
127
|
+
if (process.arch === 'x64') {
|
|
128
|
+
if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
|
|
129
|
+
try {
|
|
130
|
+
return require('./xlsxdown-node.win32-x64-gnu.node')
|
|
131
|
+
} catch (e) {
|
|
132
|
+
loadErrors.push(e)
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const binding = require('@d0paminedriven/xlsxdown-win32-x64-gnu')
|
|
136
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-win32-x64-gnu/package.json').version
|
|
137
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
138
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
|
+
}
|
|
140
|
+
return binding
|
|
141
|
+
} catch (e) {
|
|
142
|
+
loadErrors.push(e)
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
try {
|
|
146
|
+
return require('./xlsxdown-node.win32-x64-msvc.node')
|
|
147
|
+
} catch (e) {
|
|
148
|
+
loadErrors.push(e)
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const binding = require('@d0paminedriven/xlsxdown-win32-x64-msvc')
|
|
152
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-win32-x64-msvc/package.json').version
|
|
153
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
154
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
155
|
+
}
|
|
156
|
+
return binding
|
|
157
|
+
} catch (e) {
|
|
158
|
+
loadErrors.push(e)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} else if (process.arch === 'ia32') {
|
|
162
|
+
try {
|
|
163
|
+
return require('./xlsxdown-node.win32-ia32-msvc.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const binding = require('@d0paminedriven/xlsxdown-win32-ia32-msvc')
|
|
169
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-win32-ia32-msvc/package.json').version
|
|
170
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
+
}
|
|
173
|
+
return binding
|
|
174
|
+
} catch (e) {
|
|
175
|
+
loadErrors.push(e)
|
|
176
|
+
}
|
|
177
|
+
} else if (process.arch === 'arm64') {
|
|
178
|
+
try {
|
|
179
|
+
return require('./xlsxdown-node.win32-arm64-msvc.node')
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const binding = require('@d0paminedriven/xlsxdown-win32-arm64-msvc')
|
|
185
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-win32-arm64-msvc/package.json').version
|
|
186
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
|
+
}
|
|
189
|
+
return binding
|
|
190
|
+
} catch (e) {
|
|
191
|
+
loadErrors.push(e)
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
195
|
+
}
|
|
196
|
+
} else if (process.platform === 'darwin') {
|
|
197
|
+
try {
|
|
198
|
+
return require('./xlsxdown-node.darwin-universal.node')
|
|
199
|
+
} catch (e) {
|
|
200
|
+
loadErrors.push(e)
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const binding = require('@d0paminedriven/xlsxdown-darwin-universal')
|
|
204
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-darwin-universal/package.json').version
|
|
205
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
206
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
|
+
}
|
|
208
|
+
return binding
|
|
209
|
+
} catch (e) {
|
|
210
|
+
loadErrors.push(e)
|
|
211
|
+
}
|
|
212
|
+
if (process.arch === 'x64') {
|
|
213
|
+
try {
|
|
214
|
+
return require('./xlsxdown-node.darwin-x64.node')
|
|
215
|
+
} catch (e) {
|
|
216
|
+
loadErrors.push(e)
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const binding = require('@d0paminedriven/xlsxdown-darwin-x64')
|
|
220
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-darwin-x64/package.json').version
|
|
221
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
222
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
|
+
}
|
|
224
|
+
return binding
|
|
225
|
+
} catch (e) {
|
|
226
|
+
loadErrors.push(e)
|
|
227
|
+
}
|
|
228
|
+
} else if (process.arch === 'arm64') {
|
|
229
|
+
try {
|
|
230
|
+
return require('./xlsxdown-node.darwin-arm64.node')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const binding = require('@d0paminedriven/xlsxdown-darwin-arm64')
|
|
236
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-darwin-arm64/package.json').version
|
|
237
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
|
+
}
|
|
240
|
+
return binding
|
|
241
|
+
} catch (e) {
|
|
242
|
+
loadErrors.push(e)
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
246
|
+
}
|
|
247
|
+
} else if (process.platform === 'freebsd') {
|
|
248
|
+
if (process.arch === 'x64') {
|
|
249
|
+
try {
|
|
250
|
+
return require('./xlsxdown-node.freebsd-x64.node')
|
|
251
|
+
} catch (e) {
|
|
252
|
+
loadErrors.push(e)
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
const binding = require('@d0paminedriven/xlsxdown-freebsd-x64')
|
|
256
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-freebsd-x64/package.json').version
|
|
257
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
258
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
|
+
}
|
|
260
|
+
return binding
|
|
261
|
+
} catch (e) {
|
|
262
|
+
loadErrors.push(e)
|
|
263
|
+
}
|
|
264
|
+
} else if (process.arch === 'arm64') {
|
|
265
|
+
try {
|
|
266
|
+
return require('./xlsxdown-node.freebsd-arm64.node')
|
|
267
|
+
} catch (e) {
|
|
268
|
+
loadErrors.push(e)
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const binding = require('@d0paminedriven/xlsxdown-freebsd-arm64')
|
|
272
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-freebsd-arm64/package.json').version
|
|
273
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
274
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
275
|
+
}
|
|
276
|
+
return binding
|
|
277
|
+
} catch (e) {
|
|
278
|
+
loadErrors.push(e)
|
|
279
|
+
}
|
|
280
|
+
} else if (process.arch === 'ppc64') {
|
|
281
|
+
try {
|
|
282
|
+
return require('./xlsxdown-node.freebsd-ppc64.node')
|
|
283
|
+
} catch (e) {
|
|
284
|
+
loadErrors.push(e)
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const binding = require('@d0paminedriven/xlsxdown-freebsd-ppc64')
|
|
288
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-freebsd-ppc64/package.json').version
|
|
289
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
290
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
291
|
+
}
|
|
292
|
+
return binding
|
|
293
|
+
} catch (e) {
|
|
294
|
+
loadErrors.push(e)
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
298
|
+
}
|
|
299
|
+
} else if (process.platform === 'linux') {
|
|
300
|
+
if (process.arch === 'x64') {
|
|
301
|
+
if (isMusl()) {
|
|
302
|
+
try {
|
|
303
|
+
return require('./xlsxdown-node.linux-x64-musl.node')
|
|
304
|
+
} catch (e) {
|
|
305
|
+
loadErrors.push(e)
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-x64-musl')
|
|
309
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-x64-musl/package.json').version
|
|
310
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
311
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
312
|
+
}
|
|
313
|
+
return binding
|
|
314
|
+
} catch (e) {
|
|
315
|
+
loadErrors.push(e)
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
try {
|
|
319
|
+
return require('./xlsxdown-node.linux-x64-gnu.node')
|
|
320
|
+
} catch (e) {
|
|
321
|
+
loadErrors.push(e)
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-x64-gnu')
|
|
325
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-x64-gnu/package.json').version
|
|
326
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
327
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
328
|
+
}
|
|
329
|
+
return binding
|
|
330
|
+
} catch (e) {
|
|
331
|
+
loadErrors.push(e)
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} else if (process.arch === 'arm64') {
|
|
335
|
+
if (isMusl()) {
|
|
336
|
+
try {
|
|
337
|
+
return require('./xlsxdown-node.linux-arm64-musl.node')
|
|
338
|
+
} catch (e) {
|
|
339
|
+
loadErrors.push(e)
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-arm64-musl')
|
|
343
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-arm64-musl/package.json').version
|
|
344
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
345
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
346
|
+
}
|
|
347
|
+
return binding
|
|
348
|
+
} catch (e) {
|
|
349
|
+
loadErrors.push(e)
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
try {
|
|
353
|
+
return require('./xlsxdown-node.linux-arm64-gnu.node')
|
|
354
|
+
} catch (e) {
|
|
355
|
+
loadErrors.push(e)
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-arm64-gnu')
|
|
359
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-arm64-gnu/package.json').version
|
|
360
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
361
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
362
|
+
}
|
|
363
|
+
return binding
|
|
364
|
+
} catch (e) {
|
|
365
|
+
loadErrors.push(e)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} else if (process.arch === 'arm') {
|
|
369
|
+
if (isMusl()) {
|
|
370
|
+
try {
|
|
371
|
+
return require('./xlsxdown-node.linux-arm-musleabihf.node')
|
|
372
|
+
} catch (e) {
|
|
373
|
+
loadErrors.push(e)
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-arm-musleabihf')
|
|
377
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-arm-musleabihf/package.json').version
|
|
378
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
379
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
380
|
+
}
|
|
381
|
+
return binding
|
|
382
|
+
} catch (e) {
|
|
383
|
+
loadErrors.push(e)
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
try {
|
|
387
|
+
return require('./xlsxdown-node.linux-arm-gnueabihf.node')
|
|
388
|
+
} catch (e) {
|
|
389
|
+
loadErrors.push(e)
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-arm-gnueabihf')
|
|
393
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-arm-gnueabihf/package.json').version
|
|
394
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
395
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
396
|
+
}
|
|
397
|
+
return binding
|
|
398
|
+
} catch (e) {
|
|
399
|
+
loadErrors.push(e)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
} else if (process.arch === 'loong64') {
|
|
403
|
+
if (isMusl()) {
|
|
404
|
+
try {
|
|
405
|
+
return require('./xlsxdown-node.linux-loong64-musl.node')
|
|
406
|
+
} catch (e) {
|
|
407
|
+
loadErrors.push(e)
|
|
408
|
+
}
|
|
409
|
+
try {
|
|
410
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-loong64-musl')
|
|
411
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-loong64-musl/package.json').version
|
|
412
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
413
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
414
|
+
}
|
|
415
|
+
return binding
|
|
416
|
+
} catch (e) {
|
|
417
|
+
loadErrors.push(e)
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
try {
|
|
421
|
+
return require('./xlsxdown-node.linux-loong64-gnu.node')
|
|
422
|
+
} catch (e) {
|
|
423
|
+
loadErrors.push(e)
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-loong64-gnu')
|
|
427
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-loong64-gnu/package.json').version
|
|
428
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
429
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
|
+
}
|
|
431
|
+
return binding
|
|
432
|
+
} catch (e) {
|
|
433
|
+
loadErrors.push(e)
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
} else if (process.arch === 'riscv64') {
|
|
437
|
+
if (isMusl()) {
|
|
438
|
+
try {
|
|
439
|
+
return require('./xlsxdown-node.linux-riscv64-musl.node')
|
|
440
|
+
} catch (e) {
|
|
441
|
+
loadErrors.push(e)
|
|
442
|
+
}
|
|
443
|
+
try {
|
|
444
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-riscv64-musl')
|
|
445
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-riscv64-musl/package.json').version
|
|
446
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
447
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
448
|
+
}
|
|
449
|
+
return binding
|
|
450
|
+
} catch (e) {
|
|
451
|
+
loadErrors.push(e)
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
try {
|
|
455
|
+
return require('./xlsxdown-node.linux-riscv64-gnu.node')
|
|
456
|
+
} catch (e) {
|
|
457
|
+
loadErrors.push(e)
|
|
458
|
+
}
|
|
459
|
+
try {
|
|
460
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-riscv64-gnu')
|
|
461
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-riscv64-gnu/package.json').version
|
|
462
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
463
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
464
|
+
}
|
|
465
|
+
return binding
|
|
466
|
+
} catch (e) {
|
|
467
|
+
loadErrors.push(e)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
} else if (process.arch === 'ppc64') {
|
|
471
|
+
try {
|
|
472
|
+
return require('./xlsxdown-node.linux-ppc64-gnu.node')
|
|
473
|
+
} catch (e) {
|
|
474
|
+
loadErrors.push(e)
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-ppc64-gnu')
|
|
478
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-ppc64-gnu/package.json').version
|
|
479
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
|
+
}
|
|
482
|
+
return binding
|
|
483
|
+
} catch (e) {
|
|
484
|
+
loadErrors.push(e)
|
|
485
|
+
}
|
|
486
|
+
} else if (process.arch === 's390x') {
|
|
487
|
+
try {
|
|
488
|
+
return require('./xlsxdown-node.linux-s390x-gnu.node')
|
|
489
|
+
} catch (e) {
|
|
490
|
+
loadErrors.push(e)
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
const binding = require('@d0paminedriven/xlsxdown-linux-s390x-gnu')
|
|
494
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-linux-s390x-gnu/package.json').version
|
|
495
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
|
+
}
|
|
498
|
+
return binding
|
|
499
|
+
} catch (e) {
|
|
500
|
+
loadErrors.push(e)
|
|
501
|
+
}
|
|
502
|
+
} else {
|
|
503
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
504
|
+
}
|
|
505
|
+
} else if (process.platform === 'openharmony') {
|
|
506
|
+
if (process.arch === 'arm64') {
|
|
507
|
+
try {
|
|
508
|
+
return require('./xlsxdown-node.openharmony-arm64.node')
|
|
509
|
+
} catch (e) {
|
|
510
|
+
loadErrors.push(e)
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
const binding = require('@d0paminedriven/xlsxdown-openharmony-arm64')
|
|
514
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-openharmony-arm64/package.json').version
|
|
515
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
516
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
|
+
}
|
|
518
|
+
return binding
|
|
519
|
+
} catch (e) {
|
|
520
|
+
loadErrors.push(e)
|
|
521
|
+
}
|
|
522
|
+
} else if (process.arch === 'x64') {
|
|
523
|
+
try {
|
|
524
|
+
return require('./xlsxdown-node.openharmony-x64.node')
|
|
525
|
+
} catch (e) {
|
|
526
|
+
loadErrors.push(e)
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
const binding = require('@d0paminedriven/xlsxdown-openharmony-x64')
|
|
530
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-openharmony-x64/package.json').version
|
|
531
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
532
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
533
|
+
}
|
|
534
|
+
return binding
|
|
535
|
+
} catch (e) {
|
|
536
|
+
loadErrors.push(e)
|
|
537
|
+
}
|
|
538
|
+
} else if (process.arch === 'arm') {
|
|
539
|
+
try {
|
|
540
|
+
return require('./xlsxdown-node.openharmony-arm.node')
|
|
541
|
+
} catch (e) {
|
|
542
|
+
loadErrors.push(e)
|
|
543
|
+
}
|
|
544
|
+
try {
|
|
545
|
+
const binding = require('@d0paminedriven/xlsxdown-openharmony-arm')
|
|
546
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-openharmony-arm/package.json').version
|
|
547
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
548
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
549
|
+
}
|
|
550
|
+
return binding
|
|
551
|
+
} catch (e) {
|
|
552
|
+
loadErrors.push(e)
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
556
|
+
}
|
|
557
|
+
} else {
|
|
558
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function createLoadErrorChain(errors) {
|
|
563
|
+
return errors.reduce((previous, current) => {
|
|
564
|
+
let message
|
|
565
|
+
try {
|
|
566
|
+
message =
|
|
567
|
+
current && typeof current.message === 'string'
|
|
568
|
+
? current.message
|
|
569
|
+
: String(current)
|
|
570
|
+
} catch {
|
|
571
|
+
message = 'Unknown error'
|
|
572
|
+
}
|
|
573
|
+
const error = new Error(message)
|
|
574
|
+
error.cause = previous
|
|
575
|
+
return error
|
|
576
|
+
}, null)
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
580
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
581
|
+
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
582
|
+
// 'error' → require WASI without initializing a native fallback
|
|
583
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
584
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
585
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
586
|
+
//
|
|
587
|
+
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
588
|
+
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
589
|
+
const __napiWasiFlavors = ['wasm32-wasi']
|
|
590
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
591
|
+
const __napiWasiFlavorRequested =
|
|
592
|
+
typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
593
|
+
if (
|
|
594
|
+
__napiWasiFlavorRequested &&
|
|
595
|
+
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
596
|
+
) {
|
|
597
|
+
throw new Error(
|
|
598
|
+
'Unsupported WASI flavor "' +
|
|
599
|
+
__napiWasiFlavor +
|
|
600
|
+
'". Available flavors: ' +
|
|
601
|
+
__napiWasiFlavors.join(', '),
|
|
602
|
+
)
|
|
603
|
+
}
|
|
604
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
605
|
+
const forceWasi =
|
|
606
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
607
|
+
forceWasiError ||
|
|
608
|
+
__napiWasiFlavorRequested
|
|
609
|
+
|
|
610
|
+
if (!forceWasi) {
|
|
611
|
+
nativeBinding = requireNative()
|
|
612
|
+
__napiRequiredNativeBinding = nativeBinding
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (!nativeBinding || forceWasi) {
|
|
616
|
+
let wasiBinding = null
|
|
617
|
+
let wasiBindingLoaded = false
|
|
618
|
+
const wasiBindingErrors = []
|
|
619
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
620
|
+
try {
|
|
621
|
+
require.resolve(specifier)
|
|
622
|
+
} catch (resolveError) {
|
|
623
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
624
|
+
throw resolveError
|
|
625
|
+
}
|
|
626
|
+
if (isPackage) {
|
|
627
|
+
try {
|
|
628
|
+
require.resolve(specifier + '/package.json')
|
|
629
|
+
} catch (packageError) {
|
|
630
|
+
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
631
|
+
return resolveError
|
|
632
|
+
}
|
|
633
|
+
// An exports restriction proves the package exists even when its
|
|
634
|
+
// package.json is not public. Preserve the root resolution failure.
|
|
635
|
+
throw resolveError
|
|
636
|
+
}
|
|
637
|
+
// The package exists but its main/export target is broken.
|
|
638
|
+
throw resolveError
|
|
639
|
+
}
|
|
640
|
+
return resolveError
|
|
641
|
+
}
|
|
642
|
+
if (localArtifacts) {
|
|
643
|
+
let artifactError = null
|
|
644
|
+
for (let i = 0; i < localArtifacts.length; i++) {
|
|
645
|
+
try {
|
|
646
|
+
require.resolve(localArtifacts[i])
|
|
647
|
+
return null
|
|
648
|
+
} catch (resolveError) {
|
|
649
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
650
|
+
throw resolveError
|
|
651
|
+
}
|
|
652
|
+
artifactError = resolveError
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return artifactError
|
|
656
|
+
}
|
|
657
|
+
return null
|
|
658
|
+
}
|
|
659
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
660
|
+
let candidateError = null
|
|
661
|
+
let candidateFailed = false
|
|
662
|
+
try {
|
|
663
|
+
candidateError = __napiWasiResolveCandidate('./xlsxdown-node.wasi.cjs', false, ['./xlsxdown-node.wasm32-wasi.debug.wasm', './xlsxdown-node.wasm32-wasi.wasm'])
|
|
664
|
+
candidateFailed = candidateError !== null
|
|
665
|
+
if (!candidateFailed) {
|
|
666
|
+
wasiBinding = require('./xlsxdown-node.wasi.cjs')
|
|
667
|
+
nativeBinding = wasiBinding
|
|
668
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
669
|
+
wasiBindingLoaded = true
|
|
670
|
+
}
|
|
671
|
+
} catch (err) {
|
|
672
|
+
candidateError = err
|
|
673
|
+
candidateFailed = true
|
|
674
|
+
}
|
|
675
|
+
if (candidateFailed) {
|
|
676
|
+
wasiBindingErrors.push(candidateError)
|
|
677
|
+
loadErrors.push(candidateError)
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
681
|
+
let candidateError = null
|
|
682
|
+
let candidateFailed = false
|
|
683
|
+
try {
|
|
684
|
+
candidateError = __napiWasiResolveCandidate('@d0paminedriven/xlsxdown-wasm32-wasi', true, undefined)
|
|
685
|
+
candidateFailed = candidateError !== null
|
|
686
|
+
if (!candidateFailed) {
|
|
687
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
688
|
+
const bindingPackageVersion = require('@d0paminedriven/xlsxdown-wasm32-wasi/package.json').version
|
|
689
|
+
if (bindingPackageVersion !== '0.1.0') {
|
|
690
|
+
throw new Error(`WASI binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
wasiBinding = require('@d0paminedriven/xlsxdown-wasm32-wasi')
|
|
694
|
+
nativeBinding = wasiBinding
|
|
695
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
696
|
+
wasiBindingLoaded = true
|
|
697
|
+
}
|
|
698
|
+
} catch (err) {
|
|
699
|
+
candidateError = err
|
|
700
|
+
candidateFailed = true
|
|
701
|
+
}
|
|
702
|
+
if (candidateFailed) {
|
|
703
|
+
wasiBindingErrors.push(candidateError)
|
|
704
|
+
loadErrors.push(candidateError)
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if (
|
|
708
|
+
!wasiBindingLoaded &&
|
|
709
|
+
forceWasi &&
|
|
710
|
+
!forceWasiError &&
|
|
711
|
+
!__napiWasiFlavorRequested
|
|
712
|
+
) {
|
|
713
|
+
nativeBinding = requireNative()
|
|
714
|
+
__napiRequiredNativeBinding = nativeBinding
|
|
715
|
+
}
|
|
716
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
717
|
+
const error = new Error(
|
|
718
|
+
__napiWasiFlavorRequested
|
|
719
|
+
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
720
|
+
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
721
|
+
)
|
|
722
|
+
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
723
|
+
throw error
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (!nativeBinding) {
|
|
728
|
+
if (loadErrors.length > 0) {
|
|
729
|
+
const error = new Error(
|
|
730
|
+
`Cannot find native binding. ` +
|
|
731
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
732
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
733
|
+
)
|
|
734
|
+
// assign instead of the `new Error(message, { cause })` options form,
|
|
735
|
+
// which Node < 16.9 silently ignores
|
|
736
|
+
error.cause = createLoadErrorChain(loadErrors)
|
|
737
|
+
throw error
|
|
738
|
+
}
|
|
739
|
+
throw new Error(`Failed to load native binding`)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// A package can patch its own fallback in front of the load-failure check
|
|
743
|
+
// above, e.g. a WebContainer download through `napi-postinstall/fallback`.
|
|
744
|
+
// That fallback swaps `nativeBinding` for a generated WASI loader, which has
|
|
745
|
+
// already stamped its own flavor, while the target above still says 'native'.
|
|
746
|
+
// Take that flavor over, or the CommonJS stamp throws a conflict and the ESM
|
|
747
|
+
// export reports the wrong artifact. Three limits keep the conflict check:
|
|
748
|
+
// - only a binding this loader did not load itself, so a native addon whose
|
|
749
|
+
// `#[napi(module_exports)]` hook claims the name is still rejected;
|
|
750
|
+
// - only an own data property, read through its descriptor, so no addon
|
|
751
|
+
// getter runs here, and it must read back the same, as the stamp reads it;
|
|
752
|
+
// - only a flavor in `__napiWasiFlavors`, the ones this loader's own WASI
|
|
753
|
+
// chain can report ('wasm32-wasi' for a package without a WASI target).
|
|
754
|
+
// This is metadata and never fails a load: a throwing Proxy trap keeps 'native'.
|
|
755
|
+
if (
|
|
756
|
+
__napiLoadedBindingTarget === 'native' &&
|
|
757
|
+
nativeBinding !== __napiRequiredNativeBinding
|
|
758
|
+
) {
|
|
759
|
+
try {
|
|
760
|
+
const __napiBindingTargetDescriptor = Object.getOwnPropertyDescriptor(
|
|
761
|
+
nativeBinding,
|
|
762
|
+
'__napiBindingTarget',
|
|
763
|
+
)
|
|
764
|
+
if (
|
|
765
|
+
__napiBindingTargetDescriptor &&
|
|
766
|
+
__napiWasiFlavors.indexOf(__napiBindingTargetDescriptor.value) !== -1 &&
|
|
767
|
+
nativeBinding.__napiBindingTarget === __napiBindingTargetDescriptor.value
|
|
768
|
+
) {
|
|
769
|
+
__napiLoadedBindingTarget = __napiBindingTargetDescriptor.value
|
|
770
|
+
}
|
|
771
|
+
} catch {
|
|
772
|
+
// keep 'native'
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const { XlsxDown, NumberSubtype, spreadsheetCells, spreadsheetCellsAsync } = nativeBinding
|
|
777
|
+
export { XlsxDown }
|
|
778
|
+
export { NumberSubtype }
|
|
779
|
+
export { spreadsheetCells }
|
|
780
|
+
export { spreadsheetCellsAsync }
|
|
781
|
+
export const __napiBindingTarget = __napiLoadedBindingTarget
|
package/package.json
CHANGED
|
@@ -1,6 +1,118 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0paminedriven/xlsxdown",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rust powered xlsx extraction for Node",
|
|
5
|
+
"packageManager": "yarn@4.18.1+sha512.b2e1e7524f654f2749d32b4ebcb4622473cb5bcbc485df2007e12a154e50162a4d795526768bc5f5b8f81717bfd79deb2472813d86fb5ae2eb551fa9c872b08f",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"xlsx",
|
|
8
|
+
"Excel",
|
|
9
|
+
"Rust",
|
|
10
|
+
"node-tooling",
|
|
11
|
+
"rust-based-tooling",
|
|
12
|
+
"Spreadsheet"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/DopamineDriven/assetdown.git"
|
|
18
|
+
},
|
|
19
|
+
"resolutions": {
|
|
20
|
+
"@napi-rs/wasm-runtime": "1.2.7"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"index.d.ts",
|
|
24
|
+
"index.js",
|
|
25
|
+
"browser.js"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "index.js",
|
|
29
|
+
"types": "index.d.ts",
|
|
30
|
+
"browser": "browser.js",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"registry": "https://registry.npmjs.org/"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"artifacts": "napi artifacts",
|
|
37
|
+
"build": "yarn build:base",
|
|
38
|
+
"build:base": "napi build --platform --esm --release",
|
|
39
|
+
"build:wasm": "yarn build:wasm32",
|
|
40
|
+
"build:wasm32": "napi build --platform --esm --release --target wasm32-wasip1-threads",
|
|
41
|
+
"format": "run-p format:oxfmt format:rs format:toml",
|
|
42
|
+
"format:oxfmt": "oxfmt",
|
|
43
|
+
"format:rs": "cargo fmt",
|
|
44
|
+
"format:toml": "taplo format",
|
|
45
|
+
"lint": "oxlint .",
|
|
46
|
+
"lint:rs": "cargo fmt -- --check && cargo clippy --all-features -- -D warnings",
|
|
47
|
+
"version": "napi version",
|
|
48
|
+
"prepare": "husky",
|
|
49
|
+
"test": "yarn tsx --test \"__test__/**/*.spec.ts\"",
|
|
50
|
+
"test:wasi": "NAPI_RS_FORCE_WASI=error yarn tsx --test \"__test__/wasi.spec.ts\""
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@d0paminedriven/fs": "^11.0.0",
|
|
54
|
+
"@d0paminedriven/type-utils": "^1.3.0",
|
|
55
|
+
"@emnapi/core": "2.0.0-alpha.5",
|
|
56
|
+
"@emnapi/runtime": "2.0.0-alpha.5",
|
|
57
|
+
"@napi-rs/cli": "^3.10.12",
|
|
58
|
+
"@napi-rs/wasm-runtime": "^1.2.7",
|
|
59
|
+
"@oxc-node/core": "^1.0.2",
|
|
60
|
+
"@oxc-node/core-wasm32-wasi": "^1.0.2",
|
|
61
|
+
"@taplo/cli": "^0.7.0",
|
|
62
|
+
"@tybys/wasm-util": "^0.10.4",
|
|
63
|
+
"@types/node": "^26.6.6",
|
|
64
|
+
"chalk": "^6.0.1",
|
|
65
|
+
"dotenv": "^18.0.10",
|
|
66
|
+
"emnapi": "2.0.0-alpha.5",
|
|
67
|
+
"husky": "^9.1.7",
|
|
68
|
+
"lint-staged": "^17.6.0",
|
|
69
|
+
"npm-run-all2": "^9.0.4",
|
|
70
|
+
"oxfmt": "^0.78.0",
|
|
71
|
+
"oxlint": "^1.93.0",
|
|
72
|
+
"tinybench": "^6.2.3",
|
|
73
|
+
"tslib": "^2.9.1",
|
|
74
|
+
"tsx": "^4.23.15",
|
|
75
|
+
"typescript": "^7.0.2"
|
|
76
|
+
},
|
|
77
|
+
"napi": {
|
|
78
|
+
"binaryName": "xlsxdown-node",
|
|
79
|
+
"packageName": "@d0paminedriven/xlsxdown",
|
|
80
|
+
"constEnum": false,
|
|
81
|
+
"dtsHeader": "/* auto-generated by @d0paminedriven/xlsxdown */",
|
|
82
|
+
"targets": [
|
|
83
|
+
"x86_64-pc-windows-msvc",
|
|
84
|
+
"x86_64-apple-darwin",
|
|
85
|
+
"x86_64-unknown-linux-gnu",
|
|
86
|
+
"x86_64-unknown-linux-musl",
|
|
87
|
+
"aarch64-unknown-linux-gnu",
|
|
88
|
+
"i686-pc-windows-msvc",
|
|
89
|
+
"armv7-unknown-linux-gnueabihf",
|
|
90
|
+
"aarch64-apple-darwin",
|
|
91
|
+
"aarch64-linux-android",
|
|
92
|
+
"x86_64-unknown-freebsd",
|
|
93
|
+
"aarch64-unknown-linux-musl",
|
|
94
|
+
"aarch64-pc-windows-msvc",
|
|
95
|
+
"armv7-linux-androideabi",
|
|
96
|
+
"wasm32-wasip1-threads"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=24"
|
|
101
|
+
},
|
|
102
|
+
"optionalDependencies": {
|
|
103
|
+
"@d0paminedriven/xlsxdown-win32-x64-msvc": "0.1.0",
|
|
104
|
+
"@d0paminedriven/xlsxdown-darwin-x64": "0.1.0",
|
|
105
|
+
"@d0paminedriven/xlsxdown-linux-x64-gnu": "0.1.0",
|
|
106
|
+
"@d0paminedriven/xlsxdown-linux-x64-musl": "0.1.0",
|
|
107
|
+
"@d0paminedriven/xlsxdown-linux-arm64-gnu": "0.1.0",
|
|
108
|
+
"@d0paminedriven/xlsxdown-win32-ia32-msvc": "0.1.0",
|
|
109
|
+
"@d0paminedriven/xlsxdown-linux-arm-gnueabihf": "0.1.0",
|
|
110
|
+
"@d0paminedriven/xlsxdown-darwin-arm64": "0.1.0",
|
|
111
|
+
"@d0paminedriven/xlsxdown-android-arm64": "0.1.0",
|
|
112
|
+
"@d0paminedriven/xlsxdown-freebsd-x64": "0.1.0",
|
|
113
|
+
"@d0paminedriven/xlsxdown-linux-arm64-musl": "0.1.0",
|
|
114
|
+
"@d0paminedriven/xlsxdown-win32-arm64-msvc": "0.1.0",
|
|
115
|
+
"@d0paminedriven/xlsxdown-android-arm-eabi": "0.1.0",
|
|
116
|
+
"@d0paminedriven/xlsxdown-wasm32-wasi": "0.1.0"
|
|
117
|
+
}
|
|
118
|
+
}
|