UNPKG

oxlint

Version:

Linter for the JavaScript Oxidation Compiler

1,308 lines 1.13 MB
import { a as JSONStringify, c as ObjectAssign, f as ObjectFreeze, g as ObjectPrototype, h as ObjectPreventExtensions, i as JSONParse, l as ObjectCreate, m as ObjectKeys, n as ArrayIsArray, o as MathMax, p as ObjectHasOwn, s as MathMin, u as ObjectDefineProperty, v as StringFromCodePoint, y as SymbolIterator } from "./globals.js"; import { a as setCurrentWorkspace, n as currentWorkspace, o as workspaces, r as currentWorkspaceUri } from "./workspace2.js"; import { t as getErrorMessage } from "./utils.js"; import { createRequire } from "node:module"; import "node:assert"; //#region \0rolldown/runtime.js var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports), __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) key = keys[i], !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }, __toESM = (mod, isNodeMode, target) => (target = mod == null ? {} : __create(__getProtoOf(mod)), __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod)), __require = /* @__PURE__ */ createRequire(import.meta.url); //#endregion //#region src-js/generated/constants.ts /** * Total size of the allocator block (including metadata and allocator `ChunkFooter`). */ const BLOCK_SIZE = 2147483632, BLOCK_ALIGN = 4294967296, BUFFER_SIZE = 2147483576, ACTIVE_SIZE = 2147483560, DATA_POINTER_POS_32 = 536870890, { freeze } = Object, $EMPTY = freeze([]), DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([ "decorators", "key", "typeAnnotation", "value" ]), LEFT__RIGHT = freeze(["left", "right"]), ARGUMENT = freeze(["argument"]), BODY = freeze(["body"]), LABEL = freeze(["label"]), CALLEE__TYPE_ARGUMENTS__ARGUMENTS = freeze([ "callee", "typeArguments", "arguments" ]), EXPRESSION = freeze(["expression"]), DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY = freeze([ "decorators", "id", "typeParameters", "superClass", "superTypeArguments", "implements", "body" ]), TEST__CONSEQUENT__ALTERNATE = freeze([ "test", "consequent", "alternate" ]), LEFT__RIGHT__BODY = freeze([ "left", "right", "body" ]), ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY = freeze([ "id", "typeParameters", "params", "returnType", "body" ]), KEY__VALUE = freeze(["key", "value"]), LOCAL = freeze(["local"]), OBJECT__PROPERTY = freeze(["object", "property"]), DECORATORS__KEY__TYPE_ANNOTATION = freeze([ "decorators", "key", "typeAnnotation" ]), EXPRESSION__TYPE_ANNOTATION = freeze(["expression", "typeAnnotation"]), TYPE_PARAMETERS__PARAMS__RETURN_TYPE = freeze([ "typeParameters", "params", "returnType" ]), EXPRESSION__TYPE_ARGUMENTS = freeze(["expression", "typeArguments"]), MEMBERS = freeze(["members"]), ID__BODY = freeze(["id", "body"]), TYPES = freeze(["types"]), TYPE_ANNOTATION = freeze(["typeAnnotation"]), PARAMS = freeze(["params"]); var keys_default = freeze({ DebuggerStatement: $EMPTY, EmptyStatement: $EMPTY, Literal: $EMPTY, PrivateIdentifier: $EMPTY, Super: $EMPTY, TemplateElement: $EMPTY, ThisExpression: $EMPTY, JSXClosingFragment: $EMPTY, JSXEmptyExpression: $EMPTY, JSXIdentifier: $EMPTY, JSXOpeningFragment: $EMPTY, JSXText: $EMPTY, TSAnyKeyword: $EMPTY, TSBigIntKeyword: $EMPTY, TSBooleanKeyword: $EMPTY, TSIntrinsicKeyword: $EMPTY, TSJSDocUnknownType: $EMPTY, TSNeverKeyword: $EMPTY, TSNullKeyword: $EMPTY, TSNumberKeyword: $EMPTY, TSObjectKeyword: $EMPTY, TSStringKeyword: $EMPTY, TSSymbolKeyword: $EMPTY, TSThisType: $EMPTY, TSUndefinedKeyword: $EMPTY, TSUnknownKeyword: $EMPTY, TSVoidKeyword: $EMPTY, AccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION__VALUE, ArrayExpression: freeze(["elements"]), ArrayPattern: freeze([ "decorators", "elements", "typeAnnotation" ]), ArrowFunctionExpression: freeze([ "typeParameters", "params", "returnType", "body" ]), AssignmentExpression: LEFT__RIGHT, AssignmentPattern: freeze([ "decorators", "left", "right", "typeAnnotation" ]), AwaitExpression: ARGUMENT, BinaryExpression: LEFT__RIGHT, BlockStatement: BODY, BreakStatement: LABEL, CallExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS, CatchClause: freeze(["param", "body"]), ChainExpression: EXPRESSION, ClassBody: BODY, ClassDeclaration: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY, ClassExpression: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY, ConditionalExpression: TEST__CONSEQUENT__ALTERNATE, ContinueStatement: LABEL, Decorator: EXPRESSION, DoWhileStatement: freeze(["body", "test"]), ExportAllDeclaration: freeze([ "exported", "source", "attributes" ]), ExportDefaultDeclaration: freeze(["declaration"]), ExportNamedDeclaration: freeze([ "declaration", "specifiers", "source", "attributes" ]), ExportSpecifier: freeze(["local", "exported"]), ExpressionStatement: EXPRESSION, ForInStatement: LEFT__RIGHT__BODY, ForOfStatement: LEFT__RIGHT__BODY, ForStatement: freeze([ "init", "test", "update", "body" ]), FunctionDeclaration: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY, FunctionExpression: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY, Identifier: freeze(["decorators", "typeAnnotation"]), IfStatement: TEST__CONSEQUENT__ALTERNATE, ImportAttribute: KEY__VALUE, ImportDeclaration: freeze([ "specifiers", "source", "attributes" ]), ImportDefaultSpecifier: LOCAL, ImportExpression: freeze(["source", "options"]), ImportNamespaceSpecifier: LOCAL, ImportSpecifier: freeze(["imported", "local"]), LabeledStatement: freeze(["label", "body"]), LogicalExpression: LEFT__RIGHT, MemberExpression: OBJECT__PROPERTY, MetaProperty: freeze(["meta", "property"]), MethodDefinition: freeze([ "decorators", "key", "value" ]), NewExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS, ObjectExpression: freeze(["properties"]), ObjectPattern: freeze([ "decorators", "properties", "typeAnnotation" ]), ParenthesizedExpression: EXPRESSION, Program: BODY, Property: KEY__VALUE, PropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION__VALUE, RestElement: freeze([ "decorators", "argument", "typeAnnotation" ]), ReturnStatement: ARGUMENT, SequenceExpression: freeze(["expressions"]), SpreadElement: ARGUMENT, StaticBlock: BODY, SwitchCase: freeze(["test", "consequent"]), SwitchStatement: freeze(["discriminant", "cases"]), TaggedTemplateExpression: freeze([ "tag", "typeArguments", "quasi" ]), TemplateLiteral: freeze(["quasis", "expressions"]), ThrowStatement: ARGUMENT, TryStatement: freeze([ "block", "handler", "finalizer" ]), UnaryExpression: ARGUMENT, UpdateExpression: ARGUMENT, V8IntrinsicExpression: freeze(["name", "arguments"]), VariableDeclaration: freeze(["declarations"]), VariableDeclarator: freeze(["id", "init"]), WhileStatement: freeze(["test", "body"]), WithStatement: freeze(["object", "body"]), YieldExpression: ARGUMENT, JSXAttribute: freeze(["name", "value"]), JSXClosingElement: freeze(["name"]), JSXElement: freeze([ "openingElement", "children", "closingElement" ]), JSXExpressionContainer: EXPRESSION, JSXFragment: freeze([ "openingFragment", "children", "closingFragment" ]), JSXMemberExpression: OBJECT__PROPERTY, JSXNamespacedName: freeze(["namespace", "name"]), JSXOpeningElement: freeze([ "name", "typeArguments", "attributes" ]), JSXSpreadAttribute: ARGUMENT, JSXSpreadChild: EXPRESSION, TSAbstractAccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION, TSAbstractMethodDefinition: KEY__VALUE, TSAbstractPropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION, TSArrayType: freeze(["elementType"]), TSAsExpression: EXPRESSION__TYPE_ANNOTATION, TSCallSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE, TSClassImplements: EXPRESSION__TYPE_ARGUMENTS, TSConditionalType: freeze([ "checkType", "extendsType", "trueType", "falseType" ]), TSConstructSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE, TSConstructorType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE, TSDeclareFunction: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY, TSEmptyBodyFunctionExpression: freeze([ "id", "typeParameters", "params", "returnType" ]), TSEnumBody: MEMBERS, TSEnumDeclaration: ID__BODY, TSEnumMember: freeze(["id", "initializer"]), TSExportAssignment: EXPRESSION, TSExternalModuleReference: EXPRESSION, TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE, TSImportEqualsDeclaration: freeze(["id", "moduleReference"]), TSImportType: freeze([ "source", "options", "qualifier", "typeArguments" ]), TSIndexSignature: freeze(["parameters", "typeAnnotation"]), TSIndexedAccessType: freeze(["objectType", "indexType"]), TSInferType: freeze(["typeParameter"]), TSInstantiationExpression: EXPRESSION__TYPE_ARGUMENTS, TSInterfaceBody: BODY, TSInterfaceDeclaration: freeze([ "id", "typeParameters", "extends", "body" ]), TSInterfaceHeritage: EXPRESSION__TYPE_ARGUMENTS, TSIntersectionType: TYPES, TSJSDocNonNullableType: TYPE_ANNOTATION, TSJSDocNullableType: TYPE_ANNOTATION, TSLiteralType: freeze(["literal"]), TSMappedType: freeze([ "key", "constraint", "nameType", "typeAnnotation" ]), TSMethodSignature: freeze([ "key", "typeParameters", "params", "returnType" ]), TSModuleBlock: BODY, TSModuleDeclaration: ID__BODY, TSNamedTupleMember: freeze(["label", "elementType"]), TSNamespaceExportDeclaration: freeze(["id"]), TSNonNullExpression: EXPRESSION, TSOptionalType: TYPE_ANNOTATION, TSParameterProperty: freeze(["decorators", "parameter"]), TSParenthesizedType: TYPE_ANNOTATION, TSPropertySignature: freeze(["key", "typeAnnotation"]), TSQualifiedName: LEFT__RIGHT, TSRestType: TYPE_ANNOTATION, TSSatisfiesExpression: EXPRESSION__TYPE_ANNOTATION, TSTemplateLiteralType: freeze(["quasis", "types"]), TSTupleType: freeze(["elementTypes"]), TSTypeAliasDeclaration: freeze([ "id", "typeParameters", "typeAnnotation" ]), TSTypeAnnotation: TYPE_ANNOTATION, TSTypeAssertion: freeze(["typeAnnotation", "expression"]), TSTypeLiteral: MEMBERS, TSTypeOperator: TYPE_ANNOTATION, TSTypeParameter: freeze([ "name", "constraint", "default" ]), TSTypeParameterDeclaration: PARAMS, TSTypeParameterInstantiation: PARAMS, TSTypePredicate: freeze(["parameterName", "typeAnnotation"]), TSTypeQuery: freeze(["exprName", "typeArguments"]), TSTypeReference: freeze(["typeName", "typeArguments"]), TSUnionType: TYPES }); //#endregion //#region src-js/plugins/location.ts const LINE_BREAK_PATTERN = /\r\n|[\r\n\u2028\u2029]/gu, lines = [], lineStartIndices = [0], cachedLocations = []; let activeLocationsCount = 0; /** * Split source text into lines. */ function initLines() { sourceText === null && initSourceText(); let lastOffset = 0, offset, match; for (; (match = LINE_BREAK_PATTERN.exec(sourceText)) !== null;) offset = match.index, lines.push(sourceText.slice(lastOffset, offset)), lineStartIndices.push(lastOffset = offset + match[0].length); lines.push(sourceText.slice(lastOffset)); } /** * Reset lines after file has been linted, to free memory. * Reset `Location` object pool. */ function resetLinesAndLocs() { lines.length = 0, lineStartIndices.length = 1, activeLocationsCount = 0; } /** * Convert a source text index into a (line, column) pair. * @param offset - The index of a character in a file. * @returns `{line, column}` location object with 1-indexed line and 0-indexed column. * @throws {TypeError|RangeError} If non-numeric `offset`, or `offset` out of range. */ function getLineColumnFromOffset(offset) { if (typeof offset != "number" || offset < 0 || (offset | 0) !== offset) throw TypeError("Expected `offset` to be a non-negative integer."); if (lines.length === 0 && initLines(), offset > sourceText.length) throw RangeError(`Index out of range (requested index ${offset}, but source text has length ${sourceText.length}).`); let low = 0, high = lineStartIndices.length, mid; do mid = low + high >> 1, offset < lineStartIndices[mid] ? high = mid : low = mid + 1; while (low < high); return { line: low, column: offset - lineStartIndices[low - 1] }; } /** * Convert a `{ line, column }` pair into a range index. * @param loc - A line/column location. * @returns The character index of the location in the file. * @throws {TypeError|RangeError} If `loc` is not an object with a numeric `line` and `column`, * or if the `line` is less than or equal to zero, or the line or column is out of the expected range. */ function getOffsetFromLineColumn$1(loc) { if (typeof loc == "object" && loc) { let { line, column } = loc; if (typeof line == "number" && typeof column == "number" && (line | 0) === line && (column | 0) === column) { lines.length === 0 && initLines(); let linesCount = lineStartIndices.length; if (line <= 0 || line > linesCount) throw RangeError(`Line number out of range (line ${line} requested). Line numbers should be 1-based, and less than or equal to number of lines in file (${linesCount}).`); if (column < 0) throw RangeError(`Invalid column number (column ${column} requested).`); let lineOffset = lineStartIndices[line - 1], offset = lineOffset + column, nextLineOffset; if (line === linesCount) { if (nextLineOffset = sourceText.length, offset <= nextLineOffset) return offset; } else if (nextLineOffset = lineStartIndices[line], offset < nextLineOffset) return offset; throw RangeError(`Column number out of range (column ${column} requested, but the length of line ${line} is ${nextLineOffset - lineOffset}).`); } } throw TypeError("Expected `loc` to be an object with integer `line` and `column` properties"); } /** * Get the range of the given node or token. * @param nodeOrToken - Node or token to get the range of * @returns Range of the node or token */ function getRange(nodeOrToken) { return nodeOrToken.range; } /** * Get the location of the given node or token. * @param nodeOrToken - Node or token to get the location of * @returns Location of the node or token */ function getLoc(nodeOrToken) { return nodeOrToken.loc; } /** * Calculate the `Location` for an AST node, and cache it on the node. * * Used in `loc` getter on AST nodes (not tokens or comments - they use their own caching * via `Token` / `Comment` class private fields). * * Defines a `loc` property on the node with the calculated `Location`, so accessing `loc` twice on same node * results in the same object each time. * * For internal use only. * * @param node - AST node * @returns Location */ function getNodeLoc(node) { let loc = computeLoc(node.start, node.end); return LOC_DESCRIPTOR.value = loc, ObjectDefineProperty(node, "loc", LOC_DESCRIPTOR), loc; } const LOC_DESCRIPTOR = { value: null, writable: !0, enumerable: !1, configurable: !1 }; /** * Compute a `Location` from `start` and `end` source offsets. * * Returns a recycled `Location` object from the pool when possible, allocating only during warmup. * Initializes `lines` and `lineStartIndices` tables if they haven't been already. * * @param start - Start offset * @param end - End offset * @returns Location */ function computeLoc(start, end) { lines.length === 0 && initLines(); let loc; activeLocationsCount < cachedLocations.length ? loc = cachedLocations[activeLocationsCount] : cachedLocations.push(loc = { start: { line: 0, column: 0 }, end: { line: 0, column: 0 } }), activeLocationsCount++; let linesLen = lineStartIndices.length, line = 0, high = linesLen, mid; do mid = line + high >> 1, start < lineStartIndices[mid] ? high = mid : line = mid + 1; while (line < high); let lineStart = lineStartIndices[line - 1], locStart = loc.start; locStart.line = line, locStart.column = start - lineStart; let locEnd = loc.end; if (line === linesLen || end < lineStartIndices[line]) locEnd.line = line, locEnd.column = end - lineStart; else { for (line++, high = linesLen; line < high;) mid = line + high >> 1, end < lineStartIndices[mid] ? high = mid : line = mid + 1; locEnd.line = line, locEnd.column = end - lineStartIndices[line - 1]; } return loc; } /** * Get the deepest node containing a range index. * @param offset - Range index of the desired node * @returns The node if found, or `null` if not found */ function getNodeByRangeIndex(offset) { return ast === null && initAst(), offset < ast.start || offset >= ast.end ? null : (index = offset, traverse(ast)); } let index = 0; /** * Find deepest node containing `index`. * `node` must contain `index` itself. This function finds a deeper node if one exists. * * @param node - Node to start traversal from * @returns Deepest node containing `index` */ function traverse(node) { let keys = keys_default[node.type]; for (let keyIndex = 0, keysLen = keys.length; keyIndex < keysLen; keyIndex++) { let child = node[keys[keyIndex]]; if (ArrayIsArray(child)) for (let arrIndex = 0, arrLen = child.length; arrIndex < arrLen; arrIndex++) { let entry = child[arrIndex]; if (entry !== null) { if (entry.start > index) break; if (entry.end > index) return traverse(entry); } } else if (child !== null) { if (child.start > index) break; if (child.end > index) return traverse(child); } } return node; } //#endregion //#region src-js/utils/typed_arrays.ts const EMPTY_UINT8_ARRAY = new Uint8Array(), EMPTY_INT32_ARRAY = new Int32Array(); //#endregion //#region src-js/plugins/tokens.ts let tokens = null, tokensUint8 = null, tokensInt32 = null, tokensLen = 0, allTokensDeserialized = !1; const cachedTokens = []; let previousTokens = []; const tokensWithLoc = []; let activeTokensWithLocCount = 0; const regexObjects = []; let tokensWithRegexIndexes = EMPTY_INT32_ARRAY, activeTokensWithRegexCount = 0, deserializedTokenIndexes = EMPTY_INT32_ARRAY, deserializedTokensLen = 0, resetLoc; /** * Token implementation with lazy `loc` caching via private field. * * Using a class with a private `#loc` field avoids hidden class transitions that would occur * with `Object.defineProperty` / `delete` on plain objects. * All `Token` instances always have the same V8 hidden class, keeping property access monomorphic. */ var Token = class { type = null; value = null; regex; start = 0; end = 0; range = [0, 0]; #loc = null; get loc() { let loc = this.#loc; return loc === null ? (activeTokensWithLocCount < tokensWithLoc.length ? tokensWithLoc[activeTokensWithLocCount] = this : tokensWithLoc.push(this), activeTokensWithLocCount++, this.#loc = computeLoc(this.start, this.end)) : loc; } toJSON() { return { ...this, loc: this.loc }; } static { resetLoc = (token) => { token.#loc = null; }; } }; ObjectDefineProperty(Token.prototype, "loc", { enumerable: !0 }); const TOKEN_TYPES = [ "Identifier", "Keyword", "PrivateIdentifier", "Punctuator", "Numeric", "String", "Boolean", "Null", "RegularExpression", "Template", "JSXText", "JSXIdentifier" ]; /** * Deserialize all tokens and build the `tokens` array. * Called by `ast.tokens` getter. */ function initTokens() { allTokensDeserialized || deserializeTokens(), previousTokens.length >= tokensLen ? (previousTokens.length = tokensLen, tokens = previousTokens) : tokens = previousTokens = cachedTokens.slice(0, tokensLen); } /** * Deserialize all tokens into `cachedTokens`. * Does NOT build the `tokens` array - use `initTokens` for that. */ function deserializeTokens() { tokensInt32 === null && initTokensBuffer(); for (let i = 0; i < tokensLen; i++) deserializeTokenIfNeeded(i); allTokensDeserialized = !0, deserializedTokensLen = 0; } /** * Initialize typed array views over the tokens region of the buffer. * * Populates `tokensUint8`, `tokensInt32`, and `tokensLen`, and grows `cachedTokens` if needed. * Does NOT deserialize tokens - they are deserialized lazily via `deserializeTokenIfNeeded`. */ function initTokensBuffer() { sourceText === null && initSourceText(); let { int32 } = buffer, tokensPos = int32[536870891]; tokensLen = int32[536870892]; let arrayBuffer = buffer.buffer, absolutePos = buffer.byteOffset + tokensPos; if (tokensUint8 = new Uint8Array(arrayBuffer, absolutePos, tokensLen << 4), tokensInt32 = new Int32Array(arrayBuffer, absolutePos, tokensLen << 2), cachedTokens.length < tokensLen) { do cachedTokens.push(new Token()); while (cachedTokens.length < tokensLen); let indexesLen = deserializedTokenIndexes.length; indexesLen < tokensLen && (deserializedTokenIndexes = new Int32Array(MathMax(tokensLen, indexesLen === 0 ? 16 : indexesLen << 1))); } } /** * Get token at `index`, deserializing if needed. * * Caller must ensure `initTokensBuffer()` has been called before calling this function. * * @param index - Token index in the tokens buffer * @returns Deserialized token */ function getToken(index) { if (!allTokensDeserialized) { let token = deserializeTokenIfNeeded(index); if (token !== null) return deserializedTokenIndexes[deserializedTokensLen++] = index, token; } return cachedTokens[index]; } /** * Deserialize token at `index` if not already deserialized. * * Caller must ensure `initTokensBuffer()` has been called before calling this function. * * @param index - Token index in the tokens buffer * @returns `Token` object if newly deserialized, or `null` if already deserialized */ function deserializeTokenIfNeeded(index) { let pos = index << 4, flagPos = pos + 15; if (tokensUint8[flagPos] !== 0) return null; tokensUint8[flagPos] = 1; let token = cachedTokens[index], kind = tokensUint8[pos + 8], pos32 = pos >> 2, start = tokensInt32[pos32], end = tokensInt32[pos32 + 1], value = sourceText.slice(start + +(kind === 2), end); if (kind <= 2) tokensUint8[pos + 10] === 1 && (value = unescapeIdentifier(value)); else if (kind === 8) { let regex; if (activeTokensWithRegexCount < regexObjects.length) regex = regexObjects[activeTokensWithRegexCount]; else { regexObjects.push(regex = { pattern: null, flags: null }); let indexesLen = tokensWithRegexIndexes.length; if (indexesLen === activeTokensWithRegexCount) { let newArr = new Int32Array(indexesLen === 0 ? 16 : indexesLen << 1); newArr.set(tokensWithRegexIndexes, 0), tokensWithRegexIndexes = newArr; } } token.regex = regex, tokensWithRegexIndexes[activeTokensWithRegexCount++] = index; let patternEnd = value.lastIndexOf("/"); regex.pattern = value.slice(1, patternEnd), regex.flags = value.slice(patternEnd + 1); } return token.type = TOKEN_TYPES[kind], token.value = value, token.range[0] = token.start = start, token.range[1] = token.end = end, token; } /** * Unescape an identifier. * * We do this on JS side, because escaped identifiers are so extremely rare that this function * is never called in practice anyway. * * @param {string} name - Identifier name to unescape * @returns {string} - Unescaped identifier name */ function unescapeIdentifier(name) { return name.replace(/\\u(?:\{([0-9a-fA-F]+)\}|([0-9a-fA-F]{4}))/g, (_, hex1, hex2) => StringFromCodePoint(parseInt(hex1 ?? hex2, 16))); } /** * Reset tokens after file has been linted. * * Clears cached `loc` on tokens that had it accessed, so the getter * will recalculate it when the token is reused for a different file. */ function resetTokens() { if (tokensInt32 !== null) { if (allTokensDeserialized === !1) { for (let i = 0; i < deserializedTokensLen; i++) cachedTokens[deserializedTokenIndexes[i]].value = null; deserializedTokensLen = 0; } else { for (let i = 0; i < tokensLen; i++) cachedTokens[i].value = null; allTokensDeserialized = !1; } for (let i = 0; i < activeTokensWithLocCount; i++) resetLoc(tokensWithLoc[i]); activeTokensWithLocCount = 0; for (let i = 0; i < activeTokensWithRegexCount; i++) { let token = cachedTokens[tokensWithRegexIndexes[i]], regex = token.regex; regex.pattern = null, regex.flags = null, token.regex = void 0; } activeTokensWithRegexCount = 0, tokens = null, tokensUint8 = null, tokensInt32 = null, tokensLen = 0; } } //#endregion //#region src-js/plugins/comments.ts let comments = null, commentsUint8 = null, commentsInt32 = null, commentsLen = 0, allCommentsDeserialized = !1; const cachedComments = []; let previousComments = []; const commentsWithLoc = []; let activeCommentsWithLocCount = 0, deserializedCommentIndexes = EMPTY_INT32_ARRAY, deserializedCommentsLen = 0; const EMPTY_COMMENTS = ObjectFreeze([]); let resetCommentLoc; /** * Comment class. * * Creates `loc` lazily and caches it in a private field. * Using a class with a private `#loc` field avoids hidden class transitions that would occur * with `Object.defineProperty` / `delete` on plain objects. * All `Comment` instances always have the same V8 hidden class, keeping property access monomorphic. */ var Comment = class { type = null; value = null; start = 0; end = 0; range = [0, 0]; #loc = null; get loc() { let loc = this.#loc; return loc === null ? (activeCommentsWithLocCount < commentsWithLoc.length ? commentsWithLoc[activeCommentsWithLocCount] = this : commentsWithLoc.push(this), activeCommentsWithLocCount++, this.#loc = computeLoc(this.start, this.end)) : loc; } toJSON() { return { ...this, loc: this.loc }; } static { resetCommentLoc = (comment) => { comment.#loc = null; }; } }; ObjectDefineProperty(Comment.prototype, "loc", { enumerable: !0 }); /** * Deserialize all comments and build the `comments` array. * Called by `ast.comments` getter. */ function initComments() { allCommentsDeserialized || deserializeComments(), comments === null && (previousComments.length >= commentsLen ? (previousComments.length = commentsLen, comments = previousComments) : comments = previousComments = cachedComments.slice(0, commentsLen)); } /** * Deserialize all comments into `cachedComments`. * Does NOT build the `comments` array - use `initComments` for that. */ function deserializeComments() { commentsInt32 === null && initCommentsBuffer(); for (let i = 0; i < commentsLen; i++) deserializeCommentIfNeeded(i); allCommentsDeserialized = !0, deserializedCommentsLen = 0; } /** * Initialize typed array views over the comments region of the buffer. * * Populates `commentsUint8`, `commentsInt32`, and `commentsLen`, and grows `cachedComments` if needed. * Does NOT deserialize comments - they are deserialized lazily via `deserializeCommentIfNeeded`. * * Exception: If the file has a hashbang, eagerly deserializes the first comment and sets its type to `Shebang`. */ function initCommentsBuffer() { sourceText === null && initSourceText(); let { int32 } = buffer, programPos32 = int32[DATA_POINTER_POS_32] >> 2, commentsPos = int32[programPos32 + 8]; if (commentsLen = int32[programPos32 + 10], commentsLen === 0) { comments = EMPTY_COMMENTS, commentsUint8 = EMPTY_UINT8_ARRAY, commentsInt32 = EMPTY_INT32_ARRAY, allCommentsDeserialized = !0; return; } let arrayBuffer = buffer.buffer, absolutePos = buffer.byteOffset + commentsPos; if (commentsUint8 = new Uint8Array(arrayBuffer, absolutePos, commentsLen * 16), commentsInt32 = new Int32Array(arrayBuffer, absolutePos, commentsLen * 4), cachedComments.length < commentsLen) { do cachedComments.push(new Comment()); while (cachedComments.length < commentsLen); let indexesLen = deserializedCommentIndexes.length; indexesLen < commentsLen && (deserializedCommentIndexes = new Int32Array(MathMax(commentsLen, indexesLen === 0 ? 16 : indexesLen << 1))); } commentsInt32[0] === 0 && sourceText.startsWith("#!") && (getComment(0).type = "Shebang"); } /** * Get comment at `index`, deserializing if needed. * * Caller must ensure `initCommentsBuffer()` has been called before calling this function. * * @param index - Comment index in the comments buffer * @returns Deserialized comment */ function getComment(index) { if (!allCommentsDeserialized) { let comment = deserializeCommentIfNeeded(index); if (comment !== null) return deserializedCommentIndexes[deserializedCommentsLen++] = index, comment; } return cachedComments[index]; } /** * Deserialize comment at `index` if not already deserialized. * * Caller must ensure `initCommentsBuffer()` has been called before calling this function. * * @param index - Comment index in the comments buffer * @returns `Comment` object if newly deserialized, or `null` if already deserialized */ function deserializeCommentIfNeeded(index) { let pos = index << 4, flagPos = pos + 15; if (commentsUint8[flagPos] !== 0) return null; commentsUint8[flagPos] = 1; let comment = cachedComments[index], isBlock = commentsUint8[pos + 12] !== 0, pos32 = pos >> 2, start = commentsInt32[pos32], end = commentsInt32[pos32 + 1]; return comment.type = isBlock ? "Block" : "Line", comment.value = sourceText.slice(start + 2, end - (isBlock << 1)), comment.range[0] = comment.start = start, comment.range[1] = comment.end = end, comment; } /** * Reset comments after file has been linted. * * Clears cached `loc` on comments that had it accessed, so the getter * will recalculate it when the comment is reused for a different file. */ function resetComments() { if (commentsInt32 !== null) { if (allCommentsDeserialized === !1) { for (let i = 0; i < deserializedCommentsLen; i++) cachedComments[deserializedCommentIndexes[i]].value = null; deserializedCommentsLen = 0; } else { for (let i = 0; i < commentsLen; i++) cachedComments[i].value = null; allCommentsDeserialized = !1; } for (let i = 0; i < activeCommentsWithLocCount; i++) resetCommentLoc(commentsWithLoc[i]); activeCommentsWithLocCount = 0, comments = null, commentsUint8 = null, commentsInt32 = null, commentsLen = 0; } } //#endregion //#region src-js/generated/deserialize.js let uint8, int32, float64, sourceText$1, sourceTextLatin, sourceStartPos$1 = 0, firstNonAsciiPos = 0, parent = null; const { fromCharCode } = String, { utf8Slice: utf8Slice$1, latin1Slice } = Buffer.prototype, stringDecodeArrays = Array(65).fill(null); for (let i = 0; i <= 64; i++) stringDecodeArrays[i] = Array(i).fill(0); const NodeProto = ObjectCreate(ObjectPrototype, { loc: { get() { return getNodeLoc(this); }, enumerable: !0 } }); function deserializeProgramOnly(buffer, sourceText, sourceStartPos, sourceByteLen) { return deserializeWith(buffer, sourceText, sourceStartPos, sourceByteLen, deserializeProgram); } function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) { if (uint8 = buffer, int32 = buffer.int32, float64 = buffer.float64, sourceText$1 = sourceTextInput, sourceStartPos$1 = sourceStartPosInput, sourceText$1.length === sourceByteLen) firstNonAsciiPos = sourceStartPos$1 + sourceByteLen, sourceTextLatin = sourceText$1; else { let i = sourceStartPos$1, sourceEndPos = sourceStartPos$1 + sourceByteLen; for (; i < sourceEndPos && uint8[i] < 128; i++); firstNonAsciiPos = i, sourceTextLatin = latin1Slice.call(uint8, sourceStartPos$1, sourceEndPos); } let data = deserialize(int32[536870890]); return resetBuffer(), data; } function resetBuffer() { uint8 = int32 = float64 = sourceText$1 = sourceTextLatin = void 0; } function deserializeProgram(pos) { let end = deserializeI32(pos + 4), program = parent = { __proto__: NodeProto, type: "Program", body: null, sourceType: deserializeModuleKind(pos + 137), get comments() { return comments === null && initComments(), comments; }, get tokens() { return tokens === null && initTokens(), tokens; }, start: 0, end, range: [0, end], parent: null }, body = program.body = deserializeVecDirective(pos + 88); body.push(...deserializeVecStatement(pos + 112)); { let start; if (body.length > 0) { let first = body[0]; if (start = first.start, first.type === "ExportNamedDeclaration" || first.type === "ExportDefaultDeclaration") { let { declaration } = first; if (declaration !== null && declaration.type === "ClassDeclaration" && declaration.decorators.length > 0) { let decoratorStart = declaration.decorators[0].start; decoratorStart < start && (start = decoratorStart); } } } else start = end; program.start = program.range[0] = start; } return parent = null, program; } function deserializeExpression(pos) { switch (uint8[pos]) { case 0: return deserializeBoxBooleanLiteral(pos + 8); case 1: return deserializeBoxNullLiteral(pos + 8); case 2: return deserializeBoxNumericLiteral(pos + 8); case 3: return deserializeBoxBigIntLiteral(pos + 8); case 4: return deserializeBoxRegExpLiteral(pos + 8); case 5: return deserializeBoxStringLiteral(pos + 8); case 6: return deserializeBoxTemplateLiteral(pos + 8); case 7: return deserializeBoxIdentifierReference(pos + 8); case 8: return deserializeBoxMetaProperty(pos + 8); case 9: return deserializeBoxSuper(pos + 8); case 10: return deserializeBoxArrayExpression(pos + 8); case 11: return deserializeBoxArrowFunctionExpression(pos + 8); case 12: return deserializeBoxAssignmentExpression(pos + 8); case 13: return deserializeBoxAwaitExpression(pos + 8); case 14: return deserializeBoxBinaryExpression(pos + 8); case 15: return deserializeBoxCallExpression(pos + 8); case 16: return deserializeBoxChainExpression(pos + 8); case 17: return deserializeBoxClass(pos + 8); case 18: return deserializeBoxConditionalExpression(pos + 8); case 19: return deserializeBoxFunction(pos + 8); case 20: return deserializeBoxImportExpression(pos + 8); case 21: return deserializeBoxLogicalExpression(pos + 8); case 22: return deserializeBoxNewExpression(pos + 8); case 23: return deserializeBoxObjectExpression(pos + 8); case 24: return deserializeBoxParenthesizedExpression(pos + 8); case 25: return deserializeBoxSequenceExpression(pos + 8); case 26: return deserializeBoxTaggedTemplateExpression(pos + 8); case 27: return deserializeBoxThisExpression(pos + 8); case 28: return deserializeBoxUnaryExpression(pos + 8); case 29: return deserializeBoxUpdateExpression(pos + 8); case 30: return deserializeBoxYieldExpression(pos + 8); case 31: return deserializeBoxPrivateInExpression(pos + 8); case 32: return deserializeBoxJSXElement(pos + 8); case 33: return deserializeBoxJSXFragment(pos + 8); case 34: return deserializeBoxTSAsExpression(pos + 8); case 35: return deserializeBoxTSSatisfiesExpression(pos + 8); case 36: return deserializeBoxTSTypeAssertion(pos + 8); case 37: return deserializeBoxTSNonNullExpression(pos + 8); case 38: return deserializeBoxTSInstantiationExpression(pos + 8); case 39: return deserializeBoxV8IntrinsicExpression(pos + 8); case 48: return deserializeBoxComputedMemberExpression(pos + 8); case 49: return deserializeBoxStaticMemberExpression(pos + 8); case 50: return deserializeBoxPrivateFieldExpression(pos + 8); default: throw Error(`Unexpected discriminant ${uint8[pos]} for Expression`); } } function deserializeIdentifierName(pos) { let start, end; return { __proto__: NodeProto, type: "Identifier", decorators: [], name: deserializeStr(pos + 16), optional: !1, typeAnnotation: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; } function deserializeIdentifierReference(pos) { let start, end; return { __proto__: NodeProto, type: "Identifier", decorators: [], name: deserializeStr(pos + 16), optional: !1, typeAnnotation: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; } function deserializeBindingIdentifier(pos) { let start, end; return { __proto__: NodeProto, type: "Identifier", decorators: [], name: deserializeStr(pos + 16), optional: !1, typeAnnotation: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; } function deserializeLabelIdentifier(pos) { let start, end; return { __proto__: NodeProto, type: "Identifier", decorators: [], name: deserializeStr(pos + 16), optional: !1, typeAnnotation: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; } function deserializeThisExpression(pos) { let start, end; return { __proto__: NodeProto, type: "ThisExpression", start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; } function deserializeArrayExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "ArrayExpression", elements: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.elements = deserializeVecArrayExpressionElement(pos + 16), parent = previousParent, node; } function deserializeArrayExpressionElement(pos) { switch (uint8[pos]) { case 0: return deserializeBoxBooleanLiteral(pos + 8); case 1: return deserializeBoxNullLiteral(pos + 8); case 2: return deserializeBoxNumericLiteral(pos + 8); case 3: return deserializeBoxBigIntLiteral(pos + 8); case 4: return deserializeBoxRegExpLiteral(pos + 8); case 5: return deserializeBoxStringLiteral(pos + 8); case 6: return deserializeBoxTemplateLiteral(pos + 8); case 7: return deserializeBoxIdentifierReference(pos + 8); case 8: return deserializeBoxMetaProperty(pos + 8); case 9: return deserializeBoxSuper(pos + 8); case 10: return deserializeBoxArrayExpression(pos + 8); case 11: return deserializeBoxArrowFunctionExpression(pos + 8); case 12: return deserializeBoxAssignmentExpression(pos + 8); case 13: return deserializeBoxAwaitExpression(pos + 8); case 14: return deserializeBoxBinaryExpression(pos + 8); case 15: return deserializeBoxCallExpression(pos + 8); case 16: return deserializeBoxChainExpression(pos + 8); case 17: return deserializeBoxClass(pos + 8); case 18: return deserializeBoxConditionalExpression(pos + 8); case 19: return deserializeBoxFunction(pos + 8); case 20: return deserializeBoxImportExpression(pos + 8); case 21: return deserializeBoxLogicalExpression(pos + 8); case 22: return deserializeBoxNewExpression(pos + 8); case 23: return deserializeBoxObjectExpression(pos + 8); case 24: return deserializeBoxParenthesizedExpression(pos + 8); case 25: return deserializeBoxSequenceExpression(pos + 8); case 26: return deserializeBoxTaggedTemplateExpression(pos + 8); case 27: return deserializeBoxThisExpression(pos + 8); case 28: return deserializeBoxUnaryExpression(pos + 8); case 29: return deserializeBoxUpdateExpression(pos + 8); case 30: return deserializeBoxYieldExpression(pos + 8); case 31: return deserializeBoxPrivateInExpression(pos + 8); case 32: return deserializeBoxJSXElement(pos + 8); case 33: return deserializeBoxJSXFragment(pos + 8); case 34: return deserializeBoxTSAsExpression(pos + 8); case 35: return deserializeBoxTSSatisfiesExpression(pos + 8); case 36: return deserializeBoxTSTypeAssertion(pos + 8); case 37: return deserializeBoxTSNonNullExpression(pos + 8); case 38: return deserializeBoxTSInstantiationExpression(pos + 8); case 39: return deserializeBoxV8IntrinsicExpression(pos + 8); case 48: return deserializeBoxComputedMemberExpression(pos + 8); case 49: return deserializeBoxStaticMemberExpression(pos + 8); case 50: return deserializeBoxPrivateFieldExpression(pos + 8); case 64: return deserializeBoxSpreadElement(pos + 8); case 65: return deserializeBoxElision(pos + 8); default: throw Error(`Unexpected discriminant ${uint8[pos]} for ArrayExpressionElement`); } } function deserializeElision(pos) { return null; } function deserializeObjectExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "ObjectExpression", properties: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.properties = deserializeVecObjectPropertyKind(pos + 16), parent = previousParent, node; } function deserializeObjectPropertyKind(pos) { switch (uint8[pos]) { case 0: return deserializeBoxObjectProperty(pos + 8); case 1: return deserializeBoxSpreadElement(pos + 8); default: throw Error(`Unexpected discriminant ${uint8[pos]} for ObjectPropertyKind`); } } function deserializeObjectProperty(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "Property", kind: deserializePropertyKind(pos + 12), key: null, value: null, method: deserializeBool(pos + 13), shorthand: deserializeBool(pos + 14), computed: deserializeBool(pos + 15), optional: !1, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.key = deserializePropertyKey(pos + 16), node.value = deserializeExpression(pos + 32), parent = previousParent, node; } function deserializePropertyKey(pos) { switch (uint8[pos]) { case 0: return deserializeBoxBooleanLiteral(pos + 8); case 1: return deserializeBoxNullLiteral(pos + 8); case 2: return deserializeBoxNumericLiteral(pos + 8); case 3: return deserializeBoxBigIntLiteral(pos + 8); case 4: return deserializeBoxRegExpLiteral(pos + 8); case 5: return deserializeBoxStringLiteral(pos + 8); case 6: return deserializeBoxTemplateLiteral(pos + 8); case 7: return deserializeBoxIdentifierReference(pos + 8); case 8: return deserializeBoxMetaProperty(pos + 8); case 9: return deserializeBoxSuper(pos + 8); case 10: return deserializeBoxArrayExpression(pos + 8); case 11: return deserializeBoxArrowFunctionExpression(pos + 8); case 12: return deserializeBoxAssignmentExpression(pos + 8); case 13: return deserializeBoxAwaitExpression(pos + 8); case 14: return deserializeBoxBinaryExpression(pos + 8); case 15: return deserializeBoxCallExpression(pos + 8); case 16: return deserializeBoxChainExpression(pos + 8); case 17: return deserializeBoxClass(pos + 8); case 18: return deserializeBoxConditionalExpression(pos + 8); case 19: return deserializeBoxFunction(pos + 8); case 20: return deserializeBoxImportExpression(pos + 8); case 21: return deserializeBoxLogicalExpression(pos + 8); case 22: return deserializeBoxNewExpression(pos + 8); case 23: return deserializeBoxObjectExpression(pos + 8); case 24: return deserializeBoxParenthesizedExpression(pos + 8); case 25: return deserializeBoxSequenceExpression(pos + 8); case 26: return deserializeBoxTaggedTemplateExpression(pos + 8); case 27: return deserializeBoxThisExpression(pos + 8); case 28: return deserializeBoxUnaryExpression(pos + 8); case 29: return deserializeBoxUpdateExpression(pos + 8); case 30: return deserializeBoxYieldExpression(pos + 8); case 31: return deserializeBoxPrivateInExpression(pos + 8); case 32: return deserializeBoxJSXElement(pos + 8); case 33: return deserializeBoxJSXFragment(pos + 8); case 34: return deserializeBoxTSAsExpression(pos + 8); case 35: return deserializeBoxTSSatisfiesExpression(pos + 8); case 36: return deserializeBoxTSTypeAssertion(pos + 8); case 37: return deserializeBoxTSNonNullExpression(pos + 8); case 38: return deserializeBoxTSInstantiationExpression(pos + 8); case 39: return deserializeBoxV8IntrinsicExpression(pos + 8); case 48: return deserializeBoxComputedMemberExpression(pos + 8); case 49: return deserializeBoxStaticMemberExpression(pos + 8); case 50: return deserializeBoxPrivateFieldExpression(pos + 8); case 64: return deserializeBoxIdentifierName(pos + 8); case 65: return deserializeBoxPrivateIdentifier(pos + 8); default: throw Error(`Unexpected discriminant ${uint8[pos]} for PropertyKey`); } } function deserializePropertyKind(pos) { switch (uint8[pos]) { case 0: return "init"; case 1: return "get"; case 2: return "set"; default: throw Error(`Unexpected discriminant ${uint8[pos]} for PropertyKind`); } } function deserializeTemplateLiteral(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "TemplateLiteral", quasis: null, expressions: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.quasis = deserializeVecTemplateElement(pos + 16), node.expressions = deserializeVecExpression(pos + 40), parent = previousParent, node; } function deserializeTaggedTemplateExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "TaggedTemplateExpression", tag: null, typeArguments: null, quasi: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.tag = deserializeExpression(pos + 16), node.typeArguments = deserializeOptionBoxTSTypeParameterInstantiation(pos + 32), node.quasi = deserializeTemplateLiteral(pos + 40), parent = previousParent, node; } function deserializeTemplateElement(pos) { let tail = deserializeBool(pos + 12), start = deserializeI32(pos) - 1, end = deserializeI32(pos + 4) + 2 - tail, value = deserializeTemplateElementValue(pos + 16); return value.cooked !== null && deserializeBool(pos + 13) && (value.cooked = value.cooked.replace(/\uFFFD(.{4})/g, (_, hex) => StringFromCodePoint(parseInt(hex, 16)))), { __proto__: NodeProto, type: "TemplateElement", value, tail, start, end, range: [start, end], parent }; } function deserializeTemplateElementValue(pos) { return { raw: deserializeStr(pos), cooked: deserializeOptionStr(pos + 16) }; } function deserializeComputedMemberExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "MemberExpression", object: null, property: null, optional: deserializeBool(pos + 12), computed: !0, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.object = deserializeExpression(pos + 16), node.property = deserializeExpression(pos + 32), parent = previousParent, node; } function deserializeStaticMemberExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "MemberExpression", object: null, property: null, optional: deserializeBool(pos + 12), computed: !1, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.object = deserializeExpression(pos + 16), node.property = deserializeIdentifierName(pos + 32), parent = previousParent, node; } function deserializePrivateFieldExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "MemberExpression", object: null, property: null, optional: deserializeBool(pos + 12), computed: !1, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.object = deserializeExpression(pos + 16), node.property = deserializePrivateIdentifier(pos + 32), parent = previousParent, node; } function deserializeCallExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "CallExpression", callee: null, typeArguments: null, arguments: null, optional: deserializeBool(pos + 12), start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.callee = deserializeExpression(pos + 16), node.typeArguments = deserializeOptionBoxTSTypeParameterInstantiation(pos + 32), node.arguments = deserializeVecArgument(pos + 40), parent = previousParent, node; } function deserializeNewExpression(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "NewExpression", callee: null, typeArguments: null, arguments: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.callee = deserializeExpression(pos + 16), node.typeArguments = deserializeOptionBoxTSTypeParameterInstantiation(pos + 32), node.arguments = deserializeVecArgument(pos + 40), parent = previousParent, node; } function deserializeMetaProperty(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "MetaProperty", meta: null, property: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.meta = deserializeIdentifierName(pos + 16), node.property = deserializeIdentifierName(pos + 48), parent = previousParent, node; } function deserializeSpreadElement(pos) { let start, end, previousParent = parent, node = parent = { __proto__: NodeProto, type: "SpreadElement", argument: null, start: start = deserializeI32(pos), end: end = deserializeI32(pos + 4), range: [start, end], parent }; return node.argument = deserializeExpression(pos + 16), parent = previousParent, node; } function deserializeArgument(pos) { switch (uint8[pos]) { case 0: return deserializeBoxBooleanLiteral(pos + 8); case 1: return deserializeBoxNullLiteral(pos + 8); case 2: return deserializeBoxNumericLiteral(pos + 8); case 3: return deserializeBoxBigIntLiteral(pos + 8); case 4: return deserializeBoxRegExpLiteral(pos + 8); case 5: return deserializeBoxStringLiteral(pos + 8); case 6: return deserializeBoxTemplateLiteral(pos + 8); case 7: return deserializeBoxIdentifierReference(pos + 8); case 8: return deserialize