@nodetool-ai/timeline 0.8.1
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/README.md +55 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/animation/bakedAnimation.d.ts +84 -0
- package/dist/animation/bakedAnimation.d.ts.map +1 -0
- package/dist/animation/bakedAnimation.js +95 -0
- package/dist/animation/bakedAnimation.js.map +1 -0
- package/dist/animation/beat.d.ts +7 -0
- package/dist/animation/beat.d.ts.map +1 -0
- package/dist/animation/beat.js +36 -0
- package/dist/animation/beat.js.map +1 -0
- package/dist/animation/compile.d.ts +184 -0
- package/dist/animation/compile.d.ts.map +1 -0
- package/dist/animation/compile.js +312 -0
- package/dist/animation/compile.js.map +1 -0
- package/dist/animation/custom.d.ts +183 -0
- package/dist/animation/custom.d.ts.map +1 -0
- package/dist/animation/custom.js +583 -0
- package/dist/animation/custom.js.map +1 -0
- package/dist/animation/easing.d.ts +34 -0
- package/dist/animation/easing.d.ts.map +1 -0
- package/dist/animation/easing.js +332 -0
- package/dist/animation/easing.js.map +1 -0
- package/dist/animation/index.d.ts +20 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/links.d.ts +33 -0
- package/dist/animation/links.d.ts.map +1 -0
- package/dist/animation/links.js +126 -0
- package/dist/animation/links.js.map +1 -0
- package/dist/animation/presets.d.ts +86 -0
- package/dist/animation/presets.d.ts.map +1 -0
- package/dist/animation/presets.js +642 -0
- package/dist/animation/presets.js.map +1 -0
- package/dist/animation/sample.d.ts +145 -0
- package/dist/animation/sample.d.ts.map +1 -0
- package/dist/animation/sample.js +390 -0
- package/dist/animation/sample.js.map +1 -0
- package/dist/animation/simplify.d.ts +70 -0
- package/dist/animation/simplify.d.ts.map +1 -0
- package/dist/animation/simplify.js +278 -0
- package/dist/animation/simplify.js.map +1 -0
- package/dist/animation/sourceCurves.d.ts +45 -0
- package/dist/animation/sourceCurves.d.ts.map +1 -0
- package/dist/animation/sourceCurves.js +168 -0
- package/dist/animation/sourceCurves.js.map +1 -0
- package/dist/animation/styleTracks.d.ts +23 -0
- package/dist/animation/styleTracks.d.ts.map +1 -0
- package/dist/animation/styleTracks.js +341 -0
- package/dist/animation/styleTracks.js.map +1 -0
- package/dist/animation/types.d.ts +269 -0
- package/dist/animation/types.d.ts.map +1 -0
- package/dist/animation/types.js +173 -0
- package/dist/animation/types.js.map +1 -0
- package/dist/animation/typewriter.d.ts +8 -0
- package/dist/animation/typewriter.d.ts.map +1 -0
- package/dist/animation/typewriter.js +32 -0
- package/dist/animation/typewriter.js.map +1 -0
- package/dist/audioFade.d.ts +73 -0
- package/dist/audioFade.d.ts.map +1 -0
- package/dist/audioFade.js +134 -0
- package/dist/audioFade.js.map +1 -0
- package/dist/authoredStyles.d.ts +61 -0
- package/dist/authoredStyles.d.ts.map +1 -0
- package/dist/authoredStyles.js +90 -0
- package/dist/authoredStyles.js.map +1 -0
- package/dist/authoring.d.ts +50 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +207 -0
- package/dist/authoring.js.map +1 -0
- package/dist/beats.d.ts +103 -0
- package/dist/beats.d.ts.map +1 -0
- package/dist/beats.js +228 -0
- package/dist/beats.js.map +1 -0
- package/dist/clone.d.ts +32 -0
- package/dist/clone.d.ts.map +1 -0
- package/dist/clone.js +53 -0
- package/dist/clone.js.map +1 -0
- package/dist/composition.d.ts +87 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +253 -0
- package/dist/composition.js.map +1 -0
- package/dist/crop.d.ts +48 -0
- package/dist/crop.d.ts.map +1 -0
- package/dist/crop.js +75 -0
- package/dist/crop.js.map +1 -0
- package/dist/defaults.d.ts +142 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +335 -0
- package/dist/defaults.js.map +1 -0
- package/dist/dependencyHash.d.ts +14 -0
- package/dist/dependencyHash.d.ts.map +1 -0
- package/dist/dependencyHash.js +19 -0
- package/dist/dependencyHash.js.map +1 -0
- package/dist/dropResolve.d.ts +40 -0
- package/dist/dropResolve.d.ts.map +1 -0
- package/dist/dropResolve.js +137 -0
- package/dist/dropResolve.js.map +1 -0
- package/dist/examples/node.d.ts +11 -0
- package/dist/examples/node.d.ts.map +1 -0
- package/dist/examples/node.js +87 -0
- package/dist/examples/node.js.map +1 -0
- package/dist/extension.d.ts +52 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +269 -0
- package/dist/extension.js.map +1 -0
- package/dist/extensionRequest.d.ts +40 -0
- package/dist/extensionRequest.d.ts.map +1 -0
- package/dist/extensionRequest.js +135 -0
- package/dist/extensionRequest.js.map +1 -0
- package/dist/fill-text.d.ts +30 -0
- package/dist/fill-text.d.ts.map +1 -0
- package/dist/fill-text.js +73 -0
- package/dist/fill-text.js.map +1 -0
- package/dist/fonts/catalog.d.ts +97 -0
- package/dist/fonts/catalog.d.ts.map +1 -0
- package/dist/fonts/catalog.js +276 -0
- package/dist/fonts/catalog.js.map +1 -0
- package/dist/fonts/css.d.ts +24 -0
- package/dist/fonts/css.d.ts.map +1 -0
- package/dist/fonts/css.js +50 -0
- package/dist/fonts/css.js.map +1 -0
- package/dist/fonts/index.d.ts +10 -0
- package/dist/fonts/index.d.ts.map +1 -0
- package/dist/fonts/index.js +10 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/register-node.d.ts +45 -0
- package/dist/fonts/register-node.d.ts.map +1 -0
- package/dist/fonts/register-node.js +71 -0
- package/dist/fonts/register-node.js.map +1 -0
- package/dist/generatedMatte.d.ts +86 -0
- package/dist/generatedMatte.d.ts.map +1 -0
- package/dist/generatedMatte.js +152 -0
- package/dist/generatedMatte.js.map +1 -0
- package/dist/generative.d.ts +145 -0
- package/dist/generative.d.ts.map +1 -0
- package/dist/generative.js +396 -0
- package/dist/generative.js.map +1 -0
- package/dist/group.d.ts +47 -0
- package/dist/group.d.ts.map +1 -0
- package/dist/group.js +131 -0
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/interchange.d.ts +47 -0
- package/dist/interchange.d.ts.map +1 -0
- package/dist/interchange.js +158 -0
- package/dist/interchange.js.map +1 -0
- package/dist/keyframes.d.ts +44 -0
- package/dist/keyframes.d.ts.map +1 -0
- package/dist/keyframes.js +148 -0
- package/dist/keyframes.js.map +1 -0
- package/dist/lineDelivery.d.ts +108 -0
- package/dist/lineDelivery.d.ts.map +1 -0
- package/dist/lineDelivery.js +154 -0
- package/dist/lineDelivery.js.map +1 -0
- package/dist/linked.d.ts +41 -0
- package/dist/linked.d.ts.map +1 -0
- package/dist/linked.js +166 -0
- package/dist/linked.js.map +1 -0
- package/dist/lipSyncRequest.d.ts +65 -0
- package/dist/lipSyncRequest.d.ts.map +1 -0
- package/dist/lipSyncRequest.js +73 -0
- package/dist/lipSyncRequest.js.map +1 -0
- package/dist/measureClipDurations.d.ts +7 -0
- package/dist/measureClipDurations.d.ts.map +1 -0
- package/dist/measureClipDurations.js +17 -0
- package/dist/measureClipDurations.js.map +1 -0
- package/dist/mediaTrack.d.ts +120 -0
- package/dist/mediaTrack.d.ts.map +1 -0
- package/dist/mediaTrack.js +269 -0
- package/dist/mediaTrack.js.map +1 -0
- package/dist/midi/cacheKey.d.ts +25 -0
- package/dist/midi/cacheKey.d.ts.map +1 -0
- package/dist/midi/cacheKey.js +54 -0
- package/dist/midi/cacheKey.js.map +1 -0
- package/dist/midi/edit.d.ts +48 -0
- package/dist/midi/edit.d.ts.map +1 -0
- package/dist/midi/edit.js +93 -0
- package/dist/midi/edit.js.map +1 -0
- package/dist/midi/engines/bl1.d.ts +29 -0
- package/dist/midi/engines/bl1.d.ts.map +1 -0
- package/dist/midi/engines/bl1.js +128 -0
- package/dist/midi/engines/bl1.js.map +1 -0
- package/dist/midi/engines/dr1.d.ts +28 -0
- package/dist/midi/engines/dr1.d.ts.map +1 -0
- package/dist/midi/engines/dr1.js +101 -0
- package/dist/midi/engines/dr1.js.map +1 -0
- package/dist/midi/engines/dsp.d.ts +126 -0
- package/dist/midi/engines/dsp.d.ts.map +1 -0
- package/dist/midi/engines/dsp.js +371 -0
- package/dist/midi/engines/dsp.js.map +1 -0
- package/dist/midi/engines/index.d.ts +13 -0
- package/dist/midi/engines/index.d.ts.map +1 -0
- package/dist/midi/engines/index.js +13 -0
- package/dist/midi/engines/index.js.map +1 -0
- package/dist/midi/engines/kits.d.ts +12 -0
- package/dist/midi/engines/kits.d.ts.map +1 -0
- package/dist/midi/engines/kits.js +121 -0
- package/dist/midi/engines/kits.js.map +1 -0
- package/dist/midi/engines/wavetables.d.ts +45 -0
- package/dist/midi/engines/wavetables.d.ts.map +1 -0
- package/dist/midi/engines/wavetables.js +334 -0
- package/dist/midi/engines/wavetables.js.map +1 -0
- package/dist/midi/engines/wt1.d.ts +30 -0
- package/dist/midi/engines/wt1.d.ts.map +1 -0
- package/dist/midi/engines/wt1.js +91 -0
- package/dist/midi/engines/wt1.js.map +1 -0
- package/dist/midi/grid.d.ts +51 -0
- package/dist/midi/grid.d.ts.map +1 -0
- package/dist/midi/grid.js +104 -0
- package/dist/midi/grid.js.map +1 -0
- package/dist/midi/index.d.ts +20 -0
- package/dist/midi/index.d.ts.map +1 -0
- package/dist/midi/index.js +20 -0
- package/dist/midi/index.js.map +1 -0
- package/dist/midi/instrument.d.ts +32 -0
- package/dist/midi/instrument.d.ts.map +1 -0
- package/dist/midi/instrument.js +73 -0
- package/dist/midi/instrument.js.map +1 -0
- package/dist/midi/notes.d.ts +46 -0
- package/dist/midi/notes.d.ts.map +1 -0
- package/dist/midi/notes.js +121 -0
- package/dist/midi/notes.js.map +1 -0
- package/dist/midi/notesEdit.d.ts +94 -0
- package/dist/midi/notesEdit.d.ts.map +1 -0
- package/dist/midi/notesEdit.js +159 -0
- package/dist/midi/notesEdit.js.map +1 -0
- package/dist/midi/presets.d.ts +29 -0
- package/dist/midi/presets.d.ts.map +1 -0
- package/dist/midi/presets.js +281 -0
- package/dist/midi/presets.js.map +1 -0
- package/dist/midi/tempo.d.ts +27 -0
- package/dist/midi/tempo.d.ts.map +1 -0
- package/dist/midi/tempo.js +57 -0
- package/dist/midi/tempo.js.map +1 -0
- package/dist/midi/ticks.d.ts +25 -0
- package/dist/midi/ticks.d.ts.map +1 -0
- package/dist/midi/ticks.js +35 -0
- package/dist/midi/ticks.js.map +1 -0
- package/dist/midi/voice.d.ts +148 -0
- package/dist/midi/voice.d.ts.map +1 -0
- package/dist/midi/voice.js +348 -0
- package/dist/midi/voice.js.map +1 -0
- package/dist/midi/wav.d.ts +14 -0
- package/dist/midi/wav.d.ts.map +1 -0
- package/dist/midi/wav.js +51 -0
- package/dist/midi/wav.js.map +1 -0
- package/dist/model3d.d.ts +41 -0
- package/dist/model3d.d.ts.map +1 -0
- package/dist/model3d.js +39 -0
- package/dist/model3d.js.map +1 -0
- package/dist/model3dBake.d.ts +80 -0
- package/dist/model3dBake.d.ts.map +1 -0
- package/dist/model3dBake.js +127 -0
- package/dist/model3dBake.js.map +1 -0
- package/dist/ops/apply.d.ts +32 -0
- package/dist/ops/apply.d.ts.map +1 -0
- package/dist/ops/apply.js +1595 -0
- package/dist/ops/apply.js.map +1 -0
- package/dist/ops/index.d.ts +13 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +13 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/op.d.ts +407 -0
- package/dist/ops/op.d.ts.map +1 -0
- package/dist/ops/op.js +61 -0
- package/dist/ops/op.js.map +1 -0
- package/dist/ops/serialize.d.ts +77 -0
- package/dist/ops/serialize.d.ts.map +1 -0
- package/dist/ops/serialize.js +81 -0
- package/dist/ops/serialize.js.map +1 -0
- package/dist/ops/types.d.ts +150 -0
- package/dist/ops/types.d.ts.map +1 -0
- package/dist/ops/types.js +12 -0
- package/dist/ops/types.js.map +1 -0
- package/dist/pathSampling.d.ts +51 -0
- package/dist/pathSampling.d.ts.map +1 -0
- package/dist/pathSampling.js +111 -0
- package/dist/pathSampling.js.map +1 -0
- package/dist/placement/index.d.ts +2 -0
- package/dist/placement/index.d.ts.map +1 -0
- package/dist/placement/index.js +2 -0
- package/dist/placement/index.js.map +1 -0
- package/dist/placement/resolveTrackPlacement.d.ts +40 -0
- package/dist/placement/resolveTrackPlacement.d.ts.map +1 -0
- package/dist/placement/resolveTrackPlacement.js +71 -0
- package/dist/placement/resolveTrackPlacement.js.map +1 -0
- package/dist/production.d.ts +99 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +328 -0
- package/dist/production.js.map +1 -0
- package/dist/reassemble.d.ts +68 -0
- package/dist/reassemble.d.ts.map +1 -0
- package/dist/reassemble.js +187 -0
- package/dist/reassemble.js.map +1 -0
- package/dist/recipe.d.ts +24 -0
- package/dist/recipe.d.ts.map +1 -0
- package/dist/recipe.js +89 -0
- package/dist/recipe.js.map +1 -0
- package/dist/recordedVoiceReplacement.d.ts +70 -0
- package/dist/recordedVoiceReplacement.d.ts.map +1 -0
- package/dist/recordedVoiceReplacement.js +82 -0
- package/dist/recordedVoiceReplacement.js.map +1 -0
- package/dist/reframe.d.ts +31 -0
- package/dist/reframe.d.ts.map +1 -0
- package/dist/reframe.js +227 -0
- package/dist/reframe.js.map +1 -0
- package/dist/render/canvas2d.d.ts +419 -0
- package/dist/render/canvas2d.d.ts.map +1 -0
- package/dist/render/canvas2d.js +1392 -0
- package/dist/render/canvas2d.js.map +1 -0
- package/dist/render/color.d.ts +26 -0
- package/dist/render/color.d.ts.map +1 -0
- package/dist/render/color.js +305 -0
- package/dist/render/color.js.map +1 -0
- package/dist/render/cpuLegacyEffects.d.ts +17 -0
- package/dist/render/cpuLegacyEffects.d.ts.map +1 -0
- package/dist/render/cpuLegacyEffects.js +347 -0
- package/dist/render/cpuLegacyEffects.js.map +1 -0
- package/dist/render/cpuVisualEffects.d.ts +13 -0
- package/dist/render/cpuVisualEffects.d.ts.map +1 -0
- package/dist/render/cpuVisualEffects.js +388 -0
- package/dist/render/cpuVisualEffects.js.map +1 -0
- package/dist/render/cubeLut.d.ts +12 -0
- package/dist/render/cubeLut.d.ts.map +1 -0
- package/dist/render/cubeLut.js +81 -0
- package/dist/render/cubeLut.js.map +1 -0
- package/dist/render/curveFitting.d.ts +28 -0
- package/dist/render/curveFitting.d.ts.map +1 -0
- package/dist/render/curveFitting.js +94 -0
- package/dist/render/curveFitting.js.map +1 -0
- package/dist/render/draw.d.ts +265 -0
- package/dist/render/draw.d.ts.map +1 -0
- package/dist/render/draw.js +929 -0
- package/dist/render/draw.js.map +1 -0
- package/dist/render/effects.d.ts +120 -0
- package/dist/render/effects.d.ts.map +1 -0
- package/dist/render/effects.js +804 -0
- package/dist/render/effects.js.map +1 -0
- package/dist/render/frameCompositor.d.ts +502 -0
- package/dist/render/frameCompositor.d.ts.map +1 -0
- package/dist/render/frameCompositor.js +1331 -0
- package/dist/render/frameCompositor.js.map +1 -0
- package/dist/render/index.d.ts +27 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/layout.d.ts +17 -0
- package/dist/render/layout.d.ts.map +1 -0
- package/dist/render/layout.js +197 -0
- package/dist/render/layout.js.map +1 -0
- package/dist/render/model3dBakeSamples.d.ts +45 -0
- package/dist/render/model3dBakeSamples.d.ts.map +1 -0
- package/dist/render/model3dBakeSamples.js +68 -0
- package/dist/render/model3dBakeSamples.js.map +1 -0
- package/dist/render/motionBlur.d.ts +170 -0
- package/dist/render/motionBlur.d.ts.map +1 -0
- package/dist/render/motionBlur.js +193 -0
- package/dist/render/motionBlur.js.map +1 -0
- package/dist/render/sceneModel.d.ts +577 -0
- package/dist/render/sceneModel.d.ts.map +1 -0
- package/dist/render/sceneModel.js +1460 -0
- package/dist/render/sceneModel.js.map +1 -0
- package/dist/render/shapeGeometry.d.ts +81 -0
- package/dist/render/shapeGeometry.d.ts.map +1 -0
- package/dist/render/shapeGeometry.js +460 -0
- package/dist/render/shapeGeometry.js.map +1 -0
- package/dist/render/spatial.d.ts +9 -0
- package/dist/render/spatial.d.ts.map +1 -0
- package/dist/render/spatial.js +58 -0
- package/dist/render/spatial.js.map +1 -0
- package/dist/render/svgPath.d.ts +80 -0
- package/dist/render/svgPath.d.ts.map +1 -0
- package/dist/render/svgPath.js +199 -0
- package/dist/render/svgPath.js.map +1 -0
- package/dist/render/temporal.d.ts +6 -0
- package/dist/render/temporal.d.ts.map +1 -0
- package/dist/render/temporal.js +74 -0
- package/dist/render/temporal.js.map +1 -0
- package/dist/render/textLayout.d.ts +159 -0
- package/dist/render/textLayout.d.ts.map +1 -0
- package/dist/render/textLayout.js +301 -0
- package/dist/render/textLayout.js.map +1 -0
- package/dist/render/trackEffects.d.ts +23 -0
- package/dist/render/trackEffects.d.ts.map +1 -0
- package/dist/render/trackEffects.js +93 -0
- package/dist/render/trackEffects.js.map +1 -0
- package/dist/render/transform.d.ts +54 -0
- package/dist/render/transform.d.ts.map +1 -0
- package/dist/render/transform.js +222 -0
- package/dist/render/transform.js.map +1 -0
- package/dist/render/transition.d.ts +109 -0
- package/dist/render/transition.d.ts.map +1 -0
- package/dist/render/transition.js +351 -0
- package/dist/render/transition.js.map +1 -0
- package/dist/retarget.d.ts +73 -0
- package/dist/retarget.d.ts.map +1 -0
- package/dist/retarget.js +305 -0
- package/dist/retarget.js.map +1 -0
- package/dist/rippleEdit.d.ts +83 -0
- package/dist/rippleEdit.d.ts.map +1 -0
- package/dist/rippleEdit.js +184 -0
- package/dist/rippleEdit.js.map +1 -0
- package/dist/scene.d.ts +28 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +28 -0
- package/dist/scene.js.map +1 -0
- package/dist/script-link.d.ts +52 -0
- package/dist/script-link.d.ts.map +1 -0
- package/dist/script-link.js +78 -0
- package/dist/script-link.js.map +1 -0
- package/dist/script.d.ts +52 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +93 -0
- package/dist/script.js.map +1 -0
- package/dist/snap.d.ts +2 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +21 -0
- package/dist/snap.js.map +1 -0
- package/dist/snapping/buildSnapPoints.d.ts +16 -0
- package/dist/snapping/buildSnapPoints.d.ts.map +1 -0
- package/dist/snapping/buildSnapPoints.js +39 -0
- package/dist/snapping/buildSnapPoints.js.map +1 -0
- package/dist/snapping/index.d.ts +3 -0
- package/dist/snapping/index.d.ts.map +1 -0
- package/dist/snapping/index.js +3 -0
- package/dist/snapping/index.js.map +1 -0
- package/dist/snapping/resolveSnap.d.ts +19 -0
- package/dist/snapping/resolveSnap.d.ts.map +1 -0
- package/dist/snapping/resolveSnap.js +39 -0
- package/dist/snapping/resolveSnap.js.map +1 -0
- package/dist/sourceRate.d.ts +12 -0
- package/dist/sourceRate.d.ts.map +1 -0
- package/dist/sourceRate.js +13 -0
- package/dist/sourceRate.js.map +1 -0
- package/dist/spatialVideoRequest.d.ts +91 -0
- package/dist/spatialVideoRequest.d.ts.map +1 -0
- package/dist/spatialVideoRequest.js +175 -0
- package/dist/spatialVideoRequest.js.map +1 -0
- package/dist/splitClip.d.ts +3 -0
- package/dist/splitClip.d.ts.map +1 -0
- package/dist/splitClip.js +190 -0
- package/dist/splitClip.js.map +1 -0
- package/dist/stableSerialize.d.ts +11 -0
- package/dist/stableSerialize.d.ts.map +1 -0
- package/dist/stableSerialize.js +31 -0
- package/dist/stableSerialize.js.map +1 -0
- package/dist/staleSet.d.ts +41 -0
- package/dist/staleSet.d.ts.map +1 -0
- package/dist/staleSet.js +106 -0
- package/dist/staleSet.js.map +1 -0
- package/dist/storyboard.d.ts +221 -0
- package/dist/storyboard.d.ts.map +1 -0
- package/dist/storyboard.js +417 -0
- package/dist/storyboard.js.map +1 -0
- package/dist/subtitles.d.ts +61 -0
- package/dist/subtitles.d.ts.map +1 -0
- package/dist/subtitles.js +92 -0
- package/dist/subtitles.js.map +1 -0
- package/dist/takes.d.ts +76 -0
- package/dist/takes.d.ts.map +1 -0
- package/dist/takes.js +238 -0
- package/dist/takes.js.map +1 -0
- package/dist/timeRemap.d.ts +101 -0
- package/dist/timeRemap.d.ts.map +1 -0
- package/dist/timeRemap.js +183 -0
- package/dist/timeRemap.js.map +1 -0
- package/dist/trackOrder.d.ts +38 -0
- package/dist/trackOrder.d.ts.map +1 -0
- package/dist/trackOrder.js +54 -0
- package/dist/trackOrder.js.map +1 -0
- package/dist/transitionAtCut.d.ts +89 -0
- package/dist/transitionAtCut.d.ts.map +1 -0
- package/dist/transitionAtCut.js +217 -0
- package/dist/transitionAtCut.js.map +1 -0
- package/dist/trimClip.d.ts +13 -0
- package/dist/trimClip.d.ts.map +1 -0
- package/dist/trimClip.js +60 -0
- package/dist/trimClip.js.map +1 -0
- package/dist/types.d.ts +1772 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +84 -0
- package/dist/types.js.map +1 -0
- package/fonts/BebasNeue-Regular.ttf +0 -0
- package/fonts/Inter-ExtraBold.ttf +0 -0
- package/fonts/Inter-Italic-Variable.ttf +0 -0
- package/fonts/Inter-SemiBold.ttf +0 -0
- package/fonts/Inter-Variable.ttf +0 -0
- package/fonts/JetBrainsMono-Italic-Variable.ttf +0 -0
- package/fonts/JetBrainsMono-Variable.ttf +0 -0
- package/fonts/Lora-Italic-Variable.ttf +0 -0
- package/fonts/Lora-Variable.ttf +0 -0
- package/fonts/OFL-BebasNeue.txt +93 -0
- package/fonts/OFL-Inter.txt +93 -0
- package/fonts/OFL-JetBrainsMono.txt +93 -0
- package/fonts/OFL-Lora.txt +93 -0
- package/fonts/OFL-PlayfairDisplay.txt +93 -0
- package/fonts/OFL-SpaceGrotesk.txt +93 -0
- package/fonts/PlayfairDisplay-Italic-Variable.ttf +0 -0
- package/fonts/PlayfairDisplay-Variable.ttf +0 -0
- package/fonts/SpaceGrotesk-Variable.ttf +0 -0
- package/package.json +108 -0
|
@@ -0,0 +1,1595 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `applyTimelineOp` — one implementation of every timeline edit op (I11).
|
|
3
|
+
*
|
|
4
|
+
* Pure: it clones the state it is handed, applies one op to the clone, and
|
|
5
|
+
* returns the new document plus the op's result. A failure comes back as
|
|
6
|
+
* `error` with the state that went in, so a host can report it without a
|
|
7
|
+
* try/catch of its own and without a half-applied document.
|
|
8
|
+
*
|
|
9
|
+
* Everything a pure function cannot know — minting an id, reading an asset,
|
|
10
|
+
* baking a JS animation body, loading a composition, parsing SVG path data —
|
|
11
|
+
* arrives on {@link TimelineOpContext}. This module imports nothing from
|
|
12
|
+
* `src/render` or `@nodetool-ai/gpu`, so mobile compiles it from source (AS2).
|
|
13
|
+
*/
|
|
14
|
+
import { buildEffect, buildMask, buildTimeRemap, buildTransition, resolveDeleteTrackArgs, resolveMoveTrackArgs, resolveShapeArg } from "@nodetool-ai/protocol/api-schemas/timeline-tool-params.js";
|
|
15
|
+
import { ANIMATION_PRESETS, buildBakedAnimation, CUSTOM_ANIMATION_CONTRACT, CUSTOM_ANIMATION_PRESET_ID, normalizeCustomCurves, resolveCustomMask, typewriterTiming } from "../animation/index.js";
|
|
16
|
+
import { beatCountToCover, buildBeatGrid, snapClipsToGrid } from "../beats.js";
|
|
17
|
+
import { instantiateComposition } from "../composition.js";
|
|
18
|
+
import { DEFAULT_MEDIA_CLIP_DURATION_MS, DEFAULT_MODEL3D_CLIP_DURATION_MS, DEFAULT_MODEL3D_CLIP_NAME, DEFAULT_TEXT_CLIP_DURATION_MS, makeClip, makeClipVersion, makeTrack, mediaTypeForContentType, trackTypeForMediaType } from "../defaults.js";
|
|
19
|
+
import { selectGeneratedMatteVersion } from "../generatedMatte.js";
|
|
20
|
+
import { computeModel3DBakeHash } from "../model3dBake.js";
|
|
21
|
+
import { model3dStyleWithPatch, shapeStyleWithDefaults, textStyleWithDefaults } from "../authoredStyles.js";
|
|
22
|
+
import { isGroupClip, moveGroup, trimGroup, ungroup } from "../group.js";
|
|
23
|
+
import { isCropUsable } from "../crop.js";
|
|
24
|
+
import { splitClip } from "../splitClip.js";
|
|
25
|
+
import { activeTakeIdOf, deleteTake as deleteTakeOnClip, renameTake as renameTakeOnClip, selectTake } from "../takes.js";
|
|
26
|
+
import { moveTrackOrder } from "../trackOrder.js";
|
|
27
|
+
import { trimClip } from "../trimClip.js";
|
|
28
|
+
import { applyTransitionAtCutCandidate, planTransitionAtCut } from "../transitionAtCut.js";
|
|
29
|
+
import { resliceTracksForSplitClip, resliceTracksForTrimmedClip } from "../mediaTrack.js";
|
|
30
|
+
import { serializeClip, serializeMediaTrack, serializeTrack } from "./serialize.js";
|
|
31
|
+
/** Units a failed lookup names before it stops and points at get_state. */
|
|
32
|
+
const MAX_LISTED_UNITS = 12;
|
|
33
|
+
/**
|
|
34
|
+
* The clip one `target` names: an id, a case-insensitive name, or the literal
|
|
35
|
+
* `"selected"`. Exported because a host's own I/O needs the same resolution —
|
|
36
|
+
* the browser's `get_clip_frames` samples the clip a caller named, and reading
|
|
37
|
+
* it any other way would give the agent two different answers to "which clip is
|
|
38
|
+
* that?".
|
|
39
|
+
*/
|
|
40
|
+
export function resolveClipTarget(state, target) {
|
|
41
|
+
if (target.toLowerCase() === "selected") {
|
|
42
|
+
const selected = state.selectedClipIds;
|
|
43
|
+
if (selected.length !== 1) {
|
|
44
|
+
throw new Error(`"selected" requires exactly one selected clip (currently ${selected.length}).`);
|
|
45
|
+
}
|
|
46
|
+
const clip = state.clips.find((c) => c.id === selected[0]);
|
|
47
|
+
if (!clip)
|
|
48
|
+
throw new Error("Selected clip no longer exists.");
|
|
49
|
+
return clip;
|
|
50
|
+
}
|
|
51
|
+
const byId = state.clips.find((c) => c.id === target);
|
|
52
|
+
if (byId)
|
|
53
|
+
return byId;
|
|
54
|
+
const lower = target.toLowerCase();
|
|
55
|
+
const byName = state.clips.find((c) => c.name.toLowerCase() === lower);
|
|
56
|
+
if (byName)
|
|
57
|
+
return byName;
|
|
58
|
+
throw new Error(`No clip found matching "${target}". ${listUnits(state.clips, "clip")}`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Name the units a caller could have meant, capped: a 200-clip sequence
|
|
62
|
+
* listing all of them is one an agent stops reading.
|
|
63
|
+
*/
|
|
64
|
+
function listUnits(units, kind) {
|
|
65
|
+
if (units.length === 0)
|
|
66
|
+
return `The timeline has no ${kind}s yet.`;
|
|
67
|
+
const shown = units
|
|
68
|
+
.slice(0, MAX_LISTED_UNITS)
|
|
69
|
+
.map((u) => `${u.id} ("${u.name}")`)
|
|
70
|
+
.join(", ");
|
|
71
|
+
const rest = units.length - MAX_LISTED_UNITS;
|
|
72
|
+
return rest > 0
|
|
73
|
+
? `Valid ${kind}s: ${shown}, and ${rest} more — call get_state for the full list.`
|
|
74
|
+
: `Valid ${kind}s: ${shown}.`;
|
|
75
|
+
}
|
|
76
|
+
/** Timing and geometry are their own ops; name the op that does the job. */
|
|
77
|
+
const CLIP_PARAM_ELSEWHERE = {
|
|
78
|
+
animations: "animate_clip",
|
|
79
|
+
transition: "set_transition",
|
|
80
|
+
parentId: "set_parent",
|
|
81
|
+
mask: "set_mask",
|
|
82
|
+
effects: "set_effects",
|
|
83
|
+
timeRemap: "set_time_remap"
|
|
84
|
+
};
|
|
85
|
+
const CLIP_PARAM_KEYS = [
|
|
86
|
+
"name",
|
|
87
|
+
"startMs",
|
|
88
|
+
"trackId",
|
|
89
|
+
"durationMs",
|
|
90
|
+
"inPointMs",
|
|
91
|
+
"outPointMs",
|
|
92
|
+
"opacity",
|
|
93
|
+
"transform",
|
|
94
|
+
"speedMultiplier",
|
|
95
|
+
"volumeDb",
|
|
96
|
+
"fadeInMs",
|
|
97
|
+
"fadeOutMs",
|
|
98
|
+
"fadeInShape",
|
|
99
|
+
"fadeOutShape",
|
|
100
|
+
"blendMode",
|
|
101
|
+
"borderRadius",
|
|
102
|
+
"crop",
|
|
103
|
+
"hidden",
|
|
104
|
+
"muted",
|
|
105
|
+
"locked",
|
|
106
|
+
"fontSizePx",
|
|
107
|
+
"textStyle",
|
|
108
|
+
"shapeStyle",
|
|
109
|
+
"captionStyle"
|
|
110
|
+
];
|
|
111
|
+
function capitalize(s) {
|
|
112
|
+
return s.length > 0 ? s[0].toUpperCase() + s.slice(1) : s;
|
|
113
|
+
}
|
|
114
|
+
function mergeClipTransform(current, patch) {
|
|
115
|
+
return {
|
|
116
|
+
position: { x: 0, y: 0, ...current?.position, ...patch.position },
|
|
117
|
+
scale: { x: 1, y: 1, ...current?.scale, ...patch.scale },
|
|
118
|
+
rotation: patch.rotation ?? current?.rotation ?? 0,
|
|
119
|
+
rotationX: patch.rotationX ?? current?.rotationX,
|
|
120
|
+
rotationY: patch.rotationY ?? current?.rotationY,
|
|
121
|
+
perspective: patch.perspective ?? current?.perspective,
|
|
122
|
+
anchor: { x: 0.5, y: 0.5, ...current?.anchor, ...patch.anchor }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* One op's working copy of the document, with the lookups every handler
|
|
127
|
+
* shares. Constructed per call, thrown away when the op returns.
|
|
128
|
+
*/
|
|
129
|
+
class OpScope {
|
|
130
|
+
state;
|
|
131
|
+
ctx;
|
|
132
|
+
changed = new Set();
|
|
133
|
+
constructor(state, ctx) {
|
|
134
|
+
this.state = state;
|
|
135
|
+
this.ctx = ctx;
|
|
136
|
+
}
|
|
137
|
+
touch(...ids) {
|
|
138
|
+
for (const id of ids)
|
|
139
|
+
this.changed.add(id);
|
|
140
|
+
}
|
|
141
|
+
get tracks() {
|
|
142
|
+
return this.state.tracks;
|
|
143
|
+
}
|
|
144
|
+
get clips() {
|
|
145
|
+
return this.state.clips;
|
|
146
|
+
}
|
|
147
|
+
set clips(next) {
|
|
148
|
+
this.state.clips = next;
|
|
149
|
+
}
|
|
150
|
+
get mediaTracks() {
|
|
151
|
+
return this.state.mediaTracks ?? [];
|
|
152
|
+
}
|
|
153
|
+
set mediaTracks(next) {
|
|
154
|
+
this.state.mediaTracks = next;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The ids and names a caller could have used, for the message a failed
|
|
158
|
+
* lookup throws. Capped: a long cut has hundreds of clips and an error
|
|
159
|
+
* listing all of them is one an agent stops reading.
|
|
160
|
+
*/
|
|
161
|
+
validUnits(units, kind) {
|
|
162
|
+
return listUnits(units, kind);
|
|
163
|
+
}
|
|
164
|
+
addTrack(type, name) {
|
|
165
|
+
const index = this.tracks.length;
|
|
166
|
+
const track = makeTrack({
|
|
167
|
+
id: this.ctx.newId("track"),
|
|
168
|
+
type,
|
|
169
|
+
name: name ?? `${capitalize(type)} ${index + 1}`,
|
|
170
|
+
index
|
|
171
|
+
});
|
|
172
|
+
this.tracks.push(track);
|
|
173
|
+
return track;
|
|
174
|
+
}
|
|
175
|
+
findOrCreateTrack(type) {
|
|
176
|
+
return this.tracks.find((t) => t.type === type) ?? this.addTrack(type);
|
|
177
|
+
}
|
|
178
|
+
resolveTrack(idOrName) {
|
|
179
|
+
const byId = this.tracks.find((t) => t.id === idOrName);
|
|
180
|
+
if (byId)
|
|
181
|
+
return byId;
|
|
182
|
+
const lower = idOrName.toLowerCase();
|
|
183
|
+
const byName = this.tracks.find((t) => t.name.toLowerCase() === lower);
|
|
184
|
+
if (byName)
|
|
185
|
+
return byName;
|
|
186
|
+
throw new Error(`No track found matching "${idOrName}". ${this.validUnits(this.tracks, "track")}`);
|
|
187
|
+
}
|
|
188
|
+
trackEndMs(trackId) {
|
|
189
|
+
return this.clips
|
|
190
|
+
.filter((c) => c.trackId === trackId)
|
|
191
|
+
.reduce((m, c) => Math.max(m, c.startMs + c.durationMs), 0);
|
|
192
|
+
}
|
|
193
|
+
resolveClip(target) {
|
|
194
|
+
return resolveClipTarget(this.state, target);
|
|
195
|
+
}
|
|
196
|
+
/** Swap an engine-returned clip into `clips`, keeping the array's order. */
|
|
197
|
+
replaceClip(clip, next) {
|
|
198
|
+
const index = this.clips.findIndex((c) => c.id === clip.id);
|
|
199
|
+
if (index >= 0)
|
|
200
|
+
this.clips[index] = next;
|
|
201
|
+
return next;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The body of `trim_clip`, shared with `set_clip_params`: a caller that
|
|
205
|
+
* sends `durationMs` alongside a style change means the same edit either
|
|
206
|
+
* way, and two copies of the group-trim rule would drift.
|
|
207
|
+
*/
|
|
208
|
+
applyTrim(clip, patch) {
|
|
209
|
+
// A group carries what it holds (D4): shortening one pulls its children
|
|
210
|
+
// inside the window that leaves, rather than leaving them hanging past an
|
|
211
|
+
// edge nothing draws.
|
|
212
|
+
if (isGroupClip(clip) && patch.durationMs !== undefined) {
|
|
213
|
+
this.clips = trimGroup(this.clips, clip.id, "end", patch.durationMs - clip.durationMs);
|
|
214
|
+
const next = this.clips.find((c) => c.id === clip.id);
|
|
215
|
+
this.touch(...this.clips.filter((c) => c.parentId === clip.id).map((c) => c.id));
|
|
216
|
+
this.touch(next.id);
|
|
217
|
+
return next;
|
|
218
|
+
}
|
|
219
|
+
// Through the engine, not a raw duration write: `trimClip` refuses a
|
|
220
|
+
// time-remapped clip (D13) and carries the source out-point with the edge.
|
|
221
|
+
let next = clip;
|
|
222
|
+
if (patch.durationMs !== undefined) {
|
|
223
|
+
if (patch.durationMs <= 0) {
|
|
224
|
+
throw new Error(`durationMs must be greater than 0 (got ${patch.durationMs}); delete the clip instead of trimming it to nothing`);
|
|
225
|
+
}
|
|
226
|
+
next = this.replaceClip(clip, trimClip(clip, "end", patch.durationMs - clip.durationMs));
|
|
227
|
+
}
|
|
228
|
+
if (patch.inPointMs !== undefined)
|
|
229
|
+
next.inPointMs = patch.inPointMs;
|
|
230
|
+
if (patch.outPointMs !== undefined)
|
|
231
|
+
next.outPointMs = patch.outPointMs;
|
|
232
|
+
if (patch.durationMs !== undefined ||
|
|
233
|
+
patch.inPointMs !== undefined ||
|
|
234
|
+
patch.outPointMs !== undefined) {
|
|
235
|
+
this.touch(next.id);
|
|
236
|
+
}
|
|
237
|
+
return next;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Trim the start edge: hold the clip's end and move its start to `startMs`.
|
|
241
|
+
* A group pulls its children with it (D4); anything else goes through the
|
|
242
|
+
* engine so the source in-point follows the edge.
|
|
243
|
+
*/
|
|
244
|
+
applyTrimStart(clip, startMs) {
|
|
245
|
+
const deltaMs = clip.startMs - Math.max(0, startMs);
|
|
246
|
+
if (deltaMs === 0)
|
|
247
|
+
return clip;
|
|
248
|
+
this.touch(clip.id);
|
|
249
|
+
if (isGroupClip(clip)) {
|
|
250
|
+
this.clips = trimGroup(this.clips, clip.id, "start", deltaMs);
|
|
251
|
+
return this.clips.find((c) => c.id === clip.id);
|
|
252
|
+
}
|
|
253
|
+
return this.replaceClip(clip, trimClip(clip, "start", deltaMs));
|
|
254
|
+
}
|
|
255
|
+
/** The body of `move_clip`, shared with `set_clip_params`. */
|
|
256
|
+
applyMove(clip, patch) {
|
|
257
|
+
// Moving a group moves what it holds by the same delta (D4). Children keep
|
|
258
|
+
// their own tracks, so their z-order is untouched (I9) — only the group
|
|
259
|
+
// itself takes a new `trackId`.
|
|
260
|
+
let moved = clip;
|
|
261
|
+
if (isGroupClip(clip) && patch.startMs !== undefined) {
|
|
262
|
+
const nextStartMs = Math.max(0, patch.startMs);
|
|
263
|
+
this.clips = moveGroup(this.clips, clip.id, nextStartMs - clip.startMs);
|
|
264
|
+
moved = this.clips.find((c) => c.id === clip.id);
|
|
265
|
+
this.touch(...this.clips.filter((c) => c.parentId === clip.id).map((c) => c.id));
|
|
266
|
+
}
|
|
267
|
+
else if (patch.startMs !== undefined) {
|
|
268
|
+
clip.startMs = Math.max(0, patch.startMs);
|
|
269
|
+
}
|
|
270
|
+
if (patch.trackId !== undefined) {
|
|
271
|
+
moved.trackId = this.resolveTrack(patch.trackId).id;
|
|
272
|
+
}
|
|
273
|
+
if (patch.startMs !== undefined || patch.trackId !== undefined) {
|
|
274
|
+
this.touch(moved.id);
|
|
275
|
+
}
|
|
276
|
+
return moved;
|
|
277
|
+
}
|
|
278
|
+
/** Resolve a marker by id, or by case-insensitive label. */
|
|
279
|
+
resolveMarker(target) {
|
|
280
|
+
const byId = this.state.markers.find((m) => m.id === target);
|
|
281
|
+
if (byId)
|
|
282
|
+
return byId;
|
|
283
|
+
const lower = target.toLowerCase();
|
|
284
|
+
const byLabel = this.state.markers.find((m) => m.label.toLowerCase() === lower);
|
|
285
|
+
if (byLabel)
|
|
286
|
+
return byLabel;
|
|
287
|
+
const known = this.state.markers
|
|
288
|
+
.map((m) => `${m.id} ("${m.label}") at ${m.timeMs}ms`)
|
|
289
|
+
.join(", ");
|
|
290
|
+
throw new Error(`No marker matches "${target}". Use a marker id or its label. ` +
|
|
291
|
+
(known.length > 0
|
|
292
|
+
? `Markers: ${known}.`
|
|
293
|
+
: "This sequence has no markers yet."));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Resolve the clips one beat op addresses: the named ones, or every clip.
|
|
297
|
+
* A target that matches nothing comes back as a miss rather than throwing —
|
|
298
|
+
* a batch op that dies on one bad name hides what the other targets did.
|
|
299
|
+
*/
|
|
300
|
+
resolveSnapTargets(targets) {
|
|
301
|
+
if (!targets || targets.length === 0) {
|
|
302
|
+
return { clips: [...this.clips], missing: [] };
|
|
303
|
+
}
|
|
304
|
+
const resolved = [];
|
|
305
|
+
const missing = [];
|
|
306
|
+
for (const target of targets) {
|
|
307
|
+
try {
|
|
308
|
+
const clip = this.resolveClip(target);
|
|
309
|
+
if (!resolved.includes(clip))
|
|
310
|
+
resolved.push(clip);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
// Recorded as a skip in the op's own report, with the reason.
|
|
314
|
+
missing.push(target);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return { clips: resolved, missing };
|
|
318
|
+
}
|
|
319
|
+
clipOut(clip) {
|
|
320
|
+
return serializeClip(this.state, clip);
|
|
321
|
+
}
|
|
322
|
+
trackOut(track) {
|
|
323
|
+
return serializeTrack(this.state, track);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function rejectUnknownClipParams(patch) {
|
|
327
|
+
for (const key of Object.keys(patch)) {
|
|
328
|
+
if (CLIP_PARAM_KEYS.includes(key))
|
|
329
|
+
continue;
|
|
330
|
+
const elsewhere = CLIP_PARAM_ELSEWHERE[key];
|
|
331
|
+
if (elsewhere) {
|
|
332
|
+
throw new Error(`set_clip_params does not change \`${key}\`; use ${elsewhere}.`);
|
|
333
|
+
}
|
|
334
|
+
throw new Error(`set_clip_params has no \`${key}\` param. It takes: ${CLIP_PARAM_KEYS.join(", ")}.`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Lift a nested `custom: {curves|code|mask}` onto the animation itself. The
|
|
339
|
+
* flat form is the contract, but the nested one is the obvious guess from
|
|
340
|
+
* `preset: "custom"`, and it used to be stripped and then rejected as an
|
|
341
|
+
* animation with neither curves nor code.
|
|
342
|
+
*/
|
|
343
|
+
function liftCustom(input) {
|
|
344
|
+
if (!input.custom)
|
|
345
|
+
return input;
|
|
346
|
+
const { custom, ...rest } = input;
|
|
347
|
+
return {
|
|
348
|
+
...rest,
|
|
349
|
+
curves: input.curves ?? custom.curves,
|
|
350
|
+
code: input.code ?? custom.code,
|
|
351
|
+
mask: input.mask ?? custom.mask
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Units a staggered animation splits into — a text clip's word count, which is
|
|
356
|
+
* what a custom body reads off `inputs.staggerCount`. Zero when the clip does
|
|
357
|
+
* not stagger, matching the un-staggered block case.
|
|
358
|
+
*/
|
|
359
|
+
function staggerUnitCount(clip, stagger) {
|
|
360
|
+
if (!stagger || clip.mediaType !== "text")
|
|
361
|
+
return 0;
|
|
362
|
+
const text = clip.textStyle?.text ?? "";
|
|
363
|
+
return text
|
|
364
|
+
.trim()
|
|
365
|
+
.split(/\s+/)
|
|
366
|
+
.filter((word) => word.length > 0).length;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Build one `preset: "custom"` animation. `curves` are checked and stored;
|
|
370
|
+
* `code` is baked into curves first, by the host that supplied a baker. Both
|
|
371
|
+
* paths end at `normalizeCustomCurves`, the single gate the compiler and the
|
|
372
|
+
* validator also run, so what is stored is what will render.
|
|
373
|
+
*/
|
|
374
|
+
async function buildCustomAnimation(scope, clip, input) {
|
|
375
|
+
const code = typeof input.code === "string" ? input.code.trim() : "";
|
|
376
|
+
const hasCurves = input.curves !== undefined;
|
|
377
|
+
const hasCode = code !== "";
|
|
378
|
+
if (hasCurves && hasCode) {
|
|
379
|
+
throw new Error('A "custom" animation takes exactly one of `curves` and `code`; both were given. Pass the keyframes, or the body that produces them.');
|
|
380
|
+
}
|
|
381
|
+
if (!hasCurves && !hasCode) {
|
|
382
|
+
throw new Error('A "custom" animation needs `curves` or `code`. Accepted shape: ' +
|
|
383
|
+
'{role: "in", preset: "custom", curves: [{property: "offsetY", keyframes: [{t: 0, value: 160}, {t: 1, value: 0}]}]}' +
|
|
384
|
+
" — `t` runs 0..1 over the window. `code` is a JS body baked into curves instead. Either may also be nested under `custom`.");
|
|
385
|
+
}
|
|
386
|
+
// Curves are normalized to 0..1 over the window, so a custom animation with
|
|
387
|
+
// no duration of its own spans the clip and nothing is cropped.
|
|
388
|
+
const durationMs = input.durationMs ?? clip.durationMs;
|
|
389
|
+
let curves;
|
|
390
|
+
let maskInput;
|
|
391
|
+
if (hasCurves) {
|
|
392
|
+
const normalized = normalizeCustomCurves(input.curves);
|
|
393
|
+
if (!normalized.ok)
|
|
394
|
+
throw new Error(normalized.error);
|
|
395
|
+
curves = normalized.curves;
|
|
396
|
+
maskInput = input.mask;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
const bake = scope.ctx.bakeAnimation;
|
|
400
|
+
if (!bake) {
|
|
401
|
+
throw new Error("This surface cannot run `code`: no animation baker is wired to it. Pass `curves` instead, or bake the body through POST /api/timelines/animations/bake.");
|
|
402
|
+
}
|
|
403
|
+
const baked = await bake({
|
|
404
|
+
code,
|
|
405
|
+
role: input.role,
|
|
406
|
+
durationMs,
|
|
407
|
+
clipDurationMs: clip.durationMs,
|
|
408
|
+
canvas: { width: scope.state.width, height: scope.state.height },
|
|
409
|
+
params: input.params,
|
|
410
|
+
staggerCount: staggerUnitCount(clip, input.stagger)
|
|
411
|
+
});
|
|
412
|
+
if (!baked.ok || !baked.curves) {
|
|
413
|
+
throw new Error(baked.error ?? "The animation body returned no curves.");
|
|
414
|
+
}
|
|
415
|
+
const normalized = normalizeCustomCurves(baked.curves);
|
|
416
|
+
if (!normalized.ok)
|
|
417
|
+
throw new Error(normalized.error);
|
|
418
|
+
curves = normalized.curves;
|
|
419
|
+
maskInput = baked.mask ?? input.mask;
|
|
420
|
+
}
|
|
421
|
+
const mask = resolveCustomMask(curves, maskInput);
|
|
422
|
+
if (!mask.ok)
|
|
423
|
+
throw new Error(mask.error);
|
|
424
|
+
const custom = {
|
|
425
|
+
curves,
|
|
426
|
+
bakedAt: (scope.ctx.now ?? (() => new Date().toISOString()))()
|
|
427
|
+
};
|
|
428
|
+
if (hasCode)
|
|
429
|
+
custom.code = code;
|
|
430
|
+
if (mask.mask)
|
|
431
|
+
custom.mask = mask.mask;
|
|
432
|
+
return {
|
|
433
|
+
id: scope.ctx.newId("anim"),
|
|
434
|
+
role: input.role,
|
|
435
|
+
preset: CUSTOM_ANIMATION_PRESET_ID,
|
|
436
|
+
durationMs,
|
|
437
|
+
delayMs: input.delayMs,
|
|
438
|
+
easing: input.easing,
|
|
439
|
+
params: input.params,
|
|
440
|
+
stagger: input.stagger,
|
|
441
|
+
custom
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
/** Dispatch one op against `scope`. Throws on refusal; the caller maps it. */
|
|
445
|
+
async function runOp(scope, op) {
|
|
446
|
+
const state = scope.state;
|
|
447
|
+
switch (op.op) {
|
|
448
|
+
case "get_state": {
|
|
449
|
+
const durationMs = scope.clips.reduce((m, c) => Math.max(m, c.startMs + c.durationMs), 0);
|
|
450
|
+
return {
|
|
451
|
+
ok: true,
|
|
452
|
+
fps: state.fps,
|
|
453
|
+
width: state.width,
|
|
454
|
+
height: state.height,
|
|
455
|
+
durationMs,
|
|
456
|
+
playheadMs: state.playheadMs,
|
|
457
|
+
selectedClipIds: [...state.selectedClipIds],
|
|
458
|
+
tracks: scope.tracks.map((t) => scope.trackOut(t)),
|
|
459
|
+
clips: scope.clips.map((c) => scope.clipOut(c)),
|
|
460
|
+
mediaTracks: scope.mediaTracks.map(serializeMediaTrack),
|
|
461
|
+
markers: state.markers.map((m) => ({ ...m }))
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
case "add_track": {
|
|
465
|
+
const track = scope.addTrack(op.type, op.name);
|
|
466
|
+
return { ok: true, track: scope.trackOut(track) };
|
|
467
|
+
}
|
|
468
|
+
case "move_track": {
|
|
469
|
+
const { target, toIndex, before, after } = resolveMoveTrackArgs(op);
|
|
470
|
+
const track = scope.resolveTrack(target);
|
|
471
|
+
const destination = {};
|
|
472
|
+
if (toIndex !== undefined)
|
|
473
|
+
destination.toIndex = toIndex;
|
|
474
|
+
if (before !== undefined)
|
|
475
|
+
destination.beforeId = scope.resolveTrack(before).id;
|
|
476
|
+
if (after !== undefined)
|
|
477
|
+
destination.afterId = scope.resolveTrack(after).id;
|
|
478
|
+
const orderedIds = moveTrackOrder(scope.tracks, track.id, destination);
|
|
479
|
+
const byId = new Map(scope.tracks.map((t) => [t.id, t]));
|
|
480
|
+
// The array order is what `get_state` prints, so keep it and the indices
|
|
481
|
+
// saying the same thing.
|
|
482
|
+
scope.tracks.length = 0;
|
|
483
|
+
orderedIds.forEach((id, i) => {
|
|
484
|
+
const moved = byId.get(id);
|
|
485
|
+
moved.index = i;
|
|
486
|
+
scope.tracks.push(moved);
|
|
487
|
+
});
|
|
488
|
+
return {
|
|
489
|
+
ok: true,
|
|
490
|
+
track: scope.trackOut(track),
|
|
491
|
+
tracks: scope.tracks.map((t) => scope.trackOut(t))
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
case "delete_track": {
|
|
495
|
+
const { target, deleteClips } = resolveDeleteTrackArgs(op);
|
|
496
|
+
const track = scope.resolveTrack(target);
|
|
497
|
+
const onIt = scope.clips.filter((c) => c.trackId === track.id);
|
|
498
|
+
if (onIt.length > 0 && !deleteClips) {
|
|
499
|
+
throw new Error(`Track "${track.name}" still holds ${onIt.length} clip(s): ` +
|
|
500
|
+
`${onIt.map((c) => c.id).join(", ")}. Move them first, or pass ` +
|
|
501
|
+
"deleteClips: true to delete them with the track.");
|
|
502
|
+
}
|
|
503
|
+
const removedClipIds = onIt.map((c) => c.id);
|
|
504
|
+
const kept = scope.clips.filter((c) => c.trackId !== track.id);
|
|
505
|
+
scope.clips.length = 0;
|
|
506
|
+
scope.clips.push(...kept);
|
|
507
|
+
// A parent that went with the track would leave its children pointing at
|
|
508
|
+
// a clip that no longer exists, which the validator reads as a broken
|
|
509
|
+
// document rather than a deletion.
|
|
510
|
+
for (const clip of scope.clips) {
|
|
511
|
+
if (clip.parentId && removedClipIds.includes(clip.parentId)) {
|
|
512
|
+
delete clip.parentId;
|
|
513
|
+
scope.touch(clip.id);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
scope.touch(...removedClipIds);
|
|
517
|
+
state.selectedClipIds = state.selectedClipIds.filter((id) => !removedClipIds.includes(id));
|
|
518
|
+
const remaining = scope.tracks.filter((t) => t.id !== track.id);
|
|
519
|
+
scope.tracks.length = 0;
|
|
520
|
+
// Index is z-order, so the stack has to close over the gap.
|
|
521
|
+
remaining.forEach((t, i) => {
|
|
522
|
+
t.index = i;
|
|
523
|
+
scope.tracks.push(t);
|
|
524
|
+
});
|
|
525
|
+
return {
|
|
526
|
+
ok: true,
|
|
527
|
+
deleted: { id: track.id, name: track.name, type: track.type },
|
|
528
|
+
deletedClipIds: removedClipIds,
|
|
529
|
+
tracks: scope.tracks.map((t) => scope.trackOut(t))
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
case "add_text_clip": {
|
|
533
|
+
const track = op.trackId
|
|
534
|
+
? scope.resolveTrack(op.trackId)
|
|
535
|
+
: scope.findOrCreateTrack("overlay");
|
|
536
|
+
// `style` wins over a top-level twin: a caller that sent both meant the
|
|
537
|
+
// bag it named.
|
|
538
|
+
const s = { ...(op.loose ?? {}), ...(op.style ?? {}) };
|
|
539
|
+
const clip = makeClip({
|
|
540
|
+
id: scope.ctx.newId("clip"),
|
|
541
|
+
trackId: track.id,
|
|
542
|
+
name: op.name ?? op.text,
|
|
543
|
+
startMs: op.startMs ?? scope.trackEndMs(track.id),
|
|
544
|
+
durationMs: op.durationMs ?? DEFAULT_TEXT_CLIP_DURATION_MS,
|
|
545
|
+
mediaType: "text",
|
|
546
|
+
sourceType: "imported",
|
|
547
|
+
status: "generated",
|
|
548
|
+
textStyle: textStyleWithDefaults(op.text, s)
|
|
549
|
+
});
|
|
550
|
+
if (op.opacity !== undefined)
|
|
551
|
+
clip.opacity = op.opacity;
|
|
552
|
+
if (op.transform)
|
|
553
|
+
clip.transform = mergeClipTransform(clip.transform, op.transform);
|
|
554
|
+
scope.clips.push(clip);
|
|
555
|
+
state.selectedClipIds = [clip.id];
|
|
556
|
+
scope.touch(clip.id);
|
|
557
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
558
|
+
}
|
|
559
|
+
case "add_media_clip": {
|
|
560
|
+
const resolveAsset = scope.ctx.resolveAsset;
|
|
561
|
+
if (!resolveAsset) {
|
|
562
|
+
throw new Error("This timeline surface cannot look up assets, so an existing asset cannot be placed here.");
|
|
563
|
+
}
|
|
564
|
+
const found = await resolveAsset(op.asset);
|
|
565
|
+
if (!found) {
|
|
566
|
+
throw new Error(`No asset found for "${op.asset}". Pass an asset id or an asset:// URI from list_assets.`);
|
|
567
|
+
}
|
|
568
|
+
const mediaType = mediaTypeForContentType(found.contentType);
|
|
569
|
+
if (!mediaType) {
|
|
570
|
+
throw new Error(`Asset "${found.name}" is ${found.contentType}, which is not video, image, or audio and cannot go on a timeline.`);
|
|
571
|
+
}
|
|
572
|
+
if (mediaType !== "image" &&
|
|
573
|
+
op.durationMs === undefined &&
|
|
574
|
+
!found.durationMs) {
|
|
575
|
+
throw new Error(`Asset "${found.name}" has no known duration. Supply durationMs or import media that can be probed.`);
|
|
576
|
+
}
|
|
577
|
+
const track = op.trackId
|
|
578
|
+
? scope.resolveTrack(op.trackId)
|
|
579
|
+
: scope.findOrCreateTrack(trackTypeForMediaType(mediaType));
|
|
580
|
+
const init = {
|
|
581
|
+
id: scope.ctx.newId("clip"),
|
|
582
|
+
trackId: track.id,
|
|
583
|
+
name: op.name ?? found.name,
|
|
584
|
+
startMs: op.startMs ?? scope.trackEndMs(track.id),
|
|
585
|
+
durationMs: op.durationMs ?? found.durationMs ?? DEFAULT_MEDIA_CLIP_DURATION_MS,
|
|
586
|
+
mediaType,
|
|
587
|
+
sourceType: "imported",
|
|
588
|
+
status: "generated",
|
|
589
|
+
currentAssetId: found.id
|
|
590
|
+
};
|
|
591
|
+
if (found.thumbnailAssetId)
|
|
592
|
+
init.thumbnailAssetId = found.thumbnailAssetId;
|
|
593
|
+
const clip = makeClip(init);
|
|
594
|
+
if (op.transform)
|
|
595
|
+
clip.transform = mergeClipTransform(clip.transform, op.transform);
|
|
596
|
+
scope.clips.push(clip);
|
|
597
|
+
state.selectedClipIds = [clip.id];
|
|
598
|
+
scope.touch(clip.id);
|
|
599
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
600
|
+
}
|
|
601
|
+
case "add_shape_clip": {
|
|
602
|
+
const track = op.trackId
|
|
603
|
+
? scope.resolveTrack(op.trackId)
|
|
604
|
+
: scope.findOrCreateTrack("overlay");
|
|
605
|
+
const shapeArg = resolveShapeArg(op.shape, op.shapeStyle, op.loose ?? {});
|
|
606
|
+
const clip = makeClip({
|
|
607
|
+
id: scope.ctx.newId("clip"),
|
|
608
|
+
trackId: track.id,
|
|
609
|
+
name: op.name ?? capitalize(shapeArg.kind),
|
|
610
|
+
startMs: op.startMs ?? scope.trackEndMs(track.id),
|
|
611
|
+
durationMs: op.durationMs ?? DEFAULT_TEXT_CLIP_DURATION_MS,
|
|
612
|
+
mediaType: "shape",
|
|
613
|
+
sourceType: "imported",
|
|
614
|
+
status: "generated",
|
|
615
|
+
shapeStyle: shapeStyleWithDefaults(shapeArg)
|
|
616
|
+
});
|
|
617
|
+
if (op.opacity !== undefined)
|
|
618
|
+
clip.opacity = op.opacity;
|
|
619
|
+
if (op.transform)
|
|
620
|
+
clip.transform = mergeClipTransform(clip.transform, op.transform);
|
|
621
|
+
scope.clips.push(clip);
|
|
622
|
+
state.selectedClipIds = [clip.id];
|
|
623
|
+
scope.touch(clip.id);
|
|
624
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
625
|
+
}
|
|
626
|
+
case "add_model3d_clip": {
|
|
627
|
+
const assetId = op.assetId.trim();
|
|
628
|
+
if (!assetId) {
|
|
629
|
+
throw new Error("add_model3d_clip needs the glTF's asset id — a 3D clip draws its " +
|
|
630
|
+
"asset the way an image clip draws its image. list_assets prints " +
|
|
631
|
+
"the ids.");
|
|
632
|
+
}
|
|
633
|
+
// 3D is picture (D1), so it lands where a title lands: the first overlay
|
|
634
|
+
// track, or one made for it.
|
|
635
|
+
const track = op.trackId
|
|
636
|
+
? scope.resolveTrack(op.trackId)
|
|
637
|
+
: scope.findOrCreateTrack("overlay");
|
|
638
|
+
const clip = makeClip({
|
|
639
|
+
id: scope.ctx.newId("clip"),
|
|
640
|
+
trackId: track.id,
|
|
641
|
+
name: DEFAULT_MODEL3D_CLIP_NAME,
|
|
642
|
+
startMs: op.startMs ?? scope.trackEndMs(track.id),
|
|
643
|
+
durationMs: op.durationMs ?? DEFAULT_MODEL3D_CLIP_DURATION_MS,
|
|
644
|
+
mediaType: "model3d",
|
|
645
|
+
sourceType: "imported",
|
|
646
|
+
status: "generated",
|
|
647
|
+
currentAssetId: assetId,
|
|
648
|
+
model3dStyle: model3dStyleWithPatch(undefined, op.style)
|
|
649
|
+
});
|
|
650
|
+
if (op.transform)
|
|
651
|
+
clip.transform = mergeClipTransform(clip.transform, op.transform);
|
|
652
|
+
scope.clips.push(clip);
|
|
653
|
+
state.selectedClipIds = [clip.id];
|
|
654
|
+
scope.touch(clip.id);
|
|
655
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
656
|
+
}
|
|
657
|
+
case "set_model3d_style": {
|
|
658
|
+
const clip = scope.resolveClip(op.target);
|
|
659
|
+
if (clip.mediaType !== "model3d") {
|
|
660
|
+
throw new Error(`Clip "${clip.name}" is a ${clip.mediaType} clip, not a 3D clip — ` +
|
|
661
|
+
"model3dStyle names a camera, an animation and lighting for a " +
|
|
662
|
+
"glTF, and nothing else reads it.");
|
|
663
|
+
}
|
|
664
|
+
clip.model3dStyle = model3dStyleWithPatch(clip.model3dStyle, op.patch);
|
|
665
|
+
scope.touch(clip.id);
|
|
666
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
667
|
+
}
|
|
668
|
+
case "bake_model3d_clip": {
|
|
669
|
+
const clip = scope.resolveClip(op.target);
|
|
670
|
+
if (clip.mediaType !== "model3d") {
|
|
671
|
+
throw new Error(`Clip "${clip.name}" is a ${clip.mediaType} clip, not a 3D clip — ` +
|
|
672
|
+
"only a 3D clip has a camera, lighting and a glTF to render.");
|
|
673
|
+
}
|
|
674
|
+
const style = clip.model3dStyle;
|
|
675
|
+
if (!style) {
|
|
676
|
+
throw new Error(`Clip "${clip.name}" has no model3dStyle, so nothing names the ` +
|
|
677
|
+
"camera, lighting or animation a bake would render.");
|
|
678
|
+
}
|
|
679
|
+
if (!clip.currentAssetId) {
|
|
680
|
+
throw new Error(`Clip "${clip.name}" has no glTF asset to bake — a 3D clip draws ` +
|
|
681
|
+
"its asset the way an image clip draws its image.");
|
|
682
|
+
}
|
|
683
|
+
const sequence = {
|
|
684
|
+
fps: state.fps,
|
|
685
|
+
width: state.width,
|
|
686
|
+
height: state.height
|
|
687
|
+
};
|
|
688
|
+
const dependencyHash = computeModel3DBakeHash(clip, sequence);
|
|
689
|
+
if (!scope.ctx.bakeModel3DClip) {
|
|
690
|
+
return {
|
|
691
|
+
ok: true,
|
|
692
|
+
clip: scope.clipOut(clip),
|
|
693
|
+
bakeStarted: false,
|
|
694
|
+
note: "This surface has no Blender renderer, so nothing was baked."
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
const baked = await scope.ctx.bakeModel3DClip({
|
|
698
|
+
clip,
|
|
699
|
+
sequence,
|
|
700
|
+
dependencyHash
|
|
701
|
+
});
|
|
702
|
+
const now = (scope.ctx.now ?? (() => new Date().toISOString()))();
|
|
703
|
+
clip.model3dStyle = {
|
|
704
|
+
...style,
|
|
705
|
+
bake: { assetId: baked.assetId, dependencyHash }
|
|
706
|
+
};
|
|
707
|
+
// The bake joins the clip's own version history, so an earlier one can
|
|
708
|
+
// be restored the way an earlier generation can.
|
|
709
|
+
clip.versions = [
|
|
710
|
+
...(clip.versions ?? []),
|
|
711
|
+
makeClipVersion({
|
|
712
|
+
id: scope.ctx.newId("version"),
|
|
713
|
+
createdAt: now,
|
|
714
|
+
workflowUpdatedAt: now,
|
|
715
|
+
jobId: baked.jobId ?? "",
|
|
716
|
+
assetId: baked.assetId,
|
|
717
|
+
dependencyHash
|
|
718
|
+
})
|
|
719
|
+
];
|
|
720
|
+
scope.touch(clip.id);
|
|
721
|
+
return { ok: true, clip: scope.clipOut(clip), bakeStarted: true };
|
|
722
|
+
}
|
|
723
|
+
case "add_group": {
|
|
724
|
+
// Resolve every child before anything is written: a half-applied group
|
|
725
|
+
// leaves the caller with an empty group and no idea which of its clips
|
|
726
|
+
// moved.
|
|
727
|
+
const targets = (op.children ?? []).map((ref) => scope.resolveClip(ref));
|
|
728
|
+
const track = op.trackId
|
|
729
|
+
? scope.resolveTrack(op.trackId)
|
|
730
|
+
: scope.findOrCreateTrack("overlay");
|
|
731
|
+
const group = makeClip({
|
|
732
|
+
id: scope.ctx.newId("clip"),
|
|
733
|
+
trackId: track.id,
|
|
734
|
+
name: op.name,
|
|
735
|
+
startMs: op.startMs,
|
|
736
|
+
durationMs: op.durationMs,
|
|
737
|
+
mediaType: "group",
|
|
738
|
+
sourceType: "imported",
|
|
739
|
+
status: "generated"
|
|
740
|
+
});
|
|
741
|
+
if (op.transform)
|
|
742
|
+
group.transform = mergeClipTransform(group.transform, op.transform);
|
|
743
|
+
scope.clips.push(group);
|
|
744
|
+
for (const child of targets) {
|
|
745
|
+
child.parentId = group.id;
|
|
746
|
+
scope.touch(child.id);
|
|
747
|
+
}
|
|
748
|
+
state.selectedClipIds = [group.id];
|
|
749
|
+
scope.touch(group.id);
|
|
750
|
+
return {
|
|
751
|
+
ok: true,
|
|
752
|
+
clip: scope.clipOut(group),
|
|
753
|
+
children: targets.map((c) => c.id)
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
case "generate_clip": {
|
|
757
|
+
const mediaType = op.kind === "text-to-video"
|
|
758
|
+
? "video"
|
|
759
|
+
: op.kind === "text-to-image"
|
|
760
|
+
? "image"
|
|
761
|
+
: "audio";
|
|
762
|
+
const track = op.trackId
|
|
763
|
+
? scope.resolveTrack(op.trackId)
|
|
764
|
+
: op.kind === "text-to-audio"
|
|
765
|
+
? scope.findOrCreateTrack("audio")
|
|
766
|
+
: op.kind === "text-to-video"
|
|
767
|
+
? scope.findOrCreateTrack("video")
|
|
768
|
+
: (scope.tracks.find((t) => t.type === "video" || t.type === "overlay") ?? scope.findOrCreateTrack("video"));
|
|
769
|
+
const generationStarted = op.autoGenerate !== false;
|
|
770
|
+
const clip = makeClip({
|
|
771
|
+
id: scope.ctx.newId("clip"),
|
|
772
|
+
trackId: track.id,
|
|
773
|
+
name: op.prompt,
|
|
774
|
+
startMs: op.startMs ?? scope.trackEndMs(track.id),
|
|
775
|
+
durationMs: op.durationMs ?? (op.kind === "text-to-audio" ? 3000 : 5000),
|
|
776
|
+
mediaType,
|
|
777
|
+
sourceType: "generated",
|
|
778
|
+
bindingKind: op.kind,
|
|
779
|
+
status: generationStarted ? "generating" : "draft",
|
|
780
|
+
prompt: op.prompt,
|
|
781
|
+
provider: op.provider,
|
|
782
|
+
model: op.model,
|
|
783
|
+
voice: op.voice,
|
|
784
|
+
width: op.width,
|
|
785
|
+
height: op.height,
|
|
786
|
+
aspectRatio: op.aspectRatio,
|
|
787
|
+
resolution: op.resolution
|
|
788
|
+
});
|
|
789
|
+
scope.clips.push(clip);
|
|
790
|
+
state.selectedClipIds = [clip.id];
|
|
791
|
+
scope.touch(clip.id);
|
|
792
|
+
const result = { ok: true, clip: scope.clipOut(clip), generationStarted };
|
|
793
|
+
if (!generationStarted) {
|
|
794
|
+
result.note = "Generation not started (autoGenerate=false).";
|
|
795
|
+
}
|
|
796
|
+
return result;
|
|
797
|
+
}
|
|
798
|
+
case "split_clip": {
|
|
799
|
+
const clip = scope.resolveClip(op.target);
|
|
800
|
+
const at = op.atMs ?? state.playheadMs;
|
|
801
|
+
const [left, right] = splitClip(clip, at);
|
|
802
|
+
left.id = scope.ctx.newId("clip");
|
|
803
|
+
right.id = scope.ctx.newId("clip");
|
|
804
|
+
const idx = scope.clips.findIndex((c) => c.id === clip.id);
|
|
805
|
+
scope.clips.splice(idx, 1, left, right);
|
|
806
|
+
state.selectedClipIds = state.selectedClipIds.filter((id) => id !== clip.id);
|
|
807
|
+
scope.touch(clip.id, left.id, right.id);
|
|
808
|
+
scope.mediaTracks = resliceTracksForSplitClip(scope.mediaTracks, clip.id, left, right, () => scope.ctx.newId("track"));
|
|
809
|
+
return { ok: true, clips: [scope.clipOut(left), scope.clipOut(right)] };
|
|
810
|
+
}
|
|
811
|
+
case "trim_clip": {
|
|
812
|
+
const trimmed = scope.applyTrim(scope.resolveClip(op.target), {
|
|
813
|
+
durationMs: op.durationMs,
|
|
814
|
+
inPointMs: op.inPointMs,
|
|
815
|
+
outPointMs: op.outPointMs
|
|
816
|
+
});
|
|
817
|
+
scope.mediaTracks = resliceTracksForTrimmedClip(scope.mediaTracks, trimmed);
|
|
818
|
+
return { ok: true, clip: scope.clipOut(trimmed) };
|
|
819
|
+
}
|
|
820
|
+
case "move_clip": {
|
|
821
|
+
const moved = scope.applyMove(scope.resolveClip(op.target), {
|
|
822
|
+
startMs: op.startMs,
|
|
823
|
+
trackId: op.trackId
|
|
824
|
+
});
|
|
825
|
+
return { ok: true, clip: scope.clipOut(moved) };
|
|
826
|
+
}
|
|
827
|
+
case "delete_clip": {
|
|
828
|
+
const clip = scope.resolveClip(op.target);
|
|
829
|
+
// Deleting a group deletes the parent, not the picture: its children stay
|
|
830
|
+
// where they are and stop inheriting (D4). Leaving them with a `parentId`
|
|
831
|
+
// nothing answers is what the validator calls a dangling parent.
|
|
832
|
+
const wasChild = scope.clips
|
|
833
|
+
.filter((c) => c.parentId === clip.id)
|
|
834
|
+
.map((c) => c.id);
|
|
835
|
+
const remaining = isGroupClip(clip)
|
|
836
|
+
? ungroup(scope.clips, clip.id)
|
|
837
|
+
: scope.clips;
|
|
838
|
+
const out = scope.clipOut(clip);
|
|
839
|
+
scope.clips = remaining.filter((c) => c.id !== clip.id);
|
|
840
|
+
state.selectedClipIds = state.selectedClipIds.filter((id) => id !== clip.id);
|
|
841
|
+
scope.touch(clip.id, ...wasChild);
|
|
842
|
+
return { ok: true, deleted: out };
|
|
843
|
+
}
|
|
844
|
+
case "duplicate_clip": {
|
|
845
|
+
const src = scope.resolveClip(op.target);
|
|
846
|
+
const copy = {
|
|
847
|
+
...src,
|
|
848
|
+
id: scope.ctx.newId("clip"),
|
|
849
|
+
startMs: src.startMs + src.durationMs + (op.gapMs ?? 0),
|
|
850
|
+
versions: [],
|
|
851
|
+
animations: src.animations?.map((a) => ({
|
|
852
|
+
...a,
|
|
853
|
+
id: scope.ctx.newId("anim")
|
|
854
|
+
}))
|
|
855
|
+
};
|
|
856
|
+
scope.clips.push(copy);
|
|
857
|
+
state.selectedClipIds = [copy.id];
|
|
858
|
+
scope.touch(copy.id);
|
|
859
|
+
return { ok: true, clip: scope.clipOut(copy) };
|
|
860
|
+
}
|
|
861
|
+
case "set_clip_params": {
|
|
862
|
+
let clip = scope.resolveClip(op.target);
|
|
863
|
+
const patch = { ...op.patch };
|
|
864
|
+
rejectUnknownClipParams(patch);
|
|
865
|
+
// Timing belongs to move_clip and trim_clip, but a caller sending it here
|
|
866
|
+
// means one edit either way — so apply it through the same code rather
|
|
867
|
+
// than dropping it or making them call twice.
|
|
868
|
+
clip = scope.applyTrim(clip, {
|
|
869
|
+
durationMs: patch.durationMs,
|
|
870
|
+
inPointMs: patch.inPointMs,
|
|
871
|
+
outPointMs: patch.outPointMs
|
|
872
|
+
});
|
|
873
|
+
clip = scope.applyMove(clip, {
|
|
874
|
+
startMs: patch.startMs,
|
|
875
|
+
trackId: patch.trackId
|
|
876
|
+
});
|
|
877
|
+
if (patch.fontSizePx !== undefined) {
|
|
878
|
+
// Shorthand for the one text field callers reach for by name.
|
|
879
|
+
const style = patch.textStyle ?? clip.textStyle;
|
|
880
|
+
if (!style) {
|
|
881
|
+
throw new Error(`Clip "${clip.name}" carries no text to size; fontSizePx applies to a text clip's textStyle.`);
|
|
882
|
+
}
|
|
883
|
+
patch.textStyle = { ...style, fontSizePx: patch.fontSizePx };
|
|
884
|
+
}
|
|
885
|
+
if (patch.name !== undefined)
|
|
886
|
+
clip.name = patch.name;
|
|
887
|
+
if (patch.opacity !== undefined)
|
|
888
|
+
clip.opacity = patch.opacity;
|
|
889
|
+
if (patch.transform !== undefined) {
|
|
890
|
+
clip.transform = mergeClipTransform(clip.transform, patch.transform);
|
|
891
|
+
}
|
|
892
|
+
if (patch.speedMultiplier !== undefined) {
|
|
893
|
+
clip.speedMultiplier = patch.speedMultiplier;
|
|
894
|
+
}
|
|
895
|
+
if (patch.volumeDb !== undefined)
|
|
896
|
+
clip.volumeDb = patch.volumeDb;
|
|
897
|
+
if (patch.fadeInMs !== undefined)
|
|
898
|
+
clip.fadeInMs = patch.fadeInMs;
|
|
899
|
+
if (patch.fadeOutMs !== undefined)
|
|
900
|
+
clip.fadeOutMs = patch.fadeOutMs;
|
|
901
|
+
if (patch.fadeInShape !== undefined)
|
|
902
|
+
clip.fadeInShape = patch.fadeInShape;
|
|
903
|
+
if (patch.fadeOutShape !== undefined) {
|
|
904
|
+
clip.fadeOutShape = patch.fadeOutShape;
|
|
905
|
+
}
|
|
906
|
+
if (patch.blendMode !== undefined) {
|
|
907
|
+
clip.blendMode = patch.blendMode;
|
|
908
|
+
}
|
|
909
|
+
if (patch.borderRadius !== undefined)
|
|
910
|
+
clip.borderRadius = patch.borderRadius;
|
|
911
|
+
if (patch.crop !== undefined) {
|
|
912
|
+
// Null is how a caller puts the whole source back; leaving the field
|
|
913
|
+
// with all-zero insets would store a crop that means nothing.
|
|
914
|
+
if (patch.crop === null) {
|
|
915
|
+
delete clip.crop;
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
if (!isCropUsable(patch.crop)) {
|
|
919
|
+
throw new Error(`Crop on clip "${clip.name}" keeps no picture: left + right and ` +
|
|
920
|
+
"top + bottom must each stay below 1.");
|
|
921
|
+
}
|
|
922
|
+
clip.crop = patch.crop;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (patch.hidden !== undefined)
|
|
926
|
+
clip.hidden = patch.hidden;
|
|
927
|
+
if (patch.muted !== undefined)
|
|
928
|
+
clip.muted = patch.muted;
|
|
929
|
+
if (patch.locked !== undefined)
|
|
930
|
+
clip.locked = patch.locked;
|
|
931
|
+
if (patch.textStyle !== undefined)
|
|
932
|
+
clip.textStyle = patch.textStyle;
|
|
933
|
+
if (patch.shapeStyle !== undefined)
|
|
934
|
+
clip.shapeStyle = patch.shapeStyle;
|
|
935
|
+
if (patch.captionStyle !== undefined) {
|
|
936
|
+
// The style rides on the clip's caption, so a clip with no words to
|
|
937
|
+
// draw has nowhere to put it. Say so rather than storing a look nothing
|
|
938
|
+
// renders.
|
|
939
|
+
if (!clip.caption) {
|
|
940
|
+
throw new Error(`Clip "${clip.name}" carries no caption to style.`);
|
|
941
|
+
}
|
|
942
|
+
clip.caption = { ...clip.caption, style: patch.captionStyle };
|
|
943
|
+
}
|
|
944
|
+
scope.touch(clip.id);
|
|
945
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
946
|
+
}
|
|
947
|
+
case "set_parent": {
|
|
948
|
+
const clip = scope.resolveClip(op.target);
|
|
949
|
+
scope.touch(clip.id);
|
|
950
|
+
if (op.parentId === null) {
|
|
951
|
+
delete clip.parentId;
|
|
952
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
953
|
+
}
|
|
954
|
+
const parent = scope.resolveClip(op.parentId);
|
|
955
|
+
if (parent.mediaType !== "group") {
|
|
956
|
+
throw new Error(`"${parent.name}" is a ${parent.mediaType} clip, not a group — parent to a clip created with add_group. ${scope.validUnits(scope.clips.filter((c) => c.mediaType === "group"), "group")}`);
|
|
957
|
+
}
|
|
958
|
+
// A cycle renders unparented and warns, so refusing it here is the only
|
|
959
|
+
// place it can still be fixed.
|
|
960
|
+
let cursor = parent;
|
|
961
|
+
while (cursor) {
|
|
962
|
+
if (cursor.id === clip.id) {
|
|
963
|
+
throw new Error(`"${parent.name}" is inside "${clip.name}" — parenting them would make a cycle.`);
|
|
964
|
+
}
|
|
965
|
+
const next = cursor.parentId;
|
|
966
|
+
cursor = next ? scope.clips.find((c) => c.id === next) : undefined;
|
|
967
|
+
}
|
|
968
|
+
clip.parentId = parent.id;
|
|
969
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
970
|
+
}
|
|
971
|
+
case "set_transition": {
|
|
972
|
+
const clip = scope.resolveClip(op.target);
|
|
973
|
+
if (op.transition === null) {
|
|
974
|
+
delete clip.transitionIn;
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
clip.transitionIn = buildTransition(op.transition);
|
|
978
|
+
}
|
|
979
|
+
scope.touch(clip.id);
|
|
980
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
981
|
+
}
|
|
982
|
+
case "apply_transition_at_cut": {
|
|
983
|
+
const planned = planTransitionAtCut(scope.clips, op);
|
|
984
|
+
if (!planned.ok)
|
|
985
|
+
throw new Error(planned.error);
|
|
986
|
+
const applied = applyTransitionAtCutCandidate(scope.clips, planned.candidate);
|
|
987
|
+
if (!applied.ok)
|
|
988
|
+
throw new Error(applied.error);
|
|
989
|
+
scope.clips = applied.clips;
|
|
990
|
+
scope.touch(planned.candidate.outgoingClipId, planned.candidate.incomingClipId);
|
|
991
|
+
return {
|
|
992
|
+
ok: true,
|
|
993
|
+
candidate: planned.candidate,
|
|
994
|
+
operation: planned.candidate.operation,
|
|
995
|
+
description: applied.description
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
case "set_mask": {
|
|
999
|
+
const clip = scope.resolveClip(op.target);
|
|
1000
|
+
if (op.mask === null) {
|
|
1001
|
+
delete clip.mask;
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
clip.mask = buildMask(op.mask, scope.ctx.parseSvgPath);
|
|
1005
|
+
}
|
|
1006
|
+
scope.touch(clip.id);
|
|
1007
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1008
|
+
}
|
|
1009
|
+
case "set_matte": {
|
|
1010
|
+
const clip = scope.resolveClip(op.target);
|
|
1011
|
+
scope.touch(clip.id);
|
|
1012
|
+
if (op.matte === null) {
|
|
1013
|
+
delete clip.matte;
|
|
1014
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1015
|
+
}
|
|
1016
|
+
const source = scope.resolveClip(op.matte.source);
|
|
1017
|
+
if (source.id === clip.id) {
|
|
1018
|
+
throw new Error(`"${clip.name}" cannot be its own matte source — name another clip.`);
|
|
1019
|
+
}
|
|
1020
|
+
const matteOut = {
|
|
1021
|
+
sourceClipId: source.id,
|
|
1022
|
+
mode: op.matte.mode
|
|
1023
|
+
};
|
|
1024
|
+
if (op.matte.invert !== undefined)
|
|
1025
|
+
matteOut.invert = op.matte.invert;
|
|
1026
|
+
clip.matte = matteOut;
|
|
1027
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1028
|
+
}
|
|
1029
|
+
case "set_generated_matte": {
|
|
1030
|
+
const clip = scope.resolveClip(op.target);
|
|
1031
|
+
scope.touch(clip.id);
|
|
1032
|
+
if (op.clear === true) {
|
|
1033
|
+
delete clip.generatedMatte;
|
|
1034
|
+
return { ok: true, clip: scope.clipOut(clip), generatedMatte: null };
|
|
1035
|
+
}
|
|
1036
|
+
if (!clip.generatedMatte) {
|
|
1037
|
+
throw new Error(`"${clip.name}" carries no generated matte. Run isolate_subject on ` +
|
|
1038
|
+
"it first; this op only adjusts one that exists.");
|
|
1039
|
+
}
|
|
1040
|
+
if (op.selectVersionAssetId !== undefined) {
|
|
1041
|
+
clip.generatedMatte = selectGeneratedMatteVersion(clip, op.selectVersionAssetId).generatedMatte;
|
|
1042
|
+
}
|
|
1043
|
+
// The knobs are the user's, so an absent field leaves the stored value
|
|
1044
|
+
// alone rather than resetting it to a default the caller did not name.
|
|
1045
|
+
const matte = clip.generatedMatte;
|
|
1046
|
+
if (op.invert !== undefined)
|
|
1047
|
+
matte.invert = op.invert;
|
|
1048
|
+
if (op.strength !== undefined) {
|
|
1049
|
+
matte.strength = Math.min(1, Math.max(0, op.strength));
|
|
1050
|
+
}
|
|
1051
|
+
if (op.featherPx !== undefined) {
|
|
1052
|
+
matte.featherPx = Math.max(0, op.featherPx);
|
|
1053
|
+
}
|
|
1054
|
+
return { ok: true, clip: scope.clipOut(clip), generatedMatte: matte };
|
|
1055
|
+
}
|
|
1056
|
+
case "set_time_remap": {
|
|
1057
|
+
const clip = scope.resolveClip(op.target);
|
|
1058
|
+
if (op.timeRemap === null) {
|
|
1059
|
+
delete clip.timeRemap;
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
clip.timeRemap = buildTimeRemap(op.timeRemap);
|
|
1063
|
+
}
|
|
1064
|
+
scope.touch(clip.id);
|
|
1065
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1066
|
+
}
|
|
1067
|
+
case "set_effects": {
|
|
1068
|
+
const clip = scope.resolveClip(op.target);
|
|
1069
|
+
const list = op.effects.map(buildEffect);
|
|
1070
|
+
if (list.length === 0) {
|
|
1071
|
+
delete clip.effects;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
clip.effects = list;
|
|
1075
|
+
}
|
|
1076
|
+
scope.touch(clip.id);
|
|
1077
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1078
|
+
}
|
|
1079
|
+
case "set_clip_binding": {
|
|
1080
|
+
const clip = scope.resolveClip(op.target);
|
|
1081
|
+
if (clip.sourceType !== "generated") {
|
|
1082
|
+
throw new Error(`"${clip.name}" is not a generated clip — ui_timeline_set_clip_binding only applies to clips created with ui_timeline_generate_clip.`);
|
|
1083
|
+
}
|
|
1084
|
+
if (op.prompt !== undefined)
|
|
1085
|
+
clip.prompt = op.prompt;
|
|
1086
|
+
if (op.negativePrompt !== undefined)
|
|
1087
|
+
clip.negativePrompt = op.negativePrompt;
|
|
1088
|
+
if (op.provider !== undefined)
|
|
1089
|
+
clip.provider = op.provider;
|
|
1090
|
+
if (op.model !== undefined)
|
|
1091
|
+
clip.model = op.model;
|
|
1092
|
+
if (op.voice !== undefined)
|
|
1093
|
+
clip.voice = op.voice;
|
|
1094
|
+
if (op.width !== undefined)
|
|
1095
|
+
clip.width = op.width;
|
|
1096
|
+
if (op.height !== undefined)
|
|
1097
|
+
clip.height = op.height;
|
|
1098
|
+
if (op.aspectRatio !== undefined)
|
|
1099
|
+
clip.aspectRatio = op.aspectRatio;
|
|
1100
|
+
if (op.resolution !== undefined)
|
|
1101
|
+
clip.resolution = op.resolution;
|
|
1102
|
+
if (op.strength !== undefined)
|
|
1103
|
+
clip.strength = op.strength;
|
|
1104
|
+
if (op.numInferenceSteps !== undefined) {
|
|
1105
|
+
clip.numInferenceSteps = op.numInferenceSteps;
|
|
1106
|
+
}
|
|
1107
|
+
if (op.regenerate)
|
|
1108
|
+
clip.status = "queued";
|
|
1109
|
+
scope.touch(clip.id);
|
|
1110
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1111
|
+
}
|
|
1112
|
+
case "animate_clip": {
|
|
1113
|
+
const clip = scope.resolveClip(op.target);
|
|
1114
|
+
const built = [];
|
|
1115
|
+
for (const input of op.animations) {
|
|
1116
|
+
if (input.preset === CUSTOM_ANIMATION_PRESET_ID) {
|
|
1117
|
+
// `{preset: "custom", custom: {curves}}` reads as naturally as the
|
|
1118
|
+
// flat form, so lift it rather than refusing it.
|
|
1119
|
+
built.push(await buildCustomAnimation(scope, clip, liftCustom(input)));
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
const preset = ANIMATION_PRESETS.find((p) => p.id === input.preset);
|
|
1123
|
+
if (!preset) {
|
|
1124
|
+
const ids = ANIMATION_PRESETS.map((p) => p.id).join(", ");
|
|
1125
|
+
throw new Error(`Unknown animation preset "${input.preset}". Valid presets: ${ids}, ${CUSTOM_ANIMATION_PRESET_ID}.`);
|
|
1126
|
+
}
|
|
1127
|
+
if (!preset.roles.includes(input.role)) {
|
|
1128
|
+
throw new Error(`Preset "${input.preset}" does not support role "${input.role}". Valid roles for "${input.preset}": ${preset.roles.join(", ")}.`);
|
|
1129
|
+
}
|
|
1130
|
+
if (input.preset === "typewriter" && clip.mediaType !== "text") {
|
|
1131
|
+
throw new Error('Preset "typewriter" requires a text clip.');
|
|
1132
|
+
}
|
|
1133
|
+
const timing = input.preset === "typewriter"
|
|
1134
|
+
? typewriterTiming(clip.textStyle?.text ?? "", clip.durationMs - (input.delayMs ?? 0), input.durationMs, input.stagger)
|
|
1135
|
+
: null;
|
|
1136
|
+
built.push({
|
|
1137
|
+
id: scope.ctx.newId("anim"),
|
|
1138
|
+
role: input.role,
|
|
1139
|
+
preset: input.preset,
|
|
1140
|
+
durationMs: timing?.durationMs ?? input.durationMs ?? preset.defaultDurationMs,
|
|
1141
|
+
delayMs: input.delayMs,
|
|
1142
|
+
easing: input.easing,
|
|
1143
|
+
params: input.params,
|
|
1144
|
+
stagger: timing?.stagger ?? input.stagger,
|
|
1145
|
+
caret: input.preset === "typewriter" ? input.caret : undefined
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
clip.animations =
|
|
1149
|
+
op.mode === "add" ? [...(clip.animations ?? []), ...built] : built;
|
|
1150
|
+
scope.touch(clip.id);
|
|
1151
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1152
|
+
}
|
|
1153
|
+
case "set_baked_animation": {
|
|
1154
|
+
const clip = scope.resolveClip(op.target);
|
|
1155
|
+
const outcome = buildBakedAnimation(clip, op.animation, () => scope.ctx.newId("anim"));
|
|
1156
|
+
clip.animations = outcome.animations;
|
|
1157
|
+
scope.touch(clip.id);
|
|
1158
|
+
return {
|
|
1159
|
+
ok: true,
|
|
1160
|
+
clip: scope.clipOut(clip),
|
|
1161
|
+
animationId: outcome.animationId,
|
|
1162
|
+
keyframeCount: outcome.animation.custom?.curves[0]?.keyframes.length ?? 0,
|
|
1163
|
+
replaced: outcome.replaced
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
case "clear_animations": {
|
|
1167
|
+
const clip = scope.resolveClip(op.target);
|
|
1168
|
+
clip.animations = op.role
|
|
1169
|
+
? (clip.animations ?? []).filter((a) => a.role !== op.role)
|
|
1170
|
+
: [];
|
|
1171
|
+
scope.touch(clip.id);
|
|
1172
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1173
|
+
}
|
|
1174
|
+
case "list_animation_presets": {
|
|
1175
|
+
const presets = ANIMATION_PRESETS.map((p) => ({
|
|
1176
|
+
id: p.id,
|
|
1177
|
+
roles: p.roles,
|
|
1178
|
+
defaultDurationMs: p.defaultDurationMs,
|
|
1179
|
+
defaultEasing: p.defaultEasing,
|
|
1180
|
+
params: p.params,
|
|
1181
|
+
describe: p.describe
|
|
1182
|
+
}));
|
|
1183
|
+
return {
|
|
1184
|
+
ok: true,
|
|
1185
|
+
presets,
|
|
1186
|
+
custom: CUSTOM_ANIMATION_CONTRACT,
|
|
1187
|
+
properties: CUSTOM_ANIMATION_CONTRACT.properties
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
case "select_clip": {
|
|
1191
|
+
if (!op.target) {
|
|
1192
|
+
state.selectedClipIds = [];
|
|
1193
|
+
return { ok: true, selected: null };
|
|
1194
|
+
}
|
|
1195
|
+
const clip = scope.resolveClip(op.target);
|
|
1196
|
+
state.selectedClipIds = [clip.id];
|
|
1197
|
+
return { ok: true, selected: scope.clipOut(clip) };
|
|
1198
|
+
}
|
|
1199
|
+
case "seek": {
|
|
1200
|
+
state.playheadMs = Math.max(0, op.timeMs);
|
|
1201
|
+
return { ok: true, playheadMs: state.playheadMs };
|
|
1202
|
+
}
|
|
1203
|
+
case "add_marker": {
|
|
1204
|
+
if (op.timeMs < 0) {
|
|
1205
|
+
throw new Error(`A marker cannot sit before zero; got ${op.timeMs}ms.`);
|
|
1206
|
+
}
|
|
1207
|
+
const marker = {
|
|
1208
|
+
id: scope.ctx.newId("marker"),
|
|
1209
|
+
timeMs: Math.round(op.timeMs),
|
|
1210
|
+
label: op.label ?? ""
|
|
1211
|
+
};
|
|
1212
|
+
if (op.color !== undefined)
|
|
1213
|
+
marker.color = op.color;
|
|
1214
|
+
if (op.note !== undefined)
|
|
1215
|
+
marker.note = op.note;
|
|
1216
|
+
state.markers.push(marker);
|
|
1217
|
+
return { ok: true, marker: { ...marker } };
|
|
1218
|
+
}
|
|
1219
|
+
case "delete_marker": {
|
|
1220
|
+
const marker = scope.resolveMarker(op.target);
|
|
1221
|
+
state.markers = state.markers.filter((m) => m.id !== marker.id);
|
|
1222
|
+
return { ok: true, deleted: { ...marker } };
|
|
1223
|
+
}
|
|
1224
|
+
case "set_markers_from_beats": {
|
|
1225
|
+
const grid = buildBeatGrid({
|
|
1226
|
+
onsetsMs: op.onsets_ms,
|
|
1227
|
+
bpm: op.bpm,
|
|
1228
|
+
offsetMs: op.offset_ms,
|
|
1229
|
+
count: op.count
|
|
1230
|
+
});
|
|
1231
|
+
const stem = (op.label ?? "Beat").trim() || "Beat";
|
|
1232
|
+
const taken = new Set(state.markers.map((m) => m.timeMs));
|
|
1233
|
+
const added = [];
|
|
1234
|
+
const skipped = [];
|
|
1235
|
+
for (const [index, timeMs] of grid.entries()) {
|
|
1236
|
+
if (taken.has(timeMs)) {
|
|
1237
|
+
skipped.push(timeMs);
|
|
1238
|
+
continue;
|
|
1239
|
+
}
|
|
1240
|
+
const marker = {
|
|
1241
|
+
id: scope.ctx.newId("marker"),
|
|
1242
|
+
timeMs,
|
|
1243
|
+
label: `${stem} ${index + 1}`
|
|
1244
|
+
};
|
|
1245
|
+
state.markers.push(marker);
|
|
1246
|
+
taken.add(timeMs);
|
|
1247
|
+
added.push(marker);
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
ok: true,
|
|
1251
|
+
grid: {
|
|
1252
|
+
count: grid.length,
|
|
1253
|
+
firstMs: grid[0],
|
|
1254
|
+
lastMs: grid[grid.length - 1]
|
|
1255
|
+
},
|
|
1256
|
+
added: added.map((m) => ({ ...m })),
|
|
1257
|
+
skipped_times_ms: skipped,
|
|
1258
|
+
markers: state.markers.length
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
case "snap_to_beats": {
|
|
1262
|
+
const named = op.targets === undefined || op.targets === "all"
|
|
1263
|
+
? undefined
|
|
1264
|
+
: op.targets;
|
|
1265
|
+
const { clips: targeted, missing } = scope.resolveSnapTargets(named);
|
|
1266
|
+
const offsetMs = op.offset_ms ?? 0;
|
|
1267
|
+
// A tempo grid has to reach the last boundary being snapped, so its
|
|
1268
|
+
// length comes from the targets rather than from the caller.
|
|
1269
|
+
const reachMs = targeted.reduce((end, clip) => Math.max(end, clip.startMs + clip.durationMs), 0);
|
|
1270
|
+
const grid = buildBeatGrid({
|
|
1271
|
+
onsetsMs: op.onsets_ms,
|
|
1272
|
+
bpm: op.bpm,
|
|
1273
|
+
offsetMs: op.offset_ms,
|
|
1274
|
+
count: op.bpm === undefined
|
|
1275
|
+
? undefined
|
|
1276
|
+
: beatCountToCover(op.bpm, offsetMs, reachMs)
|
|
1277
|
+
});
|
|
1278
|
+
const options = {};
|
|
1279
|
+
if (op.tolerance_ms !== undefined)
|
|
1280
|
+
options.toleranceMs = op.tolerance_ms;
|
|
1281
|
+
if (op.mode !== undefined)
|
|
1282
|
+
options.mode = op.mode;
|
|
1283
|
+
if (op.action !== undefined)
|
|
1284
|
+
options.action = op.action;
|
|
1285
|
+
const result = snapClipsToGrid(targeted.map((clip) => ({
|
|
1286
|
+
id: clip.id,
|
|
1287
|
+
startMs: clip.startMs,
|
|
1288
|
+
durationMs: clip.durationMs
|
|
1289
|
+
})), grid, options);
|
|
1290
|
+
const byId = new Map(targeted.map((clip) => [clip.id, clip]));
|
|
1291
|
+
const reported = result.clips.map((entry) => {
|
|
1292
|
+
const clip = byId.get(entry.clipId);
|
|
1293
|
+
if (entry.snapped && clip) {
|
|
1294
|
+
// Through the same ops the caller would use: a group carries its
|
|
1295
|
+
// children (D4) and a trim carries the source points, neither of
|
|
1296
|
+
// which a raw startMs/durationMs write does.
|
|
1297
|
+
try {
|
|
1298
|
+
if (entry.after.durationMs === entry.before.durationMs) {
|
|
1299
|
+
scope.applyMove(clip, { startMs: entry.after.startMs });
|
|
1300
|
+
}
|
|
1301
|
+
else {
|
|
1302
|
+
let trimmed = clip;
|
|
1303
|
+
if (entry.after.startMs !== entry.before.startMs) {
|
|
1304
|
+
trimmed = scope.applyTrimStart(clip, entry.after.startMs);
|
|
1305
|
+
}
|
|
1306
|
+
scope.applyTrim(trimmed, { durationMs: entry.after.durationMs });
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
catch (error) {
|
|
1310
|
+
return {
|
|
1311
|
+
...entry,
|
|
1312
|
+
snapped: false,
|
|
1313
|
+
after: entry.before,
|
|
1314
|
+
delta: { startMs: 0, endMs: 0 },
|
|
1315
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1316
|
+
clipName: clip.name
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
return { ...entry, clipName: clip?.name ?? null };
|
|
1321
|
+
});
|
|
1322
|
+
// A name nothing matched is a skip like any other: the caller has to see
|
|
1323
|
+
// it in the same list, not infer it from a shorter one.
|
|
1324
|
+
for (const target of missing) {
|
|
1325
|
+
reported.push({
|
|
1326
|
+
clipId: target,
|
|
1327
|
+
clipName: null,
|
|
1328
|
+
snapped: false,
|
|
1329
|
+
before: { startMs: 0, endMs: 0, durationMs: 0 },
|
|
1330
|
+
after: { startMs: 0, endMs: 0, durationMs: 0 },
|
|
1331
|
+
delta: { startMs: 0, endMs: 0 },
|
|
1332
|
+
reason: `no clip matches "${target}"`
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
return {
|
|
1336
|
+
ok: true,
|
|
1337
|
+
grid: {
|
|
1338
|
+
count: grid.length,
|
|
1339
|
+
firstMs: grid[0],
|
|
1340
|
+
lastMs: grid[grid.length - 1]
|
|
1341
|
+
},
|
|
1342
|
+
toleranceMs: result.toleranceMs,
|
|
1343
|
+
mode: result.mode,
|
|
1344
|
+
action: result.action,
|
|
1345
|
+
snapped: result.snapped,
|
|
1346
|
+
skipped: result.skipped + missing.length,
|
|
1347
|
+
clips: reported
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
case "insert_composition": {
|
|
1351
|
+
const loader = scope.ctx.loadComposition;
|
|
1352
|
+
if (!loader) {
|
|
1353
|
+
throw new Error("This surface has no composition library, so insert_composition cannot resolve a template.");
|
|
1354
|
+
}
|
|
1355
|
+
const composition = await loader.get(op.composition_id);
|
|
1356
|
+
if (!composition) {
|
|
1357
|
+
const available = await loader.listIds();
|
|
1358
|
+
throw new Error(`No composition with id "${op.composition_id}". ` +
|
|
1359
|
+
(available.length > 0
|
|
1360
|
+
? `Available: ${available.join(", ")}.`
|
|
1361
|
+
: "This install has none — save one with save_composition."));
|
|
1362
|
+
}
|
|
1363
|
+
const minted = instantiateComposition(composition, {
|
|
1364
|
+
startMs: op.startMs,
|
|
1365
|
+
params: op.params,
|
|
1366
|
+
newId: () => scope.ctx.newId("clip")
|
|
1367
|
+
});
|
|
1368
|
+
// Template track ids are names, not document ids. Two clips overlapping
|
|
1369
|
+
// on one track auto-dissolve into each other, so each template track
|
|
1370
|
+
// becomes a track of its own — created front-most first, because the
|
|
1371
|
+
// lowest track index draws on top (I9).
|
|
1372
|
+
const templateTracks = [];
|
|
1373
|
+
for (const child of composition.children) {
|
|
1374
|
+
if (!templateTracks.includes(child.trackId)) {
|
|
1375
|
+
templateTracks.push(child.trackId);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
const mapped = new Map();
|
|
1379
|
+
for (const name of [...templateTracks].reverse()) {
|
|
1380
|
+
const existing = scope.tracks.find((t) => t.type === "overlay" && t.name === name);
|
|
1381
|
+
mapped.set(name, (existing ?? scope.addTrack("overlay", name)).id);
|
|
1382
|
+
}
|
|
1383
|
+
// The group draws nothing, but it still occupies its track's timeline,
|
|
1384
|
+
// and a group sharing a track with one of its children reads as an
|
|
1385
|
+
// overlap. It gets a track named after the composition instead.
|
|
1386
|
+
const groupTrack = op.trackId
|
|
1387
|
+
? scope.resolveTrack(op.trackId)
|
|
1388
|
+
: (scope.tracks.find((t) => t.type === "overlay" && t.name === composition.name) ?? scope.addTrack("overlay", composition.name));
|
|
1389
|
+
const [group, ...children] = minted;
|
|
1390
|
+
group.trackId = groupTrack.id;
|
|
1391
|
+
for (const [index, child] of children.entries()) {
|
|
1392
|
+
child.trackId =
|
|
1393
|
+
mapped.get(composition.children[index].trackId) ?? groupTrack.id;
|
|
1394
|
+
}
|
|
1395
|
+
scope.clips.push(group, ...children);
|
|
1396
|
+
state.selectedClipIds = [group.id];
|
|
1397
|
+
scope.touch(group.id, ...children.map((c) => c.id));
|
|
1398
|
+
return {
|
|
1399
|
+
ok: true,
|
|
1400
|
+
compositionId: composition.id,
|
|
1401
|
+
clip: scope.clipOut(group),
|
|
1402
|
+
children: children.map((child) => scope.clipOut(child)),
|
|
1403
|
+
params: group.compositionParams ?? {}
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
case "list_takes": {
|
|
1407
|
+
const clip = scope.resolveClip(op.target);
|
|
1408
|
+
const versions = clip.versions ?? [];
|
|
1409
|
+
const activeId = activeTakeIdOf(clip);
|
|
1410
|
+
return {
|
|
1411
|
+
ok: true,
|
|
1412
|
+
takes: versions.map((v) => ({
|
|
1413
|
+
id: v.id,
|
|
1414
|
+
label: v.label,
|
|
1415
|
+
source: v.source,
|
|
1416
|
+
provider: v.provider,
|
|
1417
|
+
model: v.model,
|
|
1418
|
+
createdAt: v.createdAt,
|
|
1419
|
+
costCredits: v.costCredits,
|
|
1420
|
+
durationMs: v.durationMs,
|
|
1421
|
+
status: v.status,
|
|
1422
|
+
favorite: v.favorite,
|
|
1423
|
+
active: v.id === activeId
|
|
1424
|
+
})),
|
|
1425
|
+
activeTakeId: activeId ?? null
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
case "select_take": {
|
|
1429
|
+
const clip = scope.resolveClip(op.target);
|
|
1430
|
+
if (clip.mediaType === "model3d") {
|
|
1431
|
+
throw new Error(`Clip "${clip.name}" is a 3D clip — its version history includes ` +
|
|
1432
|
+
"bake renders that must not replace the glTF source. Take " +
|
|
1433
|
+
"selection is not available for model3d clips yet.");
|
|
1434
|
+
}
|
|
1435
|
+
const version = (clip.versions ?? []).find((v) => v.id === op.takeId);
|
|
1436
|
+
if (!version) {
|
|
1437
|
+
throw new Error(`No take "${op.takeId}" on "${clip.name}". ${scope.validUnits((clip.versions ?? []).map((v) => ({
|
|
1438
|
+
id: v.id,
|
|
1439
|
+
name: v.label ?? v.id
|
|
1440
|
+
})), "take")}`);
|
|
1441
|
+
}
|
|
1442
|
+
if (version.status !== "success") {
|
|
1443
|
+
throw new Error(`Take "${op.takeId}" on "${clip.name}" did not finish successfully ` +
|
|
1444
|
+
`(status: ${version.status}) — only a successful take can be selected.`);
|
|
1445
|
+
}
|
|
1446
|
+
const next = selectTake(clip, op.takeId);
|
|
1447
|
+
scope.clips = scope.clips.map((c) => (c.id === clip.id ? next : c));
|
|
1448
|
+
scope.touch(clip.id);
|
|
1449
|
+
return { ok: true, clip: scope.clipOut(next) };
|
|
1450
|
+
}
|
|
1451
|
+
case "rename_take": {
|
|
1452
|
+
const clip = scope.resolveClip(op.target);
|
|
1453
|
+
if (!(clip.versions ?? []).some((v) => v.id === op.takeId)) {
|
|
1454
|
+
throw new Error(`No take "${op.takeId}" on "${clip.name}". ${scope.validUnits((clip.versions ?? []).map((v) => ({
|
|
1455
|
+
id: v.id,
|
|
1456
|
+
name: v.label ?? v.id
|
|
1457
|
+
})), "take")}`);
|
|
1458
|
+
}
|
|
1459
|
+
const next = renameTakeOnClip(clip, op.takeId, op.label);
|
|
1460
|
+
scope.clips = scope.clips.map((c) => (c.id === clip.id ? next : c));
|
|
1461
|
+
scope.touch(clip.id);
|
|
1462
|
+
return { ok: true, clip: scope.clipOut(next) };
|
|
1463
|
+
}
|
|
1464
|
+
case "delete_take": {
|
|
1465
|
+
const clip = scope.resolveClip(op.target);
|
|
1466
|
+
const { clip: next, error } = deleteTakeOnClip(clip, op.takeId);
|
|
1467
|
+
if (error) {
|
|
1468
|
+
throw new Error(error);
|
|
1469
|
+
}
|
|
1470
|
+
scope.clips = scope.clips.map((c) => (c.id === clip.id ? next : c));
|
|
1471
|
+
scope.touch(clip.id);
|
|
1472
|
+
return { ok: true, clip: scope.clipOut(next) };
|
|
1473
|
+
}
|
|
1474
|
+
// Subject/object tracks (P0 AI Video, Phase 2). The async provider call
|
|
1475
|
+
// that fills a track's samples is the `track_object` capability, not an
|
|
1476
|
+
// op — these four are the structural/synchronous surface over it.
|
|
1477
|
+
case "list_tracks": {
|
|
1478
|
+
const clipId = op.target ? scope.resolveClip(op.target).id : undefined;
|
|
1479
|
+
const tracks = scope.mediaTracks.filter((t) => clipId === undefined || t.clipId === clipId);
|
|
1480
|
+
return {
|
|
1481
|
+
ok: true,
|
|
1482
|
+
tracks: tracks.map((t) => ({
|
|
1483
|
+
id: t.id,
|
|
1484
|
+
clipId: t.clipId,
|
|
1485
|
+
name: t.name,
|
|
1486
|
+
kind: t.kind,
|
|
1487
|
+
status: t.status,
|
|
1488
|
+
sourceStartMs: t.sourceStartMs,
|
|
1489
|
+
sourceEndMs: t.sourceEndMs,
|
|
1490
|
+
sampleCount: t.samples.length,
|
|
1491
|
+
confidence: t.confidence
|
|
1492
|
+
}))
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
case "delete_track_object": {
|
|
1496
|
+
const track = scope.mediaTracks.find((t) => t.id === op.trackId);
|
|
1497
|
+
if (!track) {
|
|
1498
|
+
throw new Error(`No track "${op.trackId}". ${scope.validUnits(scope.mediaTracks.map((t) => ({ id: t.id, name: t.name })), "track")}`);
|
|
1499
|
+
}
|
|
1500
|
+
scope.mediaTracks = scope.mediaTracks.filter((t) => t.id !== op.trackId);
|
|
1501
|
+
const unboundClipIds = [];
|
|
1502
|
+
scope.clips = scope.clips.map((c) => {
|
|
1503
|
+
if (c.trackBinding?.trackId !== op.trackId)
|
|
1504
|
+
return c;
|
|
1505
|
+
unboundClipIds.push(c.id);
|
|
1506
|
+
const { trackBinding: _dropped, ...rest } = c;
|
|
1507
|
+
return rest;
|
|
1508
|
+
});
|
|
1509
|
+
scope.touch(...unboundClipIds);
|
|
1510
|
+
return { ok: true, deleted: { id: track.id, name: track.name } };
|
|
1511
|
+
}
|
|
1512
|
+
case "bind_to_track": {
|
|
1513
|
+
const clip = scope.resolveClip(op.target);
|
|
1514
|
+
const track = scope.mediaTracks.find((t) => t.id === op.trackId);
|
|
1515
|
+
if (!track) {
|
|
1516
|
+
throw new Error(`No track "${op.trackId}". ${scope.validUnits(scope.mediaTracks.map((t) => ({ id: t.id, name: t.name })), "track")}`);
|
|
1517
|
+
}
|
|
1518
|
+
if (op.mode !== "position" && op.mode !== "position_scale") {
|
|
1519
|
+
throw new Error(`bind_to_track mode "${op.mode}" is not implemented yet — only ` +
|
|
1520
|
+
`"position" and "position_scale" affect rendering in this build. ` +
|
|
1521
|
+
"The field accepts the other modes so a document can name the " +
|
|
1522
|
+
"intent without a schema migration later, but binding to one " +
|
|
1523
|
+
"today would be a no-op, so the call is refused instead.");
|
|
1524
|
+
}
|
|
1525
|
+
const binding = { trackId: op.trackId, mode: op.mode };
|
|
1526
|
+
if (op.offset !== undefined)
|
|
1527
|
+
binding.offset = op.offset;
|
|
1528
|
+
if (op.scale !== undefined)
|
|
1529
|
+
binding.scale = op.scale;
|
|
1530
|
+
if (op.rotationOffset !== undefined) {
|
|
1531
|
+
binding.rotationOffset = op.rotationOffset;
|
|
1532
|
+
}
|
|
1533
|
+
if (op.smoothing !== undefined)
|
|
1534
|
+
binding.smoothing = op.smoothing;
|
|
1535
|
+
const next = { ...clip, trackBinding: binding };
|
|
1536
|
+
scope.clips = scope.clips.map((c) => (c.id === clip.id ? next : c));
|
|
1537
|
+
scope.touch(clip.id);
|
|
1538
|
+
return { ok: true, clip: scope.clipOut(next) };
|
|
1539
|
+
}
|
|
1540
|
+
case "unbind_track": {
|
|
1541
|
+
const clip = scope.resolveClip(op.target);
|
|
1542
|
+
if (!clip.trackBinding) {
|
|
1543
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1544
|
+
}
|
|
1545
|
+
const { trackBinding: _dropped, ...next } = clip;
|
|
1546
|
+
scope.clips = scope.clips.map((c) => (c.id === clip.id ? next : c));
|
|
1547
|
+
scope.touch(clip.id);
|
|
1548
|
+
return { ok: true, clip: scope.clipOut(next) };
|
|
1549
|
+
}
|
|
1550
|
+
default: {
|
|
1551
|
+
const unknown = op;
|
|
1552
|
+
throw new Error(`Unknown timeline op "${unknown.op}".`);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
/** Deep copy of the document, so a failed op leaves the caller's state alone. */
|
|
1557
|
+
function cloneState(state) {
|
|
1558
|
+
return {
|
|
1559
|
+
fps: state.fps,
|
|
1560
|
+
width: state.width,
|
|
1561
|
+
height: state.height,
|
|
1562
|
+
tracks: state.tracks.map((t) => structuredClone(t)),
|
|
1563
|
+
clips: state.clips.map((c) => structuredClone(c)),
|
|
1564
|
+
markers: state.markers.map((m) => structuredClone(m)),
|
|
1565
|
+
mediaTracks: (state.mediaTracks ?? []).map((t) => structuredClone(t)),
|
|
1566
|
+
playheadMs: state.playheadMs,
|
|
1567
|
+
selectedClipIds: [...state.selectedClipIds]
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Apply one op to a document and report what it did.
|
|
1572
|
+
*
|
|
1573
|
+
* The state that comes back is a new object; the one handed in is never
|
|
1574
|
+
* written to. An op that refuses returns the input state with `error` set.
|
|
1575
|
+
*/
|
|
1576
|
+
export async function applyTimelineOp(state, op, ctx) {
|
|
1577
|
+
const scope = new OpScope(cloneState(state), ctx);
|
|
1578
|
+
try {
|
|
1579
|
+
const result = await runOp(scope, op);
|
|
1580
|
+
return {
|
|
1581
|
+
state: scope.state,
|
|
1582
|
+
result,
|
|
1583
|
+
changedClipIds: [...scope.changed]
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
catch (error) {
|
|
1587
|
+
return {
|
|
1588
|
+
state,
|
|
1589
|
+
result: {},
|
|
1590
|
+
changedClipIds: [],
|
|
1591
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
//# sourceMappingURL=apply.js.map
|