@napi-rs/cli 3.0.0-alpha.41 → 3.0.0-alpha.43
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/dist/api/templates/js-binding.js +83 -276
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/index.cjs +84 -277
- package/package.json +2 -2
- package/src/api/templates/js-binding.ts +84 -276
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
export function createCjsBinding(localName, pkgName, idents) {
|
|
2
|
+
function requireTuple(tuple) {
|
|
3
|
+
return `try {
|
|
4
|
+
return require('./${localName}.${tuple}.node')
|
|
5
|
+
} catch (e) {
|
|
6
|
+
loadErrors.push(e)
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return require('${pkgName}-${tuple}')
|
|
10
|
+
} catch (e) {
|
|
11
|
+
loadErrors.push(e)
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
}
|
|
2
15
|
return `// prettier-ignore
|
|
3
16
|
/* eslint-disable */
|
|
4
17
|
/* auto-generated by NAPI-RS */
|
|
5
18
|
|
|
6
|
-
const {
|
|
7
|
-
const { join } = require('path')
|
|
8
|
-
|
|
9
|
-
const { platform, arch } = process
|
|
19
|
+
const { readFileSync } = require('fs')
|
|
10
20
|
|
|
11
21
|
let nativeBinding = null
|
|
12
|
-
|
|
13
|
-
let loadError = null
|
|
22
|
+
const loadErrors = []
|
|
14
23
|
|
|
15
24
|
const isMusl = () => {
|
|
16
25
|
let musl = false
|
|
@@ -61,281 +70,75 @@ const isMuslFromChildProcess = () => {
|
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
nativeBinding = require('${pkgName}-android-arm64')
|
|
74
|
-
}
|
|
75
|
-
} catch (e) {
|
|
76
|
-
loadError = e
|
|
77
|
-
}
|
|
78
|
-
break
|
|
79
|
-
case 'arm':
|
|
80
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.android-arm-eabi.node'))
|
|
81
|
-
try {
|
|
82
|
-
if (localFileExisted) {
|
|
83
|
-
nativeBinding = require('./${localName}.android-arm-eabi.node')
|
|
84
|
-
} else {
|
|
85
|
-
nativeBinding = require('${pkgName}-android-arm-eabi')
|
|
86
|
-
}
|
|
87
|
-
} catch (e) {
|
|
88
|
-
loadError = e
|
|
89
|
-
}
|
|
90
|
-
break
|
|
91
|
-
default:
|
|
92
|
-
loadError = new Error(\`Unsupported architecture on Android \${arch}\`)
|
|
73
|
+
function requireNative() {
|
|
74
|
+
if (process.platform === 'android') {
|
|
75
|
+
if (process.arch === 'arm64') {
|
|
76
|
+
${requireTuple('android-arm64')}
|
|
77
|
+
} else if (process.arch === 'arm') {
|
|
78
|
+
${requireTuple('android-arm-eabi')}
|
|
79
|
+
} else {
|
|
80
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
93
81
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
nativeBinding = require('./${localName}.win32-x64-msvc.node')
|
|
104
|
-
} else {
|
|
105
|
-
nativeBinding = require('${pkgName}-win32-x64-msvc')
|
|
106
|
-
}
|
|
107
|
-
} catch (e) {
|
|
108
|
-
loadError = e
|
|
109
|
-
}
|
|
110
|
-
break
|
|
111
|
-
case 'ia32':
|
|
112
|
-
localFileExisted = existsSync(
|
|
113
|
-
join(__dirname, '${localName}.win32-ia32-msvc.node')
|
|
114
|
-
)
|
|
115
|
-
try {
|
|
116
|
-
if (localFileExisted) {
|
|
117
|
-
nativeBinding = require('./${localName}.win32-ia32-msvc.node')
|
|
118
|
-
} else {
|
|
119
|
-
nativeBinding = require('${pkgName}-win32-ia32-msvc')
|
|
120
|
-
}
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadError = e
|
|
123
|
-
}
|
|
124
|
-
break
|
|
125
|
-
case 'arm64':
|
|
126
|
-
localFileExisted = existsSync(
|
|
127
|
-
join(__dirname, '${localName}.win32-arm64-msvc.node')
|
|
128
|
-
)
|
|
129
|
-
try {
|
|
130
|
-
if (localFileExisted) {
|
|
131
|
-
nativeBinding = require('./${localName}.win32-arm64-msvc.node')
|
|
132
|
-
} else {
|
|
133
|
-
nativeBinding = require('${pkgName}-win32-arm64-msvc')
|
|
134
|
-
}
|
|
135
|
-
} catch (e) {
|
|
136
|
-
loadError = e
|
|
137
|
-
}
|
|
138
|
-
break
|
|
139
|
-
default:
|
|
140
|
-
loadError = new Error(\`Unsupported architecture on Windows: \${arch}\`)
|
|
82
|
+
} else if (process.platform === 'win32') {
|
|
83
|
+
if (process.arch === 'x64') {
|
|
84
|
+
${requireTuple('win32-x64-msvc')}
|
|
85
|
+
} else if (process.arch === 'ia32') {
|
|
86
|
+
${requireTuple('win32-ia32-msvc')}
|
|
87
|
+
} else if (process.arch === 'arm64') {
|
|
88
|
+
${requireTuple('win32-arm64-msvc')}
|
|
89
|
+
} else {
|
|
90
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
141
91
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
break
|
|
152
|
-
} catch {}
|
|
153
|
-
switch (arch) {
|
|
154
|
-
case 'x64':
|
|
155
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.darwin-x64.node'))
|
|
156
|
-
try {
|
|
157
|
-
if (localFileExisted) {
|
|
158
|
-
nativeBinding = require('./${localName}.darwin-x64.node')
|
|
159
|
-
} else {
|
|
160
|
-
nativeBinding = require('${pkgName}-darwin-x64')
|
|
161
|
-
}
|
|
162
|
-
} catch (e) {
|
|
163
|
-
loadError = e
|
|
164
|
-
}
|
|
165
|
-
break
|
|
166
|
-
case 'arm64':
|
|
167
|
-
localFileExisted = existsSync(
|
|
168
|
-
join(__dirname, '${localName}.darwin-arm64.node')
|
|
169
|
-
)
|
|
170
|
-
try {
|
|
171
|
-
if (localFileExisted) {
|
|
172
|
-
nativeBinding = require('./${localName}.darwin-arm64.node')
|
|
173
|
-
} else {
|
|
174
|
-
nativeBinding = require('${pkgName}-darwin-arm64')
|
|
175
|
-
}
|
|
176
|
-
} catch (e) {
|
|
177
|
-
loadError = e
|
|
178
|
-
}
|
|
179
|
-
break
|
|
180
|
-
default:
|
|
181
|
-
loadError = new Error(\`Unsupported architecture on macOS: \${arch}\`)
|
|
92
|
+
} else if (process.platform === 'darwin') {
|
|
93
|
+
${requireTuple('darwin-universal')}
|
|
94
|
+
if (process.arch === 'x64') {
|
|
95
|
+
${requireTuple('darwin-x64')}
|
|
96
|
+
} else if (process.arch === 'arm64') {
|
|
97
|
+
${requireTuple('darwin-arm64')}
|
|
98
|
+
} else {
|
|
99
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
182
100
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
nativeBinding = require('./${localName}.freebsd-x64.node')
|
|
191
|
-
} else {
|
|
192
|
-
nativeBinding = require('${pkgName}-freebsd-x64')
|
|
193
|
-
}
|
|
194
|
-
} catch (e) {
|
|
195
|
-
loadError = e
|
|
196
|
-
}
|
|
197
|
-
break
|
|
198
|
-
case 'arm64':
|
|
199
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-arm64.node'))
|
|
200
|
-
try {
|
|
201
|
-
if (localFileExisted) {
|
|
202
|
-
nativeBinding = require('./${localName}.freebsd-arm64.node')
|
|
203
|
-
} else {
|
|
204
|
-
nativeBinding = require('${pkgName}-freebsd-arm64')
|
|
205
|
-
}
|
|
206
|
-
} catch (e) {
|
|
207
|
-
loadError = e
|
|
208
|
-
}
|
|
209
|
-
break
|
|
210
|
-
default:
|
|
211
|
-
loadError = new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
|
|
101
|
+
} else if (process.platform === 'freebsd') {
|
|
102
|
+
if (process.arch === 'x64') {
|
|
103
|
+
${requireTuple('freebsd-x64')}
|
|
104
|
+
} else if (process.arch === 'arm64') {
|
|
105
|
+
${requireTuple('freebsd-arm64')}
|
|
106
|
+
} else {
|
|
107
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
212
108
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
239
|
-
}
|
|
240
|
-
} catch (e) {
|
|
241
|
-
loadError = e
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
break
|
|
245
|
-
case 'arm64':
|
|
246
|
-
if (isMusl()) {
|
|
247
|
-
localFileExisted = existsSync(
|
|
248
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
249
|
-
)
|
|
250
|
-
try {
|
|
251
|
-
if (localFileExisted) {
|
|
252
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
253
|
-
} else {
|
|
254
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
255
|
-
}
|
|
256
|
-
} catch (e) {
|
|
257
|
-
loadError = e
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
localFileExisted = existsSync(
|
|
261
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
262
|
-
)
|
|
263
|
-
try {
|
|
264
|
-
if (localFileExisted) {
|
|
265
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
266
|
-
} else {
|
|
267
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
268
|
-
}
|
|
269
|
-
} catch (e) {
|
|
270
|
-
loadError = e
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
break
|
|
274
|
-
case 'arm':
|
|
275
|
-
localFileExisted = existsSync(
|
|
276
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
277
|
-
)
|
|
278
|
-
try {
|
|
279
|
-
if (localFileExisted) {
|
|
280
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
281
|
-
} else {
|
|
282
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
283
|
-
}
|
|
284
|
-
} catch (e) {
|
|
285
|
-
loadError = e
|
|
286
|
-
}
|
|
287
|
-
break
|
|
288
|
-
case 'riscv64':
|
|
289
|
-
if (isMusl()) {
|
|
290
|
-
localFileExisted = existsSync(
|
|
291
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
292
|
-
)
|
|
293
|
-
try {
|
|
294
|
-
if (localFileExisted) {
|
|
295
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
296
|
-
} else {
|
|
297
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
298
|
-
}
|
|
299
|
-
} catch (e) {
|
|
300
|
-
loadError = e
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
localFileExisted = existsSync(
|
|
304
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
305
|
-
)
|
|
306
|
-
try {
|
|
307
|
-
if (localFileExisted) {
|
|
308
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
309
|
-
} else {
|
|
310
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
311
|
-
}
|
|
312
|
-
} catch (e) {
|
|
313
|
-
loadError = e
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
break
|
|
317
|
-
case 's390x':
|
|
318
|
-
localFileExisted = existsSync(
|
|
319
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
320
|
-
)
|
|
321
|
-
try {
|
|
322
|
-
if (localFileExisted) {
|
|
323
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
324
|
-
} else {
|
|
325
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
326
|
-
}
|
|
327
|
-
} catch (e) {
|
|
328
|
-
loadError = e
|
|
329
|
-
}
|
|
330
|
-
break
|
|
331
|
-
default:
|
|
332
|
-
loadError = new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
109
|
+
} else if (process.platform === 'linux') {
|
|
110
|
+
if (process.arch === 'x64') {
|
|
111
|
+
if (isMusl()) {
|
|
112
|
+
${requireTuple('linux-x64-musl')}
|
|
113
|
+
} else {
|
|
114
|
+
${requireTuple('linux-x64-gnu')}
|
|
115
|
+
}
|
|
116
|
+
} else if (process.arch === 'arm64') {
|
|
117
|
+
if (isMusl()) {
|
|
118
|
+
${requireTuple('linux-arm64-musl')}
|
|
119
|
+
} else {
|
|
120
|
+
${requireTuple('linux-arm64-gnu')}
|
|
121
|
+
}
|
|
122
|
+
} else if (process.arch === 'arm') {
|
|
123
|
+
${requireTuple('linux-arm-gnueabihf')}
|
|
124
|
+
} else if (process.arch === 'riscv64') {
|
|
125
|
+
if (isMusl()) {
|
|
126
|
+
${requireTuple('linux-riscv64-musl')}
|
|
127
|
+
} else {
|
|
128
|
+
${requireTuple('linux-riscv64-gnu')}
|
|
129
|
+
}
|
|
130
|
+
} else if (process.arch === 's390x') {
|
|
131
|
+
${requireTuple('linux-s390x-gnu')}
|
|
132
|
+
} else {
|
|
133
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
333
134
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
135
|
+
} else {
|
|
136
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
137
|
+
}
|
|
337
138
|
}
|
|
338
139
|
|
|
140
|
+
nativeBinding = requireNative()
|
|
141
|
+
|
|
339
142
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
340
143
|
try {
|
|
341
144
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -356,8 +159,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
356
159
|
}
|
|
357
160
|
|
|
358
161
|
if (!nativeBinding) {
|
|
359
|
-
if (
|
|
360
|
-
|
|
162
|
+
if (loadErrors.length > 0) {
|
|
163
|
+
// TODO Link to documentation with potential fixes
|
|
164
|
+
// - The package owner could build/publish bindings for this arch
|
|
165
|
+
// - The user may need to bundle the correct files
|
|
166
|
+
// - The user may need to re-install node_modules to get new packages
|
|
167
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
361
168
|
}
|
|
362
169
|
throw new Error(\`Failed to load native binding\`)
|
|
363
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-binding.js","sourceRoot":"","sources":["../../../src/api/templates/js-binding.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,OAAe,EACf,MAAgB;IAEhB,
|
|
1
|
+
{"version":3,"file":"js-binding.js","sourceRoot":"","sources":["../../../src/api/templates/js-binding.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,OAAe,EACf,MAAgB;IAEhB,SAAS,YAAY,CAAC,KAAa;QACjC,OAAO;4BACiB,SAAS,IAAI,KAAK;;;;;0BAKpB,OAAO,IAAI,KAAK;;;;CAIzC,CAAA;IACC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6DD,YAAY,CAAC,eAAe,CAAC;;QAE7B,YAAY,CAAC,kBAAkB,CAAC;;;;;;QAMhC,YAAY,CAAC,gBAAgB,CAAC;;QAE9B,YAAY,CAAC,iBAAiB,CAAC;;QAE/B,YAAY,CAAC,kBAAkB,CAAC;;;;;MAKlC,YAAY,CAAC,kBAAkB,CAAC;;QAE9B,YAAY,CAAC,YAAY,CAAC;;QAE1B,YAAY,CAAC,cAAc,CAAC;;;;;;QAM5B,YAAY,CAAC,aAAa,CAAC;;QAE3B,YAAY,CAAC,eAAe,CAAC;;;;;;;UAO3B,YAAY,CAAC,gBAAgB,CAAC;;UAE9B,YAAY,CAAC,eAAe,CAAC;;;;UAI7B,YAAY,CAAC,kBAAkB,CAAC;;UAEhC,YAAY,CAAC,iBAAiB,CAAC;;;QAGjC,YAAY,CAAC,qBAAqB,CAAC;;;UAGjC,YAAY,CAAC,oBAAoB,CAAC;;UAElC,YAAY,CAAC,mBAAmB,CAAC;;;QAGnC,YAAY,CAAC,iBAAiB,CAAC;;;;;;;;;;;;;iCAaN,SAAS;;;;;;;;iCAQT,OAAO;;;;;;;;;;;;;;;;;;;;EAoBtC,MAAM;SACL,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,KAAK,oBAAoB,KAAK,EAAE,CAAC;SAClE,IAAI,CAAC,IAAI,CAAC;CACZ,CAAA;AACD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -16826,18 +16826,27 @@ var createPackageJson = async ({ name, binaryName, targets, license, engineRequi
|
|
|
16826
16826
|
|
|
16827
16827
|
// dist/api/templates/js-binding.js
|
|
16828
16828
|
function createCjsBinding(localName, pkgName, idents) {
|
|
16829
|
+
function requireTuple(tuple) {
|
|
16830
|
+
return `try {
|
|
16831
|
+
return require('./${localName}.${tuple}.node')
|
|
16832
|
+
} catch (e) {
|
|
16833
|
+
loadErrors.push(e)
|
|
16834
|
+
}
|
|
16835
|
+
try {
|
|
16836
|
+
return require('${pkgName}-${tuple}')
|
|
16837
|
+
} catch (e) {
|
|
16838
|
+
loadErrors.push(e)
|
|
16839
|
+
}
|
|
16840
|
+
`;
|
|
16841
|
+
}
|
|
16829
16842
|
return `// prettier-ignore
|
|
16830
16843
|
/* eslint-disable */
|
|
16831
16844
|
/* auto-generated by NAPI-RS */
|
|
16832
16845
|
|
|
16833
|
-
const {
|
|
16834
|
-
const { join } = require('path')
|
|
16835
|
-
|
|
16836
|
-
const { platform, arch } = process
|
|
16846
|
+
const { readFileSync } = require('fs')
|
|
16837
16847
|
|
|
16838
16848
|
let nativeBinding = null
|
|
16839
|
-
|
|
16840
|
-
let loadError = null
|
|
16849
|
+
const loadErrors = []
|
|
16841
16850
|
|
|
16842
16851
|
const isMusl = () => {
|
|
16843
16852
|
let musl = false
|
|
@@ -16888,281 +16897,75 @@ const isMuslFromChildProcess = () => {
|
|
|
16888
16897
|
}
|
|
16889
16898
|
}
|
|
16890
16899
|
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
default:
|
|
16919
|
-
loadError = new Error(\`Unsupported architecture on Android \${arch}\`)
|
|
16920
|
-
}
|
|
16921
|
-
break
|
|
16922
|
-
case 'win32':
|
|
16923
|
-
switch (arch) {
|
|
16924
|
-
case 'x64':
|
|
16925
|
-
localFileExisted = existsSync(
|
|
16926
|
-
join(__dirname, '${localName}.win32-x64-msvc.node')
|
|
16927
|
-
)
|
|
16928
|
-
try {
|
|
16929
|
-
if (localFileExisted) {
|
|
16930
|
-
nativeBinding = require('./${localName}.win32-x64-msvc.node')
|
|
16931
|
-
} else {
|
|
16932
|
-
nativeBinding = require('${pkgName}-win32-x64-msvc')
|
|
16933
|
-
}
|
|
16934
|
-
} catch (e) {
|
|
16935
|
-
loadError = e
|
|
16936
|
-
}
|
|
16937
|
-
break
|
|
16938
|
-
case 'ia32':
|
|
16939
|
-
localFileExisted = existsSync(
|
|
16940
|
-
join(__dirname, '${localName}.win32-ia32-msvc.node')
|
|
16941
|
-
)
|
|
16942
|
-
try {
|
|
16943
|
-
if (localFileExisted) {
|
|
16944
|
-
nativeBinding = require('./${localName}.win32-ia32-msvc.node')
|
|
16945
|
-
} else {
|
|
16946
|
-
nativeBinding = require('${pkgName}-win32-ia32-msvc')
|
|
16947
|
-
}
|
|
16948
|
-
} catch (e) {
|
|
16949
|
-
loadError = e
|
|
16950
|
-
}
|
|
16951
|
-
break
|
|
16952
|
-
case 'arm64':
|
|
16953
|
-
localFileExisted = existsSync(
|
|
16954
|
-
join(__dirname, '${localName}.win32-arm64-msvc.node')
|
|
16955
|
-
)
|
|
16956
|
-
try {
|
|
16957
|
-
if (localFileExisted) {
|
|
16958
|
-
nativeBinding = require('./${localName}.win32-arm64-msvc.node')
|
|
16959
|
-
} else {
|
|
16960
|
-
nativeBinding = require('${pkgName}-win32-arm64-msvc')
|
|
16961
|
-
}
|
|
16962
|
-
} catch (e) {
|
|
16963
|
-
loadError = e
|
|
16964
|
-
}
|
|
16965
|
-
break
|
|
16966
|
-
default:
|
|
16967
|
-
loadError = new Error(\`Unsupported architecture on Windows: \${arch}\`)
|
|
16900
|
+
function requireNative() {
|
|
16901
|
+
if (process.platform === 'android') {
|
|
16902
|
+
if (process.arch === 'arm64') {
|
|
16903
|
+
${requireTuple("android-arm64")}
|
|
16904
|
+
} else if (process.arch === 'arm') {
|
|
16905
|
+
${requireTuple("android-arm-eabi")}
|
|
16906
|
+
} else {
|
|
16907
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
16908
|
+
}
|
|
16909
|
+
} else if (process.platform === 'win32') {
|
|
16910
|
+
if (process.arch === 'x64') {
|
|
16911
|
+
${requireTuple("win32-x64-msvc")}
|
|
16912
|
+
} else if (process.arch === 'ia32') {
|
|
16913
|
+
${requireTuple("win32-ia32-msvc")}
|
|
16914
|
+
} else if (process.arch === 'arm64') {
|
|
16915
|
+
${requireTuple("win32-arm64-msvc")}
|
|
16916
|
+
} else {
|
|
16917
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
16918
|
+
}
|
|
16919
|
+
} else if (process.platform === 'darwin') {
|
|
16920
|
+
${requireTuple("darwin-universal")}
|
|
16921
|
+
if (process.arch === 'x64') {
|
|
16922
|
+
${requireTuple("darwin-x64")}
|
|
16923
|
+
} else if (process.arch === 'arm64') {
|
|
16924
|
+
${requireTuple("darwin-arm64")}
|
|
16925
|
+
} else {
|
|
16926
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
16968
16927
|
}
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16928
|
+
} else if (process.platform === 'freebsd') {
|
|
16929
|
+
if (process.arch === 'x64') {
|
|
16930
|
+
${requireTuple("freebsd-x64")}
|
|
16931
|
+
} else if (process.arch === 'arm64') {
|
|
16932
|
+
${requireTuple("freebsd-arm64")}
|
|
16933
|
+
} else {
|
|
16934
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
16935
|
+
}
|
|
16936
|
+
} else if (process.platform === 'linux') {
|
|
16937
|
+
if (process.arch === 'x64') {
|
|
16938
|
+
if (isMusl()) {
|
|
16939
|
+
${requireTuple("linux-x64-musl")}
|
|
16975
16940
|
} else {
|
|
16976
|
-
|
|
16941
|
+
${requireTuple("linux-x64-gnu")}
|
|
16977
16942
|
}
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
)
|
|
16997
|
-
try {
|
|
16998
|
-
if (localFileExisted) {
|
|
16999
|
-
nativeBinding = require('./${localName}.darwin-arm64.node')
|
|
17000
|
-
} else {
|
|
17001
|
-
nativeBinding = require('${pkgName}-darwin-arm64')
|
|
17002
|
-
}
|
|
17003
|
-
} catch (e) {
|
|
17004
|
-
loadError = e
|
|
17005
|
-
}
|
|
17006
|
-
break
|
|
17007
|
-
default:
|
|
17008
|
-
loadError = new Error(\`Unsupported architecture on macOS: \${arch}\`)
|
|
17009
|
-
}
|
|
17010
|
-
break
|
|
17011
|
-
case 'freebsd':
|
|
17012
|
-
switch (arch) {
|
|
17013
|
-
case 'x64':
|
|
17014
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-x64.node'))
|
|
17015
|
-
try {
|
|
17016
|
-
if (localFileExisted) {
|
|
17017
|
-
nativeBinding = require('./${localName}.freebsd-x64.node')
|
|
17018
|
-
} else {
|
|
17019
|
-
nativeBinding = require('${pkgName}-freebsd-x64')
|
|
17020
|
-
}
|
|
17021
|
-
} catch (e) {
|
|
17022
|
-
loadError = e
|
|
17023
|
-
}
|
|
17024
|
-
break
|
|
17025
|
-
case 'arm64':
|
|
17026
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-arm64.node'))
|
|
17027
|
-
try {
|
|
17028
|
-
if (localFileExisted) {
|
|
17029
|
-
nativeBinding = require('./${localName}.freebsd-arm64.node')
|
|
17030
|
-
} else {
|
|
17031
|
-
nativeBinding = require('${pkgName}-freebsd-arm64')
|
|
17032
|
-
}
|
|
17033
|
-
} catch (e) {
|
|
17034
|
-
loadError = e
|
|
17035
|
-
}
|
|
17036
|
-
break
|
|
17037
|
-
default:
|
|
17038
|
-
loadError = new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
|
|
17039
|
-
}
|
|
17040
|
-
break
|
|
17041
|
-
case 'linux':
|
|
17042
|
-
switch (arch) {
|
|
17043
|
-
case 'x64':
|
|
17044
|
-
if (isMusl()) {
|
|
17045
|
-
localFileExisted = existsSync(
|
|
17046
|
-
join(__dirname, '${localName}.linux-x64-musl.node')
|
|
17047
|
-
)
|
|
17048
|
-
try {
|
|
17049
|
-
if (localFileExisted) {
|
|
17050
|
-
nativeBinding = require('./${localName}.linux-x64-musl.node')
|
|
17051
|
-
} else {
|
|
17052
|
-
nativeBinding = require('${pkgName}-linux-x64-musl')
|
|
17053
|
-
}
|
|
17054
|
-
} catch (e) {
|
|
17055
|
-
loadError = e
|
|
17056
|
-
}
|
|
17057
|
-
} else {
|
|
17058
|
-
localFileExisted = existsSync(
|
|
17059
|
-
join(__dirname, '${localName}.linux-x64-gnu.node')
|
|
17060
|
-
)
|
|
17061
|
-
try {
|
|
17062
|
-
if (localFileExisted) {
|
|
17063
|
-
nativeBinding = require('./${localName}.linux-x64-gnu.node')
|
|
17064
|
-
} else {
|
|
17065
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
17066
|
-
}
|
|
17067
|
-
} catch (e) {
|
|
17068
|
-
loadError = e
|
|
17069
|
-
}
|
|
17070
|
-
}
|
|
17071
|
-
break
|
|
17072
|
-
case 'arm64':
|
|
17073
|
-
if (isMusl()) {
|
|
17074
|
-
localFileExisted = existsSync(
|
|
17075
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
17076
|
-
)
|
|
17077
|
-
try {
|
|
17078
|
-
if (localFileExisted) {
|
|
17079
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
17080
|
-
} else {
|
|
17081
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
17082
|
-
}
|
|
17083
|
-
} catch (e) {
|
|
17084
|
-
loadError = e
|
|
17085
|
-
}
|
|
17086
|
-
} else {
|
|
17087
|
-
localFileExisted = existsSync(
|
|
17088
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
17089
|
-
)
|
|
17090
|
-
try {
|
|
17091
|
-
if (localFileExisted) {
|
|
17092
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
17093
|
-
} else {
|
|
17094
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
17095
|
-
}
|
|
17096
|
-
} catch (e) {
|
|
17097
|
-
loadError = e
|
|
17098
|
-
}
|
|
17099
|
-
}
|
|
17100
|
-
break
|
|
17101
|
-
case 'arm':
|
|
17102
|
-
localFileExisted = existsSync(
|
|
17103
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
17104
|
-
)
|
|
17105
|
-
try {
|
|
17106
|
-
if (localFileExisted) {
|
|
17107
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
17108
|
-
} else {
|
|
17109
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
17110
|
-
}
|
|
17111
|
-
} catch (e) {
|
|
17112
|
-
loadError = e
|
|
17113
|
-
}
|
|
17114
|
-
break
|
|
17115
|
-
case 'riscv64':
|
|
17116
|
-
if (isMusl()) {
|
|
17117
|
-
localFileExisted = existsSync(
|
|
17118
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
17119
|
-
)
|
|
17120
|
-
try {
|
|
17121
|
-
if (localFileExisted) {
|
|
17122
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
17123
|
-
} else {
|
|
17124
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
17125
|
-
}
|
|
17126
|
-
} catch (e) {
|
|
17127
|
-
loadError = e
|
|
17128
|
-
}
|
|
17129
|
-
} else {
|
|
17130
|
-
localFileExisted = existsSync(
|
|
17131
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
17132
|
-
)
|
|
17133
|
-
try {
|
|
17134
|
-
if (localFileExisted) {
|
|
17135
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
17136
|
-
} else {
|
|
17137
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
17138
|
-
}
|
|
17139
|
-
} catch (e) {
|
|
17140
|
-
loadError = e
|
|
17141
|
-
}
|
|
17142
|
-
}
|
|
17143
|
-
break
|
|
17144
|
-
case 's390x':
|
|
17145
|
-
localFileExisted = existsSync(
|
|
17146
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
17147
|
-
)
|
|
17148
|
-
try {
|
|
17149
|
-
if (localFileExisted) {
|
|
17150
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
17151
|
-
} else {
|
|
17152
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
17153
|
-
}
|
|
17154
|
-
} catch (e) {
|
|
17155
|
-
loadError = e
|
|
17156
|
-
}
|
|
17157
|
-
break
|
|
17158
|
-
default:
|
|
17159
|
-
loadError = new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
16943
|
+
} else if (process.arch === 'arm64') {
|
|
16944
|
+
if (isMusl()) {
|
|
16945
|
+
${requireTuple("linux-arm64-musl")}
|
|
16946
|
+
} else {
|
|
16947
|
+
${requireTuple("linux-arm64-gnu")}
|
|
16948
|
+
}
|
|
16949
|
+
} else if (process.arch === 'arm') {
|
|
16950
|
+
${requireTuple("linux-arm-gnueabihf")}
|
|
16951
|
+
} else if (process.arch === 'riscv64') {
|
|
16952
|
+
if (isMusl()) {
|
|
16953
|
+
${requireTuple("linux-riscv64-musl")}
|
|
16954
|
+
} else {
|
|
16955
|
+
${requireTuple("linux-riscv64-gnu")}
|
|
16956
|
+
}
|
|
16957
|
+
} else if (process.arch === 's390x') {
|
|
16958
|
+
${requireTuple("linux-s390x-gnu")}
|
|
16959
|
+
} else {
|
|
16960
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
17160
16961
|
}
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
16962
|
+
} else {
|
|
16963
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
16964
|
+
}
|
|
17164
16965
|
}
|
|
17165
16966
|
|
|
16967
|
+
nativeBinding = requireNative()
|
|
16968
|
+
|
|
17166
16969
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
17167
16970
|
try {
|
|
17168
16971
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -17183,8 +16986,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
17183
16986
|
}
|
|
17184
16987
|
|
|
17185
16988
|
if (!nativeBinding) {
|
|
17186
|
-
if (
|
|
17187
|
-
|
|
16989
|
+
if (loadErrors.length > 0) {
|
|
16990
|
+
// TODO Link to documentation with potential fixes
|
|
16991
|
+
// - The package owner could build/publish bindings for this arch
|
|
16992
|
+
// - The user may need to bundle the correct files
|
|
16993
|
+
// - The user may need to re-install node_modules to get new packages
|
|
16994
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
17188
16995
|
}
|
|
17189
16996
|
throw new Error(\`Failed to load native binding\`)
|
|
17190
16997
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.43",
|
|
4
4
|
"description": "Cli tools for napi-rs",
|
|
5
5
|
"author": "LongYinan <lynweklm@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/napi-rs/napi-rs",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"**/__tests__/**/*.spec.ts"
|
|
131
131
|
]
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "4d5655accb56f57efbae318d2729a7f799657da4"
|
|
134
134
|
}
|
|
@@ -3,18 +3,28 @@ export function createCjsBinding(
|
|
|
3
3
|
pkgName: string,
|
|
4
4
|
idents: string[],
|
|
5
5
|
): string {
|
|
6
|
+
function requireTuple(tuple: string) {
|
|
7
|
+
return `try {
|
|
8
|
+
return require('./${localName}.${tuple}.node')
|
|
9
|
+
} catch (e) {
|
|
10
|
+
loadErrors.push(e)
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return require('${pkgName}-${tuple}')
|
|
14
|
+
} catch (e) {
|
|
15
|
+
loadErrors.push(e)
|
|
16
|
+
}
|
|
17
|
+
`
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
return `// prettier-ignore
|
|
7
21
|
/* eslint-disable */
|
|
8
22
|
/* auto-generated by NAPI-RS */
|
|
9
23
|
|
|
10
|
-
const {
|
|
11
|
-
const { join } = require('path')
|
|
12
|
-
|
|
13
|
-
const { platform, arch } = process
|
|
24
|
+
const { readFileSync } = require('fs')
|
|
14
25
|
|
|
15
26
|
let nativeBinding = null
|
|
16
|
-
|
|
17
|
-
let loadError = null
|
|
27
|
+
const loadErrors = []
|
|
18
28
|
|
|
19
29
|
const isMusl = () => {
|
|
20
30
|
let musl = false
|
|
@@ -65,281 +75,75 @@ const isMuslFromChildProcess = () => {
|
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} else {
|
|
77
|
-
nativeBinding = require('${pkgName}-android-arm64')
|
|
78
|
-
}
|
|
79
|
-
} catch (e) {
|
|
80
|
-
loadError = e
|
|
81
|
-
}
|
|
82
|
-
break
|
|
83
|
-
case 'arm':
|
|
84
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.android-arm-eabi.node'))
|
|
85
|
-
try {
|
|
86
|
-
if (localFileExisted) {
|
|
87
|
-
nativeBinding = require('./${localName}.android-arm-eabi.node')
|
|
88
|
-
} else {
|
|
89
|
-
nativeBinding = require('${pkgName}-android-arm-eabi')
|
|
90
|
-
}
|
|
91
|
-
} catch (e) {
|
|
92
|
-
loadError = e
|
|
93
|
-
}
|
|
94
|
-
break
|
|
95
|
-
default:
|
|
96
|
-
loadError = new Error(\`Unsupported architecture on Android \${arch}\`)
|
|
78
|
+
function requireNative() {
|
|
79
|
+
if (process.platform === 'android') {
|
|
80
|
+
if (process.arch === 'arm64') {
|
|
81
|
+
${requireTuple('android-arm64')}
|
|
82
|
+
} else if (process.arch === 'arm') {
|
|
83
|
+
${requireTuple('android-arm-eabi')}
|
|
84
|
+
} else {
|
|
85
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
97
86
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
nativeBinding = require('./${localName}.win32-x64-msvc.node')
|
|
108
|
-
} else {
|
|
109
|
-
nativeBinding = require('${pkgName}-win32-x64-msvc')
|
|
110
|
-
}
|
|
111
|
-
} catch (e) {
|
|
112
|
-
loadError = e
|
|
113
|
-
}
|
|
114
|
-
break
|
|
115
|
-
case 'ia32':
|
|
116
|
-
localFileExisted = existsSync(
|
|
117
|
-
join(__dirname, '${localName}.win32-ia32-msvc.node')
|
|
118
|
-
)
|
|
119
|
-
try {
|
|
120
|
-
if (localFileExisted) {
|
|
121
|
-
nativeBinding = require('./${localName}.win32-ia32-msvc.node')
|
|
122
|
-
} else {
|
|
123
|
-
nativeBinding = require('${pkgName}-win32-ia32-msvc')
|
|
124
|
-
}
|
|
125
|
-
} catch (e) {
|
|
126
|
-
loadError = e
|
|
127
|
-
}
|
|
128
|
-
break
|
|
129
|
-
case 'arm64':
|
|
130
|
-
localFileExisted = existsSync(
|
|
131
|
-
join(__dirname, '${localName}.win32-arm64-msvc.node')
|
|
132
|
-
)
|
|
133
|
-
try {
|
|
134
|
-
if (localFileExisted) {
|
|
135
|
-
nativeBinding = require('./${localName}.win32-arm64-msvc.node')
|
|
136
|
-
} else {
|
|
137
|
-
nativeBinding = require('${pkgName}-win32-arm64-msvc')
|
|
138
|
-
}
|
|
139
|
-
} catch (e) {
|
|
140
|
-
loadError = e
|
|
141
|
-
}
|
|
142
|
-
break
|
|
143
|
-
default:
|
|
144
|
-
loadError = new Error(\`Unsupported architecture on Windows: \${arch}\`)
|
|
87
|
+
} else if (process.platform === 'win32') {
|
|
88
|
+
if (process.arch === 'x64') {
|
|
89
|
+
${requireTuple('win32-x64-msvc')}
|
|
90
|
+
} else if (process.arch === 'ia32') {
|
|
91
|
+
${requireTuple('win32-ia32-msvc')}
|
|
92
|
+
} else if (process.arch === 'arm64') {
|
|
93
|
+
${requireTuple('win32-arm64-msvc')}
|
|
94
|
+
} else {
|
|
95
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
145
96
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
break
|
|
156
|
-
} catch {}
|
|
157
|
-
switch (arch) {
|
|
158
|
-
case 'x64':
|
|
159
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.darwin-x64.node'))
|
|
160
|
-
try {
|
|
161
|
-
if (localFileExisted) {
|
|
162
|
-
nativeBinding = require('./${localName}.darwin-x64.node')
|
|
163
|
-
} else {
|
|
164
|
-
nativeBinding = require('${pkgName}-darwin-x64')
|
|
165
|
-
}
|
|
166
|
-
} catch (e) {
|
|
167
|
-
loadError = e
|
|
168
|
-
}
|
|
169
|
-
break
|
|
170
|
-
case 'arm64':
|
|
171
|
-
localFileExisted = existsSync(
|
|
172
|
-
join(__dirname, '${localName}.darwin-arm64.node')
|
|
173
|
-
)
|
|
174
|
-
try {
|
|
175
|
-
if (localFileExisted) {
|
|
176
|
-
nativeBinding = require('./${localName}.darwin-arm64.node')
|
|
177
|
-
} else {
|
|
178
|
-
nativeBinding = require('${pkgName}-darwin-arm64')
|
|
179
|
-
}
|
|
180
|
-
} catch (e) {
|
|
181
|
-
loadError = e
|
|
182
|
-
}
|
|
183
|
-
break
|
|
184
|
-
default:
|
|
185
|
-
loadError = new Error(\`Unsupported architecture on macOS: \${arch}\`)
|
|
97
|
+
} else if (process.platform === 'darwin') {
|
|
98
|
+
${requireTuple('darwin-universal')}
|
|
99
|
+
if (process.arch === 'x64') {
|
|
100
|
+
${requireTuple('darwin-x64')}
|
|
101
|
+
} else if (process.arch === 'arm64') {
|
|
102
|
+
${requireTuple('darwin-arm64')}
|
|
103
|
+
} else {
|
|
104
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
186
105
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
nativeBinding = require('./${localName}.freebsd-x64.node')
|
|
195
|
-
} else {
|
|
196
|
-
nativeBinding = require('${pkgName}-freebsd-x64')
|
|
197
|
-
}
|
|
198
|
-
} catch (e) {
|
|
199
|
-
loadError = e
|
|
200
|
-
}
|
|
201
|
-
break
|
|
202
|
-
case 'arm64':
|
|
203
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-arm64.node'))
|
|
204
|
-
try {
|
|
205
|
-
if (localFileExisted) {
|
|
206
|
-
nativeBinding = require('./${localName}.freebsd-arm64.node')
|
|
207
|
-
} else {
|
|
208
|
-
nativeBinding = require('${pkgName}-freebsd-arm64')
|
|
209
|
-
}
|
|
210
|
-
} catch (e) {
|
|
211
|
-
loadError = e
|
|
212
|
-
}
|
|
213
|
-
break
|
|
214
|
-
default:
|
|
215
|
-
loadError = new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
|
|
106
|
+
} else if (process.platform === 'freebsd') {
|
|
107
|
+
if (process.arch === 'x64') {
|
|
108
|
+
${requireTuple('freebsd-x64')}
|
|
109
|
+
} else if (process.arch === 'arm64') {
|
|
110
|
+
${requireTuple('freebsd-arm64')}
|
|
111
|
+
} else {
|
|
112
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
216
113
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
243
|
-
}
|
|
244
|
-
} catch (e) {
|
|
245
|
-
loadError = e
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
break
|
|
249
|
-
case 'arm64':
|
|
250
|
-
if (isMusl()) {
|
|
251
|
-
localFileExisted = existsSync(
|
|
252
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
253
|
-
)
|
|
254
|
-
try {
|
|
255
|
-
if (localFileExisted) {
|
|
256
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
257
|
-
} else {
|
|
258
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
259
|
-
}
|
|
260
|
-
} catch (e) {
|
|
261
|
-
loadError = e
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
localFileExisted = existsSync(
|
|
265
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
266
|
-
)
|
|
267
|
-
try {
|
|
268
|
-
if (localFileExisted) {
|
|
269
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
270
|
-
} else {
|
|
271
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
272
|
-
}
|
|
273
|
-
} catch (e) {
|
|
274
|
-
loadError = e
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
break
|
|
278
|
-
case 'arm':
|
|
279
|
-
localFileExisted = existsSync(
|
|
280
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
281
|
-
)
|
|
282
|
-
try {
|
|
283
|
-
if (localFileExisted) {
|
|
284
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
285
|
-
} else {
|
|
286
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
287
|
-
}
|
|
288
|
-
} catch (e) {
|
|
289
|
-
loadError = e
|
|
290
|
-
}
|
|
291
|
-
break
|
|
292
|
-
case 'riscv64':
|
|
293
|
-
if (isMusl()) {
|
|
294
|
-
localFileExisted = existsSync(
|
|
295
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
296
|
-
)
|
|
297
|
-
try {
|
|
298
|
-
if (localFileExisted) {
|
|
299
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
300
|
-
} else {
|
|
301
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
302
|
-
}
|
|
303
|
-
} catch (e) {
|
|
304
|
-
loadError = e
|
|
305
|
-
}
|
|
306
|
-
} else {
|
|
307
|
-
localFileExisted = existsSync(
|
|
308
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
309
|
-
)
|
|
310
|
-
try {
|
|
311
|
-
if (localFileExisted) {
|
|
312
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
313
|
-
} else {
|
|
314
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
315
|
-
}
|
|
316
|
-
} catch (e) {
|
|
317
|
-
loadError = e
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
break
|
|
321
|
-
case 's390x':
|
|
322
|
-
localFileExisted = existsSync(
|
|
323
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
324
|
-
)
|
|
325
|
-
try {
|
|
326
|
-
if (localFileExisted) {
|
|
327
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
328
|
-
} else {
|
|
329
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
330
|
-
}
|
|
331
|
-
} catch (e) {
|
|
332
|
-
loadError = e
|
|
333
|
-
}
|
|
334
|
-
break
|
|
335
|
-
default:
|
|
336
|
-
loadError = new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
114
|
+
} else if (process.platform === 'linux') {
|
|
115
|
+
if (process.arch === 'x64') {
|
|
116
|
+
if (isMusl()) {
|
|
117
|
+
${requireTuple('linux-x64-musl')}
|
|
118
|
+
} else {
|
|
119
|
+
${requireTuple('linux-x64-gnu')}
|
|
120
|
+
}
|
|
121
|
+
} else if (process.arch === 'arm64') {
|
|
122
|
+
if (isMusl()) {
|
|
123
|
+
${requireTuple('linux-arm64-musl')}
|
|
124
|
+
} else {
|
|
125
|
+
${requireTuple('linux-arm64-gnu')}
|
|
126
|
+
}
|
|
127
|
+
} else if (process.arch === 'arm') {
|
|
128
|
+
${requireTuple('linux-arm-gnueabihf')}
|
|
129
|
+
} else if (process.arch === 'riscv64') {
|
|
130
|
+
if (isMusl()) {
|
|
131
|
+
${requireTuple('linux-riscv64-musl')}
|
|
132
|
+
} else {
|
|
133
|
+
${requireTuple('linux-riscv64-gnu')}
|
|
134
|
+
}
|
|
135
|
+
} else if (process.arch === 's390x') {
|
|
136
|
+
${requireTuple('linux-s390x-gnu')}
|
|
137
|
+
} else {
|
|
138
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
337
139
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
140
|
+
} else {
|
|
141
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
142
|
+
}
|
|
341
143
|
}
|
|
342
144
|
|
|
145
|
+
nativeBinding = requireNative()
|
|
146
|
+
|
|
343
147
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
344
148
|
try {
|
|
345
149
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -360,8 +164,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
360
164
|
}
|
|
361
165
|
|
|
362
166
|
if (!nativeBinding) {
|
|
363
|
-
if (
|
|
364
|
-
|
|
167
|
+
if (loadErrors.length > 0) {
|
|
168
|
+
// TODO Link to documentation with potential fixes
|
|
169
|
+
// - The package owner could build/publish bindings for this arch
|
|
170
|
+
// - The user may need to bundle the correct files
|
|
171
|
+
// - The user may need to re-install node_modules to get new packages
|
|
172
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
365
173
|
}
|
|
366
174
|
throw new Error(\`Failed to load native binding\`)
|
|
367
175
|
}
|