oxc-parser 0.72.2 → 0.73.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 +1 -1
- package/generated/deserialize/js.js +12 -156
- package/generated/deserialize/lazy.js +13853 -0
- package/generated/deserialize/ts.js +21 -169
- package/index.d.ts +26 -27
- package/index.js +11 -288
- package/package.json +26 -21
- package/raw-transfer/eager.js +56 -0
- package/raw-transfer/index.js +283 -0
- package/raw-transfer/lazy.js +87 -0
|
@@ -13,8 +13,8 @@ const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }),
|
|
|
13
13
|
|
|
14
14
|
function deserialize(buffer, sourceTextInput, sourceLenInput) {
|
|
15
15
|
uint8 = buffer;
|
|
16
|
-
uint32 =
|
|
17
|
-
float64 =
|
|
16
|
+
uint32 = buffer.uint32;
|
|
17
|
+
float64 = buffer.float64;
|
|
18
18
|
|
|
19
19
|
sourceText = sourceTextInput;
|
|
20
20
|
sourceLen = sourceLenInput;
|
|
@@ -424,9 +424,9 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
424
424
|
type: 'AssignmentPattern',
|
|
425
425
|
start: start,
|
|
426
426
|
end: end,
|
|
427
|
+
decorators: [],
|
|
427
428
|
left: keyCopy,
|
|
428
429
|
right: init,
|
|
429
|
-
decorators: [],
|
|
430
430
|
optional: false,
|
|
431
431
|
typeAnnotation: null,
|
|
432
432
|
};
|
|
@@ -735,11 +735,7 @@ function deserializeCatchClause(pos) {
|
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
function deserializeCatchParameter(pos) {
|
|
738
|
-
return
|
|
739
|
-
...deserializeBindingPatternKind(pos + 8),
|
|
740
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 24),
|
|
741
|
-
optional: deserializeBool(pos + 32),
|
|
742
|
-
};
|
|
738
|
+
return deserializeBindingPattern(pos + 8);
|
|
743
739
|
}
|
|
744
740
|
|
|
745
741
|
function deserializeDebuggerStatement(pos) {
|
|
@@ -751,11 +747,10 @@ function deserializeDebuggerStatement(pos) {
|
|
|
751
747
|
}
|
|
752
748
|
|
|
753
749
|
function deserializeBindingPattern(pos) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
};
|
|
750
|
+
const pattern = deserializeBindingPatternKind(pos);
|
|
751
|
+
pattern.optional = deserializeBool(pos + 24);
|
|
752
|
+
pattern.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 16);
|
|
753
|
+
return pattern;
|
|
759
754
|
}
|
|
760
755
|
|
|
761
756
|
function deserializeAssignmentPattern(pos) {
|
|
@@ -857,8 +852,8 @@ function deserializeFormalParameters(pos) {
|
|
|
857
852
|
type: 'RestElement',
|
|
858
853
|
start: deserializeU32(pos),
|
|
859
854
|
end: deserializeU32(pos + 4),
|
|
860
|
-
argument: deserializeBindingPatternKind(pos + 8),
|
|
861
855
|
decorators: [],
|
|
856
|
+
argument: deserializeBindingPatternKind(pos + 8),
|
|
862
857
|
optional: deserializeBool(pos + 32),
|
|
863
858
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(
|
|
864
859
|
pos + 24,
|
|
@@ -875,12 +870,10 @@ function deserializeFormalParameter(pos) {
|
|
|
875
870
|
override = deserializeBool(pos + 66);
|
|
876
871
|
let param;
|
|
877
872
|
if (accessibility === null && !readonly && !override) {
|
|
878
|
-
param =
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 48),
|
|
883
|
-
};
|
|
873
|
+
param = deserializeBindingPatternKind(pos + 32);
|
|
874
|
+
param.decorators = deserializeVecDecorator(pos + 8);
|
|
875
|
+
param.optional = deserializeBool(pos + 56);
|
|
876
|
+
param.typeAnnotation = deserializeOptionBoxTSTypeAnnotation(pos + 48);
|
|
884
877
|
} else {
|
|
885
878
|
param = {
|
|
886
879
|
type: 'TSParameterProperty',
|
|
@@ -970,8 +963,8 @@ function deserializeMethodDefinition(pos) {
|
|
|
970
963
|
type: 'Identifier',
|
|
971
964
|
start: key.start,
|
|
972
965
|
end: key.end,
|
|
973
|
-
name: 'constructor',
|
|
974
966
|
decorators: [],
|
|
967
|
+
name: 'constructor',
|
|
975
968
|
optional: false,
|
|
976
969
|
typeAnnotation: null,
|
|
977
970
|
};
|
|
@@ -1230,14 +1223,13 @@ function deserializeStringLiteral(pos) {
|
|
|
1230
1223
|
}
|
|
1231
1224
|
|
|
1232
1225
|
function deserializeBigIntLiteral(pos) {
|
|
1233
|
-
const
|
|
1234
|
-
bigint = raw.slice(0, -1).replace(/_/g, '');
|
|
1226
|
+
const bigint = deserializeStr(pos + 8);
|
|
1235
1227
|
return {
|
|
1236
1228
|
type: 'Literal',
|
|
1237
1229
|
start: deserializeU32(pos),
|
|
1238
1230
|
end: deserializeU32(pos + 4),
|
|
1239
1231
|
value: BigInt(bigint),
|
|
1240
|
-
raw,
|
|
1232
|
+
raw: deserializeOptionStr(pos + 24),
|
|
1241
1233
|
bigint,
|
|
1242
1234
|
};
|
|
1243
1235
|
}
|
|
@@ -1785,8 +1777,8 @@ function deserializeTSClassImplements(pos) {
|
|
|
1785
1777
|
end: expression.end,
|
|
1786
1778
|
object: expression.left,
|
|
1787
1779
|
property: expression.right,
|
|
1788
|
-
computed: false,
|
|
1789
1780
|
optional: false,
|
|
1781
|
+
computed: false,
|
|
1790
1782
|
};
|
|
1791
1783
|
|
|
1792
1784
|
while (parent.object.type === 'TSQualifiedName') {
|
|
@@ -1797,8 +1789,8 @@ function deserializeTSClassImplements(pos) {
|
|
|
1797
1789
|
end: object.end,
|
|
1798
1790
|
object: object.left,
|
|
1799
1791
|
property: object.right,
|
|
1800
|
-
computed: false,
|
|
1801
1792
|
optional: false,
|
|
1793
|
+
computed: false,
|
|
1802
1794
|
};
|
|
1803
1795
|
}
|
|
1804
1796
|
}
|
|
@@ -2288,10 +2280,11 @@ function deserializeRawTransferData(pos) {
|
|
|
2288
2280
|
|
|
2289
2281
|
function deserializeError(pos) {
|
|
2290
2282
|
return {
|
|
2291
|
-
severity: deserializeErrorSeverity(pos +
|
|
2283
|
+
severity: deserializeErrorSeverity(pos + 72),
|
|
2292
2284
|
message: deserializeStr(pos),
|
|
2293
2285
|
labels: deserializeVecErrorLabel(pos + 16),
|
|
2294
2286
|
helpMessage: deserializeOptionStr(pos + 40),
|
|
2287
|
+
codeframe: deserializeStr(pos + 56),
|
|
2295
2288
|
};
|
|
2296
2289
|
}
|
|
2297
2290
|
|
|
@@ -4242,11 +4235,6 @@ function deserializeVecStatement(pos) {
|
|
|
4242
4235
|
return arr;
|
|
4243
4236
|
}
|
|
4244
4237
|
|
|
4245
|
-
function deserializeOptionScopeId(pos) {
|
|
4246
|
-
if (uint32[pos >> 2] === 0) return null;
|
|
4247
|
-
return deserializeScopeId(pos);
|
|
4248
|
-
}
|
|
4249
|
-
|
|
4250
4238
|
function deserializeBoxBooleanLiteral(pos) {
|
|
4251
4239
|
return deserializeBooleanLiteral(uint32[pos >> 2]);
|
|
4252
4240
|
}
|
|
@@ -4407,16 +4395,6 @@ function deserializeBoxV8IntrinsicExpression(pos) {
|
|
|
4407
4395
|
return deserializeV8IntrinsicExpression(uint32[pos >> 2]);
|
|
4408
4396
|
}
|
|
4409
4397
|
|
|
4410
|
-
function deserializeOptionReferenceId(pos) {
|
|
4411
|
-
if (uint32[pos >> 2] === 0) return null;
|
|
4412
|
-
return deserializeReferenceId(pos);
|
|
4413
|
-
}
|
|
4414
|
-
|
|
4415
|
-
function deserializeOptionSymbolId(pos) {
|
|
4416
|
-
if (uint32[pos >> 2] === 0) return null;
|
|
4417
|
-
return deserializeSymbolId(pos);
|
|
4418
|
-
}
|
|
4419
|
-
|
|
4420
4398
|
function deserializeVecArrayExpressionElement(pos) {
|
|
4421
4399
|
const arr = [],
|
|
4422
4400
|
pos32 = pos >> 2,
|
|
@@ -5022,15 +5000,6 @@ function deserializeF64(pos) {
|
|
|
5022
5000
|
return float64[pos >> 3];
|
|
5023
5001
|
}
|
|
5024
5002
|
|
|
5025
|
-
function deserializeBoxPattern(pos) {
|
|
5026
|
-
return deserializePattern(uint32[pos >> 2]);
|
|
5027
|
-
}
|
|
5028
|
-
|
|
5029
|
-
function deserializeOptionBoxPattern(pos) {
|
|
5030
|
-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5031
|
-
return deserializeBoxPattern(pos);
|
|
5032
|
-
}
|
|
5033
|
-
|
|
5034
5003
|
function deserializeU8(pos) {
|
|
5035
5004
|
return uint8[pos];
|
|
5036
5005
|
}
|
|
@@ -5419,74 +5388,6 @@ function deserializeOptionNameSpan(pos) {
|
|
|
5419
5388
|
return deserializeNameSpan(pos);
|
|
5420
5389
|
}
|
|
5421
5390
|
|
|
5422
|
-
function deserializeVecAlternative(pos) {
|
|
5423
|
-
const arr = [],
|
|
5424
|
-
pos32 = pos >> 2,
|
|
5425
|
-
len = uint32[pos32 + 2];
|
|
5426
|
-
pos = uint32[pos32];
|
|
5427
|
-
for (let i = 0; i < len; i++) {
|
|
5428
|
-
arr.push(deserializeAlternative(pos));
|
|
5429
|
-
pos += 32;
|
|
5430
|
-
}
|
|
5431
|
-
return arr;
|
|
5432
|
-
}
|
|
5433
|
-
|
|
5434
|
-
function deserializeVecTerm(pos) {
|
|
5435
|
-
const arr = [],
|
|
5436
|
-
pos32 = pos >> 2,
|
|
5437
|
-
len = uint32[pos32 + 2];
|
|
5438
|
-
pos = uint32[pos32];
|
|
5439
|
-
for (let i = 0; i < len; i++) {
|
|
5440
|
-
arr.push(deserializeTerm(pos));
|
|
5441
|
-
pos += 16;
|
|
5442
|
-
}
|
|
5443
|
-
return arr;
|
|
5444
|
-
}
|
|
5445
|
-
|
|
5446
|
-
function deserializeBoxBoundaryAssertion(pos) {
|
|
5447
|
-
return deserializeBoundaryAssertion(uint32[pos >> 2]);
|
|
5448
|
-
}
|
|
5449
|
-
|
|
5450
|
-
function deserializeBoxLookAroundAssertion(pos) {
|
|
5451
|
-
return deserializeLookAroundAssertion(uint32[pos >> 2]);
|
|
5452
|
-
}
|
|
5453
|
-
|
|
5454
|
-
function deserializeBoxQuantifier(pos) {
|
|
5455
|
-
return deserializeQuantifier(uint32[pos >> 2]);
|
|
5456
|
-
}
|
|
5457
|
-
|
|
5458
|
-
function deserializeBoxCharacter(pos) {
|
|
5459
|
-
return deserializeCharacter(uint32[pos >> 2]);
|
|
5460
|
-
}
|
|
5461
|
-
|
|
5462
|
-
function deserializeBoxCharacterClassEscape(pos) {
|
|
5463
|
-
return deserializeCharacterClassEscape(uint32[pos >> 2]);
|
|
5464
|
-
}
|
|
5465
|
-
|
|
5466
|
-
function deserializeBoxUnicodePropertyEscape(pos) {
|
|
5467
|
-
return deserializeUnicodePropertyEscape(uint32[pos >> 2]);
|
|
5468
|
-
}
|
|
5469
|
-
|
|
5470
|
-
function deserializeBoxCharacterClass(pos) {
|
|
5471
|
-
return deserializeCharacterClass(uint32[pos >> 2]);
|
|
5472
|
-
}
|
|
5473
|
-
|
|
5474
|
-
function deserializeBoxCapturingGroup(pos) {
|
|
5475
|
-
return deserializeCapturingGroup(uint32[pos >> 2]);
|
|
5476
|
-
}
|
|
5477
|
-
|
|
5478
|
-
function deserializeBoxIgnoreGroup(pos) {
|
|
5479
|
-
return deserializeIgnoreGroup(uint32[pos >> 2]);
|
|
5480
|
-
}
|
|
5481
|
-
|
|
5482
|
-
function deserializeBoxIndexedReference(pos) {
|
|
5483
|
-
return deserializeIndexedReference(uint32[pos >> 2]);
|
|
5484
|
-
}
|
|
5485
|
-
|
|
5486
|
-
function deserializeBoxNamedReference(pos) {
|
|
5487
|
-
return deserializeNamedReference(uint32[pos >> 2]);
|
|
5488
|
-
}
|
|
5489
|
-
|
|
5490
5391
|
function deserializeU64(pos) {
|
|
5491
5392
|
const pos32 = pos >> 2;
|
|
5492
5393
|
return uint32[pos32] + uint32[pos32 + 1] * 4294967296;
|
|
@@ -5497,55 +5398,6 @@ function deserializeOptionU64(pos) {
|
|
|
5497
5398
|
return deserializeU64(pos + 8);
|
|
5498
5399
|
}
|
|
5499
5400
|
|
|
5500
|
-
function deserializeVecCharacterClassContents(pos) {
|
|
5501
|
-
const arr = [],
|
|
5502
|
-
pos32 = pos >> 2,
|
|
5503
|
-
len = uint32[pos32 + 2];
|
|
5504
|
-
pos = uint32[pos32];
|
|
5505
|
-
for (let i = 0; i < len; i++) {
|
|
5506
|
-
arr.push(deserializeCharacterClassContents(pos));
|
|
5507
|
-
pos += 16;
|
|
5508
|
-
}
|
|
5509
|
-
return arr;
|
|
5510
|
-
}
|
|
5511
|
-
|
|
5512
|
-
function deserializeBoxCharacterClassRange(pos) {
|
|
5513
|
-
return deserializeCharacterClassRange(uint32[pos >> 2]);
|
|
5514
|
-
}
|
|
5515
|
-
|
|
5516
|
-
function deserializeBoxClassStringDisjunction(pos) {
|
|
5517
|
-
return deserializeClassStringDisjunction(uint32[pos >> 2]);
|
|
5518
|
-
}
|
|
5519
|
-
|
|
5520
|
-
function deserializeVecClassString(pos) {
|
|
5521
|
-
const arr = [],
|
|
5522
|
-
pos32 = pos >> 2,
|
|
5523
|
-
len = uint32[pos32 + 2];
|
|
5524
|
-
pos = uint32[pos32];
|
|
5525
|
-
for (let i = 0; i < len; i++) {
|
|
5526
|
-
arr.push(deserializeClassString(pos));
|
|
5527
|
-
pos += 40;
|
|
5528
|
-
}
|
|
5529
|
-
return arr;
|
|
5530
|
-
}
|
|
5531
|
-
|
|
5532
|
-
function deserializeVecCharacter(pos) {
|
|
5533
|
-
const arr = [],
|
|
5534
|
-
pos32 = pos >> 2,
|
|
5535
|
-
len = uint32[pos32 + 2];
|
|
5536
|
-
pos = uint32[pos32];
|
|
5537
|
-
for (let i = 0; i < len; i++) {
|
|
5538
|
-
arr.push(deserializeCharacter(pos));
|
|
5539
|
-
pos += 16;
|
|
5540
|
-
}
|
|
5541
|
-
return arr;
|
|
5542
|
-
}
|
|
5543
|
-
|
|
5544
|
-
function deserializeOptionModifiers(pos) {
|
|
5545
|
-
if (uint8[pos] === 0) return null;
|
|
5546
|
-
return deserializeModifiers(pos + 8);
|
|
5547
|
-
}
|
|
5548
|
-
|
|
5549
5401
|
function deserializeVecError(pos) {
|
|
5550
5402
|
const arr = [],
|
|
5551
5403
|
pos32 = pos >> 2,
|
|
@@ -5553,7 +5405,7 @@ function deserializeVecError(pos) {
|
|
|
5553
5405
|
pos = uint32[pos32];
|
|
5554
5406
|
for (let i = 0; i < len; i++) {
|
|
5555
5407
|
arr.push(deserializeError(pos));
|
|
5556
|
-
pos +=
|
|
5408
|
+
pos += 80;
|
|
5557
5409
|
}
|
|
5558
5410
|
return arr;
|
|
5559
5411
|
}
|
package/index.d.ts
CHANGED
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
export * from '@oxc-project/types';
|
|
5
|
-
export declare class ParseResult {
|
|
6
|
-
get program(): import("@oxc-project/types").Program
|
|
7
|
-
get module(): EcmaScriptModule
|
|
8
|
-
get comments(): Array<Comment>
|
|
9
|
-
get errors(): Array<OxcError>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
export interface Comment {
|
|
13
6
|
type: 'Line' | 'Block'
|
|
14
7
|
value: string
|
|
@@ -16,6 +9,32 @@ export interface Comment {
|
|
|
16
9
|
end: number
|
|
17
10
|
}
|
|
18
11
|
|
|
12
|
+
export interface ErrorLabel {
|
|
13
|
+
message?: string
|
|
14
|
+
start: number
|
|
15
|
+
end: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface OxcError {
|
|
19
|
+
severity: Severity
|
|
20
|
+
message: string
|
|
21
|
+
labels: Array<ErrorLabel>
|
|
22
|
+
helpMessage?: string
|
|
23
|
+
codeframe?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare const enum Severity {
|
|
27
|
+
Error = 'Error',
|
|
28
|
+
Warning = 'Warning',
|
|
29
|
+
Advice = 'Advice'
|
|
30
|
+
}
|
|
31
|
+
export declare class ParseResult {
|
|
32
|
+
get program(): import("@oxc-project/types").Program
|
|
33
|
+
get module(): EcmaScriptModule
|
|
34
|
+
get comments(): Array<Comment>
|
|
35
|
+
get errors(): Array<OxcError>
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
export interface DynamicImport {
|
|
20
39
|
start: number
|
|
21
40
|
end: number
|
|
@@ -41,12 +60,6 @@ export interface EcmaScriptModule {
|
|
|
41
60
|
importMetas: Array<Span>
|
|
42
61
|
}
|
|
43
62
|
|
|
44
|
-
export interface ErrorLabel {
|
|
45
|
-
message?: string
|
|
46
|
-
start: number
|
|
47
|
-
end: number
|
|
48
|
-
}
|
|
49
|
-
|
|
50
63
|
export interface ExportExportName {
|
|
51
64
|
kind: ExportExportNameKind
|
|
52
65
|
name?: string
|
|
@@ -124,14 +137,6 @@ export declare const enum ImportNameKind {
|
|
|
124
137
|
Default = 'Default'
|
|
125
138
|
}
|
|
126
139
|
|
|
127
|
-
export interface OxcError {
|
|
128
|
-
severity: Severity
|
|
129
|
-
message: string
|
|
130
|
-
labels: Array<ErrorLabel>
|
|
131
|
-
helpMessage?: string
|
|
132
|
-
codeframe?: string
|
|
133
|
-
}
|
|
134
|
-
|
|
135
140
|
/**
|
|
136
141
|
* Parse asynchronously.
|
|
137
142
|
*
|
|
@@ -238,12 +243,6 @@ export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourc
|
|
|
238
243
|
/** Returns `true` if raw transfer is supported on this platform. */
|
|
239
244
|
export declare function rawTransferSupported(): boolean
|
|
240
245
|
|
|
241
|
-
export declare const enum Severity {
|
|
242
|
-
Error = 'Error',
|
|
243
|
-
Warning = 'Warning',
|
|
244
|
-
Advice = 'Advice'
|
|
245
|
-
}
|
|
246
|
-
|
|
247
246
|
export interface Span {
|
|
248
247
|
start: number
|
|
249
248
|
end: number
|