@napi-rs/image 1.11.2 → 1.12.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.
Files changed (3) hide show
  1. package/index.d.ts +41 -46
  2. package/index.js +118 -54
  3. package/package.json +17 -17
package/index.d.ts CHANGED
@@ -386,12 +386,7 @@ export declare enum PngRowFilter {
386
386
  Sub = 1,
387
387
  Up = 2,
388
388
  Average = 3,
389
- Paeth = 4,
390
- MinSum = 5,
391
- Entropy = 6,
392
- Bigrams = 7,
393
- BigEnt = 8,
394
- Brute = 9
389
+ Paeth = 4
395
390
  }
396
391
 
397
392
  /**
@@ -412,26 +407,26 @@ export declare enum PngRowFilter {
412
407
  *
413
408
  * <!-- NOTE: To test new test images locally, replace the GitHub path with `../../../docs/` -->
414
409
  * <div style="display: flex; flex-wrap: wrap; align-items: flex-start;">
415
- * <div style="margin: 0 8px 8px 0;">
416
- * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-near.png" title="Nearest"><br>
417
- * Nearest Neighbor
418
- * </div>
419
- * <div style="margin: 0 8px 8px 0;">
420
- * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-tri.png" title="Triangle"><br>
421
- * Linear: Triangle
422
- * </div>
423
- * <div style="margin: 0 8px 8px 0;">
424
- * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-cmr.png" title="CatmullRom"><br>
425
- * Cubic: Catmull-Rom
426
- * </div>
427
- * <div style="margin: 0 8px 8px 0;">
428
- * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-gauss.png" title="Gaussian"><br>
429
- * Gaussian
430
- * </div>
431
- * <div style="margin: 0 8px 8px 0;">
432
- * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-lcz2.png" title="Lanczos3"><br>
433
- * Lanczos with window 3
434
- * </div>
410
+ * <div style="margin: 0 8px 8px 0;">
411
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-near.png" title="Nearest"><br>
412
+ * Nearest Neighbor
413
+ * </div>
414
+ * <div style="margin: 0 8px 8px 0;">
415
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-tri.png" title="Triangle"><br>
416
+ * Linear: Triangle
417
+ * </div>
418
+ * <div style="margin: 0 8px 8px 0;">
419
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-cmr.png" title="CatmullRom"><br>
420
+ * Cubic: Catmull-Rom
421
+ * </div>
422
+ * <div style="margin: 0 8px 8px 0;">
423
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-gauss.png" title="Gaussian"><br>
424
+ * Gaussian
425
+ * </div>
426
+ * <div style="margin: 0 8px 8px 0;">
427
+ * <img src="https://raw.githubusercontent.com/image-rs/image/master/examples/scaledown/scaledown-test-lcz2.png" title="Lanczos3"><br>
428
+ * Lanczos with window 3
429
+ * </div>
435
430
  * </div>
436
431
  *
437
432
  * ## Speed
@@ -440,26 +435,26 @@ export declare enum PngRowFilter {
440
435
  * i7-4770 CPU with Rust 1.37 in release mode:
441
436
  *
442
437
  * <table style="width: auto;">
443
- * <tr>
444
- * <th>Nearest</th>
445
- * <td>31 ms</td>
446
- * </tr>
447
- * <tr>
448
- * <th>Triangle</th>
449
- * <td>414 ms</td>
450
- * </tr>
451
- * <tr>
452
- * <th>CatmullRom</th>
453
- * <td>817 ms</td>
454
- * </tr>
455
- * <tr>
456
- * <th>Gaussian</th>
457
- * <td>1180 ms</td>
458
- * </tr>
459
- * <tr>
460
- * <th>Lanczos3</th>
461
- * <td>1170 ms</td>
462
- * </tr>
438
+ * <tr>
439
+ * <th>Nearest</th>
440
+ * <td>31 ms</td>
441
+ * </tr>
442
+ * <tr>
443
+ * <th>Triangle</th>
444
+ * <td>414 ms</td>
445
+ * </tr>
446
+ * <tr>
447
+ * <th>CatmullRom</th>
448
+ * <td>817 ms</td>
449
+ * </tr>
450
+ * <tr>
451
+ * <th>Gaussian</th>
452
+ * <td>1180 ms</td>
453
+ * </tr>
454
+ * <tr>
455
+ * <th>Lanczos3</th>
456
+ * <td>1170 ms</td>
457
+ * </tr>
463
458
  * </table>
464
459
  */
