import { Expression, ModuleItem, StringLiteral, TemplateElement, TemplateLiteral } from "@swc/core"; import Visitor from "@swc/core/Visitor"; /** * Traverses an AST (or parts of it) to collect all StringLiterals and TemplateElements that contain * needle in their value. */ export declare class StringCollector extends Visitor { matchingStrings: (StringLiteral | TemplateElement)[]; private readonly needle; constructor(needle: string); visitStringLiteral(n: StringLiteral): StringLiteral; visitTemplateLiteral(n: TemplateLiteral): Expression; } /** * Represents a string as bytes, so it can be sliced via * byte-positions. */ export declare class StringAsBytes { private string; private decoder; constructor(string: string); /** * Returns a slice of the string by providing byte indices. * @param from - Byte index to slice from * @param to - Optional byte index to slice to */ slice(from: number, to?: number): string; } /** * Parses js code into a AST. * @param code */ export declare function parseCode(code: string): Promise<[number, ModuleItem[]]>; /** * Returns an array of StringLiterals and TemplateElements from an AST that contain needle in their value. * @param needle * @param ast */ export declare function collectMatchingStrings(needle: string, ast: ModuleItem[]): (StringLiteral | TemplateElement)[];