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.
@@ -4,7 +4,9 @@
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.2";
8
+ var packageJson = {
9
+ version: version$1};
8
10
 
9
11
  const unicodeLookup = ((compressed, lookup) => {
10
12
  const result = new Uint32Array(69632);
@@ -1524,12 +1526,14 @@
1524
1526
  const ch = advanceChar(parser);
1525
1527
  if (parser.currentChar === 123) {
1526
1528
  let code = 0;
1529
+ let digits = 0;
1527
1530
  while ((CharTypes[advanceChar(parser)] & 64) !== 0) {
1528
1531
  code = (code << 4) | toHex(parser.currentChar);
1529
1532
  if (code > 1114111)
1530
1533
  return -5;
1534
+ digits++;
1531
1535
  }
1532
- if (parser.currentChar < 1 || parser.currentChar !== 125) {
1536
+ if (digits === 0 || parser.currentChar < 1 || parser.currentChar !== 125) {
1533
1537
  return -4;
1534
1538
  }
1535
1539
  return code;
@@ -1554,7 +1558,7 @@
1554
1558
  }
1555
1559
  case 56:
1556
1560
  case 57:
1557
- if (isTemplate || !parser.options.webcompat || context & 1)
1561
+ if (isTemplate || context & 1)
1558
1562
  return -3;
1559
1563
  parser.flags |= 4096;
1560
1564
  default:
@@ -4548,10 +4552,22 @@
4548
4552
  return parser.getToken();
4549
4553
  }
4550
4554
 
4555
+ function normalizeRanges(ranges) {
4556
+ if (!ranges)
4557
+ return undefined;
4558
+ if (ranges === true)
4559
+ return { start: true, end: true, range: true };
4560
+ return {
4561
+ start: ranges.start ?? false,
4562
+ end: ranges.end ?? false,
4563
+ range: ranges.range ?? false,
4564
+ };
4565
+ }
4551
4566
  function normalizeOptions(rawOptions) {
4552
4567
  const options = {
4553
4568
  validateRegex: true,
4554
4569
  ...rawOptions,
4570
+ ranges: normalizeRanges(rawOptions.ranges),
4555
4571
  };
4556
4572
  if (options.module && !options.sourceType) {
4557
4573
  options.sourceType = 'module';
@@ -4737,6 +4753,7 @@
4737
4753
  exportedBindings = new Set();
4738
4754
  assignable = 0;
4739
4755
  destructible = 0;
4756
+ strictReservedRange = null;
4740
4757
  leadingDecorators = { decorators: [] };
4741
4758
  constructor(source, rawOptions = {}) {
4742
4759
  this.source = source;
@@ -4793,11 +4810,15 @@
4793
4810
  return { index: this.index, line: this.line, column: this.column };
4794
4811
  }
4795
4812
  finishNode(node, start, end) {
4796
- if (this.options.ranges) {
4797
- node.start = start.index;
4813
+ const { ranges } = this.options;
4814
+ if (ranges) {
4798
4815
  const endIndex = end ? end.index : this.startIndex;
4799
- node.end = endIndex;
4800
- node.range = [start.index, endIndex];
4816
+ if (ranges.start)
4817
+ node.start = start.index;
4818
+ if (ranges.end)
4819
+ node.end = endIndex;
4820
+ if (ranges.range)
4821
+ node.range = [start.index, endIndex];
4801
4822
  }
4802
4823
  if (this.options.loc) {
4803
4824
  node.loc = {
@@ -4848,8 +4869,14 @@
4848
4869
  return this.cloneLocationInformation({ ...original }, original);
4849
4870
  }
4850
4871
  cloneLocationInformation(node, original) {
4851
- if (this.options.ranges) {
4852
- node.range = [...original.range];
4872
+ const { ranges } = this.options;
4873
+ if (ranges) {
4874
+ if (ranges.start)
4875
+ node.start = original.start;
4876
+ if (ranges.end)
4877
+ node.end = original.end;
4878
+ if (ranges.range)
4879
+ node.range = [...original.range];
4853
4880
  }
4854
4881
  if (this.options.loc) {
4855
4882
  node.loc = {
@@ -4867,10 +4894,14 @@
4867
4894
  type,
4868
4895
  value,
4869
4896
  };
4870
- if (options.ranges) {
4871
- comment.start = start;
4872
- comment.end = end;
4873
- comment.range = [start, end];
4897
+ const { ranges } = options;
4898
+ if (ranges) {
4899
+ if (ranges.start)
4900
+ comment.start = start;
4901
+ if (ranges.end)
4902
+ comment.end = end;
4903
+ if (ranges.range)
4904
+ comment.range = [start, end];
4874
4905
  }
4875
4906
  if (options.loc) {
4876
4907
  comment.loc = loc;
@@ -4883,10 +4914,14 @@
4883
4914
  const token = {
4884
4915
  token: type,
4885
4916
  };
4886
- if (options.ranges) {
4887
- token.start = start;
4888
- token.end = end;
4889
- token.range = [start, end];
4917
+ const { ranges } = options;
4918
+ if (ranges) {
4919
+ if (ranges.start)
4920
+ token.start = start;
4921
+ if (ranges.end)
4922
+ token.end = end;
4923
+ if (ranges.range)
4924
+ token.range = [start, end];
4890
4925
  }
4891
4926
  if (options.loc) {
4892
4927
  token.loc = loc;
@@ -4905,7 +4940,7 @@
4905
4940
  context |= 1;
4906
4941
  skipHashBang(parser);
4907
4942
  const scope = parser.createScopeIfLexical();
4908
- let body = [];
4943
+ let body;
4909
4944
  let sourceType = 'script';
4910
4945
  if (context & 2) {
4911
4946
  sourceType = 'module';
@@ -5398,7 +5433,6 @@
5398
5433
  }
5399
5434
  function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
5400
5435
  let param = null;
5401
- let additionalScope = scope;
5402
5436
  if (consumeOpt(parser, context, 67174411)) {
5403
5437
  scope = scope?.createChildScope(4);
5404
5438
  param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
@@ -5412,7 +5446,7 @@
5412
5446
  }
5413
5447
  consume(parser, context | 32, 16);
5414
5448
  }
5415
- additionalScope = scope?.createChildScope(32);
5449
+ const additionalScope = scope?.createChildScope(32);
5416
5450
  const body = parseBlock(parser, context, additionalScope, privateScope, { $: labels });
5417
5451
  return parser.finishNode({
5418
5452
  type: 'CatchClause',
@@ -5450,7 +5484,8 @@
5450
5484
  const { tokenValue, tokenStart } = parser;
5451
5485
  const token = parser.getToken();
5452
5486
  let expr = parseIdentifier(parser, context);
5453
- if (parser.getToken() & (143360 | 2097152)) {
5487
+ if (parser.getToken() & (143360 | 2097152) &&
5488
+ (parser.getToken() & 20480) !== 20480) {
5454
5489
  const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8, 0);
5455
5490
  matchOrInsertSemicolon(parser, context | 32);
5456
5491
  return parser.finishNode({
@@ -5525,7 +5560,7 @@
5525
5560
  if (parser.getToken() === 1077936155) {
5526
5561
  nextToken(parser, context | 32);
5527
5562
  init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
5528
- if (origin & 32 || (token & 2097152) === 0) {
5563
+ if (origin & 32) {
5529
5564
  if (parser.getToken() === 471156 ||
5530
5565
  (parser.getToken() === 8673330 &&
5531
5566
  (token & 2097152 || (kind & 4) === 0 || context & 1))) {
@@ -5563,18 +5598,13 @@
5563
5598
  if (isVarDecl) {
5564
5599
  if (token === 241737) {
5565
5600
  init = parseIdentifier(parser, context);
5566
- if (parser.getToken() & (143360 | 2097152)) {
5567
- if (parser.getToken() === 8673330) {
5568
- if (context & 1)
5569
- parser.report(67);
5570
- }
5571
- else {
5572
- init = parser.finishNode({
5573
- type: 'VariableDeclaration',
5574
- kind: 'let',
5575
- declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
5576
- }, tokenStart);
5577
- }
5601
+ if (parser.getToken() & (143360 | 2097152) &&
5602
+ (parser.getToken() & 20480) !== 20480) {
5603
+ init = parser.finishNode({
5604
+ type: 'VariableDeclaration',
5605
+ kind: 'let',
5606
+ declarations: parseVariableDeclarationList(parser, context | 131072, scope, privateScope, 8, 32),
5607
+ }, tokenStart);
5578
5608
  parser.assignable = 1;
5579
5609
  }
5580
5610
  else if (context & 1) {
@@ -5695,7 +5725,7 @@
5695
5725
  function parseImportDeclaration(parser, context, scope) {
5696
5726
  const start = parser.tokenStart;
5697
5727
  nextToken(parser, context);
5698
- let source = null;
5728
+ let source;
5699
5729
  const { tokenStart } = parser;
5700
5730
  let specifiers = [];
5701
5731
  if (parser.getToken() === 134283267) {
@@ -6272,8 +6302,12 @@
6272
6302
  }
6273
6303
  if (parser.flags & 512)
6274
6304
  parser.report(119);
6275
- if (parser.flags & 256)
6305
+ if (parser.flags & 256) {
6306
+ if (parser.strictReservedRange) {
6307
+ throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 118);
6308
+ }
6276
6309
  parser.report(118);
6310
+ }
6277
6311
  }
6278
6312
  }
6279
6313
  parser.flags =
@@ -6358,6 +6392,10 @@
6358
6392
  break;
6359
6393
  }
6360
6394
  case 69271571: {
6395
+ if ((parser.flags & 8192) === 8192) {
6396
+ parser.flags = (parser.flags | 8192) ^ 8192;
6397
+ return expr;
6398
+ }
6361
6399
  let restoreHasOptionalChaining = false;
6362
6400
  if ((parser.flags & 2048) === 2048) {
6363
6401
  restoreHasOptionalChaining = true;
@@ -6780,6 +6818,7 @@
6780
6818
  consume(parser, context, 67174409);
6781
6819
  quasis.push(parseTemplateElement(parser, tokenValue, tokenRaw, tokenStart, true));
6782
6820
  }
6821
+ parser.assignable = 2;
6783
6822
  return parser.finishNode({
6784
6823
  type: 'TemplateLiteral',
6785
6824
  expressions,
@@ -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;
@@ -8403,7 +8452,7 @@
8403
8452
  }, start);
8404
8453
  }
8405
8454
  let destructible = 0;
8406
- let expr = null;
8455
+ let expr;
8407
8456
  let isNonSimpleParameterList = 0;
8408
8457
  parser.destructible =
8409
8458
  (parser.destructible | 256 | 128) ^
@@ -8713,6 +8762,9 @@
8713
8762
  break;
8714
8763
  case 209008:
8715
8764
  if (parser.getToken() !== 67174411) {
8765
+ if (parser.getToken() === 8391476 && parser.flags & 1) {
8766
+ return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8767
+ }
8716
8768
  if ((parser.getToken() & 1073741824) === 1073741824) {
8717
8769
  return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8718
8770
  }
@@ -8721,6 +8773,9 @@
8721
8773
  break;
8722
8774
  case 209009:
8723
8775
  if (parser.getToken() !== 67174411) {
8776
+ if (parser.getToken() === 8391476 && parser.flags & 1) {
8777
+ return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8778
+ }
8724
8779
  if ((parser.getToken() & 1073741824) === 1073741824) {
8725
8780
  return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
8726
8781
  }
@@ -9183,7 +9238,7 @@
9183
9238
  const { tokenStart } = parser;
9184
9239
  if (parser.getToken() === 14)
9185
9240
  return parseJSXSpreadChild(parser, context, privateScope, start);
9186
- let expression = null;
9241
+ let expression;
9187
9242
  if (parser.getToken() === 1074790415) {
9188
9243
  if (isAttr)
9189
9244
  parser.report(157);
@@ -9237,7 +9292,7 @@
9237
9292
  }, start);
9238
9293
  }
9239
9294
 
9240
- const version = version$1;
9295
+ const { version } = packageJson;
9241
9296
  function parseScript(source, options) {
9242
9297
  return parseSource(source, { ...options, sourceType: 'script' });
9243
9298
  }