@bennyblader/ddk-ts 0.3.39 → 0.3.40

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/index.js CHANGED
@@ -3,10 +3,7 @@
3
3
  // @ts-nocheck
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- const { createRequire } = require('node:module')
7
- require = createRequire(__filename)
8
-
9
- const { readFileSync } = require('node:fs')
6
+ const { readFileSync } = require('fs')
10
7
  let nativeBinding = null
11
8
  const loadErrors = []
12
9
 
@@ -36,7 +33,7 @@ const isMuslFromFilesystem = () => {
36
33
 
37
34
  const isMuslFromReport = () => {
38
35
  let report = null
39
- if (typeof process.report?.getReport === 'function') {
36
+ if (process.report && typeof process.report.getReport === 'function') {
40
37
  process.report.excludeNetwork = true
41
38
  report = process.report.getReport()
42
39
  }
@@ -80,8 +77,8 @@ function requireNative() {
80
77
  try {
81
78
  const binding = require('@bennyblader/ddk-ts-android-arm64')
82
79
  const bindingPackageVersion = require('@bennyblader/ddk-ts-android-arm64/package.json').version
83
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
84
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
85
82
  }
86
83
  return binding
87
84
  } catch (e) {
@@ -96,8 +93,8 @@ function requireNative() {
96
93
  try {
97
94
  const binding = require('@bennyblader/ddk-ts-android-arm-eabi')
98
95
  const bindingPackageVersion = require('@bennyblader/ddk-ts-android-arm-eabi/package.json').version
99
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
100
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
101
98
  }
102
99
  return binding
103
100
  } catch (e) {
@@ -108,7 +105,24 @@ function requireNative() {
108
105
  }
109
106
  } else if (process.platform === 'win32') {
110
107
  if (process.arch === 'x64') {
108
+ 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
+ try {
110
+ return require('./ddk-ts.win32-x64-gnu.node')
111
+ } catch (e) {
112
+ loadErrors.push(e)
113
+ }
111
114
  try {
115
+ const binding = require('@bennyblader/ddk-ts-win32-x64-gnu')
116
+ const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-x64-gnu/package.json').version
117
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
+ }
120
+ return binding
121
+ } catch (e) {
122
+ loadErrors.push(e)
123
+ }
124
+ } else {
125
+ try {
112
126
  return require('./ddk-ts.win32-x64-msvc.node')
113
127
  } catch (e) {
114
128
  loadErrors.push(e)
@@ -116,13 +130,14 @@ function requireNative() {
116
130
  try {
117
131
  const binding = require('@bennyblader/ddk-ts-win32-x64-msvc')
118
132
  const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-x64-msvc/package.json').version
119
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
120
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
135
  }
122
136
  return binding
123
137
  } catch (e) {
124
138
  loadErrors.push(e)
125
139
  }
140
+ }
126
141
  } else if (process.arch === 'ia32') {
127
142
  try {
128
143
  return require('./ddk-ts.win32-ia32-msvc.node')
@@ -132,8 +147,8 @@ function requireNative() {
132
147
  try {
133
148
  const binding = require('@bennyblader/ddk-ts-win32-ia32-msvc')
134
149
  const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-ia32-msvc/package.json').version
135
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
136
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
152
  }
138
153
  return binding
139
154
  } catch (e) {
@@ -148,8 +163,8 @@ function requireNative() {
148
163
  try {
149
164
  const binding = require('@bennyblader/ddk-ts-win32-arm64-msvc')
150
165
  const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-arm64-msvc/package.json').version
151
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
152
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
153
168
  }
154
169
  return binding
155
170
  } catch (e) {
@@ -167,8 +182,8 @@ function requireNative() {
167
182
  try {
168
183
  const binding = require('@bennyblader/ddk-ts-darwin-universal')
169
184
  const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-universal/package.json').version
170
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
187
  }
173
188
  return binding
174
189
  } catch (e) {
@@ -183,8 +198,8 @@ function requireNative() {
183
198
  try {
184
199
  const binding = require('@bennyblader/ddk-ts-darwin-x64')
185
200
  const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-x64/package.json').version
186
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
187
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
188
203
  }
189
204
  return binding
190
205
  } catch (e) {
@@ -199,8 +214,8 @@ function requireNative() {
199
214
  try {
200
215
  const binding = require('@bennyblader/ddk-ts-darwin-arm64')
201
216
  const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-arm64/package.json').version
202
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
203
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
204
219
  }
205
220
  return binding
206
221
  } catch (e) {
@@ -219,8 +234,8 @@ function requireNative() {
219
234
  try {
220
235
  const binding = require('@bennyblader/ddk-ts-freebsd-x64')
221
236
  const bindingPackageVersion = require('@bennyblader/ddk-ts-freebsd-x64/package.json').version
222
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
223
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
224
239
  }
225
240
  return binding
226
241
  } catch (e) {
@@ -235,8 +250,8 @@ function requireNative() {
235
250
  try {
236
251
  const binding = require('@bennyblader/ddk-ts-freebsd-arm64')
237
252
  const bindingPackageVersion = require('@bennyblader/ddk-ts-freebsd-arm64/package.json').version
238
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
239
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
240
255
  }
241
256
  return binding
242
257
  } catch (e) {
@@ -256,8 +271,8 @@ function requireNative() {
256
271
  try {
257
272
  const binding = require('@bennyblader/ddk-ts-linux-x64-musl')
258
273
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-x64-musl/package.json').version
259
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
260
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
261
276
  }
262
277
  return binding
263
278
  } catch (e) {
@@ -272,8 +287,8 @@ function requireNative() {
272
287
  try {
273
288
  const binding = require('@bennyblader/ddk-ts-linux-x64-gnu')
274
289
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-x64-gnu/package.json').version
275
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
276
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
277
292
  }
278
293
  return binding
279
294
  } catch (e) {
@@ -290,8 +305,8 @@ function requireNative() {
290
305
  try {
291
306
  const binding = require('@bennyblader/ddk-ts-linux-arm64-musl')
292
307
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm64-musl/package.json').version
293
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
294
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
295
310
  }
296
311
  return binding
297
312
  } catch (e) {
@@ -306,8 +321,8 @@ function requireNative() {
306
321
  try {
307
322
  const binding = require('@bennyblader/ddk-ts-linux-arm64-gnu')
308
323
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm64-gnu/package.json').version
309
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
310
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
311
326
  }
312
327
  return binding
313
328
  } catch (e) {
@@ -324,8 +339,8 @@ function requireNative() {
324
339
  try {
325
340
  const binding = require('@bennyblader/ddk-ts-linux-arm-musleabihf')
326
341
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm-musleabihf/package.json').version
327
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
328
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
329
344
  }
330
345
  return binding
331
346
  } catch (e) {
@@ -340,8 +355,8 @@ function requireNative() {
340
355
  try {
341
356
  const binding = require('@bennyblader/ddk-ts-linux-arm-gnueabihf')
342
357
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm-gnueabihf/package.json').version
343
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
344
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
345
360
  }
346
361
  return binding
347
362
  } catch (e) {
@@ -358,8 +373,8 @@ function requireNative() {
358
373
  try {
359
374
  const binding = require('@bennyblader/ddk-ts-linux-loong64-musl')
360
375
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-loong64-musl/package.json').version
361
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
362
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
363
378
  }
364
379
  return binding
365
380
  } catch (e) {
@@ -374,8 +389,8 @@ function requireNative() {
374
389
  try {
375
390
  const binding = require('@bennyblader/ddk-ts-linux-loong64-gnu')
376
391
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-loong64-gnu/package.json').version
377
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
378
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
379
394
  }
380
395
  return binding
381
396
  } catch (e) {
@@ -392,8 +407,8 @@ function requireNative() {
392
407
  try {
393
408
  const binding = require('@bennyblader/ddk-ts-linux-riscv64-musl')
394
409
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-riscv64-musl/package.json').version
395
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
396
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
397
412
  }
398
413
  return binding
399
414
  } catch (e) {
@@ -408,8 +423,8 @@ function requireNative() {
408
423
  try {
409
424
  const binding = require('@bennyblader/ddk-ts-linux-riscv64-gnu')
410
425
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-riscv64-gnu/package.json').version
411
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
412
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
413
428
  }
414
429
  return binding
415
430
  } catch (e) {
@@ -425,8 +440,8 @@ function requireNative() {
425
440
  try {
426
441
  const binding = require('@bennyblader/ddk-ts-linux-ppc64-gnu')
427
442
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-ppc64-gnu/package.json').version
428
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
429
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
445
  }
431
446
  return binding
432
447
  } catch (e) {
@@ -441,8 +456,8 @@ function requireNative() {
441
456
  try {
442
457
  const binding = require('@bennyblader/ddk-ts-linux-s390x-gnu')
443
458
  const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-s390x-gnu/package.json').version
444
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
445
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
446
461
  }
447
462
  return binding
448
463
  } catch (e) {
@@ -461,8 +476,8 @@ function requireNative() {
461
476
  try {
462
477
  const binding = require('@bennyblader/ddk-ts-openharmony-arm64')
463
478
  const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-arm64/package.json').version
464
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
465
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
466
481
  }
467
482
  return binding
468
483
  } catch (e) {
@@ -477,8 +492,8 @@ function requireNative() {
477
492
  try {
478
493
  const binding = require('@bennyblader/ddk-ts-openharmony-x64')
479
494
  const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-x64/package.json').version
480
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
481
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
482
497
  }
483
498
  return binding
484
499
  } catch (e) {
@@ -493,8 +508,8 @@ function requireNative() {
493
508
  try {
494
509
  const binding = require('@bennyblader/ddk-ts-openharmony-arm')
495
510
  const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-arm/package.json').version
496
- if (bindingPackageVersion !== '0.3.39' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
497
- throw new Error(`Native binding package version mismatch, expected 0.3.39 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.3.40' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.3.40 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
498
513
  }
499
514
  return binding
500
515
  } catch (e) {
@@ -510,24 +525,38 @@ function requireNative() {
510
525
 
511
526
  nativeBinding = requireNative()
512
527
 
513
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
528
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
529
+ // unset / any other value → native binding preferred, WASI is only a fallback
530
+ // 'true' → force WASI fallback even if native loaded
531
+ // 'error' → force WASI and throw if no WASI binding is found
532
+ // Treating any non-empty string as truthy (the historical behavior) meant
533
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
534
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
535
+ const forceWasi =
536
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
537
+
538
+ if (!nativeBinding || forceWasi) {
514
539
  let wasiBinding = null
515
540
  let wasiBindingError = null
516
541
  try {
517
542
  wasiBinding = require('./ddk-ts.wasi.cjs')
518
543
  nativeBinding = wasiBinding
519
544
  } catch (err) {
520
- if (process.env.NAPI_RS_FORCE_WASI) {
545
+ if (forceWasi) {
521
546
  wasiBindingError = err
522
547
  }
523
548
  }
524
- if (!nativeBinding) {
549
+ if (!nativeBinding || forceWasi) {
525
550
  try {
526
551
  wasiBinding = require('@bennyblader/ddk-ts-wasm32-wasi')
527
552
  nativeBinding = wasiBinding
528
553
  } catch (err) {
529
- if (process.env.NAPI_RS_FORCE_WASI) {
530
- wasiBindingError.cause = err
554
+ if (forceWasi) {
555
+ if (!wasiBindingError) {
556
+ wasiBindingError = err
557
+ } else {
558
+ wasiBindingError.cause = err
559
+ }
531
560
  loadErrors.push(err)
532
561
  }
533
562
  }
@@ -541,17 +570,18 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
541
570
 
542
571
  if (!nativeBinding) {
543
572
  if (loadErrors.length > 0) {
544
- throw new Error(
573
+ const error = new Error(
545
574
  `Cannot find native binding. ` +
546
575
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
547
576
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
548
- {
549
- cause: loadErrors.reduce((err, cur) => {
550
- cur.cause = err
551
- return cur
552
- }),
553
- },
554
577
  )
578
+ // assign instead of the `new Error(message, { cause })` options form,
579
+ // which Node < 16.9 silently ignores
580
+ error.cause = loadErrors.reduce((err, cur) => {
581
+ cur.cause = err
582
+ return cur
583
+ })
584
+ throw error
555
585
  }
556
586
  throw new Error(`Failed to load native binding`)
557
587
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bennyblader/ddk-ts",
3
- "version": "0.3.39",
3
+ "version": "0.3.40",
4
4
  "description": "dlcdevkit typescript bindings",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  "binaryName": "ddk-ts",
22
22
  "packageName": "@bennyblader/ddk-ts",
23
23
  "targets": [
24
- "aarch64-apple-darwin"
24
+ "aarch64-apple-darwin",
25
+ "x86_64-unknown-linux-gnu"
25
26
  ]
26
27
  },
27
28
  "engines": {
@@ -78,6 +79,7 @@
78
79
  ],
79
80
  "packageManager": "pnpm@10.14.0",
80
81
  "optionalDependencies": {
81
- "@bennyblader/ddk-ts-darwin-arm64": "0.3.39"
82
+ "@bennyblader/ddk-ts-darwin-arm64": "0.3.40",
83
+ "@bennyblader/ddk-ts-linux-x64-gnu": "0.3.40"
82
84
  }
83
85
  }
Binary file