oxc-parser 0.62.0 → 0.63.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 +25 -14
- package/deserialize-ts.js +38 -15
- 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,16 @@ 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
|
+
let start = deserializeU32(pos);
|
|
41
|
+
const program = {
|
|
41
42
|
type: 'Program',
|
|
42
|
-
start
|
|
43
|
+
start,
|
|
43
44
|
end: deserializeU32(pos + 4),
|
|
44
45
|
body,
|
|
45
46
|
sourceType: deserializeModuleKind(pos + 9),
|
|
46
47
|
hashbang: deserializeOptionHashbang(pos + 64),
|
|
47
48
|
};
|
|
49
|
+
return program;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
function deserializeIdentifierName(pos) {
|
|
@@ -148,11 +150,16 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
function deserializeTemplateElement(pos) {
|
|
153
|
+
let value = deserializeTemplateElementValue(pos + 8);
|
|
154
|
+
if (value.cooked !== null && deserializeBool(pos + 41)) {
|
|
155
|
+
value.cooked = value.cooked
|
|
156
|
+
.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
157
|
+
}
|
|
151
158
|
return {
|
|
152
159
|
type: 'TemplateElement',
|
|
153
160
|
start: deserializeU32(pos),
|
|
154
161
|
end: deserializeU32(pos + 4),
|
|
155
|
-
value
|
|
162
|
+
value,
|
|
156
163
|
tail: deserializeBool(pos + 40),
|
|
157
164
|
};
|
|
158
165
|
}
|
|
@@ -1126,12 +1133,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1126
1133
|
}
|
|
1127
1134
|
|
|
1128
1135
|
function deserializeJSXElement(pos) {
|
|
1136
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1137
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1138
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1129
1139
|
return {
|
|
1130
1140
|
type: 'JSXElement',
|
|
1131
1141
|
start: deserializeU32(pos),
|
|
1132
1142
|
end: deserializeU32(pos + 4),
|
|
1133
|
-
openingElement
|
|
1134
|
-
closingElement
|
|
1143
|
+
openingElement,
|
|
1144
|
+
closingElement,
|
|
1135
1145
|
children: deserializeVecJSXChild(pos + 24),
|
|
1136
1146
|
};
|
|
1137
1147
|
}
|
|
@@ -1141,9 +1151,9 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1141
1151
|
type: 'JSXOpeningElement',
|
|
1142
1152
|
start: deserializeU32(pos),
|
|
1143
1153
|
end: deserializeU32(pos + 4),
|
|
1144
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1145
|
-
name: deserializeJSXElementName(pos +
|
|
1146
|
-
selfClosing:
|
|
1154
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1155
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1156
|
+
selfClosing: false,
|
|
1147
1157
|
};
|
|
1148
1158
|
}
|
|
1149
1159
|
|
|
@@ -1282,12 +1292,16 @@ function deserializeTSThisParameter(pos) {
|
|
|
1282
1292
|
}
|
|
1283
1293
|
|
|
1284
1294
|
function deserializeTSEnumDeclaration(pos) {
|
|
1295
|
+
const end = deserializeU32(pos + 4),
|
|
1296
|
+
id = deserializeBindingIdentifier(pos + 8);
|
|
1297
|
+
const tsEnumDeclMembers = deserializeVecTSEnumMember(pos + 40);
|
|
1298
|
+
const bodyStart = id.end + 1;
|
|
1285
1299
|
return {
|
|
1286
1300
|
type: 'TSEnumDeclaration',
|
|
1287
1301
|
start: deserializeU32(pos),
|
|
1288
|
-
end
|
|
1289
|
-
id
|
|
1290
|
-
|
|
1302
|
+
end,
|
|
1303
|
+
id,
|
|
1304
|
+
body: { type: 'TSEnumBody', start: bodyStart, end: end, members: tsEnumDeclMembers },
|
|
1291
1305
|
const: deserializeBool(pos + 72),
|
|
1292
1306
|
declare: deserializeBool(pos + 73),
|
|
1293
1307
|
};
|
|
@@ -1799,7 +1813,6 @@ function deserializeTSImportType(pos) {
|
|
|
1799
1813
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1800
1814
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1801
1815
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1802
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1803
1816
|
};
|
|
1804
1817
|
}
|
|
1805
1818
|
|
|
@@ -4112,8 +4125,6 @@ function deserializeModuleKind(pos) {
|
|
|
4112
4125
|
return 'script';
|
|
4113
4126
|
case 1:
|
|
4114
4127
|
return 'module';
|
|
4115
|
-
case 2:
|
|
4116
|
-
return 'unambiguous';
|
|
4117
4128
|
default:
|
|
4118
4129
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4119
4130
|
}
|
package/deserialize-ts.js
CHANGED
|
@@ -37,14 +37,17 @@ 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
|
+
let start = deserializeU32(pos);
|
|
41
|
+
if (body.length > 0) start = body[0].start;
|
|
42
|
+
const program = {
|
|
41
43
|
type: 'Program',
|
|
42
|
-
start
|
|
44
|
+
start,
|
|
43
45
|
end: deserializeU32(pos + 4),
|
|
44
46
|
body,
|
|
45
47
|
sourceType: deserializeModuleKind(pos + 9),
|
|
46
48
|
hashbang: deserializeOptionHashbang(pos + 64),
|
|
47
49
|
};
|
|
50
|
+
return program;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
function deserializeIdentifierName(pos) {
|
|
@@ -89,6 +92,9 @@ function deserializeLabelIdentifier(pos) {
|
|
|
89
92
|
start: deserializeU32(pos),
|
|
90
93
|
end: deserializeU32(pos + 4),
|
|
91
94
|
name: deserializeStr(pos + 8),
|
|
95
|
+
decorators: [],
|
|
96
|
+
optional: false,
|
|
97
|
+
typeAnnotation: null,
|
|
92
98
|
};
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -133,6 +139,7 @@ function deserializeObjectProperty(pos) {
|
|
|
133
139
|
key: deserializePropertyKey(pos + 16),
|
|
134
140
|
value: deserializeExpression(pos + 32),
|
|
135
141
|
kind: deserializePropertyKind(pos + 8),
|
|
142
|
+
optional: false,
|
|
136
143
|
};
|
|
137
144
|
}
|
|
138
145
|
|
|
@@ -158,11 +165,16 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
function deserializeTemplateElement(pos) {
|
|
168
|
+
let value = deserializeTemplateElementValue(pos + 8);
|
|
169
|
+
if (value.cooked !== null && deserializeBool(pos + 41)) {
|
|
170
|
+
value.cooked = value.cooked
|
|
171
|
+
.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
172
|
+
}
|
|
161
173
|
return {
|
|
162
174
|
type: 'TemplateElement',
|
|
163
175
|
start: deserializeU32(pos),
|
|
164
176
|
end: deserializeU32(pos + 4),
|
|
165
|
-
value
|
|
177
|
+
value,
|
|
166
178
|
tail: deserializeBool(pos + 40),
|
|
167
179
|
};
|
|
168
180
|
}
|
|
@@ -733,6 +745,7 @@ function deserializeObjectPattern(pos) {
|
|
|
733
745
|
start: deserializeU32(pos),
|
|
734
746
|
end: deserializeU32(pos + 4),
|
|
735
747
|
properties,
|
|
748
|
+
decorators: [],
|
|
736
749
|
};
|
|
737
750
|
}
|
|
738
751
|
|
|
@@ -747,6 +760,7 @@ function deserializeBindingProperty(pos) {
|
|
|
747
760
|
key: deserializePropertyKey(pos + 8),
|
|
748
761
|
value: deserializeBindingPattern(pos + 24),
|
|
749
762
|
kind: 'init',
|
|
763
|
+
optional: false,
|
|
750
764
|
};
|
|
751
765
|
}
|
|
752
766
|
|
|
@@ -955,6 +969,10 @@ function deserializeAccessorProperty(pos) {
|
|
|
955
969
|
definite: deserializeBool(pos + 82),
|
|
956
970
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 88),
|
|
957
971
|
accessibility: deserializeOptionTSAccessibility(pos + 96),
|
|
972
|
+
optional: false,
|
|
973
|
+
override: false,
|
|
974
|
+
readonly: false,
|
|
975
|
+
declare: false,
|
|
958
976
|
};
|
|
959
977
|
}
|
|
960
978
|
|
|
@@ -1053,6 +1071,7 @@ function deserializeExportDefaultDeclaration(pos) {
|
|
|
1053
1071
|
start: deserializeU32(pos),
|
|
1054
1072
|
end: deserializeU32(pos + 4),
|
|
1055
1073
|
declaration: deserializeExportDefaultDeclarationKind(pos + 64),
|
|
1074
|
+
exportKind: 'value',
|
|
1056
1075
|
};
|
|
1057
1076
|
}
|
|
1058
1077
|
|
|
@@ -1191,12 +1210,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1191
1210
|
}
|
|
1192
1211
|
|
|
1193
1212
|
function deserializeJSXElement(pos) {
|
|
1213
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1214
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1215
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1194
1216
|
return {
|
|
1195
1217
|
type: 'JSXElement',
|
|
1196
1218
|
start: deserializeU32(pos),
|
|
1197
1219
|
end: deserializeU32(pos + 4),
|
|
1198
|
-
openingElement
|
|
1199
|
-
closingElement
|
|
1220
|
+
openingElement,
|
|
1221
|
+
closingElement,
|
|
1200
1222
|
children: deserializeVecJSXChild(pos + 24),
|
|
1201
1223
|
};
|
|
1202
1224
|
}
|
|
@@ -1206,10 +1228,10 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1206
1228
|
type: 'JSXOpeningElement',
|
|
1207
1229
|
start: deserializeU32(pos),
|
|
1208
1230
|
end: deserializeU32(pos + 4),
|
|
1209
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1210
|
-
name: deserializeJSXElementName(pos +
|
|
1211
|
-
selfClosing:
|
|
1212
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
1231
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1232
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1233
|
+
selfClosing: false,
|
|
1234
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56),
|
|
1213
1235
|
};
|
|
1214
1236
|
}
|
|
1215
1237
|
|
|
@@ -1348,12 +1370,16 @@ function deserializeTSThisParameter(pos) {
|
|
|
1348
1370
|
}
|
|
1349
1371
|
|
|
1350
1372
|
function deserializeTSEnumDeclaration(pos) {
|
|
1373
|
+
const end = deserializeU32(pos + 4),
|
|
1374
|
+
id = deserializeBindingIdentifier(pos + 8);
|
|
1375
|
+
const tsEnumDeclMembers = deserializeVecTSEnumMember(pos + 40);
|
|
1376
|
+
const bodyStart = id.end + 1;
|
|
1351
1377
|
return {
|
|
1352
1378
|
type: 'TSEnumDeclaration',
|
|
1353
1379
|
start: deserializeU32(pos),
|
|
1354
|
-
end
|
|
1355
|
-
id
|
|
1356
|
-
|
|
1380
|
+
end,
|
|
1381
|
+
id,
|
|
1382
|
+
body: { type: 'TSEnumBody', start: bodyStart, end: end, members: tsEnumDeclMembers },
|
|
1357
1383
|
const: deserializeBool(pos + 72),
|
|
1358
1384
|
declare: deserializeBool(pos + 73),
|
|
1359
1385
|
};
|
|
@@ -1865,7 +1891,6 @@ function deserializeTSImportType(pos) {
|
|
|
1865
1891
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1866
1892
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1867
1893
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1868
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1869
1894
|
};
|
|
1870
1895
|
}
|
|
1871
1896
|
|
|
@@ -4178,8 +4203,6 @@ function deserializeModuleKind(pos) {
|
|
|
4178
4203
|
return 'script';
|
|
4179
4204
|
case 1:
|
|
4180
4205
|
return 'module';
|
|
4181
|
-
case 2:
|
|
4182
|
-
return 'unambiguous';
|
|
4183
4206
|
default:
|
|
4184
4207
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4185
4208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.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.63.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.63.0",
|
|
76
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.63.0",
|
|
77
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.63.0",
|
|
78
|
+
"@oxc-parser/binding-linux-x64-musl": "0.63.0",
|
|
79
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.63.0",
|
|
80
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.63.0",
|
|
81
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.63.0",
|
|
82
|
+
"@oxc-parser/binding-darwin-x64": "0.63.0",
|
|
83
|
+
"@oxc-parser/binding-darwin-arm64": "0.63.0",
|
|
84
|
+
"@oxc-parser/binding-wasm32-wasi": "0.63.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|