@versatiles/versatiles-rs 5.4.0 → 5.5.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 (5) hide show
  1. package/index.cjs +112 -55
  2. package/index.js +112 -55
  3. package/package.json +13 -13
  4. package/vpl.d.ts +52 -0
  5. package/vpl.js +35 -0
package/index.cjs CHANGED
@@ -6,8 +6,13 @@ const { readFileSync } = require('fs')
6
6
  let nativeBinding = null
7
7
  // Which artifact actually loaded. The WASI fallback chain overwrites it with
8
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.
9
+ // it only runs while no WASI candidate has been loaded. The take-over check
10
+ // after the load-failure block can also set it.
10
11
  let __napiLoadedBindingTarget = 'native'
12
+ // What this loader's own `requireNative()` calls returned. The check after
13
+ // the load-failure block compares it with `nativeBinding` to tell a binding
14
+ // this loader loaded from one that code outside it put in its place.
15
+ let __napiRequiredNativeBinding = null
11
16
  const loadErrors = []
12
17
 
13
18
  const isMusl = () => {
@@ -89,8 +94,8 @@ function requireNative() {
89
94
  try {
90
95
  const binding = require('@versatiles/versatiles-rs-android-arm64')
91
96
  const bindingPackageVersion = require('@versatiles/versatiles-rs-android-arm64/package.json').version
92
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
97
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
98
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
94
99
  }
95
100
  return binding
96
101
  } catch (e) {
@@ -105,8 +110,8 @@ function requireNative() {
105
110
  try {
106
111
  const binding = require('@versatiles/versatiles-rs-android-arm-eabi')
107
112
  const bindingPackageVersion = require('@versatiles/versatiles-rs-android-arm-eabi/package.json').version
108
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
113
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
114
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
110
115
  }
111
116
  return binding
112
117
  } catch (e) {
@@ -126,8 +131,8 @@ function requireNative() {
126
131
  try {
127
132
  const binding = require('@versatiles/versatiles-rs-win32-x64-gnu')
128
133
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-x64-gnu/package.json').version
129
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
134
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
135
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
136
  }
132
137
  return binding
133
138
  } catch (e) {
@@ -142,8 +147,8 @@ function requireNative() {
142
147
  try {
143
148
  const binding = require('@versatiles/versatiles-rs-win32-x64-msvc')
144
149
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-x64-msvc/package.json').version
145
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
152
  }
148
153
  return binding
149
154
  } catch (e) {
@@ -159,8 +164,8 @@ function requireNative() {
159
164
  try {
160
165
  const binding = require('@versatiles/versatiles-rs-win32-ia32-msvc')
161
166
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-ia32-msvc/package.json').version
162
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
167
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
168
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
164
169
  }
165
170
  return binding
166
171
  } catch (e) {
@@ -175,8 +180,8 @@ function requireNative() {
175
180
  try {
176
181
  const binding = require('@versatiles/versatiles-rs-win32-arm64-msvc')
177
182
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-arm64-msvc/package.json').version
178
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
183
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
184
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
180
185
  }
181
186
  return binding
182
187
  } catch (e) {
@@ -194,8 +199,8 @@ function requireNative() {
194
199
  try {
195
200
  const binding = require('@versatiles/versatiles-rs-darwin-universal')
196
201
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-universal/package.json').version
197
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
202
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
199
204
  }
200
205
  return binding
201
206
  } catch (e) {
@@ -210,8 +215,8 @@ function requireNative() {
210
215
  try {
211
216
  const binding = require('@versatiles/versatiles-rs-darwin-x64')
212
217
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-x64/package.json').version
213
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
218
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
219
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
215
220
  }
216
221
  return binding
217
222
  } catch (e) {
@@ -226,8 +231,8 @@ function requireNative() {
226
231
  try {
227
232
  const binding = require('@versatiles/versatiles-rs-darwin-arm64')
228
233
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-arm64/package.json').version
229
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
234
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
235
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
231
236
  }
232
237
  return binding
233
238
  } catch (e) {
@@ -246,8 +251,8 @@ function requireNative() {
246
251
  try {
247
252
  const binding = require('@versatiles/versatiles-rs-freebsd-x64')
248
253
  const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-x64/package.json').version
249
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
254
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
255
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
251
256
  }
252
257
  return binding
253
258
  } catch (e) {
@@ -262,8 +267,24 @@ function requireNative() {
262
267
  try {
263
268
  const binding = require('@versatiles/versatiles-rs-freebsd-arm64')
264
269
  const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-arm64/package.json').version
265
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
270
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
271
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
272
+ }
273
+ return binding
274
+ } catch (e) {
275
+ loadErrors.push(e)
276
+ }
277
+ } else if (process.arch === 'ppc64') {
278
+ try {
279
+ return require('./versatiles.freebsd-ppc64.node')
280
+ } catch (e) {
281
+ loadErrors.push(e)
282
+ }
283
+ try {
284
+ const binding = require('@versatiles/versatiles-rs-freebsd-ppc64')
285
+ const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-ppc64/package.json').version
286
+ if (bindingPackageVersion !== '5.5.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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
267
288
  }
268
289
  return binding
269
290
  } catch (e) {
@@ -283,8 +304,8 @@ function requireNative() {
283
304
  try {
284
305
  const binding = require('@versatiles/versatiles-rs-linux-x64-musl')
285
306
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-x64-musl/package.json').version
286
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
307
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
308
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
288
309
  }
289
310
  return binding
290
311
  } catch (e) {
@@ -299,8 +320,8 @@ function requireNative() {
299
320
  try {
300
321
  const binding = require('@versatiles/versatiles-rs-linux-x64-gnu')
301
322
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-x64-gnu/package.json').version
302
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
323
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
324
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
304
325
  }
305
326
  return binding
306
327
  } catch (e) {
@@ -317,8 +338,8 @@ function requireNative() {
317
338
  try {
318
339
  const binding = require('@versatiles/versatiles-rs-linux-arm64-musl')
319
340
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm64-musl/package.json').version
320
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
341
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
342
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
322
343
  }
323
344
  return binding
324
345
  } catch (e) {
@@ -333,8 +354,8 @@ function requireNative() {
333
354
  try {
334
355
  const binding = require('@versatiles/versatiles-rs-linux-arm64-gnu')
335
356
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm64-gnu/package.json').version
336
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
357
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
358
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
338
359
  }
339
360
  return binding
340
361
  } catch (e) {
@@ -351,8 +372,8 @@ function requireNative() {
351
372
  try {
352
373
  const binding = require('@versatiles/versatiles-rs-linux-arm-musleabihf')
353
374
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm-musleabihf/package.json').version
354
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
375
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
376
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
356
377
  }
357
378
  return binding
358
379
  } catch (e) {
@@ -367,8 +388,8 @@ function requireNative() {
367
388
  try {
368
389
  const binding = require('@versatiles/versatiles-rs-linux-arm-gnueabihf')
369
390
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm-gnueabihf/package.json').version
370
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
391
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
392
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
372
393
  }
373
394
  return binding
374
395
  } catch (e) {
@@ -385,8 +406,8 @@ function requireNative() {
385
406
  try {
386
407
  const binding = require('@versatiles/versatiles-rs-linux-loong64-musl')
387
408
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-loong64-musl/package.json').version
388
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
409
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
410
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
390
411
  }
391
412
  return binding
392
413
  } catch (e) {
@@ -401,8 +422,8 @@ function requireNative() {
401
422
  try {
402
423
  const binding = require('@versatiles/versatiles-rs-linux-loong64-gnu')
403
424
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-loong64-gnu/package.json').version
404
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
425
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
426
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
406
427
  }
407
428
  return binding
408
429
  } catch (e) {
@@ -419,8 +440,8 @@ function requireNative() {
419
440
  try {
420
441
  const binding = require('@versatiles/versatiles-rs-linux-riscv64-musl')
421
442
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-riscv64-musl/package.json').version
422
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
424
445
  }
425
446
  return binding
426
447
  } catch (e) {
@@ -435,8 +456,8 @@ function requireNative() {
435
456
  try {
436
457
  const binding = require('@versatiles/versatiles-rs-linux-riscv64-gnu')
437
458
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-riscv64-gnu/package.json').version
438
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
440
461
  }
441
462
  return binding
442
463
  } catch (e) {
@@ -452,8 +473,8 @@ function requireNative() {
452
473
  try {
453
474
  const binding = require('@versatiles/versatiles-rs-linux-ppc64-gnu')
454
475
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-ppc64-gnu/package.json').version
455
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
476
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
477
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
457
478
  }
458
479
  return binding
459
480
  } catch (e) {
@@ -468,8 +489,8 @@ function requireNative() {
468
489
  try {
469
490
  const binding = require('@versatiles/versatiles-rs-linux-s390x-gnu')
470
491
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-s390x-gnu/package.json').version
471
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
492
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
493
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
473
494
  }
474
495
  return binding
475
496
  } catch (e) {
@@ -488,8 +509,8 @@ function requireNative() {
488
509
  try {
489
510
  const binding = require('@versatiles/versatiles-rs-openharmony-arm64')
490
511
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-arm64/package.json').version
491
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
512
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
513
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
493
514
  }
494
515
  return binding
495
516
  } catch (e) {
@@ -504,8 +525,8 @@ function requireNative() {
504
525
  try {
505
526
  const binding = require('@versatiles/versatiles-rs-openharmony-x64')
506
527
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-x64/package.json').version
507
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
528
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
529
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
509
530
  }
510
531
  return binding
511
532
  } catch (e) {
@@ -520,8 +541,8 @@ function requireNative() {
520
541
  try {
521
542
  const binding = require('@versatiles/versatiles-rs-openharmony-arm')
522
543
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-arm/package.json').version
523
- if (bindingPackageVersion !== '5.4.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 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
544
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
545
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
525
546
  }
526
547
  return binding
527
548
  } catch (e) {
@@ -585,6 +606,7 @@ const forceWasi =
585
606
 
586
607
  if (!forceWasi) {
587
608
  nativeBinding = requireNative()
609
+ __napiRequiredNativeBinding = nativeBinding
588
610
  }
589
611
 
590
612
  if (!nativeBinding || forceWasi) {
@@ -661,8 +683,8 @@ if (!nativeBinding || forceWasi) {
661
683
  if (!candidateFailed) {
662
684
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
663
685
  const bindingPackageVersion = require('@versatiles/versatiles-rs-wasm32-wasi/package.json').version
664
- if (bindingPackageVersion !== '5.4.0') {
665
- throw new Error(`WASI binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
686
+ if (bindingPackageVersion !== '5.5.0') {
687
+ throw new Error(`WASI binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
666
688
  }
667
689
  }
668
690
  wasiBinding = require('@versatiles/versatiles-rs-wasm32-wasi')
@@ -686,6 +708,7 @@ if (!nativeBinding || forceWasi) {
686
708
  !__napiWasiFlavorRequested
687
709
  ) {
688
710
  nativeBinding = requireNative()
711
+ __napiRequiredNativeBinding = nativeBinding
689
712
  }
690
713
  if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
691
714
  const error = new Error(
@@ -713,6 +736,40 @@ if (!nativeBinding) {
713
736
  throw new Error(`Failed to load native binding`)
714
737
  }
715
738
 
739
+ // A package can patch its own fallback in front of the load-failure check
740
+ // above, e.g. a WebContainer download through `napi-postinstall/fallback`.
741
+ // That fallback swaps `nativeBinding` for a generated WASI loader, which has
742
+ // already stamped its own flavor, while the target above still says 'native'.
743
+ // Take that flavor over, or the CommonJS stamp throws a conflict and the ESM
744
+ // export reports the wrong artifact. Three limits keep the conflict check:
745
+ // - only a binding this loader did not load itself, so a native addon whose
746
+ // `#[napi(module_exports)]` hook claims the name is still rejected;
747
+ // - only an own data property, read through its descriptor, so no addon
748
+ // getter runs here, and it must read back the same, as the stamp reads it;
749
+ // - only a flavor in `__napiWasiFlavors`, the ones this loader's own WASI
750
+ // chain can report ('wasm32-wasi' for a package without a WASI target).
751
+ // This is metadata and never fails a load: a throwing Proxy trap keeps 'native'.
752
+ if (
753
+ __napiLoadedBindingTarget === 'native' &&
754
+ nativeBinding !== __napiRequiredNativeBinding
755
+ ) {
756
+ try {
757
+ const __napiBindingTargetDescriptor = Object.getOwnPropertyDescriptor(
758
+ nativeBinding,
759
+ '__napiBindingTarget',
760
+ )
761
+ if (
762
+ __napiBindingTargetDescriptor &&
763
+ __napiWasiFlavors.indexOf(__napiBindingTargetDescriptor.value) !== -1 &&
764
+ nativeBinding.__napiBindingTarget === __napiBindingTargetDescriptor.value
765
+ ) {
766
+ __napiLoadedBindingTarget = __napiBindingTargetDescriptor.value
767
+ }
768
+ } catch {
769
+ // keep 'native'
770
+ }
771
+ }
772
+
716
773
  function __napiStampBindingTarget(exportsObject, target) {
717
774
  if (
718
775
  Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
package/index.js CHANGED
@@ -9,8 +9,13 @@ const { readFileSync } = require('fs')
9
9
  let nativeBinding = null
10
10
  // Which artifact actually loaded. The WASI fallback chain overwrites it with
11
11
  // the flavor it resolved; the late native retry below leaves it alone because
12
- // it only runs while no WASI candidate has been loaded.
12
+ // it only runs while no WASI candidate has been loaded. The take-over check
13
+ // after the load-failure block can also set it.
13
14
  let __napiLoadedBindingTarget = 'native'
15
+ // What this loader's own `requireNative()` calls returned. The check after
16
+ // the load-failure block compares it with `nativeBinding` to tell a binding
17
+ // this loader loaded from one that code outside it put in its place.
18
+ let __napiRequiredNativeBinding = null
14
19
  const loadErrors = []
15
20
 
16
21
  const isMusl = () => {
@@ -92,8 +97,8 @@ function requireNative() {
92
97
  try {
93
98
  const binding = require('@versatiles/versatiles-rs-android-arm64')
94
99
  const bindingPackageVersion = require('@versatiles/versatiles-rs-android-arm64/package.json').version
95
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
96
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
97
102
  }
98
103
  return binding
99
104
  } catch (e) {
@@ -108,8 +113,8 @@ function requireNative() {
108
113
  try {
109
114
  const binding = require('@versatiles/versatiles-rs-android-arm-eabi')
110
115
  const bindingPackageVersion = require('@versatiles/versatiles-rs-android-arm-eabi/package.json').version
111
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
112
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
116
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
117
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
113
118
  }
114
119
  return binding
115
120
  } catch (e) {
@@ -129,8 +134,8 @@ function requireNative() {
129
134
  try {
130
135
  const binding = require('@versatiles/versatiles-rs-win32-x64-gnu')
131
136
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-x64-gnu/package.json').version
132
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
133
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
134
139
  }
135
140
  return binding
136
141
  } catch (e) {
@@ -145,8 +150,8 @@ function requireNative() {
145
150
  try {
146
151
  const binding = require('@versatiles/versatiles-rs-win32-x64-msvc')
147
152
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-x64-msvc/package.json').version
148
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
149
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
153
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
154
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
155
  }
151
156
  return binding
152
157
  } catch (e) {
@@ -162,8 +167,8 @@ function requireNative() {
162
167
  try {
163
168
  const binding = require('@versatiles/versatiles-rs-win32-ia32-msvc')
164
169
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-ia32-msvc/package.json').version
165
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
166
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
167
172
  }
168
173
  return binding
169
174
  } catch (e) {
@@ -178,8 +183,8 @@ function requireNative() {
178
183
  try {
179
184
  const binding = require('@versatiles/versatiles-rs-win32-arm64-msvc')
180
185
  const bindingPackageVersion = require('@versatiles/versatiles-rs-win32-arm64-msvc/package.json').version
181
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
182
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
186
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
183
188
  }
184
189
  return binding
185
190
  } catch (e) {
@@ -197,8 +202,8 @@ function requireNative() {
197
202
  try {
198
203
  const binding = require('@versatiles/versatiles-rs-darwin-universal')
199
204
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-universal/package.json').version
200
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
201
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
202
207
  }
203
208
  return binding
204
209
  } catch (e) {
@@ -213,8 +218,8 @@ function requireNative() {
213
218
  try {
214
219
  const binding = require('@versatiles/versatiles-rs-darwin-x64')
215
220
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-x64/package.json').version
216
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
217
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
218
223
  }
219
224
  return binding
220
225
  } catch (e) {
@@ -229,8 +234,8 @@ function requireNative() {
229
234
  try {
230
235
  const binding = require('@versatiles/versatiles-rs-darwin-arm64')
231
236
  const bindingPackageVersion = require('@versatiles/versatiles-rs-darwin-arm64/package.json').version
232
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
233
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
234
239
  }
235
240
  return binding
236
241
  } catch (e) {
@@ -249,8 +254,8 @@ function requireNative() {
249
254
  try {
250
255
  const binding = require('@versatiles/versatiles-rs-freebsd-x64')
251
256
  const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-x64/package.json').version
252
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
253
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
254
259
  }
255
260
  return binding
256
261
  } catch (e) {
@@ -265,8 +270,24 @@ function requireNative() {
265
270
  try {
266
271
  const binding = require('@versatiles/versatiles-rs-freebsd-arm64')
267
272
  const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-arm64/package.json').version
268
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
269
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
273
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
274
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
275
+ }
276
+ return binding
277
+ } catch (e) {
278
+ loadErrors.push(e)
279
+ }
280
+ } else if (process.arch === 'ppc64') {
281
+ try {
282
+ return require('./versatiles.freebsd-ppc64.node')
283
+ } catch (e) {
284
+ loadErrors.push(e)
285
+ }
286
+ try {
287
+ const binding = require('@versatiles/versatiles-rs-freebsd-ppc64')
288
+ const bindingPackageVersion = require('@versatiles/versatiles-rs-freebsd-ppc64/package.json').version
289
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
270
291
  }
271
292
  return binding
272
293
  } catch (e) {
@@ -286,8 +307,8 @@ function requireNative() {
286
307
  try {
287
308
  const binding = require('@versatiles/versatiles-rs-linux-x64-musl')
288
309
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-x64-musl/package.json').version
289
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
291
312
  }
292
313
  return binding
293
314
  } catch (e) {
@@ -302,8 +323,8 @@ function requireNative() {
302
323
  try {
303
324
  const binding = require('@versatiles/versatiles-rs-linux-x64-gnu')
304
325
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-x64-gnu/package.json').version
305
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
306
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
327
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
307
328
  }
308
329
  return binding
309
330
  } catch (e) {
@@ -320,8 +341,8 @@ function requireNative() {
320
341
  try {
321
342
  const binding = require('@versatiles/versatiles-rs-linux-arm64-musl')
322
343
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm64-musl/package.json').version
323
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
324
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
325
346
  }
326
347
  return binding
327
348
  } catch (e) {
@@ -336,8 +357,8 @@ function requireNative() {
336
357
  try {
337
358
  const binding = require('@versatiles/versatiles-rs-linux-arm64-gnu')
338
359
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm64-gnu/package.json').version
339
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
340
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
361
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
341
362
  }
342
363
  return binding
343
364
  } catch (e) {
@@ -354,8 +375,8 @@ function requireNative() {
354
375
  try {
355
376
  const binding = require('@versatiles/versatiles-rs-linux-arm-musleabihf')
356
377
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm-musleabihf/package.json').version
357
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
358
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
359
380
  }
360
381
  return binding
361
382
  } catch (e) {
@@ -370,8 +391,8 @@ function requireNative() {
370
391
  try {
371
392
  const binding = require('@versatiles/versatiles-rs-linux-arm-gnueabihf')
372
393
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-arm-gnueabihf/package.json').version
373
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
374
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
375
396
  }
376
397
  return binding
377
398
  } catch (e) {
@@ -388,8 +409,8 @@ function requireNative() {
388
409
  try {
389
410
  const binding = require('@versatiles/versatiles-rs-linux-loong64-musl')
390
411
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-loong64-musl/package.json').version
391
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
392
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
393
414
  }
394
415
  return binding
395
416
  } catch (e) {
@@ -404,8 +425,8 @@ function requireNative() {
404
425
  try {
405
426
  const binding = require('@versatiles/versatiles-rs-linux-loong64-gnu')
406
427
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-loong64-gnu/package.json').version
407
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
408
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
409
430
  }
410
431
  return binding
411
432
  } catch (e) {
@@ -422,8 +443,8 @@ function requireNative() {
422
443
  try {
423
444
  const binding = require('@versatiles/versatiles-rs-linux-riscv64-musl')
424
445
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-riscv64-musl/package.json').version
425
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
426
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
446
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
427
448
  }
428
449
  return binding
429
450
  } catch (e) {
@@ -438,8 +459,8 @@ function requireNative() {
438
459
  try {
439
460
  const binding = require('@versatiles/versatiles-rs-linux-riscv64-gnu')
440
461
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-riscv64-gnu/package.json').version
441
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
442
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
462
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
464
  }
444
465
  return binding
445
466
  } catch (e) {
@@ -455,8 +476,8 @@ function requireNative() {
455
476
  try {
456
477
  const binding = require('@versatiles/versatiles-rs-linux-ppc64-gnu')
457
478
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-ppc64-gnu/package.json').version
458
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
459
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
460
481
  }
461
482
  return binding
462
483
  } catch (e) {
@@ -471,8 +492,8 @@ function requireNative() {
471
492
  try {
472
493
  const binding = require('@versatiles/versatiles-rs-linux-s390x-gnu')
473
494
  const bindingPackageVersion = require('@versatiles/versatiles-rs-linux-s390x-gnu/package.json').version
474
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
475
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '5.5.0' && 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 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
476
497
  }
477
498
  return binding
478
499
  } catch (e) {
@@ -491,8 +512,8 @@ function requireNative() {
491
512
  try {
492
513
  const binding = require('@versatiles/versatiles-rs-openharmony-arm64')
493
514
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-arm64/package.json').version
494
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
495
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
496
517
  }
497
518
  return binding
498
519
  } catch (e) {
@@ -507,8 +528,8 @@ function requireNative() {
507
528
  try {
508
529
  const binding = require('@versatiles/versatiles-rs-openharmony-x64')
509
530
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-x64/package.json').version
510
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
511
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
531
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
532
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
512
533
  }
513
534
  return binding
514
535
  } catch (e) {
@@ -523,8 +544,8 @@ function requireNative() {
523
544
  try {
524
545
  const binding = require('@versatiles/versatiles-rs-openharmony-arm')
525
546
  const bindingPackageVersion = require('@versatiles/versatiles-rs-openharmony-arm/package.json').version
526
- if (bindingPackageVersion !== '5.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
527
- throw new Error(`Native binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
547
+ if (bindingPackageVersion !== '5.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
548
+ throw new Error(`Native binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
528
549
  }
529
550
  return binding
530
551
  } catch (e) {
@@ -588,6 +609,7 @@ const forceWasi =
588
609
 
589
610
  if (!forceWasi) {
590
611
  nativeBinding = requireNative()
612
+ __napiRequiredNativeBinding = nativeBinding
591
613
  }
592
614
 
593
615
  if (!nativeBinding || forceWasi) {
@@ -664,8 +686,8 @@ if (!nativeBinding || forceWasi) {
664
686
  if (!candidateFailed) {
665
687
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
666
688
  const bindingPackageVersion = require('@versatiles/versatiles-rs-wasm32-wasi/package.json').version
667
- if (bindingPackageVersion !== '5.4.0') {
668
- throw new Error(`WASI binding package version mismatch, expected 5.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
689
+ if (bindingPackageVersion !== '5.5.0') {
690
+ throw new Error(`WASI binding package version mismatch, expected 5.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
669
691
  }
670
692
  }
671
693
  wasiBinding = require('@versatiles/versatiles-rs-wasm32-wasi')
@@ -689,6 +711,7 @@ if (!nativeBinding || forceWasi) {
689
711
  !__napiWasiFlavorRequested
690
712
  ) {
691
713
  nativeBinding = requireNative()
714
+ __napiRequiredNativeBinding = nativeBinding
692
715
  }
693
716
  if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
694
717
  const error = new Error(
@@ -716,6 +739,40 @@ if (!nativeBinding) {
716
739
  throw new Error(`Failed to load native binding`)
717
740
  }
718
741
 
742
+ // A package can patch its own fallback in front of the load-failure check
743
+ // above, e.g. a WebContainer download through `napi-postinstall/fallback`.
744
+ // That fallback swaps `nativeBinding` for a generated WASI loader, which has
745
+ // already stamped its own flavor, while the target above still says 'native'.
746
+ // Take that flavor over, or the CommonJS stamp throws a conflict and the ESM
747
+ // export reports the wrong artifact. Three limits keep the conflict check:
748
+ // - only a binding this loader did not load itself, so a native addon whose
749
+ // `#[napi(module_exports)]` hook claims the name is still rejected;
750
+ // - only an own data property, read through its descriptor, so no addon
751
+ // getter runs here, and it must read back the same, as the stamp reads it;
752
+ // - only a flavor in `__napiWasiFlavors`, the ones this loader's own WASI
753
+ // chain can report ('wasm32-wasi' for a package without a WASI target).
754
+ // This is metadata and never fails a load: a throwing Proxy trap keeps 'native'.
755
+ if (
756
+ __napiLoadedBindingTarget === 'native' &&
757
+ nativeBinding !== __napiRequiredNativeBinding
758
+ ) {
759
+ try {
760
+ const __napiBindingTargetDescriptor = Object.getOwnPropertyDescriptor(
761
+ nativeBinding,
762
+ '__napiBindingTarget',
763
+ )
764
+ if (
765
+ __napiBindingTargetDescriptor &&
766
+ __napiWasiFlavors.indexOf(__napiBindingTargetDescriptor.value) !== -1 &&
767
+ nativeBinding.__napiBindingTarget === __napiBindingTargetDescriptor.value
768
+ ) {
769
+ __napiLoadedBindingTarget = __napiBindingTargetDescriptor.value
770
+ }
771
+ } catch {
772
+ // keep 'native'
773
+ }
774
+ }
775
+
719
776
  const { SourceType, TileCoord, TileServer, TileSource, checkVpl, convert, formatVplCst, generateVplTypescript, layerStats, parseVpl, parseVplCst, stringifyVpl, stringifyVplCst } = nativeBinding
720
777
  export { SourceType }
721
778
  export { TileCoord }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versatiles/versatiles-rs",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "Node.js bindings for VersaTiles - convert, serve, and process map tiles",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -82,13 +82,13 @@
82
82
  "test:watch": "vitest",
83
83
  "test": "vitest run",
84
84
  "typecheck": "tsc --noEmit",
85
- "upgrade": "npm-check-updates -u --peer && npm install",
85
+ "upgrade": "npm-check-updates -u --peer && npm install && npm audit fix",
86
86
  "version": "napi version"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@eslint/js": "^10.0.1",
90
- "@napi-rs/cli": "^3.10.8",
91
- "@types/node": "^26.6.5",
90
+ "@napi-rs/cli": "^3.10.9",
91
+ "@types/node": "^26.6.6",
92
92
  "@vitest/ui": "^5.0.5",
93
93
  "chalk": "^6.0.1",
94
94
  "eslint": "^10.13.0",
@@ -98,18 +98,18 @@
98
98
  "tsx": "^4.23.15",
99
99
  "typedoc": "^0.28.20",
100
100
  "typescript": "^6.0.3",
101
- "typescript-eslint": "^8.71.2",
101
+ "typescript-eslint": "^8.72.1",
102
102
  "vitest": "^5.0.5"
103
103
  },
104
104
  "optionalDependencies": {
105
- "@versatiles/versatiles-rs-darwin-arm64": "5.4.0",
106
- "@versatiles/versatiles-rs-darwin-x64": "5.4.0",
107
- "@versatiles/versatiles-rs-linux-arm64-gnu": "5.4.0",
108
- "@versatiles/versatiles-rs-linux-arm64-musl": "5.4.0",
109
- "@versatiles/versatiles-rs-linux-x64-gnu": "5.4.0",
110
- "@versatiles/versatiles-rs-linux-x64-musl": "5.4.0",
111
- "@versatiles/versatiles-rs-win32-arm64-msvc": "5.4.0",
112
- "@versatiles/versatiles-rs-win32-x64-msvc": "5.4.0"
105
+ "@versatiles/versatiles-rs-darwin-arm64": "5.5.0",
106
+ "@versatiles/versatiles-rs-darwin-x64": "5.5.0",
107
+ "@versatiles/versatiles-rs-linux-arm64-gnu": "5.5.0",
108
+ "@versatiles/versatiles-rs-linux-arm64-musl": "5.5.0",
109
+ "@versatiles/versatiles-rs-linux-x64-gnu": "5.5.0",
110
+ "@versatiles/versatiles-rs-linux-x64-musl": "5.5.0",
111
+ "@versatiles/versatiles-rs-win32-arm64-msvc": "5.5.0",
112
+ "@versatiles/versatiles-rs-win32-x64-msvc": "5.5.0"
113
113
  },
114
114
  "allowScripts": {
115
115
  "esbuild": true,
package/vpl.d.ts CHANGED
@@ -444,6 +444,52 @@ export interface RemapCoordsOptions {
444
444
  */
445
445
  swapXy?: boolean;
446
446
  }
447
+ export interface DemColorizeOptions {
448
+ /** Colour stops, as `elevation:colour,…`. Defaults to a hypsometric tint. */
449
+ ramp?: string;
450
+ /** DEM encoding of the source. Defaults to the encoding its tile schema implies. */
451
+ encoding?: "mapbox" | "terrarium";
452
+ }
453
+ export interface DemHillshadeOptions {
454
+ /**
455
+ * Direction the light comes from, in degrees clockwise from north. Defaults to `335`.
456
+ *
457
+ * @default 335
458
+ */
459
+ azimuth?: number;
460
+ /**
461
+ * Intensity of the shading, from 0 to 1. Defaults to `0.5`.
462
+ *
463
+ * @default 0.5
464
+ */
465
+ exaggeration?: number;
466
+ /**
467
+ * Colour of slopes facing away from the light. Defaults to `000000`.
468
+ *
469
+ * @default 000000
470
+ */
471
+ shadowColor?: string | [number, number, number];
472
+ /**
473
+ * Colour of slopes facing the light. Defaults to `FFFFFF`.
474
+ *
475
+ * @default FFFFFF
476
+ */
477
+ highlightColor?: string | [number, number, number];
478
+ /**
479
+ * Colour that accentuates steep terrain, such as cliffs and gorges. Defaults to `000000`.
480
+ *
481
+ * @default 000000
482
+ */
483
+ accentColor?: string | [number, number, number];
484
+ /** DEM encoding of the source. Defaults to the encoding its tile schema implies. */
485
+ encoding?: "mapbox" | "terrarium";
486
+ }
487
+ export interface DemOverscaleOptions {
488
+ /** Highest zoom level to create tiles at. Defaults to the source's highest. */
489
+ levelMax?: number;
490
+ /** DEM encoding of the source. Defaults to the encoding its tile schema implies. */
491
+ encoding?: "mapbox" | "terrarium";
492
+ }
447
493
  export interface DemOverviewOptions {
448
494
  /** Zoom level to build the overview from. Defaults to the source's highest. */
449
495
  level?: number;
@@ -669,6 +715,12 @@ export declare class VPL {
669
715
  metaUpdate(options?: MetaUpdateOptions): VPL;
670
716
  /** Relabels tile coordinates, correcting a source that uses TMS row order or `z/y/x` paths. */
671
717
  remapCoords(options?: RemapCoordsOptions): VPL;
718
+ /** Colours DEM tiles by elevation, the way MapLibre's `color-relief` layer colours them. */
719
+ demColorize(options?: DemColorizeOptions): VPL;
720
+ /** Renders DEM tiles as hillshading, the way MapLibre's `hillshade` layer shades them. */
721
+ demHillshade(options?: DemHillshadeOptions): VPL;
722
+ /** Creates the DEM tiles a source lacks by upscaling the tiles it has, as heights. */
723
+ demOverscale(options?: DemOverscaleOptions): VPL;
672
724
  /** Generates lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
673
725
  demOverview(options?: DemOverviewOptions): VPL;
674
726
  /** Quantizes DEM raster tiles by rounding elevations to a per-tile power-of-two step. */
package/vpl.js CHANGED
@@ -260,6 +260,41 @@ export class VPL {
260
260
  params['swap_xy'] = options?.swapXy;
261
261
  return new VPL([...this.steps, { name: 'remap_coords', params }]);
262
262
  }
263
+ /** Colours DEM tiles by elevation, the way MapLibre's `color-relief` layer colours them. */
264
+ demColorize(options) {
265
+ const params = {};
266
+ if (options?.ramp !== undefined)
267
+ params['ramp'] = options?.ramp;
268
+ if (options?.encoding !== undefined)
269
+ params['encoding'] = options?.encoding;
270
+ return new VPL([...this.steps, { name: 'dem_colorize', params }]);
271
+ }
272
+ /** Renders DEM tiles as hillshading, the way MapLibre's `hillshade` layer shades them. */
273
+ demHillshade(options) {
274
+ const params = {};
275
+ if (options?.azimuth !== undefined)
276
+ params['azimuth'] = options?.azimuth;
277
+ if (options?.exaggeration !== undefined)
278
+ params['exaggeration'] = options?.exaggeration;
279
+ if (options?.shadowColor !== undefined)
280
+ params['shadow_color'] = options?.shadowColor;
281
+ if (options?.highlightColor !== undefined)
282
+ params['highlight_color'] = options?.highlightColor;
283
+ if (options?.accentColor !== undefined)
284
+ params['accent_color'] = options?.accentColor;
285
+ if (options?.encoding !== undefined)
286
+ params['encoding'] = options?.encoding;
287
+ return new VPL([...this.steps, { name: 'dem_hillshade', params }]);
288
+ }
289
+ /** Creates the DEM tiles a source lacks by upscaling the tiles it has, as heights. */
290
+ demOverscale(options) {
291
+ const params = {};
292
+ if (options?.levelMax !== undefined)
293
+ params['level_max'] = options?.levelMax;
294
+ if (options?.encoding !== undefined)
295
+ params['encoding'] = options?.encoding;
296
+ return new VPL([...this.steps, { name: 'dem_overscale', params }]);
297
+ }
263
298
  /** Generates lower-zoom DEM overview tiles by averaging 24-bit elevation values. */
264
299
  demOverview(options) {
265
300
  const params = {};