feat(fix-d12): add TransferredVideoChunk wire-format type in src/shared/types.ts
- Add TransferredVideoChunk { data: string (base64); type: string
(MIME); timestamp: number; isFirst?: boolean } as the
JSON-serializable shape for chunks traversing the offscreen↔SW
chrome.runtime.Port boundary.
- Retarget PortMessage.chunks?: TransferredVideoChunk[] (was
VideoChunk[]). The in-memory VideoChunk type is unchanged — both
the offscreen ring buffer and the SW-side merge step keep using
it after decoding the wire payload.
- No behavior change yet; this commit only lands the type. The
encode/decode call sites land in the next two commits.
Refs: debug session d12-blob-port-transfer-fails.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user