feat(01-03): add OffscreenLogger and clean up shared types
- Add PortMessageType and PortMessage interface to src/shared/types.ts for the long-lived port (offscreen ↔ SW; D-17 / Plan 04 wires the ping loop + REQUEST_BUFFER / BUFFER traffic). - Remove 'VIDEO_CHUNK' and 'VIDEO_CHUNK_SAVED' from MessageType union (per D-19 — chunks no longer travel via chrome.runtime.sendMessage; the IndexedDB SW-side plumbing is the audit P0 #2 broken path). - OffscreenLogger class was already added alongside Task 2 because recorder.ts imports it at module top. Inline SW cleanup (Rule 3 — blocking dependency, plan acceptance gates on `npx tsc --noEmit` exit 0): - Remove src/background/index.ts VIDEO_CHUNK + VIDEO_CHUNK_SAVED case branches (refs to deleted union members). - Remove now-unreferenced loadChunkFromIndexedDB / openIndexedDB (only reachable from the deleted VIDEO_CHUNK_SAVED branch). - Remove now-unreferenced addVideoChunkFromBlob / cleanupVideoBuffer / firstChunkSaved / VIDEO_BUFFER_DURATION_MS constant (the SW-side ring buffer now lives in src/offscreen/recorder.ts per D-16). - Keep SW-side `videoBuffer: VideoChunk[] = []` as a placeholder; Plan 04 wires it to fetch from offscreen over the keepalive port. The remaining `getVideoBuffer` + `saveArchive` callers continue to compile against the empty array until Plan 04 lands. - Plan 05 owns the broader SW shell cleanup. Verification (post-commit): - npx vitest run tests/offscreen/ring-buffer.test.ts tests/offscreen/codec-check.test.ts → 6/6 PASS - npx tsc --noEmit → exit 0 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,6 @@ export type MessageType =
|
||||
| 'START_RECORDING'
|
||||
| 'STOP_RECORDING'
|
||||
| 'RECORDING_ERROR'
|
||||
| 'VIDEO_CHUNK'
|
||||
| 'VIDEO_CHUNK_SAVED'
|
||||
| 'OFFSCREEN_READY';
|
||||
|
||||
export interface Message<T = any> {
|
||||
@@ -23,6 +21,17 @@ export interface Message<T = any> {
|
||||
tabId?: number;
|
||||
}
|
||||
|
||||
// Типы сообщений в long-lived port (offscreen ↔ SW; D-17 / Plan 04)
|
||||
export type PortMessageType =
|
||||
| 'PING'
|
||||
| 'REQUEST_BUFFER'
|
||||
| 'BUFFER';
|
||||
|
||||
export interface PortMessage {
|
||||
type: PortMessageType;
|
||||
chunks?: VideoChunk[];
|
||||
}
|
||||
|
||||
// Видеобуфер
|
||||
export interface VideoChunk {
|
||||
data: Blob;
|
||||
|
||||
Reference in New Issue
Block a user