oxc-parser 0.88.0 → 0.90.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/bindings.mjs +195 -31
- package/generated/deserialize/js.mjs +13 -8
- package/generated/deserialize/ts.mjs +13 -8
- package/package.json +20 -20
- package/raw-transfer/common.mjs +5 -7
- package/raw-transfer/eager.mjs +9 -2
package/bindings.mjs
CHANGED
|
@@ -67,7 +67,7 @@ const isMuslFromChildProcess = () => {
|
|
|
67
67
|
function requireNative() {
|
|
68
68
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
69
69
|
try {
|
|
70
|
-
|
|
70
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
71
71
|
} catch (err) {
|
|
72
72
|
loadErrors.push(err)
|
|
73
73
|
}
|
|
@@ -79,7 +79,12 @@ function requireNative() {
|
|
|
79
79
|
loadErrors.push(e)
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
|
-
|
|
82
|
+
const binding = require('@oxc-parser/binding-android-arm64')
|
|
83
|
+
const bindingPackageVersion = require('@oxc-parser/binding-android-arm64/package.json').version
|
|
84
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
85
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
|
+
}
|
|
87
|
+
return binding
|
|
83
88
|
} catch (e) {
|
|
84
89
|
loadErrors.push(e)
|
|
85
90
|
}
|
|
@@ -90,7 +95,12 @@ function requireNative() {
|
|
|
90
95
|
loadErrors.push(e)
|
|
91
96
|
}
|
|
92
97
|
try {
|
|
93
|
-
|
|
98
|
+
const binding = require('@oxc-parser/binding-android-arm-eabi')
|
|
99
|
+
const bindingPackageVersion = require('@oxc-parser/binding-android-arm-eabi/package.json').version
|
|
100
|
+
if (bindingPackageVersion !== '0.89.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 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
|
+
}
|
|
103
|
+
return binding
|
|
94
104
|
} catch (e) {
|
|
95
105
|
loadErrors.push(e)
|
|
96
106
|
}
|
|
@@ -105,7 +115,12 @@ function requireNative() {
|
|
|
105
115
|
loadErrors.push(e)
|
|
106
116
|
}
|
|
107
117
|
try {
|
|
108
|
-
|
|
118
|
+
const binding = require('@oxc-parser/binding-win32-x64-msvc')
|
|
119
|
+
const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-msvc/package.json').version
|
|
120
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
121
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
122
|
+
}
|
|
123
|
+
return binding
|
|
109
124
|
} catch (e) {
|
|
110
125
|
loadErrors.push(e)
|
|
111
126
|
}
|
|
@@ -116,7 +131,12 @@ function requireNative() {
|
|
|
116
131
|
loadErrors.push(e)
|
|
117
132
|
}
|
|
118
133
|
try {
|
|
119
|
-
|
|
134
|
+
const binding = require('@oxc-parser/binding-win32-ia32-msvc')
|
|
135
|
+
const bindingPackageVersion = require('@oxc-parser/binding-win32-ia32-msvc/package.json').version
|
|
136
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
137
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
138
|
+
}
|
|
139
|
+
return binding
|
|
120
140
|
} catch (e) {
|
|
121
141
|
loadErrors.push(e)
|
|
122
142
|
}
|
|
@@ -127,7 +147,12 @@ function requireNative() {
|
|
|
127
147
|
loadErrors.push(e)
|
|
128
148
|
}
|
|
129
149
|
try {
|
|
130
|
-
|
|
150
|
+
const binding = require('@oxc-parser/binding-win32-arm64-msvc')
|
|
151
|
+
const bindingPackageVersion = require('@oxc-parser/binding-win32-arm64-msvc/package.json').version
|
|
152
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
153
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
154
|
+
}
|
|
155
|
+
return binding
|
|
131
156
|
} catch (e) {
|
|
132
157
|
loadErrors.push(e)
|
|
133
158
|
}
|
|
@@ -141,7 +166,12 @@ function requireNative() {
|
|
|
141
166
|
loadErrors.push(e)
|
|
142
167
|
}
|
|
143
168
|
try {
|
|
144
|
-
|
|
169
|
+
const binding = require('@oxc-parser/binding-darwin-universal')
|
|
170
|
+
const bindingPackageVersion = require('@oxc-parser/binding-darwin-universal/package.json').version
|
|
171
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
172
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
173
|
+
}
|
|
174
|
+
return binding
|
|
145
175
|
} catch (e) {
|
|
146
176
|
loadErrors.push(e)
|
|
147
177
|
}
|
|
@@ -152,7 +182,12 @@ function requireNative() {
|
|
|
152
182
|
loadErrors.push(e)
|
|
153
183
|
}
|
|
154
184
|
try {
|
|
155
|
-
|
|
185
|
+
const binding = require('@oxc-parser/binding-darwin-x64')
|
|
186
|
+
const bindingPackageVersion = require('@oxc-parser/binding-darwin-x64/package.json').version
|
|
187
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
188
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
189
|
+
}
|
|
190
|
+
return binding
|
|
156
191
|
} catch (e) {
|
|
157
192
|
loadErrors.push(e)
|
|
158
193
|
}
|
|
@@ -163,7 +198,12 @@ function requireNative() {
|
|
|
163
198
|
loadErrors.push(e)
|
|
164
199
|
}
|
|
165
200
|
try {
|
|
166
|
-
|
|
201
|
+
const binding = require('@oxc-parser/binding-darwin-arm64')
|
|
202
|
+
const bindingPackageVersion = require('@oxc-parser/binding-darwin-arm64/package.json').version
|
|
203
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
204
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
205
|
+
}
|
|
206
|
+
return binding
|
|
167
207
|
} catch (e) {
|
|
168
208
|
loadErrors.push(e)
|
|
169
209
|
}
|
|
@@ -178,7 +218,12 @@ function requireNative() {
|
|
|
178
218
|
loadErrors.push(e)
|
|
179
219
|
}
|
|
180
220
|
try {
|
|
181
|
-
|
|
221
|
+
const binding = require('@oxc-parser/binding-freebsd-x64')
|
|
222
|
+
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-x64/package.json').version
|
|
223
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
224
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
225
|
+
}
|
|
226
|
+
return binding
|
|
182
227
|
} catch (e) {
|
|
183
228
|
loadErrors.push(e)
|
|
184
229
|
}
|
|
@@ -189,7 +234,12 @@ function requireNative() {
|
|
|
189
234
|
loadErrors.push(e)
|
|
190
235
|
}
|
|
191
236
|
try {
|
|
192
|
-
|
|
237
|
+
const binding = require('@oxc-parser/binding-freebsd-arm64')
|
|
238
|
+
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-arm64/package.json').version
|
|
239
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
240
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
241
|
+
}
|
|
242
|
+
return binding
|
|
193
243
|
} catch (e) {
|
|
194
244
|
loadErrors.push(e)
|
|
195
245
|
}
|
|
@@ -205,7 +255,12 @@ function requireNative() {
|
|
|
205
255
|
loadErrors.push(e)
|
|
206
256
|
}
|
|
207
257
|
try {
|
|
208
|
-
|
|
258
|
+
const binding = require('@oxc-parser/binding-linux-x64-musl')
|
|
259
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-musl/package.json').version
|
|
260
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
261
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
262
|
+
}
|
|
263
|
+
return binding
|
|
209
264
|
} catch (e) {
|
|
210
265
|
loadErrors.push(e)
|
|
211
266
|
}
|
|
@@ -216,7 +271,12 @@ function requireNative() {
|
|
|
216
271
|
loadErrors.push(e)
|
|
217
272
|
}
|
|
218
273
|
try {
|
|
219
|
-
|
|
274
|
+
const binding = require('@oxc-parser/binding-linux-x64-gnu')
|
|
275
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-gnu/package.json').version
|
|
276
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
277
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
278
|
+
}
|
|
279
|
+
return binding
|
|
220
280
|
} catch (e) {
|
|
221
281
|
loadErrors.push(e)
|
|
222
282
|
}
|
|
@@ -229,7 +289,12 @@ function requireNative() {
|
|
|
229
289
|
loadErrors.push(e)
|
|
230
290
|
}
|
|
231
291
|
try {
|
|
232
|
-
|
|
292
|
+
const binding = require('@oxc-parser/binding-linux-arm64-musl')
|
|
293
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-musl/package.json').version
|
|
294
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
295
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
|
+
}
|
|
297
|
+
return binding
|
|
233
298
|
} catch (e) {
|
|
234
299
|
loadErrors.push(e)
|
|
235
300
|
}
|
|
@@ -240,7 +305,12 @@ function requireNative() {
|
|
|
240
305
|
loadErrors.push(e)
|
|
241
306
|
}
|
|
242
307
|
try {
|
|
243
|
-
|
|
308
|
+
const binding = require('@oxc-parser/binding-linux-arm64-gnu')
|
|
309
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-gnu/package.json').version
|
|
310
|
+
if (bindingPackageVersion !== '0.89.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 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
312
|
+
}
|
|
313
|
+
return binding
|
|
244
314
|
} catch (e) {
|
|
245
315
|
loadErrors.push(e)
|
|
246
316
|
}
|
|
@@ -253,7 +323,12 @@ function requireNative() {
|
|
|
253
323
|
loadErrors.push(e)
|
|
254
324
|
}
|
|
255
325
|
try {
|
|
256
|
-
|
|
326
|
+
const binding = require('@oxc-parser/binding-linux-arm-musleabihf')
|
|
327
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-musleabihf/package.json').version
|
|
328
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
|
+
}
|
|
331
|
+
return binding
|
|
257
332
|
} catch (e) {
|
|
258
333
|
loadErrors.push(e)
|
|
259
334
|
}
|
|
@@ -264,7 +339,46 @@ function requireNative() {
|
|
|
264
339
|
loadErrors.push(e)
|
|
265
340
|
}
|
|
266
341
|
try {
|
|
267
|
-
|
|
342
|
+
const binding = require('@oxc-parser/binding-linux-arm-gnueabihf')
|
|
343
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-gnueabihf/package.json').version
|
|
344
|
+
if (bindingPackageVersion !== '0.89.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 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
346
|
+
}
|
|
347
|
+
return binding
|
|
348
|
+
} catch (e) {
|
|
349
|
+
loadErrors.push(e)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else if (process.arch === 'loong64') {
|
|
353
|
+
if (isMusl()) {
|
|
354
|
+
try {
|
|
355
|
+
return require('./parser.linux-loong64-musl.node')
|
|
356
|
+
} catch (e) {
|
|
357
|
+
loadErrors.push(e)
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const binding = require('@oxc-parser/binding-linux-loong64-musl')
|
|
361
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-musl/package.json').version
|
|
362
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
363
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
|
+
}
|
|
365
|
+
return binding
|
|
366
|
+
} catch (e) {
|
|
367
|
+
loadErrors.push(e)
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
try {
|
|
371
|
+
return require('./parser.linux-loong64-gnu.node')
|
|
372
|
+
} catch (e) {
|
|
373
|
+
loadErrors.push(e)
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
const binding = require('@oxc-parser/binding-linux-loong64-gnu')
|
|
377
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-gnu/package.json').version
|
|
378
|
+
if (bindingPackageVersion !== '0.89.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 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
380
|
+
}
|
|
381
|
+
return binding
|
|
268
382
|
} catch (e) {
|
|
269
383
|
loadErrors.push(e)
|
|
270
384
|
}
|
|
@@ -277,7 +391,12 @@ function requireNative() {
|
|
|
277
391
|
loadErrors.push(e)
|
|
278
392
|
}
|
|
279
393
|
try {
|
|
280
|
-
|
|
394
|
+
const binding = require('@oxc-parser/binding-linux-riscv64-musl')
|
|
395
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-musl/package.json').version
|
|
396
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
397
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
|
+
}
|
|
399
|
+
return binding
|
|
281
400
|
} catch (e) {
|
|
282
401
|
loadErrors.push(e)
|
|
283
402
|
}
|
|
@@ -288,7 +407,12 @@ function requireNative() {
|
|
|
288
407
|
loadErrors.push(e)
|
|
289
408
|
}
|
|
290
409
|
try {
|
|
291
|
-
|
|
410
|
+
const binding = require('@oxc-parser/binding-linux-riscv64-gnu')
|
|
411
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-gnu/package.json').version
|
|
412
|
+
if (bindingPackageVersion !== '0.89.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 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
414
|
+
}
|
|
415
|
+
return binding
|
|
292
416
|
} catch (e) {
|
|
293
417
|
loadErrors.push(e)
|
|
294
418
|
}
|
|
@@ -300,7 +424,12 @@ function requireNative() {
|
|
|
300
424
|
loadErrors.push(e)
|
|
301
425
|
}
|
|
302
426
|
try {
|
|
303
|
-
|
|
427
|
+
const binding = require('@oxc-parser/binding-linux-ppc64-gnu')
|
|
428
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-ppc64-gnu/package.json').version
|
|
429
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
430
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
431
|
+
}
|
|
432
|
+
return binding
|
|
304
433
|
} catch (e) {
|
|
305
434
|
loadErrors.push(e)
|
|
306
435
|
}
|
|
@@ -311,7 +440,12 @@ function requireNative() {
|
|
|
311
440
|
loadErrors.push(e)
|
|
312
441
|
}
|
|
313
442
|
try {
|
|
314
|
-
|
|
443
|
+
const binding = require('@oxc-parser/binding-linux-s390x-gnu')
|
|
444
|
+
const bindingPackageVersion = require('@oxc-parser/binding-linux-s390x-gnu/package.json').version
|
|
445
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
446
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
447
|
+
}
|
|
448
|
+
return binding
|
|
315
449
|
} catch (e) {
|
|
316
450
|
loadErrors.push(e)
|
|
317
451
|
}
|
|
@@ -321,34 +455,49 @@ function requireNative() {
|
|
|
321
455
|
} else if (process.platform === 'openharmony') {
|
|
322
456
|
if (process.arch === 'arm64') {
|
|
323
457
|
try {
|
|
324
|
-
return require('./parser.
|
|
458
|
+
return require('./parser.openharmony-arm64.node')
|
|
325
459
|
} catch (e) {
|
|
326
460
|
loadErrors.push(e)
|
|
327
461
|
}
|
|
328
462
|
try {
|
|
329
|
-
|
|
463
|
+
const binding = require('@oxc-parser/binding-openharmony-arm64')
|
|
464
|
+
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm64/package.json').version
|
|
465
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
466
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
467
|
+
}
|
|
468
|
+
return binding
|
|
330
469
|
} catch (e) {
|
|
331
470
|
loadErrors.push(e)
|
|
332
471
|
}
|
|
333
472
|
} else if (process.arch === 'x64') {
|
|
334
473
|
try {
|
|
335
|
-
return require('./parser.
|
|
474
|
+
return require('./parser.openharmony-x64.node')
|
|
336
475
|
} catch (e) {
|
|
337
476
|
loadErrors.push(e)
|
|
338
477
|
}
|
|
339
478
|
try {
|
|
340
|
-
|
|
479
|
+
const binding = require('@oxc-parser/binding-openharmony-x64')
|
|
480
|
+
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-x64/package.json').version
|
|
481
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
482
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
483
|
+
}
|
|
484
|
+
return binding
|
|
341
485
|
} catch (e) {
|
|
342
486
|
loadErrors.push(e)
|
|
343
487
|
}
|
|
344
488
|
} else if (process.arch === 'arm') {
|
|
345
489
|
try {
|
|
346
|
-
return require('./parser.
|
|
490
|
+
return require('./parser.openharmony-arm.node')
|
|
347
491
|
} catch (e) {
|
|
348
492
|
loadErrors.push(e)
|
|
349
493
|
}
|
|
350
494
|
try {
|
|
351
|
-
|
|
495
|
+
const binding = require('@oxc-parser/binding-openharmony-arm')
|
|
496
|
+
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm/package.json').version
|
|
497
|
+
if (bindingPackageVersion !== '0.89.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
498
|
+
throw new Error(`Native binding package version mismatch, expected 0.89.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
499
|
+
}
|
|
500
|
+
return binding
|
|
352
501
|
} catch (e) {
|
|
353
502
|
loadErrors.push(e)
|
|
354
503
|
}
|
|
@@ -363,22 +512,32 @@ function requireNative() {
|
|
|
363
512
|
nativeBinding = requireNative()
|
|
364
513
|
|
|
365
514
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
515
|
+
let wasiBinding = null
|
|
516
|
+
let wasiBindingError = null
|
|
366
517
|
try {
|
|
367
|
-
|
|
518
|
+
wasiBinding = require('./parser.wasi.cjs')
|
|
519
|
+
nativeBinding = wasiBinding
|
|
368
520
|
} catch (err) {
|
|
369
521
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
370
|
-
|
|
522
|
+
wasiBindingError = err
|
|
371
523
|
}
|
|
372
524
|
}
|
|
373
525
|
if (!nativeBinding) {
|
|
374
526
|
try {
|
|
375
|
-
|
|
527
|
+
wasiBinding = require('@oxc-parser/binding-wasm32-wasi')
|
|
528
|
+
nativeBinding = wasiBinding
|
|
376
529
|
} catch (err) {
|
|
377
530
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
531
|
+
wasiBindingError.cause = err
|
|
378
532
|
loadErrors.push(err)
|
|
379
533
|
}
|
|
380
534
|
}
|
|
381
535
|
}
|
|
536
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
537
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
538
|
+
error.cause = wasiBindingError
|
|
539
|
+
throw error
|
|
540
|
+
}
|
|
382
541
|
}
|
|
383
542
|
|
|
384
543
|
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
@@ -395,7 +554,12 @@ if (!nativeBinding) {
|
|
|
395
554
|
`Cannot find native binding. ` +
|
|
396
555
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
397
556
|
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
398
|
-
{
|
|
557
|
+
{
|
|
558
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
559
|
+
cur.cause = err
|
|
560
|
+
return cur
|
|
561
|
+
}),
|
|
562
|
+
},
|
|
399
563
|
)
|
|
400
564
|
}
|
|
401
565
|
throw new Error(`Failed to load native binding`)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
2
2
|
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs`.
|
|
3
3
|
|
|
4
|
-
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen;
|
|
4
|
+
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen, preserveParens;
|
|
5
5
|
|
|
6
6
|
const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
|
|
7
7
|
decodeStr = textDecoder.decode.bind(textDecoder),
|
|
8
8
|
{ fromCodePoint } = String;
|
|
9
9
|
|
|
10
|
-
export function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
|
|
10
|
+
export function deserialize(buffer, sourceTextInput, sourceByteLenInput, preserveParensInput) {
|
|
11
11
|
uint8 = buffer;
|
|
12
12
|
uint32 = buffer.uint32;
|
|
13
13
|
float64 = buffer.float64;
|
|
@@ -15,6 +15,7 @@ export function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
|
|
|
15
15
|
sourceText = sourceTextInput;
|
|
16
16
|
sourceByteLen = sourceByteLenInput;
|
|
17
17
|
sourceIsAscii = sourceText.length === sourceByteLen;
|
|
18
|
+
preserveParens = preserveParensInput;
|
|
18
19
|
|
|
19
20
|
const data = deserializeRawTransferData(uint32[536870902]);
|
|
20
21
|
|
|
@@ -438,12 +439,16 @@ function deserializeChainExpression(pos) {
|
|
|
438
439
|
}
|
|
439
440
|
|
|
440
441
|
function deserializeParenthesizedExpression(pos) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
442
|
+
let node = deserializeExpression(pos + 8);
|
|
443
|
+
if (preserveParens) {
|
|
444
|
+
node = {
|
|
445
|
+
type: 'ParenthesizedExpression',
|
|
446
|
+
expression: node,
|
|
447
|
+
start: deserializeU32(pos),
|
|
448
|
+
end: deserializeU32(pos + 4),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return node;
|
|
447
452
|
}
|
|
448
453
|
|
|
449
454
|
function deserializeDirective(pos) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
2
2
|
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs`.
|
|
3
3
|
|
|
4
|
-
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen;
|
|
4
|
+
let uint8, uint32, float64, sourceText, sourceIsAscii, sourceByteLen, preserveParens;
|
|
5
5
|
|
|
6
6
|
const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
|
|
7
7
|
decodeStr = textDecoder.decode.bind(textDecoder),
|
|
8
8
|
{ fromCodePoint } = String;
|
|
9
9
|
|
|
10
|
-
export function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
|
|
10
|
+
export function deserialize(buffer, sourceTextInput, sourceByteLenInput, preserveParensInput) {
|
|
11
11
|
uint8 = buffer;
|
|
12
12
|
uint32 = buffer.uint32;
|
|
13
13
|
float64 = buffer.float64;
|
|
@@ -15,6 +15,7 @@ export function deserialize(buffer, sourceTextInput, sourceByteLenInput) {
|
|
|
15
15
|
sourceText = sourceTextInput;
|
|
16
16
|
sourceByteLen = sourceByteLenInput;
|
|
17
17
|
sourceIsAscii = sourceText.length === sourceByteLen;
|
|
18
|
+
preserveParens = preserveParensInput;
|
|
18
19
|
|
|
19
20
|
const data = deserializeRawTransferData(uint32[536870902]);
|
|
20
21
|
|
|
@@ -488,12 +489,16 @@ function deserializeChainExpression(pos) {
|
|
|
488
489
|
}
|
|
489
490
|
|
|
490
491
|
function deserializeParenthesizedExpression(pos) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
492
|
+
let node = deserializeExpression(pos + 8);
|
|
493
|
+
if (preserveParens) {
|
|
494
|
+
node = {
|
|
495
|
+
type: 'ParenthesizedExpression',
|
|
496
|
+
expression: node,
|
|
497
|
+
start: deserializeU32(pos),
|
|
498
|
+
end: deserializeU32(pos + 4),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
return node;
|
|
497
502
|
}
|
|
498
503
|
|
|
499
504
|
function deserializeDirective(pos) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
|
-
"main": "index.
|
|
5
|
+
"main": "index.mjs",
|
|
6
6
|
"browser": "wasm.mjs",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
9
9
|
},
|
|
10
10
|
"description": "Oxc Parser Node API",
|
|
11
11
|
"keywords": [
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@oxc-project/types": "^0.
|
|
53
|
+
"@oxc-project/types": "^0.90.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
57
|
-
"@napi-rs/wasm-runtime": "1.0.
|
|
57
|
+
"@napi-rs/wasm-runtime": "1.0.5",
|
|
58
58
|
"@vitest/browser": "3.2.4",
|
|
59
59
|
"esbuild": "^0.25.0",
|
|
60
60
|
"playwright": "^1.51.0",
|
|
@@ -90,21 +90,21 @@
|
|
|
90
90
|
"dtsHeaderFile": "header.js"
|
|
91
91
|
},
|
|
92
92
|
"optionalDependencies": {
|
|
93
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
94
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
95
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
96
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
97
|
-
"@oxc-parser/binding-freebsd-x64": "0.
|
|
98
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
99
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
100
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
101
|
-
"@oxc-parser/binding-linux-arm-musleabihf": "0.
|
|
102
|
-
"@oxc-parser/binding-linux-s390x-gnu": "0.
|
|
103
|
-
"@oxc-parser/binding-linux-riscv64-gnu": "0.
|
|
104
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
105
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
106
|
-
"@oxc-parser/binding-android-arm64": "0.
|
|
107
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
93
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.90.0",
|
|
94
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.90.0",
|
|
95
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.90.0",
|
|
96
|
+
"@oxc-parser/binding-linux-x64-musl": "0.90.0",
|
|
97
|
+
"@oxc-parser/binding-freebsd-x64": "0.90.0",
|
|
98
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.90.0",
|
|
99
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.90.0",
|
|
100
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.90.0",
|
|
101
|
+
"@oxc-parser/binding-linux-arm-musleabihf": "0.90.0",
|
|
102
|
+
"@oxc-parser/binding-linux-s390x-gnu": "0.90.0",
|
|
103
|
+
"@oxc-parser/binding-linux-riscv64-gnu": "0.90.0",
|
|
104
|
+
"@oxc-parser/binding-darwin-x64": "0.90.0",
|
|
105
|
+
"@oxc-parser/binding-darwin-arm64": "0.90.0",
|
|
106
|
+
"@oxc-parser/binding-android-arm64": "0.90.0",
|
|
107
|
+
"@oxc-parser/binding-wasm32-wasi": "0.90.0"
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"build-dev": "napi build --esm --platform --js bindings.mjs",
|
package/raw-transfer/common.mjs
CHANGED
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
import { BUFFER_ALIGN, BUFFER_SIZE, IS_TS_FLAG_POS } from '../generated/constants.mjs';
|
|
8
8
|
import { rawTransferSupported } from './supported.mjs';
|
|
9
9
|
|
|
10
|
-
export { isJsAst, parseAsyncRawImpl, parseSyncRawImpl, prepareRaw, returnBufferToCache };
|
|
11
|
-
|
|
12
10
|
// Throw an error if running on a platform which raw transfer doesn't support.
|
|
13
11
|
//
|
|
14
12
|
// Note: This module is lazy-loaded only when user calls `parseSync` or `parseAsync` with
|
|
@@ -34,7 +32,7 @@ if (!rawTransferSupported()) {
|
|
|
34
32
|
* @param {function} convert - Function to convert the buffer returned from Rust into a JS object
|
|
35
33
|
* @returns {Object} - The return value of `convert`
|
|
36
34
|
*/
|
|
37
|
-
function parseSyncRawImpl(filename, sourceText, options, convert) {
|
|
35
|
+
export function parseSyncRawImpl(filename, sourceText, options, convert) {
|
|
38
36
|
const { buffer, sourceByteLen } = prepareRaw(sourceText);
|
|
39
37
|
parseSyncRawBinding(filename, buffer, sourceByteLen, options);
|
|
40
38
|
return convert(buffer, sourceText, sourceByteLen);
|
|
@@ -93,7 +91,7 @@ const queue = [];
|
|
|
93
91
|
* @param {function} convert - Function to convert the buffer returned from Rust into a JS object
|
|
94
92
|
* @returns {Object} - The return value of `convert`
|
|
95
93
|
*/
|
|
96
|
-
async function parseAsyncRawImpl(filename, sourceText, options, convert) {
|
|
94
|
+
export async function parseAsyncRawImpl(filename, sourceText, options, convert) {
|
|
97
95
|
// Wait for a free CPU core if all CPUs are currently busy.
|
|
98
96
|
//
|
|
99
97
|
// Note: `availableCores` is NOT decremented if have to wait in the queue first,
|
|
@@ -180,7 +178,7 @@ const textEncoder = new TextEncoder();
|
|
|
180
178
|
* - `sourceByteLen`: Length of source text in UTF-8 bytes
|
|
181
179
|
* (which may not be equal to `sourceText.length` if source contains non-ASCII characters).
|
|
182
180
|
*/
|
|
183
|
-
function prepareRaw(sourceText) {
|
|
181
|
+
export function prepareRaw(sourceText) {
|
|
184
182
|
// Cancel timeout for clearing buffers
|
|
185
183
|
if (clearBuffersTimeout !== null) {
|
|
186
184
|
clearTimeout(clearBuffersTimeout);
|
|
@@ -218,7 +216,7 @@ function prepareRaw(sourceText) {
|
|
|
218
216
|
* @param {Uint8Array} buffer - Buffer containing AST in raw form
|
|
219
217
|
* @returns {boolean} - `true` if AST is JS, `false` if TS
|
|
220
218
|
*/
|
|
221
|
-
function isJsAst(buffer) {
|
|
219
|
+
export function isJsAst(buffer) {
|
|
222
220
|
return buffer[IS_TS_FLAG_POS] === 0;
|
|
223
221
|
}
|
|
224
222
|
|
|
@@ -229,7 +227,7 @@ function isJsAst(buffer) {
|
|
|
229
227
|
* @param {Uint8Array} buffer - Buffer
|
|
230
228
|
* @returns {undefined}
|
|
231
229
|
*/
|
|
232
|
-
function returnBufferToCache(buffer) {
|
|
230
|
+
export function returnBufferToCache(buffer) {
|
|
233
231
|
buffers.push(buffer);
|
|
234
232
|
|
|
235
233
|
if (clearBuffersTimeout !== null) clearTimeout(clearBuffersTimeout);
|
package/raw-transfer/eager.mjs
CHANGED
|
@@ -56,7 +56,10 @@ function deserialize(buffer, sourceText, sourceByteLen) {
|
|
|
56
56
|
let data;
|
|
57
57
|
if (isJsAst(buffer)) {
|
|
58
58
|
if (deserializeJS === null) deserializeJS = require('../generated/deserialize/js.mjs').deserialize;
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
// `preserveParens` argument is unconditionally `true` here. If `options` contains `preserveParens: false`,
|
|
61
|
+
// `ParenthesizedExpression` nodes won't be in AST anyway, so the value is irrelevant.
|
|
62
|
+
data = deserializeJS(buffer, sourceText, sourceByteLen, true);
|
|
60
63
|
|
|
61
64
|
// Add a line comment for hashbang
|
|
62
65
|
const { hashbang } = data.program;
|
|
@@ -65,7 +68,11 @@ function deserialize(buffer, sourceText, sourceByteLen) {
|
|
|
65
68
|
}
|
|
66
69
|
} else {
|
|
67
70
|
if (deserializeTS === null) deserializeTS = require('../generated/deserialize/ts.mjs').deserialize;
|
|
68
|
-
|
|
71
|
+
|
|
72
|
+
// `preserveParens` argument is unconditionally `true` here. If `options` contains `preserveParens: false`,
|
|
73
|
+
// `ParenthesizedExpression` nodes won't be in AST anyway, so the value is irrelevant.
|
|
74
|
+
data = deserializeTS(buffer, sourceText, sourceByteLen, true);
|
|
75
|
+
|
|
69
76
|
// Note: Do not add line comment for hashbang, to match `@typescript-eslint/parser`.
|
|
70
77
|
// See https://github.com/oxc-project/oxc/blob/ea784f5f082e4c53c98afde9bf983afd0b95e44e/napi/parser/src/lib.rs#L106-L130
|
|
71
78
|
}
|