import { ObjectDictionary } from "@opticss/util"; import { ImportedCompiledCssFile, ImportedFile, Importer, NodeJsImporter, ResolvedConfiguration, Syntax } from "../../src"; export interface SourceWithSyntax { contents: string; syntax: Syntax; dfnContents?: string; dfnIdentifier?: string; hasEmbeddedDfnData?: boolean; } export declare type SourceRegistry = ObjectDictionary; export declare type ImportedFiles = ObjectDictionary; /** * A fake importer that behaves similar to the NodeJsImporter, but doesn't actually * read any files from the file system. */ export declare class MockImporter extends NodeJsImporter { registry: MockImportRegistry; constructor(registry: MockImportRegistry); identifier(fromFile: string | null, importPath: string, _options: ResolvedConfiguration): string; import(resolvedPath: string, configuration: ResolvedConfiguration): Promise; importSync(resolvedPath: string, configuration: ResolvedConfiguration): ImportedFile | ImportedCompiledCssFile; } /** * A registry of sources that the MockImporter can pull files from. When writing * integration or acceptance tests, you can use this to avoid interacting with the * file system directly. */ export declare class MockImportRegistry { sources: SourceRegistry; imported: ImportedFiles; /** * Register a source "file" that can be read by the MockImporter. * @param sourcePath - The filepath the source can be looked up from. * @param contents - The contents of the source. * @param syntax - The syntax/format of the source data. Defaults to CSS. * @param hasEmbeddedDfnData - Whether the source data includes embedded base64 definition data. Defaults to false. */ registerSource(sourcePath: string, contents: string, syntax?: Syntax, hasEmbeddedDfnData?: boolean): void; /** * Registers a Compiled CSS source "file" and its associated definition "file" that can both * be read by the MockImporter. * @param sourcePath - The filepath the Compiled CSS can be looked up from. * @param cssContents - The contents of the Compiled CSS. * @param dfnIdentifier - The filepath the definition data can be looked up from. * @param dfnContents - The contents of the definition data. */ registerCompiledCssSource(sourcePath: string, cssContents: string, dfnIdentifier: string, dfnContents: string): void; /** * Records that a particular source path has been imported. * @param sourcePath - The source path to record as imported. */ markImported(sourcePath: string): void; /** * Assers that a particular source path has been imported by the MockImporter. * @param sourcePath - The source path to assert was imported. */ assertImported(sourcePath: string): void; /** * Given an absolute path, generate the relative path, relative to the root of /core. * @param absolutePath - The absolute path to turn into a relative path. * @returns The relative path. */ relativize(absolutePath: string): string; /** * Generates a new MockImporter associated with this MockImportRegistry instance. * You can hand this importer off to other classes such as BlockFactory to import * mock "files" from this registry. * @returns The generated Importer instance. */ importer(): Importer; /** * Resets the sources and imported paths in this registry, without fully destroying * the MockImporter or this instance. */ reset(): void; } //# sourceMappingURL=MockImportRegistry.d.ts.map