@ssgoi/core 0.0.3 → 2.1.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 (58) hide show
  1. package/README.md +252 -23
  2. package/dist/animator.d.ts +28 -17
  3. package/dist/animator.d.ts.map +1 -1
  4. package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
  5. package/dist/create-transition-callback.d.ts +3 -32
  6. package/dist/create-transition-callback.d.ts.map +1 -1
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +374 -213
  11. package/dist/presets/index.cjs +1 -0
  12. package/dist/presets/index.d.ts +16 -0
  13. package/dist/presets/index.d.ts.map +1 -0
  14. package/dist/presets/index.js +35 -0
  15. package/dist/transition-strategy.d.ts +60 -0
  16. package/dist/transition-strategy.d.ts.map +1 -0
  17. package/dist/transition.d.ts +55 -11
  18. package/dist/transition.d.ts.map +1 -1
  19. package/dist/transitions/blur.d.ts +5 -1
  20. package/dist/transitions/blur.d.ts.map +1 -1
  21. package/dist/transitions/bounce.d.ts +5 -0
  22. package/dist/transitions/bounce.d.ts.map +1 -1
  23. package/dist/transitions/fade.d.ts +3 -0
  24. package/dist/transitions/fade.d.ts.map +1 -1
  25. package/dist/transitions/fly.d.ts +30 -0
  26. package/dist/transitions/fly.d.ts.map +1 -0
  27. package/dist/transitions/index.cjs +1 -1
  28. package/dist/transitions/index.d.ts +1 -0
  29. package/dist/transitions/index.d.ts.map +1 -1
  30. package/dist/transitions/index.js +200 -120
  31. package/dist/transitions/none.d.ts +3 -0
  32. package/dist/transitions/none.d.ts.map +1 -1
  33. package/dist/transitions/rotate.d.ts +6 -0
  34. package/dist/transitions/rotate.d.ts.map +1 -1
  35. package/dist/transitions/scale.d.ts +6 -3
  36. package/dist/transitions/scale.d.ts.map +1 -1
  37. package/dist/transitions/slide.d.ts +6 -1
  38. package/dist/transitions/slide.d.ts.map +1 -1
  39. package/dist/types.d.ts +19 -7
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/utils-8Eptbv7c.cjs +2 -0
  42. package/dist/utils-DTRMUQW4.js +31 -0
  43. package/dist/utils.d.ts +11 -0
  44. package/dist/utils.d.ts.map +1 -1
  45. package/dist/view-transitions/drill.d.ts +9 -0
  46. package/dist/view-transitions/drill.d.ts.map +1 -0
  47. package/dist/view-transitions/fade.d.ts +3 -1
  48. package/dist/view-transitions/fade.d.ts.map +1 -1
  49. package/dist/view-transitions/hero.d.ts.map +1 -1
  50. package/dist/view-transitions/index.cjs +1 -1
  51. package/dist/view-transitions/index.d.ts +2 -1
  52. package/dist/view-transitions/index.d.ts.map +1 -1
  53. package/dist/view-transitions/index.js +233 -177
  54. package/dist/view-transitions/scroll.d.ts +8 -0
  55. package/dist/view-transitions/scroll.d.ts.map +1 -0
  56. package/package.json +28 -10
  57. package/dist/utils-BSgyev81.cjs +0 -1
  58. package/dist/utils-DR41YsAh.js +0 -16
