Skip to content

Open source CapCut alternative.

TypeScript

feat(site): teach the chat slot and dive [rebuild]

David Le0eba507371dc
diff --git a/site/src/cut/components/AnimationTiles.tools.ts b/site/src/cut/components/AnimationTiles.tools.ts
index f9ac9798..ce89aa01 100644
--- a/site/src/cut/components/AnimationTiles.tools.ts
+++ b/site/src/cut/components/AnimationTiles.tools.ts
@@ -14,8 +14,11 @@ import {
OVERLAY_ANIM_MIN_SECONDS,
GLYPH_ANIM_STYLE_IDS,
GLYPH_LOOP_STYLE_IDS,
+ DIVE_ANIM_STYLE_IDS,
+ edgeNotes,
OVERLAY_ANIM_STYLE_IDS,
OVERLAY_LOOP_STYLE_IDS,
+ TEXT_ONLY_ANIM_STYLE_IDS,
wordEffectCatalog,
WORD_EFFECT_IDS,
WORD_POP_SCALE,
@@ -36,7 +39,7 @@ export const OVERLAY_ANIMATION_TOOLS = [
{
name: "set_overlay_animation",
description:
- `Animate an overlay element (title, shape, or sticker): preset In/Out ramps, a Loop that runs its whole duration, and a Move that says what the element does WHILE it holds. Omitted slots keep their setting; pass "none" to clear one. In/Out styles: ${OVERLAY_ANIM_STYLE_IDS.join(", ")} — slide names are the motion direction; typewriter animates titles only; ${GLYPH_ANIM_STYLE_IDS.join(", ")} move a title's letters one at a time, and move any other kind as one piece. Loop styles: ${OVERLAY_LOOP_STYLE_IDS.join(", ")} — ${GLYPH_LOOP_STYLE_IDS.join(", ")} carry a title's letters on their own delays, and carry any other kind as one piece. A move is a slot like the others and never touches the element's keyframe track; set_overlay_keyframes is the precise way to move an element and the default reach, so name a move when it is exactly what you mean — the two compose together. Word effects — words_style, titles only — play the line word by word, timed against the cut's transcript when there is one and spread across the element's own span when there is not: an emphasis travels along a line that is fully up, and a build assembles the line as it is spoken. It is the slot for "make each word pop as I say it" and for "have the words appear one by one".`,
+ `Animate an overlay element (title, shape, or sticker): preset In/Out ramps, a Loop that runs its whole duration, and a Move that says what the element does WHILE it holds. Omitted slots keep their setting; pass "none" to clear one. In/Out styles: ${OVERLAY_ANIM_STYLE_IDS.join(", ")} — slide names are the motion direction; ${TEXT_ONLY_ANIM_STYLE_IDS.join(", ")} animate titles only; ${GLYPH_ANIM_STYLE_IDS.join(", ")} move a title's letters one at a time, and move any other kind as one piece. ${edgeNotes()} ${DIVE_ANIM_STYLE_IDS.join(", ")} as the exit is the zoom-through-a-letter transition: the shot after the element shows once the ink has filled the frame, so it needs no freeze frames, image stills or per-letter keyframes. Loop styles: ${OVERLAY_LOOP_STYLE_IDS.join(", ")} — ${GLYPH_LOOP_STYLE_IDS.join(", ")} carry a title's letters on their own delays, and carry any other kind as one piece. A move is a slot like the others and never touches the element's keyframe track; set_overlay_keyframes is the precise way to move an element and the default reach, so name a move when it is exactly what you mean — the two compose together. Word effects — words_style, titles only — play the line word by word, timed against the cut's transcript when there is one and spread across the element's own span when there is not: an emphasis travels along a line that is fully up, and a build assembles the line as it is spoken. It is the slot for "make each word pop as I say it" and for "have the words appear one by one".`,
inputSchema: obj({
id: str("Overlay element id"),
move: {
diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.ts
index cfafdc0c..a2d85839 100644
--- a/site/src/cut/lib/aiTools.ts
+++ b/site/src/cut/lib/aiTools.ts
@@ -63,6 +63,7 @@ import {
OVERLAY_ANIM_MAX_SECONDS,
OVERLAY_ANIM_MIN_SECONDS,
OVERLAY_ANIM_STYLE_IDS,
+ TEXT_ONLY_ANIM_STYLE_IDS,
OVERLAY_LOOP_STYLE_IDS,
hasOverlayAnim,
WORD_EFFECT_IDS,
@@ -575,8 +576,8 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {
}
if (!(OVERLAY_ANIM_STYLE_IDS as string[]).includes(raw))
throw new ToolError(`Unknown ${slot} style: ${raw}`);
- if (raw === "typewriter" && (o.kind ?? "text") !== "text")
- throw new ToolError("typewriter animates titles only.");
+ if ((TEXT_ONLY_ANIM_STYLE_IDS as string[]).includes(raw) && (o.kind ?? "text") !== "text")
+ throw new ToolError(`${raw} animates titles only.`);
anim[slot] = {
style: raw as OverlayAnimStyle,
seconds: secs ?? anim[slot]?.seconds ?? OVERLAY_ANIM_DEFAULT_SECONDS,
diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.ts
index e6df90fb..940570cc 100644
--- a/site/src/cut/server/ai/catalog.ts
+++ b/site/src/cut/server/ai/catalog.ts
@@ -56,9 +56,12 @@ import {
HSL_BANDS,
LOOK_EFFECTS,
MASK_SHAPE_KINDS,
+ DIVE_ANIM_STYLE_IDS,
+ GLYPH_ANIM_STYLE_IDS,
OVERLAY_ANIM_STYLE_IDS,
OVERLAY_LOOP_STYLE_IDS,
SOUND_EQ_BANDS,
+ TEXT_ONLY_ANIM_STYLE_IDS,
SOURCE_PROFILES,
WHEEL_LABELS,
WHEEL_ZONES,
@@ -379,7 +382,7 @@ Stickers (add_sticker): a project image asset (generated cutouts in the Elements
Custom stickers (create_sticker): one call generates the image, removes the background, adds the die-cut outline, and places it — use it when the user asks for a sticker of something they don't have (it spends credits like image generation).
Effects (add_effect): time-ranged treatments over the finished cut. Three families, one list: the picture treatments (${EFFECT_TREATMENTS.join(", ")}), the graded looks (${LOOK_EFFECTS.join(", ")}), and the audio treatments (${AUDIO_EFFECT_IDS.join(", ")}). A picture effect treats the footage and everything laid over it; an audio effect treats everything audible under its window at once — clip sound, upper-track sound and the soundtrack — so "make this bit sound like a phone call", "put an echo on that line", or "muffle the music here" is an effect element over that stretch, and a per-clip volume, fade or duck is the audio tools instead. A handover on the sound at a cut belongs to the transition on that cut — the audiocross style — not here. Placed like any element and tuned with \`amount\` (update_overlay), and trims like anything else: a picture effect dropped over a clip opens covering that clip, while an audio effect opens at the standard length wherever it was placed — a treatment on the sound is aimed at a moment, so give it the window you mean. One effect at a time reads best, amounts under ~0.5. Effects are stylized post treatments on a stretch of timeline; pure color — exposure, warmth, a cinematic or film palette on one clip — is the per-clip grading tools instead (color-grading skill), whose preset catalog is separate from the look effects.
Advanced text (update_overlay): italic, align (multi-line), letter_spacing (em), line_height, wrap_width (frame-width fraction; side grips wrap text, height follows content; corners scale type proportionally), stroke_color/stroke_width (em outline behind the fill), and richer shadows. Bundled Google families join the system set — ${GOOGLE_FONT_IDS.join(", ")} — and so do the user's own: a .ttf/.otf/.woff/.woff2 file dropped on the Library is offered in every project under a font id like "font:<key>". Editor_state lists the ones this account has under \`fonts\` — use an id from there instead of guessing at a family name, and when someone asks for a typeface that is not in the list, tell them the Library takes font files.
-Animation (set_overlay_animation): every element takes preset In/Out ramps (${OVERLAY_ANIM_STYLE_IDS.join(", ")} — typewriter for titles only; the per-letter styles sweep a title character by character), a Loop (${OVERLAY_LOOP_STYLE_IDS.join(", ")}) that runs its whole duration, and a Move that says what it does WHILE it holds. A title takes one more: Words (${WORD_EFFECT_IDS.join(", ")}), which plays the line word by word — an emphasis travelling along a line that is fully up, or a build assembling the line as it is spoken. Entrances 0.3–0.6s read well; one loop per scene, sparingly; a move on the lines that matter. All of them are slots on the element, applied internally, and they compose over its keyframe track. A slot is the reach when the motion is per-letter or per-word — typewriter, the glyph sweeps, the word effects — which one pose track cannot express; what the whole element does is keyed.
+Animation (set_overlay_animation): every element takes preset In/Out ramps (${OVERLAY_ANIM_STYLE_IDS.join(", ")} — ${TEXT_ONLY_ANIM_STYLE_IDS.join(", ")} for titles only; the per-letter styles sweep a title character by character; ${DIVE_ANIM_STYLE_IDS.join(", ")} flies into the last letter until its ink fills the frame, the built-in zoom-through transition), a Loop (${OVERLAY_LOOP_STYLE_IDS.join(", ")}) that runs its whole duration, and a Move that says what it does WHILE it holds. A title takes one more: Words (${WORD_EFFECT_IDS.join(", ")}), which plays the line word by word — an emphasis travelling along a line that is fully up, or a build assembling the line as it is spoken. Entrances 0.3–0.6s read well; one loop per scene, sparingly; a move on the lines that matter. All of them are slots on the element, applied internally, and they compose over its keyframe track. A slot is the reach when the motion is per-letter or per-word — typewriter, the glyph sweeps, the word effects — which one pose track cannot express; what the whole element does is keyed.
Keyframes (set_overlay_keyframes): for motion no preset covers — a path across the frame, a slow push in, a drift that holds first. A key is a whole pose (position, scale, rotation, opacity) at a time in seconds from the element's start; the pose moves linearly between keys and holds outside them, and presets still compose on top. This is the default way to animate an element: a key names the exact pose at the exact second, where a named ramp only approximates it. Two or three keys carry almost everything. In the UI the diamond in the inspector adds a key at the playhead, and dragging the element then records into it. set_clip_keyframes is the same track on a video clip (any track): pans, push-ins, picture-in-picture flights, spins, and fades on the footage itself.
Masks (set_mask): trim any element or video clip to a shape — ${MASK_SHAPE_KINDS.join(", ")} — with feather, invert, rounded corners on a box, and its own keyframe track for reveals and wipes. The pen kind takes an outline as points, for any region the fixed shapes miss: the gap framed between two hands, a doorway, a screen — read the region's corners off a captured frame in frame fractions, and stack a masked copy of the shot (a filter, a title) so it shows through only there. The subject kind trims by the person in the shot (on-device segmentation; preview and export match): inverted sits the item behind the speaker, plain keeps it only on the speaker. Behind-speaker reads well when the speaker is clearly separated from the background; with no detectable person it degrades to the plain picture. Group and Ungroup are in the timeline toolbar (⌘/Ctrl+G and ⇧⌘/Ctrl+G).
Composite builds: these primitives compose. Stacked overlay video copies, masks and their keys, pose keyframes, staggered starts, and shapes construct effects beyond any preset list. Given a reference (a screenshot or clip of an effect the user wants), reverse-engineer it:
@@ -478,11 +481,11 @@ Read this before any text-heavy job the user calls flat, boring, samey, or "not
33. **Arrival and hold are two decisions.** \`in_style\` is how it appears; \`move\` is what it does for the rest of its life. A line with only an entrance freezes the moment it lands.
34. **The moves** — each is a slot beside the entrance and loop, applied for the element's whole hold and composing over whatever the keyframe track does:
${textMoveCatalog()}
-35. **Per-glyph entrances.** rise, drop, grow, flip, swivel, bounce, wave, converge, streak, tumble and scatter move a title's letters one at a time. They cost nothing extra and are the difference between a title and kinetic typography.
+35. **Per-glyph entrances.** ${GLYPH_ANIM_STYLE_IDS.join(", ")} move a title's letters one at a time. They cost nothing extra and are the difference between a title and kinetic typography. slot rolls each letter up a reel like a scoreboard: counts, years, a name landing.
36. **Typewriter for a reveal.** Slow it to two thirds of the line's hold so the text finishes typing just before it leaves.
37. **Wipe for a band.** A wipe entrance on a line sitting in a shape band reads as a broadcast lower third.
38. **Loops, sparingly.** flicker on neon, float on dreamy, wiggle on comedy — one loop per passage, never on every line.
-39. **Exit matters.** A run where every line simply cuts out feels cheap; a 0.2s fade or a converge out costs nothing.
+39. **Exit matters.** A run where every line simply cuts out feels cheap; a 0.2s fade or a converge out costs nothing. A dive out flies into the last letter until its color fills the frame, a transition into whatever comes next.
40. **Contrast the move to the entrance.** A violent entrance (slam, tumble) into a still hold; a soft entrance (fade) into a slow push. Both loud reads as noise.
41. **Match the move to the beat.** punch and slam on hits, push and creep under sustained notes, float and breathe under held vocals.
42. **Key it yourself.** set_overlay_keyframes takes whole poses in seconds from the element's start — a path across the frame, a hold-then-drift, a beat that lands on a specific hit in the music. It is the first reach for motion, because a key lands on the second you name: two or three carry almost everything, and a preset entrance still composes over them.