import { Language } from 'web-tree-sitter';
import type { TreeSitterLanguage } from './types.ts';
/** Thrown when downloaded WASM SHA-256 doesn't match the hardcoded manifest. */
export declare class GrammarSHAMismatchError extends Error {
    readonly language: TreeSitterLanguage;
    readonly expected: string;
    readonly actual: string;
    constructor(language: TreeSitterLanguage, expected: string, actual: string);
}
/** Thrown when a grammar can't be obtained: download failed AND cache empty. */
export declare class GrammarUnavailableError extends Error {
    readonly language: TreeSitterLanguage;
    readonly cause?: unknown;
    constructor(language: TreeSitterLanguage, cause?: unknown);
}
/**
 * Thrown when the cache path resolves to a symlink (or any non-regular
 * file). Pre-creating a symlink at the expected cache path is a known
 * vector for redirecting reads/writes elsewhere on the filesystem.
 * (Phase 3.5 finding #3 — symlink attack on cache dir.)
 */
export declare class GrammarCacheSymlinkError extends Error {
    readonly cachePath: string;
    constructor(cachePath: string);
}
/**
 * Thrown when a manifest URL is not HTTPS. The manifest is hardcoded in
 * source, but defense in depth: any future edit that introduces an http://
 * URL is rejected at load time, not at code review.
 * (Phase 3.5 finding #3 — MITM on download.)
 */
export declare class GrammarUrlNotHttpsError extends Error {
    readonly url: string;
    constructor(url: string);
}
interface ManifestEntry {
    url: string;
    sha256: string;
    version: string;
}
/**
 * Hardcoded grammar manifest. Source-code-resident; tampering requires a
 * release.
 *
 * Source: `tree-sitter-wasms` npm package (https://npm.im/tree-sitter-wasms)
 * — pre-built WASM binaries for Tree-sitter language parsers. NOT added as
 * a dependency (per plan §Phase 0 ban on bundling); fetched from unpkg at
 * first use. The individual `tree-sitter-<lang>` packages on npm do NOT
 * ship `.wasm` files, only C source + native .node prebuilds — confirmed
 * by inspecting unpkg `?meta` listings during Phase 9 release-prep.
 *
 * SHA-256 hashes computed 2026-04-28 via:
 *   curl -fsSL <url> | shasum -a 256
 *
 * The verification code path is exercised in `tree-sitter-loader.test.ts`
 * by injecting test manifest entries that intentionally mismatch.
 */
export declare const GRAMMAR_MANIFEST: Partial<Record<TreeSitterLanguage, ManifestEntry>>;
/** Test-injection hook: lets tests force eviction without writing a new grammar. */
export declare function _evictCacheForTest(retain?: number): void;
/**
 * `Parser.init()` is async and must be called once before any `new Parser()`.
 * This function is idempotent — repeated calls return the same promise.
 *
 * Test harnesses can mock this by stubbing `Parser.init`.
 */
export declare function ensureParserInitialized(): Promise<void>;
interface LoaderOptions {
    /**
     * Test-injection: override the manifest entry for a language. Production
     * callers leave this undefined; tests use it to exercise SHA-mismatch and
     * download-failure paths.
     */
    manifestOverride?: Partial<Record<TreeSitterLanguage, ManifestEntry>>;
    /**
     * Test-injection: override the fetch implementation. Defaults to global
     * `fetch`. Tests pass a mock that returns a fixed body or throws.
     */
    fetchImpl?: (url: string) => Promise<{
        ok: boolean;
        arrayBuffer: () => Promise<ArrayBuffer>;
        status?: number;
    }>;
}
/**
 * Lazy-load a Tree-sitter grammar. Only fetches/caches the grammar for
 * `language`; other languages are unaffected.
 *
 * Order:
 *   1. In-memory cache hit → return.
 *   2. Disk cache hit + SHA verify pass → load from disk.
 *   3. Disk cache hit + SHA mismatch → throw GrammarSHAMismatchError.
 *   4. Cache miss → fetch from pinned URL → SHA verify → atomic write → load.
 *   5. Fetch fails AND no cache → throw GrammarUnavailableError.
 */
export declare function loadGrammar(language: TreeSitterLanguage, options?: LoaderOptions): Promise<Language>;
/**
 * Test-only: clear in-memory loaded grammar cache. Disk cache persists.
 * Production code never needs this; the in-memory map lives for the process.
 */
export declare function __resetLoadedGrammars(): void;
export {};
