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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* FableCut command search (Ctrl/Cmd+K) — how typed words find editor actions,
|
|
2
|
+
panels, settings, Inspector sections, media, clips and shortcuts. Zero
|
|
3
|
+
dependencies. Loaded by the editor as a plain script (global
|
|
4
|
+
`FableCutSearch`) and required by the tests; the editor builds the items
|
|
5
|
+
(app.js) and runs the one that is picked.
|
|
6
|
+
|
|
7
|
+
rank(query, items, limit?) → items that match, best first
|
|
8
|
+
item: {label, group?, keywords?, ...anything}
|
|
9
|
+
score(query, item) → a number, 0 = no match
|
|
10
|
+
|
|
11
|
+
Every typed word has to be found in the item's label, group or keywords:
|
|
12
|
+
at the start of a word (best), inside a word, or as letters in order
|
|
13
|
+
from the start of a word in the label ("rpdl" finds "Ripple delete",
|
|
14
|
+
weakest). Case, accents and punctuation don't matter; letters of any script
|
|
15
|
+
count ("猫" finds "猫.mp4"). A query of symbols only (";") matches items
|
|
16
|
+
whose `keys` hold it. An empty query matches everything, in the order given. */
|
|
17
|
+
(function (root, factory) {
|
|
18
|
+
const api = factory();
|
|
19
|
+
if (typeof module === "object" && module.exports) module.exports = api;
|
|
20
|
+
else root.FableCutSearch = api;
|
|
21
|
+
})(typeof self !== "undefined" ? self : this, function () {
|
|
22
|
+
"use strict";
|
|
23
|
+
|
|
24
|
+
const fold = (s) => String(s == null ? "" : s).toLowerCase().normalize("NFD")
|
|
25
|
+
// accents on Latin, Greek and Cyrillic letters go (Café = cafe); other scripts' marks are
|
|
26
|
+
// part of the letter (दिन is not दीन), so they stay
|
|
27
|
+
.replace(/(\p{Script=Latin}|\p{Script=Greek}|\p{Script=Cyrillic})\p{M}+/gu, "$1")
|
|
28
|
+
.replace(/[^\p{L}\p{N}\p{M}]+/gu, " ").trim();
|
|
29
|
+
const words = (s) => fold(s).split(" ").filter(Boolean);
|
|
30
|
+
|
|
31
|
+
/** How well one typed word matches a text (folded, its words given): 0 when it doesn't.
|
|
32
|
+
Letters in order count only when asked (the label), starting at one of its words. */
|
|
33
|
+
function wordScore(w, text, parts, loose) {
|
|
34
|
+
if (parts.some((p) => p === w)) return 10;
|
|
35
|
+
if (parts.some((p) => p.startsWith(w))) return 8;
|
|
36
|
+
if (text.includes(w)) return 5;
|
|
37
|
+
if (!loose || w.length < 2) return 0;
|
|
38
|
+
for (let s = 0; s < text.length; s++) {
|
|
39
|
+
if (text[s] !== w[0] || (s && text[s - 1] !== " ")) continue;
|
|
40
|
+
let i = 1;
|
|
41
|
+
for (let k = s + 1; k < text.length && i < w.length; k++) if (text[k] === w[i]) i++;
|
|
42
|
+
if (i === w.length) return 2;
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
/** A query with no letters or digits: the items whose `keys` hold exactly that. */
|
|
47
|
+
const symbolOnly = (query) => !words(query).length && String(query || "").trim() !== "";
|
|
48
|
+
const symbolScore = (query, item) => {
|
|
49
|
+
const q = String(query).trim();
|
|
50
|
+
// "+ / -" holds "+"; "Shift+;" holds ";"
|
|
51
|
+
return (item.keys || []).some((k) => String(k).trim() === q || String(k).split(/[\s/,·]+/).includes(q) || String(k).split(/[\s/,+·]+/).includes(q)) ? 10 : 0;
|
|
52
|
+
};
|
|
53
|
+
function score(query, item) {
|
|
54
|
+
if (symbolOnly(query)) return symbolScore(query, item);
|
|
55
|
+
const q = words(query);
|
|
56
|
+
if (!q.length) return 1;
|
|
57
|
+
const label = fold(item.label), lp = label.split(" ");
|
|
58
|
+
const extra = fold([item.group, ...(item.keywords || [])].join(" ")), ep = extra.split(" ").filter(Boolean);
|
|
59
|
+
let total = 0;
|
|
60
|
+
for (const w of q) {
|
|
61
|
+
const inLabel = wordScore(w, label, lp, true);
|
|
62
|
+
const inExtra = wordScore(w, extra, ep, false) * 0.6; // the label counts for more than group and keywords
|
|
63
|
+
const s = Math.max(inLabel, inExtra);
|
|
64
|
+
if (!s) return 0;
|
|
65
|
+
total += s;
|
|
66
|
+
}
|
|
67
|
+
if (label.startsWith(q.join(" "))) total += 6; // the label begins with what was typed
|
|
68
|
+
return total - Math.min(label.length, 60) / 100; // a shorter label wins a tie
|
|
69
|
+
}
|
|
70
|
+
function rank(query, items, limit = 50) {
|
|
71
|
+
if (!words(query).length && !symbolOnly(query)) return items.slice(0, limit);
|
|
72
|
+
return items.map((it, i) => ({ it, i, s: score(query, it) }))
|
|
73
|
+
.filter((x) => x.s > 0)
|
|
74
|
+
.sort((a, b) => b.s - a.s || a.i - b.i)
|
|
75
|
+
.slice(0, limit)
|
|
76
|
+
.map((x) => x.it);
|
|
77
|
+
}
|
|
78
|
+
return { rank, score, fold };
|
|
79
|
+
});
|
package/delivery.js
CHANGED
|
@@ -502,7 +502,7 @@
|
|
|
502
502
|
return parts.join(",");
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
/** One ffmpeg pass. o: {fps, input:"jpeg"|"rgba", canvasW, canvasH, frame
|
|
505
|
+
/** One ffmpeg pass. o: {fps, input:"jpeg"|"png"|"rgba", canvasW, canvasH, frame
|
|
506
506
|
* (from reframe), wavPath|null, outPath, duration (s, frames ÷ fps),
|
|
507
507
|
* loudnorm (pass-one measurement, when the spec has a loudness target), dry}. `dry` swaps stdin for a
|
|
508
508
|
* 0.1 s synthetic picture of the canvas size, to check the settings
|
|
@@ -510,8 +510,11 @@
|
|
|
510
510
|
function ffmpegArgs(spec, o) {
|
|
511
511
|
const rate = fpsRational(o.fps);
|
|
512
512
|
const args = ["-y", "-hide_banner"];
|
|
513
|
-
const rgba = o.input === "rgba";
|
|
514
|
-
|
|
513
|
+
const rgba = o.input === "rgba", png = o.input === "png";
|
|
514
|
+
// PNG and raw RGBA both arrive as full-range RGB
|
|
515
|
+
const rgb = rgba || png;
|
|
516
|
+
if (o.dry) args.push("-f", "lavfi", "-i", `color=c=black:s=${o.canvasW}x${o.canvasH}:r=${rate}:d=0.1,format=${rgb ? "rgba" : "yuvj420p"}`);
|
|
517
|
+
else if (png) args.push("-thread_queue_size", "64", "-f", "image2pipe", "-framerate", rate, "-c:v", "png", "-i", "-");
|
|
515
518
|
else if (rgba) args.push("-thread_queue_size", "8", "-f", "rawvideo", "-pix_fmt", "rgba", "-s", `${o.canvasW}x${o.canvasH}`, "-framerate", rate, "-i", "-");
|
|
516
519
|
else args.push("-thread_queue_size", "64", "-f", "image2pipe", "-framerate", rate, "-c:v", "mjpeg", "-i", "-");
|
|
517
520
|
const audio = spec.audio.codec !== "none" && (o.dry ? o.hasAudio !== false : !!o.wavPath);
|
|
@@ -521,7 +524,7 @@
|
|
|
521
524
|
}
|
|
522
525
|
args.push("-map", "0:v:0");
|
|
523
526
|
if (audio) args.push("-map", "1:a:0");
|
|
524
|
-
args.push("-vf", videoFilter(spec, o.frame,
|
|
527
|
+
args.push("-vf", videoFilter(spec, o.frame, rgb ? "bt709" : "bt601"));
|
|
525
528
|
args.push(...videoArgs(spec, +o.fps));
|
|
526
529
|
const c = COLORS[spec.color] || COLORS.bt709;
|
|
527
530
|
args.push("-colorspace", c.matrix, "-color_primaries", c.primaries, "-color_trc", c.trc, "-color_range", c.range);
|
|
@@ -646,11 +649,13 @@
|
|
|
646
649
|
return `${m}:${r < 10 ? "0" : ""}${r.toFixed(2)}`;
|
|
647
650
|
}
|
|
648
651
|
|
|
649
|
-
/** How the browser should hand frames over: JPEG is 4:2:0 8-bit, so
|
|
650
|
-
*
|
|
652
|
+
/** How the browser should hand frames over: JPEG is 4:2:0 8-bit, so anything
|
|
653
|
+
* that keeps more chroma or bit depth gets lossless PNG instead. The canvas is
|
|
654
|
+
* 8-bit RGB, so PNG carries exactly its pixels (as raw RGBA did) at about a
|
|
655
|
+
* tenth of the bytes, and every byte uploaded costs the tab memory (#165). */
|
|
651
656
|
function frameInput(spec) {
|
|
652
657
|
const v = spec.video;
|
|
653
|
-
return v.codec === "ffv1" || /422|444|10le/.test(v.pixFmt) ? "
|
|
658
|
+
return v.codec === "ffv1" || /422|444|10le/.test(v.pixFmt) ? "png" : "jpeg";
|
|
654
659
|
}
|
|
655
660
|
function jpegQuality(spec) {
|
|
656
661
|
const v = spec.video;
|
package/export-jobs.js
CHANGED
|
@@ -112,7 +112,7 @@ function createExportJobs(opts) {
|
|
|
112
112
|
* kind "transcribe" turns files' speech into words and saves them (fablecut_transcribe).
|
|
113
113
|
* A scopes job's `image` flag also returns that still as a JPEG data URL,
|
|
114
114
|
* which is how fablecut_frame shows an agent the composed program picture. */
|
|
115
|
-
request({ kind = "export", range, profile, delivery = null, deliveries = null, time, revision, where = "auto", matte = null, mask = null, track = null, transcribe = null, image = false }) {
|
|
115
|
+
request({ kind = "export", range, profile, delivery = null, deliveries = null, name = null, time, revision, project = null, where = "auto", matte = null, mask = null, track = null, transcribe = null, image = false }) {
|
|
116
116
|
if (!["auto", "tab", "headless"].includes(where)) throw Object.assign(new Error("where must be auto, tab or headless"), { code: 400 });
|
|
117
117
|
if (!["export", "scopes", "track", "transcribe"].includes(kind)) throw Object.assign(new Error("kind must be export, scopes, track or transcribe"), { code: 400 });
|
|
118
118
|
if (time != null && !(Number.isFinite(time) && time >= 0)) throw Object.assign(new Error("time must be seconds ≥ 0"), { code: 400 });
|
|
@@ -125,7 +125,9 @@ function createExportJobs(opts) {
|
|
|
125
125
|
const j = {
|
|
126
126
|
id: "x_" + Math.random().toString(36).slice(2, 10), kind, status: "pending", progress: 0,
|
|
127
127
|
range: range || null, profile: profile || null, delivery: kind === "export" && delivery ? delivery : null,
|
|
128
|
+
name: kind === "export" && typeof name === "string" && name.trim() ? name.trim().slice(0, 120) : null,
|
|
128
129
|
deliveries: kind === "export" && Array.isArray(deliveries) && deliveries.length ? deliveries : null, time: time ?? null, revision: Number.isFinite(revision) ? revision : null,
|
|
130
|
+
project: typeof project === "string" && project ? project : null, // the project it was asked for
|
|
129
131
|
matte: kind === "scopes" && matte ? { clip: String(matte.clip), layer: matte.layer } : null,
|
|
130
132
|
mask: kind === "scopes" && mask ? { clip: String(mask.clip) } : null,
|
|
131
133
|
track: kind === "track" && track ? track : null,
|
|
@@ -142,7 +144,7 @@ function createExportJobs(opts) {
|
|
|
142
144
|
},
|
|
143
145
|
get(id) { const j = jobs.get(id); return j ? view(j) : null; },
|
|
144
146
|
/** What a tab needs to run the job (headless pages fetch it by id). */
|
|
145
|
-
ticket(id) { const j = jobs.get(id); return j ? { id: j.id, kind: j.kind, range: j.range, profile: j.profile, delivery: j.delivery || null, deliveries: j.deliveries || null, time: j.time, revision: j.revision, matte: j.matte || null, mask: j.mask || null, track: j.track || null, transcribe: j.transcribe || null, image: !!j.image, status: j.status } : null; },
|
|
147
|
+
ticket(id) { const j = jobs.get(id); return j ? { id: j.id, kind: j.kind, range: j.range, profile: j.profile, delivery: j.delivery || null, deliveries: j.deliveries || null, name: j.name || null, time: j.time, revision: j.revision, project: j.project || null, matte: j.matte || null, mask: j.mask || null, track: j.track || null, transcribe: j.transcribe || null, image: !!j.image, status: j.status } : null; },
|
|
146
148
|
/** First tab to claim a pending job runs it. */
|
|
147
149
|
claim(id) {
|
|
148
150
|
const j = jobs.get(id);
|
package/focus.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* FableCut focus hygiene — keyboard shortcuts keep working after the mouse
|
|
2
|
+
uses a control.
|
|
3
|
+
|
|
4
|
+
A button, checkbox, slider or <select> keeps keyboard focus after it is
|
|
5
|
+
clicked. Space then pressed that control again (re-toggling Snap, say)
|
|
6
|
+
instead of playing the timeline, and ←/→ nudged the last slider instead of
|
|
7
|
+
stepping the playhead. Here:
|
|
8
|
+
|
|
9
|
+
- a control used with the mouse gives focus back to the page once the click
|
|
10
|
+
or drag is over (its own handler runs first; if that moves focus on, into
|
|
11
|
+
a popover's field say, it is left alone);
|
|
12
|
+
- Space on a control that still has focus from the mouse plays the timeline
|
|
13
|
+
(spaceShouldPlay, used by the editor's Space handler).
|
|
14
|
+
|
|
15
|
+
Inside a dialog or a popover nothing changes: Tab / Space / Enter work there
|
|
16
|
+
as usual. A control reached with Tab keeps its focus and Space presses it,
|
|
17
|
+
so the editor stays usable from the keyboard. Text fields are never touched.
|
|
18
|
+
|
|
19
|
+
Loaded by the editor as a plain script (global `FableCutFocus`, installed on
|
|
20
|
+
load) and required by the tests. */
|
|
21
|
+
(function (root, factory) {
|
|
22
|
+
const api = factory();
|
|
23
|
+
if (typeof module === "object" && module.exports) module.exports = api;
|
|
24
|
+
else {
|
|
25
|
+
root.FableCutFocus = api;
|
|
26
|
+
if (typeof document !== "undefined") api.install(root, document);
|
|
27
|
+
}
|
|
28
|
+
})(typeof self !== "undefined" ? self : this, function () {
|
|
29
|
+
"use strict";
|
|
30
|
+
|
|
31
|
+
/* Where keys belong to the UI under focus (dialogs, popovers, menus). */
|
|
32
|
+
const KEYBOARD_SCOPE = ".overlay, .ctx-menu, .style-menu, [role=dialog], [role=menu], [role=listbox]";
|
|
33
|
+
/* <input> types that are clicked or dragged, not typed into. */
|
|
34
|
+
const CLICK_INPUTS = ["range", "checkbox", "radio", "button", "submit", "reset", "color", "file"];
|
|
35
|
+
const CLICK_ROLES = ["button", "tab", "checkbox", "switch"];
|
|
36
|
+
|
|
37
|
+
/** A control that is clicked or dragged, not typed into. */
|
|
38
|
+
function isClickControl(el) {
|
|
39
|
+
if (!el || !el.tagName) return false;
|
|
40
|
+
const tag = el.tagName.toUpperCase();
|
|
41
|
+
if (tag === "BUTTON" || tag === "SUMMARY") return true;
|
|
42
|
+
// a dropdown is clicked; a list box (multiple, or size > 1) is worked from the keyboard (Space selects in it)
|
|
43
|
+
if (tag === "SELECT") return !el.multiple && !(el.size > 1);
|
|
44
|
+
if (tag === "INPUT") return CLICK_INPUTS.includes(String(el.type || "text").toLowerCase());
|
|
45
|
+
if (tag === "A") return !!(el.hasAttribute && el.hasAttribute("href"));
|
|
46
|
+
const role = el.getAttribute && el.getAttribute("role");
|
|
47
|
+
return CLICK_ROLES.includes(role);
|
|
48
|
+
}
|
|
49
|
+
/** Inside a dialog, popover or menu, where keys belong to that UI. */
|
|
50
|
+
function inKeyboardScope(el) {
|
|
51
|
+
return !!(el && el.closest && el.closest(KEYBOARD_SCOPE));
|
|
52
|
+
}
|
|
53
|
+
/* The element that last got focus from the keyboard (Tab) or from code, not a click.
|
|
54
|
+
:focus-visible can't tell: Chrome turns it on for a focused <select> as soon as a key is pressed. */
|
|
55
|
+
let keyFocused = null;
|
|
56
|
+
/* The slider a pointer is dragging right now (set by install). */
|
|
57
|
+
let dragHeld = null;
|
|
58
|
+
/** Record how `el` got focus: true = keyboard / code, false = pointer. */
|
|
59
|
+
function noteFocus(el, byKeyboard) { keyFocused = byKeyboard ? el : null; }
|
|
60
|
+
/** Space with focus on `el` should play the timeline, not press `el`. */
|
|
61
|
+
function spaceShouldPlay(el) {
|
|
62
|
+
// a slider still under the pointer keeps its focus: released mid-drag, playback would move its thumb under the pointer
|
|
63
|
+
return isClickControl(el) && !inKeyboardScope(el) && el !== keyFocused && el !== dragHeld;
|
|
64
|
+
}
|
|
65
|
+
/** Give focus back to the page when `el` is a click control outside a dialog. */
|
|
66
|
+
function release(el) {
|
|
67
|
+
if (!isClickControl(el) || inKeyboardScope(el)) return false;
|
|
68
|
+
el.blur();
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function install(win, doc) {
|
|
73
|
+
if (install.done) return;
|
|
74
|
+
install.done = true;
|
|
75
|
+
let byPointer = false;
|
|
76
|
+
// the slider a pointer is dragging and that pointer's id, until that same pointer
|
|
77
|
+
// lifts or cancels (a key pressed mid-drag, or a second finger, doesn't end it)
|
|
78
|
+
let dragging = null, dragPointer = null;
|
|
79
|
+
// bumped by each new drag, so a release left pending by the last one can't blur it
|
|
80
|
+
let dragGen = 0;
|
|
81
|
+
// The pointerdown a click comes from. byPointer only says what the last input was;
|
|
82
|
+
// a screen reader's virtual-cursor click fires `click` with no pointerdown, so a
|
|
83
|
+
// click counts as a mouse click only when a pointerdown on that same element came
|
|
84
|
+
// just before it.
|
|
85
|
+
let downOn = null, downAt = 0;
|
|
86
|
+
const CLICK_MS = 1500; // a press held longer than this isn't paired (the click is left to the keyboard path)
|
|
87
|
+
win.addEventListener("pointerdown", (e) => {
|
|
88
|
+
// only the primary button: a right-click opens a menu, it doesn't use the control
|
|
89
|
+
if (e.button > 0) return;
|
|
90
|
+
byPointer = true;
|
|
91
|
+
downOn = e.target; downAt = Date.now();
|
|
92
|
+
// clicking a control that already had keyboard focus (no new focusin): it is now a mouse focus
|
|
93
|
+
if (keyFocused && (e.target === keyFocused || (keyFocused.contains && keyFocused.contains(e.target)))) keyFocused = null;
|
|
94
|
+
const t = e.target;
|
|
95
|
+
if (dragging) return; // another pointer is already dragging a slider
|
|
96
|
+
if (t && t.tagName === "INPUT" && t.type === "range") { dragging = dragHeld = t; dragPointer = e.pointerId; dragGen++; }
|
|
97
|
+
}, { capture: true, passive: true });
|
|
98
|
+
// a press the browser cancelled (a touch that became a scroll) clicks nothing
|
|
99
|
+
win.addEventListener("pointercancel", () => { downOn = null; }, { capture: true, passive: true });
|
|
100
|
+
win.addEventListener("keydown", () => { byPointer = false; }, { capture: true, passive: true });
|
|
101
|
+
/** True when `t` is the element a recent mouse press landed on (or its label / control):
|
|
102
|
+
the focus or click on `t` comes from that press. Anything else (Tab, a screen reader's
|
|
103
|
+
virtual cursor, el.focus() / el.click() from code) is not from the mouse. */
|
|
104
|
+
const fromPress = (t) => byPointer && !!downOn && !!t && Date.now() - downAt < CLICK_MS &&
|
|
105
|
+
(downOn === t || (downOn.contains && downOn.contains(t)) || (t.contains && t.contains(downOn)) ||
|
|
106
|
+
(t.control && (t.control === downOn || (t.control.contains && t.control.contains(downOn)))) ||
|
|
107
|
+
(downOn.control && downOn.control === t) || pressedLabelOf(t));
|
|
108
|
+
// a press on the text inside a <label> focuses the label's control
|
|
109
|
+
const pressedLabelOf = (t) => {
|
|
110
|
+
const lab = downOn.closest && downOn.closest("label");
|
|
111
|
+
return !!lab && (lab.control === t || (lab.contains && lab.contains(t)));
|
|
112
|
+
};
|
|
113
|
+
doc.addEventListener("focusin", (e) => noteFocus(e.target, !fromPress(e.target)), true);
|
|
114
|
+
// Bubble phase: the control's own click handler has run by now.
|
|
115
|
+
win.addEventListener("click", (e) => {
|
|
116
|
+
const paired = fromPress(e.target);
|
|
117
|
+
// A click on a label is passed on to its control (focus, then a click of its own)
|
|
118
|
+
// after this listener has run: keep the press for that one.
|
|
119
|
+
const lab = paired && e.target && e.target.closest && e.target.closest("label");
|
|
120
|
+
const passesOn = !!(lab && lab.control && lab.control !== e.target && !(lab.control.contains && lab.control.contains(e.target)));
|
|
121
|
+
if (!passesOn) downOn = null;
|
|
122
|
+
if (!paired) return; // a click with no mouse press (screen reader, el.click() in code): focus stays
|
|
123
|
+
const el = doc.activeElement;
|
|
124
|
+
// a <select> stays focused while its list is open; a text field is typed into
|
|
125
|
+
if (!el || !isClickControl(el) || el.tagName === "SELECT") return;
|
|
126
|
+
const t = e.target;
|
|
127
|
+
const label = t && t.closest && t.closest("label");
|
|
128
|
+
if (el === t || el.contains(t) || (label && (label.contains(el) || label.control === el))) release(el);
|
|
129
|
+
});
|
|
130
|
+
// A slider lets go when the drag ends; a select once a value is picked.
|
|
131
|
+
// that pointer lifting, or the browser cancelling it (a touch turned into a scroll), ends the drag
|
|
132
|
+
const endDrag = (e) => {
|
|
133
|
+
if (!dragging || e.pointerId !== dragPointer) return;
|
|
134
|
+
const el = dragging;
|
|
135
|
+
dragging = dragHeld = null; dragPointer = null;
|
|
136
|
+
const gen = dragGen;
|
|
137
|
+
setTimeout(() => { if (gen === dragGen && doc.activeElement === el) release(el); }, 0);
|
|
138
|
+
};
|
|
139
|
+
win.addEventListener("pointerup", endDrag, true);
|
|
140
|
+
win.addEventListener("pointercancel", endDrag, true);
|
|
141
|
+
win.addEventListener("change", (e) => {
|
|
142
|
+
const el = e.target;
|
|
143
|
+
// picked from a select the mouse focused (a key held meanwhile, Shift say, doesn't change that)
|
|
144
|
+
if (el === doc.activeElement && el.tagName === "SELECT" && el !== keyFocused) release(el);
|
|
145
|
+
});
|
|
146
|
+
// A native select picker closed without a change (Esc, a click outside, the
|
|
147
|
+
// same option) leaves the select focused, and ←/→ would change its value
|
|
148
|
+
// instead of moving the playhead. An arrow key on a select still focused from
|
|
149
|
+
// the mouse lets it go first, so the editor's arrow shortcuts run (Space is
|
|
150
|
+
// handled by the editor's Space check). The picker is closed by then: while
|
|
151
|
+
// it is open the browser keeps the keys, so nothing here closes it early.
|
|
152
|
+
win.addEventListener("keydown", (e) => {
|
|
153
|
+
const el = doc.activeElement;
|
|
154
|
+
if (!el || el.tagName !== "SELECT" || el === keyFocused || inKeyboardScope(el)) return;
|
|
155
|
+
// the editor's themed list (select-menu.js) is open on it: the arrows move through the list
|
|
156
|
+
if (el.classList && el.classList.contains("fc-open")) return;
|
|
157
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown") release(el);
|
|
158
|
+
}, true);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** True while a pointer is dragging slider `el`: Space neither plays nor presses it then. */
|
|
162
|
+
function isDragging(el) { return el != null && el === dragHeld; }
|
|
163
|
+
|
|
164
|
+
return { isClickControl, inKeyboardScope, spaceShouldPlay, isDragging, noteFocus, release, install, KEYBOARD_SCOPE };
|
|
165
|
+
});
|
package/index.html
CHANGED
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
<button type="button" class="btn tiny" data-track-size="l" title="Large tracks">L</button>
|
|
31
31
|
</span>
|
|
32
32
|
</span>
|
|
33
|
+
<button class="btn ghost" id="btnSearch" title="Search actions, panels, settings, media and shortcuts (Ctrl/Cmd+K)" aria-label="Search">
|
|
34
|
+
<svg class="ico" viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><circle cx="7" cy="7" r="4.6" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10.4 10.4L14 14" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
|
|
35
|
+
</button>
|
|
33
36
|
<button class="btn ghost" id="btnSettings" title="Settings" aria-label="Settings">
|
|
34
37
|
<svg class="ico" viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
|
|
35
38
|
<path fill="currentColor" fill-rule="evenodd" d="M6.71 2.81L6.88.94L9.12.94L9.29 2.81L10.76 3.41L12.2 2.22L13.78 3.8L12.59 5.24L13.19 6.71L15.06 6.88L15.06 9.12L13.19 9.29L12.59 10.76L13.78 12.2L12.2 13.78L10.76 12.59L9.29 13.19L9.12 15.06L6.88 15.06L6.71 13.19L5.24 12.59L3.8 13.78L2.22 12.2L3.41 10.76L2.81 9.29L.94 9.12L.94 6.88L2.81 6.71L3.41 5.24L2.22 3.8L3.8 2.22L5.24 3.41Z M5.15 8a2.85 2.85 0 1 0 5.7 0a2.85 2.85 0 1 0-5.7 0"/>
|
|
@@ -303,6 +306,11 @@
|
|
|
303
306
|
<div class="dialog export-dialog" role="dialog" aria-modal="true" aria-labelledby="exportSetupTitle">
|
|
304
307
|
<h2 id="exportSetupTitle">Export</h2>
|
|
305
308
|
<div class="export-body">
|
|
309
|
+
<div class="export-profile-row" id="exportNameRow">
|
|
310
|
+
<label class="export-profile-label" for="exportName">Save as</label>
|
|
311
|
+
<input type="text" class="export-name" id="exportName" maxlength="120" spellcheck="false" aria-describedby="exportNameNote">
|
|
312
|
+
<p class="dim export-profile-note" id="exportNameNote"></p>
|
|
313
|
+
</div>
|
|
306
314
|
<div class="export-profile-row" id="exportRangeRow">
|
|
307
315
|
<label class="export-profile-label" for="exportRangeSel">Range</label>
|
|
308
316
|
<select class="export-profile-sel" id="exportRangeSel" aria-describedby="exportRangeNote">
|
|
@@ -443,6 +451,7 @@
|
|
|
443
451
|
<div class="export-track-warn hidden" id="exportTrackWarn" role="status"></div>
|
|
444
452
|
</div>
|
|
445
453
|
<div class="dialog-actions">
|
|
454
|
+
<label class="export-skip" title="The Export button then renders straight away with these settings. Settings brings this dialog back."><input type="checkbox" id="exportSkipAsk"> Don't ask again</label>
|
|
446
455
|
<button class="btn dlv-queue-open" id="btnOpenQueue" title="Show the export queue">Queue</button>
|
|
447
456
|
<button class="btn" id="btnCancelSetup">Cancel</button>
|
|
448
457
|
<button class="btn" id="btnBatchExport" title="Queue every checked batch output and start">Export checked</button>
|
|
@@ -491,10 +500,30 @@
|
|
|
491
500
|
</span>
|
|
492
501
|
</label>
|
|
493
502
|
</div>
|
|
503
|
+
<div class="settings-section">
|
|
504
|
+
<h3>Export</h3>
|
|
505
|
+
<label class="settings-row">
|
|
506
|
+
<input type="checkbox" id="setExportAsk">
|
|
507
|
+
<span>
|
|
508
|
+
<span class="settings-label">Ask before exporting</span>
|
|
509
|
+
<span class="settings-hint">Export opens a dialog to name the file and check the settings before it renders. Off: Export renders straight away with the last settings. On by default.</span>
|
|
510
|
+
</span>
|
|
511
|
+
</label>
|
|
512
|
+
</div>
|
|
494
513
|
<div class="dialog-actions"><button class="btn primary" id="btnCloseSettings">Close</button></div>
|
|
495
514
|
</div>
|
|
496
515
|
</div>
|
|
497
516
|
|
|
517
|
+
<!-- ══════════ COMMAND SEARCH (Ctrl/Cmd+K) ══════════ -->
|
|
518
|
+
<div class="overlay hidden" id="cmdkOverlay">
|
|
519
|
+
<div class="cmdk" role="dialog" aria-modal="true" aria-label="Search">
|
|
520
|
+
<input type="text" id="cmdkInput" class="cmdk-input" placeholder="Search actions, panels, settings, media, shortcuts…" autocomplete="off" spellcheck="false"
|
|
521
|
+
role="combobox" aria-expanded="true" aria-controls="cmdkList" aria-autocomplete="list">
|
|
522
|
+
<ul class="cmdk-list" id="cmdkList" role="listbox"></ul>
|
|
523
|
+
<div class="cmdk-foot dim"><kbd>↑</kbd> <kbd>↓</kbd> to move · <kbd>Enter</kbd> to run · <kbd>Esc</kbd> to close</div>
|
|
524
|
+
</div>
|
|
525
|
+
</div>
|
|
526
|
+
|
|
498
527
|
<!-- ══════════ HELP OVERLAY ══════════ -->
|
|
499
528
|
<div class="overlay hidden" id="helpOverlay">
|
|
500
529
|
<div class="dialog help">
|
|
@@ -506,6 +535,7 @@
|
|
|
506
535
|
<section class="keys-sec">
|
|
507
536
|
<h3>Playback</h3>
|
|
508
537
|
<table class="keys">
|
|
538
|
+
<tr><td><kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>K</kbd></td><td>Search: actions, panels, settings, Inspector sections, media, clips and shortcuts</td></tr>
|
|
509
539
|
<tr><td><kbd>Space</kbd></td><td>Play / pause (Source or Program — whichever is active)</td></tr>
|
|
510
540
|
<tr><td><kbd>J</kbd> <kbd>K</kbd> <kbd>L</kbd></td><td>Shuttle — <kbd>L</kbd> plays forward, <kbd>J</kbd> in reverse (silent); tap again for 1.5× · 2× · 4×, the other key turns around; <kbd>K</kbd> stops</td></tr>
|
|
511
541
|
<tr><td><kbd>K</kbd>+<kbd>J</kbd> / <kbd>K</kbd>+<kbd>L</kbd></td><td>Hold <kbd>K</kbd> and tap to step one frame; hold both to crawl at ¼ speed</td></tr>
|
|
@@ -691,8 +721,11 @@
|
|
|
691
721
|
<script src="sequences.js"></script>
|
|
692
722
|
<script src="templates.js"></script>
|
|
693
723
|
<script src="media-lib.js"></script>
|
|
724
|
+
<script src="command-search.js"></script>
|
|
694
725
|
<script src="delivery.js"></script>
|
|
695
726
|
<script src="mp4-demux.js"></script>
|
|
727
|
+
<script src="focus.js"></script>
|
|
728
|
+
<script src="select-menu.js"></script>
|
|
696
729
|
<script src="app.js"></script>
|
|
697
730
|
</body>
|
|
698
731
|
</html>
|
package/manifest.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": "0.2",
|
|
3
|
+
"name": "fablecut",
|
|
4
|
+
"display_name": "FableCut",
|
|
5
|
+
"version": "1.20.0",
|
|
6
|
+
"description": "Zero-dependency browser video editor that AI agents can drive — JSON timeline, MCP tools, live-reloading UI.",
|
|
7
|
+
"long_description": "FableCut is a Premiere-style non-linear video editor that runs in the browser with zero npm dependencies. An AI agent edits video by patching a single project.json timeline (clips, keyframes, transitions, text animations, filters, speed ramps, adjustment layers) through MCP tools, with color grading, masks and tracking, an audio mixer with effects, motion graphics (shape layers, compositions, animation presets and templates), and media management with offline relink and proxies; the open editor UI live-reloads within ~150 ms and exports through ffmpeg with delivery presets (YouTube, Reels, TikTok, Broadcast ProRes, lossless archive…), batch outputs from one render, loudness normalization and a check of every file. Includes reference-video analysis (shot cuts, beats, BPM, energy, drop) so agents can remake an edit with new footage.",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Ronak Parmar",
|
|
10
|
+
"url": "https://github.com/ronak-create"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/ronak-create/FableCut"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://fablecut.space/",
|
|
17
|
+
"documentation": "https://github.com/ronak-create/FableCut/blob/main/CLAUDE.md",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"keywords": ["video-editor", "nle", "timeline", "canvas", "mcp", "ai-agent", "ffmpeg"],
|
|
20
|
+
"server": {
|
|
21
|
+
"type": "node",
|
|
22
|
+
"entry_point": "mcp-server.js",
|
|
23
|
+
"mcp_config": {
|
|
24
|
+
"command": "node",
|
|
25
|
+
"args": ["${__dirname}/mcp-server.js"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"tools": [
|
|
29
|
+
{ "name": "fablecut_status", "description": "Auto-start the editor server and return its URL plus a project summary" },
|
|
30
|
+
{ "name": "fablecut_docs", "description": "Return the full editor manual (project.json schema, props, recipes), optionally a single section" },
|
|
31
|
+
{ "name": "fablecut_get_project", "description": "Read the timeline JSON (compact mode available for token-efficient planning)" },
|
|
32
|
+
{ "name": "fablecut_set_project", "description": "Replace the timeline JSON with optimistic-concurrency conflict detection" },
|
|
33
|
+
{ "name": "fablecut_patch_project", "description": "Apply targeted, merge-safe ops (add/update/remove clip or media, set project fields, track levels, submix buses, audio effects and their automation, color grades and secondaries, clip masks, track mattes) and timeline edits (split, ripple delete, lift/extract, insert/overwrite, ripple/roll/slip/slide, crossfade)" },
|
|
34
|
+
{ "name": "fablecut_import_media", "description": "Copy a local file into the project's media folder and register it" },
|
|
35
|
+
{ "name": "fablecut_files", "description": "List, make folders in, move, rename and trash files in the media folder (trash is restorable)" },
|
|
36
|
+
{ "name": "fablecut_analyze_reference", "description": "Analyze a reference video into an edit blueprint: shot cuts, beats, BPM, energy curve, drop; extracts its music" },
|
|
37
|
+
{ "name": "fablecut_frame", "description": "Look at the footage: one JPEG frame of a source clip at a timestamp, an N-up contact sheet across a clip, or the composed timeline rendered and graded at a moment - returned inline as an image the agent can see" },
|
|
38
|
+
{ "name": "fablecut_encode_profiles", "description": "List the delivery presets (YouTube, Reels, Broadcast…) and ffmpeg encoding profiles available for export" },
|
|
39
|
+
{ "name": "fablecut_normalize_audio", "description": "Loudness-normalize clips (BS.1770 LUFS or sample peak) by setting their clip gain" },
|
|
40
|
+
{ "name": "fablecut_auto_duck", "description": "Duck music under dialogue: write duck keyframes wherever the voice tracks speak" },
|
|
41
|
+
{ "name": "fablecut_denoise", "description": "Reduce background noise on audio clips: render a cleaned copy of the file and switch the clips to it" },
|
|
42
|
+
{ "name": "fablecut_silence", "description": "Find the pauses in speech and cut them out, keeping linked stems in step and a little quiet beside each phrase" },
|
|
43
|
+
{ "name": "fablecut_beats", "description": "Find the music's beat (BPM, a steady beat grid, the drop), mark it, snap cuts to it, or re-cut a track's clips on it" },
|
|
44
|
+
{ "name": "fablecut_reframe", "description": "Reframe for another shape (9:16, 1:1, 4:5): a copy of the sequence on that canvas whose shots follow the subject" },
|
|
45
|
+
{ "name": "fablecut_highlights", "description": "The best moments of long footage (movement, sound, a clear picture) cut into a short edit in a new sequence" },
|
|
46
|
+
{ "name": "fablecut_transcribe", "description": "Transcribe speech word by word in the browser, read it on the timeline, find a phrase and cut it out (text-based editing)" },
|
|
47
|
+
{ "name": "fablecut_captions", "description": "Make captions from the transcript (subtitle, karaoke, word highlight, word pop), timed word by word; export or import SRT / WebVTT" },
|
|
48
|
+
{ "name": "fablecut_proxy", "description": "Make, check or delete proxies: light copies of heavy footage the editor plays while editing (export always uses the originals)" },
|
|
49
|
+
{ "name": "fablecut_workflows", "description": "Save workflows (recipes of steps and the tool calls that did them) and follow them again on other projects" },
|
|
50
|
+
{ "name": "fablecut_versions", "description": "Save, compare, restore and mark final versions of a project; restoring never loses the current state" },
|
|
51
|
+
{ "name": "fablecut_projects", "description": "List, open, create, duplicate, rename, annotate, archive and delete projects; start new ones from canvas presets or saved project templates" },
|
|
52
|
+
{ "name": "fablecut_export", "description": "Render the timeline to a video file with the editor's Fast export, in an open editor tab or a headless browser" },
|
|
53
|
+
{ "name": "fablecut_scopes", "description": "Measure the graded picture at a moment: luma levels, clipping, mean RGB, saturation and colour cast — and what a grade layer's matte or a clip's masks select" },
|
|
54
|
+
{ "name": "fablecut_track", "description": "Motion tracking: follow a region of a video clip frame by frame, store it as a track, and make a mask follow it or pin another clip to it" }
|
|
55
|
+
],
|
|
56
|
+
"compatibility": {
|
|
57
|
+
"runtimes": { "node": ">=22" }
|
|
58
|
+
}
|
|
59
|
+
}
|