@mkbabb/keyframes.js 5.0.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +112 -217
  2. package/dist/backward-color-BtbRcnna.js +108 -0
  3. package/dist/compile-BHCTPerD.js +30 -0
  4. package/dist/{waapi-D0ssxKy1.js → delegation-BQYCrP2p.js} +117 -99
  5. package/dist/{draw-svg-Dat9mHgi.js → draw-svg-CK9Qrly8.js} +18 -26
  6. package/dist/easing-registry-DHV2-5gA.js +27 -0
  7. package/dist/easing-registry-y1p9McFy.js +2 -0
  8. package/dist/easing-serialize-D4LZCB6i.js +21 -0
  9. package/dist/engine/index.d.ts +3139 -0
  10. package/dist/engine/index.js +16 -0
  11. package/dist/engine-CPK_udUQ.js +1172 -0
  12. package/dist/engine-DlpimZtM.js +3 -0
  13. package/dist/entry-D82NKUhP.js +148 -0
  14. package/dist/format-BdIvdLzG.js +114 -0
  15. package/dist/group-HM7N4uOE.js +390 -0
  16. package/dist/handle-D4xrf_ya.js +21 -0
  17. package/dist/{ingest-CU-kdYcM.js → ingest-_g6tfk2e.js} +62 -56
  18. package/dist/keyframes.d.ts +1156 -1099
  19. package/dist/keyframes.js +412 -132
  20. package/dist/morph-svg-KUrH9KnK.js +79 -0
  21. package/dist/motion-path-wM5tPfrY.js +26 -0
  22. package/dist/parse-flatten-DRMHFytp.js +2 -0
  23. package/dist/parse-flatten-ZZUSEQEL.js +63 -0
  24. package/dist/presets-DeDJYL4G.js +275 -0
  25. package/dist/{scheduler-7eIr_q1g.js → scheduler-CfGIC3GX.js} +1 -1
  26. package/dist/scroll-BEyCx0b_.js +287 -0
  27. package/dist/sequence-s0bL7Uul.js +736 -0
  28. package/dist/{validate-B1pE-Y_T.js → validate-xFZ_Ld1k.js} +17 -13
  29. package/dist/view-transition-BPJQxUTC.js +305 -0
  30. package/package.json +123 -84
  31. package/dist/animate-CTWr6K7j.js +0 -26
  32. package/dist/animations-CZxf0rep.js +0 -224
  33. package/dist/compile-YRJRdpKF.js +0 -251
  34. package/dist/decay-BvNmFk51.js +0 -25
  35. package/dist/engine-DQcb7CLW.js +0 -1349
  36. package/dist/errors-W8zkvPw4.js +0 -21
  37. package/dist/format-BUgCTjmr.js +0 -123
  38. package/dist/morph-svg-83uyYxoW.js +0 -84
  39. package/dist/motion-path-C0OHqcA3.js +0 -31
  40. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  41. package/dist/scroll-grammar-B4kPvGh5.js +0 -23
  42. package/dist/scroll-scene-DQxhxn9I.js +0 -176
  43. package/dist/sequence-cBr7thU8.js +0 -198
  44. package/dist/springTimingFunction-D26gPkAy.js +0 -63
  45. package/dist/timeline-vY3eD3Ax.js +0 -430
  46. package/dist/utils-BPRImVl5.js +0 -100
