fablecut 1.18.0 → 1.19.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/app.js CHANGED
@@ -110,9 +110,19 @@ const FILTER_PRESETS = {
110
110
  };
111
111
  const SYSTEM_FONTS = ["Segoe UI", "Arial", "Georgia", "Impact", "Courier New",
112
112
  "Trebuchet MS", "Verdana", "Times New Roman", "Comic Sans MS", "Consolas"];
113
- const GOOGLE_FONTS = ["Anton", "Archivo Black", "Abril Fatface", "Barlow", "Bebas Neue",
114
- "Caveat", "Inter", "Lobster", "Montserrat", "Oswald", "Pacifico", "Permanent Marker",
115
- "Playfair Display", "Poppins", "Roboto", "Roboto Condensed", "Teko"];
113
+ /* Google fonts offered in the font picker, by look. Any other Google Font loads by name too. */
114
+ const GOOGLE_FONT_GROUPS = {
115
+ Display: ["Anton", "Archivo Black", "Bebas Neue", "Bangers", "Bungee", "Oswald", "Teko", "Russo One",
116
+ "Alfa Slab One", "Black Ops One", "Righteous", "Fjalla One", "Unbounded", "Syne"],
117
+ Sans: ["Inter", "Montserrat", "Poppins", "Roboto", "Roboto Condensed", "Barlow", "Lato", "Open Sans", "Raleway",
118
+ "Nunito", "Work Sans", "DM Sans", "Rubik", "Kanit", "Lexend", "Outfit", "Sora", "Space Grotesk", "Josefin Sans", "Fredoka"],
119
+ Serif: ["Playfair Display", "Abril Fatface", "Cinzel", "Cormorant Garamond", "Lora", "Merriweather",
120
+ "DM Serif Display", "Libre Baskerville", "Marcellus"],
121
+ "Script & hand": ["Caveat", "Pacifico", "Lobster", "Permanent Marker", "Dancing Script", "Great Vibes",
122
+ "Satisfy", "Shadows Into Light", "Kalam"],
123
+ "Retro & mono": ["Monoton", "Press Start 2P", "Special Elite", "Space Mono", "VT323", "Courier Prime"],
124
+ };
125
+ const GOOGLE_FONTS = Object.values(GOOGLE_FONT_GROUPS).flat();
116
126
 
117
127
  /* ── Title styles: cohesive one-tap looks. Each bundles a DIFFERENT font,
118
128
  placement and animation, so titles vary instead of all looking basic.
@@ -121,7 +131,7 @@ const FONT_CUT_DEFAULT = ["Anton", "Bebas Neue", "Archivo Black", "Oswald", "Imp
121
131
  const STYLE_RESET = { // decorative props a style owns; reset before applying
122
132
  color2: "", glow: 0, glowColor: "", strokeWidth: 0, bgColor: "#000000", bgOpacity: 0,
123
133
  rotation: 0, letterSpacing: 0, uppercase: false, italic: false, textShadow: 12,
124
- fontCutSet: undefined, align: "center",
134
+ fontCutSet: undefined, align: "center", weight: 0, strokeColor: "#000000", highlightColor: "#ffd166",
125
135
  };
126
136
  const TITLE_STYLES = {
127
137
  plain: { label: "Plain", place: "center", props: { font: "Segoe UI", fontSize: 72, bold: true, color: "#ffffff", textAnim: "none" } },
@@ -134,8 +144,20 @@ const TITLE_STYLES = {
134
144
  subtitle: { label: "Subtitle", place: "lower", props: { font: "Roboto", fontSize: 52, bold: false, color: "#ffffff", bgColor: "#000000", bgOpacity: 0.5, textAnim: "karaoke" } },
135
145
  boldRise: { label: "Bold rise", place: "lower", props: { font: "Archivo Black", fontSize: 92, bold: false, uppercase: true, color: "#ffffff", textAnim: "rise-mask" } },
136
146
  luxury: { label: "Luxury", place: "center", props: { font: "Cinzel", fontSize: 88, bold: false, uppercase: true, color: "#faf0dc", color2: "#c9a227", letterSpacing: 6, textAnim: "clip-reveal" } },
147
+ popOutline: { label: "Pop outline", place: "center", props: { font: "Montserrat", fontSize: 100, bold: false, weight: 900, uppercase: true, color: "#ffd166", strokeWidth: 6, strokeColor: "#111111", textShadow: 0, textAnim: "letter-pop" } },
148
+ boxed: { label: "Boxed", place: "lower", props: { font: "Inter", fontSize: 60, bold: false, weight: 800, color: "#111111", bgColor: "#ffffff", bgOpacity: 0.95, textShadow: 0, textAnim: "word-slide" } },
149
+ headline: { label: "Headline", place: "center", props: { font: "Montserrat", fontSize: 92, bold: false, weight: 900, uppercase: true, color: "#ffffff", highlightColor: "#ff4d6d", strokeWidth: 4, strokeColor: "#000000", textShadow: 0, textAnim: "highlight" } },
150
+ comic: { label: "Comic", place: "center", props: { font: "Bangers", fontSize: 112, bold: false, color: "#ffe14d", strokeWidth: 8, strokeColor: "#1a1a1a", rotation: -3, letterSpacing: 2, textShadow: 0, textAnim: "bounce" } },
151
+ typewriter: { label: "Typewriter", place: "lower-left", props: { font: "Special Elite", fontSize: 64, bold: false, color: "#f5f0e6", textShadow: 6, textAnim: "typewriter" } },
152
+ minimal: { label: "Minimal", place: "center", props: { font: "Inter", fontSize: 60, bold: false, weight: 300, uppercase: true, color: "#ffffff", letterSpacing: 12, textShadow: 0, textAnim: "rise-mask" } },
153
+ script: { label: "Script", place: "center", props: { font: "Great Vibes", fontSize: 120, bold: false, color: "#ffffff", color2: "#f9c5d1", textShadow: 10, textAnim: "clip-reveal" } },
154
+ retro: { label: "Retro", place: "center", props: { font: "Monoton", fontSize: 96, bold: false, uppercase: true, color: "#ff6ec7", glow: 40, glowColor: "#ff6ec7", textAnim: "letter-pop" } },
155
+ sticker: { label: "Sticker", place: "lower", props: { font: "Fredoka", fontSize: 80, bold: false, weight: 700, color: "#ffffff", bgColor: "#7b6cff", bgOpacity: 1, rotation: -2, textShadow: 0, textAnim: "word-pop" } },
156
+ glitch: { label: "Glitch", place: "center", props: { font: "Russo One", fontSize: 100, bold: false, uppercase: true, color: "#e8f9ff", glow: 30, glowColor: "#ff2e63", letterSpacing: 2, textAnim: "shake" } },
157
+ cinematic: { label: "Cinematic", place: "center", props: { font: "Cormorant Garamond", fontSize: 84, bold: false, weight: 500, uppercase: true, color: "#f2efe9", letterSpacing: 14, textShadow: 8, textAnim: "rise-mask" } },
137
158
  };
138
- const STYLE_CYCLE = ["impact", "elegant", "kinetic", "neon", "handwritten", "serifDrop", "boldRise", "luxury"];
159
+ const STYLE_CYCLE = ["impact", "elegant", "kinetic", "neon", "handwritten", "serifDrop", "boldRise", "luxury",
160
+ "popOutline", "boxed", "comic", "typewriter", "script", "sticker", "cinematic"];
139
161
  const AUDIO_EXT = /\.(mp3|wav|ogg|m4a|aac|flac|mpeg)$/i;
140
162
  const VIDEO_EXT = /\.(mp4|webm|mov|mkv|m4v)$/i;
141
163
  const IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
@@ -477,6 +499,9 @@ const DEFAULT_SETTINGS = {
477
499
  webCodecsBitrateMode: "variable", // "variable" | "constant"
478
500
  snapTargets: { clips: true, playhead: true, markers: true, inout: true, keyframes: false, frames: true },
479
501
  useProxies: true, // play proxies (when a file has one) while editing; export always reads the original
502
+ exportAsk: true, // Export opens its dialog (name + settings) first; false = render straight away
503
+ exportEngine: null, // "fast" | "second" — what the last export used ("Don't ask again" reuses it)
504
+ exportChoice: null, // the Export dialog's preset / profile last used ("d:<preset>" | "p:<profile>"), reused with it
480
505
  };
481
506
  let settings = { ...DEFAULT_SETTINGS };
482
507
  function loadSettings() {
@@ -1746,6 +1771,8 @@ async function syncFromServer(force) {
1746
1771
  // another project was opened (the dashboard, another tab, an agent)
1747
1772
  const pid = res.headers.get("X-FableCut-Project");
1748
1773
  const switched = !!(pid && runtime.projectId && pid !== runtime.projectId);
1774
+ if (switched && runtime.jobHold) { runtime.pendingSync = true; return false; } // an agent's job is rendering this project
1775
+ if (pid && pid !== runtime.projectId && cmdk.pid && cmdkOpen()) closeCmdk(false); // its results were for the other project
1749
1776
  if (pid) runtime.projectId = pid;
1750
1777
  if (switched) {
1751
1778
  onProjectSwitched();
@@ -3419,7 +3446,7 @@ function pjNewHtml() {
3419
3446
  async function pjOpenProject(id) {
3420
3447
  const p = pj.list.find((x) => x.id === id);
3421
3448
  if (!p || p.active || pj.busy) return;
3422
- if (state.exporting) { toast("Wait for the export to finish before switching projects"); return; }
3449
+ if (exportBusy()) { toast("Wait for the export to finish before switching projects"); return; }
3423
3450
  pj.busy = true;
3424
3451
  try {
3425
3452
  if (!(await flushSaveBeforeSwitch())) return;
@@ -3441,7 +3468,7 @@ async function pjAction(act, btn) {
3441
3468
  if (act === "new-cancel") { pj.mode = "detail"; renderProjects(); return; }
3442
3469
  if (act === "new-create") {
3443
3470
  if (pj.busy) return;
3444
- if (state.exporting) { toast("Wait for the export to finish before switching projects"); return; }
3471
+ if (exportBusy()) { toast("Wait for the export to finish before switching projects"); return; }
3445
3472
  const name = ($("pjNewName")?.value || "").trim() || "Untitled Project";
3446
3473
  const fps = $("pjNewFps")?.value;
3447
3474
  pj.busy = true;
@@ -3618,7 +3645,7 @@ async function pjVersionRun(act, btn) {
3618
3645
  setTimeout(() => { if (btn.isConnected) { btn.dataset.armed = ""; btn.textContent = "Restore…"; } }, 3000);
3619
3646
  return;
3620
3647
  }
3621
- if (p.active && state.exporting) { toast("Wait for the export to finish before restoring"); return; }
3648
+ if (p.active && exportBusy()) { toast("Wait for the export to finish before restoring"); return; }
3622
3649
  if (p.active && !(await flushSaveForVersion("nothing was restored"))) return;
3623
3650
  const out = await post({ action: "restore", version: v });
3624
3651
  if (!out) return;
@@ -6847,7 +6874,8 @@ function renderInspector(lite) {
6847
6874
  ${row("Family", `<select data-k="font">
6848
6875
  ${fontGroup("System", SYSTEM_FONTS)}
6849
6876
  ${fontGroup("Library fonts", runtime.customFonts)}
6850
- ${fontGroup("Google fonts", [...new Set([...GOOGLE_FONTS, ...runtime.googleLoaded])])}
6877
+ ${Object.entries(GOOGLE_FONT_GROUPS).map(([g, list]) => fontGroup("Google · " + g, list)).join("")}
6878
+ ${fontGroup("Google · loaded by name", [...runtime.googleLoaded].filter((f) => !GOOGLE_FONTS.includes(f)))}
6851
6879
  ${known.includes(p.font) ? "" : `<option selected>${p.font}</option>`}
6852
6880
  </select>`, "", "font")}
6853
6881
  ${row("Google font", `<input type="text" data-gfont placeholder="Type any Google Font name…">
@@ -8879,6 +8907,8 @@ function cutSilences() {
8879
8907
  const TRANSCRIBE_KEY = "fablecut-transcribe";
8880
8908
  const trState = { open: false, built: false, busy: null, sig: "", words: [], sel: null, anchor: null, drag: false, query: "", hits: [], now: -1 };
8881
8909
  const transcriptCache = new Map(); // src → validated transcript | false (none) | Promise while asking the server
8910
+ const transcriptHeld = new Map(); // src → the last transcript (or false) shown, kept while a refresh is pending
8911
+ const transcriptStale = new Set(); // srcs whose shown transcript the server hasn't confirmed (a failed read or save)
8882
8912
  let transcriptGen = 0; // bumps whenever a transcript arrives or changes: the tab redraws
8883
8913
  function transcribeSettings() {
8884
8914
  let o = {};
@@ -8901,16 +8931,34 @@ function transcriptOf(src) {
8901
8931
  function loadTranscript(src, force = false) {
8902
8932
  const have = transcriptCache.get(src);
8903
8933
  if (!force && have !== undefined) return have instanceof Promise ? have : Promise.resolve(have);
8904
- const p = fetch("/api/transcript?src=" + encodeURIComponent(src)).then((r) => (r.ok ? r.json() : null))
8934
+ return readTranscript(src).then((r) => r.doc);
8935
+ }
8936
+ /** One read from the server → {doc, ok}: ok only when this read answered (a transcript, or that
8937
+ there is none) and no later read has replaced it. A read that fails (a server error, no network,
8938
+ a document that doesn't validate) keeps what was shown, marked unconfirmed. */
8939
+ function readTranscript(src) {
8940
+ let p = null;
8941
+ const read = fetch("/api/transcript?src=" + encodeURIComponent(src))
8942
+ .then((r) => (r.ok ? r.json() : r.status === 404 ? { transcript: null } : Promise.reject(new Error("HTTP " + r.status))))
8905
8943
  .then((j) => {
8906
- let d = false;
8907
- try { d = j && j.transcript ? FableCutTranscribe.validate(j.transcript) : false; } catch { }
8908
- if (transcriptCache.get(src) === p) { transcriptCache.set(src, d); transcriptGen++; }
8909
- return d;
8944
+ const d = j && j.transcript ? FableCutTranscribe.validate(j.transcript) : false;
8945
+ const latest = transcriptCache.get(src) === p;
8946
+ if (latest) { setTranscript(src, d); transcriptStale.delete(src); }
8947
+ return { doc: d, ok: latest };
8910
8948
  })
8911
- .catch(() => { if (transcriptCache.get(src) === p) transcriptCache.set(src, false); return false; });
8949
+ .catch(() => {
8950
+ const d = transcriptHeld.get(src) || false;
8951
+ if (transcriptCache.get(src) === p) { setTranscript(src, d); transcriptStale.add(src); }
8952
+ return { doc: d, ok: false };
8953
+ });
8954
+ p = read.then((r) => r.doc);
8912
8955
  transcriptCache.set(src, p);
8913
- return p;
8956
+ return read;
8957
+ }
8958
+ function setTranscript(src, d) {
8959
+ transcriptCache.set(src, d);
8960
+ transcriptHeld.set(src, d);
8961
+ transcriptGen++;
8914
8962
  }
