meriyah 4.3.9 → 4.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [4.4.1](https://github.com/meriyah/meriyah/compare/v4.4.0...v4.4.1) (2024-03-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **parser:** fix `import.meta` in sequence ([15ea395](https://github.com/meriyah/meriyah/commit/15ea395a1dc59a253c99d57e4697c3a33147e3a8))
7
+ * **parser:** fix async assignment in comma expression ([9652602](https://github.com/meriyah/meriyah/commit/9652602728cca827ebabcdcf3ed8f240ec125c7f))
8
+ * **parser:** fix async assignment in sequence ([223936e](https://github.com/meriyah/meriyah/commit/223936ec62b3b4f008a351075f25c466ca89e9da))
9
+
10
+
11
+
12
+ # [4.4.0](https://github.com/meriyah/meriyah/compare/v4.3.9...v4.4.0) (2024-03-05)
13
+
14
+
15
+ ### Features
16
+
17
+ * **parser:** add onInsertedSemicolon option ([557a893](https://github.com/meriyah/meriyah/commit/557a89301bab294f77d46e431b5c527d6b8c9011))
18
+
19
+
20
+
1
21
  ## [4.3.9](https://github.com/meriyah/meriyah/compare/v4.3.8...v4.3.9) (2023-11-24)
2
22
 
3
23
 
package/README.md CHANGED
@@ -85,6 +85,9 @@ This is the available options:
85
85
  // Allows comment extraction. Accepts either a function or array
86
86
  onComment: []
87
87
 
88
+ // Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the charater offset where the semicolon was inserted
89
+ onInsertedSemicolon: (pos) => {}
90
+
88
91
  // Allows token extraction. Accepts either a function or array
89
92
  onToken: []
90
93
 
@@ -115,13 +118,20 @@ If an array is supplied, comments/tokens will be pushed to the array, the item i
115
118
  If a function callback is supplied, the signature must be
116
119
 
117
120
  ```ts
118
- function onComment(type: string, value: string, start: number, end: number, loc: SourceLocation): void {}
121
+ declare function onComment(type: string, value: string, start: number, end: number, loc: SourceLocation): void;
119
122
 
120
- function onToken(token: string, start: number, end: number, loc: SourceLocation): void {}
123
+ declare function onToken(token: string, start: number, end: number, loc: SourceLocation): void;
121
124
  ```
122
125
 
123
126
  Note the `start/end/loc` information are provided to the function callback regardless of the settings on ranges and loc flags. onComment callback has one extra argument `value: string` for the body string of the comment.
124
127
 
128
+ ### onInsertedSemicolon
129
+ If a function callback is supplied, the signature must be
130
+
131
+ ```ts
132
+ declare function onInsertedSemicolon(position: number): void;
133
+ ```
134
+
125
135
  ## Example usage
126
136
 
127
137
  ```js
@@ -184,4 +194,4 @@ This will return when serialized in json:
184
194
  }
185
195
  ]
186
196
  }
187
- ```
197
+ ```
@@ -4365,7 +4365,9 @@ define(['exports'], (function (exports) { 'use strict';
4365
4365
  !specDeviation) {
4366
4366
  report(parser, 28, KeywordDescTable[parser.token & 255]);
4367
4367
  }
4368
- consumeOpt(parser, context, 1074790417);
4368
+ if (!consumeOpt(parser, context, 1074790417)) {
4369
+ parser.onInsertedSemicolon?.(parser.startPos);
4370
+ }
4369
4371
  }
4370
4372
  function isValidStrictMode(parser, index, tokenPos, tokenValue) {
4371
4373
  if (index - tokenPos < 13 && tokenValue === 'use strict') {
@@ -4707,7 +4709,7 @@ define(['exports'], (function (exports) { 'use strict';
4707
4709
  report(parser, 0);
4708
4710
  }
4709
4711
 
4710
- function create(source, sourceFile, onComment, onToken) {
4712
+ function create(source, sourceFile, onComment, onToken, onInsertedSemicolon) {
4711
4713
  return {
4712
4714
  source,
4713
4715
  flags: 0,
@@ -4733,12 +4735,14 @@ define(['exports'], (function (exports) { 'use strict';
4733
4735
  destructible: 0,
4734
4736
  onComment,
4735
4737
  onToken,
4738
+ onInsertedSemicolon,
4736
4739
  leadingDecorators: []
4737
4740
  };
4738
4741
  }
4739
4742
  function parseSource(source, options, context) {
4740
4743
  let sourceFile = '';
4741
4744
  let onComment;
4745
+ let onInsertedSemicolon;
4742
4746
  let onToken;
4743
4747
  if (options != null) {
4744
4748
  if (options.module)
@@ -4776,11 +4780,13 @@ define(['exports'], (function (exports) { 'use strict';
4776
4780
  if (options.onComment != null) {
4777
4781
  onComment = Array.isArray(options.onComment) ? pushComment(context, options.onComment) : options.onComment;
4778
4782
  }
4783
+ if (options.onInsertedSemicolon != null)
4784
+ onInsertedSemicolon = options.onInsertedSemicolon;
4779
4785
  if (options.onToken != null) {
4780
4786
  onToken = Array.isArray(options.onToken) ? pushToken(context, options.onToken) : options.onToken;
4781
4787
  }
4782
4788
  }
4783
- const parser = create(source, sourceFile, onComment, onToken);
4789
+ const parser = create(source, sourceFile, onComment, onToken, onInsertedSemicolon);
4784
4790
  if (context & 1)
4785
4791
  skipHashBang(parser);
4786
4792
  const scope = context & 64 ? createScope() : void 0;
@@ -5051,10 +5057,11 @@ define(['exports'], (function (exports) { 'use strict';
5051
5057
  parser.assignable = 1;
5052
5058
  }
5053
5059
  expr = parseMemberOrUpdateExpression(parser, context, expr, 0, 0, start, line, column);
5054
- if (parser.token === 18)
5055
- expr = parseSequenceExpression(parser, context, 0, start, line, column, expr);
5056
5060
  expr = parseAssignmentExpression(parser, context, 0, 0, start, line, column, expr);
5057
5061
  parser.assignable = 1;
5062
+ if (parser.token === 18) {
5063
+ expr = parseSequenceExpression(parser, context, 0, start, line, column, expr);
5064
+ }
5058
5065
  return parseExpressionStatement(parser, context, expr, start, line, column);
5059
5066
  }
5060
5067
  function parseDirective(parser, context, expression, token, start, line, column) {
@@ -5666,6 +5673,9 @@ define(['exports'], (function (exports) { 'use strict';
5666
5673
  }), start, line, column);
5667
5674
  expr = parseMemberOrUpdateExpression(parser, context, expr, 0, 0, start, line, column);
5668
5675
  expr = parseAssignmentExpression(parser, context, 0, 0, start, line, column, expr);
5676
+ if (parser.token === 18) {
5677
+ expr = parseSequenceExpression(parser, context, 0, start, line, column, expr);
5678
+ }
5669
5679
  return parseExpressionStatement(parser, context, expr, start, line, column);
5670
5680
  }
5671
5681
  function parseImportCallDeclaration(parser, context, start, line, column) {
@@ -5999,6 +6009,7 @@ define(['exports'], (function (exports) { 'use strict';
5999
6009
  report(parser, 49);
6000
6010
  return parseArrowFromIdentifier(parser, context, parser.tokenValue, expr, inNew, canAssign, 0, start, line, column);
6001
6011
  }
6012
+ parser.assignable = 1;
6002
6013
  return expr;
6003
6014
  }
6004
6015
  function parseYieldExpression(parser, context, inGroup, canAssign, start, line, column) {
@@ -8819,7 +8830,7 @@ define(['exports'], (function (exports) { 'use strict';
8819
8830
  __proto__: null
8820
8831
  });
8821
8832
 
8822
- var version$1 = "4.3.9";
8833
+ var version$1 = "4.4.1";
8823
8834
 
8824
8835
  const version = version$1;
8825
8836
  function parseScript(source, options) {