/** * Global plugin registry for bQuery. * * Provides `use()` to register plugins and query helpers consumed by * other modules (e.g. the view module reads custom directives from here). * * @module bquery/plugin */ import type { BQueryPlugin, CustomDirective, CustomDirectiveHandler } from './types'; /** * Register a bQuery plugin. * * Plugins are installed at most once (identified by `plugin.name`). * Duplicate calls with the same name are silently ignored. * * @param plugin - The plugin object implementing `{ name, install }`. * @param options - Optional configuration forwarded to `plugin.install()`. * @throws If `plugin` is not a valid plugin object. * * @example * ```ts * import { use } from '@bquery/bquery/plugin'; * * use({ * name: 'highlight', * install(ctx) { * ctx.directive('highlight', (el, expr) => { * (el as HTMLElement).style.background = String(expr); * }); * }, * }); * ``` */ export declare const use: (plugin: BQueryPlugin, options?: TOptions) => void; /** * Check whether a plugin with the given name has been installed. * * @param name - The plugin name to check. * @returns `true` if the plugin was previously installed via `use()`. * * @example * ```ts * import { isInstalled } from '@bquery/bquery/plugin'; * * if (!isInstalled('my-plugin')) { * use(myPlugin); * } * ``` */ export declare const isInstalled: (name: string) => boolean; /** * Return a read-only snapshot of all installed plugin names. * * @returns Array of plugin name strings. * * @example * ```ts * import { getInstalledPlugins } from '@bquery/bquery/plugin'; * console.log(getInstalledPlugins()); // ['my-plugin', 'other-plugin'] * ``` */ export declare const getInstalledPlugins: () => readonly string[]; /** * Retrieve the handler for a custom directive registered by a plugin. * * This is used internally by the view module's `processElement` to * resolve directives that aren't built-in. * * @param name - Directive name **without** prefix (e.g. `'tooltip'`). * @returns The handler, or `undefined` if none is registered. * * @example * ```ts * import { getCustomDirective } from '@bquery/bquery/plugin'; * const handler = getCustomDirective('tooltip'); * ``` */ export declare const getCustomDirective: (name: string) => CustomDirectiveHandler | undefined; /** * Return a read-only snapshot of all registered custom directives. * * @returns Array of `{ name, handler }` descriptors. * * @example * ```ts * import { getCustomDirectives } from '@bquery/bquery/plugin'; * for (const { name, handler } of getCustomDirectives()) { * console.log(`Directive: bq-${name}`); * } * ``` */ export declare const getCustomDirectives: () => readonly CustomDirective[]; /** * Reset all plugin registrations. * * Clears all installed plugins and custom directives. * * This utility is primarily intended for tests and other isolated environments * that need to reinitialize plugin state between runs. * * @example * ```ts * import { resetPlugins } from '@bquery/bquery/plugin'; * afterEach(() => resetPlugins()); * ``` */ export declare const resetPlugins: () => void; //# sourceMappingURL=registry.d.ts.map