fablecut 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/history.js ADDED
@@ -0,0 +1,341 @@
1
+ /* ═══════════════════════════════════════════════════════════════════════════
2
+ Versions: a project's history, kept beside it, never destructive.
3
+
4
+ projects/<id>/history/v0007.json the document as it was
5
+ projects/<id>/history/v0007.meta.json {v, name, note, kind, created,
6
+ revision, clips, duration, final}
7
+
8
+ One pair of files per version, created with an exclusive open, so the
9
+ editor server and an MCP server can both save versions without a shared
10
+ index to race on. Kinds: manual (the user or an agent), auto (every few
11
+ minutes while the project changes), agent (before an agent rewrites or
12
+ starts editing it), restore (what was there before a restore).
13
+
14
+ Restoring a version first saves the current document as a version, then
15
+ writes the old one back with a new revision: nothing is ever lost.
16
+ ═══════════════════════════════════════════════════════════════════════════ */
17
+ "use strict";
18
+ const crypto = require("crypto");
19
+ const fs = require("fs");
20
+ const path = require("path");
21
+ const SeqLib = require("./sequences");
22
+
23
+ const KINDS = ["manual", "auto", "agent", "restore"];
24
+ const MAX_NAME = 120, MAX_NOTE = 2000;
25
+ const pad = (n) => String(n).padStart(4, "0");
26
+ const readJSON = (file) => JSON.parse(fs.readFileSync(file, "utf8").replace(/^/, ""));
27
+ function writeJSON(file, obj) {
28
+ const tmp = `${file}.${crypto.randomUUID()}.tmp`;
29
+ fs.writeFileSync(tmp, JSON.stringify(obj, null, 2));
30
+ fs.renameSync(tmp, file);
31
+ }
32
+ const timelineEnd = (doc) => (Array.isArray(doc.clips) ? doc.clips : [])
33
+ .reduce((m, c) => Math.max(m, (+c.start || 0) + (+c.duration || 0)), 0);
34
+ const fmtDur = (s) => { const t = Math.round(s); return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`; };
35
+
36
+ /* What changed from document a (older) to b (newer), for people and agents.
37
+ With several sequences, each one's timeline is compared with the same
38
+ sequence in the other document, whichever was open in either. */
39
+ const TIMELINE_SETTINGS = ["width", "height", "fps", "background", "inPoint", "outPoint"];
40
+ const TIMELINE_LISTS = ["tracks", "markers", "master", "buses", "delivery", "outputs", "exportFrame"];
41
+ function timelineDiff(a, b) {
42
+ const byId = (arr) => new Map((Array.isArray(arr) ? arr : []).filter((x) => x && x.id).map((x) => [x.id, x]));
43
+ const label = (c) => `${c.name ? `"${c.name}"` : c.kind || "clip"} (${c.id})`;
44
+ const ca = byId(a.clips), cb = byId(b.clips);
45
+ const added = [...cb.values()].filter((c) => !ca.has(c.id));
46
+ const removed = [...ca.values()].filter((c) => !cb.has(c.id));
47
+ const changed = [];
48
+ for (const [id, cn] of cb) {
49
+ const co = ca.get(id);
50
+ if (!co || JSON.stringify(co) === JSON.stringify(cn)) continue;
51
+ const what = [];
52
+ if (co.track !== cn.track) what.push(`track ${co.track}→${cn.track}`);
53
+ if (co.start !== cn.start || co.duration !== cn.duration || co.in !== cn.in) what.push("timing");
54
+ if (JSON.stringify(co.props || {}) !== JSON.stringify(cn.props || {})) {
55
+ const keys = new Set([...Object.keys(co.props || {}), ...Object.keys(cn.props || {})]);
56
+ const ks = [...keys].filter((k) => JSON.stringify((co.props || {})[k]) !== JSON.stringify((cn.props || {})[k]));
57
+ what.push(ks.length > 4 ? `${ks.length} props` : ks.join(", "));
58
+ }
59
+ if (JSON.stringify(co.keyframes || {}) !== JSON.stringify(cn.keyframes || {})) what.push("keyframes");
60
+ if (JSON.stringify(co.fx || []) !== JSON.stringify(cn.fx || [])) what.push("effects");
61
+ if (JSON.stringify([co.transitionIn, co.transitionOut]) !== JSON.stringify([cn.transitionIn, cn.transitionOut])) what.push("transitions");
62
+ if (co.mediaId !== cn.mediaId) what.push("source");
63
+ if (!what.length) what.push("other fields");
64
+ changed.push({ id, name: cn.name || null, kind: cn.kind, what });
65
+ }
66
+ const settings = [];
67
+ for (const k of TIMELINE_SETTINGS)
68
+ if ((a[k] ?? null) !== (b[k] ?? null)) settings.push(`${k} ${JSON.stringify(a[k] ?? null)}→${JSON.stringify(b[k] ?? null)}`);
69
+ for (const k of TIMELINE_LISTS)
70
+ if (JSON.stringify(a[k] ?? null) !== JSON.stringify(b[k] ?? null)) settings.push(k);
71
+ const lenA = timelineEnd(a), lenB = timelineEnd(b);
72
+ const lines = [];
73
+ if (added.length) lines.push(`${added.length} clip(s) added: ${added.slice(0, 8).map(label).join(", ")}${added.length > 8 ? ", …" : ""}`);
74
+ if (removed.length) lines.push(`${removed.length} clip(s) removed: ${removed.slice(0, 8).map(label).join(", ")}${removed.length > 8 ? ", …" : ""}`);
75
+ if (changed.length) lines.push(`${changed.length} clip(s) changed: ${changed.slice(0, 8).map((c) => `${label(c)} ${c.what.join("/")}`).join("; ")}${changed.length > 8 ? "; …" : ""}`);
76
+ if (Math.abs(lenA - lenB) > 0.005) lines.push(`length ${fmtDur(lenA)} → ${fmtDur(lenB)}`);
77
+ return { added, removed, changed, settings, lines };
78
+ }
79
+ function diffDocs(a, b) {
80
+ const brief = (c) => ({ id: c.id, name: c.name || null, kind: c.kind });
81
+ const byId = (arr) => new Map((Array.isArray(arr) ? arr : []).filter((x) => x && x.id).map((x) => [x.id, x]));
82
+ const ma = byId(a.media), mb = byId(b.media);
83
+ const mediaAdded = [...mb.values()].filter((m) => !ma.has(m.id)), mediaRemoved = [...ma.values()].filter((m) => !mb.has(m.id));
84
+ // the project's own settings; the canvas, IN / OUT, tracks, mix and delivery belong to a sequence
85
+ const renamed = (a.name ?? null) !== (b.name ?? null) ? [`name ${JSON.stringify(a.name ?? null)}→${JSON.stringify(b.name ?? null)}`] : [];
86
+ const shared = ["comps", "collections", "folders"].filter((k) => JSON.stringify(a[k] ?? null) !== JSON.stringify(b[k] ?? null));
87
+ const project = [...renamed, ...shared];
88
+ const several = SeqLib.entries(a).length > 1 || SeqLib.entries(b).length > 1;
89
+ const lines = [];
90
+ let main, settings;
91
+ const sequences = [];
92
+ if (!several) {
93
+ main = timelineDiff(a, b);
94
+ settings = [...renamed, ...main.settings, ...shared];
95
+ lines.push(...main.lines.filter((l) => !l.startsWith("length ")));
96
+ if (mediaAdded.length || mediaRemoved.length) lines.push(mediaLine(mediaAdded, mediaRemoved));
97
+ lines.push(...main.lines.filter((l) => l.startsWith("length ")));
98
+ if (settings.length) lines.push(`project: ${settings.join(", ")}`);
99
+ } else {
100
+ // each sequence against itself; the clip lists returned are the newer document's open sequence
101
+ const view = (doc, id) => SeqLib.open(JSON.parse(JSON.stringify(doc)), id);
102
+ const ea = new Map(SeqLib.entries(a).map((x) => [x.id, x])), eb = new Map(SeqLib.entries(b).map((x) => [x.id, x]));
103
+ const openB = SeqLib.activeId(b);
104
+ settings = project.slice();
105
+ for (const [id, s] of eb) {
106
+ if (!ea.has(id)) { lines.push(`sequence "${s.name}" added`); sequences.push({ id, name: s.name, added: true }); continue; }
107
+ const d = timelineDiff(view(a, id), view(b, id));
108
+ const nameOld = ea.get(id).name;
109
+ if (nameOld !== s.name) d.lines.unshift(`renamed from "${nameOld}"`);
110
+ if (d.settings.length) d.lines.push(`settings: ${d.settings.join(", ")}`);
111
+ if (id === openB) { main = d; settings.push(...d.settings); }
112
+ if (d.lines.length) { lines.push(...d.lines.map((l) => `"${s.name}": ${l}`)); sequences.push({ id, name: s.name, lines: d.lines }); }
113
+ }
114
+ for (const [id, s] of ea) if (!eb.has(id)) { lines.push(`sequence "${s.name}" removed`); sequences.push({ id, name: s.name, removed: true }); }
115
+ if (SeqLib.activeId(a) !== openB && ea.has(openB)) lines.push(`open sequence "${ea.get(SeqLib.activeId(a))?.name || SeqLib.activeId(a)}" → "${eb.get(openB).name}"`);
116
+ if (!main) main = timelineDiff({ clips: [] }, view(b, openB));
117
+ if (mediaAdded.length || mediaRemoved.length) lines.push(mediaLine(mediaAdded, mediaRemoved));
118
+ if (project.length) lines.push(`project: ${project.join(", ")}`);
119
+ }
120
+ return {
121
+ same: !lines.length, lines,
122
+ added: main.added.map(brief), removed: main.removed.map(brief),
123
+ changed: main.changed, mediaAdded: mediaAdded.map((m) => m.id), mediaRemoved: mediaRemoved.map((m) => m.id), settings,
124
+ ...(several ? { sequences } : {}),
125
+ };
126
+ }
127
+ const mediaLine = (added, removed) => `media ${added.length ? "+" + added.length : ""}${added.length && removed.length ? " " : ""}${removed.length ? "−" + removed.length : ""}`;
128
+
129
+ function createHistory({ projects, autoMinutes = 10, keepAuto = 30 }) {
130
+ const dir = (pid) => path.join(projects.DIR, pid, "history");
131
+ const docPath = (pid, v) => path.join(dir(pid), `v${pad(v)}.json`);
132
+ const metaPath = (pid, v) => path.join(dir(pid), `v${pad(v)}.meta.json`);
133
+ const resolve = (pid) => {
134
+ const id = pid || projects.activeId();
135
+ projects.mustExist(id);
136
+ return id;
137
+ };
138
+
139
+ function entries(pid) {
140
+ let files = [];
141
+ try { files = fs.readdirSync(dir(pid)).filter((f) => /^v\d+\.meta\.json$/.test(f)); } catch { }
142
+ const out = [];
143
+ for (const f of files) { try { out.push(readJSON(path.join(dir(pid), f))); } catch { } }
144
+ return out.sort((x, y) => y.v - x.v); // newest first
145
+ }
146
+ const entry = (pid, v) => {
147
+ const n = Number(String(v).replace(/^v/i, ""));
148
+ const e = Number.isInteger(n) && entries(pid).find((x) => x.v === n);
149
+ if (!e) throw new Error(`no version ${JSON.stringify(v)} of this project (versions lists them)`);
150
+ return e;
151
+ };
152
+
153
+ /* Save the project as it is now. */
154
+ function save(pid, { name, note, kind = "manual", final = false, doc } = {}) {
155
+ pid = resolve(pid);
156
+ if (!KINDS.includes(kind)) throw new Error(`kind must be one of ${KINDS.join(", ")}`);
157
+ const cur = doc || projects.readDoc(pid);
158
+ fs.mkdirSync(dir(pid), { recursive: true });
159
+ const have = entries(pid);
160
+ let v = (have[0]?.v || 0) + 1;
161
+ // an exclusive create claims the number; another process may have taken it
162
+ for (;; v++) {
163
+ try { fs.writeFileSync(docPath(pid, v), JSON.stringify(cur, null, 2), { flag: "wx" }); break; }
164
+ catch (e) { if (e.code !== "EEXIST") throw e; }
165
+ }
166
+ const meta = {
167
+ v, name: String(name || "").trim().slice(0, MAX_NAME) || defaultName(kind, v),
168
+ note: String(note || "").slice(0, MAX_NOTE), kind, created: new Date().toISOString(),
169
+ revision: cur.revision || 0, clips: (cur.clips || []).length, duration: +timelineEnd(cur).toFixed(2), final: false,
170
+ };
171
+ writeJSON(metaPath(pid, v), meta);
172
+ if (final) markFinal(pid, v, true);
173
+ if (kind === "auto") prune(pid);
174
+ return { project: pid, version: final ? entry(pid, v) : meta };
175
+ }
176
+ const defaultName = (kind, v) => ({ manual: `Version ${String(v).padStart(2, "0")}`, auto: "Auto-save", agent: "Before agent edits", restore: "Before restore" })[kind];
177
+
178
+ function prune(pid) {
179
+ const autos = entries(pid).filter((e) => e.kind === "auto" && !e.final);
180
+ for (const e of autos.slice(keepAuto)) remove(pid, e.v, { force: true });
181
+ }
182
+
183
+ function list(pid) {
184
+ pid = resolve(pid);
185
+ return { project: pid, versions: entries(pid) };
186
+ }
187
+ function get(pid, v) {
188
+ pid = resolve(pid);
189
+ return readJSON(docPath(pid, entry(pid, v).v));
190
+ }
191
+
192
+ /* Write a version back. What was there is saved first, so a restore can be undone by restoring that. */
193
+ function restore(pid, v) {
194
+ pid = resolve(pid);
195
+ const e = entry(pid, v);
196
+ const old = readJSON(docPath(pid, e.v));
197
+ const before = save(pid, { kind: "restore", name: `Before restoring v${e.v}` }).version;
198
+ const cur = projects.readDoc(pid);
199
+ // writeDoc lifts the open project's revision past this one, so tabs and agents see the change
200
+ projects.writeDoc(pid, { ...old, revision: Math.max(cur.revision || 0, old.revision || 0) });
201
+ return { project: pid, restored: e, saved: before };
202
+ }
203
+
204
+ /* What changed between two versions, or from a version to now (b default "current"). */
205
+ function diff(pid, a, b = "current") {
206
+ pid = resolve(pid);
207
+ const load = (x) => (x === "current" || x == null ? projects.readDoc(pid) : get(pid, x));
208
+ return { project: pid, from: a, to: b, ...diffDocs(load(a), load(b)) };
209
+ }
210
+
211
+ function markFinal(pid, v, on = true) {
212
+ const e = entry(pid, v);
213
+ if (on) for (const o of entries(pid)) if (o.final && o.v !== e.v) writeJSON(metaPath(pid, o.v), { ...o, final: false });
214
+ writeJSON(metaPath(pid, e.v), { ...e, final: !!on });
215
+ return entry(pid, e.v);
216
+ }
217
+ function update(pid, v, { name, note, final } = {}) {
218
+ pid = resolve(pid);
219
+ let e = entry(pid, v);
220
+ if (name != null || note != null) {
221
+ e = { ...e };
222
+ if (name != null) { const n = String(name).trim().slice(0, MAX_NAME); if (!n) throw new Error("name can't be empty"); e.name = n; }
223
+ if (note != null) e.note = String(note).slice(0, MAX_NOTE);
224
+ writeJSON(metaPath(pid, e.v), e);
225
+ }
226
+ if (final != null) e = markFinal(pid, e.v, !!final);
227
+ return { project: pid, version: e };
228
+ }
229
+ function remove(pid, v, { force = false } = {}) {
230
+ pid = resolve(pid);
231
+ const e = entry(pid, v);
232
+ if (e.final && !force) throw new Error(`v${e.v} is marked final — unmark it first`);
233
+ for (const f of [docPath(pid, e.v), metaPath(pid, e.v)]) { try { fs.unlinkSync(f); } catch { } }
234
+ return { project: pid, deleted: e.v };
235
+ }
236
+
237
+ /* Auto-save the open project when it changed and the last version is old enough. */
238
+ function maybeAuto(now = Date.now()) {
239
+ let cur;
240
+ try { cur = projects.readRoot(); } catch { return null; }
241
+ let pid = projects.peekActive();
242
+ if (!pid) {
243
+ if (!(cur.clips || []).length) return null; // nothing worth keeping yet
244
+ pid = projects.activeId(); // versions need the project's folder
245
+ }
246
+ const last = entries(pid)[0];
247
+ if (last && (last.revision === (cur.revision || 0) || now - new Date(last.created).getTime() < autoMinutes * 60000)) return null;
248
+ if (!last && !(cur.clips || []).length) return null; // nothing worth keeping yet
249
+ return save(pid, { kind: "auto", doc: cur }).version;
250
+ }
251
+
252
+ /* Before an agent changes the project: one version per session start / rewrite, not one per edit. */
253
+ function beforeAgent(name) {
254
+ const pid = projects.activeId();
255
+ const cur = projects.readDoc(pid);
256
+ const last = entries(pid)[0];
257
+ if (last && last.revision === (cur.revision || 0)) return null; // already saved as it is
258
+ return save(pid, { kind: "agent", name, doc: cur }).version;
259
+ }
260
+
261
+ /* A whole project with its versions, as one JSON file. */
262
+ function backup(pid) {
263
+ pid = resolve(pid);
264
+ const meta = projects.list({ archived: "all" }).projects.find((p) => p.id === pid) || {};
265
+ return {
266
+ fablecut: "backup", format: 1, created: new Date().toISOString(),
267
+ name: meta.name, notes: meta.notes || "", tags: meta.tags || [],
268
+ project: projects.readDoc(pid),
269
+ versions: entries(pid).reverse().map((e) => ({ ...e, project: readJSON(docPath(pid, e.v)) })),
270
+ };
271
+ }
272
+ function importBackup(b, { name, open = false } = {}) {
273
+ if (!b || b.fablecut !== "backup" || !b.project) throw new Error("not a FableCut backup");
274
+ const out = projects.importDoc(b.project, { name: name || b.name, open: false });
275
+ projects.update(out.id, { notes: b.notes || "", tags: b.tags || [] });
276
+ fs.mkdirSync(dir(out.id), { recursive: true });
277
+ // each version is checked like a project, and its details are worked out again from it
278
+ const isDoc = (d) => d && typeof d === "object" && !Array.isArray(d) && Array.isArray(d.clips) && Array.isArray(d.media);
279
+ const good = (Array.isArray(b.versions) ? b.versions : []).filter((e) => e && Number.isInteger(e.v) && e.v > 0 && isDoc(e.project));
280
+ const finalV = good.filter((e) => e.final === true).map((e) => e.v).pop(); // one final cut: the newest one marked
281
+ let n = 0;
282
+ for (const e of good) {
283
+ const created = typeof e.created === "string" && !isNaN(Date.parse(e.created)) ? e.created : new Date().toISOString();
284
+ writeJSON(docPath(out.id, e.v), e.project);
285
+ writeJSON(metaPath(out.id, e.v), {
286
+ v: e.v, name: String(e.name || "").trim().slice(0, MAX_NAME) || `Version ${String(e.v).padStart(2, "0")}`,
287
+ note: String(e.note || "").slice(0, MAX_NOTE), kind: KINDS.includes(e.kind) ? e.kind : "manual", created,
288
+ revision: e.project.revision || 0, clips: e.project.clips.length, duration: +timelineEnd(e.project).toFixed(2), final: e.v === finalV,
289
+ });
290
+ n++;
291
+ }
292
+ const res = open ? projects.open(out.id) : { id: out.id, project: projects.list({ archived: "all" }).projects.find((p) => p.id === out.id) };
293
+ return { ...res, versions: n };
294
+ }
295
+
296
+ /* project.json can't be read at startup: keep the broken file, put back the newest good copy. */
297
+ function recover(projectFile) {
298
+ const pid = projects.peekActive();
299
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
300
+ const aside = projectFile.replace(/\.json$/, `.corrupt-${stamp}.json`);
301
+ fs.renameSync(projectFile, aside);
302
+ const cands = [];
303
+ if (pid) {
304
+ for (const e of entries(pid)) {
305
+ let t = new Date(e.created).getTime();
306
+ if (!Number.isFinite(t)) { try { t = fs.statSync(docPath(pid, e.v)).mtimeMs; } catch { t = 0; } } // a meta file without a usable date
307
+ cands.push({ t, file: docPath(pid, e.v), from: `version v${e.v}` });
308
+ }
309
+ const parked = path.join(projects.DIR, pid, "project.json");
310
+ try { cands.push({ t: fs.statSync(parked).mtimeMs, file: parked, from: "its last saved copy" }); } catch { }
311
+ }
312
+ cands.sort((x, y) => y.t - x.t);
313
+ for (const c of cands) {
314
+ try {
315
+ const doc = readJSON(c.file);
316
+ // only a document the editor can open: the next candidate otherwise
317
+ if (!doc || typeof doc !== "object" || Array.isArray(doc) || !Array.isArray(doc.clips) || !Array.isArray(doc.media)) continue;
318
+ writeJSON(projectFile, { ...doc, revision: (doc.revision || 0) + 1 });
319
+ return { recovered: true, from: c.from, aside };
320
+ } catch { }
321
+ }
322
+ return { recovered: false, aside };
323
+ }
324
+
325
+ function act(a = {}) {
326
+ const pid = a.project || null;
327
+ switch (a.action || "list") {
328
+ case "list": return list(pid);
329
+ case "save": return save(pid, { name: a.name, note: a.note, final: !!a.final });
330
+ case "restore": return restore(pid, a.version);
331
+ case "diff": return diff(pid, a.version, a.to || "current");
332
+ case "update": return update(pid, a.version, a);
333
+ case "delete": return remove(pid, a.version);
334
+ default: throw new Error(`unknown action ${JSON.stringify(a.action)} (list|save|restore|diff|update|delete)`);
335
+ }
336
+ }
337
+
338
+ return { list, get, save, restore, diff, update, remove, maybeAuto, beforeAgent, backup, importBackup, recover, act };
339
+ }
340
+
341
+ module.exports = { createHistory, diffDocs, KINDS };
package/index.html CHANGED
@@ -15,6 +15,7 @@
15
15
  <!-- ══════════ TOP BAR ══════════ -->
16
16
  <header class="topbar">
17
17
  <div class="logo"><span class="logo-mark">▶</span> Fable<b>Cut</b></div>
18
+ <button type="button" class="btn tiny hidden" id="btnProjectsDash" title="Projects (Ctrl/Cmd+O): open, create, duplicate, archive">Projects</button>
18
19
  <div class="topbar-center" id="projectName">Untitled Project</div>
19
20
  <div class="topbar-right">
20
21
  <span class="btn-group ws-switch" id="wsSwitch" role="tablist" title="Workspace">
@@ -60,6 +61,17 @@
60
61
  <button type="button" data-tab="shapes" title="Shape layers and null objects">Shapes</button>
61
62
  <button type="button" data-tab="templates" title="Lower thirds, logo animations and social layouts — with fields you edit in the Inspector">Templates</button>
62
63
  </div>
64
+ <div class="bin-tools" id="binTools">
65
+ <input type="search" id="binSearch" class="bin-search" placeholder="Search name, #tag, codec, 4k…" aria-label="Search the Project bin" spellcheck="false" autocomplete="off">
66
+ <select id="binFilter" class="bin-filter" title="Show only…" aria-label="Show"></select>
67
+ <select id="binSort" class="bin-sort" title="Sort by" aria-label="Sort by">
68
+ <option value="name">Name</option><option value="kind">Kind</option><option value="duration">Duration</option>
69
+ <option value="resolution">Resolution</option><option value="fps">Frame rate</option><option value="codec">Codec</option>
70
+ <option value="audio">Audio channels</option><option value="size">File size</option><option value="usage">Times used</option>
71
+ </select>
72
+ <button type="button" class="btn tiny" id="binSortDir" title="Ascending — click for descending">↑</button>
73
+ <button type="button" class="btn tiny" id="binViewBtn" title="List view: metadata columns">☰</button>
74
+ </div>
63
75
  <input type="file" id="fileInput" class="sr-only" multiple accept="video/*,audio/*,image/*,.mp4,.mov,.webm,.mkv,.mp3,.wav,.m4a,.png,.jpg,.jpeg,.gif,.webp,.svg">
64
76
  <div class="bin-list" id="binList">
65
77
  <div class="bin-empty" id="binEmpty">
@@ -95,6 +107,7 @@
95
107
  <button class="btn tiny toggle" id="btnExportFrame" title="Toggle export frame overlay (drag handle to reframe)">⬒ Frame</button>
96
108
  <button type="button" class="btn tiny toggle hidden" id="btnExportFrameDim" aria-pressed="true" title="Lights off — crop to the export frame"><svg class="ico" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><g class="ef-bulb-rays" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><path d="M8 .4v1.05M1.7 3.45l.85.65M14.3 3.45l-.85.65"/></g><path class="ef-bulb-glass" fill="none" stroke="currentColor" stroke-width="1.55" stroke-linejoin="round" d="M8 1.7A4.1 4.1 0 0 0 3.9 5.8c0 1.62.86 2.72 1.8 3.5.38.32.62.68.62 1.15v.35h4.36v-.35c0-.47.24-.83.62-1.15.94-.78 1.8-1.88 1.8-3.5A4.1 4.1 0 0 0 8 1.7z"/><path fill="none" stroke="currentColor" stroke-width="1.45" stroke-linecap="square" d="M6.25 12.85h3.5M6.7 14.35h2.6"/></svg></button>
97
109
  <button class="btn tiny toggle" id="btnGuides" title="Toggle safe-area guides">▦ Safe</button>
110
+ <button class="btn tiny toggle proxy-btn" id="btnProxy" title="Play proxies while editing (export always uses the originals)">Proxy</button>
98
111
  <span class="dim" id="monitorRes"></span>
99
112
  </span>
100
113
  </div>
@@ -197,6 +210,7 @@
197
210
  <!-- ══════════ TIMELINE ══════════ -->
198
211
  <section class="panel timeline-panel" id="timelinePanel">
199
212
  <div class="timeline-toolbar">
213
+ <button type="button" class="btn tiny seq-btn" id="btnSequences" aria-haspopup="menu" title="Sequences"><svg class="ico" viewBox="0 0 16 16" width="13" height="13" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.5" d="M1.75 3.25h12.5M1.75 8h8.5M1.75 12.75h10.5"/></svg> <span class="seq-name">Main</span><span class="seq-count"></span> ▾</button>
200
214
  <span class="comp-crumb hidden" id="compCrumb" aria-label="Open composition"></span>
201
215
  <button class="btn tiny hidden" id="btnTrimIO" title="Trim clips to IN/OUT (⇧T)"><svg class="ico" viewBox="0 0 16 16" width="13" height="13" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="square" d="M1.25 4.5H12M4.5 1.25V12M4.5 12H14.75M12 4.5V14.75"/></svg> Trim</button>
202
216
  <button class="btn tiny toggle hidden" id="btnWorkAreaPlay" title="Limit playback to IN/OUT (Home/End jump to markers; playhead outside = override)"><svg class="ico" viewBox="0 0 16 16" width="13" height="13" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="square" stroke-linejoin="miter" d="M1.5 2.5V13.5M14.5 2.5V13.5M4.25 8H11.75M9.35 5.6L12 8L9.35 10.4"/></svg> Limit</button>
@@ -256,10 +270,37 @@
256
270
  </div>
257
271
  </div>
258
272
 
273
+ <!-- ══════════ PROJECTS ══════════ -->
274
+ <div class="overlay hidden" id="projectsOverlay">
275
+ <div class="dialog projects-dialog" id="projectsDialog" role="dialog" aria-modal="true" aria-labelledby="projectsTitle" tabindex="-1">
276
+ <div class="pj-head">
277
+ <h2 id="projectsTitle">Projects</h2>
278
+ <span class="btn-group pj-views" role="tablist">
279
+ <button type="button" class="btn tiny on" data-pj-view="active">All projects</button>
280
+ <button type="button" class="btn tiny" data-pj-view="archived">Archived</button>
281
+ </span>
282
+ <input type="search" id="pjSearch" class="pj-search" placeholder="Search name, notes, #tag" aria-label="Search projects" spellcheck="false" autocomplete="off">
283
+ <select id="pjSort" class="pj-sort" aria-label="Sort by" title="Sort by">
284
+ <option value="opened">Last opened</option><option value="modified">Last modified</option>
285
+ <option value="created">Created</option><option value="name">Name</option>
286
+ </select>
287
+ <label class="btn tiny" for="pjImportFile" title="Add a project file (.json): an old backup, or one from another machine">Import…</label>
288
+ <input type="file" id="pjImportFile" class="sr-only" accept=".json,application/json">
289
+ <button type="button" class="btn tiny accent" id="pjNewBtn">+ New project</button>
290
+ <button type="button" class="btn ghost pj-close" id="pjClose" aria-label="Close" title="Close (Esc)">✕</button>
291
+ </div>
292
+ <div class="pj-body">
293
+ <div class="pj-grid" id="pjGrid"></div>
294
+ <aside class="pj-side" id="pjSide"></aside>
295
+ </div>
296
+ </div>
297
+ </div>
298
+
259
299
  <!-- ══════════ EXPORT SETUP ══════════ -->
260
300
  <div class="overlay hidden" id="exportSetup">
261
- <div class="dialog">
262
- <h2>Export</h2>
301
+ <div class="dialog export-dialog" role="dialog" aria-modal="true" aria-labelledby="exportSetupTitle">
302
+ <h2 id="exportSetupTitle">Export</h2>
303
+ <div class="export-body">
263
304
  <div class="export-profile-row" id="exportRangeRow">
264
305
  <label class="export-profile-label" for="exportRangeSel">Range</label>
265
306
  <select class="export-profile-sel" id="exportRangeSel" aria-describedby="exportRangeNote">
@@ -276,11 +317,102 @@
276
317
  <input type="radio" name="engine" id="engineRealtime">
277
318
  <span><b>WebCodecs (HW encode)</b><br><span class="dim" id="engineWebCodecsNote">Frame-accurate. Browser encodes H.264; server muxes. Needs a modern Chromium and ffmpeg.</span></span>
278
319
  </label>
279
- <div class="export-profile-row" id="exportProfileRow">
280
- <label class="export-profile-label" for="exportProfileSel">Encoding profile</label>
320
+ <div class="export-profile-row dlv" id="exportProfileRow">
321
+ <div class="dlv-preset-line">
322
+ <label class="export-profile-label" for="exportProfileSel">Preset</label>
323
+ <span class="dlv-preset-actions">
324
+ <button type="button" class="btn tiny" id="dlvSaveBtn" title="Save these settings as a preset for every project">Save preset…</button>
325
+ <button type="button" class="btn tiny hidden" id="dlvDeleteBtn" title="Delete this saved preset">Delete</button>
326
+ </span>
327
+ </div>
281
328
  <select class="export-profile-sel" id="exportProfileSel" aria-describedby="exportProfileNote exportProfileHint"></select>
329
+ <div class="dlv-save-row hidden" id="dlvSaveRow">
330
+ <input type="text" id="dlvSaveName" maxlength="60" placeholder="Preset name, e.g. Client 4K" aria-label="Preset name">
331
+ <button type="button" class="btn tiny primary" id="dlvSaveOk">Save</button>
332
+ <button type="button" class="btn tiny" id="dlvSaveCancel">Cancel</button>
333
+ </div>
282
334
  <p class="dim export-profile-note" id="exportProfileNote"></p>
283
335
  <p class="dim export-profile-hint" id="exportProfileHint"></p>
336
+ <div class="dlv-body" id="dlvBody">
337
+ <details class="dlv-sec" id="dlvVideoSec" open>
338
+ <summary>Video</summary>
339
+ <div class="dlv-grid">
340
+ <label class="dlv-f">Resolution<select id="dlvRes"></select></label>
341
+ <label class="dlv-f dlv-wh hidden" id="dlvWhField">Width × height
342
+ <span class="dlv-wh-in"><input type="number" id="dlvW" min="16" max="8192" step="2" aria-label="Width"><span>×</span><input type="number" id="dlvH" min="16" max="8192" step="2" aria-label="Height"></span></label>
343
+ <label class="dlv-f" id="dlvReframeField">Reframe<select id="dlvReframe">
344
+ <option value="fill">Fill (crop to fit)</option>
345
+ <option value="fit">Fit (black bars)</option>
346
+ <option value="stretch">Stretch</option>
347
+ </select></label>
348
+ <label class="dlv-f">Frame rate<select id="dlvFps"></select></label>
349
+ <label class="dlv-f">Codec<select id="dlvCodec"></select></label>
350
+ <label class="dlv-f" id="dlvEncoderField">Encoder<select id="dlvEncoder"></select></label>
351
+ <label class="dlv-f" id="dlvProfileField">Profile<select id="dlvProfile"></select></label>
352
+ <label class="dlv-f" id="dlvRateField">Rate control<select id="dlvRate">
353
+ <option value="crf">CRF (constant quality)</option>
354
+ <option value="vbr">VBR (variable bitrate)</option>
355
+ <option value="cbr">CBR (constant bitrate)</option>
356
+ </select></label>
357
+ <label class="dlv-f" id="dlvCrfField">CRF<input type="number" id="dlvCrf" min="0" max="63" step="1" title="Lower = better quality, bigger file"></label>
358
+ <label class="dlv-f" id="dlvBitrateField">Bitrate (Mb/s)<input type="number" id="dlvBitrate" min="0.1" max="400" step="0.5"></label>
359
+ <label class="dlv-f" id="dlvMaxrateField">Max rate (Mb/s)<input type="number" id="dlvMaxrate" min="0.1" max="800" step="0.5" placeholder="none"></label>
360
+ <label class="dlv-f" id="dlvKeyintField">Keyframe every (s)<input type="number" id="dlvKeyint" min="0" max="20" step="0.5" title="0 = the encoder's default"></label>
361
+ <label class="dlv-f" id="dlvSpeedField">Encoder speed<select id="dlvSpeed">
362
+ <option value="fast">Fast</option>
363
+ <option value="balanced">Balanced</option>
364
+ <option value="best">Best quality (slow)</option>
365
+ </select></label>
366
+ <label class="dlv-f">Pixel format<select id="dlvPixFmt"></select></label>
367
+ <label class="dlv-f">Color<select id="dlvColor"></select></label>
368
+ <label class="dlv-f">Container<select id="dlvContainer"></select></label>
369
+ </div>
370
+ </details>
371
+ <details class="dlv-sec" id="dlvAudioSec" open>
372
+ <summary>Audio</summary>
373
+ <div class="dlv-grid">
374
+ <label class="dlv-f">Codec<select id="dlvACodec"></select></label>
375
+ <label class="dlv-f" id="dlvABitrateField">Bitrate (kb/s)<select id="dlvABitrate"></select></label>
376
+ <label class="dlv-f" id="dlvARateField">Sample rate<select id="dlvARate">
377
+ <option value="48000">48 kHz</option>
378
+ <option value="44100">44.1 kHz</option>
379
+ </select></label>
380
+ <label class="dlv-f" id="dlvAChField">Channels<select id="dlvACh">
381
+ <option value="2">Stereo</option>
382
+ <option value="1">Mono</option>
383
+ </select></label>
384
+ <label class="dlv-f" id="dlvLoudField">Loudness<select id="dlvLoud" title="Turn the whole mix up or down to an integrated loudness, with a true-peak limiter"></select></label>
385
+ <label class="dlv-f" id="dlvTpField">True peak (dBTP)<input type="number" id="dlvTp" min="-9" max="0" step="0.5"></label>
386
+ </div>
387
+ </details>
388
+ <details class="dlv-sec" id="dlvFileSec">
389
+ <summary>File name and metadata</summary>
390
+ <label class="dlv-f dlv-wide">File name
391
+ <input type="text" id="dlvFilename" maxlength="160" spellcheck="false" aria-describedby="dlvFilePreview dlvTokens"></label>
392
+ <p class="dim dlv-file-preview" id="dlvFilePreview"></p>
393
+ <p class="dim dlv-tokens" id="dlvTokens"></p>
394
+ <div class="dlv-grid dlv-meta">
395
+ <label class="dlv-f">Title<input type="text" id="dlvMetaTitle" maxlength="300"></label>
396
+ <label class="dlv-f">Artist / author<input type="text" id="dlvMetaArtist" maxlength="300"></label>
397
+ <label class="dlv-f">Copyright<input type="text" id="dlvMetaCopyright" maxlength="300"></label>
398
+ <label class="dlv-f">Date<input type="text" id="dlvMetaDate" maxlength="40" placeholder="2026-10-18"></label>
399
+ <label class="dlv-f dlv-wide">Description<textarea id="dlvMetaDescription" rows="2" maxlength="2000"></textarea></label>
400
+ <label class="dlv-f dlv-wide">Keywords<input type="text" id="dlvMetaKeywords" maxlength="300" placeholder="comma, separated"></label>
401
+ </div>
402
+ </details>
403
+ <p class="dim dlv-summary" id="dlvSummary"></p>
404
+ </div>
405
+ </div>
406
+ <div class="export-profile-row dlv-batch" id="dlvBatch">
407
+ <div class="dlv-preset-line">
408
+ <span class="export-profile-label">Batch outputs <span class="dim" id="dlvBatchCount"></span></span>
409
+ <span class="dlv-preset-actions">
410
+ <button type="button" class="btn tiny" id="dlvBatchAdd" title="Add the settings above to this project's outputs">+ Add these settings</button>
411
+ <button type="button" class="btn tiny" id="dlvBatchTypical" title="Master, YouTube 1080p, Reel 1080×1920, Square 1080 and a 720p preview">+ Typical set</button>
412
+ </span>
413
+ </div>
414
+ <p class="dim export-profile-hint" id="dlvBatchHint">One render, several files: every checked output is encoded from the same frames. Saved with the project.</p>
415
+ <ul class="dlv-batch-list" id="dlvBatchList"></ul>
284
416
  </div>
285
417
  <div class="export-wc-opts hidden" id="exportWcOpts">
286
418
  <label class="export-wc-field" for="exportWcBitrate">Bitrate
@@ -305,14 +437,33 @@
305
437
  </label>
306
438
  <p class="dim export-wc-hint">WebCodecs has no CRF — quality is driven by bitrate. VBR spends bits on hard frames; CBR holds a steady rate.</p>
307
439
  </div>
440
+ <div class="export-track-warn hidden" id="dlvWarn" role="status"></div>
308
441
  <div class="export-track-warn hidden" id="exportTrackWarn" role="status"></div>
442
+ </div>
309
443
  <div class="dialog-actions">
444
+ <button class="btn dlv-queue-open" id="btnOpenQueue" title="Show the export queue">Queue</button>
310
445
  <button class="btn" id="btnCancelSetup">Cancel</button>
446
+ <button class="btn" id="btnBatchExport" title="Queue every checked batch output and start">Export checked</button>
447
+ <button class="btn" id="btnQueueExport" title="Add these settings to the export queue">Add to queue</button>
311
448
  <button class="btn primary" id="btnStartExport">Export</button>
312
449
  </div>
313
450
  </div>
314
451
  </div>
315
452
 
453
+ <!-- ══════════ EXPORT QUEUE ══════════ -->
454
+ <div class="overlay hidden" id="exportQueue">
455
+ <div class="dialog export-dialog" role="dialog" aria-modal="true" aria-labelledby="exportQueueTitle">
456
+ <h2 id="exportQueueTitle">Export queue</h2>
457
+ <p class="dim" id="exportQueueNote"></p>
458
+ <div class="export-body"><ol class="xq-list" id="exportQueueList"></ol></div>
459
+ <div class="dialog-actions">
460
+ <button class="btn" id="btnQueueClear">Clear finished</button>
461
+ <button class="btn" id="btnQueueClose">Close</button>
462
+ <button class="btn primary" id="btnQueueStart">Start</button>
463
+ </div>
464
+ </div>
465
+ </div>
466
+
316
467
  <!-- ══════════ EXPORT OVERLAY ══════════ -->
317
468
  <div class="overlay hidden" id="exportOverlay">
318
469
  <div class="dialog">
@@ -445,12 +596,32 @@
445
596
  <table class="keys">
446
597
  <tr><td><kbd>Ctrl</kbd>+click bin</td><td>Import media files</td></tr>
447
598
  <tr><td>Right-click <b>Project</b> tab</td><td>New folder · New composition</td></tr>
599
+ <tr><td>Bin search</td><td>Name, kind, codec, <code>2160p</code> or a tag; <code>#tag</code> matches tags only · <kbd>Esc</kbd> clears</td></tr>
600
+ <tr><td>Right-click a bin file</td><td>Find timeline instances · Media info · favorites · Tags · collections</td></tr>
601
+ <tr><td>☆ / uses badge on a bin file</td><td>Star it · list where it is used (click one to jump there)</td></tr>
602
+ <tr><td>☰ in the bin</td><td>List view with metadata columns · click a heading to sort</td></tr>
603
+ <tr><td>Right-click a clip</td><td><b>Reveal in project</b> — show its file in the bin</td></tr>
604
+ <tr><td>Right-click a bin file</td><td><b>Relink…</b> — point it at the footage where it is now · <b>Replace file…</b> — a new file for every clip that uses it</td></tr>
605
+ <tr><td>Right-click a bin video</td><td><b>Create proxy</b> — a light copy to edit with (right-click the Project tab for all of them) · <b>Proxy</b> above the monitor plays proxies on / off; export always uses the originals</td></tr>
448
606
  <tr><td>Comp clip / bin comp</td><td>Double-click to open it on the timeline · drag a bin comp onto the timeline to place it · the breadcrumb above the timeline steps back out</td></tr>
449
607
  <tr><td>Right-click clips</td><td><b>Precompose</b> — move the selection into a new comp</td></tr>
450
608
  <tr><td><kbd>Esc</kbd> inside a comp</td><td>Back out one level (once nothing is selected)</td></tr>
451
609
  <tr><td><b>Templates</b> tab</td><td>Drag a lower third, logo animation or social layout onto the timeline (or click +) · fill in its fields in the Inspector's <b>Template</b> section · right-click a comp → <b>Save as template</b></td></tr>
452
610
  </table>
453
611
  </section>
612
+ <section class="keys-sec">
613
+ <h3>Projects <span>top bar → Projects</span></h3>
614
+ <table class="keys">
615
+ <tr><td><kbd>Ctrl/Cmd</kbd>+<kbd>O</kbd></td><td>Open the Projects dashboard (or click the project name)</td></tr>
616
+ <tr><td><kbd>Ctrl/Cmd</kbd>+<kbd>S</kbd></td><td>Save a version of the open project (every edit is saved anyway; a version is a point to come back to)</td></tr>
617
+ <tr><td>Project → <b>Versions…</b></td><td>Compare a version with now · <b>Restore…</b> (click twice; what is there is saved as a version first) · mark the final cut</td></tr>
618
+ <tr><td>Timeline toolbar → <b>sequence menu</b></td><td>Open another sequence of this project · <b>New sequence…</b> (any canvas, empty or a copy) · <b>Duplicate</b> · <b>Rename…</b> · <b>Delete…</b> (click twice; kept as a version first)</td></tr>
619
+ <tr><td>Project card</td><td>Click to see its details, notes and tags · double-click to open it</td></tr>
620
+ <tr><td><kbd>Enter</kbd> on a card</td><td>Open that project</td></tr>
621
+ <tr><td><kbd>Esc</kbd></td><td>Back out of <b>New project</b>, then close the dashboard</td></tr>
622
+ <tr><td><b>Delete…</b> (Archived)</td><td>Click twice — only archived projects can be deleted</td></tr>
623
+ </table>
624
+ </section>
454
625
  <section class="keys-sec">
455
626
  <h3>Color workspace</h3>
456
627
  <table class="keys">
@@ -500,7 +671,11 @@
500
671
  <script src="color.js"></script>
501
672
  <script src="edit-ops.js"></script>
502
673
  <script src="comp.js"></script>
674
+ <script src="sequences.js"></script>
503
675
  <script src="templates.js"></script>
676
+ <script src="media-lib.js"></script>
677
+ <script src="delivery.js"></script>
678
+ <script src="mp4-demux.js"></script>
504
679
  <script src="app.js"></script>
505
680
  </body>
506
681
  </html>