@pixerate/flair 0.35.2 → 0.37.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -3
  3. package/dist/catalog/index.d.ts +3 -3
  4. package/dist/catalog/index.js +2 -2
  5. package/dist/{chunk-VKIDRHBG.js → chunk-6B62CBTP.js} +49 -4
  6. package/dist/chunk-6B62CBTP.js.map +1 -0
  7. package/dist/{chunk-O5QKC2L7.js → chunk-D4GVMDHE.js} +6 -6
  8. package/dist/{chunk-MOLJPWME.js → chunk-G5M777AN.js} +3 -3
  9. package/dist/{chunk-N5HXMQOK.js → chunk-OIRDNPMD.js} +22 -7
  10. package/dist/chunk-OIRDNPMD.js.map +1 -0
  11. package/dist/{chunk-JETRHCP3.js → chunk-XAQ5FWKS.js} +4 -4
  12. package/dist/chunk-XAQ5FWKS.js.map +1 -0
  13. package/dist/{chunk-2O3RMSOE.js → chunk-XFTSWPSX.js} +3 -3
  14. package/dist/{chunk-IHUNCBMF.js → chunk-Z3LKEODP.js} +2 -2
  15. package/dist/cli.js +2 -2
  16. package/dist/editor/index.d.ts +40 -4
  17. package/dist/editor/index.js +58 -3
  18. package/dist/editor/index.js.map +1 -1
  19. package/dist/{effect-HL4XF4FD.js → effect-RXOSCAK2.js} +8 -8
  20. package/dist/embed/index.d.ts +2 -2
  21. package/dist/embed/index.js +4 -4
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +12 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/node.d.ts +2 -2
  26. package/dist/node.js +7 -7
  27. package/dist/react/index.d.ts +2 -2
  28. package/dist/react/index.js +5 -5
  29. package/dist/svelte/index.d.ts +2 -2
  30. package/dist/svelte/index.js +5 -5
  31. package/dist/{svg-DaKRPA9v.d.ts → svg-cunB0HBn.d.ts} +23 -6
  32. package/dist/{types-B4Wjzde0.d.ts → types-CVgiEJyP.d.ts} +1 -1
  33. package/dist/vector/index.d.ts +2 -2
  34. package/dist/vector/index.js +12 -4
  35. package/package.json +3 -3
  36. package/dist/chunk-JETRHCP3.js.map +0 -1
  37. package/dist/chunk-N5HXMQOK.js.map +0 -1
  38. package/dist/chunk-VKIDRHBG.js.map +0 -1
  39. /package/dist/{chunk-O5QKC2L7.js.map → chunk-D4GVMDHE.js.map} +0 -0
  40. /package/dist/{chunk-MOLJPWME.js.map → chunk-G5M777AN.js.map} +0 -0
  41. /package/dist/{chunk-2O3RMSOE.js.map → chunk-XFTSWPSX.js.map} +0 -0
  42. /package/dist/{chunk-IHUNCBMF.js.map → chunk-Z3LKEODP.js.map} +0 -0
  43. /package/dist/{effect-HL4XF4FD.js.map → effect-RXOSCAK2.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/svg.ts"],"sourcesContent":["/**\n * Drawing animated SVG pictures (see `SvgMotion`) in the DOM: a sanitising\n * parser, a view that applies frames, and a player that runs on a `Clock`.\n */\n\nimport { realClock, type Clock } from \"../time/clock.js\";\nimport {\n easeFunction,\n formatCount,\n STEP_MS,\n SVG_PICTURE,\n svgFrame,\n svgOpeningTag,\n type SvgEase,\n type SvgBox,\n type SvgMotion,\n} from \"./motion.js\";\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n/**\n * The `<svg>` in `markup`, parsed and made safe to show: no scripts, event\n * handlers, `<foreignObject>` or links outside itself. Undefined when it is\n * not an SVG.\n */\nexport function parseSvg(markup: string): SVGSVGElement | undefined {\n // Parsed as XML, an <svg> without its namespace is not an SVG at all.\n let source = markup.trim();\n const open = svgOpeningTag(source);\n if (!/\\sxmlns\\s*=/i.test(open)) source = source.replace(/^<svg/i, `<svg xmlns=\"${SVG_NS}\"`);\n if (/xlink:/.test(source) && !/\\sxmlns:xlink\\s*=/i.test(open))\n source = source.replace(/^<svg/i, '<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"');\n const doc = new DOMParser().parseFromString(source, \"image/svg+xml\");\n const svg = doc.documentElement;\n if (svg.namespaceURI !== SVG_NS || svg.localName !== \"svg\" || doc.querySelector(\"parsererror\"))\n return undefined;\n for (const bad of svg.querySelectorAll(\"script, foreignObject\")) bad.remove();\n for (const el of [svg, ...svg.querySelectorAll(\"*\")]) {\n for (const attr of [...el.attributes]) {\n const name = attr.name.toLowerCase();\n const link = name === \"href\" || name === \"xlink:href\" || name === \"src\";\n if (name.startsWith(\"on\") || (link && !/^(#|data:image\\/)/i.test(attr.value.trim())))\n el.removeAttribute(attr.name);\n }\n }\n return document.importNode(svg, true) as unknown as SVGSVGElement;\n}\n\n/** Live views made so far, for ids unique on the page (see {@link scopeIds}). */\nlet views = 0;\n\nconst URL_REF = /url\\(\\s*(['\"]?)#([^'\")\\s]+)\\1\\s*\\)/g;\n\n/**\n * Gives the ids a live picture refers to (by `url(#…)` in attributes and\n * styles, or `href=\"#…\"`: its gradients, filters, clips, masks, `<use>`d\n * shapes) `suffix`, and points the references at the new ids, so two\n * pictures on one page that both define `id=\"glow\"` each use their own.\n * Other ids stay as written. The original id is kept in `data-flair-id`;\n * returns how ids map.\n */\nfunction scopeIds(svg: Element, suffix: string): Map<string, string> {\n const all = [svg, ...svg.querySelectorAll(\"*\")];\n const referred = new Set<string>();\n for (const el of all) {\n const texts = [...el.attributes].map((a) => [a.name.toLowerCase(), a.value] as const);\n if (el.localName === \"style\") texts.push([\"\", el.textContent ?? \"\"]);\n for (const [name, value] of texts) {\n if ((name === \"href\" || name === \"xlink:href\") && value.startsWith(\"#\")) referred.add(value.slice(1));\n for (const m of value.matchAll(URL_REF)) referred.add(m[2]!);\n }\n }\n const ids = new Map<string, string>();\n for (const el of all) {\n if (!el.id || !referred.has(el.id) || ids.has(el.id)) continue;\n ids.set(el.id, `${el.id}-${suffix}`);\n el.setAttribute(\"data-flair-id\", el.id);\n el.id = `${el.id}-${suffix}`;\n }\n if (ids.size)\n for (const el of [svg, ...svg.querySelectorAll(\"*\")]) {\n for (const attr of [...el.attributes]) {\n const scoped = scopedRefs(attr.value, ids, attr.name);\n if (scoped !== attr.value) attr.value = scoped;\n }\n if (el.localName === \"style\" && el.textContent) el.textContent = scopedRefs(el.textContent, ids);\n }\n return ids;\n}\n\n/** `value` with its references to ids in `ids` pointed at their scoped ids. */\nfunction scopedRefs(value: string, ids: ReadonlyMap<string, string>, attr = \"\"): string {\n const name = attr.toLowerCase();\n if (name === \"href\" || name === \"xlink:href\") {\n const to = value.startsWith(\"#\") ? ids.get(value.slice(1)) : undefined;\n return to ? `#${to}` : value;\n }\n if (!value.includes(\"url(\")) return value;\n return value.replace(URL_REF, (whole, quote: string, id: string) => {\n const to = ids.get(id);\n return to ? `url(${quote}#${to}${quote})` : whole;\n });\n}\n\n/** Share of an element's size left round it when a `view` frames it. */\nconst VIEW_MARGIN = 0.12;\n\n/**\n * The box a `view` frames, in viewBox units: a box as given, an element's\n * box with a margin, widened to the picture's shape so the zoom does not\n * skew, or the whole picture for `null`.\n */\nfunction viewBox(view: SvgBox | string | null, whole: SvgBox, byId: Map<string, Element>): SvgBox {\n if (view === null) return whole;\n if (typeof view !== \"string\") return view;\n const el = byId.get(view) as SVGGraphicsElement | undefined;\n let box: DOMRect | undefined;\n try {\n box = el?.getBBox?.();\n } catch {\n // Not laid out (or not drawable): keep the whole picture.\n }\n if (!box || !(box.width > 0 || box.height > 0)) return whole;\n // In the picture's own units: through the element's transforms (a point\n // placed with one), which its box leaves out.\n try {\n const svg = el!.ownerSVGElement;\n const m = svg?.getScreenCTM()?.inverse().multiply(el!.getScreenCTM()!);\n if (m) {\n const corners = [\n [box.x, box.y],\n [box.x + box.width, box.y],\n [box.x, box.y + box.height],\n [box.x + box.width, box.y + box.height],\n ].map(([x, y]) => new DOMPoint(x, y).matrixTransform(m));\n const xs = corners.map((p) => p.x);\n const ys = corners.map((p) => p.y);\n box = new DOMRect(\n Math.min(...xs),\n Math.min(...ys),\n Math.max(...xs) - Math.min(...xs),\n Math.max(...ys) - Math.min(...ys),\n );\n }\n } catch {\n // Not laid out: keep its own box.\n }\n const aspect = whole[2] / whole[3];\n let w = box.width * (1 + 2 * VIEW_MARGIN);\n let h = box.height * (1 + 2 * VIEW_MARGIN);\n if (w / h > aspect) h = w / aspect;\n else w = h * aspect;\n return [box.x + box.width / 2 - w / 2, box.y + box.height / 2 - h / 2, w, h];\n}\n\n/**\n * Keeps the picture's `data-nonscaling` elements (a map's pins and labels)\n * the same size on screen as a `view` zooms: each is scaled round its own\n * origin by how far the picture is zoomed (so draw it round (0, 0) inside a\n * group that places it).\n */\nfunction keepSize(svg: SVGSVGElement, whole: SvgBox, nonscaling: Element[]) {\n if (!nonscaling.length) return;\n const width = Number((svg.getAttribute(\"viewBox\") ?? \"\").trim().split(/[\\s,]+/)[2]);\n const zoom = width > 0 ? width / whole[2] : 1;\n const transform = Math.abs(zoom - 1) < 1e-4 ? \"\" : `scale(${+zoom.toFixed(4)})`;\n for (const el of nonscaling)\n if ((el.getAttribute(\"transform\") ?? \"\") !== transform)\n if (transform) el.setAttribute(\"transform\", transform);\n else el.removeAttribute(\"transform\");\n}\n\n/** Applies a frame of the media's animations to `svg`. */\nfunction apply(\n svg: SVGSVGElement,\n whole: SvgBox,\n byId: Map<string, Element>,\n motion: SvgMotion,\n timeMs: number,\n steps: readonly number[],\n ids: ReadonlyMap<string, string> = new Map(),\n) {\n for (const [id, frame] of svgFrame(motion.animate ?? [], steps, timeMs)) {\n if (id === SVG_PICTURE && frame.view) {\n const a = viewBox(frame.view.from, whole, byId);\n const b = viewBox(frame.view.to, whole, byId);\n const u = frame.view.u;\n svg.setAttribute(\"viewBox\", a.map((n, i) => +(n + (b[i]! - n) * u).toFixed(2)).join(\" \"));\n continue;\n }\n const el = byId.get(id);\n if (!el) continue;\n for (const [name, value] of Object.entries(frame.attrs)) el.setAttribute(name, scopedRefs(value, ids, name));\n if (frame.draw !== undefined) {\n // A path length of 1 lets the dash be a fraction, with nothing measured.\n el.setAttribute(\"pathLength\", \"1\");\n el.setAttribute(\"stroke-dasharray\", \"1 1\");\n el.setAttribute(\"stroke-dashoffset\", String(1 - frame.draw));\n }\n if (frame.text !== undefined) el.textContent = frame.text;\n if (frame.solo !== undefined) {\n const children = Array.from(el.children);\n children.forEach((child, idx) => {\n if (child instanceof SVGElement || child instanceof HTMLElement) {\n if (idx === frame.solo) {\n child.removeAttribute(\"display\");\n } else {\n child.setAttribute(\"display\", \"none\");\n }\n }\n });\n }\n if (frame.along) {\n const path = byId.get(frame.along.path) as SVGGeometryElement | undefined;\n try {\n const length = path?.getTotalLength?.();\n if (path && length !== undefined) {\n const p = path.getPointAtLength(frame.along.at * length);\n el.setAttribute(\"transform\", `translate(${+p.x.toFixed(2)} ${+p.y.toFixed(2)})`);\n }\n } catch {\n // Not laid out: leave it where it is.\n }\n }\n }\n}\n\nconst VAR = /var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*([^()]*(?:\\([^()]*\\)[^()]*)*))?\\)/g;\n\n/**\n * `copy` with the CSS variables in its attributes and styles replaced by\n * their values on `live` (its original, in the page), or their fallbacks:\n * an image of the SVG is drawn on its own, where the page's variables (a\n * host's palette) mean nothing.\n */\nfunction resolveVariables(live: SVGSVGElement, copy: SVGSVGElement) {\n const originals = [live, ...live.querySelectorAll(\"*\")];\n const copies = [copy, ...copy.querySelectorAll(\"*\")];\n copies.forEach((el, i) => {\n let style: CSSStyleDeclaration | undefined;\n for (const attr of [...el.attributes]) {\n if (!attr.value.includes(\"var(\")) continue;\n style ??= getComputedStyle(originals[i] ?? live);\n el.setAttribute(\n attr.name,\n attr.value.replace(\n VAR,\n (_, name: string, fallback?: string) =>\n style!.getPropertyValue(name).trim() || fallback?.trim() || \"\",\n ),\n );\n }\n });\n}\n\n/** An image of the picture as drawn now (its layers in order), at `pixels`. */\nasync function rasterize(layers: SVGSVGElement[], pixels: { width: number; height: number }): Promise<HTMLCanvasElement> {\n const canvas = document.createElement(\"canvas\");\n canvas.width = pixels.width;\n canvas.height = pixels.height;\n const defs = layers[0]?.querySelector(\"defs\");\n for (const [i, svg] of layers.entries()) {\n const copy = svg.cloneNode(true) as SVGSVGElement;\n resolveVariables(svg, copy);\n // A fixed layer's gradients and markers live in the picture's <defs>.\n if (i > 0 && defs) copy.prepend(defs.cloneNode(true));\n copy.setAttribute(\"xmlns\", SVG_NS);\n copy.setAttribute(\"width\", String(pixels.width));\n copy.setAttribute(\"height\", String(pixels.height));\n const url = URL.createObjectURL(\n new Blob([new XMLSerializer().serializeToString(copy)], { type: \"image/svg+xml\" }),\n );\n try {\n const image = new Image();\n image.src = url;\n await image.decode();\n canvas.getContext(\"2d\")!.drawImage(image, 0, 0, pixels.width, pixels.height);\n } finally {\n URL.revokeObjectURL(url);\n }\n }\n return canvas;\n}\n\n/**\n * Moves the picture's `data-fixed` elements (titles, legends, notes) into a\n * layer over it that keeps the original `viewBox`, so a `view` zooms the\n * picture under them while they stay put. Undefined when it has none.\n */\nfunction fixedLayer(svg: SVGSVGElement): SVGSVGElement | undefined {\n const fixed = [...svg.querySelectorAll(\"[data-fixed]\")].filter(\n (el) => !el.parentElement?.closest(\"[data-fixed]\"),\n );\n if (!fixed.length) return undefined;\n // The picture's own attributes (viewBox, fonts, fills) without its id.\n const layer = svg.cloneNode(false) as SVGSVGElement;\n layer.removeAttribute(\"id\");\n layer.setAttribute(\"aria-hidden\", \"true\");\n layer.style.cssText = \"position:absolute;inset:0;overflow:visible\";\n for (const el of fixed) layer.appendChild(el);\n return layer;\n}\n\nexport interface SvgViewOptions {\n /**\n * Called with the id of the innermost element with an id that is clicked:\n * its id in the motion's markup (in the page, ids carry a suffix that keeps\n * them unique, so several pictures can use the same ones).\n */\n onPick?: (id: string) => void;\n}\n\n/** An {@link SvgMotion} drawn into an element; call `draw` with a time to show it then. */\nexport interface SvgView {\n /** A `div` filled by the picture; put it anywhere. */\n readonly element: HTMLDivElement;\n /** Shows the picture at `timeMs`, with steps starting at `steps` (ms). */\n draw(timeMs: number, steps?: readonly number[]): void;\n /** An image of the picture as drawn now. */\n capture(pixels: { width: number; height: number }): Promise<HTMLCanvasElement | undefined>;\n}\n\n/** Shows an {@link SvgMotion} as a live view; with `onPick`, clicks report the id of the element clicked. */\nexport function svgView(motion: SvgMotion, options: SvgViewOptions = {}): SvgView {\n const element = document.createElement(\"div\");\n element.style.width = \"100%\";\n element.style.height = \"100%\";\n const { onPick } = options;\n if (onPick)\n element.addEventListener(\"click\", (event) => {\n // The innermost element with an id, up to the picture itself.\n for (let el = event.target as Element | null; el && el !== element; el = el.parentElement)\n if (el.id && el.localName !== \"svg\") return onPick(el.getAttribute(\"data-flair-id\") ?? el.id);\n });\n let svg: SVGSVGElement | undefined | null = null;\n let fixed: SVGSVGElement | undefined;\n let nonscaling: Element[] = [];\n let whole: SvgBox = [0, 0, 100, 100];\n const byId = new Map<string, Element>();\n let ids: ReadonlyMap<string, string> = new Map();\n const suffix = `f${++views}`;\n return {\n element,\n draw(timeMs, steps = []) {\n if (svg === null) {\n // Parsed on first use, so a view made and dropped costs nothing.\n svg = parseSvg(motion.svg);\n if (svg) {\n ids = scopeIds(svg, suffix);\n svg.setAttribute(\"width\", \"100%\");\n svg.setAttribute(\"height\", \"100%\");\n element.appendChild(svg);\n fixed = fixedLayer(svg);\n if (fixed) {\n element.style.position = \"relative\";\n element.appendChild(fixed);\n }\n for (const layer of [svg, fixed])\n for (const el of layer?.querySelectorAll(\"[id]\") ?? [])\n byId.set(el.getAttribute(\"data-flair-id\") ?? el.id, el);\n nonscaling = [...svg.querySelectorAll(\"[data-nonscaling]\")];\n const box = (svg.getAttribute(\"viewBox\") ?? \"\")\n .trim()\n .split(/[\\s,]+/)\n .map(Number);\n if (box.length === 4 && box.every(Number.isFinite)) whole = box as unknown as SvgBox;\n }\n }\n if (svg) {\n apply(svg, whole, byId, motion, timeMs, steps, ids);\n keepSize(svg, whole, nonscaling);\n }\n },\n capture: async (pixels) => (svg ? rasterize(fixed ? [svg, fixed] : [svg], pixels) : undefined),\n };\n}\n\n/** How long an {@link SvgMotion} runs: its last change's end, in ms (at least 1). */\nexport function svgDuration(motion: SvgMotion, steps: readonly number[] = []): number {\n let end = 0;\n for (const a of motion.animate ?? []) {\n const step = a.step ?? 0;\n const start = step <= 0 ? 0 : steps[step - 1];\n if (start === undefined) continue;\n end = Math.max(end, start + (a.delay ?? 0) + (a.ms ?? 800));\n }\n return Math.max(1, end);\n}\n\nexport interface SvgPlayerOptions extends SvgViewOptions {\n /** Time source (default: animation frames). Pass a `ManualClock` to step frames yourself. */\n clock?: Clock;\n /** Start playing at once (default `true`). */\n autoplay?: boolean;\n /**\n * Start again at the end (default `true`). When `false` it plays once and\n * stays on the last frame (hidden instead with `hideWhenPaused`).\n */\n loop?: boolean;\n /** Loop length in ms (default: the picture's own, see {@link svgDuration}, plus `hold`). */\n duration?: number;\n /** Ms to rest on the last frame before looping (default 600). */\n hold?: number;\n /** Playback speed (default 1). */\n speed?: number;\n /** Step start times in ms, for pictures that change on steps (default none). */\n steps?: readonly number[];\n /** Pause the animation loop when scrolled out of view via IntersectionObserver (default false). */\n pauseWhenHidden?: boolean;\n /** Wait to start playing until the element enters the viewport via IntersectionObserver (default false). When true, autoplay is deferred until first visible. */\n playOnEnter?: boolean;\n /** Hide the view (`visibility: hidden`) whenever playback is paused or reset (default false). */\n hideWhenPaused?: boolean;\n /**\n * Plays in answer to the pointer or the page instead of on its own (see\n * {@link SvgTrigger}): `\"hover\"` and `\"press\"` play to the end while\n * hovered or held and back to the start after; `\"click\"` plays the next\n * step on each click, starting over after the last; `\"scroll\"` follows\n * the trigger target's progress through the viewport (see `scrollRange`),\n * scrubbing back and forth as the page scrolls. `autoplay`, `loop` and\n * `steps` are ignored.\n */\n trigger?: SvgTrigger;\n /** The element whose pointer events trigger it, or whose scrolling a scroll trigger follows (default the container). */\n triggerTarget?: HTMLElement;\n /**\n * For a scroll trigger: the stretch of the target's progress through the\n * viewport (0 as its top comes in at the bottom, 1 as its bottom leaves at\n * the top) over which the picture plays from start to end (default\n * `[0.1, 0.6]`: from just after it comes into view to a little past the\n * middle).\n */\n scrollRange?: readonly [number, number];\n}\n\n/** What makes a triggered {@link SvgPlayer} play. */\nexport type SvgTrigger = \"hover\" | \"press\" | \"click\" | \"scroll\";\n\n/** The stretch of the viewport a scroll-triggered picture plays over (see `SvgPlayerOptions.scrollRange`). */\nexport const SCROLL_RANGE: readonly [number, number] = [0.1, 0.6];\n\n/**\n * Plays an {@link SvgMotion} inside `container`: loops by default, and can be\n * paused, sought and sped up. Dispose it to stop and remove the picture.\n */\nexport class SvgPlayer {\n readonly view: SvgView;\n private readonly clock: Clock;\n private steps: readonly number[];\n private readonly loop: boolean;\n private length: number;\n private readonly motion: SvgMotion;\n private readonly trigger?: SvgTrigger;\n private readonly triggerTarget?: HTMLElement;\n /** With a hover or press trigger: 1 playing to the end, -1 back to the start. */\n private direction = 1;\n /** With a click trigger: when each click came, in ms of playback. */\n private clicks: number[] = [];\n private readonly hideWhenPaused: boolean;\n private speed: number;\n private time = 0;\n private last = 0;\n private playing = false;\n private disposed = false;\n private wasPlayingBeforeHidden = false;\n private hasEnteredViewport = false;\n private intersectionObserver?: IntersectionObserver;\n private readonly scrollRange: readonly [number, number];\n /** A scroll trigger's pending update (one per frame). */\n private scrollFrame = 0;\n private followingScroll = false;\n\n constructor(\n private readonly container: HTMLElement,\n motion: SvgMotion,\n options: SvgPlayerOptions = {},\n ) {\n this.clock = options.clock ?? realClock;\n this.motion = motion;\n this.trigger = options.trigger;\n this.steps = this.trigger ? [] : (options.steps ?? []);\n this.loop = this.trigger ? false : (options.loop ?? true);\n this.speed = options.speed ?? 1;\n this.hideWhenPaused = Boolean(options.hideWhenPaused);\n this.scrollRange = options.scrollRange ?? SCROLL_RANGE;\n this.length = options.duration ?? svgDuration(motion, this.steps) + (options.hold ?? 600);\n this.view = svgView(motion, options);\n container.appendChild(this.view.element);\n this.view.draw(0, this.steps);\n\n const needsObserver =\n (options.pauseWhenHidden || options.playOnEnter) && typeof IntersectionObserver !== \"undefined\";\n\n if (needsObserver) {\n this.intersectionObserver = new IntersectionObserver(([entry]) => {\n if (!entry) return;\n if (entry.isIntersecting) {\n if (options.playOnEnter && !this.hasEnteredViewport) {\n this.hasEnteredViewport = true;\n if (options.autoplay ?? true) {\n this.play();\n }\n } else if (this.wasPlayingBeforeHidden) {\n this.wasPlayingBeforeHidden = false;\n this.play();\n }\n } else {\n if (this.playing && options.pauseWhenHidden) {\n this.wasPlayingBeforeHidden = true;\n this.pause();\n }\n }\n });\n this.intersectionObserver.observe(this.view.element);\n }\n\n if (this.trigger === \"scroll\") {\n this.length = options.duration ?? svgDuration(motion);\n this.triggerTarget = options.triggerTarget ?? container;\n this.followingScroll = true;\n this.listen(true);\n this.followScroll();\n return;\n }\n\n if (this.trigger) {\n // A click-triggered picture runs until its latest step is over, however many clicks.\n // Hovers and presses run to the last change and back, with no rest to wait through.\n this.length = this.trigger === \"click\" ? Infinity : (options.duration ?? svgDuration(motion));\n this.triggerTarget = options.triggerTarget ?? container;\n this.listen(true);\n return;\n }\n\n // Without IntersectionObserver (a server, a test), nothing would say it entered: play at once.\n const shouldAutoplay = (options.autoplay ?? true) && !(options.playOnEnter && needsObserver);\n if (shouldAutoplay) {\n this.play();\n } else if (this.hideWhenPaused) {\n this.view.element.style.visibility = \"hidden\";\n }\n }\n\n /** The loop length in ms. */\n get duration(): number {\n return this.length;\n }\n\n /** The time shown, in ms. */\n get currentTime(): number {\n return this.time;\n }\n\n get isPlaying(): boolean {\n return this.playing;\n }\n\n play(): void {\n if (this.playing || this.disposed) return;\n this.playing = true;\n if (this.hideWhenPaused) this.view.element.style.visibility = \"visible\";\n this.last = this.clock.now();\n void this.run();\n }\n\n pause(): void {\n this.playing = false;\n if (this.hideWhenPaused) this.view.element.style.visibility = \"hidden\";\n }\n\n /** Stops playback, rewinds to `0 ms`, and hides the view if `hideWhenPaused` is enabled. */\n reset(): void {\n this.playing = false;\n this.wasPlayingBeforeHidden = false;\n this.seek(0);\n if (this.hideWhenPaused) this.view.element.style.visibility = \"hidden\";\n }\n\n /** Shows the picture at `ms` (wrapped into the loop when looping). */\n seek(ms: number): void {\n this.time = this.loop\n ? ((ms % this.length) + this.length) % this.length\n : Math.min(Math.max(ms, 0), this.length);\n this.view.draw(this.time, this.steps);\n }\n\n /**\n * Shows the picture at `progress` of the way through it, 0–1: how hosts\n * scrub it themselves (a slider, a scroll position of their own). A scroll\n * trigger stops following the page once a host calls this.\n */\n setProgress(progress: number): void {\n if (this.followingScroll) {\n this.followingScroll = false;\n this.listen(false);\n }\n this.playing = false;\n this.seek(Math.min(1, Math.max(0, progress)) * (Number.isFinite(this.length) ? this.length : svgDuration(this.motion, this.steps)));\n }\n\n /**\n * A scroll trigger's playback position, 0–1, for the trigger target's\n * `progress` through the viewport (see {@link SvgPlayerOptions.scrollRange}).\n */\n scrollPosition(progress: number): number {\n const [from, to] = this.scrollRange;\n return to > from ? Math.min(1, Math.max(0, (progress - from) / (to - from))) : progress >= to ? 1 : 0;\n }\n\n setSpeed(speed: number): void {\n this.speed = speed;\n }\n\n /**\n * Plays to the end (`true`) or back to the start (`false`) from wherever it\n * is: what a hover or press trigger does, for hosts that drive it themselves\n * (a hovered card, a focused button).\n */\n setActive(active: boolean): void {\n this.direction = active ? 1 : -1;\n this.play();\n }\n\n /**\n * Plays the picture's next step (what a click trigger does): steps 1, 2, …\n * in turn, then step 1 again, so a picture whose last step leads back to\n * how it started toggles; one with no steps plays again from the start.\n */\n advance(): void {\n const last = Math.max(0, ...(this.motion.animate ?? []).map((a) => a.step ?? 0));\n if (last === 0) {\n this.clicks = [];\n this.time = 0;\n } else {\n this.clicks.push(this.time);\n // Only the clicks of the current round count, so each round starts from how the last ended.\n this.steps = this.clicks.slice(Math.floor((this.clicks.length - 1) / last) * last);\n }\n this.view.draw(this.time, this.steps);\n this.play();\n }\n\n dispose(): void {\n this.disposed = true;\n this.playing = false;\n if (this.trigger && (this.trigger !== \"scroll\" || this.followingScroll)) this.listen(false);\n if (this.scrollFrame && typeof cancelAnimationFrame !== \"undefined\") cancelAnimationFrame(this.scrollFrame);\n this.intersectionObserver?.disconnect();\n this.view.element.remove();\n }\n\n private onEnter = () => this.setActive(true);\n private onLeave = () => this.setActive(false);\n private onClick = () => this.advance();\n\n /** Seeks to where the trigger target is in the viewport. */\n private followScroll = () => {\n this.scrollFrame = 0;\n if (!this.followingScroll || this.disposed) return;\n const rect = this.triggerTarget!.getBoundingClientRect();\n const viewport = window.innerHeight || document.documentElement.clientHeight || 1;\n const travel = viewport + rect.height;\n const progress = travel > 0 ? Math.min(1, Math.max(0, (viewport - rect.top) / travel)) : 0;\n this.seek(this.scrollPosition(progress) * this.length);\n };\n\n /** A scroll or resize: follow it on the next frame (or now, without frames). */\n private onScroll = () => {\n if (typeof requestAnimationFrame === \"undefined\") return this.followScroll();\n if (!this.scrollFrame) this.scrollFrame = requestAnimationFrame(this.followScroll);\n };\n\n private listen(on: boolean) {\n const target = this.triggerTarget!;\n const method = on ? \"addEventListener\" : \"removeEventListener\";\n if (this.trigger === \"scroll\") {\n // Any scroll that may move the target: the page's or a scrolling element's.\n window[method](\"scroll\", this.onScroll, { capture: true, passive: true } as AddEventListenerOptions);\n window[method](\"resize\", this.onScroll, { passive: true } as AddEventListenerOptions);\n } else if (this.trigger === \"hover\") {\n target[method](\"pointerenter\", this.onEnter);\n target[method](\"pointerleave\", this.onLeave);\n } else if (this.trigger === \"press\") {\n target[method](\"pointerdown\", this.onEnter);\n window[method](\"pointerup\", this.onLeave);\n window[method](\"pointercancel\", this.onLeave);\n } else target[method](\"click\", this.onClick);\n }\n\n private async run(): Promise<void> {\n while (this.playing && !this.disposed) {\n await this.clock.frame();\n if (!this.playing || this.disposed) return;\n const now = this.clock.now();\n const dt = (now - this.last) * this.speed;\n this.last = now;\n if (this.trigger === \"click\") {\n // Rest once the latest step is over, until the next click.\n const end = svgDuration(this.motion, this.steps);\n this.time = Math.min(this.time + dt, Math.max(end, this.time));\n this.view.draw(this.time, this.steps);\n if (this.time >= end) this.playing = false;\n continue;\n }\n if (this.trigger) {\n const next = Math.min(Math.max(this.time + dt * this.direction, 0), this.length);\n this.seek(next);\n if (next === 0 || next === this.length) this.playing = false;\n continue;\n }\n const next = this.time + dt;\n if (!this.loop && next >= this.length) {\n this.seek(this.length);\n this.playing = false;\n if (this.hideWhenPaused) this.view.element.style.visibility = \"hidden\";\n return;\n }\n this.seek(next);\n }\n }\n}\n\nexport interface AnimateCountOptions {\n /** Starting number. */\n from: number;\n /** Ending number. */\n to: number;\n /** Duration in ms (default {@link STEP_MS}). */\n ms?: number;\n /** Delay before starting in ms (default 0). */\n delay?: number;\n /** Easing curve (default `\"out\"`), by name or as a `[x1, y1, x2, y2]` cubic-bezier. */\n ease?: SvgEase;\n /** Number of decimal places (default 0). */\n decimals?: number;\n /** Format template where `{n}` is replaced by the formatted number (default `\"{n}\"`). */\n format?: string;\n /** Time source (default: animation frames). */\n clock?: Clock;\n /** Called with each formatted text frame (and raw numeric value). */\n onUpdate: (text: string, value: number) => void;\n}\n\n/**\n * Counts a number from `from` to `to` over `ms` using Flair's easing curves\n * and `Clock`, calling `onUpdate` with the formatted string on each frame.\n * Returns a cancel function that stops the animation.\n */\nexport function animateCount(options: AnimateCountOptions): () => void {\n const clock = options.clock ?? realClock;\n const ms = options.ms ?? STEP_MS;\n const delay = options.delay ?? 0;\n const ease = easeFunction(options.ease, \"out\");\n const start = clock.now();\n let stopped = false;\n\n const emit = (u: number) => {\n const v = options.from + (options.to - options.from) * ease(u);\n options.onUpdate(formatCount(v, options), v);\n };\n\n emit(ms <= 0 && delay <= 0 ? 1 : 0);\n if (ms <= 0 && delay <= 0) return () => {};\n\n void (async () => {\n while (!stopped) {\n await clock.frame();\n if (stopped) return;\n const elapsed = clock.now() - start - delay;\n if (elapsed < 0) continue;\n if (ms <= 0 || elapsed >= ms) {\n emit(1);\n return;\n }\n emit(elapsed / ms);\n }\n })();\n\n return () => {\n stopped = true;\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAM,SAAS;AAOR,SAAS,SAAS,QAA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AAU,EAAG;AACjB,UAAI,MAAM,KAAK,WAAW,IAAI;AAC5B,aAAK,CAAC;AACN;AAAA,MACF;AACA,WAAK,UAAU,EAAE;AAAA,IACnB;AAAA,EACF,GAAG;AAEH,SAAO,MAAM;AACX,cAAU;AAAA,EACZ;AACF;","names":["next"]}
