import type { Plugin, PluginContext, PluginCommand, MessageInterceptor, MessageContext, CustomRenderer, SettingsSchema, PluginTheme, PluginLogEntry, UIButtonDefinition, UILocation } from './PluginInterfaces.js'; import type { IPluginStorage } from './interfaces.js'; /** * Configuration options for the PluginRegistry. */ export interface PluginRegistryOptions { /** * Storage adapter for persisting plugin settings. * Defaults to in-memory storage if not provided. * Pass `localStorage` (or a wrapper) for browser environments. */ storage?: IPluginStorage; /** * Called when a plugin registers a theme. * The host is responsible for injecting the CSS into the document. * Receives the full theme ID (used as the CSS class name) and the generated CSS string. */ onThemeRegistered?: (themeId: string, className: string, css: string) => void; /** * Called when a plugin unregisters a theme. * The host is responsible for removing the injected CSS. */ onThemeUnregistered?: (themeId: string) => void; } /** * Central registry that manages all loaded plugins and their side-effects. * Create a single instance and share it across your application. */ export declare class PluginRegistry { private readonly plugins; private readonly commands; private beforeSendInterceptors; private receiveInterceptors; private readonly renderers; private readonly buttons; private readonly settingsSchemas; private readonly pluginSettings; private readonly matrixHandlers; private readonly timers; private readonly themes; private logs; private readonly maxLogs; private readonly storage; private readonly onThemeRegistered?; private readonly onThemeUnregistered?; constructor(options?: PluginRegistryOptions); /** Register a plugin and its context. Called after the host has loaded the module. */ registerPlugin(id: string, plugin: Plugin, context: PluginContext): void; /** Unregister a plugin, calling its onUnload hook and cleaning up all side-effects. */ unregisterPlugin(id: string): Promise; /** Register a command contributed by a plugin. */ registerCommand(pluginId: string, command: PluginCommand): void; /** Remove a registered command by name. */ unregisterCommand(name: string): void; /** Execute a command by name, passing raw argument string. */ executeCommand(name: string, rawArgs: string, roomId?: string): Promise; private parseCommandArgs; /** Return all registered commands. */ getCommands(): Array<{ name: string; pluginId: string; command: PluginCommand; }>; /** Add a before-send interceptor for a plugin. */ addBeforeSendInterceptor(pluginId: string, interceptor: MessageInterceptor): void; /** Add a receive interceptor for a plugin. */ addReceiveInterceptor(pluginId: string, interceptor: MessageInterceptor): void; /** Run a message through all before-send interceptors in registration order. */ processBeforeSend(msg: MessageContext): Promise; /** Run a message through all receive interceptors in registration order. */ processReceive(msg: MessageContext): Promise; /** Register a custom renderer contributed by a plugin. */ registerRenderer(pluginId: string, type: string, renderer: CustomRenderer): void; /** Remove a renderer by type. */ unregisterRenderer(type: string): void; /** Get the renderer for a given type, if any. */ getRenderer(type: string): CustomRenderer | undefined; /** Register a UI button contributed by a plugin. */ registerButton(pluginId: string, button: UIButtonDefinition): void; /** Remove a registered button by ID. */ unregisterButton(pluginId: string, buttonId: string): void; /** * Get all buttons for a specific UI location, sorted by position configuration. * Returns buttons in the order they should be rendered. */ getButtonsForLocation(location: UILocation): UIButtonDefinition[]; /** * Sort buttons according to their position configuration. * - Buttons with position.before/after are positioned relative to existing buttons * - Buttons in groups are kept together * - Within groups, buttons are sorted by order property */ private sortButtonsByPosition; /** Define the settings schema for a plugin and load persisted values. */ defineSettings(pluginId: string, schema: SettingsSchema): void; /** Get a plugin setting value. */ getPluginSetting(pluginId: string, key: string): T | undefined; /** Set a plugin setting value and persist it. */ setPluginSetting(pluginId: string, key: string, value: unknown): void; /** Get the settings schema for a plugin. */ getPluginSettingsSchema(pluginId: string): SettingsSchema | undefined; /** Register a theme contributed by a plugin. */ registerTheme(pluginId: string, theme: PluginTheme): void; /** Unregister a theme contributed by a plugin. */ unregisterTheme(pluginId: string, themeId: string): void; /** Return all registered plugin themes. */ getPluginThemes(): Array<{ id: string; name: string; kind: 'light' | 'dark'; className: string; }>; /** Track an event handler registered by a plugin. */ addEventHandler(pluginId: string, eventType: string, handler: (...args: any[]) => void): void; /** Remove a previously tracked event handler. */ removeEventHandler(pluginId: string, eventType: string, handler: (...args: any[]) => void): void; /** Get all tracked handlers for an event type. */ getEventHandlers(eventType: string): Array<{ pluginId: string; handler: (...args: any[]) => void; }>; /** Track a timer ID for a plugin so it can be cleared on unload. */ addTimer(pluginId: string, timerId: number): void; /** Remove a timer ID from tracking (e.g. after manual clearInterval). */ removeTimer(pluginId: string, timerId: number): void; /** Append a log entry from a plugin. */ addLog(pluginId: string, level: 'log' | 'warn' | 'error', args: unknown[]): void; /** Return log entries, optionally filtered to a specific plugin. */ getLogs(pluginId?: string): PluginLogEntry[]; /** Clear log entries, optionally scoped to a specific plugin. */ clearLogs(pluginId?: string): void; /** Get the public exports of a loaded plugin. */ getPluginExports(pluginId: string): unknown; /** * Returns metadata for all currently registered plugins. * Useful for displaying a plugin directory / manager UI. */ getRegisteredPlugins(): Array<{ id: string; name: string; version: string; commandCount: number; interceptorCount: number; themeCount: number; hasSettings: boolean; }>; /** Unload the current plugin instance and load a new one in-place. */ reloadPlugin(pluginId: string, newPlugin: Plugin, newContext: PluginContext): Promise; /** Unload all plugins and clear all registry state. */ clear(): void; } //# sourceMappingURL=PluginRegistry.d.ts.map