feat(fix-a3): rename TransferredVideoChunk → TransferredVideoSegment
Pure rename pass — zero behavioural change at any call site. The
prior "chunk" naming is a vestige of D-09..D-11's chunk-level
buffer; under D-13 the unit of transfer is a self-contained ~10 s
WebM segment, so the type name now matches the data shape.
Renames propagated atomically:
- src/shared/types.ts
* TransferredVideoChunk → TransferredVideoSegment
(also: the `isFirst?: boolean` field is dropped — D-13 segments
are all implicitly their own header, so the flag is meaningless
and only existed for the retired ring-buffer's pin semantics)
* VideoChunk → VideoSegment (drops `isFirst?` for the same reason)
* PortMessage.chunks? → PortMessage.segments?
* VideoBufferResponse.chunks → VideoBufferResponse.segments
- src/offscreen/recorder.ts
* import type rename
* encodeAndSendBuffer's per-element accumulator + filter type
* the port.postMessage payload field
- src/background/index.ts
* import type rename
* getVideoBufferFromOffscreen reads `(msg as {segments?}).segments`
(matching the new wire field name)
* empty-buffer returns `{ segments: [] }`
* mergeVideoSegments signature takes VideoSegment[]
* createArchive consumes videoBufferResponse.segments
* saveArchive log line says "segments"
Verification:
- npx tsc --noEmit clean.
- npx vitest run → 28 passed / 2 failed (the 2 fixture-empirical
ffmpeg dry-runs; unchanged — they're gated on ./smoke.sh regen).
- npm run build succeeds, all 60 modules transformed.
- grep predicates clean in src/:
* no addChunk / trimAged / firstChunkSaved / isFirst
* no TransferredVideoChunk / VideoChunk (old names)
* 21 occurrences of new names propagated correctly
- Pre-existing port-serialization.test.ts still GREEN: its `isFirst`
references are inside inline-test-scoped objects (not imports
from production types), and its tests assert JSON-roundtrip
behaviour rather than the production type shape.
This commit is contained in:
@@ -21,7 +21,7 @@ export interface Message<T = any> {
|
||||
tabId?: number;
|
||||
}
|
||||
|
||||
// Типы сообщений в long-lived port (offscreen ↔ SW; D-17 / Plan 04)
|
||||
// Типы сообщений в long-lived port (offscreen ↔ SW; D-17 / Plan 04 / D-13)
|
||||
export type PortMessageType =
|
||||
| 'PING'
|
||||
| 'REQUEST_BUFFER'
|
||||
@@ -29,31 +29,35 @@ export type PortMessageType =
|
||||
|
||||
export interface PortMessage {
|
||||
type: PortMessageType;
|
||||
// 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[];
|
||||
// Wire-format (D-12 base64 transfer + D-13 segment lifecycle):
|
||||
// segments travel as TransferredVideoSegment[] because
|
||||
// chrome.runtime.Port JSON-serializes payloads across extension
|
||||
// contexts and JSON.stringify(blob) === "{}" loses binary content.
|
||||
// Each entry is one self-contained ~10 s WebM segment (EBML header
|
||||
// + seed keyframe). The receive side reconstructs VideoSegment[]
|
||||
// via src/shared/binary.ts.
|
||||
segments?: TransferredVideoSegment[];
|
||||
}
|
||||
|
||||
// In-memory chunk shape used by the offscreen ring buffer and by
|
||||
// mergeVideoChunks after the SW decodes the wire format.
|
||||
export interface VideoChunk {
|
||||
// In-memory segment shape used by mergeVideoSegments after the SW
|
||||
// decodes the wire format. Под D-13 каждый сегмент — самодостаточный
|
||||
// WebM-блок ≈ 10 секунд (свой EBML-заголовок и стартовый keyframe).
|
||||
export interface VideoSegment {
|
||||
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 {
|
||||
// Wire-format for video segments traveling across the offscreen↔SW
|
||||
// chrome.runtime.Port boundary. Replaces the previous Blob payload,
|
||||
// which failed because Blob is not JSON-serializable.
|
||||
// See debug session d12-blob-port-transfer-fails (resolved) and the
|
||||
// GREEN block of tests/offscreen/port-serialization.test.ts for the
|
||||
// pinned shape. The header-pin flag from the D-09..D-11 era is gone
|
||||
// — under D-13 every segment IS implicitly its own header.
|
||||
export interface TransferredVideoSegment {
|
||||
data: string; // base64-encoded blob bytes (no data: prefix)
|
||||
type: string; // MIME type to apply when reconstructing the Blob
|
||||
timestamp: number;
|
||||
isFirst?: boolean;
|
||||
}
|
||||
|
||||
// Лог событий пользователя
|
||||
@@ -86,9 +90,9 @@ export interface PopupState {
|
||||
|
||||
// Ответы от Service Worker
|
||||
export interface VideoBufferResponse {
|
||||
chunks: VideoChunk[];
|
||||
segments: VideoSegment[];
|
||||
}
|
||||
|
||||
export interface RrwebEventsResponse {
|
||||
events: any[];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user