meriyah 6.1.4 → 7.0.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.
@@ -1,5 +1,5 @@
1
- import { Token } from './token';
2
1
  import { type Parser } from './parser/parser';
2
+ import { Token } from './token';
3
3
  export declare const enum Context {
4
4
  None = 0,
5
5
  Strict = 1,
@@ -127,4 +127,3 @@ export type Location = {
127
127
  readonly line: number;
128
128
  readonly column: number;
129
129
  };
130
- export declare function getOwnProperty<T>(object: Record<string | number, T>, key: string | number): T | undefined;
@@ -1,5 +1,5 @@
1
- import { type _Node, type SourceLocation } from './estree';
2
1
  import { type Location } from './common';
2
+ import { type _Node, type SourceLocation } from './estree';
3
3
  export declare const enum Errors {
4
4
  Unexpected = 0,
5
5
  StrictOctalEscape = 1,
@@ -21,7 +21,7 @@ export interface Comment extends _Node {
21
21
  type: CommentType;
22
22
  value: string;
23
23
  }
24
- export type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BigIntLiteral | BinaryExpression | BlockStatement | BreakStatement | CallExpression | ChainExpression | ImportExpression | CatchClause | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | PropertyDefinition | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportDeclaration | ImportDefaultSpecifier | ImportAttribute | ImportNamespaceSpecifier | ImportSpecifier | JSXNamespacedName | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXMemberExpression | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | ParenthesizedExpression | PrivateIdentifier | Program | Property | RegExpLiteral | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | UpdateExpression | UnaryExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
24
+ export type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BreakStatement | CallExpression | ChainExpression | ImportExpression | CatchClause | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | PropertyDefinition | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportDeclaration | ImportDefaultSpecifier | ImportAttribute | ImportNamespaceSpecifier | ImportSpecifier | JSXNamespacedName | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXMemberExpression | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | ParenthesizedExpression | PrivateIdentifier | Program | Property | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | UpdateExpression | UnaryExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
25
25
  export type BindingPattern = ArrayPattern | ObjectPattern | Identifier;
26
26
  export type ClassElement = FunctionExpression | MethodDefinition;
27
27
  export type DeclarationStatement = ClassDeclaration | ClassExpression | ExportDefaultDeclaration | ExportAllDeclaration | ExportNamedDeclaration | FunctionDeclaration;
@@ -29,7 +29,6 @@ export type EntityName = Identifier;
29
29
  export type ExportDeclaration = ClassDeclaration | ClassExpression | FunctionDeclaration | VariableDeclaration;
30
30
  export type Expression = ArrowFunctionExpression | AssignmentExpression | BinaryExpression | ConditionalExpression | MetaProperty | ChainExpression | JSXClosingElement | JSXClosingFragment | JSXExpressionContainer | JSXOpeningElement | JSXOpeningFragment | JSXSpreadChild | LogicalExpression | NewExpression | RestElement | SequenceExpression | SpreadElement | AwaitExpression | LeftHandSideExpression | UnaryExpression | UpdateExpression | YieldExpression;
31
31
  export type ForInitializer = Expression | VariableDeclaration;
32
- export { ForInitializer as ForInitialiser };
33
32
  export type ImportClause = ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier;
34
33
  export type IterationStatement = DoWhileStatement | ForInStatement | ForOfStatement | ForStatement | WhileStatement;
35
34
  export type JSXChild = JSXElement | JSXExpression | JSXFragment | JSXText;
@@ -90,9 +89,6 @@ export interface AwaitExpression extends _Node {
90
89
  type: 'AwaitExpression';
91
90
  argument: Expression;
92
91
  }
93
- export interface BigIntLiteral extends Literal {
94
- bigint: string;
95
- }
96
92
  export interface BinaryExpression extends _Node {
97
93
  type: 'BinaryExpression';
98
94
  operator: string;
@@ -186,8 +182,8 @@ export interface EmptyStatement extends _Node {
186
182
  }
187
183
  export interface ExportAllDeclaration extends _Node {
188
184
  type: 'ExportAllDeclaration';
189
- source: Literal;
190
- exported: Identifier | Literal | null;
185
+ source: StringLiteral;
186
+ exported: Identifier | StringLiteral | null;
191
187
  attributes: ImportAttribute[];
192
188
  }
193
189
  export interface ExportDefaultDeclaration extends _Node {
@@ -198,13 +194,13 @@ export interface ExportNamedDeclaration extends _Node {
198
194
  type: 'ExportNamedDeclaration';
199
195
  declaration: ExportDeclaration | null;
200
196
  specifiers: ExportSpecifier[];
201
- source: Literal | null;
197
+ source: StringLiteral | null;
202
198
  attributes: ImportAttribute[];
203
199
  }
204
200
  export interface ExportSpecifier extends _Node {
205
201
  type: 'ExportSpecifier';
206
- local: Identifier | Literal;
207
- exported: Identifier | Literal;
202
+ local: Identifier | StringLiteral;
203
+ exported: Identifier | StringLiteral;
208
204
  }
209
205
  export interface ExpressionStatement extends _Node {
210
206
  type: 'ExpressionStatement';
@@ -249,14 +245,14 @@ export interface IfStatement extends _Node {
249
245
  }
250
246
  export interface ImportDeclaration extends _Node {
251
247
  type: 'ImportDeclaration';
252
- source: Literal;
248
+ source: StringLiteral;
253
249
  specifiers: ImportClause[];
254
250
  attributes: ImportAttribute[];
255
251
  }
256
252
  export interface ImportAttribute extends _Node {
257
253
  type: 'ImportAttribute';
258
- key: Identifier | Literal;
259
- value: Literal;
254
+ key: Identifier | StringLiteral;
255
+ value: StringLiteral;
260
256
  }
261
257
  export interface ImportDefaultSpecifier extends _Node {
262
258
  type: 'ImportDefaultSpecifier';
@@ -269,7 +265,7 @@ export interface ImportNamespaceSpecifier extends _Node {
269
265
  export interface ImportSpecifier extends _Node {
270
266
  type: 'ImportSpecifier';
271
267
  local: Identifier;
272
- imported: Identifier | Literal;
268
+ imported: Identifier | StringLiteral;
273
269
  }
274
270
  export interface JSXNamespacedName extends _Node {
275
271
  type: 'JSXNamespacedName';
@@ -344,11 +340,34 @@ export interface LabeledStatement extends _Node {
344
340
  label: Identifier;
345
341
  body: Statement;
346
342
  }
347
- export interface Literal extends _Node {
343
+ export type Literal = StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | BigIntLiteral | RegExpLiteral;
344
+ export interface _LiteralBase extends _Node {
348
345
  type: 'Literal';
349
- value: boolean | number | string | null | RegExp | bigint;
350
346
  raw?: string;
351
347
  }
348
+ export interface StringLiteral extends _LiteralBase {
349
+ value: string;
350
+ }
351
+ export interface NumericLiteral extends _LiteralBase {
352
+ value: number;
353
+ }
354
+ export interface BooleanLiteral extends _LiteralBase {
355
+ value: boolean;
356
+ }
357
+ export interface NullLiteral extends _LiteralBase {
358
+ value: null;
359
+ }
360
+ export interface BigIntLiteral extends _LiteralBase {
361
+ value: bigint;
362
+ bigint: string;
363
+ }
364
+ export interface RegExpLiteral extends _LiteralBase {
365
+ value: RegExp | null;
366
+ regex: {
367
+ pattern: string;
368
+ flags: string;
369
+ };
370
+ }
352
371
  export interface LogicalExpression extends _Node {
353
372
  type: 'LogicalExpression';
354
373
  operator: string;
@@ -408,12 +427,6 @@ export interface Property extends _Node {
408
427
  shorthand: boolean;
409
428
  kind: 'init' | 'get' | 'set';
410
429
  }
411
- export interface RegExpLiteral extends Literal {
412
- regex: {
413
- pattern: string;
414
- flags: string;
415
- };
416
- }
417
430
  export interface RestElement extends _Node {
418
431
  type: 'RestElement';
419
432
  argument: BindingPattern | Identifier | Expression | PropertyName;
@@ -516,3 +529,4 @@ export interface YieldExpression extends _Node {
516
529
  delegate: boolean;
517
530
  argument?: Expression | null;
518
531
  }
532
+ export {};
@@ -1,6 +1,6 @@
1
- import { LexerState } from './common';
2
1
  import { Context, type Location } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { LexerState } from './common';
4
4
  export declare const enum CommentType {
5
5
  Single = 0,
6
6
  Multi = 1,
@@ -1,5 +1,5 @@
1
- import { Token } from '../token';
2
1
  import { type Parser } from '../parser/parser';
2
+ import { Token } from '../token';
3
3
  export declare const enum LexerState {
4
4
  None = 0,
5
5
  NewLine = 1,
@@ -1,6 +1,6 @@
1
- import { Token } from './../token';
2
1
  import { Context } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { Token } from './../token';
4
4
  export declare function scanIdentifier(parser: Parser, context: Context, isValidAsKeyword: 0 | 1): Token;
5
5
  export declare function scanUnicodeIdentifier(parser: Parser, context: Context): Token;
6
6
  export declare function scanIdentifierSlowCase(parser: Parser, context: Context, hasEscape: 0 | 1, isValidAsKeyword: number): Token;
@@ -1,6 +1,6 @@
1
- import { Token } from '../token';
2
1
  import { type Context } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { Token } from '../token';
4
4
  export declare function scanJSXAttributeValue(parser: Parser, context: Context): Token;
5
5
  export declare function nextJSXToken(parser: Parser): void;
6
6
  export declare function rescanJSXIdentifier(parser: Parser): Token;
@@ -1,6 +1,6 @@
1
- import { Token } from '../token';
2
1
  import { Context } from '../common';
3
2
  import { type Parser } from '../parser/parser';
3
+ import { Token } from '../token';
4
4
  import { LexerState } from './common';
5
5
  export declare function nextToken(parser: Parser, context: Context): void;
6
6
  export declare function scanSingleToken(parser: Parser, context: Context, state: LexerState): Token;
@@ -1,8 +1,8 @@
1
1
  import { type Program } from './estree';
2
2
  import { type Options } from './options';
3
3
  declare const version: string;
4
- export declare function parseScript(source: string, options?: Options): Program;
5
- export declare function parseModule(source: string, options?: Options): Program;
4
+ export declare function parseScript(source: string, options?: Omit<Options, 'sourceType'>): Program;
5
+ export declare function parseModule(source: string, options?: Omit<Options, 'sourceType'>): Program;
6
6
  export declare function parse(source: string, options?: Options): Program;
7
7
  export { type Options, version };
8
8
  export type * as ESTree from './estree';
@@ -1,16 +1,16 @@
1
1
  import type * as ESTree from './estree';
2
2
  import { type Token } from './token';
3
3
  type OnInsertedSemicolon = (pos: number) => any;
4
+ type SourceType = 'script' | 'module' | 'commonjs';
4
5
  export type OnToken = (token: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
5
6
  export type OnComment = (type: ESTree.CommentType, value: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
6
7
  export interface Options {
7
- module?: boolean;
8
+ sourceType?: SourceType;
8
9
  next?: boolean;
9
10
  ranges?: boolean;
10
11
  webcompat?: boolean;
11
12
  loc?: boolean;
12
13
  raw?: boolean;
13
- globalReturn?: boolean;
14
14
  impliedStrict?: boolean;
15
15
  preserveParens?: boolean;
16
16
  lexical?: boolean;
@@ -19,9 +19,12 @@ export interface Options {
19
19
  onComment?: ESTree.Comment[] | OnComment;
20
20
  onInsertedSemicolon?: OnInsertedSemicolon;
21
21
  onToken?: Token[] | OnToken;
22
- uniqueKeyInPattern?: boolean;
22
+ validateRegex?: boolean;
23
+ module?: boolean;
24
+ globalReturn?: boolean;
23
25
  }
24
- export type NormalizedOptions = Omit<Options, 'onComment' | 'onToken'> & {
26
+ export type NormalizedOptions = Omit<Options, 'validateRegex' | 'onComment' | 'onToken'> & {
27
+ validateRegex: boolean;
25
28
  onComment?: OnComment;
26
29
  onToken?: OnToken;
27
30
  };
@@ -1,14 +1,14 @@
1
- import { Token } from '../token';
2
- import type * as ESTree from '../estree';
3
- import { type Location, Flags, type AssignmentKind, type DestructuringKind } from '../common';
1
+ import { type AssignmentKind, type DestructuringKind, Flags, type Location } from '../common';
4
2
  import { Errors } from '../errors';
5
- import { type NormalizedOptions, type OnComment, type OnToken } from '../options';
6
- import { Scope, type ScopeKind } from './scope';
3
+ import type * as ESTree from '../estree';
4
+ import { type NormalizedOptions, type Options } from '../options';
5
+ import { Token } from '../token';
7
6
  import { PrivateScope } from './private-scope';
7
+ import { Scope, type ScopeKind } from './scope';
8
8
  export declare class Parser {
9
9
  readonly source: string;
10
- readonly options: NormalizedOptions;
11
10
  private lastOnToken;
11
+ options: NormalizedOptions;
12
12
  token: Token;
13
13
  flags: Flags;
14
14
  index: number;
@@ -36,7 +36,7 @@ export declare class Parser {
36
36
  start?: Location;
37
37
  decorators: ESTree.Decorator[];
38
38
  };
39
- constructor(source: string, options?: NormalizedOptions);
39
+ constructor(source: string, rawOptions?: Options);
40
40
  getToken(): Token;
41
41
  setToken(value: Token, replaceLast?: boolean): Token;
42
42
  get tokenStart(): Location;
@@ -48,6 +48,7 @@ export declare class Parser {
48
48
  createScopeIfLexical(type?: ScopeKind, parent?: Scope): Scope | undefined;
49
49
  createScope(type?: ScopeKind, parent?: Scope): Scope;
50
50
  createPrivateScopeIfLexical(parent?: PrivateScope): PrivateScope | undefined;
51
+ cloneIdentifier(original: ESTree.Identifier): ESTree.Identifier;
52
+ cloneStringLiteral(original: ESTree.StringLiteral): ESTree.StringLiteral;
53
+ private cloneLocationInformation;
51
54
  }
52
- export declare function pushComment(comments: ESTree.Comment[], options: NormalizedOptions): OnComment;
53
- export declare function pushToken(tokens: Token[], options: NormalizedOptions): OnToken;
@@ -1,4 +1,4 @@
1
- import { PropertyKind, type Location } from '../common';
1
+ import { type Location, PropertyKind } from '../common';
2
2
  import { type Parser } from './parser';
3
3
  export declare class PrivateScope {
4
4
  readonly parser: Parser;
@@ -1,5 +1,5 @@
1
+ import { BindingKind, Context, type Location, Origin } from '../common';
1
2
  import { Errors } from '../errors';
2
- import { type Location, Context, BindingKind, Origin } from '../common';
3
3
  import { type Parser } from './parser';
4
4
  export declare const enum ScopeKind {
5
5
  ForStatement = 1,
@@ -1,9 +1,4 @@
1
- import { Token } from './token';
1
+ import { Context } from './common';
2
2
  import type * as ESTree from './estree';
3
- import { Context, type Location } from './common';
4
- import { Parser } from './parser/parser';
5
3
  import { type Options } from './options';
6
- import { type Scope } from './parser/scope';
7
4
  export declare function parseSource(source: string, rawOptions?: Options, context?: Context): ESTree.Program;
8
- export declare function parseModuleItem(parser: Parser, context: Context, scope: Scope | undefined): any;
9
- export declare function parseDirective(parser: Parser, context: Context, expression: ESTree.ArgumentExpression | ESTree.SequenceExpression | ESTree.Expression, token: Token, start: Location): ESTree.ExpressionStatement;
@@ -0,0 +1 @@
1
+ export declare function getOwnProperty<T>(object: Record<string | number, T>, key: string | number): T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meriyah",
3
- "version": "6.1.4",
3
+ "version": "7.0.0",
4
4
  "description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",
5
5
  "main": "dist/meriyah.cjs",
6
6
  "module": "dist/meriyah.min.mjs",
@@ -65,6 +65,7 @@
65
65
  "fix:prettier": "prettier . --write",
66
66
  "test": "vitest",
67
67
  "test:watch": "vitest --watch",
68
+ "test:unicode": "node scripts/generate-unicode.mjs --check",
68
69
  "production-test": "npm run build && cross-env PRODUCTION_TEST=1 vitest test/production/production-tests.ts",
69
70
  "prepare-nightly": "node scripts/bump-dev-version.mjs",
70
71
  "coverage": "vitest --coverage",
@@ -82,9 +83,10 @@
82
83
  "@eslint/js": "^9.30.0",
83
84
  "@rollup/plugin-json": "^6.1.0",
84
85
  "@rollup/plugin-terser": "^0.4.4",
86
+ "@stylistic/eslint-plugin": "^5.1.0",
85
87
  "@types/babel__code-frame": "^7.0.6",
86
88
  "@types/node": "^24.0.7",
87
- "@unicode/unicode-16.0.0": "^1.6.6",
89
+ "@unicode/unicode-17.0.0": "^1.6.10",
88
90
  "@vitest/coverage-v8": "^3.2.4",
89
91
  "acorn": "^8.15.0",
90
92
  "coveralls": "^3.1.1",
@@ -94,7 +96,8 @@
94
96
  "eslint-import-resolver-typescript": "^4.4.4",
95
97
  "eslint-plugin-import-x": "^4.16.1",
96
98
  "eslint-plugin-n": "^17.20.0",
97
- "eslint-plugin-unicorn": "^59.0.1",
99
+ "eslint-plugin-simple-import-sort": "^12.1.1",
100
+ "eslint-plugin-unicorn": "^62.0.0",
98
101
  "globals": "^16.2.0",
99
102
  "husky": "^9.1.7",
100
103
  "knip": "^5.61.3",
@@ -111,7 +114,7 @@
111
114
  "vitest": "^3.2.4"
112
115
  },
113
116
  "engines": {
114
- "node": ">=18.0.0"
117
+ "node": ">=20.0.0"
115
118
  },
116
119
  "lint-staged": {
117
120
  "*.{ts,mts,cts,js,mjs,cjs}": "eslint --fix",