fablecut 1.18.0 → 1.20.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/CLAUDE.md +144 -11
- package/README.md +18 -16
- package/app.js +648 -110
- package/command-search.js +79 -0
- package/delivery.js +12 -7
- package/export-jobs.js +4 -2
- package/focus.js +165 -0
- package/index.html +33 -0
- package/manifest.json +59 -0
- package/mcp-server.js +124 -4
- package/media-files.js +271 -0
- package/package.json +3 -2
- package/paths.js +4 -3
- package/select-menu.js +295 -0
- package/server.js +286 -11
- package/style.css +318 -1
- package/transcripts.js +10 -0
- package/workflows.js +153 -0
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
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
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 (
|
|
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 (
|
|
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 &&
|
|
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
|
|
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…">
|
|
@@ -6894,8 +6922,12 @@ function renderInspector(lite) {
|
|
|
6894
6922
|
});
|
|
6895
6923
|
els.inspector.querySelectorAll("[data-k]").forEach((input) => {
|
|
6896
6924
|
const k = input.dataset.k;
|
|
6925
|
+
let armed = null; // the project as it was when a field / slider got focus; recorded on its first edit
|
|
6897
6926
|
input.addEventListener("input", (e) => {
|
|
6898
6927
|
if (!input.isConnected) return;
|
|
6928
|
+
// a dropdown pick is a whole edit: one undo step each; a field or slider takes one per focus that edits
|
|
6929
|
+
if (input.tagName === "SELECT") pushUndo();
|
|
6930
|
+
else if (armed) { pushUndo(armed); armed = null; }
|
|
6899
6931
|
if (input.type === "range" && (e.ctrlKey || e.metaKey)) return;
|
|
6900
6932
|
let v = input.type === "checkbox" ? input.checked
|
|
6901
6933
|
: input.type === "range" || input.type === "number" ? parseFloat(input.value)
|
|
@@ -6950,9 +6982,9 @@ function renderInspector(lite) {
|
|
|
6950
6982
|
if (ANIMATABLE.includes(k)) syncInspectorPlayhead();
|
|
6951
6983
|
});
|
|
6952
6984
|
input.addEventListener("focus", () => {
|
|
6953
|
-
|
|
6985
|
+
if (input.tagName !== "SELECT") armed = undoSnapshot();
|
|
6954
6986
|
if (ANIMATABLE.includes(k) && state.playing) pause();
|
|
6955
|
-
}
|
|
6987
|
+
});
|
|
6956
6988
|
});
|
|
6957
6989
|
els.inspector.querySelectorAll("[data-action]").forEach((btn) => {
|
|
6958
6990
|
btn.addEventListener("click", () => {
|
|
@@ -8879,6 +8911,8 @@ function cutSilences() {
|
|
|
8879
8911
|
const TRANSCRIBE_KEY = "fablecut-transcribe";
|
|
8880
8912
|
const trState = { open: false, built: false, busy: null, sig: "", words: [], sel: null, anchor: null, drag: false, query: "", hits: [], now: -1 };
|
|
8881
8913
|
const transcriptCache = new Map(); // src → validated transcript | false (none) | Promise while asking the server
|
|
8914
|
+
const transcriptHeld = new Map(); // src → the last transcript (or false) shown, kept while a refresh is pending
|
|
8915
|
+
const transcriptStale = new Set(); // srcs whose shown transcript the server hasn't confirmed (a failed read or save)
|
|
8882
8916
|
let transcriptGen = 0; // bumps whenever a transcript arrives or changes: the tab redraws
|
|
8883
8917
|
function transcribeSettings() {
|
|
8884
8918
|
let o = {};
|
|
@@ -8901,16 +8935,34 @@ function transcriptOf(src) {
|
|
|
8901
8935
|
function loadTranscript(src, force = false) {
|
|
8902
8936
|
const have = transcriptCache.get(src);
|
|
8903
8937
|
if (!force && have !== undefined) return have instanceof Promise ? have : Promise.resolve(have);
|
|
8904
|
-
|
|
8938
|
+
return readTranscript(src).then((r) => r.doc);
|
|
8939
|
+
}
|
|
8940
|
+
/** One read from the server → {doc, ok}: ok only when this read answered (a transcript, or that
|
|
8941
|
+
there is none) and no later read has replaced it. A read that fails (a server error, no network,
|
|
8942
|
+
a document that doesn't validate) keeps what was shown, marked unconfirmed. */
|
|
8943
|
+
function readTranscript(src) {
|
|
8944
|
+
let p = null;
|
|
8945
|
+
const read = fetch("/api/transcript?src=" + encodeURIComponent(src))
|
|
8946
|
+
.then((r) => (r.ok ? r.json() : r.status === 404 ? { transcript: null } : Promise.reject(new Error("HTTP " + r.status))))
|
|
8905
8947
|
.then((j) => {
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
if (
|
|
8909
|
-
return d;
|
|
8948
|
+
const d = j && j.transcript ? FableCutTranscribe.validate(j.transcript) : false;
|
|
8949
|
+
const latest = transcriptCache.get(src) === p;
|
|
8950
|
+
if (latest) { setTranscript(src, d); transcriptStale.delete(src); }
|
|
8951
|
+
return { doc: d, ok: latest };
|
|
8910
8952
|
})
|
|
8911
|
-
.catch(() => {
|
|
8953
|
+
.catch(() => {
|
|
8954
|
+
const d = transcriptHeld.get(src) || false;
|
|
8955
|
+
if (transcriptCache.get(src) === p) { setTranscript(src, d); transcriptStale.add(src); }
|
|
8956
|
+
return { doc: d, ok: false };
|
|
8957
|
+
});
|
|
8958
|
+
p = read.then((r) => r.doc);
|
|
8912
8959
|
transcriptCache.set(src, p);
|
|
8913
|
-
return
|
|
8960
|
+
return read;
|
|
8961
|
+
}
|
|
8962
|
+
function setTranscript(src, d) {
|
|
8963
|
+
transcriptCache.set(src, d);
|
|
8964
|
+
transcriptHeld.set(src, d);
|
|
8965
|
+
transcriptGen++;
|
|
8914
8966
|
}
|
|
8915
8967
|
function onTranscriptEvent(data) {
|
|
8916
8968
|
let src = null;
|
|
@@ -8989,8 +9041,8 @@ async function transcribeFile(src, { model, language, onProgress, cancelled }) {
|
|
|
8989
9041
|
const doc = T.validate({ src, model, language: language || "auto", duration, created: new Date().toISOString(), words });
|
|
8990
9042
|
let saved = false;
|
|
8991
9043
|
try { saved = (await fetch("/api/transcript?src=" + encodeURIComponent(src), { method: "POST", body: JSON.stringify(doc) })).ok; } catch { }
|
|
8992
|
-
|
|
8993
|
-
|
|
9044
|
+
setTranscript(src, doc);
|
|
9045
|
+
if (saved) transcriptStale.delete(src); else transcriptStale.add(src);
|
|
8994
9046
|
return { doc, saved };
|
|
8995
9047
|
}
|
|
8996
9048
|
/** Transcribe files one after another. `beat(fraction)` hears about progress (an agent's job). */
|
|
@@ -9050,14 +9102,23 @@ function transcriptWords() {
|
|
|
9050
9102
|
/** What Transcribe works on: the selected clips' files, else every file on the timeline without a transcript. */
|
|
9051
9103
|
function transcribeTargets() {
|
|
9052
9104
|
const groups = transcriptGroups();
|
|
9105
|
+
// a selected clip picks the file its speech group is heard from (a picture's sound may come
|
|
9106
|
+
// from denoised stems, another file): the group counts when it or a clip linked to it is selected
|
|
9053
9107
|
const picked = new Set();
|
|
9054
|
-
for (const
|
|
9055
|
-
const
|
|
9056
|
-
if (
|
|
9108
|
+
for (const g of groups) {
|
|
9109
|
+
const ids = new Set(withLinked(g).map((c) => c.id));
|
|
9110
|
+
if ([...ids].some((id) => state.selIds.has(id))) picked.add(getMedia(g[0].mediaId).src);
|
|
9057
9111
|
}
|
|
9058
9112
|
const srcs = [...new Set(groups.map((g) => getMedia(g[0].mediaId).src))];
|
|
9059
9113
|
const sel = srcs.filter((s) => picked.has(s));
|
|
9060
|
-
|
|
9114
|
+
if (sel.length) return { srcs: sel, selected: true };
|
|
9115
|
+
// a selection with no speech in it (a title) never turns into a timeline-wide action
|
|
9116
|
+
if (state.selIds.size) return { srcs: [], selected: false, none: true };
|
|
9117
|
+
const missing = srcs.filter((s) => transcriptCache.get(s) === false);
|
|
9118
|
+
// every file has a transcript already (an agent may have made them): the button offers them all again
|
|
9119
|
+
if (!missing.length && srcs.length && srcs.every((s) => transcriptCache.get(s) && !(transcriptCache.get(s) instanceof Promise)))
|
|
9120
|
+
return { srcs, selected: false, again: true };
|
|
9121
|
+
return { srcs: missing, selected: false };
|
|
9061
9122
|
}
|
|
9062
9123
|
/** What the words' places depend on: the timeline and the transcripts. */
|
|
9063
9124
|
function transcriptWordsSig() {
|
|
@@ -9192,15 +9253,32 @@ function renderTranscript(force = false) {
|
|
|
9192
9253
|
const words = trState.words = transcriptWords();
|
|
9193
9254
|
trState.wsig = transcriptWordsSig();
|
|
9194
9255
|
const tgt = transcribeTargets();
|
|
9195
|
-
E.go.textContent = tgt.selected ? `Transcribe selected (${tgt.srcs.length})` : tgt.
|
|
9256
|
+
E.go.textContent = tgt.selected ? `Transcribe selected (${tgt.srcs.length})` : tgt.again ? `Transcribe again (${tgt.srcs.length})`
|
|
9257
|
+
: tgt.srcs.length ? `Transcribe ${tgt.srcs.length} file${tgt.srcs.length === 1 ? "" : "s"}` : "Transcribe";
|
|
9196
9258
|
E.go.disabled = !!trState.busy || !tgt.srcs.length;
|
|
9197
|
-
E.go.title = tgt.
|
|
9198
|
-
:
|
|
9259
|
+
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)"
|
|
9260
|
+
: tgt.srcs.length ? "Turn the speech into words, in this browser (the model downloads once). Select clips to transcribe just those, or again"
|
|
9261
|
+
: 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"
|
|
9262
|
+
: "Put clips with speech on the timeline first";
|
|
9199
9263
|
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
9264
|
let html = "";
|
|
9201
9265
|
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
9266
|
else {
|
|
9203
9267
|
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>`;
|
|
9268
|
+
// which model and language made these words, so wrong words point at the fix
|
|
9269
|
+
const docs = groups.map((g) => transcriptCache.get(getMedia(g[0].mediaId).src)).filter((d) => d && d.words);
|
|
9270
|
+
const made = new Map();
|
|
9271
|
+
for (const d of docs) made.set(JSON.stringify([d.model ?? null, d.language ?? null]), d);
|
|
9272
|
+
if (made.size) {
|
|
9273
|
+
const said = [...made.values()].map((d) => {
|
|
9274
|
+
const model = d.model == null ? "an unknown model" : T.MODELS[d.model]?.label || d.model;
|
|
9275
|
+
const lang = d.language == null ? "an unknown language" : d.language === "" || d.language === "auto" ? "auto-detected" : T.LANGUAGES[d.language] || d.language;
|
|
9276
|
+
return `${escapeHtml(model)}, ${escapeHtml(lang)}`;
|
|
9277
|
+
});
|
|
9278
|
+
// with some files still untranscribed the button does those, so redoing others takes a selection
|
|
9279
|
+
const how = tgt.selected ? "then Transcribe selected" : tgt.again ? "then Transcribe again" : "select those clips, then Transcribe selected";
|
|
9280
|
+
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>`;
|
|
9281
|
+
}
|
|
9204
9282
|
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
9283
|
for (const s of T.segments(words)) {
|
|
9206
9284
|
let p = "";
|
|
@@ -9306,10 +9384,32 @@ function copyTranscript() {
|
|
|
9306
9384
|
navigator.clipboard.writeText(lines.join("\n")).then(() => toast(`Copied ${lines.length} line${lines.length === 1 ? "" : "s"}`), () => toast("Couldn't copy — the browser refused"));
|
|
9307
9385
|
}
|
|
9308
9386
|
async function transcribeFromTab() {
|
|
9309
|
-
|
|
9310
|
-
|
|
9387
|
+
// what the click meant is taken now (its files, its model and language); a selection already names its files
|
|
9388
|
+
let tgt = transcribeTargets();
|
|
9389
|
+
const opts = transcribeSettings();
|
|
9390
|
+
if (!tgt.selected && !tgt.none) {
|
|
9391
|
+
// transcripts being re-read (another tab saved one) decide which files are left: wait for
|
|
9392
|
+
// those of this timeline's files (a few seconds at most), then take the targets again,
|
|
9393
|
+
// unless the timeline or the selection changed meanwhile
|
|
9394
|
+
const at = silenceSig() + "|" + [...state.selIds].join(",");
|
|
9395
|
+
const srcs = new Set(transcriptGroups().map((g) => getMedia(g[0].mediaId).src));
|
|
9396
|
+
const loading = [...transcriptCache].filter(([s, v]) => srcs.has(s) && v instanceof Promise).map(([, v]) => v);
|
|
9397
|
+
if (loading.length) {
|
|
9398
|
+
await Promise.race([Promise.allSettled(loading), new Promise((r) => setTimeout(r, 5000))]);
|
|
9399
|
+
if (silenceSig() + "|" + [...state.selIds].join(",") !== at) { renderTranscript(true); toast("The timeline changed — check the button and click again"); return; }
|
|
9400
|
+
// the same action as clicked: "Transcribe N files" drops files whose transcript just arrived
|
|
9401
|
+
// (it never turns into a rerun of everything); "Transcribe again" stays a rerun
|
|
9402
|
+
if (!tgt.srcs.length) tgt = transcribeTargets(); // the button hadn't caught up: what it offers now
|
|
9403
|
+
else if (!tgt.again) {
|
|
9404
|
+
tgt = { ...tgt, srcs: tgt.srcs.filter((s) => transcriptCache.get(s) === false) };
|
|
9405
|
+
if (!tgt.srcs.length) { renderTranscript(true); toast("Those files have transcripts now"); return; }
|
|
9406
|
+
}
|
|
9407
|
+
}
|
|
9408
|
+
}
|
|
9409
|
+
const { srcs } = tgt;
|
|
9410
|
+
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
9411
|
let out;
|
|
9312
|
-
try { out = await transcribeSrcs(srcs); } catch (e) { toast(e.message); return; }
|
|
9412
|
+
try { out = await transcribeSrcs(srcs, opts); } catch (e) { toast(e.message); return; }
|
|
9313
9413
|
const unsaved = out.done.filter((d) => !d.saved).length;
|
|
9314
9414
|
const words = out.done.reduce((n, d) => n + d.words, 0);
|
|
9315
9415
|
toast(out.cancelled ? `Stopped — ${out.done.length} file${out.done.length === 1 ? "" : "s"} transcribed`
|
|
@@ -9413,7 +9513,11 @@ async function runTranscribeJob(ticket, fail) {
|
|
|
9413
9513
|
if (trState.busy) return fail("this editor tab is already transcribing — wait for it, or cancel it there");
|
|
9414
9514
|
const srcs = [], skipped = [];
|
|
9415
9515
|
for (const src of spec.srcs || []) {
|
|
9416
|
-
|
|
9516
|
+
// a transcript only counts as there when the server just confirmed it (a failed read is no proof)
|
|
9517
|
+
if (!spec.again) {
|
|
9518
|
+
const r = await readTranscript(src);
|
|
9519
|
+
if (r.ok && r.doc) { skipped.push(src); continue; }
|
|
9520
|
+
}
|
|
9417
9521
|
srcs.push(src);
|
|
9418
9522
|
}
|
|
9419
9523
|
const report = (body, force) => fetch("/api/export/job/report?id=" + encodeURIComponent(ticket.id), { method: "POST", body: JSON.stringify(body) })
|
|
@@ -11907,7 +12011,7 @@ function seqUndoPrint(d, withOthers) {
|
|
|
11907
12011
|
}
|
|
11908
12012
|
/** Open sequence `id` in the editor. False when it can't be opened now. */
|
|
11909
12013
|
function openSequence(id) {
|
|
11910
|
-
if (
|
|
12014
|
+
if (exportBusy()) { toast("Wait for the export to finish before opening another sequence"); return false; }
|
|
11911
12015
|
if (state.gesture) return false;
|
|
11912
12016
|
if (state.compCtx) exitComp(state.compCtx.path.length);
|
|
11913
12017
|
if (SeqLib.activeId(project) === id) return true;
|
|
@@ -11926,7 +12030,7 @@ function openSequence(id) {
|
|
|
11926
12030
|
}
|
|
11927
12031
|
/** Add a sequence ({name?, from?, width?, height?}) and open it. */
|
|
11928
12032
|
function newSequence(opts, clips = null) {
|
|
11929
|
-
if (
|
|
12033
|
+
if (exportBusy()) { toast("Wait for the export to finish"); return; }
|
|
11930
12034
|
if (state.compCtx) exitComp(state.compCtx.path.length);
|
|
11931
12035
|
const doc = projectJSONHere();
|
|
11932
12036
|
let s;
|
|
@@ -11947,7 +12051,7 @@ function renameSequence(id, name) {
|
|
|
11947
12051
|
async function deleteSequence(id) {
|
|
11948
12052
|
const r = seqRoot(), s = SeqLib.find(r, id);
|
|
11949
12053
|
if (!s || SeqLib.entries(r).length < 2) return;
|
|
11950
|
-
if (
|
|
12054
|
+
if (exportBusy()) { toast("Wait for the export to finish"); return; }
|
|
11951
12055
|
if (state.compCtx) exitComp(state.compCtx.path.length);
|
|
11952
12056
|
let kept = null;
|
|
11953
12057
|
if (state.connected) {
|
|
@@ -11962,7 +12066,7 @@ async function deleteSequence(id) {
|
|
|
11962
12066
|
if (!kept) { toast(`Couldn't keep a version of the project, so “${s.name}” was not deleted. Try again in a moment.`); return; }
|
|
11963
12067
|
}
|
|
11964
12068
|
// the editor may have moved on while the version was saved
|
|
11965
|
-
if (
|
|
12069
|
+
if (exportBusy()) { toast("Wait for the export to finish"); return; }
|
|
11966
12070
|
if (state.compCtx) exitComp(state.compCtx.path.length);
|
|
11967
12071
|
if (!SeqLib.find(project, id) || SeqLib.entries(project).length < 2) return; // deleted or changed meanwhile (another tab, an agent)
|
|
11968
12072
|
const wasOpen = SeqLib.activeId(project) === id;
|
|
@@ -13406,7 +13510,7 @@ async function readHighlightSource(c, cancelled, onFrame) {
|
|
|
13406
13510
|
async function makeHighlights(clips, { duration = 30, shot, size = null, follow = false, progress, cancelled: stop } = {}) {
|
|
13407
13511
|
if (!Highlights) { toast("Highlights module missing — reload the editor"); return null; }
|
|
13408
13512
|
if (highlightRun.busy) { toast("Already making highlights — wait for it, or Cancel"); return null; }
|
|
13409
|
-
if (
|
|
13513
|
+
if (exportBusy()) { toast("Wait for the export to finish"); return null; }
|
|
13410
13514
|
const { take, skip } = Highlights.sourcesOf({ clips: project.clips, disabledTracks: [...state.disabledTracks] }, clips && clips.map((c) => c.id));
|
|
13411
13515
|
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
13516
|
Object.assign(highlightRun, { busy: true, cancel: false });
|
|
@@ -13754,6 +13858,7 @@ els.preview.addEventListener("pointerdown", (e) => {
|
|
|
13754
13858
|
}, true);
|
|
13755
13859
|
window.addEventListener("keydown", (e) => {
|
|
13756
13860
|
if (e.key !== "Escape" || (!trackUi.run && trackUi.tool !== "point")) return;
|
|
13861
|
+
if (!$("cmdkOverlay").classList.contains("hidden")) return; // Esc belongs to Search while it is open
|
|
13757
13862
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
13758
13863
|
if (trackUi.run) trackUi.run.cancel = true;
|
|
13759
13864
|
else { trackUi.tool = null; renderInspector(); }
|
|
@@ -14176,6 +14281,7 @@ els.preview.addEventListener("dblclick", (e) => {
|
|
|
14176
14281
|
maskUi.pt = -1; scheduleSave(); renderInspector();
|
|
14177
14282
|
}, true);
|
|
14178
14283
|
window.addEventListener("keydown", (e) => {
|
|
14284
|
+
if (!$("cmdkOverlay").classList.contains("hidden")) return; // keys belong to Search while it is open
|
|
14179
14285
|
if (e.key === "Escape" && colorState.maskDraw) { // the Color tab's Draw
|
|
14180
14286
|
e.preventDefault(); e.stopImmediatePropagation();
|
|
14181
14287
|
colorState.maskDraw = false; colorState.maskStroke = null; state.dirtyTimeline = true; renderColorPage(true);
|
|
@@ -16379,6 +16485,7 @@ function refreshDeliveryNotes() {
|
|
|
16379
16485
|
$("dlvSummary").textContent = `${Delivery.describe(sp, { width: fr.outW, height: fr.outH, fps })}` +
|
|
16380
16486
|
(size ? ` · about ${Delivery.fmtBytes(size)}` : "");
|
|
16381
16487
|
$("dlvFilePreview").textContent = "→ exports/" + deliveryFileName(sp, fps) + Delivery.CONTAINERS[sp.container].ext;
|
|
16488
|
+
syncExportName();
|
|
16382
16489
|
const cv = deliveryCanvas();
|
|
16383
16490
|
const warn = [...dlvNotes.map((n) => n[0].toUpperCase() + n.slice(1)),
|
|
16384
16491
|
...Delivery.checks(sp, { duration: range.dur, fps, canvasW: cv.w, canvasH: cv.h, region: cv.region })];
|
|
@@ -16457,10 +16564,65 @@ function webCodecsBitrate(w, h, fps) {
|
|
|
16457
16564
|
// ~0.1 bit/pixel/frame, clamped — same heuristic as before
|
|
16458
16565
|
return Math.min(20_000_000, Math.max(2_000_000, Math.round(w * h * fps * 0.1)));
|
|
16459
16566
|
}
|
|
16567
|
+
/* The Export dialog's "Save as" name. The field shows the name the export would get;
|
|
16568
|
+
once typed in, that name is used for this export (cleared = the default, shown greyed). */
|
|
16569
|
+
let exportNameTyped = false;
|
|
16570
|
+
let exportNameShown = ""; // the default the Save as field shows (a {time} in it is the time it was filled in)
|
|
16571
|
+
/** The engine the dialog's choices lead to, as startChosenExport picks it. */
|
|
16572
|
+
function chosenExportEngine() {
|
|
16573
|
+
if (els.engineFast.checked && !els.engineFast.disabled) return "fast";
|
|
16574
|
+
if (!els.engineRealtime.checked || els.engineRealtime.disabled) return null;
|
|
16575
|
+
return state.connected && state.ffmpeg && state.webCodecs && !getExportFrame() ? "webcodecs" : "recorder";
|
|
16576
|
+
}
|
|
16577
|
+
function defaultExportName() {
|
|
16578
|
+
const c = selectedExportChoice();
|
|
16579
|
+
if (chosenExportEngine() === "fast" && c.kind === "delivery" && dlvSpec) return deliveryFileName(dlvSpec);
|
|
16580
|
+
return project.name.replace(/[^\w\- ]+/g, "").trim() || "export";
|
|
16581
|
+
}
|
|
16582
|
+
function exportNameExt() {
|
|
16583
|
+
const engine = chosenExportEngine(), c = selectedExportChoice();
|
|
16584
|
+
if (engine === "fast" && c.kind === "delivery" && dlvSpec) return Delivery.CONTAINERS[dlvSpec.container].ext;
|
|
16585
|
+
if (engine === "recorder") return (pickMime() || "").startsWith("video/mp4") ? ".mp4" : ".webm";
|
|
16586
|
+
if (engine === "fast" && c.kind === "profile") return encodeProfiles.profiles[c.id]?.extension || ".mp4";
|
|
16587
|
+
return ".mp4";
|
|
16588
|
+
}
|
|
16589
|
+
function syncExportName() {
|
|
16590
|
+
const el = $("exportName");
|
|
16591
|
+
if (!el) return;
|
|
16592
|
+
const def = exportNameShown = defaultExportName();
|
|
16593
|
+
el.placeholder = def;
|
|
16594
|
+
if (!exportNameTyped) el.value = def;
|
|
16595
|
+
const note = $("exportNameNote");
|
|
16596
|
+
if (!note) return;
|
|
16597
|
+
const file = (exportName() || def) + exportNameExt();
|
|
16598
|
+
note.textContent = chosenExportEngine() === "recorder"
|
|
16599
|
+
? "→ the browser downloads " + file
|
|
16600
|
+
: "→ exports/" + file + " · a number is added if that name is taken";
|
|
16601
|
+
// (the browser download names its own copies when the name is taken)
|
|
16602
|
+
}
|
|
16603
|
+
/** The typed name (file-safe), or null for the default. */
|
|
16604
|
+
function exportName() {
|
|
16605
|
+
const v = exportNameTyped ? ($("exportName")?.value || "").trim() : "";
|
|
16606
|
+
const ext = exportNameExt().toLowerCase();
|
|
16607
|
+
const base = ext && v.toLowerCase().endsWith(ext) ? v.slice(0, -ext.length) : v;
|
|
16608
|
+
const safe = base.replace(/\.(mp4|mov|m4v|mkv|webm|mxf)$/i, "").replace(/[^\w\- ()\[\].]+/g, "_").replace(/^[.\s]+/, "").slice(0, 120);
|
|
16609
|
+
return safe || null;
|
|
16610
|
+
}
|
|
16611
|
+
let exportSetupOpening = false; // one Export click at a time, while the dialog's lists load
|
|
16612
|
+
/* An export getting ready (its players, fonts, encoder check) holds the canvas before
|
|
16613
|
+
state.exporting is set: every engine, the queue and agent jobs wait for both. */
|
|
16614
|
+
let exportStarting = false;
|
|
16615
|
+
function exportBusy() { return state.exporting || exportStarting; }
|
|
16616
|
+
/** Which timeline an Export click was for: a project or sequence opened meanwhile isn't it. */
|
|
16617
|
+
function exportContext() { return (runtime.projectId || "") + "|" + (project.sequence || "") + "|" + (state.compCtx ? state.compCtx.path.join("/") : ""); }
|
|
16460
16618
|
async function openExportSetup() {
|
|
16461
|
-
if (
|
|
16619
|
+
if (exportBusy() || exportSetupOpening) return;
|
|
16620
|
+
const ctx = exportContext();
|
|
16621
|
+
// the dialog already open is being refreshed (a setting changed): keep what was typed in it
|
|
16622
|
+
const fresh = els.exportSetup.classList.contains("hidden");
|
|
16462
16623
|
if (!project.clips.length) { alert("Timeline is empty — add some clips first."); return; }
|
|
16463
|
-
|
|
16624
|
+
exportSetupOpening = true;
|
|
16625
|
+
try { await detectWebCodecs(); } catch { }
|
|
16464
16626
|
const ef = getExportFrame();
|
|
16465
16627
|
const fastOk = state.connected && state.ffmpeg;
|
|
16466
16628
|
// WebCodecs and MediaRecorder encode the full canvas — only Fast crops.
|
|
@@ -16525,14 +16687,68 @@ async function openExportSetup() {
|
|
|
16525
16687
|
syncExportRangeUi();
|
|
16526
16688
|
syncExportProfileVisibility();
|
|
16527
16689
|
Promise.all([fetchEncodeProfiles(), fetchDeliveryInfo()]).then(() => {
|
|
16690
|
+
if (exportContext() !== ctx) { toast("Another timeline opened — click Export again"); return; }
|
|
16528
16691
|
populateExportProfileSelect();
|
|
16529
16692
|
syncExportProfileVisibility();
|
|
16530
16693
|
renderBatchList();
|
|
16531
16694
|
renderQueue();
|
|
16695
|
+
if (fresh) {
|
|
16696
|
+
exportNameTyped = false;
|
|
16697
|
+
const skip = $("exportSkipAsk");
|
|
16698
|
+
if (skip) skip.checked = false;
|
|
16699
|
+
}
|
|
16700
|
+
syncExportName();
|
|
16701
|
+
if (fresh && !getSetting("exportAsk")) {
|
|
16702
|
+
// "Don't ask again": render with the last engine and settings under the default name;
|
|
16703
|
+
// if that engine can't run now, ask after all rather than switch engines silently
|
|
16704
|
+
const last = getSetting("exportEngine");
|
|
16705
|
+
// (older settings say "second" for either real-time encoder)
|
|
16706
|
+
const radio = last === "fast" ? els.engineFast : last === "second" || last === "webcodecs" || last === "recorder" ? els.engineRealtime : null;
|
|
16707
|
+
// ...and the last preset or profile picked, when it is still in the list
|
|
16708
|
+
const choice = getSetting("exportChoice");
|
|
16709
|
+
// (a raw profile has to still be on the server: a deleted one can linger in the list as a placeholder)
|
|
16710
|
+
const choiceOk = !choice || (choice.startsWith("p:") ? Object.hasOwn(encodeProfiles.profiles, choice.slice(2))
|
|
16711
|
+
: [...els.exportProfileSel.options].some((o) => o.value === choice));
|
|
16712
|
+
if (choiceOk && choice) {
|
|
16713
|
+
if (els.exportProfileSel.value !== choice) {
|
|
16714
|
+
els.exportProfileSel.value = choice;
|
|
16715
|
+
els.exportProfileSel.dispatchEvent(new Event("change"));
|
|
16716
|
+
}
|
|
16717
|
+
// the delivery as last exported (its size, codec…), even when the project pins the same preset
|
|
16718
|
+
const lastDlv = getSetting("delivery");
|
|
16719
|
+
if (choice.startsWith("d:") && lastDlv?.preset === choice.slice(2)) {
|
|
16720
|
+
dlvSpec = normalizeDelivery(lastDlv).spec;
|
|
16721
|
+
fillDeliveryControls(); // the dialog, if it opens, shows what Render will write
|
|
16722
|
+
refreshDeliveryNotes();
|
|
16723
|
+
}
|
|
16724
|
+
}
|
|
16725
|
+
if (radio) {
|
|
16726
|
+
els.engineFast.checked = radio === els.engineFast && !radio.disabled; els.engineRealtime.checked = radio === els.engineRealtime && !radio.disabled;
|
|
16727
|
+
// the dialog, if it opens, shows the engine's own controls
|
|
16728
|
+
syncExportProfileVisibility(); syncExportWcOpts();
|
|
16729
|
+
}
|
|
16730
|
+
// the range counted in frames of what will be written (a delivery may have its own frame rate)
|
|
16731
|
+
const outFps = chosenExportEngine() === "fast" && selectedExportChoice().kind === "delivery" && dlvSpec?.fps || projectFps();
|
|
16732
|
+
const engineOk = !radio || (!radio.disabled && (last === "second" || last === "fast" || chosenExportEngine() === last));
|
|
16733
|
+
if (engineOk && choiceOk && exportRange(outFps).frames >= 1) {
|
|
16734
|
+
syncExportName();
|
|
16735
|
+
toast(`Exporting “${defaultExportName()}” — Settings → Ask before exporting brings the dialog back`);
|
|
16736
|
+
startChosenExport();
|
|
16737
|
+
return;
|
|
16738
|
+
}
|
|
16739
|
+
toast(exportRange(outFps).frames < 1 ? "The export range is empty — pick one"
|
|
16740
|
+
: !choiceOk ? "The last export's preset isn't there any more — pick one" : "The last export's engine isn't available — pick one");
|
|
16741
|
+
}
|
|
16532
16742
|
els.exportSetup.classList.remove("hidden");
|
|
16533
16743
|
// aria-modal hides what is behind — focus has to come inside
|
|
16534
16744
|
if (!els.exportSetup.contains(document.activeElement)) $("exportRangeSel")?.focus();
|
|
16535
|
-
});
|
|
16745
|
+
}).finally(() => { exportSetupOpening = false; });
|
|
16746
|
+
}
|
|
16747
|
+
/* The progress overlay takes focus: left on the Export button, Space would
|
|
16748
|
+
play the timeline under a running export (focus.js) instead of pressing Cancel. */
|
|
16749
|
+
function showExportOverlay() {
|
|
16750
|
+
els.exportOverlay.classList.remove("hidden");
|
|
16751
|
+
$("btnCancelExport")?.focus();
|
|
16536
16752
|
}
|
|
16537
16753
|
function closeExportSetup() {
|
|
16538
16754
|
els.exportSetup.classList.add("hidden");
|
|
@@ -16555,17 +16771,22 @@ function startChosenExport() {
|
|
|
16555
16771
|
alert("Export range is empty — IN/OUT is at or past the end of the timeline. Choose Entire timeline, or move the markers.");
|
|
16556
16772
|
return;
|
|
16557
16773
|
}
|
|
16774
|
+
// the name shown now (a default with {time} must not tick over while the audio mixes)
|
|
16775
|
+
const name = exportName() || exportNameShown || defaultExportName();
|
|
16776
|
+
if ($("exportSkipAsk")?.checked) setSetting("exportAsk", false);
|
|
16777
|
+
setSetting("exportEngine", chosenExportEngine());
|
|
16778
|
+
setSetting("exportChoice", els.exportProfileSel?.value || null);
|
|
16558
16779
|
closeExportSetup();
|
|
16559
16780
|
if (useFast) {
|
|
16560
16781
|
const c = selectedExportChoice();
|
|
16561
16782
|
setSetting("exportKind", c.kind);
|
|
16562
16783
|
if (c.kind === "delivery") {
|
|
16563
16784
|
setSetting("delivery", dlvSpec);
|
|
16564
|
-
fastExport({ delivery: dlvSpec });
|
|
16565
|
-
} else fastExport({ profile: c.id });
|
|
16785
|
+
fastExport({ delivery: dlvSpec, name });
|
|
16786
|
+
} else fastExport({ profile: c.id, name });
|
|
16566
16787
|
}
|
|
16567
|
-
else if (useSecond && state.connected && state.ffmpeg && state.webCodecs && !getExportFrame()) webCodecsExport();
|
|
16568
|
-
else startExport();
|
|
16788
|
+
else if (useSecond && state.connected && state.ffmpeg && state.webCodecs && !getExportFrame()) webCodecsExport(name);
|
|
16789
|
+
else startExport(name);
|
|
16569
16790
|
}
|
|
16570
16791
|
|
|
16571
16792
|
/* Keep Range's IN–OUT option in sync with marker presence without clobbering
|
|
@@ -16652,31 +16873,15 @@ function snapshotExportFrame() {
|
|
|
16652
16873
|
return { kind: "rgba", data: img.data, w: src.width, h: src.height };
|
|
16653
16874
|
} catch (e) { throw canvasTaintError(e); }
|
|
16654
16875
|
}
|
|
16655
|
-
let exportRgbaOff = null, exportRgbaCtx = null;
|
|
16656
|
-
/** Raw RGBA of the frame, for outputs that keep more than JPEG's 4:2:0 8-bit
|
|
16657
|
-
* (ProRes, DNxHR, FFV1, 10-bit, 4:2:2 / 4:4:4). */
|
|
16658
|
-
function snapshotExportRgba() {
|
|
16659
|
-
const src = exportSourceCanvas();
|
|
16660
|
-
try {
|
|
16661
|
-
if (!exportRgbaOff || exportRgbaOff.width !== src.width || exportRgbaOff.height !== src.height) {
|
|
16662
|
-
exportRgbaOff = typeof OffscreenCanvas === "function" ? new OffscreenCanvas(src.width, src.height)
|
|
16663
|
-
: Object.assign(document.createElement("canvas"), { width: src.width, height: src.height });
|
|
16664
|
-
exportRgbaCtx = exportRgbaOff.getContext("2d", { alpha: false, willReadFrequently: true });
|
|
16665
|
-
}
|
|
16666
|
-
exportRgbaCtx.drawImage(src, 0, 0);
|
|
16667
|
-
const img = exportRgbaCtx.getImageData(0, 0, src.width, src.height);
|
|
16668
|
-
return new Uint8Array(img.data.buffer, img.data.byteOffset, img.data.byteLength);
|
|
16669
|
-
} catch (e) { throw canvasTaintError(e); }
|
|
16670
|
-
}
|
|
16671
16876
|
const JPEG_WORKER_SRC = `"use strict";
|
|
16672
16877
|
self.onmessage = async (e) => {
|
|
16673
|
-
const { id, bmp, quality } = e.data;
|
|
16878
|
+
const { id, bmp, quality, type } = e.data;
|
|
16674
16879
|
try {
|
|
16675
16880
|
const c = new OffscreenCanvas(bmp.width, bmp.height);
|
|
16676
16881
|
const ctx = c.getContext("2d", { alpha: false });
|
|
16677
16882
|
ctx.drawImage(bmp, 0, 0);
|
|
16678
16883
|
bmp.close();
|
|
16679
|
-
const blob = await c.convertToBlob({ type: "image/jpeg", quality: quality || 0.92 });
|
|
16884
|
+
const blob = await c.convertToBlob(type === "image/png" ? { type } : { type: "image/jpeg", quality: quality || 0.92 });
|
|
16680
16885
|
const buf = await blob.arrayBuffer();
|
|
16681
16886
|
self.postMessage({ id, buf }, [buf]);
|
|
16682
16887
|
} catch (err) {
|
|
@@ -16712,12 +16917,12 @@ function createJpegWorkers(n) {
|
|
|
16712
16917
|
w.onerror = () => {};
|
|
16713
16918
|
}
|
|
16714
16919
|
return {
|
|
16715
|
-
encode(bmp, quality) {
|
|
16920
|
+
encode(bmp, quality, type) {
|
|
16716
16921
|
const id = nextId++;
|
|
16717
16922
|
const w = workers[rr++ % workers.length];
|
|
16718
16923
|
return new Promise((resolve, reject) => {
|
|
16719
16924
|
pending.set(id, { resolve, reject });
|
|
16720
|
-
try { w.postMessage({ id, bmp, quality }, [bmp]); }
|
|
16925
|
+
try { w.postMessage({ id, bmp, quality, type }, [bmp]); }
|
|
16721
16926
|
catch (e) { pending.delete(id); reject(e); }
|
|
16722
16927
|
});
|
|
16723
16928
|
},
|
|
@@ -16728,7 +16933,7 @@ function createJpegWorkers(n) {
|
|
|
16728
16933
|
},
|
|
16729
16934
|
};
|
|
16730
16935
|
}
|
|
16731
|
-
function jpegFromBitmap(bmp, quality) {
|
|
16936
|
+
function jpegFromBitmap(bmp, quality, type = "image/jpeg") {
|
|
16732
16937
|
const c = document.createElement("canvas");
|
|
16733
16938
|
c.width = bmp.width; c.height = bmp.height;
|
|
16734
16939
|
c.getContext("2d", { alpha: false }).drawImage(bmp, 0, 0);
|
|
@@ -16738,7 +16943,7 @@ function jpegFromBitmap(bmp, quality) {
|
|
|
16738
16943
|
c.toBlob((b) => {
|
|
16739
16944
|
if (!b) return rej(new Error("frame encode failed"));
|
|
16740
16945
|
b.arrayBuffer().then(res, rej);
|
|
16741
|
-
},
|
|
16946
|
+
}, type, quality);
|
|
16742
16947
|
} catch (e) { rej(canvasTaintError(e)); }
|
|
16743
16948
|
});
|
|
16744
16949
|
}
|
|
@@ -16808,6 +17013,29 @@ async function armExportCors() {
|
|
|
16808
17013
|
if (missing.length)
|
|
16809
17014
|
toast("No CORS on " + missing.join(", ") + " — blank in the export. Import into the project or add Access-Control-Allow-Origin.");
|
|
16810
17015
|
}
|
|
17016
|
+
/* One frame upload. XMLHttpRequest, not fetch: in Chromium each fetch body leaves
|
|
17017
|
+
about twice its size of native memory behind for the life of the tab, an
|
|
17018
|
+
XHR body about half that, and a long export runs the renderer out of memory
|
|
17019
|
+
(#165). */
|
|
17020
|
+
function postFrames(url, body, signal) {
|
|
17021
|
+
return new Promise((ok, bad) => {
|
|
17022
|
+
if (signal && signal.aborted) return bad(new Error("cancelled"));
|
|
17023
|
+
const xhr = new XMLHttpRequest();
|
|
17024
|
+
const onAbort = () => xhr.abort();
|
|
17025
|
+
const done = (fn) => { if (signal) signal.removeEventListener("abort", onAbort); fn(); };
|
|
17026
|
+
xhr.open("POST", url, true);
|
|
17027
|
+
xhr.onload = () => done(() => {
|
|
17028
|
+
if (xhr.status >= 200 && xhr.status < 300) return ok();
|
|
17029
|
+
let msg = "frame upload failed";
|
|
17030
|
+
try { msg = JSON.parse(xhr.responseText).error || msg; } catch { }
|
|
17031
|
+
bad(new Error(msg));
|
|
17032
|
+
});
|
|
17033
|
+
xhr.onerror = () => done(() => bad(new Error("frame upload failed")));
|
|
17034
|
+
xhr.onabort = () => done(() => bad(new Error("cancelled")));
|
|
17035
|
+
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
|
17036
|
+
xhr.send(body);
|
|
17037
|
+
});
|
|
17038
|
+
}
|
|
16811
17039
|
/* Sequential /frame POSTs, batched. Concurrent bodies can still race on ffmpeg
|
|
16812
17040
|
stdin if they complete out of order, so the client starts each fetch only
|
|
16813
17041
|
after the previous one settles; rendering runs ahead under backpressure.
|
|
@@ -16835,10 +17063,7 @@ function createExportUploader(sessId, { batchItems, batchBytes, signal, getError
|
|
|
16835
17063
|
if (cancelled()) throw new Error("cancelled");
|
|
16836
17064
|
const err = getError();
|
|
16837
17065
|
if (err) throw err;
|
|
16838
|
-
|
|
16839
|
-
method: "POST", body, signal,
|
|
16840
|
-
});
|
|
16841
|
-
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || "frame upload failed");
|
|
17066
|
+
await postFrames("/api/export/frame?id=" + sessId, body, signal);
|
|
16842
17067
|
});
|
|
16843
17068
|
uploadTail = p.catch((err) => {
|
|
16844
17069
|
if (!getError()) setError(err);
|
|
@@ -17472,17 +17697,17 @@ async function prepareFrameAssets(t) {
|
|
|
17472
17697
|
* opts.silent: no overlay, alert or download (the export queue shows it);
|
|
17473
17698
|
* opts.onProgress(0…1). Resolves {outputs:[{file, ok, src?, error?}]} or {error, cancelled}. */
|
|
17474
17699
|
async function fastExport(opts = {}) {
|
|
17475
|
-
if (
|
|
17700
|
+
if (exportBusy()) return { error: "an export is already running in this tab", busy: true };
|
|
17476
17701
|
const job = opts.job || null;
|
|
17477
17702
|
pause();
|
|
17478
17703
|
state.exporting = true; state.rendering = true; renderCancelled = false;
|
|
17479
17704
|
exportAbort = new AbortController();
|
|
17480
17705
|
const signal = exportAbort.signal;
|
|
17481
|
-
if (!opts.silent)
|
|
17706
|
+
if (!opts.silent) showExportOverlay();
|
|
17482
17707
|
els.exportProgress.style.width = "0%";
|
|
17483
17708
|
els.exportNote.textContent = "Rendering frames → ffmpeg. You can switch tabs; export continues.";
|
|
17484
17709
|
restoreExportVideoState();
|
|
17485
|
-
const deliveries = opts.deliveries || (opts.delivery ? [{ delivery: opts.delivery }] : null);
|
|
17710
|
+
const deliveries = opts.deliveries || (opts.delivery ? [{ delivery: opts.delivery, name: opts.name || undefined }] : null);
|
|
17486
17711
|
const delivery = deliveries ? deliveries[0].delivery : null;
|
|
17487
17712
|
const fps = (delivery && delivery.fps) || projectFps();
|
|
17488
17713
|
let result = null;
|
|
@@ -17504,7 +17729,7 @@ async function fastExport(opts = {}) {
|
|
|
17504
17729
|
canvasW: cv.w, canvasH: cv.h, region: cv.region, hasAudio: !!wav,
|
|
17505
17730
|
} : {
|
|
17506
17731
|
fps,
|
|
17507
|
-
name: project.name.replace(/[^\w\- ]+/g, "") || "export",
|
|
17732
|
+
name: opts.name || project.name.replace(/[^\w\- ]+/g, "") || "export",
|
|
17508
17733
|
profile: profileId,
|
|
17509
17734
|
hasAudio: !!wav,
|
|
17510
17735
|
}),
|
|
@@ -17513,7 +17738,9 @@ async function fastExport(opts = {}) {
|
|
|
17513
17738
|
if (!begin.id) throw new Error(begin.error || "export begin failed");
|
|
17514
17739
|
sessId = begin.id;
|
|
17515
17740
|
const jpegQ = delivery ? begin.jpegQuality ?? 0.95 : exportProfileMeta(profileId).jpegQuality ?? 0.95;
|
|
17516
|
-
|
|
17741
|
+
// lossless PNG frames for outputs that keep more than JPEG's 4:2:0: the canvas is 8-bit RGB,
|
|
17742
|
+
// so PNG carries exactly its pixels, at about a tenth of raw RGBA's upload (#165)
|
|
17743
|
+
const frameType = begin.input === "png" ? "image/png" : "image/jpeg";
|
|
17517
17744
|
exportFullCanvas = !!delivery;
|
|
17518
17745
|
if (wav) {
|
|
17519
17746
|
const r = await fetch("/api/export/audio?id=" + sessId, { method: "POST", body: wav, signal });
|
|
@@ -17557,12 +17784,11 @@ async function fastExport(opts = {}) {
|
|
|
17557
17784
|
await seekVideosTo(t, { queueBusy });
|
|
17558
17785
|
await prepareFrameAssets(t);
|
|
17559
17786
|
drawFrame(t);
|
|
17560
|
-
const snap =
|
|
17787
|
+
const snap = snapshotExportFrame();
|
|
17561
17788
|
pixelsInflight++;
|
|
17562
17789
|
let jpegP;
|
|
17563
|
-
if (snap.kind === "
|
|
17564
|
-
|
|
17565
|
-
jpegP = workers ? workers.encode(snap.bmp, jpegQ) : jpegFromBitmap(snap.bmp, jpegQ);
|
|
17790
|
+
if (snap.kind === "bmp") {
|
|
17791
|
+
jpegP = workers ? workers.encode(snap.bmp, jpegQ, frameType) : jpegFromBitmap(snap.bmp, jpegQ, frameType);
|
|
17566
17792
|
} else {
|
|
17567
17793
|
const c = document.createElement("canvas");
|
|
17568
17794
|
c.width = snap.w; c.height = snap.h;
|
|
@@ -17572,7 +17798,7 @@ async function fastExport(opts = {}) {
|
|
|
17572
17798
|
c.toBlob((b) => {
|
|
17573
17799
|
if (!b) return rej(new Error("frame encode failed"));
|
|
17574
17800
|
b.arrayBuffer().then(res, rej);
|
|
17575
|
-
},
|
|
17801
|
+
}, frameType, jpegQ);
|
|
17576
17802
|
} catch (e) { rej(canvasTaintError(e)); }
|
|
17577
17803
|
});
|
|
17578
17804
|
}
|
|
@@ -17718,7 +17944,7 @@ function renderQueueProgress() {
|
|
|
17718
17944
|
}
|
|
17719
17945
|
}
|
|
17720
17946
|
async function runQueue() {
|
|
17721
|
-
if (queueRunning ||
|
|
17947
|
+
if (queueRunning || exportBusy()) return;
|
|
17722
17948
|
if (!(state.connected && state.ffmpeg)) { alert("The export queue needs the server and ffmpeg (Fast export)."); return; }
|
|
17723
17949
|
queueRunning = true; queueStop = false;
|
|
17724
17950
|
renderQueue();
|
|
@@ -17838,8 +18064,23 @@ async function reportExportJob(id, body, force = false) {
|
|
|
17838
18064
|
if (r?.cancel) { renderCancelled = true; exportAbort?.abort(); }
|
|
17839
18065
|
} catch { }
|
|
17840
18066
|
}
|
|
18067
|
+
let skippedTicket = null, skippedTimer = 0;
|
|
17841
18068
|
async function runExportJob(ticket) {
|
|
17842
|
-
if (!ticket?.id
|
|
18069
|
+
if (!ticket?.id) return;
|
|
18070
|
+
if (exportBusy()) {
|
|
18071
|
+
// a busy tab leaves it for another, but tries again when it is free (the server's claim
|
|
18072
|
+
// decides: a ticket another tab took, or one the agent cancelled, is refused)
|
|
18073
|
+
skippedTicket = ticket;
|
|
18074
|
+
clearInterval(skippedTimer);
|
|
18075
|
+
const until = Date.now() + 30000;
|
|
18076
|
+
skippedTimer = setInterval(() => {
|
|
18077
|
+
if (exportBusy() && Date.now() < until) return;
|
|
18078
|
+
clearInterval(skippedTimer);
|
|
18079
|
+
const t = skippedTicket; skippedTicket = null;
|
|
18080
|
+
if (t && !exportBusy()) runExportJob(t);
|
|
18081
|
+
}, 500);
|
|
18082
|
+
return;
|
|
18083
|
+
}
|
|
17843
18084
|
const claimed = await fetch("/api/export/job/claim?id=" + encodeURIComponent(ticket.id), { method: "POST" })
|
|
17844
18085
|
.then((r) => r.ok).catch(() => false);
|
|
17845
18086
|
if (!claimed) return;
|
|
@@ -17848,9 +18089,20 @@ async function runExportJob(ticket) {
|
|
|
17848
18089
|
for (let i = 0; i < 150 && ticket.revision != null && (project.revision || 0) < ticket.revision; i++)
|
|
17849
18090
|
await new Promise((r) => setTimeout(r, 100));
|
|
17850
18091
|
if (ticket.revision != null && (project.revision || 0) < ticket.revision) await syncFromServer();
|
|
18092
|
+
// a ticket that waited here while the tab switched projects must not render the other one
|
|
18093
|
+
if (ticket.project && runtime.projectId && ticket.project !== runtime.projectId && ticket.kind !== "transcribe")
|
|
18094
|
+
return fail("another project was opened before this job could start — open the project again and retry");
|
|
18095
|
+
if (ticket.kind === "transcribe") return runTranscribeJob(ticket, fail);
|
|
18096
|
+
// from here until the job ends, a project opened elsewhere waits: the job renders the one it was asked for
|
|
18097
|
+
runtime.jobHold = (runtime.jobHold || 0) + 1;
|
|
18098
|
+
try { return await runHeldJob(ticket, fail); } finally {
|
|
18099
|
+
runtime.jobHold--;
|
|
18100
|
+
if (!runtime.jobHold && runtime.pendingSync) syncFromServer();
|
|
18101
|
+
}
|
|
18102
|
+
}
|
|
18103
|
+
async function runHeldJob(ticket, fail) {
|
|
17851
18104
|
if (ticket.kind === "scopes") return runScopesJob(ticket, fail);
|
|
17852
18105
|
if (ticket.kind === "track") return runTrackJob(ticket, fail);
|
|
17853
|
-
if (ticket.kind === "transcribe") return runTranscribeJob(ticket, fail);
|
|
17854
18106
|
if (!state.ffmpeg) {
|
|
17855
18107
|
const j = await fetch("/api/export/ffmpeg").then((r) => r.json()).catch(() => ({}));
|
|
17856
18108
|
state.ffmpeg = !!j.available;
|
|
@@ -17873,7 +18125,7 @@ async function runExportJob(ticket) {
|
|
|
17873
18125
|
const specs = ticket.deliveries.map((d) => normalizeDelivery(d).spec);
|
|
17874
18126
|
const groups = new Map();
|
|
17875
18127
|
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 })) });
|
|
18128
|
+
if (groups.size === 1) { const res = await fastExport({ job: ticket.id, deliveries: specs.map((delivery) => ({ delivery })) }); if (res?.busy) return fail(res.error); }
|
|
17877
18129
|
else {
|
|
17878
18130
|
const all = [];
|
|
17879
18131
|
let i = 0;
|
|
@@ -17881,6 +18133,7 @@ async function runExportJob(ticket) {
|
|
|
17881
18133
|
const res = await fastExport({ deliveries: group.map((delivery) => ({ delivery })), silent: true,
|
|
17882
18134
|
onProgress: (f) => reportExportJob(ticket.id, { progress: (i + f) / groups.size }) });
|
|
17883
18135
|
i++;
|
|
18136
|
+
if (res?.busy) return fail(res.error);
|
|
17884
18137
|
if (res && res.cancelled) return reportExportJob(ticket.id, { status: "failed", error: "cancelled" }, true);
|
|
17885
18138
|
if (res && res.outputs) all.push(...res.outputs);
|
|
17886
18139
|
else all.push(...group.map((sp) => ({ file: deliveryFileName(sp), ok: false, error: (res && res.error) || "export failed" })));
|
|
@@ -17889,7 +18142,11 @@ async function runExportJob(ticket) {
|
|
|
17889
18142
|
if (!ok) return fail(all.map((o) => o.error).join(" · "));
|
|
17890
18143
|
await reportExportJob(ticket.id, { status: "done", src: ok.src, result: { outputs: all } }, true);
|
|
17891
18144
|
}
|
|
17892
|
-
} else
|
|
18145
|
+
} else {
|
|
18146
|
+
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 });
|
|
18147
|
+
// another export took the tab while this job was getting ready: say so rather than leave it running
|
|
18148
|
+
if (res?.busy) return fail(res.error);
|
|
18149
|
+
}
|
|
17893
18150
|
} finally {
|
|
17894
18151
|
exportRangeForced = null;
|
|
17895
18152
|
}
|
|
@@ -17970,7 +18227,10 @@ async function runTrackJob(ticket, fail) {
|
|
|
17970
18227
|
if (state.connected) {
|
|
17971
18228
|
clearTimeout(runtime.saveTimer); runtime.saveTimer = null;
|
|
17972
18229
|
project.revision++;
|
|
17973
|
-
|
|
18230
|
+
// the project this job tracked in: a project opened elsewhere meanwhile refuses the save (409)
|
|
18231
|
+
const headers = { "Content-Type": "application/json" };
|
|
18232
|
+
if (runtime.projectId) headers["X-FableCut-Project"] = runtime.projectId;
|
|
18233
|
+
const res = await fetch("/api/project", { method: "PUT", headers, body: JSON.stringify(projectJSON(), null, 2) });
|
|
17974
18234
|
if (!res.ok) {
|
|
17975
18235
|
project.revision--;
|
|
17976
18236
|
// put back only the clips this job changed (edits elsewhere since stay), and drop its undo step
|
|
@@ -18166,15 +18426,18 @@ function waitEncodeQueue(encoder, max = 2, { signal, getError } = {}) {
|
|
|
18166
18426
|
tick();
|
|
18167
18427
|
});
|
|
18168
18428
|
}
|
|
18169
|
-
async function webCodecsExport() {
|
|
18429
|
+
async function webCodecsExport(name) {
|
|
18430
|
+
if (exportBusy()) return;
|
|
18431
|
+
exportStarting = true;
|
|
18432
|
+
try { await detectWebCodecs(); } finally { exportStarting = false; }
|
|
18170
18433
|
if (state.exporting) return;
|
|
18171
|
-
|
|
18172
|
-
if (!state.webCodecs) { startExport(); return; }
|
|
18434
|
+
// no encoder: the recorder takes over at once, so nothing slips in between
|
|
18435
|
+
if (!state.webCodecs) { startExport(name); return; }
|
|
18173
18436
|
pause();
|
|
18174
18437
|
state.exporting = true; state.rendering = true; renderCancelled = false;
|
|
18175
18438
|
exportAbort = new AbortController();
|
|
18176
18439
|
const signal = exportAbort.signal;
|
|
18177
|
-
|
|
18440
|
+
showExportOverlay();
|
|
18178
18441
|
els.exportProgress.style.width = "0%";
|
|
18179
18442
|
els.exportNote.textContent = "Encoding with WebCodecs → ffmpeg mux. You can switch tabs; export continues.";
|
|
18180
18443
|
restoreExportVideoState();
|
|
@@ -18195,7 +18458,7 @@ async function webCodecsExport() {
|
|
|
18195
18458
|
method: "POST",
|
|
18196
18459
|
body: JSON.stringify({
|
|
18197
18460
|
fps,
|
|
18198
|
-
name: project.name.replace(/[^\w\- ]+/g, "") || "export",
|
|
18461
|
+
name: name || project.name.replace(/[^\w\- ]+/g, "") || "export",
|
|
18199
18462
|
mode: "annexb",
|
|
18200
18463
|
hasAudio: !!wav,
|
|
18201
18464
|
}),
|
|
@@ -18316,24 +18579,38 @@ function pickMime() {
|
|
|
18316
18579
|
];
|
|
18317
18580
|
return cands.find((m) => window.MediaRecorder && MediaRecorder.isTypeSupported(m)) || "";
|
|
18318
18581
|
}
|
|
18319
|
-
async function startExport() {
|
|
18320
|
-
if (
|
|
18582
|
+
async function startExport(name) {
|
|
18583
|
+
if (exportBusy()) return;
|
|
18321
18584
|
if (!project.clips.length) { alert("Timeline is empty — add some clips first."); return; }
|
|
18322
18585
|
const mime = pickMime();
|
|
18323
18586
|
if (!mime) { alert("MediaRecorder is not supported in this browser."); return; }
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18587
|
+
exportStarting = true;
|
|
18588
|
+
let stream = null;
|
|
18589
|
+
try {
|
|
18590
|
+
ensureAudio();
|
|
18591
|
+
await runtime.audio.ctx.resume();
|
|
18592
|
+
pause();
|
|
18593
|
+
const { start } = beginExportWindow();
|
|
18594
|
+
state.time = start;
|
|
18595
|
+
await useOriginalPlayers(); // proxies are for editing — export reads the originals
|
|
18596
|
+
seekMediaWhilePaused();
|
|
18597
|
+
await new Promise((r) => setTimeout(r, 350)); // let first frames decode
|
|
18598
|
+
await loadProjectFonts();
|
|
18599
|
+
stream = els.preview.captureStream(projectFps());
|
|
18600
|
+
for (const tr of runtime.audio.recDest.stream.getAudioTracks()) stream.addTrack(tr);
|
|
18601
|
+
recorder = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 10_000_000 });
|
|
18602
|
+
} catch (e) {
|
|
18603
|
+
exportStarting = false;
|
|
18604
|
+
// the canvas track was made for this attempt; the audio track is shared, so it stays
|
|
18605
|
+
for (const tr of stream?.getVideoTracks() || []) tr.stop();
|
|
18606
|
+
recorder = null;
|
|
18607
|
+
releaseOriginalPlayers();
|
|
18608
|
+
endExportWindow();
|
|
18609
|
+
toast("Export couldn't start: " + (e.message || e));
|
|
18610
|
+
return;
|
|
18611
|
+
}
|
|
18612
|
+
exportStarting = false;
|
|
18335
18613
|
recChunks = []; recDiscard = false;
|
|
18336
|
-
recorder = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 10_000_000 });
|
|
18337
18614
|
recorder.ondataavailable = (e) => { if (e.data.size) recChunks.push(e.data); };
|
|
18338
18615
|
recorder.onstop = () => {
|
|
18339
18616
|
els.exportOverlay.classList.add("hidden");
|
|
@@ -18342,14 +18619,23 @@ async function startExport() {
|
|
|
18342
18619
|
const blob = new Blob(recChunks, { type: mime.split(";")[0] });
|
|
18343
18620
|
const a = document.createElement("a");
|
|
18344
18621
|
a.href = URL.createObjectURL(blob);
|
|
18345
|
-
a.download = (project.name.replace(/[^\w\- ]+/g, "") || "export") + "." + ext;
|
|
18622
|
+
a.download = (name || project.name.replace(/[^\w\- ]+/g, "") || "export") + "." + ext;
|
|
18346
18623
|
a.click();
|
|
18347
18624
|
setTimeout(() => URL.revokeObjectURL(a.href), 30_000);
|
|
18348
18625
|
};
|
|
18349
|
-
|
|
18626
|
+
showExportOverlay();
|
|
18350
18627
|
els.exportProgress.style.width = "0%";
|
|
18351
18628
|
state.exporting = true;
|
|
18352
|
-
recorder.start(250);
|
|
18629
|
+
try { recorder.start(250); }
|
|
18630
|
+
catch (e) {
|
|
18631
|
+
state.exporting = false;
|
|
18632
|
+
for (const tr of stream.getVideoTracks()) tr.stop();
|
|
18633
|
+
els.exportOverlay.classList.add("hidden");
|
|
18634
|
+
releaseOriginalPlayers();
|
|
18635
|
+
endExportWindow();
|
|
18636
|
+
toast("Export couldn't start: " + (e.message || e));
|
|
18637
|
+
return;
|
|
18638
|
+
}
|
|
18353
18639
|
pauseSource();
|
|
18354
18640
|
setMonitorMode("program");
|
|
18355
18641
|
state.playing = true;
|
|
@@ -18401,6 +18687,12 @@ $("btnRippleDelete").addEventListener("click", () => {
|
|
|
18401
18687
|
});
|
|
18402
18688
|
$("btnExport").addEventListener("click", openExportSetup);
|
|
18403
18689
|
$("btnStartExport").addEventListener("click", startChosenExport);
|
|
18690
|
+
$("exportName")?.addEventListener("input", () => { exportNameTyped = true; syncExportName(); });
|
|
18691
|
+
$("exportName")?.addEventListener("keydown", (e) => {
|
|
18692
|
+
if (e.key === "Enter" && !e.isComposing && !$("btnStartExport").disabled) { e.preventDefault(); startChosenExport(); }
|
|
18693
|
+
});
|
|
18694
|
+
els.engineFast?.addEventListener("change", syncExportName);
|
|
18695
|
+
els.engineRealtime?.addEventListener("change", syncExportName);
|
|
18404
18696
|
els.exportSetup?.addEventListener("change", (e) => {
|
|
18405
18697
|
if (e.target.name === "engine") {
|
|
18406
18698
|
syncExportProfileVisibility();
|
|
@@ -18413,6 +18705,7 @@ els.exportProfileSel?.addEventListener("change", () => {
|
|
|
18413
18705
|
if (c.kind === "profile" && !project.encodeProfile)
|
|
18414
18706
|
setSetting("encodeProfile", c.id === encodeProfiles.default ? null : c.id);
|
|
18415
18707
|
syncExportChoiceUi("preset");
|
|
18708
|
+
syncExportName();
|
|
18416
18709
|
});
|
|
18417
18710
|
$("dlvBody")?.addEventListener("change", onDeliveryControl);
|
|
18418
18711
|
$("dlvBody")?.addEventListener("input", onDeliveryControl);
|
|
@@ -18544,7 +18837,9 @@ $("btnHelp").addEventListener("click", () => {
|
|
|
18544
18837
|
});
|
|
18545
18838
|
$("btnCloseHelp").addEventListener("click", () => $("helpOverlay").classList.add("hidden"));
|
|
18546
18839
|
/** Keyboard shortcuts filter: keeps the rows (and whole sections, by heading) that match every typed word. */
|
|
18547
|
-
|
|
18840
|
+
/** `only` (a row of the list) shows just that one: what Search opened. */
|
|
18841
|
+
function filterHelp(only) {
|
|
18842
|
+
const row = only instanceof HTMLElement ? only : null;
|
|
18548
18843
|
const words = $("helpFilter").value.toLowerCase().split(/\s+/).filter(Boolean);
|
|
18549
18844
|
let any = false;
|
|
18550
18845
|
for (const sec of $("helpKeys").querySelectorAll(".keys-sec")) {
|
|
@@ -18552,7 +18847,7 @@ function filterHelp() {
|
|
|
18552
18847
|
let shown = 0;
|
|
18553
18848
|
for (const tr of sec.querySelectorAll("tr")) {
|
|
18554
18849
|
const text = head + " " + tr.textContent.toLowerCase();
|
|
18555
|
-
const hit = words.every((w) => text.includes(w));
|
|
18850
|
+
const hit = row ? tr === row : words.every((w) => text.includes(w));
|
|
18556
18851
|
tr.classList.toggle("hidden", !hit);
|
|
18557
18852
|
if (hit) shown++;
|
|
18558
18853
|
}
|
|
@@ -18569,6 +18864,226 @@ $("helpFilter").addEventListener("keydown", (e) => {
|
|
|
18569
18864
|
if ($("helpFilter").value) { $("helpFilter").value = ""; filterHelp(); }
|
|
18570
18865
|
else $("helpOverlay").classList.add("hidden");
|
|
18571
18866
|
});
|
|
18867
|
+
/* ── Command search (Ctrl/Cmd+K) ──
|
|
18868
|
+
One box that finds what the editor can do: toolbar actions, panels and
|
|
18869
|
+
tabs, Settings, the selected clip's Inspector sections, media in the bin,
|
|
18870
|
+
clips on the timeline and the keyboard shortcuts. The items are read from
|
|
18871
|
+
the page each time it opens, so a new button or setting turns up without a
|
|
18872
|
+
list to keep; command-search.js ranks them. */
|
|
18873
|
+
const cmdk = { items: [], shown: [], active: 0, back: null };
|
|
18874
|
+
/** A control's name: its aria-label, else the start of its title, else its text. */
|
|
18875
|
+
function cmdkName(el) {
|
|
18876
|
+
const text = (el.textContent || "").replace(/\s+/g, " ").trim();
|
|
18877
|
+
const title = (el.getAttribute("aria-label") || el.title || "").replace(/\s+/g, " ").trim();
|
|
18878
|
+
const short = title.split(/ — |: |\. | \(/)[0];
|
|
18879
|
+
// icons and single symbols (▶ ⊡ ?) say little; a title does
|
|
18880
|
+
return /[a-z]{3}/i.test(text) && text.length <= 32 ? text.replace(/^[^\w(]+/, "") : short || text;
|
|
18881
|
+
}
|
|
18882
|
+
const cmdkShown = (el) => !el.disabled && !el.closest(".hidden") && el.getClientRects().length > 0;
|
|
18883
|
+
function cmdkFlash(el) {
|
|
18884
|
+
if (!el) return;
|
|
18885
|
+
el.scrollIntoView({ block: "nearest" });
|
|
18886
|
+
el.classList.remove("cmdk-flash");
|
|
18887
|
+
void el.offsetWidth;
|
|
18888
|
+
el.classList.add("cmdk-flash");
|
|
18889
|
+
}
|
|
18890
|
+
function cmdkCollect() {
|
|
18891
|
+
const items = [], seen = new Set();
|
|
18892
|
+
const add = (it) => {
|
|
18893
|
+
const key = it.key || it.group + "|" + it.label; // media and clips by id: two of one name both show
|
|
18894
|
+
if (!it.label || seen.has(key)) return;
|
|
18895
|
+
seen.add(key);
|
|
18896
|
+
items.push(it);
|
|
18897
|
+
};
|
|
18898
|
+
// panels and tabs
|
|
18899
|
+
// (the Color workspace and the Color side tab share a name: where each lives tells them apart)
|
|
18900
|
+
const panelWhere = { sideTabs: "Side panel", binTabs: "Bin", wsSwitch: "Workspace" };
|
|
18901
|
+
for (const b of document.querySelectorAll("#sideTabs [data-side], #binTabs [data-tab], #wsSwitch [data-ws]")) {
|
|
18902
|
+
const where = panelWhere[b.parentElement.id] || "", title = (b.title || "").split(/ — |: /)[0] === cmdkName(b) ? "" : b.title;
|
|
18903
|
+
add({ key: "Panel|" + b.parentElement.id + "|" + cmdkName(b), label: cmdkName(b), group: "Panel", hint: [where, title].filter(Boolean).join(" · "),
|
|
18904
|
+
keywords: ["tab", "show", "open", where], run: () => { if (b.closest("#binTabs")) cmdkShowBin(); b.click(); } });
|
|
18905
|
+
}
|
|
18906
|
+
// toolbar actions: every named button outside dialogs, menus and the Inspector (and the timeline's edit tools)
|
|
18907
|
+
const actions = [];
|
|
18908
|
+
for (const b of document.querySelectorAll("button[id], button[data-edit-tool]")) {
|
|
18909
|
+
if (b.closest(".overlay, .ctx-menu, .style-menu, #inspector, #sideTabs, #binTabs, #wsSwitch") || b.id === "btnSearch") continue;
|
|
18910
|
+
if (!cmdkShown(b)) continue;
|
|
18911
|
+
actions.push(b);
|
|
18912
|
+
}
|
|
18913
|
+
// two buttons of one name (the monitor's Fit and the timeline's) go by their titles instead
|
|
18914
|
+
const named = new Map();
|
|
18915
|
+
for (const b of actions) named.set(cmdkName(b), (named.get(cmdkName(b)) || 0) + 1);
|
|
18916
|
+
for (const b of actions) {
|
|
18917
|
+
const title = (b.title || "").replace(/\s+/g, " ").trim(), short = title.split(/ — |: |\. | \(/)[0];
|
|
18918
|
+
const label = named.get(cmdkName(b)) > 1 && short ? short : cmdkName(b);
|
|
18919
|
+
add({ key: "a:" + (b.id || "tool-" + b.dataset.editTool), label, group: "Action", hint: title && title !== label ? title : "", run: () => b.click() });
|
|
18920
|
+
}
|
|
18921
|
+
// the selected clip's Inspector sections
|
|
18922
|
+
for (const h of document.querySelectorAll("#inspector .insp-section > h3")) {
|
|
18923
|
+
const name = h.textContent.replace(/\s+/g, " ").trim();
|
|
18924
|
+
add({ label: name, group: "Inspector", keywords: ["inspector", "section", "clip"], run: () => {
|
|
18925
|
+
setSideTab("inspector");
|
|
18926
|
+
// the tab rebuilds the Inspector: find the section in the new one
|
|
18927
|
+
const live = [...document.querySelectorAll("#inspector .insp-section > h3")].find((x) => x.textContent.replace(/\s+/g, " ").trim() === name);
|
|
18928
|
+
if (live) cmdkFlash(live.closest(".insp-section"));
|
|
18929
|
+
} });
|
|
18930
|
+
}
|
|
18931
|
+
// Settings
|
|
18932
|
+
for (const row of document.querySelectorAll("#settingsDialog .settings-row")) {
|
|
18933
|
+
const name = row.querySelector(".settings-label")?.textContent.trim();
|
|
18934
|
+
const hint = row.querySelector(".settings-hint")?.textContent.trim() || "";
|
|
18935
|
+
add({ label: name, group: "Setting", hint, keywords: ["settings", "preference", "option"], run: () => { openSettings(); const inp = row.querySelector("input, select"); inp?.focus(); cmdkFlash(row); } });
|
|
18936
|
+
}
|
|
18937
|
+
// media in the bin, clips on the timeline
|
|
18938
|
+
for (const m of project.media || []) {
|
|
18939
|
+
// the bin folder it sits in tells two files of one name apart
|
|
18940
|
+
const folders = [];
|
|
18941
|
+
for (let f = m.folderId && getFolder(m.folderId), n = 0; f && n < 16; f = f.parentId && getFolder(f.parentId), n++) folders.unshift(f.name);
|
|
18942
|
+
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 }); } });
|
|
18943
|
+
}
|
|
18944
|
+
for (const c of project.clips || []) {
|
|
18945
|
+
const name = c.kind === "text" ? (c.props?.text || "Title").split("\n")[0].slice(0, 60) : c.name || getMedia(c.mediaId)?.name || c.kind;
|
|
18946
|
+
add({ key: "c:" + c.id, label: name, group: "Clip", hint: `${c.track} · ${fmt(c.start)}`, keywords: [c.kind, c.track], run: () => {
|
|
18947
|
+
// where the clip is now (an edit may have arrived while Search was open)
|
|
18948
|
+
const cur = project.clips.find((x) => x.id === c.id);
|
|
18949
|
+
if (!cur) { toast("That clip isn't on the timeline any more"); return; }
|
|
18950
|
+
if (isSourceMode()) setMonitorMode("program");
|
|
18951
|
+
selectClip(cur.id);
|
|
18952
|
+
setTime(cur.start);
|
|
18953
|
+
revealTime(cur.start);
|
|
18954
|
+
} });
|
|
18955
|
+
}
|
|
18956
|
+
// keyboard shortcuts: Enter opens the list, filtered to that one
|
|
18957
|
+
for (const tr of document.querySelectorAll("#helpKeys tr")) {
|
|
18958
|
+
const cells = tr.querySelectorAll("td");
|
|
18959
|
+
if (cells.length < 2) continue;
|
|
18960
|
+
const keys = cells[0].textContent.replace(/\s+/g, " ").trim(), what = cells[1].textContent.replace(/\s+/g, " ").trim();
|
|
18961
|
+
const label = what.split(/ — |; |\. /)[0].slice(0, 70);
|
|
18962
|
+
const section = tr.closest(".keys-sec")?.querySelector("h3")?.textContent || "";
|
|
18963
|
+
add({ label, group: "Shortcut", hint: keys, keys: [keys], keywords: [section, keys, what], run: () => {
|
|
18964
|
+
$("helpOverlay").classList.remove("hidden");
|
|
18965
|
+
// the row itself, not every row its first words also start
|
|
18966
|
+
$("helpFilter").value = label;
|
|
18967
|
+
filterHelp(tr);
|
|
18968
|
+
$("helpFilter").focus();
|
|
18969
|
+
} });
|
|
18970
|
+
}
|
|
18971
|
+
return items;
|
|
18972
|
+
}
|
|
18973
|
+
function cmdkRender() {
|
|
18974
|
+
const list = $("cmdkList");
|
|
18975
|
+
cmdk.shown = FableCutSearch.rank($("cmdkInput").value, cmdk.items, 60);
|
|
18976
|
+
cmdk.active = Math.min(cmdk.active, Math.max(0, cmdk.shown.length - 1));
|
|
18977
|
+
list.innerHTML = cmdk.shown.length
|
|
18978
|
+
? 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}">` +
|
|
18979
|
+
`<span class="cmdk-label">${escapeHtml(it.label)}</span>${it.hint ? `<span class="cmdk-hint">${escapeHtml(it.hint)}</span>` : ""}` +
|
|
18980
|
+
`<span class="cmdk-group">${it.group}</span></li>`).join("")
|
|
18981
|
+
: `<li class="cmdk-empty">Nothing matches — try another word.</li>`;
|
|
18982
|
+
$("cmdkInput").setAttribute("aria-activedescendant", cmdk.shown.length ? "cmdk-" + cmdk.active : "");
|
|
18983
|
+
list.querySelector(".cmdk-item.active")?.scrollIntoView({ block: "nearest" });
|
|
18984
|
+
}
|
|
18985
|
+
function openCmdk() {
|
|
18986
|
+
if (state.exporting) return;
|
|
18987
|
+
cmdk.pid = runtime.projectId; // results belong to this project
|
|
18988
|
+
cmdk.back = document.activeElement;
|
|
18989
|
+
cmdk.items = cmdkCollect();
|
|
18990
|
+
cmdk.active = 0;
|
|
18991
|
+
$("cmdkInput").value = "";
|
|
18992
|
+
$("cmdkOverlay").classList.remove("hidden");
|
|
18993
|
+
cmdkRender();
|
|
18994
|
+
$("cmdkInput").focus();
|
|
18995
|
+
}
|
|
18996
|
+
/** Another dialog is open over the editor (Export setup finishing its load, …). */
|
|
18997
|
+
const cmdkOtherOverlay = () => [...document.querySelectorAll(".overlay")].some((o) => o.id !== "cmdkOverlay" && !o.classList.contains("hidden"));
|
|
18998
|
+
/** The Color workspace hides the bin: a result that shows the bin goes back to Edit first. */
|
|
18999
|
+
function cmdkShowBin() {
|
|
19000
|
+
if (colorState.ws === "color") setWorkspace("edit");
|
|
19001
|
+
}
|
|
19002
|
+
function closeCmdk(refocus = true) {
|
|
19003
|
+
$("cmdkOverlay").classList.add("hidden");
|
|
19004
|
+
if (refocus && cmdk.back && document.contains(cmdk.back)) cmdk.back.focus();
|
|
19005
|
+
cmdk.back = null;
|
|
19006
|
+
}
|
|
19007
|
+
function runCmdk(i) {
|
|
19008
|
+
const it = cmdk.shown[i];
|
|
19009
|
+
if (!it) return;
|
|
19010
|
+
const back = cmdk.back, pid = cmdk.pid;
|
|
19011
|
+
closeCmdk(false);
|
|
19012
|
+
if (pid !== runtime.projectId) { toast("Another project opened — search again"); return; }
|
|
19013
|
+
// after the box has gone, so the action sees the editor as it was
|
|
19014
|
+
setTimeout(() => {
|
|
19015
|
+
// an export (an agent's too) may have taken the timeline meanwhile
|
|
19016
|
+
if (state.exporting) { toast("Wait for the export to finish"); return; }
|
|
19017
|
+
if (pid !== runtime.projectId) { toast("Another project opened — search again"); return; }
|
|
19018
|
+
if (cmdkOtherOverlay()) return; // a dialog that opened meanwhile keeps the screen
|
|
19019
|
+
try { it.run(); } catch (e) { toast(String(e.message || e)); }
|
|
19020
|
+
// an action that puts focus nowhere hands it back to where it was before Search
|
|
19021
|
+
const a = document.activeElement;
|
|
19022
|
+
if ((!a || a === document.body || a === $("cmdkInput")) && back && document.contains(back)) back.focus();
|
|
19023
|
+
}, 0);
|
|
19024
|
+
}
|
|
19025
|
+
const cmdkOpen = () => !$("cmdkOverlay").classList.contains("hidden");
|
|
19026
|
+
$("btnSearch")?.addEventListener("click", openCmdk);
|
|
19027
|
+
$("cmdkInput").addEventListener("input", () => { cmdk.active = 0; cmdkRender(); });
|
|
19028
|
+
$("cmdkInput").addEventListener("keydown", (e) => {
|
|
19029
|
+
if (e.isComposing || e.keyCode === 229) return; // the IME is choosing a word
|
|
19030
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
19031
|
+
e.preventDefault();
|
|
19032
|
+
const n = cmdk.shown.length;
|
|
19033
|
+
if (n) cmdk.active = (cmdk.active + (e.key === "ArrowDown" ? 1 : n - 1)) % n;
|
|
19034
|
+
cmdkRender();
|
|
19035
|
+
} else if (e.key === "Enter") {
|
|
19036
|
+
e.preventDefault();
|
|
19037
|
+
runCmdk(cmdk.active);
|
|
19038
|
+
} else if (e.key === "Escape") {
|
|
19039
|
+
e.preventDefault();
|
|
19040
|
+
e.stopPropagation();
|
|
19041
|
+
if ($("cmdkInput").value) { $("cmdkInput").value = ""; cmdk.active = 0; cmdkRender(); }
|
|
19042
|
+
else closeCmdk();
|
|
19043
|
+
} else if (e.key === "Tab") e.preventDefault(); // the box is the dialog's only control
|
|
19044
|
+
});
|
|
19045
|
+
$("cmdkList").addEventListener("mousemove", (e) => {
|
|
19046
|
+
const li = e.target.closest(".cmdk-item");
|
|
19047
|
+
if (!li || +li.dataset.i === cmdk.active) return;
|
|
19048
|
+
cmdk.active = +li.dataset.i;
|
|
19049
|
+
cmdkRender();
|
|
19050
|
+
});
|
|
19051
|
+
$("cmdkList").addEventListener("click", (e) => {
|
|
19052
|
+
const li = e.target.closest(".cmdk-item");
|
|
19053
|
+
if (li) runCmdk(+li.dataset.i);
|
|
19054
|
+
});
|
|
19055
|
+
$("cmdkOverlay").addEventListener("mousedown", (e) => {
|
|
19056
|
+
if (e.target === $("cmdkOverlay")) closeCmdk();
|
|
19057
|
+
else if (e.target !== $("cmdkInput")) e.preventDefault(); // a click on the list or footer keeps the focus in the box
|
|
19058
|
+
});
|
|
19059
|
+
/* Ctrl/Cmd+K, before any field's own key handling (the bin's search stops its keys): one
|
|
19060
|
+
toggle per press. While Search is open, the editor's other shortcuts wait; the box keeps
|
|
19061
|
+
its own keys. */
|
|
19062
|
+
window.addEventListener("keydown", (e) => {
|
|
19063
|
+
const k = e.key;
|
|
19064
|
+
// e.code: the K key on any layout (a Cyrillic one reports "л")
|
|
19065
|
+
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (k === "k" || k === "K" || e.code === "KeyK")) {
|
|
19066
|
+
e.preventDefault();
|
|
19067
|
+
e.stopImmediatePropagation();
|
|
19068
|
+
if (e.repeat) return;
|
|
19069
|
+
// (focus stays with a dialog that opened over Search)
|
|
19070
|
+
if (cmdkOpen()) closeCmdk(!cmdkOtherOverlay());
|
|
19071
|
+
// another dialog keeps the keyboard until it closes
|
|
19072
|
+
else if (!cmdkOtherOverlay()) openCmdk();
|
|
19073
|
+
return;
|
|
19074
|
+
}
|
|
19075
|
+
if (!cmdkOpen()) return;
|
|
19076
|
+
// a dialog that opened meanwhile (Export setup finishing its load) takes the keyboard over
|
|
19077
|
+
if (cmdkOtherOverlay()) { closeCmdk(false); return; }
|
|
19078
|
+
if (e.target !== $("cmdkInput")) { e.stopImmediatePropagation(); return; }
|
|
19079
|
+
// Esc is Search's (before any picker or tool listening for it): clear the box, then close
|
|
19080
|
+
if (k === "Escape" && !e.isComposing) {
|
|
19081
|
+
e.preventDefault();
|
|
19082
|
+
e.stopImmediatePropagation();
|
|
19083
|
+
if ($("cmdkInput").value) { $("cmdkInput").value = ""; cmdk.active = 0; cmdkRender(); }
|
|
19084
|
+
else closeCmdk();
|
|
19085
|
+
}
|
|
19086
|
+
}, true);
|
|
18572
19087
|
function settingsFocusables() {
|
|
18573
19088
|
const root = $("settingsDialog");
|
|
18574
19089
|
if (!root) return [];
|
|
@@ -18591,6 +19106,8 @@ function onSettingsTabTrap(e) {
|
|
|
18591
19106
|
function openSettings() {
|
|
18592
19107
|
const cb = $("setLinkSelect");
|
|
18593
19108
|
if (cb) cb.checked = !!getSetting("linkSelect");
|
|
19109
|
+
const ask = $("setExportAsk");
|
|
19110
|
+
if (ask) ask.checked = getSetting("exportAsk") !== false;
|
|
18594
19111
|
const overlay = $("settingsOverlay");
|
|
18595
19112
|
overlay.classList.remove("hidden");
|
|
18596
19113
|
overlay.addEventListener("keydown", onSettingsTabTrap);
|
|
@@ -18608,6 +19125,7 @@ $("btnCloseSettings").addEventListener("click", closeSettings);
|
|
|
18608
19125
|
$("settingsOverlay").addEventListener("click", (e) => {
|
|
18609
19126
|
if (e.target === $("settingsOverlay")) closeSettings();
|
|
18610
19127
|
});
|
|
19128
|
+
$("setExportAsk")?.addEventListener("change", (e) => setSetting("exportAsk", !!e.target.checked));
|
|
18611
19129
|
$("setLinkSelect").addEventListener("change", (e) => {
|
|
18612
19130
|
setSetting("linkSelect", !!e.target.checked);
|
|
18613
19131
|
if (!getSetting("linkSelect")) {
|
|
@@ -19095,6 +19613,7 @@ els.exportFrameOverlay?.querySelector(".ef-handle")?.addEventListener("keydown",
|
|
|
19095
19613
|
|
|
19096
19614
|
window.addEventListener("keydown", (e) => {
|
|
19097
19615
|
const k = e.key;
|
|
19616
|
+
if (!$("cmdkOverlay").classList.contains("hidden")) return; // Search has the keyboard (its box handles its own keys)
|
|
19098
19617
|
if ((k === "Delete" || k === "Backspace") && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
19099
19618
|
if (!isTypingTarget(document.activeElement) && clearFocusedTransition()) {
|
|
19100
19619
|
e.preventDefault();
|
|
@@ -19107,6 +19626,7 @@ window.addEventListener("keydown", (e) => {
|
|
|
19107
19626
|
if (!e.repeat && $("btnProjectsDash") && !$("btnProjectsDash").classList.contains("hidden")) saveVersionNow(); // holding the keys makes one
|
|
19108
19627
|
return;
|
|
19109
19628
|
}
|
|
19629
|
+
// (Ctrl/Cmd+K, the command search, is handled before this, by its own listener)
|
|
19110
19630
|
// Ctrl/Cmd+O: the Projects dashboard (where the editor server has projects)
|
|
19111
19631
|
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (k === "o" || k === "O") && $("btnProjectsDash") && !$("btnProjectsDash").classList.contains("hidden")) {
|
|
19112
19632
|
e.preventDefault();
|
|
@@ -19118,8 +19638,26 @@ window.addEventListener("keydown", (e) => {
|
|
|
19118
19638
|
closeImportUrl();
|
|
19119
19639
|
return;
|
|
19120
19640
|
}
|
|
19641
|
+
// Space on a button / select / slider still focused from a mouse click plays
|
|
19642
|
+
// instead of pressing that control again (focus.js)
|
|
19643
|
+
if (k === " " && !e.ctrlKey && !e.metaKey && !e.altKey && typeof FableCutFocus !== "undefined") {
|
|
19644
|
+
const el = document.activeElement;
|
|
19645
|
+
if (FableCutFocus.spaceShouldPlay(el)) {
|
|
19646
|
+
e.preventDefault();
|
|
19647
|
+
FableCutFocus.release(el);
|
|
19648
|
+
if (!e.repeat) toggleTransportPlay();
|
|
19649
|
+
return;
|
|
19650
|
+
}
|
|
19651
|
+
// mid-drag, playing would move the slider's value under the pointer
|
|
19652
|
+
if (FableCutFocus.isDragging(el)) { e.preventDefault(); return; }
|
|
19653
|
+
// reached with Tab, or in a dialog / popover: Space presses the control as usual.
|
|
19654
|
+
// A slider has nothing for Space to press, so outside dialogs it still plays.
|
|
19655
|
+
const slider = el && el.tagName === "INPUT" && el.type === "range";
|
|
19656
|
+
if (FableCutFocus.isClickControl(el) && !(slider && !FableCutFocus.inKeyboardScope(el))) return;
|
|
19657
|
+
}
|
|
19121
19658
|
if (isTypingTarget(document.activeElement)) return;
|
|
19122
|
-
|
|
19659
|
+
// holding Space plays or pauses once, not on every key repeat
|
|
19660
|
+
if (k === " ") { e.preventDefault(); if (!e.repeat) toggleTransportPlay(); }
|
|
19123
19661
|
// JKL shuttle — bare keys only, so Cmd/Ctrl+J/K/L stay with the browser.
|
|
19124
19662
|
// K stops; hold K and tap J / L to step a frame, hold both to crawl.
|
|
19125
19663
|
else if ((k === "k" || k === "K") && !e.ctrlKey && !e.metaKey && !e.altKey) {
|