@wyxos/vibe 4.5.0 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/ReelFeed.vue.d.ts +5 -1
- package/lib/components/ReelLayout.vue.d.ts +7 -1
- package/lib/components/VibeSurface.vue.d.ts +2 -0
- package/lib/core/activeItemRemoval.d.ts +3 -0
- package/lib/core/exactMediaRemovalController.d.ts +23 -0
- package/lib/core/feed.d.ts +4 -1
- package/lib/core/itemRemovalController.d.ts +2 -1
- package/lib/core/reelForwardController.d.ts +24 -0
- package/lib/core/removalControllers.d.ts +20 -0
- package/lib/core/runtime.d.ts +5 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +758 -504
- package/lib/style.css +1 -1
- package/lib/types.d.ts +21 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -34,6 +34,7 @@ function F(e) {
|
|
|
34
34
|
next: e.next,
|
|
35
35
|
nextPageError: e.nextPageError,
|
|
36
36
|
reelAutoAdvance: { ...e.reelAutoAdvance },
|
|
37
|
+
reelForward: { ...e.reelForward },
|
|
37
38
|
reelInfoSheet: { ...e.reelInfoSheet },
|
|
38
39
|
reelOrigin: e.reelOrigin,
|
|
39
40
|
total: e.total
|
|
@@ -84,7 +85,7 @@ var I = {
|
|
|
84
85
|
onClick: n[0] ||= (e) => t.$emit("retryEnd")
|
|
85
86
|
}, " Check for more ", 8, B)]))])) : a("", !0);
|
|
86
87
|
}
|
|
87
|
-
}),
|
|
88
|
+
}), ee = /* @__PURE__ */ u({
|
|
88
89
|
__name: "FeedFooter",
|
|
89
90
|
props: {
|
|
90
91
|
actions: {},
|
|
@@ -135,7 +136,7 @@ var I = {
|
|
|
135
136
|
"load-more-locked"
|
|
136
137
|
]));
|
|
137
138
|
}
|
|
138
|
-
}),
|
|
139
|
+
}), H = ["role"], U = { class: "gallery-status" }, te = /* @__PURE__ */ u({
|
|
139
140
|
__name: "FeedStatus",
|
|
140
141
|
props: {
|
|
141
142
|
actions: {},
|
|
@@ -149,7 +150,7 @@ var I = {
|
|
|
149
150
|
return (n, u) => (y(), o("main", {
|
|
150
151
|
class: "gallery-shell",
|
|
151
152
|
role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
|
|
152
|
-
}, [s("p",
|
|
153
|
+
}, [s("p", U, [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(ee, {
|
|
153
154
|
key: 0,
|
|
154
155
|
actions: t.actions,
|
|
155
156
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -170,36 +171,36 @@ var I = {
|
|
|
170
171
|
"is-loading",
|
|
171
172
|
"load-more-locked",
|
|
172
173
|
"state"
|
|
173
|
-
])) : a("", !0)], 8,
|
|
174
|
+
])) : a("", !0)], 8, H));
|
|
174
175
|
}
|
|
175
176
|
});
|
|
176
|
-
function
|
|
177
|
+
function W(e) {
|
|
177
178
|
return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
|
|
178
179
|
}
|
|
179
180
|
//#endregion
|
|
180
181
|
//#region src/core/masonry.ts
|
|
181
|
-
function
|
|
182
|
+
function ne(e) {
|
|
182
183
|
let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
|
|
183
184
|
return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function re(e) {
|
|
186
187
|
return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
+
function ie(e) {
|
|
189
190
|
return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
+
function G(e, t) {
|
|
192
193
|
let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
|
|
193
194
|
return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
+
function K(e, t, n) {
|
|
196
197
|
if (t <= 0 || e.length === 0) return {
|
|
197
198
|
columns: 0,
|
|
198
199
|
height: 0,
|
|
199
200
|
items: []
|
|
200
201
|
};
|
|
201
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) => {
|
|
202
|
-
let t =
|
|
203
|
+
let t = re(c), n = s * ne(e) + i, a = {
|
|
203
204
|
x: t * (s + r),
|
|
204
205
|
y: c[t],
|
|
205
206
|
width: s,
|
|
@@ -215,10 +216,10 @@ function J(e, t, n) {
|
|
|
215
216
|
}
|
|
216
217
|
//#endregion
|
|
217
218
|
//#region src/core/scrollbar.ts
|
|
218
|
-
function
|
|
219
|
+
function q(e, t, n) {
|
|
219
220
|
return Math.min(n, Math.max(t, e));
|
|
220
221
|
}
|
|
221
|
-
function
|
|
222
|
+
function J({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
|
|
222
223
|
let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
|
|
223
224
|
if (!(c > 0 && o > 0)) return {
|
|
224
225
|
maximumScrollPosition: c,
|
|
@@ -227,23 +228,23 @@ function X({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
|
|
|
227
228
|
thumbSize: o,
|
|
228
229
|
thumbTravel: 0
|
|
229
230
|
};
|
|
230
|
-
let l =
|
|
231
|
+
let l = q(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
|
|
231
232
|
return {
|
|
232
233
|
maximumScrollPosition: c,
|
|
233
234
|
scrollable: !0,
|
|
234
|
-
thumbOffset: u * (
|
|
235
|
+
thumbOffset: u * (q(n, 0, c) / c),
|
|
235
236
|
thumbSize: l,
|
|
236
237
|
thumbTravel: u
|
|
237
238
|
};
|
|
238
239
|
}
|
|
239
240
|
//#endregion
|
|
240
241
|
//#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
|
|
241
|
-
var
|
|
242
|
+
var ae = ["aria-hidden"], oe = [
|
|
242
243
|
"aria-controls",
|
|
243
244
|
"aria-valuemax",
|
|
244
245
|
"aria-valuenow",
|
|
245
246
|
"tabindex"
|
|
246
|
-
],
|
|
247
|
+
], Y = 32, X = 40, Z = 120, se = /* @__PURE__ */ u({
|
|
247
248
|
__name: "GalleryScrollbar",
|
|
248
249
|
props: {
|
|
249
250
|
contentSize: {},
|
|
@@ -265,16 +266,16 @@ var re = ["aria-hidden"], ie = [
|
|
|
265
266
|
function k() {
|
|
266
267
|
v !== null && clearTimeout(v), v = setTimeout(() => {
|
|
267
268
|
v = null, c.value || (l.value = !1);
|
|
268
|
-
},
|
|
269
|
+
}, Z);
|
|
269
270
|
}
|
|
270
271
|
function A() {
|
|
271
272
|
l.value = !0, k();
|
|
272
273
|
}
|
|
273
274
|
function j() {
|
|
274
275
|
let e = t.scrollElement, n = i.value;
|
|
275
|
-
return !e || !n ? r :
|
|
276
|
+
return !e || !n ? r : J({
|
|
276
277
|
contentSize: e.scrollHeight,
|
|
277
|
-
minimumThumbSize:
|
|
278
|
+
minimumThumbSize: Y,
|
|
278
279
|
scrollPosition: e.scrollTop,
|
|
279
280
|
trackSize: n.clientHeight,
|
|
280
281
|
viewportSize: e.clientHeight
|
|
@@ -327,7 +328,7 @@ var re = ["aria-hidden"], ie = [
|
|
|
327
328
|
}
|
|
328
329
|
function z(e) {
|
|
329
330
|
if (!E.value) return;
|
|
330
|
-
let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r -
|
|
331
|
+
let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - X : e.key === "ArrowDown" ? r + X : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
|
|
331
332
|
i !== null && (e.preventDefault(), A(), P(i));
|
|
332
333
|
}
|
|
333
334
|
function B(e) {
|
|
@@ -373,7 +374,7 @@ var re = ["aria-hidden"], ie = [
|
|
|
373
374
|
onPointerdown: I,
|
|
374
375
|
onPointermove: L,
|
|
375
376
|
onPointerup: R
|
|
376
|
-
}, null, 44,
|
|
377
|
+
}, null, 44, oe)], 42, ae));
|
|
377
378
|
}
|
|
378
379
|
}), ce = (e) => {
|
|
379
380
|
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
@@ -692,45 +693,45 @@ var Oe = /* @__PURE__ */ u({
|
|
|
692
693
|
function x(e = !1, t = "pointer") {
|
|
693
694
|
e && b("activate", t);
|
|
694
695
|
}
|
|
695
|
-
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),
|
|
696
|
-
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), ee = C(1), H = 1, U = n(() => c.interactive && !!(c.cardHeader || c.cardFooter));
|
|
697
|
+
function te(e) {
|
|
697
698
|
return e.detail === 0 ? "keyboard" : "pointer";
|
|
698
699
|
}
|
|
699
|
-
function
|
|
700
|
+
function W(e, t) {
|
|
700
701
|
let n = S.value.length, r = (e + n) % n;
|
|
701
702
|
r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
|
|
702
703
|
}
|
|
703
|
-
function
|
|
704
|
+
function ne(e, t, n) {
|
|
704
705
|
return t === 1 ? e * 16 : t === 2 ? e * n : e;
|
|
705
706
|
}
|
|
706
|
-
function
|
|
707
|
+
function re() {
|
|
707
708
|
d = 0, f = !1, u !== null && clearTimeout(u), u = null;
|
|
708
709
|
}
|
|
709
|
-
function
|
|
710
|
-
u !== null && clearTimeout(u), u = setTimeout(
|
|
710
|
+
function ie() {
|
|
711
|
+
u !== null && clearTimeout(u), u = setTimeout(re, Xe);
|
|
711
712
|
}
|
|
712
|
-
function
|
|
713
|
+
function G(e) {
|
|
713
714
|
if (S.value.length <= 1) return;
|
|
714
|
-
let t = e.currentTarget?.clientWidth || 1, n =
|
|
715
|
-
if (n === 0 || (e.preventDefault(),
|
|
715
|
+
let t = e.currentTarget?.clientWidth || 1, n = ne(e.deltaX, e.deltaMode, t);
|
|
716
|
+
if (n === 0 || (e.preventDefault(), ie(), f) || (d += n, Math.abs(d) < Ze)) return;
|
|
716
717
|
let r = Math.sign(d);
|
|
717
|
-
d = 0, f = !0,
|
|
718
|
+
d = 0, f = !0, W(E.value + r);
|
|
718
719
|
}
|
|
719
|
-
function
|
|
720
|
+
function K(e) {
|
|
720
721
|
let t = e.touches[0];
|
|
721
722
|
c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
|
|
722
723
|
}
|
|
723
|
-
function
|
|
724
|
+
function q(e) {
|
|
724
725
|
let t = e.changedTouches[0];
|
|
725
726
|
if (p === null || h === null || !t) return;
|
|
726
727
|
let n = p - t.clientX, r = h - t.clientY;
|
|
727
|
-
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 || W(E.value + Math.sign(n)));
|
|
728
729
|
}
|
|
729
|
-
let
|
|
730
|
-
function
|
|
731
|
-
c.layout === "reel" && (e.stopPropagation(),
|
|
730
|
+
let J = n(() => De(P.value));
|
|
731
|
+
function ae(e) {
|
|
732
|
+
c.layout === "reel" && (e.stopPropagation(), oe());
|
|
732
733
|
}
|
|
733
|
-
async function
|
|
734
|
+
async function oe() {
|
|
734
735
|
if (L.value) {
|
|
735
736
|
if (V.value) {
|
|
736
737
|
L.value.pause();
|
|
@@ -743,35 +744,35 @@ var Oe = /* @__PURE__ */ u({
|
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
746
|
}
|
|
746
|
-
function
|
|
747
|
+
function Y(e) {
|
|
747
748
|
return Number.isFinite(e) ? Math.max(0, e) : 0;
|
|
748
749
|
}
|
|
749
|
-
function
|
|
750
|
+
function X(e) {
|
|
750
751
|
let t = e?.currentTarget ?? L.value;
|
|
751
|
-
t && (R.value =
|
|
752
|
+
t && (R.value = Y(t.currentTime), z.value = Y(t.duration), B.value = t.muted, ee.value = t.volume, t.volume > 0 && (H = t.volume));
|
|
752
753
|
}
|
|
753
|
-
function
|
|
754
|
-
|
|
754
|
+
function Z(e) {
|
|
755
|
+
X(e), b("ready", E.value);
|
|
755
756
|
}
|
|
756
757
|
function se() {
|
|
757
758
|
V.value = !1, b("ended", E.value);
|
|
758
759
|
}
|
|
759
760
|
function ce(e) {
|
|
760
761
|
let t = L.value;
|
|
761
|
-
!t || !Number.isFinite(e) || (t.currentTime = Math.min(
|
|
762
|
+
!t || !Number.isFinite(e) || (t.currentTime = Math.min(Y(t.duration), Math.max(0, e)), R.value = t.currentTime);
|
|
762
763
|
}
|
|
763
764
|
function le(e) {
|
|
764
765
|
let t = L.value;
|
|
765
766
|
if (!t || !Number.isFinite(e)) return;
|
|
766
767
|
let n = Math.min(1, Math.max(0, e));
|
|
767
|
-
t.volume = n, t.muted = n === 0, n > 0 && (
|
|
768
|
+
t.volume = n, t.muted = n === 0, n > 0 && (H = n), X();
|
|
768
769
|
}
|
|
769
770
|
function ue() {
|
|
770
771
|
let e = L.value;
|
|
771
|
-
e && (e.muted && e.volume === 0 && (e.volume =
|
|
772
|
+
e && (e.muted && e.volume === 0 && (e.volume = H), e.muted = !e.muted, X());
|
|
772
773
|
}
|
|
773
774
|
return _(() => {
|
|
774
|
-
|
|
775
|
+
re();
|
|
775
776
|
}), (n, r) => (y(), o("article", {
|
|
776
777
|
"data-post-id": e.item.postId,
|
|
777
778
|
"data-media-index": E.value,
|
|
@@ -785,10 +786,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
785
786
|
"aria-hidden": e.leaving || void 0,
|
|
786
787
|
"aria-busy": e.previewState === "loading",
|
|
787
788
|
inert: e.leaving || void 0,
|
|
788
|
-
role: e.interactive && !e.leaving && !
|
|
789
|
-
tabindex: e.interactive && !e.leaving && !
|
|
790
|
-
onClick: r[11] ||= (t) => x(e.interactive && !
|
|
791
|
-
onKeydown: [r[12] ||= k((t) => x(e.interactive && !
|
|
789
|
+
role: e.interactive && !e.leaving && !U.value ? "button" : void 0,
|
|
790
|
+
tabindex: e.interactive && !e.leaving && !U.value ? 0 : void 0,
|
|
791
|
+
onClick: r[11] ||= (t) => x(e.interactive && !U.value, te(t)),
|
|
792
|
+
onKeydown: [r[12] ||= k((t) => x(e.interactive && !U.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !U.value, "keyboard"), ["prevent"]), ["space"])]
|
|
792
793
|
}, [s("div", Re, [
|
|
793
794
|
e.cardHeader ? (y(), i(Oe, {
|
|
794
795
|
key: 0,
|
|
@@ -816,9 +817,9 @@ var Oe = /* @__PURE__ */ u({
|
|
|
816
817
|
s("div", {
|
|
817
818
|
class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
|
|
818
819
|
"data-media-direction": v.value,
|
|
819
|
-
onWheel:
|
|
820
|
-
onTouchstartPassive:
|
|
821
|
-
onTouchendPassive:
|
|
820
|
+
onWheel: G,
|
|
821
|
+
onTouchstartPassive: K,
|
|
822
|
+
onTouchendPassive: q
|
|
822
823
|
}, [
|
|
823
824
|
l(t, { name: `media-slide-${v.value}` }, {
|
|
824
825
|
default: O(() => [(y(), o("div", {
|
|
@@ -831,7 +832,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
831
832
|
class: "media-error",
|
|
832
833
|
role: "img",
|
|
833
834
|
"aria-label": `${T(we)(P.value)} ${T(Te)(P.value)}`
|
|
834
|
-
}, [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), J.value ? (y(), o("video", {
|
|
835
836
|
key: 2,
|
|
836
837
|
ref_key: "videoElement",
|
|
837
838
|
ref: L,
|
|
@@ -847,14 +848,14 @@ var Oe = /* @__PURE__ */ u({
|
|
|
847
848
|
muted: B.value,
|
|
848
849
|
playsinline: "",
|
|
849
850
|
preload: e.fetchPriority === "high" ? "auto" : "metadata",
|
|
850
|
-
onLoadedmetadata:
|
|
851
|
-
onDurationchange:
|
|
852
|
-
onTimeupdate:
|
|
853
|
-
onVolumechange:
|
|
851
|
+
onLoadedmetadata: Z,
|
|
852
|
+
onDurationchange: X,
|
|
853
|
+
onTimeupdate: X,
|
|
854
|
+
onVolumechange: X,
|
|
854
855
|
onPlaying: r[0] ||= (e) => V.value = !0,
|
|
855
856
|
onPause: r[1] ||= (e) => V.value = !1,
|
|
856
857
|
onEnded: se,
|
|
857
|
-
onClick:
|
|
858
|
+
onClick: ae,
|
|
858
859
|
onError: r[2] ||= (e) => n.$emit("error", E.value)
|
|
859
860
|
}, null, 42, We)) : (y(), o("img", {
|
|
860
861
|
key: 3,
|
|
@@ -871,17 +872,17 @@ var Oe = /* @__PURE__ */ u({
|
|
|
871
872
|
}, null, 42, Ge))], 8, Be))]),
|
|
872
873
|
_: 1
|
|
873
874
|
}, 8, ["name"]),
|
|
874
|
-
|
|
875
|
+
J.value && e.previewState === "ready" ? (y(), i(Ie, {
|
|
875
876
|
key: 0,
|
|
876
877
|
"current-time": R.value,
|
|
877
878
|
duration: z.value,
|
|
878
879
|
layout: e.layout,
|
|
879
880
|
muted: B.value,
|
|
880
881
|
playing: V.value,
|
|
881
|
-
volume:
|
|
882
|
+
volume: ee.value,
|
|
882
883
|
onSeek: ce,
|
|
883
884
|
onToggleMute: ue,
|
|
884
|
-
onTogglePlayback:
|
|
885
|
+
onTogglePlayback: oe,
|
|
885
886
|
onVolumeChange: le
|
|
886
887
|
}, null, 8, [
|
|
887
888
|
"current-time",
|
|
@@ -899,21 +900,21 @@ var Oe = /* @__PURE__ */ u({
|
|
|
899
900
|
type: "button",
|
|
900
901
|
class: "media-carousel-control media-carousel-control--previous",
|
|
901
902
|
"aria-label": `Previous media for post ${e.item.postId}`,
|
|
902
|
-
onClick: r[5] ||= A((e) =>
|
|
903
|
+
onClick: r[5] ||= A((e) => W(E.value - 1, e), ["stop"]),
|
|
903
904
|
onKeydown: r[6] ||= A(() => {}, ["stop"])
|
|
904
905
|
}, [l(T(_e), { size: 20 })], 40, Ke), s("button", {
|
|
905
906
|
type: "button",
|
|
906
907
|
class: "media-carousel-control media-carousel-control--next",
|
|
907
908
|
"aria-label": `Next media for post ${e.item.postId}`,
|
|
908
|
-
onClick: r[7] ||= A((e) =>
|
|
909
|
+
onClick: r[7] ||= A((e) => W(E.value + 1, e), ["stop"]),
|
|
909
910
|
onKeydown: r[8] ||= A(() => {}, ["stop"])
|
|
910
911
|
}, [l(T(ve), { size: 20 })], 40, qe)], 2)) : a("", !0),
|
|
911
|
-
|
|
912
|
+
U.value ? (y(), o("button", {
|
|
912
913
|
key: 2,
|
|
913
914
|
class: "media-card-activator",
|
|
914
915
|
type: "button",
|
|
915
916
|
"aria-label": `Open post ${e.item.postId}`,
|
|
916
|
-
onClick: r[9] ||= A((e) => n.$emit("activate",
|
|
917
|
+
onClick: r[9] ||= A((e) => n.$emit("activate", te(e)), ["stop"]),
|
|
917
918
|
onKeydown: r[10] ||= A(() => {}, ["stop"])
|
|
918
919
|
}, null, 40, Je)) : a("", !0)
|
|
919
920
|
], 42, ze),
|
|
@@ -976,14 +977,14 @@ var Oe = /* @__PURE__ */ u({
|
|
|
976
977
|
"retryEnd"
|
|
977
978
|
],
|
|
978
979
|
setup(t, { expose: r, emit: a }) {
|
|
979
|
-
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(() => K(c.items, h.value, {
|
|
980
981
|
additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
|
|
981
982
|
gap: v.value,
|
|
982
983
|
minColumnWidth: tt
|
|
983
984
|
})), M = n(() => {
|
|
984
985
|
let e = j.value;
|
|
985
986
|
if (c.leavingPostIds.size === 0) return e;
|
|
986
|
-
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 = K(t, h.value, {
|
|
987
988
|
additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
|
|
988
989
|
gap: v.value,
|
|
989
990
|
minColumnWidth: tt
|
|
@@ -996,16 +997,16 @@ var Oe = /* @__PURE__ */ u({
|
|
|
996
997
|
let e = Math.max(it, S.value * at), t = {
|
|
997
998
|
scrollTop: b.value - w.value,
|
|
998
999
|
viewportHeight: S.value
|
|
999
|
-
}, n =
|
|
1000
|
+
}, n = G(M.value.items, {
|
|
1000
1001
|
...t,
|
|
1001
1002
|
overscan: e
|
|
1002
|
-
}), r = c.leavingPostIds.size === 0 ? [] :
|
|
1003
|
+
}), r = c.leavingPostIds.size === 0 ? [] : G(j.value.items, {
|
|
1003
1004
|
...t,
|
|
1004
1005
|
overscan: e
|
|
1005
|
-
}), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a =
|
|
1006
|
+
}), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = G(M.value.items, {
|
|
1006
1007
|
...t,
|
|
1007
1008
|
overscan: 0
|
|
1008
|
-
}), o = c.leavingPostIds.size === 0 ? [] :
|
|
1009
|
+
}), o = c.leavingPostIds.size === 0 ? [] : G(j.value.items, {
|
|
1009
1010
|
...t,
|
|
1010
1011
|
overscan: 0
|
|
1011
1012
|
}), s = new Set([...a, ...o]);
|
|
@@ -1021,7 +1022,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1021
1022
|
function I(e) {
|
|
1022
1023
|
let t = M.value.items[e], n = c.items[e]?.postId;
|
|
1023
1024
|
if (!t) return {};
|
|
1024
|
-
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 ? ie({
|
|
1025
1026
|
containerHeight: j.value.height,
|
|
1026
1027
|
gap: v.value
|
|
1027
1028
|
}) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
|
|
@@ -1045,11 +1046,11 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1045
1046
|
}
|
|
1046
1047
|
function z(e) {
|
|
1047
1048
|
let t = e.currentTarget;
|
|
1048
|
-
t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll &&
|
|
1049
|
+
t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && W(t) && u("loadMore"));
|
|
1049
1050
|
}
|
|
1050
1051
|
function B() {
|
|
1051
1052
|
let e = d.value;
|
|
1052
|
-
!c.loadMoreLocked && e &&
|
|
1053
|
+
!c.loadMoreLocked && e && W(e) && u("loadMore");
|
|
1053
1054
|
}
|
|
1054
1055
|
function V() {
|
|
1055
1056
|
return d.value;
|
|
@@ -1123,7 +1124,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1123
1124
|
"onMediaChange",
|
|
1124
1125
|
"onReady",
|
|
1125
1126
|
"onError"
|
|
1126
|
-
]))), 128))], 6), l(
|
|
1127
|
+
]))), 128))], 6), l(ee, {
|
|
1127
1128
|
actions: t.feedFooterActions,
|
|
1128
1129
|
"can-retry-end": t.canRetryEnd,
|
|
1129
1130
|
"feed-footer": t.feedFooter,
|
|
@@ -1174,12 +1175,16 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1174
1175
|
onAnimationend: n[0] ||= (e) => i("complete")
|
|
1175
1176
|
}, null, 36)], 8, st));
|
|
1176
1177
|
}
|
|
1177
|
-
}), lt = ["data-active-post-id", "data-active-media-index"], ut =
|
|
1178
|
+
}), lt = ["data-active-post-id", "data-active-media-index"], ut = ["role", "data-status"], dt = 2, ft = /* @__PURE__ */ u({
|
|
1178
1179
|
__name: "ReelFeed",
|
|
1179
1180
|
props: {
|
|
1180
1181
|
initialPostId: {},
|
|
1181
1182
|
mediaSource: {},
|
|
1182
1183
|
reelAutoAdvance: {},
|
|
1184
|
+
reelForward: { default: () => ({
|
|
1185
|
+
error: null,
|
|
1186
|
+
status: "idle"
|
|
1187
|
+
}) },
|
|
1183
1188
|
canRetryEnd: { type: Boolean },
|
|
1184
1189
|
cardFooter: {},
|
|
1185
1190
|
cardHeader: {},
|
|
@@ -1203,95 +1208,96 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1203
1208
|
"loadMore",
|
|
1204
1209
|
"mediaChange",
|
|
1205
1210
|
"ready",
|
|
1206
|
-
"retryEnd"
|
|
1211
|
+
"retryEnd",
|
|
1212
|
+
"retryForward"
|
|
1207
1213
|
],
|
|
1208
1214
|
setup(t, { expose: r, emit: c }) {
|
|
1209
|
-
let
|
|
1210
|
-
let e = Math.max(0,
|
|
1211
|
-
return
|
|
1212
|
-
fetchPriority: e + n ===
|
|
1215
|
+
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 - dt), t = Math.min(l.items.length - 1, h.value + dt);
|
|
1217
|
+
return l.items.slice(e, t + 1).map((t, n) => ({
|
|
1218
|
+
fetchPriority: e + n === h.value ? "high" : "low",
|
|
1213
1219
|
index: e + n,
|
|
1214
1220
|
item: t
|
|
1215
1221
|
}));
|
|
1216
|
-
}), F = n(() =>
|
|
1222
|
+
}), F = n(() => l.items[h.value]?.postId), I = n(() => l.items[h.value]), L = n(() => {
|
|
1217
1223
|
let e = F.value;
|
|
1218
|
-
return e === void 0 ? 0 :
|
|
1224
|
+
return e === void 0 ? 0 : l.mediaIndices.get(e) ?? 0;
|
|
1219
1225
|
}), R = n(() => {
|
|
1220
1226
|
let e = F.value;
|
|
1221
|
-
return e === void 0 ? "loading" :
|
|
1227
|
+
return e === void 0 ? "loading" : l.previewStates.get(P(e, L.value)) ?? "loading";
|
|
1222
1228
|
}), z = n(() => {
|
|
1223
1229
|
let e = I.value;
|
|
1224
1230
|
if (!e) return "";
|
|
1225
1231
|
let t = N(e, L.value);
|
|
1226
|
-
return
|
|
1232
|
+
return l.mediaSource === "original" ? t.src : t.preview.src;
|
|
1227
1233
|
}), B = n(() => R.value === "ready" && De(z.value)), V = n(() => [
|
|
1228
1234
|
F.value,
|
|
1229
1235
|
L.value,
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
].join(":")),
|
|
1236
|
-
let e = I.value, t = !!(e &&
|
|
1236
|
+
l.items.length,
|
|
1237
|
+
l.loadMoreLocked,
|
|
1238
|
+
l.reelAutoAdvance.enabled,
|
|
1239
|
+
l.reelAutoAdvance.includePostItems,
|
|
1240
|
+
l.reelAutoAdvance.intervalMs
|
|
1241
|
+
].join(":")), H = n(() => {
|
|
1242
|
+
let e = I.value, t = !!(e && l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
|
|
1237
1243
|
return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
|
|
1238
|
-
}),
|
|
1239
|
-
function
|
|
1244
|
+
}), U = n(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && I.value !== void 0 && R.value !== "loading" && !B.value), te = 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.");
|
|
1245
|
+
function ne(e) {
|
|
1240
1246
|
return { gridRow: `${e + 1}` };
|
|
1241
1247
|
}
|
|
1242
|
-
function
|
|
1243
|
-
let t =
|
|
1244
|
-
return t <= 0 ||
|
|
1248
|
+
function re(e) {
|
|
1249
|
+
let t = S || e.clientHeight;
|
|
1250
|
+
return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
|
|
1245
1251
|
}
|
|
1246
|
-
function
|
|
1252
|
+
function ie(e) {
|
|
1247
1253
|
let t = e.currentTarget;
|
|
1248
|
-
t && (
|
|
1254
|
+
t && (b.value || (h.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && W(t) && u("loadMore"));
|
|
1249
1255
|
}
|
|
1250
|
-
function
|
|
1251
|
-
let e =
|
|
1252
|
-
e && (
|
|
1253
|
-
e.scrollTop =
|
|
1254
|
-
}),
|
|
1256
|
+
function G() {
|
|
1257
|
+
let e = d.value;
|
|
1258
|
+
e && (J(!0), S = e.clientHeight, e.scrollTop = h.value * S, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
|
|
1259
|
+
e.scrollTop = h.value * e.clientHeight, S = e.clientHeight, O = null;
|
|
1260
|
+
}), K());
|
|
1255
1261
|
}
|
|
1256
|
-
function
|
|
1262
|
+
function K() {
|
|
1257
1263
|
k !== null && clearTimeout(k), k = setTimeout(() => {
|
|
1258
1264
|
k = null;
|
|
1259
|
-
let e =
|
|
1260
|
-
e && (
|
|
1265
|
+
let e = d.value;
|
|
1266
|
+
e && (S = e.clientHeight, e.scrollTop = h.value * S), J(!1);
|
|
1261
1267
|
}, 120);
|
|
1262
1268
|
}
|
|
1263
|
-
function
|
|
1264
|
-
|
|
1265
|
-
let e =
|
|
1266
|
-
e && (
|
|
1269
|
+
function q() {
|
|
1270
|
+
J(!0);
|
|
1271
|
+
let e = d.value;
|
|
1272
|
+
e && (S = e.clientHeight, e.scrollTop = h.value * S), K();
|
|
1267
1273
|
}
|
|
1268
|
-
function
|
|
1269
|
-
|
|
1274
|
+
function J(e) {
|
|
1275
|
+
b.value = e, d.value?.toggleAttribute("data-resizing", e);
|
|
1270
1276
|
}
|
|
1271
|
-
function
|
|
1272
|
-
let e =
|
|
1273
|
-
!
|
|
1277
|
+
function ae() {
|
|
1278
|
+
let e = d.value;
|
|
1279
|
+
!l.loadMoreLocked && e && W(e) && u("loadMore");
|
|
1274
1280
|
}
|
|
1275
|
-
function
|
|
1281
|
+
function oe(e) {
|
|
1276
1282
|
let t = I.value;
|
|
1277
1283
|
if (!t) return !1;
|
|
1278
1284
|
let n = j(t).length;
|
|
1279
1285
|
if (n <= 1) return !1;
|
|
1280
1286
|
let r = (L.value + e + n) % n;
|
|
1281
|
-
return
|
|
1287
|
+
return u("mediaChange", t.postId, r), !0;
|
|
1282
1288
|
}
|
|
1283
|
-
function
|
|
1284
|
-
let t =
|
|
1285
|
-
return !
|
|
1289
|
+
function Y(e) {
|
|
1290
|
+
let t = h.value + e;
|
|
1291
|
+
return !d.value || t < 0 || t >= l.items.length ? !1 : (Z(t), !0);
|
|
1286
1292
|
}
|
|
1287
|
-
function
|
|
1293
|
+
function X() {
|
|
1288
1294
|
return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1289
1295
|
}
|
|
1290
1296
|
function Z(e) {
|
|
1291
|
-
let t =
|
|
1297
|
+
let t = d.value;
|
|
1292
1298
|
if (!t) return;
|
|
1293
|
-
let n = e * (
|
|
1294
|
-
if (
|
|
1299
|
+
let n = e * (S || t.clientHeight);
|
|
1300
|
+
if (h.value = e, !X() && typeof t.scrollTo == "function") {
|
|
1295
1301
|
t.scrollTo({
|
|
1296
1302
|
behavior: "smooth",
|
|
1297
1303
|
top: n
|
|
@@ -1300,40 +1306,41 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1300
1306
|
}
|
|
1301
1307
|
t.scrollTop = n;
|
|
1302
1308
|
}
|
|
1303
|
-
function
|
|
1304
|
-
if (!
|
|
1309
|
+
function se() {
|
|
1310
|
+
if (!l.reelAutoAdvance.enabled) return;
|
|
1305
1311
|
let e = I.value;
|
|
1306
1312
|
if (!e) return;
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1313
|
+
if (l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1) {
|
|
1314
|
+
u("mediaChange", e.postId, L.value + 1);
|
|
1309
1315
|
return;
|
|
1310
1316
|
}
|
|
1311
|
-
let t =
|
|
1317
|
+
let t = h.value + 1, n = l.items[t];
|
|
1312
1318
|
if (!n) {
|
|
1313
|
-
|
|
1319
|
+
l.hasNext && !l.loadMoreLocked && u("loadMore");
|
|
1314
1320
|
return;
|
|
1315
1321
|
}
|
|
1316
|
-
|
|
1322
|
+
l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), Z(t);
|
|
1317
1323
|
}
|
|
1318
|
-
function
|
|
1319
|
-
!
|
|
1324
|
+
function ce(e, t) {
|
|
1325
|
+
!l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || se();
|
|
1320
1326
|
}
|
|
1321
|
-
return D(
|
|
1322
|
-
E?.disconnect(), E = null, e && (
|
|
1323
|
-
}), D(() =>
|
|
1324
|
-
|
|
1327
|
+
return D(d, (e) => {
|
|
1328
|
+
E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(G), E.observe(e)));
|
|
1329
|
+
}), D([() => l.items.length, () => l.initialPostId], async ([e, t]) => {
|
|
1330
|
+
let n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
|
|
1331
|
+
h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), G();
|
|
1325
1332
|
}), D(F, (e) => {
|
|
1326
|
-
e !== void 0 &&
|
|
1333
|
+
e !== void 0 && u("activeChange", e);
|
|
1327
1334
|
}, { immediate: !0 }), v(() => {
|
|
1328
|
-
window.addEventListener("resize",
|
|
1335
|
+
window.addEventListener("resize", q), window.addEventListener("orientationchange", q), f >= 0 && p(G);
|
|
1329
1336
|
}), _(() => {
|
|
1330
|
-
window.removeEventListener("resize",
|
|
1337
|
+
window.removeEventListener("resize", q), window.removeEventListener("orientationchange", q), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
|
|
1331
1338
|
}), r({
|
|
1332
|
-
activeIndex:
|
|
1339
|
+
activeIndex: h,
|
|
1333
1340
|
activePostId: F,
|
|
1334
|
-
changeActiveMedia:
|
|
1335
|
-
loadIfNearBottom:
|
|
1336
|
-
moveActivePost:
|
|
1341
|
+
changeActiveMedia: oe,
|
|
1342
|
+
loadIfNearBottom: ae,
|
|
1343
|
+
moveActivePost: Y
|
|
1337
1344
|
}), (n, r) => (y(), o("main", {
|
|
1338
1345
|
class: m(["reel-shell", {
|
|
1339
1346
|
"reel-shell--has-footer": !!t.cardFooter,
|
|
@@ -1341,9 +1348,9 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1341
1348
|
}]),
|
|
1342
1349
|
"data-layout-mode": "reel"
|
|
1343
1350
|
}, [
|
|
1344
|
-
t.cardHeader && I.value ? (y(), i(Oe, {
|
|
1351
|
+
t.cardHeader && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
|
|
1345
1352
|
key: 0,
|
|
1346
|
-
index:
|
|
1353
|
+
index: h.value,
|
|
1347
1354
|
item: I.value,
|
|
1348
1355
|
layout: "reel",
|
|
1349
1356
|
"loaded-count": t.items.length,
|
|
@@ -1365,24 +1372,25 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1365
1372
|
])) : a("", !0),
|
|
1366
1373
|
s("div", {
|
|
1367
1374
|
ref_key: "galleryElement",
|
|
1368
|
-
ref:
|
|
1375
|
+
ref: d,
|
|
1369
1376
|
class: "gallery-shell reel-feed",
|
|
1370
1377
|
"data-active-post-id": F.value,
|
|
1371
1378
|
"data-active-media-index": L.value,
|
|
1372
|
-
onScrollPassive:
|
|
1373
|
-
}, [
|
|
1379
|
+
onScrollPassive: ie
|
|
1380
|
+
}, [t.reelForward.status === "idle" ? (y(), o("section", {
|
|
1381
|
+
key: 1,
|
|
1374
1382
|
class: "reel-track",
|
|
1375
1383
|
style: g(A.value),
|
|
1376
1384
|
"aria-label": "Media gallery"
|
|
1377
1385
|
}, [(y(!0), o(e, null, x(M.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i(Qe, {
|
|
1378
1386
|
key: n.postId,
|
|
1379
|
-
"advance-on-media-end":
|
|
1387
|
+
"advance-on-media-end": l.reelAutoAdvance.enabled && r === h.value,
|
|
1380
1388
|
class: "reel-item",
|
|
1381
1389
|
entering: !1,
|
|
1382
1390
|
"fetch-priority": e,
|
|
1383
1391
|
index: r,
|
|
1384
1392
|
item: n,
|
|
1385
|
-
"item-style":
|
|
1393
|
+
"item-style": ne(r),
|
|
1386
1394
|
"media-card": t.mediaCard,
|
|
1387
1395
|
layout: "reel",
|
|
1388
1396
|
"loaded-count": t.items.length,
|
|
@@ -1390,10 +1398,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1390
1398
|
"media-source": t.mediaSource,
|
|
1391
1399
|
"preview-state": t.previewStates.get(T(P)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
|
|
1392
1400
|
total: t.total,
|
|
1393
|
-
onMediaChange: (e) =>
|
|
1394
|
-
onEnded: (e) =>
|
|
1395
|
-
onReady: (e) =>
|
|
1396
|
-
onError: (e) =>
|
|
1401
|
+
onMediaChange: (e) => u("mediaChange", n.postId, e),
|
|
1402
|
+
onEnded: (e) => ce(n.postId, e),
|
|
1403
|
+
onReady: (e) => u("ready", n.postId, e),
|
|
1404
|
+
onError: (e) => u("error", n.postId, e)
|
|
1397
1405
|
}, null, 8, [
|
|
1398
1406
|
"advance-on-media-end",
|
|
1399
1407
|
"fetch-priority",
|
|
@@ -1410,7 +1418,18 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1410
1418
|
"onEnded",
|
|
1411
1419
|
"onReady",
|
|
1412
1420
|
"onError"
|
|
1413
|
-
]))), 128))], 4),
|
|
1421
|
+
]))), 128))], 4)) : (y(), o("div", {
|
|
1422
|
+
key: 0,
|
|
1423
|
+
class: "reel-forward-status",
|
|
1424
|
+
role: t.reelForward.status === "error" ? "alert" : "status",
|
|
1425
|
+
"data-status": t.reelForward.status
|
|
1426
|
+
}, [s("p", null, w(te.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (y(), o("button", {
|
|
1427
|
+
key: 0,
|
|
1428
|
+
class: "reel-forward-retry",
|
|
1429
|
+
type: "button",
|
|
1430
|
+
onClick: r[0] ||= (e) => u("retryForward")
|
|
1431
|
+
}, " Retry ")) : a("", !0)], 8, ut)), t.reelForward.status === "idle" ? (y(), i(ee, {
|
|
1432
|
+
key: 2,
|
|
1414
1433
|
actions: t.feedFooterActions,
|
|
1415
1434
|
"can-retry-end": t.canRetryEnd,
|
|
1416
1435
|
"feed-footer": t.feedFooter,
|
|
@@ -1419,8 +1438,8 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1419
1438
|
"is-loading": t.isLoadingMore,
|
|
1420
1439
|
"load-more-locked": t.loadMoreLocked,
|
|
1421
1440
|
state: t.state,
|
|
1422
|
-
onLoadMore: r[
|
|
1423
|
-
onRetryEnd: r[
|
|
1441
|
+
onLoadMore: r[1] ||= (e) => u("loadMore"),
|
|
1442
|
+
onRetryEnd: r[2] ||= (e) => u("retryEnd")
|
|
1424
1443
|
}, null, 8, [
|
|
1425
1444
|
"actions",
|
|
1426
1445
|
"can-retry-end",
|
|
@@ -1430,10 +1449,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1430
1449
|
"is-loading",
|
|
1431
1450
|
"load-more-locked",
|
|
1432
1451
|
"state"
|
|
1433
|
-
])], 40, lt),
|
|
1434
|
-
t.cardFooter && I.value ? (y(), i(Oe, {
|
|
1452
|
+
])) : a("", !0)], 40, lt),
|
|
1453
|
+
t.cardFooter && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
|
|
1435
1454
|
key: 1,
|
|
1436
|
-
index:
|
|
1455
|
+
index: h.value,
|
|
1437
1456
|
item: I.value,
|
|
1438
1457
|
layout: "reel",
|
|
1439
1458
|
"loaded-count": t.items.length,
|
|
@@ -1453,26 +1472,28 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1453
1472
|
"style",
|
|
1454
1473
|
"total"
|
|
1455
1474
|
])) : a("", !0),
|
|
1456
|
-
|
|
1475
|
+
U.value ? (y(), i(ct, {
|
|
1457
1476
|
key: V.value,
|
|
1458
1477
|
"duration-ms": t.reelAutoAdvance.intervalMs,
|
|
1459
|
-
label:
|
|
1460
|
-
onComplete:
|
|
1478
|
+
label: H.value,
|
|
1479
|
+
onComplete: se
|
|
1461
1480
|
}, null, 8, ["duration-ms", "label"])) : a("", !0)
|
|
1462
1481
|
], 2));
|
|
1463
1482
|
}
|
|
1464
|
-
}),
|
|
1483
|
+
}), pt = ["data-info-sheet-open", "data-info-sheet-mode"], mt = ["aria-hidden", "inert"], ht = {
|
|
1465
1484
|
key: 0,
|
|
1466
1485
|
class: "reel-info-sheet-layer",
|
|
1467
1486
|
"data-test": "reel-info-sheet"
|
|
1468
|
-
},
|
|
1487
|
+
}, gt = [
|
|
1469
1488
|
"role",
|
|
1470
1489
|
"aria-modal",
|
|
1471
1490
|
"tabindex",
|
|
1472
1491
|
"data-active-post-id"
|
|
1473
|
-
],
|
|
1492
|
+
], _t = /* @__PURE__ */ u({
|
|
1474
1493
|
__name: "ReelLayout",
|
|
1475
1494
|
props: {
|
|
1495
|
+
forwardIndex: { default: null },
|
|
1496
|
+
forwardItem: { default: null },
|
|
1476
1497
|
infoSheet: {},
|
|
1477
1498
|
infoSheetEnabled: { type: Boolean },
|
|
1478
1499
|
infoSheetOverlay: { type: Boolean },
|
|
@@ -1480,6 +1501,10 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1480
1501
|
initialPostId: {},
|
|
1481
1502
|
mediaSource: {},
|
|
1482
1503
|
reelAutoAdvance: {},
|
|
1504
|
+
reelForward: { default: () => ({
|
|
1505
|
+
error: null,
|
|
1506
|
+
status: "idle"
|
|
1507
|
+
}) },
|
|
1483
1508
|
canRetryEnd: { type: Boolean },
|
|
1484
1509
|
cardFooter: {},
|
|
1485
1510
|
cardHeader: {},
|
|
@@ -1504,55 +1529,56 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1504
1529
|
"loadMore",
|
|
1505
1530
|
"mediaChange",
|
|
1506
1531
|
"ready",
|
|
1507
|
-
"retryEnd"
|
|
1532
|
+
"retryEnd",
|
|
1533
|
+
"retryForward"
|
|
1508
1534
|
],
|
|
1509
1535
|
setup(e, { expose: r, emit: c }) {
|
|
1510
1536
|
let u = e, f = c, g = C(null), v = C(null), b = null, x = n(() => {
|
|
1511
1537
|
let e = u.initialPostId === null || u.initialPostId === void 0 ? -1 : u.items.findIndex((e) => e.postId === u.initialPostId);
|
|
1512
1538
|
return Math.max(0, e);
|
|
1513
|
-
}), w = n(() => u.items[x.value]), T = n(() => {
|
|
1514
|
-
let e =
|
|
1539
|
+
}), w = n(() => u.items[x.value]), T = n(() => w.value ?? (u.reelForward.status === "idle" ? void 0 : u.forwardItem ?? void 0)), E = n(() => w.value ? x.value : u.forwardIndex ?? 0), k = n(() => {
|
|
1540
|
+
let e = T.value?.postId;
|
|
1515
1541
|
return e === void 0 ? 0 : u.mediaIndices.get(e) ?? 0;
|
|
1516
|
-
}),
|
|
1517
|
-
let e =
|
|
1542
|
+
}), A = n(() => !!(u.infoSheet && u.infoSheetEnabled && T.value)), M = n(() => {
|
|
1543
|
+
let e = T.value;
|
|
1518
1544
|
return e ? {
|
|
1519
|
-
close:
|
|
1520
|
-
index:
|
|
1545
|
+
close: P,
|
|
1546
|
+
index: E.value,
|
|
1521
1547
|
item: e,
|
|
1522
1548
|
layout: "reel",
|
|
1523
1549
|
loadedCount: u.items.length,
|
|
1524
1550
|
mediaCount: j(e).length,
|
|
1525
|
-
mediaIndex:
|
|
1526
|
-
mediaItem: N(e,
|
|
1551
|
+
mediaIndex: k.value,
|
|
1552
|
+
mediaItem: N(e, k.value),
|
|
1527
1553
|
mediaSource: u.mediaSource ?? "preview",
|
|
1528
1554
|
origin: u.origin,
|
|
1529
1555
|
total: u.total
|
|
1530
1556
|
} : null;
|
|
1531
1557
|
});
|
|
1532
|
-
function
|
|
1558
|
+
function P() {
|
|
1533
1559
|
f("closeInfoSheet");
|
|
1534
1560
|
}
|
|
1535
|
-
function
|
|
1561
|
+
function F(e) {
|
|
1536
1562
|
return g.value?.changeActiveMedia(e) ?? !1;
|
|
1537
1563
|
}
|
|
1538
|
-
function
|
|
1564
|
+
function I() {
|
|
1539
1565
|
g.value?.loadIfNearBottom();
|
|
1540
1566
|
}
|
|
1541
|
-
function
|
|
1567
|
+
function L(e) {
|
|
1542
1568
|
return g.value?.moveActivePost(e) ?? !1;
|
|
1543
1569
|
}
|
|
1544
|
-
function
|
|
1570
|
+
function R(e, t) {
|
|
1545
1571
|
f("error", e, t);
|
|
1546
1572
|
}
|
|
1547
|
-
function
|
|
1573
|
+
function z(e, t) {
|
|
1548
1574
|
f("mediaChange", e, t);
|
|
1549
1575
|
}
|
|
1550
|
-
function
|
|
1576
|
+
function B(e, t) {
|
|
1551
1577
|
f("ready", e, t);
|
|
1552
1578
|
}
|
|
1553
1579
|
return D(() => ({
|
|
1554
1580
|
overlay: u.infoSheetOverlay,
|
|
1555
|
-
visible:
|
|
1581
|
+
visible: A.value
|
|
1556
1582
|
}), async (e, t) => {
|
|
1557
1583
|
if (e.visible && !t?.visible) {
|
|
1558
1584
|
b = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.overlay && (await p(), v.value?.focus({ preventScroll: !0 }));
|
|
@@ -1565,18 +1591,18 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1565
1591
|
}), _(() => {
|
|
1566
1592
|
b = null;
|
|
1567
1593
|
}), r({
|
|
1568
|
-
changeActiveMedia:
|
|
1569
|
-
loadIfNearBottom:
|
|
1570
|
-
moveActivePost:
|
|
1594
|
+
changeActiveMedia: F,
|
|
1595
|
+
loadIfNearBottom: I,
|
|
1596
|
+
moveActivePost: L
|
|
1571
1597
|
}), (n, r) => (y(), o("section", {
|
|
1572
1598
|
class: m(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
|
|
1573
|
-
"data-info-sheet-open":
|
|
1599
|
+
"data-info-sheet-open": A.value || void 0,
|
|
1574
1600
|
"data-info-sheet-mode": e.infoSheetOverlay ? "overlay" : "layout"
|
|
1575
1601
|
}, [s("div", {
|
|
1576
1602
|
class: "reel-layout-main",
|
|
1577
|
-
"aria-hidden": e.infoSheetOverlay &&
|
|
1578
|
-
inert: e.infoSheetOverlay &&
|
|
1579
|
-
}, [l(
|
|
1603
|
+
"aria-hidden": e.infoSheetOverlay && A.value || void 0,
|
|
1604
|
+
inert: e.infoSheetOverlay && A.value || void 0
|
|
1605
|
+
}, [l(ft, {
|
|
1580
1606
|
ref_key: "reelFeed",
|
|
1581
1607
|
ref: g,
|
|
1582
1608
|
"can-retry-end": e.canRetryEnd,
|
|
@@ -1596,14 +1622,16 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1596
1622
|
"next-page-error": e.nextPageError,
|
|
1597
1623
|
"preview-states": e.previewStates,
|
|
1598
1624
|
"reel-auto-advance": e.reelAutoAdvance,
|
|
1625
|
+
"reel-forward": e.reelForward,
|
|
1599
1626
|
state: e.state,
|
|
1600
1627
|
total: e.total,
|
|
1601
1628
|
onActiveChange: r[0] ||= (e) => f("activeChange", e),
|
|
1602
|
-
onError:
|
|
1629
|
+
onError: R,
|
|
1603
1630
|
onLoadMore: r[1] ||= (e) => f("loadMore"),
|
|
1604
|
-
onMediaChange:
|
|
1605
|
-
onReady:
|
|
1606
|
-
onRetryEnd: r[2] ||= (e) => f("retryEnd")
|
|
1631
|
+
onMediaChange: z,
|
|
1632
|
+
onReady: B,
|
|
1633
|
+
onRetryEnd: r[2] ||= (e) => f("retryEnd"),
|
|
1634
|
+
onRetryForward: r[3] ||= (e) => f("retryForward")
|
|
1607
1635
|
}, null, 8, [
|
|
1608
1636
|
"can-retry-end",
|
|
1609
1637
|
"card-footer",
|
|
@@ -1622,10 +1650,11 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1622
1650
|
"next-page-error",
|
|
1623
1651
|
"preview-states",
|
|
1624
1652
|
"reel-auto-advance",
|
|
1653
|
+
"reel-forward",
|
|
1625
1654
|
"state",
|
|
1626
1655
|
"total"
|
|
1627
|
-
])], 8,
|
|
1628
|
-
default: O(() => [
|
|
1656
|
+
])], 8, mt), l(t, { name: "vibe-info-sheet" }, {
|
|
1657
|
+
default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div", ht, [s("aside", {
|
|
1629
1658
|
ref_key: "sheetElement",
|
|
1630
1659
|
ref: v,
|
|
1631
1660
|
class: "reel-info-sheet",
|
|
@@ -1633,12 +1662,12 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1633
1662
|
"aria-label": "Reel information",
|
|
1634
1663
|
"aria-modal": e.infoSheetOverlay ? "true" : void 0,
|
|
1635
1664
|
tabindex: e.infoSheetOverlay ? -1 : void 0,
|
|
1636
|
-
"data-active-post-id":
|
|
1637
|
-
}, [(y(), i(S(e.infoSheet.component), h(d(
|
|
1665
|
+
"data-active-post-id": T.value?.postId
|
|
1666
|
+
}, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8, gt)])) : a("", !0)]),
|
|
1638
1667
|
_: 1
|
|
1639
|
-
})], 10,
|
|
1668
|
+
})], 10, pt));
|
|
1640
1669
|
}
|
|
1641
|
-
}),
|
|
1670
|
+
}), vt = 35, yt = 420, bt = /* @__PURE__ */ u({
|
|
1642
1671
|
__name: "VibeSurface",
|
|
1643
1672
|
props: {
|
|
1644
1673
|
canRetryEnd: { type: Boolean },
|
|
@@ -1656,96 +1685,97 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1656
1685
|
"loadMore",
|
|
1657
1686
|
"openReel",
|
|
1658
1687
|
"reelInfoSheetChange",
|
|
1659
|
-
"retryEnd"
|
|
1688
|
+
"retryEnd",
|
|
1689
|
+
"retryForward"
|
|
1660
1690
|
],
|
|
1661
1691
|
setup(r, { expose: s, emit: c }) {
|
|
1662
|
-
let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Set()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = C(/* @__PURE__ */ new Map()), N =
|
|
1663
|
-
function
|
|
1692
|
+
let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Set()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = C(/* @__PURE__ */ new Map()), N = n(() => F(u.state)), I = n(() => u.state.reelMediaSource === "original" ? j.value : A.value), L = new Set(u.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
|
|
1693
|
+
function V() {
|
|
1664
1694
|
return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1665
1695
|
}
|
|
1666
|
-
function
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1696
|
+
function ee() {
|
|
1697
|
+
R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
|
|
1698
|
+
R = requestAnimationFrame(() => {
|
|
1699
|
+
R = null, w.value = /* @__PURE__ */ new Set();
|
|
1670
1700
|
});
|
|
1671
1701
|
});
|
|
1672
1702
|
}
|
|
1673
|
-
function
|
|
1703
|
+
function H(e, t, n) {
|
|
1674
1704
|
let r = P(e, t);
|
|
1675
|
-
|
|
1705
|
+
A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
|
|
1676
1706
|
}
|
|
1677
|
-
function
|
|
1707
|
+
function U(e, t, n) {
|
|
1678
1708
|
let r = P(e, t);
|
|
1679
|
-
|
|
1709
|
+
j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
|
|
1680
1710
|
}
|
|
1681
|
-
function
|
|
1682
|
-
|
|
1711
|
+
function W(e, t) {
|
|
1712
|
+
H(e, t, "error");
|
|
1683
1713
|
}
|
|
1684
1714
|
function ne(e, t) {
|
|
1685
|
-
|
|
1715
|
+
H(e, t, "ready");
|
|
1686
1716
|
}
|
|
1687
|
-
function
|
|
1688
|
-
|
|
1717
|
+
function re(e, t) {
|
|
1718
|
+
U(e, t, "error");
|
|
1689
1719
|
}
|
|
1690
|
-
function
|
|
1691
|
-
|
|
1720
|
+
function ie(e, t) {
|
|
1721
|
+
U(e, t, "ready");
|
|
1692
1722
|
}
|
|
1693
|
-
function
|
|
1723
|
+
function G(e, t) {
|
|
1694
1724
|
if (u.state.reelMediaSource === "original") {
|
|
1695
|
-
|
|
1725
|
+
re(e, t);
|
|
1696
1726
|
return;
|
|
1697
1727
|
}
|
|
1698
|
-
|
|
1728
|
+
W(e, t);
|
|
1699
1729
|
}
|
|
1700
|
-
function
|
|
1730
|
+
function K(e, t) {
|
|
1701
1731
|
if (u.state.reelMediaSource === "original") {
|
|
1702
|
-
|
|
1732
|
+
ie(e, t);
|
|
1703
1733
|
return;
|
|
1704
1734
|
}
|
|
1705
1735
|
ne(e, t);
|
|
1706
1736
|
}
|
|
1707
|
-
function
|
|
1737
|
+
function q(e, t) {
|
|
1708
1738
|
let n = u.state.items.find((t) => t.postId === e);
|
|
1709
1739
|
if (!n) return;
|
|
1710
1740
|
let r = M(n, t);
|
|
1711
|
-
(
|
|
1741
|
+
(u.state.mediaIndices.get(e) ?? 0) !== r && (u.state.mediaIndices = new Map(u.state.mediaIndices).set(e, r));
|
|
1712
1742
|
}
|
|
1713
|
-
async function
|
|
1743
|
+
async function J() {
|
|
1714
1744
|
await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
|
|
1715
1745
|
}
|
|
1716
|
-
function
|
|
1746
|
+
function ae(e) {
|
|
1717
1747
|
return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
|
|
1718
1748
|
}
|
|
1719
|
-
function
|
|
1749
|
+
function oe(e) {
|
|
1720
1750
|
return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
|
|
1721
1751
|
}
|
|
1722
|
-
function
|
|
1752
|
+
function Y() {
|
|
1723
1753
|
return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
|
|
1724
1754
|
}
|
|
1725
|
-
function
|
|
1726
|
-
|
|
1755
|
+
function X(e, t) {
|
|
1756
|
+
z = e, B = t === "keyboard", x.value = le(e), d("openReel", e), p(() => h.value?.focus());
|
|
1727
1757
|
}
|
|
1728
|
-
function
|
|
1758
|
+
function Z(e) {
|
|
1729
1759
|
let t = b.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
|
|
1730
1760
|
return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
|
|
1731
1761
|
}
|
|
1732
|
-
function
|
|
1733
|
-
if (u.state.layout !== "masonry" || u.state.reelOrigin !== null ||
|
|
1734
|
-
let t = [...new Set(e)], n = t.filter(
|
|
1762
|
+
function se(e) {
|
|
1763
|
+
if (u.state.layout !== "masonry" || u.state.reelOrigin !== null || V()) return 0;
|
|
1764
|
+
let t = [...new Set(e)], n = t.filter(Z);
|
|
1735
1765
|
if (n.length === 0) return 0;
|
|
1736
1766
|
let r = new Map(k.value);
|
|
1737
1767
|
return n.forEach((e, t) => {
|
|
1738
|
-
r.set(e, t *
|
|
1739
|
-
}), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r,
|
|
1768
|
+
r.set(e, t * vt);
|
|
1769
|
+
}), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, yt + (n.length - 1) * vt;
|
|
1740
1770
|
}
|
|
1741
|
-
function
|
|
1742
|
-
let n =
|
|
1771
|
+
function ce(e, t) {
|
|
1772
|
+
let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
|
|
1743
1773
|
r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
|
|
1744
1774
|
r.classList.remove("media-card-focus-silent");
|
|
1745
1775
|
}, { once: !0 }), r?.focus({ preventScroll: !0 }));
|
|
1746
1776
|
}
|
|
1747
|
-
function
|
|
1748
|
-
let t = b.value, n =
|
|
1777
|
+
function le(e) {
|
|
1778
|
+
let t = b.value, n = Z(e);
|
|
1749
1779
|
if (t === null || n === null) return {};
|
|
1750
1780
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
1751
1781
|
return {
|
|
@@ -1755,19 +1785,19 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1755
1785
|
"--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
|
|
1756
1786
|
};
|
|
1757
1787
|
}
|
|
1758
|
-
function
|
|
1759
|
-
u.state.reelOrigin === "masonry" && (
|
|
1788
|
+
function ue() {
|
|
1789
|
+
u.state.reelOrigin === "masonry" && (z ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
|
|
1760
1790
|
}
|
|
1761
|
-
function
|
|
1762
|
-
let e =
|
|
1763
|
-
S.value = !1,
|
|
1764
|
-
e !== null &&
|
|
1791
|
+
function de() {
|
|
1792
|
+
let e = z, t = B;
|
|
1793
|
+
S.value = !1, z = null, B = !1, x.value = {}, p(() => {
|
|
1794
|
+
e !== null && ce(e, t);
|
|
1765
1795
|
});
|
|
1766
1796
|
}
|
|
1767
|
-
function
|
|
1797
|
+
function fe(e) {
|
|
1768
1798
|
let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
|
|
1769
1799
|
if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
|
|
1770
|
-
e.preventDefault(),
|
|
1800
|
+
e.preventDefault(), u.state.reelInfoSheetOverlay && u.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), ue();
|
|
1771
1801
|
return;
|
|
1772
1802
|
}
|
|
1773
1803
|
if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
|
|
@@ -1785,42 +1815,29 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1785
1815
|
r !== 0 && m.value?.changeActiveMedia?.(r) && e.preventDefault();
|
|
1786
1816
|
}
|
|
1787
1817
|
return D(() => u.state.items.map((e) => e.postId), (e) => {
|
|
1788
|
-
let t = e.filter((e) => !
|
|
1789
|
-
if (
|
|
1818
|
+
let t = e.filter((e) => !L.has(e)), n = new Set(e);
|
|
1819
|
+
if (L = new Set(e), E.value = new Set([...E.value].filter((e) => n.has(e))), k.value = new Map([...k.value].filter(([e]) => n.has(e))), t.length === 0 || V()) return;
|
|
1790
1820
|
let r = /* @__PURE__ */ new Map();
|
|
1791
1821
|
e.forEach((e) => {
|
|
1792
1822
|
let t = T.value.get(e);
|
|
1793
1823
|
t !== void 0 && r.set(e, t);
|
|
1794
1824
|
}), t.forEach((e, t) => {
|
|
1795
|
-
r.set(e, t *
|
|
1796
|
-
}), T.value = r, w.value = new Set([...w.value, ...t]),
|
|
1797
|
-
}, { flush: "sync" }), v(() => window.addEventListener("keydown",
|
|
1798
|
-
window.removeEventListener("keydown",
|
|
1825
|
+
r.set(e, t * vt);
|
|
1826
|
+
}), T.value = r, w.value = new Set([...w.value, ...t]), ee();
|
|
1827
|
+
}, { flush: "sync" }), v(() => window.addEventListener("keydown", fe)), _(() => {
|
|
1828
|
+
window.removeEventListener("keydown", fe), R !== null && cancelAnimationFrame(R);
|
|
1799
1829
|
}), s({
|
|
1800
|
-
changeActiveReelMedia:
|
|
1801
|
-
getAutoScrollElement:
|
|
1802
|
-
loadIfNearBottom:
|
|
1803
|
-
moveActiveReelPost:
|
|
1804
|
-
startItemRemoval:
|
|
1830
|
+
changeActiveReelMedia: ae,
|
|
1831
|
+
getAutoScrollElement: Y,
|
|
1832
|
+
loadIfNearBottom: J,
|
|
1833
|
+
moveActiveReelPost: oe,
|
|
1834
|
+
startItemRemoval: se
|
|
1805
1835
|
}), (n, s) => (y(), o("div", {
|
|
1806
1836
|
ref_key: "surfaceElement",
|
|
1807
1837
|
ref: b,
|
|
1808
1838
|
class: "vibe-surface"
|
|
1809
|
-
}, [r.state.
|
|
1839
|
+
}, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(_t, {
|
|
1810
1840
|
key: 0,
|
|
1811
|
-
actions: r.feedFooterActions,
|
|
1812
|
-
"can-retry-end": r.canRetryEnd,
|
|
1813
|
-
"feed-footer": r.feedFooter,
|
|
1814
|
-
state: I.value,
|
|
1815
|
-
onLoadMore: s[0] ||= (e) => d("loadMore"),
|
|
1816
|
-
onRetryEnd: s[1] ||= (e) => d("retryEnd")
|
|
1817
|
-
}, null, 8, [
|
|
1818
|
-
"actions",
|
|
1819
|
-
"can-retry-end",
|
|
1820
|
-
"feed-footer",
|
|
1821
|
-
"state"
|
|
1822
|
-
])) : r.state.layout === "reel" ? (y(), i(gt, {
|
|
1823
|
-
key: 1,
|
|
1824
1841
|
ref_key: "reelRenderer",
|
|
1825
1842
|
ref: m,
|
|
1826
1843
|
"can-retry-end": r.canRetryEnd,
|
|
@@ -1829,30 +1846,34 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1829
1846
|
"card-header": r.cardHeader,
|
|
1830
1847
|
"feed-footer": r.feedFooter,
|
|
1831
1848
|
"feed-footer-actions": r.feedFooterActions,
|
|
1849
|
+
"forward-index": r.state.reelForwardIndex,
|
|
1850
|
+
"forward-item": r.state.reelForwardItem,
|
|
1832
1851
|
"media-card": r.mediaCard,
|
|
1833
1852
|
"infinite-scroll": r.state.infiniteScroll,
|
|
1834
1853
|
"is-loading-more": r.state.isLoadingMore,
|
|
1835
1854
|
items: r.state.items,
|
|
1836
1855
|
"load-more-locked": r.state.loadMoreLocked,
|
|
1837
1856
|
"media-source": r.state.reelMediaSource,
|
|
1838
|
-
"media-indices":
|
|
1857
|
+
"media-indices": r.state.mediaIndices,
|
|
1839
1858
|
"initial-post-id": r.state.activeReelPostId,
|
|
1840
1859
|
"info-sheet": r.reelInfoSheet,
|
|
1841
1860
|
"info-sheet-enabled": r.state.reelInfoSheet.enabled,
|
|
1842
1861
|
"info-sheet-overlay": r.state.reelInfoSheetOverlay,
|
|
1843
1862
|
"next-page-error": !!r.state.nextPageError,
|
|
1844
1863
|
origin: "reel",
|
|
1845
|
-
"preview-states":
|
|
1864
|
+
"preview-states": I.value,
|
|
1846
1865
|
"reel-auto-advance": r.state.reelAutoAdvance,
|
|
1847
|
-
|
|
1866
|
+
"reel-forward": r.state.reelForward,
|
|
1867
|
+
state: N.value,
|
|
1848
1868
|
total: r.state.total,
|
|
1849
|
-
onActiveChange: s[
|
|
1850
|
-
onCloseInfoSheet: s[
|
|
1851
|
-
onError:
|
|
1852
|
-
onLoadMore: s[
|
|
1853
|
-
onMediaChange:
|
|
1854
|
-
onReady:
|
|
1855
|
-
onRetryEnd: s[
|
|
1869
|
+
onActiveChange: s[0] ||= (e) => d("activeReelChange", e),
|
|
1870
|
+
onCloseInfoSheet: s[1] ||= (e) => d("reelInfoSheetChange", !1),
|
|
1871
|
+
onError: G,
|
|
1872
|
+
onLoadMore: s[2] ||= (e) => d("loadMore"),
|
|
1873
|
+
onMediaChange: q,
|
|
1874
|
+
onReady: K,
|
|
1875
|
+
onRetryEnd: s[3] ||= (e) => d("retryEnd"),
|
|
1876
|
+
onRetryForward: s[4] ||= (e) => d("retryForward")
|
|
1856
1877
|
}, null, 8, [
|
|
1857
1878
|
"can-retry-end",
|
|
1858
1879
|
"has-next",
|
|
@@ -1860,6 +1881,8 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1860
1881
|
"card-header",
|
|
1861
1882
|
"feed-footer",
|
|
1862
1883
|
"feed-footer-actions",
|
|
1884
|
+
"forward-index",
|
|
1885
|
+
"forward-item",
|
|
1863
1886
|
"media-card",
|
|
1864
1887
|
"infinite-scroll",
|
|
1865
1888
|
"is-loading-more",
|
|
@@ -1874,8 +1897,22 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1874
1897
|
"next-page-error",
|
|
1875
1898
|
"preview-states",
|
|
1876
1899
|
"reel-auto-advance",
|
|
1900
|
+
"reel-forward",
|
|
1877
1901
|
"state",
|
|
1878
1902
|
"total"
|
|
1903
|
+
])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(te, {
|
|
1904
|
+
key: 1,
|
|
1905
|
+
actions: r.feedFooterActions,
|
|
1906
|
+
"can-retry-end": r.canRetryEnd,
|
|
1907
|
+
"feed-footer": r.feedFooter,
|
|
1908
|
+
state: N.value,
|
|
1909
|
+
onLoadMore: s[5] ||= (e) => d("loadMore"),
|
|
1910
|
+
onRetryEnd: s[6] ||= (e) => d("retryEnd")
|
|
1911
|
+
}, null, 8, [
|
|
1912
|
+
"actions",
|
|
1913
|
+
"can-retry-end",
|
|
1914
|
+
"feed-footer",
|
|
1915
|
+
"state"
|
|
1879
1916
|
])) : (y(), o(e, { key: 2 }, [l(ot, {
|
|
1880
1917
|
ref_key: "masonryRenderer",
|
|
1881
1918
|
ref: f,
|
|
@@ -1894,18 +1931,18 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1894
1931
|
"is-loading-more": r.state.isLoadingMore,
|
|
1895
1932
|
items: r.state.items,
|
|
1896
1933
|
"load-more-locked": r.state.loadMoreLocked,
|
|
1897
|
-
"media-indices":
|
|
1934
|
+
"media-indices": r.state.mediaIndices,
|
|
1898
1935
|
"next-page-error": !!r.state.nextPageError,
|
|
1899
|
-
"preview-states":
|
|
1936
|
+
"preview-states": A.value,
|
|
1900
1937
|
suspended: r.state.reelOrigin === "masonry" || S.value,
|
|
1901
|
-
state:
|
|
1938
|
+
state: N.value,
|
|
1902
1939
|
total: r.state.total,
|
|
1903
|
-
onActivate:
|
|
1904
|
-
onError:
|
|
1905
|
-
onLoadMore: s[
|
|
1906
|
-
onMediaChange:
|
|
1940
|
+
onActivate: X,
|
|
1941
|
+
onError: W,
|
|
1942
|
+
onLoadMore: s[7] ||= (e) => d("loadMore"),
|
|
1943
|
+
onMediaChange: q,
|
|
1907
1944
|
onReady: ne,
|
|
1908
|
-
onRetryEnd: s[
|
|
1945
|
+
onRetryEnd: s[8] ||= (e) => d("retryEnd")
|
|
1909
1946
|
}, null, 8, [
|
|
1910
1947
|
"can-retry-end",
|
|
1911
1948
|
"entering-post-ids",
|
|
@@ -1930,7 +1967,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1930
1967
|
"total"
|
|
1931
1968
|
]), l(t, {
|
|
1932
1969
|
name: "vibe-reel-viewer",
|
|
1933
|
-
onAfterLeave:
|
|
1970
|
+
onAfterLeave: de
|
|
1934
1971
|
}, {
|
|
1935
1972
|
default: O(() => [r.state.reelOrigin === "masonry" ? (y(), o("section", {
|
|
1936
1973
|
key: 0,
|
|
@@ -1942,7 +1979,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1942
1979
|
"aria-modal": "true",
|
|
1943
1980
|
tabindex: "-1",
|
|
1944
1981
|
style: g(x.value)
|
|
1945
|
-
}, [l(
|
|
1982
|
+
}, [l(_t, {
|
|
1946
1983
|
ref_key: "reelRenderer",
|
|
1947
1984
|
ref: m,
|
|
1948
1985
|
"can-retry-end": r.canRetryEnd,
|
|
@@ -1950,6 +1987,8 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1950
1987
|
"card-header": r.cardHeader,
|
|
1951
1988
|
"feed-footer": r.feedFooter,
|
|
1952
1989
|
"feed-footer-actions": r.feedFooterActions,
|
|
1990
|
+
"forward-index": r.state.reelForwardIndex,
|
|
1991
|
+
"forward-item": r.state.reelForwardItem,
|
|
1953
1992
|
"media-card": r.mediaCard,
|
|
1954
1993
|
"has-next": r.state.next !== null,
|
|
1955
1994
|
"infinite-scroll": r.state.infiniteScroll,
|
|
@@ -1960,27 +1999,31 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1960
1999
|
"is-loading-more": r.state.isLoadingMore,
|
|
1961
2000
|
items: r.state.items,
|
|
1962
2001
|
"load-more-locked": r.state.loadMoreLocked,
|
|
1963
|
-
"media-indices":
|
|
2002
|
+
"media-indices": r.state.mediaIndices,
|
|
1964
2003
|
"media-source": "original",
|
|
1965
2004
|
"next-page-error": !!r.state.nextPageError,
|
|
1966
2005
|
origin: "masonry",
|
|
1967
|
-
"preview-states":
|
|
2006
|
+
"preview-states": j.value,
|
|
1968
2007
|
"reel-auto-advance": r.state.reelAutoAdvance,
|
|
1969
|
-
|
|
2008
|
+
"reel-forward": r.state.reelForward,
|
|
2009
|
+
state: N.value,
|
|
1970
2010
|
total: r.state.total,
|
|
1971
|
-
onActiveChange: s[
|
|
1972
|
-
onCloseInfoSheet: s[
|
|
1973
|
-
onError:
|
|
1974
|
-
onLoadMore: s[
|
|
1975
|
-
onMediaChange:
|
|
1976
|
-
onReady:
|
|
1977
|
-
onRetryEnd: s[
|
|
2011
|
+
onActiveChange: s[9] ||= (e) => d("activeReelChange", e),
|
|
2012
|
+
onCloseInfoSheet: s[10] ||= (e) => d("reelInfoSheetChange", !1),
|
|
2013
|
+
onError: re,
|
|
2014
|
+
onLoadMore: s[11] ||= (e) => d("loadMore"),
|
|
2015
|
+
onMediaChange: q,
|
|
2016
|
+
onReady: ie,
|
|
2017
|
+
onRetryEnd: s[12] ||= (e) => d("retryEnd"),
|
|
2018
|
+
onRetryForward: s[13] ||= (e) => d("retryForward")
|
|
1978
2019
|
}, null, 8, [
|
|
1979
2020
|
"can-retry-end",
|
|
1980
2021
|
"card-footer",
|
|
1981
2022
|
"card-header",
|
|
1982
2023
|
"feed-footer",
|
|
1983
2024
|
"feed-footer-actions",
|
|
2025
|
+
"forward-index",
|
|
2026
|
+
"forward-item",
|
|
1984
2027
|
"media-card",
|
|
1985
2028
|
"has-next",
|
|
1986
2029
|
"infinite-scroll",
|
|
@@ -1995,6 +2038,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
1995
2038
|
"next-page-error",
|
|
1996
2039
|
"preview-states",
|
|
1997
2040
|
"reel-auto-advance",
|
|
2041
|
+
"reel-forward",
|
|
1998
2042
|
"state",
|
|
1999
2043
|
"total"
|
|
2000
2044
|
])], 4)) : a("", !0)]),
|
|
@@ -2004,7 +2048,7 @@ var Oe = /* @__PURE__ */ u({
|
|
|
2004
2048
|
});
|
|
2005
2049
|
//#endregion
|
|
2006
2050
|
//#region src/core/page.ts
|
|
2007
|
-
function
|
|
2051
|
+
function xt(e) {
|
|
2008
2052
|
if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
|
|
2009
2053
|
if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
|
|
2010
2054
|
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.");
|
|
@@ -2016,32 +2060,32 @@ function Q(e, t) {
|
|
|
2016
2060
|
}
|
|
2017
2061
|
//#endregion
|
|
2018
2062
|
//#region src/core/requestDelay.ts
|
|
2019
|
-
var
|
|
2063
|
+
var St = 2e3, Ct = 1e4, wt = 250, Tt = {
|
|
2020
2064
|
delayRemainingMs: null,
|
|
2021
2065
|
nextRequestAt: null
|
|
2022
2066
|
};
|
|
2023
|
-
function
|
|
2067
|
+
function Et(e, t) {
|
|
2024
2068
|
return e === void 0 ? t : Math.floor(e);
|
|
2025
2069
|
}
|
|
2026
|
-
function
|
|
2070
|
+
function Dt(e, t) {
|
|
2027
2071
|
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.`);
|
|
2028
2072
|
}
|
|
2029
|
-
function
|
|
2030
|
-
let n =
|
|
2073
|
+
function Ot(e, t = {}) {
|
|
2074
|
+
let n = Et(t.delayStepMs, St), r = Et(t.delayMaxMs, Ct);
|
|
2031
2075
|
return Math.min(Math.max(0, e) * n, r);
|
|
2032
2076
|
}
|
|
2033
2077
|
function $(e) {
|
|
2034
|
-
if (e == null || !Number.isFinite(e)) return { ...
|
|
2078
|
+
if (e == null || !Number.isFinite(e)) return { ...Tt };
|
|
2035
2079
|
let t = Math.max(0, Math.floor(e - Date.now()));
|
|
2036
2080
|
return t > 0 ? {
|
|
2037
2081
|
delayRemainingMs: t,
|
|
2038
2082
|
nextRequestAt: e
|
|
2039
|
-
} : { ...
|
|
2083
|
+
} : { ...Tt };
|
|
2040
2084
|
}
|
|
2041
|
-
async function
|
|
2085
|
+
async function kt({ delayMs: e, onChange: t, signal: n }) {
|
|
2042
2086
|
if (n.aborted) throw new DOMException("Aborted", "AbortError");
|
|
2043
2087
|
if (e <= 0) {
|
|
2044
|
-
t({ ...
|
|
2088
|
+
t({ ...Tt });
|
|
2045
2089
|
return;
|
|
2046
2090
|
}
|
|
2047
2091
|
let r = Date.now() + e;
|
|
@@ -2049,9 +2093,9 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2049
2093
|
delayRemainingMs: e,
|
|
2050
2094
|
nextRequestAt: r
|
|
2051
2095
|
}), await new Promise((i, a) => {
|
|
2052
|
-
let o = !1, s = setInterval(f,
|
|
2096
|
+
let o = !1, s = setInterval(f, wt), c = setTimeout(() => u(), e);
|
|
2053
2097
|
function l() {
|
|
2054
|
-
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...
|
|
2098
|
+
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Tt });
|
|
2055
2099
|
}
|
|
2056
2100
|
function u(e) {
|
|
2057
2101
|
o || (o = !0, l(), e ? a(e) : i());
|
|
@@ -2066,13 +2110,13 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2066
2110
|
n.addEventListener("abort", d, { once: !0 });
|
|
2067
2111
|
});
|
|
2068
2112
|
}
|
|
2069
|
-
var
|
|
2113
|
+
var At = class {
|
|
2070
2114
|
interval = null;
|
|
2071
2115
|
constructor(e) {
|
|
2072
2116
|
this.onChange = e;
|
|
2073
2117
|
}
|
|
2074
2118
|
clear() {
|
|
2075
|
-
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...
|
|
2119
|
+
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Tt });
|
|
2076
2120
|
}
|
|
2077
2121
|
sync(e) {
|
|
2078
2122
|
this.clear();
|
|
@@ -2080,22 +2124,22 @@ var kt = class {
|
|
|
2080
2124
|
this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
|
|
2081
2125
|
let t = $(e);
|
|
2082
2126
|
this.onChange(t), t.delayRemainingMs === null && this.clear();
|
|
2083
|
-
},
|
|
2127
|
+
}, wt));
|
|
2084
2128
|
}
|
|
2085
2129
|
};
|
|
2086
|
-
function
|
|
2130
|
+
function jt(e, t = !0) {
|
|
2087
2131
|
return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
|
|
2088
2132
|
}
|
|
2089
|
-
function
|
|
2133
|
+
function Mt(e) {
|
|
2090
2134
|
return `${typeof e}:${String(e)}`;
|
|
2091
2135
|
}
|
|
2092
|
-
function
|
|
2136
|
+
function Nt(e, t) {
|
|
2093
2137
|
if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
|
|
2094
2138
|
}
|
|
2095
|
-
function
|
|
2139
|
+
function Pt(e) {
|
|
2096
2140
|
if (!e) return;
|
|
2097
|
-
if (
|
|
2098
|
-
|
|
2141
|
+
if (Nt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
|
|
2142
|
+
Dt(e, "frontend autofill");
|
|
2099
2143
|
let t = e.maxAdditionalPages;
|
|
2100
2144
|
if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
|
|
2101
2145
|
return;
|
|
@@ -2107,7 +2151,7 @@ function Nt(e) {
|
|
|
2107
2151
|
if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
|
|
2108
2152
|
}
|
|
2109
2153
|
}
|
|
2110
|
-
function
|
|
2154
|
+
function Ft(e, t, n = !0) {
|
|
2111
2155
|
if (!e) return {
|
|
2112
2156
|
cycleId: null,
|
|
2113
2157
|
delayRemainingMs: null,
|
|
@@ -2141,7 +2185,7 @@ function Pt(e, t, n = !0) {
|
|
|
2141
2185
|
strategy: e.strategy
|
|
2142
2186
|
};
|
|
2143
2187
|
}
|
|
2144
|
-
function
|
|
2188
|
+
function It(e) {
|
|
2145
2189
|
return [
|
|
2146
2190
|
"cancelling",
|
|
2147
2191
|
"filling",
|
|
@@ -2149,9 +2193,9 @@ function Ft(e) {
|
|
|
2149
2193
|
"waiting"
|
|
2150
2194
|
].includes(e.status);
|
|
2151
2195
|
}
|
|
2152
|
-
async function
|
|
2196
|
+
async function Lt(e, t, n) {
|
|
2153
2197
|
let r = t.autofill;
|
|
2154
|
-
if (!
|
|
2198
|
+
if (!It(r) || !r.cycleId) return;
|
|
2155
2199
|
let i = {
|
|
2156
2200
|
cycleId: r.cycleId,
|
|
2157
2201
|
feedKey: r.feedKey ?? "",
|
|
@@ -2164,20 +2208,20 @@ async function It(e, t, n) {
|
|
|
2164
2208
|
throw r.error = e, r.status = "error", e;
|
|
2165
2209
|
}
|
|
2166
2210
|
}
|
|
2167
|
-
function
|
|
2211
|
+
function Rt(e, t, n) {
|
|
2168
2212
|
return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
|
|
2169
2213
|
}
|
|
2170
|
-
async function
|
|
2171
|
-
let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ??
|
|
2214
|
+
async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
|
|
2215
|
+
let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? jt(o), m = t, h = t, g = 0, _;
|
|
2172
2216
|
for (; g < p;) {
|
|
2173
|
-
let e =
|
|
2217
|
+
let e = Mt(m);
|
|
2174
2218
|
if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
|
|
2175
|
-
f.add(e), await
|
|
2176
|
-
delayMs:
|
|
2219
|
+
f.add(e), await kt({
|
|
2220
|
+
delayMs: Ot(c + g, o),
|
|
2177
2221
|
onChange: i,
|
|
2178
2222
|
signal: l
|
|
2179
2223
|
});
|
|
2180
|
-
let t =
|
|
2224
|
+
let t = xt(await n({
|
|
2181
2225
|
cursor: m,
|
|
2182
2226
|
signal: l
|
|
2183
2227
|
}));
|
|
@@ -2217,30 +2261,30 @@ async function Rt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2217
2261
|
total: _
|
|
2218
2262
|
};
|
|
2219
2263
|
}
|
|
2220
|
-
var
|
|
2221
|
-
function
|
|
2264
|
+
var Bt = 100;
|
|
2265
|
+
function Vt(e, t) {
|
|
2222
2266
|
if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
|
|
2223
2267
|
}
|
|
2224
|
-
function
|
|
2268
|
+
function Ht(e, t, n) {
|
|
2225
2269
|
return Math.min(n, Math.max(t, e));
|
|
2226
2270
|
}
|
|
2227
|
-
function
|
|
2271
|
+
function Ut(e) {
|
|
2228
2272
|
if (!e) return;
|
|
2229
2273
|
let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
|
|
2230
|
-
if (
|
|
2231
|
-
e.speedPxPerSecond !== void 0 &&
|
|
2274
|
+
if (Vt("autoScroll.minSpeedPxPerSecond", t), Vt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
|
|
2275
|
+
e.speedPxPerSecond !== void 0 && Vt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
|
|
2232
2276
|
}
|
|
2233
|
-
function
|
|
2277
|
+
function Wt(e) {
|
|
2234
2278
|
let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
|
|
2235
2279
|
return {
|
|
2236
2280
|
enabled: e?.enabled ?? !1,
|
|
2237
2281
|
maxSpeedPxPerSecond: n,
|
|
2238
2282
|
minSpeedPxPerSecond: t,
|
|
2239
2283
|
paused: !1,
|
|
2240
|
-
speedPxPerSecond:
|
|
2284
|
+
speedPxPerSecond: Ht(e?.speedPxPerSecond ?? 80, t, n)
|
|
2241
2285
|
};
|
|
2242
2286
|
}
|
|
2243
|
-
var
|
|
2287
|
+
var Gt = class {
|
|
2244
2288
|
frame = null;
|
|
2245
2289
|
lastTimestamp = null;
|
|
2246
2290
|
mounted = !1;
|
|
@@ -2260,9 +2304,9 @@ var Wt = class {
|
|
|
2260
2304
|
this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
|
|
2261
2305
|
}
|
|
2262
2306
|
setSpeed(e) {
|
|
2263
|
-
|
|
2307
|
+
Vt("auto-scroll speed", e);
|
|
2264
2308
|
let t = this.options.state;
|
|
2265
|
-
t.speedPxPerSecond =
|
|
2309
|
+
t.speedPxPerSecond = Ht(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
|
|
2266
2310
|
}
|
|
2267
2311
|
tick = (e) => {
|
|
2268
2312
|
this.frame = null;
|
|
@@ -2274,7 +2318,7 @@ var Wt = class {
|
|
|
2274
2318
|
return;
|
|
2275
2319
|
}
|
|
2276
2320
|
if (this.lastTimestamp !== null) {
|
|
2277
|
-
let r = Math.min(
|
|
2321
|
+
let r = Math.min(Bt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
|
|
2278
2322
|
n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
|
|
2279
2323
|
}
|
|
2280
2324
|
this.lastTimestamp = e, this.schedule();
|
|
@@ -2288,7 +2332,7 @@ var Wt = class {
|
|
|
2288
2332
|
};
|
|
2289
2333
|
//#endregion
|
|
2290
2334
|
//#region src/core/backendAutofill.ts
|
|
2291
|
-
async function
|
|
2335
|
+
async function Kt(e, t, n, r) {
|
|
2292
2336
|
let i = await e.onUnderfilled(n);
|
|
2293
2337
|
if (!r()) return;
|
|
2294
2338
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
|
|
@@ -2302,19 +2346,19 @@ async function Gt(e, t, n, r) {
|
|
|
2302
2346
|
status: "waiting"
|
|
2303
2347
|
});
|
|
2304
2348
|
}
|
|
2305
|
-
function
|
|
2349
|
+
function qt(e, t) {
|
|
2306
2350
|
["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);
|
|
2307
2351
|
}
|
|
2308
|
-
function
|
|
2352
|
+
function Jt(e, t, n) {
|
|
2309
2353
|
let r = t.autofill;
|
|
2310
|
-
return !
|
|
2354
|
+
return !Rt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (qt(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);
|
|
2311
2355
|
}
|
|
2312
|
-
function
|
|
2313
|
-
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill =
|
|
2356
|
+
function Yt(e, t, n) {
|
|
2357
|
+
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Ft(e, n), qt(t, n), !0);
|
|
2314
2358
|
}
|
|
2315
2359
|
//#endregion
|
|
2316
2360
|
//#region src/core/initialAutofill.ts
|
|
2317
|
-
async function
|
|
2361
|
+
async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
|
|
2318
2362
|
let o = r.autofill;
|
|
2319
2363
|
if (!o) return;
|
|
2320
2364
|
let s = a.items.length;
|
|
@@ -2327,7 +2371,7 @@ async function Yt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2327
2371
|
return;
|
|
2328
2372
|
}
|
|
2329
2373
|
if (o.strategy === "backend") {
|
|
2330
|
-
await
|
|
2374
|
+
await Kt(o, a, {
|
|
2331
2375
|
cycleId: e,
|
|
2332
2376
|
feedKey: o.feedKey,
|
|
2333
2377
|
items: [...a.items],
|
|
@@ -2344,11 +2388,11 @@ async function Yt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2344
2388
|
a.autofill.status = "exhausted";
|
|
2345
2389
|
return;
|
|
2346
2390
|
}
|
|
2347
|
-
let c = await
|
|
2391
|
+
let c = await zt({
|
|
2348
2392
|
existingItems: a.items,
|
|
2349
2393
|
initialCursor: a.next,
|
|
2350
2394
|
loadPage: r.loadPage,
|
|
2351
|
-
maximumRequests:
|
|
2395
|
+
maximumRequests: jt(o, !1),
|
|
2352
2396
|
onDelayChange: (e) => {
|
|
2353
2397
|
t() && Object.assign(a.autofill, e);
|
|
2354
2398
|
},
|
|
@@ -2369,13 +2413,13 @@ async function Yt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
|
|
|
2369
2413
|
}
|
|
2370
2414
|
//#endregion
|
|
2371
2415
|
//#region src/core/fill.ts
|
|
2372
|
-
function
|
|
2416
|
+
function Zt(e) {
|
|
2373
2417
|
return "pages" in e ? { pages: e.pages } : { until: "end" };
|
|
2374
2418
|
}
|
|
2375
|
-
function
|
|
2419
|
+
function Qt(e) {
|
|
2376
2420
|
return `${typeof e}:${String(e)}`;
|
|
2377
2421
|
}
|
|
2378
|
-
function
|
|
2422
|
+
function $t(e) {
|
|
2379
2423
|
if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
|
|
2380
2424
|
if ("pages" in e) {
|
|
2381
2425
|
if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
|
|
@@ -2384,20 +2428,20 @@ function Qt(e) {
|
|
|
2384
2428
|
if ("until" in e && e.until === "end") return { until: "end" };
|
|
2385
2429
|
throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
|
|
2386
2430
|
}
|
|
2387
|
-
function
|
|
2431
|
+
function en(e) {
|
|
2388
2432
|
if (!e) return;
|
|
2389
2433
|
if (e.strategy === "frontend") {
|
|
2390
|
-
|
|
2434
|
+
Dt(e, "frontend fill");
|
|
2391
2435
|
return;
|
|
2392
2436
|
}
|
|
2393
2437
|
if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
|
|
2394
2438
|
let t = e.initialSession;
|
|
2395
2439
|
if (t) {
|
|
2396
2440
|
if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
|
|
2397
|
-
|
|
2441
|
+
$t(t.target);
|
|
2398
2442
|
}
|
|
2399
2443
|
}
|
|
2400
|
-
function
|
|
2444
|
+
function tn(e, t, n = !0) {
|
|
2401
2445
|
let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
|
|
2402
2446
|
return {
|
|
2403
2447
|
completedPages: i?.completedPages ?? 0,
|
|
@@ -2411,10 +2455,10 @@ function en(e, t, n = !0) {
|
|
|
2411
2455
|
sessionId: i?.sessionId ?? null,
|
|
2412
2456
|
status: i?.status ?? "idle",
|
|
2413
2457
|
strategy: e?.strategy ?? null,
|
|
2414
|
-
target: i ?
|
|
2458
|
+
target: i ? Zt(i.target) : null
|
|
2415
2459
|
};
|
|
2416
2460
|
}
|
|
2417
|
-
function
|
|
2461
|
+
function nn(e) {
|
|
2418
2462
|
return [
|
|
2419
2463
|
"cancelling",
|
|
2420
2464
|
"filling",
|
|
@@ -2422,17 +2466,17 @@ function tn(e) {
|
|
|
2422
2466
|
"waiting"
|
|
2423
2467
|
].includes(e.status);
|
|
2424
2468
|
}
|
|
2425
|
-
async function
|
|
2469
|
+
async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
|
|
2426
2470
|
let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
|
|
2427
2471
|
for (; p !== null;) {
|
|
2428
|
-
let e =
|
|
2472
|
+
let e = Qt(f);
|
|
2429
2473
|
if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
|
|
2430
|
-
u.add(e), await
|
|
2431
|
-
delayMs:
|
|
2474
|
+
u.add(e), await kt({
|
|
2475
|
+
delayMs: Ot(d, a),
|
|
2432
2476
|
onChange: r,
|
|
2433
2477
|
signal: o
|
|
2434
2478
|
});
|
|
2435
|
-
let t =
|
|
2479
|
+
let t = xt(await n({
|
|
2436
2480
|
cursor: f,
|
|
2437
2481
|
signal: o
|
|
2438
2482
|
}));
|
|
@@ -2474,7 +2518,7 @@ async function nn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
|
|
|
2474
2518
|
}
|
|
2475
2519
|
//#endregion
|
|
2476
2520
|
//#region src/core/backendFill.ts
|
|
2477
|
-
async function
|
|
2521
|
+
async function an(e, t, n, r) {
|
|
2478
2522
|
let i = await e.onStart(n);
|
|
2479
2523
|
if (r()) {
|
|
2480
2524
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
|
|
@@ -2488,22 +2532,22 @@ async function rn(e, t, n, r) {
|
|
|
2488
2532
|
});
|
|
2489
2533
|
}
|
|
2490
2534
|
}
|
|
2491
|
-
function
|
|
2535
|
+
function on(e, t, n) {
|
|
2492
2536
|
return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
|
|
2493
2537
|
}
|
|
2494
|
-
function
|
|
2538
|
+
function sn(e) {
|
|
2495
2539
|
return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
|
|
2496
2540
|
}
|
|
2497
|
-
function
|
|
2541
|
+
function cn(e, t) {
|
|
2498
2542
|
if (!["complete", "exhausted"].includes(t.status)) return !0;
|
|
2499
2543
|
let n = e.fill.target;
|
|
2500
2544
|
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;
|
|
2501
2545
|
}
|
|
2502
|
-
function
|
|
2546
|
+
function ln(e, t, n) {
|
|
2503
2547
|
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));
|
|
2504
2548
|
}
|
|
2505
|
-
function
|
|
2506
|
-
return !
|
|
2549
|
+
function un(e, t, n, r) {
|
|
2550
|
+
return !on(e, t, n) || !sn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !cn(t, n) ? !1 : (ln(t, n, r), Object.assign(t.fill, {
|
|
2507
2551
|
...$(n.status === "waiting" ? n.nextRequestAt : null),
|
|
2508
2552
|
completedPages: n.completedPages,
|
|
2509
2553
|
error: n.error ?? null,
|
|
@@ -2512,41 +2556,41 @@ function ln(e, t, n, r) {
|
|
|
2512
2556
|
status: n.status
|
|
2513
2557
|
}), !0);
|
|
2514
2558
|
}
|
|
2515
|
-
function
|
|
2559
|
+
function dn(e, t, n, r) {
|
|
2516
2560
|
if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
|
|
2517
2561
|
let i = t.fill;
|
|
2518
|
-
return t.fill =
|
|
2562
|
+
return t.fill = tn(e, n), !sn(n) || !cn(t, n) ? (t.fill = i, !1) : (ln(t, n, r), !0);
|
|
2519
2563
|
}
|
|
2520
2564
|
//#endregion
|
|
2521
2565
|
//#region src/core/fillController.ts
|
|
2522
|
-
var
|
|
2566
|
+
var fn = class {
|
|
2523
2567
|
abortController = null;
|
|
2524
2568
|
cycle = 0;
|
|
2525
2569
|
delayCountdown;
|
|
2526
2570
|
requestVersion = 0;
|
|
2527
2571
|
constructor(e) {
|
|
2528
|
-
this.options = e, this.delayCountdown = new
|
|
2572
|
+
this.options = e, this.delayCountdown = new At((e) => {
|
|
2529
2573
|
Object.assign(this.options.state.fill, e);
|
|
2530
2574
|
}), this.syncBackendCountdown();
|
|
2531
2575
|
}
|
|
2532
2576
|
isActive() {
|
|
2533
|
-
return
|
|
2577
|
+
return nn(this.options.state.fill);
|
|
2534
2578
|
}
|
|
2535
2579
|
applyUpdate(e) {
|
|
2536
|
-
let t =
|
|
2580
|
+
let t = un(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2537
2581
|
return t && this.syncBackendCountdown(), t;
|
|
2538
2582
|
}
|
|
2539
2583
|
restoreSession(e) {
|
|
2540
|
-
let t =
|
|
2584
|
+
let t = dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2541
2585
|
return t && this.syncBackendCountdown(), t;
|
|
2542
2586
|
}
|
|
2543
2587
|
async start(e) {
|
|
2544
2588
|
let t = this.options.fill;
|
|
2545
2589
|
if (!t) throw Error("Vibe fill is not configured.");
|
|
2546
2590
|
if (this.isActive()) throw Error("Vibe fill is already active.");
|
|
2547
|
-
let n =
|
|
2591
|
+
let n = $t(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
2548
2592
|
if (this.options.state.fill = {
|
|
2549
|
-
...
|
|
2593
|
+
...tn(t, void 0, !1),
|
|
2550
2594
|
cycleId: r,
|
|
2551
2595
|
status: "filling",
|
|
2552
2596
|
target: n
|
|
@@ -2557,7 +2601,7 @@ var dn = class {
|
|
|
2557
2601
|
let i = ++this.requestVersion, a = new AbortController();
|
|
2558
2602
|
this.abortController = a;
|
|
2559
2603
|
try {
|
|
2560
|
-
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await
|
|
2604
|
+
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await an(t, this.options.state, {
|
|
2561
2605
|
cycleId: r,
|
|
2562
2606
|
feedKey: t.feedKey,
|
|
2563
2607
|
items: [...this.options.state.items],
|
|
@@ -2575,7 +2619,7 @@ var dn = class {
|
|
|
2575
2619
|
}
|
|
2576
2620
|
async cancel() {
|
|
2577
2621
|
let { fill: e, state: t } = this.options;
|
|
2578
|
-
if (!
|
|
2622
|
+
if (!nn(t.fill) || !t.fill.cycleId) return;
|
|
2579
2623
|
let n = {
|
|
2580
2624
|
cycleId: t.fill.cycleId,
|
|
2581
2625
|
feedKey: t.fill.feedKey ?? "",
|
|
@@ -2589,7 +2633,7 @@ var dn = class {
|
|
|
2589
2633
|
}
|
|
2590
2634
|
}
|
|
2591
2635
|
reset() {
|
|
2592
|
-
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill =
|
|
2636
|
+
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = tn(this.options.fill, void 0, !1);
|
|
2593
2637
|
}
|
|
2594
2638
|
destroy() {
|
|
2595
2639
|
this.abortLocalRequest(), this.delayCountdown.clear();
|
|
@@ -2605,7 +2649,7 @@ var dn = class {
|
|
|
2605
2649
|
if (!i) throw Error("Vibe frontend fill requires loadPage.");
|
|
2606
2650
|
let a = this.options.state;
|
|
2607
2651
|
a.isLoadingMore = !0;
|
|
2608
|
-
let o = await
|
|
2652
|
+
let o = await rn({
|
|
2609
2653
|
existingItems: a.items,
|
|
2610
2654
|
initialCursor: a.next,
|
|
2611
2655
|
loadPage: i,
|
|
@@ -2632,7 +2676,7 @@ var dn = class {
|
|
|
2632
2676
|
};
|
|
2633
2677
|
//#endregion
|
|
2634
2678
|
//#region src/core/feedFooter.ts
|
|
2635
|
-
function
|
|
2679
|
+
function pn(e) {
|
|
2636
2680
|
return {
|
|
2637
2681
|
cancelAutofill: () => e.cancelAutofill(),
|
|
2638
2682
|
loadMore: () => e.loadNext(),
|
|
@@ -2640,55 +2684,62 @@ function fn(e) {
|
|
|
2640
2684
|
retryEnd: () => e.retryEnd()
|
|
2641
2685
|
};
|
|
2642
2686
|
}
|
|
2643
|
-
function pn(e) {
|
|
2644
|
-
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
2645
|
-
}
|
|
2646
2687
|
function mn(e) {
|
|
2647
|
-
e
|
|
2688
|
+
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
2648
2689
|
}
|
|
2649
2690
|
function hn(e) {
|
|
2691
|
+
e?.intervalMs !== void 0 && mn(e.intervalMs);
|
|
2692
|
+
}
|
|
2693
|
+
function gn(e) {
|
|
2650
2694
|
return {
|
|
2651
2695
|
enabled: e?.enabled ?? !1,
|
|
2652
2696
|
includePostItems: e?.includePostItems ?? !1,
|
|
2653
2697
|
intervalMs: e?.intervalMs ?? 5e3
|
|
2654
2698
|
};
|
|
2655
2699
|
}
|
|
2656
|
-
function
|
|
2700
|
+
function _n(e, t) {
|
|
2657
2701
|
if (typeof t == "boolean") {
|
|
2658
2702
|
e.enabled = t;
|
|
2659
2703
|
return;
|
|
2660
2704
|
}
|
|
2661
|
-
|
|
2705
|
+
hn(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);
|
|
2662
2706
|
}
|
|
2663
2707
|
//#endregion
|
|
2664
2708
|
//#region src/core/reelInfoSheet.ts
|
|
2665
|
-
function
|
|
2709
|
+
function vn(e) {
|
|
2666
2710
|
return { enabled: e?.enabled ?? !1 };
|
|
2667
2711
|
}
|
|
2668
|
-
function
|
|
2712
|
+
function yn(e, t, n) {
|
|
2669
2713
|
if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
|
|
2670
2714
|
e.enabled = n;
|
|
2671
2715
|
}
|
|
2672
2716
|
//#endregion
|
|
2673
2717
|
//#region src/core/initialRuntimeState.ts
|
|
2674
|
-
function
|
|
2718
|
+
function bn(e, t) {
|
|
2675
2719
|
let n = e.initialPage;
|
|
2676
2720
|
return {
|
|
2677
2721
|
activeReelPostId: null,
|
|
2678
|
-
autoScroll:
|
|
2679
|
-
autofill:
|
|
2722
|
+
autoScroll: Wt(e.autoScroll),
|
|
2723
|
+
autofill: Ft(e.autofill),
|
|
2680
2724
|
error: null,
|
|
2681
|
-
fill:
|
|
2725
|
+
fill: tn(e.fill),
|
|
2682
2726
|
infiniteScroll: e.infiniteScroll ?? !0,
|
|
2683
2727
|
isLoading: !n,
|
|
2684
2728
|
isLoadingMore: !1,
|
|
2685
2729
|
items: n ? Q([], n.items) : [],
|
|
2686
2730
|
layout: t === "reel" ? "reel" : "masonry",
|
|
2687
2731
|
loadMoreLocked: !1,
|
|
2732
|
+
mediaIndices: /* @__PURE__ */ new Map(),
|
|
2688
2733
|
next: n?.next ?? null,
|
|
2689
2734
|
nextPageError: null,
|
|
2690
|
-
reelAutoAdvance:
|
|
2691
|
-
|
|
2735
|
+
reelAutoAdvance: gn(e.reelAutoAdvance),
|
|
2736
|
+
reelForward: {
|
|
2737
|
+
error: null,
|
|
2738
|
+
status: "idle"
|
|
2739
|
+
},
|
|
2740
|
+
reelForwardIndex: null,
|
|
2741
|
+
reelForwardItem: null,
|
|
2742
|
+
reelInfoSheet: vn(e.reelInfoSheet),
|
|
2692
2743
|
reelInfoSheetOverlay: !1,
|
|
2693
2744
|
reelMediaSource: "original",
|
|
2694
2745
|
reelOrigin: null,
|
|
@@ -2696,19 +2747,136 @@ function yn(e, t) {
|
|
|
2696
2747
|
};
|
|
2697
2748
|
}
|
|
2698
2749
|
//#endregion
|
|
2750
|
+
//#region src/core/options.ts
|
|
2751
|
+
function xn(e, t) {
|
|
2752
|
+
if (t) {
|
|
2753
|
+
if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
|
|
2754
|
+
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
function Sn(e, t) {
|
|
2758
|
+
if (t) {
|
|
2759
|
+
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
|
|
2760
|
+
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.`);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
function Cn(e) {
|
|
2764
|
+
if (Ut(e.autoScroll), xn("cardHeader", e.cardHeader), xn("cardFooter", e.cardFooter), Sn("header", e.mediaCard?.header), Sn("footer", e.mediaCard?.footer), Pt(e.autofill), en(e.fill), hn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
|
|
2765
|
+
if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
|
|
2766
|
+
if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
|
|
2767
|
+
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
2768
|
+
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
2769
|
+
}
|
|
2770
|
+
function wn(e) {
|
|
2771
|
+
if (typeof e != "string") return e;
|
|
2772
|
+
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
2773
|
+
let t = document.querySelector(e);
|
|
2774
|
+
if (!t) throw Error(`Vibe target not found: ${e}`);
|
|
2775
|
+
return t;
|
|
2776
|
+
}
|
|
2777
|
+
//#endregion
|
|
2778
|
+
//#region src/core/activeItemRemoval.ts
|
|
2779
|
+
function Tn(e, t, n, r, i) {
|
|
2780
|
+
let a = new Set(t.map(({ item: e }) => e.postId));
|
|
2781
|
+
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
2782
|
+
let o = e.items[Math.max(n, 0)];
|
|
2783
|
+
if (o) {
|
|
2784
|
+
r(o.postId);
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
let s = t.find(({ item: t }) => t.postId === e.activeReelPostId)?.item;
|
|
2788
|
+
s && i(Math.max(n, 0), s);
|
|
2789
|
+
}
|
|
2790
|
+
//#endregion
|
|
2791
|
+
//#region src/core/exactMediaRemovalController.ts
|
|
2792
|
+
function En(e, t) {
|
|
2793
|
+
let [n, ...r] = t;
|
|
2794
|
+
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
2795
|
+
return {
|
|
2796
|
+
...e,
|
|
2797
|
+
...n,
|
|
2798
|
+
items: r
|
|
2799
|
+
};
|
|
2800
|
+
}
|
|
2801
|
+
function Dn(e) {
|
|
2802
|
+
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
2803
|
+
}
|
|
2804
|
+
var On = class {
|
|
2805
|
+
generation = 0;
|
|
2806
|
+
metadata = /* @__PURE__ */ new WeakMap();
|
|
2807
|
+
state;
|
|
2808
|
+
constructor(e) {
|
|
2809
|
+
this.options = e, this.state = e.state;
|
|
2810
|
+
}
|
|
2811
|
+
remove(e) {
|
|
2812
|
+
Dn(e);
|
|
2813
|
+
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
2814
|
+
if (!n) return null;
|
|
2815
|
+
let r = [...j(n)], i = r[e.mediaIndex];
|
|
2816
|
+
if (!i) return null;
|
|
2817
|
+
let a = Object.freeze({
|
|
2818
|
+
media: i,
|
|
2819
|
+
mediaIndex: e.mediaIndex,
|
|
2820
|
+
postId: e.postId,
|
|
2821
|
+
postIndex: t
|
|
2822
|
+
});
|
|
2823
|
+
this.metadata.set(a, {
|
|
2824
|
+
generation: this.generation,
|
|
2825
|
+
originalItem: n,
|
|
2826
|
+
restored: !1
|
|
2827
|
+
});
|
|
2828
|
+
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
2829
|
+
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = En(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);
|
|
2830
|
+
}
|
|
2831
|
+
reset() {
|
|
2832
|
+
this.generation += 1;
|
|
2833
|
+
}
|
|
2834
|
+
restore(e) {
|
|
2835
|
+
let t = this.metadata.get(e);
|
|
2836
|
+
if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
|
|
2837
|
+
if (t.generation !== this.generation || t.restored) return !1;
|
|
2838
|
+
t.restored = !0;
|
|
2839
|
+
let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
|
|
2840
|
+
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;
|
|
2841
|
+
}
|
|
2842
|
+
advanceFromRemovedPost(e, t) {
|
|
2843
|
+
let n = this.state.items[e.postIndex];
|
|
2844
|
+
if (n) {
|
|
2845
|
+
this.options.onActivate(n.postId);
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
this.options.reelForward.start(e, e.postIndex, t);
|
|
2849
|
+
}
|
|
2850
|
+
isReelOpen() {
|
|
2851
|
+
return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
|
|
2852
|
+
}
|
|
2853
|
+
restoreIntoPost(e, t) {
|
|
2854
|
+
let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
|
|
2855
|
+
if (r.splice(i, 0, t.media), this.state.items[e] = En(n, r), this.state.activeReelPostId !== t.postId) return;
|
|
2856
|
+
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
2857
|
+
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
2858
|
+
}
|
|
2859
|
+
updateMediaIndexAfterRemoval(e, t, n) {
|
|
2860
|
+
let r = this.state.items.find((t) => t.postId === e);
|
|
2861
|
+
if (!r) return;
|
|
2862
|
+
let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
|
|
2863
|
+
n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
//#endregion
|
|
2699
2867
|
//#region src/core/itemPlacement.ts
|
|
2700
|
-
function
|
|
2868
|
+
function kn(e, t) {
|
|
2701
2869
|
let n = new Set(t);
|
|
2702
2870
|
return e.flatMap((e, t) => n.has(e.postId) ? [{
|
|
2703
2871
|
index: t,
|
|
2704
2872
|
item: e
|
|
2705
2873
|
}] : []);
|
|
2706
2874
|
}
|
|
2707
|
-
function
|
|
2875
|
+
function An(e, t) {
|
|
2708
2876
|
let n = new Set(t.map(({ item: e }) => e.postId));
|
|
2709
2877
|
return e.filter((e) => !n.has(e.postId));
|
|
2710
2878
|
}
|
|
2711
|
-
function
|
|
2879
|
+
function jn(e, t) {
|
|
2712
2880
|
t.forEach(({ index: e }) => {
|
|
2713
2881
|
if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
|
|
2714
2882
|
});
|
|
@@ -2719,7 +2887,7 @@ function Sn(e, t) {
|
|
|
2719
2887
|
}
|
|
2720
2888
|
//#endregion
|
|
2721
2889
|
//#region src/core/itemRemovalController.ts
|
|
2722
|
-
var
|
|
2890
|
+
var Mn = 20, Nn = class {
|
|
2723
2891
|
generation = 0;
|
|
2724
2892
|
historyLimit;
|
|
2725
2893
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -2728,7 +2896,7 @@ var Cn = 20, wn = class {
|
|
|
2728
2896
|
itemOrder;
|
|
2729
2897
|
stopItemsWatcher;
|
|
2730
2898
|
constructor(e) {
|
|
2731
|
-
this.options = e, this.historyLimit = e.historyLimit ??
|
|
2899
|
+
this.options = e, this.historyLimit = e.historyLimit ?? Mn, 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" });
|
|
2732
2900
|
}
|
|
2733
2901
|
destroy() {
|
|
2734
2902
|
this.reset(), this.stopItemsWatcher();
|
|
@@ -2738,8 +2906,8 @@ var Cn = 20, wn = class {
|
|
|
2738
2906
|
if (t.length === 0) return n;
|
|
2739
2907
|
let r = t.map(({ item: e }) => e.postId), i = this.options.startRemoval(r);
|
|
2740
2908
|
if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
|
|
2741
|
-
let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId);
|
|
2742
|
-
return this.state.items =
|
|
2909
|
+
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);
|
|
2910
|
+
return this.state.items = An(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
|
|
2743
2911
|
}
|
|
2744
2912
|
reset() {
|
|
2745
2913
|
this.generation += 1, this.history = [], this.itemOrder = [];
|
|
@@ -2750,13 +2918,16 @@ var Cn = 20, wn = class {
|
|
|
2750
2918
|
this.restoreRemoval(t);
|
|
2751
2919
|
return;
|
|
2752
2920
|
}
|
|
2753
|
-
let n =
|
|
2921
|
+
let n = jn(this.state.items, e);
|
|
2754
2922
|
this.registerExternalPlacements(e), this.state.items = n;
|
|
2755
2923
|
}
|
|
2756
2924
|
restoreRemoval(e) {
|
|
2757
2925
|
let t = this.metadata.get(e);
|
|
2758
2926
|
if (!t) throw TypeError("Vibe removal does not belong to this instance.");
|
|
2759
|
-
|
|
2927
|
+
if (t.generation !== this.generation || t.restored) return !1;
|
|
2928
|
+
t.restored = !0, this.removeFromHistory(e);
|
|
2929
|
+
let n = this.restoreOrderedPlacements(e);
|
|
2930
|
+
return n && this.options.onRemovalRestored(e), n;
|
|
2760
2931
|
}
|
|
2761
2932
|
undoLast() {
|
|
2762
2933
|
for (; this.history.length > 0;) {
|
|
@@ -2773,7 +2944,7 @@ var Cn = 20, wn = class {
|
|
|
2773
2944
|
}
|
|
2774
2945
|
collectOrderedPlacements(e) {
|
|
2775
2946
|
let t = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
2776
|
-
return
|
|
2947
|
+
return kn(this.state.items, e).map((e) => ({
|
|
2777
2948
|
index: t.get(e.item.postId) ?? e.index,
|
|
2778
2949
|
item: e.item
|
|
2779
2950
|
}));
|
|
@@ -2804,46 +2975,121 @@ var Cn = 20, wn = class {
|
|
|
2804
2975
|
let r = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
2805
2976
|
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;
|
|
2806
2977
|
}
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2978
|
+
}, Pn = class {
|
|
2979
|
+
forward = null;
|
|
2980
|
+
forwardPromise = null;
|
|
2981
|
+
forwardVersion = 0;
|
|
2982
|
+
state;
|
|
2983
|
+
constructor(e) {
|
|
2984
|
+
this.options = e, this.state = e.state;
|
|
2814
2985
|
}
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2986
|
+
start(e, t, n) {
|
|
2987
|
+
this.forward = {
|
|
2988
|
+
item: n,
|
|
2989
|
+
postIndex: t,
|
|
2990
|
+
token: e,
|
|
2991
|
+
version: ++this.forwardVersion
|
|
2992
|
+
}, this.state.reelForward = {
|
|
2993
|
+
error: null,
|
|
2994
|
+
status: "loading"
|
|
2995
|
+
}, this.state.reelForwardIndex = t, this.state.reelForwardItem = n, this.startForwardRequest(!1);
|
|
2996
|
+
}
|
|
2997
|
+
cancel(e) {
|
|
2998
|
+
if (this.forward?.token !== e || this.state.reelForward.status === "idle") return null;
|
|
2999
|
+
let t = this.forward.item;
|
|
3000
|
+
return this.forwardVersion += 1, this.forward = null, this.clearState(), t;
|
|
2820
3001
|
}
|
|
3002
|
+
reset() {
|
|
3003
|
+
this.forwardVersion += 1, this.forward = null, this.forwardPromise = null, this.clearState();
|
|
3004
|
+
}
|
|
3005
|
+
retry() {
|
|
3006
|
+
return !this.forward || this.state.reelForward.status === "idle" ? Promise.resolve() : (this.state.nextPageError = null, this.state.reelForward = {
|
|
3007
|
+
error: null,
|
|
3008
|
+
status: "loading"
|
|
3009
|
+
}, this.startForwardRequest(this.state.next === null));
|
|
3010
|
+
}
|
|
3011
|
+
clearState() {
|
|
3012
|
+
this.state.reelForward = {
|
|
3013
|
+
error: null,
|
|
3014
|
+
status: "idle"
|
|
3015
|
+
}, this.state.reelForwardIndex = null, this.state.reelForwardItem = null;
|
|
3016
|
+
}
|
|
3017
|
+
startForwardRequest(e) {
|
|
3018
|
+
if (this.forwardPromise) return this.forwardPromise;
|
|
3019
|
+
let t = this.loadForward(e);
|
|
3020
|
+
return this.forwardPromise = t, t.finally(() => {
|
|
3021
|
+
this.forwardPromise === t && (this.forwardPromise = null, this.forward && this.state.reelForward.status === "loading" && this.startForwardRequest(!1));
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
async loadForward(e) {
|
|
3025
|
+
let t = this.forward;
|
|
3026
|
+
if (t) for (e && await this.options.retryEnd(); this.forward === t && t.version === this.forwardVersion;) {
|
|
3027
|
+
let e = this.state.items[t.postIndex];
|
|
3028
|
+
if (e) {
|
|
3029
|
+
this.forward = null, this.clearState(), this.options.onActivate(e.postId);
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
if (this.state.nextPageError) {
|
|
3033
|
+
this.state.reelForward = {
|
|
3034
|
+
error: this.state.nextPageError,
|
|
3035
|
+
status: "error"
|
|
3036
|
+
};
|
|
3037
|
+
return;
|
|
3038
|
+
}
|
|
3039
|
+
if (this.state.next === null) {
|
|
3040
|
+
this.state.reelForward = {
|
|
3041
|
+
error: null,
|
|
3042
|
+
status: "end"
|
|
3043
|
+
};
|
|
3044
|
+
return;
|
|
3045
|
+
}
|
|
3046
|
+
let n = this.state.next;
|
|
3047
|
+
if (await this.options.loadNext(), this.state.next === n && !this.state.nextPageError && !this.state.items[t.postIndex]) {
|
|
3048
|
+
this.state.reelForward = {
|
|
3049
|
+
error: /* @__PURE__ */ Error("Vibe could not advance while page loading is unavailable."),
|
|
3050
|
+
status: "error"
|
|
3051
|
+
};
|
|
3052
|
+
return;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
//#endregion
|
|
3058
|
+
//#region src/core/removalControllers.ts
|
|
3059
|
+
function Fn(e) {
|
|
3060
|
+
let t = new Pn(e);
|
|
3061
|
+
return {
|
|
3062
|
+
exactMediaRemoval: new On({
|
|
3063
|
+
onActivate: e.onActivate,
|
|
3064
|
+
reelForward: t,
|
|
3065
|
+
state: e.state
|
|
3066
|
+
}),
|
|
3067
|
+
itemRemoval: new Nn({
|
|
3068
|
+
historyLimit: e.historyLimit,
|
|
3069
|
+
onItemsRemoved: (n, r, i) => {
|
|
3070
|
+
Tn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
|
|
3071
|
+
},
|
|
3072
|
+
onRemovalRestored: (n) => {
|
|
3073
|
+
let r = t.cancel(n);
|
|
3074
|
+
r && e.onActivate(r.postId);
|
|
3075
|
+
},
|
|
3076
|
+
startRemoval: e.startRemoval,
|
|
3077
|
+
state: e.state
|
|
3078
|
+
}),
|
|
3079
|
+
reelForward: t
|
|
3080
|
+
};
|
|
2821
3081
|
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
|
|
2825
|
-
if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
|
|
2826
|
-
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
2827
|
-
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
2828
|
-
}
|
|
2829
|
-
function On(e) {
|
|
2830
|
-
if (typeof e != "string") return e;
|
|
2831
|
-
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
2832
|
-
let t = document.querySelector(e);
|
|
2833
|
-
if (!t) throw Error(`Vibe target not found: ${e}`);
|
|
2834
|
-
return t;
|
|
2835
|
-
}
|
|
2836
|
-
var kn = 1.5;
|
|
2837
|
-
function An(e) {
|
|
3082
|
+
var In = 1.5;
|
|
3083
|
+
function Ln(e) {
|
|
2838
3084
|
let t = Math.min(e.screenWidth, e.screenHeight);
|
|
2839
3085
|
if (t > 0 && t < 600) return !0;
|
|
2840
|
-
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n *
|
|
3086
|
+
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * In;
|
|
2841
3087
|
return !e.hasHover && n > 0 && n < 600 && r;
|
|
2842
3088
|
}
|
|
2843
|
-
function
|
|
2844
|
-
return
|
|
3089
|
+
function Rn(e) {
|
|
3090
|
+
return Ln(e) ? "reel" : "masonry";
|
|
2845
3091
|
}
|
|
2846
|
-
function
|
|
3092
|
+
function zn(e) {
|
|
2847
3093
|
let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
|
|
2848
3094
|
return {
|
|
2849
3095
|
hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
|
|
@@ -2853,15 +3099,15 @@ function Mn(e) {
|
|
|
2853
3099
|
viewportWidth: n.clientWidth
|
|
2854
3100
|
};
|
|
2855
3101
|
}
|
|
2856
|
-
function
|
|
2857
|
-
return
|
|
3102
|
+
function Bn(e) {
|
|
3103
|
+
return Ln(zn(e));
|
|
2858
3104
|
}
|
|
2859
|
-
function
|
|
2860
|
-
return
|
|
3105
|
+
function Vn(e) {
|
|
3106
|
+
return Rn(zn(e));
|
|
2861
3107
|
}
|
|
2862
3108
|
//#endregion
|
|
2863
3109
|
//#region src/core/responsiveLayoutController.ts
|
|
2864
|
-
var
|
|
3110
|
+
var Hn = class {
|
|
2865
3111
|
layoutMode;
|
|
2866
3112
|
resizeObserver = null;
|
|
2867
3113
|
target = null;
|
|
@@ -2886,10 +3132,10 @@ var Fn = class {
|
|
|
2886
3132
|
}
|
|
2887
3133
|
handleResponsiveLayout = () => {
|
|
2888
3134
|
if (!this.target) return;
|
|
2889
|
-
let e =
|
|
2890
|
-
this.state.reelInfoSheetOverlay =
|
|
3135
|
+
let e = Vn(this.target);
|
|
3136
|
+
this.state.reelInfoSheetOverlay = Bn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
|
|
2891
3137
|
};
|
|
2892
|
-
},
|
|
3138
|
+
}, Un = class {
|
|
2893
3139
|
routedReelPostId = null;
|
|
2894
3140
|
reelRouteIsActive = !1;
|
|
2895
3141
|
constructor(e, t) {
|
|
@@ -2916,7 +3162,7 @@ var Fn = class {
|
|
|
2916
3162
|
let i = this.reelRouteIsActive ? "replace" : "push";
|
|
2917
3163
|
this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
|
|
2918
3164
|
}
|
|
2919
|
-
},
|
|
3165
|
+
}, Wn = class {
|
|
2920
3166
|
app = null;
|
|
2921
3167
|
autoScroll;
|
|
2922
3168
|
autofillDelayCountdown;
|
|
@@ -2927,49 +3173,55 @@ var Fn = class {
|
|
|
2927
3173
|
responsiveLayout;
|
|
2928
3174
|
routing;
|
|
2929
3175
|
fillController;
|
|
3176
|
+
exactMediaRemoval;
|
|
2930
3177
|
itemRemoval;
|
|
3178
|
+
reelForward;
|
|
2931
3179
|
surface = null;
|
|
2932
3180
|
stopStateWatcher = null;
|
|
2933
3181
|
lastLoadedCursor = null;
|
|
2934
3182
|
state;
|
|
2935
3183
|
constructor(e) {
|
|
2936
|
-
this.options = e,
|
|
3184
|
+
this.options = e, Cn(e);
|
|
2937
3185
|
let t = e.layout ?? "masonry";
|
|
2938
|
-
this.state = b(
|
|
3186
|
+
this.state = b(bn(e, t)), this.autoScroll = new Gt({
|
|
2939
3187
|
getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
|
|
2940
3188
|
state: this.state.autoScroll
|
|
2941
|
-
}), this.autofillDelayCountdown = new
|
|
3189
|
+
}), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new fn({
|
|
2942
3190
|
fill: e.fill,
|
|
2943
3191
|
loadPage: e.loadPage,
|
|
2944
3192
|
onLastCursor: (e) => {
|
|
2945
3193
|
this.lastLoadedCursor = e;
|
|
2946
3194
|
},
|
|
2947
3195
|
state: this.state
|
|
2948
|
-
}), this.routing = new
|
|
3196
|
+
}), this.routing = new Un(e.routing, this.state);
|
|
3197
|
+
let n = Fn({
|
|
2949
3198
|
historyLimit: e.removalHistoryLimit,
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
3199
|
+
loadNext: () => this.loadNext(),
|
|
3200
|
+
onActivate: (e) => this.setActiveReelPost(e),
|
|
3201
|
+
retryEnd: () => this.retryEnd(),
|
|
2953
3202
|
startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
|
|
2954
3203
|
state: this.state
|
|
2955
|
-
})
|
|
3204
|
+
});
|
|
3205
|
+
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.responsiveLayout = new Hn(t, this.state, () => {
|
|
2956
3206
|
this.routing.syncFeed();
|
|
2957
3207
|
}), this.startStateNotifications();
|
|
2958
3208
|
}
|
|
2959
3209
|
async mount() {
|
|
2960
3210
|
if (this.app) throw Error("Vibe is already mounted.");
|
|
2961
3211
|
this.startStateNotifications();
|
|
2962
|
-
let e =
|
|
2963
|
-
this.responsiveLayout.mount(e), this.app = r(
|
|
3212
|
+
let e = wn(this.options.target);
|
|
3213
|
+
this.responsiveLayout.mount(e), this.app = r(bt, {
|
|
2964
3214
|
canRetryEnd: !!this.options.loadPage,
|
|
2965
3215
|
cardFooter: this.options.cardFooter,
|
|
2966
3216
|
cardHeader: this.options.cardHeader,
|
|
2967
3217
|
feedFooter: this.options.feedFooter,
|
|
2968
|
-
feedFooterActions:
|
|
3218
|
+
feedFooterActions: pn(this),
|
|
2969
3219
|
mediaCard: this.options.mediaCard,
|
|
2970
3220
|
reelInfoSheet: this.options.reelInfoSheet,
|
|
2971
3221
|
state: this.state,
|
|
2972
|
-
onActiveReelChange: (e) =>
|
|
3222
|
+
onActiveReelChange: (e) => {
|
|
3223
|
+
this.state.reelForward.status === "idle" && this.setActiveReelPost(e);
|
|
3224
|
+
},
|
|
2973
3225
|
onCloseReel: () => this.closeMasonryReel(),
|
|
2974
3226
|
onLoadMore: () => {
|
|
2975
3227
|
this.loadNext();
|
|
@@ -2978,24 +3230,36 @@ var Fn = class {
|
|
|
2978
3230
|
onReelInfoSheetChange: (e) => this.setReelInfoSheet(e),
|
|
2979
3231
|
onRetryEnd: () => {
|
|
2980
3232
|
this.retryEnd();
|
|
3233
|
+
},
|
|
3234
|
+
onRetryForward: () => {
|
|
3235
|
+
this.retryReelForward();
|
|
2981
3236
|
}
|
|
2982
3237
|
}), 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();
|
|
2983
3238
|
}
|
|
2984
3239
|
destroy() {
|
|
2985
|
-
this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
|
|
3240
|
+
this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
|
|
2986
3241
|
}
|
|
2987
3242
|
getState() {
|
|
2988
3243
|
return F(this.state);
|
|
2989
3244
|
}
|
|
3245
|
+
removeMedia(e) {
|
|
3246
|
+
return this.exactMediaRemoval.remove(e);
|
|
3247
|
+
}
|
|
2990
3248
|
removeItems(e) {
|
|
2991
3249
|
return this.itemRemoval.remove(e);
|
|
2992
3250
|
}
|
|
2993
3251
|
restoreItems(e) {
|
|
2994
3252
|
this.itemRemoval.restoreItems(e);
|
|
2995
3253
|
}
|
|
3254
|
+
restoreMediaRemoval(e) {
|
|
3255
|
+
return this.exactMediaRemoval.restore(e);
|
|
3256
|
+
}
|
|
2996
3257
|
restoreRemoval(e) {
|
|
2997
3258
|
return this.itemRemoval.restoreRemoval(e);
|
|
2998
3259
|
}
|
|
3260
|
+
retryReelForward() {
|
|
3261
|
+
return this.reelForward.retry();
|
|
3262
|
+
}
|
|
2999
3263
|
undoLastRemoval() {
|
|
3000
3264
|
return this.itemRemoval.undoLast();
|
|
3001
3265
|
}
|
|
@@ -3024,11 +3288,11 @@ var Fn = class {
|
|
|
3024
3288
|
this.autoScroll.setSpeed(e);
|
|
3025
3289
|
}
|
|
3026
3290
|
applyAutofillUpdate(e) {
|
|
3027
|
-
let t =
|
|
3291
|
+
let t = Jt(this.options.autofill, this.state, e);
|
|
3028
3292
|
return t && this.syncAutofillCountdown(), t;
|
|
3029
3293
|
}
|
|
3030
3294
|
async cancelAutofill() {
|
|
3031
|
-
await
|
|
3295
|
+
await Lt(this.options.autofill, this.state, () => this.cancelRequest());
|
|
3032
3296
|
}
|
|
3033
3297
|
applyFillUpdate(e) {
|
|
3034
3298
|
return this.fillController.applyUpdate(e);
|
|
@@ -3037,11 +3301,11 @@ var Fn = class {
|
|
|
3037
3301
|
return this.fillController.cancel();
|
|
3038
3302
|
}
|
|
3039
3303
|
async fill(e) {
|
|
3040
|
-
if (this.pendingRequest ||
|
|
3304
|
+
if (this.pendingRequest || It(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
|
|
3041
3305
|
await this.fillController.start(e);
|
|
3042
3306
|
}
|
|
3043
3307
|
restoreAutofillSession(e) {
|
|
3044
|
-
let t =
|
|
3308
|
+
let t = Yt(this.options.autofill, this.state, e);
|
|
3045
3309
|
return t && this.syncAutofillCountdown(), t;
|
|
3046
3310
|
}
|
|
3047
3311
|
restoreFillSession(e) {
|
|
@@ -3049,7 +3313,7 @@ var Fn = class {
|
|
|
3049
3313
|
}
|
|
3050
3314
|
async loadNext() {
|
|
3051
3315
|
if (this.pendingRequest) return this.pendingRequest;
|
|
3052
|
-
if (!this.state.loadMoreLocked && !(
|
|
3316
|
+
if (!this.state.loadMoreLocked && !(It(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);
|
|
3053
3317
|
}
|
|
3054
3318
|
async refresh() {
|
|
3055
3319
|
return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
|
|
@@ -3059,11 +3323,11 @@ var Fn = class {
|
|
|
3059
3323
|
}
|
|
3060
3324
|
async replaceFeed(e, t) {
|
|
3061
3325
|
if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
|
|
3062
|
-
return
|
|
3326
|
+
return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.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);
|
|
3063
3327
|
}
|
|
3064
3328
|
async retryEnd() {
|
|
3065
3329
|
if (this.pendingRequest) return this.pendingRequest;
|
|
3066
|
-
if (!this.state.loadMoreLocked && !(
|
|
3330
|
+
if (!this.state.loadMoreLocked && !(It(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);
|
|
3067
3331
|
}
|
|
3068
3332
|
setInfiniteScroll(e) {
|
|
3069
3333
|
this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
|
|
@@ -3072,10 +3336,10 @@ var Fn = class {
|
|
|
3072
3336
|
this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
|
|
3073
3337
|
}
|
|
3074
3338
|
setReelAutoAdvance(e) {
|
|
3075
|
-
|
|
3339
|
+
_n(this.state.reelAutoAdvance, e);
|
|
3076
3340
|
}
|
|
3077
3341
|
setReelInfoSheet(e) {
|
|
3078
|
-
|
|
3342
|
+
yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
|
|
3079
3343
|
}
|
|
3080
3344
|
setLayout(e) {
|
|
3081
3345
|
this.responsiveLayout.setLayout(e);
|
|
@@ -3083,16 +3347,6 @@ var Fn = class {
|
|
|
3083
3347
|
closeMasonryReel() {
|
|
3084
3348
|
this.state.reelOrigin === "masonry" && (this.state.activeReelPostId = null, this.state.reelOrigin = null, this.routing.syncFeed());
|
|
3085
3349
|
}
|
|
3086
|
-
restoreActiveItemAfterRemoval(e, t) {
|
|
3087
|
-
let n = new Set(e.map(({ item: e }) => e.postId));
|
|
3088
|
-
if (this.state.activeReelPostId === null || !n.has(this.state.activeReelPostId)) return;
|
|
3089
|
-
if (this.state.reelOrigin === "masonry") {
|
|
3090
|
-
this.closeMasonryReel();
|
|
3091
|
-
return;
|
|
3092
|
-
}
|
|
3093
|
-
let r = this.state.items[Math.min(Math.max(t, 0), this.state.items.length - 1)];
|
|
3094
|
-
this.state.activeReelPostId = r?.postId ?? null, r ? this.routing.syncReel(r.postId) : this.routing.syncFeed();
|
|
3095
|
-
}
|
|
3096
3350
|
openMasonryReel(e) {
|
|
3097
3351
|
this.state.layout === "masonry" && this.state.items.some((t) => t.postId === e) && (this.state.activeReelPostId = e, this.state.reelOrigin = "masonry", this.routing.syncReel(e));
|
|
3098
3352
|
}
|
|
@@ -3109,7 +3363,7 @@ var Fn = class {
|
|
|
3109
3363
|
this.abortController = i;
|
|
3110
3364
|
try {
|
|
3111
3365
|
if (a?.strategy === "frontend") {
|
|
3112
|
-
let o = await
|
|
3366
|
+
let o = await zt({
|
|
3113
3367
|
existingItems: t ? this.state.items : [],
|
|
3114
3368
|
initialCursor: e,
|
|
3115
3369
|
loadPage: n,
|
|
@@ -3131,7 +3385,7 @@ var Fn = class {
|
|
|
3131
3385
|
});
|
|
3132
3386
|
return;
|
|
3133
3387
|
}
|
|
3134
|
-
let c =
|
|
3388
|
+
let c = xt(await n({
|
|
3135
3389
|
cursor: e,
|
|
3136
3390
|
signal: i.signal
|
|
3137
3391
|
}));
|
|
@@ -3146,7 +3400,7 @@ var Fn = class {
|
|
|
3146
3400
|
this.state.autofill.status = "complete";
|
|
3147
3401
|
return;
|
|
3148
3402
|
}
|
|
3149
|
-
await
|
|
3403
|
+
await Kt(a, this.state, {
|
|
3150
3404
|
cycleId: o,
|
|
3151
3405
|
feedKey: a.feedKey,
|
|
3152
3406
|
items: u.slice(l.length),
|
|
@@ -3171,7 +3425,7 @@ var Fn = class {
|
|
|
3171
3425
|
this.autofillDelayCountdown.clear();
|
|
3172
3426
|
let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
|
|
3173
3427
|
return this.state.autofill = {
|
|
3174
|
-
...
|
|
3428
|
+
...Ft(e, void 0, !1),
|
|
3175
3429
|
cycleId: t,
|
|
3176
3430
|
status: "filling"
|
|
3177
3431
|
}, t;
|
|
@@ -3189,7 +3443,7 @@ var Fn = class {
|
|
|
3189
3443
|
startInitialAutofill() {
|
|
3190
3444
|
let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
|
|
3191
3445
|
this.abortController = t, this.state.isLoadingMore = !0;
|
|
3192
|
-
let r =
|
|
3446
|
+
let r = Xt({
|
|
3193
3447
|
cycleId: n,
|
|
3194
3448
|
isCurrent: () => e === this.requestVersion,
|
|
3195
3449
|
onLastCursor: (e) => {
|
|
@@ -3213,8 +3467,8 @@ var Fn = class {
|
|
|
3213
3467
|
}));
|
|
3214
3468
|
}
|
|
3215
3469
|
};
|
|
3216
|
-
function
|
|
3217
|
-
return new
|
|
3470
|
+
function Gn(e) {
|
|
3471
|
+
return new Wn(e);
|
|
3218
3472
|
}
|
|
3219
3473
|
//#endregion
|
|
3220
|
-
export {
|
|
3474
|
+
export { Gn as createVibe };
|