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