/** * @license * Copyright 2023 Nuraly, Laabidi Aymen * SPDX-License-Identifier: MIT */ import { ReactiveController, ReactiveControllerHost } from 'lit'; /** * Minimal host interface that all component hosts must satisfy */ export interface BaseHost { requestUpdate(): void; } /** * Error handler interface for consistent error handling across controllers */ export interface ErrorHandler { handleError(error: Error, context: string): void; } /** * Generic base controller class that implements common functionality * shared across all NuralyUI component controllers. * * Provides lifecycle hooks, error handling, safe update/dispatch, * and utility methods (safeExecute, debounce). * * @typeParam THost - The component host type, must extend BaseHost & ReactiveControllerHost */ export declare abstract class BaseComponentController implements ReactiveController, ErrorHandler { protected _host: THost; constructor(host: THost); /** * Get the host element */ get host(): THost; /** * Reactive controller lifecycle - called when host connects */ hostConnected(): void; /** * Reactive controller lifecycle - called when host disconnects */ hostDisconnected(): void; /** * Reactive controller lifecycle - called when host updates */ hostUpdate(): void; /** * Reactive controller lifecycle - called after host updates */ hostUpdated(): void; /** * Request host update safely */ protected requestUpdate(): void; /** * Dispatch custom event from host safely */ protected dispatchEvent(event: Event): boolean; /** * Handle errors with consistent logging and event dispatching. * Standardizes error events to 'nr-controller-error'. */ handleError(error: Error, context: string): void; /** * Safely execute a function with error handling */ protected safeExecute(fn: () => T, context: string, fallback?: T): T | undefined; /** * Debounce utility for controllers. * Returns a debounced function with a cancel() method for cleanup. */ protected debounce any>(fn: T, wait: number): ((...args: Parameters) => void) & { cancel: () => void; }; } //# sourceMappingURL=base.controller.d.ts.map