@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.
Files changed (61) hide show
  1. package/dist/animation/animation.d.ts +21 -0
  2. package/dist/animation/animation.d.ts.map +1 -1
  3. package/dist/animation/host-animation.d.ts +28 -19
  4. package/dist/animation/host-animation.d.ts.map +1 -1
  5. package/dist/animation/multi-animation.d.ts +13 -2
  6. package/dist/animation/multi-animation.d.ts.map +1 -1
  7. package/dist/animation/web-animation.d.ts +76 -4
  8. package/dist/animation/web-animation.d.ts.map +1 -1
  9. package/dist/animation/web-presentation.d.ts +25 -0
  10. package/dist/animation/web-presentation.d.ts.map +1 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1206 -1184
  15. package/dist/internal.cjs +1 -1
  16. package/dist/internal.js +924 -631
  17. package/dist/{page-motion-MEazegOU.js → page-motion-CoPTk-Gd.js} +1 -1
  18. package/dist/{page-motion-DF3fFkOw.cjs → page-motion-Dhj3UfzO.cjs} +1 -1
  19. package/dist/provider-BLf6XeXT.js +291 -0
  20. package/dist/provider-JDtJ5Jzf.cjs +1 -0
  21. package/dist/retain-opacity-C5ajTKSI.cjs +1 -0
  22. package/dist/retain-opacity-ChyA_fg_.js +1142 -0
  23. package/dist/runtime/index.d.ts +1 -0
  24. package/dist/runtime/index.d.ts.map +1 -1
  25. package/dist/runtime/motion-matching.d.ts +31 -0
  26. package/dist/runtime/motion-matching.d.ts.map +1 -0
  27. package/dist/runtime/timeline.d.ts +6 -2
  28. package/dist/runtime/timeline.d.ts.map +1 -1
  29. package/dist/runtime.cjs +1 -1
  30. package/dist/runtime.js +29 -25
  31. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  32. package/dist/transitions/blind/transition.d.ts.map +1 -1
  33. package/dist/transitions/crossfade.d.ts +1 -6
  34. package/dist/transitions/crossfade.d.ts.map +1 -1
  35. package/dist/transitions/film/transition.d.ts.map +1 -1
  36. package/dist/transitions/hero/in-place.d.ts +5 -2
  37. package/dist/transitions/hero/in-place.d.ts.map +1 -1
  38. package/dist/transitions/hero/provider/chrome/fade.d.ts.map +1 -1
  39. package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
  40. package/dist/transitions/hero/transition.d.ts.map +1 -1
  41. package/dist/transitions/hero/types.d.ts +2 -1
  42. package/dist/transitions/hero/types.d.ts.map +1 -1
  43. package/dist/transitions/shared-visibility.d.ts +2 -0
  44. package/dist/transitions/shared-visibility.d.ts.map +1 -0
  45. package/dist/transitions/sheet/transition.d.ts.map +1 -1
  46. package/dist/transitions/zoom/crossfade.d.ts.map +1 -1
  47. package/dist/transitions/zoom/provider/blur.d.ts.map +1 -1
  48. package/dist/transitions/zoom/transition.d.ts.map +1 -1
  49. package/dist/transitions/zoom/types.d.ts +2 -1
  50. package/dist/transitions/zoom/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +4 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/utils/index.d.ts +1 -0
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/retain-opacity.d.ts +7 -0
  56. package/dist/utils/retain-opacity.d.ts.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/multi-animation-Du9W3ZS_.js +0 -503
  59. package/dist/multi-animation-hDUcfD7W.cjs +0 -1
  60. package/dist/provider-Cea0Pfm1.js +0 -232
  61. package/dist/provider-D9Q2URox.cjs +0 -1
