//#region src/debug/bus-frame.d.ts /** * Binary framing for the buffer-pool bus transport. * * Every message transferred over the worker port is an `ArrayBuffer` * laid out as: * * offset size field * ------ ---- ----- * 0 4 uint32 usedBytes (length of valid payload, ≤ buf.byteLength) * 4 4 uint32 type (see `BUS_TYPE` below) * 8 4 uint32 tsLow ┐ `Date.now()` split into two uint32s * 12 4 uint32 tsHigh ┘ so we don't have to carry BigInts * 16 … payload (type-specific TLV, see `writeDataPayload`) * * Small / large tiers share this header. Header is fixed-size so the * writer can go straight to offset 16 for the payload. * * Section TLVs inside a `data` payload: * * section: * 4 uint32 featureId (see `FEATURE_ID`) * 4 uint32 sectionBytes (length of payload that follows) * … raw payload — typed-array bytes, preceded by a per-feature * header (frame number for stats, etc.). Each feature's * encoder knows its own sub-format. * * Keep this file dependency-free — it's imported by both the worker * bundle and the main thread, and should hold no DOM / three.js refs. * * NOTE: not yet wired to a live transport. The in-process bus moves data * via `bus-pool` typed-array transfer over the worker port; this framing * is the wire format for the planned WebSocket / remote-debug transport * (mobile debugging) — see #114. Kept as that foundation, not dead code. */ /** Four-byte header tag for every message type. Stable on the wire. */ declare const BUS_TYPE: { readonly DATA: 1; readonly SUBSCRIBE: 2; readonly SUBSCRIBE_ACK: 3; readonly ACK: 4; readonly UNSUBSCRIBE: 5; readonly PING: 6; readonly PROVIDER_ANNOUNCE: 7; readonly PROVIDER_QUERY: 8; readonly PROVIDER_GONE: 9; readonly POOL_INIT: 10; readonly POOL_RELEASE: 11; }; type BusType = (typeof BUS_TYPE)[keyof typeof BUS_TYPE]; /** Feature-section ids inside a `data` payload. */ declare const FEATURE_ID: { readonly STATS: 1; readonly ENV: 2; readonly REGISTRY: 3; readonly BUFFERS: 4; }; type FeatureId = (typeof FEATURE_ID)[keyof typeof FEATURE_ID]; declare const HEADER_BYTES = 16; /** * Writer wrapping a single acquired buffer. Tracks the cursor, writes * header + TLV sections, and finalises by patching `usedBytes` into * the header. Keeps zero per-write allocations — all numeric writes * go via a `DataView`. */ declare class FrameWriter { readonly buffer: ArrayBuffer; private _view; private _u8; private _cursor; constructor(buffer: ArrayBuffer); /** Reset for reuse (after the buffer is bounced back from the worker). */ reset(): void; /** Finalise: stamp header (type, ts, usedBytes). Call after all sections are written. */ finalise(type: BusType, ts: number): void; /** Bytes written so far (including header). */ get bytesUsed(): number; /** Bytes remaining in this buffer. */ get bytesRemaining(): number; writeUint32(v: number): void; writeInt32(v: number): void; writeFloat64(v: number): void; /** Write a short UTF-8 string preceded by a uint16 byte length. Max 65535 bytes. */ writeString(s: string): void; /** Memcpy a typed-array view's bytes into the frame. */ writeBytes(src: ArrayBufferView): void; } /** * Reader for a frame received on the worker side (or any side that * wants to decode). Does NOT copy — exposes `Uint8Array` / `DataView` * views into the buffer. Consumers of those views should copy * anything they want to keep, because the buffer is about to be * bounced back to the producer's pool and overwritten. */ declare class FrameReader { readonly buffer: ArrayBuffer; private _view; private _u8; private _cursor; constructor(buffer: ArrayBuffer); get type(): BusType; get usedBytes(): number; get ts(): number; readUint32(): number; readInt32(): number; readFloat64(): number; readString(): string; /** Returns a view into the buffer — caller copies if retention needed. */ readBytesView(length: number): Uint8Array; /** Bytes still available to read within `usedBytes`. */ get bytesRemaining(): number; /** Seek absolute position (for section-skip). */ seek(offset: number): void; get cursor(): number; } //#endregion export { BUS_TYPE, BusType, FEATURE_ID, FeatureId, FrameReader, FrameWriter, HEADER_BYTES }; //# sourceMappingURL=bus-frame.d.ts.map