@glint/core
Version:
A CLI for performing typechecking on Glimmer templates
52 lines (51 loc) • 2.23 kB
TypeScript
import { GlintConfig } from '../config/index.js';
export declare type Document = {
/** A unique identifier shared by all possible paths that may point to a document. */
id: string;
/** The "true" path where this document's source of truth can be found. */
canonicalPath: string;
/** Incremented each time the contents of a document changes (used by TS itself). */
version: number;
/** The current string contents of this document. */
contents: string;
/**
* Whether this document is a placeholder for something that might exist, or has actually
* been read from disk or opened in an editor.
*/
speculative: boolean;
/** Whether this document has changed on disk since the last time we read it. */
stale: boolean;
};
/**
* A read-through cache for workspace document contents.
*
* Via the Glint configuration it's instantiated with, this cache is aware
* of two things:
* - the relationship between companion script and template files, treating
* a change to one member of such pairs as affecting the version of both
* - the existence of custom extensions that would result in multiple
* potential on-disk paths corresponding to a single logical TS module,
* where one path must win out.
*/
export default class DocumentCache {
private glintConfig;
private readonly documents;
private readonly ts;
constructor(glintConfig: GlintConfig);
getDocumentID(path: string): string;
getCanonicalDocumentPath(path: string): string;
documentExists(path: string): boolean;
getCandidateDocumentPaths(filename: string): Array<string>;
getCompanionDocumentPath(path: string): string | undefined;
getDocumentContents(path: string, encoding?: string): string;
getCompoundDocumentVersion(path: string): string;
getDocumentVersion(path: string): string;
updateDocument(path: string, contents: string): void;
markDocumentStale(path: string): void;
removeDocument(path: string): void;
private incrementCompanionVersion;
private findCompanionDocument;
private getDocument;
private getCandidateExtensions;
}
export declare function templatePathForSynthesizedModule(path: string): string;