(script: string)
| 418 | } |
| 419 | |
| 420 | function 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 |
no test coverage detected