@wyxos/vibe 4.5.1 → 4.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/ReelFeed.vue.d.ts +4 -0
- package/lib/components/ReelLayout.vue.d.ts +4 -0
- package/lib/components/VibeSurface.vue.d.ts +2 -0
- package/lib/core/activeItemRemoval.d.ts +2 -3
- package/lib/core/exactMediaRemovalController.d.ts +2 -9
- package/lib/core/feed.d.ts +10 -0
- package/lib/core/itemRemovalController.d.ts +3 -1
- package/lib/core/reelForwardController.d.ts +24 -0
- package/lib/core/reelRemovalTransitionController.d.ts +21 -0
- package/lib/core/reelScrollTransition.d.ts +1 -0
- package/lib/core/removalControllers.d.ts +23 -0
- package/lib/index.cjs +1 -1
- package/lib/index.js +666 -524
- package/lib/style.css +1 -1
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var I = {
|
|
|
85
85
|
onClick: n[0] ||= (e) => t.$emit("retryEnd")
|
|
86
86
|
}, " Check for more ", 8, B)]))])) : a("", !0);
|
|
87
87
|
}
|
|
88
|
-
}),
|
|
88
|
+
}), H = /* @__PURE__ */ u({
|
|
89
89
|
__name: "FeedFooter",
|
|
90
90
|
props: {
|
|
91
91
|
actions: {},
|
|
@@ -136,7 +136,7 @@ var I = {
|
|
|
136
136
|
"load-more-locked"
|
|
137
137
|
]));
|
|
138
138
|
}
|
|
139
|
-
}),
|
|
139
|
+
}), U = ["role"], W = { class: "gallery-status" }, ee = /* @__PURE__ */ u({
|
|
140
140
|
__name: "FeedStatus",
|
|
141
141
|
props: {
|
|
142
142
|
actions: {},
|
|
@@ -150,7 +150,7 @@ var I = {
|
|
|
150
150
|
return (n, u) => (y(), o("main", {
|
|
151
151
|
class: "gallery-shell",
|
|
152
152
|
role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
|
|
153
|
-
}, [s("p",
|
|
153
|
+
}, [s("p", W, [r.state.error ? (y(), o(e, { key: 0 }, [c(" Unable to load media. ")], 64)) : r.state.isLoading ? (y(), o(e, { key: 1 }, [c(" Loading media… ")], 64)) : (y(), o(e, { key: 2 }, [c(" No media found. ")], 64))]), t.feedFooter ? (y(), i(H, {
|
|
154
154
|
key: 0,
|
|
155
155
|
actions: t.actions,
|
|
156
156
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -171,36 +171,36 @@ var I = {
|
|
|
171
171
|
"is-loading",
|
|
172
172
|
"load-more-locked",
|
|
173
173
|
"state"
|
|
174
|
-
])) : a("", !0)], 8,
|
|
174
|
+
])) : a("", !0)], 8, U));
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
function
|
|
177
|
+
function G(e) {
|
|
178
178
|
return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
|
|
179
179
|
}
|
|
180
180
|
//#endregion
|
|
181
181
|
//#region src/core/masonry.ts
|
|
182
|
-
function
|
|
182
|
+
function te(e) {
|
|
183
183
|
let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
|
|
184
184
|
return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function ne(e) {
|
|
187
187
|
return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function re(e) {
|
|
190
190
|
return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function K(e, t) {
|
|
193
193
|
let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
|
|
194
194
|
return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function q(e, t, n) {
|
|
197
197
|
if (t <= 0 || e.length === 0) return {
|
|
198
198
|
columns: 0,
|
|
199
199
|
height: 0,
|
|
200
200
|
items: []
|
|
201
201
|
};
|
|
202
202
|
let r = Math.max(0, n.gap), i = Number.isFinite(n.additionalHeight) ? Math.max(0, n.additionalHeight ?? 0) : 0, a = Math.max(1, n.minColumnWidth), o = Math.max(1, Math.floor((t + r) / (a + r))), s = (t - r * (o - 1)) / o, c = Array.from({ length: o }, () => 0), l = e.map((e) => {
|
|
203
|
-
let t =
|
|
203
|
+
let t = ne(c), n = s * te(e) + i, a = {
|
|
204
204
|
x: t * (s + r),
|
|
205
205
|
y: c[t],
|
|
206
206
|
width: s,
|
|
@@ -216,10 +216,10 @@ function K(e, t, n) {
|
|
|
216
216
|
}
|
|
217
217
|
//#endregion
|
|
218
218
|
//#region src/core/scrollbar.ts
|
|
219
|
-
function
|
|
219
|
+
function J(e, t, n) {
|
|
220
220
|
return Math.min(n, Math.max(t, e));
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
|
|
223
223
|
let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
|
|
224
224
|
if (!(c > 0 && o > 0)) return {
|
|
225
225
|
maximumScrollPosition: c,
|
|
@@ -228,23 +228,23 @@ function J({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
|
|
|
228
228
|
thumbSize: o,
|
|
229
229
|
thumbTravel: 0
|
|
230
230
|
};
|
|
231
|
-
let l =
|
|
231
|
+
let l = J(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
|
|
232
232
|
return {
|
|
233
233
|
maximumScrollPosition: c,
|
|
234
234
|
scrollable: !0,
|
|
235
|
-
thumbOffset: u * (
|
|
235
|
+
thumbOffset: u * (J(n, 0, c) / c),
|
|
236
236
|
thumbSize: l,
|
|
237
237
|
thumbTravel: u
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
//#endregion
|
|
241
241
|
//#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
|
|
242
|
-
var
|
|
242
|
+
var ie = ["aria-hidden"], ae = [
|
|
243
243
|
"aria-controls",
|
|
244
244
|
"aria-valuemax",
|
|
245
245
|
"aria-valuenow",
|
|
246
246
|
"tabindex"
|
|
247
|
-
],
|
|
247
|
+
], oe = 32, X = 40, Z = 120, se = /* @__PURE__ */ u({
|
|
248
248
|
__name: "GalleryScrollbar",
|
|
249
249
|
props: {
|
|
250
250
|
contentSize: {},
|
|
@@ -273,9 +273,9 @@ var ae = ["aria-hidden"], oe = [
|
|
|
273
273
|
}
|
|
274
274
|
function j() {
|
|
275
275
|
let e = t.scrollElement, n = i.value;
|
|
276
|
-
return !e || !n ? r :
|
|
276
|
+
return !e || !n ? r : Y({
|
|
277
277
|
contentSize: e.scrollHeight,
|
|
278
|
-
minimumThumbSize:
|
|
278
|
+
minimumThumbSize: oe,
|
|
279
279
|
scrollPosition: e.scrollTop,
|
|
280
280
|
trackSize: n.clientHeight,
|
|
281
281
|
viewportSize: e.clientHeight
|
|
@@ -374,7 +374,7 @@ var ae = ["aria-hidden"], oe = [
|
|
|
374
374
|
onPointerdown: I,
|
|
375
375
|
onPointermove: L,
|
|
376
376
|
onPointerup: R
|
|
377
|
-
}, null, 44,
|
|
377
|
+
}, null, 44, ae)], 42, ie));
|
|
378
378
|
}
|
|
379
379
|
}), ce = (e) => {
|
|
380
380
|
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
@@ -693,45 +693,45 @@ var Oe = /* @__PURE__ */ u({
|
|
|
693
693
|
function x(e = !1, t = "pointer") {
|
|
694
694
|
e && b("activate", t);
|
|
695
695
|
}
|
|
696
|
-
let S = n(() => j(c.item)), E = n(() => M(c.item, c.mediaIndex)), D = n(() => N(c.item, E.value)), P = n(() => c.mediaSource === "original" ? D.value.src : D.value.preview.src), F = n(() => c.mediaSource === "original" ? D.value.width : D.value.preview.width), I = n(() => c.mediaSource === "original" ? D.value.height : D.value.preview.height), L = C(null), R = C(0), z = C(0), B = C(!0), V = C(!1),
|
|
697
|
-
function
|
|
696
|
+
let S = n(() => j(c.item)), E = n(() => M(c.item, c.mediaIndex)), D = n(() => N(c.item, E.value)), P = n(() => c.mediaSource === "original" ? D.value.src : D.value.preview.src), F = n(() => c.mediaSource === "original" ? D.value.width : D.value.preview.width), I = n(() => c.mediaSource === "original" ? D.value.height : D.value.preview.height), L = C(null), R = C(0), z = C(0), B = C(!0), V = C(!1), H = C(1), U = 1, W = n(() => c.interactive && !!(c.cardHeader || c.cardFooter));
|
|
697
|
+
function ee(e) {
|
|
698
698
|
return e.detail === 0 ? "keyboard" : "pointer";
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function G(e, t) {
|
|
701
701
|
let n = S.value.length, r = (e + n) % n;
|
|
702
702
|
r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
|
|
703
703
|
}
|
|
704
|
-
function
|
|
704
|
+
function te(e, t, n) {
|
|
705
705
|
return t === 1 ? e * 16 : t === 2 ? e * n : e;
|
|
706
706
|
}
|
|
707
|
-
function
|
|
707
|
+
function ne() {
|
|
708
708
|
d = 0, f = !1, u !== null && clearTimeout(u), u = null;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
u !== null && clearTimeout(u), u = setTimeout(
|
|
710
|
+
function re() {
|
|
711
|
+
u !== null && clearTimeout(u), u = setTimeout(ne, Xe);
|
|
712
712
|
}
|
|
713
|
-
function
|
|
713
|
+
function K(e) {
|
|
714
714
|
if (S.value.length <= 1) return;
|
|
715
|
-
let t = e.currentTarget?.clientWidth || 1, n =
|
|
716
|
-
if (n === 0 || (e.preventDefault(),
|
|
715
|
+
let t = e.currentTarget?.clientWidth || 1, n = te(e.deltaX, e.deltaMode, t);
|
|
716
|
+
if (n === 0 || (e.preventDefault(), re(), f) || (d += n, Math.abs(d) < Ze)) return;
|
|
717
717
|
let r = Math.sign(d);
|
|
718
|
-
d = 0, f = !0,
|
|
718
|
+
d = 0, f = !0, G(E.value + r);
|
|
719
719
|
}
|
|
720
|
-
function
|
|
720
|
+
function q(e) {
|
|
721
721
|
let t = e.touches[0];
|
|
722
722
|
c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function J(e) {
|
|
725
725
|
let t = e.changedTouches[0];
|
|
726
726
|
if (p === null || h === null || !t) return;
|
|
727
727
|
let n = p - t.clientX, r = h - t.clientY;
|
|
728
|
-
p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ye ||
|
|
728
|
+
p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ye || G(E.value + Math.sign(n)));
|
|
729
729
|
}
|
|
730
|
-
let
|
|
731
|
-
function
|
|
732
|
-
c.layout === "reel" && (e.stopPropagation(),
|
|
730
|
+
let Y = n(() => De(P.value));
|
|
731
|
+
function ie(e) {
|
|
732
|
+
c.layout === "reel" && (e.stopPropagation(), ae());
|
|
733
733
|
}
|
|
734
|
-
async function
|
|
734
|
+
async function ae() {
|
|
735
735
|
if (L.value) {
|
|
736
736
|
if (V.value) {
|
|
737
737
|
L.value.pause();
|
|
@@ -744,12 +744,12 @@ var Oe = /* @__PURE__ */ u({
|
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function oe(e) {
|
|
748
748
|
return Number.isFinite(e) ? Math.max(0, e) : 0;
|
|
749
749
|
}
|
|
750
750
|
function X(e) {
|
|
751
751
|
let t = e?.currentTarget ?? L.value;
|
|
752
|
-
t && (R.value =
|
|
752
|
+
t && (R.value = oe(t.currentTime), z.value = oe(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
|
|
753
753
|
}
|
|
754
754
|
function Z(e) {
|
|
755
755
|
X(e), b("ready", E.value);
|
|
@@ -759,20 +759,20 @@ var Oe = /* @__PURE__ */ u({
|
|
|
759
759
|
}
|
|
760
760
|
function ce(e) {
|
|
761
761
|
let t = L.value;
|
|
762
|
-
!t || !Number.isFinite(e) || (t.currentTime = Math.min(
|
|
762
|
+
!t || !Number.isFinite(e) || (t.currentTime = Math.min(oe(t.duration), Math.max(0, e)), R.value = t.currentTime);
|
|
763
763
|
}
|
|
764
764
|
function le(e) {
|
|
765
765
|
let t = L.value;
|
|
766
766
|
if (!t || !Number.isFinite(e)) return;
|
|
767
767
|
let n = Math.min(1, Math.max(0, e));
|
|
768
|
-
t.volume = n, t.muted = n === 0, n > 0 && (
|
|
768
|
+
t.volume = n, t.muted = n === 0, n > 0 && (U = n), X();
|
|
769
769
|
}
|
|
770
770
|
function ue() {
|
|
771
771
|
let e = L.value;
|
|
772
|
-
e && (e.muted && e.volume === 0 && (e.volume =
|
|
772
|
+
e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, X());
|
|
773
773
|
}
|
|
774
774
|
return _(() => {
|
|
775
|
-
|
|
775
|
+
ne();
|
|
776
776
|
}), (n, r) => (y(), o("article", {
|
|
777
777
|
"data-post-id": e.item.postId,
|
|
778
778
|
"data-media-index": E.value,
|
|
@@ -786,10 +786,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
786
786
|
"aria-hidden": e.leaving || void 0,
|
|
787
787
|
"aria-busy": e.previewState === "loading",
|
|
788
788
|
inert: e.leaving || void 0,
|
|
789
|
-
role: e.interactive && !e.leaving && !
|
|
790
|
-
tabindex: e.interactive && !e.leaving && !
|
|
791
|
-
onClick: r[11] ||= (t) => x(e.interactive && !
|
|
792
|
-
onKeydown: [r[12] ||= k((t) => x(e.interactive && !
|
|
789
|
+
role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
|
|
790
|
+
tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
|
|
791
|
+
onClick: r[11] ||= (t) => x(e.interactive && !W.value, ee(t)),
|
|
792
|
+
onKeydown: [r[12] ||= k((t) => x(e.interactive && !W.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !W.value, "keyboard"), ["prevent"]), ["space"])]
|
|
793
793
|
}, [s("div", Re, [
|
|
794
794
|
e.cardHeader ? (y(), i(Oe, {
|
|
795
795
|
key: 0,
|
|
@@ -817,13 +817,13 @@ var Oe = /* @__PURE__ */ u({
|
|
|
817
817
|
s("div", {
|
|
818
818
|
class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
|
|
819
819
|
"data-media-direction": v.value,
|
|
820
|
-
onWheel:
|
|
821
|
-
onTouchstartPassive:
|
|
822
|
-
onTouchendPassive:
|
|
820
|
+
onWheel: K,
|
|
821
|
+
onTouchstartPassive: q,
|
|
822
|
+
onTouchendPassive: J
|
|
823
823
|
}, [
|
|
824
824
|
l(t, { name: `media-slide-${v.value}` }, {
|
|
825
825
|
default: O(() => [(y(), o("div", {
|
|
826
|
-
key: `${e.item.postId}:${
|
|
826
|
+
key: `${e.item.postId}:${D.value.src}:${e.mediaSource ?? "preview"}`,
|
|
827
827
|
class: "media-card-frame",
|
|
828
828
|
"data-media-index": E.value
|
|
829
829
|
}, [e.previewState === "loading" ? (y(), o("div", Ve, [...r[14] ||= [s("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (y(), o("div", {
|
|
@@ -832,7 +832,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
832
832
|
class: "media-error",
|
|
833
833
|
role: "img",
|
|
834
834
|
"aria-label": `${T(we)(P.value)} ${T(Te)(P.value)}`
|
|
835
|
-
}, [s("strong", Ue, w(T(we)(P.value)), 1), s("span", null, w(T(Te)(P.value)), 1)], 8, He)) : a("", !0),
|
|
835
|
+
}, [s("strong", Ue, w(T(we)(P.value)), 1), s("span", null, w(T(Te)(P.value)), 1)], 8, He)) : a("", !0), Y.value ? (y(), o("video", {
|
|
836
836
|
key: 2,
|
|
837
837
|
ref_key: "videoElement",
|
|
838
838
|
ref: L,
|
|
@@ -855,7 +855,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
855
855
|
onPlaying: r[0] ||= (e) => V.value = !0,
|
|
856
856
|
onPause: r[1] ||= (e) => V.value = !1,
|
|
857
857
|
onEnded: se,
|
|
858
|
-
onClick:
|
|
858
|
+
onClick: ie,
|
|
859
859
|
onError: r[2] ||= (e) => n.$emit("error", E.value)
|
|
860
860
|
}, null, 42, We)) : (y(), o("img", {
|
|
861
861
|
key: 3,
|
|
@@ -872,17 +872,17 @@ var Oe = /* @__PURE__ */ u({
|
|
|
872
872
|
}, null, 42, Ge))], 8, Be))]),
|
|
873
873
|
_: 1
|
|
874
874
|
}, 8, ["name"]),
|
|
875
|
-
|
|
875
|
+
Y.value && e.previewState === "ready" ? (y(), i(Ie, {
|
|
876
876
|
key: 0,
|
|
877
877
|
"current-time": R.value,
|
|
878
878
|
duration: z.value,
|
|
879
879
|
layout: e.layout,
|
|
880
880
|
muted: B.value,
|
|
881
881
|
playing: V.value,
|
|
882
|
-
volume:
|
|
882
|
+
volume: H.value,
|
|
883
883
|
onSeek: ce,
|
|
884
884
|
onToggleMute: ue,
|
|
885
|
-
onTogglePlayback:
|
|
885
|
+
onTogglePlayback: ae,
|
|
886
886
|
onVolumeChange: le
|
|
887
887
|
}, null, 8, [
|
|
888
888
|
"current-time",
|
|
@@ -900,21 +900,21 @@ var Oe = /* @__PURE__ */ u({
|
|
|
900
900
|
type: "button",
|
|
901
901
|
class: "media-carousel-control media-carousel-control--previous",
|
|
902
902
|
"aria-label": `Previous media for post ${e.item.postId}`,
|
|
903
|
-
onClick: r[5] ||= A((e) =>
|
|
903
|
+
onClick: r[5] ||= A((e) => G(E.value - 1, e), ["stop"]),
|
|
904
904
|
onKeydown: r[6] ||= A(() => {}, ["stop"])
|
|
905
905
|
}, [l(T(_e), { size: 20 })], 40, Ke), s("button", {
|
|
906
906
|
type: "button",
|
|
907
907
|
class: "media-carousel-control media-carousel-control--next",
|
|
908
908
|
"aria-label": `Next media for post ${e.item.postId}`,
|
|
909
|
-
onClick: r[7] ||= A((e) =>
|
|
909
|
+
onClick: r[7] ||= A((e) => G(E.value + 1, e), ["stop"]),
|
|
910
910
|
onKeydown: r[8] ||= A(() => {}, ["stop"])
|
|
911
911
|
}, [l(T(ve), { size: 20 })], 40, qe)], 2)) : a("", !0),
|
|
912
|
-
|
|
912
|
+
W.value ? (y(), o("button", {
|
|
913
913
|
key: 2,
|
|
914
914
|
class: "media-card-activator",
|
|
915
915
|
type: "button",
|
|
916
916
|
"aria-label": `Open post ${e.item.postId}`,
|
|
917
|
-
onClick: r[9] ||= A((e) => n.$emit("activate",
|
|
917
|
+
onClick: r[9] ||= A((e) => n.$emit("activate", ee(e)), ["stop"]),
|
|
918
918
|
onKeydown: r[10] ||= A(() => {}, ["stop"])
|
|
919
919
|
}, null, 40, Je)) : a("", !0)
|
|
920
920
|
], 42, ze),
|
|
@@ -977,14 +977,14 @@ var Oe = /* @__PURE__ */ u({
|
|
|
977
977
|
"retryEnd"
|
|
978
978
|
],
|
|
979
979
|
setup(t, { expose: r, emit: a }) {
|
|
980
|
-
let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(nt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() =>
|
|
980
|
+
let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(nt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => q(c.items, h.value, {
|
|
981
981
|
additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
|
|
982
982
|
gap: v.value,
|
|
983
983
|
minColumnWidth: tt
|
|
984
984
|
})), M = n(() => {
|
|
985
985
|
let e = j.value;
|
|
986
986
|
if (c.leavingPostIds.size === 0) return e;
|
|
987
|
-
let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n =
|
|
987
|
+
let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = q(t, h.value, {
|
|
988
988
|
additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
|
|
989
989
|
gap: v.value,
|
|
990
990
|
minColumnWidth: tt
|
|
@@ -997,16 +997,16 @@ var Oe = /* @__PURE__ */ u({
|
|
|
997
997
|
let e = Math.max(it, S.value * at), t = {
|
|
998
998
|
scrollTop: b.value - w.value,
|
|
999
999
|
viewportHeight: S.value
|
|
1000
|
-
}, n =
|
|
1000
|
+
}, n = K(M.value.items, {
|
|
1001
1001
|
...t,
|
|
1002
1002
|
overscan: e
|
|
1003
|
-
}), r = c.leavingPostIds.size === 0 ? [] :
|
|
1003
|
+
}), r = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
|
|
1004
1004
|
...t,
|
|
1005
1005
|
overscan: e
|
|
1006
|
-
}), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a =
|
|
1006
|
+
}), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = K(M.value.items, {
|
|
1007
1007
|
...t,
|
|
1008
1008
|
overscan: 0
|
|
1009
|
-
}), o = c.leavingPostIds.size === 0 ? [] :
|
|
1009
|
+
}), o = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
|
|
1010
1010
|
...t,
|
|
1011
1011
|
overscan: 0
|
|
1012
1012
|
}), s = new Set([...a, ...o]);
|
|
@@ -1022,7 +1022,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1022
1022
|
function I(e) {
|
|
1023
1023
|
let t = M.value.items[e], n = c.items[e]?.postId;
|
|
1024
1024
|
if (!t) return {};
|
|
1025
|
-
let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ?
|
|
1025
|
+
let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? re({
|
|
1026
1026
|
containerHeight: j.value.height,
|
|
1027
1027
|
gap: v.value
|
|
1028
1028
|
}) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
|
|
@@ -1046,11 +1046,11 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1046
1046
|
}
|
|
1047
1047
|
function z(e) {
|
|
1048
1048
|
let t = e.currentTarget;
|
|
1049
|
-
t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll &&
|
|
1049
|
+
t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && G(t) && u("loadMore"));
|
|
1050
1050
|
}
|
|
1051
1051
|
function B() {
|
|
1052
1052
|
let e = d.value;
|
|
1053
|
-
!c.loadMoreLocked && e &&
|
|
1053
|
+
!c.loadMoreLocked && e && G(e) && u("loadMore");
|
|
1054
1054
|
}
|
|
1055
1055
|
function V() {
|
|
1056
1056
|
return d.value;
|
|
@@ -1124,7 +1124,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1124
1124
|
"onMediaChange",
|
|
1125
1125
|
"onReady",
|
|
1126
1126
|
"onError"
|
|
1127
|
-
]))), 128))], 6), l(
|
|
1127
|
+
]))), 128))], 6), l(H, {
|
|
1128
1128
|
actions: t.feedFooterActions,
|
|
1129
1129
|
"can-retry-end": t.canRetryEnd,
|
|
1130
1130
|
"feed-footer": t.feedFooter,
|
|
@@ -1155,7 +1155,28 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1155
1155
|
"suspended"
|
|
1156
1156
|
])]));
|
|
1157
1157
|
}
|
|
1158
|
-
}), st =
|
|
1158
|
+
}), st = 300;
|
|
1159
|
+
function ct(e, t, n) {
|
|
1160
|
+
let r = e.scrollTop;
|
|
1161
|
+
if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
|
|
1162
|
+
e.setAttribute("data-transitioning", "");
|
|
1163
|
+
let i = performance.now(), a = 0;
|
|
1164
|
+
return new Promise((n) => {
|
|
1165
|
+
let o = (s) => {
|
|
1166
|
+
a += 1;
|
|
1167
|
+
let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / st), u = 1 - (1 - l) ** 3;
|
|
1168
|
+
if (e.scrollTop = r + (t - r) * u, l < 1) {
|
|
1169
|
+
requestAnimationFrame(o);
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
e.removeAttribute("data-transitioning"), e.scrollTop = t, n();
|
|
1173
|
+
};
|
|
1174
|
+
requestAnimationFrame(o);
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
|
|
1179
|
+
var lt = ["aria-label"], ut = /* @__PURE__ */ u({
|
|
1159
1180
|
__name: "ReelAutoAdvanceProgress",
|
|
1160
1181
|
props: {
|
|
1161
1182
|
durationMs: {},
|
|
@@ -1173,9 +1194,9 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1173
1194
|
class: "reel-auto-advance-progress",
|
|
1174
1195
|
style: g(a.value),
|
|
1175
1196
|
onAnimationend: n[0] ||= (e) => i("complete")
|
|
1176
|
-
}, null, 36)], 8,
|
|
1197
|
+
}, null, 36)], 8, lt));
|
|
1177
1198
|
}
|
|
1178
|
-
}),
|
|
1199
|
+
}), dt = ["data-active-post-id", "data-active-media-index"], ft = ["role", "data-status"], pt = 2, mt = 300, ht = /* @__PURE__ */ u({
|
|
1179
1200
|
__name: "ReelFeed",
|
|
1180
1201
|
props: {
|
|
1181
1202
|
initialPostId: {},
|
|
@@ -1213,7 +1234,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1213
1234
|
],
|
|
1214
1235
|
setup(t, { expose: r, emit: c }) {
|
|
1215
1236
|
let l = t, u = c, d = C(null), f = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), h = C(Math.max(0, f)), b = C(!1), S = 0, E = null, O = null, k = null, A = n(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), M = n(() => {
|
|
1216
|
-
let e = Math.max(0, h.value -
|
|
1237
|
+
let e = Math.max(0, h.value - pt), t = Math.min(l.items.length - 1, h.value + pt);
|
|
1217
1238
|
return l.items.slice(e, t + 1).map((t, n) => ({
|
|
1218
1239
|
fetchPriority: e + n === h.value ? "high" : "low",
|
|
1219
1240
|
index: e + n,
|
|
@@ -1238,47 +1259,47 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1238
1259
|
l.reelAutoAdvance.enabled,
|
|
1239
1260
|
l.reelAutoAdvance.includePostItems,
|
|
1240
1261
|
l.reelAutoAdvance.intervalMs
|
|
1241
|
-
].join(":")),
|
|
1262
|
+
].join(":")), U = n(() => {
|
|
1242
1263
|
let e = I.value, t = !!(e && l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
|
|
1243
1264
|
return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
|
|
1244
|
-
}),
|
|
1245
|
-
function
|
|
1265
|
+
}), W = n(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && I.value !== void 0 && R.value !== "loading" && !B.value), ee = n(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
|
|
1266
|
+
function te(e) {
|
|
1246
1267
|
return { gridRow: `${e + 1}` };
|
|
1247
1268
|
}
|
|
1248
|
-
function
|
|
1269
|
+
function ne(e) {
|
|
1249
1270
|
let t = S || e.clientHeight;
|
|
1250
1271
|
return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
|
|
1251
1272
|
}
|
|
1252
|
-
function
|
|
1273
|
+
function re(e) {
|
|
1253
1274
|
let t = e.currentTarget;
|
|
1254
|
-
t && (b.value || (h.value =
|
|
1275
|
+
t && (b.value || (h.value = ne(t)), !l.loadMoreLocked && l.infiniteScroll && G(t) && u("loadMore"));
|
|
1255
1276
|
}
|
|
1256
|
-
function
|
|
1277
|
+
function K() {
|
|
1257
1278
|
let e = d.value;
|
|
1258
|
-
e && (
|
|
1279
|
+
e && (Y(!0), S = e.clientHeight, e.scrollTop = h.value * S, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
|
|
1259
1280
|
e.scrollTop = h.value * e.clientHeight, S = e.clientHeight, O = null;
|
|
1260
|
-
}),
|
|
1281
|
+
}), q());
|
|
1261
1282
|
}
|
|
1262
|
-
function
|
|
1283
|
+
function q() {
|
|
1263
1284
|
k !== null && clearTimeout(k), k = setTimeout(() => {
|
|
1264
1285
|
k = null;
|
|
1265
1286
|
let e = d.value;
|
|
1266
|
-
e && (S = e.clientHeight, e.scrollTop = h.value * S),
|
|
1287
|
+
e && (S = e.clientHeight, e.scrollTop = h.value * S), Y(!1);
|
|
1267
1288
|
}, 120);
|
|
1268
1289
|
}
|
|
1269
|
-
function
|
|
1270
|
-
|
|
1290
|
+
function J() {
|
|
1291
|
+
Y(!0);
|
|
1271
1292
|
let e = d.value;
|
|
1272
|
-
e && (S = e.clientHeight, e.scrollTop = h.value * S),
|
|
1293
|
+
e && (S = e.clientHeight, e.scrollTop = h.value * S), q();
|
|
1273
1294
|
}
|
|
1274
|
-
function
|
|
1295
|
+
function Y(e) {
|
|
1275
1296
|
b.value = e, d.value?.toggleAttribute("data-resizing", e);
|
|
1276
1297
|
}
|
|
1277
|
-
function
|
|
1298
|
+
function ie() {
|
|
1278
1299
|
let e = d.value;
|
|
1279
|
-
!l.loadMoreLocked && e &&
|
|
1300
|
+
!l.loadMoreLocked && e && G(e) && u("loadMore");
|
|
1280
1301
|
}
|
|
1281
|
-
function
|
|
1302
|
+
function ae(e) {
|
|
1282
1303
|
let t = I.value;
|
|
1283
1304
|
if (!t) return !1;
|
|
1284
1305
|
let n = j(t).length;
|
|
@@ -1286,27 +1307,30 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1286
1307
|
let r = (L.value + e + n) % n;
|
|
1287
1308
|
return u("mediaChange", t.postId, r), !0;
|
|
1288
1309
|
}
|
|
1289
|
-
function
|
|
1310
|
+
function oe(e) {
|
|
1290
1311
|
let t = h.value + e;
|
|
1291
|
-
return !d.value || t < 0 || t >= l.items.length ? !1 : (
|
|
1312
|
+
return !d.value || t < 0 || t >= l.items.length ? !1 : (se(t), !0);
|
|
1292
1313
|
}
|
|
1293
1314
|
function X() {
|
|
1294
1315
|
return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1295
1316
|
}
|
|
1296
1317
|
function Z(e) {
|
|
1297
1318
|
let t = d.value;
|
|
1298
|
-
if (!t) return;
|
|
1319
|
+
if (!t) return Promise.resolve();
|
|
1299
1320
|
let n = e * (S || t.clientHeight);
|
|
1300
|
-
|
|
1301
|
-
t.scrollTo({
|
|
1302
|
-
behavior: "smooth",
|
|
1303
|
-
top: n
|
|
1304
|
-
});
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
|
-
t.scrollTop = n;
|
|
1321
|
+
return h.value = e, ct(t, n, X());
|
|
1308
1322
|
}
|
|
1309
|
-
function se() {
|
|
1323
|
+
function se(e) {
|
|
1324
|
+
Z(e);
|
|
1325
|
+
}
|
|
1326
|
+
async function ce(e) {
|
|
1327
|
+
let t = l.items.findIndex((t) => t.postId === e);
|
|
1328
|
+
return t < 0 || t === h.value ? !1 : (await Z(t), !0);
|
|
1329
|
+
}
|
|
1330
|
+
async function le(e) {
|
|
1331
|
+
return ae(e) ? (X() || await new Promise((e) => setTimeout(e, mt)), !0) : !1;
|
|
1332
|
+
}
|
|
1333
|
+
function ue() {
|
|
1310
1334
|
if (!l.reelAutoAdvance.enabled) return;
|
|
1311
1335
|
let e = I.value;
|
|
1312
1336
|
if (!e) return;
|
|
@@ -1319,27 +1343,30 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1319
1343
|
l.hasNext && !l.loadMoreLocked && u("loadMore");
|
|
1320
1344
|
return;
|
|
1321
1345
|
}
|
|
1322
|
-
l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0),
|
|
1346
|
+
l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), se(t);
|
|
1323
1347
|
}
|
|
1324
|
-
function
|
|
1325
|
-
!l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value ||
|
|
1348
|
+
function de(e, t) {
|
|
1349
|
+
!l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || ue();
|
|
1326
1350
|
}
|
|
1327
1351
|
return D(d, (e) => {
|
|
1328
|
-
E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(
|
|
1329
|
-
}), D(() => l.items.length, async (e) => {
|
|
1330
|
-
|
|
1352
|
+
E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(K), E.observe(e)));
|
|
1353
|
+
}), D([() => l.items.length, () => l.initialPostId], async ([e, t]) => {
|
|
1354
|
+
let n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
|
|
1355
|
+
h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), K();
|
|
1331
1356
|
}), D(F, (e) => {
|
|
1332
1357
|
e !== void 0 && u("activeChange", e);
|
|
1333
1358
|
}, { immediate: !0 }), v(() => {
|
|
1334
|
-
window.addEventListener("resize",
|
|
1359
|
+
window.addEventListener("resize", J), window.addEventListener("orientationchange", J), f >= 0 && p(K);
|
|
1335
1360
|
}), _(() => {
|
|
1336
|
-
window.removeEventListener("resize",
|
|
1361
|
+
window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
|
|
1337
1362
|
}), r({
|
|
1338
1363
|
activeIndex: h,
|
|
1339
1364
|
activePostId: F,
|
|
1340
|
-
changeActiveMedia:
|
|
1341
|
-
loadIfNearBottom:
|
|
1342
|
-
moveActivePost:
|
|
1365
|
+
changeActiveMedia: ae,
|
|
1366
|
+
loadIfNearBottom: ie,
|
|
1367
|
+
moveActivePost: oe,
|
|
1368
|
+
transitionActiveMedia: le,
|
|
1369
|
+
transitionActivePost: ce
|
|
1343
1370
|
}), (n, r) => (y(), o("main", {
|
|
1344
1371
|
class: m(["reel-shell", {
|
|
1345
1372
|
"reel-shell--has-footer": !!t.cardFooter,
|
|
@@ -1375,7 +1402,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1375
1402
|
class: "gallery-shell reel-feed",
|
|
1376
1403
|
"data-active-post-id": F.value,
|
|
1377
1404
|
"data-active-media-index": L.value,
|
|
1378
|
-
onScrollPassive:
|
|
1405
|
+
onScrollPassive: re
|
|
1379
1406
|
}, [t.reelForward.status === "idle" ? (y(), o("section", {
|
|
1380
1407
|
key: 1,
|
|
1381
1408
|
class: "reel-track",
|
|
@@ -1389,7 +1416,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1389
1416
|
"fetch-priority": e,
|
|
1390
1417
|
index: r,
|
|
1391
1418
|
item: n,
|
|
1392
|
-
"item-style":
|
|
1419
|
+
"item-style": te(r),
|
|
1393
1420
|
"media-card": t.mediaCard,
|
|
1394
1421
|
layout: "reel",
|
|
1395
1422
|
"loaded-count": t.items.length,
|
|
@@ -1398,7 +1425,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1398
1425
|
"preview-state": t.previewStates.get(T(P)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
|
|
1399
1426
|
total: t.total,
|
|
1400
1427
|
onMediaChange: (e) => u("mediaChange", n.postId, e),
|
|
1401
|
-
onEnded: (e) =>
|
|
1428
|
+
onEnded: (e) => de(n.postId, e),
|
|
1402
1429
|
onReady: (e) => u("ready", n.postId, e),
|
|
1403
1430
|
onError: (e) => u("error", n.postId, e)
|
|
1404
1431
|
}, null, 8, [
|
|
@@ -1422,12 +1449,12 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1422
1449
|
class: "reel-forward-status",
|
|
1423
1450
|
role: t.reelForward.status === "error" ? "alert" : "status",
|
|
1424
1451
|
"data-status": t.reelForward.status
|
|
1425
|
-
}, [s("p", null, w(
|
|
1452
|
+
}, [s("p", null, w(ee.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (y(), o("button", {
|
|
1426
1453
|
key: 0,
|
|
1427
1454
|
class: "reel-forward-retry",
|
|
1428
1455
|
type: "button",
|
|
1429
1456
|
onClick: r[0] ||= (e) => u("retryForward")
|
|
1430
|
-
}, " Retry ")) : a("", !0)], 8,
|
|
1457
|
+
}, " Retry ")) : a("", !0)], 8, ft)), t.reelForward.status === "idle" ? (y(), i(H, {
|
|
1431
1458
|
key: 2,
|
|
1432
1459
|
actions: t.feedFooterActions,
|
|
1433
1460
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -1448,7 +1475,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1448
1475
|
"is-loading",
|
|
1449
1476
|
"load-more-locked",
|
|
1450
1477
|
"state"
|
|
1451
|
-
])) : a("", !0)], 40,
|
|
1478
|
+
])) : a("", !0)], 40, dt),
|
|
1452
1479
|
t.cardFooter && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
|
|
1453
1480
|
key: 1,
|
|
1454
1481
|
index: h.value,
|
|
@@ -1471,24 +1498,24 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1471
1498
|
"style",
|
|
1472
1499
|
"total"
|
|
1473
1500
|
])) : a("", !0),
|
|
1474
|
-
|
|
1501
|
+
W.value ? (y(), i(ut, {
|
|
1475
1502
|
key: V.value,
|
|
1476
1503
|
"duration-ms": t.reelAutoAdvance.intervalMs,
|
|
1477
|
-
label:
|
|
1478
|
-
onComplete:
|
|
1504
|
+
label: U.value,
|
|
1505
|
+
onComplete: ue
|
|
1479
1506
|
}, null, 8, ["duration-ms", "label"])) : a("", !0)
|
|
1480
1507
|
], 2));
|
|
1481
1508
|
}
|
|
1482
|
-
}),
|
|
1509
|
+
}), gt = ["data-info-sheet-open", "data-info-sheet-mode"], _t = ["aria-hidden", "inert"], vt = {
|
|
1483
1510
|
key: 0,
|
|
1484
1511
|
class: "reel-info-sheet-layer",
|
|
1485
1512
|
"data-test": "reel-info-sheet"
|
|
1486
|
-
},
|
|
1513
|
+
}, yt = [
|
|
1487
1514
|
"role",
|
|
1488
1515
|
"aria-modal",
|
|
1489
1516
|
"tabindex",
|
|
1490
1517
|
"data-active-post-id"
|
|
1491
|
-
],
|
|
1518
|
+
], bt = /* @__PURE__ */ u({
|
|
1492
1519
|
__name: "ReelLayout",
|
|
1493
1520
|
props: {
|
|
1494
1521
|
forwardIndex: { default: null },
|
|
@@ -1566,13 +1593,19 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1566
1593
|
function L(e) {
|
|
1567
1594
|
return g.value?.moveActivePost(e) ?? !1;
|
|
1568
1595
|
}
|
|
1569
|
-
function R(e
|
|
1596
|
+
function R(e) {
|
|
1597
|
+
return g.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
|
|
1598
|
+
}
|
|
1599
|
+
function z(e) {
|
|
1600
|
+
return g.value?.transitionActivePost(e) ?? Promise.resolve(!1);
|
|
1601
|
+
}
|
|
1602
|
+
function B(e, t) {
|
|
1570
1603
|
f("error", e, t);
|
|
1571
1604
|
}
|
|
1572
|
-
function
|
|
1605
|
+
function V(e, t) {
|
|
1573
1606
|
f("mediaChange", e, t);
|
|
1574
1607
|
}
|
|
1575
|
-
function
|
|
1608
|
+
function H(e, t) {
|
|
1576
1609
|
f("ready", e, t);
|
|
1577
1610
|
}
|
|
1578
1611
|
return D(() => ({
|
|
@@ -1592,7 +1625,9 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1592
1625
|
}), r({
|
|
1593
1626
|
changeActiveMedia: F,
|
|
1594
1627
|
loadIfNearBottom: I,
|
|
1595
|
-
moveActivePost: L
|
|
1628
|
+
moveActivePost: L,
|
|
1629
|
+
transitionActiveMedia: R,
|
|
1630
|
+
transitionActivePost: z
|
|
1596
1631
|
}), (n, r) => (y(), o("section", {
|
|
1597
1632
|
class: m(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
|
|
1598
1633
|
"data-info-sheet-open": A.value || void 0,
|
|
@@ -1601,7 +1636,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1601
1636
|
class: "reel-layout-main",
|
|
1602
1637
|
"aria-hidden": e.infoSheetOverlay && A.value || void 0,
|
|
1603
1638
|
inert: e.infoSheetOverlay && A.value || void 0
|
|
1604
|
-
}, [l(
|
|
1639
|
+
}, [l(ht, {
|
|
1605
1640
|
ref_key: "reelFeed",
|
|
1606
1641
|
ref: g,
|
|
1607
1642
|
"can-retry-end": e.canRetryEnd,
|
|
@@ -1625,10 +1660,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1625
1660
|
state: e.state,
|
|
1626
1661
|
total: e.total,
|
|
1627
1662
|
onActiveChange: r[0] ||= (e) => f("activeChange", e),
|
|
1628
|
-
onError:
|
|
1663
|
+
onError: B,
|
|
1629
1664
|
onLoadMore: r[1] ||= (e) => f("loadMore"),
|
|
1630
|
-
onMediaChange:
|
|
1631
|
-
onReady:
|
|
1665
|
+
onMediaChange: V,
|
|
1666
|
+
onReady: H,
|
|
1632
1667
|
onRetryEnd: r[2] ||= (e) => f("retryEnd"),
|
|
1633
1668
|
onRetryForward: r[3] ||= (e) => f("retryForward")
|
|
1634
1669
|
}, null, 8, [
|
|
@@ -1652,8 +1687,8 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1652
1687
|
"reel-forward",
|
|
1653
1688
|
"state",
|
|
1654
1689
|
"total"
|
|
1655
|
-
])], 8,
|
|
1656
|
-
default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div",
|
|
1690
|
+
])], 8, _t), l(t, { name: "vibe-info-sheet" }, {
|
|
1691
|
+
default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div", vt, [s("aside", {
|
|
1657
1692
|
ref_key: "sheetElement",
|
|
1658
1693
|
ref: v,
|
|
1659
1694
|
class: "reel-info-sheet",
|
|
@@ -1662,11 +1697,11 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1662
1697
|
"aria-modal": e.infoSheetOverlay ? "true" : void 0,
|
|
1663
1698
|
tabindex: e.infoSheetOverlay ? -1 : void 0,
|
|
1664
1699
|
"data-active-post-id": T.value?.postId
|
|
1665
|
-
}, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8,
|
|
1700
|
+
}, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8, yt)])) : a("", !0)]),
|
|
1666
1701
|
_: 1
|
|
1667
|
-
})], 10,
|
|
1702
|
+
})], 10, gt));
|
|
1668
1703
|
}
|
|
1669
|
-
}),
|
|
1704
|
+
}), xt = 35, St = 420, Ct = /* @__PURE__ */ u({
|
|
1670
1705
|
__name: "VibeSurface",
|
|
1671
1706
|
props: {
|
|
1672
1707
|
canRetryEnd: { type: Boolean },
|
|
@@ -1692,63 +1727,63 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1692
1727
|
function V() {
|
|
1693
1728
|
return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1694
1729
|
}
|
|
1695
|
-
function
|
|
1730
|
+
function H() {
|
|
1696
1731
|
R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
|
|
1697
1732
|
R = requestAnimationFrame(() => {
|
|
1698
1733
|
R = null, w.value = /* @__PURE__ */ new Set();
|
|
1699
1734
|
});
|
|
1700
1735
|
});
|
|
1701
1736
|
}
|
|
1702
|
-
function
|
|
1737
|
+
function U(e, t, n) {
|
|
1703
1738
|
let r = P(e, t);
|
|
1704
1739
|
A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
|
|
1705
1740
|
}
|
|
1706
|
-
function
|
|
1741
|
+
function W(e, t, n) {
|
|
1707
1742
|
let r = P(e, t);
|
|
1708
1743
|
j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
|
|
1709
1744
|
}
|
|
1710
|
-
function
|
|
1711
|
-
|
|
1745
|
+
function G(e, t) {
|
|
1746
|
+
U(e, t, "error");
|
|
1747
|
+
}
|
|
1748
|
+
function te(e, t) {
|
|
1749
|
+
U(e, t, "ready");
|
|
1712
1750
|
}
|
|
1713
1751
|
function ne(e, t) {
|
|
1714
|
-
|
|
1752
|
+
W(e, t, "error");
|
|
1715
1753
|
}
|
|
1716
1754
|
function re(e, t) {
|
|
1717
|
-
|
|
1755
|
+
W(e, t, "ready");
|
|
1718
1756
|
}
|
|
1719
|
-
function
|
|
1720
|
-
U(e, t, "ready");
|
|
1721
|
-
}
|
|
1722
|
-
function G(e, t) {
|
|
1757
|
+
function K(e, t) {
|
|
1723
1758
|
if (u.state.reelMediaSource === "original") {
|
|
1724
|
-
|
|
1759
|
+
ne(e, t);
|
|
1725
1760
|
return;
|
|
1726
1761
|
}
|
|
1727
|
-
|
|
1762
|
+
G(e, t);
|
|
1728
1763
|
}
|
|
1729
|
-
function
|
|
1764
|
+
function q(e, t) {
|
|
1730
1765
|
if (u.state.reelMediaSource === "original") {
|
|
1731
|
-
|
|
1766
|
+
re(e, t);
|
|
1732
1767
|
return;
|
|
1733
1768
|
}
|
|
1734
|
-
|
|
1769
|
+
te(e, t);
|
|
1735
1770
|
}
|
|
1736
|
-
function
|
|
1771
|
+
function J(e, t) {
|
|
1737
1772
|
let n = u.state.items.find((t) => t.postId === e);
|
|
1738
1773
|
if (!n) return;
|
|
1739
1774
|
let r = M(n, t);
|
|
1740
1775
|
(u.state.mediaIndices.get(e) ?? 0) !== r && (u.state.mediaIndices = new Map(u.state.mediaIndices).set(e, r));
|
|
1741
1776
|
}
|
|
1742
|
-
async function
|
|
1777
|
+
async function Y() {
|
|
1743
1778
|
await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
|
|
1744
1779
|
}
|
|
1745
|
-
function
|
|
1780
|
+
function ie(e) {
|
|
1746
1781
|
return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
|
|
1747
1782
|
}
|
|
1748
|
-
function
|
|
1783
|
+
function ae(e) {
|
|
1749
1784
|
return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
|
|
1750
1785
|
}
|
|
1751
|
-
function
|
|
1786
|
+
function oe() {
|
|
1752
1787
|
return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
|
|
1753
1788
|
}
|
|
1754
1789
|
function X(e, t) {
|
|
@@ -1764,8 +1799,8 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1764
1799
|
if (n.length === 0) return 0;
|
|
1765
1800
|
let r = new Map(k.value);
|
|
1766
1801
|
return n.forEach((e, t) => {
|
|
1767
|
-
r.set(e, t *
|
|
1768
|
-
}), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r,
|
|
1802
|
+
r.set(e, t * xt);
|
|
1803
|
+
}), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, St + (n.length - 1) * xt;
|
|
1769
1804
|
}
|
|
1770
1805
|
function ce(e, t) {
|
|
1771
1806
|
let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
|
|
@@ -1796,7 +1831,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1796
1831
|
function fe(e) {
|
|
1797
1832
|
let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
|
|
1798
1833
|
if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
|
|
1799
|
-
e.preventDefault(), ue();
|
|
1834
|
+
e.preventDefault(), u.state.reelInfoSheetOverlay && u.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), ue();
|
|
1800
1835
|
return;
|
|
1801
1836
|
}
|
|
1802
1837
|
if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
|
|
@@ -1821,21 +1856,23 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1821
1856
|
let t = T.value.get(e);
|
|
1822
1857
|
t !== void 0 && r.set(e, t);
|
|
1823
1858
|
}), t.forEach((e, t) => {
|
|
1824
|
-
r.set(e, t *
|
|
1825
|
-
}), T.value = r, w.value = new Set([...w.value, ...t]),
|
|
1859
|
+
r.set(e, t * xt);
|
|
1860
|
+
}), T.value = r, w.value = new Set([...w.value, ...t]), H();
|
|
1826
1861
|
}, { flush: "sync" }), v(() => window.addEventListener("keydown", fe)), _(() => {
|
|
1827
1862
|
window.removeEventListener("keydown", fe), R !== null && cancelAnimationFrame(R);
|
|
1828
1863
|
}), s({
|
|
1829
|
-
changeActiveReelMedia:
|
|
1830
|
-
getAutoScrollElement:
|
|
1831
|
-
loadIfNearBottom:
|
|
1832
|
-
moveActiveReelPost:
|
|
1833
|
-
startItemRemoval: se
|
|
1864
|
+
changeActiveReelMedia: ie,
|
|
1865
|
+
getAutoScrollElement: oe,
|
|
1866
|
+
loadIfNearBottom: Y,
|
|
1867
|
+
moveActiveReelPost: ae,
|
|
1868
|
+
startItemRemoval: se,
|
|
1869
|
+
transitionActiveReelMedia: (e) => m.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
|
|
1870
|
+
transitionActiveReelPost: (e) => m.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
|
|
1834
1871
|
}), (n, s) => (y(), o("div", {
|
|
1835
1872
|
ref_key: "surfaceElement",
|
|
1836
1873
|
ref: b,
|
|
1837
1874
|
class: "vibe-surface"
|
|
1838
|
-
}, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(
|
|
1875
|
+
}, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(bt, {
|
|
1839
1876
|
key: 0,
|
|
1840
1877
|
ref_key: "reelRenderer",
|
|
1841
1878
|
ref: m,
|
|
@@ -1867,10 +1904,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1867
1904
|
total: r.state.total,
|
|
1868
1905
|
onActiveChange: s[0] ||= (e) => d("activeReelChange", e),
|
|
1869
1906
|
onCloseInfoSheet: s[1] ||= (e) => d("reelInfoSheetChange", !1),
|
|
1870
|
-
onError:
|
|
1907
|
+
onError: K,
|
|
1871
1908
|
onLoadMore: s[2] ||= (e) => d("loadMore"),
|
|
1872
|
-
onMediaChange:
|
|
1873
|
-
onReady:
|
|
1909
|
+
onMediaChange: J,
|
|
1910
|
+
onReady: q,
|
|
1874
1911
|
onRetryEnd: s[3] ||= (e) => d("retryEnd"),
|
|
1875
1912
|
onRetryForward: s[4] ||= (e) => d("retryForward")
|
|
1876
1913
|
}, null, 8, [
|
|
@@ -1899,7 +1936,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1899
1936
|
"reel-forward",
|
|
1900
1937
|
"state",
|
|
1901
1938
|
"total"
|
|
1902
|
-
])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(
|
|
1939
|
+
])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(ee, {
|
|
1903
1940
|
key: 1,
|
|
1904
1941
|
actions: r.feedFooterActions,
|
|
1905
1942
|
"can-retry-end": r.canRetryEnd,
|
|
@@ -1937,10 +1974,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1937
1974
|
state: N.value,
|
|
1938
1975
|
total: r.state.total,
|
|
1939
1976
|
onActivate: X,
|
|
1940
|
-
onError:
|
|
1977
|
+
onError: G,
|
|
1941
1978
|
onLoadMore: s[7] ||= (e) => d("loadMore"),
|
|
1942
|
-
onMediaChange:
|
|
1943
|
-
onReady:
|
|
1979
|
+
onMediaChange: J,
|
|
1980
|
+
onReady: te,
|
|
1944
1981
|
onRetryEnd: s[8] ||= (e) => d("retryEnd")
|
|
1945
1982
|
}, null, 8, [
|
|
1946
1983
|
"can-retry-end",
|
|
@@ -1978,7 +2015,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1978
2015
|
"aria-modal": "true",
|
|
1979
2016
|
tabindex: "-1",
|
|
1980
2017
|
style: g(x.value)
|
|
1981
|
-
}, [l(
|
|
2018
|
+
}, [l(bt, {
|
|
1982
2019
|
ref_key: "reelRenderer",
|
|
1983
2020
|
ref: m,
|
|
1984
2021
|
"can-retry-end": r.canRetryEnd,
|
|
@@ -2009,10 +2046,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
2009
2046
|
total: r.state.total,
|
|
2010
2047
|
onActiveChange: s[9] ||= (e) => d("activeReelChange", e),
|
|
2011
2048
|
onCloseInfoSheet: s[10] ||= (e) => d("reelInfoSheetChange", !1),
|
|
2012
|
-
onError:
|
|
2049
|
+
onError: ne,
|
|
2013
2050
|
onLoadMore: s[11] ||= (e) => d("loadMore"),
|
|
2014
|
-
onMediaChange:
|
|
2015
|
-
onReady:
|
|
2051
|
+
onMediaChange: J,
|
|
2052
|
+
onReady: re,
|
|
2016
2053
|
onRetryEnd: s[12] ||= (e) => d("retryEnd"),
|
|
2017
2054
|
onRetryForward: s[13] ||= (e) => d("retryForward")
|
|
2018
2055
|
}, null, 8, [
|
|
@@ -2047,7 +2084,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
2047
2084
|
});
|
|
2048
2085
|
//#endregion
|
|
2049
2086
|
//#region src/core/page.ts
|
|
2050
|
-
function
|
|
2087
|
+
function wt(e) {
|
|
2051
2088
|
if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
|
|
2052
2089
|
if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
|
|
2053
2090
|
if (e.total !== void 0 && (!Number.isFinite(e.total) || e.total < 0)) throw TypeError("Vibe page total must be a non-negative number when provided.");
|
|
@@ -2059,32 +2096,32 @@ function Q(e, t) {
|
|
|
2059
2096
|
}
|
|
2060
2097
|
//#endregion
|
|
2061
2098
|
//#region src/core/requestDelay.ts
|
|
2062
|
-
var
|
|
2099
|
+
var Tt = 2e3, Et = 1e4, Dt = 250, Ot = {
|
|
2063
2100
|
delayRemainingMs: null,
|
|
2064
2101
|
nextRequestAt: null
|
|
2065
2102
|
};
|
|
2066
|
-
function
|
|
2103
|
+
function kt(e, t) {
|
|
2067
2104
|
return e === void 0 ? t : Math.floor(e);
|
|
2068
2105
|
}
|
|
2069
|
-
function
|
|
2106
|
+
function At(e, t) {
|
|
2070
2107
|
for (let [n, r] of [["delayStepMs", e.delayStepMs], ["delayMaxMs", e.delayMaxMs]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe ${t} ${n} must be a non-negative number.`);
|
|
2071
2108
|
}
|
|
2072
|
-
function
|
|
2073
|
-
let n =
|
|
2109
|
+
function jt(e, t = {}) {
|
|
2110
|
+
let n = kt(t.delayStepMs, Tt), r = kt(t.delayMaxMs, Et);
|
|
2074
2111
|
return Math.min(Math.max(0, e) * n, r);
|
|
2075
2112
|
}
|
|
2076
2113
|
function $(e) {
|
|
2077
|
-
if (e == null || !Number.isFinite(e)) return { ...
|
|
2114
|
+
if (e == null || !Number.isFinite(e)) return { ...Ot };
|
|
2078
2115
|
let t = Math.max(0, Math.floor(e - Date.now()));
|
|
2079
2116
|
return t > 0 ? {
|
|
2080
2117
|
delayRemainingMs: t,
|
|
2081
2118
|
nextRequestAt: e
|
|
2082
|
-
} : { ...
|
|
2119
|
+
} : { ...Ot };
|
|
2083
2120
|
}
|
|
2084
|
-
async function
|
|
2121
|
+
async function Mt({ delayMs: e, onChange: t, signal: n }) {
|
|
2085
2122
|
if (n.aborted) throw new DOMException("Aborted", "AbortError");
|
|
2086
2123
|
if (e <= 0) {
|
|
2087
|
-
t({ ...
|
|
2124
|
+
t({ ...Ot });
|
|
2088
2125
|
return;
|
|
2089
2126
|
}
|
|
2090
2127
|
let r = Date.now() + e;
|
|
@@ -2092,9 +2129,9 @@ async function kt({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2092
2129
|
delayRemainingMs: e,
|
|
2093
2130
|
nextRequestAt: r
|
|
2094
2131
|
}), await new Promise((i, a) => {
|
|
2095
|
-
let o = !1, s = setInterval(f,
|
|
2132
|
+
let o = !1, s = setInterval(f, Dt), c = setTimeout(() => u(), e);
|
|
2096
2133
|
function l() {
|
|
2097
|
-
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...
|
|
2134
|
+
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Ot });
|
|
2098
2135
|
}
|
|
2099
2136
|
function u(e) {
|
|
2100
2137
|
o || (o = !0, l(), e ? a(e) : i());
|
|
@@ -2109,13 +2146,13 @@ async function kt({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2109
2146
|
n.addEventListener("abort", d, { once: !0 });
|
|
2110
2147
|
});
|
|
2111
2148
|
}
|
|
2112
|
-
var
|
|
2149
|
+
var Nt = class {
|
|
2113
2150
|
interval = null;
|
|
2114
2151
|
constructor(e) {
|
|
2115
2152
|
this.onChange = e;
|
|
2116
2153
|
}
|
|
2117
2154
|
clear() {
|
|
2118
|
-
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...
|
|
2155
|
+
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Ot });
|
|
2119
2156
|
}
|
|
2120
2157
|
sync(e) {
|
|
2121
2158
|
this.clear();
|
|
@@ -2123,22 +2160,22 @@ var At = class {
|
|
|
2123
2160
|
this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
|
|
2124
2161
|
let t = $(e);
|
|
2125
2162
|
this.onChange(t), t.delayRemainingMs === null && this.clear();
|
|
2126
|
-
},
|
|
2163
|
+
}, Dt));
|
|
2127
2164
|
}
|
|
2128
2165
|
};
|
|
2129
|
-
function
|
|
2166
|
+
function Pt(e, t = !0) {
|
|
2130
2167
|
return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
|
|
2131
2168
|
}
|
|
2132
|
-
function
|
|
2169
|
+
function Ft(e) {
|
|
2133
2170
|
return `${typeof e}:${String(e)}`;
|
|
2134
2171
|
}
|
|
2135
|
-
function
|
|
2172
|
+
function It(e, t) {
|
|
2136
2173
|
if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
|
|
2137
2174
|
}
|
|
2138
|
-
function
|
|
2175
|
+
function Lt(e) {
|
|
2139
2176
|
if (!e) return;
|
|
2140
|
-
if (
|
|
2141
|
-
|
|
2177
|
+
if (It(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
|
|
2178
|
+
At(e, "frontend autofill");
|
|
2142
2179
|
let t = e.maxAdditionalPages;
|
|
2143
2180
|
if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
|
|
2144
2181
|
return;
|
|
@@ -2150,7 +2187,7 @@ function Pt(e) {
|
|
|
2150
2187
|
if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
|
|
2151
2188
|
}
|
|
2152
2189
|
}
|
|
2153
|
-
function
|
|
2190
|
+
function Rt(e, t, n = !0) {
|
|
2154
2191
|
if (!e) return {
|
|
2155
2192
|
cycleId: null,
|
|
2156
2193
|
delayRemainingMs: null,
|
|
@@ -2184,7 +2221,7 @@ function Ft(e, t, n = !0) {
|
|
|
2184
2221
|
strategy: e.strategy
|
|
2185
2222
|
};
|
|
2186
2223
|
}
|
|
2187
|
-
function
|
|
2224
|
+
function zt(e) {
|
|
2188
2225
|
return [
|
|
2189
2226
|
"cancelling",
|
|
2190
2227
|
"filling",
|
|
@@ -2192,9 +2229,9 @@ function It(e) {
|
|
|
2192
2229
|
"waiting"
|
|
2193
2230
|
].includes(e.status);
|
|
2194
2231
|
}
|
|
2195
|
-
async function
|
|
2232
|
+
async function Bt(e, t, n) {
|
|
2196
2233
|
let r = t.autofill;
|
|
2197
|
-
if (!
|
|
2234
|
+
if (!zt(r) || !r.cycleId) return;
|
|
2198
2235
|
let i = {
|
|
2199
2236
|
cycleId: r.cycleId,
|
|
2200
2237
|
feedKey: r.feedKey ?? "",
|
|
@@ -2207,20 +2244,20 @@ async function Lt(e, t, n) {
|
|
|
2207
2244
|
throw r.error = e, r.status = "error", e;
|
|
2208
2245
|
}
|
|
2209
2246
|
}
|
|
2210
|
-
function
|
|
2247
|
+
function Vt(e, t, n) {
|
|
2211
2248
|
return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
|
|
2212
2249
|
}
|
|
2213
|
-
async function
|
|
2214
|
-
let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ??
|
|
2250
|
+
async function Ht({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
|
|
2251
|
+
let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? Pt(o), m = t, h = t, g = 0, _;
|
|
2215
2252
|
for (; g < p;) {
|
|
2216
|
-
let e =
|
|
2253
|
+
let e = Ft(m);
|
|
2217
2254
|
if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
|
|
2218
|
-
f.add(e), await
|
|
2219
|
-
delayMs:
|
|
2255
|
+
f.add(e), await Mt({
|
|
2256
|
+
delayMs: jt(c + g, o),
|
|
2220
2257
|
onChange: i,
|
|
2221
2258
|
signal: l
|
|
2222
2259
|
});
|
|
2223
|
-
let t =
|
|
2260
|
+
let t = wt(await n({
|
|
2224
2261
|
cursor: m,
|
|
2225
2262
|
signal: l
|
|
2226
2263
|
}));
|
|
@@ -2260,30 +2297,30 @@ async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2260
2297
|
total: _
|
|
2261
2298
|
};
|
|
2262
2299
|
}
|
|
2263
|
-
var
|
|
2264
|
-
function
|
|
2300
|
+
var Ut = 100;
|
|
2301
|
+
function Wt(e, t) {
|
|
2265
2302
|
if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
|
|
2266
2303
|
}
|
|
2267
|
-
function
|
|
2304
|
+
function Gt(e, t, n) {
|
|
2268
2305
|
return Math.min(n, Math.max(t, e));
|
|
2269
2306
|
}
|
|
2270
|
-
function
|
|
2307
|
+
function Kt(e) {
|
|
2271
2308
|
if (!e) return;
|
|
2272
2309
|
let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
|
|
2273
|
-
if (
|
|
2274
|
-
e.speedPxPerSecond !== void 0 &&
|
|
2310
|
+
if (Wt("autoScroll.minSpeedPxPerSecond", t), Wt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
|
|
2311
|
+
e.speedPxPerSecond !== void 0 && Wt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
|
|
2275
2312
|
}
|
|
2276
|
-
function
|
|
2313
|
+
function qt(e) {
|
|
2277
2314
|
let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
|
|
2278
2315
|
return {
|
|
2279
2316
|
enabled: e?.enabled ?? !1,
|
|
2280
2317
|
maxSpeedPxPerSecond: n,
|
|
2281
2318
|
minSpeedPxPerSecond: t,
|
|
2282
2319
|
paused: !1,
|
|
2283
|
-
speedPxPerSecond:
|
|
2320
|
+
speedPxPerSecond: Gt(e?.speedPxPerSecond ?? 80, t, n)
|
|
2284
2321
|
};
|
|
2285
2322
|
}
|
|
2286
|
-
var
|
|
2323
|
+
var Jt = class {
|
|
2287
2324
|
frame = null;
|
|
2288
2325
|
lastTimestamp = null;
|
|
2289
2326
|
mounted = !1;
|
|
@@ -2303,9 +2340,9 @@ var Gt = class {
|
|
|
2303
2340
|
this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
|
|
2304
2341
|
}
|
|
2305
2342
|
setSpeed(e) {
|
|
2306
|
-
|
|
2343
|
+
Wt("auto-scroll speed", e);
|
|
2307
2344
|
let t = this.options.state;
|
|
2308
|
-
t.speedPxPerSecond =
|
|
2345
|
+
t.speedPxPerSecond = Gt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
|
|
2309
2346
|
}
|
|
2310
2347
|
tick = (e) => {
|
|
2311
2348
|
this.frame = null;
|
|
@@ -2317,7 +2354,7 @@ var Gt = class {
|
|
|
2317
2354
|
return;
|
|
2318
2355
|
}
|
|
2319
2356
|
if (this.lastTimestamp !== null) {
|
|
2320
|
-
let r = Math.min(
|
|
2357
|
+
let r = Math.min(Ut, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
|
|
2321
2358
|
n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
|
|
2322
2359
|
}
|
|
2323
2360
|
this.lastTimestamp = e, this.schedule();
|
|
@@ -2331,7 +2368,7 @@ var Gt = class {
|
|
|
2331
2368
|
};
|
|
2332
2369
|
//#endregion
|
|
2333
2370
|
//#region src/core/backendAutofill.ts
|
|
2334
|
-
async function
|
|
2371
|
+
async function Yt(e, t, n, r) {
|
|
2335
2372
|
let i = await e.onUnderfilled(n);
|
|
2336
2373
|
if (!r()) return;
|
|
2337
2374
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
|
|
@@ -2345,19 +2382,19 @@ async function Kt(e, t, n, r) {
|
|
|
2345
2382
|
status: "waiting"
|
|
2346
2383
|
});
|
|
2347
2384
|
}
|
|
2348
|
-
function
|
|
2385
|
+
function Xt(e, t) {
|
|
2349
2386
|
["complete", "exhausted"].includes(t.status) && t.items && (e.items = Q(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
|
|
2350
2387
|
}
|
|
2351
|
-
function
|
|
2388
|
+
function Zt(e, t, n) {
|
|
2352
2389
|
let r = t.autofill;
|
|
2353
|
-
return !
|
|
2390
|
+
return !Vt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Xt(t, n), Object.assign(r, $(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
|
|
2354
2391
|
}
|
|
2355
|
-
function
|
|
2356
|
-
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill =
|
|
2392
|
+
function Qt(e, t, n) {
|
|
2393
|
+
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Rt(e, n), Xt(t, n), !0);
|
|
2357
2394
|
}
|
|
2358
2395
|
//#endregion
|
|
2359
2396
|
//#region src/core/initialAutofill.ts
|
|
2360
|
-
async function
|
|
2397
|
+
async function $t({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
|
|
2361
2398
|
let o = r.autofill;
|
|
2362
2399
|
if (!o) return;
|
|
2363
2400
|
let s = a.items.length;
|
|
@@ -2370,7 +2407,7 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2370
2407
|
return;
|
|
2371
2408
|
}
|
|
2372
2409
|
if (o.strategy === "backend") {
|
|
2373
|
-
await
|
|
2410
|
+
await Yt(o, a, {
|
|
2374
2411
|
cycleId: e,
|
|
2375
2412
|
feedKey: o.feedKey,
|
|
2376
2413
|
items: [...a.items],
|
|
@@ -2387,11 +2424,11 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2387
2424
|
a.autofill.status = "exhausted";
|
|
2388
2425
|
return;
|
|
2389
2426
|
}
|
|
2390
|
-
let c = await
|
|
2427
|
+
let c = await Ht({
|
|
2391
2428
|
existingItems: a.items,
|
|
2392
2429
|
initialCursor: a.next,
|
|
2393
2430
|
loadPage: r.loadPage,
|
|
2394
|
-
maximumRequests:
|
|
2431
|
+
maximumRequests: Pt(o, !1),
|
|
2395
2432
|
onDelayChange: (e) => {
|
|
2396
2433
|
t() && Object.assign(a.autofill, e);
|
|
2397
2434
|
},
|
|
@@ -2411,163 +2448,14 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2411
2448
|
}));
|
|
2412
2449
|
}
|
|
2413
2450
|
//#endregion
|
|
2414
|
-
//#region src/core/activeItemRemoval.ts
|
|
2415
|
-
function Zt(e, t, n, r, i) {
|
|
2416
|
-
let a = new Set(n.map(({ item: e }) => e.postId));
|
|
2417
|
-
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
2418
|
-
if (e.reelOrigin === "masonry") {
|
|
2419
|
-
i();
|
|
2420
|
-
return;
|
|
2421
|
-
}
|
|
2422
|
-
let o = e.items[Math.min(Math.max(r, 0), e.items.length - 1)];
|
|
2423
|
-
e.activeReelPostId = o?.postId ?? null, o ? t.syncReel(o.postId) : t.syncFeed();
|
|
2424
|
-
}
|
|
2425
|
-
//#endregion
|
|
2426
|
-
//#region src/core/exactMediaRemovalController.ts
|
|
2427
|
-
function Qt(e, t) {
|
|
2428
|
-
let [n, ...r] = t;
|
|
2429
|
-
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
2430
|
-
return {
|
|
2431
|
-
...e,
|
|
2432
|
-
...n,
|
|
2433
|
-
items: r
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
function $t(e) {
|
|
2437
|
-
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
2438
|
-
}
|
|
2439
|
-
var en = class {
|
|
2440
|
-
forward = null;
|
|
2441
|
-
forwardPromise = null;
|
|
2442
|
-
forwardVersion = 0;
|
|
2443
|
-
generation = 0;
|
|
2444
|
-
metadata = /* @__PURE__ */ new WeakMap();
|
|
2445
|
-
state;
|
|
2446
|
-
constructor(e) {
|
|
2447
|
-
this.options = e, this.state = e.state;
|
|
2448
|
-
}
|
|
2449
|
-
remove(e) {
|
|
2450
|
-
$t(e);
|
|
2451
|
-
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
2452
|
-
if (!n) return null;
|
|
2453
|
-
let r = [...j(n)], i = r[e.mediaIndex];
|
|
2454
|
-
if (!i) return null;
|
|
2455
|
-
let a = Object.freeze({
|
|
2456
|
-
media: i,
|
|
2457
|
-
mediaIndex: e.mediaIndex,
|
|
2458
|
-
postId: e.postId,
|
|
2459
|
-
postIndex: t
|
|
2460
|
-
});
|
|
2461
|
-
this.metadata.set(a, {
|
|
2462
|
-
generation: this.generation,
|
|
2463
|
-
originalItem: n,
|
|
2464
|
-
restored: !1
|
|
2465
|
-
});
|
|
2466
|
-
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
2467
|
-
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Qt(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
|
|
2468
|
-
}
|
|
2469
|
-
reset() {
|
|
2470
|
-
this.generation += 1, this.forwardVersion += 1, this.forward = null, this.forwardPromise = null, this.clearForwardState();
|
|
2471
|
-
}
|
|
2472
|
-
restore(e) {
|
|
2473
|
-
let t = this.metadata.get(e);
|
|
2474
|
-
if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
|
|
2475
|
-
if (t.generation !== this.generation || t.restored) return !1;
|
|
2476
|
-
t.restored = !0;
|
|
2477
|
-
let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
|
|
2478
|
-
return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.forward?.removal === e && this.state.reelForward.status !== "idle" && (this.forwardVersion += 1, this.forward = null, this.clearForwardState(), this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
|
|
2479
|
-
}
|
|
2480
|
-
retryForward() {
|
|
2481
|
-
return !this.forward || this.state.reelForward.status === "idle" ? Promise.resolve() : (this.state.nextPageError = null, this.state.reelForward = {
|
|
2482
|
-
error: null,
|
|
2483
|
-
status: "loading"
|
|
2484
|
-
}, this.startForwardRequest(this.state.next === null));
|
|
2485
|
-
}
|
|
2486
|
-
advanceFromRemovedPost(e, t) {
|
|
2487
|
-
let n = this.state.items[e.postIndex];
|
|
2488
|
-
if (n) {
|
|
2489
|
-
this.options.onActivate(n.postId);
|
|
2490
|
-
return;
|
|
2491
|
-
}
|
|
2492
|
-
this.forward = {
|
|
2493
|
-
postIndex: e.postIndex,
|
|
2494
|
-
removal: e,
|
|
2495
|
-
version: ++this.forwardVersion
|
|
2496
|
-
}, this.state.reelForward = {
|
|
2497
|
-
error: null,
|
|
2498
|
-
status: "loading"
|
|
2499
|
-
}, this.state.reelForwardIndex = e.postIndex, this.state.reelForwardItem = t, this.startForwardRequest(!1);
|
|
2500
|
-
}
|
|
2501
|
-
clearForwardState() {
|
|
2502
|
-
this.state.reelForward = {
|
|
2503
|
-
error: null,
|
|
2504
|
-
status: "idle"
|
|
2505
|
-
}, this.state.reelForwardIndex = null, this.state.reelForwardItem = null;
|
|
2506
|
-
}
|
|
2507
|
-
isReelOpen() {
|
|
2508
|
-
return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
|
|
2509
|
-
}
|
|
2510
|
-
restoreIntoPost(e, t) {
|
|
2511
|
-
let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
|
|
2512
|
-
if (r.splice(i, 0, t.media), this.state.items[e] = Qt(n, r), this.state.activeReelPostId !== t.postId) return;
|
|
2513
|
-
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
2514
|
-
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
2515
|
-
}
|
|
2516
|
-
startForwardRequest(e) {
|
|
2517
|
-
if (this.forwardPromise) return this.forwardPromise;
|
|
2518
|
-
let t = this.loadForward(e);
|
|
2519
|
-
return this.forwardPromise = t, t.finally(() => {
|
|
2520
|
-
this.forwardPromise === t && (this.forwardPromise = null, this.forward && this.state.reelForward.status === "loading" && this.startForwardRequest(!1));
|
|
2521
|
-
});
|
|
2522
|
-
}
|
|
2523
|
-
async loadForward(e) {
|
|
2524
|
-
let t = this.forward;
|
|
2525
|
-
if (t) for (e && await this.options.retryEnd(); this.forward === t && t.version === this.forwardVersion;) {
|
|
2526
|
-
let e = this.state.items[t.postIndex];
|
|
2527
|
-
if (e) {
|
|
2528
|
-
this.forward = null, this.clearForwardState(), this.options.onActivate(e.postId);
|
|
2529
|
-
return;
|
|
2530
|
-
}
|
|
2531
|
-
if (this.state.nextPageError) {
|
|
2532
|
-
this.state.reelForward = {
|
|
2533
|
-
error: this.state.nextPageError,
|
|
2534
|
-
status: "error"
|
|
2535
|
-
};
|
|
2536
|
-
return;
|
|
2537
|
-
}
|
|
2538
|
-
if (this.state.next === null) {
|
|
2539
|
-
this.state.reelForward = {
|
|
2540
|
-
error: null,
|
|
2541
|
-
status: "end"
|
|
2542
|
-
};
|
|
2543
|
-
return;
|
|
2544
|
-
}
|
|
2545
|
-
let n = this.state.next;
|
|
2546
|
-
if (await this.options.loadNext(), this.state.next === n && !this.state.nextPageError && !this.state.items[t.postIndex]) {
|
|
2547
|
-
this.state.reelForward = {
|
|
2548
|
-
error: /* @__PURE__ */ Error("Vibe could not advance while page loading is unavailable."),
|
|
2549
|
-
status: "error"
|
|
2550
|
-
};
|
|
2551
|
-
return;
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
updateMediaIndexAfterRemoval(e, t, n) {
|
|
2556
|
-
let r = this.state.items.find((t) => t.postId === e);
|
|
2557
|
-
if (!r) return;
|
|
2558
|
-
let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
|
|
2559
|
-
n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
|
|
2560
|
-
}
|
|
2561
|
-
};
|
|
2562
|
-
//#endregion
|
|
2563
2451
|
//#region src/core/fill.ts
|
|
2564
|
-
function
|
|
2452
|
+
function en(e) {
|
|
2565
2453
|
return "pages" in e ? { pages: e.pages } : { until: "end" };
|
|
2566
2454
|
}
|
|
2567
|
-
function
|
|
2455
|
+
function tn(e) {
|
|
2568
2456
|
return `${typeof e}:${String(e)}`;
|
|
2569
2457
|
}
|
|
2570
|
-
function
|
|
2458
|
+
function nn(e) {
|
|
2571
2459
|
if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
|
|
2572
2460
|
if ("pages" in e) {
|
|
2573
2461
|
if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
|
|
@@ -2576,20 +2464,20 @@ function rn(e) {
|
|
|
2576
2464
|
if ("until" in e && e.until === "end") return { until: "end" };
|
|
2577
2465
|
throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
|
|
2578
2466
|
}
|
|
2579
|
-
function
|
|
2467
|
+
function rn(e) {
|
|
2580
2468
|
if (!e) return;
|
|
2581
2469
|
if (e.strategy === "frontend") {
|
|
2582
|
-
|
|
2470
|
+
At(e, "frontend fill");
|
|
2583
2471
|
return;
|
|
2584
2472
|
}
|
|
2585
2473
|
if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
|
|
2586
2474
|
let t = e.initialSession;
|
|
2587
2475
|
if (t) {
|
|
2588
2476
|
if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
|
|
2589
|
-
|
|
2477
|
+
nn(t.target);
|
|
2590
2478
|
}
|
|
2591
2479
|
}
|
|
2592
|
-
function
|
|
2480
|
+
function an(e, t, n = !0) {
|
|
2593
2481
|
let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
|
|
2594
2482
|
return {
|
|
2595
2483
|
completedPages: i?.completedPages ?? 0,
|
|
@@ -2603,10 +2491,10 @@ function on(e, t, n = !0) {
|
|
|
2603
2491
|
sessionId: i?.sessionId ?? null,
|
|
2604
2492
|
status: i?.status ?? "idle",
|
|
2605
2493
|
strategy: e?.strategy ?? null,
|
|
2606
|
-
target: i ?
|
|
2494
|
+
target: i ? en(i.target) : null
|
|
2607
2495
|
};
|
|
2608
2496
|
}
|
|
2609
|
-
function
|
|
2497
|
+
function on(e) {
|
|
2610
2498
|
return [
|
|
2611
2499
|
"cancelling",
|
|
2612
2500
|
"filling",
|
|
@@ -2614,17 +2502,17 @@ function sn(e) {
|
|
|
2614
2502
|
"waiting"
|
|
2615
2503
|
].includes(e.status);
|
|
2616
2504
|
}
|
|
2617
|
-
async function
|
|
2505
|
+
async function sn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
|
|
2618
2506
|
let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
|
|
2619
2507
|
for (; p !== null;) {
|
|
2620
|
-
let e =
|
|
2508
|
+
let e = tn(f);
|
|
2621
2509
|
if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
|
|
2622
|
-
u.add(e), await
|
|
2623
|
-
delayMs:
|
|
2510
|
+
u.add(e), await Mt({
|
|
2511
|
+
delayMs: jt(d, a),
|
|
2624
2512
|
onChange: r,
|
|
2625
2513
|
signal: o
|
|
2626
2514
|
});
|
|
2627
|
-
let t =
|
|
2515
|
+
let t = wt(await n({
|
|
2628
2516
|
cursor: f,
|
|
2629
2517
|
signal: o
|
|
2630
2518
|
}));
|
|
@@ -2666,7 +2554,7 @@ async function cn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
|
|
|
2666
2554
|
}
|
|
2667
2555
|
//#endregion
|
|
2668
2556
|
//#region src/core/backendFill.ts
|
|
2669
|
-
async function
|
|
2557
|
+
async function cn(e, t, n, r) {
|
|
2670
2558
|
let i = await e.onStart(n);
|
|
2671
2559
|
if (r()) {
|
|
2672
2560
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
|
|
@@ -2680,22 +2568,22 @@ async function ln(e, t, n, r) {
|
|
|
2680
2568
|
});
|
|
2681
2569
|
}
|
|
2682
2570
|
}
|
|
2683
|
-
function
|
|
2571
|
+
function ln(e, t, n) {
|
|
2684
2572
|
return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
|
|
2685
2573
|
}
|
|
2686
|
-
function
|
|
2574
|
+
function un(e) {
|
|
2687
2575
|
return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
|
|
2688
2576
|
}
|
|
2689
|
-
function
|
|
2577
|
+
function dn(e, t) {
|
|
2690
2578
|
if (!["complete", "exhausted"].includes(t.status)) return !0;
|
|
2691
2579
|
let n = e.fill.target;
|
|
2692
2580
|
return !n || !Array.isArray(t.items) || t.next === void 0 || t.lastCursor === void 0 ? !1 : t.status === "exhausted" ? "pages" in n && t.completedPages < n.pages && t.next === null : "pages" in n ? t.completedPages === n.pages : t.next === null;
|
|
2693
2581
|
}
|
|
2694
|
-
function
|
|
2582
|
+
function fn(e, t, n) {
|
|
2695
2583
|
t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Q(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
|
|
2696
2584
|
}
|
|
2697
|
-
function
|
|
2698
|
-
return !
|
|
2585
|
+
function pn(e, t, n, r) {
|
|
2586
|
+
return !ln(e, t, n) || !un(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !dn(t, n) ? !1 : (fn(t, n, r), Object.assign(t.fill, {
|
|
2699
2587
|
...$(n.status === "waiting" ? n.nextRequestAt : null),
|
|
2700
2588
|
completedPages: n.completedPages,
|
|
2701
2589
|
error: n.error ?? null,
|
|
@@ -2704,41 +2592,41 @@ function mn(e, t, n, r) {
|
|
|
2704
2592
|
status: n.status
|
|
2705
2593
|
}), !0);
|
|
2706
2594
|
}
|
|
2707
|
-
function
|
|
2595
|
+
function mn(e, t, n, r) {
|
|
2708
2596
|
if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
|
|
2709
2597
|
let i = t.fill;
|
|
2710
|
-
return t.fill =
|
|
2598
|
+
return t.fill = an(e, n), !un(n) || !dn(t, n) ? (t.fill = i, !1) : (fn(t, n, r), !0);
|
|
2711
2599
|
}
|
|
2712
2600
|
//#endregion
|
|
2713
2601
|
//#region src/core/fillController.ts
|
|
2714
|
-
var
|
|
2602
|
+
var hn = class {
|
|
2715
2603
|
abortController = null;
|
|
2716
2604
|
cycle = 0;
|
|
2717
2605
|
delayCountdown;
|
|
2718
2606
|
requestVersion = 0;
|
|
2719
2607
|
constructor(e) {
|
|
2720
|
-
this.options = e, this.delayCountdown = new
|
|
2608
|
+
this.options = e, this.delayCountdown = new Nt((e) => {
|
|
2721
2609
|
Object.assign(this.options.state.fill, e);
|
|
2722
2610
|
}), this.syncBackendCountdown();
|
|
2723
2611
|
}
|
|
2724
2612
|
isActive() {
|
|
2725
|
-
return
|
|
2613
|
+
return on(this.options.state.fill);
|
|
2726
2614
|
}
|
|
2727
2615
|
applyUpdate(e) {
|
|
2728
|
-
let t =
|
|
2616
|
+
let t = pn(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2729
2617
|
return t && this.syncBackendCountdown(), t;
|
|
2730
2618
|
}
|
|
2731
2619
|
restoreSession(e) {
|
|
2732
|
-
let t =
|
|
2620
|
+
let t = mn(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2733
2621
|
return t && this.syncBackendCountdown(), t;
|
|
2734
2622
|
}
|
|
2735
2623
|
async start(e) {
|
|
2736
2624
|
let t = this.options.fill;
|
|
2737
2625
|
if (!t) throw Error("Vibe fill is not configured.");
|
|
2738
2626
|
if (this.isActive()) throw Error("Vibe fill is already active.");
|
|
2739
|
-
let n =
|
|
2627
|
+
let n = nn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
2740
2628
|
if (this.options.state.fill = {
|
|
2741
|
-
...
|
|
2629
|
+
...an(t, void 0, !1),
|
|
2742
2630
|
cycleId: r,
|
|
2743
2631
|
status: "filling",
|
|
2744
2632
|
target: n
|
|
@@ -2749,7 +2637,7 @@ var gn = class {
|
|
|
2749
2637
|
let i = ++this.requestVersion, a = new AbortController();
|
|
2750
2638
|
this.abortController = a;
|
|
2751
2639
|
try {
|
|
2752
|
-
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await
|
|
2640
|
+
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await cn(t, this.options.state, {
|
|
2753
2641
|
cycleId: r,
|
|
2754
2642
|
feedKey: t.feedKey,
|
|
2755
2643
|
items: [...this.options.state.items],
|
|
@@ -2767,7 +2655,7 @@ var gn = class {
|
|
|
2767
2655
|
}
|
|
2768
2656
|
async cancel() {
|
|
2769
2657
|
let { fill: e, state: t } = this.options;
|
|
2770
|
-
if (!
|
|
2658
|
+
if (!on(t.fill) || !t.fill.cycleId) return;
|
|
2771
2659
|
let n = {
|
|
2772
2660
|
cycleId: t.fill.cycleId,
|
|
2773
2661
|
feedKey: t.fill.feedKey ?? "",
|
|
@@ -2781,7 +2669,7 @@ var gn = class {
|
|
|
2781
2669
|
}
|
|
2782
2670
|
}
|
|
2783
2671
|
reset() {
|
|
2784
|
-
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill =
|
|
2672
|
+
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = an(this.options.fill, void 0, !1);
|
|
2785
2673
|
}
|
|
2786
2674
|
destroy() {
|
|
2787
2675
|
this.abortLocalRequest(), this.delayCountdown.clear();
|
|
@@ -2797,7 +2685,7 @@ var gn = class {
|
|
|
2797
2685
|
if (!i) throw Error("Vibe frontend fill requires loadPage.");
|
|
2798
2686
|
let a = this.options.state;
|
|
2799
2687
|
a.isLoadingMore = !0;
|
|
2800
|
-
let o = await
|
|
2688
|
+
let o = await sn({
|
|
2801
2689
|
existingItems: a.items,
|
|
2802
2690
|
initialCursor: a.next,
|
|
2803
2691
|
loadPage: i,
|
|
@@ -2824,7 +2712,7 @@ var gn = class {
|
|
|
2824
2712
|
};
|
|
2825
2713
|
//#endregion
|
|
2826
2714
|
//#region src/core/feedFooter.ts
|
|
2827
|
-
function
|
|
2715
|
+
function gn(e) {
|
|
2828
2716
|
return {
|
|
2829
2717
|
cancelAutofill: () => e.cancelAutofill(),
|
|
2830
2718
|
loadMore: () => e.loadNext(),
|
|
@@ -2832,45 +2720,45 @@ function _n(e) {
|
|
|
2832
2720
|
retryEnd: () => e.retryEnd()
|
|
2833
2721
|
};
|
|
2834
2722
|
}
|
|
2835
|
-
function
|
|
2723
|
+
function _n(e) {
|
|
2836
2724
|
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
2837
2725
|
}
|
|
2838
|
-
function
|
|
2839
|
-
e?.intervalMs !== void 0 &&
|
|
2726
|
+
function vn(e) {
|
|
2727
|
+
e?.intervalMs !== void 0 && _n(e.intervalMs);
|
|
2840
2728
|
}
|
|
2841
|
-
function
|
|
2729
|
+
function yn(e) {
|
|
2842
2730
|
return {
|
|
2843
2731
|
enabled: e?.enabled ?? !1,
|
|
2844
2732
|
includePostItems: e?.includePostItems ?? !1,
|
|
2845
2733
|
intervalMs: e?.intervalMs ?? 5e3
|
|
2846
2734
|
};
|
|
2847
2735
|
}
|
|
2848
|
-
function
|
|
2736
|
+
function bn(e, t) {
|
|
2849
2737
|
if (typeof t == "boolean") {
|
|
2850
2738
|
e.enabled = t;
|
|
2851
2739
|
return;
|
|
2852
2740
|
}
|
|
2853
|
-
|
|
2741
|
+
vn(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
|
|
2854
2742
|
}
|
|
2855
2743
|
//#endregion
|
|
2856
2744
|
//#region src/core/reelInfoSheet.ts
|
|
2857
|
-
function
|
|
2745
|
+
function xn(e) {
|
|
2858
2746
|
return { enabled: e?.enabled ?? !1 };
|
|
2859
2747
|
}
|
|
2860
|
-
function
|
|
2748
|
+
function Sn(e, t, n) {
|
|
2861
2749
|
if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
|
|
2862
2750
|
e.enabled = n;
|
|
2863
2751
|
}
|
|
2864
2752
|
//#endregion
|
|
2865
2753
|
//#region src/core/initialRuntimeState.ts
|
|
2866
|
-
function
|
|
2754
|
+
function Cn(e, t) {
|
|
2867
2755
|
let n = e.initialPage;
|
|
2868
2756
|
return {
|
|
2869
2757
|
activeReelPostId: null,
|
|
2870
|
-
autoScroll:
|
|
2871
|
-
autofill:
|
|
2758
|
+
autoScroll: qt(e.autoScroll),
|
|
2759
|
+
autofill: Rt(e.autofill),
|
|
2872
2760
|
error: null,
|
|
2873
|
-
fill:
|
|
2761
|
+
fill: an(e.fill),
|
|
2874
2762
|
infiniteScroll: e.infiniteScroll ?? !0,
|
|
2875
2763
|
isLoading: !n,
|
|
2876
2764
|
isLoadingMore: !1,
|
|
@@ -2880,14 +2768,14 @@ function wn(e, t) {
|
|
|
2880
2768
|
mediaIndices: /* @__PURE__ */ new Map(),
|
|
2881
2769
|
next: n?.next ?? null,
|
|
2882
2770
|
nextPageError: null,
|
|
2883
|
-
reelAutoAdvance:
|
|
2771
|
+
reelAutoAdvance: yn(e.reelAutoAdvance),
|
|
2884
2772
|
reelForward: {
|
|
2885
2773
|
error: null,
|
|
2886
2774
|
status: "idle"
|
|
2887
2775
|
},
|
|
2888
2776
|
reelForwardIndex: null,
|
|
2889
2777
|
reelForwardItem: null,
|
|
2890
|
-
reelInfoSheet:
|
|
2778
|
+
reelInfoSheet: xn(e.reelInfoSheet),
|
|
2891
2779
|
reelInfoSheetOverlay: !1,
|
|
2892
2780
|
reelMediaSource: "original",
|
|
2893
2781
|
reelOrigin: null,
|
|
@@ -2895,19 +2783,136 @@ function wn(e, t) {
|
|
|
2895
2783
|
};
|
|
2896
2784
|
}
|
|
2897
2785
|
//#endregion
|
|
2898
|
-
//#region src/core/
|
|
2786
|
+
//#region src/core/options.ts
|
|
2787
|
+
function wn(e, t) {
|
|
2788
|
+
if (t) {
|
|
2789
|
+
if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
|
|
2790
|
+
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2899
2793
|
function Tn(e, t) {
|
|
2794
|
+
if (t) {
|
|
2795
|
+
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
|
|
2796
|
+
for (let [n, r] of [["paddingX", t.paddingX], ["paddingY", t.paddingY]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe mediaCard ${e} ${n} must be a non-negative number.`);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
function En(e) {
|
|
2800
|
+
if (Kt(e.autoScroll), wn("cardHeader", e.cardHeader), wn("cardFooter", e.cardFooter), Tn("header", e.mediaCard?.header), Tn("footer", e.mediaCard?.footer), Lt(e.autofill), rn(e.fill), vn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
|
|
2801
|
+
if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
|
|
2802
|
+
if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
|
|
2803
|
+
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
2804
|
+
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
2805
|
+
}
|
|
2806
|
+
function Dn(e) {
|
|
2807
|
+
if (typeof e != "string") return e;
|
|
2808
|
+
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
2809
|
+
let t = document.querySelector(e);
|
|
2810
|
+
if (!t) throw Error(`Vibe target not found: ${e}`);
|
|
2811
|
+
return t;
|
|
2812
|
+
}
|
|
2813
|
+
//#endregion
|
|
2814
|
+
//#region src/core/activeItemRemoval.ts
|
|
2815
|
+
function On(e, t, n, r, i) {
|
|
2816
|
+
let a = new Set(t.map(({ item: e }) => e.postId));
|
|
2817
|
+
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
2818
|
+
let o = e.items[Math.max(n, 0)];
|
|
2819
|
+
if (o) {
|
|
2820
|
+
r(o.postId);
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
let s = t.find(({ item: t }) => t.postId === e.activeReelPostId)?.item;
|
|
2824
|
+
s && i(Math.max(n, 0), s);
|
|
2825
|
+
}
|
|
2826
|
+
//#endregion
|
|
2827
|
+
//#region src/core/exactMediaRemovalController.ts
|
|
2828
|
+
function kn(e, t) {
|
|
2829
|
+
let [n, ...r] = t;
|
|
2830
|
+
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
2831
|
+
return {
|
|
2832
|
+
...e,
|
|
2833
|
+
...n,
|
|
2834
|
+
items: r
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
function An(e) {
|
|
2838
|
+
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
2839
|
+
}
|
|
2840
|
+
var jn = class {
|
|
2841
|
+
generation = 0;
|
|
2842
|
+
metadata = /* @__PURE__ */ new WeakMap();
|
|
2843
|
+
state;
|
|
2844
|
+
constructor(e) {
|
|
2845
|
+
this.options = e, this.state = e.state;
|
|
2846
|
+
}
|
|
2847
|
+
remove(e) {
|
|
2848
|
+
An(e);
|
|
2849
|
+
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
2850
|
+
if (!n) return null;
|
|
2851
|
+
let r = [...j(n)], i = r[e.mediaIndex];
|
|
2852
|
+
if (!i) return null;
|
|
2853
|
+
let a = Object.freeze({
|
|
2854
|
+
media: i,
|
|
2855
|
+
mediaIndex: e.mediaIndex,
|
|
2856
|
+
postId: e.postId,
|
|
2857
|
+
postIndex: t
|
|
2858
|
+
});
|
|
2859
|
+
this.metadata.set(a, {
|
|
2860
|
+
generation: this.generation,
|
|
2861
|
+
originalItem: n,
|
|
2862
|
+
restored: !1
|
|
2863
|
+
});
|
|
2864
|
+
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
2865
|
+
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = kn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
|
|
2866
|
+
}
|
|
2867
|
+
reset() {
|
|
2868
|
+
this.generation += 1;
|
|
2869
|
+
}
|
|
2870
|
+
restore(e) {
|
|
2871
|
+
let t = this.metadata.get(e);
|
|
2872
|
+
if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
|
|
2873
|
+
if (t.generation !== this.generation || t.restored) return !1;
|
|
2874
|
+
t.restored = !0;
|
|
2875
|
+
let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
|
|
2876
|
+
return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.options.reelForward.cancel(e) && (this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
|
|
2877
|
+
}
|
|
2878
|
+
advanceFromRemovedPost(e, t) {
|
|
2879
|
+
let n = this.state.items[e.postIndex];
|
|
2880
|
+
if (n) {
|
|
2881
|
+
this.options.onActivate(n.postId);
|
|
2882
|
+
return;
|
|
2883
|
+
}
|
|
2884
|
+
this.options.reelForward.start(e, e.postIndex, t);
|
|
2885
|
+
}
|
|
2886
|
+
isReelOpen() {
|
|
2887
|
+
return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
|
|
2888
|
+
}
|
|
2889
|
+
restoreIntoPost(e, t) {
|
|
2890
|
+
let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
|
|
2891
|
+
if (r.splice(i, 0, t.media), this.state.items[e] = kn(n, r), this.state.activeReelPostId !== t.postId) return;
|
|
2892
|
+
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
2893
|
+
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
2894
|
+
}
|
|
2895
|
+
updateMediaIndexAfterRemoval(e, t, n) {
|
|
2896
|
+
let r = this.state.items.find((t) => t.postId === e);
|
|
2897
|
+
if (!r) return;
|
|
2898
|
+
let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
|
|
2899
|
+
n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
//#endregion
|
|
2903
|
+
//#region src/core/itemPlacement.ts
|
|
2904
|
+
function Mn(e, t) {
|
|
2900
2905
|
let n = new Set(t);
|
|
2901
2906
|
return e.flatMap((e, t) => n.has(e.postId) ? [{
|
|
2902
2907
|
index: t,
|
|
2903
2908
|
item: e
|
|
2904
2909
|
}] : []);
|
|
2905
2910
|
}
|
|
2906
|
-
function
|
|
2911
|
+
function Nn(e, t) {
|
|
2907
2912
|
let n = new Set(t.map(({ item: e }) => e.postId));
|
|
2908
2913
|
return e.filter((e) => !n.has(e.postId));
|
|
2909
2914
|
}
|
|
2910
|
-
function
|
|
2915
|
+
function Pn(e, t) {
|
|
2911
2916
|
t.forEach(({ index: e }) => {
|
|
2912
2917
|
if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
|
|
2913
2918
|
});
|
|
@@ -2918,7 +2923,7 @@ function Dn(e, t) {
|
|
|
2918
2923
|
}
|
|
2919
2924
|
//#endregion
|
|
2920
2925
|
//#region src/core/itemRemovalController.ts
|
|
2921
|
-
var
|
|
2926
|
+
var Fn = 20, In = class {
|
|
2922
2927
|
generation = 0;
|
|
2923
2928
|
historyLimit;
|
|
2924
2929
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -2927,7 +2932,7 @@ var On = 20, kn = class {
|
|
|
2927
2932
|
itemOrder;
|
|
2928
2933
|
stopItemsWatcher;
|
|
2929
2934
|
constructor(e) {
|
|
2930
|
-
this.options = e, this.historyLimit = e.historyLimit ??
|
|
2935
|
+
this.options = e, this.historyLimit = e.historyLimit ?? Fn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
|
|
2931
2936
|
}
|
|
2932
2937
|
destroy() {
|
|
2933
2938
|
this.reset(), this.stopItemsWatcher();
|
|
@@ -2935,10 +2940,12 @@ var On = 20, kn = class {
|
|
|
2935
2940
|
async remove(e) {
|
|
2936
2941
|
let t = this.collectOrderedPlacements(e), n = this.createRemoval(t);
|
|
2937
2942
|
if (t.length === 0) return n;
|
|
2938
|
-
let r = t.map(({ item: e }) => e.postId)
|
|
2943
|
+
let r = t.map(({ item: e }) => e.postId);
|
|
2944
|
+
if (await this.options.prepareRemoval(r), this.metadata.get(n)?.generation !== this.generation) return n;
|
|
2945
|
+
let i = this.options.startRemoval(r);
|
|
2939
2946
|
if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
|
|
2940
|
-
let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId);
|
|
2941
|
-
return this.state.items =
|
|
2947
|
+
let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
|
|
2948
|
+
return this.state.items = Nn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
|
|
2942
2949
|
}
|
|
2943
2950
|
reset() {
|
|
2944
2951
|
this.generation += 1, this.history = [], this.itemOrder = [];
|
|
@@ -2949,13 +2956,16 @@ var On = 20, kn = class {
|
|
|
2949
2956
|
this.restoreRemoval(t);
|
|
2950
2957
|
return;
|
|
2951
2958
|
}
|
|
2952
|
-
let n =
|
|
2959
|
+
let n = Pn(this.state.items, e);
|
|
2953
2960
|
this.registerExternalPlacements(e), this.state.items = n;
|
|
2954
2961
|
}
|
|
2955
2962
|
restoreRemoval(e) {
|
|
2956
2963
|
let t = this.metadata.get(e);
|
|
2957
2964
|
if (!t) throw TypeError("Vibe removal does not belong to this instance.");
|
|
2958
|
-
|
|
2965
|
+
if (t.generation !== this.generation || t.restored) return !1;
|
|
2966
|
+
t.restored = !0, this.removeFromHistory(e);
|
|
2967
|
+
let n = this.restoreOrderedPlacements(e);
|
|
2968
|
+
return n && this.options.onRemovalRestored(e), n;
|
|
2959
2969
|
}
|
|
2960
2970
|
undoLast() {
|
|
2961
2971
|
for (; this.history.length > 0;) {
|
|
@@ -2972,7 +2982,7 @@ var On = 20, kn = class {
|
|
|
2972
2982
|
}
|
|
2973
2983
|
collectOrderedPlacements(e) {
|
|
2974
2984
|
let t = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
2975
|
-
return
|
|
2985
|
+
return Mn(this.state.items, e).map((e) => ({
|
|
2976
2986
|
index: t.get(e.item.postId) ?? e.index,
|
|
2977
2987
|
item: e.item
|
|
2978
2988
|
}));
|
|
@@ -3003,46 +3013,174 @@ var On = 20, kn = class {
|
|
|
3003
3013
|
let r = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
3004
3014
|
return this.state.items = [...this.state.items, ...n].sort((e, t) => (r.get(e.postId) ?? 2 ** 53 - 1) - (r.get(t.postId) ?? 2 ** 53 - 1)), !0;
|
|
3005
3015
|
}
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3016
|
+
}, Ln = class {
|
|
3017
|
+
forward = null;
|
|
3018
|
+
forwardPromise = null;
|
|
3019
|
+
forwardVersion = 0;
|
|
3020
|
+
state;
|
|
3021
|
+
constructor(e) {
|
|
3022
|
+
this.options = e, this.state = e.state;
|
|
3013
3023
|
}
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3024
|
+
start(e, t, n) {
|
|
3025
|
+
this.forward = {
|
|
3026
|
+
item: n,
|
|
3027
|
+
postIndex: t,
|
|
3028
|
+
token: e,
|
|
3029
|
+
version: ++this.forwardVersion
|
|
3030
|
+
}, this.state.reelForward = {
|
|
3031
|
+
error: null,
|
|
3032
|
+
status: "loading"
|
|
3033
|
+
}, this.state.reelForwardIndex = t, this.state.reelForwardItem = n, this.startForwardRequest(!1);
|
|
3019
3034
|
}
|
|
3035
|
+
cancel(e) {
|
|
3036
|
+
if (this.forward?.token !== e || this.state.reelForward.status === "idle") return null;
|
|
3037
|
+
let t = this.forward.item;
|
|
3038
|
+
return this.forwardVersion += 1, this.forward = null, this.clearState(), t;
|
|
3039
|
+
}
|
|
3040
|
+
reset() {
|
|
3041
|
+
this.forwardVersion += 1, this.forward = null, this.forwardPromise = null, this.clearState();
|
|
3042
|
+
}
|
|
3043
|
+
retry() {
|
|
3044
|
+
return !this.forward || this.state.reelForward.status === "idle" ? Promise.resolve() : (this.state.nextPageError = null, this.state.reelForward = {
|
|
3045
|
+
error: null,
|
|
3046
|
+
status: "loading"
|
|
3047
|
+
}, this.startForwardRequest(this.state.next === null));
|
|
3048
|
+
}
|
|
3049
|
+
clearState() {
|
|
3050
|
+
this.state.reelForward = {
|
|
3051
|
+
error: null,
|
|
3052
|
+
status: "idle"
|
|
3053
|
+
}, this.state.reelForwardIndex = null, this.state.reelForwardItem = null;
|
|
3054
|
+
}
|
|
3055
|
+
startForwardRequest(e) {
|
|
3056
|
+
if (this.forwardPromise) return this.forwardPromise;
|
|
3057
|
+
let t = this.loadForward(e);
|
|
3058
|
+
return this.forwardPromise = t, t.finally(() => {
|
|
3059
|
+
this.forwardPromise === t && (this.forwardPromise = null, this.forward && this.state.reelForward.status === "loading" && this.startForwardRequest(!1));
|
|
3060
|
+
});
|
|
3061
|
+
}
|
|
3062
|
+
async loadForward(e) {
|
|
3063
|
+
let t = this.forward;
|
|
3064
|
+
if (t) for (e && await this.options.retryEnd(); this.forward === t && t.version === this.forwardVersion;) {
|
|
3065
|
+
let e = this.state.items[t.postIndex];
|
|
3066
|
+
if (e) {
|
|
3067
|
+
this.forward = null, this.clearState(), this.options.onActivate(e.postId);
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
if (this.state.nextPageError) {
|
|
3071
|
+
this.state.reelForward = {
|
|
3072
|
+
error: this.state.nextPageError,
|
|
3073
|
+
status: "error"
|
|
3074
|
+
};
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3077
|
+
if (this.state.next === null) {
|
|
3078
|
+
this.state.reelForward = {
|
|
3079
|
+
error: null,
|
|
3080
|
+
status: "end"
|
|
3081
|
+
};
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
let n = this.state.next;
|
|
3085
|
+
if (await this.options.loadNext(), this.state.next === n && !this.state.nextPageError && !this.state.items[t.postIndex]) {
|
|
3086
|
+
this.state.reelForward = {
|
|
3087
|
+
error: /* @__PURE__ */ Error("Vibe could not advance while page loading is unavailable."),
|
|
3088
|
+
status: "error"
|
|
3089
|
+
};
|
|
3090
|
+
return;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}, Rn = class {
|
|
3095
|
+
generation = 0;
|
|
3096
|
+
pending = Promise.resolve();
|
|
3097
|
+
constructor(e) {
|
|
3098
|
+
this.options = e;
|
|
3099
|
+
}
|
|
3100
|
+
prepareItems(e) {
|
|
3101
|
+
return this.serialize(() => this.preparePosts(e));
|
|
3102
|
+
}
|
|
3103
|
+
prepareMedia(e) {
|
|
3104
|
+
return this.serialize(async () => {
|
|
3105
|
+
let { state: t } = this.options;
|
|
3106
|
+
if (!this.isReelActive() || t.activeReelPostId !== e.postId) return;
|
|
3107
|
+
let n = t.items.find(({ postId: t }) => t === e.postId);
|
|
3108
|
+
if (!n) return;
|
|
3109
|
+
let r = t.mediaIndices.get(e.postId) ?? 0;
|
|
3110
|
+
if (e.mediaIndex === r) {
|
|
3111
|
+
if (j(n).length > 1) {
|
|
3112
|
+
await this.options.transitionMedia(1);
|
|
3113
|
+
return;
|
|
3114
|
+
}
|
|
3115
|
+
await this.preparePosts([e.postId]);
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
reset() {
|
|
3120
|
+
this.generation += 1, this.pending = Promise.resolve();
|
|
3121
|
+
}
|
|
3122
|
+
async preparePosts(e) {
|
|
3123
|
+
let { state: t } = this.options, n = t.activeReelPostId, r = new Set(e);
|
|
3124
|
+
if (!this.isReelActive() || n === null || !r.has(n)) return;
|
|
3125
|
+
let i = this.generation, a = t.items.findIndex(({ postId: e }) => e === n);
|
|
3126
|
+
if (a < 0) return;
|
|
3127
|
+
let o = this.nextSurvivor(a, r);
|
|
3128
|
+
o && i === this.generation && t.activeReelPostId === n && await this.options.transitionPost(o.postId);
|
|
3129
|
+
}
|
|
3130
|
+
isReelActive() {
|
|
3131
|
+
let { state: e } = this.options;
|
|
3132
|
+
return e.layout === "reel" || e.reelOrigin === "masonry";
|
|
3133
|
+
}
|
|
3134
|
+
nextSurvivor(e, t) {
|
|
3135
|
+
if (!(e < 0)) return this.options.state.items.slice(e + 1).find(({ postId: e }) => !t.has(e));
|
|
3136
|
+
}
|
|
3137
|
+
serialize(e) {
|
|
3138
|
+
let t = this.pending.then(e, e);
|
|
3139
|
+
return this.pending = t.catch(() => void 0), t;
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
//#endregion
|
|
3143
|
+
//#region src/core/removalControllers.ts
|
|
3144
|
+
function zn(e) {
|
|
3145
|
+
let t = new Ln(e), n = new Rn({
|
|
3146
|
+
state: e.state,
|
|
3147
|
+
transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
|
|
3148
|
+
transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
|
|
3149
|
+
});
|
|
3150
|
+
return {
|
|
3151
|
+
exactMediaRemoval: new jn({
|
|
3152
|
+
onActivate: e.onActivate,
|
|
3153
|
+
reelForward: t,
|
|
3154
|
+
state: e.state
|
|
3155
|
+
}),
|
|
3156
|
+
itemRemoval: new In({
|
|
3157
|
+
historyLimit: e.historyLimit,
|
|
3158
|
+
onItemsRemoved: (n, r, i) => {
|
|
3159
|
+
On(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
|
|
3160
|
+
},
|
|
3161
|
+
onRemovalRestored: (n) => {
|
|
3162
|
+
let r = t.cancel(n);
|
|
3163
|
+
r && e.onActivate(r.postId);
|
|
3164
|
+
},
|
|
3165
|
+
prepareRemoval: (e) => n.prepareItems(e),
|
|
3166
|
+
startRemoval: (t) => e.surface()?.startItemRemoval(t) ?? 0,
|
|
3167
|
+
state: e.state
|
|
3168
|
+
}),
|
|
3169
|
+
reelForward: t,
|
|
3170
|
+
reelRemoval: n
|
|
3171
|
+
};
|
|
3020
3172
|
}
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
|
|
3024
|
-
if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
|
|
3025
|
-
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
3026
|
-
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
3027
|
-
}
|
|
3028
|
-
function Nn(e) {
|
|
3029
|
-
if (typeof e != "string") return e;
|
|
3030
|
-
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
3031
|
-
let t = document.querySelector(e);
|
|
3032
|
-
if (!t) throw Error(`Vibe target not found: ${e}`);
|
|
3033
|
-
return t;
|
|
3034
|
-
}
|
|
3035
|
-
var Pn = 1.5;
|
|
3036
|
-
function Fn(e) {
|
|
3173
|
+
var Bn = 1.5;
|
|
3174
|
+
function Vn(e) {
|
|
3037
3175
|
let t = Math.min(e.screenWidth, e.screenHeight);
|
|
3038
3176
|
if (t > 0 && t < 600) return !0;
|
|
3039
|
-
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n *
|
|
3177
|
+
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Bn;
|
|
3040
3178
|
return !e.hasHover && n > 0 && n < 600 && r;
|
|
3041
3179
|
}
|
|
3042
|
-
function
|
|
3043
|
-
return
|
|
3180
|
+
function Hn(e) {
|
|
3181
|
+
return Vn(e) ? "reel" : "masonry";
|
|
3044
3182
|
}
|
|
3045
|
-
function
|
|
3183
|
+
function Un(e) {
|
|
3046
3184
|
let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
|
|
3047
3185
|
return {
|
|
3048
3186
|
hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
|
|
@@ -3052,15 +3190,15 @@ function Ln(e) {
|
|
|
3052
3190
|
viewportWidth: n.clientWidth
|
|
3053
3191
|
};
|
|
3054
3192
|
}
|
|
3055
|
-
function
|
|
3056
|
-
return
|
|
3193
|
+
function Wn(e) {
|
|
3194
|
+
return Vn(Un(e));
|
|
3057
3195
|
}
|
|
3058
|
-
function
|
|
3059
|
-
return
|
|
3196
|
+
function Gn(e) {
|
|
3197
|
+
return Hn(Un(e));
|
|
3060
3198
|
}
|
|
3061
3199
|
//#endregion
|
|
3062
3200
|
//#region src/core/responsiveLayoutController.ts
|
|
3063
|
-
var
|
|
3201
|
+
var Kn = class {
|
|
3064
3202
|
layoutMode;
|
|
3065
3203
|
resizeObserver = null;
|
|
3066
3204
|
target = null;
|
|
@@ -3085,10 +3223,10 @@ var Bn = class {
|
|
|
3085
3223
|
}
|
|
3086
3224
|
handleResponsiveLayout = () => {
|
|
3087
3225
|
if (!this.target) return;
|
|
3088
|
-
let e =
|
|
3089
|
-
this.state.reelInfoSheetOverlay =
|
|
3226
|
+
let e = Gn(this.target);
|
|
3227
|
+
this.state.reelInfoSheetOverlay = Wn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
|
|
3090
3228
|
};
|
|
3091
|
-
},
|
|
3229
|
+
}, qn = class {
|
|
3092
3230
|
routedReelPostId = null;
|
|
3093
3231
|
reelRouteIsActive = !1;
|
|
3094
3232
|
constructor(e, t) {
|
|
@@ -3115,7 +3253,7 @@ var Bn = class {
|
|
|
3115
3253
|
let i = this.reelRouteIsActive ? "replace" : "push";
|
|
3116
3254
|
this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
|
|
3117
3255
|
}
|
|
3118
|
-
},
|
|
3256
|
+
}, Jn = class {
|
|
3119
3257
|
app = null;
|
|
3120
3258
|
autoScroll;
|
|
3121
3259
|
autofillDelayCountdown;
|
|
@@ -3128,53 +3266,54 @@ var Bn = class {
|
|
|
3128
3266
|
fillController;
|
|
3129
3267
|
exactMediaRemoval;
|
|
3130
3268
|
itemRemoval;
|
|
3269
|
+
reelForward;
|
|
3270
|
+
reelRemoval;
|
|
3131
3271
|
surface = null;
|
|
3132
3272
|
stopStateWatcher = null;
|
|
3133
3273
|
lastLoadedCursor = null;
|
|
3134
3274
|
state;
|
|
3135
3275
|
constructor(e) {
|
|
3136
|
-
this.options = e,
|
|
3276
|
+
this.options = e, En(e);
|
|
3137
3277
|
let t = e.layout ?? "masonry";
|
|
3138
|
-
this.state = b(
|
|
3278
|
+
this.state = b(Cn(e, t)), this.autoScroll = new Jt({
|
|
3139
3279
|
getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
|
|
3140
3280
|
state: this.state.autoScroll
|
|
3141
|
-
}), this.autofillDelayCountdown = new
|
|
3281
|
+
}), this.autofillDelayCountdown = new Nt((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new hn({
|
|
3142
3282
|
fill: e.fill,
|
|
3143
3283
|
loadPage: e.loadPage,
|
|
3144
3284
|
onLastCursor: (e) => {
|
|
3145
3285
|
this.lastLoadedCursor = e;
|
|
3146
3286
|
},
|
|
3147
3287
|
state: this.state
|
|
3148
|
-
}), this.routing = new
|
|
3288
|
+
}), this.routing = new qn(e.routing, this.state);
|
|
3289
|
+
let n = zn({
|
|
3290
|
+
historyLimit: e.removalHistoryLimit,
|
|
3149
3291
|
loadNext: () => this.loadNext(),
|
|
3150
3292
|
onActivate: (e) => this.setActiveReelPost(e),
|
|
3151
3293
|
retryEnd: () => this.retryEnd(),
|
|
3152
|
-
state: this.state
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
Zt(this.state, this.routing, e, t, () => this.closeMasonryReel());
|
|
3157
|
-
},
|
|
3158
|
-
startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
|
|
3159
|
-
state: this.state
|
|
3160
|
-
}), this.responsiveLayout = new Bn(t, this.state, () => {
|
|
3294
|
+
state: this.state,
|
|
3295
|
+
surface: () => this.surface
|
|
3296
|
+
});
|
|
3297
|
+
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Kn(t, this.state, () => {
|
|
3161
3298
|
this.routing.syncFeed();
|
|
3162
3299
|
}), this.startStateNotifications();
|
|
3163
3300
|
}
|
|
3164
3301
|
async mount() {
|
|
3165
3302
|
if (this.app) throw Error("Vibe is already mounted.");
|
|
3166
3303
|
this.startStateNotifications();
|
|
3167
|
-
let e =
|
|
3168
|
-
this.responsiveLayout.mount(e), this.app = r(
|
|
3304
|
+
let e = Dn(this.options.target);
|
|
3305
|
+
this.responsiveLayout.mount(e), this.app = r(Ct, {
|
|
3169
3306
|
canRetryEnd: !!this.options.loadPage,
|
|
3170
3307
|
cardFooter: this.options.cardFooter,
|
|
3171
3308
|
cardHeader: this.options.cardHeader,
|
|
3172
3309
|
feedFooter: this.options.feedFooter,
|
|
3173
|
-
feedFooterActions:
|
|
3310
|
+
feedFooterActions: gn(this),
|
|
3174
3311
|
mediaCard: this.options.mediaCard,
|
|
3175
3312
|
reelInfoSheet: this.options.reelInfoSheet,
|
|
3176
3313
|
state: this.state,
|
|
3177
|
-
onActiveReelChange: (e) =>
|
|
3314
|
+
onActiveReelChange: (e) => {
|
|
3315
|
+
this.state.reelForward.status === "idle" && this.setActiveReelPost(e);
|
|
3316
|
+
},
|
|
3178
3317
|
onCloseReel: () => this.closeMasonryReel(),
|
|
3179
3318
|
onLoadMore: () => {
|
|
3180
3319
|
this.loadNext();
|
|
@@ -3190,7 +3329,7 @@ var Bn = class {
|
|
|
3190
3329
|
}), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
|
|
3191
3330
|
}
|
|
3192
3331
|
destroy() {
|
|
3193
|
-
this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
|
|
3332
|
+
this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
|
|
3194
3333
|
}
|
|
3195
3334
|
getState() {
|
|
3196
3335
|
return F(this.state);
|
|
@@ -3198,6 +3337,9 @@ var Bn = class {
|
|
|
3198
3337
|
removeMedia(e) {
|
|
3199
3338
|
return this.exactMediaRemoval.remove(e);
|
|
3200
3339
|
}
|
|
3340
|
+
removeMediaAnimated(e) {
|
|
3341
|
+
return this.reelRemoval.prepareMedia(e).then(() => this.exactMediaRemoval.remove(e));
|
|
3342
|
+
}
|
|
3201
3343
|
removeItems(e) {
|
|
3202
3344
|
return this.itemRemoval.remove(e);
|
|
3203
3345
|
}
|
|
@@ -3211,7 +3353,7 @@ var Bn = class {
|
|
|
3211
3353
|
return this.itemRemoval.restoreRemoval(e);
|
|
3212
3354
|
}
|
|
3213
3355
|
retryReelForward() {
|
|
3214
|
-
return this.
|
|
3356
|
+
return this.reelForward.retry();
|
|
3215
3357
|
}
|
|
3216
3358
|
undoLastRemoval() {
|
|
3217
3359
|
return this.itemRemoval.undoLast();
|
|
@@ -3241,11 +3383,11 @@ var Bn = class {
|
|
|
3241
3383
|
this.autoScroll.setSpeed(e);
|
|
3242
3384
|
}
|
|
3243
3385
|
applyAutofillUpdate(e) {
|
|
3244
|
-
let t =
|
|
3386
|
+
let t = Zt(this.options.autofill, this.state, e);
|
|
3245
3387
|
return t && this.syncAutofillCountdown(), t;
|
|
3246
3388
|
}
|
|
3247
3389
|
async cancelAutofill() {
|
|
3248
|
-
await
|
|
3390
|
+
await Bt(this.options.autofill, this.state, () => this.cancelRequest());
|
|
3249
3391
|
}
|
|
3250
3392
|
applyFillUpdate(e) {
|
|
3251
3393
|
return this.fillController.applyUpdate(e);
|
|
@@ -3254,11 +3396,11 @@ var Bn = class {
|
|
|
3254
3396
|
return this.fillController.cancel();
|
|
3255
3397
|
}
|
|
3256
3398
|
async fill(e) {
|
|
3257
|
-
if (this.pendingRequest ||
|
|
3399
|
+
if (this.pendingRequest || zt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
|
|
3258
3400
|
await this.fillController.start(e);
|
|
3259
3401
|
}
|
|
3260
3402
|
restoreAutofillSession(e) {
|
|
3261
|
-
let t =
|
|
3403
|
+
let t = Qt(this.options.autofill, this.state, e);
|
|
3262
3404
|
return t && this.syncAutofillCountdown(), t;
|
|
3263
3405
|
}
|
|
3264
3406
|
restoreFillSession(e) {
|
|
@@ -3266,7 +3408,7 @@ var Bn = class {
|
|
|
3266
3408
|
}
|
|
3267
3409
|
async loadNext() {
|
|
3268
3410
|
if (this.pendingRequest) return this.pendingRequest;
|
|
3269
|
-
if (!this.state.loadMoreLocked && !(
|
|
3411
|
+
if (!this.state.loadMoreLocked && !(zt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next === null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.state.next, !0);
|
|
3270
3412
|
}
|
|
3271
3413
|
async refresh() {
|
|
3272
3414
|
return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
|
|
@@ -3276,11 +3418,11 @@ var Bn = class {
|
|
|
3276
3418
|
}
|
|
3277
3419
|
async replaceFeed(e, t) {
|
|
3278
3420
|
if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
|
|
3279
|
-
return
|
|
3421
|
+
return zt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Rt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
|
|
3280
3422
|
}
|
|
3281
3423
|
async retryEnd() {
|
|
3282
3424
|
if (this.pendingRequest) return this.pendingRequest;
|
|
3283
|
-
if (!this.state.loadMoreLocked && !(
|
|
3425
|
+
if (!this.state.loadMoreLocked && !(zt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
|
|
3284
3426
|
}
|
|
3285
3427
|
setInfiniteScroll(e) {
|
|
3286
3428
|
this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
|
|
@@ -3289,10 +3431,10 @@ var Bn = class {
|
|
|
3289
3431
|
this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
|
|
3290
3432
|
}
|
|
3291
3433
|
setReelAutoAdvance(e) {
|
|
3292
|
-
|
|
3434
|
+
bn(this.state.reelAutoAdvance, e);
|
|
3293
3435
|
}
|
|
3294
3436
|
setReelInfoSheet(e) {
|
|
3295
|
-
|
|
3437
|
+
Sn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
|
|
3296
3438
|
}
|
|
3297
3439
|
setLayout(e) {
|
|
3298
3440
|
this.responsiveLayout.setLayout(e);
|
|
@@ -3316,7 +3458,7 @@ var Bn = class {
|
|
|
3316
3458
|
this.abortController = i;
|
|
3317
3459
|
try {
|
|
3318
3460
|
if (a?.strategy === "frontend") {
|
|
3319
|
-
let o = await
|
|
3461
|
+
let o = await Ht({
|
|
3320
3462
|
existingItems: t ? this.state.items : [],
|
|
3321
3463
|
initialCursor: e,
|
|
3322
3464
|
loadPage: n,
|
|
@@ -3338,7 +3480,7 @@ var Bn = class {
|
|
|
3338
3480
|
});
|
|
3339
3481
|
return;
|
|
3340
3482
|
}
|
|
3341
|
-
let c =
|
|
3483
|
+
let c = wt(await n({
|
|
3342
3484
|
cursor: e,
|
|
3343
3485
|
signal: i.signal
|
|
3344
3486
|
}));
|
|
@@ -3353,7 +3495,7 @@ var Bn = class {
|
|
|
3353
3495
|
this.state.autofill.status = "complete";
|
|
3354
3496
|
return;
|
|
3355
3497
|
}
|
|
3356
|
-
await
|
|
3498
|
+
await Yt(a, this.state, {
|
|
3357
3499
|
cycleId: o,
|
|
3358
3500
|
feedKey: a.feedKey,
|
|
3359
3501
|
items: u.slice(l.length),
|
|
@@ -3378,7 +3520,7 @@ var Bn = class {
|
|
|
3378
3520
|
this.autofillDelayCountdown.clear();
|
|
3379
3521
|
let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
|
|
3380
3522
|
return this.state.autofill = {
|
|
3381
|
-
...
|
|
3523
|
+
...Rt(e, void 0, !1),
|
|
3382
3524
|
cycleId: t,
|
|
3383
3525
|
status: "filling"
|
|
3384
3526
|
}, t;
|
|
@@ -3396,7 +3538,7 @@ var Bn = class {
|
|
|
3396
3538
|
startInitialAutofill() {
|
|
3397
3539
|
let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
|
|
3398
3540
|
this.abortController = t, this.state.isLoadingMore = !0;
|
|
3399
|
-
let r =
|
|
3541
|
+
let r = $t({
|
|
3400
3542
|
cycleId: n,
|
|
3401
3543
|
isCurrent: () => e === this.requestVersion,
|
|
3402
3544
|
onLastCursor: (e) => {
|
|
@@ -3420,8 +3562,8 @@ var Bn = class {
|
|
|
3420
3562
|
}));
|
|
3421
3563
|
}
|
|
3422
3564
|
};
|
|
3423
|
-
function
|
|
3424
|
-
return new
|
|
3565
|
+
function Yn(e) {
|
|
3566
|
+
return new Jn(e);
|
|
3425
3567
|
}
|
|
3426
3568
|
//#endregion
|
|
3427
|
-
export {
|
|
3569
|
+
export { Yn as createVibe };
|