oxc-parser 0.61.0 → 0.62.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 +8 -0
- package/deserialize-js.js +38 -18
- package/deserialize-ts.js +47 -22
- package/package.json +18 -14
- package/webcontainer-fallback.js +23 -0
package/bindings.js
CHANGED
|
@@ -359,6 +359,14 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
363
|
+
try {
|
|
364
|
+
nativeBinding = require('./webcontainer-fallback.js');
|
|
365
|
+
} catch (err) {
|
|
366
|
+
loadErrors.push(err)
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
362
370
|
if (!nativeBinding) {
|
|
363
371
|
if (loadErrors.length > 0) {
|
|
364
372
|
// TODO Link to documentation with potential fixes
|
package/deserialize-js.js
CHANGED
|
@@ -361,25 +361,28 @@ function deserializeAssignmentTargetWithDefault(pos) {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
364
|
+
const start = deserializeU32(pos),
|
|
365
|
+
end = deserializeU32(pos + 4),
|
|
366
|
+
key = deserializeIdentifierReference(pos + 8);
|
|
364
367
|
const init = deserializeOptionExpression(pos + 40),
|
|
365
|
-
|
|
368
|
+
keyCopy = { ...key },
|
|
366
369
|
value = init === null
|
|
367
|
-
?
|
|
370
|
+
? keyCopy
|
|
368
371
|
: {
|
|
369
372
|
type: 'AssignmentPattern',
|
|
370
|
-
start:
|
|
371
|
-
end:
|
|
372
|
-
left:
|
|
373
|
+
start: start,
|
|
374
|
+
end: end,
|
|
375
|
+
left: keyCopy,
|
|
373
376
|
right: init,
|
|
374
377
|
};
|
|
375
378
|
return {
|
|
376
379
|
type: 'Property',
|
|
377
|
-
start
|
|
378
|
-
end
|
|
380
|
+
start,
|
|
381
|
+
end,
|
|
379
382
|
method: false,
|
|
380
383
|
shorthand: true,
|
|
381
384
|
computed: false,
|
|
382
|
-
key
|
|
385
|
+
key,
|
|
383
386
|
value,
|
|
384
387
|
kind: 'init',
|
|
385
388
|
};
|
|
@@ -749,6 +752,7 @@ function deserializeBindingRestElement(pos) {
|
|
|
749
752
|
}
|
|
750
753
|
|
|
751
754
|
function deserializeFunction(pos) {
|
|
755
|
+
const params = deserializeBoxFormalParameters(pos + 72);
|
|
752
756
|
return {
|
|
753
757
|
type: deserializeFunctionType(pos + 8),
|
|
754
758
|
start: deserializeU32(pos),
|
|
@@ -757,7 +761,7 @@ function deserializeFunction(pos) {
|
|
|
757
761
|
expression: false,
|
|
758
762
|
generator: deserializeBool(pos + 48),
|
|
759
763
|
async: deserializeBool(pos + 49),
|
|
760
|
-
params
|
|
764
|
+
params,
|
|
761
765
|
body: deserializeOptionBoxFunctionBody(pos + 88),
|
|
762
766
|
};
|
|
763
767
|
}
|
|
@@ -794,17 +798,18 @@ function deserializeFunctionBody(pos) {
|
|
|
794
798
|
}
|
|
795
799
|
|
|
796
800
|
function deserializeArrowFunctionExpression(pos) {
|
|
801
|
+
const expression = deserializeBool(pos + 8);
|
|
797
802
|
let body = deserializeBoxFunctionBody(pos + 40);
|
|
798
803
|
return {
|
|
799
804
|
type: 'ArrowFunctionExpression',
|
|
800
805
|
start: deserializeU32(pos),
|
|
801
806
|
end: deserializeU32(pos + 4),
|
|
802
807
|
id: null,
|
|
803
|
-
expression
|
|
808
|
+
expression,
|
|
804
809
|
generator: false,
|
|
805
810
|
async: deserializeBool(pos + 9),
|
|
806
811
|
params: deserializeBoxFormalParameters(pos + 24),
|
|
807
|
-
body:
|
|
812
|
+
body: expression ? body.body[0].expression : body,
|
|
808
813
|
};
|
|
809
814
|
}
|
|
810
815
|
|
|
@@ -1056,11 +1061,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1056
1061
|
}
|
|
1057
1062
|
|
|
1058
1063
|
function deserializeStringLiteral(pos) {
|
|
1064
|
+
let value = deserializeStr(pos + 8);
|
|
1065
|
+
if (deserializeBool(pos + 40)) {
|
|
1066
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1067
|
+
}
|
|
1059
1068
|
return {
|
|
1060
1069
|
type: 'Literal',
|
|
1061
1070
|
start: deserializeU32(pos),
|
|
1062
1071
|
end: deserializeU32(pos + 4),
|
|
1063
|
-
value
|
|
1072
|
+
value,
|
|
1064
1073
|
raw: deserializeOptionStr(pos + 24),
|
|
1065
1074
|
};
|
|
1066
1075
|
}
|
|
@@ -1262,10 +1271,13 @@ function deserializeJSXText(pos) {
|
|
|
1262
1271
|
|
|
1263
1272
|
function deserializeTSThisParameter(pos) {
|
|
1264
1273
|
return {
|
|
1265
|
-
type: '
|
|
1274
|
+
type: 'Identifier',
|
|
1266
1275
|
start: deserializeU32(pos),
|
|
1267
1276
|
end: deserializeU32(pos + 4),
|
|
1277
|
+
name: 'this',
|
|
1268
1278
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1279
|
+
decorators: [],
|
|
1280
|
+
optional: false,
|
|
1269
1281
|
};
|
|
1270
1282
|
}
|
|
1271
1283
|
|
|
@@ -1602,12 +1614,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1602
1614
|
}
|
|
1603
1615
|
|
|
1604
1616
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1617
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1605
1618
|
return {
|
|
1606
1619
|
type: 'TSInterfaceDeclaration',
|
|
1607
1620
|
start: deserializeU32(pos),
|
|
1608
1621
|
end: deserializeU32(pos + 4),
|
|
1609
1622
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1610
|
-
extends:
|
|
1623
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1611
1624
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1612
1625
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1613
1626
|
declare: deserializeBool(pos + 88),
|
|
@@ -1633,6 +1646,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1633
1646
|
readonly: deserializeBool(pos + 10),
|
|
1634
1647
|
key: deserializePropertyKey(pos + 16),
|
|
1635
1648
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1649
|
+
accessibility: null,
|
|
1650
|
+
static: false,
|
|
1636
1651
|
};
|
|
1637
1652
|
}
|
|
1638
1653
|
|
|
@@ -1645,6 +1660,7 @@ function deserializeTSIndexSignature(pos) {
|
|
|
1645
1660
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 40),
|
|
1646
1661
|
readonly: deserializeBool(pos + 48),
|
|
1647
1662
|
static: deserializeBool(pos + 49),
|
|
1663
|
+
accessibility: null,
|
|
1648
1664
|
};
|
|
1649
1665
|
}
|
|
1650
1666
|
|
|
@@ -1654,7 +1670,6 @@ function deserializeTSCallSignatureDeclaration(pos) {
|
|
|
1654
1670
|
start: deserializeU32(pos),
|
|
1655
1671
|
end: deserializeU32(pos + 4),
|
|
1656
1672
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
|
|
1657
|
-
thisParam: deserializeOptionTSThisParameter(pos + 16),
|
|
1658
1673
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1659
1674
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1660
1675
|
};
|
|
@@ -1670,9 +1685,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1670
1685
|
optional: deserializeBool(pos + 25),
|
|
1671
1686
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1672
1687
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1673
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1674
1688
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1675
1689
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1690
|
+
accessibility: null,
|
|
1691
|
+
readonly: false,
|
|
1692
|
+
static: false,
|
|
1676
1693
|
};
|
|
1677
1694
|
}
|
|
1678
1695
|
|
|
@@ -1694,6 +1711,8 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1694
1711
|
end: deserializeU32(pos + 4),
|
|
1695
1712
|
name: deserializeStr(pos + 8),
|
|
1696
1713
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1714
|
+
decorators: [],
|
|
1715
|
+
optional: false,
|
|
1697
1716
|
};
|
|
1698
1717
|
}
|
|
1699
1718
|
|
|
@@ -1719,14 +1738,16 @@ function deserializeTSTypePredicate(pos) {
|
|
|
1719
1738
|
}
|
|
1720
1739
|
|
|
1721
1740
|
function deserializeTSModuleDeclaration(pos) {
|
|
1741
|
+
const kind = deserializeTSModuleDeclarationKind(pos + 80);
|
|
1722
1742
|
return {
|
|
1723
1743
|
type: 'TSModuleDeclaration',
|
|
1724
1744
|
start: deserializeU32(pos),
|
|
1725
1745
|
end: deserializeU32(pos + 4),
|
|
1726
1746
|
id: deserializeTSModuleDeclarationName(pos + 8),
|
|
1727
1747
|
body: deserializeOptionTSModuleDeclarationBody(pos + 64),
|
|
1728
|
-
kind
|
|
1748
|
+
kind,
|
|
1729
1749
|
declare: deserializeBool(pos + 81),
|
|
1750
|
+
global: kind === 'global',
|
|
1730
1751
|
};
|
|
1731
1752
|
}
|
|
1732
1753
|
|
|
@@ -1788,7 +1809,6 @@ function deserializeTSFunctionType(pos) {
|
|
|
1788
1809
|
start: deserializeU32(pos),
|
|
1789
1810
|
end: deserializeU32(pos + 4),
|
|
1790
1811
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
|
|
1791
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 16),
|
|
1792
1812
|
params: deserializeBoxFormalParameters(pos + 24),
|
|
1793
1813
|
returnType: deserializeBoxTSTypeAnnotation(pos + 32),
|
|
1794
1814
|
};
|
package/deserialize-ts.js
CHANGED
|
@@ -77,6 +77,9 @@ function deserializeBindingIdentifier(pos) {
|
|
|
77
77
|
start: deserializeU32(pos),
|
|
78
78
|
end: deserializeU32(pos + 4),
|
|
79
79
|
name: deserializeStr(pos + 8),
|
|
80
|
+
decorators: [],
|
|
81
|
+
optional: false,
|
|
82
|
+
typeAnnotation: null,
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -370,25 +373,28 @@ function deserializeAssignmentTargetWithDefault(pos) {
|
|
|
370
373
|
}
|
|
371
374
|
|
|
372
375
|
function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
376
|
+
const start = deserializeU32(pos),
|
|
377
|
+
end = deserializeU32(pos + 4),
|
|
378
|
+
key = deserializeIdentifierReference(pos + 8);
|
|
373
379
|
const init = deserializeOptionExpression(pos + 40),
|
|
374
|
-
|
|
380
|
+
keyCopy = { ...key },
|
|
375
381
|
value = init === null
|
|
376
|
-
?
|
|
382
|
+
? keyCopy
|
|
377
383
|
: {
|
|
378
384
|
type: 'AssignmentPattern',
|
|
379
|
-
start:
|
|
380
|
-
end:
|
|
381
|
-
left:
|
|
385
|
+
start: start,
|
|
386
|
+
end: end,
|
|
387
|
+
left: keyCopy,
|
|
382
388
|
right: init,
|
|
383
389
|
};
|
|
384
390
|
return {
|
|
385
391
|
type: 'Property',
|
|
386
|
-
start
|
|
387
|
-
end
|
|
392
|
+
start,
|
|
393
|
+
end,
|
|
388
394
|
method: false,
|
|
389
395
|
shorthand: true,
|
|
390
396
|
computed: false,
|
|
391
|
-
key
|
|
397
|
+
key,
|
|
392
398
|
value,
|
|
393
399
|
kind: 'init',
|
|
394
400
|
};
|
|
@@ -714,6 +720,7 @@ function deserializeAssignmentPattern(pos) {
|
|
|
714
720
|
end: deserializeU32(pos + 4),
|
|
715
721
|
left: deserializeBindingPattern(pos + 8),
|
|
716
722
|
right: deserializeExpression(pos + 40),
|
|
723
|
+
decorators: [],
|
|
717
724
|
};
|
|
718
725
|
}
|
|
719
726
|
|
|
@@ -752,6 +759,9 @@ function deserializeArrayPattern(pos) {
|
|
|
752
759
|
start: deserializeU32(pos),
|
|
753
760
|
end: deserializeU32(pos + 4),
|
|
754
761
|
elements,
|
|
762
|
+
decorators: [],
|
|
763
|
+
optional: false,
|
|
764
|
+
typeAnnotation: null,
|
|
755
765
|
};
|
|
756
766
|
}
|
|
757
767
|
|
|
@@ -765,6 +775,9 @@ function deserializeBindingRestElement(pos) {
|
|
|
765
775
|
}
|
|
766
776
|
|
|
767
777
|
function deserializeFunction(pos) {
|
|
778
|
+
const params = deserializeBoxFormalParameters(pos + 72);
|
|
779
|
+
const thisParam = deserializeOptionBoxTSThisParameter(pos + 64);
|
|
780
|
+
if (thisParam !== null) params.unshift(thisParam);
|
|
768
781
|
return {
|
|
769
782
|
type: deserializeFunctionType(pos + 8),
|
|
770
783
|
start: deserializeU32(pos),
|
|
@@ -773,11 +786,10 @@ function deserializeFunction(pos) {
|
|
|
773
786
|
expression: false,
|
|
774
787
|
generator: deserializeBool(pos + 48),
|
|
775
788
|
async: deserializeBool(pos + 49),
|
|
776
|
-
params
|
|
789
|
+
params,
|
|
777
790
|
body: deserializeOptionBoxFunctionBody(pos + 88),
|
|
778
791
|
declare: deserializeBool(pos + 50),
|
|
779
792
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 56),
|
|
780
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 64),
|
|
781
793
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 80),
|
|
782
794
|
};
|
|
783
795
|
}
|
|
@@ -806,9 +818,6 @@ function deserializeFormalParameter(pos) {
|
|
|
806
818
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
807
819
|
optional: deserializeBool(pos + 64),
|
|
808
820
|
decorators: deserializeVecDecorator(pos + 8),
|
|
809
|
-
accessibility: deserializeOptionTSAccessibility(pos + 72),
|
|
810
|
-
readonly: deserializeBool(pos + 73),
|
|
811
|
-
override: deserializeBool(pos + 74),
|
|
812
821
|
};
|
|
813
822
|
}
|
|
814
823
|
|
|
@@ -824,17 +833,18 @@ function deserializeFunctionBody(pos) {
|
|
|
824
833
|
}
|
|
825
834
|
|
|
826
835
|
function deserializeArrowFunctionExpression(pos) {
|
|
836
|
+
const expression = deserializeBool(pos + 8);
|
|
827
837
|
let body = deserializeBoxFunctionBody(pos + 40);
|
|
828
838
|
return {
|
|
829
839
|
type: 'ArrowFunctionExpression',
|
|
830
840
|
start: deserializeU32(pos),
|
|
831
841
|
end: deserializeU32(pos + 4),
|
|
832
842
|
id: null,
|
|
833
|
-
expression
|
|
843
|
+
expression,
|
|
834
844
|
generator: false,
|
|
835
845
|
async: deserializeBool(pos + 9),
|
|
836
846
|
params: deserializeBoxFormalParameters(pos + 24),
|
|
837
|
-
body:
|
|
847
|
+
body: expression ? body.body[0].expression : body,
|
|
838
848
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 16),
|
|
839
849
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
840
850
|
};
|
|
@@ -1116,11 +1126,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1116
1126
|
}
|
|
1117
1127
|
|
|
1118
1128
|
function deserializeStringLiteral(pos) {
|
|
1129
|
+
let value = deserializeStr(pos + 8);
|
|
1130
|
+
if (deserializeBool(pos + 40)) {
|
|
1131
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1132
|
+
}
|
|
1119
1133
|
return {
|
|
1120
1134
|
type: 'Literal',
|
|
1121
1135
|
start: deserializeU32(pos),
|
|
1122
1136
|
end: deserializeU32(pos + 4),
|
|
1123
|
-
value
|
|
1137
|
+
value,
|
|
1124
1138
|
raw: deserializeOptionStr(pos + 24),
|
|
1125
1139
|
};
|
|
1126
1140
|
}
|
|
@@ -1323,10 +1337,13 @@ function deserializeJSXText(pos) {
|
|
|
1323
1337
|
|
|
1324
1338
|
function deserializeTSThisParameter(pos) {
|
|
1325
1339
|
return {
|
|
1326
|
-
type: '
|
|
1340
|
+
type: 'Identifier',
|
|
1327
1341
|
start: deserializeU32(pos),
|
|
1328
1342
|
end: deserializeU32(pos + 4),
|
|
1343
|
+
name: 'this',
|
|
1329
1344
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1345
|
+
decorators: [],
|
|
1346
|
+
optional: false,
|
|
1330
1347
|
};
|
|
1331
1348
|
}
|
|
1332
1349
|
|
|
@@ -1663,12 +1680,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1663
1680
|
}
|
|
1664
1681
|
|
|
1665
1682
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1683
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1666
1684
|
return {
|
|
1667
1685
|
type: 'TSInterfaceDeclaration',
|
|
1668
1686
|
start: deserializeU32(pos),
|
|
1669
1687
|
end: deserializeU32(pos + 4),
|
|
1670
1688
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1671
|
-
extends:
|
|
1689
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1672
1690
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1673
1691
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1674
1692
|
declare: deserializeBool(pos + 88),
|
|
@@ -1694,6 +1712,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1694
1712
|
readonly: deserializeBool(pos + 10),
|
|
1695
1713
|
key: deserializePropertyKey(pos + 16),
|
|
1696
1714
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1715
|
+
accessibility: null,
|
|
1716
|
+
static: false,
|
|
1697
1717
|
};
|
|
1698
1718
|
}
|
|
1699
1719
|
|
|
@@ -1706,6 +1726,7 @@ function deserializeTSIndexSignature(pos) {
|
|
|
1706
1726
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 40),
|
|
1707
1727
|
readonly: deserializeBool(pos + 48),
|
|
1708
1728
|
static: deserializeBool(pos + 49),
|
|
1729
|
+
accessibility: null,
|
|
1709
1730
|
};
|
|
1710
1731
|
}
|
|
1711
1732
|
|
|
@@ -1715,7 +1736,6 @@ function deserializeTSCallSignatureDeclaration(pos) {
|
|
|
1715
1736
|
start: deserializeU32(pos),
|
|
1716
1737
|
end: deserializeU32(pos + 4),
|
|
1717
1738
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
|
|
1718
|
-
thisParam: deserializeOptionTSThisParameter(pos + 16),
|
|
1719
1739
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1720
1740
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1721
1741
|
};
|
|
@@ -1731,9 +1751,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1731
1751
|
optional: deserializeBool(pos + 25),
|
|
1732
1752
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1733
1753
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1734
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1735
1754
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1736
1755
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1756
|
+
accessibility: null,
|
|
1757
|
+
readonly: false,
|
|
1758
|
+
static: false,
|
|
1737
1759
|
};
|
|
1738
1760
|
}
|
|
1739
1761
|
|
|
@@ -1755,6 +1777,8 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1755
1777
|
end: deserializeU32(pos + 4),
|
|
1756
1778
|
name: deserializeStr(pos + 8),
|
|
1757
1779
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1780
|
+
decorators: [],
|
|
1781
|
+
optional: false,
|
|
1758
1782
|
};
|
|
1759
1783
|
}
|
|
1760
1784
|
|
|
@@ -1780,14 +1804,16 @@ function deserializeTSTypePredicate(pos) {
|
|
|
1780
1804
|
}
|
|
1781
1805
|
|
|
1782
1806
|
function deserializeTSModuleDeclaration(pos) {
|
|
1807
|
+
const kind = deserializeTSModuleDeclarationKind(pos + 80);
|
|
1783
1808
|
return {
|
|
1784
1809
|
type: 'TSModuleDeclaration',
|
|
1785
1810
|
start: deserializeU32(pos),
|
|
1786
1811
|
end: deserializeU32(pos + 4),
|
|
1787
1812
|
id: deserializeTSModuleDeclarationName(pos + 8),
|
|
1788
1813
|
body: deserializeOptionTSModuleDeclarationBody(pos + 64),
|
|
1789
|
-
kind
|
|
1814
|
+
kind,
|
|
1790
1815
|
declare: deserializeBool(pos + 81),
|
|
1816
|
+
global: kind === 'global',
|
|
1791
1817
|
};
|
|
1792
1818
|
}
|
|
1793
1819
|
|
|
@@ -1849,7 +1875,6 @@ function deserializeTSFunctionType(pos) {
|
|
|
1849
1875
|
start: deserializeU32(pos),
|
|
1850
1876
|
end: deserializeU32(pos + 4),
|
|
1851
1877
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
|
|
1852
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 16),
|
|
1853
1878
|
params: deserializeBoxFormalParameters(pos + 24),
|
|
1854
1879
|
returnType: deserializeBoxTSTypeAnnotation(pos + 32),
|
|
1855
1880
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.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,14 +39,15 @@
|
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.62.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.0.
|
|
47
|
+
"@vitest/browser": "3.0.9",
|
|
48
|
+
"esbuild": "^0.25.0",
|
|
47
49
|
"playwright": "^1.51.0",
|
|
48
|
-
"vitest": "3.0.
|
|
50
|
+
"vitest": "3.0.9"
|
|
49
51
|
},
|
|
50
52
|
"napi": {
|
|
51
53
|
"binaryName": "parser",
|
|
@@ -70,22 +72,24 @@
|
|
|
70
72
|
"dtsHeaderFile": "header.js"
|
|
71
73
|
},
|
|
72
74
|
"optionalDependencies": {
|
|
73
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
74
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
75
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
76
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
77
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
78
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
79
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
80
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
81
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
82
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
75
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.62.0",
|
|
76
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.62.0",
|
|
77
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.62.0",
|
|
78
|
+
"@oxc-parser/binding-linux-x64-musl": "0.62.0",
|
|
79
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.62.0",
|
|
80
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.62.0",
|
|
81
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.62.0",
|
|
82
|
+
"@oxc-parser/binding-darwin-x64": "0.62.0",
|
|
83
|
+
"@oxc-parser/binding-darwin-arm64": "0.62.0",
|
|
84
|
+
"@oxc-parser/binding-wasm32-wasi": "0.62.0"
|
|
83
85
|
},
|
|
84
86
|
"scripts": {
|
|
85
87
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|
|
86
88
|
"build": "pnpm run build-dev --features allocator --release",
|
|
89
|
+
"postbuild-dev": "node patch.mjs",
|
|
87
90
|
"build-wasi": "pnpm run build-dev --release --target wasm32-wasip1-threads",
|
|
88
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 .",
|
|
92
|
+
"build-browser-bundle": "node build-browser-bundle.mjs",
|
|
89
93
|
"test": "pnpm run test-node run && tsc",
|
|
90
94
|
"test-node": "vitest --dir ./test",
|
|
91
95
|
"test-browser": "vitest -c vitest.config.browser.mts",
|
|
@@ -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);
|