Milestone v1 (v2.0.0): Mokosh — Session Capture #1

Merged
strategy155 merged 297 commits from gsd/phase-04-harden-clean-up-optional into main 2026-05-31 15:34:17 +00:00
Showing only changes of commit f8a9c10758 - Show all commits

View File

@@ -1,5 +1,5 @@
import { Logger } from '../shared/logger';
import { base64ToBlob } from '../shared/binary';
import { base64ToBlob, blobToBase64 } from '../shared/binary';
import type {
Message,
TransferredVideoSegment,
@@ -391,14 +391,12 @@ async function downloadArchive(archiveBlob: Blob) {
logger.log(`Downloading archive: ${filename} (${archiveBlob.size} bytes)`);
// Конвертируем Blob в Data URL (работает в Service Worker)
const arrayBuffer = await archiveBlob.arrayBuffer();
const uint8Array = new Uint8Array(arrayBuffer);
let binary = '';
for (let i = 0; i < uint8Array.length; i++) {
binary += String.fromCharCode(uint8Array[i]);
}
const base64 = btoa(binary);
// WR-08 fix: delegate to the shared `blobToBase64` helper instead of
// re-implementing the same per-byte concat + btoa inline. Keeps the
// wire-format encoding single-source-of-truth (also used by the
// offscreen↔SW port; see src/shared/binary.ts) and ensures any future
// performance work (chunked apply, etc.) propagates to both call sites.
const base64 = await blobToBase64(archiveBlob);
const url = `data:application/zip;base64,${base64}`;
await chrome.downloads.download({