/// import type { ReadableFromPort } from '../streams/index.js'; import type { StreamMessageType } from '../constants/streams.js'; import type { Awaitable } from './utilities.js'; export type OnStreamCallback = (stream: ReadableFromPort) => Awaitable; export type AcceptStreamFunction = () => ReadableFromPort; export type DeclineStreamFunction = () => void; export type ConfirmStreamCallback = (data: { metaData: Record; accept: AcceptStreamFunction; }) => Awaitable; export interface Messagable { on(event: 'message', callback: (value: any) => void): any; off(event: 'message', callback: (value: any) => void): any; postMessage(value: any): void; } export type StreamBaseMessageBody = { type: Type; }; export type StreamStartMessageBody> = { id: string; meta: MetaData; } & StreamBaseMessageBody; export type StreamReadyMessageBody = { id: string; } & StreamBaseMessageBody; export type StreamChunkMessageBody = { id: string; data: Buffer; } & StreamBaseMessageBody; export type StreamEndMessageBody = { id: string; } & StreamBaseMessageBody;