import type { EcoBuildPlugin } from '../build/contracts/build-types.js'; import type { EcoPagesAppConfig, IClientBridge } from '../types/internal-types.js'; import { GENERATED_BASE_PATHS } from '../config/constants.js'; import type { RuntimeCapabilityDeclaration } from './runtime-capability.js'; export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js'; export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/contracts/build-types.js'; export declare const PROCESSOR_ERRORS: { readonly CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context"; }; export declare function mergeProcessorOptions(defaults: TDefaults, overrides: TOverrides): TDefaults & TOverrides; export declare function resolveGeneratedPath(type: keyof typeof GENERATED_BASE_PATHS, options: { root: string; module: string; subPath?: string; }): string; /** * Serializes the TypeScript `@types` package manifest for generated virtual-module declarations. */ export declare function serializeGeneratedTypesPackage(packageName: string): string; /** * Writes the generated `@types` package manifest that TypeScript auto-loads from `node_modules`. */ export declare function writeGeneratedTypesPackage(options: { root: string; module: string; packageName: string; writeFile: (filePath: string, content: string) => void; }): void; export interface ProcessorWatchContext { path: string; bridge: IClientBridge; } export interface ProcessorWatchConfig { paths: string[]; /** * File extensions that trigger watch callbacks (`onCreate`, `onChange`, `onDelete`). * * @remarks * Watch extensions drive notifications only. They do not declare asset ownership. * Ownership requires {@link ProcessorConfig.capabilities} and controls whether dev * invalidation skips server modules and HMR for processor-handled assets. */ extensions?: string[]; onCreate?: (ctx: ProcessorWatchContext) => Promise; onChange?: (ctx: ProcessorWatchContext) => Promise; onDelete?: (ctx: ProcessorWatchContext) => Promise; onError?: (error: Error) => void; } export type ProcessorAssetKind = 'script' | 'stylesheet' | 'image'; export type ProcessorExtensionPattern = string; export interface ProcessorAssetCapability { kind: ProcessorAssetKind; /** * Supported patterns: * - `*` (all extensions) * - `.css` or `css` * - `*.css` * - `*.{css,scss,sass}` * * Pattern matching is case-insensitive and trims surrounding spaces, * including grouped values (e.g. `*.{ CSS, ScSs }`). */ extensions?: ProcessorExtensionPattern[]; } export interface ProcessorConfig> { name: string; description?: string; options?: TOptions; watch?: ProcessorWatchConfig; capabilities?: ProcessorAssetCapability[]; runtimeCapability?: RuntimeCapabilityDeclaration; } export interface ProcessorContext { config: EcoPagesAppConfig; rootDir: string; srcDir: string; distDir: string; cache?: string; } /** * Base class for content and asset processors that contribute build plugins. * * @remarks * Processors declare plugins through two getters that map to * {@link AppBuildManifest} buckets (names differ from integrations): * * - `plugins` → `runtimePlugins` (server **and** browser builds) * - `buildPlugins` → `browserBundlePlugins` (browser bundles only) * * Virtual modules that must resolve during route-module transpile belong in * `plugins`. Browser-only bundler hooks belong in `buildPlugins`. */ export declare abstract class Processor> { readonly name: string; protected context?: ProcessorContext; protected options?: TOptions; protected watchConfig?: ProcessorWatchConfig; protected capabilities: ProcessorAssetCapability[]; readonly runtimeCapability?: RuntimeCapabilityDeclaration; /** * Browser-bundle-only plugins. * * @remarks * Maps to {@link AppBuildManifest.browserBundlePlugins}. Integrations name the * same bucket `browserBuildPlugins`. */ abstract buildPlugins?: EcoBuildPlugin[]; /** * Shared build plugins for server-oriented and browser-oriented work. * * @remarks * Maps to {@link AppBuildManifest.runtimePlugins}. Despite the name, these are * bundler plugins—not dev-server file processors. Runtime-only setup stays in * {@link setup}. */ abstract plugins?: EcoBuildPlugin[]; constructor(config: ProcessorConfig); setContext(appConfig: EcoPagesAppConfig): void; /** * Prepares build-facing processor contributions before config finalization. * * @remarks * Override this when a processor must compute runtime/build plugins or other * manifest-owned state before startup. Runtime-only work such as cache * warming or watcher registration should stay in `setup()`. */ prepareBuildContributions(): Promise; /** * Declares watch-mode SSR prewarm pathnames and readiness for core. * * @remarks * Processors return paths and readiness only; core owns parallel rendering and page cache population. */ collectDevPrewarmPlan(): Promise<{ pathnames: readonly string[]; readiness: 'background' | 'beforeReady'; }>; /** * Reports whether this processor's build inputs changed since the last * incremental static build. * * @remarks * No shipped processor overrides this today. Integrations and processors can * opt in when they own build inputs that should invalidate incremental static * exports without a full rebuild. */ didChange(): boolean; abstract setup(): Promise; abstract process(input: unknown, filePath?: string): Promise; /** * Releases runtime resources owned by the processor. * * @remarks * Core does not call this hook today. Override only when a processor owns * watchers, compiler handles, or other resources that outlive individual * requests. */ teardown(): Promise; protected getCachePath(key: string): string; protected readCache(key: string): Promise; protected writeCache(key: string, data: T): Promise; getWatchConfig(): ProcessorWatchConfig | undefined; getName(): string; getAssetCapabilities(): ProcessorAssetCapability[]; matchesFileFilter(_filepath: string): boolean; canProcessAsset(kind: ProcessorAssetKind, filepath?: string): boolean; private matchesCapabilityExtensions; private normalizeExtensionPattern; }