import type { Plugin as UnifiedPlugin } from 'unified'; import type { Theme } from './theme.js'; import type { RenderContext, ExportContext } from './context.js'; import type { Page } from 'playwright-core'; import type { PluginRegistry } from '../plugins/registry.js'; export interface BasePlugin { name: string; priority?: 'first' | 'normal'; setup?: (registry: PluginRegistry) => void | Promise; teardown?: () => void | Promise; } export interface MarkdownPlugin extends BasePlugin { type: 'markdown'; plugin: UnifiedPlugin; options?: unknown; } export interface HtmlPlugin extends BasePlugin { type: 'html'; plugin: UnifiedPlugin; options?: unknown; } export interface RenderPlugin extends BasePlugin { type: 'render'; hooks: { /** Transform the final HTML string before Playwright opens it */ beforeRender?: (html: string, ctx: RenderContext) => Promise | string; /** Called after page loads, before PDF is generated */ afterPageLoad?: (page: Page, ctx: RenderContext) => Promise; /** Post-process the PDF buffer */ afterPdf?: (pdf: Buffer, ctx: RenderContext) => Promise | Buffer; }; } export interface ThemePlugin extends BasePlugin { type: 'theme'; theme: Theme; } export interface ExportPlugin extends BasePlugin { type: 'export'; format: string; extension: string; export: (html: string, ctx: ExportContext) => Promise; } export type AnyPlugin = MarkdownPlugin | HtmlPlugin | RenderPlugin | ThemePlugin | ExportPlugin; export declare function createMarkdownPlugin(options: Omit): MarkdownPlugin; export declare function createHtmlPlugin(options: Omit): HtmlPlugin; export declare function createRenderPlugin(options: Omit): RenderPlugin; export declare function createThemePlugin(options: Omit): ThemePlugin; export declare function createExportPlugin(options: Omit): ExportPlugin;