import { EncodedSourceMap } from '@jridgewell/trace-mapping';
import { TemplateNode } from 'svelte/types/compiler/interfaces';
import { IExportedNames } from 'svelte2tsx';
import ts from 'typescript';
import { Position, Range, TextDocumentContentChangeEvent } from 'vscode-languageserver';
import { Document, DocumentMapper, IdentityMapper, TagInformation, FilePosition } from '../../lib/documents';
import { SvelteNode, SvelteNodeWalker } from './svelte-ast-utils';
/**
 * Computes the change range between two snapshots by scanning for the first and last
 * differing characters. This allows TypeScript to do incremental re-parsing instead of
 * a full reparse when a snapshot changes.
 */
export declare function computeChangeRange(oldText: string, newText: string): ts.TextChangeRange;
/**
 * An error which occurred while trying to parse/preprocess the svelte file contents.
 */
export interface ParserError {
    message: string;
    range: Range;
    code: number;
}
/**
 * Initial version of snapshots.
 */
export declare const INITIAL_VERSION = 0;
/**
 * A document snapshot suitable for the ts language service and the plugin.
 * Can be a real ts/js file or a virtual ts/js file which is generated from a Svelte file.
 */
export interface DocumentSnapshot extends ts.IScriptSnapshot, DocumentMapper {
    version: number;
    filePath: string;
    scriptKind: ts.ScriptKind;
    scriptInfo: TagInformation | null;
    positionAt(offset: number): Position;
    offsetAt(position: Position): number;
    /**
     * Convenience function for getText(0, getLength())
     */
    getFullText(): string;
    isOpenedInClient(): boolean;
}
/**
 * Options that apply to svelte files.
 */
export interface SvelteSnapshotOptions {
    parse: typeof import('svelte/compiler').parse | undefined;
    version: string | undefined;
    transformOnTemplateError: boolean;
    typingsNamespace: string;
    emitJsDoc?: boolean;
    rewriteExternalImports?: {
        workspacePath: string;
        generatedPath: string;
    };
}
export declare namespace DocumentSnapshot {
    /**
     * Returns a svelte snapshot from a svelte document.
     * @param document the svelte document
     * @param options options that apply to the svelte document
     */
    function fromDocument(document: Document, options: SvelteSnapshotOptions): SvelteDocumentSnapshot;
    /**
     * Returns a svelte or ts/js snapshot from a file path, depending on the file contents.
     * @param filePath path to the js/ts/svelte file
     * @param createDocument function that is used to create a document in case it's a Svelte file
     * @param options options that apply in case it's a svelte file
     */
    function fromFilePath(filePath: string, createDocument: (filePath: string, text: string) => Document, options: SvelteSnapshotOptions, tsSystem: ts.System): SvelteDocumentSnapshot | JSOrTSDocumentSnapshot;
    /**
     * Returns a ts/js snapshot from a file path.
     * @param filePath path to the js/ts file
     * @param options options that apply in case it's a svelte file
     */
    function fromNonSvelteFilePath(filePath: string, tsSystem: ts.System): JSOrTSDocumentSnapshot;
    /**
     * Returns a svelte snapshot from a file path.
     * @param filePath path to the svelte file
     * @param createDocument function that is used to create a document
     * @param options options that apply in case it's a svelte file
     */
    function fromSvelteFilePath(filePath: string, createDocument: (filePath: string, text: string) => Document, options: SvelteSnapshotOptions, tsSystem: ts.System): SvelteDocumentSnapshot;
}
/**
 * A svelte document snapshot suitable for the TS language service and the plugin.
 * It contains the generated code (Svelte->TS/JS) so the TS language service can understand it.
 */
export declare class SvelteDocumentSnapshot implements DocumentSnapshot {
    readonly parent: Document;
    readonly parserError: ParserError | null;
    readonly scriptKind: ts.ScriptKind;
    readonly svelteVersion: string | undefined;
    private readonly text;
    private readonly nrPrependedLines;
    private readonly exportedNames;
    private readonly tsxMap?;
    private readonly htmlAst?;
    private mapper?;
    private lineOffsets?;
    private url;
    version: number;
    isSvelte5Plus: boolean;
    constructor(parent: Document, parserError: ParserError | null, scriptKind: ts.ScriptKind, svelteVersion: string | undefined, text: string, nrPrependedLines: number, exportedNames: IExportedNames, tsxMap?: EncodedSourceMap | undefined, htmlAst?: TemplateNode | undefined);
    get filePath(): string;
    get scriptInfo(): TagInformation | null;
    get moduleScriptInfo(): TagInformation | null;
    getOriginalText(range?: Range): string;
    getText(start: number, end: number): string;
    getLength(): number;
    getFullText(): string;
    getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange | undefined;
    positionAt(offset: number): Position;
    offsetAt(position: Position): number;
    getLineContainingOffset(offset: number): string;
    hasProp(name: string): boolean;
    svelteNodeAt(positionOrOffset: number | Position): SvelteNode | null;
    walkSvelteAst(walker: SvelteNodeWalker): void;
    getOriginalPosition(pos: Position): Position;
    getGeneratedPosition(pos: Position): Position;
    isInGenerated(pos: Position): boolean;
    getURL(): string;
    isOpenedInClient(): boolean;
    private getLineOffsets;
    private getMapper;
    private initMapper;
}
/**
 * A js/ts document snapshot suitable for the ts language service and the plugin.
 * Since no mapping has to be done here, it also implements the mapper interface.
 * If it's a SvelteKit file (e.g. +page.ts), types will be auto-added if not explicitly typed.
 */
export declare class JSOrTSDocumentSnapshot extends IdentityMapper implements DocumentSnapshot {
    version: number;
    readonly filePath: string;
    private text;
    private openedByClient;
    scriptKind: ts.ScriptKind;
    scriptInfo: null;
    originalText: string;
    kitFile: boolean;
    private lineOffsets?;
    private internalLineOffsets?;
    private addedCode;
    private paramsPath;
    private serverHooksPath;
    private clientHooksPath;
    private universalHooksPath;
    isOpenedInClient(): boolean;
    constructor(version: number, filePath: string, text: string, openedByClient?: boolean);
    getText(start: number, end: number): string;
    getLength(): number;
    getFullText(): string;
    getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange;
    positionAt(offset: number): Position;
    offsetAt(position: Position): number;
    getGeneratedPosition(originalPosition: Position): Position;
    getOriginalPosition(generatedPosition: Position): Position;
    update(changes: TextDocumentContentChangeEvent[]): JSOrTSDocumentSnapshot;
    protected getLineOffsets(): number[];
    private originalOffsetAt;
    private originalPositionAt;
    private getOriginalLineOffsets;
    private adjustText;
    private createSource;
}
export declare class DtsDocumentSnapshot extends JSOrTSDocumentSnapshot implements DocumentMapper {
    private tsSys;
    private traceMap;
    private mapperInitialized;
    constructor(version: number, filePath: string, text: string, tsSys: ts.System);
    getOriginalFilePosition(generatedPosition: Position): FilePosition;
    private initMapper;
    private initMapperByRawSourceMap;
    private logFailedToResolveSourceMap;
}
