Fix Lottie replay for Next builds and fallback sources

This commit is contained in:
Samraaj Bath
2026-07-03 14:03:42 -07:00
parent 7e192863b4
commit 13ce4b89a1
3 changed files with 53 additions and 26 deletions
+14
View File
@@ -62,6 +62,20 @@ describe("buildLottieSpec", () => {
assert.equal(spec.items[0]!.renderer, "canvas");
});
it("falls back to inline animationData when a source URL was detected but not downloaded", () => {
const ir = irWith(node("n0", {}, [node("n6", { "data-cid-cap": "cap-1" })]));
const motion = emptyMotion({
lotties: [lottie({ src: "https://x/missing.json", inlineKey: "k0" })],
lottieInline: { k0: { v: "5.7", layers: [] } },
});
const graph: AssetGraph = { entries: [], byUrl: new Map() };
const spec = buildLottieSpec(ir, motion, graph);
assert.equal(spec.items.length, 1);
assert.equal(spec.items[0]!.path, null);
assert.deepEqual(spec.items[0]!.animationData, { v: "5.7", layers: [] });
});
it("drops a lottie whose container node didn't survive into the IR", () => {
const ir = irWith(node("n0", {}, [node("n6", { "data-cid-cap": "other-cap" })]));
const motion = emptyMotion({ lotties: [lottie({ src: "https://x/anim.json" })] });