import type { CustomDirective, StxOptions } from './types';
/**
 * Define an stx plugin with type safety.
 *
 * Usage:
 * ```typescript
 * import { definePlugin } from 'stx'
 *
 * export default definePlugin({
 *   name: 'my-plugin',
 *   components: './components',
 *   functions: './functions',
 *   setup(options, stx) {
 *     stx.addRoute('/api/custom', handler)
 *   },
 * })
 * ```
 */
export declare function definePlugin(config: StxPlugin): StxPlugin;
/**
 * Create a simple directive plugin
 */
export declare function createDirectivePlugin(name: string, directives: CustomDirective[], options?: Partial<Omit<StxPlugin, 'name' | 'registerDirectives'>>): StxPlugin;
/**
 * Create a simple filter plugin
 */
export declare function createFilterPlugin(name: string, filters: Record<string, (value: unknown, ...args: unknown[]) => unknown>, options?: Partial<Omit<StxPlugin, 'name' | 'registerFilters'>>): StxPlugin;
/**
 * Variables plugin that adds common variables to context
 */
export declare function createVariablesPlugin(variables: Record<string, unknown>): StxPlugin;
/**
 * Global plugin manager instance
 */
export declare const pluginManager: PluginManager;
/**
 * Debug plugin that logs all lifecycle events
 */
export declare const debugPlugin: StxPlugin;
/**
 * Timing plugin that measures processing time
 */
export declare const timingPlugin: StxPlugin;
/**
 * Context passed to lifecycle hooks
 */
export declare interface PluginContext {
  template: string
  context: Record<string, unknown>
  filePath: string
  options: StxOptions
  dependencies: Set<string>
  metadata: Record<string, unknown>
}
/**
 * Result from a lifecycle hook
 */
export declare interface PluginHookResult {
  template?: string
  context?: Record<string, unknown>
  skip?: boolean
  metadata?: Record<string, unknown>
}
/**
 * Error context passed to onError hook
 */
export declare interface PluginErrorContext extends PluginContext {
  error: Error
  phase: string
  directive?: string
}
/**
 * Plugin definition interface
 */
export declare interface StxPlugin {
  name: string
  version?: string
  description?: string
  dependencies?: string[]
  priority?: number
  beforeProcess?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  afterParse?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  beforeDirective?: (phase: DirectivePhase, ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  afterDirective?: (phase: DirectivePhase, ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  beforeRender?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  afterRender?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
  onError?: (ctx: PluginErrorContext) => PluginHookResult | Promise<PluginHookResult> | void
  registerDirectives?: () => CustomDirective[]
  registerFilters?: () => Record<string, (value: unknown, ...args: unknown[]) => unknown>
  onRegister?: (options: StxOptions) => void | Promise<void>
  onUnregister?: () => void | Promise<void>
  components?: string
  functions?: string
  stores?: string
  pages?: string
  middleware?: string
  setup?: (options: Record<string, any>, stx: PluginSetupContext) => void | Promise<void>
}
/**
 * Context passed to plugin setup() function
 */
export declare interface PluginSetupContext {
  addDirective: (directive: CustomDirective) => void
  addRoute: (path: string, handler: (req: Request) => Response | Promise<Response>) => void
  addMiddleware: (middleware: any) => void
  pluginDir: string
  config: StxOptions
}
/**
 * Directive type identifier for beforeDirective/afterDirective hooks
 */
export type DirectivePhase = | 'comments'
  | 'escaped'
  | 'stacks'
  | 'layouts'
  | 'includes'
  | 'js'
  | 'ts'
  | 'custom'
  | 'components'
  | 'animation'
  | 'routes'
  | 'auth'
  | 'csrf'
  | 'method'
  | 'loops'
  | 'conditionals'
  | 'forms'
  | 'markdown'
  | 'i18n'
  | 'a11y'
  | 'seo'
  | 'expressions';
/**
 * Plugin manager that handles registration, lifecycle, and execution
 */
export declare class PluginManager {
  register(plugin: StxPlugin, options: StxOptions): Promise<void>;
  unregister(name: string): Promise<boolean>;
  get(name: string): StxPlugin | undefined;
  has(name: string): boolean;
  getAll(): StxPlugin[];
  getAllDirectives(): CustomDirective[];
  getAllFilters(): Record<string, (value: unknown, ...args: unknown[]) => unknown>;
  runBeforeProcess(ctx: PluginContext): Promise<PluginContext>;
  runAfterParse(ctx: PluginContext): Promise<PluginContext>;
  runBeforeDirective(phase: DirectivePhase, ctx: PluginContext): Promise<PluginContext>;
  runAfterDirective(phase: DirectivePhase, ctx: PluginContext): Promise<PluginContext>;
  runBeforeRender(ctx: PluginContext): Promise<PluginContext>;
  runAfterRender(ctx: PluginContext): Promise<PluginContext>;
  runOnError(ctx: PluginErrorContext): Promise<PluginContext | null>;
}
