@atbash/sdk 0.12.0-dev.0 → 0.13.2-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +89 -11
- package/dist/browser.mjs +133 -29
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +89 -11
- package/dist/index.d.ts +89 -11
- package/dist/index.js +179 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -42
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +25 -16
- package/index.js +294 -103
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
1
|
/* eslint-disable */
|
|
3
2
|
// @ts-nocheck
|
|
4
3
|
/* auto-generated by NAPI-RS */
|
|
5
4
|
|
|
6
5
|
const { readFileSync } = require('fs')
|
|
7
6
|
let nativeBinding = null
|
|
7
|
+
// Which artifact actually loaded. The WASI fallback chain overwrites it with
|
|
8
|
+
// the flavor it resolved; the late native retry below leaves it alone because
|
|
9
|
+
// it only runs while no WASI candidate has been loaded.
|
|
10
|
+
let __napiLoadedBindingTarget = 'native'
|
|
8
11
|
const loadErrors = []
|
|
9
12
|
|
|
10
13
|
const isMusl = () => {
|
|
@@ -63,7 +66,16 @@ const isMuslFromChildProcess = () => {
|
|
|
63
66
|
function requireNative() {
|
|
64
67
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
68
|
try {
|
|
66
|
-
|
|
69
|
+
const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
70
|
+
// The override may be a generated WASI loader, which already reports its
|
|
71
|
+
// own flavor. Adopt it: `module.exports` aliases this object, so claiming
|
|
72
|
+
// 'native' would both misreport the artifact and overwrite the loader's
|
|
73
|
+
// marker through the alias.
|
|
74
|
+
__napiLoadedBindingTarget =
|
|
75
|
+
overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
|
|
76
|
+
? overrideBinding.__napiBindingTarget
|
|
77
|
+
: 'native'
|
|
78
|
+
return overrideBinding
|
|
67
79
|
} catch (err) {
|
|
68
80
|
loadErrors.push(err)
|
|
69
81
|
}
|
|
@@ -77,8 +89,8 @@ function requireNative() {
|
|
|
77
89
|
try {
|
|
78
90
|
const binding = require('@atbash/sdk-android-arm64')
|
|
79
91
|
const bindingPackageVersion = require('@atbash/sdk-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
92
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
93
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
94
|
}
|
|
83
95
|
return binding
|
|
84
96
|
} catch (e) {
|
|
@@ -93,8 +105,8 @@ function requireNative() {
|
|
|
93
105
|
try {
|
|
94
106
|
const binding = require('@atbash/sdk-android-arm-eabi')
|
|
95
107
|
const bindingPackageVersion = require('@atbash/sdk-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
108
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
109
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
110
|
}
|
|
99
111
|
return binding
|
|
100
112
|
} catch (e) {
|
|
@@ -107,36 +119,36 @@ function requireNative() {
|
|
|
107
119
|
if (process.arch === 'x64') {
|
|
108
120
|
if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
|
|
109
121
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
return require('./atbash.win32-x64-gnu.node')
|
|
123
|
+
} catch (e) {
|
|
124
|
+
loadErrors.push(e)
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const binding = require('@atbash/sdk-win32-x64-gnu')
|
|
128
|
+
const bindingPackageVersion = require('@atbash/sdk-win32-x64-gnu/package.json').version
|
|
129
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
130
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
131
|
+
}
|
|
132
|
+
return binding
|
|
133
|
+
} catch (e) {
|
|
134
|
+
loadErrors.push(e)
|
|
119
135
|
}
|
|
120
|
-
return binding
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadErrors.push(e)
|
|
123
|
-
}
|
|
124
136
|
} else {
|
|
125
137
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
return require('./atbash.win32-x64-msvc.node')
|
|
139
|
+
} catch (e) {
|
|
140
|
+
loadErrors.push(e)
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const binding = require('@atbash/sdk-win32-x64-msvc')
|
|
144
|
+
const bindingPackageVersion = require('@atbash/sdk-win32-x64-msvc/package.json').version
|
|
145
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
146
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
147
|
+
}
|
|
148
|
+
return binding
|
|
149
|
+
} catch (e) {
|
|
150
|
+
loadErrors.push(e)
|
|
135
151
|
}
|
|
136
|
-
return binding
|
|
137
|
-
} catch (e) {
|
|
138
|
-
loadErrors.push(e)
|
|
139
|
-
}
|
|
140
152
|
}
|
|
141
153
|
} else if (process.arch === 'ia32') {
|
|
142
154
|
try {
|
|
@@ -147,8 +159,8 @@ function requireNative() {
|
|
|
147
159
|
try {
|
|
148
160
|
const binding = require('@atbash/sdk-win32-ia32-msvc')
|
|
149
161
|
const bindingPackageVersion = require('@atbash/sdk-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
162
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
164
|
}
|
|
153
165
|
return binding
|
|
154
166
|
} catch (e) {
|
|
@@ -163,8 +175,8 @@ function requireNative() {
|
|
|
163
175
|
try {
|
|
164
176
|
const binding = require('@atbash/sdk-win32-arm64-msvc')
|
|
165
177
|
const bindingPackageVersion = require('@atbash/sdk-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
178
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
179
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
180
|
}
|
|
169
181
|
return binding
|
|
170
182
|
} catch (e) {
|
|
@@ -182,8 +194,8 @@ function requireNative() {
|
|
|
182
194
|
try {
|
|
183
195
|
const binding = require('@atbash/sdk-darwin-universal')
|
|
184
196
|
const bindingPackageVersion = require('@atbash/sdk-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
197
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
198
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
199
|
}
|
|
188
200
|
return binding
|
|
189
201
|
} catch (e) {
|
|
@@ -198,8 +210,8 @@ function requireNative() {
|
|
|
198
210
|
try {
|
|
199
211
|
const binding = require('@atbash/sdk-darwin-x64')
|
|
200
212
|
const bindingPackageVersion = require('@atbash/sdk-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
213
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
214
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
215
|
}
|
|
204
216
|
return binding
|
|
205
217
|
} catch (e) {
|
|
@@ -214,8 +226,8 @@ function requireNative() {
|
|
|
214
226
|
try {
|
|
215
227
|
const binding = require('@atbash/sdk-darwin-arm64')
|
|
216
228
|
const bindingPackageVersion = require('@atbash/sdk-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
229
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
230
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
231
|
}
|
|
220
232
|
return binding
|
|
221
233
|
} catch (e) {
|
|
@@ -234,8 +246,8 @@ function requireNative() {
|
|
|
234
246
|
try {
|
|
235
247
|
const binding = require('@atbash/sdk-freebsd-x64')
|
|
236
248
|
const bindingPackageVersion = require('@atbash/sdk-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
249
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
250
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
251
|
}
|
|
240
252
|
return binding
|
|
241
253
|
} catch (e) {
|
|
@@ -250,8 +262,8 @@ function requireNative() {
|
|
|
250
262
|
try {
|
|
251
263
|
const binding = require('@atbash/sdk-freebsd-arm64')
|
|
252
264
|
const bindingPackageVersion = require('@atbash/sdk-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
265
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
267
|
}
|
|
256
268
|
return binding
|
|
257
269
|
} catch (e) {
|
|
@@ -271,8 +283,8 @@ function requireNative() {
|
|
|
271
283
|
try {
|
|
272
284
|
const binding = require('@atbash/sdk-linux-x64-musl')
|
|
273
285
|
const bindingPackageVersion = require('@atbash/sdk-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
286
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
288
|
}
|
|
277
289
|
return binding
|
|
278
290
|
} catch (e) {
|
|
@@ -287,8 +299,8 @@ function requireNative() {
|
|
|
287
299
|
try {
|
|
288
300
|
const binding = require('@atbash/sdk-linux-x64-gnu')
|
|
289
301
|
const bindingPackageVersion = require('@atbash/sdk-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
302
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
303
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
304
|
}
|
|
293
305
|
return binding
|
|
294
306
|
} catch (e) {
|
|
@@ -305,8 +317,8 @@ function requireNative() {
|
|
|
305
317
|
try {
|
|
306
318
|
const binding = require('@atbash/sdk-linux-arm64-musl')
|
|
307
319
|
const bindingPackageVersion = require('@atbash/sdk-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
320
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
321
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
322
|
}
|
|
311
323
|
return binding
|
|
312
324
|
} catch (e) {
|
|
@@ -321,8 +333,8 @@ function requireNative() {
|
|
|
321
333
|
try {
|
|
322
334
|
const binding = require('@atbash/sdk-linux-arm64-gnu')
|
|
323
335
|
const bindingPackageVersion = require('@atbash/sdk-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
336
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
337
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
338
|
}
|
|
327
339
|
return binding
|
|
328
340
|
} catch (e) {
|
|
@@ -339,8 +351,8 @@ function requireNative() {
|
|
|
339
351
|
try {
|
|
340
352
|
const binding = require('@atbash/sdk-linux-arm-musleabihf')
|
|
341
353
|
const bindingPackageVersion = require('@atbash/sdk-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
354
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
355
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
356
|
}
|
|
345
357
|
return binding
|
|
346
358
|
} catch (e) {
|
|
@@ -355,8 +367,8 @@ function requireNative() {
|
|
|
355
367
|
try {
|
|
356
368
|
const binding = require('@atbash/sdk-linux-arm-gnueabihf')
|
|
357
369
|
const bindingPackageVersion = require('@atbash/sdk-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
370
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
371
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
372
|
}
|
|
361
373
|
return binding
|
|
362
374
|
} catch (e) {
|
|
@@ -373,8 +385,8 @@ function requireNative() {
|
|
|
373
385
|
try {
|
|
374
386
|
const binding = require('@atbash/sdk-linux-loong64-musl')
|
|
375
387
|
const bindingPackageVersion = require('@atbash/sdk-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
388
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
389
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
390
|
}
|
|
379
391
|
return binding
|
|
380
392
|
} catch (e) {
|
|
@@ -389,8 +401,8 @@ function requireNative() {
|
|
|
389
401
|
try {
|
|
390
402
|
const binding = require('@atbash/sdk-linux-loong64-gnu')
|
|
391
403
|
const bindingPackageVersion = require('@atbash/sdk-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
404
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
405
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
406
|
}
|
|
395
407
|
return binding
|
|
396
408
|
} catch (e) {
|
|
@@ -407,8 +419,8 @@ function requireNative() {
|
|
|
407
419
|
try {
|
|
408
420
|
const binding = require('@atbash/sdk-linux-riscv64-musl')
|
|
409
421
|
const bindingPackageVersion = require('@atbash/sdk-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
422
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
423
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
424
|
}
|
|
413
425
|
return binding
|
|
414
426
|
} catch (e) {
|
|
@@ -423,8 +435,8 @@ function requireNative() {
|
|
|
423
435
|
try {
|
|
424
436
|
const binding = require('@atbash/sdk-linux-riscv64-gnu')
|
|
425
437
|
const bindingPackageVersion = require('@atbash/sdk-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
438
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
439
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
440
|
}
|
|
429
441
|
return binding
|
|
430
442
|
} catch (e) {
|
|
@@ -440,8 +452,8 @@ function requireNative() {
|
|
|
440
452
|
try {
|
|
441
453
|
const binding = require('@atbash/sdk-linux-ppc64-gnu')
|
|
442
454
|
const bindingPackageVersion = require('@atbash/sdk-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
455
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
456
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
457
|
}
|
|
446
458
|
return binding
|
|
447
459
|
} catch (e) {
|
|
@@ -456,8 +468,8 @@ function requireNative() {
|
|
|
456
468
|
try {
|
|
457
469
|
const binding = require('@atbash/sdk-linux-s390x-gnu')
|
|
458
470
|
const bindingPackageVersion = require('@atbash/sdk-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
471
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
472
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
473
|
}
|
|
462
474
|
return binding
|
|
463
475
|
} catch (e) {
|
|
@@ -476,8 +488,8 @@ function requireNative() {
|
|
|
476
488
|
try {
|
|
477
489
|
const binding = require('@atbash/sdk-openharmony-arm64')
|
|
478
490
|
const bindingPackageVersion = require('@atbash/sdk-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
491
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
492
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
493
|
}
|
|
482
494
|
return binding
|
|
483
495
|
} catch (e) {
|
|
@@ -492,8 +504,8 @@ function requireNative() {
|
|
|
492
504
|
try {
|
|
493
505
|
const binding = require('@atbash/sdk-openharmony-x64')
|
|
494
506
|
const bindingPackageVersion = require('@atbash/sdk-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
507
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
508
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
509
|
}
|
|
498
510
|
return binding
|
|
499
511
|
} catch (e) {
|
|
@@ -508,8 +520,8 @@ function requireNative() {
|
|
|
508
520
|
try {
|
|
509
521
|
const binding = require('@atbash/sdk-openharmony-arm')
|
|
510
522
|
const bindingPackageVersion = require('@atbash/sdk-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
523
|
+
if (bindingPackageVersion !== '0.12.0-dev.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
524
|
+
throw new Error(`Native binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
525
|
}
|
|
514
526
|
return binding
|
|
515
527
|
} catch (e) {
|
|
@@ -523,47 +535,165 @@ function requireNative() {
|
|
|
523
535
|
}
|
|
524
536
|
}
|
|
525
537
|
|
|
526
|
-
|
|
538
|
+
function createLoadErrorChain(errors) {
|
|
539
|
+
return errors.reduce((previous, current) => {
|
|
540
|
+
let message
|
|
541
|
+
try {
|
|
542
|
+
message =
|
|
543
|
+
current && typeof current.message === 'string'
|
|
544
|
+
? current.message
|
|
545
|
+
: String(current)
|
|
546
|
+
} catch {
|
|
547
|
+
message = 'Unknown error'
|
|
548
|
+
}
|
|
549
|
+
const error = new Error(message)
|
|
550
|
+
error.cause = previous
|
|
551
|
+
return error
|
|
552
|
+
}, null)
|
|
553
|
+
}
|
|
527
554
|
|
|
528
555
|
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
529
556
|
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
530
|
-
// 'true' →
|
|
531
|
-
// 'error' →
|
|
557
|
+
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
558
|
+
// 'error' → require WASI without initializing a native fallback
|
|
532
559
|
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
533
560
|
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
534
561
|
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
562
|
+
//
|
|
563
|
+
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
564
|
+
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
565
|
+
const __napiWasiFlavors = ['wasm32-wasi']
|
|
566
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
567
|
+
const __napiWasiFlavorRequested =
|
|
568
|
+
typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
569
|
+
if (
|
|
570
|
+
__napiWasiFlavorRequested &&
|
|
571
|
+
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
572
|
+
) {
|
|
573
|
+
throw new Error(
|
|
574
|
+
'Unsupported WASI flavor "' +
|
|
575
|
+
__napiWasiFlavor +
|
|
576
|
+
'". Available flavors: ' +
|
|
577
|
+
__napiWasiFlavors.join(', '),
|
|
578
|
+
)
|
|
579
|
+
}
|
|
580
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
535
581
|
const forceWasi =
|
|
536
|
-
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
582
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
583
|
+
forceWasiError ||
|
|
584
|
+
__napiWasiFlavorRequested
|
|
585
|
+
|
|
586
|
+
if (!forceWasi) {
|
|
587
|
+
nativeBinding = requireNative()
|
|
588
|
+
}
|
|
537
589
|
|
|
538
590
|
if (!nativeBinding || forceWasi) {
|
|
539
591
|
let wasiBinding = null
|
|
540
|
-
let
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
592
|
+
let wasiBindingLoaded = false
|
|
593
|
+
const wasiBindingErrors = []
|
|
594
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
595
|
+
try {
|
|
596
|
+
require.resolve(specifier)
|
|
597
|
+
} catch (resolveError) {
|
|
598
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
599
|
+
throw resolveError
|
|
600
|
+
}
|
|
601
|
+
if (isPackage) {
|
|
602
|
+
try {
|
|
603
|
+
require.resolve(specifier + '/package.json')
|
|
604
|
+
} catch (packageError) {
|
|
605
|
+
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
606
|
+
return resolveError
|
|
607
|
+
}
|
|
608
|
+
// An exports restriction proves the package exists even when its
|
|
609
|
+
// package.json is not public. Preserve the root resolution failure.
|
|
610
|
+
throw resolveError
|
|
611
|
+
}
|
|
612
|
+
// The package exists but its main/export target is broken.
|
|
613
|
+
throw resolveError
|
|
614
|
+
}
|
|
615
|
+
return resolveError
|
|
547
616
|
}
|
|
617
|
+
if (localArtifacts) {
|
|
618
|
+
let artifactError = null
|
|
619
|
+
for (let i = 0; i < localArtifacts.length; i++) {
|
|
620
|
+
try {
|
|
621
|
+
require.resolve(localArtifacts[i])
|
|
622
|
+
return null
|
|
623
|
+
} catch (resolveError) {
|
|
624
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
625
|
+
throw resolveError
|
|
626
|
+
}
|
|
627
|
+
artifactError = resolveError
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return artifactError
|
|
631
|
+
}
|
|
632
|
+
return null
|
|
548
633
|
}
|
|
549
|
-
if (!
|
|
634
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
635
|
+
let candidateError = null
|
|
636
|
+
let candidateFailed = false
|
|
550
637
|
try {
|
|
551
|
-
|
|
552
|
-
|
|
638
|
+
candidateError = __napiWasiResolveCandidate('./atbash.wasi.cjs', false, ['./atbash.wasm32-wasi.debug.wasm', './atbash.wasm32-wasi.wasm'])
|
|
639
|
+
candidateFailed = candidateError !== null
|
|
640
|
+
if (!candidateFailed) {
|
|
641
|
+
wasiBinding = require('./atbash.wasi.cjs')
|
|
642
|
+
nativeBinding = wasiBinding
|
|
643
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
644
|
+
wasiBindingLoaded = true
|
|
645
|
+
}
|
|
553
646
|
} catch (err) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
647
|
+
candidateError = err
|
|
648
|
+
candidateFailed = true
|
|
649
|
+
}
|
|
650
|
+
if (candidateFailed) {
|
|
651
|
+
wasiBindingErrors.push(candidateError)
|
|
652
|
+
loadErrors.push(candidateError)
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
656
|
+
let candidateError = null
|
|
657
|
+
let candidateFailed = false
|
|
658
|
+
try {
|
|
659
|
+
candidateError = __napiWasiResolveCandidate('@atbash/sdk-wasm32-wasi', true, undefined)
|
|
660
|
+
candidateFailed = candidateError !== null
|
|
661
|
+
if (!candidateFailed) {
|
|
662
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
663
|
+
const bindingPackageVersion = require('@atbash/sdk-wasm32-wasi/package.json').version
|
|
664
|
+
if (bindingPackageVersion !== '0.12.0-dev.0') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 0.12.0-dev.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
|
+
}
|
|
559
667
|
}
|
|
560
|
-
|
|
668
|
+
wasiBinding = require('@atbash/sdk-wasm32-wasi')
|
|
669
|
+
nativeBinding = wasiBinding
|
|
670
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
671
|
+
wasiBindingLoaded = true
|
|
561
672
|
}
|
|
673
|
+
} catch (err) {
|
|
674
|
+
candidateError = err
|
|
675
|
+
candidateFailed = true
|
|
676
|
+
}
|
|
677
|
+
if (candidateFailed) {
|
|
678
|
+
wasiBindingErrors.push(candidateError)
|
|
679
|
+
loadErrors.push(candidateError)
|
|
562
680
|
}
|
|
563
681
|
}
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
|
|
682
|
+
if (
|
|
683
|
+
!wasiBindingLoaded &&
|
|
684
|
+
forceWasi &&
|
|
685
|
+
!forceWasiError &&
|
|
686
|
+
!__napiWasiFlavorRequested
|
|
687
|
+
) {
|
|
688
|
+
nativeBinding = requireNative()
|
|
689
|
+
}
|
|
690
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
691
|
+
const error = new Error(
|
|
692
|
+
__napiWasiFlavorRequested
|
|
693
|
+
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
694
|
+
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
695
|
+
)
|
|
696
|
+
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
567
697
|
throw error
|
|
568
698
|
}
|
|
569
699
|
}
|
|
@@ -577,15 +707,76 @@ if (!nativeBinding) {
|
|
|
577
707
|
)
|
|
578
708
|
// assign instead of the `new Error(message, { cause })` options form,
|
|
579
709
|
// which Node < 16.9 silently ignores
|
|
580
|
-
error.cause = loadErrors
|
|
581
|
-
cur.cause = err
|
|
582
|
-
return cur
|
|
583
|
-
})
|
|
710
|
+
error.cause = createLoadErrorChain(loadErrors)
|
|
584
711
|
throw error
|
|
585
712
|
}
|
|
586
713
|
throw new Error(`Failed to load native binding`)
|
|
587
714
|
}
|
|
588
715
|
|
|
716
|
+
function __napiStampBindingTarget(exportsObject, target) {
|
|
717
|
+
if (
|
|
718
|
+
Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
|
|
719
|
+
) {
|
|
720
|
+
if (exportsObject.__napiBindingTarget === target) {
|
|
721
|
+
// Already ours: the root entry aliases the object it loaded, so a WASI
|
|
722
|
+
// fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
|
|
723
|
+
// is a generated loader — arrives already stamped with this same value.
|
|
724
|
+
return target
|
|
725
|
+
}
|
|
726
|
+
const error = new Error(
|
|
727
|
+
'`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
|
|
728
|
+
)
|
|
729
|
+
error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
|
|
730
|
+
throw error
|
|
731
|
+
}
|
|
732
|
+
if (!Object.isExtensible(exportsObject)) {
|
|
733
|
+
// A `#[napi(module_exports)]` hook may seal or freeze this object
|
|
734
|
+
// (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
|
|
735
|
+
// never a reason to fail an otherwise successful load, so the stamp is
|
|
736
|
+
// skipped. What a consumer still sees then follows the entry point: the
|
|
737
|
+
// browser and deferred loaders declare `__napiBindingTarget` at module
|
|
738
|
+
// level and go on reporting it, while the CommonJS entries hand back this
|
|
739
|
+
// very object as `module.exports`, so there the value is absent.
|
|
740
|
+
return target
|
|
741
|
+
}
|
|
742
|
+
try {
|
|
743
|
+
// [[Define]], not [[Set]]: an ordinary assignment walks the prototype
|
|
744
|
+
// chain, so an inherited accessor could swallow the value or throw and
|
|
745
|
+
// fail an otherwise successful load. The descriptor is what a successful
|
|
746
|
+
// assignment would have produced.
|
|
747
|
+
Object.defineProperty(exportsObject, '__napiBindingTarget', {
|
|
748
|
+
configurable: true,
|
|
749
|
+
enumerable: true,
|
|
750
|
+
value: target,
|
|
751
|
+
writable: true,
|
|
752
|
+
})
|
|
753
|
+
} catch {
|
|
754
|
+
// Same rule as the non-extensible skip above: reporting the artifact is
|
|
755
|
+
// metadata, never a reason to fail an otherwise successful load. An exotic
|
|
756
|
+
// object (a Proxy whose defineProperty trap refuses) is skipped, not
|
|
757
|
+
// thrown over.
|
|
758
|
+
}
|
|
759
|
+
// The CommonJS loaders assign this return value so `cjs-module-lexer` — and
|
|
760
|
+
// therefore Node's CJS -> ESM named export detection — can see
|
|
761
|
+
// `__napiBindingTarget` statically.
|
|
762
|
+
return target
|
|
763
|
+
}
|
|
764
|
+
// Stamp before the alias, not after. The guard only reads `nativeBinding`
|
|
765
|
+
// (`hasOwnProperty` plus a comparison), which is safe against any addon
|
|
766
|
+
// accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
|
|
767
|
+
// expose a getter reporting this very value and a setter that throws. So the
|
|
768
|
+
// assignment lands on the loader's own `module.exports`, still the original
|
|
769
|
+
// object here, and the alias below replaces it.
|
|
770
|
+
//
|
|
771
|
+
// The assignment is what keeps the marker a statically visible CommonJS export:
|
|
772
|
+
// `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
|
|
773
|
+
// a bare call, and the later `module.exports = nativeBinding` does not undo the
|
|
774
|
+
// detection. The assignment itself always succeeds — its target is this
|
|
775
|
+
// loader's own, still extensible `module.exports` — and the alias below then
|
|
776
|
+
// discards the value it wrote. What a consumer reads is whatever the guard put
|
|
777
|
+
// on `nativeBinding`, so on a frozen binding, where the guard skips, the
|
|
778
|
+
// linked import resolves to `undefined`.
|
|
779
|
+
module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
|
|
589
780
|
module.exports = nativeBinding
|
|
590
781
|
module.exports.ARG_AGENT_PUBKEY = nativeBinding.ARG_AGENT_PUBKEY
|
|
591
782
|
module.exports.ARG_FILE_PATH = nativeBinding.ARG_FILE_PATH
|