8915
8963
  function onTranscriptEvent(data) {
8916
8964
  let src = null;
@@ -8989,8 +9037,8 @@ async function transcribeFile(src, { model, language, onProgress, cancelled }) {
8989
9037
  const doc = T.validate({ src, model, language: language || "auto", duration, created: new Date().toISOString(), words });
8990
9038
  let saved = false;
8991
9039
  try { saved = (await fetch("/api/transcript?src=" + encodeURIComponent(src), { method: "POST", body: JSON.stringify(doc) })).ok; } catch { }
8992
- transcriptCache.set(src, doc);
8993
- transcriptGen++;
9040
+ setTranscript(src, doc);
9041
+ if (saved) transcriptStale.delete(src); else transcriptStale.add(src);
8994
9042
  return { doc, saved };
8995
9043
  }
8996
9044
  /** Transcribe files one after another. `beat(fraction)` hears about progress (an agent's job). */
@@ -9050,14 +9098,23 @@ function transcriptWords() {
9050
9098
  /** What Transcribe works on: the selected clips' files, else every file on the timeline without a transcript. */
9051
9099
  function transcribeTargets() {
9052
9100
  const groups = transcriptGroups();
9101
+ // a selected clip picks the file its speech group is heard from (a picture's sound may come
9102
+ // from denoised stems, another file): the group counts when it or a clip linked to it is selected
9053
9103
  const picked = new Set();
9054
- for (const id of state.selIds) {
9055
- const c = getClip(id);
9056
- if (c && (c.kind === "video" || c.kind === "audio")) { const m = getMedia(c.mediaId); if (m) picked.add(m.src); }
9104
+ for (const g of groups) {
9105
+ const ids = new Set(withLinked(g).map((c) => c.id));
9106
+ if ([...ids].some((id) => state.selIds.has(id))) picked.add(getMedia(g[0].mediaId).src);
9057
9107
  }
9058
9108
  const srcs = [...new Set(groups.map((g) => getMedia(g[0].mediaId).src))];
9059
9109
  const sel = srcs.filter((s) => picked.has(s));
9060
- return sel.length ? { srcs: sel, selected: true } : { srcs: srcs.filter((s) => transcriptCache.get(s) === false), selected: false };
9110
+ if (sel.length) return { srcs: sel, selected: true };
9111
+ // a selection with no speech in it (a title) never turns into a timeline-wide action
9112
+ if (state.selIds.size) return { srcs: [], selected: false, none: true };
9113
+ const missing = srcs.filter((s) => transcriptCache.get(s) === false);
9114
+ // every file has a transcript already (an agent may have made them): the button offers them all again
9115
+ if (!missing.length && srcs.length && srcs.every((s) => transcriptCache.get(s) && !(transcriptCache.get(s) instanceof Promise)))
9116
+ return { srcs, selected: false, again: true };
9117
+ return { srcs: missing, selected: false };
9061
9118
  }
9062
9119
  /** What the words' places depend on: the timeline and the transcripts. */
9063
9120
  function transcriptWordsSig() {
@@ -9192,15 +9249,32 @@ function renderTranscript(force = false) {
9192
9249
  const words = trState.words = transcriptWords();
9193
9250
  trState.wsig = transcriptWordsSig();
9194
9251
  const tgt = transcribeTargets();
9195
- E.go.textContent = tgt.selected ? `Transcribe selected (${tgt.srcs.length})` : tgt.srcs.length ? `Transcribe ${tgt.srcs.length} file${tgt.srcs.length === 1 ? "" : "s"}` : "Transcribe";
9252
+ E.go.textContent = tgt.selected ? `Transcribe selected (${tgt.srcs.length})` : tgt.again ? `Transcribe again (${tgt.srcs.length})`
9253
+ : tgt.srcs.length ? `Transcribe ${tgt.srcs.length} file${tgt.srcs.length === 1 ? "" : "s"}` : "Transcribe";
9196
9254
  E.go.disabled = !!trState.busy || !tgt.srcs.length;
9197
- E.go.title = tgt.srcs.length ? "Turn the speech into words, in this browser (the model downloads once). Select clips to transcribe just those, or again"
9198
- : groups.length ? "Every file on the timeline has a transcript — select clips to transcribe them again" : "Put clips with speech on the timeline first";
9255
+ E.go.title = tgt.again ? "Every file on the timeline has a transcript. Transcribe them all again, with the model and language picked here (or select clips to redo just those)"
9256
+ : tgt.srcs.length ? "Turn the speech into words, in this browser (the model downloads once). Select clips to transcribe just those, or again"
9257
+ : tgt.none ? "The selected clips have no speech. Select clips with speech to transcribe those, or clear the selection to transcribe the timeline's files"
9258
+ : "Put clips with speech on the timeline first";
9199
9259
  const missing = [...new Set(groups.map((g) => getMedia(g[0].mediaId)).filter((m) => transcriptCache.get(m.src) === false).map((m) => m.name || m.src))];
9200
9260
  let html = "";
9201
9261
  if (!groups.length) html = `<div class="tr-empty">Put clips with speech on the timeline, then transcribe them here. Speech becomes words in this browser; your audio never leaves it.</div>`;
9202
9262
  else {
9203
9263
  if (missing.length) html += `<div class="tr-note">No transcript yet: ${missing.slice(0, 6).map(escapeHtml).join(", ")}${missing.length > 6 ? ` +${missing.length - 6} more` : ""}</div>`;
9264
+ // which model and language made these words, so wrong words point at the fix
9265
+ const docs = groups.map((g) => transcriptCache.get(getMedia(g[0].mediaId).src)).filter((d) => d && d.words);
9266
+ const made = new Map();
9267
+ for (const d of docs) made.set(JSON.stringify([d.model ?? null, d.language ?? null]), d);
9268
+ if (made.size) {
9269
+ const said = [...made.values()].map((d) => {
9270
+ const model = d.model == null ? "an unknown model" : T.MODELS[d.model]?.label || d.model;
9271
+ const lang = d.language == null ? "an unknown language" : d.language === "" || d.language === "auto" ? "auto-detected" : T.LANGUAGES[d.language] || d.language;
9272
+ return `${escapeHtml(model)}, ${escapeHtml(lang)}`;
9273
+ });
9274
+ // with some files still untranscribed the button does those, so redoing others takes a selection
9275
+ const how = tgt.selected ? "then Transcribe selected" : tgt.again ? "then Transcribe again" : "select those clips, then Transcribe selected";
9276
+ html += `<div class="tr-note tr-made">Transcribed with ${said.join("; ")}. Words look wrong? Pick the language spoken and the Small model above, ${how}.</div>`;
9277
+ }
9204
9278
  if (!words.length && !missing.length) html += `<div class="tr-empty">${[...transcriptCache.values()].some((v) => v instanceof Promise) ? "Loading…" : "No words in these clips."}</div>`;
9205
9279
  for (const s of T.segments(words)) {
9206
9280
  let p = "";
@@ -9306,10 +9380,32 @@ function copyTranscript() {
9306
9380
  navigator.clipboard.writeText(lines.join("\n")).then(() => toast(`Copied ${lines.length} line${lines.length === 1 ? "" : "s"}`), () => toast("Couldn't copy — the browser refused"));
9307
9381
  }
9308
9382
  async function transcribeFromTab() {
9309
- const { srcs } = transcribeTargets();
9310
- if (!srcs.length) { toast("Put a clip with speech on the timeline first"); return; }
9383
+ // what the click meant is taken now (its files, its model and language); a selection already names its files
9384
+ let tgt = transcribeTargets();
9385
+ const opts = transcribeSettings();
9386
+ if (!tgt.selected && !tgt.none) {
9387
+ // transcripts being re-read (another tab saved one) decide which files are left: wait for
9388
+ // those of this timeline's files (a few seconds at most), then take the targets again,
9389
+ // unless the timeline or the selection changed meanwhile
9390
+ const at = silenceSig() + "|" + [...state.selIds].join(",");
9391
+ const srcs = new Set(transcriptGroups().map((g) => getMedia(g[0].mediaId).src));
9392
+ const loading = [...transcriptCache].filter(([s, v]) => srcs.has(s) && v instanceof Promise).map(([, v]) => v);
9393
+ if (loading.length) {
9394
+ await Promise.race([Promise.allSettled(loading), new Promise((r) => setTimeout(r, 5000))]);
9395
+ if (silenceSig() + "|" + [...state.selIds].join(",") !== at) { renderTranscript(true); toast("The timeline changed — check the button and click again"); return; }
9396
+ // the same action as clicked: "Transcribe N files" drops files whose transcript just arrived
9397
+ // (it never turns into a rerun of everything); "Transcribe again" stays a rerun
9398
+ if (!tgt.srcs.length) tgt = transcribeTargets(); // the button hadn't caught up: what it offers now
9399
+ else if (!tgt.again) {
9400
+ tgt = { ...tgt, srcs: tgt.srcs.filter((s) => transcriptCache.get(s) === false) };
9401
+ if (!tgt.srcs.length) { renderTranscript(true); toast("Those files have transcripts now"); return; }
9402
+ }
9403
+ }
9404
+ }
9405
+ const { srcs } = tgt;
9406
+ if (!srcs.length) { toast(tgt.none ? "The selected clips have no speech — select clips with speech, or clear the selection" : "Put a clip with speech on the timeline first"); return; }
9311
9407
  let out;
9312
- try { out = await transcribeSrcs(srcs); } catch (e) { toast(e.message); return; }
9408
+ try { out = await transcribeSrcs(srcs, opts); } catch (e) { toast(e.message); return; }
9313
9409
  const unsaved = out.done.filter((d) => !d.saved).length;
9314
9410
  const words = out.done.reduce((n, d) => n + d.words, 0);
9315
9411
  toast(out.cancelled ? `Stopped — ${out.done.length} file${out.done.length === 1 ? "" : "s"} transcribed`
@@ -9413,7 +9509,11 @@ async function runTranscribeJob(ticket, fail) {
9413
9509
  if (trState.busy) return fail("this editor tab is already transcribing — wait for it, or cancel it there");
9414
9510
  const srcs = [], skipped = [];
9415
9511
  for (const src of spec.srcs || []) {
9416
- if (!spec.again && await loadTranscript(src, true)) { skipped.push(src); continue; }
9512
+ // a transcript only counts as there when the server just confirmed it (a failed read is no proof)
9513
+ if (!spec.again) {
9514
+ const r = await readTranscript(src);
9515
+ if (r.ok && r.doc) { skipped.push(src); continue; }
9516
+ }
9417
9517
  srcs.push(src);
9418
9518
  }
9419
9519
  const report = (body, force) => fetch("/api/export/job/report?id=" + encodeURIComponent(ticket.id), { method: "POST", body: JSON.stringify(body) })
@@ -11907,7 +12007,7 @@ function seqUndoPrint(d, withOthers) {
11907
12007
  }
11908
12008
  /** Open sequence `id` in the editor. False when it can't be opened now. */
11909
12009
  function openSequence(id) {
11910
- if (state.exporting) { toast("Wait for the export to finish before opening another sequence"); return false; }
12010
+ if (exportBusy()) { toast("Wait for the export to finish before opening another sequence"); return false; }
11911
12011
  if (state.gesture) return false;
11912
12012
  if (state.compCtx) exitComp(state.compCtx.path.length);
11913
12013
  if (SeqLib.activeId(project) === id) return true;
@@ -11926,7 +12026,7 @@ function openSequence(id) {
11926
12026
  }
11927
12027
  /** Add a sequence ({name?, from?, width?, height?}) and open it. */
11928
12028
  function newSequence(opts, clips = null) {
11929
- if (state.exporting) { toast("Wait for the export to finish"); return; }
12029
+ if (exportBusy()) { toast("Wait for the export to finish"); return; }
11930
12030
  if (state.compCtx) exitComp(state.compCtx.path.length);
11931
12031
  const doc = projectJSONHere();
11932
12032
  let s;
@@ -11947,7 +12047,7 @@ function renameSequence(id, name) {
11947
12047
  async function deleteSequence(id) {
11948
12048
  const r = seqRoot(), s = SeqLib.find(r, id);
11949
12049
  if (!s || SeqLib.entries(r).length < 2) return;
11950
- if (state.exporting) { toast("Wait for the export to finish"); return; }
12050
+ if (exportBusy()) { toast("Wait for the export to finish"); return; }
11951
12051
  if (state.compCtx) exitComp(state.compCtx.path.length);
11952
12052
  let kept = null;
11953
12053
  if (state.connected) {
@@ -11962,7 +12062,7 @@ async function deleteSequence(id) {
11962
12062
  if (!kept) { toast(`Couldn't keep a version of the project, so “${s.name}” was not deleted. Try again in a moment.`); return; }
11963
12063
  }
11964
12064
  // the editor may have moved on while the version was saved
11965
- if (state.exporting) { toast("Wait for the export to finish"); return; }
12065
+ if (exportBusy()) { toast("Wait for the export to finish"); return; }
11966
12066
  if (state.compCtx) exitComp(state.compCtx.path.length);
11967
12067
  if (!SeqLib.find(project, id) || SeqLib.entries(project).length < 2) return; // deleted or changed meanwhile (another tab, an agent)
11968
12068
  const wasOpen = SeqLib.activeId(project) === id;
@@ -13406,7 +13506,7 @@ async function readHighlightSource(c, cancelled, onFrame) {
13406
13506
  async function makeHighlights(clips, { duration = 30, shot, size = null, follow = false, progress, cancelled: stop } = {}) {
13407
13507
  if (!Highlights) { toast("Highlights module missing — reload the editor"); return null; }
13408
13508
  if (highlightRun.busy) { toast("Already making highlights — wait for it, or Cancel"); return null; }
13409
- if (state.exporting) { toast("Wait for the export to finish"); return null; }
13509
+ if (exportBusy()) { toast("Wait for the export to finish"); return null; }
13410
13510
  const { take, skip } = Highlights.sourcesOf({ clips: project.clips, disabledTracks: [...state.disabledTracks] }, clips && clips.map((c) => c.id));
13411
13511
  if (!take.length) { toast(skip.length ? `Nothing to look at: ${skip[0].id} is ${skip[0].why}` : "Put video on the timeline first"); return null; }
13412
13512
  Object.assign(highlightRun, { busy: true, cancel: false });
@@ -13754,6 +13854,7 @@ els.preview.addEventListener("pointerdown", (e) => {
13754
13854
  }, true);
13755
13855
  window.addEventListener("keydown", (e) => {
13756
13856
  if (e.key !== "Escape" || (!trackUi.run && trackUi.tool !== "point")) return;
13857
+ if (!$("cmdkOverlay").classList.contains("hidden")) return; // Esc belongs to Search while it is open
13757
13858
  e.preventDefault(); e.stopImmediatePropagation();
13758
13859
  if (trackUi.run) trackUi.run.cancel = true;
13759
13860
  else { trackUi.tool = null; renderInspector(); }
@@ -14176,6 +14277,7 @@ els.preview.addEventListener("dblclick", (e) => {
14176
14277
  maskUi.pt = -1; scheduleSave(); renderInspector();
14177
14278
  }, true);
14178
14279
  window.addEventListener("keydown", (e) => {
14280
+ if (!$("cmdkOverlay").classList.contains("hidden")) return; // keys belong to Search while it is open
14179
14281
  if (e.key === "Escape" && colorState.maskDraw) { // the Color tab's Draw
14180
14282
  e.preventDefault(); e.stopImmediatePropagation();
14181
14283
  colorState.maskDraw = false; colorState.maskStroke = null; state.dirtyTimeline = true; renderColorPage(true);
@@ -16379,6 +16481,7 @@ function refreshDeliveryNotes() {
16379
16481
  $("dlvSummary").textContent = `${Delivery.describe(sp, { width: fr.outW, height: fr.outH, fps })}` +
16380
16482
  (size ? ` · about ${Delivery.fmtBytes(size)}` : "");
16381
16483
  $("dlvFilePreview").textContent = "→ exports/" + deliveryFileName(sp, fps) + Delivery.CONTAINERS[sp.container].ext;
16484
+ syncExportName();
16382
16485
  const cv = deliveryCanvas();
16383
16486
  const warn = [...dlvNotes.map((n) => n[0].toUpperCase() + n.slice(1)),
16384
16487
  ...Delivery.checks(sp, { duration: range.dur, fps, canvasW: cv.w, canvasH: cv.h, region: cv.region })];
@@ -16457,10 +16560,65 @@ function webCodecsBitrate(w, h, fps) {
16457
16560
  // ~0.1 bit/pixel/frame, clamped — same heuristic as before
16458
16561
  return Math.min(20_000_000, Math.max(2_000_000, Math.round(w * h * fps * 0.1)));
16459
16562
  }
16563
+ /* The Export dialog's "Save as" name. The field shows the name the export would get;
16564
+ once typed in, that name is used for this export (cleared = the default, shown greyed). */
16565
+ let exportNameTyped = false;
16566
+ let exportNameShown = ""; // the default the Save as field shows (a {time} in it is the time it was filled in)
16567
+ /** The engine the dialog's choices lead to, as startChosenExport picks it. */
16568
+ function chosenExportEngine() {
16569
+ if (els.engineFast.checked && !els.engineFast.disabled) return "fast";
16570
+ if (!els.engineRealtime.checked || els.engineRealtime.disabled) return null;
16571
+ return state.connected && state.ffmpeg && state.webCodecs && !getExportFrame() ? "webcodecs" : "recorder";
16572
+ }
16573
+ function defaultExportName() {
16574
+ const c = selectedExportChoice();
16575
+ if (chosenExportEngine() === "fast" && c.kind === "delivery" && dlvSpec) return deliveryFileName(dlvSpec);
16576
+ return project.name.replace(/[^\w\- ]+/g, "").trim() || "export";
16577
+ }
16578
+ function exportNameExt() {
16579
+ const engine = chosenExportEngine(), c = selectedExportChoice();
16580
+ if (engine === "fast" && c.kind === "delivery" && dlvSpec) return Delivery.CONTAINERS[dlvSpec.container].ext;
16581
+ if (engine === "recorder") return (pickMime() || "").startsWith("video/mp4") ? ".mp4" : ".webm";
16582
+ if (engine === "fast" && c.kind === "profile") return encodeProfiles.profiles[c.id]?.extension || ".mp4";
16583
+ return ".mp4";
16584
+ }
16585
+ function syncExportName() {
16586
+ const el = $("exportName");
16587
+ if (!el) return;
16588
+ const def = exportNameShown = defaultExportName();
16589
+ el.placeholder = def;
16590
+ if (!exportNameTyped) el.value = def;
16591
+ const note = $("exportNameNote");
16592
+ if (!note) return;
16593
+ const file = (exportName() || def) + exportNameExt();
16594
+ note.textContent = chosenExportEngine() === "recorder"
16595
+ ? "→ the browser downloads " + file
16596
+ : "→ exports/" + file + " · a number is added if that name is taken";
16597
+ // (the browser download names its own copies when the name is taken)
16598
+ }
16599
+ /** The typed name (file-safe), or null for the default. */
16600
+ function exportName() {
16601
+ const v = exportNameTyped ? ($("exportName")?.value || "").trim() : "";
16602
+ const ext = exportNameExt().toLowerCase();
16603
+ const base = ext && v.toLowerCase().endsWith(ext) ? v.slice(0, -ext.length) : v;
16604
+ const safe = base.replace(/\.(mp4|mov|m4v|mkv|webm|mxf)$/i, "").replace(/[^\w\- ()\[\].]+/g, "_").replace(/^[.\s]+/, "").slice(0, 120);
16605
+ return safe || null;
16606
+ }
16607
+ let exportSetupOpening = false; // one Export click at a time, while the dialog's lists load
16608
+ /* An export getting ready (its players, fonts, encoder check) holds the canvas before
16609
+ state.exporting is set: every engine, the queue and agent jobs wait for both. */
16610
+ let exportStarting = false;
16611
+ function exportBusy() { return state.exporting || exportStarting; }
16612
+ /** Which timeline an Export click was for: a project or sequence opened meanwhile isn't it. */
16613
+ function exportContext() { return (runtime.projectId || "") + "|" + (project.sequence || "") + "|" + (state.compCtx ? state.compCtx.path.join("/") : ""); }
16460
16614
  async function openExportSetup() {
16461
- if (state.exporting) return;
16615
+ if (exportBusy() || exportSetupOpening) return;
16616
+ const ctx = exportContext();
16617
+ // the dialog already open is being refreshed (a setting changed): keep what was typed in it
16618
+ const fresh = els.exportSetup.classList.contains("hidden");
16462
16619
  if (!project.clips.length) { alert("Timeline is empty — add some clips first."); return; }
16463
- await detectWebCodecs();
16620
+ exportSetupOpening = true;
16621
+ try { await detectWebCodecs(); } catch { }
16464
16622
  const ef = getExportFrame();
16465
16623
  const fastOk = state.connected && state.ffmpeg;
16466
16624
  // WebCodecs and MediaRecorder encode the full canvas — only Fast crops.
@@ -16525,14 +16683,62 @@ async function openExportSetup() {
16525
16683
  syncExportRangeUi();
16526
16684
  syncExportProfileVisibility();
16527
16685
  Promise.all([fetchEncodeProfiles(), fetchDeliveryInfo()]).then(() => {
16686
+ if (exportContext() !== ctx) { toast("Another timeline opened — click Export again"); return; }
16528
16687
  populateExportProfileSelect();
16529
16688
  syncExportProfileVisibility();
16530
16689
  renderBatchList();
16531
16690
  renderQueue();
16691
+ if (fresh) {
16692
+ exportNameTyped = false;
16693
+ const skip = $("exportSkipAsk");
16694
+ if (skip) skip.checked = false;
16695
+ }
16696
+ syncExportName();
16697
+ if (fresh && !getSetting("exportAsk")) {
16698
+ // "Don't ask again": render with the last engine and settings under the default name;
16699
+ // if that engine can't run now, ask after all rather than switch engines silently
16700
+ const last = getSetting("exportEngine");
16701
+ // (older settings say "second" for either real-time encoder)
16702
+ const radio = last === "fast" ? els.engineFast : last === "second" || last === "webcodecs" || last === "recorder" ? els.engineRealtime : null;
16703
+ // ...and the last preset or profile picked, when it is still in the list
16704
+ const choice = getSetting("exportChoice");
16705
+ // (a raw profile has to still be on the server: a deleted one can linger in the list as a placeholder)
16706
+ const choiceOk = !choice || (choice.startsWith("p:") ? Object.hasOwn(encodeProfiles.profiles, choice.slice(2))
16707
+ : [...els.exportProfileSel.options].some((o) => o.value === choice));
16708
+ if (choiceOk && choice) {
16709
+ if (els.exportProfileSel.value !== choice) {
16710
+ els.exportProfileSel.value = choice;
16711
+ els.exportProfileSel.dispatchEvent(new Event("change"));
16712
+ }
16713
+ // the delivery as last exported (its size, codec…), even when the project pins the same preset
16714
+ const lastDlv = getSetting("delivery");
16715
+ if (choice.startsWith("d:") && lastDlv?.preset === choice.slice(2)) {
16716
+ dlvSpec = normalizeDelivery(lastDlv).spec;
16717
+ fillDeliveryControls(); // the dialog, if it opens, shows what Render will write
16718
+ refreshDeliveryNotes();
16719
+ }
16720
+ }
16721
+ if (radio) {
16722
+ els.engineFast.checked = radio === els.engineFast && !radio.disabled; els.engineRealtime.checked = radio === els.engineRealtime && !radio.disabled;
16723
+ // the dialog, if it opens, shows the engine's own controls
16724
+ syncExportProfileVisibility(); syncExportWcOpts();
16725
+ }
16726
+ // the range counted in frames of what will be written (a delivery may have its own frame rate)
16727
+ const outFps = chosenExportEngine() === "fast" && selectedExportChoice().kind === "delivery" && dlvSpec?.fps || projectFps();
16728
+ const engineOk = !radio || (!radio.disabled && (last === "second" || last === "fast" || chosenExportEngine() === last));
16729
+ if (engineOk && choiceOk && exportRange(outFps).frames >= 1) {
16730
+ syncExportName();
16731
+ toast(`Exporting “${defaultExportName()}” — Settings → Ask before exporting brings the dialog back`);
16732
+ startChosenExport();
16733
+ return;
16734
+ }
16735
+ toast(exportRange(outFps).frames < 1 ? "The export range is empty — pick one"
16736
+ : !choiceOk ? "The last export's preset isn't there any more — pick one" : "The last export's engine isn't available — pick one");
16737
+ }
16532
16738
  els.exportSetup.classList.remove("hidden");
16533
16739
  // aria-modal hides what is behind — focus has to come inside
16534
16740
  if (!els.exportSetup.contains(document.activeElement)) $("exportRangeSel")?.focus();
16535
- });
16741
+ }).finally(() => { exportSetupOpening = false; });
16536
16742
  }
16537
16743
  function closeExportSetup() {
16538
16744
  els.exportSetup.classList.add("hidden");
@@ -16555,17 +16761,22 @@ function startChosenExport() {
16555
16761
  alert("Export range is empty — IN/OUT is at or past the end of the timeline. Choose Entire timeline, or move the markers.");
16556
16762
  return;
16557
16763
  }
16764
+ // the name shown now (a default with {time} must not tick over while the audio mixes)
16765
+ const name = exportName() || exportNameShown || defaultExportName();
16766
+ if ($("exportSkipAsk")?.checked) setSetting("exportAsk", false);
16767
+ setSetting("exportEngine", chosenExportEngine());
16768
+ setSetting("exportChoice", els.exportProfileSel?.value || null);
16558
16769
  closeExportSetup();
16559
16770
  if (useFast) {
16560
16771
  const c = selectedExportChoice();
16561
16772
  setSetting("exportKind", c.kind);
16562
16773
  if (c.kind === "delivery") {
16563
16774
  setSetting("delivery", dlvSpec);
16564
- fastExport({ delivery: dlvSpec });
16565
- } else fastExport({ profile: c.id });
16775
+ fastExport({ delivery: dlvSpec, name });
16776
+ } else fastExport({ profile: c.id, name });
16566
16777
  }
16567
- else if (useSecond && state.connected && state.ffmpeg && state.webCodecs && !getExportFrame()) webCodecsExport();
16568
- else startExport();
16778
+ else if (useSecond && state.connected && state.ffmpeg && state.webCodecs && !getExportFrame()) webCodecsExport(name);
16779
+ else startExport(name);
16569
16780
  }
16570
16781
 
16571
16782
  /* Keep Range's IN–OUT option in sync with marker presence without clobbering
@@ -17472,7 +17683,7 @@ async function prepareFrameAssets(t) {
17472
17683
  * opts.silent: no overlay, alert or download (the export queue shows it);
17473
17684
  * opts.onProgress(0…1). Resolves {outputs:[{file, ok, src?, error?}]} or {error, cancelled}. */
17474
17685
  async function fastExport(opts = {}) {
17475
- if (state.exporting) return { error: "an export is already running" };
17686
+ if (exportBusy()) return { error: "an export is already running in this tab", busy: true };
17476
17687
  const job = opts.job || null;
17477
17688
  pause();
17478
17689
  state.exporting = true; state.rendering = true; renderCancelled = false;
@@ -17482,7 +17693,7 @@ async function fastExport(opts = {}) {
17482
17693
  els.exportProgress.style.width = "0%";
17483
17694
  els.exportNote.textContent = "Rendering frames → ffmpeg. You can switch tabs; export continues.";
17484
17695
  restoreExportVideoState();
17485
- const deliveries = opts.deliveries || (opts.delivery ? [{ delivery: opts.delivery }] : null);
17696
+ const deliveries = opts.deliveries || (opts.delivery ? [{ delivery: opts.delivery, name: opts.name || undefined }] : null);
17486
17697
  const delivery = deliveries ? deliveries[0].delivery : null;
17487
17698
  const fps = (delivery && delivery.fps) || projectFps();
17488
17699
  let result = null;
@@ -17504,7 +17715,7 @@ async function fastExport(opts = {}) {
17504
17715
  canvasW: cv.w, canvasH: cv.h, region: cv.region, hasAudio: !!wav,
17505
17716
  } : {
17506
17717
  fps,
17507
- name: project.name.replace(/[^\w\- ]+/g, "") || "export",
17718
+ name: opts.name || project.name.replace(/[^\w\- ]+/g, "") || "export",
17508
17719
  profile: profileId,
17509
17720
  hasAudio: !!wav,
17510
17721
  }),
@@ -17718,7 +17929,7 @@ function renderQueueProgress() {
17718
17929
  }
17719
17930
  }
17720
17931
  async function runQueue() {
17721
- if (queueRunning || state.exporting) return;
17932
+ if (queueRunning || exportBusy()) return;
17722
17933
  if (!(state.connected && state.ffmpeg)) { alert("The export queue needs the server and ffmpeg (Fast export)."); return; }
17723
17934
  queueRunning = true; queueStop = false;
17724
17935
  renderQueue();
@@ -17838,8 +18049,23 @@ async function reportExportJob(id, body, force = false) {
17838
18049
  if (r?.cancel) { renderCancelled = true; exportAbort?.abort(); }
17839
18050
  } catch { }
17840
18051
  }
18052
+ let skippedTicket = null, skippedTimer = 0;
17841
18053
  async function runExportJob(ticket) {
17842
- if (!ticket?.id || state.exporting) return; // a busy tab leaves it for another
18054
+ if (!ticket?.id) return;
18055
+ if (exportBusy()) {
18056
+ // a busy tab leaves it for another, but tries again when it is free (the server's claim
18057
+ // decides: a ticket another tab took, or one the agent cancelled, is refused)
18058
+ skippedTicket = ticket;
18059
+ clearInterval(skippedTimer);
18060
+ const until = Date.now() + 30000;
18061
+ skippedTimer = setInterval(() => {
18062
+ if (exportBusy() && Date.now() < until) return;
18063
+ clearInterval(skippedTimer);
18064
+ const t = skippedTicket; skippedTicket = null;
18065
+ if (t && !exportBusy()) runExportJob(t);
18066
+ }, 500);
18067
+ return;
18068
+ }
17843
18069
  const claimed = await fetch("/api/export/job/claim?id=" + encodeURIComponent(ticket.id), { method: "POST" })
17844
18070
  .then((r) => r.ok).catch(() => false);
17845
18071
  if (!claimed) return;
@@ -17848,9 +18074,20 @@ async function runExportJob(ticket) {
17848
18074
  for (let i = 0; i < 150 && ticket.revision != null && (project.revision || 0) < ticket.revision; i++)
17849
18075
  await new Promise((r) => setTimeout(r, 100));
17850
18076
  if (ticket.revision != null && (project.revision || 0) < ticket.revision) await syncFromServer();
18077
+ // a ticket that waited here while the tab switched projects must not render the other one
18078
+ if (ticket.project && runtime.projectId && ticket.project !== runtime.projectId && ticket.kind !== "transcribe")
18079
+ return fail("another project was opened before this job could start — open the project again and retry");
18080
+ if (ticket.kind === "transcribe") return runTranscribeJob(ticket, fail);
18081
+ // from here until the job ends, a project opened elsewhere waits: the job renders the one it was asked for
18082
+ runtime.jobHold = (runtime.jobHold || 0) + 1;
18083
+ try { return await runHeldJob(ticket, fail); } finally {
18084
+ runtime.jobHold--;
18085
+ if (!runtime.jobHold && runtime.pendingSync) syncFromServer();
18086
+ }
18087
+ }
18088
+ async function runHeldJob(ticket, fail) {
17851
18089
  if (ticket.kind === "scopes") return runScopesJob(ticket, fail);
17852
18090
  if (ticket.kind === "track") return runTrackJob(ticket, fail);
17853
- if (ticket.kind === "transcribe") return runTranscribeJob(ticket, fail);
17854
18091
  if (!state.ffmpeg) {
17855
18092
  const j = await fetch("/api/export/ffmpeg").then((r) => r.json()).catch(() => ({}));
17856
18093
  state.ffmpeg = !!j.available;
@@ -17873,7 +18110,7 @@ async function runExportJob(ticket) {
17873
18110
  const specs = ticket.deliveries.map((d) => normalizeDelivery(d).spec);
17874
18111
  const groups = new Map();
17875
18112
  for (const sp of specs) { const k = sp.fps || projectFps(); if (!groups.has(k)) groups.set(k, []); groups.get(k).push(sp); }
17876
- if (groups.size === 1) await fastExport({ job: ticket.id, deliveries: specs.map((delivery) => ({ delivery })) });
18113
+ if (groups.size === 1) { const res = await fastExport({ job: ticket.id, deliveries: specs.map((delivery) => ({ delivery })) }); if (res?.busy) return fail(res.error); }
17877
18114
  else {
17878
18115
  const all = [];
17879
18116
  let i = 0;
@@ -17881,6 +18118,7 @@ async function runExportJob(ticket) {
17881
18118
  const res = await fastExport({ deliveries: group.map((delivery) => ({ delivery })), silent: true,
17882
18119
  onProgress: (f) => reportExportJob(ticket.id, { progress: (i + f) / groups.size }) });
17883
18120
  i++;
18121
+ if (res?.busy) return fail(res.error);
17884
18122
  if (res && res.cancelled) return reportExportJob(ticket.id, { status: "failed", error: "cancelled" }, true);
17885
18123
  if (res && res.outputs) all.push(...res.outputs);
17886
18124
  else all.push(...group.map((sp) => ({ file: deliveryFileName(sp), ok: false, error: (res && res.error) || "export failed" })));
@@ -17889,7 +18127,11 @@ async function runExportJob(ticket) {
17889
18127
  if (!ok) return fail(all.map((o) => o.error).join(" · "));
17890
18128
  await reportExportJob(ticket.id, { status: "done", src: ok.src, result: { outputs: all } }, true);
17891
18129
  }
17892
- } else await fastExport(want ? { job: ticket.id, delivery: normalizeDelivery(want).spec } : { job: ticket.id, profile: ticket.profile });
18130
+ } else {
18131
+ const res = await fastExport(want ? { job: ticket.id, delivery: normalizeDelivery(want).spec, name: ticket.name || null } : { job: ticket.id, profile: ticket.profile, name: ticket.name || null });
18132
+ // another export took the tab while this job was getting ready: say so rather than leave it running
18133
+ if (res?.busy) return fail(res.error);
18134
+ }
17893
18135
  } finally {
17894
18136
  exportRangeForced = null;
17895
18137
  }
@@ -17970,7 +18212,10 @@ async function runTrackJob(ticket, fail) {
17970
18212
  if (state.connected) {
17971
18213
  clearTimeout(runtime.saveTimer); runtime.saveTimer = null;
17972
18214
  project.revision++;
17973
- const res = await fetch("/api/project", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(projectJSON(), null, 2) });
18215
+ // the project this job tracked in: a project opened elsewhere meanwhile refuses the save (409)
18216
+ const headers = { "Content-Type": "application/json" };
18217
+ if (runtime.projectId) headers["X-FableCut-Project"] = runtime.projectId;
18218
+ const res = await fetch("/api/project", { method: "PUT", headers, body: JSON.stringify(projectJSON(), null, 2) });
17974
18219
  if (!res.ok) {
17975
18220
  project.revision--;
17976
18221
  // put back only the clips this job changed (edits elsewhere since stay), and drop its undo step
@@ -18166,10 +18411,13 @@ function waitEncodeQueue(encoder, max = 2, { signal, getError } = {}) {
18166
18411
  tick();
18167
18412
  });
18168
18413
  }
18169
- async function webCodecsExport() {
18414
+ async function webCodecsExport(name) {
18415
+ if (exportBusy()) return;
18416
+ exportStarting = true;
18417
+ try { await detectWebCodecs(); } finally { exportStarting = false; }
18170
18418
  if (state.exporting) return;
18171
- await detectWebCodecs();
18172
- if (!state.webCodecs) { startExport(); return; }
18419
+ // no encoder: the recorder takes over at once, so nothing slips in between
18420
+ if (!state.webCodecs) { startExport(name); return; }
18173
18421
  pause();
18174
18422
  state.exporting = true; state.rendering = true; renderCancelled = false;
18175
18423
  exportAbort = new AbortController();
@@ -18195,7 +18443,7 @@ async function webCodecsExport() {
18195
18443
  method: "POST",
18196
18444
  body: JSON.stringify({
18197
18445
  fps,
18198
- name: project.name.replace(/[^\w\- ]+/g, "") || "export",
18446
+ name: name || project.name.replace(/[^\w\- ]+/g, "") || "export",
18199
18447
  mode: "annexb",
18200
18448
  hasAudio: !!wav,
18201
18449
  }),
@@ -18316,24 +18564,38 @@ function pickMime() {
18316
18564
  ];
18317
18565
  return cands.find((m) => window.MediaRecorder && MediaRecorder.isTypeSupported(m)) || "";
18318
18566
  }
18319
- async function startExport() {
18320
- if (state.exporting) return;
18567
+ async function startExport(name) {
18568
+ if (exportBusy()) return;
18321
18569
  if (!project.clips.length) { alert("Timeline is empty — add some clips first."); return; }
18322
18570
  const mime = pickMime();
18323
18571
  if (!mime) { alert("MediaRecorder is not supported in this browser."); return; }
18324
- ensureAudio();
18325
- await runtime.audio.ctx.resume();
18326
- pause();
18327
- const { start } = beginExportWindow();
18328
- state.time = start;
18329
- await useOriginalPlayers(); // proxies are for editing — export reads the originals
18330
- seekMediaWhilePaused();
18331
- await new Promise((r) => setTimeout(r, 350)); // let first frames decode
18332
- await loadProjectFonts();
18333
- const stream = els.preview.captureStream(projectFps());
18334
- for (const tr of runtime.audio.recDest.stream.getAudioTracks()) stream.addTrack(tr);
18572
+ exportStarting = true;
18573
+ let stream = null;
18574
+ try {
18575
+ ensureAudio();
18576
+ await runtime.audio.ctx.resume();
18577
+ pause();
18578
+ const { start } = beginExportWindow();
18579
+ state.time = start;
18580
+ await useOriginalPlayers(); // proxies are for editing — export reads the originals
18581
+ seekMediaWhilePaused();
18582
+ await new Promise((r) => setTimeout(r, 350)); // let first frames decode
18583
+ await loadProjectFonts();
18584
+ stream = els.preview.captureStream(projectFps());
18585
+ for (const tr of runtime.audio.recDest.stream.getAudioTracks()) stream.addTrack(tr);
18586
+ recorder = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 10_000_000 });
18587
+ } catch (e) {
18588
+ exportStarting = false;
18589
+ // the canvas track was made for this attempt; the audio track is shared, so it stays
18590
+ for (const tr of stream?.getVideoTracks() || []) tr.stop();
18591
+ recorder = null;
18592
+ releaseOriginalPlayers();
18593
+ endExportWindow();
18594
+ toast("Export couldn't start: " + (e.message || e));
18595
+ return;
18596
+ }
18597
+ exportStarting = false;
18335
18598
  recChunks = []; recDiscard = false;
18336
- recorder = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 10_000_000 });
18337
18599
  recorder.ondataavailable = (e) => { if (e.data.size) recChunks.push(e.data); };
18338
18600
  recorder.onstop = () => {
18339
18601
  els.exportOverlay.classList.add("hidden");
@@ -18342,14 +18604,23 @@ async function startExport() {
18342
18604
  const blob = new Blob(recChunks, { type: mime.split(";")[0] });
18343
18605
  const a = document.createElement("a");
18344
18606
  a.href = URL.createObjectURL(blob);
18345
- a.download = (project.name.replace(/[^\w\- ]+/g, "") || "export") + "." + ext;
18607
+ a.download = (name || project.name.replace(/[^\w\- ]+/g, "") || "export") + "." + ext;
18346
18608
  a.click();
18347
18609
  setTimeout(() => URL.revokeObjectURL(a.href), 30_000);
18348
18610
  };
18349
18611
  els.exportOverlay.classList.remove("hidden");
18350
18612
  els.exportProgress.style.width = "0%";
18351
18613
  state.exporting = true;
18352
- recorder.start(250);
18614
+ try { recorder.start(250); }
18615
+ catch (e) {
18616
+ state.exporting = false;
18617
+ for (const tr of stream.getVideoTracks()) tr.stop();
18618
+ els.exportOverlay.classList.add("hidden");
18619
+ releaseOriginalPlayers();
18620
+ endExportWindow();
18621
+ toast("Export couldn't start: " + (e.message || e));
18622
+ return;
18623
+ }
18353
18624
  pauseSource();
18354
18625
  setMonitorMode("program");
18355
18626
  state.playing = true;
@@ -18401,6 +18672,12 @@ $("btnRippleDelete").addEventListener("click", () => {
18401
18672
  });
18402
18673
  $("btnExport").addEventListener("click", openExportSetup);
18403
18674
  $("btnStartExport").addEventListener("click", startChosenExport);
18675
+ $("exportName")?.addEventListener("input", () => { exportNameTyped = true; syncExportName(); });
18676
+ $("exportName")?.addEventListener("keydown", (e) => {
18677
+ if (e.key === "Enter" && !e.isComposing && !$("btnStartExport").disabled) { e.preventDefault(); startChosenExport(); }
18678
+ });
18679
+ els.engineFast?.addEventListener("change", syncExportName);
18680
+ els.engineRealtime?.addEventListener("change", syncExportName);
18404
18681
  els.exportSetup?.addEventListener("change", (e) => {
18405
18682
  if (e.target.name === "engine") {
18406
18683
  syncExportProfileVisibility();
@@ -18413,6 +18690,7 @@ els.exportProfileSel?.addEventListener("change", () => {
18413
18690
  if (c.kind === "profile" && !project.encodeProfile)
18414
18691
  setSetting("encodeProfile", c.id === encodeProfiles.default ? null : c.id);
18415
18692
  syncExportChoiceUi("preset");
18693
+ syncExportName();
18416
18694
  });
18417
18695
  $("dlvBody")?.addEventListener("change", onDeliveryControl);
18418
18696
  $("dlvBody")?.addEventListener("input", onDeliveryControl);
@@ -18544,7 +18822,9 @@ $("btnHelp").addEventListener("click", () => {
18544
18822
  });
18545
18823
  $("btnCloseHelp").addEventListener("click", () => $("helpOverlay").classList.add("hidden"));
18546
18824
  /** Keyboard shortcuts filter: keeps the rows (and whole sections, by heading) that match every typed word. */
18547
- function filterHelp() {
18825
+ /** `only` (a row of the list) shows just that one: what Search opened. */
18826
+ function filterHelp(only) {
18827
+ const row = only instanceof HTMLElement ? only : null;
18548
18828
  const words = $("helpFilter").value.toLowerCase().split(/\s+/).filter(Boolean);
18549
18829
  let any = false;
18550
18830
  for (const sec of $("helpKeys").querySelectorAll(".keys-sec")) {
@@ -18552,7 +18832,7 @@ function filterHelp() {
18552
18832
  let shown = 0;
18553
18833
  for (const tr of sec.querySelectorAll("tr")) {
18554
18834
  const text = head + " " + tr.textContent.toLowerCase();
18555
- const hit = words.every((w) => text.includes(w));
18835
+ const hit = row ? tr === row : words.every((w) => text.includes(w));
18556
18836
  tr.classList.toggle("hidden", !hit);
18557
18837
  if (hit) shown++;
18558
18838
  }
@@ -18569,6 +18849,226 @@ $("helpFilter").addEventListener("keydown", (e) => {
18569
18849
  if ($("helpFilter").value) { $("helpFilter").value = ""; filterHelp(); }
18570
18850
  else $("helpOverlay").classList.add("hidden");
18571
18851
  });
18852
+ /* ── Command search (Ctrl/Cmd+K) ──
18853
+ One box that finds what the editor can do: toolbar actions, panels and
18854
+ tabs, Settings, the selected clip's Inspector sections, media in the bin,
18855
+ clips on the timeline and the keyboard shortcuts. The items are read from
18856
+ the page each time it opens, so a new button or setting turns up without a
18857
+ list to keep; command-search.js ranks them. */
18858
+ const cmdk = { items: [], shown: [], active: 0, back: null };
18859
+ /** A control's name: its aria-label, else the start of its title, else its text. */
18860
+ function cmdkName(el) {
18861
+ const text = (el.textContent || "").replace(/\s+/g, " ").trim();
18862
+ const title = (el.getAttribute("aria-label") || el.title || "").replace(/\s+/g, " ").trim();
18863
+ const short = title.split(/ — |: |\. | \(/)[0];
18864
+ // icons and single symbols (▶ ⊡ ?) say little; a title does
18865
+ return /[a-z]{3}/i.test(text) && text.length <= 32 ? text.replace(/^[^\w(]+/, "") : short || text;
18866
+ }
18867
+ const cmdkShown = (el) => !el.disabled && !el.closest(".hidden") && el.getClientRects().length > 0;
18868
+ function cmdkFlash(el) {
18869
+ if (!el) return;
18870
+ el.scrollIntoView({ block: "nearest" });
18871
+ el.classList.remove("cmdk-flash");
18872
+ void el.offsetWidth;
18873
+ el.classList.add("cmdk-flash");
18874
+ }
18875
+ function cmdkCollect() {
18876
+ const items = [], seen = new Set();
18877
+ const add = (it) => {
18878
+ const key = it.key || it.group + "|" + it.label; // media and clips by id: two of one name both show
18879
+ if (!it.label || seen.has(key)) return;
18880
+ seen.add(key);
18881
+ items.push(it);
18882
+ };
18883
+ // panels and tabs
18884
+ // (the Color workspace and the Color side tab share a name: where each lives tells them apart)
18885
+ const panelWhere = { sideTabs: "Side panel", binTabs: "Bin", wsSwitch: "Workspace" };
18886
+ for (const b of document.querySelectorAll("#sideTabs [data-side], #binTabs [data-tab], #wsSwitch [data-ws]")) {
18887
+ const where = panelWhere[b.parentElement.id] || "", title = (b.title || "").split(/ — |: /)[0] === cmdkName(b) ? "" : b.title;
18888
+ add({ key: "Panel|" + b.parentElement.id + "|" + cmdkName(b), label: cmdkName(b), group: "Panel", hint: [where, title].filter(Boolean).join(" · "),
18889
+ keywords: ["tab", "show", "open", where], run: () => { if (b.closest("#binTabs")) cmdkShowBin(); b.click(); } });
18890
+ }
18891
+ // toolbar actions: every named button outside dialogs, menus and the Inspector (and the timeline's edit tools)
18892
+ const actions = [];
18893
+ for (const b of document.querySelectorAll("button[id], button[data-edit-tool]")) {
18894
+ if (b.closest(".overlay, .ctx-menu, .style-menu, #inspector, #sideTabs, #binTabs, #wsSwitch") || b.id === "btnSearch") continue;
18895
+ if (!cmdkShown(b)) continue;
18896
+ actions.push(b);
18897
+ }
18898
+ // two buttons of one name (the monitor's Fit and the timeline's) go by their titles instead
18899
+ const named = new Map();
18900
+ for (const b of actions) named.set(cmdkName(b), (named.get(cmdkName(b)) || 0) + 1);
18901
+ for (const b of actions) {
18902
+ const title = (b.title || "").replace(/\s+/g, " ").trim(), short = title.split(/ — |: |\. | \(/)[0];
18903
+ const label = named.get(cmdkName(b)) > 1 && short ? short : cmdkName(b);
18904
+ add({ key: "a:" + (b.id || "tool-" + b.dataset.editTool), label, group: "Action", hint: title && title !== label ? title : "", run: () => b.click() });
18905
+ }
18906
+ // the selected clip's Inspector sections
18907
+ for (const h of document.querySelectorAll("#inspector .insp-section > h3")) {
18908
+ const name = h.textContent.replace(/\s+/g, " ").trim();
18909
+ add({ label: name, group: "Inspector", keywords: ["inspector", "section", "clip"], run: () => {
18910
+ setSideTab("inspector");
18911
+ // the tab rebuilds the Inspector: find the section in the new one
18912
+ const live = [...document.querySelectorAll("#inspector .insp-section > h3")].find((x) => x.textContent.replace(/\s+/g, " ").trim() === name);
18913
+ if (live) cmdkFlash(live.closest(".insp-section"));
18914
+ } });
18915
+ }
18916
+ // Settings
18917
+ for (const row of document.querySelectorAll("#settingsDialog .settings-row")) {
18918
+ const name = row.querySelector(".settings-label")?.textContent.trim();
18919
+ const hint = row.querySelector(".settings-hint")?.textContent.trim() || "";
18920
+ add({ label: name, group: "Setting", hint, keywords: ["settings", "preference", "option"], run: () => { openSettings(); const inp = row.querySelector("input, select"); inp?.focus(); cmdkFlash(row); } });
18921
+ }
18922
+ // media in the bin, clips on the timeline
18923
+ for (const m of project.media || []) {
18924
+ // the bin folder it sits in tells two files of one name apart
18925
+ const folders = [];
18926
+ for (let f = m.folderId && getFolder(m.folderId), n = 0; f && n < 16; f = f.parentId && getFolder(f.parentId), n++) folders.unshift(f.name);
18927
+ add({ key: "m:" + m.id, label: m.name, group: "Media", hint: folders.length ? `${m.kind} · ${folders.join(" / ")}` : m.kind, keywords: [m.kind, ...(m.tags || [])], run: () => { cmdkShowBin(); revealInProject({ kind: m.kind, mediaId: m.id }); } });
18928
+ }
18929
+ for (const c of project.clips || []) {
18930
+ const name = c.kind === "text" ? (c.props?.text || "Title").split("\n")[0].slice(0, 60) : c.name || getMedia(c.mediaId)?.name || c.kind;
18931
+ add({ key: "c:" + c.id, label: name, group: "Clip", hint: `${c.track} · ${fmt(c.start)}`, keywords: [c.kind, c.track], run: () => {
18932
+ // where the clip is now (an edit may have arrived while Search was open)
18933
+ const cur = project.clips.find((x) => x.id === c.id);
18934
+ if (!cur) { toast("That clip isn't on the timeline any more"); return; }
18935
+ if (isSourceMode()) setMonitorMode("program");
18936
+ selectClip(cur.id);
18937
+ setTime(cur.start);
18938
+ revealTime(cur.start);
18939
+ } });
18940
+ }
18941
+ // keyboard shortcuts: Enter opens the list, filtered to that one
18942
+ for (const tr of document.querySelectorAll("#helpKeys tr")) {
18943
+ const cells = tr.querySelectorAll("td");
18944
+ if (cells.length < 2) continue;
18945
+ const keys = cells[0].textContent.replace(/\s+/g, " ").trim(), what = cells[1].textContent.replace(/\s+/g, " ").trim();
18946
+ const label = what.split(/ — |; |\. /)[0].slice(0, 70);
18947
+ const section = tr.closest(".keys-sec")?.querySelector("h3")?.textContent || "";
18948
+ add({ label, group: "Shortcut", hint: keys, keys: [keys], keywords: [section, keys, what], run: () => {
18949
+ $("helpOverlay").classList.remove("hidden");
18950
+ // the row itself, not every row its first words also start
18951
+ $("helpFilter").value = label;
18952
+ filterHelp(tr);
18953
+ $("helpFilter").focus();
18954
+ } });
18955
+ }
18956
+ return items;
18957
+ }
18958
+ function cmdkRender() {
18959
+ const list = $("cmdkList");
18960
+ cmdk.shown = FableCutSearch.rank($("cmdkInput").value, cmdk.items, 60);
18961
+ cmdk.active = Math.min(cmdk.active, Math.max(0, cmdk.shown.length - 1));
18962
+ list.innerHTML = cmdk.shown.length
18963
+ ? cmdk.shown.map((it, i) => `<li class="cmdk-item${i === cmdk.active ? " active" : ""}" role="option" id="cmdk-${i}" data-i="${i}" aria-selected="${i === cmdk.active}">` +
18964
+ `<span class="cmdk-label">${escapeHtml(it.label)}</span>${it.hint ? `<span class="cmdk-hint">${escapeHtml(it.hint)}</span>` : ""}` +
18965
+ `<span class="cmdk-group">${it.group}</span></li>`).join("")
18966
+ : `<li class="cmdk-empty">Nothing matches — try another word.</li>`;
18967
+ $("cmdkInput").setAttribute("aria-activedescendant", cmdk.shown.length ? "cmdk-" + cmdk.active : "");
18968
+ list.querySelector(".cmdk-item.active")?.scrollIntoView({ block: "nearest" });
18969
+ }
18970
+ function openCmdk() {
18971
+ if (state.exporting) return;
18972
+ cmdk.pid = runtime.projectId; // results belong to this project
18973
+ cmdk.back = document.activeElement;
18974
+ cmdk.items = cmdkCollect();
18975
+ cmdk.active = 0;
18976
+ $("cmdkInput").value = "";
18977
+ $("cmdkOverlay").classList.remove("hidden");
18978
+ cmdkRender();
18979
+ $("cmdkInput").focus();
18980
+ }
18981
+ /** Another dialog is open over the editor (Export setup finishing its load, …). */
18982
+ const cmdkOtherOverlay = () => [...document.querySelectorAll(".overlay")].some((o) => o.id !== "cmdkOverlay" && !o.classList.contains("hidden"));
18983
+ /** The Color workspace hides the bin: a result that shows the bin goes back to Edit first. */
18984
+ function cmdkShowBin() {
18985
+ if (colorState.ws === "color") setWorkspace("edit");
18986
+ }
18987
+ function closeCmdk(refocus = true) {
18988
+ $("cmdkOverlay").classList.add("hidden");
18989
+ if (refocus && cmdk.back && document.contains(cmdk.back)) cmdk.back.focus();
18990
+ cmdk.back = null;
18991
+ }
18992
+ function runCmdk(i) {
18993
+ const it = cmdk.shown[i];
18994
+ if (!it) return;
18995
+ const back = cmdk.back, pid = cmdk.pid;
18996
+ closeCmdk(false);
18997
+ if (pid !== runtime.projectId) { toast("Another project opened — search again"); return; }
18998
+ // after the box has gone, so the action sees the editor as it was
18999
+ setTimeout(() => {
19000
+ // an export (an agent's too) may have taken the timeline meanwhile
19001
+ if (state.exporting) { toast("Wait for the export to finish"); return; }
19002
+ if (pid !== runtime.projectId) { toast("Another project opened — search again"); return; }
19003
+ if (cmdkOtherOverlay()) return; // a dialog that opened meanwhile keeps the screen
19004
+ try { it.run(); } catch (e) { toast(String(e.message || e)); }
19005
+ // an action that puts focus nowhere hands it back to where it was before Search
19006
+ const a = document.activeElement;
19007
+ if ((!a || a === document.body || a === $("cmdkInput")) && back && document.contains(back)) back.focus();
19008
+ }, 0);
19009
+ }
19010
+ const cmdkOpen = () => !$("cmdkOverlay").classList.contains("hidden");
19011
+ $("btnSearch")?.addEventListener("click", openCmdk);
19012
+ $("cmdkInput").addEventListener("input", () => { cmdk.active = 0; cmdkRender(); });
19013
+ $("cmdkInput").addEventListener("keydown", (e) => {
19014
+ if (e.isComposing || e.keyCode === 229) return; // the IME is choosing a word
19015
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
19016
+ e.preventDefault();
19017
+ const n = cmdk.shown.length;
19018
+ if (n) cmdk.active = (cmdk.active + (e.key === "ArrowDown" ? 1 : n - 1)) % n;
19019
+ cmdkRender();
19020
+ } else if (e.key === "Enter") {
19021
+ e.preventDefault();
19022
+ runCmdk(cmdk.active);
19023
+ } else if (e.key === "Escape") {
19024
+ e.preventDefault();
19025
+ e.stopPropagation();
19026
+ if ($("cmdkInput").value) { $("cmdkInput").value = ""; cmdk.active = 0; cmdkRender(); }
19027
+ else closeCmdk();
19028
+ } else if (e.key === "Tab") e.preventDefault(); // the box is the dialog's only control
19029
+ });
19030
+ $("cmdkList").addEventListener("mousemove", (e) => {
19031
+ const li = e.target.closest(".cmdk-item");
19032
+ if (!li || +li.dataset.i === cmdk.active) return;
19033
+ cmdk.active = +li.dataset.i;
19034
+ cmdkRender();
19035
+ });
19036
+ $("cmdkList").addEventListener("click", (e) => {
19037
+ const li = e.target.closest(".cmdk-item");
19038
+ if (li) runCmdk(+li.dataset.i);
19039
+ });
19040
+ $("cmdkOverlay").addEventListener("mousedown", (e) => {
19041
+ if (e.target === $("cmdkOverlay")) closeCmdk();
19042
+ else if (e.target !== $("cmdkInput")) e.preventDefault(); // a click on the list or footer keeps the focus in the box
19043
+ });
19044
+ /* Ctrl/Cmd+K, before any field's own key handling (the bin's search stops its keys): one
19045
+ toggle per press. While Search is open, the editor's other shortcuts wait; the box keeps
19046
+ its own keys. */
19047
+ window.addEventListener("keydown", (e) => {
19048
+ const k = e.key;
19049
+ // e.code: the K key on any layout (a Cyrillic one reports "л")
19050
+ if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (k === "k" || k === "K" || e.code === "KeyK")) {
19051
+ e.preventDefault();
19052
+ e.stopImmediatePropagation();
19053
+ if (e.repeat) return;
19054
+ // (focus stays with a dialog that opened over Search)
19055
+ if (cmdkOpen()) closeCmdk(!cmdkOtherOverlay());
19056
+ // another dialog keeps the keyboard until it closes
19057
+ else if (!cmdkOtherOverlay()) openCmdk();
19058
+ return;
19059
+ }
19060
+ if (!cmdkOpen()) return;
19061
+ // a dialog that opened meanwhile (Export setup finishing its load) takes the keyboard over
19062
+ if (cmdkOtherOverlay()) { closeCmdk(false); return; }
19063
+ if (e.target !== $("cmdkInput")) { e.stopImmediatePropagation(); return; }
19064
+ // Esc is Search's (before any picker or tool listening for it): clear the box, then close
19065
+ if (k === "Escape" && !e.isComposing) {
19066
+ e.preventDefault();
19067
+ e.stopImmediatePropagation();
19068
+ if ($("cmdkInput").value) { $("cmdkInput").value = ""; cmdk.active = 0; cmdkRender(); }
19069
+ else closeCmdk();
19070
+ }
19071
+ }, true);
18572
19072
  function settingsFocusables() {
18573
19073
  const root = $("settingsDialog");
18574
19074
  if (!root) return [];
@@ -18591,6 +19091,8 @@ function onSettingsTabTrap(e) {
18591
19091
  function openSettings() {
18592
19092
  const cb = $("setLinkSelect");
18593
19093
  if (cb) cb.checked = !!getSetting("linkSelect");
19094
+ const ask = $("setExportAsk");
19095
+ if (ask) ask.checked = getSetting("exportAsk") !== false;
18594
19096
  const overlay = $("settingsOverlay");
18595
19097
  overlay.classList.remove("hidden");
18596
19098
  overlay.addEventListener("keydown", onSettingsTabTrap);
@@ -18608,6 +19110,7 @@ $("btnCloseSettings").addEventListener("click", closeSettings);
18608
19110
  $("settingsOverlay").addEventListener("click", (e) => {
18609
19111
  if (e.target === $("settingsOverlay")) closeSettings();
18610
19112
  });
19113
+ $("setExportAsk")?.addEventListener("change", (e) => setSetting("exportAsk", !!e.target.checked));
18611
19114
  $("setLinkSelect").addEventListener("change", (e) => {
18612
19115
  setSetting("linkSelect", !!e.target.checked);
18613
19116
  if (!getSetting("linkSelect")) {
@@ -19095,6 +19598,7 @@ els.exportFrameOverlay?.querySelector(".ef-handle")?.addEventListener("keydown",
19095
19598
 
19096
19599
  window.addEventListener("keydown", (e) => {
19097
19600
  const k = e.key;
19601
+ if (!$("cmdkOverlay").classList.contains("hidden")) return; // Search has the keyboard (its box handles its own keys)
19098
19602
  if ((k === "Delete" || k === "Backspace") && !e.ctrlKey && !e.metaKey && !e.altKey) {
19099
19603
  if (!isTypingTarget(document.activeElement) && clearFocusedTransition()) {
19100
19604
  e.preventDefault();
@@ -19107,6 +19611,7 @@ window.addEventListener("keydown", (e) => {
19107
19611
  if (!e.repeat && $("btnProjectsDash") && !$("btnProjectsDash").classList.contains("hidden")) saveVersionNow(); // holding the keys makes one
19108
19612
  return;
19109
19613
  }
19614
+ // (Ctrl/Cmd+K, the command search, is handled before this, by its own listener)
19110
19615
  // Ctrl/Cmd+O: the Projects dashboard (where the editor server has projects)
19111
19616
  if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (k === "o" || k === "O") && $("btnProjectsDash") && !$("btnProjectsDash").classList.contains("hidden")) {
19112
19617
  e.preventDefault();