@napi-rs/webcodecs 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/index.d.ts +157 -129
- package/index.js +376 -106
- package/package.json +40 -62
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
const { readFileSync } = require('
|
|
6
|
+
const { readFileSync } = require('fs')
|
|
7
7
|
let nativeBinding = null
|
|
8
8
|
const loadErrors = []
|
|
9
9
|
|
|
@@ -33,7 +33,7 @@ const isMuslFromFilesystem = () => {
|
|
|
33
33
|
|
|
34
34
|
const isMuslFromReport = () => {
|
|
35
35
|
let report = null
|
|
36
|
-
if (typeof process.report
|
|
36
|
+
if (process.report && typeof process.report.getReport === 'function') {
|
|
37
37
|
process.report.excludeNetwork = true
|
|
38
38
|
report = process.report.getReport()
|
|
39
39
|
}
|
|
@@ -63,7 +63,7 @@ const isMuslFromChildProcess = () => {
|
|
|
63
63
|
function requireNative() {
|
|
64
64
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
65
|
try {
|
|
66
|
-
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
66
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
67
67
|
} catch (err) {
|
|
68
68
|
loadErrors.push(err)
|
|
69
69
|
}
|
|
@@ -77,8 +77,14 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@napi-rs/webcodecs-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@napi-rs/webcodecs-android-arm64/package.json').version
|
|
80
|
-
if (
|
|
81
|
-
|
|
80
|
+
if (
|
|
81
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
82
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
83
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
84
|
+
) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
87
|
+
)
|
|
82
88
|
}
|
|
83
89
|
return binding
|
|
84
90
|
} catch (e) {
|
|
@@ -93,8 +99,14 @@ function requireNative() {
|
|
|
93
99
|
try {
|
|
94
100
|
const binding = require('@napi-rs/webcodecs-android-arm-eabi')
|
|
95
101
|
const bindingPackageVersion = require('@napi-rs/webcodecs-android-arm-eabi/package.json').version
|
|
96
|
-
if (
|
|
97
|
-
|
|
102
|
+
if (
|
|
103
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
104
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
105
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
106
|
+
) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
109
|
+
)
|
|
98
110
|
}
|
|
99
111
|
return binding
|
|
100
112
|
} catch (e) {
|
|
@@ -105,38 +117,53 @@ function requireNative() {
|
|
|
105
117
|
}
|
|
106
118
|
} else if (process.platform === 'win32') {
|
|
107
119
|
if (process.arch === 'x64') {
|
|
108
|
-
if (
|
|
120
|
+
if (
|
|
121
|
+
(process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') ||
|
|
122
|
+
(process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')
|
|
123
|
+
) {
|
|
109
124
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
return require('./webcodecs.win32-x64-gnu.node')
|
|
126
|
+
} catch (e) {
|
|
127
|
+
loadErrors.push(e)
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const binding = require('@napi-rs/webcodecs-win32-x64-gnu')
|
|
131
|
+
const bindingPackageVersion = require('@napi-rs/webcodecs-win32-x64-gnu/package.json').version
|
|
132
|
+
if (
|
|
133
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
134
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
135
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
136
|
+
) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
return binding
|
|
142
|
+
} catch (e) {
|
|
143
|
+
loadErrors.push(e)
|
|
119
144
|
}
|
|
120
|
-
return binding
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadErrors.push(e)
|
|
123
|
-
}
|
|
124
145
|
} else {
|
|
125
146
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
return require('./webcodecs.win32-x64-msvc.node')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const binding = require('@napi-rs/webcodecs-win32-x64-msvc')
|
|
153
|
+
const bindingPackageVersion = require('@napi-rs/webcodecs-win32-x64-msvc/package.json').version
|
|
154
|
+
if (
|
|
155
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
156
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
157
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
158
|
+
) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
return binding
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
135
166
|
}
|
|
136
|
-
return binding
|
|
137
|
-
} catch (e) {
|
|
138
|
-
loadErrors.push(e)
|
|
139
|
-
}
|
|
140
167
|
}
|
|
141
168
|
} else if (process.arch === 'ia32') {
|
|
142
169
|
try {
|
|
@@ -147,8 +174,14 @@ function requireNative() {
|
|
|
147
174
|
try {
|
|
148
175
|
const binding = require('@napi-rs/webcodecs-win32-ia32-msvc')
|
|
149
176
|
const bindingPackageVersion = require('@napi-rs/webcodecs-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (
|
|
151
|
-
|
|
177
|
+
if (
|
|
178
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
179
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
180
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
181
|
+
) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
184
|
+
)
|
|
152
185
|
}
|
|
153
186
|
return binding
|
|
154
187
|
} catch (e) {
|
|
@@ -163,8 +196,14 @@ function requireNative() {
|
|
|
163
196
|
try {
|
|
164
197
|
const binding = require('@napi-rs/webcodecs-win32-arm64-msvc')
|
|
165
198
|
const bindingPackageVersion = require('@napi-rs/webcodecs-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (
|
|
167
|
-
|
|
199
|
+
if (
|
|
200
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
201
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
202
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
203
|
+
) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
206
|
+
)
|
|
168
207
|
}
|
|
169
208
|
return binding
|
|
170
209
|
} catch (e) {
|
|
@@ -182,8 +221,14 @@ function requireNative() {
|
|
|
182
221
|
try {
|
|
183
222
|
const binding = require('@napi-rs/webcodecs-darwin-universal')
|
|
184
223
|
const bindingPackageVersion = require('@napi-rs/webcodecs-darwin-universal/package.json').version
|
|
185
|
-
if (
|
|
186
|
-
|
|
224
|
+
if (
|
|
225
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
226
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
227
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
228
|
+
) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
231
|
+
)
|
|
187
232
|
}
|
|
188
233
|
return binding
|
|
189
234
|
} catch (e) {
|
|
@@ -198,8 +243,14 @@ function requireNative() {
|
|
|
198
243
|
try {
|
|
199
244
|
const binding = require('@napi-rs/webcodecs-darwin-x64')
|
|
200
245
|
const bindingPackageVersion = require('@napi-rs/webcodecs-darwin-x64/package.json').version
|
|
201
|
-
if (
|
|
202
|
-
|
|
246
|
+
if (
|
|
247
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
248
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
249
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
250
|
+
) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
253
|
+
)
|
|
203
254
|
}
|
|
204
255
|
return binding
|
|
205
256
|
} catch (e) {
|
|
@@ -214,8 +265,14 @@ function requireNative() {
|
|
|
214
265
|
try {
|
|
215
266
|
const binding = require('@napi-rs/webcodecs-darwin-arm64')
|
|
216
267
|
const bindingPackageVersion = require('@napi-rs/webcodecs-darwin-arm64/package.json').version
|
|
217
|
-
if (
|
|
218
|
-
|
|
268
|
+
if (
|
|
269
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
270
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
271
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
272
|
+
) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
275
|
+
)
|
|
219
276
|
}
|
|
220
277
|
return binding
|
|
221
278
|
} catch (e) {
|
|
@@ -234,8 +291,14 @@ function requireNative() {
|
|
|
234
291
|
try {
|
|
235
292
|
const binding = require('@napi-rs/webcodecs-freebsd-x64')
|
|
236
293
|
const bindingPackageVersion = require('@napi-rs/webcodecs-freebsd-x64/package.json').version
|
|
237
|
-
if (
|
|
238
|
-
|
|
294
|
+
if (
|
|
295
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
296
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
297
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
298
|
+
) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
301
|
+
)
|
|
239
302
|
}
|
|
240
303
|
return binding
|
|
241
304
|
} catch (e) {
|
|
@@ -250,8 +313,14 @@ function requireNative() {
|
|
|
250
313
|
try {
|
|
251
314
|
const binding = require('@napi-rs/webcodecs-freebsd-arm64')
|
|
252
315
|
const bindingPackageVersion = require('@napi-rs/webcodecs-freebsd-arm64/package.json').version
|
|
253
|
-
if (
|
|
254
|
-
|
|
316
|
+
if (
|
|
317
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
318
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
319
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
320
|
+
) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
323
|
+
)
|
|
255
324
|
}
|
|
256
325
|
return binding
|
|
257
326
|
} catch (e) {
|
|
@@ -271,8 +340,14 @@ function requireNative() {
|
|
|
271
340
|
try {
|
|
272
341
|
const binding = require('@napi-rs/webcodecs-linux-x64-musl')
|
|
273
342
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-x64-musl/package.json').version
|
|
274
|
-
if (
|
|
275
|
-
|
|
343
|
+
if (
|
|
344
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
345
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
346
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
347
|
+
) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
350
|
+
)
|
|
276
351
|
}
|
|
277
352
|
return binding
|
|
278
353
|
} catch (e) {
|
|
@@ -287,8 +362,14 @@ function requireNative() {
|
|
|
287
362
|
try {
|
|
288
363
|
const binding = require('@napi-rs/webcodecs-linux-x64-gnu')
|
|
289
364
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-x64-gnu/package.json').version
|
|
290
|
-
if (
|
|
291
|
-
|
|
365
|
+
if (
|
|
366
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
367
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
368
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
369
|
+
) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
372
|
+
)
|
|
292
373
|
}
|
|
293
374
|
return binding
|
|
294
375
|
} catch (e) {
|
|
@@ -305,8 +386,14 @@ function requireNative() {
|
|
|
305
386
|
try {
|
|
306
387
|
const binding = require('@napi-rs/webcodecs-linux-arm64-musl')
|
|
307
388
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-arm64-musl/package.json').version
|
|
308
|
-
if (
|
|
309
|
-
|
|
389
|
+
if (
|
|
390
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
391
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
392
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
393
|
+
) {
|
|
394
|
+
throw new Error(
|
|
395
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
396
|
+
)
|
|
310
397
|
}
|
|
311
398
|
return binding
|
|
312
399
|
} catch (e) {
|
|
@@ -321,8 +408,14 @@ function requireNative() {
|
|
|
321
408
|
try {
|
|
322
409
|
const binding = require('@napi-rs/webcodecs-linux-arm64-gnu')
|
|
323
410
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (
|
|
325
|
-
|
|
411
|
+
if (
|
|
412
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
413
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
414
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
415
|
+
) {
|
|
416
|
+
throw new Error(
|
|
417
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
418
|
+
)
|
|
326
419
|
}
|
|
327
420
|
return binding
|
|
328
421
|
} catch (e) {
|
|
@@ -339,8 +432,14 @@ function requireNative() {
|
|
|
339
432
|
try {
|
|
340
433
|
const binding = require('@napi-rs/webcodecs-linux-arm-musleabihf')
|
|
341
434
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (
|
|
343
|
-
|
|
435
|
+
if (
|
|
436
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
437
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
438
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
439
|
+
) {
|
|
440
|
+
throw new Error(
|
|
441
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
442
|
+
)
|
|
344
443
|
}
|
|
345
444
|
return binding
|
|
346
445
|
} catch (e) {
|
|
@@ -355,8 +454,14 @@ function requireNative() {
|
|
|
355
454
|
try {
|
|
356
455
|
const binding = require('@napi-rs/webcodecs-linux-arm-gnueabihf')
|
|
357
456
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (
|
|
359
|
-
|
|
457
|
+
if (
|
|
458
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
459
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
460
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
461
|
+
) {
|
|
462
|
+
throw new Error(
|
|
463
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
464
|
+
)
|
|
360
465
|
}
|
|
361
466
|
return binding
|
|
362
467
|
} catch (e) {
|
|
@@ -373,8 +478,14 @@ function requireNative() {
|
|
|
373
478
|
try {
|
|
374
479
|
const binding = require('@napi-rs/webcodecs-linux-loong64-musl')
|
|
375
480
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-loong64-musl/package.json').version
|
|
376
|
-
if (
|
|
377
|
-
|
|
481
|
+
if (
|
|
482
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
483
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
484
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
485
|
+
) {
|
|
486
|
+
throw new Error(
|
|
487
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
488
|
+
)
|
|
378
489
|
}
|
|
379
490
|
return binding
|
|
380
491
|
} catch (e) {
|
|
@@ -389,8 +500,14 @@ function requireNative() {
|
|
|
389
500
|
try {
|
|
390
501
|
const binding = require('@napi-rs/webcodecs-linux-loong64-gnu')
|
|
391
502
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (
|
|
393
|
-
|
|
503
|
+
if (
|
|
504
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
505
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
506
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
507
|
+
) {
|
|
508
|
+
throw new Error(
|
|
509
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
510
|
+
)
|
|
394
511
|
}
|
|
395
512
|
return binding
|
|
396
513
|
} catch (e) {
|
|
@@ -407,8 +524,14 @@ function requireNative() {
|
|
|
407
524
|
try {
|
|
408
525
|
const binding = require('@napi-rs/webcodecs-linux-riscv64-musl')
|
|
409
526
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (
|
|
411
|
-
|
|
527
|
+
if (
|
|
528
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
529
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
530
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
531
|
+
) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
534
|
+
)
|
|
412
535
|
}
|
|
413
536
|
return binding
|
|
414
537
|
} catch (e) {
|
|
@@ -423,8 +546,14 @@ function requireNative() {
|
|
|
423
546
|
try {
|
|
424
547
|
const binding = require('@napi-rs/webcodecs-linux-riscv64-gnu')
|
|
425
548
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (
|
|
427
|
-
|
|
549
|
+
if (
|
|
550
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
551
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
552
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
553
|
+
) {
|
|
554
|
+
throw new Error(
|
|
555
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
556
|
+
)
|
|
428
557
|
}
|
|
429
558
|
return binding
|
|
430
559
|
} catch (e) {
|
|
@@ -440,8 +569,14 @@ function requireNative() {
|
|
|
440
569
|
try {
|
|
441
570
|
const binding = require('@napi-rs/webcodecs-linux-ppc64-gnu')
|
|
442
571
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (
|
|
444
|
-
|
|
572
|
+
if (
|
|
573
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
574
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
575
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
576
|
+
) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
579
|
+
)
|
|
445
580
|
}
|
|
446
581
|
return binding
|
|
447
582
|
} catch (e) {
|
|
@@ -456,8 +591,14 @@ function requireNative() {
|
|
|
456
591
|
try {
|
|
457
592
|
const binding = require('@napi-rs/webcodecs-linux-s390x-gnu')
|
|
458
593
|
const bindingPackageVersion = require('@napi-rs/webcodecs-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (
|
|
460
|
-
|
|
594
|
+
if (
|
|
595
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
596
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
597
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
598
|
+
) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
601
|
+
)
|
|
461
602
|
}
|
|
462
603
|
return binding
|
|
463
604
|
} catch (e) {
|
|
@@ -476,8 +617,14 @@ function requireNative() {
|
|
|
476
617
|
try {
|
|
477
618
|
const binding = require('@napi-rs/webcodecs-openharmony-arm64')
|
|
478
619
|
const bindingPackageVersion = require('@napi-rs/webcodecs-openharmony-arm64/package.json').version
|
|
479
|
-
if (
|
|
480
|
-
|
|
620
|
+
if (
|
|
621
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
622
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
623
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
624
|
+
) {
|
|
625
|
+
throw new Error(
|
|
626
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
627
|
+
)
|
|
481
628
|
}
|
|
482
629
|
return binding
|
|
483
630
|
} catch (e) {
|
|
@@ -492,8 +639,14 @@ function requireNative() {
|
|
|
492
639
|
try {
|
|
493
640
|
const binding = require('@napi-rs/webcodecs-openharmony-x64')
|
|
494
641
|
const bindingPackageVersion = require('@napi-rs/webcodecs-openharmony-x64/package.json').version
|
|
495
|
-
if (
|
|
496
|
-
|
|
642
|
+
if (
|
|
643
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
644
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
645
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
646
|
+
) {
|
|
647
|
+
throw new Error(
|
|
648
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
649
|
+
)
|
|
497
650
|
}
|
|
498
651
|
return binding
|
|
499
652
|
} catch (e) {
|
|
@@ -508,8 +661,14 @@ function requireNative() {
|
|
|
508
661
|
try {
|
|
509
662
|
const binding = require('@napi-rs/webcodecs-openharmony-arm')
|
|
510
663
|
const bindingPackageVersion = require('@napi-rs/webcodecs-openharmony-arm/package.json').version
|
|
511
|
-
if (
|
|
512
|
-
|
|
664
|
+
if (
|
|
665
|
+
bindingPackageVersion !== '1.4.0' &&
|
|
666
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
667
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
668
|
+
) {
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
671
|
+
)
|
|
513
672
|
}
|
|
514
673
|
return binding
|
|
515
674
|
} catch (e) {
|
|
@@ -523,54 +682,165 @@ function requireNative() {
|
|
|
523
682
|
}
|
|
524
683
|
}
|
|
525
684
|
|
|
526
|
-
|
|
685
|
+
function createLoadErrorChain(errors) {
|
|
686
|
+
return errors.reduce((previous, current) => {
|
|
687
|
+
let message
|
|
688
|
+
try {
|
|
689
|
+
message = current && typeof current.message === 'string' ? current.message : String(current)
|
|
690
|
+
} catch {
|
|
691
|
+
message = 'Unknown error'
|
|
692
|
+
}
|
|
693
|
+
const error = new Error(message)
|
|
694
|
+
error.cause = previous
|
|
695
|
+
return error
|
|
696
|
+
}, null)
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
700
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
701
|
+
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
702
|
+
// 'error' → require WASI without initializing a native fallback
|
|
703
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
704
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
705
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
706
|
+
//
|
|
707
|
+
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
708
|
+
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
709
|
+
const __napiWasiFlavors = ['wasm32-wasi']
|
|
710
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
711
|
+
const __napiWasiFlavorRequested = typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
712
|
+
if (__napiWasiFlavorRequested && __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1) {
|
|
713
|
+
throw new Error(
|
|
714
|
+
'Unsupported WASI flavor "' + __napiWasiFlavor + '". Available flavors: ' + __napiWasiFlavors.join(', '),
|
|
715
|
+
)
|
|
716
|
+
}
|
|
717
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
718
|
+
const forceWasi = process.env.NAPI_RS_FORCE_WASI === 'true' || forceWasiError || __napiWasiFlavorRequested
|
|
719
|
+
|
|
720
|
+
if (!forceWasi) {
|
|
721
|
+
nativeBinding = requireNative()
|
|
722
|
+
}
|
|
527
723
|
|
|
528
|
-
if (!nativeBinding ||
|
|
724
|
+
if (!nativeBinding || forceWasi) {
|
|
529
725
|
let wasiBinding = null
|
|
530
|
-
let
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
726
|
+
let wasiBindingLoaded = false
|
|
727
|
+
const wasiBindingErrors = []
|
|
728
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
729
|
+
try {
|
|
730
|
+
require.resolve(specifier)
|
|
731
|
+
} catch (resolveError) {
|
|
732
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
733
|
+
throw resolveError
|
|
734
|
+
}
|
|
735
|
+
if (isPackage) {
|
|
736
|
+
try {
|
|
737
|
+
require.resolve(specifier + '/package.json')
|
|
738
|
+
} catch (packageError) {
|
|
739
|
+
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
740
|
+
return resolveError
|
|
741
|
+
}
|
|
742
|
+
// An exports restriction proves the package exists even when its
|
|
743
|
+
// package.json is not public. Preserve the root resolution failure.
|
|
744
|
+
throw resolveError
|
|
745
|
+
}
|
|
746
|
+
// The package exists but its main/export target is broken.
|
|
747
|
+
throw resolveError
|
|
748
|
+
}
|
|
749
|
+
return resolveError
|
|
537
750
|
}
|
|
751
|
+
if (localArtifacts) {
|
|
752
|
+
let artifactError = null
|
|
753
|
+
for (let i = 0; i < localArtifacts.length; i++) {
|
|
754
|
+
try {
|
|
755
|
+
require.resolve(localArtifacts[i])
|
|
756
|
+
return null
|
|
757
|
+
} catch (resolveError) {
|
|
758
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
759
|
+
throw resolveError
|
|
760
|
+
}
|
|
761
|
+
artifactError = resolveError
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return artifactError
|
|
765
|
+
}
|
|
766
|
+
return null
|
|
538
767
|
}
|
|
539
|
-
if (!
|
|
768
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
769
|
+
let candidateError = null
|
|
770
|
+
let candidateFailed = false
|
|
540
771
|
try {
|
|
541
|
-
|
|
542
|
-
|
|
772
|
+
candidateError = __napiWasiResolveCandidate('./webcodecs.wasi.cjs', false, [
|
|
773
|
+
'./webcodecs.wasm32-wasi.debug.wasm',
|
|
774
|
+
'./webcodecs.wasm32-wasi.wasm',
|
|
775
|
+
])
|
|
776
|
+
candidateFailed = candidateError !== null
|
|
777
|
+
if (!candidateFailed) {
|
|
778
|
+
wasiBinding = require('./webcodecs.wasi.cjs')
|
|
779
|
+
nativeBinding = wasiBinding
|
|
780
|
+
wasiBindingLoaded = true
|
|
781
|
+
}
|
|
543
782
|
} catch (err) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
783
|
+
candidateError = err
|
|
784
|
+
candidateFailed = true
|
|
785
|
+
}
|
|
786
|
+
if (candidateFailed) {
|
|
787
|
+
wasiBindingErrors.push(candidateError)
|
|
788
|
+
loadErrors.push(candidateError)
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
792
|
+
let candidateError = null
|
|
793
|
+
let candidateFailed = false
|
|
794
|
+
try {
|
|
795
|
+
candidateError = __napiWasiResolveCandidate('@napi-rs/webcodecs-wasm32-wasi', true, undefined)
|
|
796
|
+
candidateFailed = candidateError !== null
|
|
797
|
+
if (!candidateFailed) {
|
|
798
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
799
|
+
const bindingPackageVersion = require('@napi-rs/webcodecs-wasm32-wasi/package.json').version
|
|
800
|
+
if (bindingPackageVersion !== '1.4.0') {
|
|
801
|
+
throw new Error(
|
|
802
|
+
`WASI binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
803
|
+
)
|
|
804
|
+
}
|
|
549
805
|
}
|
|
550
|
-
|
|
806
|
+
wasiBinding = require('@napi-rs/webcodecs-wasm32-wasi')
|
|
807
|
+
nativeBinding = wasiBinding
|
|
808
|
+
wasiBindingLoaded = true
|
|
551
809
|
}
|
|
810
|
+
} catch (err) {
|
|
811
|
+
candidateError = err
|
|
812
|
+
candidateFailed = true
|
|
813
|
+
}
|
|
814
|
+
if (candidateFailed) {
|
|
815
|
+
wasiBindingErrors.push(candidateError)
|
|
816
|
+
loadErrors.push(candidateError)
|
|
552
817
|
}
|
|
553
818
|
}
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
|
|
819
|
+
if (!wasiBindingLoaded && forceWasi && !forceWasiError && !__napiWasiFlavorRequested) {
|
|
820
|
+
nativeBinding = requireNative()
|
|
821
|
+
}
|
|
822
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
823
|
+
const error = new Error(
|
|
824
|
+
__napiWasiFlavorRequested
|
|
825
|
+
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
826
|
+
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
827
|
+
)
|
|
828
|
+
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
557
829
|
throw error
|
|
558
830
|
}
|
|
559
831
|
}
|
|
560
832
|
|
|
561
833
|
if (!nativeBinding) {
|
|
562
834
|
if (loadErrors.length > 0) {
|
|
563
|
-
|
|
835
|
+
const error = new Error(
|
|
564
836
|
`Cannot find native binding. ` +
|
|
565
837
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
566
838
|
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
567
|
-
{
|
|
568
|
-
cause: loadErrors.reduce((err, cur) => {
|
|
569
|
-
cur.cause = err
|
|
570
|
-
return cur
|
|
571
|
-
}),
|
|
572
|
-
},
|
|
573
839
|
)
|
|
840
|
+
// assign instead of the `new Error(message, { cause })` options form,
|
|
841
|
+
// which Node < 16.9 silently ignores
|
|
842
|
+
error.cause = createLoadErrorChain(loadErrors)
|
|
843
|
+
throw error
|
|
574
844
|
}
|
|
575
845
|
throw new Error(`Failed to load native binding`)
|
|
576
846
|
}
|