oxc-parser 0.61.2 → 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 +13 -1
- package/deserialize-js.js +40 -17
- package/deserialize-ts.js +50 -18
- package/package.json +16 -14
- package/webcontainer-fallback.js +23 -0
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
|
}
|
|
@@ -359,6 +363,14 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
359
363
|
}
|
|
360
364
|
}
|
|
361
365
|
|
|
366
|
+
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
367
|
+
try {
|
|
368
|
+
nativeBinding = require('./webcontainer-fallback.js');
|
|
369
|
+
} catch (err) {
|
|
370
|
+
loadErrors.push(err)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
362
374
|
if (!nativeBinding) {
|
|
363
375
|
if (loadErrors.length > 0) {
|
|
364
376
|
// TODO Link to documentation with potential fixes
|
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
|
}
|
|
@@ -1061,11 +1068,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1061
1068
|
}
|
|
1062
1069
|
|
|
1063
1070
|
function deserializeStringLiteral(pos) {
|
|
1071
|
+
let value = deserializeStr(pos + 8);
|
|
1072
|
+
if (deserializeBool(pos + 40)) {
|
|
1073
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1074
|
+
}
|
|
1064
1075
|
return {
|
|
1065
1076
|
type: 'Literal',
|
|
1066
1077
|
start: deserializeU32(pos),
|
|
1067
1078
|
end: deserializeU32(pos + 4),
|
|
1068
|
-
value
|
|
1079
|
+
value,
|
|
1069
1080
|
raw: deserializeOptionStr(pos + 24),
|
|
1070
1081
|
};
|
|
1071
1082
|
}
|
|
@@ -1122,12 +1133,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1122
1133
|
}
|
|
1123
1134
|
|
|
1124
1135
|
function deserializeJSXElement(pos) {
|
|
1136
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1137
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1138
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1125
1139
|
return {
|
|
1126
1140
|
type: 'JSXElement',
|
|
1127
1141
|
start: deserializeU32(pos),
|
|
1128
1142
|
end: deserializeU32(pos + 4),
|
|
1129
|
-
openingElement
|
|
1130
|
-
closingElement
|
|
1143
|
+
openingElement,
|
|
1144
|
+
closingElement,
|
|
1131
1145
|
children: deserializeVecJSXChild(pos + 24),
|
|
1132
1146
|
};
|
|
1133
1147
|
}
|
|
@@ -1137,9 +1151,9 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1137
1151
|
type: 'JSXOpeningElement',
|
|
1138
1152
|
start: deserializeU32(pos),
|
|
1139
1153
|
end: deserializeU32(pos + 4),
|
|
1140
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1141
|
-
name: deserializeJSXElementName(pos +
|
|
1142
|
-
selfClosing:
|
|
1154
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1155
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1156
|
+
selfClosing: false,
|
|
1143
1157
|
};
|
|
1144
1158
|
}
|
|
1145
1159
|
|
|
@@ -1278,12 +1292,16 @@ function deserializeTSThisParameter(pos) {
|
|
|
1278
1292
|
}
|
|
1279
1293
|
|
|
1280
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;
|
|
1281
1299
|
return {
|
|
1282
1300
|
type: 'TSEnumDeclaration',
|
|
1283
1301
|
start: deserializeU32(pos),
|
|
1284
|
-
end
|
|
1285
|
-
id
|
|
1286
|
-
|
|
1302
|
+
end,
|
|
1303
|
+
id,
|
|
1304
|
+
body: { type: 'TSEnumBody', start: bodyStart, end: end, members: tsEnumDeclMembers },
|
|
1287
1305
|
const: deserializeBool(pos + 72),
|
|
1288
1306
|
declare: deserializeBool(pos + 73),
|
|
1289
1307
|
};
|
|
@@ -1610,12 +1628,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1610
1628
|
}
|
|
1611
1629
|
|
|
1612
1630
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1631
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1613
1632
|
return {
|
|
1614
1633
|
type: 'TSInterfaceDeclaration',
|
|
1615
1634
|
start: deserializeU32(pos),
|
|
1616
1635
|
end: deserializeU32(pos + 4),
|
|
1617
1636
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1618
|
-
extends:
|
|
1637
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1619
1638
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1620
1639
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1621
1640
|
declare: deserializeBool(pos + 88),
|
|
@@ -1641,6 +1660,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1641
1660
|
readonly: deserializeBool(pos + 10),
|
|
1642
1661
|
key: deserializePropertyKey(pos + 16),
|
|
1643
1662
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1663
|
+
accessibility: null,
|
|
1664
|
+
static: false,
|
|
1644
1665
|
};
|
|
1645
1666
|
}
|
|
1646
1667
|
|
|
@@ -1653,6 +1674,7 @@ function deserializeTSIndexSignature(pos) {
|
|
|
1653
1674
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 40),
|
|
1654
1675
|
readonly: deserializeBool(pos + 48),
|
|
1655
1676
|
static: deserializeBool(pos + 49),
|
|
1677
|
+
accessibility: null,
|
|
1656
1678
|
};
|
|
1657
1679
|
}
|
|
1658
1680
|
|
|
@@ -1677,9 +1699,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1677
1699
|
optional: deserializeBool(pos + 25),
|
|
1678
1700
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1679
1701
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1680
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1681
1702
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1682
1703
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1704
|
+
accessibility: null,
|
|
1705
|
+
readonly: false,
|
|
1706
|
+
static: false,
|
|
1683
1707
|
};
|
|
1684
1708
|
}
|
|
1685
1709
|
|
|
@@ -1701,6 +1725,8 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1701
1725
|
end: deserializeU32(pos + 4),
|
|
1702
1726
|
name: deserializeStr(pos + 8),
|
|
1703
1727
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1728
|
+
decorators: [],
|
|
1729
|
+
optional: false,
|
|
1704
1730
|
};
|
|
1705
1731
|
}
|
|
1706
1732
|
|
|
@@ -1787,7 +1813,6 @@ function deserializeTSImportType(pos) {
|
|
|
1787
1813
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1788
1814
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1789
1815
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1790
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1791
1816
|
};
|
|
1792
1817
|
}
|
|
1793
1818
|
|
|
@@ -4100,8 +4125,6 @@ function deserializeModuleKind(pos) {
|
|
|
4100
4125
|
return 'script';
|
|
4101
4126
|
case 1:
|
|
4102
4127
|
return 'module';
|
|
4103
|
-
case 2:
|
|
4104
|
-
return 'unambiguous';
|
|
4105
4128
|
default:
|
|
4106
4129
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4107
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
|
|
|
@@ -1126,11 +1145,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1126
1145
|
}
|
|
1127
1146
|
|
|
1128
1147
|
function deserializeStringLiteral(pos) {
|
|
1148
|
+
let value = deserializeStr(pos + 8);
|
|
1149
|
+
if (deserializeBool(pos + 40)) {
|
|
1150
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1151
|
+
}
|
|
1129
1152
|
return {
|
|
1130
1153
|
type: 'Literal',
|
|
1131
1154
|
start: deserializeU32(pos),
|
|
1132
1155
|
end: deserializeU32(pos + 4),
|
|
1133
|
-
value
|
|
1156
|
+
value,
|
|
1134
1157
|
raw: deserializeOptionStr(pos + 24),
|
|
1135
1158
|
};
|
|
1136
1159
|
}
|
|
@@ -1187,12 +1210,15 @@ function deserializeRegExpFlags(pos) {
|
|
|
1187
1210
|
}
|
|
1188
1211
|
|
|
1189
1212
|
function deserializeJSXElement(pos) {
|
|
1213
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 16);
|
|
1214
|
+
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1215
|
+
if (closingElement === null) openingElement.selfClosing = true;
|
|
1190
1216
|
return {
|
|
1191
1217
|
type: 'JSXElement',
|
|
1192
1218
|
start: deserializeU32(pos),
|
|
1193
1219
|
end: deserializeU32(pos + 4),
|
|
1194
|
-
openingElement
|
|
1195
|
-
closingElement
|
|
1220
|
+
openingElement,
|
|
1221
|
+
closingElement,
|
|
1196
1222
|
children: deserializeVecJSXChild(pos + 24),
|
|
1197
1223
|
};
|
|
1198
1224
|
}
|
|
@@ -1202,10 +1228,10 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1202
1228
|
type: 'JSXOpeningElement',
|
|
1203
1229
|
start: deserializeU32(pos),
|
|
1204
1230
|
end: deserializeU32(pos + 4),
|
|
1205
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1206
|
-
name: deserializeJSXElementName(pos +
|
|
1207
|
-
selfClosing:
|
|
1208
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
1231
|
+
attributes: deserializeVecJSXAttributeItem(pos + 24),
|
|
1232
|
+
name: deserializeJSXElementName(pos + 8),
|
|
1233
|
+
selfClosing: false,
|
|
1234
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56),
|
|
1209
1235
|
};
|
|
1210
1236
|
}
|
|
1211
1237
|
|
|
@@ -1344,12 +1370,16 @@ function deserializeTSThisParameter(pos) {
|
|
|
1344
1370
|
}
|
|
1345
1371
|
|
|
1346
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;
|
|
1347
1377
|
return {
|
|
1348
1378
|
type: 'TSEnumDeclaration',
|
|
1349
1379
|
start: deserializeU32(pos),
|
|
1350
|
-
end
|
|
1351
|
-
id
|
|
1352
|
-
|
|
1380
|
+
end,
|
|
1381
|
+
id,
|
|
1382
|
+
body: { type: 'TSEnumBody', start: bodyStart, end: end, members: tsEnumDeclMembers },
|
|
1353
1383
|
const: deserializeBool(pos + 72),
|
|
1354
1384
|
declare: deserializeBool(pos + 73),
|
|
1355
1385
|
};
|
|
@@ -1676,12 +1706,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1676
1706
|
}
|
|
1677
1707
|
|
|
1678
1708
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1709
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1679
1710
|
return {
|
|
1680
1711
|
type: 'TSInterfaceDeclaration',
|
|
1681
1712
|
start: deserializeU32(pos),
|
|
1682
1713
|
end: deserializeU32(pos + 4),
|
|
1683
1714
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1684
|
-
extends:
|
|
1715
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1685
1716
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1686
1717
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1687
1718
|
declare: deserializeBool(pos + 88),
|
|
@@ -1707,6 +1738,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1707
1738
|
readonly: deserializeBool(pos + 10),
|
|
1708
1739
|
key: deserializePropertyKey(pos + 16),
|
|
1709
1740
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1741
|
+
accessibility: null,
|
|
1742
|
+
static: false,
|
|
1710
1743
|
};
|
|
1711
1744
|
}
|
|
1712
1745
|
|
|
@@ -1744,9 +1777,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1744
1777
|
optional: deserializeBool(pos + 25),
|
|
1745
1778
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1746
1779
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1747
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1748
1780
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1749
1781
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1782
|
+
accessibility: null,
|
|
1783
|
+
readonly: false,
|
|
1784
|
+
static: false,
|
|
1750
1785
|
};
|
|
1751
1786
|
}
|
|
1752
1787
|
|
|
@@ -1856,7 +1891,6 @@ function deserializeTSImportType(pos) {
|
|
|
1856
1891
|
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1857
1892
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1858
1893
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1859
|
-
isTypeOf: deserializeBool(pos + 56),
|
|
1860
1894
|
};
|
|
1861
1895
|
}
|
|
1862
1896
|
|
|
@@ -4169,8 +4203,6 @@ function deserializeModuleKind(pos) {
|
|
|
4169
4203
|
return 'script';
|
|
4170
4204
|
case 1:
|
|
4171
4205
|
return 'module';
|
|
4172
|
-
case 2:
|
|
4173
|
-
return 'unambiguous';
|
|
4174
4206
|
default:
|
|
4175
4207
|
throw new Error(`Unexpected discriminant ${uint8[pos]} for ModuleKind`);
|
|
4176
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": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"wrap.mjs",
|
|
31
31
|
"wasm.mjs",
|
|
32
32
|
"bindings.js",
|
|
33
|
+
"webcontainer-fallback.js",
|
|
33
34
|
"deserialize-js.js",
|
|
34
35
|
"deserialize-ts.js"
|
|
35
36
|
],
|
|
@@ -38,15 +39,15 @@
|
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.63.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
45
46
|
"@napi-rs/wasm-runtime": "^0.2.7",
|
|
46
|
-
"@vitest/browser": "3.
|
|
47
|
+
"@vitest/browser": "3.1.1",
|
|
47
48
|
"esbuild": "^0.25.0",
|
|
48
49
|
"playwright": "^1.51.0",
|
|
49
|
-
"vitest": "3.
|
|
50
|
+
"vitest": "3.1.1"
|
|
50
51
|
},
|
|
51
52
|
"napi": {
|
|
52
53
|
"binaryName": "parser",
|
|
@@ -71,20 +72,21 @@
|
|
|
71
72
|
"dtsHeaderFile": "header.js"
|
|
72
73
|
},
|
|
73
74
|
"optionalDependencies": {
|
|
74
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
75
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
76
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
77
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
78
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
79
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
80
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
81
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
82
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
83
|
-
"@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"
|
|
84
85
|
},
|
|
85
86
|
"scripts": {
|
|
86
87
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|
|
87
88
|
"build": "pnpm run build-dev --features allocator --release",
|
|
89
|
+
"postbuild-dev": "node patch.mjs",
|
|
88
90
|
"build-wasi": "pnpm run build-dev --release --target wasm32-wasip1-threads",
|
|
89
91
|
"build-npm-dir": "rm -rf npm-dir && napi create-npm-dirs --npm-dir npm-dir && pnpm napi artifacts --npm-dir npm-dir --output-dir .",
|
|
90
92
|
"build-browser-bundle": "node build-browser-bundle.mjs",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const childProcess = require('node:child_process');
|
|
3
|
+
|
|
4
|
+
const pkg = JSON.parse(
|
|
5
|
+
fs.readFileSync(require.resolve('oxc-parser/package.json'), 'utf-8'),
|
|
6
|
+
);
|
|
7
|
+
const version = pkg.version;
|
|
8
|
+
const baseDir = `/tmp/oxc-parser-${version}`;
|
|
9
|
+
const bindingEntry = `${baseDir}/node_modules/@oxc-parser/binding-wasm32-wasi/parser.wasi.cjs`;
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(bindingEntry)) {
|
|
12
|
+
fs.rmSync(baseDir, { recursive: true, force: true });
|
|
13
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
14
|
+
const bindingPkg = `@oxc-parser/binding-wasm32-wasi@${version}`;
|
|
15
|
+
// eslint-disable-next-line: no-console
|
|
16
|
+
console.log(`[oxc-parser] Downloading ${bindingPkg} on WebContainer...`);
|
|
17
|
+
childProcess.execFileSync('pnpm', ['i', bindingPkg], {
|
|
18
|
+
cwd: baseDir,
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = require(bindingEntry);
|