@ssgoi/core 7.2.0 → 7.3.0-beta.2
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/dist/animation/animation.d.ts +21 -0
- package/dist/animation/animation.d.ts.map +1 -1
- package/dist/animation/host-animation.d.ts +28 -19
- package/dist/animation/host-animation.d.ts.map +1 -1
- package/dist/animation/multi-animation.d.ts +13 -2
- package/dist/animation/multi-animation.d.ts.map +1 -1
- package/dist/animation/web-animation.d.ts +76 -4
- package/dist/animation/web-animation.d.ts.map +1 -1
- package/dist/animation/web-presentation.d.ts +25 -0
- package/dist/animation/web-presentation.d.ts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1206 -1184
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +924 -631
- package/dist/{page-motion-MEazegOU.js → page-motion-CoPTk-Gd.js} +1 -1
- package/dist/{page-motion-DF3fFkOw.cjs → page-motion-Dhj3UfzO.cjs} +1 -1
- package/dist/provider-BLf6XeXT.js +291 -0
- package/dist/provider-JDtJ5Jzf.cjs +1 -0
- package/dist/retain-opacity-C5ajTKSI.cjs +1 -0
- package/dist/retain-opacity-ChyA_fg_.js +1142 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/motion-matching.d.ts +31 -0
- package/dist/runtime/motion-matching.d.ts.map +1 -0
- package/dist/runtime/timeline.d.ts +6 -2
- package/dist/runtime/timeline.d.ts.map +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +29 -25
- package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/transitions/blind/transition.d.ts.map +1 -1
- package/dist/transitions/crossfade.d.ts +1 -6
- package/dist/transitions/crossfade.d.ts.map +1 -1
- package/dist/transitions/film/transition.d.ts.map +1 -1
- package/dist/transitions/hero/in-place.d.ts +5 -2
- package/dist/transitions/hero/in-place.d.ts.map +1 -1
- package/dist/transitions/hero/provider/chrome/fade.d.ts.map +1 -1
- package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
- package/dist/transitions/hero/transition.d.ts.map +1 -1
- package/dist/transitions/hero/types.d.ts +2 -1
- package/dist/transitions/hero/types.d.ts.map +1 -1
- package/dist/transitions/shared-visibility.d.ts +2 -0
- package/dist/transitions/shared-visibility.d.ts.map +1 -0
- package/dist/transitions/sheet/transition.d.ts.map +1 -1
- package/dist/transitions/zoom/crossfade.d.ts.map +1 -1
- package/dist/transitions/zoom/provider/blur.d.ts.map +1 -1
- package/dist/transitions/zoom/transition.d.ts.map +1 -1
- package/dist/transitions/zoom/types.d.ts +2 -1
- package/dist/transitions/zoom/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/retain-opacity.d.ts +7 -0
- package/dist/utils/retain-opacity.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/multi-animation-Du9W3ZS_.js +0 -503
- package/dist/multi-animation-hDUcfD7W.cjs +0 -1
- package/dist/provider-Cea0Pfm1.js +0 -232
- package/dist/provider-D9Q2URox.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const S=require("./provider-
|
|
1
|
+
"use strict";const S=require("./provider-JDtJ5Jzf.cjs"),g={spring:{stiffness:180,damping:20,doubleSpring:!0}},c={spring:{stiffness:170,damping:20,doubleSpring:!0}},r={spring:{stiffness:170,damping:22,doubleSpring:.8}};function f(n,i=0){var e,a;const o=((e=n.integrator)==null?void 0:e.call(n))??S.IntegratorProvider.from(n),t=S.simulate(o,0,1,0);if(t.some(u=>!Number.isFinite(u.position)||!Number.isFinite(u.velocity)))throw new Error("SSGOI: physics produced a non-finite timeline.");return{frames:t,offset:i,duration:((a=t[t.length-1])==null?void 0:a.time)??0}}function d(n,i,o){const t=f(o??(n==="fade"?g:r)),e=f(o??(n==="fade"?c:r),n==="fade"?t.duration:0);return{kind:n,direction:i,out:t,in:e,duration:Math.max(t.duration,e.offset+e.duration)}}function s(n,i,o,t){"worklet";return n==="fade"?{opacity:i==="in"?t:1-t,x:0}:{opacity:1,x:(o==="forward"?1:-1)*(i==="in"?1-t:-t)}}exports.FADE_IN_PHYSICS=c;exports.FADE_OUT_PHYSICS=g;exports.SLIDE_PHYSICS=r;exports.createPageMotionPlan=d;exports.pageMotionStyle=s;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var I = (n, e, t) => e in n ? F(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var r = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
let N = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
/** Current playback rate (1 = realtime, 0 = paused, negative = backwards) */
|
|
7
|
+
r(this, "_playbackRate", 1);
|
|
8
|
+
/** Fired every frame with the most recent value. Optional. */
|
|
9
|
+
r(this, "onUpdate");
|
|
10
|
+
/** Fired once when the animation settles. */
|
|
11
|
+
r(this, "onComplete");
|
|
12
|
+
}
|
|
13
|
+
get playbackRate() {
|
|
14
|
+
return this._playbackRate;
|
|
15
|
+
}
|
|
16
|
+
set playbackRate(e) {
|
|
17
|
+
this._playbackRate = e;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const M = 0.01, T = 0.01, R = 0.05, S = 1e3 / 60;
|
|
21
|
+
function U(n, e, t, s, i, o = !1) {
|
|
22
|
+
if (e === t && s === 0 && (!i || n.isSettled(i, t)))
|
|
23
|
+
return [];
|
|
24
|
+
const l = 600;
|
|
25
|
+
let c = {
|
|
26
|
+
...i,
|
|
27
|
+
position: e,
|
|
28
|
+
velocity: s
|
|
29
|
+
}, p = 0;
|
|
30
|
+
const a = [];
|
|
31
|
+
for (let h = 0; h < l; h++) {
|
|
32
|
+
const d = h * S;
|
|
33
|
+
if (a.push({
|
|
34
|
+
time: d,
|
|
35
|
+
position: c.position,
|
|
36
|
+
velocity: c.velocity,
|
|
37
|
+
...o ? { state: c } : {}
|
|
38
|
+
}), c = n.step(c, t, S / 1e3), n.isSettled(c, t)) {
|
|
39
|
+
if (p += S / 1e3, p >= R) {
|
|
40
|
+
a.push({
|
|
41
|
+
time: (h + 1) * S,
|
|
42
|
+
position: t,
|
|
43
|
+
velocity: 0
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
} else
|
|
48
|
+
p = 0;
|
|
49
|
+
}
|
|
50
|
+
return a;
|
|
51
|
+
}
|
|
52
|
+
function x(n, e) {
|
|
53
|
+
"worklet";
|
|
54
|
+
if (n.length === 0) return { position: 0, velocity: 0 };
|
|
55
|
+
const t = n[0], s = n[n.length - 1];
|
|
56
|
+
if (e <= 0)
|
|
57
|
+
return { position: t.position, velocity: t.velocity };
|
|
58
|
+
if (e >= s.time)
|
|
59
|
+
return { position: s.position, velocity: s.velocity };
|
|
60
|
+
let i = 0, o = n.length - 1;
|
|
61
|
+
for (; i < o - 1; ) {
|
|
62
|
+
const a = i + o >> 1;
|
|
63
|
+
n[a].time <= e ? i = a : o = a;
|
|
64
|
+
}
|
|
65
|
+
const l = n[i], c = n[o], p = (e - l.time) / (c.time - l.time);
|
|
66
|
+
return {
|
|
67
|
+
position: l.position + (c.position - l.position) * p,
|
|
68
|
+
velocity: l.velocity + (c.velocity - l.velocity) * p
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function q(n, e, t, s) {
|
|
72
|
+
const i = x(n, e);
|
|
73
|
+
let o = n[0];
|
|
74
|
+
for (const p of n) {
|
|
75
|
+
if (p.time > e) break;
|
|
76
|
+
o = p;
|
|
77
|
+
}
|
|
78
|
+
if (!(o != null && o.state)) return i;
|
|
79
|
+
const l = Math.max(0, Math.min(1e3 / 60, e - o.time)) / 1e3;
|
|
80
|
+
return { ...l ? t.step(o.state, s, l) : o.state, ...i };
|
|
81
|
+
}
|
|
82
|
+
function z(n, e) {
|
|
83
|
+
const t = /* @__PURE__ */ new Set();
|
|
84
|
+
return e.map((s) => {
|
|
85
|
+
const i = (a) => a.role === s.role && a.space === s.space, o = n.filter(
|
|
86
|
+
(a) => a.target === s.target && i(a) && (a.key === void 0 || s.key === void 0 || a.key === s.key)
|
|
87
|
+
), l = o.length ? o : s.key === void 0 ? [] : n.filter(
|
|
88
|
+
(a) => a.key === s.key && i(a)
|
|
89
|
+
), c = e.filter(
|
|
90
|
+
(a) => a.role === s.role && a.space === s.space && (a.target === s.target || s.key !== void 0 && a.key === s.key)
|
|
91
|
+
).length > 1;
|
|
92
|
+
if (l.length > 1 || c || l[0] && t.has(l[0]))
|
|
93
|
+
return { next: s, reason: "ambiguous" };
|
|
94
|
+
const p = l[0];
|
|
95
|
+
return p ? (t.add(p), {
|
|
96
|
+
next: s,
|
|
97
|
+
previous: p,
|
|
98
|
+
reason: o.length ? "element" : "key"
|
|
99
|
+
}) : { next: s, reason: "enter" };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function B(n, e) {
|
|
103
|
+
return n.schema === e.schema && n.value.length === e.value.length && n.velocity.length === n.value.length && e.velocity.length === e.value.length && [...n.value, ...n.velocity, ...e.value, ...e.velocity].every(
|
|
104
|
+
Number.isFinite
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function V(n, e, t, s) {
|
|
108
|
+
if (!(s > 0) || t >= s)
|
|
109
|
+
return { value: 0, velocity: 0 };
|
|
110
|
+
const i = Math.max(0, t) / s, o = 2 * i ** 3 - 3 * i ** 2 + 1, l = i ** 3 - 2 * i ** 2 + i;
|
|
111
|
+
return {
|
|
112
|
+
value: o * n + l * s * e,
|
|
113
|
+
velocity: (6 * i ** 2 - 6 * i) * n / s + (3 * i ** 2 - 4 * i + 1) * e
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
class D {
|
|
117
|
+
constructor(e) {
|
|
118
|
+
r(this, "stiffness");
|
|
119
|
+
r(this, "damping");
|
|
120
|
+
r(this, "omega");
|
|
121
|
+
// Angular frequency
|
|
122
|
+
r(this, "zeta");
|
|
123
|
+
// Damping ratio
|
|
124
|
+
r(this, "restDelta");
|
|
125
|
+
r(this, "restSpeed");
|
|
126
|
+
const { stiffness: t, damping: s } = e, i = 1;
|
|
127
|
+
this.stiffness = t, this.damping = s, this.omega = Math.sqrt(t / i), this.zeta = s / (2 * Math.sqrt(t * i)), this.restDelta = e.restDelta ?? M, this.restSpeed = e.restSpeed ?? T;
|
|
128
|
+
}
|
|
129
|
+
step(e, t, s) {
|
|
130
|
+
const i = Math.min(s, 0.033), { omega: o, zeta: l } = this, { position: c, velocity: p } = e, a = -2 * i * l * o * p, h = i * o * o * (t - c), d = p + a + h;
|
|
131
|
+
return {
|
|
132
|
+
position: c + i * d,
|
|
133
|
+
velocity: d
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
isSettled(e, t) {
|
|
137
|
+
const s = Math.abs(t - e.position), i = Math.abs(e.velocity);
|
|
138
|
+
return s < this.restDelta && i < this.restSpeed;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
class A {
|
|
142
|
+
constructor(e) {
|
|
143
|
+
/** Leader spring values (the follower is derived; see `follower`). */
|
|
144
|
+
r(this, "stiffness");
|
|
145
|
+
r(this, "damping");
|
|
146
|
+
r(this, "leader");
|
|
147
|
+
r(this, "follower");
|
|
148
|
+
r(this, "restDelta");
|
|
149
|
+
r(this, "restSpeed");
|
|
150
|
+
this.stiffness = e.stiffness, this.damping = e.damping, this.restDelta = e.restDelta ?? M, this.restSpeed = e.restSpeed ?? T, this.leader = new D({
|
|
151
|
+
stiffness: e.stiffness,
|
|
152
|
+
damping: e.damping,
|
|
153
|
+
restDelta: this.restDelta,
|
|
154
|
+
restSpeed: this.restSpeed
|
|
155
|
+
});
|
|
156
|
+
let t, s, i, o;
|
|
157
|
+
typeof e.follower == "number" ? (t = e.stiffness * e.follower, s = e.damping) : e.follower ? (t = e.follower.stiffness, s = e.follower.damping, i = e.follower.restDelta, o = e.follower.restSpeed) : (t = e.stiffness, s = e.damping), this.follower = new D({
|
|
158
|
+
stiffness: t,
|
|
159
|
+
damping: s,
|
|
160
|
+
restDelta: i ?? this.restDelta,
|
|
161
|
+
restSpeed: o ?? this.restSpeed
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
step(e, t, s) {
|
|
165
|
+
const o = e._leader ?? {
|
|
166
|
+
position: e.position,
|
|
167
|
+
velocity: e.velocity
|
|
168
|
+
}, l = this.leader.step(o, t, s), c = this.follower.step(
|
|
169
|
+
e,
|
|
170
|
+
l.position,
|
|
171
|
+
s
|
|
172
|
+
);
|
|
173
|
+
return {
|
|
174
|
+
position: c.position,
|
|
175
|
+
velocity: c.velocity,
|
|
176
|
+
_leader: l
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
isSettled(e, t) {
|
|
180
|
+
const s = e, i = Math.abs(t - e.position) < this.restDelta && Math.abs(e.velocity) < this.restSpeed;
|
|
181
|
+
return s._leader ? Math.abs(t - s._leader.position) < this.restDelta && Math.abs(s._leader.velocity) < this.restSpeed && i : i;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const O = 0.01, L = 500, g = 10;
|
|
185
|
+
class H {
|
|
186
|
+
constructor(e) {
|
|
187
|
+
r(this, "acceleration");
|
|
188
|
+
r(this, "resistance");
|
|
189
|
+
r(this, "resistanceType");
|
|
190
|
+
r(this, "min");
|
|
191
|
+
r(this, "max");
|
|
192
|
+
r(this, "bounceStiffness");
|
|
193
|
+
r(this, "bounceDamping");
|
|
194
|
+
r(this, "restDelta");
|
|
195
|
+
this.acceleration = e.acceleration, this.resistance = e.resistance, this.resistanceType = e.resistanceType ?? "quadratic", this.min = e.min, this.max = e.max, this.bounceStiffness = e.bounceStiffness ?? L, this.bounceDamping = e.bounceDamping ?? g, this.restDelta = e.restDelta ?? O;
|
|
196
|
+
}
|
|
197
|
+
step(e, t, s) {
|
|
198
|
+
const i = Math.min(s, 0.033), { acceleration: o, resistance: l, resistanceType: c, min: p, max: a } = this, { position: h, velocity: d } = e, y = p !== void 0 && h < p, b = a !== void 0 && h > a;
|
|
199
|
+
let v;
|
|
200
|
+
if (y || b) {
|
|
201
|
+
const f = h - (y ? p : a), _ = -this.bounceStiffness * f, E = -this.bounceDamping * d;
|
|
202
|
+
v = _ + E;
|
|
203
|
+
} else {
|
|
204
|
+
const u = t > h ? 1 : -1;
|
|
205
|
+
let f;
|
|
206
|
+
c === "linear" ? f = l * d : f = l * d * Math.abs(d), v = u * o - f;
|
|
207
|
+
}
|
|
208
|
+
const w = d + v * i;
|
|
209
|
+
let m = h + w * i;
|
|
210
|
+
if (!y && !b) {
|
|
211
|
+
const u = t > h ? 1 : -1;
|
|
212
|
+
(u > 0 && m > t || u < 0 && m < t) && (m = t);
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
position: m,
|
|
216
|
+
velocity: m === t ? 0 : w
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
isSettled(e, t) {
|
|
220
|
+
return Math.abs(t - e.position) < this.restDelta;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
class k {
|
|
224
|
+
/**
|
|
225
|
+
* Create an Integrator from physics config
|
|
226
|
+
*
|
|
227
|
+
* @param config Physics configuration (spring or inertia)
|
|
228
|
+
* @returns Appropriate Integrator instance
|
|
229
|
+
* @throws Error if both spring and inertia are provided
|
|
230
|
+
*/
|
|
231
|
+
static from(e) {
|
|
232
|
+
if (e.spring && e.inertia)
|
|
233
|
+
throw new Error(
|
|
234
|
+
"Cannot use both 'spring' and 'inertia' together. Choose one physics type."
|
|
235
|
+
);
|
|
236
|
+
if (e.inertia)
|
|
237
|
+
return new H({
|
|
238
|
+
acceleration: e.inertia.acceleration,
|
|
239
|
+
resistance: e.inertia.resistance,
|
|
240
|
+
resistanceType: e.inertia.resistanceType,
|
|
241
|
+
min: e.inertia.min,
|
|
242
|
+
max: e.inertia.max,
|
|
243
|
+
bounceStiffness: e.inertia.bounceStiffness,
|
|
244
|
+
bounceDamping: e.inertia.bounceDamping,
|
|
245
|
+
restDelta: e.inertia.restDelta
|
|
246
|
+
});
|
|
247
|
+
const t = e.spring ?? { stiffness: 300, damping: 30 };
|
|
248
|
+
if (t.doubleSpring) {
|
|
249
|
+
const s = t.doubleSpring;
|
|
250
|
+
let i;
|
|
251
|
+
return typeof s == "number" ? i = s : typeof s == "object" && (i = {
|
|
252
|
+
stiffness: s.stiffness,
|
|
253
|
+
damping: s.damping
|
|
254
|
+
}), new A({
|
|
255
|
+
stiffness: t.stiffness,
|
|
256
|
+
damping: t.damping,
|
|
257
|
+
follower: i,
|
|
258
|
+
restDelta: t.restDelta,
|
|
259
|
+
restSpeed: t.restSpeed
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return new D({
|
|
263
|
+
stiffness: t.stiffness,
|
|
264
|
+
damping: t.damping,
|
|
265
|
+
restDelta: t.restDelta,
|
|
266
|
+
restSpeed: t.restSpeed
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Create an Integrator from SpringConfig (legacy support)
|
|
271
|
+
* @deprecated Use from({ spring: config }) instead
|
|
272
|
+
*/
|
|
273
|
+
static fromSpring(e) {
|
|
274
|
+
return k.from({ spring: e });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
N as A,
|
|
279
|
+
A as D,
|
|
280
|
+
k as I,
|
|
281
|
+
M as P,
|
|
282
|
+
D as S,
|
|
283
|
+
U as a,
|
|
284
|
+
R as b,
|
|
285
|
+
B as c,
|
|
286
|
+
H as d,
|
|
287
|
+
x as i,
|
|
288
|
+
z as m,
|
|
289
|
+
V as r,
|
|
290
|
+
q as s
|
|
291
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var O=Object.defineProperty;var A=(n,e,t)=>e in n?O(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>A(n,typeof e!="symbol"?e+"":e,t);let L=class{constructor(){a(this,"_playbackRate",1);a(this,"onUpdate");a(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e}};const b=.01,E=.01,I=.05,S=1e3/60;function x(n,e,t,s,i,o=!1){if(e===t&&s===0&&(!i||n.isSettled(i,t)))return[];const l=600;let c={...i,position:e,velocity:s},p=0;const r=[];for(let h=0;h<l;h++){const m=h*S;if(r.push({time:m,position:c.position,velocity:c.velocity,...o?{state:c}:{}}),c=n.step(c,t,S/1e3),n.isSettled(c,t)){if(p+=S/1e3,p>=I){r.push({time:(h+1)*S,position:t,velocity:0});break}}else p=0}return r}function _(n,e){"worklet";if(n.length===0)return{position:0,velocity:0};const t=n[0],s=n[n.length-1];if(e<=0)return{position:t.position,velocity:t.velocity};if(e>=s.time)return{position:s.position,velocity:s.velocity};let i=0,o=n.length-1;for(;i<o-1;){const r=i+o>>1;n[r].time<=e?i=r:o=r}const l=n[i],c=n[o],p=(e-l.time)/(c.time-l.time);return{position:l.position+(c.position-l.position)*p,velocity:l.velocity+(c.velocity-l.velocity)*p}}function H(n,e,t,s){const i=_(n,e);let o=n[0];for(const p of n){if(p.time>e)break;o=p}if(!(o!=null&&o.state))return i;const l=Math.max(0,Math.min(1e3/60,e-o.time))/1e3;return{...l?t.step(o.state,s,l):o.state,...i}}function C(n,e){const t=new Set;return e.map(s=>{const i=r=>r.role===s.role&&r.space===s.space,o=n.filter(r=>r.target===s.target&&i(r)&&(r.key===void 0||s.key===void 0||r.key===s.key)),l=o.length?o:s.key===void 0?[]:n.filter(r=>r.key===s.key&&i(r)),c=e.filter(r=>r.role===s.role&&r.space===s.space&&(r.target===s.target||s.key!==void 0&&r.key===s.key)).length>1;if(l.length>1||c||l[0]&&t.has(l[0]))return{next:s,reason:"ambiguous"};const p=l[0];return p?(t.add(p),{next:s,previous:p,reason:o.length?"element":"key"}):{next:s,reason:"enter"}})}function N(n,e){return n.schema===e.schema&&n.value.length===e.value.length&&n.velocity.length===n.value.length&&e.velocity.length===e.value.length&&[...n.value,...n.velocity,...e.value,...e.velocity].every(Number.isFinite)}function P(n,e,t,s){if(!(s>0)||t>=s)return{value:0,velocity:0};const i=Math.max(0,t)/s,o=2*i**3-3*i**2+1,l=i**3-2*i**2+i;return{value:o*n+l*s*e,velocity:(6*i**2-6*i)*n/s+(3*i**2-4*i+1)*e}}class v{constructor(e){a(this,"stiffness");a(this,"damping");a(this,"omega");a(this,"zeta");a(this,"restDelta");a(this,"restSpeed");const{stiffness:t,damping:s}=e,i=1;this.stiffness=t,this.damping=s,this.omega=Math.sqrt(t/i),this.zeta=s/(2*Math.sqrt(t*i)),this.restDelta=e.restDelta??b,this.restSpeed=e.restSpeed??E}step(e,t,s){const i=Math.min(s,.033),{omega:o,zeta:l}=this,{position:c,velocity:p}=e,r=-2*i*l*o*p,h=i*o*o*(t-c),m=p+r+h;return{position:c+i*m,velocity:m}}isSettled(e,t){const s=Math.abs(t-e.position),i=Math.abs(e.velocity);return s<this.restDelta&&i<this.restSpeed}}class k{constructor(e){a(this,"stiffness");a(this,"damping");a(this,"leader");a(this,"follower");a(this,"restDelta");a(this,"restSpeed");this.stiffness=e.stiffness,this.damping=e.damping,this.restDelta=e.restDelta??b,this.restSpeed=e.restSpeed??E,this.leader=new v({stiffness:e.stiffness,damping:e.damping,restDelta:this.restDelta,restSpeed:this.restSpeed});let t,s,i,o;typeof e.follower=="number"?(t=e.stiffness*e.follower,s=e.damping):e.follower?(t=e.follower.stiffness,s=e.follower.damping,i=e.follower.restDelta,o=e.follower.restSpeed):(t=e.stiffness,s=e.damping),this.follower=new v({stiffness:t,damping:s,restDelta:i??this.restDelta,restSpeed:o??this.restSpeed})}step(e,t,s){const o=e._leader??{position:e.position,velocity:e.velocity},l=this.leader.step(o,t,s),c=this.follower.step(e,l.position,s);return{position:c.position,velocity:c.velocity,_leader:l}}isSettled(e,t){const s=e,i=Math.abs(t-e.position)<this.restDelta&&Math.abs(e.velocity)<this.restSpeed;return s._leader?Math.abs(t-s._leader.position)<this.restDelta&&Math.abs(s._leader.velocity)<this.restSpeed&&i:i}}const U=.01,q=500,z=10;class g{constructor(e){a(this,"acceleration");a(this,"resistance");a(this,"resistanceType");a(this,"min");a(this,"max");a(this,"bounceStiffness");a(this,"bounceDamping");a(this,"restDelta");this.acceleration=e.acceleration,this.resistance=e.resistance,this.resistanceType=e.resistanceType??"quadratic",this.min=e.min,this.max=e.max,this.bounceStiffness=e.bounceStiffness??q,this.bounceDamping=e.bounceDamping??z,this.restDelta=e.restDelta??U}step(e,t,s){const i=Math.min(s,.033),{acceleration:o,resistance:l,resistanceType:c,min:p,max:r}=this,{position:h,velocity:m}=e,y=p!==void 0&&h<p,T=r!==void 0&&h>r;let D;if(y||T){const f=h-(y?p:r),F=-this.bounceStiffness*f,R=-this.bounceDamping*m;D=F+R}else{const u=t>h?1:-1;let f;c==="linear"?f=l*m:f=l*m*Math.abs(m),D=u*o-f}const M=m+D*i;let d=h+M*i;if(!y&&!T){const u=t>h?1:-1;(u>0&&d>t||u<0&&d<t)&&(d=t)}return{position:d,velocity:d===t?0:M}}isSettled(e,t){return Math.abs(t-e.position)<this.restDelta}}class w{static from(e){if(e.spring&&e.inertia)throw new Error("Cannot use both 'spring' and 'inertia' together. Choose one physics type.");if(e.inertia)return new g({acceleration:e.inertia.acceleration,resistance:e.inertia.resistance,resistanceType:e.inertia.resistanceType,min:e.inertia.min,max:e.inertia.max,bounceStiffness:e.inertia.bounceStiffness,bounceDamping:e.inertia.bounceDamping,restDelta:e.inertia.restDelta});const t=e.spring??{stiffness:300,damping:30};if(t.doubleSpring){const s=t.doubleSpring;let i;return typeof s=="number"?i=s:typeof s=="object"&&(i={stiffness:s.stiffness,damping:s.damping}),new k({stiffness:t.stiffness,damping:t.damping,follower:i,restDelta:t.restDelta,restSpeed:t.restSpeed})}return new v({stiffness:t.stiffness,damping:t.damping,restDelta:t.restDelta,restSpeed:t.restSpeed})}static fromSpring(e){return w.from({spring:e})}}exports.Animation=L;exports.DoubleSpringIntegrator=k;exports.InertiaIntegrator=g;exports.IntegratorProvider=w;exports.POSITION_THRESHOLD=b;exports.SETTLE_THRESHOLD=I;exports.SpringIntegrator=v;exports.compatibleChannel=N;exports.interpolateFrame=_;exports.matchMotion=C;exports.residualAt=P;exports.sampleIntegratorState=H;exports.simulate=x;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ht=Object.defineProperty;var ct=(s,r,t)=>r in s?ht(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var h=(s,r,t)=>ct(s,typeof r!="symbol"?r+"":r,t);const A=require("./provider-JDtJ5Jzf.cjs"),x={reason:"finished",owns:()=>!0};class Z extends A.Animation{constructor(){super(...arguments);h(this,"_startCondition");h(this,"onDispose");h(this,"deferDisposal",!1)}getMotionTracks(){return[]}validate(){}get supportsInterruption(){return!1}stop(){this.pause()}cancel(t){var e;this.isComplete||this.complete(),(e=this.onDispose)==null||e.call(this,t)}get startCondition(){return this._startCondition}set(t){if(t.startAt){const{after:e,at:i}=t.startAt;if(e===this)throw new Error("An animation cannot start after itself");if(i!=="settled"&&(!Number.isFinite(i)||i<0||i>1))throw new Error("startAt.at must be a progress from 0 to 1 or settled")}if(t.integrator!==void 0){if(typeof t.integrator.step!="function"||typeof t.integrator.isSettled!="function")throw new Error("An integrator must implement step and isSettled");this.setIntegrator(t.integrator)}return t.startAt!==void 0&&(this._startCondition=t.startAt?{...t.startAt}:void 0),this}setIntegrator(t){throw new Error("This animation does not support replacing its integrator")}}const U=[1,0,0,1,0,0],nt=(s,r)=>[s[0]*r[0]+s[2]*r[1],s[1]*r[0]+s[3]*r[1],s[0]*r[2]+s[2]*r[3],s[1]*r[2]+s[3]*r[3],s[0]*r[4]+s[2]*r[5]+s[4],s[1]*r[4]+s[3]*r[5]+s[5]];function tt(s){const r=s[0]*s[3]-s[1]*s[2];return Math.abs(r)<1e-10?null:[s[3]/r,-s[1]/r,-s[2]/r,s[0]/r,(s[2]*s[5]-s[3]*s[4])/r,(s[1]*s[4]-s[0]*s[5])/r]}const B=(s,r)=>[1,0,0,1,s,r],K=(s,r)=>[s,0,0,r,0,0];function ut(s,r,t){if(!s||s==="none")return[...U];let e=[...U];const i=/([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;let a="";for(const c of s.matchAll(i)){a+=c[0];const d=c[1].toLowerCase(),u=c[2].trim().split(/\s*,\s*|\s+/);if(u.some(n=>!/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(n)))return null;const m=u.map(Number.parseFloat);if(m.some(n=>!Number.isFinite(n)))return null;const g=(n,y)=>{var o;return m[n]*((o=u[n])!=null&&o.endsWith("%")?y/100:1)},p=n=>{var y,o;return m[n]*((y=u[n])!=null&&y.endsWith("rad")?1:(o=u[n])!=null&&o.endsWith("turn")?2*Math.PI:Math.PI/180)};let l;if(d==="matrix"&&m.length===6)l=m;else if(d==="translate"||d==="translate3d"){if(d==="translate3d"&&m[2]!==0)return null;l=B(g(0,r),u[1]?g(1,t):0)}else if(d==="translatex")l=B(g(0,r),0);else if(d==="translatey")l=B(0,g(0,t));else if(d==="translatez"&&m[0]===0)l=[...U];else if(d==="scale")l=K(m[0],m[1]??m[0]);else if(d==="scalex")l=K(m[0],1);else if(d==="scaley")l=K(1,m[0]);else if(d==="rotate"||d==="rotatez"){const n=p(0);l=[Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]}else return null;e=nt(e,l)}return a.replace(/\s/g,"")===s.replace(/\s/g,"")?e:null}function et(s,r){return{schema:s,value:r,velocity:r.map(()=>0)}}const st=/[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi,M=s=>[s[0],s[2],s[4],s[1],s[3],s[5],0,0,1];function O(s,r){return Array.from({length:9},(t,e)=>{const i=Math.floor(e/3),a=e%3;return s[i*3]*r[a]+s[i*3+1]*r[a+3]+s[i*3+2]*r[a+6]})}function at(s){return Math.abs(s[8])<1e-8||!s.every(Number.isFinite)?null:s.map(r=>r/s[8])}function it(s,r,t){const e=ut(s,r,t);if(e)return M(e);if(typeof DOMMatrix>"u")return null;const i=s.replace(/(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,(a,c,d)=>{const u=d.split(/\s*,\s*|\s+/).map((m,g)=>{if(!m.endsWith("%"))return m;const p=c.toLowerCase()==="translatey"||g===1?t:r;return`${Number.parseFloat(m)*p/100}px`});return`${c}(${u.join(",")})`});try{const a=new DOMMatrix(i);return at([a.m11,a.m21,a.m41,a.m12,a.m22,a.m42,a.m14,a.m24,a.m44])}catch{return null}}const rt="viewport-plane-v1";function N(s){var w;const r=s.offsetWidth||1,t=s.offsetHeight||1,e=typeof getComputedStyle=="function"?getComputedStyle(s):null,i=((e==null?void 0:e.transformOrigin)||`${r/2}px ${t/2}px`).split(" "),a=Number.parseFloat(i[0])||0,c=Number.parseFloat(i[1])||0;let d=!0;if(typeof getComputedStyle=="function")for(let C=s.parentElement;C;C=C.parentElement){const S=getComputedStyle(C);if(S.transform&&S.transform!=="none"||S.perspective&&S.perspective!=="none"){d=!1;break}}const u=(w=s.getBoundingClientRect)==null?void 0:w.call(s),m=it((e==null?void 0:e.transform)||"",r,t)??M(U),g=O(O(M(B(a,c)),m),M(B(-a,-c))),p=[[0,0],[r,0],[0,t],[r,t]].map(([C,S])=>{const F=g[6]*C+g[7]*S+g[8];return[(g[0]*C+g[1]*S+g[2])/F,(g[3]*C+g[4]*S+g[5])/F]}),l=((u==null?void 0:u.left)??0)-Math.min(...p.map(C=>C[0])),n=((u==null?void 0:u.top)??0)-Math.min(...p.map(C=>C[1])),y=B(l+a,n+c),o=nt(B(-a,-c),K(r,t)),f=M(tt(y)),b=M(tt(o));return{frame:d?{left:l,top:n,width:r,height:t}:void 0,read(C){const S={};for(const[F,_]of Object.entries(C)){const k=String(_);if(F==="transform"){if(!d)continue;const T=it(k,r,t),V=T&&at(O(O(M(y),T),M(o)));if(V){const[W,z,P,E,D,I,j,v]=V,L=W-P*j,$=E-I*j,J=z-P*v,Q=D-I*v,H=Math.hypot(L,$);if(H>1e-8){S[F]=et(rt,[P,I,Math.atan2($,L),H,(L*Q-$*J)/H,(L*J+$*Q)/H,j,v]);continue}}}const R=[...k.matchAll(st)].map(T=>Number(T[0]));R.length&&R.every(Number.isFinite)&&(S[F]=et(`css:${k.replace(st,"#")}`,R))}return S},write(C){const S={};for(const[F,_]of Object.entries(C))if(F==="transform"&&_.schema===rt){const[k,R,T,V,W,z,P,E]=_.value,D=Math.cos(T),I=Math.sin(T),j=[D*V+k*P,D*z-I*W+k*E,k,I*V+R*P,I*z+D*W+R*E,R,P,E,1],v=O(O(f,j),b);Math.abs(v[6])+Math.abs(v[7])<1e-10&&Math.abs(v[8]-1)<1e-10?S[F]=`matrix(${[v[0],v[3],v[1],v[4],v[2],v[5]].join(",")})`:S[F]=`matrix3d(${[v[0],v[3],0,v[6],v[1],v[4],0,v[7],0,0,1,0,v[2],v[5],0,v[8]].join(",")})`}else if(_.schema.startsWith("css:")){let k=0;S[F]=_.schema.slice(4).replace(/#/g,()=>String(_.value[k++]))}return S}}}const dt=1e3/60,ot=1e3/30,pt=ot+1;class ft{constructor(){h(this,"drivers",new Set);h(this,"observers",new Set);h(this,"frameRequest",null);h(this,"previousTimestamp",null);h(this,"tick",r=>{this.frameRequest=null;const t=this.previousTimestamp===null?dt:Math.max(0,r-this.previousTimestamp);this.previousTimestamp=r;const e={delta:Math.min(t,ot),rawDelta:t};this.runPhase(this.drivers,e),this.runPhase(this.observers,e),this.hasCallbacks()?this.requestFrame():this.previousTimestamp=null})}subscribe(r,t="drive"){const e=t==="drive"?this.drivers:this.observers;return e.add(r),this.requestFrame(),()=>{e.delete(r),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||!this.hasCallbacks()||(this.frameRequest=requestAnimationFrame(this.tick))}runPhase(r,t){for(const e of[...r])r.has(e)&&e(t)}hasCallbacks(){return this.drivers.size>0||this.observers.size>0}stopIfIdle(){this.hasCallbacks()||(this.frameRequest!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameRequest),this.frameRequest=null,this.previousTimestamp=null)}}const lt=new ft,mt=2;class Y extends Z{constructor(t){super();h(this,"_element");h(this,"_integrator");h(this,"label");h(this,"styleFn");h(this,"lowerBound");h(this,"upperBound");h(this,"currentValue");h(this,"currentVelocity",0);h(this,"solverState");h(this,"solverTarget",1);h(this,"presentationTime",0);h(this,"renderedStyles",[]);h(this,"frames",[]);h(this,"waapi",null);h(this,"runId",0);h(this,"waitingForStart",!1);h(this,"startReady",!1);h(this,"pendingFirstFrame");h(this,"stopStartupClock",null);h(this,"startupStableFrames",0);h(this,"running",!1);h(this,"paused",!1);h(this,"settled",!1);h(this,"reversing",!1);h(this,"disposed",!1);h(this,"legacyCompletionCleanup");h(this,"motion");h(this,"codec");h(this,"adopted");h(this,"presentationFrames",[]);h(this,"hold",null);h(this,"fallbackCopy",null);h(this,"fallbackChannels",new Set);h(this,"fallbackMode");this._element=t.element,this._integrator=t.integrator,this.label=t.label,this.styleFn=t.style,this.lowerBound=t.lowerBound??0,this.upperBound=t.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=t.onUpdate,this.legacyCompletionCleanup=!!t.onComplete&&!t.onDispose,this.onComplete=t.onComplete,this.onDispose=t.onDispose,this.motion=t.motion??{}}get handoffFallbackMode(){return this.fallbackMode}get handoffFallbacks(){return[...this.fallbackChannels]}get element(){return this._element}get integrator(){return this._integrator}set integrator(t){this._integrator=t,this.solverState=void 0}setIntegrator(t){this._integrator=t,this.solverState=void 0}play(){var e;const t=this.reversing;if(this.reversing=!1,this.paused&&this.waapi&&!t){if(this.paused=!1,this.running=!0,this.waitingForStart){this.startReady&&this.startFramePacedPlayback(this.waapi);return}this.waapi.play(),(e=this.fallbackCopy)==null||e.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e,i;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),(e=this.fallbackCopy)==null||e.pause(),(i=this.stopStartupClock)==null||i.call(this),this.stopStartupClock=null,this.running=!1,this.paused=!0)}complete(){this.settled||(this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,this.finish())}validate(){const t=this.motion.handoffDuration??280;if(!Number.isFinite(t)||t<0||t>1e4)throw new Error("handoffDuration must be finite and between 0 and 10000 ms")}getMotionTracks(){return[this]}get supportsInterruption(){return!this.legacyCompletionCleanup}stop(){var t,e;this.captureLiveState(),this.clearWaapi(),(t=this.hold)==null||t.cancel(),this.hold=null,(e=this.fallbackCopy)==null||e.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.running=!1,this.paused=!1}cancel(t){this.stop(),this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed&&(this.disposed=!0,t.owns(this.element)))try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] animation cleanup failed",i)}}finish(){var t,e,i,a;this.presentationTime=((t=this.frames[this.frames.length-1])==null?void 0:t.time)??0,this.solverState=void 0,(e=this.hold)==null||e.cancel(),this.hold=null,this.applyStyleAt(this.currentValue),this.clearWaapi(),(i=this.fallbackCopy)==null||i.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.deferDisposal||this.disposeResources(x),(a=this.onComplete)==null||a.call(this)}get motionIdentity(){return{target:this.element,key:this.motion.key,role:this.motion.role,space:this.motion.space,lifetime:this.motion.lifetime}}getMotionSnapshot(){var a,c;this.running&&this.captureLiveState();const t=this.samplePresentation(q(this.waapi)??this.presentationTime),e=this.paused||this.waitingForStart&&!q(this.waapi)?0:this.playbackRate,i={...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),...(a=this.codec)==null?void 0:a.write(t)};return{...this.motionIdentity,displayStyle:i,inlineStyle:this.element.style.cssText,frame:(c=this.codec)==null?void 0:c.frame,channels:Object.fromEntries(Object.entries(t).map(([d,u])=>[d,{...u,velocity:u.velocity.map(m=>m*e)}]))}}adopt(t){var d,u,m,g,p;this.codec??(this.codec=this.motion.codec??N(this.element)),this.adopted=t;const e=this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)});this.fallbackChannels.clear(),this.fallbackMode=void 0;const i=this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),a=t.displayStyle;for(const[l,n]of Object.entries(a??{}))l in i&&String(n)!==String(i[l])&&(!t.channels[l]||!e[l])&&this.fallbackChannels.add(l);for(const[l,n]of Object.entries(t.channels)){const y=e[l];y&&!A.compatibleChannel(n,y)&&this.fallbackChannels.add(l)}if(this.fallbackChannels.size&&(this.fallbackMode="finish"),this.fallbackChannels.size&&this.motion.fallback!=="finish"){const l=t;if(l.frame&&l.displayStyle&&t.target.cloneNode&&t.target.parentElement&&!t.target.shadowRoot&&!((u=(d=t.target).matches)!=null&&u.call(d,"canvas, video, audio, iframe, object, embed"))&&!((g=(m=t.target).querySelector)!=null&&g.call(m,"canvas, video, audio, iframe, object, embed"))){this.fallbackMode="crossfade";const n=t.target.cloneNode(!0);n.removeAttribute("id"),n.removeAttribute("data-ssgoi-transition");for(const o of n.querySelectorAll("[id], [data-ssgoi-transition]"))o.removeAttribute("id"),o.removeAttribute("data-ssgoi-transition");n.style.cssText=l.inlineStyle??"",Object.assign(n.style,l.displayStyle,{position:"fixed",left:`${l.frame.left}px`,top:`${l.frame.top}px`,width:`${l.frame.width}px`,height:`${l.frame.height}px`,margin:"0",pointerEvents:"none",zIndex:"2147483646"}),n.setAttribute("aria-hidden","true"),n.inert=!0,t.target.parentElement.appendChild(n);const y=Number(l.displayStyle.opacity??1);this.fallbackCopy=new Y({element:n,integrator:{step:(o,f,b)=>({position:Math.min(f,o.position+b/.18),velocity:0}),isSettled:(o,f)=>o.position>=f},style:(o,f)=>({opacity:y*f}),onDispose:()=>n.remove()}),this.adopted={...t,channels:{...t.channels,opacity:{schema:"css:#",value:[0],velocity:[0]}}}}}const c=this.codec.write(this.adopted.channels);(p=this.hold)==null||p.cancel(),Object.keys(c).length&&(this.hold=this.element.animate([c],{duration:1,fill:"both"}),this.hold.pause(),this.hold.currentTime=0)}channelsAt(t){const e=this.presentationFrames[t];if(e)return e.channels;const i=this.frames[t];return this.codec??(this.codec=this.motion.codec??N(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(i.position,this.lowerBound+this.upperBound-i.position)})}samplePresentation(t){const e=this.frames;if(!e.length)return this.adopted?{...this.adopted.channels}:(this.codec??(this.codec=this.motion.codec??N(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)}));let i=e.findIndex(n=>n.time>t);i<0&&(i=e.length-1);const a=Math.max(0,i-1),c=e[a],d=e[i],u=this.channelsAt(a),m=a===i?u:this.channelsAt(i),g=(d.time-c.time)/1e3,p=g?Math.max(0,Math.min(1,(t-c.time)/(g*1e3))):0,l={};for(const[n,y]of Object.entries(u)){const o=m[n];if(!o||!A.compatibleChannel(y,o)){l[n]=y;continue}l[n]={schema:y.schema,value:y.value.map((f,b)=>f+(o.value[b]-f)*p),velocity:y.value.map((f,b)=>t>=e[e.length-1].time||!g?0:(o.value[b]-f)/g)}}return l}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const i of this.frames)if((i.position-this.lowerBound)/e>=t)return i.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this._element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map((e,i)=>{const a=e.position,c=this.lowerBound+this.upperBound-a;return{time:e.time,value:e.position,velocity:e.velocity,style:this.renderedStyles[i]??this.styleFn(a,c)}});return[{element:this._element,frames:t}]}matchInto(t){const e=t.find(i=>i.element===this._element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity,this.solverState=void 0)}runToward(t){var m,g;if(this.validate(),this.running||this.paused){const p=this.getMotionSnapshot();this.captureLiveState(),this.adopted=p}if(this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.disposed=!1,this.presentationTime=0,this.presentationFrames=[],this.solverTarget=t,this.frames=A.simulate(this._integrator,this.currentValue,t,this.currentVelocity,this.solverState,!0),this.frames.length===0&&this.adopted&&(this.frames=[{time:0,position:t,velocity:0}]),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,this.finish();return}const e=p=>this.styleFn(p.position,this.lowerBound+this.upperBound-p.position),i=this.adopted?this.bridgeKeyframes(e):this.frames.map(p=>e(p));this.renderedStyles=i,this.adopted=void 0;const a=i[0],c=this.frames[this.frames.length-1],d=c.time;this.runId++;const u=this._element.animate(i,{duration:d,fill:"both",easing:"linear",composite:"replace"});u.playbackRate=this.playbackRate,u.currentTime=0,u.pause(),this.waapi=u,(m=this.fallbackCopy)==null||m.play(),(g=this.hold)==null||g.cancel(),this.hold=null,this.waitingForStart=!0,this.startReady=!0,this.pendingFirstFrame=a,this.running=!0,u.onfinish=()=>{!this.running||this.waapi!==u||(this.running=!1,this.settled=!0,this.currentValue=c.position,this.currentVelocity=0,this.finish())},this.startFramePacedPlayback(u)}bridgeKeyframes(t){var g;this.codec=this.motion.codec??N(this.element);const e=this.codec,i=Math.max(16,this.motion.handoffDuration??280),a=this.frames[this.frames.length-1];for(let p=a.time+1e3/60;p<i+1e3/60;p+=1e3/60)this.frames.push({time:p,position:a.position,velocity:0});const c=this.frames.map(p=>e.read({transform:"none",opacity:1,...t(p)}));for(let p=1;p<c.length;p++){const l=c[p-1].transform,n=c[p].transform;if((l==null?void 0:l.schema)==="viewport-plane-v1"&&(n==null?void 0:n.schema)===l.schema){const y=[...n.value];y[2]=l.value[2]+Math.atan2(Math.sin(y[2]-l.value[2]),Math.cos(y[2]-l.value[2])),c[p].transform={...n,value:y}}}const d=c[0],u=c[1]??d,m={};for(const[p,l]of Object.entries(((g=this.adopted)==null?void 0:g.channels)??{})){let n=d[p];if(!n){const o=p==="transform"?{transform:"none"}:p==="opacity"?{opacity:1}:{};if(n=e.read(o)[p],n)for(const f of c)f[p]=n}if(!n||!A.compatibleChannel(l,n))continue;const y=u[p]??n;m[p]={offset:l.value.map((o,f)=>{let b=o-n.value[f];return p==="transform"&&l.schema==="viewport-plane-v1"&&f===2&&(b=Math.atan2(Math.sin(b),Math.cos(b))),b}),velocity:l.velocity.map((o,f)=>o/Math.max(Math.abs(this.playbackRate),1e-4)-(y.value[f]-n.value[f])*60)}}return this.presentationFrames=this.frames.map((p,l)=>{const n={...c[l]};for(const[y,o]of Object.entries(m)){const f=n[y];n[y]={...f,value:f.value.map((b,w)=>b+A.residualAt(o.offset[w],o.velocity[w],p.time/1e3,i/1e3).value)}}return{time:p.time,channels:n}}),this.frames.map((p,l)=>{const n=this.presentationFrames[l].channels;return{...t(p),...e.write(Object.fromEntries(Object.keys(m).map(y=>[y,n[y]])))}})}clearWaapi(){var t,e;this.runId++,(t=this.waapi)==null||t.cancel(),this.waapi=null,this.waitingForStart=!1,this.startReady=!1,this.pendingFirstFrame=void 0,(e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.startupStableFrames=0}captureLiveState(){if(this.frames.length===0)return;const t=q(this.waapi);if(t===null)return;this.presentationTime=t;const{position:e,velocity:i}=A.interpolateFrame(this.frames,t);this.currentValue=e,this.currentVelocity=i,this.solverState=A.sampleIntegratorState(this.frames,t,this._integrator,this.solverTarget)}startFramePacedPlayback(t){if(!(this.waapi!==t||!this.waitingForStart||!this.startReady||this.stopStartupClock)){if(typeof requestAnimationFrame>"u"||this.playbackRate<0){this.clearStartStyles(),this.handOffToWaapi(t);return}this.startupStableFrames=0,this.stopStartupClock=lt.subscribe(e=>{this.advanceFramePacedStartup(t,e)})}}clearStartStyles(){if(this.pendingFirstFrame)for(const t of Object.keys(this.pendingFirstFrame))this._element.style[t]="";this.pendingFirstFrame=void 0}advanceFramePacedStartup(t,e){if(this.waapi!==t||!this.running||this.paused||!this.waitingForStart)return;const i=this.frames[this.frames.length-1];if(!i)return;const a=q(t)??0,c=Math.min(i.time,a+e.delta*Math.max(0,this.playbackRate));if(t.currentTime=c,this.clearStartStyles(),this.captureLiveState(),c>=i.time){this.finishFramePacedRun(t,i);return}e.rawDelta<=pt?this.startupStableFrames++:this.startupStableFrames=0,!(this.startupStableFrames<mt)&&this.handOffToWaapi(t)}handOffToWaapi(t){var c,d;if(this.waapi!==t||!this.running||this.paused)return;(c=this.stopStartupClock)==null||c.call(this),this.stopStartupClock=null,this.waitingForStart=!1,this.startReady=!1,this.startupStableFrames=0;const e=(d=t.timeline)==null?void 0:d.currentTime,i=q(t),a=this.playbackRate;if(typeof e=="number"&&i!==null&&a!==0){t.startTime=e-i/a;return}t.play()}finishFramePacedRun(t,e){var i;this.waapi!==t||!this.running||((i=this.stopStartupClock)==null||i.call(this),this.stopStartupClock=null,this.waitingForStart=!1,this.startReady=!1,this.startupStableFrames=0,this.running=!1,this.settled=!0,this.currentValue=e.position,this.currentVelocity=0,this.finish())}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,i=this.styleFn(t,e);for(const[a,c]of Object.entries(i))this._element.style[a]=typeof c=="number"?String(c):c}}function q(s){const r=s==null?void 0:s.currentTime;return typeof r=="number"?r:null}function gt(s){return typeof s.step=="function"?s:A.IntegratorProvider.from(s)}class G extends Z{constructor(t,e={}){super();h(this,"_children");h(this,"progressChildren");h(this,"_startAt");h(this,"namedChildren");h(this,"restoreChildCallbacks",[]);h(this,"runId",0);h(this,"pendingComplete",0);h(this,"running",!1);h(this,"disposed",!1);h(this,"settled",!1);h(this,"startedChildren",new Set);h(this,"lastMethod","play");h(this,"pausedRun",!1);h(this,"pendingStartObservers",[]);this.namedChildren=new Map(Array.isArray(t)?[]:Object.entries(t)),this._children=Array.isArray(t)?[...t]:[...this.namedChildren.values()];for(const i of this._children)i.deferDisposal=!0;this.progressChildren=this._children.filter(i=>!(i instanceof G)||i.progressChildren.length>0),(e.mode??"parallel")==="sequence"?this._startAt=this._children.map((i,a)=>a===0?0:1):this._startAt=e.startAt??[]}get children(){return this._children}get startAt(){return this._startAt}set startAt(t){this._startAt=t}tracks(){return this._children.flatMap(t=>[...t.getMotionTracks()])}getMotionTracks(){return this.tracks()}validate(){this.buildDependencies();for(const t of this._children)t.validate()}select(t){const e=this.namedChildren.get(t);if(!e)throw new Error(`Unknown animation child: ${t}`);return e}set(t,e){if(typeof t=="string"){const i=this.select(t);return(e==null?void 0:e.integrator)!==void 0&&i.set({integrator:gt(e.integrator)}),this}return super.set(t)}setIntegrator(t){for(const e of this._children)e.set({integrator:t})}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.pausedRun=this.running||this.pausedRun,this.running=!1,this.clearPendingStartObservers();for(const t of this._children)t.pause()}complete(){var t;if(!this.settled){this.settled=!0,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const e of this._children)e.complete();if(!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}get supportsInterruption(){return this._children.every(t=>t.supportsInterruption)}stop(){this.runId++,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const t of this._children)t.stop()}cancel(t){this.stop();for(const e of this._children)e.cancel(t);this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed){this.disposed=!0;try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] composite cleanup failed",i)}}}get progress(){if(this.progressChildren.length===0)return 0;let t=0;for(const e of this.progressChildren)t+=e.progress;return t/this.progressChildren.length}getPose(){return this._children.flatMap(t=>t.getPose())}getTimeline(){return this._children.flatMap(t=>t.getTimeline())}matchInto(t){for(const e of this._children)e.matchInto(t)}get isAnimating(){return this._children.some(t=>t.isAnimating)}get isPaused(){return this._children.some(t=>t.isPaused)&&this._children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.settled}get isReversing(){return this._children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this._children)e.playbackRate=t}startRun(t){const e=this.buildDependencies(),i=this.pausedRun&&t===this.lastMethod,a=t!==this.lastMethod,c=new Set(this.startedChildren),d=new Set(this._children.filter(o=>o.isComplete)),u=t==="reverse"&&c.size?this._children.filter(o=>c.has(o)):[...this._children],m=t==="reverse"?[...u].reverse():u,g=new Map;if(t==="reverse")for(const[o,f]of e){if(!u.includes(o)||!u.includes(f.after))continue;const b=g.get(f.after)??[];b.push({after:o,at:f.at==="settled"?"settled":1-f.at}),g.set(f.after,b)}else for(const[o,f]of e)g.set(o,[f]);if(a||i)for(const o of c)d.has(o)||g.delete(o);this.running&&this.pause(),this.restoreCompletionHandlers();const p=++this.runId;if(this.running=!0,this.pausedRun=!1,this.lastMethod=t,this.disposed=!1,this.settled=!1,this.pendingComplete=u.length,!i&&!a&&this.startedChildren.clear(),this.pendingComplete===0){this.handleFinished();return}const l=new Set,n=new Set;if(i)for(const o of u)c.has(o)&&d.has(o)&&(n.add(o),l.add(o),this.pendingComplete--);for(const o of u){const f=o.onComplete,b=()=>{if(!(this.runId!==p||!this.running||l.has(o))){try{f==null||f()}catch(w){console.error("[ssgoi] animation completion failed",w)}l.add(o),--this.pendingComplete===0&&this.handleFinished()}};o.onComplete=b,this.restoreChildCallbacks.push(()=>{o.onComplete===b&&(o.onComplete=f)})}const y=()=>{let o=!0;for(;this.running&&this.runId===p&&o;){o=!1;for(const f of m)!this.running||n.has(f)||(g.get(f)??[]).some(w=>!n.has(w.after)||!this.hasReachedThreshold(w.after,w.at,t))||(n.add(f),this.startedChildren.add(f),f[t](),o=!0)}n.size===u.length&&this.clearPendingStartObservers()};y(),this.pendingComplete===0&&this.handleFinished(),this.running&&n.size!==u.length&&this.pendingStartObservers.push(lt.subscribe(y,"observe"))}buildDependencies(){const t=new Map,e=new Set(this._children);if(e.size!==this._children.length)throw new Error("Each child animation must occur once in a MultiAnimation");this._children.forEach((d,u)=>{const m=d.startCondition;if(m){if(!e.has(m.after))throw new Error("startAt.after must reference a sibling in the same MultiAnimation");t.set(d,{...m})}else u>0&&this._startAt.some(g=>g>0)&&t.set(d,{after:this._children[u-1],at:this._startAt[u]??0})});const i=new Set,a=new Set,c=d=>{if(a.has(d))throw new Error("Animation startAt dependencies form a cycle");if(i.has(d))return;a.add(d);const u=t.get(d);u&&c(u.after),a.delete(d),i.add(d)};return this._children.forEach(c),t}hasReachedThreshold(t,e,i){return t.isComplete?!0:e==="settled"?!1:e<=0?!0:(i==="play"?t.progress:1-t.progress)>=e}clearPendingStartObservers(){for(const t of this.pendingStartObservers)t();this.pendingStartObservers=[]}restoreCompletionHandlers(){for(const t of this.restoreChildCallbacks)t();this.restoreChildCallbacks=[]}handleFinished(){var t;if(this.running){if(this.running=!1,this.settled=!0,this.clearPendingStartObservers(),this.restoreCompletionHandlers(),!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}findTimeForProgress(t){return null}}const X=new WeakMap;function yt(s){const r=X.get(s)??{value:s.style.getPropertyValue("opacity"),priority:s.style.getPropertyPriority("opacity"),opacity:typeof getComputedStyle=="function"?Number.parseFloat(getComputedStyle(s).opacity):Number.NaN,users:new Set},t={};r.users.add(t),X.set(s,r);let e=!1;return{opacity:Number.isFinite(r.opacity)?r.opacity:1,set:i=>{t.value=i,s.style.opacity=String(i)},restore:()=>{if(!e){if(e=!0,r.users.delete(t),r.users.size>0){const i=Array.from(r.users),a=i[i.length-1];(a==null?void 0:a.value)!==void 0&&(s.style.opacity=String(a.value));return}r.value?s.style.setProperty("opacity",r.value,r.priority):s.style.removeProperty("opacity"),X.delete(s)}}}}exports.Animation=Z;exports.MultiAnimation=G;exports.WebAnimation=Y;exports.createWebPresentationCodec=N;exports.finishedDisposal=x;exports.retainOpacity=yt;
|