MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / surfaceAnime

Function surfaceAnime

packages/cli/src/commands/keyframes.ts:420–440  ·  view source on GitHub ↗
(script: string)

Source from the content-addressed store, hash-verified

418}
419
420function surfaceAnime(script: string): SurfacedAnimeAnimation[] {
421 if (!/\banime\s*(?:\.(?:timeline|createTimeline))?\s*\(/.test(script)) return [];
422 const registered = /__hfAnime[\s\S]*?\.push\s*\(/.test(script) || /__hfAnime\s*=/.test(script);
423 const timelineCount = (script.match(/\banime\.(?:timeline|createTimeline)\s*\(/g) ?? []).length;
424 const animationCount = (script.match(/\banime\s*\(/g) ?? []).length;
425 const targets = [
426 ...valuesFromProperty(script, "targets").filter(
427 (value): value is string => typeof value === "string",
428 ),
429 ...animeAddTargets(script),
430 ];
431 const durations = valuesFromProperty(script, "duration");
432 const out: SurfacedAnimeAnimation[] = [];
433 for (let i = 0; i < timelineCount; i++) {
434 out.push({ kind: "timeline", targets, durations, registered });
435 }
436 for (let i = 0; i < animationCount; i++) {
437 out.push({ kind: "animation", targets, durations, registered });
438 }
439 return out;
440}
441
442// A nested element's rendered motion is the COMPOSITION of its own tween and any
443// animated ancestor's. The per-element surface would otherwise hide the parent's

Callers 1

surfaceCompositionFunction · 0.85

Calls 2

valuesFromPropertyFunction · 0.85
animeAddTargetsFunction · 0.85

Tested by

no test coverage detected