package/dist/index.js CHANGED
@@ -1,41 +1,110 @@
1
- var E = Object.defineProperty;
2
- var R = (o, t, n) => t in o ? E(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n;
3
- var d = (o, t, n) => R(o, typeof t != "symbol" ? t + "" : t, n);
4
- import { animate as P } from "popmotion";
5
- import { g as b } from "./utils-DR41YsAh.js";
6
- class v {
1
+ var M = Object.defineProperty;
2
+ var x = (i, t, o) => t in i ? M(i, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : i[t] = o;
3
+ var g = (i, t, o) => x(i, typeof t != "symbol" ? t + "" : t, o);
4
+ import { animate as E } from "popmotion";
5
+ import { p as U, g as _ } from "./utils-DTRMUQW4.js";
6
+ class V {
7
7
  constructor(t) {
8
- d(this, "options");
9
- d(this, "currentValue");
10
- d(this, "velocity", 0);
11
- d(this, "isAnimating", !1);
12
- d(this, "controls", null);
13
- d(this, "animate", (t = !1) => {
8
+ g(this, "options");
9
+ g(this, "currentValue");
10
+ g(this, "velocity");
11
+ g(this, "isAnimating", !1);
12
+ g(this, "controls", null);
13
+ // For object animations
14
+ g(this, "animationMap", null);
15
+ g(this, "activeAnimations", /* @__PURE__ */ new Set());
16
+ g(this, "completedAnimations", /* @__PURE__ */ new Set());
17
+ g(this, "updatedProperties", /* @__PURE__ */ new Set());
18
+ g(this, "animate", (t = !1) => {
14
19
  !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
15
- const n = t ? this.options.from : this.options.to;
16
- let s = this.currentValue, c = performance.now();
17
- this.controls = P({
20
+ const o = t ? this.options.from : this.options.to;
21
+ if (typeof this.currentValue == "object" && this.currentValue !== null) {
22
+ this.animateObject(o, t);
23
+ return;
24
+ }
25
+ let n = this.currentValue, e = performance.now();
26
+ const m = {
18
27
  from: this.currentValue,
19
- to: n,
20
- velocity: this.velocity * 1e3,
21
- // Convert to px/s
28
+ to: o,
22
29
  stiffness: this.options.spring.stiffness,
23
30
  damping: this.options.spring.damping,
24
- mass: 1,
25
- onUpdate: (u) => {
26
- const l = performance.now(), S = (l - c) / 1e3;
27
- if (S > 0) {
28
- const w = (u - s) / S;
29
- this.velocity = w / 1e3, s = u, c = l;
31
+ mass: 1
32
+ };
33
+ typeof this.velocity == "number" && (m.velocity = this.velocity * 1e3), this.controls = E({
34
+ ...m,
35
+ onUpdate: (a) => {
36
+ const f = performance.now(), h = (f - e) / 1e3;
37
+ if (h > 0) {
38
+ if (typeof a == "number" && typeof n == "number") {
39
+ const c = (a - n) / h;
40
+ this.velocity = c / 1e3;
41
+ } else if (typeof a == "object" && a !== null) {
42
+ const c = {};
43
+ Object.keys(a).forEach((u) => {
44
+ const r = a[u], s = n[u];
45
+ if (typeof r == "number" && typeof s == "number") {
46
+ const p = (r - s) / h;
47
+ c[u] = p / 1e3;
48
+ }
49
+ }), this.velocity = c;
50
+ }
51
+ n = a, e = f;
30
52
  }
31
- this.currentValue = u, this.options.onUpdate(u);
53
+ this.currentValue = a, this.options.onUpdate(a);
32
54
  },
33
55
  onComplete: () => {
34
- this.currentValue = n, this.isAnimating = !1, this.controls = null, this.velocity = 0, this.options.onComplete();
56
+ this.currentValue = o, this.isAnimating = !1, this.controls = null, typeof this.velocity == "object" && this.velocity !== null ? Object.keys(this.velocity).forEach((a) => {
57
+ this.velocity[a] = 0;
58
+ }) : this.velocity = 0, this.options.onComplete();
59
+ }
60
+ });
61
+ });
62
+ g(this, "animateObject", (t, o) => {
63
+ const n = this.currentValue, e = Object.keys(n);
64
+ this.animationMap = /* @__PURE__ */ new Map(), this.activeAnimations.clear(), this.completedAnimations.clear(), this.updatedProperties.clear();
65
+ const m = { ...n }, a = {};
66
+ let f = !1;
67
+ const h = () => {
68
+ const c = e.filter((r) => !this.completedAnimations.has(r));
69
+ if (c.every((r) => this.updatedProperties.has(r)) && c.length > 0) {
70
+ if (typeof this.velocity == "object" && this.velocity) {
71
+ const r = performance.now();
72
+ Object.keys(m).forEach((s) => {
73
+ if (a[s]) {
74
+ const p = (r - a[s]) / 1e3, l = this.currentValue[s], d = m[s];
75
+ typeof l == "number" && typeof d == "number" && p > 0 && (this.velocity[s] = (d - l) / p / 1e3);
76
+ }
77
+ a[s] = r;
78
+ });
79
+ }
80
+ this.currentValue = { ...m }, this.options.onUpdate(this.currentValue), this.updatedProperties.clear(), !f && this.options.onStart && (f = !0, this.options.onStart());
35
81
  }
82
+ };
83
+ e.forEach((c) => {
84
+ this.activeAnimations.add(c);
85
+ const u = {
86
+ from: n[c],
87
+ to: t[c],
88
+ stiffness: this.options.spring.stiffness,
89
+ damping: this.options.spring.damping,
90
+ mass: 1
91
+ };
92
+ typeof this.velocity == "object" && this.velocity && c in this.velocity && (u.velocity = this.velocity[c] * 1e3);
93
+ const r = E({
94
+ ...u,
95
+ onUpdate: (s) => {
96
+ m[c] = s, this.updatedProperties.add(c), h();
97
+ },
98
+ onComplete: () => {
99
+ this.completedAnimations.add(c), this.updatedProperties.delete(c), this.completedAnimations.size === e.length && (this.currentValue = t, this.isAnimating = !1, this.animationMap = null, typeof this.velocity == "object" && this.velocity && Object.keys(this.velocity).forEach((s) => {
100
+ this.velocity[s] = 0;
101
+ }), this.options.onComplete());
102
+ }
103
+ });
104
+ this.animationMap.set(c, r);
36
105
  });
37
106
  });
38
- this.options = {
107
+ if (this.options = {
39
108
  from: t.from ?? 0,
40
109
  to: t.to ?? 1,
41
110
  spring: t.spring ?? { stiffness: 100, damping: 10 },
@@ -44,7 +113,13 @@ class v {
44
113
  onComplete: t.onComplete ?? (() => {
45
114
  }),
46
115
  onStart: t.onStart
47
- }, this.currentValue = this.options.from;
116
+ }, this.currentValue = this.options.from, typeof this.options.from == "object" && this.options.from !== null) {
117
+ const o = {};
118
+ Object.keys(this.options.from).forEach((n) => {
119
+ o[n] = 0;
120
+ }), this.velocity = o;
121
+ } else
122
+ this.velocity = 0;
48
123
  }
49
124
  // Animation control methods
50
125
  forward() {
@@ -56,12 +131,17 @@ class v {
56
131
  reverse() {
57
132
  const t = this.options.from;
58
133
  if (this.options.from = this.options.to, this.options.to = t, this.isAnimating) {
59
- const n = this.currentValue > (this.options.from + this.options.to) / 2;
60
- this.stop(), this.animate(!n);
134
+ const o = this.shouldReverse();
135
+ this.stop(), this.animate(!o);
61
136
  }
62
137
  }
138
+ shouldReverse() {
139
+ return typeof this.currentValue == "number" && typeof this.options.from == "number" && typeof this.options.to == "number" ? this.currentValue > (this.options.from + this.options.to) / 2 : !1;
140
+ }
63
141
  stop() {
64
- this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null);
142
+ this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null), this.animationMap && (this.animationMap.forEach((t) => {
143
+ t.stop();
144
+ }), this.animationMap.clear(), this.animationMap = null), this.updatedProperties.clear();
65
145
  }
66
146
  // State getters
67
147
  getVelocity() {
@@ -76,7 +156,9 @@ class v {
76
156
  getCurrentState() {
77
157
  return {
78
158
  position: this.currentValue,
79
- velocity: this.velocity
159
+ velocity: this.velocity,
160
+ from: this.options.from,
161
+ to: this.options.to
80
162
  };
81
163
  }
82
164
  // State setters
@@ -89,223 +171,302 @@ class v {
89
171
  // Configuration
90
172
  updateOptions(t) {
91
173
  if (this.options = { ...this.options, ...t }, this.isAnimating && this.controls) {
92
- const n = this.currentValue < this.options.to;
93
- this.stop(), this.animate(!n);
174
+ const o = this.shouldReverse();
175
+ this.stop(), this.animate(!o);
94
176
  }
95
177
  }
96
178
  // Static factory method
97
- static fromState(t, n) {
98
- const s = new v(n);
99
- return s.setValue(t.position), s.setVelocity(t.velocity), s;
179
+ static fromState(t, o) {
180
+ const n = new V(o);
181
+ return n.setValue(t.position), n.setVelocity(t.velocity), n;
100
182
  }
101
183
  }
102
- function k(o, t) {
103
- let n = null, s = null, c = null, u = null, l = !1;
104
- const S = async (f) => {
105
- var h;
106
- if (n && n.getIsAnimating() && !l) {
107
- const m = n.getCurrentState();
108
- n.stop(), s && (s.remove(), s = null), l = !0;
109
- const e = o();
110
- if (!e.out) return;
111
- const r = await Promise.resolve(e.out(f));
112
- n = v.fromState(m, {
113
- from: 1,
114
- to: 0,
115
- spring: r.spring,
116
- onStart: r.onStart,
117
- onUpdate: (i) => {
118
- var a;
119
- (a = r.tick) == null || a.call(r, i);
120
- },
121
- onComplete: () => {
122
- var i;
123
- n = null, l = !1, (i = r.onEnd) == null || i.call(r);
124
- }
125
- }), n.backward();
126
- return;
184
+ const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
185
+ runIn: async (t) => {
186
+ const { currentAnimation: o } = i;
187
+ if (o && o.direction === "out") {
188
+ const a = o.animator.getCurrentState();
189
+ if (o.animator.stop(), t.out) {
190
+ const f = await t.out, { from: h = 1, to: c = 0 } = f;
191
+ return {
192
+ config: f,
193
+ state: a,
194
+ from: h,
195
+ // OUT animation's from
196
+ to: c,
197
+ // OUT animation's to
198
+ direction: "backward"
199
+ // Will actually go 0→1
200
+ };
201
+ }
127
202
  }
128
- if (!n || !n.getIsAnimating()) {
129
- l = !0;
130
- const m = o();
131
- if (!m.in) return;
132
- const e = await Promise.resolve(m.in(f));
133
- (h = e.prepare) == null || h.call(e, f), n = new v({
203
+ const n = await t.in;
204
+ if (!n)
205
+ return {
206
+ state: {
207
+ position: 0,
208
+ velocity: 0
209
+ },
134
210
  from: 0,
135
211
  to: 1,
136
- spring: e.spring,
137
- onStart: e.onStart,
138
- onUpdate: (r) => {
139
- var i;
140
- (i = e.tick) == null || i.call(e, r);
212
+ direction: "forward"
213
+ };
214
+ const { from: e = 0, to: m = 1 } = n;
215
+ return {
216
+ config: n,
217
+ state: {
218
+ position: e,
219
+ velocity: 0
220
+ },
221
+ from: e,
222
+ to: m,
223
+ direction: "forward"
224
+ };
225
+ },
226
+ runOut: async (t) => {
227
+ const { currentAnimation: o } = i;
228
+ if (o && o.direction === "in") {
229
+ const a = o.animator.getCurrentState();
230
+ if (o.animator.stop(), t.in) {
231
+ const f = await t.in, { from: h = 0, to: c = 1 } = f;
232
+ return {
233
+ config: f,
234
+ state: {
235
+ position: a.position,
236
+ velocity: a.velocity
237
+ },
238
+ from: h,
239
+ // IN animation's from
240
+ to: c,
241
+ // IN animation's to
242
+ direction: "backward"
243
+ // Will actually go 1→0
244
+ };
245
+ }
246
+ }
247
+ const n = await t.out;
248
+ if (!n)
249
+ return {
250
+ state: {
251
+ position: 1,
252
+ velocity: 0
141
253
  },
142
- onComplete: () => {
143
- var r;
144
- n = null, l = !1, (r = e.onEnd) == null || r.call(e);
145
- }
146
- }), n.forward();
254
+ from: 1,
255
+ to: 0,
256
+ direction: "forward"
257
+ };
258
+ const { from: e = 1, to: m = 0 } = n;
259
+ return {
260
+ config: n,
261
+ state: {
262
+ position: e,
263
+ velocity: 0
264
+ },
265
+ from: e,
266
+ to: m,
267
+ direction: "forward"
268
+ };
269
+ }
270
+ });
271
+ function D(i, t) {
272
+ var u;
273
+ let o = null, n = null, e = null, m = null;
274
+ const a = {
275
+ get currentAnimation() {
276
+ return o;
147
277
  }
148
- };
149
- function w(f) {
150
- const h = () => {
151
- !c || !s || (u && c.contains(u) ? c.insertBefore(s, u) : c.appendChild(s));
152
- }, m = () => {
153
- var r;
154
- s && (s.remove(), s = null), n = null, l = !1, (r = t == null ? void 0 : t.onCleanupEnd) == null || r.call(t);
155
- }, e = o();
156
- if (s = f.cloneNode(!0), n && n.getIsAnimating() && l) {
157
- const r = n.getCurrentState();
158
- if (n.stop(), l = !1, !e.in) {
159
- s = null, m();
160
- return;
278
+ }, f = ((u = t == null ? void 0 : t.strategy) == null ? void 0 : u.call(t, a)) || I(a), h = async (r) => {
279
+ var y, S;
280
+ n && (n.remove(), n = null);
281
+ const s = i(), p = {
282
+ in: s.in && Promise.resolve(s.in(r)),
283
+ out: s.out && Promise.resolve(s.out(r))
284
+ }, l = await f.runIn(p);
285
+ if (!l.config)
286
+ return;
287
+ (S = (y = l.config).prepare) == null || S.call(y, r), l.config.wait && await l.config.wait();
288
+ const d = V.fromState(l.state, {
289
+ from: l.from,
290
+ to: l.to,
291
+ spring: l.config.spring,
292
+ onStart: l.config.onStart,
293
+ onUpdate: l.config.tick,
294
+ onComplete: () => {
295
+ var v, w;
296
+ o = null, (w = (v = l.config) == null ? void 0 : v.onEnd) == null || w.call(v);
161
297
  }
162
- Promise.resolve(e.in(s)).then(async (i) => {
163
- var p;
164
- const a = s && await ((p = e.out) == null ? void 0 : p.call(e, s));
165
- a != null && a.prepare && s && a.prepare(s), h(), n = v.fromState(r, {
166
- from: 0,
167
- to: 1,
168
- spring: i.spring,
169
- onStart: i.onStart,
170
- onUpdate: (y) => {
171
- var A;
172
- (A = i.tick) == null || A.call(i, y);
173
- },
174
- onComplete: () => {
175
- var y;
176
- (y = i.onEnd) == null || y.call(i), m();
177
- }
178
- }), n.backward();
179
- });
298
+ });
299
+ o = { animator: d, direction: "in" }, l.direction === "forward" ? d.forward() : d.backward();
300
+ }, c = async (r) => {
301
+ var S, v;
302
+ n = r;
303
+ const s = i(), p = {
304
+ in: s.in && Promise.resolve(s.in(r)),
305
+ out: s.out && Promise.resolve(s.out(r))
306
+ }, l = await f.runOut(p);
307
+ if (!l.config)
180
308
  return;
181
- }
182
- if (!n || !n.getIsAnimating() || !l) {
183
- if (l = !1, !e.out) {
184
- s = null, m();
185
- return;
309
+ (v = (S = l.config).prepare) == null || v.call(S, r), y(), l.config.wait && await l.config.wait();
310
+ const d = V.fromState(l.state, {
311
+ from: l.from,
312
+ to: l.to,
313
+ spring: l.config.spring,
314
+ onStart: l.config.onStart,
315
+ onUpdate: l.config.tick,
316
+ onComplete: () => {
317
+ var w, T, O;
318
+ (T = (w = l.config) == null ? void 0 : w.onEnd) == null || T.call(w), n && (n.remove(), n = null), o = null, (O = t == null ? void 0 : t.onCleanupEnd) == null || O.call(t);
186
319
  }
187
- Promise.resolve(e.out(s)).then((r) => {
188
- var i;
189
- s && ((i = r.prepare) == null || i.call(r, s)), h(), n = new v({
190
- from: 1,
191
- to: 0,
192
- spring: r.spring,
193
- onStart: r.onStart,
194
- onUpdate: (a) => {
195
- var p;
196
- (p = r.tick) == null || p.call(r, a);
197
- },
198
- onComplete: () => {
199
- var a;
200
- (a = r.onEnd) == null || a.call(r), m();
201
- }
202
- }), n.forward();
203
- });
320
+ });
321
+ o = { animator: d, direction: "out" }, l.direction === "forward" ? d.forward() : d.backward();
322
+ function y() {
323
+ !e || !n || (m && e.contains(m) ? e.insertBefore(n, m) : e.appendChild(n));
204
324
  }
205
- }
206
- return (f) => f ? (c = f.parentElement, u = f.nextElementSibling, o().in && S(f), () => {
207
- w(f);
208
- }) : void 0;
325
+ };
326
+ return (r) => {
327
+ if (r)
328
+ return e = r.parentElement, m = r.nextElementSibling, h(r), () => {
329
+ const s = r.cloneNode(!0);
330
+ c(s);
331
+ };
332
+ };
209
333
  }
210
- const g = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
211
- function U(o, t) {
212
- g.set(o, t);
213
- let n = x.get(o);
214
- return n || (n = k(
334
+ const A = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
335
+ function N(i, t, o) {
336
+ A.set(i, t);
337
+ let n = C.get(i);
338
+ return n || (n = D(
215
339
  () => {
216
- const s = g.get(o);
217
- return s || (console.warn(`Transition "${String(o)}" not found`), {});
340
+ const e = A.get(i);
341
+ return e || (console.warn(`Transition "${String(i)}" not found`), {});
218
342
  },
219
343
  {
220
- onCleanupEnd: () => I(o)
344
+ strategy: o,
345
+ onCleanupEnd: () => P(i)
221
346
  }
222
- ), x.set(o, n), n);
347
+ ), C.set(i, n), n);
223
348
  }
224
- function I(o) {
225
- g.delete(o), x.delete(o);
349
+ function P(i) {
350
+ A.delete(i), C.delete(i);
226
351
  }
227
- function L(o) {
228
- return U(o.key, {
229
- in: o.in,
230
- out: o.out
231
- });
352
+ function $() {
353
+ const i = U(new Error().stack);
354
+ return i ? `auto_${i.file}_${i.line}_${i.column}` : Symbol(`ssgoi_auto_${Date.now()}`);
355
+ }
356
+ const R = globalThis.FinalizationRegistry, j = R ? new R((i) => {
357
+ try {
358
+ P(i);
359
+ } catch {
360
+ }
361
+ }) : void 0;
362
+ function Y(i) {
363
+ const t = i.key ?? $();
364
+ if (i.ref && j)
365
+ try {
366
+ j.register(i.ref, t);
367
+ } catch {
368
+ }
369
+ return N(
370
+ t,
371
+ {
372
+ in: i.in,
373
+ out: i.out
374
+ },
375
+ i[k]
376
+ );
232
377
  }
233
- function W(o) {
234
- let t = null;
235
- const n = [...o.transitions], s = [];
236
- for (const e of o.transitions)
237
- e.symmetric && (n.some(
238
- (i) => i.from === e.to && i.to === e.from
239
- ) || s.push({
240
- from: e.to,
241
- to: e.from,
242
- transition: e.transition
243
- // Don't add symmetric flag to the reverse to avoid infinite loop
244
- }));
245
- n.push(...s);
246
- let c = null;
247
- const u = /* @__PURE__ */ new Map();
248
- let l = null;
249
- const S = () => {
250
- c && l && u.set(l, {
251
- x: c.scrollLeft,
252
- y: c.scrollTop
378
+ function F(i) {
379
+ const t = i.filter((o) => o.symmetric).map((o) => ({
380
+ from: o.to,
381
+ to: o.from,
382
+ transition: o.transition
383
+ }));
384
+ return [...i, ...t];
385
+ }
386
+ function L() {
387
+ let i = null;
388
+ const t = /* @__PURE__ */ new Map();
389
+ let o = null;
390
+ const n = () => {
391
+ i && o && t.set(o, {
392
+ x: i.scrollLeft,
393
+ y: i.scrollTop
253
394
  });
254
- }, w = (e, r) => {
255
- c || (c = b(e), c.addEventListener("scroll", S, {
256
- passive: !0
257
- })), l = r;
258
- }, f = () => {
259
- const e = t == null ? void 0 : t.from, r = t == null ? void 0 : t.to, i = e && u.has(e) ? u.get(e) : { x: 0, y: 0 }, a = r && u.has(r) ? u.get(r) : { x: 0, y: 0 };
260
- return {
261
- x: -a.x + i.x,
262
- y: -a.y + i.y
263
- };
264
395
  };
396
+ return {
397
+ startScrollTracking: (a, f) => {
398
+ i || (i = _(a), (i === document.documentElement ? window : i).addEventListener("scroll", n, {
399
+ passive: !0
400
+ })), o = f;
401
+ },
402
+ calculateScrollOffset: (a, f) => {
403
+ const h = a && t.has(a) ? t.get(a) : { x: 0, y: 0 }, c = f && t.has(f) ? t.get(f) : { x: 0, y: 0 };
404
+ return {
405
+ x: -c.x + h.x,
406
+ y: -c.y + h.y
407
+ };
408
+ }
409
+ };
410
+ }
411
+ function B(i) {
412
+ const {
413
+ transitions: t = [],
414
+ defaultTransition: o,
415
+ middleware: n = (u, r) => ({ from: u, to: r })
416
+ // Identity function as default
417
+ } = i;
418
+ let e = null;
419
+ const m = F(t), { startScrollTracking: a, calculateScrollOffset: f } = L();
265
420
  function h() {
266
- if (t != null && t.from && (t != null && t.to)) {
267
- const r = T(
268
- t.from,
269
- t.to,
270
- n
271
- ) || o.defaultTransition, a = { scrollOffset: f() };
272
- r && (r.out && t.outResolve && t.outResolve(
273
- (p) => r.out(p, a)
274
- ), r.in && t.inResolve && t.inResolve(
275
- (p) => r.in(p, a)
276
- )), t = null;
421
+ if (e != null && e.from && (e != null && e.to)) {
422
+ const { from: u, to: r } = n(
423
+ e.from,
424
+ e.to
425
+ ), p = z(
426
+ u,
427
+ r,
428
+ m
429
+ ) || o, d = { scrollOffset: f(e.from, e.to) };
430
+ p && (p.out && e.outResolve && e.outResolve(
431
+ (y) => p.out(y, d)
432
+ ), p.in && e.inResolve && e.inResolve(
433
+ (y) => p.in(y, d)
434
+ )), e = null;
277
435
  }
278
436
  }
279
- const m = async (e, r) => r === "in" && (!t || !t.from) ? () => ({}) : (t || (t = {}), r === "out" ? (t.from = e, new Promise((i) => {
280
- t.outResolve = i, h();
281
- })) : (t.to = e, new Promise((i) => {
282
- t.inResolve = i, h();
437
+ const c = async (u, r) => r === "in" && (!e || !e.from) ? () => ({}) : (e || (e = {}), r === "out" ? (e.from = u, new Promise((s) => {
438
+ e.outResolve = s, h();
439
+ })) : (e.to = u, new Promise((s) => {
440
+ e.inResolve = s, h();
283
441
  })));
284
- return (e) => ({
285
- key: e,
286
- in: async (r) => (w(r, e), (await m(e, "in"))(r)),
287
- out: async (r) => (await m(e, "out"))(r)
442
+ return (u) => ({
443
+ key: u,
444
+ in: async (r) => (a(r, u), (await c(u, "in"))(r)),
445
+ out: async (r) => (await c(u, "out"))(r)
288
446
  });
289
447
  }
290
- function T(o, t, n) {
291
- for (const s of n)
292
- if (V(o, s.from) && V(t, s.to))
293
- return s.transition;
294
- for (const s of n)
295
- if ((s.from === "*" || V(o, s.from)) && (s.to === "*" || V(t, s.to)))
296
- return s.transition;
448
+ function z(i, t, o) {
449
+ for (const n of o)
450
+ if (b(i, n.from) && b(t, n.to))
451
+ return n.transition;
452
+ for (const n of o)
453
+ if ((n.from === "*" || b(i, n.from)) && (n.to === "*" || b(t, n.to)))
454
+ return n.transition;
297
455
  return null;
298
456
  }
299
- function V(o, t) {
457
+ function b(i, t) {
300
458
  if (t === "*")
301
459
  return !0;
302
460
  if (t.endsWith("/*")) {
303
- const n = t.slice(0, -2);
304
- return o === n || o.startsWith(n + "/");
461
+ const o = t.slice(0, -2);
462
+ return i === o || i.startsWith(o + "/");
305
463
  }
306
- return o === t;
464
+ return i === t;
307
465
  }
308
466
  export {
309
- W as createSggoiTransitionContext,
310
- L as transition
467
+ k as TRANSITION_STRATEGY,
468
+ I as createDefaultStrategy,
469
+ B as createSggoiTransitionContext,
470
+ $ as generateAutoKey,
471
+ Y as transition
311
472
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={stiffness:170,damping:26},n={stiffness:120,damping:14},t={stiffness:180,damping:12},e={stiffness:210,damping:20},f={stiffness:280,damping:60},i={stiffness:280,damping:120},o={default:s,gentle:n,wobbly:t,stiff:e,slow:f,molasses:i};exports.config=o;exports.defaultSpring=s;exports.gentle=n;exports.molasses=i;exports.slow=f;exports.stiff=e;exports.wobbly=t;