@napi-rs/cli 3.0.0-alpha.41 → 3.0.0-alpha.42
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 +82 -273
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/index.cjs +83 -274
- package/package.json +2 -2
- package/src/api/templates/js-binding.ts +83 -273
|
@@ -1,4 +1,17 @@
|
|
|
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 */
|
|
@@ -6,11 +19,9 @@ export function createCjsBinding(localName, pkgName, idents) {
|
|
|
6
19
|
const { existsSync, readFileSync } = require('fs')
|
|
7
20
|
const { join } = require('path')
|
|
8
21
|
|
|
9
|
-
const { platform, arch } = process
|
|
10
|
-
|
|
11
22
|
let nativeBinding = null
|
|
12
23
|
let localFileExisted = false
|
|
13
|
-
let
|
|
24
|
+
let loadErrors = []
|
|
14
25
|
|
|
15
26
|
const isMusl = () => {
|
|
16
27
|
let musl = false
|
|
@@ -61,281 +72,75 @@ const isMuslFromChildProcess = () => {
|
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
74
|
|
|
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}\`)
|
|
75
|
+
function requireNative() {
|
|
76
|
+
if (process.platform === 'android') {
|
|
77
|
+
if (process.arch === 'arm64') {
|
|
78
|
+
${requireTuple('android-arm64')}
|
|
79
|
+
} else if (process.arch === 'arm') {
|
|
80
|
+
${requireTuple('android-arm-eabi')}
|
|
81
|
+
} else {
|
|
82
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
93
83
|
}
|
|
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}\`)
|
|
84
|
+
} else if (process.platform === 'win32') {
|
|
85
|
+
if (process.arch === 'x64') {
|
|
86
|
+
${requireTuple('win32-x64-msvc')}
|
|
87
|
+
} else if (process.arch === 'ia32') {
|
|
88
|
+
${requireTuple('win32-ia32-msvc')}
|
|
89
|
+
} else if (process.arch === 'arm64') {
|
|
90
|
+
${requireTuple('win32-arm64-msvc')}
|
|
91
|
+
} else {
|
|
92
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
141
93
|
}
|
|
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}\`)
|
|
94
|
+
} else if (process.platform === 'darwin') {
|
|
95
|
+
${requireTuple('darwin-universal')}
|
|
96
|
+
if (process.arch === 'x64') {
|
|
97
|
+
${requireTuple('darwin-x64')}
|
|
98
|
+
} else if (process.arch === 'arm64') {
|
|
99
|
+
${requireTuple('darwin-arm64')}
|
|
100
|
+
} else {
|
|
101
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
182
102
|
}
|
|
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}\`)
|
|
103
|
+
} else if (process.platform === 'freebsd') {
|
|
104
|
+
if (process.arch === 'x64') {
|
|
105
|
+
${requireTuple('freebsd-x64')}
|
|
106
|
+
} else if (process.arch === 'arm64') {
|
|
107
|
+
${requireTuple('freebsd-arm64')}
|
|
108
|
+
} else {
|
|
109
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
212
110
|
}
|
|
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}\`)
|
|
111
|
+
} else if (process.platform === 'linux') {
|
|
112
|
+
if (process.arch === 'x64') {
|
|
113
|
+
if (isMusl()) {
|
|
114
|
+
${requireTuple('linux-x64-musl')}
|
|
115
|
+
} else {
|
|
116
|
+
${requireTuple('linux-x64-gnu')}
|
|
117
|
+
}
|
|
118
|
+
} else if (process.arch === 'arm64') {
|
|
119
|
+
if (isMusl()) {
|
|
120
|
+
${requireTuple('linux-arm64-musl')}
|
|
121
|
+
} else {
|
|
122
|
+
${requireTuple('linux-arm64-gnu')}
|
|
123
|
+
}
|
|
124
|
+
} else if (process.arch === 'arm') {
|
|
125
|
+
${requireTuple('linux-arm-gnueabihf')}
|
|
126
|
+
} else if (process.arch === 'riscv64') {
|
|
127
|
+
if (isMusl()) {
|
|
128
|
+
${requireTuple('linux-riscv64-musl')}
|
|
129
|
+
} else {
|
|
130
|
+
${requireTuple('linux-riscv64-gnu')}
|
|
131
|
+
}
|
|
132
|
+
} else if (process.arch === 's390x') {
|
|
133
|
+
${requireTuple('linux-s390x-gnu')}
|
|
134
|
+
} else {
|
|
135
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
333
136
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
137
|
+
} else {
|
|
138
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
139
|
+
}
|
|
337
140
|
}
|
|
338
141
|
|
|
142
|
+
nativeBinding = requireNative()
|
|
143
|
+
|
|
339
144
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
340
145
|
try {
|
|
341
146
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -356,8 +161,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
356
161
|
}
|
|
357
162
|
|
|
358
163
|
if (!nativeBinding) {
|
|
359
|
-
if (
|
|
360
|
-
|
|
164
|
+
if (loadErrors.length > 0) {
|
|
165
|
+
// TODO Link to documentation with potential fixes
|
|
166
|
+
// - The package owner could build/publish bindings for this arch
|
|
167
|
+
// - The user may need to bundle the correct files
|
|
168
|
+
// - The user may need to re-install node_modules to get new packages
|
|
169
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
361
170
|
}
|
|
362
171
|
throw new Error(\`Failed to load native binding\`)
|
|
363
172
|
}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+DD,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,6 +16826,19 @@ 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 */
|
|
@@ -16833,11 +16846,9 @@ function createCjsBinding(localName, pkgName, idents) {
|
|
|
16833
16846
|
const { existsSync, readFileSync } = require('fs')
|
|
16834
16847
|
const { join } = require('path')
|
|
16835
16848
|
|
|
16836
|
-
const { platform, arch } = process
|
|
16837
|
-
|
|
16838
16849
|
let nativeBinding = null
|
|
16839
16850
|
let localFileExisted = false
|
|
16840
|
-
let
|
|
16851
|
+
let loadErrors = []
|
|
16841
16852
|
|
|
16842
16853
|
const isMusl = () => {
|
|
16843
16854
|
let musl = false
|
|
@@ -16888,281 +16899,75 @@ const isMuslFromChildProcess = () => {
|
|
|
16888
16899
|
}
|
|
16889
16900
|
}
|
|
16890
16901
|
|
|
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}\`)
|
|
16902
|
+
function requireNative() {
|
|
16903
|
+
if (process.platform === 'android') {
|
|
16904
|
+
if (process.arch === 'arm64') {
|
|
16905
|
+
${requireTuple("android-arm64")}
|
|
16906
|
+
} else if (process.arch === 'arm') {
|
|
16907
|
+
${requireTuple("android-arm-eabi")}
|
|
16908
|
+
} else {
|
|
16909
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
16910
|
+
}
|
|
16911
|
+
} else if (process.platform === 'win32') {
|
|
16912
|
+
if (process.arch === 'x64') {
|
|
16913
|
+
${requireTuple("win32-x64-msvc")}
|
|
16914
|
+
} else if (process.arch === 'ia32') {
|
|
16915
|
+
${requireTuple("win32-ia32-msvc")}
|
|
16916
|
+
} else if (process.arch === 'arm64') {
|
|
16917
|
+
${requireTuple("win32-arm64-msvc")}
|
|
16918
|
+
} else {
|
|
16919
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
16920
|
+
}
|
|
16921
|
+
} else if (process.platform === 'darwin') {
|
|
16922
|
+
${requireTuple("darwin-universal")}
|
|
16923
|
+
if (process.arch === 'x64') {
|
|
16924
|
+
${requireTuple("darwin-x64")}
|
|
16925
|
+
} else if (process.arch === 'arm64') {
|
|
16926
|
+
${requireTuple("darwin-arm64")}
|
|
16927
|
+
} else {
|
|
16928
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
16968
16929
|
}
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16930
|
+
} else if (process.platform === 'freebsd') {
|
|
16931
|
+
if (process.arch === 'x64') {
|
|
16932
|
+
${requireTuple("freebsd-x64")}
|
|
16933
|
+
} else if (process.arch === 'arm64') {
|
|
16934
|
+
${requireTuple("freebsd-arm64")}
|
|
16935
|
+
} else {
|
|
16936
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
16937
|
+
}
|
|
16938
|
+
} else if (process.platform === 'linux') {
|
|
16939
|
+
if (process.arch === 'x64') {
|
|
16940
|
+
if (isMusl()) {
|
|
16941
|
+
${requireTuple("linux-x64-musl")}
|
|
16975
16942
|
} else {
|
|
16976
|
-
|
|
16943
|
+
${requireTuple("linux-x64-gnu")}
|
|
16977
16944
|
}
|
|
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}\`)
|
|
16945
|
+
} else if (process.arch === 'arm64') {
|
|
16946
|
+
if (isMusl()) {
|
|
16947
|
+
${requireTuple("linux-arm64-musl")}
|
|
16948
|
+
} else {
|
|
16949
|
+
${requireTuple("linux-arm64-gnu")}
|
|
16950
|
+
}
|
|
16951
|
+
} else if (process.arch === 'arm') {
|
|
16952
|
+
${requireTuple("linux-arm-gnueabihf")}
|
|
16953
|
+
} else if (process.arch === 'riscv64') {
|
|
16954
|
+
if (isMusl()) {
|
|
16955
|
+
${requireTuple("linux-riscv64-musl")}
|
|
16956
|
+
} else {
|
|
16957
|
+
${requireTuple("linux-riscv64-gnu")}
|
|
16958
|
+
}
|
|
16959
|
+
} else if (process.arch === 's390x') {
|
|
16960
|
+
${requireTuple("linux-s390x-gnu")}
|
|
16961
|
+
} else {
|
|
16962
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
17160
16963
|
}
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
16964
|
+
} else {
|
|
16965
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
16966
|
+
}
|
|
17164
16967
|
}
|
|
17165
16968
|
|
|
16969
|
+
nativeBinding = requireNative()
|
|
16970
|
+
|
|
17166
16971
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
17167
16972
|
try {
|
|
17168
16973
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -17183,8 +16988,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
17183
16988
|
}
|
|
17184
16989
|
|
|
17185
16990
|
if (!nativeBinding) {
|
|
17186
|
-
if (
|
|
17187
|
-
|
|
16991
|
+
if (loadErrors.length > 0) {
|
|
16992
|
+
// TODO Link to documentation with potential fixes
|
|
16993
|
+
// - The package owner could build/publish bindings for this arch
|
|
16994
|
+
// - The user may need to bundle the correct files
|
|
16995
|
+
// - The user may need to re-install node_modules to get new packages
|
|
16996
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
17188
16997
|
}
|
|
17189
16998
|
throw new Error(\`Failed to load native binding\`)
|
|
17190
16999
|
}
|
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.42",
|
|
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": "9abcb484ba059374f9a5e2d34fe8d9cb470ea4c4"
|
|
134
134
|
}
|
|
@@ -3,6 +3,20 @@ 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 */
|
|
@@ -10,11 +24,9 @@ export function createCjsBinding(
|
|
|
10
24
|
const { existsSync, readFileSync } = require('fs')
|
|
11
25
|
const { join } = require('path')
|
|
12
26
|
|
|
13
|
-
const { platform, arch } = process
|
|
14
|
-
|
|
15
27
|
let nativeBinding = null
|
|
16
28
|
let localFileExisted = false
|
|
17
|
-
let
|
|
29
|
+
let loadErrors = []
|
|
18
30
|
|
|
19
31
|
const isMusl = () => {
|
|
20
32
|
let musl = false
|
|
@@ -65,281 +77,75 @@ const isMuslFromChildProcess = () => {
|
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
|
|
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}\`)
|
|
80
|
+
function requireNative() {
|
|
81
|
+
if (process.platform === 'android') {
|
|
82
|
+
if (process.arch === 'arm64') {
|
|
83
|
+
${requireTuple('android-arm64')}
|
|
84
|
+
} else if (process.arch === 'arm') {
|
|
85
|
+
${requireTuple('android-arm-eabi')}
|
|
86
|
+
} else {
|
|
87
|
+
loadErrors.push(new Error(\`Unsupported architecture on Android \${process.arch}\`))
|
|
97
88
|
}
|
|
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}\`)
|
|
89
|
+
} else if (process.platform === 'win32') {
|
|
90
|
+
if (process.arch === 'x64') {
|
|
91
|
+
${requireTuple('win32-x64-msvc')}
|
|
92
|
+
} else if (process.arch === 'ia32') {
|
|
93
|
+
${requireTuple('win32-ia32-msvc')}
|
|
94
|
+
} else if (process.arch === 'arm64') {
|
|
95
|
+
${requireTuple('win32-arm64-msvc')}
|
|
96
|
+
} else {
|
|
97
|
+
loadErrors.push(new Error(\`Unsupported architecture on Windows: \${process.arch}\`))
|
|
145
98
|
}
|
|
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}\`)
|
|
99
|
+
} else if (process.platform === 'darwin') {
|
|
100
|
+
${requireTuple('darwin-universal')}
|
|
101
|
+
if (process.arch === 'x64') {
|
|
102
|
+
${requireTuple('darwin-x64')}
|
|
103
|
+
} else if (process.arch === 'arm64') {
|
|
104
|
+
${requireTuple('darwin-arm64')}
|
|
105
|
+
} else {
|
|
106
|
+
loadErrors.push(new Error(\`Unsupported architecture on macOS: \${process.arch}\`))
|
|
186
107
|
}
|
|
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}\`)
|
|
108
|
+
} else if (process.platform === 'freebsd') {
|
|
109
|
+
if (process.arch === 'x64') {
|
|
110
|
+
${requireTuple('freebsd-x64')}
|
|
111
|
+
} else if (process.arch === 'arm64') {
|
|
112
|
+
${requireTuple('freebsd-arm64')}
|
|
113
|
+
} else {
|
|
114
|
+
loadErrors.push(new Error(\`Unsupported architecture on FreeBSD: \${process.arch}\`))
|
|
216
115
|
}
|
|
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}\`)
|
|
116
|
+
} else if (process.platform === 'linux') {
|
|
117
|
+
if (process.arch === 'x64') {
|
|
118
|
+
if (isMusl()) {
|
|
119
|
+
${requireTuple('linux-x64-musl')}
|
|
120
|
+
} else {
|
|
121
|
+
${requireTuple('linux-x64-gnu')}
|
|
122
|
+
}
|
|
123
|
+
} else if (process.arch === 'arm64') {
|
|
124
|
+
if (isMusl()) {
|
|
125
|
+
${requireTuple('linux-arm64-musl')}
|
|
126
|
+
} else {
|
|
127
|
+
${requireTuple('linux-arm64-gnu')}
|
|
128
|
+
}
|
|
129
|
+
} else if (process.arch === 'arm') {
|
|
130
|
+
${requireTuple('linux-arm-gnueabihf')}
|
|
131
|
+
} else if (process.arch === 'riscv64') {
|
|
132
|
+
if (isMusl()) {
|
|
133
|
+
${requireTuple('linux-riscv64-musl')}
|
|
134
|
+
} else {
|
|
135
|
+
${requireTuple('linux-riscv64-gnu')}
|
|
136
|
+
}
|
|
137
|
+
} else if (process.arch === 's390x') {
|
|
138
|
+
${requireTuple('linux-s390x-gnu')}
|
|
139
|
+
} else {
|
|
140
|
+
loadErrors.push(new Error(\`Unsupported architecture on Linux: \${process.arch}\`))
|
|
337
141
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
142
|
+
} else {
|
|
143
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
144
|
+
}
|
|
341
145
|
}
|
|
342
146
|
|
|
147
|
+
nativeBinding = requireNative()
|
|
148
|
+
|
|
343
149
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
344
150
|
try {
|
|
345
151
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -360,8 +166,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
360
166
|
}
|
|
361
167
|
|
|
362
168
|
if (!nativeBinding) {
|
|
363
|
-
if (
|
|
364
|
-
|
|
169
|
+
if (loadErrors.length > 0) {
|
|
170
|
+
// TODO Link to documentation with potential fixes
|
|
171
|
+
// - The package owner could build/publish bindings for this arch
|
|
172
|
+
// - The user may need to bundle the correct files
|
|
173
|
+
// - The user may need to re-install node_modules to get new packages
|
|
174
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
365
175
|
}
|
|
366
176
|
throw new Error(\`Failed to load native binding\`)
|
|
367
177
|
}
|