@@ -12,7 +12,7 @@ import {
12
12
  getEffect,
13
13
  renderVectorEffect,
14
14
  textImage
15
- } from "./chunk-IHUNCBMF.js";
15
+ } from "./chunk-Z3LKEODP.js";
16
16
  import {
17
17
  parseColor
18
18
  } from "./chunk-VYOMXE6I.js";
@@ -20,7 +20,7 @@ import {
20
20
  SvgPlayer,
21
21
  svgDuration,
22
22
  svgView
23
- } from "./chunk-JETRHCP3.js";
23
+ } from "./chunk-XAQ5FWKS.js";
24
24
 
25
25
  // src/export/mp4mux.ts
26
26
  var AAC_RATES = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350];
@@ -1126,4 +1126,4 @@ export {
1126
1126
  subjectValues,
1127
1127
  mountEffect
1128
1128
  };
1129
- //# sourceMappingURL=chunk-2O3RMSOE.js.map
1129
+ //# sourceMappingURL=chunk-XFTSWPSX.js.map
@@ -14,7 +14,7 @@ import {
14
14
  lerpAttr,
15
15
  morphPaths,
16
16
  morphSequence
17
- } from "./chunk-VKIDRHBG.js";
17
+ } from "./chunk-6B62CBTP.js";
18
18
 