@@ -1,503 +0,0 @@
1
- var w = Object.defineProperty;
2
- var F = (o, n, t) => n in o ? w(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
- var r = (o, n, t) => F(o, typeof n != "symbol" ? n + "" : n, t);
4
- import { A as S, s as _, i as v, I as C } from "./provider-Cea0Pfm1.js";
5
- class m extends S {
6
- constructor() {
7
- super(...arguments);
8
- r(this, "_startCondition");
9
- }
10
- /** Scheduling metadata read by the parent immediately before playback. */
11
- get startCondition() {
12
- return this._startCondition;
13
- }
14
- /** Retune this animation before playback; omitted values stay unchanged. */
15
- set(t) {
16
- if (t.startAt) {
17
- const { after: e, at: s } = t.startAt;
18
- if (e === this)
19
- throw new Error("An animation cannot start after itself");
20
- if (s !== "settled" && (!Number.isFinite(s) || s < 0 || s > 1))
21
- throw new Error("startAt.at must be a progress from 0 to 1 or settled");
22
- }
23
- if (t.integrator !== void 0) {
24
- if (typeof t.integrator.step != "function" || typeof t.integrator.isSettled != "function")
25
- throw new Error("An integrator must implement step and isSettled");
26
- this.setIntegrator(t.integrator);
27
- }
28
- return t.startAt !== void 0 && (this._startCondition = t.startAt ? { ...t.startAt } : void 0), this;
29
- }
30
- /** Custom drivers can opt into physics editing by implementing this method. */
31
- setIntegrator(t) {
32
- throw new Error("This animation does not support replacing its integrator");
33
- }
34
- }
35
- function A(o) {
36
- return new Promise((n) => {
37
- requestAnimationFrame(() => {
38
- requestAnimationFrame(() => {
39
- n();
40
- });
41
- });
42
- });
43
- }
44
- const R = 1e3 / 60, g = 1e3 / 30, k = g + 1;
45
- class T {
46
- constructor() {
47
- r(this, "drivers", /* @__PURE__ */ new Set());
48
- r(this, "observers", /* @__PURE__ */ new Set());
49
- r(this, "frameRequest", null);
50
- r(this, "previousTimestamp", null);
51
- r(this, "tick", (n) => {
52
- this.frameRequest = null;
53
- const t = this.previousTimestamp === null ? R : Math.max(0, n - this.previousTimestamp);
54
- this.previousTimestamp = n;
55
- const e = {
56
- delta: Math.min(t, g),
57
- rawDelta: t
58
- };
59
- this.runPhase(this.drivers, e), this.runPhase(this.observers, e), this.hasCallbacks() ? this.requestFrame() : this.previousTimestamp = null;
60
- });
61
- }
62
- subscribe(n, t = "drive") {
63
- const e = t === "drive" ? this.drivers : this.observers;
64
- return e.add(n), this.requestFrame(), () => {
65
- e.delete(n), this.stopIfIdle();
66
- };
67
- }
68
- requestFrame() {
69
- this.frameRequest !== null || !this.hasCallbacks() || (this.frameRequest = requestAnimationFrame(this.tick));
70
- }
71
- runPhase(n, t) {
72
- for (const e of [...n])
73
- n.has(e) && e(t);
74
- }
75
- hasCallbacks() {
76
- return this.drivers.size > 0 || this.observers.size > 0;
77
- }
78
- stopIfIdle() {
79
- this.hasCallbacks() || (this.frameRequest !== null && typeof cancelAnimationFrame < "u" && cancelAnimationFrame(this.frameRequest), this.frameRequest = null, this.previousTimestamp = null);
80
- }
81
- }
82
- const y = new T(), P = 2;
83
- class B extends m {
84
- constructor(t) {
85
- super();
86
- r(this, "_element");
87
- r(this, "_integrator");
88
- /** Role label, see `WebAnimationOptions.label`. */
89
- r(this, "label");
90
- r(this, "styleFn");
91
- r(this, "lowerBound");
92
- r(this, "upperBound");
93
- r(this, "currentValue");
94
- r(this, "currentVelocity", 0);
95
- r(this, "frames", []);
96
- r(this, "waapi", null);
97
- r(this, "runId", 0);
98
- r(this, "waitingForStart", !1);
99
- r(this, "startReady", !1);
100
- r(this, "pendingFirstFrame");
101
- r(this, "stopStartupClock", null);
102
- r(this, "startupStableFrames", 0);
103
- r(this, "running", !1);
104
- r(this, "paused", !1);
105
- r(this, "settled", !1);
106
- r(this, "reversing", !1);
107
- 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.onComplete = t.onComplete;
108
- }
109
- /** The DOM node this track drives. */
110
- get element() {
111
- return this._element;
112
- }
113
- /**
114
- * Physics that drives this track. Read lazily at `play()` / `reverse()`
115
- * (the simulation runs then), so replacing it before playback takes effect
116
- * for the next run — this is what `withOverride` relies on.
117
- */
118
- get integrator() {
119
- return this._integrator;
120
- }
121
- set integrator(t) {
122
- this._integrator = t;
123
- }
124
- setIntegrator(t) {
125
- this._integrator = t;
126
- }
127
- play() {
128
- if (this.reversing = !1, this.paused && this.waapi) {
129
- if (this.paused = !1, this.running = !0, this.waitingForStart) {
130
- this.startReady && this.startFramePacedPlayback(this.waapi);
131
- return;
132
- }
133
- this.waapi.play();
134
- return;
135
- }
136
- this.runToward(this.upperBound);
137
- }
138
- reverse() {
139
- this.reversing = !0, this.runToward(this.lowerBound);
140
- }
141
- pause() {
142
- var t, e;
143
- this.running && (this.captureLiveState(), (t = this.waapi) == null || t.pause(), (e = this.stopStartupClock) == null || e.call(this), this.stopStartupClock = null, this.running = !1, this.paused = !0);
144
- }
145
- complete() {
146
- var t;
147
- this.clearWaapi(), this.running = !1, this.paused = !1, this.currentValue = this.upperBound, this.currentVelocity = 0, this.applyStyleAt(this.currentValue), this.settled = !0, (t = this.onComplete) == null || t.call(this);
148
- }
149
- /**
150
- * Drop the WAAPI forwards-fill after the run has settled, letting inline
151
- * styles govern the resting visual. Call only from `onComplete` (the run is
152
- * already finished) — otherwise it cancels mid-flight. Unlike `complete()`,
153
- * it writes no final frame, so a caller can reset the element to its natural
154
- * state without the lingering fill clobbering it.
155
- */
156
- releaseFill() {
157
- this.clearWaapi();
158
- }
159
- get isAnimating() {
160
- return this.running;
161
- }
162
- get isPaused() {
163
- return this.paused;
164
- }
165
- get isComplete() {
166
- return this.settled;
167
- }
168
- get isReversing() {
169
- return this.reversing;
170
- }
171
- get progress() {
172
- this.running && this.captureLiveState();
173
- const t = this.upperBound - this.lowerBound;
174
- if (t === 0) return 0;
175
- const e = (this.currentValue - this.lowerBound) / t;
176
- return e < 0 ? 0 : e > 1 ? 1 : e;
177
- }
178
- findTimeForProgress(t) {
179
- if (this.frames.length < 2) return null;
180
- const e = this.upperBound - this.lowerBound;
181
- if (e === 0) return 0;
182
- for (const s of this.frames)
183
- if ((s.position - this.lowerBound) / e >= t) return s.time;
184
- return this.frames[this.frames.length - 1].time;
185
- }
186
- get playbackRate() {
187
- return super.playbackRate;
188
- }
189
- set playbackRate(t) {
190
- super.playbackRate = t, this.waapi && (this.waapi.playbackRate = t);
191
- }
192
- getPose() {
193
- return this.running && this.captureLiveState(), [
194
- {
195
- element: this._element,
196
- value: this.currentValue,
197
- velocity: this.currentVelocity
198
- }
199
- ];
200
- }
201
- getTimeline() {
202
- const t = this.frames.map((e) => {
203
- const s = e.position, a = this.lowerBound + this.upperBound - s;
204
- return {
205
- time: e.time,
206
- value: e.position,
207
- velocity: e.velocity,
208
- style: this.styleFn(s, a)
209
- };
210
- });
211
- return [{ element: this._element, frames: t }];
212
- }
213
- matchInto(t) {
214
- const e = t.find((s) => s.element === this._element);
215
- e && (this.currentValue = e.value, this.currentVelocity = e.velocity);
216
- }
217
- /* ───────────────────────────────────────────────────────── private */
218
- runToward(t) {
219
- var l;
220
- if (this.running && this.captureLiveState(), this.clearWaapi(), this.running = !1, this.paused = !1, this.settled = !1, this.frames = _(
221
- this._integrator,
222
- this.currentValue,
223
- t,
224
- this.currentVelocity
225
- ), this.frames.length === 0) {
226
- this.currentValue = t, this.currentVelocity = 0, this.applyStyleAt(t), this.settled = !0, (l = this.onComplete) == null || l.call(this);
227
- return;
228
- }
229
- const e = this.frames.map((c) => {
230
- const p = c.position, b = this.lowerBound + this.upperBound - p;
231
- return this.styleFn(p, b);
232
- }), s = e[0], a = this.frames[this.frames.length - 1], h = a.time, u = ++this.runId, i = this._element.animate(e, {
233
- duration: h,
234
- fill: "both",
235
- easing: "linear",
236
- composite: "replace"
237
- });
238
- i.playbackRate = this.playbackRate, i.currentTime = 0, i.pause(), this.waapi = i, this.waitingForStart = !0, this.startReady = !1, this.pendingFirstFrame = s, this.running = !0, i.onfinish = () => {
239
- var c;
240
- !this.running || this.waapi !== i || (this.running = !1, this.settled = !0, this.currentValue = a.position, this.currentVelocity = 0, (c = this.onComplete) == null || c.call(this));
241
- }, this.startWhenReady(i, u);
242
- }
243
- clearWaapi() {
244
- var t, e;
245
- 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;
246
- }
247
- captureLiveState() {
248
- if (this.frames.length === 0) return;
249
- const t = f(this.waapi);
250
- if (t === null) return;
251
- const { position: e, velocity: s } = v(this.frames, t);
252
- this.currentValue = e, this.currentVelocity = s;
253
- }
254
- async startWhenReady(t, e) {
255
- try {
256
- await t.ready, typeof requestAnimationFrame < "u" && await A(this._element);
257
- } catch {
258
- return;
259
- }
260
- this.runId !== e || this.waapi !== t || (this.startReady = !0, !(!this.running || this.paused) && this.startFramePacedPlayback(t));
261
- }
262
- startFramePacedPlayback(t) {
263
- if (!(this.waapi !== t || !this.waitingForStart || !this.startReady || this.stopStartupClock)) {
264
- if (this.pendingFirstFrame)
265
- for (const e of Object.keys(this.pendingFirstFrame))
266
- this._element.style[e] = "";
267
- if (this.pendingFirstFrame = void 0, typeof requestAnimationFrame > "u" || this.playbackRate < 0) {
268
- this.handOffToWaapi(t);
269
- return;
270
- }
271
- this.startupStableFrames = 0, this.stopStartupClock = y.subscribe((e) => {
272
- this.advanceFramePacedStartup(t, e);
273
- });
274
- }
275
- }
276
- advanceFramePacedStartup(t, e) {
277
- if (this.waapi !== t || !this.running || this.paused || !this.waitingForStart)
278
- return;
279
- const s = this.frames[this.frames.length - 1];
280
- if (!s) return;
281
- const a = f(t) ?? 0, h = Math.min(
282
- s.time,
283
- a + e.delta * Math.max(0, this.playbackRate)
284
- );
285
- if (t.currentTime = h, this.captureLiveState(), h >= s.time) {
286
- this.finishFramePacedRun(t, s);
287
- return;
288
- }
289
- e.rawDelta <= k ? this.startupStableFrames++ : this.startupStableFrames = 0, !(this.startupStableFrames < P) && this.handOffToWaapi(t);
290
- }
291
- handOffToWaapi(t) {
292
- var e;
293
- this.waapi !== t || !this.running || this.paused || ((e = this.stopStartupClock) == null || e.call(this), this.stopStartupClock = null, this.waitingForStart = !1, this.startReady = !1, this.startupStableFrames = 0, t.play());
294
- }
295
- finishFramePacedRun(t, e) {
296
- var s, a;
297
- this.waapi !== t || !this.running || ((s = this.stopStartupClock) == null || s.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, (a = this.onComplete) == null || a.call(this));
298
- }
299
- applyStyleAt(t) {
300
- const e = this.lowerBound + this.upperBound - t, s = this.styleFn(t, e);
301
- for (const [a, h] of Object.entries(s))
302
- this._element.style[a] = typeof h == "number" ? String(h) : h;
303
- }
304
- }
305
- function f(o) {
306
- const n = o == null ? void 0 : o.currentTime;
307
- return typeof n == "number" ? n : null;
308
- }
309
- function I(o) {
310
- return typeof o.step == "function" ? o : C.from(o);
311
- }
312
- class d extends m {
313
- constructor(t, e = {}) {
314
- super();
315
- r(this, "_children");
316
- r(this, "progressChildren");
317
- r(this, "_startAt");
318
- r(this, "namedChildren");
319
- r(this, "restoreChildCallbacks", []);
320
- r(this, "runId", 0);
321
- r(this, "pendingComplete", 0);
322
- r(this, "running", !1);
323
- r(this, "pendingStartObservers", []);
324
- this.namedChildren = new Map(
325
- Array.isArray(t) ? [] : Object.entries(t)
326
- ), this._children = Array.isArray(t) ? [...t] : [...this.namedChildren.values()], this.progressChildren = this._children.filter(
327
- (s) => !(s instanceof d) || s.progressChildren.length > 0
328
- ), (e.mode ?? "parallel") === "sequence" ? this._startAt = this._children.map((s, a) => a === 0 ? 0 : 1) : this._startAt = e.startAt ?? [];
329
- }
330
- /** Child animations in play order. */
331
- get children() {
332
- return this._children;
333
- }
334
- /**
335
- * Per-child start thresholds (see `MultiAnimationOptions.startAt`). Read
336
- * at run time, so replacing it before `play()` changes the overlap.
337
- */
338
- get startAt() {
339
- return this._startAt;
340
- }
341
- set startAt(t) {
342
- this._startAt = t;
343
- }
344
- /** Every `WebAnimation` in this composite, nested composites included. */
345
- tracks() {
346
- const t = [];
347
- for (const e of this._children)
348
- e instanceof B ? t.push(e) : e instanceof d && t.push(...e.tracks());
349
- return t;
350
- }
351
- /** Select a registered child, which may itself be a composite. */
352
- select(t) {
353
- const e = this.namedChildren.get(t);
354
- if (!e) throw new Error(`Unknown animation child: ${t}`);
355
- return e;
356
- }
357
- set(t, e) {
358
- if (typeof t == "string") {
359
- const s = this.select(t);
360
- return (e == null ? void 0 : e.integrator) !== void 0 && s.set({ integrator: I(e.integrator) }), this;
361
- }
362
- return super.set(t);
363
- }
364
- /** Setting the composite explicitly retunes every child in the group. */
365
- setIntegrator(t) {
366
- for (const e of this._children) e.set({ integrator: t });
367
- }
368
- play() {
369
- this.startRun("play");
370
- }
371
- reverse() {
372
- this.startRun("reverse");
373
- }
374
- pause() {
375
- this.running = !1, this.clearPendingStartObservers();
376
- for (const t of this._children) t.pause();
377
- }
378
- complete() {
379
- var t;
380
- this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers();
381
- for (const e of this._children) e.complete();
382
- (t = this.onComplete) == null || t.call(this);
383
- }
384
- get progress() {
385
- if (this.progressChildren.length === 0) return 0;
386
- let t = 0;
387
- for (const e of this.progressChildren) t += e.progress;
388
- return t / this.progressChildren.length;
389
- }
390
- getPose() {
391
- return this._children.flatMap((t) => t.getPose());
392
- }
393
- getTimeline() {
394
- return this._children.flatMap((t) => t.getTimeline());
395
- }
396
- matchInto(t) {
397
- }
398
- get isAnimating() {
399
- return this._children.some((t) => t.isAnimating);
400
- }
401
- get isPaused() {
402
- return this._children.some((t) => t.isPaused) && this._children.every((t) => t.isPaused || t.isComplete);
403
- }
404
- get isComplete() {
405
- return this._children.every((t) => t.isComplete);
406
- }
407
- get isReversing() {
408
- return this._children.some((t) => t.isReversing);
409
- }
410
- get playbackRate() {
411
- return super.playbackRate;
412
- }
413
- set playbackRate(t) {
414
- super.playbackRate = t;
415
- for (const e of this._children) e.playbackRate = t;
416
- }
417
- /* ───────────────────────────────────────────────────────── private */
418
- startRun(t) {
419
- const e = this.buildDependencies();
420
- this.running && this.pause(), this.restoreCompletionHandlers();
421
- const s = ++this.runId;
422
- if (this.running = !0, this.pendingComplete = this._children.length, this.pendingComplete === 0) {
423
- this.handleFinished();
424
- return;
425
- }
426
- const a = /* @__PURE__ */ new Set();
427
- for (const i of this._children) {
428
- const l = i.onComplete, c = () => {
429
- l == null || l(), !(this.runId !== s || !this.running || a.has(i)) && (a.add(i), --this.pendingComplete === 0 && this.handleFinished());
430
- };
431
- i.onComplete = c, this.restoreChildCallbacks.push(() => {
432
- i.onComplete === c && (i.onComplete = l);
433
- });
434
- }
435
- const h = /* @__PURE__ */ new Set(), u = () => {
436
- let i = !0;
437
- for (; this.running && i; ) {
438
- i = !1;
439
- for (const l of this._children) {
440
- if (!this.running || h.has(l)) continue;
441
- const c = e.get(l);
442
- c && (!h.has(c.after) || !this.hasReachedThreshold(c.after, c.at, t)) || (h.add(l), l[t](), i = !0);
443
- }
444
- }
445
- h.size === this._children.length && this.clearPendingStartObservers();
446
- };
447
- u(), this.running && h.size !== this._children.length && this.pendingStartObservers.push(
448
- y.subscribe(u, "observe")
449
- );
450
- }
451
- buildDependencies() {
452
- const t = /* @__PURE__ */ new Map(), e = new Set(this._children);
453
- if (e.size !== this._children.length)
454
- throw new Error(
455
- "Each child animation must occur once in a MultiAnimation"
456
- );
457
- this._children.forEach((u, i) => {
458
- const l = u.startCondition;
459
- if (l) {
460
- if (!e.has(l.after))
461
- throw new Error(
462
- "startAt.after must reference a sibling in the same MultiAnimation"
463
- );
464
- t.set(u, { ...l });
465
- } else i > 0 && this._startAt.some((c) => c > 0) && t.set(u, {
466
- after: this._children[i - 1],
467
- at: this._startAt[i] ?? 0
468
- });
469
- });
470
- const s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = (u) => {
471
- if (a.has(u))
472
- throw new Error("Animation startAt dependencies form a cycle");
473
- if (s.has(u)) return;
474
- a.add(u);
475
- const i = t.get(u);
476
- i && h(i.after), a.delete(u), s.add(u);
477
- };
478
- return this._children.forEach(h), t;
479
- }
480
- hasReachedThreshold(t, e, s) {
481
- return t.isComplete ? !0 : e === "settled" ? !1 : e <= 0 ? !0 : (s === "play" ? t.progress : 1 - t.progress) >= e;
482
- }
483
- clearPendingStartObservers() {
484
- for (const t of this.pendingStartObservers) t();
485
- this.pendingStartObservers = [];
486
- }
487
- restoreCompletionHandlers() {
488
- for (const t of this.restoreChildCallbacks) t();
489
- this.restoreChildCallbacks = [];
490
- }
491
- handleFinished() {
492
- var t;
493
- this.running && (this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers(), (t = this.onComplete) == null || t.call(this));
494
- }
495
- findTimeForProgress(t) {
496
- return null;
497
- }
498
- }
499
- export {
500
- m as A,
501
- d as M,
502
- B as W
503
- };
@@ -1 +0,0 @@
1
- "use strict";var v=Object.defineProperty;var S=(o,n,t)=>n in o?v(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var r=(o,n,t)=>S(o,typeof n!="symbol"?n+"":n,t);const d=require("./provider-D9Q2URox.cjs");class f extends d.Animation{constructor(){super(...arguments);r(this,"_startCondition")}get startCondition(){return this._startCondition}set(t){if(t.startAt){const{after:e,at:s}=t.startAt;if(e===this)throw new Error("An animation cannot start after itself");if(s!=="settled"&&(!Number.isFinite(s)||s<0||s>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")}}function _(o){return new Promise(n=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})})}const C=1e3/60,y=1e3/30,A=y+1;class R{constructor(){r(this,"drivers",new Set);r(this,"observers",new Set);r(this,"frameRequest",null);r(this,"previousTimestamp",null);r(this,"tick",n=>{this.frameRequest=null;const t=this.previousTimestamp===null?C:Math.max(0,n-this.previousTimestamp);this.previousTimestamp=n;const e={delta:Math.min(t,y),rawDelta:t};this.runPhase(this.drivers,e),this.runPhase(this.observers,e),this.hasCallbacks()?this.requestFrame():this.previousTimestamp=null})}subscribe(n,t="drive"){const e=t==="drive"?this.drivers:this.observers;return e.add(n),this.requestFrame(),()=>{e.delete(n),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||!this.hasCallbacks()||(this.frameRequest=requestAnimationFrame(this.tick))}runPhase(n,t){for(const e of[...n])n.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 b=new R,k=2;class w extends f{constructor(t){super();r(this,"_element");r(this,"_integrator");r(this,"label");r(this,"styleFn");r(this,"lowerBound");r(this,"upperBound");r(this,"currentValue");r(this,"currentVelocity",0);r(this,"frames",[]);r(this,"waapi",null);r(this,"runId",0);r(this,"waitingForStart",!1);r(this,"startReady",!1);r(this,"pendingFirstFrame");r(this,"stopStartupClock",null);r(this,"startupStableFrames",0);r(this,"running",!1);r(this,"paused",!1);r(this,"settled",!1);r(this,"reversing",!1);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.onComplete=t.onComplete}get element(){return this._element}get integrator(){return this._integrator}set integrator(t){this._integrator=t}setIntegrator(t){this._integrator=t}play(){if(this.reversing=!1,this.paused&&this.waapi){if(this.paused=!1,this.running=!0,this.waitingForStart){this.startReady&&this.startFramePacedPlayback(this.waapi);return}this.waapi.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),(e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.running=!1,this.paused=!0)}complete(){var t;this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,(t=this.onComplete)==null||t.call(this)}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 s of this.frames)if((s.position-this.lowerBound)/e>=t)return s.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=>{const s=e.position,a=this.lowerBound+this.upperBound-s;return{time:e.time,value:e.position,velocity:e.velocity,style:this.styleFn(s,a)}});return[{element:this._element,frames:t}]}matchInto(t){const e=t.find(s=>s.element===this._element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity)}runToward(t){var l;if(this.running&&this.captureLiveState(),this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.frames=d.simulate(this._integrator,this.currentValue,t,this.currentVelocity),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,(l=this.onComplete)==null||l.call(this);return}const e=this.frames.map(c=>{const m=c.position,F=this.lowerBound+this.upperBound-m;return this.styleFn(m,F)}),s=e[0],a=this.frames[this.frames.length-1],h=a.time,u=++this.runId,i=this._element.animate(e,{duration:h,fill:"both",easing:"linear",composite:"replace"});i.playbackRate=this.playbackRate,i.currentTime=0,i.pause(),this.waapi=i,this.waitingForStart=!0,this.startReady=!1,this.pendingFirstFrame=s,this.running=!0,i.onfinish=()=>{var c;!this.running||this.waapi!==i||(this.running=!1,this.settled=!0,this.currentValue=a.position,this.currentVelocity=0,(c=this.onComplete)==null||c.call(this))},this.startWhenReady(i,u)}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=g(this.waapi);if(t===null)return;const{position:e,velocity:s}=d.interpolateFrame(this.frames,t);this.currentValue=e,this.currentVelocity=s}async startWhenReady(t,e){try{await t.ready,typeof requestAnimationFrame<"u"&&await _(this._element)}catch{return}this.runId!==e||this.waapi!==t||(this.startReady=!0,!(!this.running||this.paused)&&this.startFramePacedPlayback(t))}startFramePacedPlayback(t){if(!(this.waapi!==t||!this.waitingForStart||!this.startReady||this.stopStartupClock)){if(this.pendingFirstFrame)for(const e of Object.keys(this.pendingFirstFrame))this._element.style[e]="";if(this.pendingFirstFrame=void 0,typeof requestAnimationFrame>"u"||this.playbackRate<0){this.handOffToWaapi(t);return}this.startupStableFrames=0,this.stopStartupClock=b.subscribe(e=>{this.advanceFramePacedStartup(t,e)})}}advanceFramePacedStartup(t,e){if(this.waapi!==t||!this.running||this.paused||!this.waitingForStart)return;const s=this.frames[this.frames.length-1];if(!s)return;const a=g(t)??0,h=Math.min(s.time,a+e.delta*Math.max(0,this.playbackRate));if(t.currentTime=h,this.captureLiveState(),h>=s.time){this.finishFramePacedRun(t,s);return}e.rawDelta<=A?this.startupStableFrames++:this.startupStableFrames=0,!(this.startupStableFrames<k)&&this.handOffToWaapi(t)}handOffToWaapi(t){var e;this.waapi!==t||!this.running||this.paused||((e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.waitingForStart=!1,this.startReady=!1,this.startupStableFrames=0,t.play())}finishFramePacedRun(t,e){var s,a;this.waapi!==t||!this.running||((s=this.stopStartupClock)==null||s.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,(a=this.onComplete)==null||a.call(this))}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,s=this.styleFn(t,e);for(const[a,h]of Object.entries(s))this._element.style[a]=typeof h=="number"?String(h):h}}function g(o){const n=o==null?void 0:o.currentTime;return typeof n=="number"?n:null}function T(o){return typeof o.step=="function"?o:d.IntegratorProvider.from(o)}class p extends f{constructor(t,e={}){super();r(this,"_children");r(this,"progressChildren");r(this,"_startAt");r(this,"namedChildren");r(this,"restoreChildCallbacks",[]);r(this,"runId",0);r(this,"pendingComplete",0);r(this,"running",!1);r(this,"pendingStartObservers",[]);this.namedChildren=new Map(Array.isArray(t)?[]:Object.entries(t)),this._children=Array.isArray(t)?[...t]:[...this.namedChildren.values()],this.progressChildren=this._children.filter(s=>!(s instanceof p)||s.progressChildren.length>0),(e.mode??"parallel")==="sequence"?this._startAt=this._children.map((s,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(){const t=[];for(const e of this._children)e instanceof w?t.push(e):e instanceof p&&t.push(...e.tracks());return t}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 s=this.select(t);return(e==null?void 0:e.integrator)!==void 0&&s.set({integrator:T(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.running=!1,this.clearPendingStartObservers();for(const t of this._children)t.pause()}complete(){var t;this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const e of this._children)e.complete();(t=this.onComplete)==null||t.call(this)}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){}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._children.every(t=>t.isComplete)}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();this.running&&this.pause(),this.restoreCompletionHandlers();const s=++this.runId;if(this.running=!0,this.pendingComplete=this._children.length,this.pendingComplete===0){this.handleFinished();return}const a=new Set;for(const i of this._children){const l=i.onComplete,c=()=>{l==null||l(),!(this.runId!==s||!this.running||a.has(i))&&(a.add(i),--this.pendingComplete===0&&this.handleFinished())};i.onComplete=c,this.restoreChildCallbacks.push(()=>{i.onComplete===c&&(i.onComplete=l)})}const h=new Set,u=()=>{let i=!0;for(;this.running&&i;){i=!1;for(const l of this._children){if(!this.running||h.has(l))continue;const c=e.get(l);c&&(!h.has(c.after)||!this.hasReachedThreshold(c.after,c.at,t))||(h.add(l),l[t](),i=!0)}}h.size===this._children.length&&this.clearPendingStartObservers()};u(),this.running&&h.size!==this._children.length&&this.pendingStartObservers.push(b.subscribe(u,"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((u,i)=>{const l=u.startCondition;if(l){if(!e.has(l.after))throw new Error("startAt.after must reference a sibling in the same MultiAnimation");t.set(u,{...l})}else i>0&&this._startAt.some(c=>c>0)&&t.set(u,{after:this._children[i-1],at:this._startAt[i]??0})});const s=new Set,a=new Set,h=u=>{if(a.has(u))throw new Error("Animation startAt dependencies form a cycle");if(s.has(u))return;a.add(u);const i=t.get(u);i&&h(i.after),a.delete(u),s.add(u)};return this._children.forEach(h),t}hasReachedThreshold(t,e,s){return t.isComplete?!0:e==="settled"?!1:e<=0?!0:(s==="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;this.running&&(this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers(),(t=this.onComplete)==null||t.call(this))}findTimeForProgress(t){return null}}exports.Animation=f;exports.MultiAnimation=p;exports.WebAnimation=w;