meriyah 7.1.0 → 7.1.2
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/CHANGELOG.md +21 -0
- package/README.md +10 -5
- package/dist/meriyah.cjs +99 -44
- package/dist/meriyah.min.mjs +1 -1
- package/dist/meriyah.mjs +99 -44
- package/dist/meriyah.umd.js +99 -44
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/types/common.d.ts +4 -3
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/lexer/comments.d.ts +3 -3
- package/dist/types/lexer/common.d.ts +2 -2
- package/dist/types/lexer/identifier.d.ts +3 -3
- package/dist/types/lexer/index.d.ts +3 -3
- package/dist/types/lexer/jsx.d.ts +3 -3
- package/dist/types/lexer/numeric.d.ts +4 -4
- package/dist/types/lexer/regexp.d.ts +2 -2
- package/dist/types/lexer/scan.d.ts +4 -4
- package/dist/types/lexer/string.d.ts +3 -3
- package/dist/types/lexer/template.d.ts +3 -3
- package/dist/types/meriyah.d.ts +6 -6
- package/dist/types/options.d.ts +14 -4
- package/dist/types/parser/parser.d.ts +8 -7
- package/dist/types/parser/private-scope.d.ts +2 -2
- package/dist/types/parser/scope.d.ts +3 -3
- package/dist/types/parser.d.ts +3 -3
- package/package.json +1 -1
package/dist/meriyah.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var version$1 = "7.1.
|
|
1
|
+
var version$1 = "7.1.2";
|
|
2
|
+
var packageJson = {
|
|
3
|
+
version: version$1};
|
|
2
4
|
|
|
3
5
|
const unicodeLookup = ((compressed, lookup) => {
|
|
4
6
|
const result = new Uint32Array(69632);
|
|
@@ -1518,12 +1520,14 @@ function parseEscape(parser, context, first, isTemplate = 0) {
|
|
|
1518
1520
|
const ch = advanceChar(parser);
|
|
1519
1521
|
if (parser.currentChar === 123) {
|
|
1520
1522
|
let code = 0;
|
|
1523
|
+
let digits = 0;
|
|
1521
1524
|
while ((CharTypes[advanceChar(parser)] & 64) !== 0) {
|
|
1522
1525
|
code = (code << 4) | toHex(parser.currentChar);
|
|
1523
1526
|
if (code > 1114111)
|
|
1524
1527
|
return -5;
|
|
1528
|
+
digits++;
|
|
1525
1529
|
}
|
|
1526
|
-
if (parser.currentChar < 1 || parser.currentChar !== 125) {
|
|
1530
|
+
if (digits === 0 || parser.currentChar < 1 || parser.currentChar !== 125) {
|
|
1527
1531
|
return -4;
|
|
1528
1532
|
}
|
|
1529
1533
|
return code;
|
|
@@ -1548,7 +1552,7 @@ function parseEscape(parser, context, first, isTemplate = 0) {
|
|
|
1548
1552
|
}
|
|
1549
1553
|
case 56:
|
|
1550
1554
|
case 57:
|
|
1551
|
-
if (isTemplate ||
|
|
1555
|
+
if (isTemplate || context & 1)
|
|
1552
1556
|
return -3;
|
|
1553
1557
|
parser.flags |= 4096;
|
|
1554
1558
|
default:
|
|
@@ -4542,10 +4546,22 @@ function rescanJSXIdentifier(parser) {
|
|
|
4542
4546
|
return parser.getToken();
|
|
4543
4547
|
}
|
|
4544
4548
|
|
|
4549
|
+
function normalizeRanges(ranges) {
|
|
4550
|
+
if (!ranges)
|
|
4551
|
+
return undefined;
|
|
4552
|
+
if (ranges === true)
|
|
4553
|
+
return { start: true, end: true, range: true };
|
|
4554
|
+
return {
|
|
4555
|
+
start: ranges.start ?? false,
|
|
4556
|
+
end: ranges.end ?? false,
|
|
4557
|
+
range: ranges.range ?? false,
|
|
4558
|
+
};
|
|
4559
|
+
}
|
|
4545
4560
|
function normalizeOptions(rawOptions) {
|
|
4546
4561
|
const options = {
|
|
4547
4562
|
validateRegex: true,
|
|
4548
4563
|
...rawOptions,
|
|
4564
|
+
ranges: normalizeRanges(rawOptions.ranges),
|
|
4549
4565
|
};
|
|
4550
4566
|
if (options.module && !options.sourceType) {
|
|
4551
4567
|
options.sourceType = 'module';
|
|
@@ -4731,6 +4747,7 @@ class Parser {
|
|
|
4731
4747
|
exportedBindings = new Set();
|
|
4732
4748
|
assignable = 0;
|
|
4733
4749
|
destructible = 0;
|
|
4750
|
+
strictReservedRange = null;
|
|
4734
4751
|
leadingDecorators = { decorators: [] };
|
|
4735
4752
|
constructor(source, rawOptions = {}) {
|
|
4736
4753
|
this.source = source;
|
|
@@ -4787,11 +4804,15 @@ class Parser {
|
|
|
4787
4804
|
return { index: this.index, line: this.line, column: this.column };
|
|
4788
4805
|
}
|
|
4789
4806
|
finishNode(node, start, end) {
|
|
4790
|
-
|
|
4791
|
-
|
|
4807
|
+
const { ranges } = this.options;
|
|
4808
|
+
if (ranges) {
|
|
4792
4809
|
const endIndex = end ? end.index : this.startIndex;
|
|
4793
|
-
|
|
4794
|
-
|
|
4810
|
+
if (ranges.start)
|
|
4811
|
+
node.start = start.index;
|
|
4812
|
+
if (ranges.end)
|
|
4813
|
+
node.end = endIndex;
|
|
4814
|
+
if (ranges.range)
|
|
4815
|
+
node.range = [start.index, endIndex];
|
|
4795
4816
|
}
|
|
4796
4817
|
if (this.options.loc) {
|
|
4797
4818
|
node.loc = {
|
|
@@ -4842,8 +4863,14 @@ class Parser {
|
|
|
4842
4863
|
return this.cloneLocationInformation({ ...original }, original);
|
|
4843
4864
|
}
|
|
4844
4865
|
cloneLocationInformation(node, original) {
|
|
4845
|
-
|
|
4846
|
-
|
|
4866
|
+
const { ranges } = this.options;
|
|
4867
|
+
if (ranges) {
|
|
4868
|
+
if (ranges.start)
|
|
4869
|
+
node.start = original.start;
|
|
4870
|
+
if (ranges.end)
|
|
4871
|
+
node.end = original.end;
|
|
4872
|
+
if (ranges.range)
|
|
4873
|
+
node.range = [...original.range];
|
|
4847
4874
|
}
|
|
4848
4875
|
if (this.options.loc) {
|
|
4849
4876
|
node.loc = {
|
|
@@ -4861,10 +4888,14 @@ function pushComment(comments, options) {
|
|
|
4861
4888
|
type,
|
|
4862
4889
|
value,
|
|
4863
4890
|
};
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4891
|
+
const { ranges } = options;
|
|
4892
|
+
if (ranges) {
|
|
4893
|
+
if (ranges.start)
|
|
4894
|
+
comment.start = start;
|
|
4895
|
+
if (ranges.end)
|
|
4896
|
+
comment.end = end;
|
|
4897
|
+
if (ranges.range)
|
|
4898
|
+
comment.range = [start, end];
|
|
4868
4899
|
}
|
|
4869
4900
|
if (options.loc) {
|
|
4870
4901
|
comment.loc = loc;
|
|
@@ -4877,10 +4908,14 @@ function pushToken(tokens, options) {
|
|
|
4877
4908
|
const token = {
|
|
4878
4909
|
token: type,
|
|
4879
4910
|
};
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4911
|
+
const { ranges } = options;
|
|
4912
|
+
if (ranges) {
|
|
4913
|
+
if (ranges.start)
|
|
4914
|
+
token.start = start;
|
|
4915
|
+
if (ranges.end)
|
|
4916
|
+
token.end = end;
|
|
4917
|
+
if (ranges.range)
|
|
4918
|
+
token.range = [start, end];
|
|
4884
4919
|
}
|
|
4885
4920
|
if (options.loc) {
|
|
4886
4921
|
token.loc = loc;
|
|
@@ -4899,7 +4934,7 @@ function parseSource(source, rawOptions = {}, context = 0) {
|
|
|
4899
4934
|
context |= 1;
|
|
4900
4935
|
skipHashBang(parser);
|
|
4901
4936
|
const scope = parser.createScopeIfLexical();
|
|
4902
|
-
let body
|
|
4937
|
+
let body;
|
|
4903
4938
|
let sourceType = 'script';
|
|
4904
4939
|
if (context & 2) {
|
|
4905
4940
|
sourceType = 'module';
|
|
@@ -5392,7 +5427,6 @@ function parseTryStatement(parser, context, scope, privateScope, labels) {
|
|
|
5392
5427
|
}
|
|
5393
5428
|
function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
|
|
5394
5429
|
let param = null;
|
|
5395
|
-
let additionalScope = scope;
|
|
5396
5430
|
if (consumeOpt(parser, context, 67174411)) {
|
|
5397
5431
|
scope = scope?.createChildScope(4);
|
|
5398
5432
|
param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
|
|
@@ -5406,7 +5440,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
|
|
|
5406
5440
|
}
|
|
5407
5441
|
consume(parser, context | 32, 16);
|
|
5408
5442
|
}
|
|
5409
|
-
additionalScope = scope?.createChildScope(32);
|
|
5443
|
+
const additionalScope = scope?.createChildScope(32);
|
|
5410
5444
|
const body = parseBlock(parser, context, additionalScope, privateScope, { $: labels });
|
|
5411
5445
|
return parser.finishNode({
|
|
5412
5446
|
type: 'CatchClause',
|
|
@@ -5444,7 +5478,8 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
|
|
|
5444
5478
|
const { tokenValue, tokenStart } = parser;
|
|
5445
5479
|
const token = parser.getToken();
|
|
5446
5480
|
let expr = parseIdentifier(parser, context);
|
|
5447
|
-
if (parser.getToken() & (143360 | 2097152)
|
|
5481
|
+
if (parser.getToken() & (143360 | 2097152) &&
|
|
5482
|
+
(parser.getToken() & 20480) !== 20480) {
|
|
5448
5483
|
const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
|
|
5449
5484
|
matchOrInsertSemicolon(parser, context | 32);
|
|
5450
5485
|
return parser.finishNode({
|
|
@@ -5519,7 +5554,7 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
|
|
|
5519
5554
|
if (parser.getToken() === 1077936155) {
|
|
5520
5555
|
nextToken(parser, context | 32);
|
|
5521
5556
|
init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
|
|
5522
|
-
if (origin & 32
|
|
5557
|
+
if (origin & 32) {
|
|
5523
5558
|
if (parser.getToken() === 471156 ||
|
|
5524
5559
|
(parser.getToken() === 8673330 &&
|
|
5525
5560
|
(token & 2097152 || (kind & 4) === 0 || context & 1))) {
|
|
@@ -5557,18 +5592,13 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
|
|
|
5557
5592
|
if (isVarDecl) {
|
|
5558
5593
|
if (token === 241737) {
|
|
5559
5594
|
init = parseIdentifier(parser, context);
|
|
5560
|
-
if (parser.getToken() & (143360 | 2097152)
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
type: 'VariableDeclaration',
|
|
5568
|
-
kind: 'let',
|
|
5569
|
-
declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
|
|
5570
|
-
}, tokenStart);
|
|
5571
|
-
}
|
|
5595
|
+
if (parser.getToken() & (143360 | 2097152) &&
|
|
5596
|
+
(parser.getToken() & 20480) !== 20480) {
|
|
5597
|
+
init = parser.finishNode({
|
|
5598
|
+
type: 'VariableDeclaration',
|
|
5599
|
+
kind: 'let',
|
|
5600
|
+
declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
|
|
5601
|
+
}, tokenStart);
|
|
5572
5602
|
parser.assignable = 1;
|
|
5573
5603
|
}
|
|
5574
5604
|
else if (context & 1) {
|
|
@@ -5689,7 +5719,7 @@ function parseRestrictedIdentifier(parser, context, scope) {
|
|
|
5689
5719
|
function parseImportDeclaration(parser, context, scope) {
|
|
5690
5720
|
const start = parser.tokenStart;
|
|
5691
5721
|
nextToken(parser, context);
|
|
5692
|
-
let source
|
|
5722
|
+
let source;
|
|
5693
5723
|
const { tokenStart } = parser;
|
|
5694
5724
|
let specifiers = [];
|
|
5695
5725
|
if (parser.getToken() === 134283267) {
|
|
@@ -6266,8 +6296,12 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
|
|
|
6266
6296
|
}
|
|
6267
6297
|
if (parser.flags & 512)
|
|
6268
6298
|
parser.report(119);
|
|
6269
|
-
if (parser.flags & 256)
|
|
6299
|
+
if (parser.flags & 256) {
|
|
6300
|
+
if (parser.strictReservedRange) {
|
|
6301
|
+
throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
|
|
6302
|
+
}
|
|
6270
6303
|
parser.report(118);
|
|
6304
|
+
}
|
|
6271
6305
|
}
|
|
6272
6306
|
}
|
|
6273
6307
|
parser.flags =
|
|
@@ -6352,6 +6386,10 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
|
|
|
6352
6386
|
break;
|
|
6353
6387
|
}
|
|
6354
6388
|
case 69271571: {
|
|
6389
|
+
if ((parser.flags & 8192) === 8192) {
|
|
6390
|
+
parser.flags = (parser.flags | 8192) ^ 8192;
|
|
6391
|
+
return expr;
|
|
6392
|
+
}
|
|
6355
6393
|
let restoreHasOptionalChaining = false;
|
|
6356
6394
|
if ((parser.flags & 2048) === 2048) {
|
|
6357
6395
|
restoreHasOptionalChaining = true;
|
|
@@ -6774,6 +6812,7 @@ function parseTemplate(parser, context, privateScope) {
|
|
|
6774
6812
|
consume(parser, context, 67174409);
|
|
6775
6813
|
quasis.push(parseTemplateElement(parser, tokenValue, tokenRaw, tokenStart, true));
|
|
6776
6814
|
}
|
|
6815
|
+
parser.assignable = 2;
|
|
6777
6816
|
return parser.finishNode({
|
|
6778
6817
|
type: 'TemplateLiteral',
|
|
6779
6818
|
expressions,
|
|
@@ -6790,11 +6829,16 @@ function parseTemplateElement(parser, cooked, raw, start, tail) {
|
|
|
6790
6829
|
tail,
|
|
6791
6830
|
}, start);
|
|
6792
6831
|
const tailSize = tail ? 1 : 2;
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6832
|
+
const { ranges } = parser.options;
|
|
6833
|
+
if (ranges) {
|
|
6834
|
+
if (ranges.start)
|
|
6835
|
+
node.start += 1;
|
|
6836
|
+
if (ranges.end)
|
|
6837
|
+
node.end -= tailSize;
|
|
6838
|
+
if (ranges.range) {
|
|
6839
|
+
node.range[0] += 1;
|
|
6840
|
+
node.range[1] -= tailSize;
|
|
6841
|
+
}
|
|
6798
6842
|
}
|
|
6799
6843
|
if (parser.options.loc) {
|
|
6800
6844
|
node.loc.start.column += 1;
|
|
@@ -7884,6 +7928,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
|
|
|
7884
7928
|
consume(parser, context, 67174411);
|
|
7885
7929
|
const params = [];
|
|
7886
7930
|
parser.flags = (parser.flags | 128) ^ 128;
|
|
7931
|
+
parser.strictReservedRange = null;
|
|
7887
7932
|
if (parser.getToken() === 16) {
|
|
7888
7933
|
if (kind & 512) {
|
|
7889
7934
|
parser.report(37, 'Setter', 'one', '');
|
|
@@ -7907,6 +7952,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
|
|
|
7907
7952
|
if ((context & 1) === 0) {
|
|
7908
7953
|
if ((parser.getToken() & 36864) === 36864) {
|
|
7909
7954
|
parser.flags |= 256;
|
|
7955
|
+
parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
|
|
7910
7956
|
}
|
|
7911
7957
|
if ((parser.getToken() & 537079808) === 537079808) {
|
|
7912
7958
|
parser.flags |= 512;
|
|
@@ -8191,6 +8237,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
|
|
|
8191
8237
|
if ((parser.flags & 1) === 0) {
|
|
8192
8238
|
parser.report(116);
|
|
8193
8239
|
}
|
|
8240
|
+
parser.flags |= 8192;
|
|
8194
8241
|
break;
|
|
8195
8242
|
case 67108877:
|
|
8196
8243
|
case 67174409:
|
|
@@ -8221,6 +8268,7 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
|
|
|
8221
8268
|
function parseFormalParametersOrFormalList(parser, context, scope, privateScope, inGroup, kind) {
|
|
8222
8269
|
consume(parser, context, 67174411);
|
|
8223
8270
|
parser.flags = (parser.flags | 128) ^ 128;
|
|
8271
|
+
parser.strictReservedRange = null;
|
|
8224
8272
|
const params = [];
|
|
8225
8273
|
if (consumeOpt(parser, context, 16))
|
|
8226
8274
|
return params;
|
|
@@ -8234,6 +8282,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
|
|
|
8234
8282
|
if ((context & 1) === 0) {
|
|
8235
8283
|
if ((token & 36864) === 36864) {
|
|
8236
8284
|
parser.flags |= 256;
|
|
8285
|
+
parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
|
|
8237
8286
|
}
|
|
8238
8287
|
if ((token & 537079808) === 537079808) {
|
|
8239
8288
|
parser.flags |= 512;
|
|
@@ -8397,7 +8446,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8397
8446
|
}, start);
|
|
8398
8447
|
}
|
|
8399
8448
|
let destructible = 0;
|
|
8400
|
-
let expr
|
|
8449
|
+
let expr;
|
|
8401
8450
|
let isNonSimpleParameterList = 0;
|
|
8402
8451
|
parser.destructible =
|
|
8403
8452
|
(parser.destructible | 256 | 128) ^
|
|
@@ -8707,6 +8756,9 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
|
|
|
8707
8756
|
break;
|
|
8708
8757
|
case 209008:
|
|
8709
8758
|
if (parser.getToken() !== 67174411) {
|
|
8759
|
+
if (parser.getToken() === 8391476 && parser.flags & 1) {
|
|
8760
|
+
return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
|
|
8761
|
+
}
|
|
8710
8762
|
if ((parser.getToken() & 1073741824) === 1073741824) {
|
|
8711
8763
|
return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
|
|
8712
8764
|
}
|
|
@@ -8715,6 +8767,9 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
|
|
|
8715
8767
|
break;
|
|
8716
8768
|
case 209009:
|
|
8717
8769
|
if (parser.getToken() !== 67174411) {
|
|
8770
|
+
if (parser.getToken() === 8391476 && parser.flags & 1) {
|
|
8771
|
+
return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
|
|
8772
|
+
}
|
|
8718
8773
|
if ((parser.getToken() & 1073741824) === 1073741824) {
|
|
8719
8774
|
return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
|
|
8720
8775
|
}
|
|
@@ -9177,7 +9232,7 @@ function parseJSXExpressionContainer(parser, context, privateScope, inJSXChild,
|
|
|
9177
9232
|
const { tokenStart } = parser;
|
|
9178
9233
|
if (parser.getToken() === 14)
|
|
9179
9234
|
return parseJSXSpreadChild(parser, context, privateScope, start);
|
|
9180
|
-
let expression
|
|
9235
|
+
let expression;
|
|
9181
9236
|
if (parser.getToken() === 1074790415) {
|
|
9182
9237
|
if (isAttr)
|
|
9183
9238
|
parser.report(157);
|
|
@@ -9231,7 +9286,7 @@ function parseJSXIdentifier(parser, context) {
|
|
|
9231
9286
|
}, start);
|
|
9232
9287
|
}
|
|
9233
9288
|
|
|
9234
|
-
const version =
|
|
9289
|
+
const { version } = packageJson;
|
|
9235
9290
|
function parseScript(source, options) {
|
|
9236
9291
|
return parseSource(source, { ...options, sourceType: 'script' });
|
|
9237
9292
|
}
|