oxc-parser 0.33.0 → 0.35.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 +1 -2
- package/bindings.js +368 -0
- package/index.d.ts +2 -1
- package/index.js +16 -368
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -15,8 +15,7 @@ test(oxc.parseSync(sourceText, options));
|
|
|
15
15
|
test(await oxc.parseAsync(sourceText, options));
|
|
16
16
|
|
|
17
17
|
function test(ret) {
|
|
18
|
-
|
|
19
|
-
assert(program.body.length == 1);
|
|
18
|
+
assert(ret.program.body.length == 1);
|
|
20
19
|
assert(ret.errors.length == 0);
|
|
21
20
|
}
|
|
22
21
|
```
|
package/bindings.js
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* auto-generated by NAPI-RS */
|
|
4
|
+
|
|
5
|
+
const { readFileSync } = require('fs')
|
|
6
|
+
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
|
36
|
+
if (!report) {
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
43
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const isMuslFromChildProcess = () => {
|
|
51
|
+
try {
|
|
52
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function requireNative() {
|
|
60
|
+
if (process.platform === 'android') {
|
|
61
|
+
if (process.arch === 'arm64') {
|
|
62
|
+
try {
|
|
63
|
+
return require('./parser.android-arm64.node')
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadErrors.push(e)
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return require('@oxc-parser/binding-android-arm64')
|
|
69
|
+
} catch (e) {
|
|
70
|
+
loadErrors.push(e)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} else if (process.arch === 'arm') {
|
|
74
|
+
try {
|
|
75
|
+
return require('./parser.android-arm-eabi.node')
|
|
76
|
+
} catch (e) {
|
|
77
|
+
loadErrors.push(e)
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
return require('@oxc-parser/binding-android-arm-eabi')
|
|
81
|
+
} catch (e) {
|
|
82
|
+
loadErrors.push(e)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} else {
|
|
86
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
87
|
+
}
|
|
88
|
+
} else if (process.platform === 'win32') {
|
|
89
|
+
if (process.arch === 'x64') {
|
|
90
|
+
try {
|
|
91
|
+
return require('./parser.win32-x64-msvc.node')
|
|
92
|
+
} catch (e) {
|
|
93
|
+
loadErrors.push(e)
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return require('@oxc-parser/binding-win32-x64-msvc')
|
|
97
|
+
} catch (e) {
|
|
98
|
+
loadErrors.push(e)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
} else if (process.arch === 'ia32') {
|
|
102
|
+
try {
|
|
103
|
+
return require('./parser.win32-ia32-msvc.node')
|
|
104
|
+
} catch (e) {
|
|
105
|
+
loadErrors.push(e)
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
return require('@oxc-parser/binding-win32-ia32-msvc')
|
|
109
|
+
} catch (e) {
|
|
110
|
+
loadErrors.push(e)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} else if (process.arch === 'arm64') {
|
|
114
|
+
try {
|
|
115
|
+
return require('./parser.win32-arm64-msvc.node')
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e)
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return require('@oxc-parser/binding-win32-arm64-msvc')
|
|
121
|
+
} catch (e) {
|
|
122
|
+
loadErrors.push(e)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} else {
|
|
126
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
127
|
+
}
|
|
128
|
+
} else if (process.platform === 'darwin') {
|
|
129
|
+
try {
|
|
130
|
+
return require('./parser.darwin-universal.node')
|
|
131
|
+
} catch (e) {
|
|
132
|
+
loadErrors.push(e)
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
return require('@oxc-parser/binding-darwin-universal')
|
|
136
|
+
} catch (e) {
|
|
137
|
+
loadErrors.push(e)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (process.arch === 'x64') {
|
|
141
|
+
try {
|
|
142
|
+
return require('./parser.darwin-x64.node')
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadErrors.push(e)
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
return require('@oxc-parser/binding-darwin-x64')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
} else if (process.arch === 'arm64') {
|
|
153
|
+
try {
|
|
154
|
+
return require('./parser.darwin-arm64.node')
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
return require('@oxc-parser/binding-darwin-arm64')
|
|
160
|
+
} catch (e) {
|
|
161
|
+
loadErrors.push(e)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
166
|
+
}
|
|
167
|
+
} else if (process.platform === 'freebsd') {
|
|
168
|
+
if (process.arch === 'x64') {
|
|
169
|
+
try {
|
|
170
|
+
return require('./parser.freebsd-x64.node')
|
|
171
|
+
} catch (e) {
|
|
172
|
+
loadErrors.push(e)
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
return require('@oxc-parser/binding-freebsd-x64')
|
|
176
|
+
} catch (e) {
|
|
177
|
+
loadErrors.push(e)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
} else if (process.arch === 'arm64') {
|
|
181
|
+
try {
|
|
182
|
+
return require('./parser.freebsd-arm64.node')
|
|
183
|
+
} catch (e) {
|
|
184
|
+
loadErrors.push(e)
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
return require('@oxc-parser/binding-freebsd-arm64')
|
|
188
|
+
} catch (e) {
|
|
189
|
+
loadErrors.push(e)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
} else {
|
|
193
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
194
|
+
}
|
|
195
|
+
} else if (process.platform === 'linux') {
|
|
196
|
+
if (process.arch === 'x64') {
|
|
197
|
+
if (isMusl()) {
|
|
198
|
+
try {
|
|
199
|
+
return require('./parser.linux-x64-musl.node')
|
|
200
|
+
} catch (e) {
|
|
201
|
+
loadErrors.push(e)
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return require('@oxc-parser/binding-linux-x64-musl')
|
|
205
|
+
} catch (e) {
|
|
206
|
+
loadErrors.push(e)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
try {
|
|
211
|
+
return require('./parser.linux-x64-gnu.node')
|
|
212
|
+
} catch (e) {
|
|
213
|
+
loadErrors.push(e)
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
return require('@oxc-parser/binding-linux-x64-gnu')
|
|
217
|
+
} catch (e) {
|
|
218
|
+
loadErrors.push(e)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
} else if (process.arch === 'arm64') {
|
|
223
|
+
if (isMusl()) {
|
|
224
|
+
try {
|
|
225
|
+
return require('./parser.linux-arm64-musl.node')
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return require('@oxc-parser/binding-linux-arm64-musl')
|
|
231
|
+
} catch (e) {
|
|
232
|
+
loadErrors.push(e)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
} else {
|
|
236
|
+
try {
|
|
237
|
+
return require('./parser.linux-arm64-gnu.node')
|
|
238
|
+
} catch (e) {
|
|
239
|
+
loadErrors.push(e)
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
return require('@oxc-parser/binding-linux-arm64-gnu')
|
|
243
|
+
} catch (e) {
|
|
244
|
+
loadErrors.push(e)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
} else if (process.arch === 'arm') {
|
|
249
|
+
if (isMusl()) {
|
|
250
|
+
try {
|
|
251
|
+
return require('./parser.linux-arm-musleabihf.node')
|
|
252
|
+
} catch (e) {
|
|
253
|
+
loadErrors.push(e)
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
return require('@oxc-parser/binding-linux-arm-musleabihf')
|
|
257
|
+
} catch (e) {
|
|
258
|
+
loadErrors.push(e)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
} else {
|
|
262
|
+
try {
|
|
263
|
+
return require('./parser.linux-arm-gnueabihf.node')
|
|
264
|
+
} catch (e) {
|
|
265
|
+
loadErrors.push(e)
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return require('@oxc-parser/binding-linux-arm-gnueabihf')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
} else if (process.arch === 'riscv64') {
|
|
275
|
+
if (isMusl()) {
|
|
276
|
+
try {
|
|
277
|
+
return require('./parser.linux-riscv64-musl.node')
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
return require('@oxc-parser/binding-linux-riscv64-musl')
|
|
283
|
+
} catch (e) {
|
|
284
|
+
loadErrors.push(e)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
} else {
|
|
288
|
+
try {
|
|
289
|
+
return require('./parser.linux-riscv64-gnu.node')
|
|
290
|
+
} catch (e) {
|
|
291
|
+
loadErrors.push(e)
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
return require('@oxc-parser/binding-linux-riscv64-gnu')
|
|
295
|
+
} catch (e) {
|
|
296
|
+
loadErrors.push(e)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
} else if (process.arch === 'ppc64') {
|
|
301
|
+
try {
|
|
302
|
+
return require('./parser.linux-ppc64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return require('@oxc-parser/binding-linux-ppc64-gnu')
|
|
308
|
+
} catch (e) {
|
|
309
|
+
loadErrors.push(e)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
} else if (process.arch === 's390x') {
|
|
313
|
+
try {
|
|
314
|
+
return require('./parser.linux-s390x-gnu.node')
|
|
315
|
+
} catch (e) {
|
|
316
|
+
loadErrors.push(e)
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
return require('@oxc-parser/binding-linux-s390x-gnu')
|
|
320
|
+
} catch (e) {
|
|
321
|
+
loadErrors.push(e)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
} else {
|
|
325
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
nativeBinding = requireNative()
|
|
333
|
+
|
|
334
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
335
|
+
try {
|
|
336
|
+
nativeBinding = require('./parser.wasi.cjs')
|
|
337
|
+
} catch (err) {
|
|
338
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
339
|
+
console.error(err)
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (!nativeBinding) {
|
|
343
|
+
try {
|
|
344
|
+
nativeBinding = require('@oxc-parser/binding-wasm32-wasi')
|
|
345
|
+
} catch (err) {
|
|
346
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
347
|
+
console.error(err)
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (!nativeBinding) {
|
|
354
|
+
if (loadErrors.length > 0) {
|
|
355
|
+
// TODO Link to documentation with potential fixes
|
|
356
|
+
// - The package owner could build/publish bindings for this arch
|
|
357
|
+
// - The user may need to bundle the correct files
|
|
358
|
+
// - The user may need to re-install node_modules to get new packages
|
|
359
|
+
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
360
|
+
}
|
|
361
|
+
throw new Error(`Failed to load native binding`)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
module.exports.moduleLexerAsync = nativeBinding.moduleLexerAsync
|
|
365
|
+
module.exports.moduleLexerSync = nativeBinding.moduleLexerSync
|
|
366
|
+
module.exports.parseAsync = nativeBinding.parseAsync
|
|
367
|
+
module.exports.parseSync = nativeBinding.parseSync
|
|
368
|
+
module.exports.parseWithoutReturn = nativeBinding.parseWithoutReturn
|
package/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface ImportSpecifier {
|
|
|
44
44
|
* * If this import keyword is a dynamic import, this is the start value.
|
|
45
45
|
* * If this import keyword is a static import, this is -1.
|
|
46
46
|
* * If this import keyword is an import.meta expression, this is -2.
|
|
47
|
+
* * If this import is an `export *`, this is -3.
|
|
47
48
|
*/
|
|
48
49
|
d: number
|
|
49
50
|
/**
|
|
@@ -91,7 +92,7 @@ export declare function moduleLexerSync(sourceText: string, options?: ParserOpti
|
|
|
91
92
|
export declare function parseAsync(sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
|
|
92
93
|
|
|
93
94
|
export interface ParseResult {
|
|
94
|
-
program:
|
|
95
|
+
program: import("@oxc-project/types").Program
|
|
95
96
|
comments: Array<Comment>
|
|
96
97
|
errors: Array<string>
|
|
97
98
|
}
|
package/index.js
CHANGED
|
@@ -1,368 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (musl === null) {
|
|
18
|
-
musl = isMuslFromChildProcess()
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return musl
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
-
|
|
26
|
-
const isMuslFromFilesystem = () => {
|
|
27
|
-
try {
|
|
28
|
-
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
-
} catch {
|
|
30
|
-
return null
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const isMuslFromReport = () => {
|
|
35
|
-
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
|
|
36
|
-
if (!report) {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
if (report.header && report.header.glibcVersionRuntime) {
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
if (Array.isArray(report.sharedObjects)) {
|
|
43
|
-
if (report.sharedObjects.some(isFileMusl)) {
|
|
44
|
-
return true
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return false
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const isMuslFromChildProcess = () => {
|
|
51
|
-
try {
|
|
52
|
-
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
53
|
-
} catch (e) {
|
|
54
|
-
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
55
|
-
return false
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function requireNative() {
|
|
60
|
-
if (process.platform === 'android') {
|
|
61
|
-
if (process.arch === 'arm64') {
|
|
62
|
-
try {
|
|
63
|
-
return require('./parser.android-arm64.node')
|
|
64
|
-
} catch (e) {
|
|
65
|
-
loadErrors.push(e)
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
return require('@oxc-parser/binding-android-arm64')
|
|
69
|
-
} catch (e) {
|
|
70
|
-
loadErrors.push(e)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
} else if (process.arch === 'arm') {
|
|
74
|
-
try {
|
|
75
|
-
return require('./parser.android-arm-eabi.node')
|
|
76
|
-
} catch (e) {
|
|
77
|
-
loadErrors.push(e)
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
return require('@oxc-parser/binding-android-arm-eabi')
|
|
81
|
-
} catch (e) {
|
|
82
|
-
loadErrors.push(e)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
} else {
|
|
86
|
-
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
87
|
-
}
|
|
88
|
-
} else if (process.platform === 'win32') {
|
|
89
|
-
if (process.arch === 'x64') {
|
|
90
|
-
try {
|
|
91
|
-
return require('./parser.win32-x64-msvc.node')
|
|
92
|
-
} catch (e) {
|
|
93
|
-
loadErrors.push(e)
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
return require('@oxc-parser/binding-win32-x64-msvc')
|
|
97
|
-
} catch (e) {
|
|
98
|
-
loadErrors.push(e)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
} else if (process.arch === 'ia32') {
|
|
102
|
-
try {
|
|
103
|
-
return require('./parser.win32-ia32-msvc.node')
|
|
104
|
-
} catch (e) {
|
|
105
|
-
loadErrors.push(e)
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
return require('@oxc-parser/binding-win32-ia32-msvc')
|
|
109
|
-
} catch (e) {
|
|
110
|
-
loadErrors.push(e)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
} else if (process.arch === 'arm64') {
|
|
114
|
-
try {
|
|
115
|
-
return require('./parser.win32-arm64-msvc.node')
|
|
116
|
-
} catch (e) {
|
|
117
|
-
loadErrors.push(e)
|
|
118
|
-
}
|
|
119
|
-
try {
|
|
120
|
-
return require('@oxc-parser/binding-win32-arm64-msvc')
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadErrors.push(e)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
127
|
-
}
|
|
128
|
-
} else if (process.platform === 'darwin') {
|
|
129
|
-
try {
|
|
130
|
-
return require('./parser.darwin-universal.node')
|
|
131
|
-
} catch (e) {
|
|
132
|
-
loadErrors.push(e)
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
return require('@oxc-parser/binding-darwin-universal')
|
|
136
|
-
} catch (e) {
|
|
137
|
-
loadErrors.push(e)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (process.arch === 'x64') {
|
|
141
|
-
try {
|
|
142
|
-
return require('./parser.darwin-x64.node')
|
|
143
|
-
} catch (e) {
|
|
144
|
-
loadErrors.push(e)
|
|
145
|
-
}
|
|
146
|
-
try {
|
|
147
|
-
return require('@oxc-parser/binding-darwin-x64')
|
|
148
|
-
} catch (e) {
|
|
149
|
-
loadErrors.push(e)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
} else if (process.arch === 'arm64') {
|
|
153
|
-
try {
|
|
154
|
-
return require('./parser.darwin-arm64.node')
|
|
155
|
-
} catch (e) {
|
|
156
|
-
loadErrors.push(e)
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
return require('@oxc-parser/binding-darwin-arm64')
|
|
160
|
-
} catch (e) {
|
|
161
|
-
loadErrors.push(e)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
} else {
|
|
165
|
-
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
166
|
-
}
|
|
167
|
-
} else if (process.platform === 'freebsd') {
|
|
168
|
-
if (process.arch === 'x64') {
|
|
169
|
-
try {
|
|
170
|
-
return require('./parser.freebsd-x64.node')
|
|
171
|
-
} catch (e) {
|
|
172
|
-
loadErrors.push(e)
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
return require('@oxc-parser/binding-freebsd-x64')
|
|
176
|
-
} catch (e) {
|
|
177
|
-
loadErrors.push(e)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
} else if (process.arch === 'arm64') {
|
|
181
|
-
try {
|
|
182
|
-
return require('./parser.freebsd-arm64.node')
|
|
183
|
-
} catch (e) {
|
|
184
|
-
loadErrors.push(e)
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
return require('@oxc-parser/binding-freebsd-arm64')
|
|
188
|
-
} catch (e) {
|
|
189
|
-
loadErrors.push(e)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
} else {
|
|
193
|
-
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
194
|
-
}
|
|
195
|
-
} else if (process.platform === 'linux') {
|
|
196
|
-
if (process.arch === 'x64') {
|
|
197
|
-
if (isMusl()) {
|
|
198
|
-
try {
|
|
199
|
-
return require('./parser.linux-x64-musl.node')
|
|
200
|
-
} catch (e) {
|
|
201
|
-
loadErrors.push(e)
|
|
202
|
-
}
|
|
203
|
-
try {
|
|
204
|
-
return require('@oxc-parser/binding-linux-x64-musl')
|
|
205
|
-
} catch (e) {
|
|
206
|
-
loadErrors.push(e)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
} else {
|
|
210
|
-
try {
|
|
211
|
-
return require('./parser.linux-x64-gnu.node')
|
|
212
|
-
} catch (e) {
|
|
213
|
-
loadErrors.push(e)
|
|
214
|
-
}
|
|
215
|
-
try {
|
|
216
|
-
return require('@oxc-parser/binding-linux-x64-gnu')
|
|
217
|
-
} catch (e) {
|
|
218
|
-
loadErrors.push(e)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
} else if (process.arch === 'arm64') {
|
|
223
|
-
if (isMusl()) {
|
|
224
|
-
try {
|
|
225
|
-
return require('./parser.linux-arm64-musl.node')
|
|
226
|
-
} catch (e) {
|
|
227
|
-
loadErrors.push(e)
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
return require('@oxc-parser/binding-linux-arm64-musl')
|
|
231
|
-
} catch (e) {
|
|
232
|
-
loadErrors.push(e)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
} else {
|
|
236
|
-
try {
|
|
237
|
-
return require('./parser.linux-arm64-gnu.node')
|
|
238
|
-
} catch (e) {
|
|
239
|
-
loadErrors.push(e)
|
|
240
|
-
}
|
|
241
|
-
try {
|
|
242
|
-
return require('@oxc-parser/binding-linux-arm64-gnu')
|
|
243
|
-
} catch (e) {
|
|
244
|
-
loadErrors.push(e)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
} else if (process.arch === 'arm') {
|
|
249
|
-
if (isMusl()) {
|
|
250
|
-
try {
|
|
251
|
-
return require('./parser.linux-arm-musleabihf.node')
|
|
252
|
-
} catch (e) {
|
|
253
|
-
loadErrors.push(e)
|
|
254
|
-
}
|
|
255
|
-
try {
|
|
256
|
-
return require('@oxc-parser/binding-linux-arm-musleabihf')
|
|
257
|
-
} catch (e) {
|
|
258
|
-
loadErrors.push(e)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
} else {
|
|
262
|
-
try {
|
|
263
|
-
return require('./parser.linux-arm-gnueabihf.node')
|
|
264
|
-
} catch (e) {
|
|
265
|
-
loadErrors.push(e)
|
|
266
|
-
}
|
|
267
|
-
try {
|
|
268
|
-
return require('@oxc-parser/binding-linux-arm-gnueabihf')
|
|
269
|
-
} catch (e) {
|
|
270
|
-
loadErrors.push(e)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
} else if (process.arch === 'riscv64') {
|
|
275
|
-
if (isMusl()) {
|
|
276
|
-
try {
|
|
277
|
-
return require('./parser.linux-riscv64-musl.node')
|
|
278
|
-
} catch (e) {
|
|
279
|
-
loadErrors.push(e)
|
|
280
|
-
}
|
|
281
|
-
try {
|
|
282
|
-
return require('@oxc-parser/binding-linux-riscv64-musl')
|
|
283
|
-
} catch (e) {
|
|
284
|
-
loadErrors.push(e)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
} else {
|
|
288
|
-
try {
|
|
289
|
-
return require('./parser.linux-riscv64-gnu.node')
|
|
290
|
-
} catch (e) {
|
|
291
|
-
loadErrors.push(e)
|
|
292
|
-
}
|
|
293
|
-
try {
|
|
294
|
-
return require('@oxc-parser/binding-linux-riscv64-gnu')
|
|
295
|
-
} catch (e) {
|
|
296
|
-
loadErrors.push(e)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
} else if (process.arch === 'ppc64') {
|
|
301
|
-
try {
|
|
302
|
-
return require('./parser.linux-ppc64-gnu.node')
|
|
303
|
-
} catch (e) {
|
|
304
|
-
loadErrors.push(e)
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
return require('@oxc-parser/binding-linux-ppc64-gnu')
|
|
308
|
-
} catch (e) {
|
|
309
|
-
loadErrors.push(e)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
} else if (process.arch === 's390x') {
|
|
313
|
-
try {
|
|
314
|
-
return require('./parser.linux-s390x-gnu.node')
|
|
315
|
-
} catch (e) {
|
|
316
|
-
loadErrors.push(e)
|
|
317
|
-
}
|
|
318
|
-
try {
|
|
319
|
-
return require('@oxc-parser/binding-linux-s390x-gnu')
|
|
320
|
-
} catch (e) {
|
|
321
|
-
loadErrors.push(e)
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
} else {
|
|
325
|
-
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
326
|
-
}
|
|
327
|
-
} else {
|
|
328
|
-
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
nativeBinding = requireNative()
|
|
333
|
-
|
|
334
|
-
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
335
|
-
try {
|
|
336
|
-
nativeBinding = require('./parser.wasi.cjs')
|
|
337
|
-
} catch (err) {
|
|
338
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
339
|
-
console.error(err)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
if (!nativeBinding) {
|
|
343
|
-
try {
|
|
344
|
-
nativeBinding = require('@oxc-parser/binding-wasm32-wasi')
|
|
345
|
-
} catch (err) {
|
|
346
|
-
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
347
|
-
console.error(err)
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (!nativeBinding) {
|
|
354
|
-
if (loadErrors.length > 0) {
|
|
355
|
-
// TODO Link to documentation with potential fixes
|
|
356
|
-
// - The package owner could build/publish bindings for this arch
|
|
357
|
-
// - The user may need to bundle the correct files
|
|
358
|
-
// - The user may need to re-install node_modules to get new packages
|
|
359
|
-
throw new Error('Failed to load native binding', { cause: loadErrors })
|
|
360
|
-
}
|
|
361
|
-
throw new Error(`Failed to load native binding`)
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
module.exports.moduleLexerAsync = nativeBinding.moduleLexerAsync
|
|
365
|
-
module.exports.moduleLexerSync = nativeBinding.moduleLexerSync
|
|
366
|
-
module.exports.parseAsync = nativeBinding.parseAsync
|
|
367
|
-
module.exports.parseSync = nativeBinding.parseSync
|
|
368
|
-
module.exports.parseWithoutReturn = nativeBinding.parseWithoutReturn
|
|
1
|
+
const bindings = require('./bindings.js');
|
|
2
|
+
|
|
3
|
+
module.exports.moduleLexerAsync = bindings.moduleLexerAsync;
|
|
4
|
+
module.exports.moduleLexerSync = bindings.moduleLexerSync;
|
|
5
|
+
module.exports.parseWithoutReturn = bindings.parseWithoutReturn;
|
|
6
|
+
|
|
7
|
+
module.exports.parseAsync = async function parseAsync(...args) {
|
|
8
|
+
const result = await bindings.parseAsync(...args);
|
|
9
|
+
result.program = JSON.parse(result.program);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
module.exports.parseSync = function parseSync(...args) {
|
|
13
|
+
const result = bindings.parseSync(...args);
|
|
14
|
+
result.program = JSON.parse(result.program);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Oxc Parser Node API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Parser"
|
|
@@ -20,16 +20,20 @@
|
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"files": [
|
|
22
22
|
"index.d.ts",
|
|
23
|
-
"index.js"
|
|
23
|
+
"index.js",
|
|
24
|
+
"bindings.js"
|
|
24
25
|
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@oxc-project/types": "^0.35.0"
|
|
28
|
+
},
|
|
25
29
|
"optionalDependencies": {
|
|
26
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
27
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
28
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
29
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
30
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
31
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
32
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
33
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
30
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.35.0",
|
|
31
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.35.0",
|
|
32
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.35.0",
|
|
33
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.35.0",
|
|
34
|
+
"@oxc-parser/binding-linux-x64-musl": "0.35.0",
|
|
35
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.35.0",
|
|
36
|
+
"@oxc-parser/binding-darwin-x64": "0.35.0",
|
|
37
|
+
"@oxc-parser/binding-darwin-arm64": "0.35.0"
|
|
34
38
|
}
|
|
35
39
|
}
|