import ts from 'typescript'; import { PublishDiagnosticsParams, RelativePattern, TextDocumentContentChangeEvent } from 'vscode-languageserver'; import { Document, DocumentManager } from '../../lib/documents'; import { LSConfigManager } from '../../ls-config'; import { DocumentSnapshot, SvelteDocumentSnapshot } from './DocumentSnapshot'; import { LanguageServiceContainer } from './service'; interface LSAndTSDocResolverOptions { notifyExceedSizeLimit?: () => void; /** * True, if used in the context of svelte-check */ isSvelteCheck?: boolean; /** * This should only be set via svelte-check. Makes sure all documents are resolved to that tsconfig. Has to be absolute. */ tsconfigPath?: string; onProjectReloaded?: () => void; reportConfigError?: (diagnostic: PublishDiagnosticsParams) => void; watch?: boolean; tsSystem?: ts.System; watchDirectory?: (patterns: RelativePattern[]) => void; nonRecursiveWatchPattern?: string; /** * Optional callback invoked when a new snapshot is created. * Passes the absolute file path of the created snapshot. * Consumers (like svelte-check) can derive the directory as needed. */ onFileSnapshotCreated?: (filePath: string) => void; } export declare class LSAndTSDocResolver { private readonly docManager; private readonly workspaceUris; private readonly configManager; private readonly options?; constructor(docManager: DocumentManager, workspaceUris: string[], configManager: LSConfigManager, options?: LSAndTSDocResolverOptions | undefined); /** * Create a svelte document -> should only be invoked with svelte files. */ private createDocument; private tsSystem; private globalSnapshotsManager; private extendedConfigCache; private getCanonicalFileName; private userPreferencesAccessor; private readonly packageJsonWatchers; private lsDocumentContext; private readonly watchedDirectories; getLSAndTSDoc(document: Document): Promise<{ tsDoc: SvelteDocumentSnapshot; lang: ts.LanguageService; userPreferences: ts.UserPreferences; lsContainer: LanguageServiceContainer; }>; /** * Retrieves the LS for operations that don't need cross-files information. * can save some time by not synchronizing languageService program */ getLsForSyntheticOperations(document: Document): Promise<{ tsDoc: SvelteDocumentSnapshot; lang: ts.LanguageService; userPreferences: ts.UserPreferences; }>; private getLSAndTSDocWorker; /** * Retrieves and updates the snapshot for the given document or path from * the ts service it primarily belongs into. * The update is mirrored in all other services, too. */ getOrCreateSnapshot(document: Document): Promise; getOrCreateSnapshot(pathOrDoc: string | Document): Promise; private updateSnapshot; /** * Updates snapshot path in all existing ts services and retrieves snapshot */ updateSnapshotPath(oldPath: string, newPath: string): Promise; /** * Deletes snapshot in all existing ts services */ deleteSnapshot(filePath: string): Promise; invalidateModuleCache(filePaths: string[]): Promise; /** * Updates project files in all existing ts services */ updateProjectFiles(watcherNewFiles: string[]): Promise; /** * Updates file in all ts services where it exists */ updateExistingTsOrJsFile(path: string, changes?: TextDocumentContentChangeEvent[]): Promise; updateExistingSvelteFile(path: string): Promise; private updateExistingFile; getTSService(filePath?: string): Promise; getTSServiceByConfigPath(tsconfigPath: string, workspacePath: string): Promise; private getUserPreferences; private getTsUserPreferences; private wrapWithPackageJsonMonitoring; private onPackageJsonWatchChange; private updateSnapshotsInDirectory; private watchDirectory; } export {};