diff --git a/src/shared/types.ts b/src/shared/types.ts index b6f0ec8..e5f4856 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -29,16 +29,33 @@ export type PortMessageType = export interface PortMessage { type: PortMessageType; - chunks?: VideoChunk[]; + // Wire-format (post-D-12 fix): chunks travel as TransferredVideoChunk[] + // because chrome.runtime.Port JSON-serializes payloads, and + // JSON.stringify(blob) === "{}" loses binary content. The receive + // side reconstructs VideoChunk[] via src/shared/binary.ts. + chunks?: TransferredVideoChunk[]; } -// Видеобуфер +// In-memory chunk shape used by the offscreen ring buffer and by +// mergeVideoChunks after the SW decodes the wire format. export interface VideoChunk { data: Blob; timestamp: number; isFirst?: boolean; } +// Wire-format for video chunks traveling across the offscreen↔SW +// chrome.runtime.Port boundary. Replaces the previous VideoChunk[] +// payload, which failed because Blob is not JSON-serializable. +// See debug session d12-blob-port-transfer-fails and the GREEN block +// of tests/offscreen/port-serialization.test.ts for the pinned shape. +export interface TransferredVideoChunk { + data: string; // base64-encoded blob bytes (no data: prefix) + type: string; // MIME type to apply when reconstructing the Blob + timestamp: number; + isFirst?: boolean; +} + // Лог событий пользователя export interface UserEvent { timestamp: number;