Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions deps/acorn/acorn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 8.15.0 (2025-06-08)

### New features

Support `using` and `await using` syntax.

The `AnyNode` type is now defined in such a way that plugins can extend it.

### Bug fixes

Fix an issue where the `bigint` property of literal nodes for non-decimal bigints had the wrong format.

The `acorn` CLI tool no longer crashes when emitting a tree that contains a bigint.

## 8.14.1 (2025-03-05)

### Bug fixes
Expand Down
23 changes: 20 additions & 3 deletions deps/acorn/acorn/dist/acorn.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function {
export interface VariableDeclaration extends Node {
type: "VariableDeclaration"
declarations: Array<VariableDeclarator>
kind: "var" | "let" | "const"
kind: "var" | "let" | "const" | "using" | "await using"
}

export interface VariableDeclarator extends Node {
Expand Down Expand Up @@ -572,7 +572,24 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration
| ExportAllDeclaration

export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
/**
* This interface is only used for defining {@link AnyNode}.
* It exists so that it can be extended by plugins:
*
* @example
* ```typescript
* declare module 'acorn' {
* interface NodeTypes {
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
* }
* }
* ```
*/
interface NodeTypes {
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
}

export type AnyNode = NodeTypes[keyof NodeTypes]

export function parse(input: string, options: Options): Program

Expand All @@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): {
[Symbol.iterator](): Iterator<Token>
}

export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest"

export interface Options {
/**
Expand Down
23 changes: 20 additions & 3 deletions deps/acorn/acorn/dist/acorn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function {
export interface VariableDeclaration extends Node {
type: "VariableDeclaration"
declarations: Array<VariableDeclarator>
kind: "var" | "let" | "const"
kind: "var" | "let" | "const" | "using" | "await using"
}

export interface VariableDeclarator extends Node {
Expand Down Expand Up @@ -572,7 +572,24 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration
| ExportAllDeclaration

export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
/**
* This interface is only used for defining {@link AnyNode}.
* It exists so that it can be extended by plugins:
*
* @example
* ```typescript
* declare module 'acorn' {
* interface NodeTypes {
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
* }
* }
* ```
*/
interface NodeTypes {
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
}

export type AnyNode = NodeTypes[keyof NodeTypes]

export function parse(input: string, options: Options): Program

Expand All @@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): {
[Symbol.iterator](): Iterator<Token>
}

export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest"

export interface Options {
/**
Expand Down
109 changes: 94 additions & 15 deletions deps/acorn/acorn/dist/acorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,49 @@
!(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
};

pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
if (this.options.ecmaVersion < 17 || !this.isContextual(isAwaitUsing ? "await" : "using"))
{ return false }

skipWhiteSpace.lastIndex = this.pos;
var skip = skipWhiteSpace.exec(this.input);
var next = this.pos + skip[0].length;

if (lineBreak.test(this.input.slice(this.pos, next))) { return false }

if (isAwaitUsing) {
var awaitEndPos = next + 5 /* await */, after;
if (this.input.slice(next, awaitEndPos) !== "using" ||
awaitEndPos === this.input.length ||
isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) ||
(after > 0xd7ff && after < 0xdc00)
) { return false }

skipWhiteSpace.lastIndex = awaitEndPos;
var skipAfterUsing = skipWhiteSpace.exec(this.input);
if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false }
}

if (isFor) {
var ofEndPos = next + 2 /* of */, after$1;
if (this.input.slice(next, ofEndPos) === "of") {
if (ofEndPos === this.input.length ||
(!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false }
}
}

var ch = this.input.charCodeAt(next);
return isIdentifierStart(ch, true) || ch === 92 // '\'
};

pp$8.isAwaitUsing = function(isFor) {
return this.isUsingKeyword(true, isFor)
};

pp$8.isUsing = function(isFor) {
return this.isUsingKeyword(false, isFor)
};

