@napi-rs/cli 3.0.0-alpha.40 → 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 +80 -256
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/index.cjs +81 -257
- package/package.json +2 -2
- package/src/api/templates/js-binding.ts +81 -256
|
@@ -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,266 +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
|
-
throw 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
|
-
throw 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
|
-
throw 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
|
-
|
|
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}\`))
|
|
187
110
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
|
|
111
|
+
} else if (process.platform === 'linux') {
|
|
112
|
+
if (process.arch === 'x64') {
|
|
113
|
+
if (isMusl()) {
|
|
114
|
+
${requireTuple('linux-x64-musl')}
|
|
192
115
|
} else {
|
|
193
|
-
|
|
116
|
+
${requireTuple('linux-x64-gnu')}
|
|
194
117
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
loadError = e
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
localFileExisted = existsSync(
|
|
217
|
-
join(__dirname, '${localName}.linux-x64-gnu.node')
|
|
218
|
-
)
|
|
219
|
-
try {
|
|
220
|
-
if (localFileExisted) {
|
|
221
|
-
nativeBinding = require('./${localName}.linux-x64-gnu.node')
|
|
222
|
-
} else {
|
|
223
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
224
|
-
}
|
|
225
|
-
} catch (e) {
|
|
226
|
-
loadError = e
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
break
|
|
230
|
-
case 'arm64':
|
|
231
|
-
if (isMusl()) {
|
|
232
|
-
localFileExisted = existsSync(
|
|
233
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
234
|
-
)
|
|
235
|
-
try {
|
|
236
|
-
if (localFileExisted) {
|
|
237
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
238
|
-
} else {
|
|
239
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
240
|
-
}
|
|
241
|
-
} catch (e) {
|
|
242
|
-
loadError = e
|
|
243
|
-
}
|
|
244
|
-
} else {
|
|
245
|
-
localFileExisted = existsSync(
|
|
246
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
247
|
-
)
|
|
248
|
-
try {
|
|
249
|
-
if (localFileExisted) {
|
|
250
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
251
|
-
} else {
|
|
252
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
253
|
-
}
|
|
254
|
-
} catch (e) {
|
|
255
|
-
loadError = e
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
break
|
|
259
|
-
case 'arm':
|
|
260
|
-
localFileExisted = existsSync(
|
|
261
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
262
|
-
)
|
|
263
|
-
try {
|
|
264
|
-
if (localFileExisted) {
|
|
265
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
266
|
-
} else {
|
|
267
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
268
|
-
}
|
|
269
|
-
} catch (e) {
|
|
270
|
-
loadError = e
|
|
271
|
-
}
|
|
272
|
-
break
|
|
273
|
-
case 'riscv64':
|
|
274
|
-
if (isMusl()) {
|
|
275
|
-
localFileExisted = existsSync(
|
|
276
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
277
|
-
)
|
|
278
|
-
try {
|
|
279
|
-
if (localFileExisted) {
|
|
280
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
281
|
-
} else {
|
|
282
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
283
|
-
}
|
|
284
|
-
} catch (e) {
|
|
285
|
-
loadError = e
|
|
286
|
-
}
|
|
287
|
-
} else {
|
|
288
|
-
localFileExisted = existsSync(
|
|
289
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
290
|
-
)
|
|
291
|
-
try {
|
|
292
|
-
if (localFileExisted) {
|
|
293
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
294
|
-
} else {
|
|
295
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
296
|
-
}
|
|
297
|
-
} catch (e) {
|
|
298
|
-
loadError = e
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
break
|
|
302
|
-
case 's390x':
|
|
303
|
-
localFileExisted = existsSync(
|
|
304
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
305
|
-
)
|
|
306
|
-
try {
|
|
307
|
-
if (localFileExisted) {
|
|
308
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
309
|
-
} else {
|
|
310
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
311
|
-
}
|
|
312
|
-
} catch (e) {
|
|
313
|
-
loadError = e
|
|
314
|
-
}
|
|
315
|
-
break
|
|
316
|
-
default:
|
|
317
|
-
throw new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
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}\`))
|
|
318
136
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
137
|
+
} else {
|
|
138
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
139
|
+
}
|
|
322
140
|
}
|
|
323
141
|
|
|
142
|
+
nativeBinding = requireNative()
|
|
143
|
+
|
|
324
144
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
325
145
|
try {
|
|
326
146
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -341,8 +161,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
341
161
|
}
|
|
342
162
|
|
|
343
163
|
if (!nativeBinding) {
|
|
344
|
-
if (
|
|
345
|
-
|
|
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 })
|
|
346
170
|
}
|
|
347
171
|
throw new Error(\`Failed to load native binding\`)
|
|
348
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,266 +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
|
-
throw 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
|
-
throw 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
|
-
case 'x64':
|
|
16982
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.darwin-x64.node'))
|
|
16983
|
-
try {
|
|
16984
|
-
if (localFileExisted) {
|
|
16985
|
-
nativeBinding = require('./${localName}.darwin-x64.node')
|
|
16986
|
-
} else {
|
|
16987
|
-
nativeBinding = require('${pkgName}-darwin-x64')
|
|
16988
|
-
}
|
|
16989
|
-
} catch (e) {
|
|
16990
|
-
loadError = e
|
|
16991
|
-
}
|
|
16992
|
-
break
|
|
16993
|
-
case 'arm64':
|
|
16994
|
-
localFileExisted = existsSync(
|
|
16995
|
-
join(__dirname, '${localName}.darwin-arm64.node')
|
|
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
|
-
throw new Error(\`Unsupported architecture on macOS: \${arch}\`)
|
|
17009
|
-
}
|
|
17010
|
-
break
|
|
17011
|
-
case 'freebsd':
|
|
17012
|
-
if (arch !== 'x64') {
|
|
17013
|
-
throw new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
|
|
17014
|
-
}
|
|
17015
|
-
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-x64.node'))
|
|
17016
|
-
try {
|
|
17017
|
-
if (localFileExisted) {
|
|
17018
|
-
nativeBinding = require('./${localName}.freebsd-x64.node')
|
|
16945
|
+
} else if (process.arch === 'arm64') {
|
|
16946
|
+
if (isMusl()) {
|
|
16947
|
+
${requireTuple("linux-arm64-musl")}
|
|
17019
16948
|
} else {
|
|
17020
|
-
|
|
16949
|
+
${requireTuple("linux-arm64-gnu")}
|
|
17021
16950
|
}
|
|
17022
|
-
}
|
|
17023
|
-
|
|
17024
|
-
}
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
if (localFileExisted) {
|
|
17035
|
-
nativeBinding = require('./${localName}.linux-x64-musl.node')
|
|
17036
|
-
} else {
|
|
17037
|
-
nativeBinding = require('${pkgName}-linux-x64-musl')
|
|
17038
|
-
}
|
|
17039
|
-
} catch (e) {
|
|
17040
|
-
loadError = e
|
|
17041
|
-
}
|
|
17042
|
-
} else {
|
|
17043
|
-
localFileExisted = existsSync(
|
|
17044
|
-
join(__dirname, '${localName}.linux-x64-gnu.node')
|
|
17045
|
-
)
|
|
17046
|
-
try {
|
|
17047
|
-
if (localFileExisted) {
|
|
17048
|
-
nativeBinding = require('./${localName}.linux-x64-gnu.node')
|
|
17049
|
-
} else {
|
|
17050
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
17051
|
-
}
|
|
17052
|
-
} catch (e) {
|
|
17053
|
-
loadError = e
|
|
17054
|
-
}
|
|
17055
|
-
}
|
|
17056
|
-
break
|
|
17057
|
-
case 'arm64':
|
|
17058
|
-
if (isMusl()) {
|
|
17059
|
-
localFileExisted = existsSync(
|
|
17060
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
17061
|
-
)
|
|
17062
|
-
try {
|
|
17063
|
-
if (localFileExisted) {
|
|
17064
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
17065
|
-
} else {
|
|
17066
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
17067
|
-
}
|
|
17068
|
-
} catch (e) {
|
|
17069
|
-
loadError = e
|
|
17070
|
-
}
|
|
17071
|
-
} else {
|
|
17072
|
-
localFileExisted = existsSync(
|
|
17073
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
17074
|
-
)
|
|
17075
|
-
try {
|
|
17076
|
-
if (localFileExisted) {
|
|
17077
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
17078
|
-
} else {
|
|
17079
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
17080
|
-
}
|
|
17081
|
-
} catch (e) {
|
|
17082
|
-
loadError = e
|
|
17083
|
-
}
|
|
17084
|
-
}
|
|
17085
|
-
break
|
|
17086
|
-
case 'arm':
|
|
17087
|
-
localFileExisted = existsSync(
|
|
17088
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
17089
|
-
)
|
|
17090
|
-
try {
|
|
17091
|
-
if (localFileExisted) {
|
|
17092
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
17093
|
-
} else {
|
|
17094
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
17095
|
-
}
|
|
17096
|
-
} catch (e) {
|
|
17097
|
-
loadError = e
|
|
17098
|
-
}
|
|
17099
|
-
break
|
|
17100
|
-
case 'riscv64':
|
|
17101
|
-
if (isMusl()) {
|
|
17102
|
-
localFileExisted = existsSync(
|
|
17103
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
17104
|
-
)
|
|
17105
|
-
try {
|
|
17106
|
-
if (localFileExisted) {
|
|
17107
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
17108
|
-
} else {
|
|
17109
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
17110
|
-
}
|
|
17111
|
-
} catch (e) {
|
|
17112
|
-
loadError = e
|
|
17113
|
-
}
|
|
17114
|
-
} else {
|
|
17115
|
-
localFileExisted = existsSync(
|
|
17116
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
17117
|
-
)
|
|
17118
|
-
try {
|
|
17119
|
-
if (localFileExisted) {
|
|
17120
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
17121
|
-
} else {
|
|
17122
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
17123
|
-
}
|
|
17124
|
-
} catch (e) {
|
|
17125
|
-
loadError = e
|
|
17126
|
-
}
|
|
17127
|
-
}
|
|
17128
|
-
break
|
|
17129
|
-
case 's390x':
|
|
17130
|
-
localFileExisted = existsSync(
|
|
17131
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
17132
|
-
)
|
|
17133
|
-
try {
|
|
17134
|
-
if (localFileExisted) {
|
|
17135
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
17136
|
-
} else {
|
|
17137
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
17138
|
-
}
|
|
17139
|
-
} catch (e) {
|
|
17140
|
-
loadError = e
|
|
17141
|
-
}
|
|
17142
|
-
break
|
|
17143
|
-
default:
|
|
17144
|
-
throw new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
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}\`))
|
|
17145
16963
|
}
|
|
17146
|
-
|
|
17147
|
-
|
|
17148
|
-
|
|
16964
|
+
} else {
|
|
16965
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
16966
|
+
}
|
|
17149
16967
|
}
|
|
17150
16968
|
|
|
16969
|
+
nativeBinding = requireNative()
|
|
16970
|
+
|
|
17151
16971
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
17152
16972
|
try {
|
|
17153
16973
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -17168,8 +16988,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
17168
16988
|
}
|
|
17169
16989
|
|
|
17170
16990
|
if (!nativeBinding) {
|
|
17171
|
-
if (
|
|
17172
|
-
|
|
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 })
|
|
17173
16997
|
}
|
|
17174
16998
|
throw new Error(\`Failed to load native binding\`)
|
|
17175
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,266 +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
|
-
throw 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
|
-
throw 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
|
-
throw 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
|
-
|
|
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}\`))
|
|
191
115
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
116
|
+
} else if (process.platform === 'linux') {
|
|
117
|
+
if (process.arch === 'x64') {
|
|
118
|
+
if (isMusl()) {
|
|
119
|
+
${requireTuple('linux-x64-musl')}
|
|
196
120
|
} else {
|
|
197
|
-
|
|
121
|
+
${requireTuple('linux-x64-gnu')}
|
|
198
122
|
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
loadError = e
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
localFileExisted = existsSync(
|
|
221
|
-
join(__dirname, '${localName}.linux-x64-gnu.node')
|
|
222
|
-
)
|
|
223
|
-
try {
|
|
224
|
-
if (localFileExisted) {
|
|
225
|
-
nativeBinding = require('./${localName}.linux-x64-gnu.node')
|
|
226
|
-
} else {
|
|
227
|
-
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
228
|
-
}
|
|
229
|
-
} catch (e) {
|
|
230
|
-
loadError = e
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
break
|
|
234
|
-
case 'arm64':
|
|
235
|
-
if (isMusl()) {
|
|
236
|
-
localFileExisted = existsSync(
|
|
237
|
-
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
238
|
-
)
|
|
239
|
-
try {
|
|
240
|
-
if (localFileExisted) {
|
|
241
|
-
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
242
|
-
} else {
|
|
243
|
-
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
244
|
-
}
|
|
245
|
-
} catch (e) {
|
|
246
|
-
loadError = e
|
|
247
|
-
}
|
|
248
|
-
} else {
|
|
249
|
-
localFileExisted = existsSync(
|
|
250
|
-
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
251
|
-
)
|
|
252
|
-
try {
|
|
253
|
-
if (localFileExisted) {
|
|
254
|
-
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
255
|
-
} else {
|
|
256
|
-
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
257
|
-
}
|
|
258
|
-
} catch (e) {
|
|
259
|
-
loadError = e
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
break
|
|
263
|
-
case 'arm':
|
|
264
|
-
localFileExisted = existsSync(
|
|
265
|
-
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
266
|
-
)
|
|
267
|
-
try {
|
|
268
|
-
if (localFileExisted) {
|
|
269
|
-
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
270
|
-
} else {
|
|
271
|
-
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
272
|
-
}
|
|
273
|
-
} catch (e) {
|
|
274
|
-
loadError = e
|
|
275
|
-
}
|
|
276
|
-
break
|
|
277
|
-
case 'riscv64':
|
|
278
|
-
if (isMusl()) {
|
|
279
|
-
localFileExisted = existsSync(
|
|
280
|
-
join(__dirname, '${localName}.linux-riscv64-musl.node')
|
|
281
|
-
)
|
|
282
|
-
try {
|
|
283
|
-
if (localFileExisted) {
|
|
284
|
-
nativeBinding = require('./${localName}.linux-riscv64-musl.node')
|
|
285
|
-
} else {
|
|
286
|
-
nativeBinding = require('${pkgName}-linux-riscv64-musl')
|
|
287
|
-
}
|
|
288
|
-
} catch (e) {
|
|
289
|
-
loadError = e
|
|
290
|
-
}
|
|
291
|
-
} else {
|
|
292
|
-
localFileExisted = existsSync(
|
|
293
|
-
join(__dirname, '${localName}.linux-riscv64-gnu.node')
|
|
294
|
-
)
|
|
295
|
-
try {
|
|
296
|
-
if (localFileExisted) {
|
|
297
|
-
nativeBinding = require('./${localName}.linux-riscv64-gnu.node')
|
|
298
|
-
} else {
|
|
299
|
-
nativeBinding = require('${pkgName}-linux-riscv64-gnu')
|
|
300
|
-
}
|
|
301
|
-
} catch (e) {
|
|
302
|
-
loadError = e
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
break
|
|
306
|
-
case 's390x':
|
|
307
|
-
localFileExisted = existsSync(
|
|
308
|
-
join(__dirname, '${localName}.linux-s390x-gnu.node')
|
|
309
|
-
)
|
|
310
|
-
try {
|
|
311
|
-
if (localFileExisted) {
|
|
312
|
-
nativeBinding = require('./${localName}.linux-s390x-gnu.node')
|
|
313
|
-
} else {
|
|
314
|
-
nativeBinding = require('${pkgName}-linux-s390x-gnu')
|
|
315
|
-
}
|
|
316
|
-
} catch (e) {
|
|
317
|
-
loadError = e
|
|
318
|
-
}
|
|
319
|
-
break
|
|
320
|
-
default:
|
|
321
|
-
throw new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
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}\`))
|
|
322
141
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
142
|
+
} else {
|
|
143
|
+
loadErrors.push(new Error(\`Unsupported OS: \${process.platform}, architecture: \${process.arch}\`))
|
|
144
|
+
}
|
|
326
145
|
}
|
|
327
146
|
|
|
147
|
+
nativeBinding = requireNative()
|
|
148
|
+
|
|
328
149
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
329
150
|
try {
|
|
330
151
|
nativeBinding = require('./${localName}.wasi.cjs')
|
|
@@ -345,8 +166,12 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
345
166
|
}
|
|
346
167
|
|
|
347
168
|
if (!nativeBinding) {
|
|
348
|
-
if (
|
|
349
|
-
|
|
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 })
|
|
350
175
|
}
|
|
351
176
|
throw new Error(\`Failed to load native binding\`)
|
|
352
177
|
}
|