oxc-parser 0.73.0 → 0.74.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/generated/deserialize/js.js +114 -114
- package/generated/deserialize/lazy-types.js +193 -0
- package/generated/deserialize/lazy-visit.js +5457 -0
- package/generated/deserialize/lazy.js +2107 -1653
- package/generated/deserialize/ts.js +116 -129
- package/index.js +95 -18
- package/package.json +28 -20
- package/raw-transfer/{index.js → common.js} +101 -98
- package/raw-transfer/eager.js +42 -3
- package/raw-transfer/lazy-common.js +15 -0
- package/raw-transfer/lazy.js +95 -21
- package/raw-transfer/node-array.js +342 -0
- package/raw-transfer/supported.js +56 -0
- package/raw-transfer/visitor.js +127 -0
|
@@ -956,27 +956,14 @@ function deserializeClassBody(pos) {
|
|
|
956
956
|
}
|
|
957
957
|
|
|
958
958
|
function deserializeMethodDefinition(pos) {
|
|
959
|
-
const kind = deserializeMethodDefinitionKind(pos + 57);
|
|
960
|
-
let key = deserializePropertyKey(pos + 32);
|
|
961
|
-
if (kind === 'constructor') {
|
|
962
|
-
key = {
|
|
963
|
-
type: 'Identifier',
|
|
964
|
-
start: key.start,
|
|
965
|
-
end: key.end,
|
|
966
|
-
decorators: [],
|
|
967
|
-
name: 'constructor',
|
|
968
|
-
optional: false,
|
|
969
|
-
typeAnnotation: null,
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
959
|
return {
|
|
973
960
|
type: deserializeMethodDefinitionType(pos + 56),
|
|
974
961
|
start: deserializeU32(pos),
|
|
975
962
|
end: deserializeU32(pos + 4),
|
|
976
963
|
decorators: deserializeVecDecorator(pos + 8),
|
|
977
|
-
key,
|
|
964
|
+
key: deserializePropertyKey(pos + 32),
|
|
978
965
|
value: deserializeBoxFunction(pos + 48),
|
|
979
|
-
kind,
|
|
966
|
+
kind: deserializeMethodDefinitionKind(pos + 57),
|
|
980
967
|
computed: deserializeBool(pos + 58),
|
|
981
968
|
static: deserializeBool(pos + 59),
|
|
982
969
|
override: deserializeBool(pos + 60),
|
|
@@ -4196,10 +4183,10 @@ function deserializeStr(pos) {
|
|
|
4196
4183
|
|
|
4197
4184
|
function deserializeVecComment(pos) {
|
|
4198
4185
|
const arr = [],
|
|
4199
|
-
pos32 = pos >> 2
|
|
4200
|
-
len = uint32[pos32 + 2];
|
|
4186
|
+
pos32 = pos >> 2;
|
|
4201
4187
|
pos = uint32[pos32];
|
|
4202
|
-
|
|
4188
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4189
|
+
while (pos !== endPos) {
|
|
4203
4190
|
arr.push(deserializeComment(pos));
|
|
4204
4191
|
pos += 16;
|
|
4205
4192
|
}
|
|
@@ -4213,10 +4200,10 @@ function deserializeOptionHashbang(pos) {
|
|
|
4213
4200
|
|
|
4214
4201
|
function deserializeVecDirective(pos) {
|
|
4215
4202
|
const arr = [],
|
|
4216
|
-
pos32 = pos >> 2
|
|
4217
|
-
len = uint32[pos32 + 2];
|
|
4203
|
+
pos32 = pos >> 2;
|
|
4218
4204
|
pos = uint32[pos32];
|
|
4219
|
-
|
|
4205
|
+
const endPos = pos + uint32[pos32 + 2] * 72;
|
|
4206
|
+
while (pos !== endPos) {
|
|
4220
4207
|
arr.push(deserializeDirective(pos));
|
|
4221
4208
|
pos += 72;
|
|
4222
4209
|
}
|
|
@@ -4225,10 +4212,10 @@ function deserializeVecDirective(pos) {
|
|
|
4225
4212
|
|
|
4226
4213
|
function deserializeVecStatement(pos) {
|
|
4227
4214
|
const arr = [],
|
|
4228
|
-
pos32 = pos >> 2
|
|
4229
|
-
len = uint32[pos32 + 2];
|
|
4215
|
+
pos32 = pos >> 2;
|
|
4230
4216
|
pos = uint32[pos32];
|
|
4231
|
-
|
|
4217
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4218
|
+
while (pos !== endPos) {
|
|
4232
4219
|
arr.push(deserializeStatement(pos));
|
|
4233
4220
|
pos += 16;
|
|
4234
4221
|
}
|
|
@@ -4397,10 +4384,10 @@ function deserializeBoxV8IntrinsicExpression(pos) {
|
|
|
4397
4384
|
|
|
4398
4385
|
function deserializeVecArrayExpressionElement(pos) {
|
|
4399
4386
|
const arr = [],
|
|
4400
|
-
pos32 = pos >> 2
|
|
4401
|
-
len = uint32[pos32 + 2];
|
|
4387
|
+
pos32 = pos >> 2;
|
|
4402
4388
|
pos = uint32[pos32];
|
|
4403
|
-
|
|
4389
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4390
|
+
while (pos !== endPos) {
|
|
4404
4391
|
arr.push(deserializeArrayExpressionElement(pos));
|
|
4405
4392
|
pos += 16;
|
|
4406
4393
|
}
|
|
@@ -4413,10 +4400,10 @@ function deserializeBoxSpreadElement(pos) {
|
|
|
4413
4400
|
|
|
4414
4401
|
function deserializeVecObjectPropertyKind(pos) {
|
|
4415
4402
|
const arr = [],
|
|
4416
|
-
pos32 = pos >> 2
|
|
4417
|
-
len = uint32[pos32 + 2];
|
|
4403
|
+
pos32 = pos >> 2;
|
|
4418
4404
|
pos = uint32[pos32];
|
|
4419
|
-
|
|
4405
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4406
|
+
while (pos !== endPos) {
|
|
4420
4407
|
arr.push(deserializeObjectPropertyKind(pos));
|
|
4421
4408
|
pos += 16;
|
|
4422
4409
|
}
|
|
@@ -4441,10 +4428,10 @@ function deserializeBoxPrivateIdentifier(pos) {
|
|
|
4441
4428
|
|
|
4442
4429
|
function deserializeVecTemplateElement(pos) {
|
|
4443
4430
|
const arr = [],
|
|
4444
|
-
pos32 = pos >> 2
|
|
4445
|
-
len = uint32[pos32 + 2];
|
|
4431
|
+
pos32 = pos >> 2;
|
|
4446
4432
|
pos = uint32[pos32];
|
|
4447
|
-
|
|
4433
|
+
const endPos = pos + uint32[pos32 + 2] * 48;
|
|
4434
|
+
while (pos !== endPos) {
|
|
4448
4435
|
arr.push(deserializeTemplateElement(pos));
|
|
4449
4436
|
pos += 48;
|
|
4450
4437
|
}
|
|
@@ -4453,10 +4440,10 @@ function deserializeVecTemplateElement(pos) {
|
|
|
4453
4440
|
|
|
4454
4441
|
function deserializeVecExpression(pos) {
|
|
4455
4442
|
const arr = [],
|
|
4456
|
-
pos32 = pos >> 2
|
|
4457
|
-
len = uint32[pos32 + 2];
|
|
4443
|
+
pos32 = pos >> 2;
|
|
4458
4444
|
pos = uint32[pos32];
|
|
4459
|
-
|
|
4445
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4446
|
+
while (pos !== endPos) {
|
|
4460
4447
|
arr.push(deserializeExpression(pos));
|
|
4461
4448
|
pos += 16;
|
|
4462
4449
|
}
|
|
@@ -4491,10 +4478,10 @@ function deserializeBoxPrivateFieldExpression(pos) {
|
|
|
4491
4478
|
|
|
4492
4479
|
function deserializeVecArgument(pos) {
|
|
4493
4480
|
const arr = [],
|
|
4494
|
-
pos32 = pos >> 2
|
|
4495
|
-
len = uint32[pos32 + 2];
|
|
4481
|
+
pos32 = pos >> 2;
|
|
4496
4482
|
pos = uint32[pos32];
|
|
4497
|
-
|
|
4483
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4484
|
+
while (pos !== endPos) {
|
|
4498
4485
|
arr.push(deserializeArgument(pos));
|
|
4499
4486
|
pos += 16;
|
|
4500
4487
|
}
|
|
@@ -4516,10 +4503,10 @@ function deserializeOptionAssignmentTargetMaybeDefault(pos) {
|
|
|
4516
4503
|
|
|
4517
4504
|
function deserializeVecOptionAssignmentTargetMaybeDefault(pos) {
|
|
4518
4505
|
const arr = [],
|
|
4519
|
-
pos32 = pos >> 2
|
|
4520
|
-
len = uint32[pos32 + 2];
|
|
4506
|
+
pos32 = pos >> 2;
|
|
4521
4507
|
pos = uint32[pos32];
|
|
4522
|
-
|
|
4508
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4509
|
+
while (pos !== endPos) {
|
|
4523
4510
|
arr.push(deserializeOptionAssignmentTargetMaybeDefault(pos));
|
|
4524
4511
|
pos += 16;
|
|
4525
4512
|
}
|
|
@@ -4533,10 +4520,10 @@ function deserializeOptionAssignmentTargetRest(pos) {
|
|
|
4533
4520
|
|
|
4534
4521
|
function deserializeVecAssignmentTargetProperty(pos) {
|
|
4535
4522
|
const arr = [],
|
|
4536
|
-
pos32 = pos >> 2
|
|
4537
|
-
len = uint32[pos32 + 2];
|
|
4523
|
+
pos32 = pos >> 2;
|
|
4538
4524
|
pos = uint32[pos32];
|
|
4539
|
-
|
|
4525
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4526
|
+
while (pos !== endPos) {
|
|
4540
4527
|
arr.push(deserializeAssignmentTargetProperty(pos));
|
|
4541
4528
|
pos += 16;
|
|
4542
4529
|
}
|
|
@@ -4658,10 +4645,10 @@ function deserializeBoxTSImportEqualsDeclaration(pos) {
|
|
|
4658
4645
|
|
|
4659
4646
|
function deserializeVecVariableDeclarator(pos) {
|
|
4660
4647
|
const arr = [],
|
|
4661
|
-
pos32 = pos >> 2
|
|
4662
|
-
len = uint32[pos32 + 2];
|
|
4648
|
+
pos32 = pos >> 2;
|
|
4663
4649
|
pos = uint32[pos32];
|
|
4664
|
-
|
|
4650
|
+
const endPos = pos + uint32[pos32 + 2] * 64;
|
|
4651
|
+
while (pos !== endPos) {
|
|
4665
4652
|
arr.push(deserializeVariableDeclarator(pos));
|
|
4666
4653
|
pos += 64;
|
|
4667
4654
|
}
|
|
@@ -4685,10 +4672,10 @@ function deserializeOptionLabelIdentifier(pos) {
|
|
|
4685
4672
|
|
|
4686
4673
|
function deserializeVecSwitchCase(pos) {
|
|
4687
4674
|
const arr = [],
|
|
4688
|
-
pos32 = pos >> 2
|
|
4689
|
-
len = uint32[pos32 + 2];
|
|
4675
|
+
pos32 = pos >> 2;
|
|
4690
4676
|
pos = uint32[pos32];
|
|
4691
|
-
|
|
4677
|
+
const endPos = pos + uint32[pos32 + 2] * 48;
|
|
4678
|
+
while (pos !== endPos) {
|
|
4692
4679
|
arr.push(deserializeSwitchCase(pos));
|
|
4693
4680
|
pos += 48;
|
|
4694
4681
|
}
|
|
@@ -4741,10 +4728,10 @@ function deserializeBoxAssignmentPattern(pos) {
|
|
|
4741
4728
|
|
|
4742
4729
|
function deserializeVecBindingProperty(pos) {
|
|
4743
4730
|
const arr = [],
|
|
4744
|
-
pos32 = pos >> 2
|
|
4745
|
-
len = uint32[pos32 + 2];
|
|
4731
|
+
pos32 = pos >> 2;
|
|
4746
4732
|
pos = uint32[pos32];
|
|
4747
|
-
|
|
4733
|
+
const endPos = pos + uint32[pos32 + 2] * 64;
|
|
4734
|
+
while (pos !== endPos) {
|
|
4748
4735
|
arr.push(deserializeBindingProperty(pos));
|
|
4749
4736
|
pos += 64;
|
|
4750
4737
|
}
|
|
@@ -4767,10 +4754,10 @@ function deserializeOptionBindingPattern(pos) {
|
|
|
4767
4754
|
|
|
4768
4755
|
function deserializeVecOptionBindingPattern(pos) {
|
|
4769
4756
|
const arr = [],
|
|
4770
|
-
pos32 = pos >> 2
|
|
4771
|
-
len = uint32[pos32 + 2];
|
|
4757
|
+
pos32 = pos >> 2;
|
|
4772
4758
|
pos = uint32[pos32];
|
|
4773
|
-
|
|
4759
|
+
const endPos = pos + uint32[pos32 + 2] * 32;
|
|
4760
|
+
while (pos !== endPos) {
|
|
4774
4761
|
arr.push(deserializeOptionBindingPattern(pos));
|
|
4775
4762
|
pos += 32;
|
|
4776
4763
|
}
|
|
@@ -4815,10 +4802,10 @@ function deserializeOptionBoxFunctionBody(pos) {
|
|
|
4815
4802
|
|
|
4816
4803
|
function deserializeVecFormalParameter(pos) {
|
|
4817
4804
|
const arr = [],
|
|
4818
|
-
pos32 = pos >> 2
|
|
4819
|
-
len = uint32[pos32 + 2];
|
|
4805
|
+
pos32 = pos >> 2;
|
|
4820
4806
|
pos = uint32[pos32];
|
|
4821
|
-
|
|
4807
|
+
const endPos = pos + uint32[pos32 + 2] * 72;
|
|
4808
|
+
while (pos !== endPos) {
|
|
4822
4809
|
arr.push(deserializeFormalParameter(pos));
|
|
4823
4810
|
pos += 72;
|
|
4824
4811
|
}
|
|
@@ -4827,10 +4814,10 @@ function deserializeVecFormalParameter(pos) {
|
|
|
4827
4814
|
|
|
4828
4815
|
function deserializeVecDecorator(pos) {
|
|
4829
4816
|
const arr = [],
|
|
4830
|
-
pos32 = pos >> 2
|
|
4831
|
-
len = uint32[pos32 + 2];
|
|
4817
|
+
pos32 = pos >> 2;
|
|
4832
4818
|
pos = uint32[pos32];
|
|
4833
|
-
|
|
4819
|
+
const endPos = pos + uint32[pos32 + 2] * 24;
|
|
4820
|
+
while (pos !== endPos) {
|
|
4834
4821
|
arr.push(deserializeDecorator(pos));
|
|
4835
4822
|
pos += 24;
|
|
4836
4823
|
}
|
|
@@ -4844,10 +4831,10 @@ function deserializeOptionTSAccessibility(pos) {
|
|
|
4844
4831
|
|
|
4845
4832
|
function deserializeVecTSClassImplements(pos) {
|
|
4846
4833
|
const arr = [],
|
|
4847
|
-
pos32 = pos >> 2
|
|
4848
|
-
len = uint32[pos32 + 2];
|
|
4834
|
+
pos32 = pos >> 2;
|
|
4849
4835
|
pos = uint32[pos32];
|
|
4850
|
-
|
|
4836
|
+
const endPos = pos + uint32[pos32 + 2] * 32;
|
|
4837
|
+
while (pos !== endPos) {
|
|
4851
4838
|
arr.push(deserializeTSClassImplements(pos));
|
|
4852
4839
|
pos += 32;
|
|
4853
4840
|
}
|
|
@@ -4860,10 +4847,10 @@ function deserializeBoxClassBody(pos) {
|
|
|
4860
4847
|
|
|
4861
4848
|
function deserializeVecClassElement(pos) {
|
|
4862
4849
|
const arr = [],
|
|
4863
|
-
pos32 = pos >> 2
|
|
4864
|
-
len = uint32[pos32 + 2];
|
|
4850
|
+
pos32 = pos >> 2;
|
|
4865
4851
|
pos = uint32[pos32];
|
|
4866
|
-
|
|
4852
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4853
|
+
while (pos !== endPos) {
|
|
4867
4854
|
arr.push(deserializeClassElement(pos));
|
|
4868
4855
|
pos += 16;
|
|
4869
4856
|
}
|
|
@@ -4921,10 +4908,10 @@ function deserializeOptionImportPhase(pos) {
|
|
|
4921
4908
|
|
|
4922
4909
|
function deserializeVecImportDeclarationSpecifier(pos) {
|
|
4923
4910
|
const arr = [],
|
|
4924
|
-
pos32 = pos >> 2
|
|
4925
|
-
len = uint32[pos32 + 2];
|
|
4911
|
+
pos32 = pos >> 2;
|
|
4926
4912
|
pos = uint32[pos32];
|
|
4927
|
-
|
|
4913
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
4914
|
+
while (pos !== endPos) {
|
|
4928
4915
|
arr.push(deserializeImportDeclarationSpecifier(pos));
|
|
4929
4916
|
pos += 16;
|
|
4930
4917
|
}
|
|
@@ -4959,10 +4946,10 @@ function deserializeBoxImportNamespaceSpecifier(pos) {
|
|
|
4959
4946
|
|
|
4960
4947
|
function deserializeVecImportAttribute(pos) {
|
|
4961
4948
|
const arr = [],
|
|
4962
|
-
pos32 = pos >> 2
|
|
4963
|
-
len = uint32[pos32 + 2];
|
|
4949
|
+
pos32 = pos >> 2;
|
|
4964
4950
|
pos = uint32[pos32];
|
|
4965
|
-
|
|
4951
|
+
const endPos = pos + uint32[pos32 + 2] * 112;
|
|
4952
|
+
while (pos !== endPos) {
|
|
4966
4953
|
arr.push(deserializeImportAttribute(pos));
|
|
4967
4954
|
pos += 112;
|
|
4968
4955
|
}
|
|
@@ -4976,10 +4963,10 @@ function deserializeOptionDeclaration(pos) {
|
|
|
4976
4963
|
|
|
4977
4964
|
function deserializeVecExportSpecifier(pos) {
|
|
4978
4965
|
const arr = [],
|
|
4979
|
-
pos32 = pos >> 2
|
|
4980
|
-
len = uint32[pos32 + 2];
|
|
4966
|
+
pos32 = pos >> 2;
|
|
4981
4967
|
pos = uint32[pos32];
|
|
4982
|
-
|
|
4968
|
+
const endPos = pos + uint32[pos32 + 2] * 128;
|
|
4969
|
+
while (pos !== endPos) {
|
|
4983
4970
|
arr.push(deserializeExportSpecifier(pos));
|
|
4984
4971
|
pos += 128;
|
|
4985
4972
|
}
|
|
@@ -5010,10 +4997,10 @@ function deserializeBoxJSXOpeningElement(pos) {
|
|
|
5010
4997
|
|
|
5011
4998
|
function deserializeVecJSXChild(pos) {
|
|
5012
4999
|
const arr = [],
|
|
5013
|
-
pos32 = pos >> 2
|
|
5014
|
-
len = uint32[pos32 + 2];
|
|
5000
|
+
pos32 = pos >> 2;
|
|
5015
5001
|
pos = uint32[pos32];
|
|
5016
|
-
|
|
5002
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5003
|
+
while (pos !== endPos) {
|
|
5017
5004
|
arr.push(deserializeJSXChild(pos));
|
|
5018
5005
|
pos += 16;
|
|
5019
5006
|
}
|
|
@@ -5031,10 +5018,10 @@ function deserializeOptionBoxJSXClosingElement(pos) {
|
|
|
5031
5018
|
|
|
5032
5019
|
function deserializeVecJSXAttributeItem(pos) {
|
|
5033
5020
|
const arr = [],
|
|
5034
|
-
pos32 = pos >> 2
|
|
5035
|
-
len = uint32[pos32 + 2];
|
|
5021
|
+
pos32 = pos >> 2;
|
|
5036
5022
|
pos = uint32[pos32];
|
|
5037
|
-
|
|
5023
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5024
|
+
while (pos !== endPos) {
|
|
5038
5025
|
arr.push(deserializeJSXAttributeItem(pos));
|
|
5039
5026
|
pos += 16;
|
|
5040
5027
|
}
|
|
@@ -5080,10 +5067,10 @@ function deserializeBoxJSXSpreadChild(pos) {
|
|
|
5080
5067
|
|
|
5081
5068
|
function deserializeVecTSEnumMember(pos) {
|
|
5082
5069
|
const arr = [],
|
|
5083
|
-
pos32 = pos >> 2
|
|
5084
|
-
len = uint32[pos32 + 2];
|
|
5070
|
+
pos32 = pos >> 2;
|
|
5085
5071
|
pos = uint32[pos32];
|
|
5086
|
-
|
|
5072
|
+
const endPos = pos + uint32[pos32 + 2] * 40;
|
|
5073
|
+
while (pos !== endPos) {
|
|
5087
5074
|
arr.push(deserializeTSEnumMember(pos));
|
|
5088
5075
|
pos += 40;
|
|
5089
5076
|
}
|
|
@@ -5240,10 +5227,10 @@ function deserializeBoxJSDocUnknownType(pos) {
|
|
|
5240
5227
|
|
|
5241
5228
|
function deserializeVecTSType(pos) {
|
|
5242
5229
|
const arr = [],
|
|
5243
|
-
pos32 = pos >> 2
|
|
5244
|
-
len = uint32[pos32 + 2];
|
|
5230
|
+
pos32 = pos >> 2;
|
|
5245
5231
|
pos = uint32[pos32];
|
|
5246
|
-
|
|
5232
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5233
|
+
while (pos !== endPos) {
|
|
5247
5234
|
arr.push(deserializeTSType(pos));
|
|
5248
5235
|
pos += 16;
|
|
5249
5236
|
}
|
|
@@ -5252,10 +5239,10 @@ function deserializeVecTSType(pos) {
|
|
|
5252
5239
|
|
|
5253
5240
|
function deserializeVecTSTupleElement(pos) {
|
|
5254
5241
|
const arr = [],
|
|
5255
|
-
pos32 = pos >> 2
|
|
5256
|
-
len = uint32[pos32 + 2];
|
|
5242
|
+
pos32 = pos >> 2;
|
|
5257
5243
|
pos = uint32[pos32];
|
|
5258
|
-
|
|
5244
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5245
|
+
while (pos !== endPos) {
|
|
5259
5246
|
arr.push(deserializeTSTupleElement(pos));
|
|
5260
5247
|
pos += 16;
|
|
5261
5248
|
}
|
|
@@ -5281,10 +5268,10 @@ function deserializeOptionTSType(pos) {
|
|
|
5281
5268
|
|
|
5282
5269
|
function deserializeVecTSTypeParameter(pos) {
|
|
5283
5270
|
const arr = [],
|
|
5284
|
-
pos32 = pos >> 2
|
|
5285
|
-
len = uint32[pos32 + 2];
|
|
5271
|
+
pos32 = pos >> 2;
|
|
5286
5272
|
pos = uint32[pos32];
|
|
5287
|
-
|
|
5273
|
+
const endPos = pos + uint32[pos32 + 2] * 80;
|
|
5274
|
+
while (pos !== endPos) {
|
|
5288
5275
|
arr.push(deserializeTSTypeParameter(pos));
|
|
5289
5276
|
pos += 80;
|
|
5290
5277
|
}
|
|
@@ -5293,10 +5280,10 @@ function deserializeVecTSTypeParameter(pos) {
|
|
|
5293
5280
|
|
|
5294
5281
|
function deserializeVecTSInterfaceHeritage(pos) {
|
|
5295
5282
|
const arr = [],
|
|
5296
|
-
pos32 = pos >> 2
|
|
5297
|
-
len = uint32[pos32 + 2];
|
|
5283
|
+
pos32 = pos >> 2;
|
|
5298
5284
|
pos = uint32[pos32];
|
|
5299
|
-
|
|
5285
|
+
const endPos = pos + uint32[pos32 + 2] * 32;
|
|
5286
|
+
while (pos !== endPos) {
|
|
5300
5287
|
arr.push(deserializeTSInterfaceHeritage(pos));
|
|
5301
5288
|
pos += 32;
|
|
5302
5289
|
}
|
|
@@ -5309,10 +5296,10 @@ function deserializeBoxTSInterfaceBody(pos) {
|
|
|
5309
5296
|
|
|
5310
5297
|
function deserializeVecTSSignature(pos) {
|
|
5311
5298
|
const arr = [],
|
|
5312
|
-
pos32 = pos >> 2
|
|
5313
|
-
len = uint32[pos32 + 2];
|
|
5299
|
+
pos32 = pos >> 2;
|
|
5314
5300
|
pos = uint32[pos32];
|
|
5315
|
-
|
|
5301
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5302
|
+
while (pos !== endPos) {
|
|
5316
5303
|
arr.push(deserializeTSSignature(pos));
|
|
5317
5304
|
pos += 16;
|
|
5318
5305
|
}
|
|
@@ -5337,10 +5324,10 @@ function deserializeBoxTSMethodSignature(pos) {
|
|
|
5337
5324
|
|
|
5338
5325
|
function deserializeVecTSIndexSignatureName(pos) {
|
|
5339
5326
|
const arr = [],
|
|
5340
|
-
pos32 = pos >> 2
|
|
5341
|
-
len = uint32[pos32 + 2];
|
|
5327
|
+
pos32 = pos >> 2;
|
|
5342
5328
|
pos = uint32[pos32];
|
|
5343
|
-
|
|
5329
|
+
const endPos = pos + uint32[pos32 + 2] * 32;
|
|
5330
|
+
while (pos !== endPos) {
|
|
5344
5331
|
arr.push(deserializeTSIndexSignatureName(pos));
|
|
5345
5332
|
pos += 32;
|
|
5346
5333
|
}
|
|
@@ -5400,10 +5387,10 @@ function deserializeOptionU64(pos) {
|
|
|
5400
5387
|
|
|
5401
5388
|
function deserializeVecError(pos) {
|
|
5402
5389
|
const arr = [],
|
|
5403
|
-
pos32 = pos >> 2
|
|
5404
|
-
len = uint32[pos32 + 2];
|
|
5390
|
+
pos32 = pos >> 2;
|
|
5405
5391
|
pos = uint32[pos32];
|
|
5406
|
-
|
|
5392
|
+
const endPos = pos + uint32[pos32 + 2] * 80;
|
|
5393
|
+
while (pos !== endPos) {
|
|
5407
5394
|
arr.push(deserializeError(pos));
|
|
5408
5395
|
pos += 80;
|
|
5409
5396
|
}
|
|
@@ -5412,10 +5399,10 @@ function deserializeVecError(pos) {
|
|
|
5412
5399
|
|
|
5413
5400
|
function deserializeVecErrorLabel(pos) {
|
|
5414
5401
|
const arr = [],
|
|
5415
|
-
pos32 = pos >> 2
|
|
5416
|
-
len = uint32[pos32 + 2];
|
|
5402
|
+
pos32 = pos >> 2;
|
|
5417
5403
|
pos = uint32[pos32];
|
|
5418
|
-
|
|
5404
|
+
const endPos = pos + uint32[pos32 + 2] * 24;
|
|
5405
|
+
while (pos !== endPos) {
|
|
5419
5406
|
arr.push(deserializeErrorLabel(pos));
|
|
5420
5407
|
pos += 24;
|
|
5421
5408
|
}
|
|
@@ -5424,10 +5411,10 @@ function deserializeVecErrorLabel(pos) {
|
|
|
5424
5411
|
|
|
5425
5412
|
function deserializeVecStaticImport(pos) {
|
|
5426
5413
|
const arr = [],
|
|
5427
|
-
pos32 = pos >> 2
|
|
5428
|
-
len = uint32[pos32 + 2];
|
|
5414
|
+
pos32 = pos >> 2;
|
|
5429
5415
|
pos = uint32[pos32];
|
|
5430
|
-
|
|
5416
|
+
const endPos = pos + uint32[pos32 + 2] * 56;
|
|
5417
|
+
while (pos !== endPos) {
|
|
5431
5418
|
arr.push(deserializeStaticImport(pos));
|
|
5432
5419
|
pos += 56;
|
|
5433
5420
|
}
|
|
@@ -5436,10 +5423,10 @@ function deserializeVecStaticImport(pos) {
|
|
|
5436
5423
|
|
|
5437
5424
|
function deserializeVecStaticExport(pos) {
|
|
5438
5425
|
const arr = [],
|
|
5439
|
-
pos32 = pos >> 2
|
|
5440
|
-
len = uint32[pos32 + 2];
|
|
5426
|
+
pos32 = pos >> 2;
|
|
5441
5427
|
pos = uint32[pos32];
|
|
5442
|
-
|
|
5428
|
+
const endPos = pos + uint32[pos32 + 2] * 32;
|
|
5429
|
+
while (pos !== endPos) {
|
|
5443
5430
|
arr.push(deserializeStaticExport(pos));
|
|
5444
5431
|
pos += 32;
|
|
5445
5432
|
}
|
|
@@ -5448,10 +5435,10 @@ function deserializeVecStaticExport(pos) {
|
|
|
5448
5435
|
|
|
5449
5436
|
function deserializeVecDynamicImport(pos) {
|
|
5450
5437
|
const arr = [],
|
|
5451
|
-
pos32 = pos >> 2
|
|
5452
|
-
len = uint32[pos32 + 2];
|
|
5438
|
+
pos32 = pos >> 2;
|
|
5453
5439
|
pos = uint32[pos32];
|
|
5454
|
-
|
|
5440
|
+
const endPos = pos + uint32[pos32 + 2] * 16;
|
|
5441
|
+
while (pos !== endPos) {
|
|
5455
5442
|
arr.push(deserializeDynamicImport(pos));
|
|
5456
5443
|
pos += 16;
|
|
5457
5444
|
}
|
|
@@ -5460,10 +5447,10 @@ function deserializeVecDynamicImport(pos) {
|
|
|
5460
5447
|
|
|
5461
5448
|
function deserializeVecSpan(pos) {
|
|
5462
5449
|
const arr = [],
|
|
5463
|
-
pos32 = pos >> 2
|
|
5464
|
-
len = uint32[pos32 + 2];
|
|
5450
|
+
pos32 = pos >> 2;
|
|
5465
5451
|
pos = uint32[pos32];
|
|
5466
|
-
|
|
5452
|
+
const endPos = pos + uint32[pos32 + 2] * 8;
|
|
5453
|
+
while (pos !== endPos) {
|
|
5467
5454
|
arr.push(deserializeSpan(pos));
|
|
5468
5455
|
pos += 8;
|
|
5469
5456
|
}
|
|
@@ -5472,10 +5459,10 @@ function deserializeVecSpan(pos) {
|
|
|
5472
5459
|
|
|
5473
5460
|
function deserializeVecImportEntry(pos) {
|
|
5474
5461
|
const arr = [],
|
|
5475
|
-
pos32 = pos >> 2
|
|
5476
|
-
len = uint32[pos32 + 2];
|
|
5462
|
+
pos32 = pos >> 2;
|
|
5477
5463
|
pos = uint32[pos32];
|
|
5478
|
-
|
|
5464
|
+
const endPos = pos + uint32[pos32 + 2] * 96;
|
|
5465
|
+
while (pos !== endPos) {
|
|
5479
5466
|
arr.push(deserializeImportEntry(pos));
|
|
5480
5467
|
pos += 96;
|
|
5481
5468
|
}
|
|
@@ -5484,10 +5471,10 @@ function deserializeVecImportEntry(pos) {
|
|
|
5484
5471
|
|
|
5485
5472
|
function deserializeVecExportEntry(pos) {
|
|
5486
5473
|
const arr = [],
|
|
5487
|
-
pos32 = pos >> 2
|
|
5488
|
-
len = uint32[pos32 + 2];
|
|
5474
|
+
pos32 = pos >> 2;
|
|
5489
5475
|
pos = uint32[pos32];
|
|
5490
|
-
|
|
5476
|
+
const endPos = pos + uint32[pos32 + 2] * 144;
|
|
5477
|
+
while (pos !== endPos) {
|
|
5491
5478
|
arr.push(deserializeExportEntry(pos));
|
|
5492
5479
|
pos += 144;
|
|
5493
5480
|
}
|
package/index.js
CHANGED
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const bindings = require('./bindings.js');
|
|
4
4
|
const { wrap } = require('./wrap.cjs');
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
parseSyncLazy,
|
|
9
|
-
parseAsyncLazy,
|
|
10
|
-
rawTransferSupported,
|
|
11
|
-
} = require('./raw-transfer/index.js');
|
|
5
|
+
const rawTransferSupported = require('./raw-transfer/supported.js');
|
|
6
|
+
|
|
7
|
+
const { parseSync: parseSyncBinding, parseAsync: parseAsyncBinding } = bindings;
|
|
12
8
|
|
|
13
9
|
module.exports.ParseResult = bindings.ParseResult;
|
|
14
10
|
module.exports.ExportExportNameKind = bindings.ExportExportNameKind;
|
|
@@ -18,16 +14,97 @@ module.exports.ImportNameKind = bindings.ImportNameKind;
|
|
|
18
14
|
module.exports.parseWithoutReturn = bindings.parseWithoutReturn;
|
|
19
15
|
module.exports.Severity = bindings.Severity;
|
|
20
16
|
|
|
21
|
-
module.exports.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
17
|
+
module.exports.parseSync = parseSync;
|
|
18
|
+
module.exports.parseAsync = parseAsync;
|
|
19
|
+
module.exports.experimentalGetLazyVisitor = experimentalGetLazyVisitor;
|
|
20
|
+
module.exports.rawTransferSupported = rawTransferSupported;
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
// Lazily loaded as needed
|
|
23
|
+
let parseSyncRaw = null,
|
|
24
|
+
parseAsyncRaw,
|
|
25
|
+
parseSyncLazy = null,
|
|
26
|
+
parseAsyncLazy,
|
|
27
|
+
Visitor;
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Lazy-load code related to raw transfer.
|
|
31
|
+
* @returns {undefined}
|
|
32
|
+
*/
|
|
33
|
+
function loadRawTransfer() {
|
|
34
|
+
if (parseSyncRaw === null) {
|
|
35
|
+
({ parseSyncRaw, parseAsyncRaw } = require('./raw-transfer/eager.js'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Lazy-load code related to raw transfer lazy deserialization.
|
|
41
|
+
* @returns {undefined}
|
|
42
|
+
*/
|
|
43
|
+
function loadRawTransferLazy() {
|
|
44
|
+
if (parseSyncLazy === null) {
|
|
45
|
+
({ parseSyncLazy, parseAsyncLazy, Visitor } = require('./raw-transfer/lazy.js'));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parse JS/TS source synchronously on current thread.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} filename - Filename
|
|
53
|
+
* @param {string} sourceText - Source text of file
|
|
54
|
+
* @param {Object|undefined} options - Parsing options
|
|
55
|
+
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
|
|
56
|
+
* @throws {Error} - If `experimentalRawTransfer` or `experimentalLazy` option is enabled,
|
|
57
|
+
* and raw transfer is not supported on this platform
|
|
58
|
+
*/
|
|
59
|
+
function parseSync(filename, sourceText, options) {
|
|
60
|
+
if (options?.experimentalRawTransfer) {
|
|
61
|
+
loadRawTransfer();
|
|
62
|
+
return parseSyncRaw(filename, sourceText, options);
|
|
63
|
+
}
|
|
64
|
+
if (options?.experimentalLazy) {
|
|
65
|
+
loadRawTransferLazy();
|
|
66
|
+
return parseSyncLazy(filename, sourceText, options);
|
|
67
|
+
}
|
|
68
|
+
return wrap(parseSyncBinding(filename, sourceText, options));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Parse JS/TS source asynchronously on a separate thread.
|
|
73
|
+
*
|
|
74
|
+
* Note that not all of the workload can happen on a separate thread.
|
|
75
|
+
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
|
|
76
|
+
* has to happen on current thread. This synchronous deserialization work typically outweighs
|
|
77
|
+
* the asynchronous parsing by a factor of between 3 and 20.
|
|
78
|
+
*
|
|
79
|
+
* i.e. the majority of the workload cannot be parallelized by using this method.
|
|
80
|
+
*
|
|
81
|
+
* Generally `parseSync` is preferable to use as it does not have the overhead of spawning a thread.
|
|
82
|
+
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} filename - Filename
|
|
85
|
+
* @param {string} sourceText - Source text of file
|
|
86
|
+
* @param {Object|undefined} options - Parsing options
|
|
87
|
+
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
|
|
88
|
+
* @throws {Error} - If `experimentalRawTransfer` or `experimentalLazy` option is enabled,
|
|
89
|
+
* and raw transfer is not supported on this platform
|
|
90
|
+
*/
|
|
91
|
+
async function parseAsync(filename, sourceText, options) {
|
|
92
|
+
if (options?.experimentalRawTransfer) {
|
|
93
|
+
loadRawTransfer();
|
|
94
|
+
return await parseAsyncRaw(filename, sourceText, options);
|
|
95
|
+
}
|
|
96
|
+
if (options?.experimentalLazy) {
|
|
97
|
+
loadRawTransferLazy();
|
|
98
|
+
return await parseAsyncLazy(filename, sourceText, options);
|
|
99
|
+
}
|
|
100
|
+
return wrap(await parseAsyncBinding(filename, sourceText, options));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get `Visitor` class to construct visitors with.
|
|
105
|
+
* @returns {function} - `Visitor` class
|
|
106
|
+
*/
|
|
107
|
+
function experimentalGetLazyVisitor() {
|
|
108
|
+
loadRawTransferLazy();
|
|
109
|
+
return Visitor;
|
|
110
|
+
}
|