import { Diagnostic, TaglibLookup } from "@marko/compiler/babel-utils"; import { SourceMap } from "magic-string"; import * as types from "./babel-types"; export { types }; type _Config = typeof import("./config"); export interface Config extends _Config {} interface Dep { type: string; path: string; [x: string]: unknown; } interface VirtualDep { type: string; code: string; virtualPath: string; startPos?: number; endPos?: number; [x: string]: unknown; } /** * What a compile or tag lookup read beyond its template, as the absolute paths * that `taglib.invalidate` compares reported paths with. */ export interface Dependencies { /** Files whose content was read. */ readonly files: readonly string[]; /** Paths looked for and not found: one appearing changes the result. */ readonly missing: readonly string[]; /** * Directories read, with the entry names looked for, alone or with any extension * (`named` after the directory's name and a dot); none means every template and directory. */ readonly directories: readonly (readonly [ dir: string, names?: readonly string[], named?: readonly string[], ])[]; /** * What this builds on, shared rather than copied: an output's template, then * its directory's tag lookup, then the lookups above it. */ readonly parent: Dependencies | undefined; } export interface MarkoMeta { id: string; component?: string; /** What the compile read beyond the template's own source. */ dependencies: Dependencies; /** @deprecated Always empty: use `dependencies`. */ watchFiles: string[]; tags?: string[]; deps: Array; /** @deprecated Never set: use `dependencies`. */ analyzedTags?: [string, ...string[]]; diagnostics: Diagnostic[]; api: undefined | string; } // Each field follows the flag that produces it; an omitted flag may be set by // `configure`, so only `code` (on unless disabled) is assumed. export interface CompileResult { ast: C extends { ast: true } ? types.File : C extends { ast: false } ? null : types.File | null; code: C extends { code: false } ? null : string; map: C extends { code: false } ? null : C extends { sourceMaps: true | "both" } ? SourceMap : C extends { sourceMaps: false | "inline" } ? null : SourceMap | null; meta: MarkoMeta; } export const version: string; export const globalConfig: Config; export function configure(config: Config): void; export function compile( src: string, filename: string, config?: C, ): Promise>; export function compileSync( src: string, filename: string, config?: C, ): CompileResult; export function compileFile( filename: string, config?: C, ): Promise>; export function compileFileSync( filename: string, config?: C, ): CompileResult; export function getRuntimeEntryFiles( output: string, translator?: string | undefined, ): string[]; export function getRuntimeVersion(translator?: unknown): string; export namespace taglib { export function resolveOptionalTaglibs( taglibIds: string[], ): [id: string, props: { [x: string]: unknown }][]; export function excludeDir(dirname: string): void; export function excludePackage(packageName: string): void; export function register(id: string): void; export function register(id: string, props: { [x: string]: unknown }): void; export function buildLookup( dirname: string, translator?: unknown, onError?: (err: Error) => void, /** Defaults to the configured `fileSystem`. */ fileSystem?: Config["fileSystem"], ): TaglibLookup; export function clearCaches(): void; /** * Marks stale the tag lookups and templates that read any of `paths` (changed, added or * removed), and drops from `cache` those compiled with it, failed or not, returning them. */ export function invalidate( paths: Iterable, cache?: Config["cache"], fileSystem?: Config["fileSystem"], ): string[]; /** * As `invalidate`, for each path read that changed on disk since (by modified * time), for a caller no watcher tells what changed. */ export function revalidate( cache?: Config["cache"], fileSystem?: Config["fileSystem"], ): string[]; /** * What the tag lookups of `dirnames` read with every tag loaded, as plain data * that `readDependencies` reads again in any process. */ export function getDependencies( dirnames: Iterable, translator?: unknown, onError?: (err: Error) => void, fileSystem?: Config["fileSystem"], ): Dependencies; /** * A digest of what `dependencies` describe as it is now (a non-negative * safe integer): equal digests mean what read them would read the same. */ export function readDependencies( dependencies: Dependencies, fileSystem?: Config["fileSystem"], ): number; }