465
460
  export declare enum ResizeFilterType {
package/index.js CHANGED
@@ -3,9 +3,6 @@
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
6
  const { readFileSync } = require('node:fs')
10
7
  let nativeBinding = null
11
8
  const loadErrors = []
@@ -66,7 +63,7 @@ const isMuslFromChildProcess = () => {
66
63
  function requireNative() {
67
64
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
68
65
  try {
69
- nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
66
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
70
67
  } catch (err) {
71
68
  loadErrors.push(err)
72
69
  }
@@ -80,8 +77,8 @@ function requireNative() {
80
77
  try {
81
78
  const binding = require('@napi-rs/image-android-arm64')
82
79
  const bindingPackageVersion = require('@napi-rs/image-android-arm64/package.json').version
83
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-android-arm-eabi')
98
95
  const bindingPackageVersion = require('@napi-rs/image-android-arm-eabi/package.json').version
99
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
109
+ try {
110
+ return require('./image.win32-x64-gnu.node')
111
+ } catch (e) {
112
+ loadErrors.push(e)
113
+ }
111
114
  try {
115
+ const binding = require('@napi-rs/image-win32-x64-gnu')
116
+ const bindingPackageVersion = require('@napi-rs/image-win32-x64-gnu/package.json').version
117
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('./image.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('@napi-rs/image-win32-x64-msvc')
118
132
  const bindingPackageVersion = require('@napi-rs/image-win32-x64-msvc/package.json').version
119
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('./image.win32-ia32-msvc.node')
@@ -132,8 +147,8 @@ function requireNative() {
132
147
  try {
133
148
  const binding = require('@napi-rs/image-win32-ia32-msvc')
134
149
  const bindingPackageVersion = require('@napi-rs/image-win32-ia32-msvc/package.json').version
135
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-win32-arm64-msvc')
150
165
  const bindingPackageVersion = require('@napi-rs/image-win32-arm64-msvc/package.json').version
151
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-darwin-universal')
169
184
  const bindingPackageVersion = require('@napi-rs/image-darwin-universal/package.json').version
170
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-darwin-x64')
185
200
  const bindingPackageVersion = require('@napi-rs/image-darwin-x64/package.json').version
186
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-darwin-arm64')
201
216
  const bindingPackageVersion = require('@napi-rs/image-darwin-arm64/package.json').version
202
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-freebsd-x64')
221
236
  const bindingPackageVersion = require('@napi-rs/image-freebsd-x64/package.json').version
222
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-freebsd-arm64')
237
252
  const bindingPackageVersion = require('@napi-rs/image-freebsd-arm64/package.json').version
238
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-linux-x64-musl')
258
273
  const bindingPackageVersion = require('@napi-rs/image-linux-x64-musl/package.json').version
259
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-linux-x64-gnu')
274
289
  const bindingPackageVersion = require('@napi-rs/image-linux-x64-gnu/package.json').version
275
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-linux-arm64-musl')
292
307
  const bindingPackageVersion = require('@napi-rs/image-linux-arm64-musl/package.json').version
293
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-linux-arm64-gnu')
308
323
  const bindingPackageVersion = require('@napi-rs/image-linux-arm64-gnu/package.json').version
309
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 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('@napi-rs/image-linux-arm-musleabihf')
326
341
  const bindingPackageVersion = require('@napi-rs/image-linux-arm-musleabihf/package.json').version
327
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
329
344
  }
330
345
  return binding
331
346
  } catch (e) {
@@ -340,8 +355,42 @@ function requireNative() {
340
355
  try {
341
356
  const binding = require('@napi-rs/image-linux-arm-gnueabihf')
342
357
  const bindingPackageVersion = require('@napi-rs/image-linux-arm-gnueabihf/package.json').version
343
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
+ }
361
+ return binding
362
+ } catch (e) {
363
+ loadErrors.push(e)
364
+ }
365
+ }
366
+ } else if (process.arch === 'loong64') {
367
+ if (isMusl()) {
368
+ try {
369
+ return require('./image.linux-loong64-musl.node')
370
+ } catch (e) {
371
+ loadErrors.push(e)
372
+ }
373
+ try {
374
+ const binding = require('@napi-rs/image-linux-loong64-musl')
375
+ const bindingPackageVersion = require('@napi-rs/image-linux-loong64-musl/package.json').version
376
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
+ }
379
+ return binding
380
+ } catch (e) {
381
+ loadErrors.push(e)
382
+ }
383
+ } else {
384
+ try {
385
+ return require('./image.linux-loong64-gnu.node')
386
+ } catch (e) {
387
+ loadErrors.push(e)
388
+ }
389
+ try {
390
+ const binding = require('@napi-rs/image-linux-loong64-gnu')
391
+ const bindingPackageVersion = require('@napi-rs/image-linux-loong64-gnu/package.json').version
392
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
345
394
  }
346
395
  return binding
347
396
  } catch (e) {
@@ -358,8 +407,8 @@ function requireNative() {
358
407
  try {
359
408
  const binding = require('@napi-rs/image-linux-riscv64-musl')
360
409
  const bindingPackageVersion = require('@napi-rs/image-linux-riscv64-musl/package.json').version
361
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
363
412
  }
364
413
  return binding
365
414
  } catch (e) {
@@ -374,8 +423,8 @@ function requireNative() {
374
423
  try {
375
424
  const binding = require('@napi-rs/image-linux-riscv64-gnu')
376
425
  const bindingPackageVersion = require('@napi-rs/image-linux-riscv64-gnu/package.json').version
377
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
379
428
  }
380
429
  return binding
381
430
  } catch (e) {
@@ -391,8 +440,8 @@ function requireNative() {
391
440
  try {
392
441
  const binding = require('@napi-rs/image-linux-ppc64-gnu')
393
442
  const bindingPackageVersion = require('@napi-rs/image-linux-ppc64-gnu/package.json').version
394
- if (bindingPackageVersion !== '1.11.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
395
- throw new Error(`Native binding package version mismatch, expected 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
445
  }
397
446
  return binding
398
447
  } catch (e) {
@@ -407,8 +456,8 @@ function requireNative() {
407
456
  try {
408
457
  const binding = require('@napi-rs/image-linux-s390x-gnu')
409
458
  const bindingPackageVersion = require('@napi-rs/image-linux-s390x-gnu/package.json').version
410
- if (bindingPackageVersion !== '1.11.1' && 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 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
461
  }
413
462
  return binding
414
463
  } catch (e) {
@@ -427,8 +476,8 @@ function requireNative() {
427
476
  try {
428
477
  const binding = require('@napi-rs/image-openharmony-arm64')
429
478
  const bindingPackageVersion = require('@napi-rs/image-openharmony-arm64/package.json').version
430
- if (bindingPackageVersion !== '1.11.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
- throw new Error(`Native binding package version mismatch, expected 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
481
  }
433
482
  return binding
434
483
  } catch (e) {
@@ -443,8 +492,8 @@ function requireNative() {
443
492
  try {
444
493
  const binding = require('@napi-rs/image-openharmony-x64')
445
494
  const bindingPackageVersion = require('@napi-rs/image-openharmony-x64/package.json').version
446
- if (bindingPackageVersion !== '1.11.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
447
- throw new Error(`Native binding package version mismatch, expected 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
448
497
  }
449
498
  return binding
450
499
  } catch (e) {
@@ -459,8 +508,8 @@ function requireNative() {
459
508
  try {
460
509
  const binding = require('@napi-rs/image-openharmony-arm')
461
510
  const bindingPackageVersion = require('@napi-rs/image-openharmony-arm/package.json').version
462
- if (bindingPackageVersion !== '1.11.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
463
- throw new Error(`Native binding package version mismatch, expected 1.11.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '1.11.2' && 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 1.11.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
464
513
  }
465
514
  return binding
466
515
  } catch (e) {
@@ -477,22 +526,32 @@ function requireNative() {
477
526
  nativeBinding = requireNative()
478
527
 
479
528
  if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
529
+ let wasiBinding = null
530
+ let wasiBindingError = null
480
531
  try {
481
- nativeBinding = require('./image.wasi.cjs')
532
+ wasiBinding = require('./image.wasi.cjs')
533
+ nativeBinding = wasiBinding
482
534
  } catch (err) {
483
535
  if (process.env.NAPI_RS_FORCE_WASI) {
484
- loadErrors.push(err)
536
+ wasiBindingError = err
485
537
  }
486
538
  }
487
539
  if (!nativeBinding) {
488
540
  try {
489
- nativeBinding = require('@napi-rs/image-wasm32-wasi')
541
+ wasiBinding = require('@napi-rs/image-wasm32-wasi')
542
+ nativeBinding = wasiBinding
490
543
  } catch (err) {
491
544
  if (process.env.NAPI_RS_FORCE_WASI) {
545
+ wasiBindingError.cause = err
492
546
  loadErrors.push(err)
493
547
  }
494
548
  }
495
549
  }
550
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
551
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
552
+ error.cause = wasiBindingError
553
+ throw error
554
+ }
496
555
  }
497
556
 
498
557
  if (!nativeBinding) {
@@ -501,7 +560,12 @@ if (!nativeBinding) {
501
560
  `Cannot find native binding. ` +
502
561
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
503
562
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
504
- { cause: loadErrors }
563
+ {
564
+ cause: loadErrors.reduce((err, cur) => {
565
+ cur.cause = err
566
+ return cur
567
+ }),
568
+ },
505
569
  )
506
570
  }
507
571
  throw new Error(`Failed to load native binding`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/image",
3
- "version": "1.11.2",
3
+ "version": "1.12.0",
4
4
  "main": "index.js",
5
5
  "browser": "browser.js",
6
6
  "types": "index.d.ts",
@@ -72,23 +72,23 @@
72
72
  },
73
73
  "repository": "git@github.com:Brooooooklyn/Image.git",
74
74
  "devDependencies": {
75
- "@napi-rs/cli": "^3.1.2",
76
- "@napi-rs/wasm-runtime": "^1.0.3"
75
+ "@napi-rs/cli": "^3.5.0",
76
+ "@napi-rs/wasm-runtime": "^1.1.0"
77
77
  },
78
- "gitHead": "a1ebba9d4396da61a256a161595a0c15d3da88b5",
78
+ "gitHead": "71fae353ffcd590a2d9442aac3bc060f8652279b",
79
79
  "optionalDependencies": {
80
- "@napi-rs/image-darwin-x64": "1.11.2",
81
- "@napi-rs/image-win32-x64-msvc": "1.11.2",
82
- "@napi-rs/image-win32-arm64-msvc": "1.11.2",
83
- "@napi-rs/image-linux-x64-gnu": "1.11.2",
84
- "@napi-rs/image-darwin-arm64": "1.11.2",
85
- "@napi-rs/image-android-arm64": "1.11.2",
86
- "@napi-rs/image-linux-arm64-gnu": "1.11.2",
87
- "@napi-rs/image-linux-arm64-musl": "1.11.2",
88
- "@napi-rs/image-linux-arm-gnueabihf": "1.11.2",
89
- "@napi-rs/image-linux-x64-musl": "1.11.2",
90
- "@napi-rs/image-freebsd-x64": "1.11.2",
91
- "@napi-rs/image-win32-ia32-msvc": "1.11.2",
92
- "@napi-rs/image-wasm32-wasi": "1.11.2"
80
+ "@napi-rs/image-darwin-x64": "1.12.0",
81
+ "@napi-rs/image-win32-x64-msvc": "1.12.0",
82
+ "@napi-rs/image-win32-arm64-msvc": "1.12.0",
83
+ "@napi-rs/image-linux-x64-gnu": "1.12.0",
84
+ "@napi-rs/image-darwin-arm64": "1.12.0",
85
+ "@napi-rs/image-android-arm64": "1.12.0",
86
+ "@napi-rs/image-linux-arm64-gnu": "1.12.0",
87
+ "@napi-rs/image-linux-arm64-musl": "1.12.0",
88
+ "@napi-rs/image-linux-arm-gnueabihf": "1.12.0",
89
+ "@napi-rs/image-linux-x64-musl": "1.12.0",
90
+ "@napi-rs/image-freebsd-x64": "1.12.0",
91
+ "@napi-rs/image-win32-ia32-msvc": "1.12.0",
92
+ "@napi-rs/image-wasm32-wasi": "1.12.0"
93
93
  }
94
94
  }