oxc-parser 0.97.0 → 0.99.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/README.md +15 -1
- package/generated/deserialize/js.js +36 -6
- package/generated/deserialize/js_range.js +40 -6
- package/generated/deserialize/ts.js +39 -6
- package/generated/deserialize/ts_range.js +43 -6
- package/generated/lazy/constructors.js +61 -3
- package/generated/lazy/type_ids.js +24 -23
- package/generated/lazy/walk.js +49 -22
- package/generated/visit/visitor.d.ts +2 -2
- package/package.json +18 -18
- package/src-js/bindings.js +56 -56
- package/src-js/index.d.ts +1 -1
- package/src-js/index.js +9 -9
- package/src-js/raw-transfer/common.js +3 -7
- package/src-js/raw-transfer/eager.js +1 -1
- package/src-js/raw-transfer/lazy.js +2 -2
- package/src-js/wasm.js +2 -2
package/README.md
CHANGED
|
@@ -98,6 +98,20 @@ export interface EcmaScriptModule {
|
|
|
98
98
|
|
|
99
99
|
## API
|
|
100
100
|
|
|
101
|
+
### Functions
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Synchronous parsing
|
|
105
|
+
parseSync(filename: string, sourceText: string, options?: ParserOptions): ParseResult
|
|
106
|
+
|
|
107
|
+
// Asynchronous parsing
|
|
108
|
+
parse(filename: string, sourceText: string, options?: ParserOptions): Promise<ParseResult>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Use `parseSync` for synchronous parsing. Use `parse` for asynchronous parsing, which can be beneficial in I/O-bound or concurrent scenarios, though it adds async overhead.
|
|
112
|
+
|
|
113
|
+
### Example
|
|
114
|
+
|
|
101
115
|
```javascript
|
|
102
116
|
import { parseSync, Visitor } from 'oxc-parser';
|
|
103
117
|
|
|
@@ -107,7 +121,7 @@ const code = 'const url: String = /* 🤨 */ import.meta.url;';
|
|
|
107
121
|
const filename = 'test.tsx';
|
|
108
122
|
|
|
109
123
|
const result = parseSync(filename, code);
|
|
110
|
-
//
|
|
124
|
+
// Or use async version: const result = await parse(filename, code);
|
|
111
125
|
|
|
112
126
|
// An array of errors, if any.
|
|
113
127
|
console.log(result.errors);
|
|
@@ -1139,6 +1139,8 @@ function deserializeStatement(pos) {
|
|
|
1139
1139
|
case 38:
|
|
1140
1140
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1141
1141
|
case 39:
|
|
1142
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1143
|
+
case 40:
|
|
1142
1144
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1143
1145
|
case 64:
|
|
1144
1146
|
return deserializeBoxImportDeclaration(pos + 8);
|
|
@@ -1210,6 +1212,8 @@ function deserializeDeclaration(pos) {
|
|
|
1210
1212
|
case 38:
|
|
1211
1213
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1212
1214
|
case 39:
|
|
1215
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1216
|
+
case 40:
|
|
1213
1217
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1214
1218
|
default:
|
|
1215
1219
|
throw Error(`Unexpected discriminant ${uint8[pos]} for Declaration`);
|
|
@@ -3695,7 +3699,6 @@ function deserializeTSTypePredicateName(pos) {
|
|
|
3695
3699
|
|
|
3696
3700
|
function deserializeTSModuleDeclaration(pos) {
|
|
3697
3701
|
let kind = deserializeTSModuleDeclarationKind(pos + 84),
|
|
3698
|
-
global = kind === 'global',
|
|
3699
3702
|
start = deserializeU32(pos),
|
|
3700
3703
|
end = deserializeU32(pos + 4),
|
|
3701
3704
|
declare = deserializeBool(pos + 85),
|
|
@@ -3707,7 +3710,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
3707
3710
|
id: null,
|
|
3708
3711
|
kind,
|
|
3709
3712
|
declare,
|
|
3710
|
-
global,
|
|
3713
|
+
global: false,
|
|
3711
3714
|
start,
|
|
3712
3715
|
end,
|
|
3713
3716
|
};
|
|
@@ -3719,7 +3722,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
3719
3722
|
body,
|
|
3720
3723
|
kind,
|
|
3721
3724
|
declare,
|
|
3722
|
-
global,
|
|
3725
|
+
global: false,
|
|
3723
3726
|
start,
|
|
3724
3727
|
end,
|
|
3725
3728
|
};
|
|
@@ -3766,10 +3769,8 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
3766
3769
|
function deserializeTSModuleDeclarationKind(pos) {
|
|
3767
3770
|
switch (uint8[pos]) {
|
|
3768
3771
|
case 0:
|
|
3769
|
-
return 'global';
|
|
3770
|
-
case 1:
|
|
3771
3772
|
return 'module';
|
|
3772
|
-
case
|
|
3773
|
+
case 1:
|
|
3773
3774
|
return 'namespace';
|
|
3774
3775
|
default:
|
|
3775
3776
|
throw Error(`Unexpected discriminant ${uint8[pos]} for TSModuleDeclarationKind`);
|
|
@@ -3798,6 +3799,31 @@ function deserializeTSModuleDeclarationBody(pos) {
|
|
|
3798
3799
|
}
|
|
3799
3800
|
}
|
|
3800
3801
|
|
|
3802
|
+
function deserializeTSGlobalDeclaration(pos) {
|
|
3803
|
+
let start = deserializeU32(pos),
|
|
3804
|
+
end = deserializeU32(pos + 4),
|
|
3805
|
+
node = {
|
|
3806
|
+
type: 'TSModuleDeclaration',
|
|
3807
|
+
id: null,
|
|
3808
|
+
body: null,
|
|
3809
|
+
kind: null,
|
|
3810
|
+
declare: deserializeBool(pos + 76),
|
|
3811
|
+
global: null,
|
|
3812
|
+
start,
|
|
3813
|
+
end,
|
|
3814
|
+
};
|
|
3815
|
+
node.id = {
|
|
3816
|
+
type: 'Identifier',
|
|
3817
|
+
name: 'global',
|
|
3818
|
+
start: deserializeU32(pos + 8),
|
|
3819
|
+
end: deserializeU32(pos + 12),
|
|
3820
|
+
};
|
|
3821
|
+
node.body = deserializeTSModuleBlock(pos + 16);
|
|
3822
|
+
node.kind = 'global';
|
|
3823
|
+
node.global = true;
|
|
3824
|
+
return node;
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3801
3827
|
function deserializeTSModuleBlock(pos) {
|
|
3802
3828
|
let node = {
|
|
3803
3829
|
type: 'TSModuleBlock',
|
|
@@ -5087,6 +5113,10 @@ function deserializeBoxTSModuleDeclaration(pos) {
|
|
|
5087
5113
|
return deserializeTSModuleDeclaration(uint32[pos >> 2]);
|
|
5088
5114
|
}
|
|
5089
5115
|
|
|
5116
|
+
function deserializeBoxTSGlobalDeclaration(pos) {
|
|
5117
|
+
return deserializeTSGlobalDeclaration(uint32[pos >> 2]);
|
|
5118
|
+
}
|
|
5119
|
+
|
|
5090
5120
|
function deserializeBoxTSImportEqualsDeclaration(pos) {
|
|
5091
5121
|
return deserializeTSImportEqualsDeclaration(uint32[pos >> 2]);
|
|
5092
5122
|
}
|
|
@@ -1219,6 +1219,8 @@ function deserializeStatement(pos) {
|
|
|
1219
1219
|
case 38:
|
|
1220
1220
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1221
1221
|
case 39:
|
|
1222
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1223
|
+
case 40:
|
|
1222
1224
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1223
1225
|
case 64:
|
|
1224
1226
|
return deserializeBoxImportDeclaration(pos + 8);
|
|
@@ -1295,6 +1297,8 @@ function deserializeDeclaration(pos) {
|
|
|
1295
1297
|
case 38:
|
|
1296
1298
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1297
1299
|
case 39:
|
|
1300
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1301
|
+
case 40:
|
|
1298
1302
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1299
1303
|
default:
|
|
1300
1304
|
throw Error(`Unexpected discriminant ${uint8[pos]} for Declaration`);
|
|
@@ -4072,7 +4076,6 @@ function deserializeTSTypePredicateName(pos) {
|
|
|
4072
4076
|
|
|
4073
4077
|
function deserializeTSModuleDeclaration(pos) {
|
|
4074
4078
|
let kind = deserializeTSModuleDeclarationKind(pos + 84),
|
|
4075
|
-
global = kind === 'global',
|
|
4076
4079
|
start = deserializeU32(pos),
|
|
4077
4080
|
end = deserializeU32(pos + 4),
|
|
4078
4081
|
declare = deserializeBool(pos + 85),
|
|
@@ -4084,7 +4087,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4084
4087
|
id: null,
|
|
4085
4088
|
kind,
|
|
4086
4089
|
declare,
|
|
4087
|
-
global,
|
|
4090
|
+
global: false,
|
|
4088
4091
|
start,
|
|
4089
4092
|
end,
|
|
4090
4093
|
range: [start, end],
|
|
@@ -4097,7 +4100,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4097
4100
|
body,
|
|
4098
4101
|
kind,
|
|
4099
4102
|
declare,
|
|
4100
|
-
global,
|
|
4103
|
+
global: false,
|
|
4101
4104
|
start,
|
|
4102
4105
|
end,
|
|
4103
4106
|
range: [start, end],
|
|
@@ -4149,10 +4152,8 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4149
4152
|
function deserializeTSModuleDeclarationKind(pos) {
|
|
4150
4153
|
switch (uint8[pos]) {
|
|
4151
4154
|
case 0:
|
|
4152
|
-
return 'global';
|
|
4153
|
-
case 1:
|
|
4154
4155
|
return 'module';
|
|
4155
|
-
case
|
|
4156
|
+
case 1:
|
|
4156
4157
|
return 'namespace';
|
|
4157
4158
|
default:
|
|
4158
4159
|
throw Error(`Unexpected discriminant ${uint8[pos]} for TSModuleDeclarationKind`);
|
|
@@ -4181,6 +4182,35 @@ function deserializeTSModuleDeclarationBody(pos) {
|
|
|
4181
4182
|
}
|
|
4182
4183
|
}
|
|
4183
4184
|
|
|
4185
|
+
function deserializeTSGlobalDeclaration(pos) {
|
|
4186
|
+
let start = deserializeU32(pos),
|
|
4187
|
+
end = deserializeU32(pos + 4),
|
|
4188
|
+
node = {
|
|
4189
|
+
type: 'TSModuleDeclaration',
|
|
4190
|
+
id: null,
|
|
4191
|
+
body: null,
|
|
4192
|
+
kind: null,
|
|
4193
|
+
declare: deserializeBool(pos + 76),
|
|
4194
|
+
global: null,
|
|
4195
|
+
start,
|
|
4196
|
+
end,
|
|
4197
|
+
range: [start, end],
|
|
4198
|
+
},
|
|
4199
|
+
keywordStart,
|
|
4200
|
+
keywordEnd;
|
|
4201
|
+
node.id = {
|
|
4202
|
+
type: 'Identifier',
|
|
4203
|
+
name: 'global',
|
|
4204
|
+
start: (keywordStart = deserializeU32(pos + 8)),
|
|
4205
|
+
end: (keywordEnd = deserializeU32(pos + 12)),
|
|
4206
|
+
range: [keywordStart, keywordEnd],
|
|
4207
|
+
};
|
|
4208
|
+
node.body = deserializeTSModuleBlock(pos + 16);
|
|
4209
|
+
node.kind = 'global';
|
|
4210
|
+
node.global = true;
|
|
4211
|
+
return node;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4184
4214
|
function deserializeTSModuleBlock(pos) {
|
|
4185
4215
|
let start = deserializeU32(pos),
|
|
4186
4216
|
end = deserializeU32(pos + 4),
|
|
@@ -5549,6 +5579,10 @@ function deserializeBoxTSModuleDeclaration(pos) {
|
|
|
5549
5579
|
return deserializeTSModuleDeclaration(uint32[pos >> 2]);
|
|
5550
5580
|
}
|
|
5551
5581
|
|
|
5582
|
+
function deserializeBoxTSGlobalDeclaration(pos) {
|
|
5583
|
+
return deserializeTSGlobalDeclaration(uint32[pos >> 2]);
|
|
5584
|
+
}
|
|
5585
|
+
|
|
5552
5586
|
function deserializeBoxTSImportEqualsDeclaration(pos) {
|
|
5553
5587
|
return deserializeTSImportEqualsDeclaration(uint32[pos >> 2]);
|
|
5554
5588
|
}
|
|
@@ -1217,6 +1217,8 @@ function deserializeStatement(pos) {
|
|
|
1217
1217
|
case 38:
|
|
1218
1218
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1219
1219
|
case 39:
|
|
1220
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1221
|
+
case 40:
|
|
1220
1222
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1221
1223
|
case 64:
|
|
1222
1224
|
return deserializeBoxImportDeclaration(pos + 8);
|
|
@@ -1288,6 +1290,8 @@ function deserializeDeclaration(pos) {
|
|
|
1288
1290
|
case 38:
|
|
1289
1291
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1290
1292
|
case 39:
|
|
1293
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1294
|
+
case 40:
|
|
1291
1295
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1292
1296
|
default:
|
|
1293
1297
|
throw Error(`Unexpected discriminant ${uint8[pos]} for Declaration`);
|
|
@@ -3941,7 +3945,6 @@ function deserializeTSTypePredicateName(pos) {
|
|
|
3941
3945
|
|
|
3942
3946
|
function deserializeTSModuleDeclaration(pos) {
|
|
3943
3947
|
let kind = deserializeTSModuleDeclarationKind(pos + 84),
|
|
3944
|
-
global = kind === 'global',
|
|
3945
3948
|
start = deserializeU32(pos),
|
|
3946
3949
|
end = deserializeU32(pos + 4),
|
|
3947
3950
|
declare = deserializeBool(pos + 85),
|
|
@@ -3953,7 +3956,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
3953
3956
|
id: null,
|
|
3954
3957
|
kind,
|
|
3955
3958
|
declare,
|
|
3956
|
-
global,
|
|
3959
|
+
global: false,
|
|
3957
3960
|
start,
|
|
3958
3961
|
end,
|
|
3959
3962
|
};
|
|
@@ -3965,7 +3968,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
3965
3968
|
body,
|
|
3966
3969
|
kind,
|
|
3967
3970
|
declare,
|
|
3968
|
-
global,
|
|
3971
|
+
global: false,
|
|
3969
3972
|
start,
|
|
3970
3973
|
end,
|
|
3971
3974
|
};
|
|
@@ -4012,10 +4015,8 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4012
4015
|
function deserializeTSModuleDeclarationKind(pos) {
|
|
4013
4016
|
switch (uint8[pos]) {
|
|
4014
4017
|
case 0:
|
|
4015
|
-
return 'global';
|
|
4016
|
-
case 1:
|
|
4017
4018
|
return 'module';
|
|
4018
|
-
case
|
|
4019
|
+
case 1:
|
|
4019
4020
|
return 'namespace';
|
|
4020
4021
|
default:
|
|
4021
4022
|
throw Error(`Unexpected discriminant ${uint8[pos]} for TSModuleDeclarationKind`);
|
|
@@ -4044,6 +4045,34 @@ function deserializeTSModuleDeclarationBody(pos) {
|
|
|
4044
4045
|
}
|
|
4045
4046
|
}
|
|
4046
4047
|
|
|
4048
|
+
function deserializeTSGlobalDeclaration(pos) {
|
|
4049
|
+
let start = deserializeU32(pos),
|
|
4050
|
+
end = deserializeU32(pos + 4),
|
|
4051
|
+
node = {
|
|
4052
|
+
type: 'TSModuleDeclaration',
|
|
4053
|
+
id: null,
|
|
4054
|
+
body: null,
|
|
4055
|
+
kind: null,
|
|
4056
|
+
declare: deserializeBool(pos + 76),
|
|
4057
|
+
global: null,
|
|
4058
|
+
start,
|
|
4059
|
+
end,
|
|
4060
|
+
};
|
|
4061
|
+
node.id = {
|
|
4062
|
+
type: 'Identifier',
|
|
4063
|
+
decorators: [],
|
|
4064
|
+
name: 'global',
|
|
4065
|
+
optional: false,
|
|
4066
|
+
typeAnnotation: null,
|
|
4067
|
+
start: deserializeU32(pos + 8),
|
|
4068
|
+
end: deserializeU32(pos + 12),
|
|
4069
|
+
};
|
|
4070
|
+
node.body = deserializeTSModuleBlock(pos + 16);
|
|
4071
|
+
node.kind = 'global';
|
|
4072
|
+
node.global = true;
|
|
4073
|
+
return node;
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4047
4076
|
function deserializeTSModuleBlock(pos) {
|
|
4048
4077
|
let node = {
|
|
4049
4078
|
type: 'TSModuleBlock',
|
|
@@ -5333,6 +5362,10 @@ function deserializeBoxTSModuleDeclaration(pos) {
|
|
|
5333
5362
|
return deserializeTSModuleDeclaration(uint32[pos >> 2]);
|
|
5334
5363
|
}
|
|
5335
5364
|
|
|
5365
|
+
function deserializeBoxTSGlobalDeclaration(pos) {
|
|
5366
|
+
return deserializeTSGlobalDeclaration(uint32[pos >> 2]);
|
|
5367
|
+
}
|
|
5368
|
+
|
|
5336
5369
|
function deserializeBoxTSImportEqualsDeclaration(pos) {
|
|
5337
5370
|
return deserializeTSImportEqualsDeclaration(uint32[pos >> 2]);
|
|
5338
5371
|
}
|
|
@@ -1297,6 +1297,8 @@ function deserializeStatement(pos) {
|
|
|
1297
1297
|
case 38:
|
|
1298
1298
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1299
1299
|
case 39:
|
|
1300
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1301
|
+
case 40:
|
|
1300
1302
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1301
1303
|
case 64:
|
|
1302
1304
|
return deserializeBoxImportDeclaration(pos + 8);
|
|
@@ -1373,6 +1375,8 @@ function deserializeDeclaration(pos) {
|
|
|
1373
1375
|
case 38:
|
|
1374
1376
|
return deserializeBoxTSModuleDeclaration(pos + 8);
|
|
1375
1377
|
case 39:
|
|
1378
|
+
return deserializeBoxTSGlobalDeclaration(pos + 8);
|
|
1379
|
+
case 40:
|
|
1376
1380
|
return deserializeBoxTSImportEqualsDeclaration(pos + 8);
|
|
1377
1381
|
default:
|
|
1378
1382
|
throw Error(`Unexpected discriminant ${uint8[pos]} for Declaration`);
|
|
@@ -4317,7 +4321,6 @@ function deserializeTSTypePredicateName(pos) {
|
|
|
4317
4321
|
|
|
4318
4322
|
function deserializeTSModuleDeclaration(pos) {
|
|
4319
4323
|
let kind = deserializeTSModuleDeclarationKind(pos + 84),
|
|
4320
|
-
global = kind === 'global',
|
|
4321
4324
|
start = deserializeU32(pos),
|
|
4322
4325
|
end = deserializeU32(pos + 4),
|
|
4323
4326
|
declare = deserializeBool(pos + 85),
|
|
@@ -4329,7 +4332,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4329
4332
|
id: null,
|
|
4330
4333
|
kind,
|
|
4331
4334
|
declare,
|
|
4332
|
-
global,
|
|
4335
|
+
global: false,
|
|
4333
4336
|
start,
|
|
4334
4337
|
end,
|
|
4335
4338
|
range: [start, end],
|
|
@@ -4342,7 +4345,7 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4342
4345
|
body,
|
|
4343
4346
|
kind,
|
|
4344
4347
|
declare,
|
|
4345
|
-
global,
|
|
4348
|
+
global: false,
|
|
4346
4349
|
start,
|
|
4347
4350
|
end,
|
|
4348
4351
|
range: [start, end],
|
|
@@ -4394,10 +4397,8 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
4394
4397
|
function deserializeTSModuleDeclarationKind(pos) {
|
|
4395
4398
|
switch (uint8[pos]) {
|
|
4396
4399
|
case 0:
|
|
4397
|
-
return 'global';
|
|
4398
|
-
case 1:
|
|
4399
4400
|
return 'module';
|
|
4400
|
-
case
|
|
4401
|
+
case 1:
|
|
4401
4402
|
return 'namespace';
|
|
4402
4403
|
default:
|
|
4403
4404
|
throw Error(`Unexpected discriminant ${uint8[pos]} for TSModuleDeclarationKind`);
|
|
@@ -4426,6 +4427,38 @@ function deserializeTSModuleDeclarationBody(pos) {
|
|
|
4426
4427
|
}
|
|
4427
4428
|
}
|
|
4428
4429
|
|
|
4430
|
+
function deserializeTSGlobalDeclaration(pos) {
|
|
4431
|
+
let start = deserializeU32(pos),
|
|
4432
|
+
end = deserializeU32(pos + 4),
|
|
4433
|
+
node = {
|
|
4434
|
+
type: 'TSModuleDeclaration',
|
|
4435
|
+
id: null,
|
|
4436
|
+
body: null,
|
|
4437
|
+
kind: null,
|
|
4438
|
+
declare: deserializeBool(pos + 76),
|
|
4439
|
+
global: null,
|
|
4440
|
+
start,
|
|
4441
|
+
end,
|
|
4442
|
+
range: [start, end],
|
|
4443
|
+
},
|
|
4444
|
+
keywordStart,
|
|
4445
|
+
keywordEnd;
|
|
4446
|
+
node.id = {
|
|
4447
|
+
type: 'Identifier',
|
|
4448
|
+
decorators: [],
|
|
4449
|
+
name: 'global',
|
|
4450
|
+
optional: false,
|
|
4451
|
+
typeAnnotation: null,
|
|
4452
|
+
start: (keywordStart = deserializeU32(pos + 8)),
|
|
4453
|
+
end: (keywordEnd = deserializeU32(pos + 12)),
|
|
4454
|
+
range: [keywordStart, keywordEnd],
|
|
4455
|
+
};
|
|
4456
|
+
node.body = deserializeTSModuleBlock(pos + 16);
|
|
4457
|
+
node.kind = 'global';
|
|
4458
|
+
node.global = true;
|
|
4459
|
+
return node;
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4429
4462
|
function deserializeTSModuleBlock(pos) {
|
|
4430
4463
|
let start = deserializeU32(pos),
|
|
4431
4464
|
end = deserializeU32(pos + 4),
|
|
@@ -5794,6 +5827,10 @@ function deserializeBoxTSModuleDeclaration(pos) {
|
|
|
5794
5827
|
return deserializeTSModuleDeclaration(uint32[pos >> 2]);
|
|
5795
5828
|
}
|
|
5796
5829
|
|
|
5830
|
+
function deserializeBoxTSGlobalDeclaration(pos) {
|
|
5831
|
+
return deserializeTSGlobalDeclaration(uint32[pos >> 2]);
|
|
5832
|
+
}
|
|
5833
|
+
|
|
5797
5834
|
function deserializeBoxTSImportEqualsDeclaration(pos) {
|
|
5798
5835
|
return deserializeTSImportEqualsDeclaration(uint32[pos >> 2]);
|
|
5799
5836
|
}
|
|
@@ -2633,6 +2633,8 @@ function constructStatement(pos, ast) {
|
|
|
2633
2633
|
case 38:
|
|
2634
2634
|
return constructBoxTSModuleDeclaration(pos + 8, ast);
|
|
2635
2635
|
case 39:
|
|
2636
|
+
return constructBoxTSGlobalDeclaration(pos + 8, ast);
|
|
2637
|
+
case 40:
|
|
2636
2638
|
return constructBoxTSImportEqualsDeclaration(pos + 8, ast);
|
|
2637
2639
|
case 64:
|
|
2638
2640
|
return constructBoxImportDeclaration(pos + 8, ast);
|
|
@@ -2818,6 +2820,8 @@ function constructDeclaration(pos, ast) {
|
|
|
2818
2820
|
case 38:
|
|
2819
2821
|
return constructBoxTSModuleDeclaration(pos + 8, ast);
|
|
2820
2822
|
case 39:
|
|
2823
|
+
return constructBoxTSGlobalDeclaration(pos + 8, ast);
|
|
2824
|
+
case 40:
|
|
2821
2825
|
return constructBoxTSImportEqualsDeclaration(pos + 8, ast);
|
|
2822
2826
|
default:
|
|
2823
2827
|
throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for Declaration`);
|
|
@@ -10370,10 +10374,8 @@ const DebugTSModuleDeclaration = class TSModuleDeclaration {};
|
|
|
10370
10374
|
function constructTSModuleDeclarationKind(pos, ast) {
|
|
10371
10375
|
switch (ast.buffer[pos]) {
|
|
10372
10376
|
case 0:
|
|
10373
|
-
return 'global';
|
|
10374
|
-
case 1:
|
|
10375
10377
|
return 'module';
|
|
10376
|
-
case
|
|
10378
|
+
case 1:
|
|
10377
10379
|
return 'namespace';
|
|
10378
10380
|
default:
|
|
10379
10381
|
throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for TSModuleDeclarationKind`);
|
|
@@ -10402,6 +10404,58 @@ function constructTSModuleDeclarationBody(pos, ast) {
|
|
|
10402
10404
|
}
|
|
10403
10405
|
}
|
|
10404
10406
|
|
|
10407
|
+
export class TSGlobalDeclaration {
|
|
10408
|
+
type = 'TSGlobalDeclaration';
|
|
10409
|
+
#internal;
|
|
10410
|
+
|
|
10411
|
+
constructor(pos, ast) {
|
|
10412
|
+
if (ast?.token !== TOKEN) constructorError();
|
|
10413
|
+
|
|
10414
|
+
const { nodes } = ast;
|
|
10415
|
+
const cached = nodes.get(pos);
|
|
10416
|
+
if (cached !== void 0) return cached;
|
|
10417
|
+
|
|
10418
|
+
this.#internal = { pos, ast };
|
|
10419
|
+
nodes.set(pos, this);
|
|
10420
|
+
}
|
|
10421
|
+
|
|
10422
|
+
get start() {
|
|
10423
|
+
const internal = this.#internal;
|
|
10424
|
+
return constructU32(internal.pos, internal.ast);
|
|
10425
|
+
}
|
|
10426
|
+
|
|
10427
|
+
get end() {
|
|
10428
|
+
const internal = this.#internal;
|
|
10429
|
+
return constructU32(internal.pos + 4, internal.ast);
|
|
10430
|
+
}
|
|
10431
|
+
|
|
10432
|
+
get body() {
|
|
10433
|
+
const internal = this.#internal;
|
|
10434
|
+
return new TSModuleBlock(internal.pos + 16, internal.ast);
|
|
10435
|
+
}
|
|
10436
|
+
|
|
10437
|
+
get declare() {
|
|
10438
|
+
const internal = this.#internal;
|
|
10439
|
+
return constructBool(internal.pos + 76, internal.ast);
|
|
10440
|
+
}
|
|
10441
|
+
|
|
10442
|
+
toJSON() {
|
|
10443
|
+
return {
|
|
10444
|
+
type: 'TSGlobalDeclaration',
|
|
10445
|
+
start: this.start,
|
|
10446
|
+
end: this.end,
|
|
10447
|
+
body: this.body,
|
|
10448
|
+
declare: this.declare,
|
|
10449
|
+
};
|
|
10450
|
+
}
|
|
10451
|
+
|
|
10452
|
+
[inspectSymbol]() {
|
|
10453
|
+
return Object.setPrototypeOf(this.toJSON(), DebugTSGlobalDeclaration.prototype);
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10456
|
+
|
|
10457
|
+
const DebugTSGlobalDeclaration = class TSGlobalDeclaration {};
|
|
10458
|
+
|
|
10405
10459
|
export class TSModuleBlock {
|
|
10406
10460
|
type = 'TSModuleBlock';
|
|
10407
10461
|
#internal;
|
|
@@ -12986,6 +13040,10 @@ function constructBoxTSModuleDeclaration(pos, ast) {
|
|
|
12986
13040
|
return new TSModuleDeclaration(ast.buffer.uint32[pos >> 2], ast);
|
|
12987
13041
|
}
|
|
12988
13042
|
|
|
13043
|
+
function constructBoxTSGlobalDeclaration(pos, ast) {
|
|
13044
|
+
return new TSGlobalDeclaration(ast.buffer.uint32[pos >> 2], ast);
|
|
13045
|
+
}
|
|
13046
|
+
|
|
12989
13047
|
function constructBoxTSImportEqualsDeclaration(pos, ast) {
|
|
12990
13048
|
return new TSImportEqualsDeclaration(ast.buffer.uint32[pos >> 2], ast);
|
|
12991
13049
|
}
|
|
@@ -162,29 +162,30 @@ export const NODE_TYPE_IDS_MAP = new Map([
|
|
|
162
162
|
['TSInterfaceHeritage', 154],
|
|
163
163
|
['TSTypePredicate', 155],
|
|
164
164
|
['TSModuleDeclaration', 156],
|
|
165
|
-
['
|
|
166
|
-
['
|
|
167
|
-
['
|
|
168
|
-
['
|
|
169
|
-
['
|
|
170
|
-
['
|
|
171
|
-
['
|
|
172
|
-
['
|
|
173
|
-
['
|
|
174
|
-
['
|
|
175
|
-
['
|
|
176
|
-
['
|
|
177
|
-
['
|
|
178
|
-
['
|
|
179
|
-
['
|
|
180
|
-
['
|
|
181
|
-
['
|
|
182
|
-
['
|
|
183
|
-
['
|
|
184
|
-
['
|
|
185
|
-
['
|
|
186
|
-
['
|
|
165
|
+
['TSGlobalDeclaration', 157],
|
|
166
|
+
['TSModuleBlock', 158],
|
|
167
|
+
['TSTypeLiteral', 159],
|
|
168
|
+
['TSInferType', 160],
|
|
169
|
+
['TSTypeQuery', 161],
|
|
170
|
+
['TSImportType', 162],
|
|
171
|
+
['TSImportTypeQualifiedName', 163],
|
|
172
|
+
['TSFunctionType', 164],
|
|
173
|
+
['TSConstructorType', 165],
|
|
174
|
+
['TSMappedType', 166],
|
|
175
|
+
['TSTemplateLiteralType', 167],
|
|
176
|
+
['TSAsExpression', 168],
|
|
177
|
+
['TSSatisfiesExpression', 169],
|
|
178
|
+
['TSTypeAssertion', 170],
|
|
179
|
+
['TSImportEqualsDeclaration', 171],
|
|
180
|
+
['TSExternalModuleReference', 172],
|
|
181
|
+
['TSNonNullExpression', 173],
|
|
182
|
+
['Decorator', 174],
|
|
183
|
+
['TSExportAssignment', 175],
|
|
184
|
+
['TSNamespaceExportDeclaration', 176],
|
|
185
|
+
['TSInstantiationExpression', 177],
|
|
186
|
+
['JSDocNullableType', 178],
|
|
187
|
+
['JSDocNonNullableType', 179],
|
|
187
188
|
]);
|
|
188
189
|
|
|
189
|
-
export const NODE_TYPES_COUNT =
|
|
190
|
+
export const NODE_TYPES_COUNT = 180;
|
|
190
191
|
export const LEAF_NODE_TYPES_COUNT = 38;
|