meriyah 7.1.0 → 7.1.1

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/dist/meriyah.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var version$1 = "7.1.0";
1
+ var version$1 = "7.1.1";
2
2
 
3
3
  const unicodeLookup = ((compressed, lookup) => {
4
4
  const result = new Uint32Array(69632);
@@ -1548,7 +1548,7 @@ function parseEscape(parser, context, first, isTemplate = 0) {
1548
1548
  }
1549
1549
  case 56:
1550
1550
  case 57:
1551
- if (isTemplate || !parser.options.webcompat || context & 1)
1551
+ if (isTemplate || context & 1)
1552
1552
  return -3;
1553
1553
  parser.flags |= 4096;
1554
1554
  default:
@@ -4542,10 +4542,22 @@ function rescanJSXIdentifier(parser) {
4542
4542
  return parser.getToken();
4543
4543
  }
4544
4544
 
4545
+ function normalizeRanges(ranges) {
4546
+ if (!ranges)
4547
+ return undefined;
4548
+ if (ranges === true)
4549
+ return { start: true, end: true, range: true };
4550
+ return {
4551
+ start: ranges.start ?? false,
4552
+ end: ranges.end ?? false,
4553
+ range: ranges.range ?? false,
4554
+ };
4555
+ }
4545
4556
  function normalizeOptions(rawOptions) {
4546
4557
  const options = {
4547
4558
  validateRegex: true,
4548
4559
  ...rawOptions,
4560
+ ranges: normalizeRanges(rawOptions.ranges),
4549
4561
  };
4550
4562
  if (options.module && !options.sourceType) {
4551
4563
  options.sourceType = 'module';
@@ -4731,6 +4743,7 @@ class Parser {
4731
4743
  exportedBindings = new Set();
4732
4744
  assignable = 0;
4733
4745
  destructible = 0;
4746
+ strictReservedRange = null;
4734
4747
  leadingDecorators = { decorators: [] };
4735
4748
  constructor(source, rawOptions = {}) {
4736
4749
  this.source = source;
@@ -4787,11 +4800,15 @@ class Parser {
4787
4800
  return { index: this.index, line: this.line, column: this.column };
4788
4801
  }
4789
4802
  finishNode(node, start, end) {
4790
- if (this.options.ranges) {
4791
- node.start = start.index;
4803
+ const { ranges } = this.options;
4804
+ if (ranges) {
4792
4805
  const endIndex = end ? end.index : this.startIndex;
4793
- node.end = endIndex;
4794
- node.range = [start.index, endIndex];
4806
+ if (ranges.start)
4807
+ node.start = start.index;
4808
+ if (ranges.end)
4809
+ node.end = endIndex;
4810
+ if (ranges.range)
4811
+ node.range = [start.index, endIndex];
4795
4812
  }
4796
4813
  if (this.options.loc) {
4797
4814
  node.loc = {
@@ -4842,8 +4859,14 @@ class Parser {
4842
4859
  return this.cloneLocationInformation({ ...original }, original);
4843
4860
  }
4844
4861
  cloneLocationInformation(node, original) {
4845
- if (this.options.ranges) {
4846
- node.range = [...original.range];
4862
+ const { ranges } = this.options;
4863
+ if (ranges) {
4864
+ if (ranges.start)
4865
+ node.start = original.start;
4866
+ if (ranges.end)
4867
+ node.end = original.end;
4868
+ if (ranges.range)
4869
+ node.range = [...original.range];
4847
4870
  }
4848
4871
  if (this.options.loc) {
4849
4872
  node.loc = {
@@ -4861,10 +4884,14 @@ function pushComment(comments, options) {
4861
4884
  type,
4862
4885
  value,
4863
4886
  };
4864
- if (options.ranges) {
4865
- comment.start = start;
4866
- comment.end = end;
4867
- comment.range = [start, end];
4887
+ const { ranges } = options;
4888
+ if (ranges) {
4889
+ if (ranges.start)
4890
+ comment.start = start;
4891
+ if (ranges.end)
4892
+ comment.end = end;
4893
+ if (ranges.range)
4894
+ comment.range = [start, end];
4868
4895
  }
4869
4896
  if (options.loc) {
4870
4897
  comment.loc = loc;
@@ -4877,10 +4904,14 @@ function pushToken(tokens, options) {
4877
4904
  const token = {
4878
4905
  token: type,
4879
4906
  };
4880
- if (options.ranges) {
4881
- token.start = start;
4882
- token.end = end;
4883
- token.range = [start, end];
4907
+ const { ranges } = options;
4908
+ if (ranges) {
4909
+ if (ranges.start)
4910
+ token.start = start;
4911
+ if (ranges.end)
4912
+ token.end = end;
4913
+ if (ranges.range)
4914
+ token.range = [start, end];
4884
4915
  }
4885
4916
  if (options.loc) {
4886
4917
  token.loc = loc;
@@ -5519,7 +5550,7 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
5519
5550
  if (parser.getToken() === 1077936155) {
5520
5551
  nextToken(parser, context | 32);
5521
5552
  init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5522
- if (origin & 32 || (token & 2097152) === 0) {
5553
+ if (origin & 32) {
5523
5554
  if (parser.getToken() === 471156 ||
5524
5555
  (parser.getToken() === 8673330 &&
5525
5556
  (token & 2097152 || (kind & 4) === 0 || context & 1))) {
@@ -6266,8 +6297,12 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
6266
6297
  }
6267
6298
  if (parser.flags & 512)
6268
6299
  parser.report(119);
6269
- if (parser.flags & 256)
6300
+ if (parser.flags & 256) {
6301
+ if (parser.strictReservedRange) {
6302
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6303
+ }
6270
6304
  parser.report(118);
6305
+ }
6271
6306
  }
6272
6307
  }
6273
6308
  parser.flags =
@@ -6352,6 +6387,10 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
6352
6387
  break;
6353
6388
  }
6354
6389
  case 69271571: {
6390
+ if ((parser.flags & 8192) === 8192) {
6391
+ parser.flags = (parser.flags | 8192) ^ 8192;
6392
+ return expr;
6393
+ }
6355
6394
  let restoreHasOptionalChaining = false;
6356
6395
  if ((parser.flags & 2048) === 2048) {
6357
6396
  restoreHasOptionalChaining = true;
@@ -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
- if (parser.options.ranges) {
6794
- node.start += 1;
6795
- node.range[0] += 1;
6796
- node.end -= tailSize;
6797
- node.range[1] -= tailSize;
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;
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.meriyah = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var version$1 = "7.1.0";
7
+ var version$1 = "7.1.1";
8
8
 
9
9
  const unicodeLookup = ((compressed, lookup) => {
10
10
  const result = new Uint32Array(69632);
@@ -1554,7 +1554,7 @@
1554
1554
  }
1555
1555
  case 56:
1556
1556
  case 57:
1557
- if (isTemplate || !parser.options.webcompat || context & 1)
1557
+ if (isTemplate || context & 1)
1558
1558
  return -3;
1559
1559
  parser.flags |= 4096;
1560
1560
  default:
@@ -4548,10 +4548,22 @@
4548
4548
  return parser.getToken();
4549
4549
  }
4550
4550
 
4551
+ function normalizeRanges(ranges) {
4552
+ if (!ranges)
4553
+ return undefined;
4554
+ if (ranges === true)
4555
+ return { start: true, end: true, range: true };
4556
+ return {
4557
+ start: ranges.start ?? false,
4558
+ end: ranges.end ?? false,
4559
+ range: ranges.range ?? false,
4560
+ };
4561
+ }
4551
4562
  function normalizeOptions(rawOptions) {
4552
4563
  const options = {
4553
4564
  validateRegex: true,
4554
4565
  ...rawOptions,
4566
+ ranges: normalizeRanges(rawOptions.ranges),
4555
4567
  };
4556
4568
  if (options.module && !options.sourceType) {
4557
4569
  options.sourceType = 'module';
@@ -4737,6 +4749,7 @@
4737
4749
  exportedBindings = new Set();
4738
4750
  assignable = 0;
4739
4751
  destructible = 0;
4752
+ strictReservedRange = null;
4740
4753
  leadingDecorators = { decorators: [] };
4741
4754
  constructor(source, rawOptions = {}) {
4742
4755
  this.source = source;
@@ -4793,11 +4806,15 @@
4793
4806
  return { index: this.index, line: this.line, column: this.column };
4794
4807
  }
4795
4808
  finishNode(node, start, end) {
4796
- if (this.options.ranges) {
4797
- node.start = start.index;
4809
+ const { ranges } = this.options;
4810
+ if (ranges) {
4798
4811
  const endIndex = end ? end.index : this.startIndex;
4799
- node.end = endIndex;
4800
- node.range = [start.index, endIndex];
4812
+ if (ranges.start)
4813
+ node.start = start.index;
4814
+ if (ranges.end)
4815
+ node.end = endIndex;
4816
+ if (ranges.range)
4817
+ node.range = [start.index, endIndex];
4801
4818
  }
4802
4819
  if (this.options.loc) {
4803
4820
  node.loc = {
@@ -4848,8 +4865,14 @@
4848
4865
  return this.cloneLocationInformation({ ...original }, original);
4849
4866
  }
4850
4867
  cloneLocationInformation(node, original) {
4851
- if (this.options.ranges) {
4852
- node.range = [...original.range];
4868
+ const { ranges } = this.options;
4869
+ if (ranges) {
4870
+ if (ranges.start)
4871
+ node.start = original.start;
4872
+ if (ranges.end)
4873
+ node.end = original.end;
4874
+ if (ranges.range)
4875
+ node.range = [...original.range];
4853
4876
  }
4854
4877
  if (this.options.loc) {
4855
4878
  node.loc = {
@@ -4867,10 +4890,14 @@
4867
4890
  type,
4868
4891
  value,
4869
4892
  };
4870
- if (options.ranges) {
4871
- comment.start = start;
4872
- comment.end = end;
4873
- comment.range = [start, end];
4893
+ const { ranges } = options;
4894
+ if (ranges) {
4895
+ if (ranges.start)
4896
+ comment.start = start;
4897
+ if (ranges.end)
4898
+ comment.end = end;
4899
+ if (ranges.range)
4900
+ comment.range = [start, end];
4874
4901
  }
4875
4902
  if (options.loc) {
4876
4903
  comment.loc = loc;
@@ -4883,10 +4910,14 @@
4883
4910
  const token = {
4884
4911
  token: type,
4885
4912
  };
4886
- if (options.ranges) {
4887
- token.start = start;
4888
- token.end = end;
4889
- token.range = [start, end];
4913
+ const { ranges } = options;
4914
+ if (ranges) {
4915
+ if (ranges.start)
4916
+ token.start = start;
4917
+ if (ranges.end)
4918
+ token.end = end;
4919
+ if (ranges.range)
4920
+ token.range = [start, end];
4890
4921
  }
4891
4922
  if (options.loc) {
4892
4923
  token.loc = loc;
@@ -5525,7 +5556,7 @@
5525
5556
  if (parser.getToken() === 1077936155) {
5526
5557
  nextToken(parser, context | 32);
5527
5558
  init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5528
- if (origin & 32 || (token & 2097152) === 0) {
5559
+ if (origin & 32) {
5529
5560
  if (parser.getToken() === 471156 ||
5530
5561
  (parser.getToken() === 8673330 &&
5531
5562
  (token & 2097152 || (kind & 4) === 0 || context & 1))) {
@@ -6272,8 +6303,12 @@
6272
6303
  }
6273
6304
  if (parser.flags & 512)
6274
6305
  parser.report(119);
6275
- if (parser.flags & 256)
6306
+ if (parser.flags & 256) {
6307
+ if (parser.strictReservedRange) {
6308
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6309
+ }
6276
6310
  parser.report(118);
6311
+ }
6277
6312
  }
6278
6313
  }
6279
6314
  parser.flags =
@@ -6358,6 +6393,10 @@
6358
6393
  break;
6359
6394
  }
6360
6395
  case 69271571: {
6396
+ if ((parser.flags & 8192) === 8192) {
6397
+ parser.flags = (parser.flags | 8192) ^ 8192;
6398
+ return expr;
6399
+ }
6361
6400
  let restoreHasOptionalChaining = false;
6362
6401
  if ((parser.flags & 2048) === 2048) {
6363
6402
  restoreHasOptionalChaining = true;
@@ -6796,11 +6835,16 @@
6796
6835
  tail,
6797
6836
  }, start);
6798
6837
  const tailSize = tail ? 1 : 2;
6799
- if (parser.options.ranges) {
6800
- node.start += 1;
6801
- node.range[0] += 1;
6802
- node.end -= tailSize;
6803
- node.range[1] -= tailSize;
6838
+ const { ranges } = parser.options;
6839
+ if (ranges) {
6840
+ if (ranges.start)
6841
+ node.start += 1;
6842
+ if (ranges.end)
6843
+ node.end -= tailSize;
6844
+ if (ranges.range) {
6845
+ node.range[0] += 1;
6846
+ node.range[1] -= tailSize;
6847
+ }
6804
6848
  }
6805
6849
  if (parser.options.loc) {
6806
6850
  node.loc.start.column += 1;
@@ -7890,6 +7934,7 @@
7890
7934
  consume(parser, context, 67174411);
7891
7935
  const params = [];
7892
7936
  parser.flags = (parser.flags | 128) ^ 128;
7937
+ parser.strictReservedRange = null;
7893
7938
  if (parser.getToken() === 16) {
7894
7939
  if (kind & 512) {
7895
7940
  parser.report(37, 'Setter', 'one', '');
@@ -7913,6 +7958,7 @@
7913
7958
  if ((context & 1) === 0) {
7914
7959
  if ((parser.getToken() & 36864) === 36864) {
7915
7960
  parser.flags |= 256;
7961
+ parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
7916
7962
  }
7917
7963
  if ((parser.getToken() & 537079808) === 537079808) {
7918
7964
  parser.flags |= 512;
@@ -8197,6 +8243,7 @@
8197
8243
  if ((parser.flags & 1) === 0) {
8198
8244
  parser.report(116);
8199
8245
  }
8246
+ parser.flags |= 8192;
8200
8247
  break;
8201
8248
  case 67108877:
8202
8249
  case 67174409:
@@ -8227,6 +8274,7 @@
8227
8274
  function parseFormalParametersOrFormalList(parser, context, scope, privateScope, inGroup, kind) {
8228
8275
  consume(parser, context, 67174411);
8229
8276
  parser.flags = (parser.flags | 128) ^ 128;
8277
+ parser.strictReservedRange = null;
8230
8278
  const params = [];
8231
8279
  if (consumeOpt(parser, context, 16))
8232
8280
  return params;
@@ -8240,6 +8288,7 @@
8240
8288
  if ((context & 1) === 0) {
8241
8289
  if ((token & 36864) === 36864) {
8242
8290
  parser.flags |= 256;
8291
+ parser.strictReservedRange ??= [tokenStart, parser.currentLocation];
8243
8292
  }
8244
8293
  if ((token & 537079808) === 537079808) {
8245
8294
  parser.flags |= 512;