19
19
  // src/catalog/inputs.ts
20
20
  var EFFECT_INPUTS = ["image", "video", "svg", "text", "mask", "path", "audio"];
@@ -28548,4 +28548,4 @@ export {
28548
28548
  effectControls,
28549
28549
  effectDefaults
28550
28550
  };
28551
- //# sourceMappingURL=chunk-IHUNCBMF.js.map
28551
+ //# sourceMappingURL=chunk-Z3LKEODP.js.map
package/dist/cli.js CHANGED
@@ -183,7 +183,7 @@ var collect = (value, previous) => [...previous, value];
183
183
  program.command("effects").description("List catalog effects with what they take (image, video, svg, text, mask, path) and how they answer the pointer").option("--accepts <inputs>", "Only effects that take all of these (image, video, svg, text, mask, path; comma-separated or repeated)", collect, []).option("--interaction <ways>", "Only effects that answer the pointer in one of these ways (hover, press, click, trail, pointer)", collect, []).option("--category <category>", "Only this category").option("--kind <kind>", "shader or vector").option("--search <words>", "Words to look for in the id, name, description and tags").option("--json", "Output JSON (id, name, kind, category, description, inputs, presets)", false).action(async (options) => {
184
184
  try {
185
185
  const { findEffects, effectInputs } = await import("./catalog/index.js");
186
- const { effectQueryFromFlags, describeEffect } = await import("./effect-HL4XF4FD.js");
186
+ const { effectQueryFromFlags, describeEffect } = await import("./effect-RXOSCAK2.js");
187
187
  const effects = findEffects(effectQueryFromFlags(options));
188
188
  if (options.json) {
189
189
  console.log(JSON.stringify(effects.map((e) => ({ id: e.id, name: e.name, kind: e.kind, category: e.category, description: e.description, inputs: effectInputs(e), presets: e.presets?.map((p) => p.name) ?? [] })), null, 2));
@@ -204,7 +204,7 @@ ${effects.length} effect${effects.length === 1 ? "" : "s"}. Render one with: fla
204
204
  program.command("render <effect>").description("Render a catalog effect, applied to a subject, to .mp4, .webm, .mov, .gif, .svg (vector effects) or .png frames").option("--image <path>", "A picture (file path or URL); repeat for effects that take two", collect, []).option("--svg <path>", "An SVG (file path, URL or markup)", collect, []).option("--text <text>", "Words, for a text effect or a text mask", collect, []).option("--font <family>", "CSS font family for --text drawn into a shader").option("--weight <weight>", "Font weight for --text drawn into a shader").option("--path <d>", "SVG path data, for a shape control", collect, []).option("--video <path>", "A video file, decoded to frames with ffmpeg", collect, []).option("--preset <name>", "A preset by name").option("--set <name=value>", "A control value (repeatable): --set uSpeed=2 --set uTint=#ff0080", collect, []).option("--size <WxH>", "Pixels, like 1280x720").option("--fps <fps>", "Frames per second", "30").option("--duration <seconds>", "Seconds (default: the effect's loop or play-through)").option("--alpha", "Keep transparency (webm, mov, gif, png, svg)", false).option("--background <css>", "Colour under transparent pixels without --alpha").option("--no-pointer", "Leave the pointer still (interactive effects otherwise get a scripted pointer)").option("-o, --out <outputPath>", "Output: .mp4, .webm, .mov, .gif, .svg, a .png pattern (out_%04d.png) or a folder").action(async (effectId, options) => {
205
205
  try {
206
206
  if (!options.out) throw new Error("Say where to write it: -o out.mp4 (or .webm, .mov, .gif, .svg, out_%04d.png, a folder/).");
207
- const { exportEffect, parseSets, parseSize, resolveEffect, subjectsFromFlags } = await import("./effect-HL4XF4FD.js");
207
+ const { exportEffect, parseSets, parseSize, resolveEffect, subjectsFromFlags } = await import("./effect-RXOSCAK2.js");
208
208
  const effect = resolveEffect(effectId);
209
209
  const subjects = subjectsFromFlags(options);
210
210
  const size = options.size ? parseSize(options.size) : void 0;
@@ -1,13 +1,14 @@
1
- import { i as VectorControl, f as EffectPreset, E as EffectDefinition } from '../types-B4Wjzde0.js';
1
+ import { i as VectorControl, f as EffectPreset, E as EffectDefinition } from '../types-CVgiEJyP.js';
2
2
  import { C as ControlValue, a as ControlDef, b as ControlType } from '../controls-Ec6P0Vpy.js';
3
- import { S as SvgMotion, C as Clock } from '../svg-DaKRPA9v.js';
4
- import { AnimationEasingPreset, AnimationEasing, AnimationTrack, AnimationKeyframe, cubicBezierAt as cubicBezierAt$1, evaluateEasing as evaluateEasing$1 } from '@pixerate/editor/animation';
3
+ import { S as SvgMotion, C as Clock } from '../svg-cunB0HBn.js';
4
+ import { AnimationTrack, AnimationKeyframe, AnimationEasingPreset, AnimationEasing, cubicBezierAt as cubicBezierAt$1, evaluateEasing as evaluateEasing$1 } from '@pixerate/editor/animation';
5
5
  export { CubicBezierEasing, SpringEasing } from '@pixerate/editor/animation';
6
6
  import { CommandRegistry, CommandSpec } from '@pixerate/editor/commands';
7
7
  import { HistoryManager, HistoryState } from '@pixerate/editor/history';
8
8
  import { C as CompileError, b as CompileStatus } from '../renderer-tk1nbVkW.js';
9
9
  import { AgentToolProvider, McpToolResult, ToolRegistryOptions, ToolRegistry, McpToolDefinition } from '@pixerate/editor/tools';
10
10
  import { ParameterImageOption, ParametersController, ParameterField, ParameterSchema, ParameterValue, ParameterValues } from '@pixerate/editor/parameters';
11
+ export { MotionScene } from '@pixerate/editor/animation-editor';
11
12
 
12
13
  /**
13
14
  * Keyframed control values. A track holds keyframes `{ time (ms), value,
@@ -121,6 +122,33 @@ declare function parseEffectDocument(input: string | unknown): {
121
122
  errors: string[];
122
123
  };
123
124
 
125
+ /**
126
+ * Opening animations made with `@pixerate/editor`'s animation editor
127
+ * (`@pixerate/editor/animation-editor`): a scene of shots over vector
128
+ * artwork becomes a vector effect document, with the scene's colour controls
129
+ * as `{{name: color}}` placeholders and its presets kept.
130
+ */
131
+
132
+ interface AnimationImportOptions {
133
+ /** Sampling rate for motion Flair cannot express exactly (default: the scene's `fps`, else 30). */
134
+ fps?: number;
135
+ }
136
+ type AnimationImport = {
137
+ ok: true;
138
+ document: EffectDocument;
139
+ /** The scene's warnings and notes, as lines; they do not stop the import. */
140
+ warnings: string[];
141
+ } | {
142
+ ok: false;
143
+ message: string;
144
+ };
145
+ /**
146
+ * A vector effect document from an animation-editor scene (JSON text or a
147
+ * parsed object). Refuses a malformed scene, or one with errors (an unknown
148
+ * node id, say), listing every problem.
149
+ */
150
+ declare function effectDocumentFromAnimation(scene: unknown, options?: AnimationImportOptions): AnimationImport;
151
+
124
152
  /**
125
153
  * A UI-agnostic effect editor: the document, its undo history, a playhead,
126
154
  * and commands that menus, shortcuts, a palette and agents all run by id.
@@ -208,6 +236,14 @@ declare class EffectEditor {
208
236
  source: string;
209
237
  name?: string;
210
238
  }, preset?: string): EditResult;
239
+ /**
240
+ * Starts over from an animation made with `@pixerate/editor`'s animation
241
+ * editor (a `MotionScene`, as JSON text or an object), as a vector effect
242
+ * (one undo step). Refuses a scene with errors; its warnings come back.
243
+ */
244
+ loadAnimation(scene: unknown, options?: AnimationImportOptions): EditResult & {
245
+ warnings?: string[];
246
+ };
211
247
  rename(name: string): EditResult;
212
248
  /** Replaces a shader's source. Compile errors arrive later, from the renderer (see `reportCompile`). */
213
249
  setSource(source: string): EditResult;
@@ -463,4 +499,4 @@ interface EffectParametersBinding {
463
499
  */
464
500
  declare function bindEffectParameters(editor: EffectEditor, options?: EffectParameterOptions): EffectParametersBinding;
465
501
 
466
- export { CATALOG_SEARCH_LIMIT, type CompileReport, EASING_PRESETS, EFFECT_AGENT_INSTRUCTIONS, type Easing, type EasingPreset, type EditResult, type EffectDocument, EffectEditor, type EffectEditorOptions, type EffectEditorState, type EffectParameterOptions, type EffectParametersBinding, type EffectSource, type EffectToolProviderOptions, type Keyframe, type ShaderPreview, type Track, bindEffectParameters, bindShaderRenderer, bindSvgView, callTool, createEffectDocument, createEffectEditor, createEffectToolProvider, createEffectToolRegistry, cubicBezierAt, describeEditor, documentControls, documentIssues, effectCommands, evaluateEasing, evaluateTrack, interpolateControlValue, isEasing, keyframeTimes, motionAt, normalizeKeyframes, parameterFieldFor, parameterSchemaFor, parseEffectDocument, toParameterValue, toParameterValues, toolDefinitions, valuesAt };
502
+ export { type AnimationImport, type AnimationImportOptions, CATALOG_SEARCH_LIMIT, type CompileReport, EASING_PRESETS, EFFECT_AGENT_INSTRUCTIONS, type Easing, type EasingPreset, type EditResult, type EffectDocument, EffectEditor, type EffectEditorOptions, type EffectEditorState, type EffectParameterOptions, type EffectParametersBinding, type EffectSource, type EffectToolProviderOptions, type Keyframe, type ShaderPreview, type Track, bindEffectParameters, bindShaderRenderer, bindSvgView, callTool, createEffectDocument, createEffectEditor, createEffectToolProvider, createEffectToolRegistry, cubicBezierAt, describeEditor, documentControls, documentIssues, effectCommands, effectDocumentFromAnimation, evaluateEasing, evaluateTrack, interpolateControlValue, isEasing, keyframeTimes, motionAt, normalizeKeyframes, parameterFieldFor, parameterSchemaFor, parseEffectDocument, toParameterValue, toParameterValues, toolDefinitions, valuesAt };
@@ -16,7 +16,7 @@ import {
16
16
  renderVectorEffect,
17
17
  vectorControlIssues,
18
18
  vectorEffectControls
19
- } from "../chunk-IHUNCBMF.js";
19
+ } from "../chunk-Z3LKEODP.js";
20
20
  import "../chunk-EHDJ3CPJ.js";
21
21
  import {
22
22
  checkControlValue,
@@ -26,13 +26,13 @@ import {
26
26
  import {
27
27
  svgDuration,
28
28
  svgView
29
- } from "../chunk-JETRHCP3.js";
29
+ } from "../chunk-XAQ5FWKS.js";
30
30
  import {
31
31
  realClock
32
32
  } from "../chunk-WMZQCUFJ.js";
33
33
  import {
34
34
  svgMotionIssues
35
- } from "../chunk-VKIDRHBG.js";
35
+ } from "../chunk-6B62CBTP.js";
36
36
 
37
37
  // src/editor/timeline.ts
38
38
  import {
@@ -223,6 +223,28 @@ function parseEffectDocument(input) {
223
223
  import { createCommandRegistry, createHistoryCommands } from "@pixerate/editor/commands";
224
224
  import { createHistoryManager, HistoryManager } from "@pixerate/editor/history";
225
225
 
226
+ // src/editor/animation.ts
227
+ import { checkMotionScene, motionIssueLine, parseMotionScene, toFlairEffectDocument } from "@pixerate/editor/animation-editor";
228
+ function effectDocumentFromAnimation(scene, options = {}) {
229
+ let parsed;
230
+ try {
231
+ parsed = parseMotionScene(scene);
232
+ } catch (error) {
233
+ return { ok: false, message: error.message };
234
+ }
235
+ const issues = checkMotionScene(parsed);
236
+ const errors = issues.filter((i) => i.severity === "error");
237
+ if (errors.length) return { ok: false, message: `The animation has ${errors.length} error${errors.length === 1 ? "" : "s"}: ${errors.map(motionIssueLine).join(" ")}` };
238
+ const exported = toFlairEffectDocument(parsed, options.fps ? { fps: options.fps } : {});
239
+ const checked = parseEffectDocument(exported);
240
+ if (!checked.ok) return { ok: false, message: `The exported effect is not valid: ${checked.errors.join("; ")}` };
241
+ return {
242
+ ok: true,
243
+ document: checked.document,
244
+ warnings: issues.filter((i) => i.severity !== "error").map((i) => `${i.severity}: ${motionIssueLine(i)}`)
245
+ };
246
+ }
247
+
226
248
  // src/editor/commands.ts
227
249
  function done(result) {
228
250
  if (!result.ok) throw new Error(result.message);
@@ -356,6 +378,26 @@ function effectCommands() {
356
378
  },
357
379
  run: (editor, p) => done(p?.source !== void 0 ? editor.load({ source: p.source, name: p.name }) : editor.load(p?.id, p?.preset))
358
380
  },
381
+ {
382
+ id: "effect.loadAnimation",
383
+ label: "Open animation",
384
+ group: "Effect",
385
+ description: "Starts over from an animation made with @pixerate/editor's animation editor: a MotionScene ({version: 1, name, artwork, shots, controls?, presets?, \u2026}) becomes a vector effect, its colour controls become {{name: color}} placeholders and its presets are kept. Refuses a scene with errors (unknown node ids, malformed commands) and lists them; returns the scene's warnings and the document's issues.",
386
+ params: {
387
+ type: "object",
388
+ properties: {
389
+ scene: { type: "object", description: "The MotionScene, as stored by the animation editor." },
390
+ fps: { type: "number", minimum: 1, maximum: 120, description: "Sampling rate for motion Flair cannot express exactly (default: the scene's fps, else 30)." }
391
+ },
392
+ required: ["scene"],
393
+ additionalProperties: false
394
+ },
395
+ run: (editor, p) => {
396
+ const result = editor.loadAnimation(p.scene, p.fps ? { fps: p.fps } : {});
397
+ done(result);
398
+ return { ok: true, warnings: result.ok ? result.warnings ?? [] : [], issues: editor.getState().issues };
399
+ }
400
+ },
359
401
  {
360
402
  id: "effect.setSource",
361
403
  label: "Set shader source",
@@ -662,6 +704,18 @@ var EffectEditor = class {
662
704
  this.commit(`Load ${next.name}`, next);
663
705
  return ok;
664
706
  }
707
+ /**
708
+ * Starts over from an animation made with `@pixerate/editor`'s animation
709
+ * editor (a `MotionScene`, as JSON text or an object), as a vector effect
710
+ * (one undo step). Refuses a scene with errors; its warnings come back.
711
+ */
712
+ loadAnimation(scene, options = {}) {
713
+ const imported = effectDocumentFromAnimation(scene, options);
714
+ if (!imported.ok) return fail(imported.message);
715
+ this.compileReport = null;
716
+ this.commit(`Load ${imported.document.name}`, imported.document);
717
+ return { ok: true, warnings: imported.warnings };
718
+ }
665
719
  rename(name) {
666
720
  if (!name.trim()) return fail("A name cannot be empty.");
667
721
  this.commit("Rename", { ...this.doc, name: name.trim() });
@@ -1187,6 +1241,7 @@ export {
1187
1241
  documentControls,
1188
1242
  documentIssues,
1189
1243
  effectCommands,
1244
+ effectDocumentFromAnimation,
1190
1245
  evaluateEasing,
1191
1246
  evaluateTrack,
1192
1247
  interpolateControlValue,