@nodetool-ai/timeline 0.8.13 → 0.8.14
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/dist/.nodetool-build-stamp +1 -1
- package/dist/animation/custom.d.ts.map +1 -1
- package/dist/animation/custom.js +7 -9
- package/dist/animation/custom.js.map +1 -1
- package/dist/automation.d.ts.map +1 -1
- package/dist/automation.js +7 -3
- package/dist/automation.js.map +1 -1
- package/dist/keyframes.d.ts +21 -2
- package/dist/keyframes.d.ts.map +1 -1
- package/dist/keyframes.js +72 -12
- package/dist/keyframes.js.map +1 -1
- package/dist/ops/apply.d.ts.map +1 -1
- package/dist/ops/apply.js +132 -0
- package/dist/ops/apply.js.map +1 -1
- package/dist/ops/op.d.ts +3 -2
- package/dist/ops/op.d.ts.map +1 -1
- package/dist/ops/op.js +4 -0
- package/dist/ops/op.js.map +1 -1
- package/dist/ops/parse.d.ts.map +1 -1
- package/dist/ops/parse.js +16 -0
- package/dist/ops/parse.js.map +1 -1
- package/dist/paramCurves.d.ts +16 -3
- package/dist/paramCurves.d.ts.map +1 -1
- package/dist/paramCurves.js +104 -4
- package/dist/paramCurves.js.map +1 -1
- package/dist/render/sceneModel.d.ts.map +1 -1
- package/dist/render/sceneModel.js +13 -0
- package/dist/render/sceneModel.js.map +1 -1
- package/dist/takes.d.ts.map +1 -1
- package/dist/takes.js +39 -20
- package/dist/takes.js.map +1 -1
- package/dist/testing/ops.d.ts.map +1 -1
- package/dist/testing/ops.js +20 -0
- package/dist/testing/ops.js.map +1 -1
- package/dist/transcriptOps.d.ts +267 -0
- package/dist/transcriptOps.d.ts.map +1 -0
- package/dist/transcriptOps.js +754 -0
- package/dist/transcriptOps.js.map +1 -0
- package/dist/trimClip.d.ts.map +1 -1
- package/dist/trimClip.js +12 -6
- package/dist/trimClip.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -5
package/dist/ops/apply.js
CHANGED
|
@@ -39,6 +39,8 @@ import { splitClip } from "../splitClip.js";
|
|
|
39
39
|
import { activeTakeIdOf, deleteTake as deleteTakeOnClip, renameTake as renameTakeOnClip, selectTake } from "../takes.js";
|
|
40
40
|
import { moveTrackOrder } from "../trackOrder.js";
|
|
41
41
|
import { applyTransitionAtCutCandidate, transitionGrowthMs, transitionGrowthUnit, transitionLengthAtCut, planTransitionAtCut } from "../transitionAtCut.js";
|
|
42
|
+
import { closeGap, findGap, rippleDelete } from "../rippleEdit.js";
|
|
43
|
+
import { removeFillers, rippleDeleteRange } from "../transcriptOps.js";
|
|
42
44
|
import { retimeCaption, trimClip } from "../trimClip.js";
|
|
43
45
|
import { retimeClipSpeed } from "../clipSpeed.js";
|
|
44
46
|
import { serializeClip, serializeMediaTrack, serializeTrack } from "./serialize.js";
|
|
@@ -873,6 +875,40 @@ function runBeatEdit(scope, op) {
|
|
|
873
875
|
: { ok: true, beat: { ...next } };
|
|
874
876
|
}
|
|
875
877
|
/** One handler per op, so each is checked against its own op type. */
|
|
878
|
+
/** Locked tracks and locked clips, the way the ripple edits take them. */
|
|
879
|
+
function rippleLocks(scope) {
|
|
880
|
+
return {
|
|
881
|
+
lockedTrackIds: new Set(scope.tracks.filter((t) => t.locked).map((t) => t.id)),
|
|
882
|
+
lockedClipIds: new Set(scope.clips.filter((c) => c.locked).map((c) => c.id)),
|
|
883
|
+
followLinks: scope.ctx.followLinks !== false
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
/** Every clip in an edit unit that holds a locked clip or a clip on a locked track. */
|
|
887
|
+
function transcriptLocks(scope) {
|
|
888
|
+
const lockedTracks = new Set(scope.tracks.filter((t) => t.locked).map((t) => t.id));
|
|
889
|
+
const seeds = scope.clips
|
|
890
|
+
.filter((c) => c.locked || lockedTracks.has(c.trackId))
|
|
891
|
+
.map((c) => c.id);
|
|
892
|
+
return {
|
|
893
|
+
lockedClipIds: new Set(seeds.length ? moveUnitIds(scope.clips, seeds, { followLinks: true }) : [])
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/** Write a ripple result and report which clips moved or went. */
|
|
897
|
+
function commitRipple(scope, next) {
|
|
898
|
+
const before = new Map(scope.clips.map((c) => [c.id, c]));
|
|
899
|
+
const after = new Set(next.map((c) => c.id));
|
|
900
|
+
const movedClipIds = next
|
|
901
|
+
.filter((c) => {
|
|
902
|
+
const prev = before.get(c.id);
|
|
903
|
+
return prev !== undefined && (prev.startMs !== c.startMs || prev.durationMs !== c.durationMs);
|
|
904
|
+
})
|
|
905
|
+
.map((c) => c.id);
|
|
906
|
+
const removedClipIds = [...before.keys()].filter((id) => !after.has(id));
|
|
907
|
+
scope.clips = next;
|
|
908
|
+
scope.state.selectedClipIds = scope.state.selectedClipIds.filter((id) => after.has(id));
|
|
909
|
+
scope.touch(...movedClipIds, ...removedClipIds, ...next.filter((c) => !before.has(c.id)).map((c) => c.id));
|
|
910
|
+
return { movedClipIds, removedClipIds };
|
|
911
|
+
}
|
|
876
912
|
const OP_HANDLERS = {
|
|
877
913
|
get_state: (scope) => {
|
|
878
914
|
const state = scope.state;
|
|
@@ -1824,6 +1860,9 @@ const OP_HANDLERS = {
|
|
|
1824
1860
|
if (op.color !== undefined) {
|
|
1825
1861
|
marker.color = op.color;
|
|
1826
1862
|
}
|
|
1863
|
+
if (op.durationMs !== undefined && op.durationMs > 0) {
|
|
1864
|
+
marker.durationMs = Math.round(op.durationMs);
|
|
1865
|
+
}
|
|
1827
1866
|
if (op.note !== undefined) {
|
|
1828
1867
|
marker.note = op.note;
|
|
1829
1868
|
}
|
|
@@ -2238,6 +2277,99 @@ const OP_HANDLERS = {
|
|
|
2238
2277
|
scope.touch(clip.id);
|
|
2239
2278
|
return { ok: true, clip: scope.clipOut(clip) };
|
|
2240
2279
|
},
|
|
2280
|
+
set_track: (scope, op) => {
|
|
2281
|
+
const track = scope.resolveTrack(op.track);
|
|
2282
|
+
// Unlocking is the one change a locked track takes; everything else waits for it.
|
|
2283
|
+
const others = Object.keys(op).filter((key) => key !== "op" && key !== "track" && key !== "locked");
|
|
2284
|
+
if (track.locked && op.locked !== false && others.length > 0) {
|
|
2285
|
+
throw new Error(`Track "${track.name}" is locked. Send locked: false first, then change ${others.join(", ")}.`);
|
|
2286
|
+
}
|
|
2287
|
+
if ((op.volumeDb !== undefined || op.pan !== undefined) && track.type !== "audio" && track.type !== "midi") {
|
|
2288
|
+
throw new Error(`Track "${track.name}" is a ${track.type} track. volumeDb and pan apply to audio and midi tracks only.`);
|
|
2289
|
+
}
|
|
2290
|
+
if (op.name !== undefined)
|
|
2291
|
+
track.name = op.name;
|
|
2292
|
+
if (op.muted !== undefined)
|
|
2293
|
+
track.muted = op.muted;
|
|
2294
|
+
if (op.solo !== undefined)
|
|
2295
|
+
track.solo = op.solo;
|
|
2296
|
+
if (op.locked !== undefined)
|
|
2297
|
+
track.locked = op.locked;
|
|
2298
|
+
if (op.visible !== undefined)
|
|
2299
|
+
track.visible = op.visible;
|
|
2300
|
+
if (op.volumeDb !== undefined)
|
|
2301
|
+
track.volumeDb = op.volumeDb;
|
|
2302
|
+
if (op.pan !== undefined)
|
|
2303
|
+
track.pan = op.pan;
|
|
2304
|
+
if (op.heightPx !== undefined)
|
|
2305
|
+
track.heightPx = Math.round(op.heightPx);
|
|
2306
|
+
return { ok: true, track: scope.trackOut(track) };
|
|
2307
|
+
},
|
|
2308
|
+
ripple_delete: (scope, op) => {
|
|
2309
|
+
const targets = op.targets.map((ref) => scope.resolveClip(ref));
|
|
2310
|
+
const ids = new Set();
|
|
2311
|
+
for (const clip of targets) {
|
|
2312
|
+
for (const unit of scope.editTargets(clip))
|
|
2313
|
+
ids.add(unit.id);
|
|
2314
|
+
}
|
|
2315
|
+
const removing = scope.clips.filter((c) => ids.has(c.id));
|
|
2316
|
+
const next = rippleDelete(scope.clips, ids, rippleLocks(scope));
|
|
2317
|
+
const result = commitRipple(scope, next);
|
|
2318
|
+
// rippleDelete removes the clips and leaves every span open when closing
|
|
2319
|
+
// one would separate a link group. With nothing after a span there is no
|
|
2320
|
+
// hole to close.
|
|
2321
|
+
const followed = next.some((n) => removing.some((c) => n.startMs >= c.startMs + c.durationMs));
|
|
2322
|
+
const closed = !followed || result.movedClipIds.length > 0;
|
|
2323
|
+
const out = {
|
|
2324
|
+
ok: true,
|
|
2325
|
+
deleted: removing.map((c) => scope.clipOut(c)),
|
|
2326
|
+
...result,
|
|
2327
|
+
gapClosed: closed
|
|
2328
|
+
};
|
|
2329
|
+
if (!closed) {
|
|
2330
|
+
out.note =
|
|
2331
|
+
"The clips were removed, but closing the gap would separate a link group, so the gap stays.";
|
|
2332
|
+
}
|
|
2333
|
+
return out;
|
|
2334
|
+
},
|
|
2335
|
+
close_gap: (scope, op) => {
|
|
2336
|
+
const track = scope.resolveTrack(op.track);
|
|
2337
|
+
const gap = findGap(scope.clips, track.id, op.atMs);
|
|
2338
|
+
if (!gap) {
|
|
2339
|
+
return {
|
|
2340
|
+
ok: true,
|
|
2341
|
+
closed: false,
|
|
2342
|
+
note: `No gap on "${track.name}" at ${op.atMs} ms: a clip covers that time or no clip follows it.`
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
const next = closeGap(scope.clips, track.id, op.atMs, rippleLocks(scope));
|
|
2346
|
+
const result = commitRipple(scope, next);
|
|
2347
|
+
const closed = result.movedClipIds.length > 0;
|
|
2348
|
+
const out = { ok: true, closed, gap, ...result };
|
|
2349
|
+
if (!closed) {
|
|
2350
|
+
out.note = "Closing the gap would separate a link group, so nothing moved.";
|
|
2351
|
+
}
|
|
2352
|
+
return out;
|
|
2353
|
+
},
|
|
2354
|
+
cut_transcript: (scope, op) => {
|
|
2355
|
+
const locks = transcriptLocks(scope);
|
|
2356
|
+
if (op.fillers) {
|
|
2357
|
+
if (op.startMs !== undefined || op.endMs !== undefined) {
|
|
2358
|
+
throw new Error("Send either fillers: true or startMs and endMs, not both.");
|
|
2359
|
+
}
|
|
2360
|
+
return { ok: true, ...commitRipple(scope, removeFillers(scope.clips, locks).clips) };
|
|
2361
|
+
}
|
|
2362
|
+
if (op.startMs === undefined || op.endMs === undefined || op.endMs <= op.startMs) {
|
|
2363
|
+
throw new Error("Send startMs and endMs with endMs after startMs, or fillers: true.");
|
|
2364
|
+
}
|
|
2365
|
+
const lockedWord = scope.clips.some((clip) => locks.lockedClipIds?.has(clip.id) &&
|
|
2366
|
+
(clip.caption?.words ?? []).some((w) => clip.startMs + w.startMs < op.endMs && clip.startMs + w.endMs > op.startMs));
|
|
2367
|
+
if (lockedWord) {
|
|
2368
|
+
throw new Error("The span covers a word of a locked clip. Unlock it, or cut a span that avoids it.");
|
|
2369
|
+
}
|
|
2370
|
+
const out = rippleDeleteRange(scope.clips, op.startMs, op.endMs, locks);
|
|
2371
|
+
return { ok: true, ...commitRipple(scope, out.clips) };
|
|
2372
|
+
},
|
|
2241
2373
|
set_tempo: (scope, op) => {
|
|
2242
2374
|
const previous = resolveTempo(scope.state);
|
|
2243
2375
|
const tempo = {
|