@@ -1,21 +0,0 @@
1
- //#region src/animation/internal/errors.ts
2
- var e = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), t = class extends Error {
3
- option;
4
- value;
5
- code;
6
- constructor(t, n, r, i) {
7
- super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n, i !== void 0 && (this.code = i);
8
- }
9
- }, n = class extends Error {
10
- easingName;
11
- constructor(t) {
12
- super(`Unknown easing name ${e(t)} — not a value.js registry entry or cubic-bezier() literal. Pass a callable TimingFunction (or a typed Easing), or resolve the name first via \`await resolveEasing(name)\`.`), this.name = "UnknownEasingError", this.easingName = t;
13
- }
14
- };
15
- function r(e, n, r, i) {
16
- let a = r(n);
17
- if (a === void 0) throw new t(e, n, i);
18
- return a;
19
- }
20
- //#endregion
21
- export { n, r, t };
@@ -1,123 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "./errors-W8zkvPw4.js";
3
- import { camelCaseToHyphen as n, formatCSS as r, reverseAnimationShorthand as i, reverseCSSTime as a, serializeStylesheetItem as o, timingFunctions as s, unflattenObjectToString as c } from "@mkbabb/value.js";
4
- //#region src/animation/format.ts
5
- var l = /* @__PURE__ */ e({
6
- CSSKeyframesToString: () => w,
7
- CSSKeyframesToStrings: () => h,
8
- animationComposition: () => S,
9
- animationOptionsToString: () => _,
10
- animationShorthand: () => x,
11
- declaredKeyframeBodyFor: () => v,
12
- formatCSSKeyframeString: () => g,
13
- keyframesBlock: () => y,
14
- premultipliedKeyframesBlock: () => b,
15
- serializeEasing: () => u
16
- });
17
- function u(e) {
18
- if (e.css !== void 0) return e.css;
19
- let r = Object.entries(s).find(([t, n]) => n === e.fn)?.[0];
20
- if (r === void 0) throw new t("timingFunction", e.fn, "a custom TimingFunction has no CSS animation-timing-function representation — attach a faithful Easing.css twin, or use a registry name / cubic-bezier() / linear() literal");
21
- return n(r);
22
- }
23
- var d = 80, f = "@keyframes animation {\n", p = "\n}";
24
- function m(e, t, r) {
25
- let i = e.parsedVars[t] ?? {}, a = e.templateFrames[t], o = Object.entries(c(i)).map(([e, t]) => ` ${n(e)}: ${t};`), s = a.timingFunction ? u(a.timingFunction) : r;
26
- s !== r && o.push(` animation-timing-function: ${s};`);
27
- let l = a.composition;
28
- return l != null && l !== "replace" && o.push(` animation-composition: ${l};`), `{\n${o.join("\n").trim()}\n}`;
29
- }
30
- var h = async (e) => {
31
- let t = u(e.options.timingFunction), n = e.templateFrames.map(async (n, i) => {
32
- let a = m(e, i, t);
33
- return a = `${n.start}\n${a}\n`, a = f + a + p, a = await r(a, d), a.replace(f, "").replace(p, "");
34
- });
35
- return Promise.all(n);
36
- };
37
- function g(e) {
38
- let t = e.replace(/^[^{]*{/, "").replace(/^ /gm, "").replace(/}\s*$/, "");
39
- return t = t.trim(), t = t.replace(/^ /, ""), t;
40
- }
41
- function _(e, t = "animation") {
42
- let n = "";
43
- n += ` animation-name: ${t};\n`;
44
- let r = a(e.duration);
45
- n += ` animation-duration: ${r};\n`, n += ` animation-timing-function: ${u(e.timingFunction)};\n`, n += ` animation-iteration-count: ${isFinite(e.iterationCount) ? e.iterationCount : "infinite"};\n`, n += ` animation-direction: ${e.direction};\n`, n += ` animation-fill-mode: ${e.fillMode};\n`, e.delay > 0 && (n += ` animation-delay: ${a(e.delay)};\n`);
46
- let i = e.composite == null ? void 0 : S(e.composite);
47
- return i != null && (n += ` ${i}\n`), n = `.${t} {\n${n}}\n`, n;
48
- }
49
- function v(e, t, n) {
50
- return m(e, t, n);
51
- }
52
- function y(e, t, n) {
53
- let r = u(e.options.timingFunction), i = /* @__PURE__ */ new Map();
54
- e.templateFrames.forEach((t, a) => {
55
- let o = n?.get(a) ?? m(e, a, r), s = i.get(o);
56
- s ? s.push(t.start) : i.set(o, [t.start]);
57
- });
58
- let a = "";
59
- for (let [e, t] of i) a += `${t.join(", ")} ${e}\n`;
60
- return `@keyframes ${t} {\n${a}}`;
61
- }
62
- function b(e, t, r) {
63
- let i = u(e.options.timingFunction), a = /* @__PURE__ */ new Map();
64
- for (let t = 0; t < e.templateFrames.length; t++) {
65
- let o = e.templateFrames[t], s = e.parsedVars[t] ?? {}, l = {};
66
- for (let [e, t] of Object.entries(s)) {
67
- let n = t.clone();
68
- for (let t of n) if (typeof t.value == "number") t.value *= r;
69
- else if (t.unit === "color" || typeof t.value == "string") return {
70
- refused: !0,
71
- key: e
72
- };
73
- l[e] = n;
74
- }
75
- let d = Object.entries(c(l)).map(([e, t]) => ` ${n(e)}: ${t};`), f = o.timingFunction ? u(o.timingFunction) : i;
76
- f !== i && d.push(` animation-timing-function: ${f};`);
77
- let p = o.composition;
78
- p != null && p !== "replace" && d.push(` animation-composition: ${p};`);
79
- let m = `{\n${d.join("\n").trim()}\n}`, h = a.get(m);
80
- h ? h.push(o.start) : a.set(m, [o.start]);
81
- }
82
- let o = "";
83
- for (let [e, t] of a) o += `${t.join(", ")} ${e}\n`;
84
- return { block: `@keyframes ${t} {\n${o}}` };
85
- }
86
- function x(e, t) {
87
- let n = {
88
- name: t,
89
- duration: e.duration,
90
- timingFunction: u(e.timingFunction),
91
- iterationCount: isFinite(e.iterationCount) ? e.iterationCount : Infinity,
92
- direction: e.direction,
93
- fillMode: e.fillMode
94
- };
95
- return e.delay > 0 && (n.delay = e.delay), i(n);
96
- }
97
- function S(e) {
98
- return e === "replace" ? void 0 : `animation-composition: ${e};`;
99
- }
100
- function C(e) {
101
- let t = e.propertyRegistry;
102
- if (t == null || t.size === 0) return "";
103
- let n = [];
104
- for (let [e, r] of t) n.push(o({
105
- kind: "property",
106
- name: e,
107
- descriptor: r
108
- }));
109
- return n.join("\n");
110
- }
111
- async function w(e, t = "animation", n = void 0) {
112
- let i = e.options, a = /* @__PURE__ */ new Map(), o = u(i.timingFunction);
113
- e.templateFrames.forEach((t, n) => {
114
- let r = t.start, i = m(e, n, o);
115
- a.has(i) ? a.get(i).push(r) : a.set(i, [r]);
116
- });
117
- let s = "";
118
- for (let [e, t] of a) s += `${t.join(", ")} ${e}`;
119
- let c = _(i, t), l = C(e);
120
- return (await r(`${l ? `${l}\n\n` : ""}${c}\n@keyframes ${t} {\n${s}}`, n)).replace(/\(\s*\{/g, "{").replace(/\}\s*\)/g, "}");
121
- }
122
- //#endregion
123
- export { b as a, y as i, x as n, l as r, S as t };
@@ -1,84 +0,0 @@
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,31 +0,0 @@
1
- import { CSSKeyframesAnimation as e } from "./engine-DQcb7CLW.js";
2
- //#region src/animation/motion-path.ts
3
- var t = (e) => typeof e == "number" ? `${e}%` : e;
4
- function n(n, r) {
5
- let { path: i, from: a = "0%", to: o = "100%", rotate: s, autoPlay: c = !0, ...l } = r;
6
- if (typeof i != "string" || i.length === 0) throw Error("fromMotionPath(): `path` is required — pass an offset-path value (a path()/ray()/url(#id) string).");
7
- let u = Array.isArray(n) ? n : [n];
8
- for (let e of u) e.style.offsetPath = i, s !== void 0 && (e.style.offsetRotate = s);
9
- let d = {
10
- "0%": { "offset-distance": t(a) },
11
- "100%": { "offset-distance": t(o) }
12
- }, f = new e(l).fromKeyframes(d);
13
- return f.setTargets(...u), c && f.play(), f;
14
- }
15
- var r = class {
16
- animation;
17
- constructor(e, t) {
18
- this.animation = n(e, t);
19
- }
20
- play() {
21
- return this.animation.play();
22
- }
23
- pause() {
24
- return this.animation.pause(), this;
25
- }
26
- stop() {
27
- return this.animation.stop(), this;
28
- }
29
- };
30
- //#endregion
31
- export { r as MotionPath, n as fromMotionPath };
@@ -1,11 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = Object.defineProperty, t = (t, n) => {
3
- let r = {};
4
- for (var i in t) e(r, i, {
5
- get: t[i],
6
- enumerable: !0
7
- });
8
- return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
- };
10
- //#endregion
11
- export { t };
@@ -1,23 +0,0 @@
1
- import { extractTimelineOptions as e, parseAnimationRange as t, parseAnimationTimeline as n, parseCSSStylesheet as r, serializeTimelineOptions as i } from "@mkbabb/value.js";
2
- //#region src/animation/scroll-grammar.ts
3
- function a(e) {
4
- return n(e);
5
- }
6
- function o(e) {
7
- return t(e);
8
- }
9
- function s(t) {
10
- return e(typeof t == "string" ? r(t) : t);
11
- }
12
- function c(e) {
13
- return i(e);
14
- }
15
- function l(e) {
16
- let t = s(e);
17
- return {
18
- options: t,
19
- declarations: c(t)
20
- };
21
- }
22
- //#endregion
23
- export { c as a, l as i, o as n, a as r, s as t };
@@ -1,176 +0,0 @@
1
- import { a as e, c as t, f as n, i as r } from "./timeline-vY3eD3Ax.js";
2
- import { n as i } from "./decay-BvNmFk51.js";
3
- import { n as a, t as o } from "./waapi-D0ssxKy1.js";
4
- import { a as s, i as c, n as l, r as u, t as d } from "./scroll-grammar-B4kPvGh5.js";
5
- //#region src/animation/scroll-scene.ts
6
- var f = {
7
- normal: {
8
- start: 0,
9
- end: 1
10
- },
11
- cover: {
12
- start: .25,
13
- end: .75
14
- },
15
- contain: {
16
- start: .375,
17
- end: .625
18
- },
19
- entry: {
20
- start: 0,
21
- end: .25
22
- },
23
- exit: {
24
- start: .75,
25
- end: 1
26
- },
27
- "entry-crossing": {
28
- start: 0,
29
- end: .25
30
- },
31
- "exit-crossing": {
32
- start: .75,
33
- end: 1
34
- }
35
- };
36
- function p(e) {
37
- if (e == null) return null;
38
- let t = e.trim();
39
- if (t.endsWith("%")) {
40
- let e = Number.parseFloat(t.slice(0, -1));
41
- return Number.isFinite(e) ? e / 100 : null;
42
- }
43
- return null;
44
- }
45
- function m(e, t) {
46
- if (e == null) return t;
47
- let n = p(e.offset);
48
- if (n != null) {
49
- if (e.phase != null && e.phase !== "normal") {
50
- let t = f[e.phase];
51
- return t.start + n * (t.end - t.start);
52
- }
53
- return n;
54
- }
55
- return e.phase == null ? t : f[e.phase].start;
56
- }
57
- function h(e) {
58
- if (e == null) return {
59
- start: 0,
60
- end: 1
61
- };
62
- let t = m(e.start, 0), n = m(e.end, 1);
63
- return n > t ? {
64
- start: t,
65
- end: n
66
- } : {
67
- start: 0,
68
- end: 1
69
- };
70
- }
71
- function g(e) {
72
- let { animation: t, nativeSpec: n, scrub: i, snap: s, velocity: c } = e;
73
- if (i) return {
74
- backend: "js",
75
- reason: "scrub smoothing requested (native scroll has no SmoothProgress smoother)"
76
- };
77
- if (s) return {
78
- backend: "js",
79
- reason: "physics snap requested (native scroll has no decay/spring settle)"
80
- };
81
- if (c) return {
82
- backend: "js",
83
- reason: "scroll velocity / non-DOM driving requested (JS-only capability)"
84
- };
85
- if (t == null || n == null) return {
86
- backend: "js",
87
- reason: "non-DOM target or no native timeline spec (the universal JS driver)"
88
- };
89
- let l = a(t);
90
- if (!l.eligible) return {
91
- backend: "js",
92
- reason: l.reason
93
- };
94
- if (r(n) == null) return {
95
- backend: "js",
96
- reason: "native scroll/view timeline unavailable (feature absent)"
97
- };
98
- let u = o(t, n);
99
- return u.attached ? {
100
- backend: "native",
101
- attachment: u
102
- } : {
103
- backend: "js",
104
- reason: u.reason
105
- };
106
- }
107
- function _(e) {
108
- let t = ["position: sticky;"];
109
- return e?.bottom == null ? t.push(`top: ${e?.top ?? 0}px;`) : t.push(`bottom: ${e.bottom}px;`), t.join(" ");
110
- }
111
- var v = class {
112
- resolvedRange;
113
- snapPoints;
114
- snapSpring;
115
- scrubSeconds;
116
- smoother;
117
- rawScroll = 0;
118
- localProgress = 0;
119
- wasInside = !1;
120
- subscribers = new Map([["enter", /* @__PURE__ */ new Set()], ["leave", /* @__PURE__ */ new Set()]]);
121
- constructor(r = {}) {
122
- if (this.resolvedRange = h(r.range), this.scrubSeconds = r.scrub ?? 0, this.snapPoints = r.snap != null && r.snap.length > 0 ? r.snap : void 0, this.scrubSeconds > 0) {
123
- let e = n(1 / (this.scrubSeconds * 60 + 1), .01, 1);
124
- this.smoother = new t({
125
- damping: e,
126
- clamp: !0,
127
- ...r.smoothing
128
- });
129
- }
130
- this.snapPoints != null && (this.snapSpring = new e({ ...r.snapSpring }));
131
- }
132
- get range() {
133
- return this.resolvedRange;
134
- }
135
- scrollProgress(e) {
136
- this.rawScroll = n(e, 0, 1);
137
- let { start: t, end: r } = this.resolvedRange, i = r - t, a = i > 0 ? n((this.rawScroll - t) / i, 0, 1) : 0, o = this.rawScroll >= t && this.rawScroll <= r;
138
- return o && !this.wasInside && this.fire("enter", a), !o && this.wasInside && this.fire("leave", a), this.wasInside = o, this.smoother ? (this.smoother.setTarget(a), this.localProgress = this.smoother.current) : this.localProgress = a, this.localProgress;
139
- }
140
- tick(e) {
141
- return this.smoother && (this.smoother.tickDt(e), this.localProgress = this.smoother.current), this.localProgress;
142
- }
143
- get progress() {
144
- return this.localProgress;
145
- }
146
- get settled() {
147
- return this.smoother == null || this.smoother.settled;
148
- }
149
- snapTo(e = 0) {
150
- if (this.snapPoints == null || this.snapSpring == null) return null;
151
- let t = n(i({
152
- initial: this.localProgress,
153
- velocity: e
154
- }), 0, 1), r = this.snapPoints[0], a = Math.abs(t - r);
155
- for (let e of this.snapPoints) {
156
- let n = Math.abs(t - e);
157
- n < a && (a = n, r = e);
158
- }
159
- return this.snapSpring.reset(this.localProgress, e), this.snapSpring.target = r, r;
160
- }
161
- tickSnap(e) {
162
- return this.snapSpring && !this.snapSpring.settled && (this.snapSpring.tickDt(e), this.localProgress = this.snapSpring.value), this.localProgress;
163
- }
164
- on(e, t) {
165
- let n = this.subscribers.get(e);
166
- return n.add(t), () => n.delete(t);
167
- }
168
- fire(e, t) {
169
- for (let n of this.subscribers.get(e)) n(t);
170
- }
171
- };
172
- function y(e = {}) {
173
- return new v(e);
174
- }
175
- //#endregion
176
- export { v as ScrollScene, y as createScrollScene, g as dispatchScrollBackend, d as parseScrollCSS, l as parseScrollRange, u as parseScrollTimeline, _ as pinCSS, h as resolveRange, c as roundTripScrollCSS, s as serializeScrollOptions };
@@ -1,198 +0,0 @@
1
- import { f as e, l as t } from "./timeline-vY3eD3Ax.js";
2
- //#region src/animation/sequence-events.ts
3
- var n = class {
4
- subscribers = new Map([
5
- ["segment:enter", /* @__PURE__ */ new Set()],
6
- ["segment:leave", /* @__PURE__ */ new Set()],
7
- ["label", /* @__PURE__ */ new Set()]
8
- ]);
9
- _activeSegments = /* @__PURE__ */ new Set();
10
- _prevPhase = void 0;
11
- subscribe(e, t) {
12
- let n = this.subscribers.get(e);
13
- return n.add(t), () => n.delete(t);
14
- }
15
- fire(e, t, n) {
16
- let r = this.subscribers.get("segment:enter"), i = this.subscribers.get("segment:leave"), a = this.subscribers.get("label");
17
- if (r.size === 0 && i.size === 0 && a.size === 0) {
18
- this._prevPhase = n;
19
- return;
20
- }
21
- let o = this._prevPhase;
22
- if (r.size > 0 || i.size > 0) for (let t of e) {
23
- let e = n >= t.at && n < t.at + t.animation.options.duration, a = this._activeSegments.has(t);
24
- if (e && !a) {
25
- this._activeSegments.add(t);
26
- for (let e of r) e(t.animation, n);
27
- } else if (!e && a) {
28
- this._activeSegments.delete(t);
29
- for (let e of i) e(t.animation, n);
30
- }
31
- }
32
- if (a.size > 0 && o !== void 0 && o !== n) {
33
- let e = Math.min(o, n), r = Math.max(o, n);
34
- for (let [i, o] of t) if (o > e && o <= r) for (let e of a) e(i, n);
35
- }
36
- this._prevPhase = n;
37
- }
38
- }, r = class {
39
- entries = [];
40
- labels = /* @__PURE__ */ new Map();
41
- _events = new n();
42
- cursor = 0;
43
- _time = 0;
44
- respectReducedMotion;
45
- playback = new t();
46
- _boundFrame;
47
- _resolvePlay = null;
48
- _playOrigin = void 0;
49
- _playingPromise = null;
50
- _rate = 1;
51
- _repeatCount = 1;
52
- _yoyoOn = !1;
53
- _paused = !1;
54
- _lastClock = void 0;
55
- constructor(e) {
56
- this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
57
- }
58
- get duration() {
59
- let e = 0;
60
- for (let t of this.entries) {
61
- let n = t.at + t.animation.options.duration;
62
- n > e && (e = n);
63
- }
64
- return e;
65
- }
66
- get time() {
67
- return this._time;
68
- }
69
- get progress() {
70
- return this.duration === 0 ? 0 : this._time / this.duration;
71
- }
72
- set progress(t) {
73
- this.seek(e(t, 0, 1) * this.duration);
74
- }
75
- get rate() {
76
- return this._rate;
77
- }
78
- label(e, t) {
79
- return this.labels.set(e, this.resolvePosition(t)), this;
80
- }
81
- on(e, t) {
82
- return this._events.subscribe(e, t);
83
- }
84
- add(e, t) {
85
- let n = this.resolvePosition(t);
86
- return this.entries.push({
87
- animation: e,
88
- at: n
89
- }), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this;
90
- }
91
- resolvePosition(e) {
92
- if (e === void 0) return this.cursor;
93
- if (typeof e == "number") return e;
94
- let t = /^([+-])=(\d*\.?\d+)$/.exec(e);
95
- if (t) {
96
- let e = t[1] === "+" ? 1 : -1;
97
- return this.cursor + e * Number.parseFloat(t[2]);
98
- }
99
- let n = this.labels.get(e);
100
- if (n === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
101
- return n;
102
- }
103
- seek(e) {
104
- return this._time = e, this._fireCrossings(e), this._applyAt(e), this;
105
- }
106
- _applyAt(t) {
107
- for (let { animation: n, at: r } of this.entries) {
108
- let i = e(t - r, 0, n.options.duration);
109
- n.interpFrames(i, !0);
110
- }
111
- }
112
- _fireCrossings(e) {
113
- this._events.fire(this.entries, this.labels, e);
114
- }
115
- _fold(t) {
116
- let n = this.duration;
117
- if (n <= 0) return 0;
118
- let r = e(t, 0, n * this._repeatCount), i = Math.floor(r / n), a = r - i * n;
119
- return a === 0 && i > 0 && (--i, a = n), this._yoyoOn && i % 2 == 1 ? n - a : a;
120
- }
121
- setTargets(...e) {
122
- for (let { animation: t } of this.entries) t.setTargets(...e);
123
- return this;
124
- }
125
- get finished() {
126
- return this._playingPromise ?? Promise.resolve();
127
- }
128
- play() {
129
- if (this._playingPromise) return this._playingPromise;
130
- if (this.respectReducedMotion && i()) return this.seek(this.duration), Promise.resolve();
131
- for (let { animation: e, at: t } of this.entries) e.startTime = t, e.started = !0, e.managed = !0;
132
- this._time = 0, this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0;
133
- let e = new Promise((e) => {
134
- this._resolvePlay = e, this.playback.loop(this._boundFrame);
135
- });
136
- return this._playingPromise = e, e.finally(() => {
137
- this._playingPromise = null;
138
- }), e;
139
- }
140
- async _frame(e) {
141
- this._playOrigin === void 0 && (this._playOrigin = this._rate === 0 ? e : e - this._time / this._rate), this._lastClock = e;
142
- let t = (e - this._playOrigin) * this._rate, n = this.duration * this._repeatCount, r = this._rate >= 0 ? t >= n : t <= 0, i = r ? this._rate >= 0 ? this._restPhase() : 0 : this._fold(t);
143
- if (this._time = i, this._isForwardMonotone()) for (let { animation: e, at: t } of this.entries) i >= t && i - t < e.options.duration && await e.advanceTo(i);
144
- if (this._fireCrossings(i), this._applyAt(i), r) {
145
- this._settle();
146
- let e = this._resolvePlay;
147
- return this._resolvePlay = null, e?.(), !1;
148
- }
149
- return !0;
150
- }
151
- _isForwardMonotone() {
152
- return this._rate === 1 && this._repeatCount === 1 && !this._yoyoOn;
153
- }
154
- _restPhase() {
155
- let e = this.duration;
156
- return this._yoyoOn && (this._repeatCount - 1) % 2 == 1 ? 0 : e;
157
- }
158
- _reanchor() {
159
- if (!this._playingPromise) return;
160
- let e = this._lastClock;
161
- if (e === void 0) {
162
- this._playOrigin = void 0;
163
- return;
164
- }
165
- this._playOrigin = this._rate === 0 ? e : e - this._time / this._rate;
166
- }
167
- _settle() {
168
- for (let { animation: e } of this.entries) e.managed = !1, e.started = !1, e.startTime = void 0;
169
- this._playOrigin = void 0, this._lastClock = void 0, this._paused = !1;
170
- }
171
- stop() {
172
- this.playback.stop(), this._settle();
173
- let e = this._resolvePlay;
174
- return this._resolvePlay = null, e?.(), this;
175
- }
176
- pause() {
177
- return !this._playingPromise || this._paused ? this : (this._paused = !0, this.playback.stop(), this._playOrigin = void 0, this);
178
- }
179
- resume() {
180
- return !this._playingPromise || !this._paused ? this : (this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0, this.playback.loop(this._boundFrame), this);
181
- }
182
- timeScale(e) {
183
- if (!Number.isFinite(e)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${e}.`);
184
- return this._rate = e, this._reanchor(), this;
185
- }
186
- reverse() {
187
- return this._rate = -this._rate, this._reanchor(), this;
188
- }
189
- repeat(e) {
190
- if (e !== Infinity && (!Number.isInteger(e) || e < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${e}.`);
191
- return this._repeatCount = e, this;
192
- }
193
- yoyo(e = !0) {
194
- return this._yoyoOn = e, this;
195
- }
196
- }, i = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
197
- //#endregion
198
- export { r as t };