/**
 * Tree-sitter parser initialization and utilities
 *
 * This module provides a universal parser that works in Node.js, browsers, and Workers.
 */
import { Parser, Language, Tree, Node } from 'web-tree-sitter';
export { Language, Tree };
export type { Node };
export type SyntaxNode = Node;
export type SupportedLanguage = 'java' | 'c' | 'cpp' | 'javascript' | 'typescript' | 'python' | 'rust' | 'bash' | 'html' | 'go';
interface ParserOptions {
    /**
     * Custom path/URL to the tree-sitter.wasm file.
     * In Node.js, defaults to the web-tree-sitter package location.
     * In browsers/workers, must be provided.
     */
    wasmPath?: string;
    /**
     * Pre-compiled WebAssembly.Module for tree-sitter.wasm.
     * Use this for Cloudflare Workers where dynamic WASM compilation is blocked.
     * Takes precedence over wasmPath when provided.
     */
    wasmModule?: WebAssembly.Module;
    /**
     * Custom paths/URLs to language grammar WASM files.
     * Key is the language name, value is the path/URL.
     */
    languagePaths?: Partial<Record<SupportedLanguage, string>>;
    /**
     * Pre-compiled WebAssembly.Module for language grammars.
     * Use this for Cloudflare Workers where dynamic WASM compilation is blocked.
     * Takes precedence over languagePaths when provided.
     */
    languageModules?: Partial<Record<SupportedLanguage, WebAssembly.Module>>;
}
/**
 * Initialize the Tree-sitter parser runtime.
 * Must be called before parsing any code.
 * Thread-safe: handles concurrent initialization attempts.
 */
export declare function initParser(options?: ParserOptions): Promise<void>;
/**
 * Load a language grammar for parsing.
 * Thread-safe: handles concurrent load attempts for the same language.
 */
export declare function loadLanguage(language: SupportedLanguage, wasmPath?: string): Promise<Language>;
/**
 * Get a parser instance configured for the specified language. The Parser is
 * cached per-language and reused across calls — see `cachedParsers` above.
 * Use `createFreshParser()` if you need a non-shared instance.
 */
export declare function createParser(language: SupportedLanguage): Promise<Parser>;
/**
 * Create a non-cached parser. Caller is responsible for `parser.delete()` when
 * done. Prefer `createParser` unless isolation is required.
 */
export declare function createFreshParser(language: SupportedLanguage): Promise<Parser>;
/**
 * Parse source code and return the syntax tree.
 *
 * IMPORTANT: The returned Tree holds memory in the tree-sitter WASM heap. Call
 * `disposeTree(tree)` once you no longer need its nodes to free that memory.
 * Failing to dispose causes unbounded WASM heap growth at scale (#16).
 */
export declare function parse(code: string, language: SupportedLanguage): Promise<Tree>;
/**
 * Free the WASM memory backing a parsed Tree. Safe to call multiple times.
 */
export declare function disposeTree(tree: Tree | null | undefined): void;
/**
 * Walk the syntax tree and call the visitor for each node.
 */
export declare function walkTree(node: Node, visitor: (node: Node) => void): void;
/**
 * Find all nodes of a specific type in the tree.
 */
export declare function findNodes(node: Node, type: string): Node[];
/**
 * Cached node collection from a single tree traversal.
 * Use this to avoid multiple traversals of the same tree.
 */
export type NodeCache = Map<string, Node[]>;
/**
 * Collect all nodes of specified types in a single tree traversal.
 * Much more efficient than calling findNodes multiple times.
 */
export declare function collectAllNodes(node: Node, types: Set<string>): NodeCache;
/**
 * Get nodes from cache, falling back to findNodes if not cached.
 */
export declare function getNodesFromCache(node: Node, type: string, cache?: NodeCache): Node[];
/**
 * Find the first ancestor of a node that matches the given type.
 */
export declare function findAncestor(node: Node, type: string): Node | null;
/**
 * Get the text of a node from the source code.
 */
export declare function getNodeText(node: Node): string;
/**
 * Check if the parser has been initialized.
 */
export declare function isInitialized(): boolean;
/**
 * Check if a language has been loaded.
 */
export declare function isLanguageLoaded(language: SupportedLanguage): boolean;
/**
 * Reset the parser state (mainly for testing).
 *
 * Disposes any cached Parser instances and clears the language cache so the
 * next `initParser()` call starts with a clean WASM heap.
 */
export declare function resetParser(): void;
//# sourceMappingURL=parser.d.ts.map