@pixerate/flair 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +254 -2
- package/dist/catalog/index.d.ts +74 -0
- package/dist/catalog/index.js +47 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-36DTNSHU.js +160 -0
- package/dist/chunk-36DTNSHU.js.map +1 -0
- package/dist/chunk-3FAUZOGL.js +331 -0
- package/dist/chunk-3FAUZOGL.js.map +1 -0
- package/dist/chunk-CFCLT2XL.js +1 -0
- package/dist/chunk-CFCLT2XL.js.map +1 -0
- package/dist/chunk-EHDJ3CPJ.js +327 -0
- package/dist/chunk-EHDJ3CPJ.js.map +1 -0
- package/dist/chunk-G5FNZDTA.js +536 -0
- package/dist/chunk-G5FNZDTA.js.map +1 -0
- package/dist/chunk-HKXOHRCD.js +763 -0
- package/dist/chunk-HKXOHRCD.js.map +1 -0
- package/dist/chunk-J55UBNAT.js +164 -0
- package/dist/chunk-J55UBNAT.js.map +1 -0
- package/dist/chunk-JWZCPMFG.js +2074 -0
- package/dist/chunk-JWZCPMFG.js.map +1 -0
- package/dist/chunk-MWVTQFV5.js +1894 -0
- package/dist/chunk-MWVTQFV5.js.map +1 -0
- package/dist/chunk-UQQNZSYL.js +594 -0
- package/dist/chunk-UQQNZSYL.js.map +1 -0
- package/dist/chunk-WMZQCUFJ.js +73 -0
- package/dist/chunk-WMZQCUFJ.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +331 -0
- package/dist/cli.js.map +1 -0
- package/dist/clock-BhdXWH-n.d.ts +47 -0
- package/dist/controls-DdXMbovi.d.ts +97 -0
- package/dist/editor/index.d.ts +413 -0
- package/dist/editor/index.js +1009 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/export-FEBPEEO7.js +22 -0
- package/dist/export-FEBPEEO7.js.map +1 -0
- package/dist/index.d.ts +1431 -0
- package/dist/index.js +1263 -0
- package/dist/index.js.map +1 -0
- package/dist/motion-D0TVv2CF.d.ts +148 -0
- package/dist/node.d.ts +24 -0
- package/dist/node.js +10 -0
- package/dist/node.js.map +1 -0
- package/dist/recorder-WJTWMEQN.js +10 -0
- package/dist/recorder-WJTWMEQN.js.map +1 -0
- package/dist/renderer-Oyynz-fs.d.ts +293 -0
- package/dist/types-CkKkavvB.d.ts +71 -0
- package/dist/vector/index.d.ts +83 -0
- package/dist/vector/index.js +39 -0
- package/dist/vector/index.js.map +1 -0
- package/package.json +96 -4
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import {
|
|
2
|
+
realClock
|
|
3
|
+
} from "./chunk-WMZQCUFJ.js";
|
|
4
|
+
|
|
5
|
+
// src/vector/motion.ts
|
|
6
|
+
var EASES = {
|
|
7
|
+
linear: (t) => t,
|
|
8
|
+
"in-out": (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2,
|
|
9
|
+
out: (t) => 1 - (1 - t) ** 3
|
|
10
|
+
};
|
|
11
|
+
var STEP_MS = 800;
|
|
12
|
+
var clamp01 = (t) => t < 0 ? 0 : t > 1 ? 1 : t;
|
|
13
|
+
function stepStart(steps, step) {
|
|
14
|
+
if (step <= 0) return 0;
|
|
15
|
+
return steps[step - 1];
|
|
16
|
+
}
|
|
17
|
+
function stepProgress(steps, timeMs, step, options = {}) {
|
|
18
|
+
const start = stepStart(steps, step);
|
|
19
|
+
if (start === void 0) return 0;
|
|
20
|
+
const from = start + (options.delay ?? 0);
|
|
21
|
+
const ms = options.ms ?? STEP_MS;
|
|
22
|
+
const t = ms > 0 ? clamp01((timeMs - from) / ms) : timeMs >= from ? 1 : 0;
|
|
23
|
+
return EASES[options.ease ?? "in-out"](t);
|
|
24
|
+
}
|
|
25
|
+
var defaultDataKey = (item, index) => {
|
|
26
|
+
if (item && typeof item === "object") {
|
|
27
|
+
const o = item;
|
|
28
|
+
if (o.source !== void 0 && o.target !== void 0)
|
|
29
|
+
return `${String(o.source)}\u2192${String(o.target)}`;
|
|
30
|
+
for (const k of ["id", "key", "name", "label"])
|
|
31
|
+
if (typeof o[k] === "string" || typeof o[k] === "number") return String(o[k]);
|
|
32
|
+
}
|
|
33
|
+
return String(index);
|
|
34
|
+
};
|
|
35
|
+
function scaled(value, k) {
|
|
36
|
+
if (typeof value === "number") return value * k;
|
|
37
|
+
if (Array.isArray(value)) return value.map((v) => scaled(v, k));
|
|
38
|
+
if (value && typeof value === "object")
|
|
39
|
+
return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, scaled(v, k)]));
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function lerpData(a, b, u, keyOf = defaultDataKey) {
|
|
43
|
+
if (u <= 0) return a;
|
|
44
|
+
if (u >= 1) return b;
|
|
45
|
+
return blend(a, b, u, keyOf);
|
|
46
|
+
}
|
|
47
|
+
function blend(a, b, u, keyOf) {
|
|
48
|
+
if (typeof a === "number" && typeof b === "number") return a + (b - a) * u;
|
|
49
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
50
|
+
const before = new Map(a.map((item, i) => [keyOf(item, i), item]));
|
|
51
|
+
const after = new Set(b.map((item, i) => keyOf(item, i)));
|
|
52
|
+
const out = b.map((item, i) => {
|
|
53
|
+
const key = keyOf(item, i);
|
|
54
|
+
return before.has(key) ? blend(before.get(key), item, u, keyOf) : scaled(item, u);
|
|
55
|
+
});
|
|
56
|
+
a.forEach((item, i) => {
|
|
57
|
+
if (!after.has(keyOf(item, i))) out.push(scaled(item, 1 - u));
|
|
58
|
+
});
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
62
|
+
const ao = a;
|
|
63
|
+
const bo = b;
|
|
64
|
+
return Object.fromEntries(
|
|
65
|
+
[.../* @__PURE__ */ new Set([...Object.keys(ao), ...Object.keys(bo)])].map((k) => [
|
|
66
|
+
k,
|
|
67
|
+
k in ao && k in bo ? blend(ao[k], bo[k], u, keyOf) : k in bo ? scaled(bo[k], u) : scaled(ao[k], 1 - u)
|
|
68
|
+
])
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return u < 0.5 ? a : b;
|
|
72
|
+
}
|
|
73
|
+
function stepData(states, steps, timeMs, options = {}) {
|
|
74
|
+
const last = Math.min(steps.length, states.length - 1);
|
|
75
|
+
const to = states[last];
|
|
76
|
+
if (last === 0) return to;
|
|
77
|
+
const u = stepProgress(steps, timeMs, last, options);
|
|
78
|
+
return lerpData(states[last - 1], to, u, options.keyOf);
|
|
79
|
+
}
|
|
80
|
+
var SVG_PICTURE = "";
|
|
81
|
+
var NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi;
|
|
82
|
+
var HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
83
|
+
function rgb(hex) {
|
|
84
|
+
let h = hex.slice(1);
|
|
85
|
+
if (h.length === 3) h = [...h].map((c) => c + c).join("");
|
|
86
|
+
return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
87
|
+
}
|
|
88
|
+
var round = (n) => Math.round(n * 1e3) / 1e3;
|
|
89
|
+
function lerpAttr(a, b, u) {
|
|
90
|
+
if (typeof a === "number" && typeof b === "number") return String(round(a + (b - a) * u));
|
|
91
|
+
const sa = String(a);
|
|
92
|
+
const sb = String(b);
|
|
93
|
+
if (HEX.test(sa) && HEX.test(sb)) {
|
|
94
|
+
const [ca, cb] = [rgb(sa), rgb(sb)];
|
|
95
|
+
return `#${ca.map(
|
|
96
|
+
(c, i) => Math.round(c + (cb[i] - c) * u).toString(16).padStart(2, "0")
|
|
97
|
+
).join("")}`;
|
|
98
|
+
}
|
|
99
|
+
const na = sa.match(NUMBER) ?? [];
|
|
100
|
+
const nb = sb.match(NUMBER) ?? [];
|
|
101
|
+
if (na.length && na.length === nb.length && sa.replace(NUMBER, "#") === sb.replace(NUMBER, "#")) {
|
|
102
|
+
let i = 0;
|
|
103
|
+
return sa.replace(NUMBER, () => {
|
|
104
|
+
const v = Number(na[i]) + (Number(nb[i]) - Number(na[i])) * u;
|
|
105
|
+
i++;
|
|
106
|
+
return String(round(v));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return u < 0.5 ? sa : sb;
|
|
110
|
+
}
|
|
111
|
+
var startOf = (a, steps) => {
|
|
112
|
+
const s = stepStart(steps, a.step ?? 0);
|
|
113
|
+
return s === void 0 ? Infinity : s + (a.delay ?? 0);
|
|
114
|
+
};
|
|
115
|
+
function svgFrame(animations, steps, timeMs) {
|
|
116
|
+
const tracks = /* @__PURE__ */ new Map();
|
|
117
|
+
const add = (prop, anim, index) => {
|
|
118
|
+
const key = `${prop === "view" ? SVG_PICTURE : anim.id}\0${prop}`;
|
|
119
|
+
const list = tracks.get(key) ?? [];
|
|
120
|
+
list.push({ anim, start: startOf(anim, steps), index });
|
|
121
|
+
tracks.set(key, list);
|
|
122
|
+
};
|
|
123
|
+
animations.forEach((a, i) => {
|
|
124
|
+
for (const name of Object.keys(a.attrs ?? {})) add(`@${name}`, a, i);
|
|
125
|
+
if (a.draw) add("draw", a, i);
|
|
126
|
+
if (a.count) add("count", a, i);
|
|
127
|
+
if (a.view !== void 0) add("view", a, i);
|
|
128
|
+
if (a.along) add("along", a, i);
|
|
129
|
+
});
|
|
130
|
+
const frames = /* @__PURE__ */ new Map();
|
|
131
|
+
for (const [key, list] of tracks) {
|
|
132
|
+
list.sort((x, y) => x.start - y.start || x.index - y.index);
|
|
133
|
+
const [id, prop] = key.split("\0");
|
|
134
|
+
const started = list.filter((c) => c.start <= timeMs);
|
|
135
|
+
const current = started[started.length - 1];
|
|
136
|
+
const anim = (current ?? list[0]).anim;
|
|
137
|
+
const u = current ? stepProgress(steps, timeMs, anim.step ?? 0, {
|
|
138
|
+
delay: anim.delay,
|
|
139
|
+
ms: anim.ms,
|
|
140
|
+
ease: anim.ease
|
|
141
|
+
}) : 0;
|
|
142
|
+
const frame = frames.get(id) ?? { attrs: {} };
|
|
143
|
+
if (prop === "view") {
|
|
144
|
+
const before = current ? list[list.indexOf(current) - 1] : void 0;
|
|
145
|
+
frame.view = { from: before?.anim.view ?? null, to: anim.view, u };
|
|
146
|
+
} else if (prop === "along") {
|
|
147
|
+
const [a, b] = anim.at ?? [0, 1];
|
|
148
|
+
frame.along = { path: anim.along, at: a + (b - a) * u };
|
|
149
|
+
} else if (prop.startsWith("@")) {
|
|
150
|
+
const [a, b] = anim.attrs[prop.slice(1)];
|
|
151
|
+
frame.attrs[prop.slice(1)] = lerpAttr(a, b, u);
|
|
152
|
+
} else if (prop === "draw") {
|
|
153
|
+
const [a, b] = anim.draw === true ? [0, 1] : anim.draw;
|
|
154
|
+
frame.draw = a + (b - a) * u;
|
|
155
|
+
} else {
|
|
156
|
+
const [a, b] = anim.count;
|
|
157
|
+
const n = (a + (b - a) * u).toFixed(anim.decimals ?? 0);
|
|
158
|
+
frame.text = (anim.format ?? "{n}").replace("{n}", n);
|
|
159
|
+
}
|
|
160
|
+
frames.set(id, frame);
|
|
161
|
+
}
|
|
162
|
+
return frames;
|
|
163
|
+
}
|
|
164
|
+
function svgOpeningTag(markup) {
|
|
165
|
+
const end = markup.indexOf(">");
|
|
166
|
+
return end < 0 ? markup : markup.slice(0, end + 1);
|
|
167
|
+
}
|
|
168
|
+
function svgMotionIssues(motion) {
|
|
169
|
+
const issues = [];
|
|
170
|
+
const m = motion ?? {};
|
|
171
|
+
const svg = typeof m.svg === "string" ? m.svg.trim() : "";
|
|
172
|
+
if (!svg) return ["`svg` needs the picture's markup: one <svg> element"];
|
|
173
|
+
if (!/^<svg[\s>]/i.test(svg) || !svg.toLowerCase().endsWith("</svg>"))
|
|
174
|
+
issues.push("`svg` must be one <svg>\u2026</svg> element");
|
|
175
|
+
if (!/\sviewBox\s*=/i.test(svgOpeningTag(svg)))
|
|
176
|
+
issues.push("the <svg> needs a `viewBox`, so it scales to where it is placed");
|
|
177
|
+
if (/<script|<foreignObject|\son\w+\s*=/i.test(svg))
|
|
178
|
+
issues.push("`svg` cannot have scripts, event handlers or <foreignObject>");
|
|
179
|
+
if (/(?:href|src)\s*=\s*["'](?!#|data:image\/)/i.test(svg))
|
|
180
|
+
issues.push("`svg` cannot link outside itself (only #ids and data:image URLs)");
|
|
181
|
+
const ids = new Set([...svg.matchAll(/\sid\s*=\s*["']([^"']+)["']/g)].map((x) => x[1]));
|
|
182
|
+
if (m.animate !== void 0 && !Array.isArray(m.animate)) issues.push("`animate` must be a list");
|
|
183
|
+
(Array.isArray(m.animate) ? m.animate : []).forEach((a, i) => {
|
|
184
|
+
const where = `animate[${i}]`;
|
|
185
|
+
if (!a || typeof a !== "object") return void issues.push(`${where} is not an animation`);
|
|
186
|
+
if (typeof a.id !== "string") {
|
|
187
|
+
if (a.view === void 0) return void issues.push(`${where} needs an \`id\``);
|
|
188
|
+
} else if (!ids.has(a.id))
|
|
189
|
+
issues.push(`${where}: there is no element with id "${a.id}" in the SVG`);
|
|
190
|
+
if (a.step !== void 0 && !(Number.isInteger(a.step) && a.step >= 0))
|
|
191
|
+
issues.push(`${where}: \`step\` is a whole number, 0 or more`);
|
|
192
|
+
if (a.ms !== void 0 && !(a.ms >= 0)) issues.push(`${where}: \`ms\` must be 0 or more`);
|
|
193
|
+
if (a.delay !== void 0 && !(a.delay >= 0))
|
|
194
|
+
issues.push(`${where}: \`delay\` must be 0 or more`);
|
|
195
|
+
if (a.ease !== void 0 && !(a.ease in EASES))
|
|
196
|
+
issues.push(`${where}: \`ease\` is one of ${Object.keys(EASES).join(", ")}`);
|
|
197
|
+
if (!a.attrs && !a.draw && !a.count && a.view === void 0 && !a.along)
|
|
198
|
+
issues.push(
|
|
199
|
+
`${where} changes nothing: give \`attrs\`, \`draw\`, \`count\`, \`view\` or \`along\``
|
|
200
|
+
);
|
|
201
|
+
if (a.view !== void 0) {
|
|
202
|
+
const box = a.view;
|
|
203
|
+
if (typeof box === "string") {
|
|
204
|
+
if (!ids.has(box))
|
|
205
|
+
issues.push(`${where}: \`view\` frames "${box}", which is not an id in the SVG`);
|
|
206
|
+
} else if (!Array.isArray(box) || box.length !== 4 || !box.every((n) => Number.isFinite(n)) || !(box[2] > 0 && box[3] > 0))
|
|
207
|
+
issues.push(
|
|
208
|
+
`${where}: \`view\` is [x, y, width, height] (width and height above 0) or an element's id`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (a.along !== void 0) {
|
|
212
|
+
if (typeof a.along !== "string" || !ids.has(a.along))
|
|
213
|
+
issues.push(`${where}: \`along\` is the id of a path in the SVG`);
|
|
214
|
+
if (typeof a.id !== "string")
|
|
215
|
+
issues.push(`${where}: \`along\` moves an element: give its \`id\``);
|
|
216
|
+
}
|
|
217
|
+
if (a.at !== void 0 && !(Array.isArray(a.at) && a.at.length === 2 && a.at.every((v) => v >= 0 && v <= 1)))
|
|
218
|
+
issues.push(`${where}: \`at\` is [from, to] between 0 and 1`);
|
|
219
|
+
for (const [name, pair] of Object.entries(a.attrs ?? {}))
|
|
220
|
+
if (!Array.isArray(pair) || pair.length !== 2)
|
|
221
|
+
issues.push(`${where}: \`attrs.${name}\` is [from, to]`);
|
|
222
|
+
if (Array.isArray(a.draw) && a.draw.some((v) => !(v >= 0 && v <= 1)))
|
|
223
|
+
issues.push(`${where}: \`draw\` is true or [from, to] between 0 and 1`);
|
|
224
|
+
if (a.count !== void 0 && !(Array.isArray(a.count) && a.count.length === 2))
|
|
225
|
+
issues.push(`${where}: \`count\` is [from, to]`);
|
|
226
|
+
});
|
|
227
|
+
return issues;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/vector/svg.ts
|
|
231
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
232
|
+
function parseSvg(markup) {
|
|
233
|
+
let source = markup.trim();
|
|
234
|
+
const open = svgOpeningTag(source);
|
|
235
|
+
if (!/\sxmlns\s*=/i.test(open)) source = source.replace(/^<svg/i, `<svg xmlns="${SVG_NS}"`);
|
|
236
|
+
if (/xlink:/.test(source) && !/\sxmlns:xlink\s*=/i.test(open))
|
|
237
|
+
source = source.replace(/^<svg/i, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
|
|
238
|
+
const doc = new DOMParser().parseFromString(source, "image/svg+xml");
|
|
239
|
+
const svg = doc.documentElement;
|
|
240
|
+
if (svg.namespaceURI !== SVG_NS || svg.localName !== "svg" || doc.querySelector("parsererror"))
|
|
241
|
+
return void 0;
|
|
242
|
+
for (const bad of svg.querySelectorAll("script, foreignObject")) bad.remove();
|
|
243
|
+
for (const el of [svg, ...svg.querySelectorAll("*")]) {
|
|
244
|
+
for (const attr of [...el.attributes]) {
|
|
245
|
+
const name = attr.name.toLowerCase();
|
|
246
|
+
const link = name === "href" || name === "xlink:href" || name === "src";
|
|
247
|
+
if (name.startsWith("on") || link && !/^(#|data:image\/)/i.test(attr.value.trim()))
|
|
248
|
+
el.removeAttribute(attr.name);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return document.importNode(svg, true);
|
|
252
|
+
}
|
|
253
|
+
var VIEW_MARGIN = 0.12;
|
|
254
|
+
function viewBox(view, whole, byId) {
|
|
255
|
+
if (view === null) return whole;
|
|
256
|
+
if (typeof view !== "string") return view;
|
|
257
|
+
const el = byId.get(view);
|
|
258
|
+
let box;
|
|
259
|
+
try {
|
|
260
|
+
box = el?.getBBox?.();
|
|
261
|
+
} catch {
|
|
262
|
+
}
|
|
263
|
+
if (!box || !(box.width > 0 || box.height > 0)) return whole;
|
|
264
|
+
try {
|
|
265
|
+
const svg = el.ownerSVGElement;
|
|
266
|
+
const m = svg?.getScreenCTM()?.inverse().multiply(el.getScreenCTM());
|
|
267
|
+
if (m) {
|
|
268
|
+
const corners = [
|
|
269
|
+
[box.x, box.y],
|
|
270
|
+
[box.x + box.width, box.y],
|
|
271
|
+
[box.x, box.y + box.height],
|
|
272
|
+
[box.x + box.width, box.y + box.height]
|
|
273
|
+
].map(([x, y]) => new DOMPoint(x, y).matrixTransform(m));
|
|
274
|
+
const xs = corners.map((p) => p.x);
|
|
275
|
+
const ys = corners.map((p) => p.y);
|
|
276
|
+
box = new DOMRect(
|
|
277
|
+
Math.min(...xs),
|
|
278
|
+
Math.min(...ys),
|
|
279
|
+
Math.max(...xs) - Math.min(...xs),
|
|
280
|
+
Math.max(...ys) - Math.min(...ys)
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
} catch {
|
|
284
|
+
}
|
|
285
|
+
const aspect = whole[2] / whole[3];
|
|
286
|
+
let w = box.width * (1 + 2 * VIEW_MARGIN);
|
|
287
|
+
let h = box.height * (1 + 2 * VIEW_MARGIN);
|
|
288
|
+
if (w / h > aspect) h = w / aspect;
|
|
289
|
+
else w = h * aspect;
|
|
290
|
+
return [box.x + box.width / 2 - w / 2, box.y + box.height / 2 - h / 2, w, h];
|
|
291
|
+
}
|
|
292
|
+
function keepSize(svg, whole, nonscaling) {
|
|
293
|
+
if (!nonscaling.length) return;
|
|
294
|
+
const width = Number((svg.getAttribute("viewBox") ?? "").trim().split(/[\s,]+/)[2]);
|
|
295
|
+
const zoom = width > 0 ? width / whole[2] : 1;
|
|
296
|
+
const transform = Math.abs(zoom - 1) < 1e-4 ? "" : `scale(${+zoom.toFixed(4)})`;
|
|
297
|
+
for (const el of nonscaling)
|
|
298
|
+
if ((el.getAttribute("transform") ?? "") !== transform)
|
|
299
|
+
if (transform) el.setAttribute("transform", transform);
|
|
300
|
+
else el.removeAttribute("transform");
|
|
301
|
+
}
|
|
302
|
+
function apply(svg, whole, byId, motion, timeMs, steps) {
|
|
303
|
+
for (const [id, frame] of svgFrame(motion.animate ?? [], steps, timeMs)) {
|
|
304
|
+
if (id === SVG_PICTURE && frame.view) {
|
|
305
|
+
const a = viewBox(frame.view.from, whole, byId);
|
|
306
|
+
const b = viewBox(frame.view.to, whole, byId);
|
|
307
|
+
const u = frame.view.u;
|
|
308
|
+
svg.setAttribute("viewBox", a.map((n, i) => +(n + (b[i] - n) * u).toFixed(2)).join(" "));
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const el = byId.get(id);
|
|
312
|
+
if (!el) continue;
|
|
313
|
+
for (const [name, value] of Object.entries(frame.attrs)) el.setAttribute(name, value);
|
|
314
|
+
if (frame.draw !== void 0) {
|
|
315
|
+
el.setAttribute("pathLength", "1");
|
|
316
|
+
el.setAttribute("stroke-dasharray", "1 1");
|
|
317
|
+
el.setAttribute("stroke-dashoffset", String(1 - frame.draw));
|
|
318
|
+
}
|
|
319
|
+
if (frame.text !== void 0) el.textContent = frame.text;
|
|
320
|
+
if (frame.along) {
|
|
321
|
+
const path = byId.get(frame.along.path);
|
|
322
|
+
try {
|
|
323
|
+
const length = path?.getTotalLength?.();
|
|
324
|
+
if (path && length !== void 0) {
|
|
325
|
+
const p = path.getPointAtLength(frame.along.at * length);
|
|
326
|
+
el.setAttribute("transform", `translate(${+p.x.toFixed(2)} ${+p.y.toFixed(2)})`);
|
|
327
|
+
}
|
|
328
|
+
} catch {
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
var VAR = /var\(\s*(--[\w-]+)\s*(?:,\s*([^()]*(?:\([^()]*\)[^()]*)*))?\)/g;
|
|
334
|
+
function resolveVariables(live, copy) {
|
|
335
|
+
const originals = [live, ...live.querySelectorAll("*")];
|
|
336
|
+
const copies = [copy, ...copy.querySelectorAll("*")];
|
|
337
|
+
copies.forEach((el, i) => {
|
|
338
|
+
let style;
|
|
339
|
+
for (const attr of [...el.attributes]) {
|
|
340
|
+
if (!attr.value.includes("var(")) continue;
|
|
341
|
+
style ??= getComputedStyle(originals[i] ?? live);
|
|
342
|
+
el.setAttribute(
|
|
343
|
+
attr.name,
|
|
344
|
+
attr.value.replace(
|
|
345
|
+
VAR,
|
|
346
|
+
(_, name, fallback) => style.getPropertyValue(name).trim() || fallback?.trim() || ""
|
|
347
|
+
)
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async function rasterize(layers, pixels) {
|
|
353
|
+
const canvas = document.createElement("canvas");
|
|
354
|
+
canvas.width = pixels.width;
|
|
355
|
+
canvas.height = pixels.height;
|
|
356
|
+
const defs = layers[0]?.querySelector("defs");
|
|
357
|
+
for (const [i, svg] of layers.entries()) {
|
|
358
|
+
const copy = svg.cloneNode(true);
|
|
359
|
+
resolveVariables(svg, copy);
|
|
360
|
+
if (i > 0 && defs) copy.prepend(defs.cloneNode(true));
|
|
361
|
+
copy.setAttribute("xmlns", SVG_NS);
|
|
362
|
+
copy.setAttribute("width", String(pixels.width));
|
|
363
|
+
copy.setAttribute("height", String(pixels.height));
|
|
364
|
+
const url = URL.createObjectURL(
|
|
365
|
+
new Blob([new XMLSerializer().serializeToString(copy)], { type: "image/svg+xml" })
|
|
366
|
+
);
|
|
367
|
+
try {
|
|
368
|
+
const image = new Image();
|
|
369
|
+
image.src = url;
|
|
370
|
+
await image.decode();
|
|
371
|
+
canvas.getContext("2d").drawImage(image, 0, 0, pixels.width, pixels.height);
|
|
372
|
+
} finally {
|
|
373
|
+
URL.revokeObjectURL(url);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return canvas;
|
|
377
|
+
}
|
|
378
|
+
function fixedLayer(svg) {
|
|
379
|
+
const fixed = [...svg.querySelectorAll("[data-fixed]")].filter(
|
|
380
|
+
(el) => !el.parentElement?.closest("[data-fixed]")
|
|
381
|
+
);
|
|
382
|
+
if (!fixed.length) return void 0;
|
|
383
|
+
const layer = svg.cloneNode(false);
|
|
384
|
+
layer.removeAttribute("id");
|
|
385
|
+
layer.setAttribute("aria-hidden", "true");
|
|
386
|
+
layer.style.cssText = "position:absolute;inset:0;overflow:visible";
|
|
387
|
+
for (const el of fixed) layer.appendChild(el);
|
|
388
|
+
return layer;
|
|
389
|
+
}
|
|
390
|
+
function svgView(motion, options = {}) {
|
|
391
|
+
const element = document.createElement("div");
|
|
392
|
+
element.style.width = "100%";
|
|
393
|
+
element.style.height = "100%";
|
|
394
|
+
const { onPick } = options;
|
|
395
|
+
if (onPick)
|
|
396
|
+
element.addEventListener("click", (event) => {
|
|
397
|
+
for (let el = event.target; el && el !== element; el = el.parentElement)
|
|
398
|
+
if (el.id && el.localName !== "svg") return onPick(el.id);
|
|
399
|
+
});
|
|
400
|
+
let svg = null;
|
|
401
|
+
let fixed;
|
|
402
|
+
let nonscaling = [];
|
|
403
|
+
let whole = [0, 0, 100, 100];
|
|
404
|
+
const byId = /* @__PURE__ */ new Map();
|
|
405
|
+
return {
|
|
406
|
+
element,
|
|
407
|
+
draw(timeMs, steps = []) {
|
|
408
|
+
if (svg === null) {
|
|
409
|
+
svg = parseSvg(motion.svg);
|
|
410
|
+
if (svg) {
|
|
411
|
+
svg.setAttribute("width", "100%");
|
|
412
|
+
svg.setAttribute("height", "100%");
|
|
413
|
+
element.appendChild(svg);
|
|
414
|
+
fixed = fixedLayer(svg);
|
|
415
|
+
if (fixed) {
|
|
416
|
+
element.style.position = "relative";
|
|
417
|
+
element.appendChild(fixed);
|
|
418
|
+
}
|
|
419
|
+
for (const layer of [svg, fixed])
|
|
420
|
+
for (const el of layer?.querySelectorAll("[id]") ?? []) byId.set(el.id, el);
|
|
421
|
+
nonscaling = [...svg.querySelectorAll("[data-nonscaling]")];
|
|
422
|
+
const box = (svg.getAttribute("viewBox") ?? "").trim().split(/[\s,]+/).map(Number);
|
|
423
|
+
if (box.length === 4 && box.every(Number.isFinite)) whole = box;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (svg) {
|
|
427
|
+
apply(svg, whole, byId, motion, timeMs, steps);
|
|
428
|
+
keepSize(svg, whole, nonscaling);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
capture: async (pixels) => svg ? rasterize(fixed ? [svg, fixed] : [svg], pixels) : void 0
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
function svgDuration(motion, steps = []) {
|
|
435
|
+
let end = 0;
|
|
436
|
+
for (const a of motion.animate ?? []) {
|
|
437
|
+
const step = a.step ?? 0;
|
|
438
|
+
const start = step <= 0 ? 0 : steps[step - 1];
|
|
439
|
+
if (start === void 0) continue;
|
|
440
|
+
end = Math.max(end, start + (a.delay ?? 0) + (a.ms ?? 800));
|
|
441
|
+
}
|
|
442
|
+
return Math.max(1, end);
|
|
443
|
+
}
|
|
444
|
+
var SvgPlayer = class {
|
|
445
|
+
constructor(container, motion, options = {}) {
|
|
446
|
+
this.container = container;
|
|
447
|
+
this.clock = options.clock ?? realClock;
|
|
448
|
+
this.steps = options.steps ?? [];
|
|
449
|
+
this.loop = options.loop ?? true;
|
|
450
|
+
this.speed = options.speed ?? 1;
|
|
451
|
+
this.length = options.duration ?? svgDuration(motion, this.steps) + (options.hold ?? 600);
|
|
452
|
+
this.view = svgView(motion, options);
|
|
453
|
+
container.appendChild(this.view.element);
|
|
454
|
+
this.view.draw(0, this.steps);
|
|
455
|
+
if (options.autoplay ?? true) this.play();
|
|
456
|
+
}
|
|
457
|
+
container;
|
|
458
|
+
view;
|
|
459
|
+
clock;
|
|
460
|
+
steps;
|
|
461
|
+
loop;
|
|
462
|
+
length;
|
|
463
|
+
speed;
|
|
464
|
+
time = 0;
|
|
465
|
+
last = 0;
|
|
466
|
+
playing = false;
|
|
467
|
+
disposed = false;
|
|
468
|
+
/** The loop length in ms. */
|
|
469
|
+
get duration() {
|
|
470
|
+
return this.length;
|
|
471
|
+
}
|
|
472
|
+
/** The time shown, in ms. */
|
|
473
|
+
get currentTime() {
|
|
474
|
+
return this.time;
|
|
475
|
+
}
|
|
476
|
+
get isPlaying() {
|
|
477
|
+
return this.playing;
|
|
478
|
+
}
|
|
479
|
+
play() {
|
|
480
|
+
if (this.playing || this.disposed) return;
|
|
481
|
+
this.playing = true;
|
|
482
|
+
this.last = this.clock.now();
|
|
483
|
+
void this.run();
|
|
484
|
+
}
|
|
485
|
+
pause() {
|
|
486
|
+
this.playing = false;
|
|
487
|
+
}
|
|
488
|
+
/** Shows the picture at `ms` (wrapped into the loop when looping). */
|
|
489
|
+
seek(ms) {
|
|
490
|
+
this.time = this.loop ? (ms % this.length + this.length) % this.length : Math.min(Math.max(ms, 0), this.length);
|
|
491
|
+
this.view.draw(this.time, this.steps);
|
|
492
|
+
}
|
|
493
|
+
setSpeed(speed) {
|
|
494
|
+
this.speed = speed;
|
|
495
|
+
}
|
|
496
|
+
dispose() {
|
|
497
|
+
this.disposed = true;
|
|
498
|
+
this.playing = false;
|
|
499
|
+
this.view.element.remove();
|
|
500
|
+
}
|
|
501
|
+
async run() {
|
|
502
|
+
while (this.playing && !this.disposed) {
|
|
503
|
+
await this.clock.frame();
|
|
504
|
+
if (!this.playing || this.disposed) return;
|
|
505
|
+
const now = this.clock.now();
|
|
506
|
+
const next = this.time + (now - this.last) * this.speed;
|
|
507
|
+
this.last = now;
|
|
508
|
+
if (!this.loop && next >= this.length) {
|
|
509
|
+
this.seek(this.length);
|
|
510
|
+
this.playing = false;
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
this.seek(next);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
export {
|
|
519
|
+
EASES,
|
|
520
|
+
STEP_MS,
|
|
521
|
+
stepStart,
|
|
522
|
+
stepProgress,
|
|
523
|
+
defaultDataKey,
|
|
524
|
+
lerpData,
|
|
525
|
+
stepData,
|
|
526
|
+
SVG_PICTURE,
|
|
527
|
+
lerpAttr,
|
|
528
|
+
svgFrame,
|
|
529
|
+
svgOpeningTag,
|
|
530
|
+
svgMotionIssues,
|
|
531
|
+
parseSvg,
|
|
532
|
+
svgView,
|
|
533
|
+
svgDuration,
|
|
534
|
+
SvgPlayer
|
|
535
|
+
};
|
|
536
|
+
//# sourceMappingURL=chunk-G5FNZDTA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vector/motion.ts","../src/vector/svg.ts"],"sourcesContent":["/**\n * Vector motion: animated SVG pictures described as data. A picture changes in\n * steps (step 0 when it starts, step n at `steps[n - 1]` ms), and everything\n * here is a pure function of its arguments, so a frame comes out the same\n * however it is reached (played, stepped for a recording, or seeked).\n */\n\n/** Easing curves by name. */\nexport const EASES = {\n linear: (t: number) => t,\n \"in-out\": (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),\n out: (t: number) => 1 - (1 - t) ** 3,\n} as const;\n\nexport type EaseName = keyof typeof EASES;\n\n/** How long a change takes by default, in ms. */\nexport const STEP_MS = 800;\n\nconst clamp01 = (t: number) => (t < 0 ? 0 : t > 1 ? 1 : t);\n\n/**\n * When `step` starts, in ms since the media started (step 0 at 0, step n at\n * `steps[n - 1]`), or undefined if it has not started yet.\n */\nexport function stepStart(steps: readonly number[], step: number): number | undefined {\n if (step <= 0) return 0;\n return steps[step - 1];\n}\n\n/**\n * How far a change that plays on `step` (after `delay` ms, over `ms`) has\n * got at `timeMs`, eased: 0 before it starts, 1 once it is over.\n */\nexport function stepProgress(\n steps: readonly number[],\n timeMs: number,\n step: number,\n options: { delay?: number; ms?: number; ease?: EaseName } = {},\n): number {\n const start = stepStart(steps, step);\n if (start === undefined) return 0;\n const from = start + (options.delay ?? 0);\n const ms = options.ms ?? STEP_MS;\n const t = ms > 0 ? clamp01((timeMs - from) / ms) : timeMs >= from ? 1 : 0;\n return EASES[options.ease ?? \"in-out\"](t);\n}\n\n/** The key an item in a list of data keeps from one state to the next. */\nexport type DataKey = (item: unknown, index: number) => string;\n\n/**\n * Keys items by their `id`, `key`, `name` or `label` (or a link's `source`\n * and `target`), else by position.\n */\nexport const defaultDataKey: DataKey = (item, index) => {\n if (item && typeof item === \"object\") {\n const o = item as Record<string, unknown>;\n if (o.source !== undefined && o.target !== undefined)\n return `${String(o.source)}→${String(o.target)}`;\n for (const k of [\"id\", \"key\", \"name\", \"label\"])\n if (typeof o[k] === \"string\" || typeof o[k] === \"number\") return String(o[k]);\n }\n return String(index);\n};\n\n/** Every number in `value` times `k`, so an item can grow from or shrink to nothing. */\nfunction scaled(value: unknown, k: number): unknown {\n if (typeof value === \"number\") return value * k;\n if (Array.isArray(value)) return value.map((v) => scaled(v, k));\n if (value && typeof value === \"object\")\n return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, scaled(v, k)]));\n return value;\n}\n\n/**\n * Data between two states, `u` of the way from `a` to `b`. Numbers blend;\n * lists match their items by key (`keyOf`), so each keeps its identity and\n * moves rather than jumping, with items only in `b` growing from nothing and\n * items only in `a` shrinking away; objects blend field by field; anything\n * else changes halfway.\n */\nexport function lerpData<D>(a: D, b: D, u: number, keyOf: DataKey = defaultDataKey): D {\n if (u <= 0) return a;\n if (u >= 1) return b;\n return blend(a, b, u, keyOf) as D;\n}\n\nfunction blend(a: unknown, b: unknown, u: number, keyOf: DataKey): unknown {\n if (typeof a === \"number\" && typeof b === \"number\") return a + (b - a) * u;\n if (Array.isArray(a) && Array.isArray(b)) {\n const before = new Map(a.map((item, i) => [keyOf(item, i), item]));\n const after = new Set(b.map((item, i) => keyOf(item, i)));\n const out: unknown[] = b.map((item, i) => {\n const key = keyOf(item, i);\n return before.has(key) ? blend(before.get(key), item, u, keyOf) : scaled(item, u);\n });\n a.forEach((item, i) => {\n if (!after.has(keyOf(item, i))) out.push(scaled(item, 1 - u));\n });\n return out;\n }\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n const ao = a as Record<string, unknown>;\n const bo = b as Record<string, unknown>;\n return Object.fromEntries(\n [...new Set([...Object.keys(ao), ...Object.keys(bo)])].map((k) => [\n k,\n k in ao && k in bo\n ? blend(ao[k], bo[k], u, keyOf)\n : k in bo\n ? scaled(bo[k], u)\n : scaled(ao[k], 1 - u),\n ]),\n );\n }\n return u < 0.5 ? a : b;\n}\n\n/**\n * The data to show at `timeMs`, for media whose data has a state per step:\n * `states[n]` is shown from step n (the last one stays), reached by moving\n * from the state before it over `ms`.\n */\nexport function stepData<D>(\n states: readonly D[],\n steps: readonly number[],\n timeMs: number,\n options: { ms?: number; ease?: EaseName; keyOf?: DataKey } = {},\n): D {\n const last = Math.min(steps.length, states.length - 1);\n const to = states[last]!;\n if (last === 0) return to;\n const u = stepProgress(steps, timeMs, last, options);\n return lerpData(states[last - 1]!, to, u, options.keyOf);\n}\n\n// ── SVG media ──────────────────────────────────────────────────────────\n\n/**\n * An animated SVG picture: markup plus changes to its elements. Draw it with\n * `SvgPlayer` (or `svgView`), or compute frames yourself with `svgFrame`.\n */\nexport interface SvgMotion {\n /** One self-contained `<svg>` with a `viewBox`: no scripts, no outside links. */\n svg: string;\n /** Changes to its elements, each on a step. */\n animate?: SvgAnimation[];\n}\n\n/** A box in an SVG's `viewBox` units: `[x, y, width, height]`. */\nexport type SvgBox = readonly [number, number, number, number];\n\n/** A change to one element of an {@link SvgMotion}, or (with `view`) to the whole picture. */\nexport interface SvgAnimation {\n /** The element's `id` in the SVG (not needed for `view`). */\n id?: string;\n /** The step it plays on: 0 (default) when the media starts, 1 with the next shot, and so on. */\n step?: number;\n /** Ms after the step starts. */\n delay?: number;\n /** How long it takes, in ms (default {@link STEP_MS}). */\n ms?: number;\n ease?: EaseName;\n /**\n * Attributes from one value to another: numbers, colours (`#rrggbb`), or\n * strings whose numbers change while the rest stays the same (a path's\n * `d`, a `transform`, `points`).\n */\n attrs?: Record<string, readonly [string | number, string | number]>;\n /** Draws a line or outline on along its length, from 0 to 1 (or between two fractions). */\n draw?: boolean | readonly [number, number];\n /**\n * Zooms and pans the whole picture to frame a box (`[x, y, width, height]`\n * in the `viewBox`'s units) or an element by id (with a margin round it),\n * from where the last `view` left it (at first, the whole `viewBox`).\n */\n view?: SvgBox | string;\n /**\n * Moves the element along a path (by id) from its start to its end, or\n * between the fractions in `at`; draw the element round (0, 0), like a\n * circle at `cx=\"0\" cy=\"0\"`.\n */\n along?: string;\n /** How far along the path `along` moves the element, from and to (default [0, 1]). */\n at?: readonly [number, number];\n /** Counts the element's text from one number to the other. */\n count?: readonly [number, number];\n /** How a count is written: `{n}` stands for the number (\"{n}%\", \"$ {n}M\"). */\n format?: string;\n /** Decimals in a count (default 0). */\n decimals?: number;\n}\n\n/** What one element of an animated SVG shows at a time. */\nexport interface SvgElementFrame {\n attrs: Record<string, string>;\n /** How much of its length is drawn, 0–1. */\n draw?: number;\n text?: string;\n /** Where it is along a path: the path's id and the fraction of its length. */\n along?: { path: string; at: number };\n /**\n * The whole picture's framing (on the frame for {@link SVG_PICTURE}): `u`\n * of the way from one view to the next, `null` being the whole `viewBox`.\n */\n view?: { from: SvgBox | string | null; to: SvgBox | string; u: number };\n}\n\n/** The key of the whole picture's frame in {@link svgFrame}'s result (for `view`). */\nexport const SVG_PICTURE = \"\";\n\nconst NUMBER = /-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi;\nconst HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\nfunction rgb(hex: string): [number, number, number] {\n let h = hex.slice(1);\n if (h.length === 3) h = [...h].map((c) => c + c).join(\"\");\n return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16)) as [number, number, number];\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000;\n\n/** A value `u` of the way between two attribute values (see `SvgAnimation.attrs`). */\nexport function lerpAttr(a: string | number, b: string | number, u: number): string {\n if (typeof a === \"number\" && typeof b === \"number\") return String(round(a + (b - a) * u));\n const sa = String(a);\n const sb = String(b);\n if (HEX.test(sa) && HEX.test(sb)) {\n const [ca, cb] = [rgb(sa), rgb(sb)];\n return `#${ca\n .map((c, i) =>\n Math.round(c + (cb[i]! - c) * u)\n .toString(16)\n .padStart(2, \"0\"),\n )\n .join(\"\")}`;\n }\n const na = sa.match(NUMBER) ?? [];\n const nb = sb.match(NUMBER) ?? [];\n if (na.length && na.length === nb.length && sa.replace(NUMBER, \"#\") === sb.replace(NUMBER, \"#\")) {\n let i = 0;\n return sa.replace(NUMBER, () => {\n const v = Number(na[i]) + (Number(nb[i]) - Number(na[i])) * u;\n i++;\n return String(round(v));\n });\n }\n return u < 0.5 ? sa : sb;\n}\n\nconst startOf = (a: SvgAnimation, steps: readonly number[]) => {\n const s = stepStart(steps, a.step ?? 0);\n return s === undefined ? Infinity : s + (a.delay ?? 0);\n};\n\n/**\n * What each animated element shows at `timeMs`. For each attribute (or\n * line, or count) the latest change to have started wins; before the first\n * one starts, the element shows that change's starting value, so something\n * that grows in later is hidden until then.\n */\nexport function svgFrame(\n animations: readonly SvgAnimation[],\n steps: readonly number[],\n timeMs: number,\n): Map<string, SvgElementFrame> {\n // Each property's changes in the order they start (ties: list order).\n const tracks = new Map<string, { anim: SvgAnimation; start: number; index: number }[]>();\n const add = (prop: string, anim: SvgAnimation, index: number) => {\n const key = `${prop === \"view\" ? SVG_PICTURE : anim.id}\\u0000${prop}`;\n const list = tracks.get(key) ?? [];\n list.push({ anim, start: startOf(anim, steps), index });\n tracks.set(key, list);\n };\n animations.forEach((a, i) => {\n for (const name of Object.keys(a.attrs ?? {})) add(`@${name}`, a, i);\n if (a.draw) add(\"draw\", a, i);\n if (a.count) add(\"count\", a, i);\n if (a.view !== undefined) add(\"view\", a, i);\n if (a.along) add(\"along\", a, i);\n });\n const frames = new Map<string, SvgElementFrame>();\n for (const [key, list] of tracks) {\n list.sort((x, y) => x.start - y.start || x.index - y.index);\n const [id, prop] = key.split(\"\\u0000\") as [string, string];\n const started = list.filter((c) => c.start <= timeMs);\n const current = started[started.length - 1];\n const anim = (current ?? list[0]!).anim;\n const u = current\n ? stepProgress(steps, timeMs, anim.step ?? 0, {\n delay: anim.delay,\n ms: anim.ms,\n ease: anim.ease,\n })\n : 0;\n const frame = frames.get(id) ?? { attrs: {} };\n if (prop === \"view\") {\n // From where the change before it left the picture.\n const before = current ? list[list.indexOf(current) - 1] : undefined;\n frame.view = { from: before?.anim.view ?? null, to: anim.view!, u };\n } else if (prop === \"along\") {\n const [a, b] = anim.at ?? [0, 1];\n frame.along = { path: anim.along!, at: a + (b - a) * u };\n } else if (prop.startsWith(\"@\")) {\n const [a, b] = anim.attrs![prop.slice(1)]!;\n frame.attrs[prop.slice(1)] = lerpAttr(a, b, u);\n } else if (prop === \"draw\") {\n const [a, b] = anim.draw === true ? [0, 1] : (anim.draw as readonly [number, number]);\n frame.draw = a + (b - a) * u;\n } else {\n const [a, b] = anim.count!;\n const n = (a + (b - a) * u).toFixed(anim.decimals ?? 0);\n frame.text = (anim.format ?? \"{n}\").replace(\"{n}\", n);\n }\n frames.set(id, frame);\n }\n return frames;\n}\n\n/**\n * The opening tag of the root element at the start of `markup` (up to its\n * first `>`), cut out without a regular expression, so checks on it stay\n * linear however long or odd the markup is.\n */\nexport function svgOpeningTag(markup: string): string {\n const end = markup.indexOf(\">\");\n return end < 0 ? markup : markup.slice(0, end + 1);\n}\n\n/** Problems with an {@link SvgMotion}, as sentences; none when it can be drawn. */\nexport function svgMotionIssues(motion: unknown): string[] {\n const issues: string[] = [];\n const m = (motion ?? {}) as Partial<SvgMotion>;\n const svg = typeof m.svg === \"string\" ? m.svg.trim() : \"\";\n if (!svg) return [\"`svg` needs the picture's markup: one <svg> element\"];\n if (!/^<svg[\\s>]/i.test(svg) || !svg.toLowerCase().endsWith(\"</svg>\"))\n issues.push(\"`svg` must be one <svg>…</svg> element\");\n if (!/\\sviewBox\\s*=/i.test(svgOpeningTag(svg)))\n issues.push(\"the <svg> needs a `viewBox`, so it scales to where it is placed\");\n if (/<script|<foreignObject|\\son\\w+\\s*=/i.test(svg))\n issues.push(\"`svg` cannot have scripts, event handlers or <foreignObject>\");\n if (/(?:href|src)\\s*=\\s*[\"'](?!#|data:image\\/)/i.test(svg))\n issues.push(\"`svg` cannot link outside itself (only #ids and data:image URLs)\");\n const ids = new Set([...svg.matchAll(/\\sid\\s*=\\s*[\"']([^\"']+)[\"']/g)].map((x) => x[1]));\n if (m.animate !== undefined && !Array.isArray(m.animate)) issues.push(\"`animate` must be a list\");\n (Array.isArray(m.animate) ? m.animate : []).forEach((a, i) => {\n const where = `animate[${i}]`;\n if (!a || typeof a !== \"object\") return void issues.push(`${where} is not an animation`);\n if (typeof a.id !== \"string\") {\n if (a.view === undefined) return void issues.push(`${where} needs an \\`id\\``);\n } else if (!ids.has(a.id))\n issues.push(`${where}: there is no element with id \"${a.id}\" in the SVG`);\n if (a.step !== undefined && !(Number.isInteger(a.step) && a.step >= 0))\n issues.push(`${where}: \\`step\\` is a whole number, 0 or more`);\n if (a.ms !== undefined && !(a.ms >= 0)) issues.push(`${where}: \\`ms\\` must be 0 or more`);\n if (a.delay !== undefined && !(a.delay >= 0))\n issues.push(`${where}: \\`delay\\` must be 0 or more`);\n if (a.ease !== undefined && !(a.ease in EASES))\n issues.push(`${where}: \\`ease\\` is one of ${Object.keys(EASES).join(\", \")}`);\n if (!a.attrs && !a.draw && !a.count && a.view === undefined && !a.along)\n issues.push(\n `${where} changes nothing: give \\`attrs\\`, \\`draw\\`, \\`count\\`, \\`view\\` or \\`along\\``,\n );\n if (a.view !== undefined) {\n const box = a.view as unknown;\n if (typeof box === \"string\") {\n if (!ids.has(box))\n issues.push(`${where}: \\`view\\` frames \"${box}\", which is not an id in the SVG`);\n } else if (\n !Array.isArray(box) ||\n box.length !== 4 ||\n !box.every((n) => Number.isFinite(n)) ||\n !(box[2] > 0 && box[3] > 0)\n )\n issues.push(\n `${where}: \\`view\\` is [x, y, width, height] (width and height above 0) or an element's id`,\n );\n }\n if (a.along !== undefined) {\n if (typeof a.along !== \"string\" || !ids.has(a.along))\n issues.push(`${where}: \\`along\\` is the id of a path in the SVG`);\n if (typeof a.id !== \"string\")\n issues.push(`${where}: \\`along\\` moves an element: give its \\`id\\``);\n }\n if (\n a.at !== undefined &&\n !(Array.isArray(a.at) && a.at.length === 2 && a.at.every((v) => v >= 0 && v <= 1))\n )\n issues.push(`${where}: \\`at\\` is [from, to] between 0 and 1`);\n for (const [name, pair] of Object.entries(a.attrs ?? {}))\n if (!Array.isArray(pair) || pair.length !== 2)\n issues.push(`${where}: \\`attrs.${name}\\` is [from, to]`);\n if (Array.isArray(a.draw) && a.draw.some((v) => !(v >= 0 && v <= 1)))\n issues.push(`${where}: \\`draw\\` is true or [from, to] between 0 and 1`);\n if (a.count !== undefined && !(Array.isArray(a.count) && a.count.length === 2))\n issues.push(`${where}: \\`count\\` is [from, to]`);\n });\n return issues;\n}\n","/**\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 { SVG_PICTURE, svgFrame, svgOpeningTag, type SvgBox, type SvgMotion } 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/** 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) {\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, value);\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.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 /** Called with the id of the innermost element with an id that is clicked. */\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.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 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 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]\") ?? []) byId.set(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);\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 /** Start again at the end (default `true`). */\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}\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 readonly steps: readonly number[];\n private readonly loop: boolean;\n private readonly length: number;\n private speed: number;\n private time = 0;\n private last = 0;\n private playing = false;\n private disposed = false;\n\n constructor(\n private readonly container: HTMLElement,\n motion: SvgMotion,\n options: SvgPlayerOptions = {},\n ) {\n this.clock = options.clock ?? realClock;\n this.steps = options.steps ?? [];\n this.loop = options.loop ?? true;\n this.speed = options.speed ?? 1;\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 if (options.autoplay ?? true) this.play();\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 this.last = this.clock.now();\n void this.run();\n }\n\n pause(): void {\n this.playing = false;\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 setSpeed(speed: number): void {\n this.speed = speed;\n }\n\n dispose(): void {\n this.disposed = true;\n this.playing = false;\n this.view.element.remove();\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 next = this.time + (now - this.last) * this.speed;\n this.last = now;\n if (!this.loop && next >= this.length) {\n this.seek(this.length);\n this.playing = false;\n return;\n }\n this.seek(next);\n }\n }\n}\n"],"mappings":";;;;;AAQO,IAAM,QAAQ;AAAA,EACnB,QAAQ,CAAC,MAAc;AAAA,EACvB,UAAU,CAAC,MAAe,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,IAAI;AAAA,EAC5E,KAAK,CAAC,MAAc,KAAK,IAAI,MAAM;AACrC;AAKO,IAAM,UAAU;AAEvB,IAAM,UAAU,CAAC,MAAe,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI;AAMjD,SAAS,UAAU,OAA0B,MAAkC;AACpF,MAAI,QAAQ,EAAG,QAAO;AACtB,SAAO,MAAM,OAAO,CAAC;AACvB;AAMO,SAAS,aACd,OACA,QACA,MACA,UAA4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