// Parse a single statement.
//
// If expecting a statement and finding a slash operator, parse a
Expand Down Expand Up @@ -963,6 +1006,23 @@
return this.parseFunctionStatement(node, true, !context)
}

var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
if (usingKind) {
if (topLevel && this.options.sourceType === "script") {
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`");
}
if (usingKind === "await using") {
if (!this.canAwait) {
this.raise(this.start, "Await using cannot appear outside of async function");
}
this.next();
}
this.next();
this.parseVar(node, false, usingKind);
this.semicolon();
return this.finishNode(node, "VariableDeclaration")
}

var maybeName = this.value, expr = this.parseExpression();
if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon))
{ return this.parseLabeledStatement(node, maybeName, expr, context) }
Expand Down Expand Up @@ -1038,18 +1098,19 @@
this.next();
this.parseVar(init$1, true, kind);
this.finishNode(init$1, "VariableDeclaration");
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
if (this.options.ecmaVersion >= 9) {
if (this.type === types$1._in) {
if (awaitAt > -1) { this.unexpected(awaitAt); }
} else { node.await = awaitAt > -1; }
}
return this.parseForIn(node, init$1)
}
if (awaitAt > -1) { this.unexpected(awaitAt); }
return this.parseFor(node, init$1)
return this.parseForAfterInit(node, init$1, awaitAt)
}
var startsWithLet = this.isContextual("let"), isForOf = false;

var usingKind = this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null;
if (usingKind) {
var init$2 = this.startNode();
this.next();
if (usingKind === "await using") { this.next(); }
this.parseVar(init$2, true, usingKind);
this.finishNode(init$2, "VariableDeclaration");
return this.parseForAfterInit(node, init$2, awaitAt)
}
var containsEsc = this.containsEsc;
var refDestructuringErrors = new DestructuringErrors;
var initPos = this.start;
Expand All @@ -1075,6 +1136,20 @@
return this.parseFor(node, init)
};

// Helper method to parse for loop after variable initialization
pp$8.parseForAfterInit = function(node, init, awaitAt) {
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
if (this.options.ecmaVersion >= 9) {
if (this.type === types$1._in) {
if (awaitAt > -1) { this.unexpected(awaitAt); }
} else { node.await = awaitAt > -1; }
}
return this.parseForIn(node, init)
}
if (awaitAt > -1) { this.unexpected(awaitAt); }
return this.parseFor(node, init)
};

pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
this.next();
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
Expand Down Expand Up @@ -1331,6 +1406,8 @@
decl.init = this.parseMaybeAssign(isFor);
} else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
this.unexpected();
} else if (!allowMissingInitializer && (kind === "using" || kind === "await using") && this.options.ecmaVersion >= 17 && this.type !== types$1._in && !this.isContextual("of")) {
this.raise(this.lastTokEnd, ("Missing initializer in " + kind + " declaration"));
} else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
} else {
Expand All @@ -1343,7 +1420,10 @@
};

pp$8.parseVarId = function(decl, kind) {
decl.id = this.parseBindingAtom();
decl.id = kind === "using" || kind === "await using"
? this.parseIdent()
: this.parseBindingAtom();

this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
};

Expand Down Expand Up @@ -3074,7 +3154,8 @@
var node = this.startNode();
node.value = value;
node.raw = this.input.slice(this.start, this.end);
if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
if (node.raw.charCodeAt(node.raw.length - 1) === 110)
{ node.bigint = node.value != null ? node.value.toString() : node.raw.slice(0, -1).replace(/_/g, ""); }
this.next();
return this.finishNode(node, "Literal")
};
Expand Down Expand Up @@ -6104,11 +6185,9 @@
// Please use the [github bug tracker][ghbt] to report issues.
//
// [ghbt]: https://github.com/acornjs/acorn/issues
//
// [walk]: util/walk.js


var version = "8.14.1";
var version = "8.15.0";

Parser.acorn = {
Parser: Parser,
Expand Down
Loading
Loading