UNPKG

@jagodin/turbo-stream

Version:

A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.

108 lines (107 loc) 3.61 kB
import type { EncodePlugin, DecodePlugin } from "./turbo-stream.js"; /** * Global plugin registry for turbo-stream * Allows registering plugins that will be automatically used by all encode/decode calls */ declare class PluginRegistry { private encodePlugins; private decodePlugins; /** * Register an encode plugin that will be used by all encode calls * @param plugin The encode plugin to register */ registerEncodePlugin(plugin: EncodePlugin): void; /** * Register a decode plugin that will be used by all decode calls * @param plugin The decode plugin to register */ registerDecodePlugin(plugin: DecodePlugin): void; /** * Register both encode and decode plugins for a complete serialization solution * @param encodePlugin The encode plugin to register * @param decodePlugin The decode plugin to register */ registerPlugin(encodePlugin: EncodePlugin, decodePlugin: DecodePlugin): void; /** * Get all registered encode plugins * @returns Array of registered encode plugins */ getEncodePlugins(): readonly EncodePlugin[]; /** * Get all registered decode plugins * @returns Array of registered decode plugins */ getDecodePlugins(): readonly DecodePlugin[]; /** * Clear all registered plugins */ clear(): void; /** * Remove a specific encode plugin * @param plugin The plugin to remove */ unregisterEncodePlugin(plugin: EncodePlugin): void; /** * Remove a specific decode plugin * @param plugin The plugin to remove */ unregisterDecodePlugin(plugin: DecodePlugin): void; /** * Get the number of registered encode plugins */ get encodePluginCount(): number; /** * Get the number of registered decode plugins */ get decodePluginCount(): number; } declare const globalRegistry: PluginRegistry; /** * Register an encode plugin globally * @param plugin The encode plugin to register */ export declare function registerEncodePlugin(plugin: EncodePlugin): void; /** * Register a decode plugin globally * @param plugin The decode plugin to register */ export declare function registerDecodePlugin(plugin: DecodePlugin): void; /** * Register both encode and decode plugins globally * @param encodePlugin The encode plugin to register * @param decodePlugin The decode plugin to register */ export declare function registerPlugin(encodePlugin: EncodePlugin, decodePlugin: DecodePlugin): void; /** * Get all globally registered encode plugins * @returns Array of registered encode plugins */ export declare function getGlobalEncodePlugins(): readonly EncodePlugin[]; /** * Get all globally registered decode plugins * @returns Array of registered decode plugins */ export declare function getGlobalDecodePlugins(): readonly DecodePlugin[]; /** * Clear all globally registered plugins */ export declare function clearGlobalPlugins(): void; /** * Remove a specific encode plugin from global registry * @param plugin The plugin to remove */ export declare function unregisterEncodePlugin(plugin: EncodePlugin): void; /** * Remove a specific decode plugin from global registry * @param plugin The plugin to remove */ export declare function unregisterDecodePlugin(plugin: DecodePlugin): void; /** * Get the number of globally registered encode plugins */ export declare function getGlobalEncodePluginCount(): number; /** * Get the number of globally registered decode plugins */ export declare function getGlobalDecodePluginCount(): number; export { globalRegistry };