31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import type { PluginContext, NotificationOptions } from './PluginInterfaces.js';
|
|
import type { IPluginEventClient } from './interfaces.js';
|
|
import type { PluginRegistry } from './PluginRegistry.js';
|
|
/**
|
|
* Options for constructing a PluginContext via `createPluginContext`.
|
|
*/
|
|
export interface PluginContextOptions {
|
|
/** The plugin's unique identifier. */
|
|
pluginId: string;
|
|
/**
|
|
* Optional event client for the `context.events` API.
|
|
* Any object implementing `on(event, handler)` / `off(event, handler)` works —
|
|
* e.g. a MatrixClient, Node.js EventEmitter, or socket.io socket.
|
|
*/
|
|
eventClient?: IPluginEventClient;
|
|
/**
|
|
* Called when a plugin invokes `context.notify(...)`.
|
|
* The host is responsible for displaying the notification however it wants.
|
|
*/
|
|
onNotify?: (options: NotificationOptions) => void | Promise<void>;
|
|
}
|
|
/**
|
|
* Creates a PluginContext wired to the given registry.
|
|
* Call this before registering and loading a plugin.
|
|
*
|
|
* @param options - Host-specific dependencies for the plugin.
|
|
* @param registry - The shared PluginRegistry instance.
|
|
* @returns A fully-wired PluginContext ready to be passed to `plugin.onLoad`.
|
|
*/
|
|
export declare function createPluginContext(options: PluginContextOptions, registry: PluginRegistry): PluginContext;
|
|
//# sourceMappingURL=PluginContext.d.ts.map
|