@mkbabb/keyframes.js 4.4.0 → 5.0.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 +7 -7
- package/dist/{animate-CuUJt2Tb.js → animate-CTWr6K7j.js} +3 -3
- package/dist/{animations-5nf2kBkv.js → animations-CZxf0rep.js} +2 -2
- package/dist/{compile-DgNRG6Lo.js → compile-YRJRdpKF.js} +2 -2
- package/dist/{draw-svg-DYRDxBlL.js → draw-svg-Dat9mHgi.js} +1 -1
- package/dist/{engine-CNHvTgpw.js → engine-DQcb7CLW.js} +516 -289
- package/dist/{ingest-CNM5xkQT.js → ingest-CU-kdYcM.js} +1 -1
- package/dist/keyframes.d.ts +178 -115
- package/dist/keyframes.js +39 -39
- package/dist/morph-svg-83uyYxoW.js +84 -0
- package/dist/{motion-path-J-RSNmRQ.js → motion-path-C0OHqcA3.js} +1 -1
- package/dist/{scroll-scene-CXEgM49Q.js → scroll-scene-DQxhxn9I.js} +2 -2
- package/dist/{sequence-CF5hazqz.js → sequence-cBr7thU8.js} +1 -1
- package/dist/{springTimingFunction-CDHZ00JQ.js → springTimingFunction-D26gPkAy.js} +1 -1
- package/dist/{timeline-B7SV3T_E.js → timeline-vY3eD3Ax.js} +27 -39
- package/dist/{utils-D7nuAND5.js → utils-BPRImVl5.js} +28 -25
- package/dist/{validate-8r6Yo-uc.js → validate-B1pE-Y_T.js} +3 -3
- package/dist/{waapi-D9MHMm_9.js → waapi-D0ssxKy1.js} +90 -28
- package/package.json +35 -5
- package/dist/morph-svg-DRjl9Hfz.js +0 -62
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { t as e } from "./errors-W8zkvPw4.js";
|
|
2
|
+
import { CSSKeyframesAnimation as t } from "./engine-DQcb7CLW.js";
|
|
3
|
+
import { PathGeometry as n } from "@mkbabb/value.js";
|
|
4
|
+
//#region src/animation/morph-svg.ts
|
|
5
|
+
var r = 64, i = (e) => `--morph-${e}-x`, a = (e) => `--morph-${e}-y`, o = (e) => `--morph-${e}-angle`, s = (e, t, n) => {
|
|
6
|
+
let r = Array(t + 1);
|
|
7
|
+
for (let i = 0; i <= t; i++) if (n) {
|
|
8
|
+
let n = e.sampleAtLength(e.totalLength * (i / t));
|
|
9
|
+
r[i] = {
|
|
10
|
+
x: n.x,
|
|
11
|
+
y: n.y,
|
|
12
|
+
angle: n.angle
|
|
13
|
+
};
|
|
14
|
+
} else r[i] = e.getPointAtT(i / t);
|
|
15
|
+
return r;
|
|
16
|
+
}, c = (e) => Number.isInteger(e) ? `${e}` : e.toFixed(3), l = (e) => {
|
|
17
|
+
if (e.length === 0) return "";
|
|
18
|
+
let t = `M ${c(e[0].x)} ${c(e[0].y)}`;
|
|
19
|
+
for (let n = 1; n < e.length; n++) t += ` L ${c(e[n].x)} ${c(e[n].y)}`;
|
|
20
|
+
return t;
|
|
21
|
+
}, u = (e, t) => {
|
|
22
|
+
let n = Array(t + 1);
|
|
23
|
+
for (let e = 0; e <= t; e++) n[e] = {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
};
|
|
27
|
+
return (r) => {
|
|
28
|
+
let o = r;
|
|
29
|
+
for (let e = 0; e <= t; e++) {
|
|
30
|
+
let t = n[e];
|
|
31
|
+
t.x = o[i(e)]?.[0]?.value ?? 0, t.y = o[a(e)]?.[0]?.value ?? 0;
|
|
32
|
+
}
|
|
33
|
+
let s = l(n);
|
|
34
|
+
e.style.setProperty("--morph-d", s), e.style.setProperty("d", `path("${s}")`);
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
function d(c, l, d = {}) {
|
|
38
|
+
let { samples: f = r, target: p, orient: m = !1, autoPlay: h = !0, ...g } = d;
|
|
39
|
+
if (typeof c != "string" || c.length === 0) throw new e("from", c, "fromMorphSVG(): `from` must be a non-empty SVG path `d` string.");
|
|
40
|
+
if (typeof l != "string" || l.length === 0) throw new e("to", l, "fromMorphSVG(): `to` must be a non-empty SVG path `d` string.");
|
|
41
|
+
if (!Number.isInteger(f) || f < 2) throw new e("samples", f, "fromMorphSVG(): `samples` must be an integer >= 2 (a 1-sample morph is just the two endpoints, with no body to interpolate).");
|
|
42
|
+
let _ = new n(c), v = new n(l);
|
|
43
|
+
if (_.totalLength === 0) throw new e("from", c, "fromMorphSVG(): the `from` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
44
|
+
if (v.totalLength === 0) throw new e("to", l, "fromMorphSVG(): the `to` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
45
|
+
let y = s(_, f, m), b = s(v, f, m), x = {}, S = {};
|
|
46
|
+
for (let e = 0; e <= f; e++) x[i(e)] = y[e].x, x[a(e)] = y[e].y, S[i(e)] = b[e].x, S[a(e)] = b[e].y, m && (x[o(e)] = y[e].angle ?? 0, S[o(e)] = b[e].angle ?? 0);
|
|
47
|
+
let C = {
|
|
48
|
+
"0%": x,
|
|
49
|
+
"100%": S
|
|
50
|
+
}, w = p == null ? void 0 : u(p, f), T = new t(g).fromKeyframes(C, w);
|
|
51
|
+
return h && T.play(), T;
|
|
52
|
+
}
|
|
53
|
+
var f = class {
|
|
54
|
+
animation;
|
|
55
|
+
samples;
|
|
56
|
+
constructor(e, t, n = {}) {
|
|
57
|
+
this.animation = d(e, t, n), this.samples = n.samples ?? r;
|
|
58
|
+
}
|
|
59
|
+
sampleD(e) {
|
|
60
|
+
let t = (e < 0 ? 0 : e > 1 ? 1 : e) * this.animation.options.duration, n = this.animation.interpFrames(t, !1), r = Array(this.samples + 1);
|
|
61
|
+
for (let e = 0; e <= this.samples; e++) {
|
|
62
|
+
let t = n[i(e)]?.[0]?.value, o = n[a(e)]?.[0]?.value;
|
|
63
|
+
r[e] = {
|
|
64
|
+
x: t ?? 0,
|
|
65
|
+
y: o ?? 0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return l(r);
|
|
69
|
+
}
|
|
70
|
+
play() {
|
|
71
|
+
return this.animation.play();
|
|
72
|
+
}
|
|
73
|
+
pause() {
|
|
74
|
+
return this.animation.pause(), this;
|
|
75
|
+
}
|
|
76
|
+
stop() {
|
|
77
|
+
return this.animation.stop(), this;
|
|
78
|
+
}
|
|
79
|
+
get finished() {
|
|
80
|
+
return this.animation.finished;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { f as MorphSVG, d as fromMorphSVG };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as e, c as t, f as n, i as r } from "./timeline-
|
|
1
|
+
import { a as e, c as t, f as n, i as r } from "./timeline-vY3eD3Ax.js";
|
|
2
2
|
import { n as i } from "./decay-BvNmFk51.js";
|
|
3
|
-
import { n as a, t as o } from "./waapi-
|
|
3
|
+
import { n as a, t as o } from "./waapi-D0ssxKy1.js";
|
|
4
4
|
import { a as s, i as c, n as l, r as u, t as d } from "./scroll-grammar-B4kPvGh5.js";
|
|
5
5
|
//#region src/animation/scroll-scene.ts
|
|
6
6
|
var f = {
|
|
@@ -1,43 +1,31 @@
|
|
|
1
1
|
import { n as e, t } from "./errors-W8zkvPw4.js";
|
|
2
|
+
import { clamp as n, lerpArray as r, scale as i } from "@mkbabb/value.js/math";
|
|
2
3
|
//#region src/animation/easing.ts
|
|
3
|
-
var
|
|
4
|
+
var a = (e) => typeof e == "function" ? { fn: e } : e, o = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, s = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, c = (e) => {
|
|
4
5
|
let t = e.trim();
|
|
5
|
-
if (
|
|
6
|
+
if (o.test(t) || s.test(t)) return t;
|
|
6
7
|
};
|
|
7
|
-
async function
|
|
8
|
+
async function l(t) {
|
|
8
9
|
let n;
|
|
9
10
|
try {
|
|
10
|
-
n = await import("./engine-
|
|
11
|
+
n = await import("./engine-DQcb7CLW.js");
|
|
11
12
|
} catch (e) {
|
|
12
13
|
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${t}" — the easing registry is unreachable.`, { cause: e });
|
|
13
14
|
}
|
|
14
15
|
let r = n.getTimingFunction(t);
|
|
15
16
|
if (!r) throw new e(t);
|
|
16
|
-
let i = { fn: r },
|
|
17
|
-
return
|
|
17
|
+
let i = { fn: r }, a = c(t);
|
|
18
|
+
return a && (i.css = a), i;
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
20
21
|
//#region src/animation/internal/leaves.ts
|
|
21
|
-
var
|
|
22
|
-
function c(e, t, n) {
|
|
23
|
-
return Math.min(Math.max(e, t), n);
|
|
24
|
-
}
|
|
25
|
-
function l(e, t, n, r = 0, i = 1) {
|
|
26
|
-
if (n === t) throw Error("fromMax and fromMin cannot be equal");
|
|
27
|
-
let a = (i - r) / (n - t);
|
|
28
|
-
return (e - t) * a + r;
|
|
29
|
-
}
|
|
30
|
-
function u(e, t, n, r) {
|
|
31
|
-
let i = e.length, a = 1 - n;
|
|
32
|
-
for (let o = 0; o < i; o++) r[o] = a * e[o] + n * t[o];
|
|
33
|
-
return r;
|
|
34
|
-
}
|
|
22
|
+
var u = 1e3 / 60;
|
|
35
23
|
function d(e) {
|
|
36
24
|
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
37
|
-
let t =
|
|
25
|
+
let t = u, n = Date.now();
|
|
38
26
|
return setTimeout(() => {
|
|
39
27
|
let r = Date.now(), i = r - n;
|
|
40
|
-
n = r, t = Math.max(0,
|
|
28
|
+
n = r, t = Math.max(0, u - i), e(r);
|
|
41
29
|
}, t);
|
|
42
30
|
}
|
|
43
31
|
function f(e) {
|
|
@@ -82,13 +70,13 @@ var b = class {
|
|
|
82
70
|
};
|
|
83
71
|
this._rafId = d(r);
|
|
84
72
|
}
|
|
85
|
-
play = (e, t,
|
|
73
|
+
play = (e, t, r) => {
|
|
86
74
|
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
87
|
-
return this.stop(), y(
|
|
88
|
-
this._resolve =
|
|
89
|
-
this._startTime === void 0 && (this._startTime =
|
|
90
|
-
let
|
|
91
|
-
return t(
|
|
75
|
+
return this.stop(), y(r?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((r) => {
|
|
76
|
+
this._resolve = r, this._startTime = void 0, this._run((r) => {
|
|
77
|
+
this._startTime === void 0 && (this._startTime = r);
|
|
78
|
+
let i = n((r - this._startTime) / e, 0, 1);
|
|
79
|
+
return t(i), i < 1;
|
|
92
80
|
});
|
|
93
81
|
}));
|
|
94
82
|
};
|
|
@@ -139,7 +127,7 @@ var b = class {
|
|
|
139
127
|
return this.isSettled;
|
|
140
128
|
}
|
|
141
129
|
setTarget(e) {
|
|
142
|
-
this.options.clamp && (e =
|
|
130
|
+
this.options.clamp && (e = n(e, 0, 1));
|
|
143
131
|
let t = Math.abs(e - this.targetValue);
|
|
144
132
|
t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
145
133
|
this.isSettled = !1, this._onFrame && this._startLoop();
|
|
@@ -151,7 +139,7 @@ var b = class {
|
|
|
151
139
|
tickDt(e) {
|
|
152
140
|
if (this.isSettled) return this.currentValue;
|
|
153
141
|
let t = 1 - Math.exp(-this.options.damping * e / 16.667);
|
|
154
|
-
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue =
|
|
142
|
+
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = n(this.currentValue, 0, 1)), this.currentValue;
|
|
155
143
|
}
|
|
156
144
|
snap() {
|
|
157
145
|
this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
|
|
@@ -179,11 +167,11 @@ var b = class {
|
|
|
179
167
|
//#endregion
|
|
180
168
|
//#region src/animation/spring-duration.ts
|
|
181
169
|
function C(e) {
|
|
182
|
-
let { visualDuration: t, duration:
|
|
170
|
+
let { visualDuration: t, duration: r, bounce: i = 0, ...a } = e, o = t ?? r ?? .5, s = 1 - n(i, -1, 1);
|
|
183
171
|
return {
|
|
184
|
-
...
|
|
185
|
-
response:
|
|
186
|
-
dampingFraction:
|
|
172
|
+
...a,
|
|
173
|
+
response: o,
|
|
174
|
+
dampingFraction: s
|
|
187
175
|
};
|
|
188
176
|
}
|
|
189
177
|
//#endregion
|
|
@@ -368,12 +356,12 @@ var E = new Float64Array(), D = {
|
|
|
368
356
|
boundaryEpsilon;
|
|
369
357
|
constructor(e) {
|
|
370
358
|
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
371
|
-
let
|
|
372
|
-
if (typeof
|
|
373
|
-
this._easingFn =
|
|
359
|
+
let n = e?.easing;
|
|
360
|
+
if (typeof n == "string") throw new t("easing", n, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
361
|
+
this._easingFn = n == null ? (e) => e : a(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new S(e?.smoothing);
|
|
374
362
|
}
|
|
375
363
|
applyPipeline() {
|
|
376
|
-
let e =
|
|
364
|
+
let e = n(this.sample(), 0, 1);
|
|
377
365
|
e = this._easingFn(e);
|
|
378
366
|
let t = this.boundaryEpsilon;
|
|
379
367
|
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
@@ -439,4 +427,4 @@ function M(e) {
|
|
|
439
427
|
return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
|
|
440
428
|
}
|
|
441
429
|
//#endregion
|
|
442
|
-
export {
|
|
430
|
+
export { a as _, O as a, S as c, y as d, n as f, l as g, c as h, M as i, b as l, i as m, j as n, w as o, r as p, k as r, T as s, A as t, v as u };
|
|
@@ -2,27 +2,30 @@ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
|
2
2
|
import { CSSCubicBezier as t, FunctionValue as n, ValueArray as r, ValueUnit as i, cssLinear as a, flattenObject as o, functionIdentityValue as s, memoize as c, normalizeValueUnits as l, parseCSSSubValue as u, parseLinearStops as d, parseSteps as f, prepareInterpVar as p, steppedEase as m, timingFunctions as h, unflattenObjectToString as g } from "@mkbabb/value.js";
|
|
3
3
|
//#region src/animation/utils.ts
|
|
4
4
|
var _ = /* @__PURE__ */ e({
|
|
5
|
-
calcFrameTime: () =>
|
|
6
|
-
createInterpVarValue: () =>
|
|
7
|
-
getTimingFunction: () =>
|
|
8
|
-
parseAndFlattenObject: () =>
|
|
9
|
-
transformTargetsStyle: () =>
|
|
10
|
-
}), v =
|
|
11
|
-
if (e instanceof i)
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
calcFrameTime: () => k,
|
|
6
|
+
createInterpVarValue: () => O,
|
|
7
|
+
getTimingFunction: () => T,
|
|
8
|
+
parseAndFlattenObject: () => D,
|
|
9
|
+
transformTargetsStyle: () => j
|
|
10
|
+
}), v = (e) => e.fnName, y = (e, t) => {
|
|
11
|
+
if (e instanceof i) {
|
|
12
|
+
let n = e.clone();
|
|
13
|
+
return t !== void 0 && (n.fnName = t), [n];
|
|
14
|
+
}
|
|
15
|
+
if (e instanceof n) return e.values.flatMap((t) => y(t, e.name));
|
|
16
|
+
if (e instanceof r) return e.flatMap((e) => y(e, t));
|
|
14
17
|
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
|
|
15
|
-
},
|
|
18
|
+
}, b = (e) => {
|
|
16
19
|
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
17
20
|
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
18
21
|
return {
|
|
19
22
|
mainKey: n,
|
|
20
23
|
childKey: t
|
|
21
24
|
};
|
|
22
|
-
},
|
|
25
|
+
}, x = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), S = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, C = /^\s*steps\s*\(/i, w = /^\s*linear\s*\(/i, T = (e) => {
|
|
23
26
|
if (e == null) return;
|
|
24
27
|
if (typeof e != "string") return e;
|
|
25
|
-
let n = e.match(
|
|
28
|
+
let n = e.match(S);
|
|
26
29
|
if (n) {
|
|
27
30
|
let e = n.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
28
31
|
if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
|
|
@@ -30,29 +33,29 @@ var _ = /* @__PURE__ */ e({
|
|
|
30
33
|
return t(n, r, i, a);
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
if (
|
|
36
|
+
if (C.test(e)) try {
|
|
34
37
|
let { count: t, jumpTerm: n } = f(e);
|
|
35
38
|
return m(t, n);
|
|
36
39
|
} catch {}
|
|
37
40
|
if (e === "step-start") return m(1, "jump-start");
|
|
38
41
|
if (e === "step-end") return m(1, "jump-end");
|
|
39
|
-
if (
|
|
42
|
+
if (w.test(e)) try {
|
|
40
43
|
return a(d(e));
|
|
41
44
|
} catch {}
|
|
42
45
|
let r = h[e];
|
|
43
46
|
if (typeof r == "function" && r.length <= 1) return r;
|
|
44
|
-
},
|
|
47
|
+
}, E = c((e, t) => y(u(t, { subProperty: e })), {
|
|
45
48
|
maxCacheSize: 2048,
|
|
46
49
|
keyFn: (e, t) => `${e}:${t}`
|
|
47
50
|
});
|
|
48
|
-
function
|
|
51
|
+
function D(e) {
|
|
49
52
|
let t = o(e), a = (e, t) => {
|
|
50
|
-
let { childKey: o, mainKey: s } =
|
|
51
|
-
return t instanceof i ?
|
|
53
|
+
let { childKey: o, mainKey: s } = b(e);
|
|
54
|
+
return t instanceof i ? x(new r(...y(t)), s, o) : t instanceof n ? x(new r(...t.values.flatMap((n) => y(a(e, n), t.name))), s, o) : t instanceof r ? x(new r(...t.flatMap((t) => y(a(e, t)))), s, o) : x(new r(...E(o, String(t)).map((e) => e.clone())), s, o);
|
|
52
55
|
};
|
|
53
56
|
return Object.entries(t).reduce((e, [t, n]) => (e[t] = a(t, n), e), {});
|
|
54
57
|
}
|
|
55
|
-
var
|
|
58
|
+
var O = (e, t, n, r, a = "oklab", o) => {
|
|
56
59
|
let c = r[t], u = r[n];
|
|
57
60
|
if (!c || !u) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
|
|
58
61
|
let d = c[e], f = u[e];
|
|
@@ -63,7 +66,7 @@ var A = (e, t, n, r, a = "oklab", o) => {
|
|
|
63
66
|
return t;
|
|
64
67
|
});
|
|
65
68
|
for (; r.length < m;) {
|
|
66
|
-
let e = n[r.length], t = e instanceof i ?
|
|
69
|
+
let e = n[r.length], t = e instanceof i ? v(e) : void 0, a = t ? s(t) : void 0;
|
|
67
70
|
r.push(a ?? new i(0));
|
|
68
71
|
}
|
|
69
72
|
return r;
|
|
@@ -76,17 +79,17 @@ var A = (e, t, n, r, a = "oklab", o) => {
|
|
|
76
79
|
return o !== void 0 && (s.hueMethod = o), p(l(t, r, s));
|
|
77
80
|
});
|
|
78
81
|
};
|
|
79
|
-
function
|
|
82
|
+
function k(e, t, n) {
|
|
80
83
|
let [r, i] = [e.start, t.start];
|
|
81
84
|
return {
|
|
82
85
|
start: r.value * n / 100,
|
|
83
86
|
stop: i.value * n / 100
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
|
-
var
|
|
87
|
-
function
|
|
89
|
+
var A = {};
|
|
90
|
+
function j(e, t, n = !0) {
|
|
88
91
|
e = n ? e : o(e);
|
|
89
|
-
let r = g(e,
|
|
92
|
+
let r = g(e, A);
|
|
90
93
|
t.forEach((e) => {
|
|
91
94
|
Object.entries(r).forEach(([t, n]) => {
|
|
92
95
|
e.style.setProperty(t, n);
|
|
@@ -94,4 +97,4 @@ function N(e, t, n = !0) {
|
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
//#endregion
|
|
97
|
-
export {
|
|
100
|
+
export { j as a, D as i, O as n, _ as o, T as r, k as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as e } from "./waapi-
|
|
2
|
-
import { CSSKeyframesAnimation as t } from "./engine-
|
|
3
|
-
import { compileToCSS as n } from "./compile-
|
|
1
|
+
import { n as e } from "./waapi-D0ssxKy1.js";
|
|
2
|
+
import { CSSKeyframesAnimation as t } from "./engine-DQcb7CLW.js";
|
|
3
|
+
import { compileToCSS as n } from "./compile-YRJRdpKF.js";
|
|
4
4
|
import { extractKeyframes as r, parseCSSStylesheet as i } from "@mkbabb/value.js";
|
|
5
5
|
//#region src/animation/validate.ts
|
|
6
6
|
var a = (e) => new t().fromString(e);
|
|
@@ -1,7 +1,73 @@
|
|
|
1
|
-
import { f as e, i as t } from "./timeline-
|
|
1
|
+
import { f as e, i as t } from "./timeline-vY3eD3Ax.js";
|
|
2
2
|
import { COMPUTED_UNITS as n, unflattenObjectToString as r } from "@mkbabb/value.js";
|
|
3
|
+
var i = .005, a = (e, t) => {
|
|
4
|
+
let n = /* @__PURE__ */ new Map(), r = e.interpFrames(t, !1);
|
|
5
|
+
for (let e in r) {
|
|
6
|
+
let t = r[e];
|
|
7
|
+
if (t !== void 0) for (let r = 0; r < t.length; r++) {
|
|
8
|
+
let i = t[r]?.value;
|
|
9
|
+
typeof i == "number" && Number.isFinite(i) && n.set(t.length > 1 ? `${e}.${r}` : e, i);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return n;
|
|
13
|
+
}, o = 64, s = (e, t, n) => {
|
|
14
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = n - t;
|
|
15
|
+
for (let n = 0; n <= o; n++) {
|
|
16
|
+
let c = a(e, t + s * n / o);
|
|
17
|
+
for (let [e, t] of c) {
|
|
18
|
+
let n = r.get(e), a = i.get(e);
|
|
19
|
+
(n === void 0 || t < n) && r.set(e, t), (a === void 0 || t > a) && i.set(e, t);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
let c = /* @__PURE__ */ new Map();
|
|
23
|
+
for (let [e, t] of r) c.set(e, (i.get(e) ?? t) - t);
|
|
24
|
+
return c;
|
|
25
|
+
}, c = (e, t, n, r, i, o) => {
|
|
26
|
+
let s = r - t, c = 0;
|
|
27
|
+
for (let r of [.25, .75]) {
|
|
28
|
+
let l = a(e, t + s * r);
|
|
29
|
+
for (let [e, t] of l) {
|
|
30
|
+
let a = n.get(e), s = i.get(e);
|
|
31
|
+
if (a === void 0 || s === void 0) continue;
|
|
32
|
+
let l = o.get(e);
|
|
33
|
+
if (l === void 0 || l === 0) continue;
|
|
34
|
+
let u = a + (s - a) * r, d = Math.abs(t - u) / l;
|
|
35
|
+
d > c && (c = d);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return c;
|
|
39
|
+
};
|
|
40
|
+
function l(e, t, n) {
|
|
41
|
+
let r = /* @__PURE__ */ new Set();
|
|
42
|
+
if (n <= 0) return r;
|
|
43
|
+
for (let n = 1; n < t.length; n++) {
|
|
44
|
+
let o = t[n - 1], l = t[n];
|
|
45
|
+
if (l - o <= 0) continue;
|
|
46
|
+
let u = s(e, o, l), d = a(e, o), f = a(e, l), p = (t, n, r, i) => ({
|
|
47
|
+
a: t,
|
|
48
|
+
sampleA: n,
|
|
49
|
+
b: r,
|
|
50
|
+
sampleB: i,
|
|
51
|
+
error: c(e, t, n, r, i, u)
|
|
52
|
+
}), m = [p(o, d, l, f)], h = 16;
|
|
53
|
+
for (; h > 0;) {
|
|
54
|
+
let t = -1, n = i;
|
|
55
|
+
for (let e = 0; e < m.length; e++) m[e].error > n && (n = m[e].error, t = e);
|
|
56
|
+
if (t === -1) break;
|
|
57
|
+
let o = m[t], s = (o.a + o.b) / 2;
|
|
58
|
+
if (s <= o.a || s >= o.b) {
|
|
59
|
+
m.splice(t, 1);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let c = a(e, s);
|
|
63
|
+
r.add(s), h--, m.splice(t, 1, p(o.a, o.sampleA, s, c), p(s, c, o.b, o.sampleB));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return r;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
3
69
|
//#region src/animation/waapi.ts
|
|
4
|
-
var
|
|
70
|
+
var u = new Set([
|
|
5
71
|
...n,
|
|
6
72
|
"%",
|
|
7
73
|
"vh",
|
|
@@ -34,8 +100,8 @@ var i = new Set([
|
|
|
34
100
|
"cqb",
|
|
35
101
|
"cqmin",
|
|
36
102
|
"cqmax"
|
|
37
|
-
]),
|
|
38
|
-
function
|
|
103
|
+
]), d = (e) => typeof e == "string" && u.has(e), f = new Set(["offset-distance"]), p = (e) => f.has(e) || f.has(e.split(".").pop() ?? e), m = () => typeof globalThis.webkitConvertPointFromNodeToPage == "function";
|
|
104
|
+
function h(e) {
|
|
39
105
|
if (!e.targets || e.targets.length === 0) return {
|
|
40
106
|
eligible: !1,
|
|
41
107
|
reason: "no DOM targets"
|
|
@@ -63,14 +129,14 @@ function l(e) {
|
|
|
63
129
|
eligible: !1,
|
|
64
130
|
reason: "easing has no faithful CSS twin (would run bare linear on the compositor)"
|
|
65
131
|
};
|
|
66
|
-
if (t?.css?.startsWith("linear(") &&
|
|
132
|
+
if (t?.css?.startsWith("linear(") && m()) return {
|
|
67
133
|
eligible: !1,
|
|
68
134
|
reason: "WebKit refuses HW-accel for linear() easing — the spring twin stays on the rAF path (CE-1.0)"
|
|
69
135
|
};
|
|
70
136
|
for (let t of e.frames) for (let [e, n] of Object.entries(t.interpVars)) {
|
|
71
|
-
let t =
|
|
137
|
+
let t = p(e);
|
|
72
138
|
for (let e of n) {
|
|
73
|
-
let n =
|
|
139
|
+
let n = d(e.start?.unit) && !(t && e.start?.unit === "%"), r = d(e.stop?.unit) && !(t && e.stop?.unit === "%");
|
|
74
140
|
if (n || r) return {
|
|
75
141
|
eligible: !1,
|
|
76
142
|
reason: `layout-dependent unit (${String(e.start?.unit ?? e.stop?.unit)}) would freeze to px under WAAPI`
|
|
@@ -83,15 +149,11 @@ function l(e) {
|
|
|
83
149
|
}
|
|
84
150
|
return { eligible: !0 };
|
|
85
151
|
}
|
|
86
|
-
|
|
87
|
-
function d(t) {
|
|
152
|
+
function g(t) {
|
|
88
153
|
let n = t.options.duration, i = [], a = /* @__PURE__ */ new Set();
|
|
89
154
|
for (let e of t.frames) a.add(e.time.start), a.add(e.time.stop);
|
|
90
155
|
let o = [...a].sort((e, t) => e - t), s = new Set(o);
|
|
91
|
-
|
|
92
|
-
let t = o[e - 1], n = o[e] - t;
|
|
93
|
-
if (!(n <= 0)) for (let e = 1; e <= u; e++) s.add(t + n * e / 9);
|
|
94
|
-
}
|
|
156
|
+
for (let e of l(t, o, n)) s.add(e);
|
|
95
157
|
for (let a of [...s].sort((e, t) => e - t)) {
|
|
96
158
|
let o = t.interpFrames(a, !1);
|
|
97
159
|
if (Object.keys(o).length === 0) continue;
|
|
@@ -103,32 +165,32 @@ function d(t) {
|
|
|
103
165
|
}
|
|
104
166
|
return i;
|
|
105
167
|
}
|
|
106
|
-
var
|
|
168
|
+
var _ = {
|
|
107
169
|
normal: "normal",
|
|
108
170
|
reverse: "reverse",
|
|
109
171
|
alternate: "alternate",
|
|
110
172
|
"alternate-reverse": "alternate-reverse"
|
|
111
|
-
},
|
|
173
|
+
}, v = {
|
|
112
174
|
none: "none",
|
|
113
175
|
forwards: "forwards",
|
|
114
176
|
backwards: "backwards",
|
|
115
177
|
both: "both"
|
|
116
|
-
},
|
|
178
|
+
}, y = {
|
|
117
179
|
replace: "replace",
|
|
118
180
|
add: "add",
|
|
119
181
|
accumulate: "accumulate"
|
|
120
|
-
},
|
|
182
|
+
}, b = (e) => {
|
|
121
183
|
for (let t of e.frames) {
|
|
122
184
|
let e = t.composition;
|
|
123
|
-
if (e != null && e !== "replace") return
|
|
185
|
+
if (e != null && e !== "replace") return y[e] ?? "replace";
|
|
124
186
|
}
|
|
125
187
|
return "replace";
|
|
126
188
|
};
|
|
127
|
-
function
|
|
128
|
-
let t = e.options, n =
|
|
189
|
+
function x(e) {
|
|
190
|
+
let t = e.options, n = _[t.direction], r = v[t.fillMode];
|
|
129
191
|
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
130
192
|
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
131
|
-
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear", a =
|
|
193
|
+
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear", a = b(e), o = {
|
|
132
194
|
duration: t.duration,
|
|
133
195
|
delay: t.delay,
|
|
134
196
|
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
@@ -138,8 +200,8 @@ function g(e) {
|
|
|
138
200
|
};
|
|
139
201
|
return a !== "replace" && (o.composite = a), o;
|
|
140
202
|
}
|
|
141
|
-
async function
|
|
142
|
-
let t =
|
|
203
|
+
async function S(e) {
|
|
204
|
+
let t = g(e), n = x(e), r = e.targets.map((e) => e.animate(t, n));
|
|
143
205
|
e._waAnimations = r, e.playback.loop(async (t) => {
|
|
144
206
|
if (e.done) return !1;
|
|
145
207
|
if (await e.advanceTo(t), e.paused) for (let e of r) e.pause();
|
|
@@ -155,8 +217,8 @@ async function _(e) {
|
|
|
155
217
|
e.playback.stop(), e._waAnimations = [];
|
|
156
218
|
}
|
|
157
219
|
}
|
|
158
|
-
function
|
|
159
|
-
let r =
|
|
220
|
+
function C(e, n) {
|
|
221
|
+
let r = h(e);
|
|
160
222
|
if (!r.eligible) return {
|
|
161
223
|
attached: !1,
|
|
162
224
|
reason: r.reason
|
|
@@ -166,8 +228,8 @@ function v(e, n) {
|
|
|
166
228
|
attached: !1,
|
|
167
229
|
reason: "native scroll/view timeline unavailable (feature absent)"
|
|
168
230
|
};
|
|
169
|
-
let a =
|
|
170
|
-
...
|
|
231
|
+
let a = g(e), o = {
|
|
232
|
+
...x(e),
|
|
171
233
|
timeline: i
|
|
172
234
|
}, s = e.targets.map((e) => e.animate(a, o));
|
|
173
235
|
return e._waAnimations = s, {
|
|
@@ -176,4 +238,4 @@ function v(e, n) {
|
|
|
176
238
|
};
|
|
177
239
|
}
|
|
178
240
|
//#endregion
|
|
179
|
-
export {
|
|
241
|
+
export { h as n, S as r, C as t };
|