// A CLIP OF THE VISITOR'S OWN COPY, CUT IN THE BROWSER (lane browser-clip). // // The export site can stream-copy a part of a file the visitor picked — no // re-encode, nothing uploaded — between the modal's Clip in / Clip out marks. // The marks are on the CUE clock; the file is reached through the visitor's // offset (lib/localFileClock.ts): fileTime = cueTime + offset. // // A stream copy starts on a keyframe, so the clip may start a little before // the in mark; the page says where BEFORE the visitor saves (describeClip). // // This module is the pure part: the time maths, the sentences, the saved // file's name and the output format. No I/O, no library import — the copy // itself is lib/localClipEngine.ts, loaded only when a clip is asked for. import { formatOffset } from "./localFileClock"; // Shorter than this is not a clip. export const MIN_CLIP_SECONDS = 0.1; // A keyframe this close to the in mark is "at the mark". export const AT_MARK_SECONDS = 0.05; // Built in memory, a clip can be at most this big. It is held about twice // over at its peak (the written parts, then the Blob made from them), so a // clip at the limit stays near half a gigabyte; the real bytes written are // checked against it as the clip is made, since the estimate can be low. export const MEMORY_LIMIT_BYTES = 256_000_000; // Above this estimate, a browser that can write straight to disk does: half // the memory limit, so an estimate that is low by up to 2x still fits. export const DISK_SAVE_ABOVE_BYTES = 128_000_000; // The longest title part of a saved file's name. const NAME_MAX = 80; export type FileRange = | { ok: true; fileIn: number; fileOut: number } | { ok: false; reason: "order" | "short" | "outside" }; // The marks (cue clock) as a range of the file, clamped to the file's own // first and last timestamps (on the