vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
29 lines • 1.21 kB
TypeScript
import { MessageChannel } from "node:worker_threads";
/**
* Creates a pair of MessageChannels for two-port communication pattern.
*
* This is the standard pattern used throughout the codebase for worker communication:
* - Data channel: For streaming actual data (RSC chunks, HTML content, etc.)
* - Control channel: For control messages (completion signals, errors, metrics, etc.)
*
* @returns Object containing both channels with consistent naming
*/
export declare function createMessageChannels(): {
dataChannel: MessageChannel;
controlChannel: MessageChannel;
dataPort1: import("worker_threads").MessagePort;
dataPort2: import("worker_threads").MessagePort;
controlPort1: import("worker_threads").MessagePort;
controlPort2: import("worker_threads").MessagePort;
};
/**
* Creates transfer list for MessagePort communication.
*
* Used when sending ports through postMessage with transferable objects.
*
* @param port1 - First port to transfer
* @param port2 - Second port to transfer
* @returns Array suitable for transferList parameter
*/
export declare function createTransferList(port1: any, port2: any): any;
//# sourceMappingURL=createMessageChannels.d.ts.map