import { NgtscProgram } from '@angular/compiler-cli'; import * as ts from 'typescript'; import { Plugin } from 'vite'; import { EmitFileResult } from './models.js'; import { FileReplacement } from './plugins/file-replacements.plugin.js'; export declare enum DiagnosticModes { None = 0, Option = 1, Syntactic = 2, Semantic = 4, All = 7 } export interface PluginOptions { tsconfig?: string | (() => string); workspaceRoot?: string; inlineStylesExtension?: string; jit?: boolean; advanced?: { /** * Custom TypeScript transformers that are run before Angular compilation */ tsTransformers?: ts.CustomTransformers; }; supportedBrowsers?: string[]; transformFilter?: (code: string, id: string) => boolean; /** * Additional files to include in compilation */ include?: string[]; additionalContentDirs?: string[]; liveReload?: boolean; disableTypeChecking?: boolean; fileReplacements?: FileReplacement[]; /** * Opt into the fast compile path. Skips Angular's template type-checking * and routes compilation through an internal single-pass transform. * Defaults to `false`. */ fastCompile?: boolean; /** * Compilation output mode used when `fastCompile` is enabled. * - `'full'` (default): Emit final Ivy definitions for application builds. * - `'partial'`: Emit partial declarations for library publishing. */ fastCompileMode?: 'full' | 'partial'; experimental?: { useAngularCompilationAPI?: boolean; }; } /** * Subset of the esbuild-style `PartialMessage` that `@angular/build`'s * `diagnoseFiles()` returns. Only the fields the plugin reads are modeled. */ export interface AngularDiagnostic { text?: string; location?: { file?: string; line?: number; column?: number; } | null; } export declare function angular(options?: PluginOptions): Plugin[]; export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise): () => Promise; /** * Convert Analog/Angular CLI-style file replacements into the flat record * expected by `AngularHostOptions.fileReplacements`. * * Only browser replacements (`{ replace, with }`) are converted. SSR-only * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to * handle — they should not be baked into the Angular compilation host because * that would apply them to both browser and server builds. * * Relative paths are resolved against `workspaceRoot` so that the host * receives the same absolute paths it would get from the Angular CLI. */ export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record | undefined; /** * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`) * back to absolute file paths with their associated HMR code and component * class name. * * Angular's private Compilation API emits template update keys in the form * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve * them so the caller can look up updates by the same normalized absolute path * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.). */ /** * Group `@angular/build` `diagnoseFiles()` diagnostics by the source file they * point at, folding the esbuild-style `location` into each message as * `file:line:column`. Diagnostics without a file location are collected into * the `globalErrors` / `globalWarnings` buckets. * * Grouping lets the caller attach each diagnostic to its own emitted file so it * is reported exactly once, rather than duplicating the whole global list * across every emitted file (the N×M explosion in #2317). */ export declare function groupDiagnosticsByFile(diagnostics: { errors?: AngularDiagnostic[]; warnings?: AngularDiagnostic[]; }): { errorsByFile: Map; warningsByFile: Map; globalErrors: string[]; globalWarnings: string[]; }; export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap | undefined): Map; /** * Flatten the per-file diagnostics accumulated on the emitted output files * into a single list of error and warning strings. * * Each {@link EmitFileResult} carries the diagnostics for its own source file * (populated as the file is emitted). The build-mode `buildEnd` hook drains * them here so it can report every file's diagnostics together instead of * throwing on the first errored file — which would otherwise abort the build * before the remaining files are ever checked. */ export declare function collectEmittedDiagnostics(outputFiles: Map): { errors: string[]; warnings: string[]; }; /** * Format a TypeScript/Angular diagnostic as `file:line:column: message`. * * This mirrors the Compilation API path's `groupDiagnosticsByFile` output so * both compilation paths report diagnostics in the same shape — the default * path previously discarded the location and emitted only the message text. * Line/column are 1-based (matching `tsc` and editor gutters). Diagnostics * without a source location (program-wide / option diagnostics) fall back to * the bare flattened message. */ export declare function formatDiagnosticWithLocation(diagnostic: ts.Diagnostic): string; export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram['compiler'], liveReload?: boolean, disableTypeChecking?: boolean): (file: string) => { errors?: undefined; warnings?: undefined; hmrUpdateCode?: undefined; hmrEligible?: undefined; } | { errors: string[]; warnings: string[]; hmrUpdateCode: string | null | undefined; hmrEligible: boolean; }; /** * Checks for vitest run from the command line * @returns boolean */ export declare function isTestWatchMode(args?: string[]): boolean;