meriyah 4.3.9 → 4.4.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/CHANGELOG.md +9 -0
- package/README.md +13 -3
- package/dist/meriyah.amd.js +10 -4
- package/dist/meriyah.amd.min.js +1 -1
- package/dist/meriyah.cjs +10 -4
- package/dist/meriyah.cjs.js +10 -4
- package/dist/meriyah.cjs.min.js +1 -1
- package/dist/meriyah.esm.js +10 -4
- package/dist/meriyah.esm.min.js +1 -1
- package/dist/meriyah.esm.min.mjs +1 -1
- package/dist/meriyah.esm.mjs +10 -4
- package/dist/meriyah.iife.js +10 -4
- package/dist/meriyah.iife.min.js +1 -1
- package/dist/meriyah.min.cjs +1 -1
- package/dist/meriyah.system.js +10 -4
- package/dist/meriyah.system.min.js +1 -1
- package/dist/meriyah.umd.cjs +10 -4
- package/dist/meriyah.umd.es5.js +11 -4
- package/dist/meriyah.umd.es5.min.js +1 -1
- package/dist/meriyah.umd.js +10 -4
- package/dist/meriyah.umd.min.cjs +1 -1
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/src/common.d.ts +2 -0
- package/dist/src/common.d.ts.map +1 -1
- package/dist/src/parser.d.ts +3 -2
- package/dist/src/parser.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +11 -1
- package/src/parser.ts +15 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# [4.4.0](https://github.com/meriyah/meriyah/compare/v4.3.9...v4.4.0) (2024-03-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **parser:** add onInsertedSemicolon option ([557a893](https://github.com/meriyah/meriyah/commit/557a89301bab294f77d46e431b5c527d6b8c9011))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
## [4.3.9](https://github.com/meriyah/meriyah/compare/v4.3.8...v4.3.9) (2023-11-24)
|
|
2
11
|
|
|
3
12
|
|
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
|
+
```
|
package/dist/meriyah.amd.js
CHANGED
|
@@ -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;
|
|
@@ -8819,7 +8825,7 @@ define(['exports'], (function (exports) { 'use strict';
|
|
|
8819
8825
|
__proto__: null
|
|
8820
8826
|
});
|
|
8821
8827
|
|
|
8822
|
-
var version$1 = "4.
|
|
8828
|
+
var version$1 = "4.4.0";
|
|
8823
8829
|
|
|
8824
8830
|
const version = version$1;
|
|
8825
8831
|
function parseScript(source, options) {
|