@algorisys/tinyfly 0.64.0 → 0.65.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/README.md +59 -11
- package/lib/browser/tinyfly.iife.js +2 -2
- package/lib/browser/tinyfly.js +18 -4
- package/lib/browser/tinyfly.umd.js +2 -2
- package/lib/cli/tools.js +20 -3
- package/lib/embed/tinyfly-embed.iife.js +6 -3
- package/lib/embed/tinyfly-embed.js +437 -408
- package/lib/engine/tinyfly-engine.js +69 -55
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/player/tinyfly-player.es.js +86 -72
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/embed/controls.d.ts +5 -0
- package/lib/types/embed/mount.d.ts +2 -1
- package/lib/types/engine/core/timeline.d.ts +7 -2
- package/lib/types/player/player.d.ts +2 -1
- package/package.json +1 -1
|
@@ -4,14 +4,14 @@ function ae(e) {
|
|
|
4
4
|
function oe(e) {
|
|
5
5
|
return typeof e == "object" && e !== null && e.type !== "cubic-bezier";
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const K = 1;
|
|
8
8
|
function Ut(e) {
|
|
9
9
|
return e.property === "text" && "textConfig" in e;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function mt(e) {
|
|
12
12
|
return e.kind === "inertia" && "inertia" in e;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function gt(e) {
|
|
15
15
|
return e.kind === "spring" && "spring" in e;
|
|
16
16
|
}
|
|
17
17
|
function ce(e) {
|
|
@@ -53,10 +53,10 @@ function Ht(e, t, s) {
|
|
|
53
53
|
function he(e, t) {
|
|
54
54
|
return Array.from({ length: e }, (s, n) => Ht(n, e, t));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function Mt(e, t) {
|
|
57
57
|
return e <= 1 ? 0 : Math.max(...he(e, t));
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const Z = 1, zt = 6e4, tt = zt / Z, V = {
|
|
60
60
|
stiffness: 180,
|
|
61
61
|
damping: 12,
|
|
62
62
|
mass: 1,
|
|
@@ -89,7 +89,7 @@ class ue {
|
|
|
89
89
|
/** Once at rest we stop simulating; every later time returns `to`. */
|
|
90
90
|
settledStep = null;
|
|
91
91
|
constructor(t) {
|
|
92
|
-
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ??
|
|
92
|
+
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? V.stiffness, this.damping = t.damping ?? V.damping, this.mass = t.mass ?? V.mass, this.restDelta = t.restDelta ?? V.restDelta, this.restSpeed = t.restSpeed ?? V.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? V.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Whether a position/velocity pair counts as settled.
|
|
@@ -107,10 +107,10 @@ class ue {
|
|
|
107
107
|
*/
|
|
108
108
|
valueAt(t) {
|
|
109
109
|
if (t <= 0) return this.from;
|
|
110
|
-
const s = Math.floor(t /
|
|
110
|
+
const s = Math.floor(t / Z);
|
|
111
111
|
if (this.simulateTo(s + 1), this.settledStep !== null && s >= this.settledStep)
|
|
112
112
|
return this.to;
|
|
113
|
-
const n = this.samples[Math.min(s, this.samples.length - 1)], i = this.samples[Math.min(s + 1, this.samples.length - 1)], r = t /
|
|
113
|
+
const n = this.samples[Math.min(s, this.samples.length - 1)], i = this.samples[Math.min(s + 1, this.samples.length - 1)], r = t / Z - s;
|
|
114
114
|
return n + (i - n) * r;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
@@ -118,31 +118,31 @@ class ue {
|
|
|
118
118
|
* of a spring track. Runs the simulation to completion once.
|
|
119
119
|
*/
|
|
120
120
|
settleTime() {
|
|
121
|
-
return this.simulateTo(
|
|
121
|
+
return this.simulateTo(tt + 1), this.settledStep !== null ? this.settledStep * Z : zt;
|
|
122
122
|
}
|
|
123
123
|
/** Advance the cached simulation until it holds at least `steps` samples. */
|
|
124
124
|
simulateTo(t) {
|
|
125
125
|
if (this.settledStep !== null) return;
|
|
126
|
-
const s = Math.min(t,
|
|
126
|
+
const s = Math.min(t, tt + 1), n = Z / 1e3;
|
|
127
127
|
for (; this.samples.length < s; ) {
|
|
128
|
-
const i = this.samples[this.samples.length - 1], r = i - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity,
|
|
129
|
-
this.velocity +=
|
|
130
|
-
const
|
|
131
|
-
if (this.samples.push(
|
|
128
|
+
const i = this.samples[this.samples.length - 1], r = i - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, c = (a + o) / this.mass;
|
|
129
|
+
this.velocity += c * n;
|
|
130
|
+
const l = i + this.velocity * n;
|
|
131
|
+
if (this.samples.push(l), this.isAtRest(l)) {
|
|
132
132
|
this.settledStep = this.samples.length - 1;
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
this.samples.length >
|
|
136
|
+
this.samples.length > tt && (this.settledStep = tt);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
const wt = 4, fe = 2e-3, de = 1e-4, pe = 6e4;
|
|
140
|
-
function
|
|
140
|
+
function Tt(e) {
|
|
141
141
|
const t = e.friction ?? wt;
|
|
142
142
|
return t > 0 ? t : wt;
|
|
143
143
|
}
|
|
144
144
|
function me(e) {
|
|
145
|
-
return e.from + e.velocity /
|
|
145
|
+
return e.from + e.velocity / Tt(e);
|
|
146
146
|
}
|
|
147
147
|
function ge(e, t) {
|
|
148
148
|
if (t === void 0) return e;
|
|
@@ -163,18 +163,18 @@ function Qt(e) {
|
|
|
163
163
|
if (t === 0) return 0;
|
|
164
164
|
const s = e.restDelta ?? Math.max(de, t * fe);
|
|
165
165
|
if (s >= t) return 0;
|
|
166
|
-
const n = Math.log(t / s) /
|
|
166
|
+
const n = Math.log(t / s) / Tt(e);
|
|
167
167
|
return Math.min(pe, n * 1e3);
|
|
168
168
|
}
|
|
169
169
|
function xt(e, t) {
|
|
170
170
|
if (t <= 0) return e.from;
|
|
171
171
|
const s = Gt(e);
|
|
172
172
|
if (t >= Qt(e)) return s;
|
|
173
|
-
const n =
|
|
173
|
+
const n = Tt(e);
|
|
174
174
|
return e.from + (s - e.from) * (1 - Math.exp(-n * t / 1e3));
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
linear:
|
|
176
|
+
const yt = (e) => e, ye = (e) => e * e, be = (e) => 1 - (1 - e) * (1 - e), ke = (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2, Zt = (e) => e * e * e, Kt = (e) => 1 - Math.pow(1 - e, 3), Jt = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, Me = Zt, Te = Kt, Se = Jt, we = {
|
|
177
|
+
linear: yt,
|
|
178
178
|
"ease-in": Me,
|
|
179
179
|
"ease-out": Te,
|
|
180
180
|
"ease-in-out": Se,
|
|
@@ -186,34 +186,34 @@ const gt = (e) => e, ye = (e) => e * e, be = (e) => 1 - (1 - e) * (1 - e), ke =
|
|
|
186
186
|
"ease-in-out-cubic": Jt
|
|
187
187
|
};
|
|
188
188
|
function xe(e) {
|
|
189
|
-
const [t, s, n, i] = e, r = 3 * t, a = 3 * (n - t) - r, o = 1 - r - a,
|
|
189
|
+
const [t, s, n, i] = e, r = 3 * t, a = 3 * (n - t) - r, o = 1 - r - a, c = 3 * s, l = 3 * (i - s) - c, u = 1 - c - l, h = (p) => ((o * p + a) * p + r) * p, f = (p) => ((u * p + l) * p + c) * p, d = (p) => (3 * o * p + 2 * a) * p + r, b = (p) => {
|
|
190
190
|
let m = p;
|
|
191
191
|
for (let T = 0; T < 8; T++) {
|
|
192
|
-
const
|
|
193
|
-
if (Math.abs(
|
|
192
|
+
const w = h(m) - p;
|
|
193
|
+
if (Math.abs(w) < 1e-7)
|
|
194
194
|
return m;
|
|
195
195
|
const g = d(m);
|
|
196
196
|
if (Math.abs(g) < 1e-7)
|
|
197
197
|
break;
|
|
198
|
-
m -=
|
|
198
|
+
m -= w / g;
|
|
199
199
|
}
|
|
200
|
-
let
|
|
201
|
-
for (m = p;
|
|
200
|
+
let k = 0, y = 1;
|
|
201
|
+
for (m = p; k < y; ) {
|
|
202
202
|
const T = h(m);
|
|
203
203
|
if (Math.abs(T - p) < 1e-7)
|
|
204
204
|
return m;
|
|
205
|
-
p > T ?
|
|
205
|
+
p > T ? k = m : y = m, m = (k + y) / 2;
|
|
206
206
|
}
|
|
207
207
|
return m;
|
|
208
208
|
};
|
|
209
209
|
return (p) => {
|
|
210
210
|
if (p <= 0) return 0;
|
|
211
211
|
if (p >= 1) return 1;
|
|
212
|
-
const m =
|
|
212
|
+
const m = b(p);
|
|
213
213
|
return f(m);
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function ct(e, t = "out") {
|
|
217
217
|
if (t === "out") return e;
|
|
218
218
|
const s = (n) => 1 - e(1 - n);
|
|
219
219
|
return t === "in" ? s : (n) => n < 0.5 ? s(n * 2) / 2 : e(n * 2 - 1) / 2 + 0.5;
|
|
@@ -268,17 +268,17 @@ function Ie(e) {
|
|
|
268
268
|
case "steps":
|
|
269
269
|
return Pe(e.count, e.position);
|
|
270
270
|
case "elastic":
|
|
271
|
-
return
|
|
271
|
+
return ct(_e(e.amplitude, e.period), e.mode);
|
|
272
272
|
case "bounce":
|
|
273
|
-
return
|
|
273
|
+
return ct(ve, e.mode);
|
|
274
274
|
case "back":
|
|
275
|
-
return
|
|
275
|
+
return ct(Ae(e.overshoot), e.mode);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
function Ce(e) {
|
|
279
|
-
return e === void 0 ?
|
|
279
|
+
return e === void 0 ? yt : ae(e) ? xe(e.points) : oe(e) ? Ie(e) : we[e] ?? yt;
|
|
280
280
|
}
|
|
281
|
-
const _t = 32, Re = 256,
|
|
281
|
+
const _t = 32, Re = 256, H = /* @__PURE__ */ new Map(), Ee = /[MmLlHhVvCcSsQqTtAaZz]/, $e = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, De = {
|
|
282
282
|
M: 2,
|
|
283
283
|
L: 2,
|
|
284
284
|
H: 1,
|
|
@@ -309,39 +309,39 @@ function Oe(e) {
|
|
|
309
309
|
n.args.push(r === "1" ? 1 : 0), s++;
|
|
310
310
|
continue;
|
|
311
311
|
}
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
n.args.push(parseFloat(
|
|
312
|
+
const c = $e.exec(e.slice(s));
|
|
313
|
+
if (!c) break;
|
|
314
|
+
n.args.push(parseFloat(c[0])), s += c[0].length;
|
|
315
315
|
}
|
|
316
316
|
return t;
|
|
317
317
|
}
|
|
318
|
-
function Le(e, t, s, n, i, r, a, o,
|
|
319
|
-
if (e === o && t ===
|
|
320
|
-
let
|
|
321
|
-
if (
|
|
322
|
-
const h = i * Math.PI / 180, f = Math.cos(h), d = Math.sin(h),
|
|
323
|
-
if (
|
|
324
|
-
const P = Math.sqrt(
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
const T = r === a ? -1 : 1,
|
|
328
|
-
const
|
|
329
|
-
return P *
|
|
330
|
-
},
|
|
331
|
-
let
|
|
332
|
-
!a &&
|
|
333
|
-
const
|
|
334
|
-
const
|
|
335
|
-
return [f *
|
|
318
|
+
function Le(e, t, s, n, i, r, a, o, c) {
|
|
319
|
+
if (e === o && t === c) return [];
|
|
320
|
+
let l = Math.abs(s), u = Math.abs(n);
|
|
321
|
+
if (l === 0 || u === 0) return [[e, t, o, c, o, c]];
|
|
322
|
+
const h = i * Math.PI / 180, f = Math.cos(h), d = Math.sin(h), b = (e - o) / 2, p = (t - c) / 2, m = f * b + d * p, k = -d * b + f * p, y = m * m / (l * l) + k * k / (u * u);
|
|
323
|
+
if (y > 1) {
|
|
324
|
+
const P = Math.sqrt(y);
|
|
325
|
+
l *= P, u *= P;
|
|
326
|
+
}
|
|
327
|
+
const T = r === a ? -1 : 1, w = l * l * u * u - l * l * k * k - u * u * m * m, g = l * l * k * k + u * u * m * m, x = T * Math.sqrt(Math.max(0, w / g)), S = x * l * k / u, I = -x * u * m / l, Y = f * S - d * I + (e + o) / 2, _ = d * S + f * I + (t + c) / 2, C = (P, R, D, q) => {
|
|
328
|
+
const ot = P * D + R * q, J = Math.sqrt((P * P + R * R) * (D * D + q * q)), j = Math.acos(Math.max(-1, Math.min(1, ot / J)));
|
|
329
|
+
return P * q - R * D < 0 ? -j : j;
|
|
330
|
+
}, A = C(1, 0, (m - S) / l, (k - I) / u);
|
|
331
|
+
let M = C((m - S) / l, (k - I) / u, (-m - S) / l, (-k - I) / u);
|
|
332
|
+
!a && M > 0 && (M -= 2 * Math.PI), a && M < 0 && (M += 2 * Math.PI);
|
|
333
|
+
const v = Math.max(1, Math.ceil(Math.abs(M) / (Math.PI / 2))), O = M / v, E = 4 / 3 * Math.tan(O / 4), $ = (P) => {
|
|
334
|
+
const R = l * Math.cos(P), D = u * Math.sin(P);
|
|
335
|
+
return [f * R - d * D + Y, d * R + f * D + _];
|
|
336
336
|
}, B = (P) => {
|
|
337
|
-
const
|
|
338
|
-
return [f *
|
|
339
|
-
},
|
|
340
|
-
for (let P = 0; P <
|
|
341
|
-
const
|
|
342
|
-
|
|
337
|
+
const R = -l * Math.sin(P), D = u * Math.cos(P);
|
|
338
|
+
return [f * R - d * D, d * R + f * D];
|
|
339
|
+
}, U = [];
|
|
340
|
+
for (let P = 0; P < v; P++) {
|
|
341
|
+
const R = A + P * O, D = R + O, [q, ot] = $(R), [J, j] = P === v - 1 ? [o, c] : $(D), [se, ne] = B(R), [ie, re] = B(D);
|
|
342
|
+
U.push([q + E * se, ot + E * ne, J - E * ie, j - E * re, J, j]);
|
|
343
343
|
}
|
|
344
|
-
return
|
|
344
|
+
return U;
|
|
345
345
|
}
|
|
346
346
|
function N(e, t, s, n, i) {
|
|
347
347
|
const r = 1 - i;
|
|
@@ -351,7 +351,7 @@ function vt(e, t, s, n, i) {
|
|
|
351
351
|
const r = 1 - i;
|
|
352
352
|
return 3 * r * r * (t - e) + 6 * r * i * (s - t) + 3 * i * i * (n - s);
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function z(e, t, s, n) {
|
|
355
355
|
return {
|
|
356
356
|
subpath: 0,
|
|
357
357
|
type: "L",
|
|
@@ -363,104 +363,104 @@ function H(e, t, s, n) {
|
|
|
363
363
|
length: Math.hypot(s - e, n - t)
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
const [n, i, r, a, o,
|
|
366
|
+
function et(e, t, s) {
|
|
367
|
+
const [n, i, r, a, o, c] = s, l = [0];
|
|
368
368
|
let u = e, h = t, f = 0;
|
|
369
369
|
for (let d = 1; d <= _t; d++) {
|
|
370
|
-
const
|
|
371
|
-
f += Math.hypot(p - u, m - h),
|
|
370
|
+
const b = d / _t, p = N(e, n, r, o, b), m = N(t, i, a, c, b);
|
|
371
|
+
f += Math.hypot(p - u, m - h), l.push(f), u = p, h = m;
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
subpath: 0,
|
|
375
375
|
type: "C",
|
|
376
|
-
points: [n, i, r, a, o,
|
|
376
|
+
points: [n, i, r, a, o, c],
|
|
377
377
|
startX: e,
|
|
378
378
|
startY: t,
|
|
379
379
|
endX: o,
|
|
380
|
-
endY:
|
|
380
|
+
endY: c,
|
|
381
381
|
length: f,
|
|
382
|
-
lengths:
|
|
382
|
+
lengths: l
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
const t =
|
|
385
|
+
function it(e) {
|
|
386
|
+
const t = H.get(e);
|
|
387
387
|
if (t) return t;
|
|
388
388
|
const s = [];
|
|
389
|
-
let n = 0, i = 0, r = 0, a = 0, o = null,
|
|
389
|
+
let n = 0, i = 0, r = 0, a = 0, o = null, c = null, l = -1;
|
|
390
390
|
const u = /* @__PURE__ */ new Set(), h = (p) => {
|
|
391
|
-
|
|
391
|
+
l < 0 && (l = 0), p.subpath = l, s.push(p);
|
|
392
392
|
};
|
|
393
393
|
for (const { type: p, args: m } of Oe(e)) {
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
(n !== r || i !== a) && h(
|
|
394
|
+
const k = p.toUpperCase(), y = p !== k, T = De[k];
|
|
395
|
+
if (k === "Z") {
|
|
396
|
+
(n !== r || i !== a) && h(z(n, i, r, a)), l >= 0 && u.add(l), n = r, i = a, o = c = null;
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
|
-
for (let
|
|
400
|
-
const g = m.slice(
|
|
401
|
-
let I = null,
|
|
402
|
-
switch (
|
|
399
|
+
for (let w = 0; w + T <= m.length; w += T) {
|
|
400
|
+
const g = m.slice(w, w + T), x = y ? n : 0, S = y ? i : 0;
|
|
401
|
+
let I = null, Y = null;
|
|
402
|
+
switch (k) {
|
|
403
403
|
case "M":
|
|
404
|
-
|
|
404
|
+
w === 0 ? (n = g[0] + x, i = g[1] + S, r = n, a = i, (l < 0 || s[s.length - 1]?.subpath === l) && l++) : (h(z(n, i, g[0] + x, g[1] + S)), n = g[0] + x, i = g[1] + S);
|
|
405
405
|
break;
|
|
406
406
|
case "L":
|
|
407
|
-
h(
|
|
407
|
+
h(z(n, i, g[0] + x, g[1] + S)), n = g[0] + x, i = g[1] + S;
|
|
408
408
|
break;
|
|
409
409
|
case "H":
|
|
410
|
-
h(
|
|
410
|
+
h(z(n, i, g[0] + x, i)), n = g[0] + x;
|
|
411
411
|
break;
|
|
412
412
|
case "V":
|
|
413
|
-
h(
|
|
413
|
+
h(z(n, i, n, g[0] + S)), i = g[0] + S;
|
|
414
414
|
break;
|
|
415
415
|
case "C": {
|
|
416
|
-
const
|
|
417
|
-
h(
|
|
416
|
+
const _ = [g[0] + x, g[1] + S, g[2] + x, g[3] + S, g[4] + x, g[5] + S];
|
|
417
|
+
h(et(n, i, _)), I = [_[2], _[3]], n = _[4], i = _[5];
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
420
|
case "S": {
|
|
421
|
-
const [
|
|
422
|
-
h(
|
|
421
|
+
const [_, C] = o ? [2 * n - o[0], 2 * i - o[1]] : [n, i], A = [_, C, g[0] + x, g[1] + S, g[2] + x, g[3] + S];
|
|
422
|
+
h(et(n, i, A)), I = [A[2], A[3]], n = A[4], i = A[5];
|
|
423
423
|
break;
|
|
424
424
|
}
|
|
425
425
|
case "Q":
|
|
426
426
|
case "T": {
|
|
427
|
-
let
|
|
428
|
-
|
|
429
|
-
const
|
|
427
|
+
let _ = n, C = i;
|
|
428
|
+
k === "Q" ? (_ = g[0] + x, C = g[1] + S) : c && (_ = 2 * n - c[0], C = 2 * i - c[1]);
|
|
429
|
+
const A = k === "Q" ? g[2] + x : g[0] + x, M = k === "Q" ? g[3] + S : g[1] + S;
|
|
430
430
|
h(
|
|
431
|
-
|
|
432
|
-
n + 2 / 3 * (
|
|
433
|
-
i + 2 / 3 * (
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
431
|
+
et(n, i, [
|
|
432
|
+
n + 2 / 3 * (_ - n),
|
|
433
|
+
i + 2 / 3 * (C - i),
|
|
434
|
+
A + 2 / 3 * (_ - A),
|
|
435
|
+
M + 2 / 3 * (C - M),
|
|
436
|
+
A,
|
|
437
|
+
M
|
|
438
438
|
])
|
|
439
|
-
),
|
|
439
|
+
), Y = [_, C], n = A, i = M;
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case "A": {
|
|
443
|
-
const
|
|
444
|
-
let
|
|
445
|
-
for (const
|
|
446
|
-
h(
|
|
447
|
-
n =
|
|
443
|
+
const _ = g[5] + x, C = g[6] + S;
|
|
444
|
+
let A = n, M = i;
|
|
445
|
+
for (const v of Le(n, i, g[0], g[1], g[2], g[3], g[4], _, C))
|
|
446
|
+
h(et(A, M, v)), A = v[4], M = v[5];
|
|
447
|
+
n = _, i = C;
|
|
448
448
|
break;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
o = I,
|
|
451
|
+
o = I, c = Y;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
const f = s.reduce((p, m) => p + m.length, 0), d = [];
|
|
455
455
|
for (let p = 0; p < s.length; ) {
|
|
456
456
|
const m = s[p].subpath;
|
|
457
|
-
let
|
|
458
|
-
for (;
|
|
459
|
-
const T = s[p],
|
|
460
|
-
d.push({ start: p, end:
|
|
457
|
+
let k = p, y = 0;
|
|
458
|
+
for (; k < s.length && s[k].subpath === m; ) y += s[k++].length;
|
|
459
|
+
const T = s[p], w = s[k - 1], g = u.has(m) || Math.abs(w.endX - T.startX) < 1e-9 && Math.abs(w.endY - T.startY) < 1e-9;
|
|
460
|
+
d.push({ start: p, end: k, length: y, closed: g }), p = k;
|
|
461
461
|
}
|
|
462
|
-
const
|
|
463
|
-
return
|
|
462
|
+
const b = { segments: s, totalLength: f, subpaths: d };
|
|
463
|
+
return H.size >= Re && H.delete(H.keys().next().value), H.set(e, b), b;
|
|
464
464
|
}
|
|
465
465
|
function Ne(e, t) {
|
|
466
466
|
const s = e.lengths;
|
|
@@ -474,7 +474,7 @@ function Ne(e, t) {
|
|
|
474
474
|
const r = s[i] - s[n], a = r > 0 ? (t - s[n]) / r : 0;
|
|
475
475
|
return (n + a) / (s.length - 1);
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function Fe(e, t) {
|
|
478
478
|
if (e.type === "L") {
|
|
479
479
|
const h = e.length > 0 ? Math.max(0, Math.min(1, t / e.length)) : 0;
|
|
480
480
|
return {
|
|
@@ -483,16 +483,16 @@ function Xe(e, t) {
|
|
|
483
483
|
angle: Math.atan2(e.endY - e.startY, e.endX - e.startX) * 180 / Math.PI
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
const [s, n, i, r, a, o] = e.points,
|
|
487
|
-
let
|
|
488
|
-
if (Math.hypot(
|
|
489
|
-
const h =
|
|
490
|
-
|
|
486
|
+
const [s, n, i, r, a, o] = e.points, c = Ne(e, t);
|
|
487
|
+
let l = vt(e.startX, s, i, a, c), u = vt(e.startY, n, r, o, c);
|
|
488
|
+
if (Math.hypot(l, u) < 1e-9) {
|
|
489
|
+
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), f = N(e.startX, s, i, a, h), d = N(e.startY, n, r, o, h), b = N(e.startX, s, i, a, c), p = N(e.startY, n, r, o, c);
|
|
490
|
+
l = c < 0.5 ? f - b : b - f, u = c < 0.5 ? d - p : p - d;
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
|
-
x: N(e.startX, s, i, a,
|
|
494
|
-
y: N(e.startY, n, r, o,
|
|
495
|
-
angle: Math.atan2(u,
|
|
493
|
+
x: N(e.startX, s, i, a, c),
|
|
494
|
+
y: N(e.startY, n, r, o, c),
|
|
495
|
+
angle: Math.atan2(u, l) * 180 / Math.PI
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
498
|
function te(e, t, s = 0, n = e.length) {
|
|
@@ -501,20 +501,20 @@ function te(e, t, s = 0, n = e.length) {
|
|
|
501
501
|
for (let r = s; r < n; r++) {
|
|
502
502
|
const a = e[r];
|
|
503
503
|
if (i + a.length >= t || r === n - 1)
|
|
504
|
-
return
|
|
504
|
+
return Fe(a, t - i);
|
|
505
505
|
i += a.length;
|
|
506
506
|
}
|
|
507
507
|
return { x: 0, y: 0, angle: 0 };
|
|
508
508
|
}
|
|
509
|
-
function
|
|
510
|
-
const { segments: s, totalLength: n } =
|
|
509
|
+
function Xe(e, t) {
|
|
510
|
+
const { segments: s, totalLength: n } = it(e);
|
|
511
511
|
return te(s, Math.max(0, Math.min(1, t)) * n);
|
|
512
512
|
}
|
|
513
|
-
const Ye = 24, qe = 320, Ve = 2.5,
|
|
514
|
-
let
|
|
513
|
+
const Ye = 24, qe = 320, Ve = 2.5, G = 72, We = 0.2, Be = 128, st = /* @__PURE__ */ new Map();
|
|
514
|
+
let lt = 0, F;
|
|
515
515
|
const At = (e) => Math.round(e * 100) / 100;
|
|
516
516
|
function Pt(e, t) {
|
|
517
|
-
const { segments: s, subpaths: n, totalLength: i } =
|
|
517
|
+
const { segments: s, subpaths: n, totalLength: i } = it(e);
|
|
518
518
|
if (s.length === 0) return [];
|
|
519
519
|
if (t) {
|
|
520
520
|
const r = n.every((a) => a.closed);
|
|
@@ -522,7 +522,7 @@ function Pt(e, t) {
|
|
|
522
522
|
}
|
|
523
523
|
return n.filter((r) => r.length > 0).map((r) => ({ segments: s, start: r.start, end: r.end, length: r.length, closed: r.closed }));
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function bt(e, t) {
|
|
526
526
|
const s = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), n = te(e.segments, s * e.length, e.start, e.end);
|
|
527
527
|
return [n.x, n.y];
|
|
528
528
|
}
|
|
@@ -536,7 +536,7 @@ function It(e) {
|
|
|
536
536
|
function Ct(e, t) {
|
|
537
537
|
const s = [];
|
|
538
538
|
for (let n = 0; n < t; n++)
|
|
539
|
-
s.push(
|
|
539
|
+
s.push(bt(e, e.closed ? n / t : n / (t - 1)));
|
|
540
540
|
return s;
|
|
541
541
|
}
|
|
542
542
|
function Rt(e) {
|
|
@@ -548,18 +548,18 @@ function Rt(e) {
|
|
|
548
548
|
function Ue(e, t, s) {
|
|
549
549
|
const n = e.closed && t.closed;
|
|
550
550
|
if (s !== void 0)
|
|
551
|
-
return { offset: n ? Math.abs(s) %
|
|
552
|
-
const i = Rt(Ct(e,
|
|
553
|
-
let o = { offset: 0, reversed: !1 },
|
|
554
|
-
for (const
|
|
551
|
+
return { offset: n ? Math.abs(s) % G / G : 0, reversed: s < 0 };
|
|
552
|
+
const i = Rt(Ct(e, G)), r = Rt(Ct(t, G)), a = G;
|
|
553
|
+
let o = { offset: 0, reversed: !1 }, c = 1 / 0;
|
|
554
|
+
for (const l of [!1, !0]) {
|
|
555
555
|
const u = n ? a : 1;
|
|
556
556
|
for (let h = 0; h < u; h++) {
|
|
557
557
|
let f = 0;
|
|
558
|
-
for (let d = 0; d < a && f <
|
|
559
|
-
const
|
|
558
|
+
for (let d = 0; d < a && f < c; d++) {
|
|
559
|
+
const b = n ? l ? (h - d + a) % a : (d + h) % a : l ? a - 1 - d : d, p = i[d][0] - r[b][0], m = i[d][1] - r[b][1];
|
|
560
560
|
f += p * p + m * m;
|
|
561
561
|
}
|
|
562
|
-
f <
|
|
562
|
+
f < c && (c = f, o = { offset: n ? h / a : 0, reversed: l });
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
return o;
|
|
@@ -578,12 +578,12 @@ function ze(e, t, s) {
|
|
|
578
578
|
for (let h = 0; h <= r; h++) o(h / r);
|
|
579
579
|
for (const h of It(e)) o(h);
|
|
580
580
|
for (const h of It(t)) o(He(h, i, n));
|
|
581
|
-
let
|
|
582
|
-
n && (
|
|
583
|
-
const
|
|
584
|
-
for (const h of
|
|
585
|
-
|
|
586
|
-
return Ge({ from:
|
|
581
|
+
let c = [...a].sort((h, f) => h - f);
|
|
582
|
+
n && (c = c.filter((h) => h < 1));
|
|
583
|
+
const l = [], u = [];
|
|
584
|
+
for (const h of c)
|
|
585
|
+
l.push(...bt(e, h)), u.push(...bt(t, je(h, i, n)));
|
|
586
|
+
return Ge({ from: l, to: u, closed: n });
|
|
587
587
|
}
|
|
588
588
|
function Ge(e) {
|
|
589
589
|
const t = e.from.length / 2;
|
|
@@ -593,12 +593,12 @@ function Ge(e) {
|
|
|
593
593
|
const n = [[0, t - 1]];
|
|
594
594
|
for (; n.length > 0; ) {
|
|
595
595
|
const [a, o] = n.pop();
|
|
596
|
-
let
|
|
596
|
+
let c = -1, l = We;
|
|
597
597
|
for (let u = a + 1; u < o; u++) {
|
|
598
598
|
const h = Math.max(Et(e.from, a, o, u), Et(e.to, a, o, u));
|
|
599
|
-
h >
|
|
599
|
+
h > l && (l = h, c = u);
|
|
600
600
|
}
|
|
601
|
-
|
|
601
|
+
c !== -1 && (s[c] = 1, n.push([a, c], [c, o]));
|
|
602
602
|
}
|
|
603
603
|
const i = [], r = [];
|
|
604
604
|
for (let a = 0; a < t; a++)
|
|
@@ -606,23 +606,23 @@ function Ge(e) {
|
|
|
606
606
|
return { from: i, to: r, closed: e.closed };
|
|
607
607
|
}
|
|
608
608
|
function Et(e, t, s, n) {
|
|
609
|
-
const i = e[t * 2], r = e[t * 2 + 1], a = e[s * 2] - i, o = e[s * 2 + 1] - r,
|
|
610
|
-
return Math.hypot(
|
|
609
|
+
const i = e[t * 2], r = e[t * 2 + 1], a = e[s * 2] - i, o = e[s * 2 + 1] - r, c = e[n * 2] - i, l = e[n * 2 + 1] - r, u = a * a + o * o, h = u === 0 ? 0 : Math.max(0, Math.min(1, (c * a + l * o) / u));
|
|
610
|
+
return Math.hypot(c - h * a, l - h * o);
|
|
611
611
|
}
|
|
612
612
|
function Qe(e, t, s) {
|
|
613
613
|
const n = s.shapeIndex;
|
|
614
|
-
if (
|
|
615
|
-
const r =
|
|
614
|
+
if (F && F.from === e && F.to === t && F.shapeIndex === n) return F.plan;
|
|
615
|
+
const r = st.get(String(n ?? "auto"))?.get(e)?.get(t);
|
|
616
616
|
if (r)
|
|
617
|
-
return
|
|
618
|
-
const a =
|
|
619
|
-
pairs: o.map((d,
|
|
617
|
+
return F = { from: e, to: t, shapeIndex: n, plan: r }, r;
|
|
618
|
+
const a = it(e).subpaths.filter((d) => d.length > 0).length === it(t).subpaths.filter((d) => d.length > 0).length, o = Pt(e, !a), c = Pt(t, !a), l = {
|
|
619
|
+
pairs: o.map((d, b) => ze(d, c[b], s))
|
|
620
620
|
};
|
|
621
|
-
|
|
622
|
-
const u = String(n ?? "auto"), h =
|
|
623
|
-
|
|
621
|
+
lt >= Be && (st.clear(), lt = 0);
|
|
622
|
+
const u = String(n ?? "auto"), h = st.get(u) ?? /* @__PURE__ */ new Map();
|
|
623
|
+
st.set(u, h);
|
|
624
624
|
const f = h.get(e) ?? /* @__PURE__ */ new Map();
|
|
625
|
-
return h.set(e, f), f.set(t,
|
|
625
|
+
return h.set(e, f), f.set(t, l), lt++, F = { from: e, to: t, shapeIndex: n, plan: l }, l;
|
|
626
626
|
}
|
|
627
627
|
function Ze(e, t, s, n = {}) {
|
|
628
628
|
if (!e) return t;
|
|
@@ -634,9 +634,9 @@ function Ze(e, t, s, n = {}) {
|
|
|
634
634
|
if (r.pairs.length === 0) return i < 0.5 ? e : t;
|
|
635
635
|
let a = "";
|
|
636
636
|
for (const o of r.pairs) {
|
|
637
|
-
for (let
|
|
638
|
-
const
|
|
639
|
-
a += `${
|
|
637
|
+
for (let c = 0; c < o.from.length; c += 2) {
|
|
638
|
+
const l = At(o.from[c] + (o.to[c] - o.from[c]) * i), u = At(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * i);
|
|
639
|
+
a += `${c === 0 ? a ? " M" : "M" : " L"}${l} ${u}`;
|
|
640
640
|
}
|
|
641
641
|
o.closed && (a += " Z");
|
|
642
642
|
}
|
|
@@ -645,39 +645,39 @@ function Ze(e, t, s, n = {}) {
|
|
|
645
645
|
function Ke(e) {
|
|
646
646
|
return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e);
|
|
647
647
|
}
|
|
648
|
-
const L = (e, t, s) => e + (t - e) * s, ee = 512,
|
|
648
|
+
const L = (e, t, s) => e + (t - e) * s, ee = 512, ht = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Map();
|
|
649
649
|
function $t(e) {
|
|
650
|
-
const t =
|
|
650
|
+
const t = ht.get(e);
|
|
651
651
|
if (t) return t;
|
|
652
652
|
const s = e.replace("#", ""), n = [
|
|
653
653
|
parseInt(s.slice(0, 2), 16),
|
|
654
654
|
parseInt(s.slice(2, 4), 16),
|
|
655
655
|
parseInt(s.slice(4, 6), 16)
|
|
656
656
|
];
|
|
657
|
-
return
|
|
657
|
+
return ht.size < ee && ht.set(e, n), n;
|
|
658
658
|
}
|
|
659
|
-
const Dt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Lt = (e) => e.startsWith("rgba"), Je = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,
|
|
659
|
+
const Dt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Lt = (e) => e.startsWith("rgba"), Je = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, ft = (e) => Math.round(e).toString(16).padStart(2, "0");
|
|
660
660
|
function ts(e, t, s) {
|
|
661
|
-
return `#${
|
|
661
|
+
return `#${ft(e)}${ft(t)}${ft(s)}`;
|
|
662
662
|
}
|
|
663
663
|
function Nt(e) {
|
|
664
|
-
const t =
|
|
664
|
+
const t = ut.get(e);
|
|
665
665
|
if (t) return t;
|
|
666
666
|
const s = e.match(Je);
|
|
667
667
|
if (!s)
|
|
668
668
|
throw new Error(`Invalid rgb color: ${e}`);
|
|
669
669
|
const n = parseInt(s[1], 10), i = parseInt(s[2], 10), r = parseInt(s[3], 10), a = s[4] !== void 0 ? [n, i, r, parseFloat(s[4])] : [n, i, r];
|
|
670
|
-
return
|
|
670
|
+
return ut.size < ee && ut.set(e, a), a;
|
|
671
671
|
}
|
|
672
672
|
const es = (e, t, s) => {
|
|
673
673
|
if (Dt(e) && Dt(t)) {
|
|
674
|
-
const [n, i, r] = $t(e), [a, o,
|
|
675
|
-
return ts(
|
|
674
|
+
const [n, i, r] = $t(e), [a, o, c] = $t(t), l = L(n, a, s), u = L(i, o, s), h = L(r, c, s);
|
|
675
|
+
return ts(l, u, h);
|
|
676
676
|
}
|
|
677
677
|
if ((Ot(e) || Lt(e)) && (Ot(t) || Lt(t))) {
|
|
678
678
|
const n = Nt(e), i = Nt(t), r = Math.round(L(n[0], i[0], s)), a = Math.round(L(n[1], i[1], s)), o = Math.round(L(n[2], i[2], s));
|
|
679
679
|
if (n.length === 4 || i.length === 4) {
|
|
680
|
-
const
|
|
680
|
+
const c = n[3] ?? 1, l = i[3] ?? 1, u = L(c, l, s);
|
|
681
681
|
return `rgba(${r}, ${a}, ${o}, ${u})`;
|
|
682
682
|
}
|
|
683
683
|
return `rgb(${r}, ${a}, ${o})`;
|
|
@@ -688,9 +688,9 @@ const es = (e, t, s) => {
|
|
|
688
688
|
for (let r = 0; r < n; r++)
|
|
689
689
|
i.push(L(e[r], t[r], s));
|
|
690
690
|
return i;
|
|
691
|
-
},
|
|
691
|
+
}, Ft = (e, t, s) => s < 1 ? e : t, ns = (e, t, s) => Ze(e, t, s);
|
|
692
692
|
function is(e) {
|
|
693
|
-
return typeof e == "number" ? L : Array.isArray(e) ? ss : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? es : Ke(e) ? ns :
|
|
693
|
+
return typeof e == "number" ? L : Array.isArray(e) ? ss : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? es : Ke(e) ? ns : Ft : Ft;
|
|
694
694
|
}
|
|
695
695
|
function rs(e) {
|
|
696
696
|
const t = [...e.keyframes].sort((s, n) => s.time - n.time);
|
|
@@ -699,18 +699,18 @@ function rs(e) {
|
|
|
699
699
|
keyframes: t
|
|
700
700
|
};
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function X(e) {
|
|
703
703
|
return e.targets && e.targets.length > 0 ? e.targets : [e.target];
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function W(e, t, s, n) {
|
|
706
706
|
const i = s ?? 0;
|
|
707
707
|
return !n || t <= 1 ? i : i + Ht(e, t, n);
|
|
708
708
|
}
|
|
709
|
-
class
|
|
709
|
+
class dt {
|
|
710
710
|
track;
|
|
711
711
|
targets;
|
|
712
712
|
constructor(t) {
|
|
713
|
-
this.track = t, this.targets =
|
|
713
|
+
this.track = t, this.targets = X(t);
|
|
714
714
|
}
|
|
715
715
|
/**
|
|
716
716
|
* Get the interpolated value at a specific time.
|
|
@@ -719,7 +719,7 @@ class ft {
|
|
|
719
719
|
* that need every target should use `getTargetValues`.
|
|
720
720
|
*/
|
|
721
721
|
getValueAtTime(t) {
|
|
722
|
-
return this.valueForOffset(t -
|
|
722
|
+
return this.valueForOffset(t - W(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
723
723
|
}
|
|
724
724
|
/**
|
|
725
725
|
* Every target's value at a specific time, in target order.
|
|
@@ -730,7 +730,7 @@ class ft {
|
|
|
730
730
|
getTargetValues(t) {
|
|
731
731
|
const s = this.targets.length, n = [];
|
|
732
732
|
for (let i = 0; i < s; i++) {
|
|
733
|
-
const r =
|
|
733
|
+
const r = W(i, s, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
|
|
734
734
|
a !== void 0 && n.push({ target: this.targets[i], value: a, start: r + this.track.keyframes[0].time });
|
|
735
735
|
}
|
|
736
736
|
return n;
|
|
@@ -743,7 +743,7 @@ class ft {
|
|
|
743
743
|
const { keyframes: t } = this.track;
|
|
744
744
|
if (t.length === 0)
|
|
745
745
|
return 0;
|
|
746
|
-
const s = t[t.length - 1].time, n = this.track.stagger ?
|
|
746
|
+
const s = t[t.length - 1].time, n = this.track.stagger ? Mt(this.targets.length, this.track.stagger) : 0;
|
|
747
747
|
return s + (this.track.delay ?? 0) + n + (this.track.endDelay ?? 0);
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
@@ -766,8 +766,8 @@ class ft {
|
|
|
766
766
|
return;
|
|
767
767
|
if (n.time === t)
|
|
768
768
|
return n.value;
|
|
769
|
-
const r = i.time - n.time, a = (t - n.time) / r,
|
|
770
|
-
return is(n.value)(n.value, i.value,
|
|
769
|
+
const r = i.time - n.time, a = (t - n.time) / r, c = Ce(i.easing)(a);
|
|
770
|
+
return is(n.value)(n.value, i.value, c);
|
|
771
771
|
}
|
|
772
772
|
/**
|
|
773
773
|
* Find the keyframes surrounding a given time.
|
|
@@ -785,22 +785,22 @@ class as {
|
|
|
785
785
|
targets;
|
|
786
786
|
sampler;
|
|
787
787
|
constructor(t) {
|
|
788
|
-
this.track = t, this.targets =
|
|
788
|
+
this.track = t, this.targets = X(t), this.sampler = new ue(t.spring);
|
|
789
789
|
}
|
|
790
790
|
getValueAtTime(t) {
|
|
791
|
-
return this.sampler.valueAt(t -
|
|
791
|
+
return this.sampler.valueAt(t - W(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
792
792
|
}
|
|
793
793
|
getTargetValues(t) {
|
|
794
794
|
const s = this.targets.length, n = [];
|
|
795
795
|
for (let i = 0; i < s; i++) {
|
|
796
|
-
const r =
|
|
796
|
+
const r = W(i, s, this.track.delay, this.track.stagger);
|
|
797
797
|
n.push({ target: this.targets[i], value: this.sampler.valueAt(t - r), start: r });
|
|
798
798
|
}
|
|
799
799
|
return n;
|
|
800
800
|
}
|
|
801
801
|
/** Settle time plus delay and the widest stagger offset. */
|
|
802
802
|
getDuration() {
|
|
803
|
-
const t = this.track.stagger ?
|
|
803
|
+
const t = this.track.stagger ? Mt(this.targets.length, this.track.stagger) : 0;
|
|
804
804
|
return this.sampler.settleTime() + (this.track.delay ?? 0) + t;
|
|
805
805
|
}
|
|
806
806
|
getTrack() {
|
|
@@ -812,22 +812,22 @@ class os {
|
|
|
812
812
|
targets;
|
|
813
813
|
duration;
|
|
814
814
|
constructor(t) {
|
|
815
|
-
this.track = t, this.targets =
|
|
815
|
+
this.track = t, this.targets = X(t), this.duration = Qt(t.inertia);
|
|
816
816
|
}
|
|
817
817
|
getValueAtTime(t) {
|
|
818
|
-
return xt(this.track.inertia, t -
|
|
818
|
+
return xt(this.track.inertia, t - W(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
819
819
|
}
|
|
820
820
|
getTargetValues(t) {
|
|
821
821
|
const s = this.targets.length, n = [];
|
|
822
822
|
for (let i = 0; i < s; i++) {
|
|
823
|
-
const r =
|
|
823
|
+
const r = W(i, s, this.track.delay, this.track.stagger);
|
|
824
824
|
n.push({ target: this.targets[i], value: xt(this.track.inertia, t - r), start: r });
|
|
825
825
|
}
|
|
826
826
|
return n;
|
|
827
827
|
}
|
|
828
828
|
/** Settle time plus delay and the widest stagger offset. */
|
|
829
829
|
getDuration() {
|
|
830
|
-
const t = this.track.stagger ?
|
|
830
|
+
const t = this.track.stagger ? Mt(this.targets.length, this.track.stagger) : 0;
|
|
831
831
|
return this.duration + (this.track.delay ?? 0) + t;
|
|
832
832
|
}
|
|
833
833
|
getTrack() {
|
|
@@ -835,24 +835,24 @@ class os {
|
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
837
|
function cs(e, t) {
|
|
838
|
-
const s = { ...
|
|
838
|
+
const s = { ...Xe(e.pathData, t) };
|
|
839
839
|
if (e.matrix) {
|
|
840
|
-
const [n, i, r, a, o,
|
|
841
|
-
s.x = n *
|
|
840
|
+
const [n, i, r, a, o, c] = e.matrix, { x: l, y: u } = s;
|
|
841
|
+
s.x = n * l + r * u + o, s.y = i * l + a * u + c;
|
|
842
842
|
const h = s.angle * Math.PI / 180, f = Math.cos(h), d = Math.sin(h);
|
|
843
843
|
s.angle = Math.atan2(i * f + a * d, n * f + r * d) * 180 / Math.PI;
|
|
844
844
|
}
|
|
845
845
|
return e.autoRotate && e.rotateOffset && (s.angle += e.rotateOffset), s;
|
|
846
846
|
}
|
|
847
|
-
const
|
|
847
|
+
const pt = {
|
|
848
848
|
upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
849
849
|
lowerCase: "abcdefghijklmnopqrstuvwxyz",
|
|
850
850
|
upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
851
851
|
numbers: "0123456789"
|
|
852
852
|
}, ls = 20;
|
|
853
853
|
function hs(e) {
|
|
854
|
-
const t =
|
|
855
|
-
return s.length > 0 ? s : Array.from(
|
|
854
|
+
const t = pt[e ?? "upperCase"] ?? e ?? pt.upperCase, s = Array.from(t);
|
|
855
|
+
return s.length > 0 ? s : Array.from(pt.upperCase);
|
|
856
856
|
}
|
|
857
857
|
function us(e, t, s) {
|
|
858
858
|
let n = (e | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(s + 1, 2246822507);
|
|
@@ -862,25 +862,24 @@ function fs(e, t, s = 0) {
|
|
|
862
862
|
const n = e.from ?? "", i = e.to, r = Math.max(0, Math.min(1, t));
|
|
863
863
|
if (r <= 0) return n;
|
|
864
864
|
if (r >= 1) return i;
|
|
865
|
-
const a = Array.from(n), o = Array.from(i),
|
|
865
|
+
const a = Array.from(n), o = Array.from(i), c = e.rightToLeft ?? !1;
|
|
866
866
|
if (e.mode === "type") {
|
|
867
|
-
const
|
|
868
|
-
return
|
|
867
|
+
const y = Math.round(r * Math.max(a.length, o.length));
|
|
868
|
+
return c ? a.slice(0, Math.max(0, a.length - y)).join("") + o.slice(Math.max(0, o.length - y)).join("") : o.slice(0, y).join("") + a.slice(y).join("");
|
|
869
869
|
}
|
|
870
|
-
const
|
|
871
|
-
let
|
|
872
|
-
for (let
|
|
873
|
-
const T =
|
|
874
|
-
T &&
|
|
875
|
-
` ?
|
|
870
|
+
const l = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - l) / (1 - l)), h = Math.floor(u * o.length), f = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), d = hs(e.chars), b = e.refreshRate ?? ls, p = b > 0 ? Math.floor(s * b / 1e3) : 0, m = e.seed ?? 1;
|
|
871
|
+
let k = "";
|
|
872
|
+
for (let y = 0; y < f; y++) {
|
|
873
|
+
const T = c ? y >= f - h : y < h, w = c ? o[o.length - (f - y)] : o[y];
|
|
874
|
+
T && w !== void 0 || w === " " || w === `
|
|
875
|
+
` ? k += w : k += d[us(m, y, p) % d.length];
|
|
876
876
|
}
|
|
877
|
-
return
|
|
877
|
+
return k;
|
|
878
878
|
}
|
|
879
879
|
class ds {
|
|
880
880
|
id;
|
|
881
881
|
name;
|
|
882
|
-
|
|
883
|
-
captions;
|
|
882
|
+
_captions;
|
|
884
883
|
_tracks = [];
|
|
885
884
|
_trackPlayers = /* @__PURE__ */ new Map();
|
|
886
885
|
_motionPathTracks = /* @__PURE__ */ new Map();
|
|
@@ -902,7 +901,7 @@ class ds {
|
|
|
902
901
|
onUpdate = null;
|
|
903
902
|
onComplete = null;
|
|
904
903
|
constructor(t) {
|
|
905
|
-
if (this.id = t.id, this.name = t.name, this.
|
|
904
|
+
if (this.id = t.id, this.name = t.name, this._captions = t.captions, this._config = t.config ?? {}, this._explicitDuration = t.config?.duration, t.tracks)
|
|
906
905
|
for (const s of t.tracks)
|
|
907
906
|
this.addTrack(s);
|
|
908
907
|
}
|
|
@@ -1002,16 +1001,16 @@ class ds {
|
|
|
1002
1001
|
const r = 1e3;
|
|
1003
1002
|
for (let o = 0; o < r && i > 0 && this._playbackState === "playing"; o++)
|
|
1004
1003
|
if (this._direction === "forward") {
|
|
1005
|
-
const
|
|
1006
|
-
if (i >=
|
|
1007
|
-
if (i -=
|
|
1004
|
+
const c = s - this._currentTime;
|
|
1005
|
+
if (i >= c) {
|
|
1006
|
+
if (i -= c, this._currentTime = s, !this._handleEndReached())
|
|
1008
1007
|
break;
|
|
1009
1008
|
} else
|
|
1010
1009
|
this._currentTime += i, i = 0;
|
|
1011
1010
|
} else {
|
|
1012
|
-
const
|
|
1013
|
-
if (i >=
|
|
1014
|
-
if (i -=
|
|
1011
|
+
const c = this._currentTime;
|
|
1012
|
+
if (i >= c) {
|
|
1013
|
+
if (i -= c, this._currentTime = 0, !this._handleStartReached())
|
|
1015
1014
|
break;
|
|
1016
1015
|
} else
|
|
1017
1016
|
this._currentTime -= i, i = 0;
|
|
@@ -1029,8 +1028,8 @@ class ds {
|
|
|
1029
1028
|
else
|
|
1030
1029
|
for (const [n, i] of this._trackPlayers) {
|
|
1031
1030
|
const r = i.getTrack().property;
|
|
1032
|
-
for (const { target: a, value: o, start:
|
|
1033
|
-
this._write(s, n, a, r, o, t -
|
|
1031
|
+
for (const { target: a, value: o, start: c } of i.getTargetValues(t))
|
|
1032
|
+
this._write(s, n, a, r, o, t - c);
|
|
1034
1033
|
}
|
|
1035
1034
|
return {
|
|
1036
1035
|
values: s,
|
|
@@ -1057,13 +1056,13 @@ class ds {
|
|
|
1057
1056
|
const n = /* @__PURE__ */ new Map();
|
|
1058
1057
|
for (const [i, r] of this._trackPlayers) {
|
|
1059
1058
|
const a = r.getTrack().property;
|
|
1060
|
-
for (const { target: o, value:
|
|
1061
|
-
const u = `${o}\0${a}`, h =
|
|
1062
|
-
(!f || (h !== f.started ? h : h ?
|
|
1059
|
+
for (const { target: o, value: c, start: l } of r.getTargetValues(t)) {
|
|
1060
|
+
const u = `${o}\0${a}`, h = l <= t, f = n.get(u);
|
|
1061
|
+
(!f || (h !== f.started ? h : h ? l >= f.start : l <= f.start)) && n.set(u, { trackId: i, target: o, property: a, value: c, start: l, started: h });
|
|
1063
1062
|
}
|
|
1064
1063
|
}
|
|
1065
|
-
for (const { trackId: i, target: r, property: a, value: o, start:
|
|
1066
|
-
this._write(s, i, r, a, o, t -
|
|
1064
|
+
for (const { trackId: i, target: r, property: a, value: o, start: c } of n.values())
|
|
1065
|
+
this._write(s, i, r, a, o, t - c);
|
|
1067
1066
|
}
|
|
1068
1067
|
/**
|
|
1069
1068
|
* Write one track's value for a target, expanding the progress of motion paths
|
|
@@ -1074,15 +1073,15 @@ class ds {
|
|
|
1074
1073
|
if (r === void 0) return;
|
|
1075
1074
|
let o = t.get(n);
|
|
1076
1075
|
o || (o = /* @__PURE__ */ new Map(), t.set(n, o));
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
o.set("text", fs(
|
|
1076
|
+
const c = this._textTracks.get(s);
|
|
1077
|
+
if (c && typeof r == "number") {
|
|
1078
|
+
o.set("text", fs(c.textConfig, r, Math.max(0, a)));
|
|
1080
1079
|
return;
|
|
1081
1080
|
}
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
const u = cs(
|
|
1085
|
-
o.set("motionPathX", u.x), o.set("motionPathY", u.y),
|
|
1081
|
+
const l = this._motionPathTracks.get(s);
|
|
1082
|
+
if (l && typeof r == "number") {
|
|
1083
|
+
const u = cs(l.motionPathConfig, r);
|
|
1084
|
+
o.set("motionPathX", u.x), o.set("motionPathY", u.y), l.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
|
|
1086
1085
|
} else
|
|
1087
1086
|
o.set(i, r);
|
|
1088
1087
|
}
|
|
@@ -1093,7 +1092,7 @@ class ds {
|
|
|
1093
1092
|
const t = /* @__PURE__ */ new Set();
|
|
1094
1093
|
this._sharedWrites = !1;
|
|
1095
1094
|
t: for (const s of this._tracks)
|
|
1096
|
-
for (const n of
|
|
1095
|
+
for (const n of X(s)) {
|
|
1097
1096
|
const i = `${n}\0${s.property}`;
|
|
1098
1097
|
if (t.has(i)) {
|
|
1099
1098
|
this._sharedWrites = !0;
|
|
@@ -1108,16 +1107,16 @@ class ds {
|
|
|
1108
1107
|
* Add a track to the timeline.
|
|
1109
1108
|
*/
|
|
1110
1109
|
addTrack(t) {
|
|
1111
|
-
if (this._tracks.push(t), this._sharedWrites = null,
|
|
1110
|
+
if (this._tracks.push(t), this._sharedWrites = null, mt(t)) {
|
|
1112
1111
|
this._trackPlayers.set(t.id, new os(t));
|
|
1113
1112
|
return;
|
|
1114
1113
|
}
|
|
1115
|
-
if (
|
|
1114
|
+
if (gt(t)) {
|
|
1116
1115
|
this._trackPlayers.set(t.id, new as(t)), this._springTracks.set(t.id, t);
|
|
1117
1116
|
return;
|
|
1118
1117
|
}
|
|
1119
1118
|
if (Ut(t))
|
|
1120
|
-
this._trackPlayers.set(t.id, new
|
|
1119
|
+
this._trackPlayers.set(t.id, new dt(t)), this._textTracks.set(t.id, t);
|
|
1121
1120
|
else if (ce(t)) {
|
|
1122
1121
|
const s = {
|
|
1123
1122
|
id: t.id,
|
|
@@ -1129,9 +1128,9 @@ class ds {
|
|
|
1129
1128
|
targets: t.targets,
|
|
1130
1129
|
stagger: t.stagger
|
|
1131
1130
|
};
|
|
1132
|
-
this._trackPlayers.set(t.id, new
|
|
1131
|
+
this._trackPlayers.set(t.id, new dt(s)), this._motionPathTracks.set(t.id, t);
|
|
1133
1132
|
} else
|
|
1134
|
-
this._trackPlayers.set(t.id, new
|
|
1133
|
+
this._trackPlayers.set(t.id, new dt(t));
|
|
1135
1134
|
}
|
|
1136
1135
|
/**
|
|
1137
1136
|
* Replace a track with a new version, keeping its place in the track order
|
|
@@ -1182,7 +1181,7 @@ class ds {
|
|
|
1182
1181
|
const s = this._trackPlayers.get(t);
|
|
1183
1182
|
if (!s) return;
|
|
1184
1183
|
const n = s.getTrack(), i = n.delay ?? 0;
|
|
1185
|
-
if (
|
|
1184
|
+
if (gt(n) || mt(n))
|
|
1186
1185
|
return { from: i, to: s.getDuration() };
|
|
1187
1186
|
const r = n.keyframes;
|
|
1188
1187
|
if (!(!r || r.length === 0))
|
|
@@ -1204,11 +1203,11 @@ class ds {
|
|
|
1204
1203
|
for (let r = 0; r < s; r++) {
|
|
1205
1204
|
const a = this._tracks[r];
|
|
1206
1205
|
if (a.property !== n.property) continue;
|
|
1207
|
-
const o =
|
|
1206
|
+
const o = X(a).filter((h) => X(n).includes(h));
|
|
1208
1207
|
if (o.length === 0) continue;
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
1211
|
-
const u = i.from >=
|
|
1208
|
+
const c = this.getTrackSpan(a.id);
|
|
1209
|
+
if (!c || !(c.from <= i.to && i.from <= c.to)) continue;
|
|
1210
|
+
const u = i.from >= c.from;
|
|
1212
1211
|
for (const h of o)
|
|
1213
1212
|
t.push({
|
|
1214
1213
|
target: h,
|
|
@@ -1221,7 +1220,7 @@ class ds {
|
|
|
1221
1220
|
return t;
|
|
1222
1221
|
}
|
|
1223
1222
|
_matches(t, s) {
|
|
1224
|
-
if (s.id !== void 0 && t.id !== s.id || s.property !== void 0 && t.property !== s.property || s.target !== void 0 && !
|
|
1223
|
+
if (s.id !== void 0 && t.id !== s.id || s.property !== void 0 && t.property !== s.property || s.target !== void 0 && !X(t).includes(s.target)) return !1;
|
|
1225
1224
|
if (s.timeRange) {
|
|
1226
1225
|
const n = this.getTrackSpan(t.id);
|
|
1227
1226
|
if (!n || n.to < s.timeRange.from || n.from > s.timeRange.to) return !1;
|
|
@@ -1233,7 +1232,7 @@ class ds {
|
|
|
1233
1232
|
*/
|
|
1234
1233
|
toDefinition() {
|
|
1235
1234
|
return {
|
|
1236
|
-
formatVersion:
|
|
1235
|
+
formatVersion: K,
|
|
1237
1236
|
id: this.id,
|
|
1238
1237
|
name: this.name,
|
|
1239
1238
|
config: { ...this._config },
|
|
@@ -1249,6 +1248,21 @@ class ds {
|
|
|
1249
1248
|
get markers() {
|
|
1250
1249
|
return [...this._config.markers ?? []].sort((t, s) => t.time - s.time);
|
|
1251
1250
|
}
|
|
1251
|
+
/** Replace the markers (kept in time order); an empty list removes them. */
|
|
1252
|
+
setMarkers(t) {
|
|
1253
|
+
const s = t && t.length > 0 ? [...t].sort((i, r) => i.time - r.time).map((i) => ({ ...i })) : void 0, n = { ...this._config };
|
|
1254
|
+
s ? n.markers = s : delete n.markers, this._config = n;
|
|
1255
|
+
}
|
|
1256
|
+
/** Caption text per language, per marker id */
|
|
1257
|
+
get captions() {
|
|
1258
|
+
return this._captions;
|
|
1259
|
+
}
|
|
1260
|
+
/** Replace the captions; languages with no captions are dropped. */
|
|
1261
|
+
setCaptions(t) {
|
|
1262
|
+
const s = {};
|
|
1263
|
+
for (const [n, i] of Object.entries(t ?? {})) s[n] = { ...i };
|
|
1264
|
+
this._captions = Object.keys(s).length > 0 ? s : void 0;
|
|
1265
|
+
}
|
|
1252
1266
|
/** Start the between-iterations pause, if the timeline configures one. */
|
|
1253
1267
|
_armRepeatDelay() {
|
|
1254
1268
|
this._repeatDelayRemaining = this._config.repeatDelay ?? 0;
|
|
@@ -1278,26 +1292,26 @@ class ds {
|
|
|
1278
1292
|
}
|
|
1279
1293
|
const ps = 100;
|
|
1280
1294
|
function ms(e, t, s, n) {
|
|
1281
|
-
const i = [], r = [], { duration: a, alternate: o } = n,
|
|
1282
|
-
r.push([d,
|
|
1283
|
-
const
|
|
1284
|
-
e.forEach((
|
|
1285
|
-
(p === "forward" ? (m ?
|
|
1286
|
-
}),
|
|
1287
|
-
for (const
|
|
1295
|
+
const i = [], r = [], { duration: a, alternate: o } = n, c = (d, b, p, m) => {
|
|
1296
|
+
r.push([d, b]);
|
|
1297
|
+
const k = [];
|
|
1298
|
+
e.forEach((y, T) => {
|
|
1299
|
+
(p === "forward" ? (m ? y >= d : y > d) && y <= b : (m ? y <= d : y < d) && y >= b) && k.push(T);
|
|
1300
|
+
}), k.sort((y, T) => (p === "forward" ? e[y] - e[T] : e[T] - e[y]) || y - T);
|
|
1301
|
+
for (const y of k) i.push({ kind: "event", index: y, direction: p });
|
|
1288
1302
|
};
|
|
1289
|
-
let
|
|
1303
|
+
let l = t.time, u = t.direction, h = t.fresh === !0;
|
|
1290
1304
|
const f = Math.min(ps, Math.max(0, s.iteration - t.iteration));
|
|
1291
1305
|
for (let d = 0; d < f; d++) {
|
|
1292
|
-
const
|
|
1293
|
-
l
|
|
1306
|
+
const b = u === "forward" ? a : 0;
|
|
1307
|
+
c(l, b, u, h), i.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", l = b, h = !1) : (l = u === "forward" ? 0 : a, h = !0);
|
|
1294
1308
|
}
|
|
1295
|
-
return f > 0 && n.holding && !o ? { crossings: i, passes: r } : (l
|
|
1309
|
+
return f > 0 && n.holding && !o ? { crossings: i, passes: r } : (c(l, s.time, u, h), { crossings: i, passes: r });
|
|
1296
1310
|
}
|
|
1297
1311
|
function gs(e) {
|
|
1298
1312
|
return { ...e, ...Array.isArray(e.end) && { end: [...e.end] } };
|
|
1299
1313
|
}
|
|
1300
|
-
function
|
|
1314
|
+
function Q(e) {
|
|
1301
1315
|
const t = e.endDelay;
|
|
1302
1316
|
return {
|
|
1303
1317
|
...e.delay !== void 0 && { delay: e.delay },
|
|
@@ -1307,7 +1321,7 @@ function G(e) {
|
|
|
1307
1321
|
};
|
|
1308
1322
|
}
|
|
1309
1323
|
function ys(e) {
|
|
1310
|
-
if (
|
|
1324
|
+
if (mt(e)) {
|
|
1311
1325
|
const t = e;
|
|
1312
1326
|
return {
|
|
1313
1327
|
id: t.id,
|
|
@@ -1315,10 +1329,10 @@ function ys(e) {
|
|
|
1315
1329
|
property: t.property,
|
|
1316
1330
|
kind: "inertia",
|
|
1317
1331
|
inertia: gs(t.inertia),
|
|
1318
|
-
...
|
|
1332
|
+
...Q(t)
|
|
1319
1333
|
};
|
|
1320
1334
|
}
|
|
1321
|
-
if (
|
|
1335
|
+
if (gt(e)) {
|
|
1322
1336
|
const t = e;
|
|
1323
1337
|
return {
|
|
1324
1338
|
id: t.id,
|
|
@@ -1326,7 +1340,7 @@ function ys(e) {
|
|
|
1326
1340
|
property: t.property,
|
|
1327
1341
|
kind: "spring",
|
|
1328
1342
|
spring: { ...t.spring },
|
|
1329
|
-
...
|
|
1343
|
+
...Q(t)
|
|
1330
1344
|
};
|
|
1331
1345
|
}
|
|
1332
1346
|
if (Ut(e)) {
|
|
@@ -1337,7 +1351,7 @@ function ys(e) {
|
|
|
1337
1351
|
property: "text",
|
|
1338
1352
|
textConfig: { ...t.textConfig },
|
|
1339
1353
|
keyframes: [...t.keyframes].sort((s, n) => s.time - n.time),
|
|
1340
|
-
...
|
|
1354
|
+
...Q(t)
|
|
1341
1355
|
};
|
|
1342
1356
|
}
|
|
1343
1357
|
if (e.property === "motionPath" && "motionPathConfig" in e) {
|
|
@@ -1348,7 +1362,7 @@ function ys(e) {
|
|
|
1348
1362
|
property: "motionPath",
|
|
1349
1363
|
motionPathConfig: { ...t.motionPathConfig },
|
|
1350
1364
|
keyframes: s,
|
|
1351
|
-
...
|
|
1365
|
+
...Q(t)
|
|
1352
1366
|
};
|
|
1353
1367
|
}
|
|
1354
1368
|
return rs({
|
|
@@ -1356,14 +1370,14 @@ function ys(e) {
|
|
|
1356
1370
|
target: e.target,
|
|
1357
1371
|
property: e.property,
|
|
1358
1372
|
keyframes: e.keyframes,
|
|
1359
|
-
...
|
|
1373
|
+
...Q(e)
|
|
1360
1374
|
});
|
|
1361
1375
|
}
|
|
1362
|
-
function
|
|
1376
|
+
function rt(e) {
|
|
1363
1377
|
const t = e.formatVersion ?? 1;
|
|
1364
|
-
if (t >
|
|
1378
|
+
if (t > K)
|
|
1365
1379
|
throw new Error(
|
|
1366
|
-
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${
|
|
1380
|
+
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${K}. Update tinyfly to play it.`
|
|
1367
1381
|
);
|
|
1368
1382
|
return new ds({
|
|
1369
1383
|
id: e.id,
|
|
@@ -1405,7 +1419,7 @@ function ws(e) {
|
|
|
1405
1419
|
const t = e.style;
|
|
1406
1420
|
!t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
|
|
1407
1421
|
}
|
|
1408
|
-
const
|
|
1422
|
+
const Xt = /* @__PURE__ */ new Set([
|
|
1409
1423
|
"width",
|
|
1410
1424
|
"height",
|
|
1411
1425
|
"top",
|
|
@@ -1465,7 +1479,7 @@ const Ft = /* @__PURE__ */ new Set([
|
|
|
1465
1479
|
fillOpacity: "fillOpacity",
|
|
1466
1480
|
strokeOpacity: "strokeOpacity"
|
|
1467
1481
|
}, Ps = "http://www.w3.org/2000/svg";
|
|
1468
|
-
class
|
|
1482
|
+
class kt {
|
|
1469
1483
|
targets = /* @__PURE__ */ new Map();
|
|
1470
1484
|
/**
|
|
1471
1485
|
* Register an HTML element as an animation target.
|
|
@@ -1506,12 +1520,12 @@ class bt {
|
|
|
1506
1520
|
applyProperties(t, s) {
|
|
1507
1521
|
const n = [];
|
|
1508
1522
|
let i = null, r = null, a = null;
|
|
1509
|
-
const o = s.has("motionPathX"),
|
|
1523
|
+
const o = s.has("motionPathX"), c = s.has("motionPathY"), l = s.has("motionPathRotate");
|
|
1510
1524
|
for (const [f, d] of s)
|
|
1511
|
-
if (!(f === "x" && o) && !(f === "y" &&
|
|
1525
|
+
if (!(f === "x" && o) && !(f === "y" && c) && !((f === "rotate" || f === "rotateZ") && l)) {
|
|
1512
1526
|
if (xs.has(f)) {
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1527
|
+
const b = this.buildTransformPart(f, d);
|
|
1528
|
+
b && n.push(b);
|
|
1515
1529
|
} else if (_s.has(f))
|
|
1516
1530
|
typeof d == "number" && ((i ??= {})[f] = d);
|
|
1517
1531
|
else if (vs.has(f))
|
|
@@ -1522,8 +1536,8 @@ class bt {
|
|
|
1522
1536
|
if (f !== "shine") if (f === "text" && typeof d == "string")
|
|
1523
1537
|
Ss(t, d);
|
|
1524
1538
|
else if (f === "d" && typeof d == "string") {
|
|
1525
|
-
const
|
|
1526
|
-
(
|
|
1539
|
+
const b = t;
|
|
1540
|
+
(b.tagName?.toLowerCase() === "path" ? b : b.querySelector?.("path"))?.setAttribute?.("d", d);
|
|
1527
1541
|
} else
|
|
1528
1542
|
this.applyStyleProperty(t, f, d);
|
|
1529
1543
|
}
|
|
@@ -1536,8 +1550,8 @@ class bt {
|
|
|
1536
1550
|
t.style.transformOrigin = `${f}% ${d}%`;
|
|
1537
1551
|
}
|
|
1538
1552
|
if (r) {
|
|
1539
|
-
const f = r.clipTop ?? 0, d = r.clipRight ?? 0,
|
|
1540
|
-
t.style.clipPath = `inset(${f}% ${d}% ${
|
|
1553
|
+
const f = r.clipTop ?? 0, d = r.clipRight ?? 0, b = r.clipBottom ?? 0, p = r.clipLeft ?? 0;
|
|
1554
|
+
t.style.clipPath = `inset(${f}% ${d}% ${b}% ${p}%)`;
|
|
1541
1555
|
}
|
|
1542
1556
|
if (a) {
|
|
1543
1557
|
const f = Ts(a);
|
|
@@ -1606,7 +1620,7 @@ class bt {
|
|
|
1606
1620
|
return;
|
|
1607
1621
|
} else s === "fill" && t.dataset?.elementType === "text" ? i = "color" : i = As[s] ?? s;
|
|
1608
1622
|
let a;
|
|
1609
|
-
typeof n == "number" ?
|
|
1623
|
+
typeof n == "number" ? Xt.has(s) || Xt.has(i) ? a = `${n}px` : a = String(n) : Array.isArray(n) ? a = n.join(", ") : a = n, t.style[i] = a;
|
|
1610
1624
|
}
|
|
1611
1625
|
}
|
|
1612
1626
|
class qt {
|
|
@@ -1656,7 +1670,7 @@ function Is(e, t, s, n, i) {
|
|
|
1656
1670
|
}
|
|
1657
1671
|
e.update(r, n);
|
|
1658
1672
|
}
|
|
1659
|
-
class
|
|
1673
|
+
class St {
|
|
1660
1674
|
container;
|
|
1661
1675
|
timeline = null;
|
|
1662
1676
|
adapter;
|
|
@@ -1692,7 +1706,7 @@ class Tt {
|
|
|
1692
1706
|
this.container = n;
|
|
1693
1707
|
} else
|
|
1694
1708
|
this.container = t;
|
|
1695
|
-
this.options = s, this.adapter = new
|
|
1709
|
+
this.options = s, this.adapter = new kt();
|
|
1696
1710
|
}
|
|
1697
1711
|
/**
|
|
1698
1712
|
* Load animation from a URL or JSON object.
|
|
@@ -1706,7 +1720,7 @@ class Tt {
|
|
|
1706
1720
|
s = await n.json();
|
|
1707
1721
|
} else
|
|
1708
1722
|
s = t;
|
|
1709
|
-
this.options.speed !== void 0 && (s.config = { ...s.config, speed: this.options.speed }), this.options.loop !== void 0 && (s.config = { ...s.config, loop: this.options.loop }), this.options.alternate !== void 0 && (s.config = { ...s.config, alternate: this.options.alternate }), this.timeline =
|
|
1723
|
+
this.options.speed !== void 0 && (s.config = { ...s.config, speed: this.options.speed }), this.options.loop !== void 0 && (s.config = { ...s.config, loop: this.options.loop }), this.options.alternate !== void 0 && (s.config = { ...s.config, alternate: this.options.alternate }), this.timeline = rt(s), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia(), this.showInitialFrame(), this.watchReducedMotion(), this.watchVisibility(), this.options.autoplay && !this.reducedMotion && (this.options.playWhenVisible && !this.onScreen ? this.autoplayWhenSeen = !0 : this.play());
|
|
1710
1724
|
}
|
|
1711
1725
|
// --- teaching: frames, markers, reduced motion, visibility -----------------
|
|
1712
1726
|
/**
|
|
@@ -1872,11 +1886,11 @@ class Tt {
|
|
|
1872
1886
|
if (!i) return;
|
|
1873
1887
|
const r = s.get(i);
|
|
1874
1888
|
if (!r || !r.timeline.tracks?.length) return;
|
|
1875
|
-
const a = new
|
|
1889
|
+
const a = new kt();
|
|
1876
1890
|
n.querySelectorAll("[data-tinyfly]").forEach((o) => {
|
|
1877
|
-
const
|
|
1878
|
-
|
|
1879
|
-
}), this.symbolInstances.push({ adapter: a, timeline:
|
|
1891
|
+
const c = o.getAttribute("data-tinyfly");
|
|
1892
|
+
c && a.registerTarget(c, o);
|
|
1893
|
+
}), this.symbolInstances.push({ adapter: a, timeline: rt(r.timeline) });
|
|
1880
1894
|
});
|
|
1881
1895
|
}
|
|
1882
1896
|
/**
|
|
@@ -2013,12 +2027,12 @@ class Tt {
|
|
|
2013
2027
|
}
|
|
2014
2028
|
}
|
|
2015
2029
|
}
|
|
2016
|
-
async function
|
|
2017
|
-
const n = new
|
|
2030
|
+
async function Us(e, t, s = {}) {
|
|
2031
|
+
const n = new St(e, { ...s, autoplay: !0 });
|
|
2018
2032
|
return await n.load(t), n;
|
|
2019
2033
|
}
|
|
2020
|
-
function
|
|
2021
|
-
return new
|
|
2034
|
+
function js(e, t = {}) {
|
|
2035
|
+
return new St(e, t);
|
|
2022
2036
|
}
|
|
2023
2037
|
const Cs = {
|
|
2024
2038
|
play: "Play",
|
|
@@ -2030,7 +2044,8 @@ const Cs = {
|
|
|
2030
2044
|
speed: "Speed",
|
|
2031
2045
|
reveal: "Reveal",
|
|
2032
2046
|
step: "Step",
|
|
2033
|
-
of: "of"
|
|
2047
|
+
of: "of",
|
|
2048
|
+
stepFormat: "{index} / {total}"
|
|
2034
2049
|
}, Vt = "tinyfly-controls-style", Rs = `
|
|
2035
2050
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
2036
2051
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
@@ -2047,6 +2062,9 @@ const Cs = {
|
|
|
2047
2062
|
.tf-ctl-caption { margin: 6px 2px 0; min-height: 1.4em; }
|
|
2048
2063
|
.tf-ctl-question { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 2px 0; font-weight: 600; }
|
|
2049
2064
|
.tf-ctl-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
2065
|
+
/* The hidden attribute only hides through the browser's default stylesheet; any rule
|
|
2066
|
+
above that sets display would override it, so enforce it for everything here. */
|
|
2067
|
+
.tf-ctl [hidden] { display: none !important; }
|
|
2050
2068
|
`;
|
|
2051
2069
|
function Es(e) {
|
|
2052
2070
|
if (e.getElementById(Vt)) return;
|
|
@@ -2056,64 +2074,64 @@ function Es(e) {
|
|
|
2056
2074
|
function $s(e, t, s = {}) {
|
|
2057
2075
|
const n = t.ownerDocument;
|
|
2058
2076
|
Es(n);
|
|
2059
|
-
const i = { ...Cs, ...s.labels }, r = s.speeds ?? [0.5, 1, 2], a = () => e.markers.length > 0, o = n.createElement("div");
|
|
2060
|
-
|
|
2077
|
+
const i = { ...Cs, ...s.labels }, r = s.speeds ?? [0.5, 1, 2], a = () => e.markers.length > 0, o = () => e.markers.some((M) => M.label !== void 0 || e.caption(M.id) !== void 0), c = n.createElement("div");
|
|
2078
|
+
c.className = "tf-ctl";
|
|
2061
2079
|
const l = n.createElement("div");
|
|
2062
2080
|
l.className = "tf-ctl-bar", l.setAttribute("role", "group");
|
|
2063
|
-
const
|
|
2064
|
-
const
|
|
2065
|
-
return
|
|
2066
|
-
},
|
|
2081
|
+
const u = (M, v, O, E = "") => {
|
|
2082
|
+
const $ = n.createElement("button");
|
|
2083
|
+
return $.type = "button", $.className = `tf-ctl-btn ${E}`.trim(), $.setAttribute("aria-label", M), $.title = M, $.textContent = v, $.addEventListener("click", O), $;
|
|
2084
|
+
}, h = u(i.restart, "⟲", () => {
|
|
2067
2085
|
e.pause(), e.seek(0);
|
|
2068
|
-
}),
|
|
2086
|
+
}), f = u(i.prev, "◀", () => e.prev()), d = u(i.play, "▶", () => e.isPlaying ? e.pause() : p(), "tf-ctl-primary"), b = u(i.next, "▶|", () => e.next()), p = () => {
|
|
2069
2087
|
e.currentTime >= e.duration - 0.5 && e.seek(0), e.play();
|
|
2070
|
-
},
|
|
2071
|
-
|
|
2072
|
-
e.pause(), e.seek(Number(
|
|
2088
|
+
}, m = n.createElement("input");
|
|
2089
|
+
m.type = "range", m.className = "tf-ctl-scrub", m.min = "0", m.max = "1000", m.step = "1", m.setAttribute("aria-label", i.scrub), m.addEventListener("input", () => {
|
|
2090
|
+
e.pause(), e.seek(Number(m.value) / 1e3 * e.duration);
|
|
2073
2091
|
});
|
|
2074
|
-
const
|
|
2075
|
-
|
|
2092
|
+
const k = n.createElement("span");
|
|
2093
|
+
k.className = "tf-ctl-step";
|
|
2076
2094
|
const y = n.createElement("select");
|
|
2077
2095
|
y.className = "tf-ctl-speed", y.setAttribute("aria-label", i.speed);
|
|
2078
2096
|
for (const M of r) {
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
}
|
|
2082
|
-
y.addEventListener("change", () => e.setSpeed(Number(y.value))), l.append(
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
const
|
|
2090
|
-
|
|
2091
|
-
const
|
|
2097
|
+
const v = n.createElement("option");
|
|
2098
|
+
v.value = String(M), v.textContent = `${M}×`, M === 1 && (v.selected = !0), y.appendChild(v);
|
|
2099
|
+
}
|
|
2100
|
+
y.addEventListener("change", () => e.setSpeed(Number(y.value))), l.append(h, f, d, b, m, k), r.length > 0 && l.append(y), c.append(l);
|
|
2101
|
+
const T = n.createElement("p");
|
|
2102
|
+
T.className = "tf-ctl-caption", T.setAttribute("aria-live", "polite"), s.captions !== !1 && c.append(T);
|
|
2103
|
+
const w = n.createElement("div");
|
|
2104
|
+
w.className = "tf-ctl-question", w.hidden = !0;
|
|
2105
|
+
const g = n.createElement("span"), x = u(i.reveal, i.reveal, () => e.play(), "tf-ctl-primary");
|
|
2106
|
+
w.append(g, x), c.append(w);
|
|
2107
|
+
const S = s.mount;
|
|
2108
|
+
S ? S.appendChild(c) : t.insertAdjacentElement("afterend", c);
|
|
2109
|
+
const I = () => {
|
|
2092
2110
|
const M = e.isPlaying;
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
n.activeElement !==
|
|
2096
|
-
const
|
|
2097
|
-
if (
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
const
|
|
2103
|
-
|
|
2111
|
+
d.textContent = M ? "❚❚" : "▶", d.setAttribute("aria-label", M ? i.pause : i.play), d.title = M ? i.pause : i.play;
|
|
2112
|
+
const v = e.duration;
|
|
2113
|
+
n.activeElement !== m && (m.value = String(v > 0 ? Math.round(e.currentTime / v * 1e3) : 0));
|
|
2114
|
+
const O = e.markers;
|
|
2115
|
+
if (f.hidden = b.hidden = k.hidden = O.length === 0, O.length > 0) {
|
|
2116
|
+
const E = e.currentMarker, $ = E ? O.indexOf(E) + 1 : 0;
|
|
2117
|
+
k.textContent = i.stepFormat.replace("{index}", String($)).replace("{total}", String(O.length)), k.setAttribute("aria-label", `${i.step} ${$} ${i.of} ${O.length}`), f.disabled = e.currentTime <= 0.5, b.disabled = e.currentTime >= v - 0.5;
|
|
2118
|
+
const B = e.caption() ?? "";
|
|
2119
|
+
T.textContent !== B && (T.textContent = B), T.hidden = !o();
|
|
2120
|
+
const U = !M && E?.question !== void 0 && Math.abs(e.currentTime - E.time) < 1;
|
|
2121
|
+
w.hidden = !U, U && g.textContent !== E.question && (g.textContent = E.question);
|
|
2104
2122
|
} else
|
|
2105
|
-
T.hidden = !0;
|
|
2106
|
-
},
|
|
2107
|
-
|
|
2108
|
-
const
|
|
2109
|
-
!
|
|
2110
|
-
const
|
|
2111
|
-
if (
|
|
2112
|
-
const
|
|
2113
|
-
if (!(
|
|
2123
|
+
w.hidden = !0, T.hidden = !0;
|
|
2124
|
+
}, Y = e.subscribe(I);
|
|
2125
|
+
I();
|
|
2126
|
+
const _ = s.keyboardScope ?? t;
|
|
2127
|
+
!_.hasAttribute("tabindex") && _.tabIndex < 0 && (_.tabIndex = 0);
|
|
2128
|
+
const C = /* @__PURE__ */ new WeakSet(), A = (M) => {
|
|
2129
|
+
if (C.has(M) || (C.add(M), M.defaultPrevented || M.altKey || M.ctrlKey || M.metaKey)) return;
|
|
2130
|
+
const v = M.target;
|
|
2131
|
+
if (!(v.tagName === "INPUT" || v.tagName === "SELECT") && !(M.key === " " && v.tagName === "BUTTON"))
|
|
2114
2132
|
switch (M.key) {
|
|
2115
2133
|
case " ":
|
|
2116
|
-
M.preventDefault(), e.isPlaying ? e.pause() :
|
|
2134
|
+
M.preventDefault(), e.isPlaying ? e.pause() : p();
|
|
2117
2135
|
break;
|
|
2118
2136
|
case "ArrowRight":
|
|
2119
2137
|
if (!a()) return;
|
|
@@ -2128,16 +2146,16 @@ function $s(e, t, s = {}) {
|
|
|
2128
2146
|
break;
|
|
2129
2147
|
}
|
|
2130
2148
|
};
|
|
2131
|
-
return
|
|
2132
|
-
element:
|
|
2149
|
+
return _.addEventListener("keydown", A), c.addEventListener("keydown", A), {
|
|
2150
|
+
element: c,
|
|
2133
2151
|
destroy() {
|
|
2134
|
-
|
|
2152
|
+
Y(), _.removeEventListener("keydown", A), c.removeEventListener("keydown", A), c.remove();
|
|
2135
2153
|
}
|
|
2136
2154
|
};
|
|
2137
2155
|
}
|
|
2138
|
-
const
|
|
2156
|
+
const at = /* @__PURE__ */ new WeakMap();
|
|
2139
2157
|
let Ds = 0;
|
|
2140
|
-
function
|
|
2158
|
+
function nt(e, t, s) {
|
|
2141
2159
|
if (e)
|
|
2142
2160
|
try {
|
|
2143
2161
|
return JSON.parse(e);
|
|
@@ -2147,41 +2165,52 @@ function st(e, t, s) {
|
|
|
2147
2165
|
}
|
|
2148
2166
|
}
|
|
2149
2167
|
async function Os(e, t = {}) {
|
|
2150
|
-
const s =
|
|
2168
|
+
const s = at.get(e);
|
|
2151
2169
|
if (s) return s;
|
|
2152
|
-
const n = e.querySelector("script[data-tinyfly-timeline]"), i = e.getAttribute("data-src")
|
|
2153
|
-
|
|
2170
|
+
const n = e.querySelector("script[data-tinyfly-timeline]"), i = e.getAttribute("data-src");
|
|
2171
|
+
let r = n ? nt(n.textContent, "timeline", e) : void 0;
|
|
2172
|
+
const a = Ls(e.getAttribute("data-markers"));
|
|
2173
|
+
if (!r && i && a) {
|
|
2174
|
+
const h = await fetch(i);
|
|
2175
|
+
h.ok && (r = await h.json());
|
|
2176
|
+
}
|
|
2177
|
+
if (r && a && !r.config.markers?.length && (r.config = { ...r.config, markers: a.map((h, f) => ({ id: `step-${f + 1}`, time: h })) }), !r && !i) {
|
|
2154
2178
|
console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)', e);
|
|
2155
2179
|
return;
|
|
2156
2180
|
}
|
|
2157
|
-
const
|
|
2181
|
+
const o = nt(e.querySelector("script[data-tinyfly-captions]")?.textContent, "captions", e), c = {
|
|
2158
2182
|
playWhenVisible: !0,
|
|
2159
2183
|
...t.player,
|
|
2160
|
-
...
|
|
2161
|
-
...
|
|
2184
|
+
...o && { captions: o },
|
|
2185
|
+
...nt(e.getAttribute("data-options"), "data-options", e)
|
|
2162
2186
|
};
|
|
2163
|
-
|
|
2164
|
-
const l = new
|
|
2165
|
-
if (
|
|
2166
|
-
const
|
|
2167
|
-
|
|
2187
|
+
Fs(e);
|
|
2188
|
+
const l = new St(e, c), u = { element: e, player: l };
|
|
2189
|
+
if (at.set(e, u), e.setAttribute("data-tinyfly-mounted", ""), await l.load(r ?? i), e.getAttribute("data-controls") !== "false") {
|
|
2190
|
+
const h = nt(e.getAttribute("data-labels"), "data-labels", e), f = e.querySelector("figcaption");
|
|
2191
|
+
u.controls = $s(l, e, {
|
|
2168
2192
|
...t.controls,
|
|
2169
|
-
labels: { ...t.controls?.labels, ...
|
|
2193
|
+
labels: { ...t.controls?.labels, ...h },
|
|
2170
2194
|
// Inside the figure, before its figcaption, so the caption stays last.
|
|
2171
2195
|
mount: void 0
|
|
2172
|
-
}),
|
|
2196
|
+
}), f ? e.insertBefore(u.controls.element, f) : e.appendChild(u.controls.element);
|
|
2173
2197
|
}
|
|
2174
|
-
return
|
|
2198
|
+
return u;
|
|
2175
2199
|
}
|
|
2176
|
-
|
|
2200
|
+
function Ls(e) {
|
|
2201
|
+
if (!e) return;
|
|
2202
|
+
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((s) => Number.isFinite(s) && s >= 0).sort((s, n) => s - n);
|
|
2203
|
+
return t.length > 0 ? t : void 0;
|
|
2204
|
+
}
|
|
2205
|
+
async function Ns(e = document, t = {}) {
|
|
2177
2206
|
const s = Array.from(e.querySelectorAll("[data-tinyfly-embed]"));
|
|
2178
2207
|
return (await Promise.all(s.map((i) => Os(i, t)))).filter((i) => i !== void 0);
|
|
2179
2208
|
}
|
|
2180
|
-
function
|
|
2181
|
-
const t =
|
|
2182
|
-
t && (t.controls?.destroy(), t.player.destroy(),
|
|
2209
|
+
function Hs(e) {
|
|
2210
|
+
const t = at.get(e);
|
|
2211
|
+
t && (t.controls?.destroy(), t.player.destroy(), at.delete(e), e.removeAttribute("data-tinyfly-mounted"));
|
|
2183
2212
|
}
|
|
2184
|
-
function
|
|
2213
|
+
function Fs(e) {
|
|
2185
2214
|
const t = e.querySelector("svg");
|
|
2186
2215
|
if (!t || t.hasAttribute("role") || t.hasAttribute("aria-hidden")) return;
|
|
2187
2216
|
const s = e.getAttribute("data-alt"), n = e.querySelector("figcaption");
|
|
@@ -2192,75 +2221,75 @@ function Xs(e) {
|
|
|
2192
2221
|
for (const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(s[2] ?? s[3]);
|
|
2193
2222
|
return [...t];
|
|
2194
2223
|
}
|
|
2195
|
-
function
|
|
2196
|
-
const s = [], n = (
|
|
2197
|
-
if ((e.formatVersion ?? 1) >
|
|
2198
|
-
return n(`format version ${e.formatVersion} is newer than this tinyfly reads (${
|
|
2224
|
+
function zs(e, t = {}) {
|
|
2225
|
+
const s = [], n = (l) => s.push({ level: "error", message: l }), i = (l) => s.push({ level: "warning", message: l });
|
|
2226
|
+
if ((e.formatVersion ?? 1) > K)
|
|
2227
|
+
return n(`format version ${e.formatVersion} is newer than this tinyfly reads (${K})`), s;
|
|
2199
2228
|
let r = 0;
|
|
2200
2229
|
try {
|
|
2201
|
-
r =
|
|
2202
|
-
} catch (
|
|
2203
|
-
return n(`the timeline does not load: ${
|
|
2230
|
+
r = rt(e).duration;
|
|
2231
|
+
} catch (l) {
|
|
2232
|
+
return n(`the timeline does not load: ${l instanceof Error ? l.message : String(l)}`), s;
|
|
2204
2233
|
}
|
|
2205
2234
|
const a = e.config?.duration;
|
|
2206
2235
|
if (a !== void 0)
|
|
2207
|
-
for (const
|
|
2208
|
-
if (!("keyframes" in
|
|
2209
|
-
const u =
|
|
2210
|
-
u.length > 0 && n(`track "${
|
|
2236
|
+
for (const l of e.tracks) {
|
|
2237
|
+
if (!("keyframes" in l)) continue;
|
|
2238
|
+
const u = l.keyframes.filter((h) => h.time > a);
|
|
2239
|
+
u.length > 0 && n(`track "${l.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`);
|
|
2211
2240
|
}
|
|
2212
|
-
const o = e.config?.markers ?? [],
|
|
2213
|
-
o.forEach((
|
|
2214
|
-
|
|
2241
|
+
const o = e.config?.markers ?? [], c = /* @__PURE__ */ new Set();
|
|
2242
|
+
o.forEach((l, u) => {
|
|
2243
|
+
c.has(l.id) && n(`marker id "${l.id}" is used more than once`), c.add(l.id), (l.time < 0 || l.time > r) && n(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`), u > 0 && l.time < o[u - 1].time && n(`marker "${l.id}" comes before "${o[u - 1].id}" in time; list markers in order`);
|
|
2215
2244
|
});
|
|
2216
|
-
for (const [
|
|
2245
|
+
for (const [l, u] of Object.entries(e.captions ?? {})) {
|
|
2217
2246
|
for (const h of Object.keys(u))
|
|
2218
|
-
|
|
2219
|
-
for (const h of
|
|
2220
|
-
h in u || i(`marker "${h}" has no ${
|
|
2247
|
+
c.has(h) || n(`caption "${h}" (${l}) has no marker with that id`);
|
|
2248
|
+
for (const h of c)
|
|
2249
|
+
h in u || i(`marker "${h}" has no ${l} caption; its label is shown instead`);
|
|
2221
2250
|
}
|
|
2222
2251
|
if (t.markup !== void 0) {
|
|
2223
|
-
const
|
|
2252
|
+
const l = new Set(Xs(t.markup)), u = /* @__PURE__ */ new Set();
|
|
2224
2253
|
for (const h of e.tracks)
|
|
2225
2254
|
for (const f of [h.target, ...h.targets ?? []])
|
|
2226
|
-
u.add(f),
|
|
2227
|
-
for (const h of
|
|
2255
|
+
u.add(f), l.has(f) || n(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);
|
|
2256
|
+
for (const h of l) u.has(h) || i(`data-tinyfly="${h}" is never animated`);
|
|
2228
2257
|
}
|
|
2229
2258
|
return s;
|
|
2230
2259
|
}
|
|
2231
|
-
function
|
|
2232
|
-
const n =
|
|
2260
|
+
function Gs(e, t, s = "end") {
|
|
2261
|
+
const n = rt(t), i = t.config?.markers ?? [], r = s === "start" ? 0 : s === "end" ? n.duration : typeof s == "number" ? s : i.find((f) => f.id === s)?.time ?? n.duration, a = n.getStateAtTime(Math.max(0, Math.min(n.duration, r))), o = new kt(), c = /* @__PURE__ */ new Map(), l = qs(e);
|
|
2233
2262
|
for (const f of e.matchAll(Wt)) {
|
|
2234
2263
|
const d = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2] ?? "");
|
|
2235
2264
|
if (!d) continue;
|
|
2236
|
-
const
|
|
2237
|
-
if (
|
|
2238
|
-
const p =
|
|
2239
|
-
|
|
2265
|
+
const b = d[2] ?? d[3];
|
|
2266
|
+
if (c.has(b)) continue;
|
|
2267
|
+
const p = Ys(l(f.index ?? 0));
|
|
2268
|
+
c.set(b, p), o.registerTarget(b, p);
|
|
2240
2269
|
}
|
|
2241
2270
|
o.applyState(a);
|
|
2242
2271
|
let u = "", h = 0;
|
|
2243
2272
|
for (const f of e.matchAll(Wt)) {
|
|
2244
|
-
const [d,
|
|
2273
|
+
const [d, b, p = "", m] = f, k = f.index ?? 0, y = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p), T = y ? c.get(y[2] ?? y[3]) : void 0;
|
|
2245
2274
|
if (!T || Object.keys(T.style).length === 0 && T.text === void 0) continue;
|
|
2246
|
-
u += e.slice(h,
|
|
2247
|
-
const
|
|
2248
|
-
let
|
|
2249
|
-
if (
|
|
2275
|
+
u += e.slice(h, k);
|
|
2276
|
+
const w = Object.entries(T.style).map(([S, I]) => `${Vs(S)}: ${I}`).join("; "), g = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);
|
|
2277
|
+
let x = p;
|
|
2278
|
+
if (w)
|
|
2250
2279
|
if (g) {
|
|
2251
|
-
const S = `${(g[2] ?? g[3]).trim().replace(/;?$/, ";")} ${
|
|
2252
|
-
|
|
2280
|
+
const S = `${(g[2] ?? g[3]).trim().replace(/;?$/, ";")} ${w}`.trim();
|
|
2281
|
+
x = p.replace(g[0], ` style="${Bt(S)}"`);
|
|
2253
2282
|
} else
|
|
2254
|
-
|
|
2255
|
-
if (u += `<${
|
|
2256
|
-
const S = e.indexOf(`</${
|
|
2257
|
-
S !== -1 && !I.includes("<") && (u +=
|
|
2283
|
+
x = `${p} style="${Bt(w)}"`;
|
|
2284
|
+
if (u += `<${b}${x}${m ? " /" : ""}>`, h = k + d.length, T.text !== void 0 && !m) {
|
|
2285
|
+
const S = e.indexOf(`</${b}`, h), I = S === -1 ? "" : e.slice(h, S);
|
|
2286
|
+
S !== -1 && !I.includes("<") && (u += Ws(T.text), h = S);
|
|
2258
2287
|
}
|
|
2259
2288
|
}
|
|
2260
2289
|
return u + e.slice(h);
|
|
2261
2290
|
}
|
|
2262
2291
|
const Wt = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
|
|
2263
|
-
function
|
|
2292
|
+
function Ys(e) {
|
|
2264
2293
|
const t = {
|
|
2265
2294
|
style: {},
|
|
2266
2295
|
dataset: {},
|
|
@@ -2275,7 +2304,7 @@ function Fs(e) {
|
|
|
2275
2304
|
};
|
|
2276
2305
|
return e && (t.ownerSVGElement = null), t;
|
|
2277
2306
|
}
|
|
2278
|
-
function
|
|
2307
|
+
function qs(e) {
|
|
2279
2308
|
const t = [], s = /<svg[\s>]/gi;
|
|
2280
2309
|
let n;
|
|
2281
2310
|
for (; n = s.exec(e); ) {
|
|
@@ -2284,33 +2313,33 @@ function Ys(e) {
|
|
|
2284
2313
|
}
|
|
2285
2314
|
return (i) => t.some(([r, a]) => i > r && i < a);
|
|
2286
2315
|
}
|
|
2287
|
-
function
|
|
2316
|
+
function Vs(e) {
|
|
2288
2317
|
const t = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
|
2289
2318
|
return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
|
|
2290
2319
|
}
|
|
2291
2320
|
function Bt(e) {
|
|
2292
2321
|
return e.replace(/&/g, "&").replace(/"/g, """);
|
|
2293
2322
|
}
|
|
2294
|
-
function
|
|
2323
|
+
function Ws(e) {
|
|
2295
2324
|
return e.replace(/&/g, "&").replace(/</g, "<");
|
|
2296
2325
|
}
|
|
2297
|
-
const
|
|
2298
|
-
if (
|
|
2326
|
+
const Bs = typeof document < "u" ? document.currentScript : null;
|
|
2327
|
+
if (Bs?.hasAttribute("data-tinyfly-auto")) {
|
|
2299
2328
|
const e = () => {
|
|
2300
|
-
|
|
2329
|
+
Ns();
|
|
2301
2330
|
};
|
|
2302
2331
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e, { once: !0 }) : e();
|
|
2303
2332
|
}
|
|
2304
2333
|
export {
|
|
2305
2334
|
Cs as DEFAULT_LABELS,
|
|
2306
|
-
|
|
2307
|
-
|
|
2335
|
+
St as TinyflyPlayer,
|
|
2336
|
+
js as create,
|
|
2308
2337
|
$s as createControls,
|
|
2309
2338
|
Os as mount,
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2339
|
+
Ns as mountAll,
|
|
2340
|
+
Us as play,
|
|
2341
|
+
Gs as renderFrame,
|
|
2313
2342
|
Xs as targetNamesIn,
|
|
2314
|
-
|
|
2315
|
-
|
|
2343
|
+
Hs as unmount,
|
|
2344
|
+
zs as validateEmbed
|
|
2316
2345
|
};
|