oxc-parser 0.62.0 → 0.64.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.js +5 -1
- package/deserialize-js.js +54 -51
- package/deserialize-ts.js +100 -57
- package/package.json +14 -14
package/bindings.js
CHANGED
|
@@ -35,7 +35,11 @@ const isMuslFromFilesystem = () => {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const isMuslFromReport = () => {
|
|
38
|
-
|
|
38
|
+
let report = null
|
|
39
|
+
if (typeof process.report?.getReport === 'function') {
|
|
40
|
+
process.report.excludeNetwork = true
|
|
41
|
+
report = process.report.getReport()
|
|
42
|
+
}
|
|
39
43
|
if (!report) {
|
|
40
44
|
return null
|
|
41
45
|
}
|
package/deserialize-js.js
CHANGED
|
@@ -37,14 +37,19 @@ function deserialize(buffer, sourceTextInput, sourceLenInput) {
|
|
|
37
37
|
function deserializeProgram(pos) {
|
|
38
38
|
const body = deserializeVecDirective(pos + 88);
|
|
39
39
|
body.push(...deserializeVecStatement(pos + 120));
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
const start = deserializeU32(pos);
|
|
42
|
+
const end = deserializeU32(pos + 4);
|
|
43
|
+
|
|
44
|
+
const program = {
|
|
41
45
|
type: 'Program',
|
|
42
|
-
start
|
|
43
|
-
end
|
|
46
|
+
start,
|
|
47
|
+
end,
|
|
44
48
|
body,
|
|
45
49
|
sourceType: deserializeModuleKind(pos + 9),
|
|
46
50
|
hashbang: deserializeOptionHashbang(pos + 64),
|
|
47
51
|
};
|
|
52
|
+
return program;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
function deserializeIdentifierName(pos) {
|
|
@@ -148,13 +153,15 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
function deserializeTemplateElement(pos) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const tail = deserializeBool(pos + 40),
|
|
157
|
+
start = deserializeU32(pos),
|
|
158
|
+
end = deserializeU32(pos + 4),
|
|
159
|
+
value = deserializeTemplateElementValue(pos + 8);
|
|
160
|
+
if (value.cooked !== null && deserializeBool(pos + 41)) {
|
|
161
|
+
value.cooked = value.cooked
|
|
162
|
+
.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
163
|
+
}
|
|
164
|
+
return { type: 'TemplateElement', start, end, value, tail };
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
function deserializeTemplateElementValue(pos) {
|
|
@@ -899,13 +906,12 @@ function deserializeAccessorProperty(pos) {
|
|
|
899
906
|
}
|
|
900
907
|
|
|
901
908
|
function deserializeImportExpression(pos) {
|
|
902
|
-
const options = deserializeVecExpression(pos + 24);
|
|
903
909
|
return {
|
|
904
910
|
type: 'ImportExpression',
|
|
905
911
|
start: deserializeU32(pos),
|
|
906
912
|
end: deserializeU32(pos + 4),
|
|
907
913
|
source: deserializeExpression(pos + 8),
|
|
908
|
-
options:
|
|
914
|
+
options: deserializeOptionExpression(pos + 24),
|
|
909
915
|
};
|
|
910
916
|
}
|
|
911
917
|
|
|
@@ -1126,12 +1132,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1126
1132
|
}
|
|
1127
1133
|
|
|
1128
1134
|
function deserializeJSXElement(pos) {
|
|
1135
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1136
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1137
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1129
1138
|
return {
|
|
1130
1139
|
type: 'JSXElement',
|
|
1131
1140
|
start: deserializeU32(pos),
|
|
1132
1141
|
end: deserializeU32(pos + 4),
|
|
1133
|
-
openingElement
|
|
1134
|
-
closingElement
|
|
1142
|
+
openingElement,
|
|
1143
|
+
closingElement,
|
|
1135
1144
|
children: deserializeVecJSXChild(pos + 24),
|
|
1136
1145
|
};
|
|
1137
1146
|
}
|
|
@@ -1141,9 +1150,9 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1141
1150
|
type: 'JSXOpeningElement',
|
|
1142
1151
|
start: deserializeU32(pos),
|
|
1143
1152
|
end: deserializeU32(pos + 4),
|
|
1144
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1145
|
-
name: deserializeJSXElementName(pos +
|
|
1146
|
-
selfClosing:
|
|
1153
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1154
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1155
|
+
selfClosing: false,
|
|
1147
1156
|
};
|
|
1148
1157
|
}
|
|
1149
1158
|
|
|
@@ -1168,13 +1177,14 @@ function deserializeJSXFragment(pos) {
|
|
|
1168
1177
|
}
|
|
1169
1178
|
|
|
1170
1179
|
function deserializeJSXOpeningFragment(pos) {
|
|
1171
|
-
|
|
1180
|
+
const node = {
|
|
1172
1181
|
type: 'JSXOpeningFragment',
|
|
1173
1182
|
start: deserializeU32(pos),
|
|
1174
1183
|
end: deserializeU32(pos + 4),
|
|
1175
1184
|
attributes: [],
|
|
1176
1185
|
selfClosing: false,
|
|
1177
1186
|
};
|
|
1187
|
+
return node;
|
|
1178
1188
|
}
|
|
1179
1189
|
|
|
1180
1190
|
function deserializeJSXClosingFragment(pos) {
|
|
@@ -1287,9 +1297,18 @@ function deserializeTSEnumDeclaration(pos) {
|
|
|
1287
1297
|
start: deserializeU32(pos),
|
|
1288
1298
|
end: deserializeU32(pos + 4),
|
|
1289
1299
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1290
|
-
|
|
1291
|
-
const: deserializeBool(pos +
|
|
1292
|
-
declare: deserializeBool(pos +
|
|
1300
|
+
body: deserializeTSEnumBody(pos + 40),
|
|
1301
|
+
const: deserializeBool(pos + 80),
|
|
1302
|
+
declare: deserializeBool(pos + 81),
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function deserializeTSEnumBody(pos) {
|
|
1307
|
+
return {
|
|
1308
|
+
type: 'TSEnumBody',
|
|
1309
|
+
start: deserializeU32(pos),
|
|
1310
|
+
end: deserializeU32(pos + 4),
|
|
1311
|
+
members: deserializeVecTSEnumMember(pos + 8),
|
|
1293
1312
|
};
|
|
1294
1313
|
}
|
|
1295
1314
|
|
|
@@ -1299,6 +1318,7 @@ function deserializeTSEnumMember(pos) {
|
|
|
1299
1318
|
start: deserializeU32(pos),
|
|
1300
1319
|
end: deserializeU32(pos + 4),
|
|
1301
1320
|
id: deserializeTSEnumMemberName(pos + 8),
|
|
1321
|
+
computed: deserializeU8(pos + 8) > 1,
|
|
1302
1322
|
initializer: deserializeOptionExpression(pos + 24),
|
|
1303
1323
|
};
|
|
1304
1324
|
}
|
|
@@ -1799,7 +1819,6 @@ function deserializeTSImportType(pos) {
|
|
|
1799
1819
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1800
1820
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1801
1821
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1802
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1803
1822
|
};
|
|
1804
1823
|
}
|
|
1805
1824
|
|
|
@@ -1827,15 +1846,17 @@ function deserializeTSConstructorType(pos) {
|
|
|
1827
1846
|
}
|
|
1828
1847
|
|
|
1829
1848
|
function deserializeTSMappedType(pos) {
|
|
1849
|
+
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
1830
1850
|
return {
|
|
1831
1851
|
type: 'TSMappedType',
|
|
1832
1852
|
start: deserializeU32(pos),
|
|
1833
1853
|
end: deserializeU32(pos + 4),
|
|
1834
|
-
typeParameter: deserializeBoxTSTypeParameter(pos + 8),
|
|
1835
1854
|
nameType: deserializeOptionTSType(pos + 16),
|
|
1836
1855
|
typeAnnotation: deserializeOptionTSType(pos + 32),
|
|
1837
1856
|
optional: deserializeTSMappedTypeModifierOperator(pos + 48),
|
|
1838
1857
|
readonly: deserializeTSMappedTypeModifierOperator(pos + 49),
|
|
1858
|
+
key: typeParameter.name,
|
|
1859
|
+
constraint: typeParameter.constraint,
|
|
1839
1860
|
};
|
|
1840
1861
|
}
|
|
1841
1862
|
|
|
@@ -1941,13 +1962,13 @@ function deserializeTSInstantiationExpression(pos) {
|
|
|
1941
1962
|
start: deserializeU32(pos),
|
|
1942
1963
|
end: deserializeU32(pos + 4),
|
|
1943
1964
|
expression: deserializeExpression(pos + 8),
|
|
1944
|
-
|
|
1965
|
+
typeArguments: deserializeBoxTSTypeParameterInstantiation(pos + 24),
|
|
1945
1966
|
};
|
|
1946
1967
|
}
|
|
1947
1968
|
|
|
1948
1969
|
function deserializeJSDocNullableType(pos) {
|
|
1949
1970
|
return {
|
|
1950
|
-
type: '
|
|
1971
|
+
type: 'TSJSDocNullableType',
|
|
1951
1972
|
start: deserializeU32(pos),
|
|
1952
1973
|
end: deserializeU32(pos + 4),
|
|
1953
1974
|
typeAnnotation: deserializeTSType(pos + 8),
|
|
@@ -1957,7 +1978,7 @@ function deserializeJSDocNullableType(pos) {
|
|
|
1957
1978
|
|
|
1958
1979
|
function deserializeJSDocNonNullableType(pos) {
|
|
1959
1980
|
return {
|
|
1960
|
-
type: '
|
|
1981
|
+
type: 'TSJSDocNonNullableType',
|
|
1961
1982
|
start: deserializeU32(pos),
|
|
1962
1983
|
end: deserializeU32(pos + 4),
|
|
1963
1984
|
typeAnnotation: deserializeTSType(pos + 8),
|
|
@@ -1967,7 +1988,7 @@ function deserializeJSDocNonNullableType(pos) {
|
|
|
1967
1988
|
|
|
1968
1989
|
function deserializeJSDocUnknownType(pos) {
|
|
1969
1990
|
return {
|
|
1970
|
-
type: '
|
|
1991
|
+
type: 'TSJSDocUnknownType',
|
|
1971
1992
|
start: deserializeU32(pos),
|
|
1972
1993
|
end: deserializeU32(pos + 4),
|
|
1973
1994
|
};
|
|
@@ -3544,6 +3565,10 @@ function deserializeTSEnumMemberName(pos) {
|
|
|
3544
3565
|
return deserializeBoxIdentifierName(pos + 8);
|
|
3545
3566
|
case 1:
|
|
3546
3567
|
return deserializeBoxStringLiteral(pos + 8);
|
|
3568
|
+
case 2:
|
|
3569
|
+
return deserializeBoxStringLiteral(pos + 8);
|
|
3570
|
+
case 3:
|
|
3571
|
+
return deserializeBoxTemplateLiteral(pos + 8);
|
|
3547
3572
|
default:
|
|
3548
3573
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for TSEnumMemberName`);
|
|
3549
3574
|
}
|
|
@@ -3861,18 +3886,8 @@ function deserializeTSTypeQueryExprName(pos) {
|
|
|
3861
3886
|
}
|
|
3862
3887
|
|
|
3863
3888
|
function deserializeTSMappedTypeModifierOperator(pos) {
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
return 'true';
|
|
3867
|
-
case 1:
|
|
3868
|
-
return '+';
|
|
3869
|
-
case 2:
|
|
3870
|
-
return '-';
|
|
3871
|
-
case 3:
|
|
3872
|
-
return 'none';
|
|
3873
|
-
default:
|
|
3874
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for TSMappedTypeModifierOperator`);
|
|
3875
|
-
}
|
|
3889
|
+
const operator = deserializeU8(pos);
|
|
3890
|
+
return [true, '+', '-', null][operator];
|
|
3876
3891
|
}
|
|
3877
3892
|
|
|
3878
3893
|
function deserializeTSModuleReference(pos) {
|
|
@@ -4112,8 +4127,6 @@ function deserializeModuleKind(pos) {
|
|
|
4112
4127
|
return 'script';
|
|
4113
4128
|
case 1:
|
|
4114
4129
|
return 'module';
|
|
4115
|
-
case 2:
|
|
4116
|
-
return 'unambiguous';
|
|
4117
4130
|
default:
|
|
4118
4131
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4119
4132
|
}
|
|
@@ -4528,11 +4541,6 @@ function deserializeVecArrayExpressionElement(pos) {
|
|
|
4528
4541
|
return arr;
|
|
4529
4542
|
}
|
|
4530
4543
|
|
|
4531
|
-
function deserializeOptionSpan(pos) {
|
|
4532
|
-
if (uint8[pos] === 0) return null;
|
|
4533
|
-
return deserializeSpan(pos + 8);
|
|
4534
|
-
}
|
|
4535
|
-
|
|
4536
4544
|
function deserializeBoxSpreadElement(pos) {
|
|
4537
4545
|
return deserializeSpreadElement(uint32[pos >> 2]);
|
|
4538
4546
|
}
|
|
@@ -4980,11 +4988,6 @@ function deserializeVecTSClassImplements(pos) {
|
|
|
4980
4988
|
return arr;
|
|
4981
4989
|
}
|
|
4982
4990
|
|
|
4983
|
-
function deserializeOptionVecTSClassImplements(pos) {
|
|
4984
|
-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
4985
|
-
return deserializeVecTSClassImplements(pos);
|
|
4986
|
-
}
|
|
4987
|
-
|
|
4988
4991
|
function deserializeBoxClassBody(pos) {
|
|
4989
4992
|
return deserializeClassBody(uint32[pos >> 2]);
|
|
4990
4993
|
}
|
package/deserialize-ts.js
CHANGED
|
@@ -37,14 +37,35 @@ function deserialize(buffer, sourceTextInput, sourceLenInput) {
|
|
|
37
37
|
function deserializeProgram(pos) {
|
|
38
38
|
const body = deserializeVecDirective(pos + 88);
|
|
39
39
|
body.push(...deserializeVecStatement(pos + 120));
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
const end = deserializeU32(pos + 4);
|
|
42
|
+
|
|
43
|
+
let start;
|
|
44
|
+
if (body.length > 0) {
|
|
45
|
+
const first = body[0];
|
|
46
|
+
start = first.start;
|
|
47
|
+
if (first.type === 'ExportNamedDeclaration' || first.type === 'ExportDefaultDeclaration') {
|
|
48
|
+
const { declaration } = first;
|
|
49
|
+
if (
|
|
50
|
+
declaration !== null && declaration.type === 'ClassDeclaration' &&
|
|
51
|
+
declaration.decorators.length > 0
|
|
52
|
+
) {
|
|
53
|
+
const decoratorStart = declaration.decorators[0].start;
|
|
54
|
+
if (decoratorStart < start) start = decoratorStart;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
start = end;
|
|
59
|
+
}
|
|
60
|
+
const program = {
|
|
41
61
|
type: 'Program',
|
|
42
|
-
start
|
|
43
|
-
end
|
|
62
|
+
start,
|
|
63
|
+
end,
|
|
44
64
|
body,
|
|
45
65
|
sourceType: deserializeModuleKind(pos + 9),
|
|
46
66
|
hashbang: deserializeOptionHashbang(pos + 64),
|
|
47
67
|
};
|
|
68
|
+
return program;
|
|
48
69
|
}
|
|
49
70
|
|
|
50
71
|
function deserializeIdentifierName(pos) {
|
|
@@ -89,6 +110,9 @@ function deserializeLabelIdentifier(pos) {
|
|
|
89
110
|
start: deserializeU32(pos),
|
|
90
111
|
end: deserializeU32(pos + 4),
|
|
91
112
|
name: deserializeStr(pos + 8),
|
|
113
|
+
decorators: [],
|
|
114
|
+
optional: false,
|
|
115
|
+
typeAnnotation: null,
|
|
92
116
|
};
|
|
93
117
|
}
|
|
94
118
|
|
|
@@ -133,6 +157,7 @@ function deserializeObjectProperty(pos) {
|
|
|
133
157
|
key: deserializePropertyKey(pos + 16),
|
|
134
158
|
value: deserializeExpression(pos + 32),
|
|
135
159
|
kind: deserializePropertyKind(pos + 8),
|
|
160
|
+
optional: false,
|
|
136
161
|
};
|
|
137
162
|
}
|
|
138
163
|
|
|
@@ -158,13 +183,15 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
158
183
|
}
|
|
159
184
|
|
|
160
185
|
function deserializeTemplateElement(pos) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
186
|
+
const tail = deserializeBool(pos + 40),
|
|
187
|
+
start = deserializeU32(pos) - 1,
|
|
188
|
+
end = deserializeU32(pos + 4) + 2 - tail,
|
|
189
|
+
value = deserializeTemplateElementValue(pos + 8);
|
|
190
|
+
if (value.cooked !== null && deserializeBool(pos + 41)) {
|
|
191
|
+
value.cooked = value.cooked
|
|
192
|
+
.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
193
|
+
}
|
|
194
|
+
return { type: 'TemplateElement', start, end, value, tail };
|
|
168
195
|
}
|
|
169
196
|
|
|
170
197
|
function deserializeTemplateElementValue(pos) {
|
|
@@ -338,6 +365,9 @@ function deserializeArrayAssignmentTarget(pos) {
|
|
|
338
365
|
start: deserializeU32(pos),
|
|
339
366
|
end: deserializeU32(pos + 4),
|
|
340
367
|
elements,
|
|
368
|
+
decorators: [],
|
|
369
|
+
optional: false,
|
|
370
|
+
typeAnnotation: null,
|
|
341
371
|
};
|
|
342
372
|
}
|
|
343
373
|
|
|
@@ -350,6 +380,9 @@ function deserializeObjectAssignmentTarget(pos) {
|
|
|
350
380
|
start: deserializeU32(pos),
|
|
351
381
|
end: deserializeU32(pos + 4),
|
|
352
382
|
properties,
|
|
383
|
+
decorators: [],
|
|
384
|
+
optional: false,
|
|
385
|
+
typeAnnotation: null,
|
|
353
386
|
};
|
|
354
387
|
}
|
|
355
388
|
|
|
@@ -359,6 +392,10 @@ function deserializeAssignmentTargetRest(pos) {
|
|
|
359
392
|
start: deserializeU32(pos),
|
|
360
393
|
end: deserializeU32(pos + 4),
|
|
361
394
|
argument: deserializeAssignmentTarget(pos + 8),
|
|
395
|
+
decorators: [],
|
|
396
|
+
optional: false,
|
|
397
|
+
typeAnnotation: null,
|
|
398
|
+
value: null,
|
|
362
399
|
};
|
|
363
400
|
}
|
|
364
401
|
|
|
@@ -397,6 +434,7 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
397
434
|
key,
|
|
398
435
|
value,
|
|
399
436
|
kind: 'init',
|
|
437
|
+
optional: false,
|
|
400
438
|
};
|
|
401
439
|
}
|
|
402
440
|
|
|
@@ -411,6 +449,7 @@ function deserializeAssignmentTargetPropertyProperty(pos) {
|
|
|
411
449
|
key: deserializePropertyKey(pos + 8),
|
|
412
450
|
value: deserializeAssignmentTargetMaybeDefault(pos + 24),
|
|
413
451
|
kind: 'init',
|
|
452
|
+
optional: false,
|
|
414
453
|
};
|
|
415
454
|
}
|
|
416
455
|
|
|
@@ -733,6 +772,7 @@ function deserializeObjectPattern(pos) {
|
|
|
733
772
|
start: deserializeU32(pos),
|
|
734
773
|
end: deserializeU32(pos + 4),
|
|
735
774
|
properties,
|
|
775
|
+
decorators: [],
|
|
736
776
|
};
|
|
737
777
|
}
|
|
738
778
|
|
|
@@ -747,6 +787,7 @@ function deserializeBindingProperty(pos) {
|
|
|
747
787
|
key: deserializePropertyKey(pos + 8),
|
|
748
788
|
value: deserializeBindingPattern(pos + 24),
|
|
749
789
|
kind: 'init',
|
|
790
|
+
optional: false,
|
|
750
791
|
};
|
|
751
792
|
}
|
|
752
793
|
|
|
@@ -771,6 +812,10 @@ function deserializeBindingRestElement(pos) {
|
|
|
771
812
|
start: deserializeU32(pos),
|
|
772
813
|
end: deserializeU32(pos + 4),
|
|
773
814
|
argument: deserializeBindingPattern(pos + 8),
|
|
815
|
+
decorators: [],
|
|
816
|
+
optional: false,
|
|
817
|
+
typeAnnotation: null,
|
|
818
|
+
value: null,
|
|
774
819
|
};
|
|
775
820
|
}
|
|
776
821
|
|
|
@@ -861,7 +906,6 @@ function deserializeYieldExpression(pos) {
|
|
|
861
906
|
}
|
|
862
907
|
|
|
863
908
|
function deserializeClass(pos) {
|
|
864
|
-
const classImplements = deserializeOptionVecTSClassImplements(pos + 112);
|
|
865
909
|
return {
|
|
866
910
|
type: deserializeClassType(pos + 8),
|
|
867
911
|
start: deserializeU32(pos),
|
|
@@ -872,7 +916,7 @@ function deserializeClass(pos) {
|
|
|
872
916
|
decorators: deserializeVecDecorator(pos + 16),
|
|
873
917
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 80),
|
|
874
918
|
superTypeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 104),
|
|
875
|
-
implements:
|
|
919
|
+
implements: deserializeVecTSClassImplements(pos + 112),
|
|
876
920
|
abstract: deserializeBool(pos + 152),
|
|
877
921
|
declare: deserializeBool(pos + 153),
|
|
878
922
|
};
|
|
@@ -952,20 +996,23 @@ function deserializeAccessorProperty(pos) {
|
|
|
952
996
|
computed: deserializeBool(pos + 80),
|
|
953
997
|
static: deserializeBool(pos + 81),
|
|
954
998
|
decorators: deserializeVecDecorator(pos + 16),
|
|
955
|
-
definite: deserializeBool(pos +
|
|
999
|
+
definite: deserializeBool(pos + 83),
|
|
956
1000
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 88),
|
|
957
1001
|
accessibility: deserializeOptionTSAccessibility(pos + 96),
|
|
1002
|
+
optional: false,
|
|
1003
|
+
override: deserializeBool(pos + 82),
|
|
1004
|
+
readonly: false,
|
|
1005
|
+
declare: false,
|
|
958
1006
|
};
|
|
959
1007
|
}
|
|
960
1008
|
|
|
961
1009
|
function deserializeImportExpression(pos) {
|
|
962
|
-
const options = deserializeVecExpression(pos + 24);
|
|
963
1010
|
return {
|
|
964
1011
|
type: 'ImportExpression',
|
|
965
1012
|
start: deserializeU32(pos),
|
|
966
1013
|
end: deserializeU32(pos + 4),
|
|
967
1014
|
source: deserializeExpression(pos + 8),
|
|
968
|
-
options:
|
|
1015
|
+
options: deserializeOptionExpression(pos + 24),
|
|
969
1016
|
};
|
|
970
1017
|
}
|
|
971
1018
|
|
|
@@ -1053,6 +1100,7 @@ function deserializeExportDefaultDeclaration(pos) {
|
|
|
1053
1100
|
start: deserializeU32(pos),
|
|
1054
1101
|
end: deserializeU32(pos + 4),
|
|
1055
1102
|
declaration: deserializeExportDefaultDeclarationKind(pos + 64),
|
|
1103
|
+
exportKind: 'value',
|
|
1056
1104
|
};
|
|
1057
1105
|
}
|
|
1058
1106
|
|
|
@@ -1191,12 +1239,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1191
1239
|
}
|
|
1192
1240
|
|
|
1193
1241
|
function deserializeJSXElement(pos) {
|
|
1242
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1243
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1244
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1194
1245
|
return {
|
|
1195
1246
|
type: 'JSXElement',
|
|
1196
1247
|
start: deserializeU32(pos),
|
|
1197
1248
|
end: deserializeU32(pos + 4),
|
|
1198
|
-
openingElement
|
|
1199
|
-
closingElement
|
|
1249
|
+
openingElement,
|
|
1250
|
+
closingElement,
|
|
1200
1251
|
children: deserializeVecJSXChild(pos + 24),
|
|
1201
1252
|
};
|
|
1202
1253
|
}
|
|
@@ -1206,10 +1257,10 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1206
1257
|
type: 'JSXOpeningElement',
|
|
1207
1258
|
start: deserializeU32(pos),
|
|
1208
1259
|
end: deserializeU32(pos + 4),
|
|
1209
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1210
|
-
name: deserializeJSXElementName(pos +
|
|
1211
|
-
selfClosing:
|
|
1212
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
1260
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1261
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1262
|
+
selfClosing: false,
|
|
1263
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56),
|
|
1213
1264
|
};
|
|
1214
1265
|
}
|
|
1215
1266
|
|
|
@@ -1234,13 +1285,12 @@ function deserializeJSXFragment(pos) {
|
|
|
1234
1285
|
}
|
|
1235
1286
|
|
|
1236
1287
|
function deserializeJSXOpeningFragment(pos) {
|
|
1237
|
-
|
|
1288
|
+
const node = {
|
|
1238
1289
|
type: 'JSXOpeningFragment',
|
|
1239
1290
|
start: deserializeU32(pos),
|
|
1240
1291
|
end: deserializeU32(pos + 4),
|
|
1241
|
-
attributes: [],
|
|
1242
|
-
selfClosing: false,
|
|
1243
1292
|
};
|
|
1293
|
+
return node;
|
|
1244
1294
|
}
|
|
1245
1295
|
|
|
1246
1296
|
function deserializeJSXClosingFragment(pos) {
|
|
@@ -1353,9 +1403,18 @@ function deserializeTSEnumDeclaration(pos) {
|
|
|
1353
1403
|
start: deserializeU32(pos),
|
|
1354
1404
|
end: deserializeU32(pos + 4),
|
|
1355
1405
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1356
|
-
|
|
1357
|
-
const: deserializeBool(pos +
|
|
1358
|
-
declare: deserializeBool(pos +
|
|
1406
|
+
body: deserializeTSEnumBody(pos + 40),
|
|
1407
|
+
const: deserializeBool(pos + 80),
|
|
1408
|
+
declare: deserializeBool(pos + 81),
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
function deserializeTSEnumBody(pos) {
|
|
1413
|
+
return {
|
|
1414
|
+
type: 'TSEnumBody',
|
|
1415
|
+
start: deserializeU32(pos),
|
|
1416
|
+
end: deserializeU32(pos + 4),
|
|
1417
|
+
members: deserializeVecTSEnumMember(pos + 8),
|
|
1359
1418
|
};
|
|
1360
1419
|
}
|
|
1361
1420
|
|
|
@@ -1365,6 +1424,7 @@ function deserializeTSEnumMember(pos) {
|
|
|
1365
1424
|
start: deserializeU32(pos),
|
|
1366
1425
|
end: deserializeU32(pos + 4),
|
|
1367
1426
|
id: deserializeTSEnumMemberName(pos + 8),
|
|
1427
|
+
computed: deserializeU8(pos + 8) > 1,
|
|
1368
1428
|
initializer: deserializeOptionExpression(pos + 24),
|
|
1369
1429
|
};
|
|
1370
1430
|
}
|
|
@@ -1865,7 +1925,6 @@ function deserializeTSImportType(pos) {
|
|
|
1865
1925
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1866
1926
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1867
1927
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1868
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1869
1928
|
};
|
|
1870
1929
|
}
|
|
1871
1930
|
|
|
@@ -1893,15 +1952,17 @@ function deserializeTSConstructorType(pos) {
|
|
|
1893
1952
|
}
|
|
1894
1953
|
|
|
1895
1954
|
function deserializeTSMappedType(pos) {
|
|
1955
|
+
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
1896
1956
|
return {
|
|
1897
1957
|
type: 'TSMappedType',
|
|
1898
1958
|
start: deserializeU32(pos),
|
|
1899
1959
|
end: deserializeU32(pos + 4),
|
|
1900
|
-
typeParameter: deserializeBoxTSTypeParameter(pos + 8),
|
|
1901
1960
|
nameType: deserializeOptionTSType(pos + 16),
|
|
1902
1961
|
typeAnnotation: deserializeOptionTSType(pos + 32),
|
|
1903
1962
|
optional: deserializeTSMappedTypeModifierOperator(pos + 48),
|
|
1904
1963
|
readonly: deserializeTSMappedTypeModifierOperator(pos + 49),
|
|
1964
|
+
key: typeParameter.name,
|
|
1965
|
+
constraint: typeParameter.constraint,
|
|
1905
1966
|
};
|
|
1906
1967
|
}
|
|
1907
1968
|
|
|
@@ -2007,13 +2068,13 @@ function deserializeTSInstantiationExpression(pos) {
|
|
|
2007
2068
|
start: deserializeU32(pos),
|
|
2008
2069
|
end: deserializeU32(pos + 4),
|
|
2009
2070
|
expression: deserializeExpression(pos + 8),
|
|
2010
|
-
|
|
2071
|
+
typeArguments: deserializeBoxTSTypeParameterInstantiation(pos + 24),
|
|
2011
2072
|
};
|
|
2012
2073
|
}
|
|
2013
2074
|
|
|
2014
2075
|
function deserializeJSDocNullableType(pos) {
|
|
2015
2076
|
return {
|
|
2016
|
-
type: '
|
|
2077
|
+
type: 'TSJSDocNullableType',
|
|
2017
2078
|
start: deserializeU32(pos),
|
|
2018
2079
|
end: deserializeU32(pos + 4),
|
|
2019
2080
|
typeAnnotation: deserializeTSType(pos + 8),
|
|
@@ -2023,7 +2084,7 @@ function deserializeJSDocNullableType(pos) {
|
|
|
2023
2084
|
|
|
2024
2085
|
function deserializeJSDocNonNullableType(pos) {
|
|
2025
2086
|
return {
|
|
2026
|
-
type: '
|
|
2087
|
+
type: 'TSJSDocNonNullableType',
|
|
2027
2088
|
start: deserializeU32(pos),
|
|
2028
2089
|
end: deserializeU32(pos + 4),
|
|
2029
2090
|
typeAnnotation: deserializeTSType(pos + 8),
|
|
@@ -2033,7 +2094,7 @@ function deserializeJSDocNonNullableType(pos) {
|
|
|
2033
2094
|
|
|
2034
2095
|
function deserializeJSDocUnknownType(pos) {
|
|
2035
2096
|
return {
|
|
2036
|
-
type: '
|
|
2097
|
+
type: 'TSJSDocUnknownType',
|
|
2037
2098
|
start: deserializeU32(pos),
|
|
2038
2099
|
end: deserializeU32(pos + 4),
|
|
2039
2100
|
};
|
|
@@ -3610,6 +3671,10 @@ function deserializeTSEnumMemberName(pos) {
|
|
|
3610
3671
|
return deserializeBoxIdentifierName(pos + 8);
|
|
3611
3672
|
case 1:
|
|
3612
3673
|
return deserializeBoxStringLiteral(pos + 8);
|
|
3674
|
+
case 2:
|
|
3675
|
+
return deserializeBoxStringLiteral(pos + 8);
|
|
3676
|
+
case 3:
|
|
3677
|
+
return deserializeBoxTemplateLiteral(pos + 8);
|
|
3613
3678
|
default:
|
|
3614
3679
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for TSEnumMemberName`);
|
|
3615
3680
|
}
|
|
@@ -3927,18 +3992,8 @@ function deserializeTSTypeQueryExprName(pos) {
|
|
|
3927
3992
|
}
|
|
3928
3993
|
|
|
3929
3994
|
function deserializeTSMappedTypeModifierOperator(pos) {
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
return 'true';
|
|
3933
|
-
case 1:
|
|
3934
|
-
return '+';
|
|
3935
|
-
case 2:
|
|
3936
|
-
return '-';
|
|
3937
|
-
case 3:
|
|
3938
|
-
return 'none';
|
|
3939
|
-
default:
|
|
3940
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for TSMappedTypeModifierOperator`);
|
|
3941
|
-
}
|
|
3995
|
+
const operator = deserializeU8(pos);
|
|
3996
|
+
return [true, '+', '-', null][operator];
|
|
3942
3997
|
}
|
|
3943
3998
|
|
|
3944
3999
|
function deserializeTSModuleReference(pos) {
|
|
@@ -4178,8 +4233,6 @@ function deserializeModuleKind(pos) {
|
|
|
4178
4233
|
return 'script';
|
|
4179
4234
|
case 1:
|
|
4180
4235
|
return 'module';
|
|
4181
|
-
case 2:
|
|
4182
|
-
return 'unambiguous';
|
|
4183
4236
|
default:
|
|
4184
4237
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4185
4238
|
}
|
|
@@ -4594,11 +4647,6 @@ function deserializeVecArrayExpressionElement(pos) {
|
|
|
4594
4647
|
return arr;
|
|
4595
4648
|
}
|
|
4596
4649
|
|
|
4597
|
-
function deserializeOptionSpan(pos) {
|
|
4598
|
-
if (uint8[pos] === 0) return null;
|
|
4599
|
-
return deserializeSpan(pos + 8);
|
|
4600
|
-
}
|
|
4601
|
-
|
|
4602
4650
|
function deserializeBoxSpreadElement(pos) {
|
|
4603
4651
|
return deserializeSpreadElement(uint32[pos >> 2]);
|
|
4604
4652
|
}
|
|
@@ -5046,11 +5094,6 @@ function deserializeVecTSClassImplements(pos) {
|
|
|
5046
5094
|
return arr;
|
|
5047
5095
|
}
|
|
5048
5096
|
|
|
5049
|
-
function deserializeOptionVecTSClassImplements(pos) {
|
|
5050
|
-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5051
|
-
return deserializeVecTSClassImplements(pos);
|
|
5052
|
-
}
|
|
5053
|
-
|
|
5054
5097
|
function deserializeBoxClassBody(pos) {
|
|
5055
5098
|
return deserializeClassBody(uint32[pos >> 2]);
|
|
5056
5099
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"browser": "wasm.mjs",
|
|
6
6
|
"engines": {
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.64.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
46
46
|
"@napi-rs/wasm-runtime": "^0.2.7",
|
|
47
|
-
"@vitest/browser": "3.
|
|
47
|
+
"@vitest/browser": "3.1.1",
|
|
48
48
|
"esbuild": "^0.25.0",
|
|
49
49
|
"playwright": "^1.51.0",
|
|
50
|
-
"vitest": "3.
|
|
50
|
+
"vitest": "3.1.1"
|
|
51
51
|
},
|
|
52
52
|
"napi": {
|
|
53
53
|
"binaryName": "parser",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"dtsHeaderFile": "header.js"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
76
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
77
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
78
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
79
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
80
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
81
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
82
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
83
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
84
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
75
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.64.0",
|
|
76
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.64.0",
|
|
77
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.64.0",
|
|
78
|
+
"@oxc-parser/binding-linux-x64-musl": "0.64.0",
|
|
79
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.64.0",
|
|
80
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.64.0",
|
|
81
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.64.0",
|
|
82
|
+
"@oxc-parser/binding-darwin-x64": "0.64.0",
|
|
83
|
+
"@oxc-parser/binding-darwin-arm64": "0.64.0",
|
|
84
|
+
"@oxc-parser/binding-wasm32-wasi": "0.64.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|