@wyxos/vibe 5.8.3 → 5.8.4
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/MediaContextOverlay.vue.d.ts +11 -0
- package/lib/core/mediaCardOptions.d.ts +4 -0
- package/lib/index.cjs +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +374 -335
- package/lib/style.css +1 -1
- package/lib/types.d.ts +6 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -756,29 +756,55 @@ var Ie = /* @__PURE__ */ d({
|
|
|
756
756
|
])) : o("", !0)], 34));
|
|
757
757
|
}
|
|
758
758
|
}), Ye = {
|
|
759
|
+
key: 0,
|
|
760
|
+
class: "media-card-overlay-host",
|
|
761
|
+
"data-test": "media-card-overlay"
|
|
762
|
+
}, Xe = /* @__PURE__ */ d({
|
|
763
|
+
__name: "MediaContextOverlay",
|
|
764
|
+
props: {
|
|
765
|
+
item: {},
|
|
766
|
+
mediaCard: {},
|
|
767
|
+
mediaIndex: {},
|
|
768
|
+
mediaItem: {},
|
|
769
|
+
mediaSource: {}
|
|
770
|
+
},
|
|
771
|
+
setup(e) {
|
|
772
|
+
return (t, n) => e.mediaCard?.overlay?.component ? (b(), s("div", Ye, [(b(), a(C(e.mediaCard.overlay.component), {
|
|
773
|
+
item: e.item,
|
|
774
|
+
"media-index": e.mediaIndex,
|
|
775
|
+
"media-item": e.mediaItem,
|
|
776
|
+
"media-source": e.mediaSource
|
|
777
|
+
}, null, 8, [
|
|
778
|
+
"item",
|
|
779
|
+
"media-index",
|
|
780
|
+
"media-item",
|
|
781
|
+
"media-source"
|
|
782
|
+
]))])) : o("", !0);
|
|
783
|
+
}
|
|
784
|
+
}), Ze = {
|
|
759
785
|
lastAudibleVolume: 1,
|
|
760
786
|
muted: !1,
|
|
761
787
|
volume: 1
|
|
762
788
|
};
|
|
763
|
-
function
|
|
789
|
+
function Qe(e, t) {
|
|
764
790
|
return typeof e == "number" && Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : t;
|
|
765
791
|
}
|
|
766
|
-
function
|
|
767
|
-
let n =
|
|
792
|
+
function $e(e, t = Ze) {
|
|
793
|
+
let n = Qe(e?.volume, t.volume), r = Qe(e?.lastAudibleVolume, n > 0 ? n : t.lastAudibleVolume);
|
|
768
794
|
return {
|
|
769
|
-
lastAudibleVolume: r > 0 ? r :
|
|
795
|
+
lastAudibleVolume: r > 0 ? r : Ze.lastAudibleVolume,
|
|
770
796
|
muted: typeof e?.muted == "boolean" ? e.muted : n === 0 || t.muted,
|
|
771
797
|
volume: n
|
|
772
798
|
};
|
|
773
799
|
}
|
|
774
800
|
//#endregion
|
|
775
801
|
//#region src/components/useMediaCardAudio.ts
|
|
776
|
-
function
|
|
777
|
-
let t =
|
|
802
|
+
function et(e) {
|
|
803
|
+
let t = $e(e.reelAudioState()), n = e.layout() === "reel" && e.reelAudioState(), r = w(n ? t.muted : e.mediaCard()?.videoMuted ?? e.layout() === "masonry"), i = w(n ? t.volume : 1), a = n ? t.lastAudibleVolume : 1;
|
|
778
804
|
function o() {
|
|
779
805
|
let t = e.videoElement.value, n = e.reelAudioState();
|
|
780
806
|
if (!t || e.layout() !== "reel" || !n) return;
|
|
781
|
-
let o =
|
|
807
|
+
let o = $e(n);
|
|
782
808
|
a = o.lastAudibleVolume, i.value = o.volume, r.value = o.muted, t.volume = o.volume, t.muted = e.active() === !1 ? !0 : o.muted;
|
|
783
809
|
}
|
|
784
810
|
function s(e, t) {
|
|
@@ -786,7 +812,7 @@ function Qe(e) {
|
|
|
786
812
|
}
|
|
787
813
|
function c(t) {
|
|
788
814
|
if (e.layout() !== "reel") return;
|
|
789
|
-
let n =
|
|
815
|
+
let n = $e({
|
|
790
816
|
lastAudibleVolume: a,
|
|
791
817
|
muted: t.muted,
|
|
792
818
|
volume: t.volume
|
|
@@ -821,22 +847,22 @@ function Qe(e) {
|
|
|
821
847
|
}
|
|
822
848
|
//#endregion
|
|
823
849
|
//#region src/core/mediaType.ts
|
|
824
|
-
var
|
|
825
|
-
function
|
|
850
|
+
var tt = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
|
|
851
|
+
function nt(e) {
|
|
826
852
|
try {
|
|
827
|
-
return
|
|
853
|
+
return tt.test(new URL(e).pathname);
|
|
828
854
|
} catch {
|
|
829
|
-
return
|
|
855
|
+
return tt.test(e.split("?")[0] ?? e);
|
|
830
856
|
}
|
|
831
857
|
}
|
|
832
|
-
function
|
|
833
|
-
return e === void 0 ?
|
|
858
|
+
function rt(e, t) {
|
|
859
|
+
return e === void 0 ? nt(t) : e === "video";
|
|
834
860
|
}
|
|
835
|
-
var
|
|
836
|
-
function
|
|
861
|
+
var it = /* @__PURE__ */ new Map(), at = [], ot = 0, st = 0;
|
|
862
|
+
function ct(e, t) {
|
|
837
863
|
return `${t ? "timed" : "image"}:${e}`;
|
|
838
864
|
}
|
|
839
|
-
function
|
|
865
|
+
function lt(e, t, n) {
|
|
840
866
|
let r = P(e);
|
|
841
867
|
if (r.length < 2) return [];
|
|
842
868
|
let i = F(e, t), a = [];
|
|
@@ -848,7 +874,7 @@ function st(e, t, n) {
|
|
|
848
874
|
return a.flatMap((e) => {
|
|
849
875
|
let t = r[e];
|
|
850
876
|
if (!t) return [];
|
|
851
|
-
let i = N(t, n), a =
|
|
877
|
+
let i = N(t, n), a = rt(i.type, i.src), s = ct(i.src, a);
|
|
852
878
|
return o.has(s) ? [] : (o.add(s), [{
|
|
853
879
|
key: s,
|
|
854
880
|
src: i.src,
|
|
@@ -856,22 +882,22 @@ function st(e, t, n) {
|
|
|
856
882
|
}]);
|
|
857
883
|
});
|
|
858
884
|
}
|
|
859
|
-
function
|
|
885
|
+
function ut(e) {
|
|
860
886
|
let t = e.element;
|
|
861
887
|
e.element = null, t && (t instanceof HTMLVideoElement ? (t.pause(), t.removeAttribute("src"), t.load()) : t.removeAttribute("src"));
|
|
862
888
|
}
|
|
863
|
-
function
|
|
864
|
-
|
|
865
|
-
let t =
|
|
866
|
-
t >= 0 &&
|
|
889
|
+
function dt(e) {
|
|
890
|
+
it.delete(e.key);
|
|
891
|
+
let t = at.indexOf(e);
|
|
892
|
+
t >= 0 && at.splice(t, 1), e.cancel?.(), e.cancel = null, ut(e);
|
|
867
893
|
}
|
|
868
|
-
function
|
|
869
|
-
e.state = "loading",
|
|
894
|
+
function ft(e) {
|
|
895
|
+
e.state = "loading", ot += 1, e.timed && (st += 1);
|
|
870
896
|
let t = !1, n = () => void 0, r = (r) => {
|
|
871
|
-
t || (t = !0, n(), --
|
|
897
|
+
t || (t = !0, n(), --ot, e.timed && --st, e.cancel = null, e.state = r, r === "failed" && ut(e), e.refs === 0 && dt(e), pt());
|
|
872
898
|
};
|
|
873
899
|
if (e.cancel = () => {
|
|
874
|
-
t || (t = !0, n(), --
|
|
900
|
+
t || (t = !0, n(), --ot, e.timed && --st, ut(e), pt());
|
|
875
901
|
}, e.timed) {
|
|
876
902
|
let t = document.createElement("video"), i = () => r("ready"), a = () => r("failed");
|
|
877
903
|
n = () => {
|
|
@@ -890,38 +916,38 @@ function ut(e) {
|
|
|
890
916
|
i.removeEventListener("load", a), i.removeEventListener("error", o);
|
|
891
917
|
}, i.addEventListener("load", a, { once: !0 }), i.addEventListener("error", o, { once: !0 }), i.decoding = "async", i.fetchPriority = "low", i.src = e.src, e.element = i;
|
|
892
918
|
}
|
|
893
|
-
function
|
|
894
|
-
for (;
|
|
895
|
-
let e =
|
|
919
|
+
function pt() {
|
|
920
|
+
for (; ot < 6;) {
|
|
921
|
+
let e = at.findIndex((e) => e.refs > 0 && e.state === "queued" && (!e.timed || st < 2));
|
|
896
922
|
if (e < 0) return;
|
|
897
|
-
let [t] =
|
|
898
|
-
t &&
|
|
923
|
+
let [t] = at.splice(e, 1);
|
|
924
|
+
t && ft(t);
|
|
899
925
|
}
|
|
900
926
|
}
|
|
901
|
-
function
|
|
902
|
-
let t =
|
|
927
|
+
function mt(e) {
|
|
928
|
+
let t = it.get(e.key);
|
|
903
929
|
t || (t = {
|
|
904
930
|
...e,
|
|
905
931
|
cancel: null,
|
|
906
932
|
element: null,
|
|
907
933
|
refs: 0,
|
|
908
934
|
state: "queued"
|
|
909
|
-
},
|
|
935
|
+
}, it.set(t.key, t), at.push(t)), t.refs += 1, pt();
|
|
910
936
|
let n = !1;
|
|
911
937
|
return () => {
|
|
912
|
-
n || (n = !0, --t.refs, t.refs === 0 &&
|
|
938
|
+
n || (n = !0, --t.refs, t.refs === 0 && dt(t));
|
|
913
939
|
};
|
|
914
940
|
}
|
|
915
941
|
//#endregion
|
|
916
942
|
//#region src/components/useVisiblePostPreload.ts
|
|
917
|
-
function
|
|
918
|
-
let t = r(() => e.layout() === "masonry" && e.inViewport() && e.mediaReady() && e.mediaCard()?.feedPreload === "visible-post"), n = r(() => t.value ?
|
|
943
|
+
function ht(e) {
|
|
944
|
+
let t = r(() => e.layout() === "masonry" && e.inViewport() && e.mediaReady() && e.mediaCard()?.feedPreload === "visible-post"), n = r(() => t.value ? lt(e.item(), e.mediaIndex(), e.mediaSource()) : []), i = /* @__PURE__ */ new Map();
|
|
919
945
|
function a() {
|
|
920
946
|
let e = new Map(n.value.map((e) => [e.key, e]));
|
|
921
947
|
i.forEach((t, n) => {
|
|
922
948
|
e.has(n) || (t(), i.delete(n));
|
|
923
949
|
}), n.value.forEach((e) => {
|
|
924
|
-
i.has(e.key) || i.set(e.key,
|
|
950
|
+
i.has(e.key) || i.set(e.key, mt(e));
|
|
925
951
|
});
|
|
926
952
|
}
|
|
927
953
|
O(() => n.value.map(({ key: e }) => e).join("\n"), a, { immediate: !0 }), v(() => {
|
|
@@ -930,7 +956,7 @@ function pt(e) {
|
|
|
930
956
|
}
|
|
931
957
|
//#endregion
|
|
932
958
|
//#region src/components/useReelVideoActivity.ts
|
|
933
|
-
function
|
|
959
|
+
function gt(e) {
|
|
934
960
|
let t = r(() => e.layout() !== "reel" || e.active() === !0), n = r(() => t.value ? e.videoIsMuted.value : !0);
|
|
935
961
|
function i() {
|
|
936
962
|
if (!t.value) {
|
|
@@ -964,8 +990,8 @@ function mt(e) {
|
|
|
964
990
|
}
|
|
965
991
|
//#endregion
|
|
966
992
|
//#region src/components/useMediaLoading.ts
|
|
967
|
-
function
|
|
968
|
-
let t = r(() =>
|
|
993
|
+
function _t(e) {
|
|
994
|
+
let t = r(() => rt(e.mediaType(), e.mediaSource())), n = r(() => e.layout() === "masonry" && e.fetchPriority() === "low" ? "lazy" : "eager"), i = r(() => e.layout() === "reel" && !e.active() ? "none" : e.fetchPriority() === "high" ? "auto" : e.layout() === "masonry" ? "none" : "metadata");
|
|
969
995
|
return O(i, (t, n) => {
|
|
970
996
|
n !== "none" || t === "none" || m(() => e.videoElement.value?.load());
|
|
971
997
|
}), {
|
|
@@ -976,7 +1002,7 @@ function ht(e) {
|
|
|
976
1002
|
}
|
|
977
1003
|
//#endregion
|
|
978
1004
|
//#region src/components/useMediaReadiness.ts
|
|
979
|
-
function
|
|
1005
|
+
function vt(e) {
|
|
980
1006
|
let t = w(null), n = w(null), i = w(0), a = w(0), o = w(!0), s = w(!1), c = w(!1), l = null, u = !1, d = r(() => c.value || s.value ? "error" : o.value ? "loading" : e.previewState());
|
|
981
1007
|
function f() {
|
|
982
1008
|
l !== null && clearTimeout(l), l = null;
|
|
@@ -1034,7 +1060,7 @@ function gt(e) {
|
|
|
1034
1060
|
}
|
|
1035
1061
|
//#endregion
|
|
1036
1062
|
//#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
|
|
1037
|
-
var
|
|
1063
|
+
var yt = [
|
|
1038
1064
|
"data-post-id",
|
|
1039
1065
|
"data-media-index",
|
|
1040
1066
|
"aria-hidden",
|
|
@@ -1042,12 +1068,12 @@ var _t = [
|
|
|
1042
1068
|
"inert",
|
|
1043
1069
|
"role",
|
|
1044
1070
|
"tabindex"
|
|
1045
|
-
],
|
|
1071
|
+
], bt = { class: "media-card-content" }, xt = ["data-media-direction"], St = ["data-media-index"], Ct = {
|
|
1046
1072
|
key: 0,
|
|
1047
1073
|
"data-test": "media-loading",
|
|
1048
1074
|
class: "media-loading",
|
|
1049
1075
|
"aria-hidden": "true"
|
|
1050
|
-
},
|
|
1076
|
+
}, wt = [
|
|
1051
1077
|
"data-source-generation",
|
|
1052
1078
|
"src",
|
|
1053
1079
|
"width",
|
|
@@ -1056,14 +1082,14 @@ var _t = [
|
|
|
1056
1082
|
"loop",
|
|
1057
1083
|
"muted",
|
|
1058
1084
|
"preload"
|
|
1059
|
-
],
|
|
1085
|
+
], Tt = [
|
|
1060
1086
|
"data-source-generation",
|
|
1061
1087
|
"src",
|
|
1062
1088
|
"width",
|
|
1063
1089
|
"height",
|
|
1064
1090
|
"fetchpriority",
|
|
1065
1091
|
"loading"
|
|
1066
|
-
],
|
|
1092
|
+
], Et = ["aria-label"], Dt = ["aria-label"], Ot = ["aria-label"], kt = 40, At = 160, jt = 24, Mt = /* @__PURE__ */ d({
|
|
1067
1093
|
__name: "MediaCard",
|
|
1068
1094
|
props: {
|
|
1069
1095
|
active: { type: Boolean },
|
|
@@ -1102,14 +1128,14 @@ var _t = [
|
|
|
1102
1128
|
function S(e = !1, t = "pointer") {
|
|
1103
1129
|
e && x("activate", t);
|
|
1104
1130
|
}
|
|
1105
|
-
let C = r(() => P(l.item)), T = r(() => F(l.item, l.mediaIndex)), D = r(() => I(l.item, T.value)), O = r(() => N(D.value, l.mediaSource ?? "preview")), M = r(() => O.value.src), L = r(() => O.value.type), R = r(() => O.value.width), z = r(() => O.value.height), { effectivePreviewState: B, failSourceAttempt: V, imageElement: H, markSourceReady: U, noteSourceActivity: W, retrySource: ee, retrying: te, sourceGeneration: G, videoElement: K } =
|
|
1131
|
+
let C = r(() => P(l.item)), T = r(() => F(l.item, l.mediaIndex)), D = r(() => I(l.item, T.value)), O = r(() => N(D.value, l.mediaSource ?? "preview")), M = r(() => O.value.src), L = r(() => O.value.type), R = r(() => O.value.width), z = r(() => O.value.height), { effectivePreviewState: B, failSourceAttempt: V, imageElement: H, markSourceReady: U, noteSourceActivity: W, retrySource: ee, retrying: te, sourceGeneration: G, videoElement: K } = vt({
|
|
1106
1132
|
identity: () => `${l.item.postId}:${T.value}:${l.mediaSource ?? "preview"}:${M.value}:${L.value ?? ""}`,
|
|
1107
1133
|
mediaIndex: () => T.value,
|
|
1108
1134
|
onError: (e) => x("error", e),
|
|
1109
1135
|
onReady: (e) => x("ready", e),
|
|
1110
1136
|
previewState: () => l.previewState
|
|
1111
1137
|
});
|
|
1112
|
-
|
|
1138
|
+
ht({
|
|
1113
1139
|
inViewport: () => l.inViewport === !0,
|
|
1114
1140
|
item: () => l.item,
|
|
1115
1141
|
layout: () => l.layout,
|
|
@@ -1118,14 +1144,14 @@ var _t = [
|
|
|
1118
1144
|
mediaReady: () => B.value === "ready",
|
|
1119
1145
|
mediaSource: () => l.mediaSource ?? "preview"
|
|
1120
1146
|
});
|
|
1121
|
-
let ne = w(0), re = w(0), q = w(!1), { apply: ie, setVolume: ae, sync: oe, toggleMute: se, videoIsMuted: J, videoVolume: ce } =
|
|
1147
|
+
let ne = w(0), re = w(0), q = w(!1), { apply: ie, setVolume: ae, sync: oe, toggleMute: se, videoIsMuted: J, videoVolume: ce } = et({
|
|
1122
1148
|
active: () => l.active,
|
|
1123
1149
|
layout: () => l.layout,
|
|
1124
1150
|
mediaCard: () => l.mediaCard,
|
|
1125
1151
|
onChange: (e) => x("reelAudioChange", e),
|
|
1126
1152
|
reelAudioState: () => l.reelAudioState,
|
|
1127
1153
|
videoElement: K
|
|
1128
|
-
}), { effectiveMuted: le, onPlaying: ue, playbackAllowed: de } =
|
|
1154
|
+
}), { effectiveMuted: le, onPlaying: ue, playbackAllowed: de } = gt({
|
|
1129
1155
|
active: () => l.active,
|
|
1130
1156
|
layout: () => l.layout,
|
|
1131
1157
|
videoElement: K,
|
|
@@ -1146,12 +1172,12 @@ var _t = [
|
|
|
1146
1172
|
f = 0, p = !1, d !== null && clearTimeout(d), d = null;
|
|
1147
1173
|
}
|
|
1148
1174
|
function he() {
|
|
1149
|
-
d !== null && clearTimeout(d), d = setTimeout(me,
|
|
1175
|
+
d !== null && clearTimeout(d), d = setTimeout(me, At);
|
|
1150
1176
|
}
|
|
1151
1177
|
function ge(e) {
|
|
1152
1178
|
if (C.value.length <= 1) return;
|
|
1153
1179
|
let t = e.currentTarget?.clientWidth || 1, n = pe(e.deltaX, e.deltaMode, t);
|
|
1154
|
-
if (n === 0 || (e.preventDefault(), he(), p) || (f += n, Math.abs(f) <
|
|
1180
|
+
if (n === 0 || (e.preventDefault(), he(), p) || (f += n, Math.abs(f) < jt)) return;
|
|
1155
1181
|
let r = Math.sign(f);
|
|
1156
1182
|
f = 0, p = !0, X(T.value + r);
|
|
1157
1183
|
}
|
|
@@ -1163,9 +1189,9 @@ var _t = [
|
|
|
1163
1189
|
let t = e.changedTouches[0];
|
|
1164
1190
|
if (m === null || g === null || !t) return;
|
|
1165
1191
|
let n = m - t.clientX, r = g - t.clientY;
|
|
1166
|
-
m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) <
|
|
1192
|
+
m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < kt || X(T.value + Math.sign(n)));
|
|
1167
1193
|
}
|
|
1168
|
-
let { imageLoading: ye, mediaIsTimed: be, videoPreload: xe } =
|
|
1194
|
+
let { imageLoading: ye, mediaIsTimed: be, videoPreload: xe } = _t({
|
|
1169
1195
|
active: () => l.active,
|
|
1170
1196
|
fetchPriority: () => l.fetchPriority,
|
|
1171
1197
|
layout: () => l.layout,
|
|
@@ -1225,7 +1251,7 @@ var _t = [
|
|
|
1225
1251
|
tabindex: e.interactive && !e.leaving && !Y.value ? 0 : void 0,
|
|
1226
1252
|
onClick: i[14] ||= (t) => S(e.interactive && !Y.value, fe(t)),
|
|
1227
1253
|
onKeydown: [i[15] ||= A((t) => S(e.interactive && !Y.value, "keyboard"), ["enter"]), i[16] ||= A(j((t) => S(e.interactive && !Y.value, "keyboard"), ["prevent"]), ["space"])]
|
|
1228
|
-
}, [c("div",
|
|
1254
|
+
}, [c("div", bt, [
|
|
1229
1255
|
e.cardHeader ? (b(), a(Ie, {
|
|
1230
1256
|
key: 0,
|
|
1231
1257
|
index: e.index,
|
|
@@ -1264,7 +1290,7 @@ var _t = [
|
|
|
1264
1290
|
key: `${e.item.postId}:${D.value.src}:${e.mediaSource ?? "preview"}:${E(G)}`,
|
|
1265
1291
|
class: "media-card-frame",
|
|
1266
1292
|
"data-media-index": T.value
|
|
1267
|
-
}, [E(B) === "loading" ? (b(), s("div",
|
|
1293
|
+
}, [E(B) === "loading" ? (b(), s("div", Ct, [...i[17] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : E(B) === "error" ? (b(), a(Be, {
|
|
1268
1294
|
key: 1,
|
|
1269
1295
|
component: e.mediaCard?.error?.component,
|
|
1270
1296
|
label: E(Fe)(M.value),
|
|
@@ -1306,7 +1332,7 @@ var _t = [
|
|
|
1306
1332
|
onEnded: Me,
|
|
1307
1333
|
onClick: Te,
|
|
1308
1334
|
onError: i[5] ||= (...e) => E(V) && E(V)(...e)
|
|
1309
|
-
}, null, 42,
|
|
1335
|
+
}, null, 42, wt)) : (b(), s("img", {
|
|
1310
1336
|
key: 3,
|
|
1311
1337
|
ref_key: "imageElement",
|
|
1312
1338
|
ref: H,
|
|
@@ -1321,9 +1347,22 @@ var _t = [
|
|
|
1321
1347
|
loading: E(ye),
|
|
1322
1348
|
onLoad: i[6] ||= (...e) => E(U) && E(U)(...e),
|
|
1323
1349
|
onError: i[7] ||= (...e) => E(V) && E(V)(...e)
|
|
1324
|
-
}, null, 42,
|
|
1350
|
+
}, null, 42, Tt))], 8, St))]),
|
|
1325
1351
|
_: 1
|
|
1326
1352
|
}, 8, ["css", "name"]),
|
|
1353
|
+
u(Xe, {
|
|
1354
|
+
item: e.item,
|
|
1355
|
+
"media-card": e.mediaCard,
|
|
1356
|
+
"media-index": T.value,
|
|
1357
|
+
"media-item": D.value,
|
|
1358
|
+
"media-source": e.mediaSource ?? "preview"
|
|
1359
|
+
}, null, 8, [
|
|
1360
|
+
"item",
|
|
1361
|
+
"media-card",
|
|
1362
|
+
"media-index",
|
|
1363
|
+
"media-item",
|
|
1364
|
+
"media-source"
|
|
1365
|
+
]),
|
|
1327
1366
|
(b(), a(t, {
|
|
1328
1367
|
disabled: !Se.value || !e.reelControlsTarget,
|
|
1329
1368
|
to: e.reelControlsTarget ?? "body"
|
|
@@ -1367,13 +1406,13 @@ var _t = [
|
|
|
1367
1406
|
"aria-label": `Previous media for post ${e.item.postId}`,
|
|
1368
1407
|
onClick: i[8] ||= j((e) => X(T.value - 1, e), ["stop"]),
|
|
1369
1408
|
onKeydown: i[9] ||= j(() => {}, ["stop"])
|
|
1370
|
-
}, [u(E(De), { size: 20 })], 40,
|
|
1409
|
+
}, [u(E(De), { size: 20 })], 40, Et), c("button", {
|
|
1371
1410
|
type: "button",
|
|
1372
1411
|
class: "media-carousel-control media-carousel-control--next",
|
|
1373
1412
|
"aria-label": `Next media for post ${e.item.postId}`,
|
|
1374
1413
|
onClick: i[10] ||= j((e) => X(T.value + 1, e), ["stop"]),
|
|
1375
1414
|
onKeydown: i[11] ||= j(() => {}, ["stop"])
|
|
1376
|
-
}, [u(E(Oe), { size: 20 })], 40,
|
|
1415
|
+
}, [u(E(Oe), { size: 20 })], 40, Dt)], 2)) : o("", !0),
|
|
1377
1416
|
Y.value ? (b(), s("button", {
|
|
1378
1417
|
key: 1,
|
|
1379
1418
|
class: "media-card-activator",
|
|
@@ -1381,8 +1420,8 @@ var _t = [
|
|
|
1381
1420
|
"aria-label": `Open post ${e.item.postId}`,
|
|
1382
1421
|
onClick: i[12] ||= j((e) => r.$emit("activate", fe(e)), ["stop"]),
|
|
1383
1422
|
onKeydown: i[13] ||= j(() => {}, ["stop"])
|
|
1384
|
-
}, null, 40,
|
|
1385
|
-
], 42,
|
|
1423
|
+
}, null, 40, Ot)) : o("", !0)
|
|
1424
|
+
], 42, xt),
|
|
1386
1425
|
e.cardFooter ? (b(), a(Ie, {
|
|
1387
1426
|
key: 1,
|
|
1388
1427
|
index: e.index,
|
|
@@ -1406,12 +1445,12 @@ var _t = [
|
|
|
1406
1445
|
"style",
|
|
1407
1446
|
"total"
|
|
1408
1447
|
])) : o("", !0)
|
|
1409
|
-
])], 46,
|
|
1448
|
+
])], 46, yt));
|
|
1410
1449
|
}
|
|
1411
|
-
}),
|
|
1450
|
+
}), Nt = { class: "masonry-feed-shell" }, Pt = ["aria-hidden", "inert"], Ft = {
|
|
1412
1451
|
key: 0,
|
|
1413
1452
|
class: "masonry-feed-status-overlay"
|
|
1414
|
-
},
|
|
1453
|
+
}, It = 6, Lt = 12, Rt = 250, zt = /* @__PURE__ */ d({
|
|
1415
1454
|
__name: "MasonryFeed",
|
|
1416
1455
|
props: {
|
|
1417
1456
|
enteringPostIds: {},
|
|
@@ -1448,7 +1487,7 @@ var _t = [
|
|
|
1448
1487
|
"visible"
|
|
1449
1488
|
],
|
|
1450
1489
|
setup(t, { expose: n, emit: i }) {
|
|
1451
|
-
let l = 0, d = t, f = i, p = w(null), m = `vibe-masonry-${D()}`, g = w(null), y = w(0), x = w(
|
|
1490
|
+
let l = 0, d = t, f = i, p = w(null), m = `vibe-masonry-${D()}`, g = w(null), y = w(0), x = w(It), C = w(0), T = w(0), k = w(0), A = w([]), j = w([]), M = 0, N = null, P = null, F = null, I = null, R = r(() => oe(d.items, y.value, {
|
|
1452
1491
|
additionalHeight: (d.cardHeader?.height ?? 0) + (d.cardFooter?.height ?? 0),
|
|
1453
1492
|
gap: x.value,
|
|
1454
1493
|
minColumnWidth: le(d.masonry)
|
|
@@ -1559,7 +1598,7 @@ var _t = [
|
|
|
1559
1598
|
}
|
|
1560
1599
|
function pe(e) {
|
|
1561
1600
|
let t = e.ownerDocument.documentElement.clientWidth;
|
|
1562
|
-
y.value = e.clientWidth, x.value = Math.min(
|
|
1601
|
+
y.value = e.clientWidth, x.value = Math.min(Lt, Math.max(It, t * .0075)), X();
|
|
1563
1602
|
}
|
|
1564
1603
|
function me(e) {
|
|
1565
1604
|
let t = e.currentTarget;
|
|
@@ -1570,7 +1609,7 @@ var _t = [
|
|
|
1570
1609
|
Date.now() >= l && !d.loadMoreLocked && e && re(e) && f("loadMore");
|
|
1571
1610
|
}
|
|
1572
1611
|
O(() => d.items.length, (e, t) => {
|
|
1573
|
-
e > 0 && e < t && (l = Date.now() +
|
|
1612
|
+
e > 0 && e < t && (l = Date.now() + Rt);
|
|
1574
1613
|
});
|
|
1575
1614
|
function ge() {
|
|
1576
1615
|
return p.value;
|
|
@@ -1593,7 +1632,7 @@ var _t = [
|
|
|
1593
1632
|
}), n({
|
|
1594
1633
|
getScrollElement: ge,
|
|
1595
1634
|
loadIfNearBottom: he
|
|
1596
|
-
}), (n, r) => (b(), s("div",
|
|
1635
|
+
}), (n, r) => (b(), s("div", Nt, [
|
|
1597
1636
|
c("main", {
|
|
1598
1637
|
id: m,
|
|
1599
1638
|
ref_key: "galleryElement",
|
|
@@ -1609,7 +1648,7 @@ var _t = [
|
|
|
1609
1648
|
class: h(["masonry", { "masonry--ready": y.value > 0 }]),
|
|
1610
1649
|
style: _(W.value),
|
|
1611
1650
|
"aria-label": "Media gallery"
|
|
1612
|
-
}, [(b(!0), s(e, null, S(K.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(
|
|
1651
|
+
}, [(b(!0), s(e, null, S(K.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(Mt, {
|
|
1613
1652
|
key: n.postId,
|
|
1614
1653
|
class: "masonry-item",
|
|
1615
1654
|
entering: t.enteringPostIds.has(n.postId),
|
|
@@ -1651,8 +1690,8 @@ var _t = [
|
|
|
1651
1690
|
"onMediaChange",
|
|
1652
1691
|
"onReady",
|
|
1653
1692
|
"onError"
|
|
1654
|
-
]))), 128))], 6)], 42,
|
|
1655
|
-
t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && ee.value || !t.hasNext && t.canRetryEnd ? (b(), s("div",
|
|
1693
|
+
]))), 128))], 6)], 42, Pt),
|
|
1694
|
+
t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && ee.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", Ft, [u(te, {
|
|
1656
1695
|
actions: t.feedFooterActions,
|
|
1657
1696
|
"can-retry-end": t.canRetryEnd,
|
|
1658
1697
|
"feed-footer": t.feedFooter,
|
|
@@ -1687,8 +1726,8 @@ var _t = [
|
|
|
1687
1726
|
])
|
|
1688
1727
|
]));
|
|
1689
1728
|
}
|
|
1690
|
-
}),
|
|
1691
|
-
function
|
|
1729
|
+
}), Bt = 300;
|
|
1730
|
+
function Vt(e, t, n) {
|
|
1692
1731
|
let r = e.scrollTop;
|
|
1693
1732
|
if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
|
|
1694
1733
|
e.setAttribute("data-transitioning", "");
|
|
@@ -1696,7 +1735,7 @@ function zt(e, t, n) {
|
|
|
1696
1735
|
return new Promise((n) => {
|
|
1697
1736
|
let o = (s) => {
|
|
1698
1737
|
a += 1;
|
|
1699
|
-
let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c /
|
|
1738
|
+
let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / Bt), u = 1 - (1 - l) ** 3;
|
|
1700
1739
|
if (e.scrollTop = r + (t - r) * u, l < 1) {
|
|
1701
1740
|
requestAnimationFrame(o);
|
|
1702
1741
|
return;
|
|
@@ -1708,7 +1747,7 @@ function zt(e, t, n) {
|
|
|
1708
1747
|
}
|
|
1709
1748
|
//#endregion
|
|
1710
1749
|
//#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
|
|
1711
|
-
var
|
|
1750
|
+
var Ht = ["aria-label"], Ut = /* @__PURE__ */ d({
|
|
1712
1751
|
__name: "ReelAutoAdvanceProgress",
|
|
1713
1752
|
props: {
|
|
1714
1753
|
durationMs: {},
|
|
@@ -1726,9 +1765,9 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1726
1765
|
class: "reel-auto-advance-progress",
|
|
1727
1766
|
style: _(a.value),
|
|
1728
1767
|
onAnimationend: n[0] ||= (e) => i("complete")
|
|
1729
|
-
}, null, 36)], 8,
|
|
1768
|
+
}, null, 36)], 8, Ht));
|
|
1730
1769
|
}
|
|
1731
|
-
}),
|
|
1770
|
+
}), Wt = { class: "reel-viewport" }, Gt = ["data-active-post-id", "data-active-media-index"], Kt = ["role", "data-status"], qt = 300, Jt = 250, Yt = /* @__PURE__ */ d({
|
|
1732
1771
|
__name: "ReelFeed",
|
|
1733
1772
|
props: {
|
|
1734
1773
|
initialPostId: {},
|
|
@@ -1780,7 +1819,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1780
1819
|
}), H = r(() => {
|
|
1781
1820
|
let e = z.value;
|
|
1782
1821
|
return e === void 0 ? "loading" : u.previewStates.get(L(e, V.value)) ?? "loading";
|
|
1783
|
-
}), U = r(() => B.value ? I(B.value, V.value) : null), W = r(() => U.value ? N(U.value, u.mediaSource ?? "preview") : null), ee = r(() => H.value === "ready" && !!(W.value &&
|
|
1822
|
+
}), U = r(() => B.value ? I(B.value, V.value) : null), W = r(() => U.value ? N(U.value, u.mediaSource ?? "preview") : null), ee = r(() => H.value === "ready" && !!(W.value && rt(W.value.type, W.value.src))), G = r(() => [
|
|
1784
1823
|
z.value,
|
|
1785
1824
|
V.value,
|
|
1786
1825
|
u.items.length,
|
|
@@ -1831,7 +1870,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1831
1870
|
Date.now() >= l && !u.loadMoreLocked && e && re(e) && d("loadMore");
|
|
1832
1871
|
}
|
|
1833
1872
|
O(() => u.items.length, (e, t) => {
|
|
1834
|
-
e > 0 && e < t && (l = Date.now() +
|
|
1873
|
+
e > 0 && e < t && (l = Date.now() + Jt);
|
|
1835
1874
|
});
|
|
1836
1875
|
function Y(e) {
|
|
1837
1876
|
let t = B.value;
|
|
@@ -1856,7 +1895,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1856
1895
|
let t = f.value;
|
|
1857
1896
|
if (!t) return Promise.resolve();
|
|
1858
1897
|
let n = e * (k || t.clientHeight);
|
|
1859
|
-
return x.value = e,
|
|
1898
|
+
return x.value = e, Vt(t, n, pe());
|
|
1860
1899
|
}
|
|
1861
1900
|
function he(e) {
|
|
1862
1901
|
me(e);
|
|
@@ -1866,7 +1905,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1866
1905
|
return t < 0 || t === x.value ? !1 : (await me(t), !0);
|
|
1867
1906
|
}
|
|
1868
1907
|
async function _e(e) {
|
|
1869
|
-
return Y(e) ? (pe() || await new Promise((e) => setTimeout(e,
|
|
1908
|
+
return Y(e) ? (pe() || await new Promise((e) => setTimeout(e, qt)), !0) : !1;
|
|
1870
1909
|
}
|
|
1871
1910
|
function ve() {
|
|
1872
1911
|
if (!u.reelAutoAdvance.enabled) return;
|
|
@@ -1935,7 +1974,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1935
1974
|
"style",
|
|
1936
1975
|
"total"
|
|
1937
1976
|
])) : o("", !0),
|
|
1938
|
-
c("div",
|
|
1977
|
+
c("div", Wt, [c("div", {
|
|
1939
1978
|
ref_key: "galleryElement",
|
|
1940
1979
|
ref: f,
|
|
1941
1980
|
class: "gallery-shell reel-feed",
|
|
@@ -1947,7 +1986,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
1947
1986
|
class: "reel-track",
|
|
1948
1987
|
style: _(F.value),
|
|
1949
1988
|
"aria-label": "Media gallery"
|
|
1950
|
-
}, [(b(!0), s(e, null, S(R.value, ({ fetchPriority: e, item: n, index: i }) => (b(), a(
|
|
1989
|
+
}, [(b(!0), s(e, null, S(R.value, ({ fetchPriority: e, item: n, index: i }) => (b(), a(Mt, {
|
|
1951
1990
|
key: n.postId,
|
|
1952
1991
|
active: i === x.value && !C.value,
|
|
1953
1992
|
"advance-on-media-end": u.reelAutoAdvance.enabled && i === x.value,
|
|
@@ -2001,7 +2040,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2001
2040
|
class: "reel-forward-retry",
|
|
2002
2041
|
type: "button",
|
|
2003
2042
|
onClick: r[0] ||= (e) => d("retryForward")
|
|
2004
|
-
}, " Retry ")) : o("", !0)], 8,
|
|
2043
|
+
}, " Retry ")) : o("", !0)], 8, Kt)), t.reelForward.status === "idle" ? (b(), a(te, {
|
|
2005
2044
|
key: 2,
|
|
2006
2045
|
actions: t.feedFooterActions,
|
|
2007
2046
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2024,7 +2063,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2024
2063
|
"load-more-locked",
|
|
2025
2064
|
"show-load-more",
|
|
2026
2065
|
"state"
|
|
2027
|
-
])) : o("", !0)], 40,
|
|
2066
|
+
])) : o("", !0)], 40, Gt), c("div", {
|
|
2028
2067
|
ref_key: "reelControlsElement",
|
|
2029
2068
|
ref: p,
|
|
2030
2069
|
class: "reel-media-controls-host",
|
|
@@ -2052,7 +2091,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2052
2091
|
"style",
|
|
2053
2092
|
"total"
|
|
2054
2093
|
])) : o("", !0),
|
|
2055
|
-
ne.value ? (b(), a(
|
|
2094
|
+
ne.value ? (b(), a(Ut, {
|
|
2056
2095
|
key: G.value,
|
|
2057
2096
|
"duration-ms": t.reelAutoAdvance.intervalMs,
|
|
2058
2097
|
label: K.value,
|
|
@@ -2060,16 +2099,16 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2060
2099
|
}, null, 8, ["duration-ms", "label"])) : o("", !0)
|
|
2061
2100
|
], 2));
|
|
2062
2101
|
}
|
|
2063
|
-
}),
|
|
2102
|
+
}), Xt = ["data-info-sheet-open", "data-info-sheet-mode"], Zt = ["aria-hidden", "inert"], Qt = {
|
|
2064
2103
|
key: 0,
|
|
2065
2104
|
class: "reel-info-sheet-layer",
|
|
2066
2105
|
"data-test": "reel-info-sheet"
|
|
2067
|
-
},
|
|
2106
|
+
}, $t = [
|
|
2068
2107
|
"role",
|
|
2069
2108
|
"aria-modal",
|
|
2070
2109
|
"tabindex",
|
|
2071
2110
|
"data-active-post-id"
|
|
2072
|
-
],
|
|
2111
|
+
], en = /* @__PURE__ */ d({
|
|
2073
2112
|
__name: "ReelLayout",
|
|
2074
2113
|
props: {
|
|
2075
2114
|
forwardIndex: { default: null },
|
|
@@ -2196,7 +2235,7 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2196
2235
|
class: "reel-layout-main",
|
|
2197
2236
|
"aria-hidden": e.infoSheetOverlay && A.value || void 0,
|
|
2198
2237
|
inert: e.infoSheetOverlay && A.value || void 0
|
|
2199
|
-
}, [u(
|
|
2238
|
+
}, [u(Yt, {
|
|
2200
2239
|
ref_key: "reelFeed",
|
|
2201
2240
|
ref: p,
|
|
2202
2241
|
"can-retry-end": e.canRetryEnd,
|
|
@@ -2250,8 +2289,8 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2250
2289
|
"reel-forward",
|
|
2251
2290
|
"state",
|
|
2252
2291
|
"total"
|
|
2253
|
-
])], 8,
|
|
2254
|
-
default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div",
|
|
2292
|
+
])], 8, Zt), u(n, { name: "vibe-info-sheet" }, {
|
|
2293
|
+
default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", Qt, [c("aside", {
|
|
2255
2294
|
ref_key: "sheetElement",
|
|
2256
2295
|
ref: _,
|
|
2257
2296
|
class: "reel-info-sheet",
|
|
@@ -2260,14 +2299,14 @@ var Bt = ["aria-label"], Vt = /* @__PURE__ */ d({
|
|
|
2260
2299
|
"aria-modal": e.infoSheetOverlay ? "true" : void 0,
|
|
2261
2300
|
tabindex: e.infoSheetOverlay ? -1 : void 0,
|
|
2262
2301
|
"data-active-post-id": T.value?.postId
|
|
2263
|
-
}, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8,
|
|
2302
|
+
}, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, $t)])) : o("", !0)]),
|
|
2264
2303
|
_: 1
|
|
2265
|
-
})], 10,
|
|
2304
|
+
})], 10, Xt));
|
|
2266
2305
|
}
|
|
2267
2306
|
});
|
|
2268
2307
|
//#endregion
|
|
2269
2308
|
//#region src/core/mediaLifecycle.ts
|
|
2270
|
-
function
|
|
2309
|
+
function tn(e, t, n, r, i) {
|
|
2271
2310
|
let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
|
|
2272
2311
|
if (!o) return null;
|
|
2273
2312
|
let s = F(o, n), c = I(o, s);
|
|
@@ -2283,7 +2322,7 @@ function $t(e, t, n, r, i) {
|
|
|
2283
2322
|
postIndex: a
|
|
2284
2323
|
};
|
|
2285
2324
|
}
|
|
2286
|
-
function
|
|
2325
|
+
function nn(e, t) {
|
|
2287
2326
|
O(() => {
|
|
2288
2327
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
|
|
2289
2328
|
return {
|
|
@@ -2293,20 +2332,20 @@ function en(e, t) {
|
|
|
2293
2332
|
};
|
|
2294
2333
|
}, (n, r) => {
|
|
2295
2334
|
if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
|
|
2296
|
-
let i =
|
|
2335
|
+
let i = tn(e, n.postId, n.mediaIndex, "reel", n.origin);
|
|
2297
2336
|
i && t(i);
|
|
2298
2337
|
}, { flush: "sync" });
|
|
2299
2338
|
}
|
|
2300
2339
|
//#endregion
|
|
2301
2340
|
//#region src/components/useMediaLifecycle.ts
|
|
2302
|
-
function
|
|
2341
|
+
function rn(e, t) {
|
|
2303
2342
|
let n = w(/* @__PURE__ */ new Map()), i = w(/* @__PURE__ */ new Map()), a = w(/* @__PURE__ */ new Map()), o = () => e.reelMediaSource === "preview" ? n : e.reelMediaSource === "mobile" ? a : i, s = r(() => o().value);
|
|
2304
2343
|
function c(e, t, n, r) {
|
|
2305
2344
|
let i = L(t, n);
|
|
2306
2345
|
e.value.get(i) !== r && (e.value = new Map(e.value).set(i, r));
|
|
2307
2346
|
}
|
|
2308
2347
|
function l(t, n, r, i) {
|
|
2309
|
-
return
|
|
2348
|
+
return tn(e, t, n, r, i);
|
|
2310
2349
|
}
|
|
2311
2350
|
function u(e, n, r, i) {
|
|
2312
2351
|
let a = l(e, n, r, i);
|
|
@@ -2328,7 +2367,7 @@ function tn(e, t) {
|
|
|
2328
2367
|
let r = l(e, n, "masonry", null);
|
|
2329
2368
|
r && t.visible(r);
|
|
2330
2369
|
}
|
|
2331
|
-
return
|
|
2370
|
+
return nn(e, t.reelChange), O(() => {
|
|
2332
2371
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null, n = t === null ? 0 : e.mediaIndices.get(t) ?? 0;
|
|
2333
2372
|
return {
|
|
2334
2373
|
mediaIndex: n,
|
|
@@ -2353,16 +2392,16 @@ function tn(e, t) {
|
|
|
2353
2392
|
}
|
|
2354
2393
|
//#endregion
|
|
2355
2394
|
//#region src/core/reelEscapeStack.ts
|
|
2356
|
-
var
|
|
2357
|
-
function
|
|
2358
|
-
return
|
|
2359
|
-
let t =
|
|
2360
|
-
t >= 0 &&
|
|
2395
|
+
var an = [];
|
|
2396
|
+
function on(e) {
|
|
2397
|
+
return an.push(e), () => {
|
|
2398
|
+
let t = an.indexOf(e);
|
|
2399
|
+
t >= 0 && an.splice(t, 1);
|
|
2361
2400
|
};
|
|
2362
2401
|
}
|
|
2363
|
-
function
|
|
2402
|
+
function sn(e) {
|
|
2364
2403
|
if (!e.isActive()) return !1;
|
|
2365
|
-
let t =
|
|
2404
|
+
let t = an.filter((e) => e.isActive()), n = e.element();
|
|
2366
2405
|
return n !== null && t.some((t) => {
|
|
2367
2406
|
if (t === e) return !1;
|
|
2368
2407
|
let r = t.element();
|
|
@@ -2378,14 +2417,14 @@ function an(e) {
|
|
|
2378
2417
|
}
|
|
2379
2418
|
//#endregion
|
|
2380
2419
|
//#region src/components/useReelKeyboard.ts
|
|
2381
|
-
function
|
|
2420
|
+
function cn(e) {
|
|
2382
2421
|
let t = {
|
|
2383
2422
|
element: e.element,
|
|
2384
2423
|
isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
|
|
2385
2424
|
}, n = null;
|
|
2386
2425
|
function r(n) {
|
|
2387
2426
|
let r = t.isActive();
|
|
2388
|
-
if (n.key === "Escape" && r && !
|
|
2427
|
+
if (n.key === "Escape" && r && !sn(t)) return;
|
|
2389
2428
|
if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
|
|
2390
2429
|
n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
|
|
2391
2430
|
return;
|
|
@@ -2405,14 +2444,14 @@ function on(e) {
|
|
|
2405
2444
|
a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
|
|
2406
2445
|
}
|
|
2407
2446
|
y(() => {
|
|
2408
|
-
n =
|
|
2447
|
+
n = on(t), window.addEventListener("keydown", r);
|
|
2409
2448
|
}), v(() => {
|
|
2410
2449
|
window.removeEventListener("keydown", r), n?.(), n = null;
|
|
2411
2450
|
});
|
|
2412
2451
|
}
|
|
2413
2452
|
//#endregion
|
|
2414
2453
|
//#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
|
|
2415
|
-
var
|
|
2454
|
+
var ln = 35, un = 420, dn = /* @__PURE__ */ d({
|
|
2416
2455
|
__name: "VibeSurface",
|
|
2417
2456
|
props: {
|
|
2418
2457
|
canRetryEnd: { type: Boolean },
|
|
@@ -2440,7 +2479,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2440
2479
|
"retryForward"
|
|
2441
2480
|
],
|
|
2442
2481
|
setup(t, { expose: i, emit: c }) {
|
|
2443
|
-
let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), _ = w(!1), y = w(/* @__PURE__ */ new Set()), x = w(/* @__PURE__ */ new Map()), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = r(() => Object.freeze([...l.state.items])), D = r(() => z(l.state, T.value)), { markMasonryVisible: A, markPreviewError: j, markPreviewReady: M, markReelError: N, markReelReady: I, originalStates: L, previewStates: R, reelStates: B } =
|
|
2482
|
+
let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), _ = w(!1), y = w(/* @__PURE__ */ new Set()), x = w(/* @__PURE__ */ new Map()), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = r(() => Object.freeze([...l.state.items])), D = r(() => z(l.state, T.value)), { markMasonryVisible: A, markPreviewError: j, markPreviewReady: M, markReelError: N, markReelReady: I, originalStates: L, previewStates: R, reelStates: B } = rn(l.state, {
|
|
2444
2483
|
ready: (e) => d("mediaReady", e),
|
|
2445
2484
|
reelChange: (e) => d("reelMediaChange", e),
|
|
2446
2485
|
visible: (e) => d("mediaVisible", e)
|
|
@@ -2491,10 +2530,10 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2491
2530
|
if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || ee()) return 0;
|
|
2492
2531
|
let n = [...new Set(e)], r = n.filter(se);
|
|
2493
2532
|
if (r.length === 0) return 0;
|
|
2494
|
-
let i = new Map(C.value), a = t?.staggerMs ??
|
|
2533
|
+
let i = new Map(C.value), a = t?.staggerMs ?? ln;
|
|
2495
2534
|
return r.forEach((e, t) => {
|
|
2496
2535
|
i.set(e, t * a);
|
|
2497
|
-
}), y.value = new Set([...y.value].filter((e) => !r.includes(e))), S.value = new Set([...S.value, ...n]), C.value = i,
|
|
2536
|
+
}), y.value = new Set([...y.value].filter((e) => !r.includes(e))), S.value = new Set([...S.value, ...n]), C.value = i, un + (r.length - 1) * a;
|
|
2498
2537
|
}
|
|
2499
2538
|
function ce(e, t) {
|
|
2500
2539
|
let n = se(e), r = n?.querySelector(".media-card-activator") ?? n;
|
|
@@ -2511,7 +2550,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2511
2550
|
e !== null && ce(e, t);
|
|
2512
2551
|
});
|
|
2513
2552
|
}
|
|
2514
|
-
return
|
|
2553
|
+
return cn({
|
|
2515
2554
|
closeMasonryReel: le,
|
|
2516
2555
|
element: () => g.value,
|
|
2517
2556
|
isReelLeaving: () => _.value,
|
|
@@ -2526,7 +2565,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2526
2565
|
let t = x.value.get(e);
|
|
2527
2566
|
t !== void 0 && r.set(e, t);
|
|
2528
2567
|
}), t.forEach((e, t) => {
|
|
2529
|
-
r.set(e, t *
|
|
2568
|
+
r.set(e, t * ln);
|
|
2530
2569
|
}), x.value = r, y.value = new Set([...y.value, ...t]), te();
|
|
2531
2570
|
}, { flush: "sync" }), v(() => {
|
|
2532
2571
|
H !== null && cancelAnimationFrame(H);
|
|
@@ -2543,7 +2582,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2543
2582
|
ref_key: "surfaceElement",
|
|
2544
2583
|
ref: g,
|
|
2545
2584
|
class: "vibe-surface"
|
|
2546
|
-
}, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(
|
|
2585
|
+
}, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(en, {
|
|
2547
2586
|
key: 0,
|
|
2548
2587
|
ref_key: "reelRenderer",
|
|
2549
2588
|
ref: p,
|
|
@@ -2596,7 +2635,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2596
2635
|
"can-retry-end",
|
|
2597
2636
|
"feed-footer",
|
|
2598
2637
|
"state"
|
|
2599
|
-
])) : (b(), s(e, { key: 2 }, [u(
|
|
2638
|
+
])) : (b(), s(e, { key: 2 }, [u(zt, {
|
|
2600
2639
|
ref_key: "masonryRenderer",
|
|
2601
2640
|
ref: f,
|
|
2602
2641
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2667,7 +2706,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2667
2706
|
"aria-label": "Media viewer",
|
|
2668
2707
|
"aria-modal": "true",
|
|
2669
2708
|
tabindex: "-1"
|
|
2670
|
-
}, [u(
|
|
2709
|
+
}, [u(en, {
|
|
2671
2710
|
ref_key: "reelRenderer",
|
|
2672
2711
|
ref: p,
|
|
2673
2712
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2713,7 +2752,7 @@ var sn = 35, cn = 420, ln = /* @__PURE__ */ d({
|
|
|
2713
2752
|
});
|
|
2714
2753
|
//#endregion
|
|
2715
2754
|
//#region src/core/page.ts
|
|
2716
|
-
function
|
|
2755
|
+
function fn(e) {
|
|
2717
2756
|
if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
|
|
2718
2757
|
if (e.current !== void 0 && e.current !== null && typeof e.current != "string" && typeof e.current != "number") throw TypeError("Vibe page current must be a string, number, null, or undefined.");
|
|
2719
2758
|
if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
|
|
@@ -2724,22 +2763,22 @@ function Z(e, t) {
|
|
|
2724
2763
|
let n = new Set(e.map((e) => e.postId));
|
|
2725
2764
|
return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
|
|
2726
2765
|
}
|
|
2727
|
-
function
|
|
2766
|
+
function pn(e) {
|
|
2728
2767
|
return `${typeof e}:${String(e)}`;
|
|
2729
2768
|
}
|
|
2730
|
-
function
|
|
2731
|
-
return e.mediaId === void 0 ? `source:${e.src}\u0000${e.preview.src}` : `id:${
|
|
2769
|
+
function mn(e) {
|
|
2770
|
+
return e.mediaId === void 0 ? `source:${e.src}\u0000${e.preview.src}` : `id:${pn(e.mediaId)}`;
|
|
2732
2771
|
}
|
|
2733
|
-
function
|
|
2734
|
-
let n = [...e], r = new Map(e.map((e, t) => [
|
|
2772
|
+
function hn(e, t) {
|
|
2773
|
+
let n = [...e], r = new Map(e.map((e, t) => [pn(e.postId), t]));
|
|
2735
2774
|
return t.forEach((e) => {
|
|
2736
|
-
let t =
|
|
2775
|
+
let t = pn(e.postId), i = r.get(t);
|
|
2737
2776
|
if (i === void 0) {
|
|
2738
2777
|
r.set(t, n.length), n.push(e);
|
|
2739
2778
|
return;
|
|
2740
2779
|
}
|
|
2741
|
-
let a = n[i], o = new Set([a, ...a.items].map(
|
|
2742
|
-
let t =
|
|
2780
|
+
let a = n[i], o = new Set([a, ...a.items].map(mn)), s = [e, ...e.items].filter((e) => {
|
|
2781
|
+
let t = mn(e);
|
|
2743
2782
|
return o.has(t) ? !1 : (o.add(t), !0);
|
|
2744
2783
|
});
|
|
2745
2784
|
s.length > 0 && (n[i] = {
|
|
@@ -2748,14 +2787,14 @@ function pn(e, t) {
|
|
|
2748
2787
|
});
|
|
2749
2788
|
}), n;
|
|
2750
2789
|
}
|
|
2751
|
-
function
|
|
2790
|
+
function gn(e) {
|
|
2752
2791
|
return Object.prototype.hasOwnProperty.call(e, "current") ? e.current ?? null : e.next;
|
|
2753
2792
|
}
|
|
2754
2793
|
//#endregion
|
|
2755
2794
|
//#region src/core/appendPage.ts
|
|
2756
|
-
function
|
|
2757
|
-
let i =
|
|
2758
|
-
t.items =
|
|
2795
|
+
function _n(e, t, n, r) {
|
|
2796
|
+
let i = fn(e), a = n.filterItems(i.items), o = gn(i);
|
|
2797
|
+
t.items = hn(t.items, a), t.next = i.next, i.total !== void 0 && (t.total = i.total), r(o), n.recordPages([{
|
|
2759
2798
|
contributionIds: a.map(({ postId: e }) => e),
|
|
2760
2799
|
cursor: o,
|
|
2761
2800
|
next: i.next,
|
|
@@ -2764,32 +2803,32 @@ function hn(e, t, n, r) {
|
|
|
2764
2803
|
}
|
|
2765
2804
|
//#endregion
|
|
2766
2805
|
//#region src/core/requestDelay.ts
|
|
2767
|
-
var
|
|
2806
|
+
var vn = 2e3, yn = 1e4, bn = 250, xn = {
|
|
2768
2807
|
delayRemainingMs: null,
|
|
2769
2808
|
nextRequestAt: null
|
|
2770
2809
|
};
|
|
2771
|
-
function
|
|
2810
|
+
function Sn(e, t) {
|
|
2772
2811
|
return e === void 0 ? t : Math.floor(e);
|
|
2773
2812
|
}
|
|
2774
|
-
function
|
|
2813
|
+
function Cn(e, t) {
|
|
2775
2814
|
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.`);
|
|
2776
2815
|
}
|
|
2777
|
-
function
|
|
2778
|
-
let n =
|
|
2816
|
+
function wn(e, t = {}) {
|
|
2817
|
+
let n = Sn(t.delayStepMs, vn), r = Sn(t.delayMaxMs, yn);
|
|
2779
2818
|
return Math.min(Math.max(0, e) * n, r);
|
|
2780
2819
|
}
|
|
2781
2820
|
function Q(e) {
|
|
2782
|
-
if (e == null || !Number.isFinite(e)) return { ...
|
|
2821
|
+
if (e == null || !Number.isFinite(e)) return { ...xn };
|
|
2783
2822
|
let t = Math.max(0, Math.floor(e - Date.now()));
|
|
2784
2823
|
return t > 0 ? {
|
|
2785
2824
|
delayRemainingMs: t,
|
|
2786
2825
|
nextRequestAt: e
|
|
2787
|
-
} : { ...
|
|
2826
|
+
} : { ...xn };
|
|
2788
2827
|
}
|
|
2789
|
-
async function
|
|
2828
|
+
async function Tn({ delayMs: e, onChange: t, signal: n }) {
|
|
2790
2829
|
if (n.aborted) throw new DOMException("Aborted", "AbortError");
|
|
2791
2830
|
if (e <= 0) {
|
|
2792
|
-
t({ ...
|
|
2831
|
+
t({ ...xn });
|
|
2793
2832
|
return;
|
|
2794
2833
|
}
|
|
2795
2834
|
let r = Date.now() + e;
|
|
@@ -2797,9 +2836,9 @@ async function Cn({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2797
2836
|
delayRemainingMs: e,
|
|
2798
2837
|
nextRequestAt: r
|
|
2799
2838
|
}), await new Promise((i, a) => {
|
|
2800
|
-
let o = !1, s = setInterval(f,
|
|
2839
|
+
let o = !1, s = setInterval(f, bn), c = setTimeout(() => u(), e);
|
|
2801
2840
|
function l() {
|
|
2802
|
-
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...
|
|
2841
|
+
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...xn });
|
|
2803
2842
|
}
|
|
2804
2843
|
function u(e) {
|
|
2805
2844
|
o || (o = !0, l(), e ? a(e) : i());
|
|
@@ -2814,13 +2853,13 @@ async function Cn({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2814
2853
|
n.addEventListener("abort", d, { once: !0 });
|
|
2815
2854
|
});
|
|
2816
2855
|
}
|
|
2817
|
-
var
|
|
2856
|
+
var En = class {
|
|
2818
2857
|
interval = null;
|
|
2819
2858
|
constructor(e) {
|
|
2820
2859
|
this.onChange = e;
|
|
2821
2860
|
}
|
|
2822
2861
|
clear() {
|
|
2823
|
-
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...
|
|
2862
|
+
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...xn });
|
|
2824
2863
|
}
|
|
2825
2864
|
sync(e) {
|
|
2826
2865
|
this.clear();
|
|
@@ -2828,22 +2867,22 @@ var wn = class {
|
|
|
2828
2867
|
this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
|
|
2829
2868
|
let t = Q(e);
|
|
2830
2869
|
this.onChange(t), t.delayRemainingMs === null && this.clear();
|
|
2831
|
-
},
|
|
2870
|
+
}, bn));
|
|
2832
2871
|
}
|
|
2833
2872
|
};
|
|
2834
|
-
function
|
|
2873
|
+
function Dn(e, t = !0) {
|
|
2835
2874
|
return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
|
|
2836
2875
|
}
|
|
2837
|
-
function
|
|
2876
|
+
function On(e) {
|
|
2838
2877
|
return `${typeof e}:${String(e)}`;
|
|
2839
2878
|
}
|
|
2840
|
-
function
|
|
2879
|
+
function kn(e, t) {
|
|
2841
2880
|
if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
|
|
2842
2881
|
}
|
|
2843
|
-
function
|
|
2882
|
+
function An(e) {
|
|
2844
2883
|
if (!e) return;
|
|
2845
|
-
if (
|
|
2846
|
-
|
|
2884
|
+
if (kn(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
|
|
2885
|
+
Cn(e, "frontend autofill");
|
|
2847
2886
|
let t = e.maxAdditionalPages;
|
|
2848
2887
|
if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
|
|
2849
2888
|
return;
|
|
@@ -2855,7 +2894,7 @@ function On(e) {
|
|
|
2855
2894
|
if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
|
|
2856
2895
|
}
|
|
2857
2896
|
}
|
|
2858
|
-
function
|
|
2897
|
+
function jn(e, t, n = !0) {
|
|
2859
2898
|
if (!e) return {
|
|
2860
2899
|
cycleId: null,
|
|
2861
2900
|
delayRemainingMs: null,
|
|
@@ -2889,7 +2928,7 @@ function kn(e, t, n = !0) {
|
|
|
2889
2928
|
strategy: e.strategy
|
|
2890
2929
|
};
|
|
2891
2930
|
}
|
|
2892
|
-
function
|
|
2931
|
+
function Mn(e) {
|
|
2893
2932
|
return [
|
|
2894
2933
|
"cancelling",
|
|
2895
2934
|
"filling",
|
|
@@ -2897,9 +2936,9 @@ function An(e) {
|
|
|
2897
2936
|
"waiting"
|
|
2898
2937
|
].includes(e.status);
|
|
2899
2938
|
}
|
|
2900
|
-
async function
|
|
2939
|
+
async function Nn(e, t, n) {
|
|
2901
2940
|
let r = t.autofill;
|
|
2902
|
-
if (!
|
|
2941
|
+
if (!Mn(r) || !r.cycleId) return;
|
|
2903
2942
|
let i = {
|
|
2904
2943
|
cycleId: r.cycleId,
|
|
2905
2944
|
feedKey: r.feedKey ?? "",
|
|
@@ -2912,16 +2951,16 @@ async function jn(e, t, n) {
|
|
|
2912
2951
|
throw r.error = e, r.status = "error", e;
|
|
2913
2952
|
}
|
|
2914
2953
|
}
|
|
2915
|
-
function
|
|
2954
|
+
function Pn(e, t, n) {
|
|
2916
2955
|
return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
|
|
2917
2956
|
}
|
|
2918
|
-
async function
|
|
2919
|
-
let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ??
|
|
2957
|
+
async function Fn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, shouldPause: u = () => !1, signal: d }) {
|
|
2958
|
+
let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? Dn(s), g = t, _ = t, v = t, y = 0, b = [], x;
|
|
2920
2959
|
for (; y < h;) {
|
|
2921
|
-
let e =
|
|
2960
|
+
let e = On(g);
|
|
2922
2961
|
if (m.has(e)) throw Error("Vibe autofill received a repeated cursor.");
|
|
2923
|
-
if (m.add(e), await
|
|
2924
|
-
delayMs:
|
|
2962
|
+
if (m.add(e), await Tn({
|
|
2963
|
+
delayMs: wn(l + y, s),
|
|
2925
2964
|
onChange: a,
|
|
2926
2965
|
signal: d
|
|
2927
2966
|
}), y > 0 && u()) return {
|
|
@@ -2935,7 +2974,7 @@ async function Nn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2935
2974
|
status: "paused",
|
|
2936
2975
|
total: x
|
|
2937
2976
|
};
|
|
2938
|
-
let t =
|
|
2977
|
+
let t = fn(await n({
|
|
2939
2978
|
cursor: g,
|
|
2940
2979
|
signal: d
|
|
2941
2980
|
}));
|
|
@@ -2992,12 +3031,12 @@ async function Nn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2992
3031
|
}
|
|
2993
3032
|
//#endregion
|
|
2994
3033
|
//#region src/core/autofillController.ts
|
|
2995
|
-
var
|
|
3034
|
+
var In = class {
|
|
2996
3035
|
collection = null;
|
|
2997
3036
|
cycle = 0;
|
|
2998
3037
|
delayCountdown;
|
|
2999
3038
|
constructor(e) {
|
|
3000
|
-
this.context = e, this.delayCountdown = new
|
|
3039
|
+
this.context = e, this.delayCountdown = new En((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
|
|
3001
3040
|
}
|
|
3002
3041
|
beginCycle() {
|
|
3003
3042
|
let { options: e, state: t } = this.context;
|
|
@@ -3005,14 +3044,14 @@ var Pn = class {
|
|
|
3005
3044
|
this.clear();
|
|
3006
3045
|
let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
3007
3046
|
return t.autofill = {
|
|
3008
|
-
...
|
|
3047
|
+
...jn(e, void 0, !1),
|
|
3009
3048
|
cycleId: n,
|
|
3010
3049
|
status: "filling"
|
|
3011
3050
|
}, n;
|
|
3012
3051
|
}
|
|
3013
3052
|
async cancel() {
|
|
3014
3053
|
let { cancelRequest: e, options: t, state: n } = this.context;
|
|
3015
|
-
await
|
|
3054
|
+
await Nn(t, n, e), this.commitCollection();
|
|
3016
3055
|
}
|
|
3017
3056
|
captureCollection(e, t) {
|
|
3018
3057
|
t && (this.collection = e);
|
|
@@ -3040,30 +3079,30 @@ var Pn = class {
|
|
|
3040
3079
|
requests: r.requests
|
|
3041
3080
|
}), !0) : !1;
|
|
3042
3081
|
}
|
|
3043
|
-
},
|
|
3044
|
-
function
|
|
3082
|
+
}, Ln = 100;
|
|
3083
|
+
function Rn(e, t) {
|
|
3045
3084
|
if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
|
|
3046
3085
|
}
|
|
3047
|
-
function
|
|
3086
|
+
function zn(e, t, n) {
|
|
3048
3087
|
return Math.min(n, Math.max(t, e));
|
|
3049
3088
|
}
|
|
3050
|
-
function
|
|
3089
|
+
function Bn(e) {
|
|
3051
3090
|
if (!e) return;
|
|
3052
3091
|
let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
|
|
3053
|
-
if (
|
|
3054
|
-
e.speedPxPerSecond !== void 0 &&
|
|
3092
|
+
if (Rn("autoScroll.minSpeedPxPerSecond", t), Rn("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
|
|
3093
|
+
e.speedPxPerSecond !== void 0 && Rn("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
|
|
3055
3094
|
}
|
|
3056
|
-
function
|
|
3095
|
+
function Vn(e) {
|
|
3057
3096
|
let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
|
|
3058
3097
|
return {
|
|
3059
3098
|
enabled: e?.enabled ?? !1,
|
|
3060
3099
|
maxSpeedPxPerSecond: n,
|
|
3061
3100
|
minSpeedPxPerSecond: t,
|
|
3062
3101
|
paused: !1,
|
|
3063
|
-
speedPxPerSecond:
|
|
3102
|
+
speedPxPerSecond: zn(e?.speedPxPerSecond ?? 80, t, n)
|
|
3064
3103
|
};
|
|
3065
3104
|
}
|
|
3066
|
-
var
|
|
3105
|
+
var Hn = class {
|
|
3067
3106
|
frame = null;
|
|
3068
3107
|
lastTimestamp = null;
|
|
3069
3108
|
mounted = !1;
|
|
@@ -3083,9 +3122,9 @@ var Bn = class {
|
|
|
3083
3122
|
this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
|
|
3084
3123
|
}
|
|
3085
3124
|
setSpeed(e) {
|
|
3086
|
-
|
|
3125
|
+
Rn("auto-scroll speed", e);
|
|
3087
3126
|
let t = this.options.state;
|
|
3088
|
-
t.speedPxPerSecond =
|
|
3127
|
+
t.speedPxPerSecond = zn(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
|
|
3089
3128
|
}
|
|
3090
3129
|
tick = (e) => {
|
|
3091
3130
|
this.frame = null;
|
|
@@ -3097,7 +3136,7 @@ var Bn = class {
|
|
|
3097
3136
|
return;
|
|
3098
3137
|
}
|
|
3099
3138
|
if (this.lastTimestamp !== null) {
|
|
3100
|
-
let r = Math.min(
|
|
3139
|
+
let r = Math.min(Ln, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
|
|
3101
3140
|
n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
|
|
3102
3141
|
}
|
|
3103
3142
|
this.lastTimestamp = e, this.schedule();
|
|
@@ -3111,7 +3150,7 @@ var Bn = class {
|
|
|
3111
3150
|
};
|
|
3112
3151
|
//#endregion
|
|
3113
3152
|
//#region src/core/backendAutofill.ts
|
|
3114
|
-
async function
|
|
3153
|
+
async function Un(e, t, n, r) {
|
|
3115
3154
|
let i = await e.onUnderfilled(n);
|
|
3116
3155
|
if (!r()) return;
|
|
3117
3156
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
|
|
@@ -3125,19 +3164,19 @@ async function Vn(e, t, n, r) {
|
|
|
3125
3164
|
status: "waiting"
|
|
3126
3165
|
});
|
|
3127
3166
|
}
|
|
3128
|
-
function
|
|
3167
|
+
function Wn(e, t) {
|
|
3129
3168
|
["complete", "exhausted"].includes(t.status) && t.items && (e.items = Z(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
|
|
3130
3169
|
}
|
|
3131
|
-
function
|
|
3170
|
+
function Gn(e, t, n) {
|
|
3132
3171
|
let r = t.autofill;
|
|
3133
|
-
return !
|
|
3172
|
+
return !Pn(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Wn(t, n), Object.assign(r, Q(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);
|
|
3134
3173
|
}
|
|
3135
|
-
function
|
|
3136
|
-
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill =
|
|
3174
|
+
function Kn(e, t, n) {
|
|
3175
|
+
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = jn(e, n), Wn(t, n), !0);
|
|
3137
3176
|
}
|
|
3138
3177
|
//#endregion
|
|
3139
3178
|
//#region src/core/backlogRestore.ts
|
|
3140
|
-
async function
|
|
3179
|
+
async function qn(e, t, n) {
|
|
3141
3180
|
if (!e) return;
|
|
3142
3181
|
let r = new AbortController();
|
|
3143
3182
|
n(r);
|
|
@@ -3152,7 +3191,7 @@ async function Gn(e, t, n) {
|
|
|
3152
3191
|
}
|
|
3153
3192
|
//#endregion
|
|
3154
3193
|
//#region src/core/initialAutofill.ts
|
|
3155
|
-
async function
|
|
3194
|
+
async function Jn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
|
|
3156
3195
|
let c = a.autofill;
|
|
3157
3196
|
if (!c) return;
|
|
3158
3197
|
let l = s.items.length;
|
|
@@ -3165,7 +3204,7 @@ async function Kn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3165
3204
|
return;
|
|
3166
3205
|
}
|
|
3167
3206
|
if (c.strategy === "backend") {
|
|
3168
|
-
await
|
|
3207
|
+
await Un(c, s, {
|
|
3169
3208
|
cycleId: e,
|
|
3170
3209
|
feedKey: c.feedKey,
|
|
3171
3210
|
items: [...s.items],
|
|
@@ -3182,11 +3221,11 @@ async function Kn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3182
3221
|
s.autofill.status = "exhausted";
|
|
3183
3222
|
return;
|
|
3184
3223
|
}
|
|
3185
|
-
let u = await
|
|
3224
|
+
let u = await Fn({
|
|
3186
3225
|
existingItems: s.items,
|
|
3187
3226
|
initialCursor: s.next,
|
|
3188
3227
|
loadPage: a.loadPage,
|
|
3189
|
-
maximumRequests:
|
|
3228
|
+
maximumRequests: Dn(c, !1),
|
|
3190
3229
|
onCollection: n,
|
|
3191
3230
|
onDelayChange: (e) => {
|
|
3192
3231
|
t() && Object.assign(s.autofill, e);
|
|
@@ -3209,13 +3248,13 @@ async function Kn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3209
3248
|
}
|
|
3210
3249
|
//#endregion
|
|
3211
3250
|
//#region src/core/fill.ts
|
|
3212
|
-
function
|
|
3251
|
+
function Yn(e) {
|
|
3213
3252
|
return "items" in e ? { items: e.items } : "pages" in e ? { pages: e.pages } : { until: "end" };
|
|
3214
3253
|
}
|
|
3215
|
-
function
|
|
3254
|
+
function Xn(e) {
|
|
3216
3255
|
return `${typeof e}:${String(e)}`;
|
|
3217
3256
|
}
|
|
3218
|
-
function
|
|
3257
|
+
function Zn(e) {
|
|
3219
3258
|
if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
|
|
3220
3259
|
if ("pages" in e) {
|
|
3221
3260
|
if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
|
|
@@ -3228,20 +3267,20 @@ function Yn(e) {
|
|
|
3228
3267
|
if ("until" in e && e.until === "end") return { until: "end" };
|
|
3229
3268
|
throw TypeError("Vibe fill target must be { items }, { pages }, or { until: 'end' }.");
|
|
3230
3269
|
}
|
|
3231
|
-
function
|
|
3270
|
+
function Qn(e) {
|
|
3232
3271
|
if (!e) return;
|
|
3233
3272
|
if (e.strategy === "frontend") {
|
|
3234
|
-
|
|
3273
|
+
Cn(e, "frontend fill");
|
|
3235
3274
|
return;
|
|
3236
3275
|
}
|
|
3237
3276
|
if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
|
|
3238
3277
|
let t = e.initialSession;
|
|
3239
3278
|
if (t) {
|
|
3240
3279
|
if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
|
|
3241
|
-
|
|
3280
|
+
Zn(t.target);
|
|
3242
3281
|
}
|
|
3243
3282
|
}
|
|
3244
|
-
function
|
|
3283
|
+
function $n(e, t, n = !0) {
|
|
3245
3284
|
let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
|
|
3246
3285
|
return {
|
|
3247
3286
|
completedPages: i?.completedPages ?? 0,
|
|
@@ -3255,10 +3294,10 @@ function Zn(e, t, n = !0) {
|
|
|
3255
3294
|
sessionId: i?.sessionId ?? null,
|
|
3256
3295
|
status: i?.status ?? "idle",
|
|
3257
3296
|
strategy: e?.strategy ?? null,
|
|
3258
|
-
target: i ?
|
|
3297
|
+
target: i ? Yn(i.target) : null
|
|
3259
3298
|
};
|
|
3260
3299
|
}
|
|
3261
|
-
function
|
|
3300
|
+
function er(e) {
|
|
3262
3301
|
return [
|
|
3263
3302
|
"cancelling",
|
|
3264
3303
|
"filling",
|
|
@@ -3266,7 +3305,7 @@ function Qn(e) {
|
|
|
3266
3305
|
"waiting"
|
|
3267
3306
|
].includes(e.status);
|
|
3268
3307
|
}
|
|
3269
|
-
async function
|
|
3308
|
+
async function tr({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
|
|
3270
3309
|
let u = [], d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = 0, h = t, g = t, _ = t, v = 0, y;
|
|
3271
3310
|
if ("items" in l && f.length >= l.items) return {
|
|
3272
3311
|
completedPages: m,
|
|
@@ -3278,10 +3317,10 @@ async function $n({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3278
3317
|
status: "complete"
|
|
3279
3318
|
};
|
|
3280
3319
|
for (; _ !== null;) {
|
|
3281
|
-
let e =
|
|
3320
|
+
let e = Xn(h);
|
|
3282
3321
|
if (p.has(e)) throw Error("Vibe fill received a repeated cursor.");
|
|
3283
|
-
if (p.add(e), await
|
|
3284
|
-
delayMs:
|
|
3322
|
+
if (p.add(e), await Tn({
|
|
3323
|
+
delayMs: wn(m, o),
|
|
3285
3324
|
onChange: i,
|
|
3286
3325
|
signal: c
|
|
3287
3326
|
}), m > 0 && s()) return {
|
|
@@ -3294,7 +3333,7 @@ async function $n({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3294
3333
|
status: "paused",
|
|
3295
3334
|
total: y
|
|
3296
3335
|
};
|
|
3297
|
-
let t =
|
|
3336
|
+
let t = fn(await n({
|
|
3298
3337
|
cursor: h,
|
|
3299
3338
|
signal: c
|
|
3300
3339
|
}));
|
|
@@ -3362,7 +3401,7 @@ async function $n({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3362
3401
|
}
|
|
3363
3402
|
//#endregion
|
|
3364
3403
|
//#region src/core/backendFill.ts
|
|
3365
|
-
async function
|
|
3404
|
+
async function nr(e, t, n, r) {
|
|
3366
3405
|
let i = await e.onStart(n);
|
|
3367
3406
|
if (r()) {
|
|
3368
3407
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
|
|
@@ -3376,22 +3415,22 @@ async function er(e, t, n, r) {
|
|
|
3376
3415
|
});
|
|
3377
3416
|
}
|
|
3378
3417
|
}
|
|
3379
|
-
function
|
|
3418
|
+
function rr(e, t, n) {
|
|
3380
3419
|
return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
|
|
3381
3420
|
}
|
|
3382
|
-
function
|
|
3421
|
+
function ir(e) {
|
|
3383
3422
|
return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
|
|
3384
3423
|
}
|
|
3385
|
-
function
|
|
3424
|
+
function ar(e, t) {
|
|
3386
3425
|
if (!["complete", "exhausted"].includes(t.status)) return !0;
|
|
3387
3426
|
let n = e.fill.target;
|
|
3388
3427
|
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;
|
|
3389
3428
|
}
|
|
3390
|
-
function
|
|
3429
|
+
function or(e, t, n) {
|
|
3391
3430
|
t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Z(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
|
|
3392
3431
|
}
|
|
3393
|
-
function
|
|
3394
|
-
return !
|
|
3432
|
+
function sr(e, t, n, r) {
|
|
3433
|
+
return !rr(e, t, n) || !ir(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !ar(t, n) ? !1 : (or(t, n, r), Object.assign(t.fill, {
|
|
3395
3434
|
...Q(n.status === "waiting" ? n.nextRequestAt : null),
|
|
3396
3435
|
completedPages: n.completedPages,
|
|
3397
3436
|
error: n.error ?? null,
|
|
@@ -3400,45 +3439,45 @@ function ar(e, t, n, r) {
|
|
|
3400
3439
|
status: n.status
|
|
3401
3440
|
}), !0);
|
|
3402
3441
|
}
|
|
3403
|
-
function
|
|
3442
|
+
function cr(e, t, n, r) {
|
|
3404
3443
|
if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
|
|
3405
3444
|
let i = t.fill;
|
|
3406
|
-
return t.fill =
|
|
3445
|
+
return t.fill = $n(e, n), !ir(n) || !ar(t, n) ? (t.fill = i, !1) : (or(t, n, r), !0);
|
|
3407
3446
|
}
|
|
3408
3447
|
//#endregion
|
|
3409
3448
|
//#region src/core/fillController.ts
|
|
3410
|
-
var
|
|
3449
|
+
var lr = class {
|
|
3411
3450
|
abortController = null;
|
|
3412
3451
|
cycle = 0;
|
|
3413
3452
|
delayCountdown;
|
|
3414
3453
|
requestVersion = 0;
|
|
3415
3454
|
collection = null;
|
|
3416
3455
|
constructor(e) {
|
|
3417
|
-
this.options = e, this.delayCountdown = new
|
|
3456
|
+
this.options = e, this.delayCountdown = new En((e) => {
|
|
3418
3457
|
Object.assign(this.options.state.fill, e);
|
|
3419
3458
|
}), this.syncBackendCountdown();
|
|
3420
3459
|
}
|
|
3421
3460
|
isActive() {
|
|
3422
|
-
return
|
|
3461
|
+
return er(this.options.state.fill);
|
|
3423
3462
|
}
|
|
3424
3463
|
applyUpdate(e) {
|
|
3425
|
-
let t =
|
|
3464
|
+
let t = sr(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
3426
3465
|
return t && this.syncBackendCountdown(), t;
|
|
3427
3466
|
}
|
|
3428
3467
|
restoreSession(e) {
|
|
3429
|
-
let t =
|
|
3468
|
+
let t = cr(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
3430
3469
|
return t && this.syncBackendCountdown(), t;
|
|
3431
3470
|
}
|
|
3432
3471
|
async start(e, t = {}) {
|
|
3433
3472
|
let n = this.options.fill;
|
|
3434
3473
|
if (!n) throw Error("Vibe fill is not configured.");
|
|
3435
3474
|
if (this.isActive()) throw Error("Vibe fill is already active.");
|
|
3436
|
-
let r =
|
|
3475
|
+
let r = Zn(e), i = Zn(t.target ?? r), a = t.progressOffset ?? {
|
|
3437
3476
|
completedPages: 0,
|
|
3438
3477
|
received: 0
|
|
3439
3478
|
}, o = t.cycleId ?? `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
3440
3479
|
if (this.options.state.fill = {
|
|
3441
|
-
|
|
3480
|
+
...$n(n, void 0, !1),
|
|
3442
3481
|
completedPages: a.completedPages,
|
|
3443
3482
|
cycleId: o,
|
|
3444
3483
|
received: a.received,
|
|
@@ -3451,7 +3490,7 @@ var sr = class {
|
|
|
3451
3490
|
let s = ++this.requestVersion, c = new AbortController();
|
|
3452
3491
|
this.abortController = c;
|
|
3453
3492
|
try {
|
|
3454
|
-
n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await
|
|
3493
|
+
n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await nr(n, this.options.state, {
|
|
3455
3494
|
cycleId: o,
|
|
3456
3495
|
feedKey: n.feedKey,
|
|
3457
3496
|
items: [...this.options.state.items],
|
|
@@ -3469,7 +3508,7 @@ var sr = class {
|
|
|
3469
3508
|
}
|
|
3470
3509
|
async cancel() {
|
|
3471
3510
|
let { fill: e, state: t } = this.options;
|
|
3472
|
-
if (!
|
|
3511
|
+
if (!er(t.fill) || !t.fill.cycleId) return;
|
|
3473
3512
|
let n = {
|
|
3474
3513
|
cycleId: t.fill.cycleId,
|
|
3475
3514
|
feedKey: t.fill.feedKey ?? "",
|
|
@@ -3513,7 +3552,7 @@ var sr = class {
|
|
|
3513
3552
|
});
|
|
3514
3553
|
}
|
|
3515
3554
|
reset() {
|
|
3516
|
-
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill =
|
|
3555
|
+
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = $n(this.options.fill, void 0, !1), this.collection = null;
|
|
3517
3556
|
}
|
|
3518
3557
|
destroy() {
|
|
3519
3558
|
this.abortLocalRequest(), this.delayCountdown.clear();
|
|
@@ -3548,7 +3587,7 @@ var sr = class {
|
|
|
3548
3587
|
s.fill.status = "until" in t ? "complete" : "exhausted";
|
|
3549
3588
|
return;
|
|
3550
3589
|
}
|
|
3551
|
-
let c = await
|
|
3590
|
+
let c = await tr({
|
|
3552
3591
|
existingItems: s.items,
|
|
3553
3592
|
initialCursor: s.next,
|
|
3554
3593
|
loadPage: o,
|
|
@@ -3596,7 +3635,7 @@ var sr = class {
|
|
|
3596
3635
|
};
|
|
3597
3636
|
//#endregion
|
|
3598
3637
|
//#region src/core/fillReconciliation.ts
|
|
3599
|
-
async function
|
|
3638
|
+
async function ur({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, setLastCursor: i, signal: a, state: o }) {
|
|
3600
3639
|
if (!e.needsReconciliation(o.items)) return "skipped";
|
|
3601
3640
|
let s = await e.reconcile({
|
|
3602
3641
|
existingItems: o.items,
|
|
@@ -3609,7 +3648,7 @@ async function cr({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r,
|
|
|
3609
3648
|
}
|
|
3610
3649
|
//#endregion
|
|
3611
3650
|
//#region src/core/feedFooter.ts
|
|
3612
|
-
function
|
|
3651
|
+
function dr(e) {
|
|
3613
3652
|
return {
|
|
3614
3653
|
cancelAutofill: () => e.cancelAutofill(),
|
|
3615
3654
|
loadMore: () => e.loadNext(),
|
|
@@ -3621,46 +3660,46 @@ function lr(e) {
|
|
|
3621
3660
|
retryFill: () => e.retryFill()
|
|
3622
3661
|
};
|
|
3623
3662
|
}
|
|
3624
|
-
function
|
|
3663
|
+
function fr(e) {
|
|
3625
3664
|
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
3626
3665
|
}
|
|
3627
|
-
function
|
|
3628
|
-
e?.intervalMs !== void 0 &&
|
|
3666
|
+
function pr(e) {
|
|
3667
|
+
e?.intervalMs !== void 0 && fr(e.intervalMs);
|
|
3629
3668
|
}
|
|
3630
|
-
function
|
|
3669
|
+
function mr(e) {
|
|
3631
3670
|
return {
|
|
3632
3671
|
enabled: e?.enabled ?? !1,
|
|
3633
3672
|
includePostItems: e?.includePostItems ?? !1,
|
|
3634
3673
|
intervalMs: e?.intervalMs ?? 5e3
|
|
3635
3674
|
};
|
|
3636
3675
|
}
|
|
3637
|
-
function
|
|
3676
|
+
function hr(e, t) {
|
|
3638
3677
|
if (typeof t == "boolean") {
|
|
3639
3678
|
e.enabled = t;
|
|
3640
3679
|
return;
|
|
3641
3680
|
}
|
|
3642
|
-
|
|
3681
|
+
pr(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);
|
|
3643
3682
|
}
|
|
3644
3683
|
//#endregion
|
|
3645
3684
|
//#region src/core/reelInfoSheet.ts
|
|
3646
|
-
function
|
|
3685
|
+
function gr(e) {
|
|
3647
3686
|
return { enabled: e?.enabled ?? !1 };
|
|
3648
3687
|
}
|
|
3649
|
-
function
|
|
3688
|
+
function _r(e, t, n) {
|
|
3650
3689
|
if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
|
|
3651
3690
|
e.enabled = n;
|
|
3652
3691
|
}
|
|
3653
3692
|
//#endregion
|
|
3654
3693
|
//#region src/core/initialRuntimeState.ts
|
|
3655
|
-
function
|
|
3694
|
+
function vr(e, t) {
|
|
3656
3695
|
let n = e.initialPage;
|
|
3657
3696
|
return {
|
|
3658
3697
|
activeReelPostId: null,
|
|
3659
|
-
autoScroll:
|
|
3660
|
-
autofill:
|
|
3698
|
+
autoScroll: Vn(e.autoScroll),
|
|
3699
|
+
autofill: jn(e.autofill),
|
|
3661
3700
|
current: n?.current ?? null,
|
|
3662
3701
|
error: null,
|
|
3663
|
-
fill:
|
|
3702
|
+
fill: $n(e.fill),
|
|
3664
3703
|
infiniteScroll: e.infiniteScroll ?? !0,
|
|
3665
3704
|
isLoading: !n,
|
|
3666
3705
|
isLoadingMore: !1,
|
|
@@ -3671,14 +3710,14 @@ function gr(e, t) {
|
|
|
3671
3710
|
next: n?.next ?? null,
|
|
3672
3711
|
nextPageError: null,
|
|
3673
3712
|
phoneMode: !1,
|
|
3674
|
-
reelAutoAdvance:
|
|
3713
|
+
reelAutoAdvance: mr(e.reelAutoAdvance),
|
|
3675
3714
|
reelForward: {
|
|
3676
3715
|
error: null,
|
|
3677
3716
|
status: "idle"
|
|
3678
3717
|
},
|
|
3679
3718
|
reelForwardIndex: null,
|
|
3680
3719
|
reelForwardItem: null,
|
|
3681
|
-
reelInfoSheet:
|
|
3720
|
+
reelInfoSheet: gr(e.reelInfoSheet),
|
|
3682
3721
|
reelInfoSheetOverlay: !1,
|
|
3683
3722
|
reelMediaSource: "original",
|
|
3684
3723
|
reelOrigin: null,
|
|
@@ -3687,21 +3726,21 @@ function gr(e, t) {
|
|
|
3687
3726
|
}
|
|
3688
3727
|
//#endregion
|
|
3689
3728
|
//#region src/core/options.ts
|
|
3690
|
-
function
|
|
3729
|
+
function yr(e, t) {
|
|
3691
3730
|
if (t) {
|
|
3692
3731
|
if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
|
|
3693
3732
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
|
|
3694
3733
|
}
|
|
3695
3734
|
}
|
|
3696
|
-
function
|
|
3735
|
+
function br(e, t) {
|
|
3697
3736
|
if (t) {
|
|
3698
3737
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
|
|
3699
3738
|
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.`);
|
|
3700
3739
|
}
|
|
3701
3740
|
}
|
|
3702
|
-
function
|
|
3703
|
-
if (
|
|
3704
|
-
if (
|
|
3741
|
+
function xr(e) {
|
|
3742
|
+
if (Bn(e.autoScroll), yr("cardHeader", e.cardHeader), yr("cardFooter", e.cardFooter), br("header", e.mediaCard?.header), br("footer", e.mediaCard?.footer), e.mediaCard?.feedPreload !== void 0 && e.mediaCard.feedPreload !== "none" && e.mediaCard.feedPreload !== "visible-post") throw TypeError("Vibe mediaCard feedPreload must be \"none\" or \"visible-post\".");
|
|
3743
|
+
if (An(e.autofill), Qn(e.fill), de(e.masonry), pr(e.reelAutoAdvance), e.removalReconciliation) {
|
|
3705
3744
|
if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
|
|
3706
3745
|
let t = e.removalReconciliation.maxReplayPages ?? 5;
|
|
3707
3746
|
if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
|
|
@@ -3716,7 +3755,7 @@ function yr(e) {
|
|
|
3716
3755
|
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
3717
3756
|
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
3718
3757
|
}
|
|
3719
|
-
function
|
|
3758
|
+
function Sr(e) {
|
|
3720
3759
|
if (typeof e != "string") return e;
|
|
3721
3760
|
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
3722
3761
|
let t = document.querySelector(e);
|
|
@@ -3725,7 +3764,7 @@ function br(e) {
|
|
|
3725
3764
|
}
|
|
3726
3765
|
//#endregion
|
|
3727
3766
|
//#region src/core/pageRequest.ts
|
|
3728
|
-
async function
|
|
3767
|
+
async function Cr({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
|
|
3729
3768
|
let u = s.autofill, d = e && u?.strategy === "frontend" && (l.autofill.status === "paused" || l.autofill.status === "error"), f = d ? {
|
|
3730
3769
|
received: l.autofill.received,
|
|
3731
3770
|
requests: l.autofill.requests
|
|
@@ -3737,11 +3776,11 @@ async function xr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3737
3776
|
let m = !1;
|
|
3738
3777
|
try {
|
|
3739
3778
|
if (u?.strategy === "frontend") {
|
|
3740
|
-
let s = await
|
|
3779
|
+
let s = await Fn({
|
|
3741
3780
|
existingItems: e ? l.items : [],
|
|
3742
3781
|
initialCursor: n,
|
|
3743
3782
|
loadPage: i,
|
|
3744
|
-
maximumRequests: f ? Math.max(0,
|
|
3783
|
+
maximumRequests: f ? Math.max(0, Dn(u) - f.requests) : void 0,
|
|
3745
3784
|
onCollection: (e) => t.captureCollection(e, r()),
|
|
3746
3785
|
onDelayChange: (e) => {
|
|
3747
3786
|
r() && Object.assign(l.autofill, e);
|
|
@@ -3764,7 +3803,7 @@ async function xr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3764
3803
|
}), o(s.pages), t.clearCollection();
|
|
3765
3804
|
return;
|
|
3766
3805
|
}
|
|
3767
|
-
let s =
|
|
3806
|
+
let s = fn(await i({
|
|
3768
3807
|
cursor: n,
|
|
3769
3808
|
signal: c
|
|
3770
3809
|
}));
|
|
@@ -3784,7 +3823,7 @@ async function xr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3784
3823
|
l.autofill.status = "complete";
|
|
3785
3824
|
return;
|
|
3786
3825
|
}
|
|
3787
|
-
await
|
|
3826
|
+
await Un(u, l, {
|
|
3788
3827
|
cycleId: p,
|
|
3789
3828
|
feedKey: u.feedKey,
|
|
3790
3829
|
items: h.slice(d.length),
|
|
@@ -3809,13 +3848,13 @@ async function xr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3809
3848
|
function $(e) {
|
|
3810
3849
|
return `${typeof e}:${String(e)}`;
|
|
3811
3850
|
}
|
|
3812
|
-
function
|
|
3851
|
+
function wr(e) {
|
|
3813
3852
|
return `${typeof e}:${String(e)}`;
|
|
3814
3853
|
}
|
|
3815
|
-
function
|
|
3854
|
+
function Tr(e) {
|
|
3816
3855
|
return e.map(({ postId: e }) => e);
|
|
3817
3856
|
}
|
|
3818
|
-
var
|
|
3857
|
+
var Er = class {
|
|
3819
3858
|
delay;
|
|
3820
3859
|
enabled;
|
|
3821
3860
|
maxReplayPages;
|
|
@@ -3847,10 +3886,10 @@ var wr = class {
|
|
|
3847
3886
|
}
|
|
3848
3887
|
recordInitialPage(e) {
|
|
3849
3888
|
e && this.recordPages([{
|
|
3850
|
-
contributionIds:
|
|
3851
|
-
cursor:
|
|
3889
|
+
contributionIds: Tr(e.items),
|
|
3890
|
+
cursor: gn(e),
|
|
3852
3891
|
next: e.next,
|
|
3853
|
-
returnedIds:
|
|
3892
|
+
returnedIds: Tr(e.items)
|
|
3854
3893
|
}]);
|
|
3855
3894
|
}
|
|
3856
3895
|
remove(e) {
|
|
@@ -3865,14 +3904,14 @@ var wr = class {
|
|
|
3865
3904
|
async reconcile({ existingItems: e, loadPage: t, onDelayChange: n = () => void 0, shouldPause: r = () => !1, signal: i }) {
|
|
3866
3905
|
let a = this.pending ?? this.createSession(e);
|
|
3867
3906
|
for (this.pending = a; a.remainingRequests > 0;) {
|
|
3868
|
-
let e =
|
|
3907
|
+
let e = wr(a.cursor);
|
|
3869
3908
|
if (a.seenCursors.has(e)) throw Error("Vibe removal reconciliation received a repeated cursor.");
|
|
3870
|
-
if (await
|
|
3871
|
-
delayMs:
|
|
3909
|
+
if (await Tn({
|
|
3910
|
+
delayMs: wn(a.pages.length, this.delay),
|
|
3872
3911
|
onChange: n,
|
|
3873
3912
|
signal: i
|
|
3874
3913
|
}), a.pages.length > 0 && r()) return this.result(a, "paused");
|
|
3875
|
-
let o =
|
|
3914
|
+
let o = fn(await t({
|
|
3876
3915
|
cursor: a.cursor,
|
|
3877
3916
|
signal: i
|
|
3878
3917
|
}));
|
|
@@ -3885,7 +3924,7 @@ var wr = class {
|
|
|
3885
3924
|
contributionIds: c,
|
|
3886
3925
|
cursor: a.cursor,
|
|
3887
3926
|
next: o.next,
|
|
3888
|
-
returnedIds:
|
|
3927
|
+
returnedIds: Tr(s)
|
|
3889
3928
|
}), a.lastCursor = a.cursor, a.next = o.next, --a.remainingRequests, o.total !== void 0 && (a.total = o.total), a.next === null ? a.remainingRequests = 0 : a.cursor = a.next, a.remainingRequests > 0 && r()) return this.result(a, "paused");
|
|
3890
3929
|
}
|
|
3891
3930
|
return this.result(a, "complete");
|
|
@@ -3924,7 +3963,7 @@ var wr = class {
|
|
|
3924
3963
|
return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
|
|
3925
3964
|
}
|
|
3926
3965
|
recordPage(e) {
|
|
3927
|
-
let t =
|
|
3966
|
+
let t = wr(e.cursor), n = this.pages.findIndex(({ cursor: e }) => wr(e) === t);
|
|
3928
3967
|
n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
|
|
3929
3968
|
...e,
|
|
3930
3969
|
contributionIds: [...e.contributionIds],
|
|
@@ -3934,7 +3973,7 @@ var wr = class {
|
|
|
3934
3973
|
};
|
|
3935
3974
|
//#endregion
|
|
3936
3975
|
//#region src/core/activeItemRemoval.ts
|
|
3937
|
-
function
|
|
3976
|
+
function Dr(e, t, n, r, i) {
|
|
3938
3977
|
let a = new Set(t.map(({ item: e }) => e.postId));
|
|
3939
3978
|
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
3940
3979
|
let o = e.items[Math.max(n, 0)];
|
|
@@ -3947,7 +3986,7 @@ function Tr(e, t, n, r, i) {
|
|
|
3947
3986
|
}
|
|
3948
3987
|
//#endregion
|
|
3949
3988
|
//#region src/core/exactMediaRemovalController.ts
|
|
3950
|
-
function
|
|
3989
|
+
function Or(e, t) {
|
|
3951
3990
|
let [n, ...r] = t;
|
|
3952
3991
|
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
3953
3992
|
return {
|
|
@@ -3956,10 +3995,10 @@ function Er(e, t) {
|
|
|
3956
3995
|
items: r
|
|
3957
3996
|
};
|
|
3958
3997
|
}
|
|
3959
|
-
function
|
|
3998
|
+
function kr(e) {
|
|
3960
3999
|
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
3961
4000
|
}
|
|
3962
|
-
var
|
|
4001
|
+
var Ar = class {
|
|
3963
4002
|
generation = 0;
|
|
3964
4003
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
3965
4004
|
state;
|
|
@@ -3967,7 +4006,7 @@ var Or = class {
|
|
|
3967
4006
|
this.options = e, this.state = e.state;
|
|
3968
4007
|
}
|
|
3969
4008
|
remove(e) {
|
|
3970
|
-
|
|
4009
|
+
kr(e);
|
|
3971
4010
|
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
3972
4011
|
if (!n) return null;
|
|
3973
4012
|
let r = [...P(n)], i = r[e.mediaIndex];
|
|
@@ -3984,7 +4023,7 @@ var Or = class {
|
|
|
3984
4023
|
restored: !1
|
|
3985
4024
|
});
|
|
3986
4025
|
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
3987
|
-
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] =
|
|
4026
|
+
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Or(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
|
|
3988
4027
|
}
|
|
3989
4028
|
reset() {
|
|
3990
4029
|
this.generation += 1;
|
|
@@ -4010,7 +4049,7 @@ var Or = class {
|
|
|
4010
4049
|
}
|
|
4011
4050
|
restoreIntoPost(e, t) {
|
|
4012
4051
|
let n = this.state.items[e], r = [...P(n)], i = Math.min(t.mediaIndex, r.length);
|
|
4013
|
-
if (r.splice(i, 0, t.media), this.state.items[e] =
|
|
4052
|
+
if (r.splice(i, 0, t.media), this.state.items[e] = Or(n, r), this.state.activeReelPostId !== t.postId) return;
|
|
4014
4053
|
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
4015
4054
|
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
4016
4055
|
}
|
|
@@ -4023,18 +4062,18 @@ var Or = class {
|
|
|
4023
4062
|
};
|
|
4024
4063
|
//#endregion
|
|
4025
4064
|
//#region src/core/itemPlacement.ts
|
|
4026
|
-
function
|
|
4065
|
+
function jr(e, t) {
|
|
4027
4066
|
let n = new Set(t);
|
|
4028
4067
|
return e.flatMap((e, t) => n.has(e.postId) ? [{
|
|
4029
4068
|
index: t,
|
|
4030
4069
|
item: e
|
|
4031
4070
|
}] : []);
|
|
4032
4071
|
}
|
|
4033
|
-
function
|
|
4072
|
+
function Mr(e, t) {
|
|
4034
4073
|
let n = new Set(t.map(({ item: e }) => e.postId));
|
|
4035
4074
|
return e.filter((e) => !n.has(e.postId));
|
|
4036
4075
|
}
|
|
4037
|
-
function
|
|
4076
|
+
function Nr(e, t) {
|
|
4038
4077
|
t.forEach(({ index: e }) => {
|
|
4039
4078
|
if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
|
|
4040
4079
|
});
|
|
@@ -4045,7 +4084,7 @@ function jr(e, t) {
|
|
|
4045
4084
|
}
|
|
4046
4085
|
//#endregion
|
|
4047
4086
|
//#region src/core/itemRemovalController.ts
|
|
4048
|
-
var
|
|
4087
|
+
var Pr = 20, Fr = class {
|
|
4049
4088
|
generation = 0;
|
|
4050
4089
|
historyLimit;
|
|
4051
4090
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -4054,7 +4093,7 @@ var Mr = 20, Nr = class {
|
|
|
4054
4093
|
itemOrder;
|
|
4055
4094
|
stopItemsWatcher;
|
|
4056
4095
|
constructor(e) {
|
|
4057
|
-
this.options = e, this.historyLimit = e.historyLimit ??
|
|
4096
|
+
this.options = e, this.historyLimit = e.historyLimit ?? Pr, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
|
|
4058
4097
|
}
|
|
4059
4098
|
destroy() {
|
|
4060
4099
|
this.reset(), this.stopItemsWatcher();
|
|
@@ -4068,7 +4107,7 @@ var Mr = 20, Nr = class {
|
|
|
4068
4107
|
let a = this.options.startRemoval(i, t);
|
|
4069
4108
|
if (a > 0 && await new Promise((e) => setTimeout(e, a)), this.metadata.get(r)?.generation !== this.generation) return r;
|
|
4070
4109
|
let o = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), s = new Set(n.map(({ item: e }) => e.postId)), c = o < 0 ? 0 : this.state.items.slice(0, o).filter(({ postId: e }) => s.has(e)).length, l = Math.max(o - c, 0);
|
|
4071
|
-
return this.state.items =
|
|
4110
|
+
return this.state.items = Mr(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
|
|
4072
4111
|
}
|
|
4073
4112
|
reset() {
|
|
4074
4113
|
this.generation += 1, this.history = [], this.itemOrder = [];
|
|
@@ -4079,7 +4118,7 @@ var Mr = 20, Nr = class {
|
|
|
4079
4118
|
this.restoreRemoval(t);
|
|
4080
4119
|
return;
|
|
4081
4120
|
}
|
|
4082
|
-
let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i =
|
|
4121
|
+
let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i = Nr(this.state.items, r);
|
|
4083
4122
|
this.registerExternalPlacements(r), this.state.items = i, r.length > 0 && this.options.onRemovalRestored(r);
|
|
4084
4123
|
}
|
|
4085
4124
|
restoreRemoval(e) {
|
|
@@ -4105,7 +4144,7 @@ var Mr = 20, Nr = class {
|
|
|
4105
4144
|
}
|
|
4106
4145
|
collectOrderedPlacements(e) {
|
|
4107
4146
|
let t = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
4108
|
-
return
|
|
4147
|
+
return jr(this.state.items, e).map((e) => ({
|
|
4109
4148
|
index: t.get(e.item.postId) ?? e.index,
|
|
4110
4149
|
item: e.item
|
|
4111
4150
|
}));
|
|
@@ -4136,7 +4175,7 @@ var Mr = 20, Nr = class {
|
|
|
4136
4175
|
let r = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
4137
4176
|
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;
|
|
4138
4177
|
}
|
|
4139
|
-
},
|
|
4178
|
+
}, Ir = class {
|
|
4140
4179
|
forward = null;
|
|
4141
4180
|
forwardPromise = null;
|
|
4142
4181
|
forwardVersion = 0;
|
|
@@ -4223,7 +4262,7 @@ var Mr = 20, Nr = class {
|
|
|
4223
4262
|
}
|
|
4224
4263
|
}
|
|
4225
4264
|
}
|
|
4226
|
-
},
|
|
4265
|
+
}, Lr = class {
|
|
4227
4266
|
generation = 0;
|
|
4228
4267
|
pending = Promise.resolve();
|
|
4229
4268
|
constructor(e) {
|
|
@@ -4273,24 +4312,24 @@ var Mr = 20, Nr = class {
|
|
|
4273
4312
|
};
|
|
4274
4313
|
//#endregion
|
|
4275
4314
|
//#region src/core/removalControllers.ts
|
|
4276
|
-
function
|
|
4277
|
-
let t = new
|
|
4315
|
+
function Rr(e) {
|
|
4316
|
+
let t = new Ir(e), n = new Lr({
|
|
4278
4317
|
state: e.state,
|
|
4279
4318
|
transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
|
|
4280
4319
|
transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
|
|
4281
4320
|
});
|
|
4282
4321
|
return {
|
|
4283
|
-
exactMediaRemoval: new
|
|
4322
|
+
exactMediaRemoval: new Ar({
|
|
4284
4323
|
onActivate: e.onActivate,
|
|
4285
4324
|
onPostRemoved: (t) => e.onItemsRemoved([t]),
|
|
4286
4325
|
onPostRestored: (t) => e.onItemsRestored([t]),
|
|
4287
4326
|
reelForward: t,
|
|
4288
4327
|
state: e.state
|
|
4289
4328
|
}),
|
|
4290
|
-
itemRemoval: new
|
|
4329
|
+
itemRemoval: new Fr({
|
|
4291
4330
|
historyLimit: e.historyLimit,
|
|
4292
4331
|
onItemsRemoved: (n, r, i) => {
|
|
4293
|
-
e.onItemsRemoved(r.map(({ item: e }) => e.postId)),
|
|
4332
|
+
e.onItemsRemoved(r.map(({ item: e }) => e.postId)), Dr(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
|
|
4294
4333
|
},
|
|
4295
4334
|
onRemovalRestored: (n) => {
|
|
4296
4335
|
e.onItemsRestored(n.map(({ item: e }) => e.postId));
|
|
@@ -4305,17 +4344,17 @@ function Ir(e) {
|
|
|
4305
4344
|
reelRemoval: n
|
|
4306
4345
|
};
|
|
4307
4346
|
}
|
|
4308
|
-
var
|
|
4309
|
-
function
|
|
4347
|
+
var zr = 1.5;
|
|
4348
|
+
function Br(e) {
|
|
4310
4349
|
let t = Math.min(e.screenWidth, e.screenHeight);
|
|
4311
4350
|
if (t > 0 && t < 600) return !0;
|
|
4312
|
-
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n *
|
|
4351
|
+
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * zr;
|
|
4313
4352
|
return !e.hasHover && n > 0 && n < 600 && r;
|
|
4314
4353
|
}
|
|
4315
|
-
function
|
|
4316
|
-
return
|
|
4354
|
+
function Vr(e) {
|
|
4355
|
+
return Br(e) ? "reel" : "masonry";
|
|
4317
4356
|
}
|
|
4318
|
-
function
|
|
4357
|
+
function Hr(e) {
|
|
4319
4358
|
let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
|
|
4320
4359
|
return {
|
|
4321
4360
|
hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
|
|
@@ -4325,15 +4364,15 @@ function Br(e) {
|
|
|
4325
4364
|
viewportWidth: n.clientWidth
|
|
4326
4365
|
};
|
|
4327
4366
|
}
|
|
4328
|
-
function
|
|
4329
|
-
return
|
|
4367
|
+
function Ur(e) {
|
|
4368
|
+
return Br(Hr(e));
|
|
4330
4369
|
}
|
|
4331
|
-
function
|
|
4332
|
-
return
|
|
4370
|
+
function Wr(e) {
|
|
4371
|
+
return Vr(Hr(e));
|
|
4333
4372
|
}
|
|
4334
4373
|
//#endregion
|
|
4335
4374
|
//#region src/core/responsiveLayoutController.ts
|
|
4336
|
-
var
|
|
4375
|
+
var Gr = class {
|
|
4337
4376
|
layoutMode;
|
|
4338
4377
|
resizeObserver = null;
|
|
4339
4378
|
target = null;
|
|
@@ -4358,13 +4397,13 @@ var Ur = class {
|
|
|
4358
4397
|
}
|
|
4359
4398
|
handleResponsiveLayout = () => {
|
|
4360
4399
|
if (!this.target) return;
|
|
4361
|
-
let e =
|
|
4362
|
-
this.state.phoneMode =
|
|
4400
|
+
let e = Wr(this.target);
|
|
4401
|
+
this.state.phoneMode = Ur(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = this.state.phoneMode ? "mobile" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
|
|
4363
4402
|
};
|
|
4364
|
-
},
|
|
4403
|
+
}, Kr = class {
|
|
4365
4404
|
state;
|
|
4366
4405
|
constructor(e) {
|
|
4367
|
-
this.options = e, this.state = x(
|
|
4406
|
+
this.options = e, this.state = x($e({
|
|
4368
4407
|
...e.initialReelAudioState,
|
|
4369
4408
|
muted: e.initialReelAudioState?.muted ?? e.mediaCard?.videoMuted ?? !1
|
|
4370
4409
|
}));
|
|
@@ -4373,9 +4412,9 @@ var Ur = class {
|
|
|
4373
4412
|
return { ...this.state };
|
|
4374
4413
|
}
|
|
4375
4414
|
set(e, t = !1) {
|
|
4376
|
-
Object.assign(this.state,
|
|
4415
|
+
Object.assign(this.state, $e(e, this.state)), t && this.options.onReelAudioStateChange?.(this.get());
|
|
4377
4416
|
}
|
|
4378
|
-
},
|
|
4417
|
+
}, qr = class {
|
|
4379
4418
|
routedReelPostId = null;
|
|
4380
4419
|
reelRouteIsActive = !1;
|
|
4381
4420
|
constructor(e, t) {
|
|
@@ -4402,7 +4441,7 @@ var Ur = class {
|
|
|
4402
4441
|
let i = this.reelRouteIsActive ? "replace" : "push";
|
|
4403
4442
|
this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
|
|
4404
4443
|
}
|
|
4405
|
-
},
|
|
4444
|
+
}, Jr = class {
|
|
4406
4445
|
app = null;
|
|
4407
4446
|
autoScroll;
|
|
4408
4447
|
autofillController;
|
|
@@ -4425,24 +4464,24 @@ var Ur = class {
|
|
|
4425
4464
|
reelAudio;
|
|
4426
4465
|
state;
|
|
4427
4466
|
constructor(e) {
|
|
4428
|
-
this.options = e,
|
|
4467
|
+
this.options = e, xr(e);
|
|
4429
4468
|
let t = e.layout ?? "masonry";
|
|
4430
|
-
this.state = x(
|
|
4469
|
+
this.state = x(vr(e, t)), this.reelAudio = new Kr(e), this.lastLoadedCursor = e.initialPage ? gn(e.initialPage) : null, this.notificationItems = R(this.state), this.autoScroll = new Hn({
|
|
4431
4470
|
getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
|
|
4432
4471
|
state: this.state.autoScroll
|
|
4433
|
-
}), this.autofillController = new
|
|
4472
|
+
}), this.autofillController = new In({
|
|
4434
4473
|
cancelRequest: () => this.cancelRequest(),
|
|
4435
4474
|
onLastCursor: (e) => this.setCurrentCursor(e),
|
|
4436
4475
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
4437
4476
|
options: e.autofill,
|
|
4438
4477
|
state: this.state
|
|
4439
|
-
}), this.removalReconciliation = new
|
|
4478
|
+
}), this.removalReconciliation = new Er(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new lr({
|
|
4440
4479
|
fill: e.fill,
|
|
4441
4480
|
loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
|
|
4442
4481
|
needsFrontendPreparation: () => this.removalReconciliation.needsReconciliation(this.state.items),
|
|
4443
4482
|
onLastCursor: (e) => this.setCurrentCursor(e),
|
|
4444
4483
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
4445
|
-
prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) =>
|
|
4484
|
+
prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => ur({
|
|
4446
4485
|
controller: this.removalReconciliation,
|
|
4447
4486
|
isCurrent: t,
|
|
4448
4487
|
loadPage: e.loadPage,
|
|
@@ -4452,8 +4491,8 @@ var Ur = class {
|
|
|
4452
4491
|
state: this.state
|
|
4453
4492
|
}),
|
|
4454
4493
|
state: this.state
|
|
4455
|
-
}), this.routing = new
|
|
4456
|
-
let n =
|
|
4494
|
+
}), this.routing = new qr(e.routing, this.state);
|
|
4495
|
+
let n = Rr({
|
|
4457
4496
|
historyLimit: e.removalHistoryLimit,
|
|
4458
4497
|
onActivate: (e) => this.setActiveReelPost(e),
|
|
4459
4498
|
onItemsRemoved: (e) => this.removalReconciliation.remove(e),
|
|
@@ -4462,20 +4501,20 @@ var Ur = class {
|
|
|
4462
4501
|
state: this.state,
|
|
4463
4502
|
surface: () => this.surface
|
|
4464
4503
|
});
|
|
4465
|
-
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new
|
|
4504
|
+
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Gr(t, this.state, () => {
|
|
4466
4505
|
this.routing.syncFeed();
|
|
4467
4506
|
}), this.startStateNotifications();
|
|
4468
4507
|
}
|
|
4469
4508
|
async mount() {
|
|
4470
4509
|
if (this.app) throw Error("Vibe is already mounted.");
|
|
4471
4510
|
this.startStateNotifications();
|
|
4472
|
-
let e =
|
|
4473
|
-
this.responsiveLayout.mount(e), this.app = i(
|
|
4511
|
+
let e = Sr(this.options.target);
|
|
4512
|
+
this.responsiveLayout.mount(e), this.app = i(dn, {
|
|
4474
4513
|
canRetryEnd: !!this.options.loadPage,
|
|
4475
4514
|
cardFooter: this.options.cardFooter,
|
|
4476
4515
|
cardHeader: this.options.cardHeader,
|
|
4477
4516
|
feedFooter: this.options.feedFooter,
|
|
4478
|
-
feedFooterActions:
|
|
4517
|
+
feedFooterActions: dr(this),
|
|
4479
4518
|
mediaCard: this.options.mediaCard,
|
|
4480
4519
|
masonry: this.options.masonry,
|
|
4481
4520
|
onMediaReady: this.options.onMediaReady,
|
|
@@ -4500,7 +4539,7 @@ var Ur = class {
|
|
|
4500
4539
|
onRetryForward: () => {
|
|
4501
4540
|
this.retryReelForward();
|
|
4502
4541
|
}
|
|
4503
|
-
}), this.surface = this.app.mount(e), this.autoScroll.mount(), await
|
|
4542
|
+
}), this.surface = this.app.mount(e), this.autoScroll.mount(), await qn(this.options.restoreBacklog, (e) => this.appendPage(e), (e) => {
|
|
4504
4543
|
this.restoreController = e;
|
|
4505
4544
|
}), !this.options.initialPage && this.state.items.length === 0 ? await this.reload() : this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && !this.state.loadMoreLocked && await this.startInitialAutofill();
|
|
4506
4545
|
}
|
|
@@ -4571,7 +4610,7 @@ var Ur = class {
|
|
|
4571
4610
|
this.autoScroll.setSpeed(e);
|
|
4572
4611
|
}
|
|
4573
4612
|
applyAutofillUpdate(e) {
|
|
4574
|
-
let t =
|
|
4613
|
+
let t = Gn(this.options.autofill, this.state, e);
|
|
4575
4614
|
return t && this.autofillController.syncCountdown(), t;
|
|
4576
4615
|
}
|
|
4577
4616
|
cancelAutofill() {
|
|
@@ -4582,7 +4621,7 @@ var Ur = class {
|
|
|
4582
4621
|
await this.cancelFill();
|
|
4583
4622
|
return;
|
|
4584
4623
|
}
|
|
4585
|
-
if (
|
|
4624
|
+
if (Mn(this.state.autofill)) {
|
|
4586
4625
|
await this.cancelAutofill();
|
|
4587
4626
|
return;
|
|
4588
4627
|
}
|
|
@@ -4596,12 +4635,12 @@ var Ur = class {
|
|
|
4596
4635
|
}
|
|
4597
4636
|
async fill(e) {
|
|
4598
4637
|
if (!this.state.loadMoreLocked) {
|
|
4599
|
-
if (this.pendingRequest ||
|
|
4638
|
+
if (this.pendingRequest || Mn(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
|
|
4600
4639
|
await this.fillController.start(e);
|
|
4601
4640
|
}
|
|
4602
4641
|
}
|
|
4603
4642
|
restoreAutofillSession(e) {
|
|
4604
|
-
let t =
|
|
4643
|
+
let t = Kn(this.options.autofill, this.state, e);
|
|
4605
4644
|
return t && this.autofillController.syncCountdown(), t;
|
|
4606
4645
|
}
|
|
4607
4646
|
restoreFillSession(e) {
|
|
@@ -4611,14 +4650,14 @@ var Ur = class {
|
|
|
4611
4650
|
return this.startLoadMore(() => this.loadNextSequence());
|
|
4612
4651
|
}
|
|
4613
4652
|
appendPage(e) {
|
|
4614
|
-
|
|
4653
|
+
_n(e, this.state, this.removalReconciliation, (e) => this.setCurrentCursor(e));
|
|
4615
4654
|
}
|
|
4616
4655
|
replenishAfterRemoval() {
|
|
4617
4656
|
return this.startLoadMore(() => this.replenishAfterRemovalSequence());
|
|
4618
4657
|
}
|
|
4619
4658
|
async startLoadMore(e) {
|
|
4620
4659
|
if (this.pendingRequest) return this.pendingRequest;
|
|
4621
|
-
if (this.state.loadMoreLocked ||
|
|
4660
|
+
if (this.state.loadMoreLocked || Mn(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
|
|
4622
4661
|
this.state.isLoadingMore = !0, this.state.nextPageError = null;
|
|
4623
4662
|
let t = e();
|
|
4624
4663
|
return this.pendingRequest = t, t.finally(() => {
|
|
@@ -4633,12 +4672,12 @@ var Ur = class {
|
|
|
4633
4672
|
}
|
|
4634
4673
|
async replaceFeed(e, t) {
|
|
4635
4674
|
if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
|
|
4636
|
-
return
|
|
4675
|
+
return Mn(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = jn(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.removalReconciliation.reset(), this.state.error = null, this.state.current = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
|
|
4637
4676
|
}
|
|
4638
4677
|
async loadFilteredPage(e) {
|
|
4639
4678
|
let t = this.options.loadPage;
|
|
4640
4679
|
if (!t) throw Error("Vibe cannot load a page without loadPage.");
|
|
4641
|
-
let n =
|
|
4680
|
+
let n = fn(await t(e));
|
|
4642
4681
|
return {
|
|
4643
4682
|
...n,
|
|
4644
4683
|
items: this.removalReconciliation.filterItems(n.items)
|
|
@@ -4657,7 +4696,7 @@ var Ur = class {
|
|
|
4657
4696
|
let t = ++this.requestVersion, n = new AbortController();
|
|
4658
4697
|
this.abortController = n;
|
|
4659
4698
|
try {
|
|
4660
|
-
let r = await
|
|
4699
|
+
let r = await ur({
|
|
4661
4700
|
controller: this.removalReconciliation,
|
|
4662
4701
|
isCurrent: () => t === this.requestVersion,
|
|
4663
4702
|
loadPage: e,
|
|
@@ -4675,7 +4714,7 @@ var Ur = class {
|
|
|
4675
4714
|
}
|
|
4676
4715
|
async retryEnd() {
|
|
4677
4716
|
if (this.pendingRequest) return this.pendingRequest;
|
|
4678
|
-
if (!this.state.loadMoreLocked && !(
|
|
4717
|
+
if (!this.state.loadMoreLocked && !(Mn(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);
|
|
4679
4718
|
}
|
|
4680
4719
|
setInfiniteScroll(e) {
|
|
4681
4720
|
this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
|
|
@@ -4699,10 +4738,10 @@ var Ur = class {
|
|
|
4699
4738
|
this.state.total = e;
|
|
4700
4739
|
}
|
|
4701
4740
|
setReelAutoAdvance(e) {
|
|
4702
|
-
|
|
4741
|
+
hr(this.state.reelAutoAdvance, e);
|
|
4703
4742
|
}
|
|
4704
4743
|
setReelInfoSheet(e) {
|
|
4705
|
-
|
|
4744
|
+
_r(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
|
|
4706
4745
|
}
|
|
4707
4746
|
setLayout(e) {
|
|
4708
4747
|
this.responsiveLayout.setLayout(e);
|
|
@@ -4722,7 +4761,7 @@ var Ur = class {
|
|
|
4722
4761
|
async fetchPage(e, t) {
|
|
4723
4762
|
if (!this.options.loadPage) return;
|
|
4724
4763
|
let n = ++this.requestVersion, r = new AbortController();
|
|
4725
|
-
this.abortController = r, await
|
|
4764
|
+
this.abortController = r, await Cr({
|
|
4726
4765
|
append: t,
|
|
4727
4766
|
autofillController: this.autofillController,
|
|
4728
4767
|
cursor: e,
|
|
@@ -4744,7 +4783,7 @@ var Ur = class {
|
|
|
4744
4783
|
startInitialAutofill() {
|
|
4745
4784
|
let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
|
|
4746
4785
|
this.abortController = t, this.state.isLoadingMore = !0;
|
|
4747
|
-
let r =
|
|
4786
|
+
let r = Jn({
|
|
4748
4787
|
cycleId: n,
|
|
4749
4788
|
isCurrent: () => e === this.requestVersion,
|
|
4750
4789
|
onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
|
|
@@ -4771,8 +4810,8 @@ var Ur = class {
|
|
|
4771
4810
|
this.lastLoadedCursor = e, this.state.current = e;
|
|
4772
4811
|
}
|
|
4773
4812
|
};
|
|
4774
|
-
function
|
|
4775
|
-
return new
|
|
4813
|
+
function Yr(e) {
|
|
4814
|
+
return new Jr(e);
|
|
4776
4815
|
}
|
|
4777
4816
|
//#endregion
|
|
4778
|
-
export {
|
|
4817
|
+
export { Yr as createVibe };
|