import type { MiddlewareContext } from '../../commands'; import type { Awaitable } from '../../common/types/util'; import type { BaseClient, BaseClientOptions } from '../base'; import { type PluginOrderedContribution, type PluginOrderSequence } from './order'; import type { AnySeyfertPlugin, PluginAutocompleteWrapper, PluginCacheResourceConstructor, PluginCommandLoadable, PluginCommandObserver, PluginComponentLoadable, PluginDiagnosticCode, PluginDiagnosticMessage, PluginDiagnosticSeverity, PluginEventErrorHandler, PluginGatewayDispatchInterceptor, PluginGatewaySendPayloadWrapper, PluginHandlerCreator, PluginHandlerKind, PluginHandlerTransformer, PluginIntentResolvable, PluginLifecycleStatus, PluginModalLoadable, PluginOrderOpt, PluginRequirement, PluginRequirementDiagnostic, PluginRestObserver, ResolvedPluginList, SeyfertPluginOptions } from './types'; export interface PluginRuntimeRecord { plugin: AnySeyfertPlugin; identity: string; index: number; imports: readonly AnySeyfertPlugin[]; clientKeys: readonly string[]; ctxKeys: readonly string[]; optionFragments: PluginOptionContribution[]; status: PluginLifecycleStatus; } export type PluginEventContributionScope = 'register' | 'setup' | 'teardown'; export interface PluginCommandContribution { record: PluginRuntimeRecord; commands: readonly PluginCommandLoadable[]; scope: PluginEventContributionScope; override: boolean; guilds?: readonly string[]; sequence: number; } export interface PluginCommandRemovalContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; names: readonly string[]; scope: PluginEventContributionScope; } export interface PluginComponentContribution { record: PluginRuntimeRecord; components: readonly PluginComponentLoadable[]; scope: PluginEventContributionScope; override: boolean; sequence: number; } export interface PluginComponentRemovalContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; customIds: readonly string[]; scope: PluginEventContributionScope; } export interface PluginModalContribution { record: PluginRuntimeRecord; modals: readonly PluginModalLoadable[]; scope: PluginEventContributionScope; override: boolean; sequence: number; } export interface PluginModalRemovalContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; customIds: readonly string[]; scope: PluginEventContributionScope; } export interface PluginEventContribution { record: PluginRuntimeRecord; name: string; handler: (...args: unknown[]) => unknown; scope: PluginEventContributionScope; active: boolean; order?: PluginOrderOpt; sequence: number; once?: boolean; fired?: boolean; } export interface PluginAnyEventContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; handler: (name: string, ...args: unknown[]) => unknown; scope: PluginEventContributionScope; active: boolean; } export interface PluginEventErrorContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; handler: PluginEventErrorHandler; scope: PluginEventContributionScope; active: boolean; } export interface PluginMiddlewareContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; name: string; middleware: MiddlewareContext; global: boolean; override: boolean; scope: PluginEventContributionScope; } export interface PluginMiddlewareRemovalContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; names: readonly string[]; scope: PluginEventContributionScope; } export interface PluginGlobalMiddlewareContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; name: string; } export interface PluginInstalledMiddleware { middleware: MiddlewareContext; owner: PluginRuntimeRecord; } export interface PluginOptionContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; fragment: SeyfertPluginOptions; scope: PluginEventContributionScope; } export interface PluginGlobalMiddlewareOptionSources { defaults: BaseClientOptions; pluginOptions: PluginOptionContribution[]; userOptions: SeyfertPluginOptions; } export interface PluginSharedContribution { record: PluginRuntimeRecord; factory: (client: BaseClient) => unknown; dispose?: (value: unknown) => Awaitable; scope: PluginEventContributionScope; } export interface PluginSharedMutation { record: PluginRuntimeRecord; name: string; scope: PluginEventContributionScope; previous?: PluginSharedContribution; previousOwner?: PluginRuntimeRecord; } export interface PluginLangContribution { record: PluginRuntimeRecord; locale: string; prefix: string; values: Record; scope: PluginEventContributionScope; sequence: number; } export interface PluginGatewayIntentContribution { record: PluginRuntimeRecord; intents: readonly number[]; scope: PluginEventContributionScope; } export interface PluginAutocompleteWrapperContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; wrapper: PluginAutocompleteWrapper; scope: PluginEventContributionScope; } export interface PluginGatewaySendPayloadWrapperContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; wrapper: PluginGatewaySendPayloadWrapper; scope: PluginEventContributionScope; } export interface PluginGatewayDispatchInterceptorContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; interceptor: PluginGatewayDispatchInterceptor; scope: PluginEventContributionScope; } export interface PluginRestObserverContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; observer: PluginRestObserver; scope: PluginEventContributionScope; active: boolean; } export interface PluginHookContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; name: string; handler: (...args: unknown[]) => Awaitable; scope: PluginEventContributionScope; active: boolean; } export interface PluginCacheResourceContribution { record: PluginRuntimeRecord; name: string; resource: PluginCacheResourceConstructor; scope: PluginEventContributionScope; onPacket?: (event: import('../../types').GatewayDispatchPayload, cache: import('../../cache').Cache) => Awaitable; sequence: number; } export interface PluginCommandObserverContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; observer: PluginCommandObserver; scope: PluginEventContributionScope; active: boolean; } export interface PluginDefaultsContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; kind: 'commands' | 'components' | 'modals'; hooks: Record | undefined; suppressDefault?: boolean | readonly string[]; scope: PluginEventContributionScope; } export interface PluginHandlerCreatorContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; creator: PluginHandlerCreator; scope: PluginEventContributionScope; kinds?: readonly PluginHandlerKind[]; } export interface PluginHandlerTransformerContribution extends PluginOrderedContribution { record: PluginRuntimeRecord; transformer: PluginHandlerTransformer; scope: PluginEventContributionScope; kinds?: readonly PluginHandlerKind[]; } export interface PluginRequirementContribution extends PluginRequirementDiagnostic { record: PluginRuntimeRecord; } export interface PluginRuntimeRegistry extends PluginOrderSequence { plugins: ResolvedPluginList; records: readonly PluginRuntimeRecord[]; commands: PluginCommandContribution[]; commandRemovals: PluginCommandRemovalContribution[]; components: PluginComponentContribution[]; componentRemovals: PluginComponentRemovalContribution[]; modals: PluginModalContribution[]; modalRemovals: PluginModalRemovalContribution[]; events: PluginEventContribution[]; anyEvents: PluginAnyEventContribution[]; eventErrors: PluginEventErrorContribution[]; middlewares: PluginMiddlewareContribution[]; middlewareRemovals: PluginMiddlewareRemovalContribution[]; globalMiddlewares: PluginGlobalMiddlewareContribution[]; globalMiddlewareOptions?: PluginGlobalMiddlewareOptionSources; installedMiddlewares: Map; contributionMutationDiagnostics: Set; autocompleteWrappers: PluginAutocompleteWrapperContribution[]; gatewayIntents: PluginGatewayIntentContribution[]; gatewaySendPayloadWrappers: PluginGatewaySendPayloadWrapperContribution[]; gatewayDispatchInterceptors: PluginGatewayDispatchInterceptorContribution[]; restObservers: PluginRestObserverContribution[]; hooks: PluginHookContribution[]; cacheResources: PluginCacheResourceContribution[]; commandObservers: PluginCommandObserverContribution[]; pluginDefaults: PluginDefaultsContribution[]; handlerCreators: PluginHandlerCreatorContribution[]; handlerTransformers: PluginHandlerTransformerContribution[]; shared: Map; sharedOwners: Map; sharedMutations: PluginSharedMutation[]; sharedDisposals: Promise[]; langs: PluginLangContribution[]; diagnostics: PluginDiagnosticMessage[]; requirements: PluginRequirementContribution[]; client?: BaseClient; } export declare function createPluginRuntimeRegistry(plugins?: readonly AnySeyfertPlugin[]): PluginRuntimeRegistry; export declare function runPluginRegister(record: PluginRuntimeRecord, registry: PluginRuntimeRegistry): void; export declare function bindPluginClient(registry: PluginRuntimeRegistry, client: BaseClient): void; export declare function removePluginEventContribution(registry: PluginRuntimeRegistry, contribution: PluginEventContribution): void; export declare function removePluginAnyEventContribution(registry: PluginRuntimeRegistry, contribution: PluginAnyEventContribution): void; export declare function removePluginEventErrorContribution(registry: PluginRuntimeRegistry, contribution: PluginEventErrorContribution): void; export declare function removePluginCommandObserverContribution(registry: PluginRuntimeRegistry, contribution: PluginCommandObserverContribution): void; export declare function removePluginRestObserverContribution(registry: PluginRuntimeRegistry, contribution: PluginRestObserverContribution): void; export declare function removePluginGatewayDispatchInterceptorContribution(registry: PluginRuntimeRegistry, contribution: PluginGatewayDispatchInterceptorContribution): void; export declare function removePluginHookContribution(registry: PluginRuntimeRegistry, contribution: PluginHookContribution): void; export declare function activatePluginEventListeners(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord): void; export declare function cleanupPluginEventListeners(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord): void; export declare function cleanupPluginDynamicContributionMutations(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord): void; export declare function hasPluginRequirement(registry: PluginRuntimeRegistry, req: PluginRequirement): boolean; export declare function pluginIdentity(plugin: Pick): string; export declare function resolvePluginIntents(registry: PluginRuntimeRegistry, base: number): number; export declare function addPluginGlobalMiddlewares(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord, names: readonly string[]): void; export declare function addPluginOptionFragment(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord, fragment: SeyfertPluginOptions, scope: PluginEventContributionScope): void; export declare function addPluginDiagnostic(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord, diagnostic: { message: string; phase: string; severity: PluginDiagnosticSeverity; code?: PluginDiagnosticCode; data?: Record; }): void; export declare function clonePluginOptions(value: T): T; export declare function readonlyPluginOptions(value: T): Readonly; export declare function assertSafePluginResourceName(record: PluginRuntimeRecord, phase: string, name: string, reserved: ReadonlySet): void; export declare function assertCanMutatePluginContribution(registry: PluginRuntimeRegistry, record: PluginRuntimeRecord, action: 'override' | 'remove', kind: string, name: string, owner: PluginRuntimeRecord | undefined, phase: string): void; export declare function recordContributionMutationDiagnostic(registry: PluginRuntimeRegistry, contribution: PluginOrderedContribution & { record: PluginRuntimeRecord; }, action: 'override' | 'remove', kind: string, name: string, owner: PluginRuntimeRecord | undefined, phase: string): void; export declare function createPluginContextFragment(record: PluginRuntimeRecord, registry: PluginRuntimeRegistry): SeyfertPluginOptions | undefined; export declare function installPluginClientMaps(client: BaseClient, registry: PluginRuntimeRegistry): void; export declare function installPluginMiddlewares(client: BaseClient, registry: PluginRuntimeRegistry): void; export declare function resolveGatewayIntent(intent: PluginIntentResolvable): number | undefined; export declare function unknownGatewayIntentBits(intent: PluginIntentResolvable): number; export declare function validatePluginRequirements(registry: PluginRuntimeRegistry, kind?: 'plugin' | 'capability' | 'all'): void;