import { DebugMessage } from "../debug-protocol.js"; //#region src/debug/bus-transport.d.ts interface ConvertRequest { name: string; width: number; height: number; pixelType: string; display: string; frame: number; stream: boolean; forceKeyFrame: boolean; pixels: ArrayBuffer; /** Actual byte length of pixel data within the (possibly larger) pool buffer. */ pixelsByteLength: number; } interface BusTransport { /** Pop a small (4 KB) pool buffer. */ acquireSmall(): ArrayBuffer; /** Pop a medium (256 KB) pool buffer — for the per-flush data packet. */ acquireMedium(): ArrayBuffer; /** Pop a large (16 MB) pool buffer — for texture pixel readback. */ acquireLarge(): ArrayBuffer; /** * Broadcast a message. Pass any pool buffers referenced by typed * arrays inside `msg` in `bufs` so the transport can route them * back to the pool after the BroadcastChannel serialise step. In * `InlineBusTransport`, `bufs` is ignored — we don't pool * allocations on the slow path. */ post(msg: DebugMessage, bufs?: ArrayBuffer[]): void; /** * Send raw pixels to the worker for format conversion (and optional * VP9 encoding when `req.stream` is true). The pixel buffer is * transferred (zero-copy) to the worker. The worker converts to * RGBA8, then either feeds the VP9 encoder or broadcasts as * `buffer:raw`. Pool buffer is bounced back after conversion. */ convert(req: ConvertRequest, poolBuf: ArrayBuffer): void; /** * Whether the worker-side VP9 encoder is available. `null` until * the capability probe completes; `false` when WebCodecs or VP9 * is unsupported; `true` when ready. */ readonly codecSupported: boolean | null; /** * Return a buffer to the pool without sending it. Use when an * `acquire*` happened but the flush turned out to have nothing to * ship — avoids pool starvation. No-op for the inline transport * (its buffers GC themselves). */ releaseUnused(buf: ArrayBuffer): void; /** Approximate count of buffers currently held in each pool tier. */ poolStats(): { smallFree: number; mediumFree: number; largeFree: number; }; dispose(): void; } interface CreateBusTransportOptions { channelName: string; /** * Override for the worker spawn — useful for tests or for hosts * that want to provide a pre-built `Worker` instance. When omitted, * we attempt the canonical `new Worker(new URL('./bus-worker', * import.meta.url), { type: 'module' })` and fall back to the * inline transport if that throws. */ spawnWorker?: () => Worker | null; /** * Force the inline path (skip the worker even if it's available). * Useful as a kill switch. */ forceInline?: boolean; } /** * Pick the best available transport. Tries the worker; on any * failure (CSP, no bundler, etc.) returns the inline fallback. We * deliberately do not await a handshake here — the worker init is * fire-and-forget and the pool seed messages will arrive on the * worker's own schedule. Until they do, `acquireSmall`/`acquireLarge` * fall back to one-off allocations and the warn counter ticks up. */ declare function createBusTransport(opts: CreateBusTransportOptions): BusTransport; //#endregion export { BusTransport, ConvertRequest, CreateBusTransportOptions, createBusTransport }; //# sourceMappingURL=bus-transport.d.ts.map