// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
//
// SPDX-License-Identifier: GPL-2.0-or-later

export interface DecoderPlugin<TMessage = unknown> {
  readonly id: string;
  onMessage?(message: TMessage): void;
  onBatch?(messages: TMessage[]): void;
  restore?(messages: TMessage[]): void;
  reset?(): void;
  prune?(): void;
}

export interface TrxPluginRuntime {
  registerDecoder<TMessage>(plugin: DecoderPlugin<TMessage>): () => void;
  dispatch(id: string, message: unknown): boolean;
  dispatchBatch(id: string, messages: unknown[]): boolean;
  restore(id: string, messages: unknown[]): boolean;
  reset(id: string): boolean;
  resetAll(): void;
  prune(id: string): boolean;
  clearQueued(): void;
  hasDecoder(id: string): boolean;
}

export interface PluginRuntimeWindow { trxPluginRuntime: TrxPluginRuntime }
