oxc-parser 0.96.0 → 0.98.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 +15 -1
- package/generated/deserialize/js.js +7 -7
- package/generated/deserialize/js_range.js +10 -7
- package/generated/deserialize/ts.js +10 -22
- package/generated/deserialize/ts_range.js +13 -22
- package/package.json +20 -20
- package/src-js/bindings.js +56 -56
- package/src-js/index.d.ts +1 -1
- package/src-js/index.js +9 -9
- package/src-js/raw-transfer/common.js +3 -7
- package/src-js/raw-transfer/eager.js +1 -1
- package/src-js/raw-transfer/lazy.js +2 -2
- package/src-js/wasm.js +2 -2
package/README.md
CHANGED
|
@@ -98,6 +98,20 @@ export interface EcmaScriptModule {
|
|
|
98
98
|
|
|
99
99
|
## API
|
|
100
100
|
|
|
101
|
+
### Functions
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Synchronous parsing
|
|
105
|
+
parseSync(filename: string, sourceText: string, options?: ParserOptions): ParseResult
|
|
106
|
+
|
|
107
|
+
// Asynchronous parsing
|
|
108
|
+
parse(filename: string, sourceText: string, options?: ParserOptions): Promise<ParseResult>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Use `parseSync` for synchronous parsing. Use `parse` for asynchronous parsing, which can be beneficial in I/O-bound or concurrent scenarios, though it adds async overhead.
|
|
112
|
+
|
|
113
|
+
### Example
|
|
114
|
+
|
|
101
115
|
```javascript
|
|
102
116
|
import { parseSync, Visitor } from 'oxc-parser';
|
|
103
117
|
|
|
@@ -107,7 +121,7 @@ const code = 'const url: String = /* 🤨 */ import.meta.url;';
|
|
|
107
121
|
const filename = 'test.tsx';
|
|
108
122
|
|
|
109
123
|
const result = parseSync(filename, code);
|
|
110
|
-
//
|
|
124
|
+
// Or use async version: const result = await parse(filename, code);
|
|
111
125
|
|
|
112
126
|
// An array of errors, if any.
|
|
113
127
|
console.log(result.errors);
|
|
@@ -970,8 +970,13 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
970
970
|
end,
|
|
971
971
|
},
|
|
972
972
|
key = deserializeIdentifierReference(pos + 8),
|
|
973
|
-
|
|
974
|
-
|
|
973
|
+
value = {
|
|
974
|
+
type: 'Identifier',
|
|
975
|
+
name: key.name,
|
|
976
|
+
start: key.start,
|
|
977
|
+
end: key.end,
|
|
978
|
+
},
|
|
979
|
+
init = deserializeOptionExpression(pos + 40);
|
|
975
980
|
init !== null &&
|
|
976
981
|
(value = {
|
|
977
982
|
type: 'AssignmentPattern',
|
|
@@ -1808,7 +1813,6 @@ function deserializeArrowFunctionExpression(pos) {
|
|
|
1808
1813
|
expression === true && (body = body.body[0].expression);
|
|
1809
1814
|
node.params = deserializeBoxFormalParameters(pos + 16);
|
|
1810
1815
|
node.body = body;
|
|
1811
|
-
node.id = null;
|
|
1812
1816
|
node.generator = false;
|
|
1813
1817
|
return node;
|
|
1814
1818
|
}
|
|
@@ -2345,7 +2349,6 @@ function deserializeNullLiteral(pos) {
|
|
|
2345
2349
|
start,
|
|
2346
2350
|
end,
|
|
2347
2351
|
};
|
|
2348
|
-
node.value = null;
|
|
2349
2352
|
node.raw = start === 0 && end === 0 ? null : 'null';
|
|
2350
2353
|
return node;
|
|
2351
2354
|
}
|
|
@@ -3517,7 +3520,6 @@ function deserializeTSPropertySignature(pos) {
|
|
|
3517
3520
|
};
|
|
3518
3521
|
node.key = deserializePropertyKey(pos + 8);
|
|
3519
3522
|
node.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
3520
|
-
node.accessibility = null;
|
|
3521
3523
|
node.static = false;
|
|
3522
3524
|
return node;
|
|
3523
3525
|
}
|
|
@@ -3554,7 +3556,6 @@ function deserializeTSIndexSignature(pos) {
|
|
|
3554
3556
|
};
|
|
3555
3557
|
node.parameters = deserializeVecTSIndexSignatureName(pos + 8);
|
|
3556
3558
|
node.typeAnnotation = deserializeBoxTSTypeAnnotation(pos + 32);
|
|
3557
|
-
node.accessibility = null;
|
|
3558
3559
|
return node;
|
|
3559
3560
|
}
|
|
3560
3561
|
|
|
@@ -3614,7 +3615,6 @@ function deserializeTSMethodSignature(pos) {
|
|
|
3614
3615
|
node.typeParameters = deserializeOptionBoxTSTypeParameterDeclaration(pos + 24);
|
|
3615
3616
|
node.params = params;
|
|
3616
3617
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 48);
|
|
3617
|
-
node.accessibility = null;
|
|
3618
3618
|
node.readonly = false;
|
|
3619
3619
|
node.static = false;
|
|
3620
3620
|
return node;
|
|
@@ -1029,8 +1029,16 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
1029
1029
|
range: [start, end],
|
|
1030
1030
|
},
|
|
1031
1031
|
key = deserializeIdentifierReference(pos + 8),
|
|
1032
|
-
|
|
1033
|
-
|
|
1032
|
+
keyStart,
|
|
1033
|
+
keyEnd,
|
|
1034
|
+
value = {
|
|
1035
|
+
type: 'Identifier',
|
|
1036
|
+
name: key.name,
|
|
1037
|
+
start: (keyStart = key.start),
|
|
1038
|
+
end: (keyEnd = key.end),
|
|
1039
|
+
range: [keyStart, keyEnd],
|
|
1040
|
+
},
|
|
1041
|
+
init = deserializeOptionExpression(pos + 40);
|
|
1034
1042
|
init !== null &&
|
|
1035
1043
|
(value = {
|
|
1036
1044
|
type: 'AssignmentPattern',
|
|
@@ -1970,7 +1978,6 @@ function deserializeArrowFunctionExpression(pos) {
|
|
|
1970
1978
|
expression === true && (body = body.body[0].expression);
|
|
1971
1979
|
node.params = deserializeBoxFormalParameters(pos + 16);
|
|
1972
1980
|
node.body = body;
|
|
1973
|
-
node.id = null;
|
|
1974
1981
|
node.generator = false;
|
|
1975
1982
|
return node;
|
|
1976
1983
|
}
|
|
@@ -2550,7 +2557,6 @@ function deserializeNullLiteral(pos) {
|
|
|
2550
2557
|
end,
|
|
2551
2558
|
range: [start, end],
|
|
2552
2559
|
};
|
|
2553
|
-
node.value = null;
|
|
2554
2560
|
node.raw = start === 0 && end === 0 ? null : 'null';
|
|
2555
2561
|
return node;
|
|
2556
2562
|
}
|
|
@@ -3878,7 +3884,6 @@ function deserializeTSPropertySignature(pos) {
|
|
|
3878
3884
|
};
|
|
3879
3885
|
node.key = deserializePropertyKey(pos + 8);
|
|
3880
3886
|
node.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
3881
|
-
node.accessibility = null;
|
|
3882
3887
|
node.static = false;
|
|
3883
3888
|
return node;
|
|
3884
3889
|
}
|
|
@@ -3916,7 +3921,6 @@ function deserializeTSIndexSignature(pos) {
|
|
|
3916
3921
|
};
|
|
3917
3922
|
node.parameters = deserializeVecTSIndexSignatureName(pos + 8);
|
|
3918
3923
|
node.typeAnnotation = deserializeBoxTSTypeAnnotation(pos + 32);
|
|
3919
|
-
node.accessibility = null;
|
|
3920
3924
|
return node;
|
|
3921
3925
|
}
|
|
3922
3926
|
|
|
@@ -3980,7 +3984,6 @@ function deserializeTSMethodSignature(pos) {
|
|
|
3980
3984
|
node.typeParameters = deserializeOptionBoxTSTypeParameterDeclaration(pos + 24);
|
|
3981
3985
|
node.params = params;
|
|
3982
3986
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 48);
|
|
3983
|
-
node.accessibility = null;
|
|
3984
3987
|
node.readonly = false;
|
|
3985
3988
|
node.static = false;
|
|
3986
3989
|
return node;
|
|
@@ -166,7 +166,6 @@ function deserializeIdentifierName(pos) {
|
|
|
166
166
|
};
|
|
167
167
|
node.decorators = [];
|
|
168
168
|
node.optional = false;
|
|
169
|
-
node.typeAnnotation = null;
|
|
170
169
|
return node;
|
|
171
170
|
}
|
|
172
171
|
|
|
@@ -184,7 +183,6 @@ function deserializeIdentifierReference(pos) {
|
|
|
184
183
|
};
|
|
185
184
|
node.decorators = [];
|
|
186
185
|
node.optional = false;
|
|
187
|
-
node.typeAnnotation = null;
|
|
188
186
|
return node;
|
|
189
187
|
}
|
|
190
188
|
|
|
@@ -202,7 +200,6 @@ function deserializeBindingIdentifier(pos) {
|
|
|
202
200
|
};
|
|
203
201
|
node.decorators = [];
|
|
204
202
|
node.optional = false;
|
|
205
|
-
node.typeAnnotation = null;
|
|
206
203
|
return node;
|
|
207
204
|
}
|
|
208
205
|
|
|
@@ -220,7 +217,6 @@ function deserializeLabelIdentifier(pos) {
|
|
|
220
217
|
};
|
|
221
218
|
node.decorators = [];
|
|
222
219
|
node.optional = false;
|
|
223
|
-
node.typeAnnotation = null;
|
|
224
220
|
return node;
|
|
225
221
|
}
|
|
226
222
|
|
|
@@ -930,7 +926,6 @@ function deserializeArrayAssignmentTarget(pos) {
|
|
|
930
926
|
node.decorators = [];
|
|
931
927
|
node.elements = elements;
|
|
932
928
|
node.optional = false;
|
|
933
|
-
node.typeAnnotation = null;
|
|
934
929
|
return node;
|
|
935
930
|
}
|
|
936
931
|
|
|
@@ -950,7 +945,6 @@ function deserializeObjectAssignmentTarget(pos) {
|
|
|
950
945
|
node.decorators = [];
|
|
951
946
|
node.properties = properties;
|
|
952
947
|
node.optional = false;
|
|
953
|
-
node.typeAnnotation = null;
|
|
954
948
|
return node;
|
|
955
949
|
}
|
|
956
950
|
|
|
@@ -968,8 +962,6 @@ function deserializeAssignmentTargetRest(pos) {
|
|
|
968
962
|
node.decorators = [];
|
|
969
963
|
node.argument = deserializeAssignmentTarget(pos + 8);
|
|
970
964
|
node.optional = false;
|
|
971
|
-
node.typeAnnotation = null;
|
|
972
|
-
node.value = null;
|
|
973
965
|
return node;
|
|
974
966
|
}
|
|
975
967
|
|
|
@@ -1017,7 +1009,6 @@ function deserializeAssignmentTargetWithDefault(pos) {
|
|
|
1017
1009
|
node.left = deserializeAssignmentTarget(pos + 8);
|
|
1018
1010
|
node.right = deserializeExpression(pos + 24);
|
|
1019
1011
|
node.optional = false;
|
|
1020
|
-
node.typeAnnotation = null;
|
|
1021
1012
|
return node;
|
|
1022
1013
|
}
|
|
1023
1014
|
|
|
@@ -1048,8 +1039,16 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
1048
1039
|
end,
|
|
1049
1040
|
},
|
|
1050
1041
|
key = deserializeIdentifierReference(pos + 8),
|
|
1051
|
-
|
|
1052
|
-
|
|
1042
|
+
value = {
|
|
1043
|
+
type: 'Identifier',
|
|
1044
|
+
decorators: [],
|
|
1045
|
+
name: key.name,
|
|
1046
|
+
optional: false,
|
|
1047
|
+
typeAnnotation: null,
|
|
1048
|
+
start: key.start,
|
|
1049
|
+
end: key.end,
|
|
1050
|
+
},
|
|
1051
|
+
init = deserializeOptionExpression(pos + 40);
|
|
1053
1052
|
init !== null &&
|
|
1054
1053
|
(value = {
|
|
1055
1054
|
type: 'AssignmentPattern',
|
|
@@ -1360,7 +1359,6 @@ function deserializeExpressionStatement(pos) {
|
|
|
1360
1359
|
end: deserializeU32(pos + 4),
|
|
1361
1360
|
};
|
|
1362
1361
|
node.expression = deserializeExpression(pos + 8);
|
|
1363
|
-
node.directive = null;
|
|
1364
1362
|
return node;
|
|
1365
1363
|
}
|
|
1366
1364
|
|
|
@@ -1752,7 +1750,6 @@ function deserializeAssignmentPattern(pos) {
|
|
|
1752
1750
|
node.left = deserializeBindingPattern(pos + 8);
|
|
1753
1751
|
node.right = deserializeExpression(pos + 40);
|
|
1754
1752
|
node.optional = false;
|
|
1755
|
-
node.typeAnnotation = null;
|
|
1756
1753
|
return node;
|
|
1757
1754
|
}
|
|
1758
1755
|
|
|
@@ -1772,7 +1769,6 @@ function deserializeObjectPattern(pos) {
|
|
|
1772
1769
|
node.decorators = [];
|
|
1773
1770
|
node.properties = properties;
|
|
1774
1771
|
node.optional = false;
|
|
1775
|
-
node.typeAnnotation = null;
|
|
1776
1772
|
return node;
|
|
1777
1773
|
}
|
|
1778
1774
|
|
|
@@ -1815,7 +1811,6 @@ function deserializeArrayPattern(pos) {
|
|
|
1815
1811
|
node.decorators = [];
|
|
1816
1812
|
node.elements = elements;
|
|
1817
1813
|
node.optional = false;
|
|
1818
|
-
node.typeAnnotation = null;
|
|
1819
1814
|
return node;
|
|
1820
1815
|
}
|
|
1821
1816
|
|
|
@@ -1833,8 +1828,6 @@ function deserializeBindingRestElement(pos) {
|
|
|
1833
1828
|
node.decorators = [];
|
|
1834
1829
|
node.argument = deserializeBindingPattern(pos + 8);
|
|
1835
1830
|
node.optional = false;
|
|
1836
|
-
node.typeAnnotation = null;
|
|
1837
|
-
node.value = null;
|
|
1838
1831
|
return node;
|
|
1839
1832
|
}
|
|
1840
1833
|
|
|
@@ -1971,7 +1964,6 @@ function deserializeArrowFunctionExpression(pos) {
|
|
|
1971
1964
|
node.params = deserializeBoxFormalParameters(pos + 16);
|
|
1972
1965
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
1973
1966
|
node.body = body;
|
|
1974
|
-
node.id = null;
|
|
1975
1967
|
node.generator = false;
|
|
1976
1968
|
return node;
|
|
1977
1969
|
}
|
|
@@ -2553,7 +2545,6 @@ function deserializeNullLiteral(pos) {
|
|
|
2553
2545
|
start,
|
|
2554
2546
|
end,
|
|
2555
2547
|
};
|
|
2556
|
-
node.value = null;
|
|
2557
2548
|
node.raw = start === 0 && end === 0 ? null : 'null';
|
|
2558
2549
|
return node;
|
|
2559
2550
|
}
|
|
@@ -3775,7 +3766,6 @@ function deserializeTSPropertySignature(pos) {
|
|
|
3775
3766
|
};
|
|
3776
3767
|
node.key = deserializePropertyKey(pos + 8);
|
|
3777
3768
|
node.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
3778
|
-
node.accessibility = null;
|
|
3779
3769
|
node.static = false;
|
|
3780
3770
|
return node;
|
|
3781
3771
|
}
|
|
@@ -3812,7 +3802,6 @@ function deserializeTSIndexSignature(pos) {
|
|
|
3812
3802
|
};
|
|
3813
3803
|
node.parameters = deserializeVecTSIndexSignatureName(pos + 8);
|
|
3814
3804
|
node.typeAnnotation = deserializeBoxTSTypeAnnotation(pos + 32);
|
|
3815
|
-
node.accessibility = null;
|
|
3816
3805
|
return node;
|
|
3817
3806
|
}
|
|
3818
3807
|
|
|
@@ -3872,7 +3861,6 @@ function deserializeTSMethodSignature(pos) {
|
|
|
3872
3861
|
node.typeParameters = deserializeOptionBoxTSTypeParameterDeclaration(pos + 24);
|
|
3873
3862
|
node.params = params;
|
|
3874
3863
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 48);
|
|
3875
|
-
node.accessibility = null;
|
|
3876
3864
|
node.readonly = false;
|
|
3877
3865
|
node.static = false;
|
|
3878
3866
|
return node;
|
|
@@ -168,7 +168,6 @@ function deserializeIdentifierName(pos) {
|
|
|
168
168
|
};
|
|
169
169
|
node.decorators = [];
|
|
170
170
|
node.optional = false;
|
|
171
|
-
node.typeAnnotation = null;
|
|
172
171
|
return node;
|
|
173
172
|
}
|
|
174
173
|
|
|
@@ -187,7 +186,6 @@ function deserializeIdentifierReference(pos) {
|
|
|
187
186
|
};
|
|
188
187
|
node.decorators = [];
|
|
189
188
|
node.optional = false;
|
|
190
|
-
node.typeAnnotation = null;
|
|
191
189
|
return node;
|
|
192
190
|
}
|
|
193
191
|
|
|
@@ -206,7 +204,6 @@ function deserializeBindingIdentifier(pos) {
|
|
|
206
204
|
};
|
|
207
205
|
node.decorators = [];
|
|
208
206
|
node.optional = false;
|
|
209
|
-
node.typeAnnotation = null;
|
|
210
207
|
return node;
|
|
211
208
|
}
|
|
212
209
|
|
|
@@ -225,7 +222,6 @@ function deserializeLabelIdentifier(pos) {
|
|
|
225
222
|
};
|
|
226
223
|
node.decorators = [];
|
|
227
224
|
node.optional = false;
|
|
228
|
-
node.typeAnnotation = null;
|
|
229
225
|
return node;
|
|
230
226
|
}
|
|
231
227
|
|
|
@@ -979,7 +975,6 @@ function deserializeArrayAssignmentTarget(pos) {
|
|
|
979
975
|
node.decorators = [];
|
|
980
976
|
node.elements = elements;
|
|
981
977
|
node.optional = false;
|
|
982
|
-
node.typeAnnotation = null;
|
|
983
978
|
return node;
|
|
984
979
|
}
|
|
985
980
|
|
|
@@ -1002,7 +997,6 @@ function deserializeObjectAssignmentTarget(pos) {
|
|
|
1002
997
|
node.decorators = [];
|
|
1003
998
|
node.properties = properties;
|
|
1004
999
|
node.optional = false;
|
|
1005
|
-
node.typeAnnotation = null;
|
|
1006
1000
|
return node;
|
|
1007
1001
|
}
|
|
1008
1002
|
|
|
@@ -1023,8 +1017,6 @@ function deserializeAssignmentTargetRest(pos) {
|
|
|
1023
1017
|
node.decorators = [];
|
|
1024
1018
|
node.argument = deserializeAssignmentTarget(pos + 8);
|
|
1025
1019
|
node.optional = false;
|
|
1026
|
-
node.typeAnnotation = null;
|
|
1027
|
-
node.value = null;
|
|
1028
1020
|
return node;
|
|
1029
1021
|
}
|
|
1030
1022
|
|
|
@@ -1075,7 +1067,6 @@ function deserializeAssignmentTargetWithDefault(pos) {
|
|
|
1075
1067
|
node.left = deserializeAssignmentTarget(pos + 8);
|
|
1076
1068
|
node.right = deserializeExpression(pos + 24);
|
|
1077
1069
|
node.optional = false;
|
|
1078
|
-
node.typeAnnotation = null;
|
|
1079
1070
|
return node;
|
|
1080
1071
|
}
|
|
1081
1072
|
|
|
@@ -1107,8 +1098,19 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
1107
1098
|
range: [start, end],
|
|
1108
1099
|
},
|
|
1109
1100
|
key = deserializeIdentifierReference(pos + 8),
|
|
1110
|
-
|
|
1111
|
-
|
|
1101
|
+
keyStart,
|
|
1102
|
+
keyEnd,
|
|
1103
|
+
value = {
|
|
1104
|
+
type: 'Identifier',
|
|
1105
|
+
decorators: [],
|
|
1106
|
+
name: key.name,
|
|
1107
|
+
optional: false,
|
|
1108
|
+
typeAnnotation: null,
|
|
1109
|
+
start: (keyStart = key.start),
|
|
1110
|
+
end: (keyEnd = key.end),
|
|
1111
|
+
range: [keyStart, keyEnd],
|
|
1112
|
+
},
|
|
1113
|
+
init = deserializeOptionExpression(pos + 40);
|
|
1112
1114
|
init !== null &&
|
|
1113
1115
|
(value = {
|
|
1114
1116
|
type: 'AssignmentPattern',
|
|
@@ -1450,7 +1452,6 @@ function deserializeExpressionStatement(pos) {
|
|
|
1450
1452
|
range: [start, end],
|
|
1451
1453
|
};
|
|
1452
1454
|
node.expression = deserializeExpression(pos + 8);
|
|
1453
|
-
node.directive = null;
|
|
1454
1455
|
return node;
|
|
1455
1456
|
}
|
|
1456
1457
|
|
|
@@ -1894,7 +1895,6 @@ function deserializeAssignmentPattern(pos) {
|
|
|
1894
1895
|
node.left = deserializeBindingPattern(pos + 8);
|
|
1895
1896
|
node.right = deserializeExpression(pos + 40);
|
|
1896
1897
|
node.optional = false;
|
|
1897
|
-
node.typeAnnotation = null;
|
|
1898
1898
|
return node;
|
|
1899
1899
|
}
|
|
1900
1900
|
|
|
@@ -1917,7 +1917,6 @@ function deserializeObjectPattern(pos) {
|
|
|
1917
1917
|
node.decorators = [];
|
|
1918
1918
|
node.properties = properties;
|
|
1919
1919
|
node.optional = false;
|
|
1920
|
-
node.typeAnnotation = null;
|
|
1921
1920
|
return node;
|
|
1922
1921
|
}
|
|
1923
1922
|
|
|
@@ -1964,7 +1963,6 @@ function deserializeArrayPattern(pos) {
|
|
|
1964
1963
|
node.decorators = [];
|
|
1965
1964
|
node.elements = elements;
|
|
1966
1965
|
node.optional = false;
|
|
1967
|
-
node.typeAnnotation = null;
|
|
1968
1966
|
return node;
|
|
1969
1967
|
}
|
|
1970
1968
|
|
|
@@ -1985,8 +1983,6 @@ function deserializeBindingRestElement(pos) {
|
|
|
1985
1983
|
node.decorators = [];
|
|
1986
1984
|
node.argument = deserializeBindingPattern(pos + 8);
|
|
1987
1985
|
node.optional = false;
|
|
1988
|
-
node.typeAnnotation = null;
|
|
1989
|
-
node.value = null;
|
|
1990
1986
|
return node;
|
|
1991
1987
|
}
|
|
1992
1988
|
|
|
@@ -2133,7 +2129,6 @@ function deserializeArrowFunctionExpression(pos) {
|
|
|
2133
2129
|
node.params = deserializeBoxFormalParameters(pos + 16);
|
|
2134
2130
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
2135
2131
|
node.body = body;
|
|
2136
|
-
node.id = null;
|
|
2137
2132
|
node.generator = false;
|
|
2138
2133
|
return node;
|
|
2139
2134
|
}
|
|
@@ -2750,7 +2745,6 @@ function deserializeNullLiteral(pos) {
|
|
|
2750
2745
|
end,
|
|
2751
2746
|
range: [start, end],
|
|
2752
2747
|
};
|
|
2753
|
-
node.value = null;
|
|
2754
2748
|
node.raw = start === 0 && end === 0 ? null : 'null';
|
|
2755
2749
|
return node;
|
|
2756
2750
|
}
|
|
@@ -4135,7 +4129,6 @@ function deserializeTSPropertySignature(pos) {
|
|
|
4135
4129
|
};
|
|
4136
4130
|
node.key = deserializePropertyKey(pos + 8);
|
|
4137
4131
|
node.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 24);
|
|
4138
|
-
node.accessibility = null;
|
|
4139
4132
|
node.static = false;
|
|
4140
4133
|
return node;
|
|
4141
4134
|
}
|
|
@@ -4173,7 +4166,6 @@ function deserializeTSIndexSignature(pos) {
|
|
|
4173
4166
|
};
|
|
4174
4167
|
node.parameters = deserializeVecTSIndexSignatureName(pos + 8);
|
|
4175
4168
|
node.typeAnnotation = deserializeBoxTSTypeAnnotation(pos + 32);
|
|
4176
|
-
node.accessibility = null;
|
|
4177
4169
|
return node;
|
|
4178
4170
|
}
|
|
4179
4171
|
|
|
@@ -4237,7 +4229,6 @@ function deserializeTSMethodSignature(pos) {
|
|
|
4237
4229
|
node.typeParameters = deserializeOptionBoxTSTypeParameterDeclaration(pos + 24);
|
|
4238
4230
|
node.params = params;
|
|
4239
4231
|
node.returnType = deserializeOptionBoxTSTypeAnnotation(pos + 48);
|
|
4240
|
-
node.accessibility = null;
|
|
4241
4232
|
node.readonly = false;
|
|
4242
4233
|
node.static = false;
|
|
4243
4234
|
return node;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src-js/index.js",
|
|
6
6
|
"browser": "src-js/wasm.js",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@oxc-project/types": "^0.
|
|
61
|
+
"@oxc-project/types": "^0.98.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@codspeed/vitest-plugin": "^5.0.0",
|
|
65
65
|
"@napi-rs/wasm-runtime": "1.0.7",
|
|
66
66
|
"@typescript-eslint/visitor-keys": "^8.44.0",
|
|
67
|
-
"@vitest/browser": "4.0.
|
|
68
|
-
"@vitest/browser-playwright": "4.0.
|
|
67
|
+
"@vitest/browser": "4.0.6",
|
|
68
|
+
"@vitest/browser-playwright": "4.0.6",
|
|
69
69
|
"esbuild": "^0.25.0",
|
|
70
70
|
"playwright": "^1.51.0",
|
|
71
71
|
"tinypool": "^2.0.0",
|
|
72
72
|
"typescript": "5.9.3",
|
|
73
|
-
"vitest": "4.0.
|
|
73
|
+
"vitest": "4.0.6"
|
|
74
74
|
},
|
|
75
75
|
"napi": {
|
|
76
76
|
"binaryName": "parser",
|
|
@@ -100,21 +100,21 @@
|
|
|
100
100
|
"dtsHeaderFile": "src-js/header.d.ts"
|
|
101
101
|
},
|
|
102
102
|
"optionalDependencies": {
|
|
103
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
104
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
105
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
106
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
107
|
-
"@oxc-parser/binding-freebsd-x64": "0.
|
|
108
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
109
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
110
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
111
|
-
"@oxc-parser/binding-linux-arm-musleabihf": "0.
|
|
112
|
-
"@oxc-parser/binding-linux-s390x-gnu": "0.
|
|
113
|
-
"@oxc-parser/binding-linux-riscv64-gnu": "0.
|
|
114
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
115
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
116
|
-
"@oxc-parser/binding-android-arm64": "0.
|
|
117
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
103
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.98.0",
|
|
104
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.98.0",
|
|
105
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.98.0",
|
|
106
|
+
"@oxc-parser/binding-linux-x64-musl": "0.98.0",
|
|
107
|
+
"@oxc-parser/binding-freebsd-x64": "0.98.0",
|
|
108
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.98.0",
|
|
109
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.98.0",
|
|
110
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.98.0",
|
|
111
|
+
"@oxc-parser/binding-linux-arm-musleabihf": "0.98.0",
|
|
112
|
+
"@oxc-parser/binding-linux-s390x-gnu": "0.98.0",
|
|
113
|
+
"@oxc-parser/binding-linux-riscv64-gnu": "0.98.0",
|
|
114
|
+
"@oxc-parser/binding-darwin-x64": "0.98.0",
|
|
115
|
+
"@oxc-parser/binding-darwin-arm64": "0.98.0",
|
|
116
|
+
"@oxc-parser/binding-android-arm64": "0.98.0",
|
|
117
|
+
"@oxc-parser/binding-wasm32-wasi": "0.98.0"
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"build-dev": "napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js",
|
package/src-js/bindings.js
CHANGED
|
@@ -81,8 +81,8 @@ function requireNative() {
|
|
|
81
81
|
try {
|
|
82
82
|
const binding = require('@oxc-parser/binding-android-arm64')
|
|
83
83
|
const bindingPackageVersion = require('@oxc-parser/binding-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '0.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
84
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
86
|
}
|
|
87
87
|
return binding
|
|
88
88
|
} catch (e) {
|
|
@@ -97,8 +97,8 @@ function requireNative() {
|
|
|
97
97
|
try {
|
|
98
98
|
const binding = require('@oxc-parser/binding-android-arm-eabi')
|
|
99
99
|
const bindingPackageVersion = require('@oxc-parser/binding-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '0.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
100
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -118,8 +118,8 @@ function requireNative() {
|
|
|
118
118
|
try {
|
|
119
119
|
const binding = require('@oxc-parser/binding-win32-x64-gnu')
|
|
120
120
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '0.
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
121
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
122
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
123
|
}
|
|
124
124
|
return binding
|
|
125
125
|
} catch (e) {
|
|
@@ -134,8 +134,8 @@ function requireNative() {
|
|
|
134
134
|
try {
|
|
135
135
|
const binding = require('@oxc-parser/binding-win32-x64-msvc')
|
|
136
136
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '0.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
137
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
139
|
}
|
|
140
140
|
return binding
|
|
141
141
|
} catch (e) {
|
|
@@ -151,8 +151,8 @@ function requireNative() {
|
|
|
151
151
|
try {
|
|
152
152
|
const binding = require('@oxc-parser/binding-win32-ia32-msvc')
|
|
153
153
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '0.
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
154
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
155
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
156
|
}
|
|
157
157
|
return binding
|
|
158
158
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('@oxc-parser/binding-win32-arm64-msvc')
|
|
169
169
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
170
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -186,8 +186,8 @@ function requireNative() {
|
|
|
186
186
|
try {
|
|
187
187
|
const binding = require('@oxc-parser/binding-darwin-universal')
|
|
188
188
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '0.
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
189
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
190
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
191
|
}
|
|
192
192
|
return binding
|
|
193
193
|
} catch (e) {
|
|
@@ -202,8 +202,8 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require('@oxc-parser/binding-darwin-x64')
|
|
204
204
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '0.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
205
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
207
|
}
|
|
208
208
|
return binding
|
|
209
209
|
} catch (e) {
|
|
@@ -218,8 +218,8 @@ function requireNative() {
|
|
|
218
218
|
try {
|
|
219
219
|
const binding = require('@oxc-parser/binding-darwin-arm64')
|
|
220
220
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '0.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
221
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
223
|
}
|
|
224
224
|
return binding
|
|
225
225
|
} catch (e) {
|
|
@@ -238,8 +238,8 @@ function requireNative() {
|
|
|
238
238
|
try {
|
|
239
239
|
const binding = require('@oxc-parser/binding-freebsd-x64')
|
|
240
240
|
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '0.
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
241
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
242
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
243
|
}
|
|
244
244
|
return binding
|
|
245
245
|
} catch (e) {
|
|
@@ -254,8 +254,8 @@ function requireNative() {
|
|
|
254
254
|
try {
|
|
255
255
|
const binding = require('@oxc-parser/binding-freebsd-arm64')
|
|
256
256
|
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '0.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
257
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
259
|
}
|
|
260
260
|
return binding
|
|
261
261
|
} catch (e) {
|
|
@@ -275,8 +275,8 @@ function requireNative() {
|
|
|
275
275
|
try {
|
|
276
276
|
const binding = require('@oxc-parser/binding-linux-x64-musl')
|
|
277
277
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '0.
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
278
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
279
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
280
|
}
|
|
281
281
|
return binding
|
|
282
282
|
} catch (e) {
|
|
@@ -291,8 +291,8 @@ function requireNative() {
|
|
|
291
291
|
try {
|
|
292
292
|
const binding = require('@oxc-parser/binding-linux-x64-gnu')
|
|
293
293
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '0.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
294
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
296
|
}
|
|
297
297
|
return binding
|
|
298
298
|
} catch (e) {
|
|
@@ -309,8 +309,8 @@ function requireNative() {
|
|
|
309
309
|
try {
|
|
310
310
|
const binding = require('@oxc-parser/binding-linux-arm64-musl')
|
|
311
311
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '0.
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
312
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
313
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
314
|
}
|
|
315
315
|
return binding
|
|
316
316
|
} catch (e) {
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('@oxc-parser/binding-linux-arm64-gnu')
|
|
327
327
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '0.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
328
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
330
|
}
|
|
331
331
|
return binding
|
|
332
332
|
} catch (e) {
|
|
@@ -343,8 +343,8 @@ function requireNative() {
|
|
|
343
343
|
try {
|
|
344
344
|
const binding = require('@oxc-parser/binding-linux-arm-musleabihf')
|
|
345
345
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '0.
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
346
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
347
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
348
|
}
|
|
349
349
|
return binding
|
|
350
350
|
} catch (e) {
|
|
@@ -359,8 +359,8 @@ function requireNative() {
|
|
|
359
359
|
try {
|
|
360
360
|
const binding = require('@oxc-parser/binding-linux-arm-gnueabihf')
|
|
361
361
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '0.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
362
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
364
|
}
|
|
365
365
|
return binding
|
|
366
366
|
} catch (e) {
|
|
@@ -377,8 +377,8 @@ function requireNative() {
|
|
|
377
377
|
try {
|
|
378
378
|
const binding = require('@oxc-parser/binding-linux-loong64-musl')
|
|
379
379
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '0.
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
380
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
381
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
382
|
}
|
|
383
383
|
return binding
|
|
384
384
|
} catch (e) {
|
|
@@ -393,8 +393,8 @@ function requireNative() {
|
|
|
393
393
|
try {
|
|
394
394
|
const binding = require('@oxc-parser/binding-linux-loong64-gnu')
|
|
395
395
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '0.
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
396
|
+
if (bindingPackageVersion !== '0.98.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.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
398
|
}
|
|
399
399
|
return binding
|
|
400
400
|
} catch (e) {
|
|
@@ -411,8 +411,8 @@ function requireNative() {
|
|
|
411
411
|
try {
|
|
412
412
|
const binding = require('@oxc-parser/binding-linux-riscv64-musl')
|
|
413
413
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '0.
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
414
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
415
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
416
|
}
|
|
417
417
|
return binding
|
|
418
418
|
} catch (e) {
|
|
@@ -427,8 +427,8 @@ function requireNative() {
|
|
|
427
427
|
try {
|
|
428
428
|
const binding = require('@oxc-parser/binding-linux-riscv64-gnu')
|
|
429
429
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '0.
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
430
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
431
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
432
|
}
|
|
433
433
|
return binding
|
|
434
434
|
} catch (e) {
|
|
@@ -444,8 +444,8 @@ function requireNative() {
|
|
|
444
444
|
try {
|
|
445
445
|
const binding = require('@oxc-parser/binding-linux-ppc64-gnu')
|
|
446
446
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '0.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
447
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
448
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
449
|
}
|
|
450
450
|
return binding
|
|
451
451
|
} catch (e) {
|
|
@@ -460,8 +460,8 @@ function requireNative() {
|
|
|
460
460
|
try {
|
|
461
461
|
const binding = require('@oxc-parser/binding-linux-s390x-gnu')
|
|
462
462
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '0.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
463
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
464
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -480,8 +480,8 @@ function requireNative() {
|
|
|
480
480
|
try {
|
|
481
481
|
const binding = require('@oxc-parser/binding-openharmony-arm64')
|
|
482
482
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '0.
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
483
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
484
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
485
|
}
|
|
486
486
|
return binding
|
|
487
487
|
} catch (e) {
|
|
@@ -496,8 +496,8 @@ function requireNative() {
|
|
|
496
496
|
try {
|
|
497
497
|
const binding = require('@oxc-parser/binding-openharmony-x64')
|
|
498
498
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '0.
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
499
|
+
if (bindingPackageVersion !== '0.98.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
500
|
+
throw new Error(`Native binding package version mismatch, expected 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
501
|
}
|
|
502
502
|
return binding
|
|
503
503
|
} catch (e) {
|
|
@@ -512,8 +512,8 @@ function requireNative() {
|
|
|
512
512
|
try {
|
|
513
513
|
const binding = require('@oxc-parser/binding-openharmony-arm')
|
|
514
514
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '0.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
515
|
+
if (bindingPackageVersion !== '0.98.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 0.98.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
517
|
}
|
|
518
518
|
return binding
|
|
519
519
|
} catch (e) {
|
|
@@ -583,15 +583,15 @@ if (!nativeBinding) {
|
|
|
583
583
|
throw new Error(`Failed to load native binding`)
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
const { Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind,
|
|
586
|
+
const { Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse, parseSync, rawTransferSupported } = nativeBinding
|
|
587
587
|
export { Severity }
|
|
588
588
|
export { ParseResult }
|
|
589
589
|
export { ExportExportNameKind }
|
|
590
590
|
export { ExportImportNameKind }
|
|
591
591
|
export { ExportLocalNameKind }
|
|
592
592
|
export { ImportNameKind }
|
|
593
|
-
export {
|
|
593
|
+
export { parse }
|
|
594
594
|
export { parseSync }
|
|
595
595
|
export { rawTransferSupported }
|
|
596
|
-
const { getBufferOffset,
|
|
597
|
-
export { getBufferOffset,
|
|
596
|
+
const { getBufferOffset, parseRaw, parseRawSync } = nativeBinding
|
|
597
|
+
export { getBufferOffset, parseRaw, parseRawSync }
|
package/src-js/index.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ export declare const enum ImportNameKind {
|
|
|
146
146
|
*
|
|
147
147
|
* Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
|
|
148
148
|
*/
|
|
149
|
-
export declare function
|
|
149
|
+
export declare function parse(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
|
|
150
150
|
|
|
151
151
|
export interface ParserOptions {
|
|
152
152
|
/** Treat the source text as `js`, `jsx`, `ts`, `tsx` or `dts`. */
|
package/src-js/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import {
|
|
2
|
+
import { parse as parseBinding, parseSync as parseSyncBinding } from './bindings.js';
|
|
3
3
|
import { wrap } from './wrap.js';
|
|
4
4
|
|
|
5
5
|
export { default as visitorKeys } from '../generated/visit/keys.js';
|
|
@@ -19,9 +19,9 @@ const require = createRequire(import.meta.url);
|
|
|
19
19
|
|
|
20
20
|
// Lazily loaded as needed
|
|
21
21
|
let parseSyncRaw = null,
|
|
22
|
-
|
|
22
|
+
parseRaw,
|
|
23
23
|
parseSyncLazy = null,
|
|
24
|
-
|
|
24
|
+
parseLazy,
|
|
25
25
|
LazyVisitor;
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -30,7 +30,7 @@ let parseSyncRaw = null,
|
|
|
30
30
|
*/
|
|
31
31
|
function loadRawTransfer() {
|
|
32
32
|
if (parseSyncRaw === null) {
|
|
33
|
-
({ parseSyncRaw,
|
|
33
|
+
({ parseSyncRaw, parse: parseRaw } = require('./raw-transfer/eager.js'));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ function loadRawTransfer() {
|
|
|
40
40
|
*/
|
|
41
41
|
function loadRawTransferLazy() {
|
|
42
42
|
if (parseSyncLazy === null) {
|
|
43
|
-
({ parseSyncLazy,
|
|
43
|
+
({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require('./raw-transfer/lazy.js'));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -86,16 +86,16 @@ export function parseSync(filename, sourceText, options) {
|
|
|
86
86
|
* @throws {Error} - If `experimentalRawTransfer` or `experimentalLazy` option is enabled,
|
|
87
87
|
* and raw transfer is not supported on this platform
|
|
88
88
|
*/
|
|
89
|
-
export async function
|
|
89
|
+
export async function parse(filename, sourceText, options) {
|
|
90
90
|
if (options?.experimentalRawTransfer) {
|
|
91
91
|
loadRawTransfer();
|
|
92
|
-
return await
|
|
92
|
+
return await parseRaw(filename, sourceText, options);
|
|
93
93
|
}
|
|
94
94
|
if (options?.experimentalLazy) {
|
|
95
95
|
loadRawTransferLazy();
|
|
96
|
-
return await
|
|
96
|
+
return await parseLazy(filename, sourceText, options);
|
|
97
97
|
}
|
|
98
|
-
return wrap(await
|
|
98
|
+
return wrap(await parseBinding(filename, sourceText, options));
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import { BUFFER_ALIGN, BUFFER_SIZE, IS_TS_FLAG_POS } from '../../generated/constants.js';
|
|
3
|
-
import {
|
|
4
|
-
getBufferOffset,
|
|
5
|
-
parseAsyncRaw as parseAsyncRawBinding,
|
|
6
|
-
parseSyncRaw as parseSyncRawBinding,
|
|
7
|
-
} from '../bindings.js';
|
|
3
|
+
import { getBufferOffset, parseRaw as parseRawBinding, parseRawSync as parseRawSyncBinding } from '../bindings.js';
|
|
8
4
|
import { rawTransferSupported } from './supported.js';
|
|
9
5
|
|
|
10
6
|
// Throw an error if running on a platform which raw transfer doesn't support.
|
|
@@ -34,7 +30,7 @@ if (!rawTransferSupported()) {
|
|
|
34
30
|
*/
|
|
35
31
|
export function parseSyncRawImpl(filename, sourceText, options, convert) {
|
|
36
32
|
const { buffer, sourceByteLen } = prepareRaw(sourceText);
|
|
37
|
-
|
|
33
|
+
parseRawSyncBinding(filename, buffer, sourceByteLen, options);
|
|
38
34
|
return convert(buffer, sourceText, sourceByteLen, options);
|
|
39
35
|
}
|
|
40
36
|
|
|
@@ -114,7 +110,7 @@ export async function parseAsyncRawImpl(filename, sourceText, options, convert)
|
|
|
114
110
|
|
|
115
111
|
// Parse
|
|
116
112
|
const { buffer, sourceByteLen } = prepareRaw(sourceText);
|
|
117
|
-
await
|
|
113
|
+
await parseRawBinding(filename, buffer, sourceByteLen, options);
|
|
118
114
|
const data = convert(buffer, sourceText, sourceByteLen, options);
|
|
119
115
|
|
|
120
116
|
// Free the CPU core
|
|
@@ -35,7 +35,7 @@ export function parseSyncRaw(filename, sourceText, options) {
|
|
|
35
35
|
* @param {Object} options - Parsing options
|
|
36
36
|
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
|
|
37
37
|
*/
|
|
38
|
-
export function
|
|
38
|
+
export function parse(filename, sourceText, options) {
|
|
39
39
|
let _;
|
|
40
40
|
({ experimentalRawTransfer: _, ...options } = options);
|
|
41
41
|
return parseAsyncRawImpl(filename, sourceText, options, deserialize);
|
|
@@ -44,7 +44,7 @@ export function parseSyncLazy(filename, sourceText, options) {
|
|
|
44
44
|
* e.g. `program` in returned object is an instance of `Program` class, with getters for `start`, `end`,
|
|
45
45
|
* `body` etc.
|
|
46
46
|
*
|
|
47
|
-
* Because this function does not deserialize the AST, unlike `
|
|
47
|
+
* Because this function does not deserialize the AST, unlike `parse`, very little work happens
|
|
48
48
|
* on current thread in this function. Deserialization work only occurs when properties of the objects
|
|
49
49
|
* are accessed.
|
|
50
50
|
*
|
|
@@ -62,7 +62,7 @@ export function parseSyncLazy(filename, sourceText, options) {
|
|
|
62
62
|
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`,
|
|
63
63
|
* and `dispose` and `visit` methods
|
|
64
64
|
*/
|
|
65
|
-
export function
|
|
65
|
+
export function parse(filename, sourceText, options) {
|
|
66
66
|
let _;
|
|
67
67
|
({ experimentalLazy: _, ...options } = options);
|
|
68
68
|
return parseAsyncRawImpl(filename, sourceText, options, construct);
|
package/src-js/wasm.js
CHANGED
|
@@ -2,8 +2,8 @@ export * from '@oxc-parser/binding-wasm32-wasi';
|
|
|
2
2
|
import * as bindings from '@oxc-parser/binding-wasm32-wasi';
|
|
3
3
|
import { wrap } from './wrap.js';
|
|
4
4
|
|
|
5
|
-
export async function
|
|
6
|
-
return wrap(await bindings.
|
|
5
|
+
export async function parse(...args) {
|
|
6
|
+
return wrap(await bindings.parse(...args));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function parseSync(filename, sourceText, options) {
|