@ssgoi/core 2.1.2 → 2.3.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 (60) hide show
  1. package/README.md +10 -11
  2. package/dist/animator.d.ts.map +1 -1
  3. package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
  4. package/dist/create-transition-callback.d.ts.map +1 -1
  5. package/dist/index.cjs +2 -1
  6. package/dist/index.js +326 -212
  7. package/dist/transition-strategy.d.ts +5 -0
  8. package/dist/transition-strategy.d.ts.map +1 -1
  9. package/dist/transition.d.ts.map +1 -1
  10. package/dist/transitions/blur.d.ts.map +1 -1
  11. package/dist/transitions/bounce.d.ts +1 -1
  12. package/dist/transitions/bounce.d.ts.map +1 -1
  13. package/dist/transitions/fly.d.ts.map +1 -1
  14. package/dist/transitions/index.cjs +1 -1
  15. package/dist/transitions/index.d.ts +1 -0
  16. package/dist/transitions/index.d.ts.map +1 -1
  17. package/dist/transitions/index.js +199 -142
  18. package/dist/transitions/mask.d.ts +31 -0
  19. package/dist/transitions/mask.d.ts.map +1 -0
  20. package/dist/transitions/none.d.ts +4 -4
  21. package/dist/transitions/none.d.ts.map +1 -1
  22. package/dist/transitions/rotate.d.ts +1 -1
  23. package/dist/transitions/scale.d.ts +1 -1
  24. package/dist/transitions/slide.d.ts +2 -2
  25. package/dist/transitions/slide.d.ts.map +1 -1
  26. package/dist/types.d.ts +31 -0
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/utils/get-positioned-parent.d.ts +7 -0
  29. package/dist/utils/get-positioned-parent.d.ts.map +1 -0
  30. package/dist/utils/get-rect.d.ts +7 -0
  31. package/dist/utils/get-rect.d.ts.map +1 -0
  32. package/dist/utils/get-scrolling-element.d.ts +6 -0
  33. package/dist/utils/get-scrolling-element.d.ts.map +1 -0
  34. package/dist/utils/index.d.ts +7 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/dist/utils/parse-caller-location.d.ts +6 -0
  37. package/dist/utils/parse-caller-location.d.ts.map +1 -0
  38. package/dist/utils/prepare-outgoing.d.ts +6 -0
  39. package/dist/utils/prepare-outgoing.d.ts.map +1 -0
  40. package/dist/utils/sleep.d.ts +7 -0
  41. package/dist/utils/sleep.d.ts.map +1 -0
  42. package/dist/utils.d.ts.map +1 -1
  43. package/dist/view-transitions/blind.d.ts +13 -0
  44. package/dist/view-transitions/blind.d.ts.map +1 -0
  45. package/dist/view-transitions/fade.d.ts.map +1 -1
  46. package/dist/view-transitions/film.d.ts +8 -0
  47. package/dist/view-transitions/film.d.ts.map +1 -0
  48. package/dist/view-transitions/hero.d.ts.map +1 -1
  49. package/dist/view-transitions/index.cjs +35 -1
  50. package/dist/view-transitions/index.d.ts +3 -0
  51. package/dist/view-transitions/index.d.ts.map +1 -1
  52. package/dist/view-transitions/index.js +448 -202
  53. package/dist/view-transitions/pinterest.d.ts.map +1 -1
  54. package/dist/view-transitions/slide.d.ts +8 -0
  55. package/dist/view-transitions/slide.d.ts.map +1 -0
  56. package/package.json +15 -8
  57. package/dist/utils-8Eptbv7c.cjs +0 -2
  58. package/dist/utils-DTRMUQW4.js +0 -31
  59. package/dist/view-transitions/ripple.d.ts +0 -7
  60. package/dist/view-transitions/ripple.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,28 +1,27 @@
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 {
1
+ var U = Object.defineProperty;
2
+ var _ = (n, t, o) => t in n ? U(n, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[t] = o;
3
+ var y = (n, t, o) => _(n, typeof t != "symbol" ? t + "" : t, o);
4
+ import { animate as P } from "popmotion";
5
+ class C {
7
6
  constructor(t) {
8
- g(this, "options");
9
- g(this, "currentValue");
10
- g(this, "velocity");
11
- g(this, "isAnimating", !1);
12
- g(this, "controls", null);
7
+ y(this, "options");
8
+ y(this, "currentValue");
9
+ y(this, "velocity");
10
+ y(this, "isAnimating", !1);
11
+ y(this, "controls", null);
13
12
  // 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) => {
13
+ y(this, "animationMap", null);
14
+ y(this, "activeAnimations", /* @__PURE__ */ new Set());
15
+ y(this, "completedAnimations", /* @__PURE__ */ new Set());
16
+ y(this, "updatedProperties", /* @__PURE__ */ new Set());
17
+ y(this, "animate", (t = !1) => {
19
18
  !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
20
19
  const o = t ? this.options.from : this.options.to;
21
20
  if (typeof this.currentValue == "object" && this.currentValue !== null) {
22
- this.animateObject(o, t);
21
+ this.animateObject(o);
23
22
  return;
24
23
  }
25
- let n = this.currentValue, e = performance.now();
24
+ let i = this.currentValue, e = performance.now();
26
25
  const m = {
27
26
  from: this.currentValue,
28
27
  to: o,
@@ -30,78 +29,80 @@ class V {
30
29
  damping: this.options.spring.damping,
31
30
  mass: 1
32
31
  };
33
- typeof this.velocity == "number" && (m.velocity = this.velocity * 1e3), this.controls = E({
32
+ typeof this.velocity == "number" && (m.velocity = this.velocity * 1e3), this.controls = P({
34
33
  ...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;
34
+ onUpdate: (l) => {
35
+ const p = performance.now(), r = (p - e) / 1e3;
36
+ if (r > 0) {
37
+ if (typeof l == "number" && typeof i == "number") {
38
+ const u = (l - i) / r;
39
+ this.velocity = u / 1e3;
40
+ } else if (typeof l == "object" && l !== null) {
41
+ const u = {};
42
+ Object.keys(l).forEach((f) => {
43
+ const c = l[f], a = i[f];
44
+ if (typeof c == "number" && typeof a == "number") {
45
+ const h = (c - a) / r;
46
+ u[f] = h / 1e3;
48
47
  }
49
- }), this.velocity = c;
48
+ }), this.velocity = u;
50
49
  }
51
- n = a, e = f;
50
+ i = l, e = p;
52
51
  }
53
- this.currentValue = a, this.options.onUpdate(a);
52
+ this.currentValue = l, this.options.onUpdate(l);
54
53
  },
55
54
  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;
55
+ this.currentValue = o, this.isAnimating = !1, this.controls = null, typeof this.velocity == "object" && this.velocity !== null ? Object.keys(this.velocity).forEach((l) => {
56
+ this.velocity[l] = 0;
58
57
  }) : this.velocity = 0, this.options.onComplete();
59
58
  }
60
59
  });
61
60
  });
62
- g(this, "animateObject", (t, o) => {
63
- const n = this.currentValue, e = Object.keys(n);
61
+ y(this, "animateObject", (t) => {
62
+ const o = this.currentValue, i = Object.keys(o);
64
63
  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) {
64
+ const e = { ...o }, m = {};
65
+ let l = !1;
66
+ const p = () => {
67
+ const r = i.filter((f) => !this.completedAnimations.has(f));
68
+ if (r.every(
69
+ (f) => this.updatedProperties.has(f)
70
+ ) && r.length > 0) {
70
71
  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);
72
+ const f = performance.now();
73
+ Object.keys(e).forEach((c) => {
74
+ if (m[c]) {
75
+ const a = (f - m[c]) / 1e3, h = this.currentValue[c], s = e[c];
76
+ typeof h == "number" && typeof s == "number" && a > 0 && (this.velocity[c] = (s - h) / a / 1e3);
76
77
  }
77
- a[s] = r;
78
+ m[c] = f;
78
79
  });
79
80
  }
80
- this.currentValue = { ...m }, this.options.onUpdate(this.currentValue), this.updatedProperties.clear(), !f && this.options.onStart && (f = !0, this.options.onStart());
81
+ this.currentValue = { ...e }, this.options.onUpdate(this.currentValue), this.updatedProperties.clear(), !l && this.options.onStart && (l = !0, this.options.onStart());
81
82
  }
82
83
  };
83
- e.forEach((c) => {
84
- this.activeAnimations.add(c);
84
+ i.forEach((r) => {
85
+ this.activeAnimations.add(r);
85
86
  const u = {
86
- from: n[c],
87
- to: t[c],
87
+ from: o[r],
88
+ to: t[r],
88
89
  stiffness: this.options.spring.stiffness,
89
90
  damping: this.options.spring.damping,
90
91
  mass: 1
91
92
  };
92
- typeof this.velocity == "object" && this.velocity && c in this.velocity && (u.velocity = this.velocity[c] * 1e3);
93
- const r = E({
93
+ typeof this.velocity == "object" && this.velocity && r in this.velocity && (u.velocity = this.velocity[r] * 1e3);
94
+ const f = P({
94
95
  ...u,
95
- onUpdate: (s) => {
96
- m[c] = s, this.updatedProperties.add(c), h();
96
+ onUpdate: (c) => {
97
+ e[r] = c, this.updatedProperties.add(r), p();
97
98
  },
98
99
  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;
100
+ this.completedAnimations.add(r), this.updatedProperties.delete(r), this.completedAnimations.size === i.length && (this.currentValue = t, this.isAnimating = !1, this.animationMap = null, typeof this.velocity == "object" && this.velocity && Object.keys(this.velocity).forEach((c) => {
101
+ this.velocity[c] = 0;
101
102
  }), this.options.onComplete());
102
103
  }
103
104
  });
104
- this.animationMap.set(c, r);
105
+ this.animationMap.set(r, f);
105
106
  });
106
107
  });
107
108
  if (this.options = {
@@ -115,8 +116,8 @@ class V {
115
116
  onStart: t.onStart
116
117
  }, this.currentValue = this.options.from, typeof this.options.from == "object" && this.options.from !== null) {
117
118
  const o = {};
118
- Object.keys(this.options.from).forEach((n) => {
119
- o[n] = 0;
119
+ Object.keys(this.options.from).forEach((i) => {
120
+ o[i] = 0;
120
121
  }), this.velocity = o;
121
122
  } else
122
123
  this.velocity = 0;
@@ -177,31 +178,31 @@ class V {
177
178
  }
178
179
  // Static factory method
179
180
  static fromState(t, o) {
180
- const n = new V(o);
181
- return n.setValue(t.position), n.setVelocity(t.velocity), n;
181
+ const i = new C(o);
182
+ return i.setValue(t.position), i.setVelocity(t.velocity), i;
182
183
  }
183
184
  }
184
- const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
185
+ const x = Symbol.for("TRANSITION_STRATEGY"), I = (n) => ({
185
186
  runIn: async (t) => {
186
- const { currentAnimation: o } = i;
187
+ const { currentAnimation: o } = n;
187
188
  if (o && o.direction === "out") {
188
- const a = o.animator.getCurrentState();
189
+ const l = o.animator.getCurrentState();
189
190
  if (o.animator.stop(), t.out) {
190
- const f = await t.out, { from: h = 1, to: c = 0 } = f;
191
+ const p = await t.out, { from: r = 1, to: u = 0 } = p;
191
192
  return {
192
- config: f,
193
- state: a,
194
- from: h,
193
+ config: p,
194
+ state: l,
195
+ from: r,
195
196
  // OUT animation's from
196
- to: c,
197
+ to: u,
197
198
  // OUT animation's to
198
199
  direction: "backward"
199
200
  // Will actually go 0→1
200
201
  };
201
202
  }
202
203
  }
203
- const n = await t.in;
204
- if (!n)
204
+ const i = await t.in;
205
+ if (!i)
205
206
  return {
206
207
  state: {
207
208
  position: 0,
@@ -211,9 +212,9 @@ const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
211
212
  to: 1,
212
213
  direction: "forward"
213
214
  };
214
- const { from: e = 0, to: m = 1 } = n;
215
+ const { from: e = 0, to: m = 1 } = i;
215
216
  return {
216
- config: n,
217
+ config: i,
217
218
  state: {
218
219
  position: e,
219
220
  velocity: 0
@@ -224,28 +225,28 @@ const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
224
225
  };
225
226
  },
226
227
  runOut: async (t) => {
227
- const { currentAnimation: o } = i;
228
+ const { currentAnimation: o } = n;
228
229
  if (o && o.direction === "in") {
229
- const a = o.animator.getCurrentState();
230
+ const l = o.animator.getCurrentState();
230
231
  if (o.animator.stop(), t.in) {
231
- const f = await t.in, { from: h = 0, to: c = 1 } = f;
232
+ const p = await t.in, { from: r = 0, to: u = 1 } = p;
232
233
  return {
233
- config: f,
234
+ config: p,
234
235
  state: {
235
- position: a.position,
236
- velocity: a.velocity
236
+ position: l.position,
237
+ velocity: l.velocity
237
238
  },
238
- from: h,
239
+ from: r,
239
240
  // IN animation's from
240
- to: c,
241
+ to: u,
241
242
  // IN animation's to
242
243
  direction: "backward"
243
244
  // Will actually go 1→0
244
245
  };
245
246
  }
246
247
  }
247
- const n = await t.out;
248
- if (!n)
248
+ const i = await t.out;
249
+ if (!i)
249
250
  return {
250
251
  state: {
251
252
  position: 1,
@@ -255,9 +256,9 @@ const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
255
256
  to: 0,
256
257
  direction: "forward"
257
258
  };
258
- const { from: e = 1, to: m = 0 } = n;
259
+ const { from: e = 1, to: m = 0 } = i;
259
260
  return {
260
- config: n,
261
+ config: i,
261
262
  state: {
262
263
  position: e,
263
264
  velocity: 0
@@ -267,206 +268,319 @@ const k = Symbol.for("TRANSITION_STRATEGY"), I = (i) => ({
267
268
  direction: "forward"
268
269
  };
269
270
  }
271
+ }), N = () => ({
272
+ runIn: async (n) => {
273
+ const t = await n.in;
274
+ if (!t)
275
+ return {
276
+ state: {
277
+ position: 0,
278
+ velocity: 0
279
+ },
280
+ from: 0,
281
+ to: 1,
282
+ direction: "forward"
283
+ };
284
+ const { from: o = 0, to: i = 1 } = t;
285
+ return {
286
+ config: t,
287
+ state: {
288
+ position: o,
289
+ velocity: 0
290
+ },
291
+ from: o,
292
+ to: i,
293
+ direction: "forward"
294
+ };
295
+ },
296
+ runOut: async (n) => {
297
+ const t = await n.out;
298
+ if (!t)
299
+ return {
300
+ state: {
301
+ position: 1,
302
+ velocity: 0
303
+ },
304
+ from: 1,
305
+ to: 0,
306
+ direction: "forward"
307
+ };
308
+ const { from: o = 1, to: i = 0 } = t;
309
+ return {
310
+ config: t,
311
+ state: {
312
+ position: o,
313
+ velocity: 0
314
+ },
315
+ from: o,
316
+ to: i,
317
+ direction: "forward"
318
+ };
319
+ }
270
320
  });
271
- function D(i, t) {
272
- var u;
273
- let o = null, n = null, e = null, m = null;
274
- const a = {
321
+ function k(n, t) {
322
+ var f;
323
+ let o = null, i = null, e = null, m = null;
324
+ const l = {
275
325
  get currentAnimation() {
276
326
  return o;
277
327
  }
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)
328
+ }, p = ((f = t == null ? void 0 : t.strategy) == null ? void 0 : f.call(t, l)) || I(l), r = async (c) => {
329
+ var w, S;
330
+ i && (i.remove(), i = null);
331
+ const a = n(), h = {
332
+ in: a.in && Promise.resolve(a.in(c)),
333
+ out: a.out && Promise.resolve(a.out(c))
334
+ }, s = await p.runIn(h);
335
+ if (!s.config)
286
336
  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,
337
+ (S = (w = s.config).prepare) == null || S.call(w, c), s.config.wait && await s.config.wait();
338
+ const g = C.fromState(s.state, {
339
+ from: s.from,
340
+ to: s.to,
341
+ spring: s.config.spring,
342
+ onStart: s.config.onStart,
343
+ onUpdate: s.config.tick,
294
344
  onComplete: () => {
295
- var v, w;
296
- o = null, (w = (v = l.config) == null ? void 0 : v.onEnd) == null || w.call(v);
345
+ var v, d;
346
+ o = null, (d = (v = s.config) == null ? void 0 : v.onEnd) == null || d.call(v);
297
347
  }
298
348
  });
299
- o = { animator: d, direction: "in" }, l.direction === "forward" ? d.forward() : d.backward();
300
- }, c = async (r) => {
349
+ o = { animator: g, direction: "in" }, s.direction === "forward" ? g.forward() : g.backward();
350
+ }, u = async (c) => {
301
351
  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)
352
+ i = c;
353
+ const a = n(), h = {
354
+ in: a.in && Promise.resolve(a.in(c)),
355
+ out: a.out && Promise.resolve(a.out(c))
356
+ }, s = await p.runOut(h);
357
+ if (!s.config)
308
358
  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,
359
+ (v = (S = s.config).prepare) == null || v.call(S, c), w(), s.config.wait && await s.config.wait();
360
+ const g = C.fromState(s.state, {
361
+ from: s.from,
362
+ to: s.to,
363
+ spring: s.config.spring,
364
+ onStart: s.config.onStart,
365
+ onUpdate: s.config.tick,
316
366
  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);
367
+ var d, V, T;
368
+ (V = (d = s.config) == null ? void 0 : d.onEnd) == null || V.call(d), i && (i.remove(), i = null), o = null, (T = t == null ? void 0 : t.onCleanupEnd) == null || T.call(t);
319
369
  }
320
370
  });
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));
371
+ o = { animator: g, direction: "out" }, s.direction === "forward" ? g.forward() : g.backward();
372
+ function w() {
373
+ !e || !i || (m && e.contains(m) ? e.insertBefore(i, m) : e.appendChild(i));
324
374
  }
325
375
  };
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);
376
+ return (c) => {
377
+ if (c)
378
+ return e = c.parentElement, m = c.nextElementSibling, r(c), () => {
379
+ const a = c.cloneNode(!0);
380
+ u(a);
331
381
  };
332
382
  };
333
383
  }
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(
384
+ const D = 3, $ = (n) => {
385
+ if (!n) return null;
386
+ const t = n.split(`
387
+ `).map((o) => o.trim());
388
+ for (let o = D; o < Math.min(t.length, 6); o++) {
389
+ const i = t[o], e = i == null ? void 0 : i.match(/\(?([^):]+):(\d+):(\d+)\)?$/);
390
+ if (!e)
391
+ continue;
392
+ const m = e[1] ?? "", l = e[2] ?? "0", p = e[3] ?? "0";
393
+ return { file: m.split(/[\\/]/).pop() || m, line: l, column: p };
394
+ }
395
+ return null;
396
+ }, A = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
397
+ function F(n, t, o) {
398
+ A.set(n, t);
399
+ let i = E.get(n);
400
+ return i || (i = k(
339
401
  () => {
340
- const e = A.get(i);
341
- return e || (console.warn(`Transition "${String(i)}" not found`), {});
402
+ const e = A.get(n);
403
+ return e || (console.warn(`Transition "${String(n)}" not found`), {});
342
404
  },
343
405
  {
344
406
  strategy: o,
345
- onCleanupEnd: () => P(i)
407
+ onCleanupEnd: () => M(n)
346
408
  }
347
- ), C.set(i, n), n);
409
+ ), E.set(n, i), i);
348
410
  }
349
- function P(i) {
350
- A.delete(i), C.delete(i);
411
+ function M(n) {
412
+ A.delete(n), E.delete(n);
351
413
  }
352
- function $() {
353
- const i = U(new Error().stack);
354
- return i ? `auto_${i.file}_${i.line}_${i.column}` : Symbol(`ssgoi_auto_${Date.now()}`);
414
+ function K() {
415
+ const n = $(new Error().stack);
416
+ return n ? `auto_${n.file}_${n.line}_${n.column}` : Symbol(`ssgoi_auto_${Date.now()}`);
355
417
  }
356
- const R = globalThis.FinalizationRegistry, j = R ? new R((i) => {
418
+ const R = globalThis.FinalizationRegistry, O = R ? new R((n) => {
357
419
  try {
358
- P(i);
420
+ M(n);
359
421
  } catch {
360
422
  }
361
423
  }) : void 0;
362
- function Y(i) {
363
- const t = i.key ?? $();
364
- if (i.ref && j)
424
+ function X(n) {
425
+ const t = n.key ?? K();
426
+ if (n.ref && O)
365
427
  try {
366
- j.register(i.ref, t);
428
+ O.register(n.ref, t);
367
429
  } catch {
368
430
  }
369
- return N(
431
+ return F(
370
432
  t,
371
433
  {
372
- in: i.in,
373
- out: i.out
434
+ in: n.in,
435
+ out: n.out
374
436
  },
375
- i[k]
437
+ n[x]
376
438
  );
377
439
  }
378
- function F(i) {
379
- const t = i.filter((o) => o.symmetric).map((o) => ({
440
+ const W = (n) => {
441
+ let t = n.parentElement;
442
+ for (; t && t !== document.body; ) {
443
+ const o = window.getComputedStyle(t), i = o.overflow + o.overflowY + o.overflowX;
444
+ if (i.includes("auto") || i.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
445
+ return t;
446
+ t = t.parentElement;
447
+ }
448
+ return document.documentElement;
449
+ }, j = (n) => {
450
+ let t = n.parentElement;
451
+ for (; t && t !== document.body; ) {
452
+ const o = window.getComputedStyle(t).position;
453
+ if (o === "relative" || o === "absolute" || o === "fixed" || o === "sticky")
454
+ return t;
455
+ t = t.parentElement;
456
+ }
457
+ return document.body;
458
+ };
459
+ function L(n) {
460
+ const t = n.filter((o) => o.symmetric).map((o) => ({
380
461
  from: o.to,
381
462
  to: o.from,
382
463
  transition: o.transition
383
464
  }));
384
- return [...i, ...t];
465
+ return [...n, ...t];
385
466
  }
386
- function L() {
387
- let i = null;
467
+ function z() {
468
+ let n = null;
388
469
  const t = /* @__PURE__ */ new Map();
389
470
  let o = null;
390
- const n = () => {
391
- i && o && t.set(o, {
392
- x: i.scrollLeft,
393
- y: i.scrollTop
471
+ const i = () => {
472
+ n && o && t.set(o, {
473
+ x: n.scrollLeft,
474
+ y: n.scrollTop
394
475
  });
395
476
  };
396
477
  return {
397
- startScrollTracking: (a, f) => {
398
- i || (i = _(a), (i === document.documentElement ? window : i).addEventListener("scroll", n, {
478
+ startScrollTracking: (r, u) => {
479
+ n || (n = W(r), (n === document.documentElement ? window : n).addEventListener("scroll", i, {
399
480
  passive: !0
400
- })), o = f;
481
+ })), o = u;
401
482
  },
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 };
483
+ calculateScrollOffset: (r, u) => {
484
+ const f = r && t.has(r) ? t.get(r) : { x: 0, y: 0 }, c = u && t.has(u) ? t.get(u) : { x: 0, y: 0 };
404
485
  return {
405
- x: -c.x + h.x,
406
- y: -c.y + h.y
486
+ x: -c.x + f.x,
487
+ y: -c.y + f.y
407
488
  };
408
- }
489
+ },
490
+ getScrollContainer: () => n,
491
+ getScrollPosition: (r) => r && t.has(r) ? t.get(r) : { x: 0, y: 0 }
409
492
  };
410
493
  }
411
- function B(i) {
494
+ function B(n) {
412
495
  const {
413
496
  transitions: t = [],
414
497
  defaultTransition: o,
415
- middleware: n = (u, r) => ({ from: u, to: r })
498
+ middleware: i = (a, h) => ({ from: a, to: h })
416
499
  // Identity function as default
417
- } = i;
500
+ } = n;
418
501
  let e = null;
419
- const m = F(t), { startScrollTracking: a, calculateScrollOffset: f } = L();
420
- function h() {
502
+ const m = L(t), {
503
+ startScrollTracking: l,
504
+ calculateScrollOffset: p,
505
+ getScrollContainer: r,
506
+ getScrollPosition: u
507
+ } = z();
508
+ function f() {
421
509
  if (e != null && e.from && (e != null && e.to)) {
422
- const { from: u, to: r } = n(
510
+ const { from: a, to: h } = i(
423
511
  e.from,
424
512
  e.to
425
- ), p = z(
426
- u,
427
- r,
513
+ ), g = Y(
514
+ a,
515
+ h,
428
516
  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)
517
+ ) || o, w = p(
518
+ e.from,
519
+ e.to
520
+ ), S = {
521
+ scrollOffset: w,
522
+ scroll: u(e.from),
523
+ get scrollingElement() {
524
+ return r() || document.documentElement;
525
+ },
526
+ get positionedParent() {
527
+ const d = r();
528
+ return d ? j(d) : document.body;
529
+ }
530
+ }, v = {
531
+ scrollOffset: w,
532
+ scroll: u(e.to),
533
+ get scrollingElement() {
534
+ return r() || document.documentElement;
535
+ },
536
+ get positionedParent() {
537
+ const d = r();
538
+ return d ? j(d) : document.body;
539
+ }
540
+ };
541
+ g && (g.out && e.outResolve && e.outResolve(
542
+ (d) => g.out(d, S)
543
+ ), g.in && e.inResolve && e.inResolve(
544
+ (d) => g.in(d, v)
434
545
  )), e = null;
435
546
  }
436
547
  }
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();
548
+ const c = async (a, h) => h === "in" && (!e || !e.from) ? () => ({}) : (e || (e = {}), h === "out" ? (e.from = a, new Promise((s) => {
549
+ e.outResolve = s, f();
550
+ })) : (e.to = a, new Promise((s) => {
551
+ e.inResolve = s, f();
441
552
  })));
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)
553
+ return (a) => ({
554
+ key: a,
555
+ in: async (h) => (l(h, a), (await c(a, "in"))(h)),
556
+ out: async (h) => (await c(a, "out"))(h),
557
+ // Add page transition strategy for page-level transitions
558
+ [x]: N
446
559
  });
447
560
  }
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;
561
+ function Y(n, t, o) {
562
+ for (const i of o)
563
+ if (b(n, i.from) && b(t, i.to))
564
+ return i.transition;
565
+ for (const i of o)
566
+ if ((i.from === "*" || b(n, i.from)) && (i.to === "*" || b(t, i.to)))
567
+ return i.transition;
455
568
  return null;
456
569
  }
457
- function b(i, t) {
570
+ function b(n, t) {
458
571
  if (t === "*")
459
572
  return !0;
460
573
  if (t.endsWith("/*")) {
461
574
  const o = t.slice(0, -2);
462
- return i === o || i.startsWith(o + "/");
575
+ return n === o || n.startsWith(o + "/");
463
576
  }
464
- return i === t;
577
+ return n === t;
465
578
  }
466
579
  export {
467
- k as TRANSITION_STRATEGY,
580
+ x as TRANSITION_STRATEGY,
468
581
  I as createDefaultStrategy,
582
+ N as createPageTransitionStrategy,
469
583
  B as createSggoiTransitionContext,
470
- $ as generateAutoKey,
471
- Y as transition
584
+ K as generateAutoKey,
585
+ X as transition
472
586
  };