@wyxos/vibe 5.8.2 → 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/README.md +7 -0
- package/lib/components/MediaCard.vue.d.ts +1 -0
- package/lib/components/MediaContextOverlay.vue.d.ts +11 -0
- package/lib/components/useMediaLoading.d.ts +1 -1
- package/lib/components/useVisiblePostPreload.d.ts +12 -0
- package/lib/core/mediaCardOptions.d.ts +5 -0
- package/lib/core/visiblePostPreload.d.ts +22 -0
- package/lib/index.cjs +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +464 -315
- 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
|
|
@@ -820,8 +846,117 @@ function Qe(e) {
|
|
|
820
846
|
};
|
|
821
847
|
}
|
|
822
848
|
//#endregion
|
|
849
|
+
//#region src/core/mediaType.ts
|
|
850
|
+
var tt = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
|
|
851
|
+
function nt(e) {
|
|
852
|
+
try {
|
|
853
|
+
return tt.test(new URL(e).pathname);
|
|
854
|
+
} catch {
|
|
855
|
+
return tt.test(e.split("?")[0] ?? e);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function rt(e, t) {
|
|
859
|
+
return e === void 0 ? nt(t) : e === "video";
|
|
860
|
+
}
|
|
861
|
+
var it = /* @__PURE__ */ new Map(), at = [], ot = 0, st = 0;
|
|
862
|
+
function ct(e, t) {
|
|
863
|
+
return `${t ? "timed" : "image"}:${e}`;
|
|
864
|
+
}
|
|
865
|
+
function lt(e, t, n) {
|
|
866
|
+
let r = P(e);
|
|
867
|
+
if (r.length < 2) return [];
|
|
868
|
+
let i = F(e, t), a = [];
|
|
869
|
+
for (let e = 1; e < r.length; e += 1) {
|
|
870
|
+
let t = i + e, n = i - e;
|
|
871
|
+
t < r.length && a.push(t), n >= 0 && a.push(n);
|
|
872
|
+
}
|
|
873
|
+
let o = /* @__PURE__ */ new Set();
|
|
874
|
+
return a.flatMap((e) => {
|
|
875
|
+
let t = r[e];
|
|
876
|
+
if (!t) return [];
|
|
877
|
+
let i = N(t, n), a = rt(i.type, i.src), s = ct(i.src, a);
|
|
878
|
+
return o.has(s) ? [] : (o.add(s), [{
|
|
879
|
+
key: s,
|
|
880
|
+
src: i.src,
|
|
881
|
+
timed: a
|
|
882
|
+
}]);
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
function ut(e) {
|
|
886
|
+
let t = e.element;
|
|
887
|
+
e.element = null, t && (t instanceof HTMLVideoElement ? (t.pause(), t.removeAttribute("src"), t.load()) : t.removeAttribute("src"));
|
|
888
|
+
}
|
|
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);
|
|
893
|
+
}
|
|
894
|
+
function ft(e) {
|
|
895
|
+
e.state = "loading", ot += 1, e.timed && (st += 1);
|
|
896
|
+
let t = !1, n = () => void 0, r = (r) => {
|
|
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());
|
|
898
|
+
};
|
|
899
|
+
if (e.cancel = () => {
|
|
900
|
+
t || (t = !0, n(), --ot, e.timed && --st, ut(e), pt());
|
|
901
|
+
}, e.timed) {
|
|
902
|
+
let t = document.createElement("video"), i = () => r("ready"), a = () => r("failed");
|
|
903
|
+
n = () => {
|
|
904
|
+
t.removeEventListener("loadedmetadata", i), t.removeEventListener("error", a);
|
|
905
|
+
}, t.addEventListener("loadedmetadata", i, { once: !0 }), t.addEventListener("error", a, { once: !0 }), t.muted = !0, t.playsInline = !0, t.preload = "metadata", t.src = e.src, e.element = t, t.load();
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
let i = document.createElement("img"), a = () => {
|
|
909
|
+
if (typeof i.decode != "function") {
|
|
910
|
+
r("ready");
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
i.decode().then(() => r("ready"), () => r("failed"));
|
|
914
|
+
}, o = () => r("failed");
|
|
915
|
+
n = () => {
|
|
916
|
+
i.removeEventListener("load", a), i.removeEventListener("error", o);
|
|
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;
|
|
918
|
+
}
|
|
919
|
+
function pt() {
|
|
920
|
+
for (; ot < 6;) {
|
|
921
|
+
let e = at.findIndex((e) => e.refs > 0 && e.state === "queued" && (!e.timed || st < 2));
|
|
922
|
+
if (e < 0) return;
|
|
923
|
+
let [t] = at.splice(e, 1);
|
|
924
|
+
t && ft(t);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function mt(e) {
|
|
928
|
+
let t = it.get(e.key);
|
|
929
|
+
t || (t = {
|
|
930
|
+
...e,
|
|
931
|
+
cancel: null,
|
|
932
|
+
element: null,
|
|
933
|
+
refs: 0,
|
|
934
|
+
state: "queued"
|
|
935
|
+
}, it.set(t.key, t), at.push(t)), t.refs += 1, pt();
|
|
936
|
+
let n = !1;
|
|
937
|
+
return () => {
|
|
938
|
+
n || (n = !0, --t.refs, t.refs === 0 && dt(t));
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/components/useVisiblePostPreload.ts
|
|
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();
|
|
945
|
+
function a() {
|
|
946
|
+
let e = new Map(n.value.map((e) => [e.key, e]));
|
|
947
|
+
i.forEach((t, n) => {
|
|
948
|
+
e.has(n) || (t(), i.delete(n));
|
|
949
|
+
}), n.value.forEach((e) => {
|
|
950
|
+
i.has(e.key) || i.set(e.key, mt(e));
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
O(() => n.value.map(({ key: e }) => e).join("\n"), a, { immediate: !0 }), v(() => {
|
|
954
|
+
i.forEach((e) => e()), i.clear();
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
//#endregion
|
|
823
958
|
//#region src/components/useReelVideoActivity.ts
|
|
824
|
-
function
|
|
959
|
+
function gt(e) {
|
|
825
960
|
let t = r(() => e.layout() !== "reel" || e.active() === !0), n = r(() => t.value ? e.videoIsMuted.value : !0);
|
|
826
961
|
function i() {
|
|
827
962
|
if (!t.value) {
|
|
@@ -854,22 +989,9 @@ function $e(e) {
|
|
|
854
989
|
};
|
|
855
990
|
}
|
|
856
991
|
//#endregion
|
|
857
|
-
//#region src/core/mediaType.ts
|
|
858
|
-
var et = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
|
|
859
|
-
function tt(e) {
|
|
860
|
-
try {
|
|
861
|
-
return et.test(new URL(e).pathname);
|
|
862
|
-
} catch {
|
|
863
|
-
return et.test(e.split("?")[0] ?? e);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
function nt(e, t) {
|
|
867
|
-
return e === void 0 ? tt(t) : e === "video";
|
|
868
|
-
}
|
|
869
|
-
//#endregion
|
|
870
992
|
//#region src/components/useMediaLoading.ts
|
|
871
|
-
function
|
|
872
|
-
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");
|
|
873
995
|
return O(i, (t, n) => {
|
|
874
996
|
n !== "none" || t === "none" || m(() => e.videoElement.value?.load());
|
|
875
997
|
}), {
|
|
@@ -880,7 +1002,7 @@ function rt(e) {
|
|
|
880
1002
|
}
|
|
881
1003
|
//#endregion
|
|
882
1004
|
//#region src/components/useMediaReadiness.ts
|
|
883
|
-
function
|
|
1005
|
+
function vt(e) {
|
|
884
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());
|
|
885
1007
|
function f() {
|
|
886
1008
|
l !== null && clearTimeout(l), l = null;
|
|
@@ -938,7 +1060,7 @@ function it(e) {
|
|
|
938
1060
|
}
|
|
939
1061
|
//#endregion
|
|
940
1062
|
//#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
|
|
941
|
-
var
|
|
1063
|
+
var yt = [
|
|
942
1064
|
"data-post-id",
|
|
943
1065
|
"data-media-index",
|
|
944
1066
|
"aria-hidden",
|
|
@@ -946,12 +1068,12 @@ var at = [
|
|
|
946
1068
|
"inert",
|
|
947
1069
|
"role",
|
|
948
1070
|
"tabindex"
|
|
949
|
-
],
|
|
1071
|
+
], bt = { class: "media-card-content" }, xt = ["data-media-direction"], St = ["data-media-index"], Ct = {
|
|
950
1072
|
key: 0,
|
|
951
1073
|
"data-test": "media-loading",
|
|
952
1074
|
class: "media-loading",
|
|
953
1075
|
"aria-hidden": "true"
|
|
954
|
-
},
|
|
1076
|
+
}, wt = [
|
|
955
1077
|
"data-source-generation",
|
|
956
1078
|
"src",
|
|
957
1079
|
"width",
|
|
@@ -960,14 +1082,14 @@ var at = [
|
|
|
960
1082
|
"loop",
|
|
961
1083
|
"muted",
|
|
962
1084
|
"preload"
|
|
963
|
-
],
|
|
1085
|
+
], Tt = [
|
|
964
1086
|
"data-source-generation",
|
|
965
1087
|
"src",
|
|
966
1088
|
"width",
|
|
967
1089
|
"height",
|
|
968
1090
|
"fetchpriority",
|
|
969
1091
|
"loading"
|
|
970
|
-
],
|
|
1092
|
+
], Et = ["aria-label"], Dt = ["aria-label"], Ot = ["aria-label"], kt = 40, At = 160, jt = 24, Mt = /* @__PURE__ */ d({
|
|
971
1093
|
__name: "MediaCard",
|
|
972
1094
|
props: {
|
|
973
1095
|
active: { type: Boolean },
|
|
@@ -976,6 +1098,7 @@ var at = [
|
|
|
976
1098
|
cardHeader: {},
|
|
977
1099
|
entering: { type: Boolean },
|
|
978
1100
|
fetchPriority: {},
|
|
1101
|
+
inViewport: { type: Boolean },
|
|
979
1102
|
index: {},
|
|
980
1103
|
item: {},
|
|
981
1104
|
itemStyle: {},
|
|
@@ -1005,20 +1128,30 @@ var at = [
|
|
|
1005
1128
|
function S(e = !1, t = "pointer") {
|
|
1006
1129
|
e && x("activate", t);
|
|
1007
1130
|
}
|
|
1008
|
-
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({
|
|
1009
1132
|
identity: () => `${l.item.postId}:${T.value}:${l.mediaSource ?? "preview"}:${M.value}:${L.value ?? ""}`,
|
|
1010
1133
|
mediaIndex: () => T.value,
|
|
1011
1134
|
onError: (e) => x("error", e),
|
|
1012
1135
|
onReady: (e) => x("ready", e),
|
|
1013
1136
|
previewState: () => l.previewState
|
|
1014
|
-
})
|
|
1137
|
+
});
|
|
1138
|
+
ht({
|
|
1139
|
+
inViewport: () => l.inViewport === !0,
|
|
1140
|
+
item: () => l.item,
|
|
1141
|
+
layout: () => l.layout,
|
|
1142
|
+
mediaCard: () => l.mediaCard,
|
|
1143
|
+
mediaIndex: () => T.value,
|
|
1144
|
+
mediaReady: () => B.value === "ready",
|
|
1145
|
+
mediaSource: () => l.mediaSource ?? "preview"
|
|
1146
|
+
});
|
|
1147
|
+
let ne = w(0), re = w(0), q = w(!1), { apply: ie, setVolume: ae, sync: oe, toggleMute: se, videoIsMuted: J, videoVolume: ce } = et({
|
|
1015
1148
|
active: () => l.active,
|
|
1016
1149
|
layout: () => l.layout,
|
|
1017
1150
|
mediaCard: () => l.mediaCard,
|
|
1018
1151
|
onChange: (e) => x("reelAudioChange", e),
|
|
1019
1152
|
reelAudioState: () => l.reelAudioState,
|
|
1020
1153
|
videoElement: K
|
|
1021
|
-
}), { effectiveMuted: le, onPlaying: ue, playbackAllowed: de } =
|
|
1154
|
+
}), { effectiveMuted: le, onPlaying: ue, playbackAllowed: de } = gt({
|
|
1022
1155
|
active: () => l.active,
|
|
1023
1156
|
layout: () => l.layout,
|
|
1024
1157
|
videoElement: K,
|
|
@@ -1039,12 +1172,12 @@ var at = [
|
|
|
1039
1172
|
f = 0, p = !1, d !== null && clearTimeout(d), d = null;
|
|
1040
1173
|
}
|
|
1041
1174
|
function he() {
|
|
1042
|
-
d !== null && clearTimeout(d), d = setTimeout(me,
|
|
1175
|
+
d !== null && clearTimeout(d), d = setTimeout(me, At);
|
|
1043
1176
|
}
|
|
1044
1177
|
function ge(e) {
|
|
1045
1178
|
if (C.value.length <= 1) return;
|
|
1046
1179
|
let t = e.currentTarget?.clientWidth || 1, n = pe(e.deltaX, e.deltaMode, t);
|
|
1047
|
-
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;
|
|
1048
1181
|
let r = Math.sign(f);
|
|
1049
1182
|
f = 0, p = !0, X(T.value + r);
|
|
1050
1183
|
}
|
|
@@ -1056,9 +1189,9 @@ var at = [
|
|
|
1056
1189
|
let t = e.changedTouches[0];
|
|
1057
1190
|
if (m === null || g === null || !t) return;
|
|
1058
1191
|
let n = m - t.clientX, r = g - t.clientY;
|
|
1059
|
-
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)));
|
|
1060
1193
|
}
|
|
1061
|
-
let { imageLoading: ye, mediaIsTimed: be, videoPreload: xe } =
|
|
1194
|
+
let { imageLoading: ye, mediaIsTimed: be, videoPreload: xe } = _t({
|
|
1062
1195
|
active: () => l.active,
|
|
1063
1196
|
fetchPriority: () => l.fetchPriority,
|
|
1064
1197
|
layout: () => l.layout,
|
|
@@ -1118,7 +1251,7 @@ var at = [
|
|
|
1118
1251
|
tabindex: e.interactive && !e.leaving && !Y.value ? 0 : void 0,
|
|
1119
1252
|
onClick: i[14] ||= (t) => S(e.interactive && !Y.value, fe(t)),
|
|
1120
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"])]
|
|
1121
|
-
}, [c("div",
|
|
1254
|
+
}, [c("div", bt, [
|
|
1122
1255
|
e.cardHeader ? (b(), a(Ie, {
|
|
1123
1256
|
key: 0,
|
|
1124
1257
|
index: e.index,
|
|
@@ -1157,7 +1290,7 @@ var at = [
|
|
|
1157
1290
|
key: `${e.item.postId}:${D.value.src}:${e.mediaSource ?? "preview"}:${E(G)}`,
|
|
1158
1291
|
class: "media-card-frame",
|
|
1159
1292
|
"data-media-index": T.value
|
|
1160
|
-
}, [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, {
|
|
1161
1294
|
key: 1,
|
|
1162
1295
|
component: e.mediaCard?.error?.component,
|
|
1163
1296
|
label: E(Fe)(M.value),
|
|
@@ -1199,7 +1332,7 @@ var at = [
|
|
|
1199
1332
|
onEnded: Me,
|
|
1200
1333
|
onClick: Te,
|
|
1201
1334
|
onError: i[5] ||= (...e) => E(V) && E(V)(...e)
|
|
1202
|
-
}, null, 42,
|
|
1335
|
+
}, null, 42, wt)) : (b(), s("img", {
|
|
1203
1336
|
key: 3,
|
|
1204
1337
|
ref_key: "imageElement",
|
|
1205
1338
|
ref: H,
|
|
@@ -1214,9 +1347,22 @@ var at = [
|
|
|
1214
1347
|
loading: E(ye),
|
|
1215
1348
|
onLoad: i[6] ||= (...e) => E(U) && E(U)(...e),
|
|
1216
1349
|
onError: i[7] ||= (...e) => E(V) && E(V)(...e)
|
|
1217
|
-
}, null, 42,
|
|
1350
|
+
}, null, 42, Tt))], 8, St))]),
|
|
1218
1351
|
_: 1
|
|
1219
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
|
+
]),
|
|
1220
1366
|
(b(), a(t, {
|
|
1221
1367
|
disabled: !Se.value || !e.reelControlsTarget,
|
|
1222
1368
|
to: e.reelControlsTarget ?? "body"
|
|
@@ -1260,13 +1406,13 @@ var at = [
|
|
|
1260
1406
|
"aria-label": `Previous media for post ${e.item.postId}`,
|
|
1261
1407
|
onClick: i[8] ||= j((e) => X(T.value - 1, e), ["stop"]),
|
|
1262
1408
|
onKeydown: i[9] ||= j(() => {}, ["stop"])
|
|
1263
|
-
}, [u(E(De), { size: 20 })], 40,
|
|
1409
|
+
}, [u(E(De), { size: 20 })], 40, Et), c("button", {
|
|
1264
1410
|
type: "button",
|
|
1265
1411
|
class: "media-carousel-control media-carousel-control--next",
|
|
1266
1412
|
"aria-label": `Next media for post ${e.item.postId}`,
|
|
1267
1413
|
onClick: i[10] ||= j((e) => X(T.value + 1, e), ["stop"]),
|
|
1268
1414
|
onKeydown: i[11] ||= j(() => {}, ["stop"])
|
|
1269
|
-
}, [u(E(Oe), { size: 20 })], 40,
|
|
1415
|
+
}, [u(E(Oe), { size: 20 })], 40, Dt)], 2)) : o("", !0),
|
|
1270
1416
|
Y.value ? (b(), s("button", {
|
|
1271
1417
|
key: 1,
|
|
1272
1418
|
class: "media-card-activator",
|
|
@@ -1274,8 +1420,8 @@ var at = [
|
|
|
1274
1420
|
"aria-label": `Open post ${e.item.postId}`,
|
|
1275
1421
|
onClick: i[12] ||= j((e) => r.$emit("activate", fe(e)), ["stop"]),
|
|
1276
1422
|
onKeydown: i[13] ||= j(() => {}, ["stop"])
|
|
1277
|
-
}, null, 40,
|
|
1278
|
-
], 42,
|
|
1423
|
+
}, null, 40, Ot)) : o("", !0)
|
|
1424
|
+
], 42, xt),
|
|
1279
1425
|
e.cardFooter ? (b(), a(Ie, {
|
|
1280
1426
|
key: 1,
|
|
1281
1427
|
index: e.index,
|
|
@@ -1299,12 +1445,12 @@ var at = [
|
|
|
1299
1445
|
"style",
|
|
1300
1446
|
"total"
|
|
1301
1447
|
])) : o("", !0)
|
|
1302
|
-
])], 46,
|
|
1448
|
+
])], 46, yt));
|
|
1303
1449
|
}
|
|
1304
|
-
}),
|
|
1450
|
+
}), Nt = { class: "masonry-feed-shell" }, Pt = ["aria-hidden", "inert"], Ft = {
|
|
1305
1451
|
key: 0,
|
|
1306
1452
|
class: "masonry-feed-status-overlay"
|
|
1307
|
-
},
|
|
1453
|
+
}, It = 6, Lt = 12, Rt = 250, zt = /* @__PURE__ */ d({
|
|
1308
1454
|
__name: "MasonryFeed",
|
|
1309
1455
|
props: {
|
|
1310
1456
|
enteringPostIds: {},
|
|
@@ -1341,7 +1487,7 @@ var at = [
|
|
|
1341
1487
|
"visible"
|
|
1342
1488
|
],
|
|
1343
1489
|
setup(t, { expose: n, emit: i }) {
|
|
1344
|
-
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, {
|
|
1345
1491
|
additionalHeight: (d.cardHeader?.height ?? 0) + (d.cardFooter?.height ?? 0),
|
|
1346
1492
|
gap: x.value,
|
|
1347
1493
|
minColumnWidth: le(d.masonry)
|
|
@@ -1452,7 +1598,7 @@ var at = [
|
|
|
1452
1598
|
}
|
|
1453
1599
|
function pe(e) {
|
|
1454
1600
|
let t = e.ownerDocument.documentElement.clientWidth;
|
|
1455
|
-
y.value = e.clientWidth, x.value = Math.min(
|
|
1601
|
+
y.value = e.clientWidth, x.value = Math.min(Lt, Math.max(It, t * .0075)), X();
|
|
1456
1602
|
}
|
|
1457
1603
|
function me(e) {
|
|
1458
1604
|
let t = e.currentTarget;
|
|
@@ -1463,7 +1609,7 @@ var at = [
|
|
|
1463
1609
|
Date.now() >= l && !d.loadMoreLocked && e && re(e) && f("loadMore");
|
|
1464
1610
|
}
|
|
1465
1611
|
O(() => d.items.length, (e, t) => {
|
|
1466
|
-
e > 0 && e < t && (l = Date.now() +
|
|
1612
|
+
e > 0 && e < t && (l = Date.now() + Rt);
|
|
1467
1613
|
});
|
|
1468
1614
|
function ge() {
|
|
1469
1615
|
return p.value;
|
|
@@ -1486,7 +1632,7 @@ var at = [
|
|
|
1486
1632
|
}), n({
|
|
1487
1633
|
getScrollElement: ge,
|
|
1488
1634
|
loadIfNearBottom: he
|
|
1489
|
-
}), (n, r) => (b(), s("div",
|
|
1635
|
+
}), (n, r) => (b(), s("div", Nt, [
|
|
1490
1636
|
c("main", {
|
|
1491
1637
|
id: m,
|
|
1492
1638
|
ref_key: "galleryElement",
|
|
@@ -1502,7 +1648,7 @@ var at = [
|
|
|
1502
1648
|
class: h(["masonry", { "masonry--ready": y.value > 0 }]),
|
|
1503
1649
|
style: _(W.value),
|
|
1504
1650
|
"aria-label": "Media gallery"
|
|
1505
|
-
}, [(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, {
|
|
1506
1652
|
key: n.postId,
|
|
1507
1653
|
class: "masonry-item",
|
|
1508
1654
|
entering: t.enteringPostIds.has(n.postId),
|
|
@@ -1511,6 +1657,7 @@ var at = [
|
|
|
1511
1657
|
"card-footer": t.cardFooter,
|
|
1512
1658
|
"card-header": t.cardHeader,
|
|
1513
1659
|
"media-card": t.mediaCard,
|
|
1660
|
+
"in-viewport": G.value.has(r),
|
|
1514
1661
|
index: r,
|
|
1515
1662
|
item: n,
|
|
1516
1663
|
"item-style": fe(r),
|
|
@@ -1531,6 +1678,7 @@ var at = [
|
|
|
1531
1678
|
"card-footer",
|
|
1532
1679
|
"card-header",
|
|
1533
1680
|
"media-card",
|
|
1681
|
+
"in-viewport",
|
|
1534
1682
|
"index",
|
|
1535
1683
|
"item",
|
|
1536
1684
|
"item-style",
|
|
@@ -1542,8 +1690,8 @@ var at = [
|
|
|
1542
1690
|
"onMediaChange",
|
|
1543
1691
|
"onReady",
|
|
1544
1692
|
"onError"
|
|
1545
|
-
]))), 128))], 6)], 42,
|
|
1546
|
-
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, {
|
|
1547
1695
|
actions: t.feedFooterActions,
|
|
1548
1696
|
"can-retry-end": t.canRetryEnd,
|
|
1549
1697
|
"feed-footer": t.feedFooter,
|
|
@@ -1578,8 +1726,8 @@ var at = [
|
|
|
1578
1726
|
])
|
|
1579
1727
|
]));
|
|
1580
1728
|
}
|
|
1581
|
-
}),
|
|
1582
|
-
function
|
|
1729
|
+
}), Bt = 300;
|
|
1730
|
+
function Vt(e, t, n) {
|
|
1583
1731
|
let r = e.scrollTop;
|
|
1584
1732
|
if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
|
|
1585
1733
|
e.setAttribute("data-transitioning", "");
|
|
@@ -1587,7 +1735,7 @@ function Dt(e, t, n) {
|
|
|
1587
1735
|
return new Promise((n) => {
|
|
1588
1736
|
let o = (s) => {
|
|
1589
1737
|
a += 1;
|
|
1590
|
-
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;
|
|
1591
1739
|
if (e.scrollTop = r + (t - r) * u, l < 1) {
|
|
1592
1740
|
requestAnimationFrame(o);
|
|
1593
1741
|
return;
|
|
@@ -1599,7 +1747,7 @@ function Dt(e, t, n) {
|
|
|
1599
1747
|
}
|
|
1600
1748
|
//#endregion
|
|
1601
1749
|
//#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
|
|
1602
|
-
var
|
|
1750
|
+
var Ht = ["aria-label"], Ut = /* @__PURE__ */ d({
|
|
1603
1751
|
__name: "ReelAutoAdvanceProgress",
|
|
1604
1752
|
props: {
|
|
1605
1753
|
durationMs: {},
|
|
@@ -1617,9 +1765,9 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1617
1765
|
class: "reel-auto-advance-progress",
|
|
1618
1766
|
style: _(a.value),
|
|
1619
1767
|
onAnimationend: n[0] ||= (e) => i("complete")
|
|
1620
|
-
}, null, 36)], 8,
|
|
1768
|
+
}, null, 36)], 8, Ht));
|
|
1621
1769
|
}
|
|
1622
|
-
}),
|
|
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({
|
|
1623
1771
|
__name: "ReelFeed",
|
|
1624
1772
|
props: {
|
|
1625
1773
|
initialPostId: {},
|
|
@@ -1671,7 +1819,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1671
1819
|
}), H = r(() => {
|
|
1672
1820
|
let e = z.value;
|
|
1673
1821
|
return e === void 0 ? "loading" : u.previewStates.get(L(e, V.value)) ?? "loading";
|
|
1674
|
-
}), 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(() => [
|
|
1675
1823
|
z.value,
|
|
1676
1824
|
V.value,
|
|
1677
1825
|
u.items.length,
|
|
@@ -1722,7 +1870,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1722
1870
|
Date.now() >= l && !u.loadMoreLocked && e && re(e) && d("loadMore");
|
|
1723
1871
|
}
|
|
1724
1872
|
O(() => u.items.length, (e, t) => {
|
|
1725
|
-
e > 0 && e < t && (l = Date.now() +
|
|
1873
|
+
e > 0 && e < t && (l = Date.now() + Jt);
|
|
1726
1874
|
});
|
|
1727
1875
|
function Y(e) {
|
|
1728
1876
|
let t = B.value;
|
|
@@ -1747,7 +1895,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1747
1895
|
let t = f.value;
|
|
1748
1896
|
if (!t) return Promise.resolve();
|
|
1749
1897
|
let n = e * (k || t.clientHeight);
|
|
1750
|
-
return x.value = e,
|
|
1898
|
+
return x.value = e, Vt(t, n, pe());
|
|
1751
1899
|
}
|
|
1752
1900
|
function he(e) {
|
|
1753
1901
|
me(e);
|
|
@@ -1757,7 +1905,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1757
1905
|
return t < 0 || t === x.value ? !1 : (await me(t), !0);
|
|
1758
1906
|
}
|
|
1759
1907
|
async function _e(e) {
|
|
1760
|
-
return Y(e) ? (pe() || await new Promise((e) => setTimeout(e,
|
|
1908
|
+
return Y(e) ? (pe() || await new Promise((e) => setTimeout(e, qt)), !0) : !1;
|
|
1761
1909
|
}
|
|
1762
1910
|
function ve() {
|
|
1763
1911
|
if (!u.reelAutoAdvance.enabled) return;
|
|
@@ -1826,7 +1974,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1826
1974
|
"style",
|
|
1827
1975
|
"total"
|
|
1828
1976
|
])) : o("", !0),
|
|
1829
|
-
c("div",
|
|
1977
|
+
c("div", Wt, [c("div", {
|
|
1830
1978
|
ref_key: "galleryElement",
|
|
1831
1979
|
ref: f,
|
|
1832
1980
|
class: "gallery-shell reel-feed",
|
|
@@ -1838,7 +1986,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1838
1986
|
class: "reel-track",
|
|
1839
1987
|
style: _(F.value),
|
|
1840
1988
|
"aria-label": "Media gallery"
|
|
1841
|
-
}, [(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, {
|
|
1842
1990
|
key: n.postId,
|
|
1843
1991
|
active: i === x.value && !C.value,
|
|
1844
1992
|
"advance-on-media-end": u.reelAutoAdvance.enabled && i === x.value,
|
|
@@ -1892,7 +2040,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1892
2040
|
class: "reel-forward-retry",
|
|
1893
2041
|
type: "button",
|
|
1894
2042
|
onClick: r[0] ||= (e) => d("retryForward")
|
|
1895
|
-
}, " Retry ")) : o("", !0)], 8,
|
|
2043
|
+
}, " Retry ")) : o("", !0)], 8, Kt)), t.reelForward.status === "idle" ? (b(), a(te, {
|
|
1896
2044
|
key: 2,
|
|
1897
2045
|
actions: t.feedFooterActions,
|
|
1898
2046
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -1915,7 +2063,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1915
2063
|
"load-more-locked",
|
|
1916
2064
|
"show-load-more",
|
|
1917
2065
|
"state"
|
|
1918
|
-
])) : o("", !0)], 40,
|
|
2066
|
+
])) : o("", !0)], 40, Gt), c("div", {
|
|
1919
2067
|
ref_key: "reelControlsElement",
|
|
1920
2068
|
ref: p,
|
|
1921
2069
|
class: "reel-media-controls-host",
|
|
@@ -1943,7 +2091,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1943
2091
|
"style",
|
|
1944
2092
|
"total"
|
|
1945
2093
|
])) : o("", !0),
|
|
1946
|
-
ne.value ? (b(), a(
|
|
2094
|
+
ne.value ? (b(), a(Ut, {
|
|
1947
2095
|
key: G.value,
|
|
1948
2096
|
"duration-ms": t.reelAutoAdvance.intervalMs,
|
|
1949
2097
|
label: K.value,
|
|
@@ -1951,16 +2099,16 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
1951
2099
|
}, null, 8, ["duration-ms", "label"])) : o("", !0)
|
|
1952
2100
|
], 2));
|
|
1953
2101
|
}
|
|
1954
|
-
}),
|
|
2102
|
+
}), Xt = ["data-info-sheet-open", "data-info-sheet-mode"], Zt = ["aria-hidden", "inert"], Qt = {
|
|
1955
2103
|
key: 0,
|
|
1956
2104
|
class: "reel-info-sheet-layer",
|
|
1957
2105
|
"data-test": "reel-info-sheet"
|
|
1958
|
-
},
|
|
2106
|
+
}, $t = [
|
|
1959
2107
|
"role",
|
|
1960
2108
|
"aria-modal",
|
|
1961
2109
|
"tabindex",
|
|
1962
2110
|
"data-active-post-id"
|
|
1963
|
-
],
|
|
2111
|
+
], en = /* @__PURE__ */ d({
|
|
1964
2112
|
__name: "ReelLayout",
|
|
1965
2113
|
props: {
|
|
1966
2114
|
forwardIndex: { default: null },
|
|
@@ -2087,7 +2235,7 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
2087
2235
|
class: "reel-layout-main",
|
|
2088
2236
|
"aria-hidden": e.infoSheetOverlay && A.value || void 0,
|
|
2089
2237
|
inert: e.infoSheetOverlay && A.value || void 0
|
|
2090
|
-
}, [u(
|
|
2238
|
+
}, [u(Yt, {
|
|
2091
2239
|
ref_key: "reelFeed",
|
|
2092
2240
|
ref: p,
|
|
2093
2241
|
"can-retry-end": e.canRetryEnd,
|
|
@@ -2141,8 +2289,8 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
2141
2289
|
"reel-forward",
|
|
2142
2290
|
"state",
|
|
2143
2291
|
"total"
|
|
2144
|
-
])], 8,
|
|
2145
|
-
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", {
|
|
2146
2294
|
ref_key: "sheetElement",
|
|
2147
2295
|
ref: _,
|
|
2148
2296
|
class: "reel-info-sheet",
|
|
@@ -2151,14 +2299,14 @@ var Ot = ["aria-label"], kt = /* @__PURE__ */ d({
|
|
|
2151
2299
|
"aria-modal": e.infoSheetOverlay ? "true" : void 0,
|
|
2152
2300
|
tabindex: e.infoSheetOverlay ? -1 : void 0,
|
|
2153
2301
|
"data-active-post-id": T.value?.postId
|
|
2154
|
-
}, [(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)]),
|
|
2155
2303
|
_: 1
|
|
2156
|
-
})], 10,
|
|
2304
|
+
})], 10, Xt));
|
|
2157
2305
|
}
|
|
2158
2306
|
});
|
|
2159
2307
|
//#endregion
|
|
2160
2308
|
//#region src/core/mediaLifecycle.ts
|
|
2161
|
-
function
|
|
2309
|
+
function tn(e, t, n, r, i) {
|
|
2162
2310
|
let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
|
|
2163
2311
|
if (!o) return null;
|
|
2164
2312
|
let s = F(o, n), c = I(o, s);
|
|
@@ -2174,7 +2322,7 @@ function Vt(e, t, n, r, i) {
|
|
|
2174
2322
|
postIndex: a
|
|
2175
2323
|
};
|
|
2176
2324
|
}
|
|
2177
|
-
function
|
|
2325
|
+
function nn(e, t) {
|
|
2178
2326
|
O(() => {
|
|
2179
2327
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
|
|
2180
2328
|
return {
|
|
@@ -2184,20 +2332,20 @@ function Ht(e, t) {
|
|
|
2184
2332
|
};
|
|
2185
2333
|
}, (n, r) => {
|
|
2186
2334
|
if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
|
|
2187
|
-
let i =
|
|
2335
|
+
let i = tn(e, n.postId, n.mediaIndex, "reel", n.origin);
|
|
2188
2336
|
i && t(i);
|
|
2189
2337
|
}, { flush: "sync" });
|
|
2190
2338
|
}
|
|
2191
2339
|
//#endregion
|
|
2192
2340
|
//#region src/components/useMediaLifecycle.ts
|
|
2193
|
-
function
|
|
2341
|
+
function rn(e, t) {
|
|
2194
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);
|
|
2195
2343
|
function c(e, t, n, r) {
|
|
2196
2344
|
let i = L(t, n);
|
|
2197
2345
|
e.value.get(i) !== r && (e.value = new Map(e.value).set(i, r));
|
|
2198
2346
|
}
|
|
2199
2347
|
function l(t, n, r, i) {
|
|
2200
|
-
return
|
|
2348
|
+
return tn(e, t, n, r, i);
|
|
2201
2349
|
}
|
|
2202
2350
|
function u(e, n, r, i) {
|
|
2203
2351
|
let a = l(e, n, r, i);
|
|
@@ -2219,7 +2367,7 @@ function Ut(e, t) {
|
|
|
2219
2367
|
let r = l(e, n, "masonry", null);
|
|
2220
2368
|
r && t.visible(r);
|
|
2221
2369
|
}
|
|
2222
|
-
return
|
|
2370
|
+
return nn(e, t.reelChange), O(() => {
|
|
2223
2371
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null, n = t === null ? 0 : e.mediaIndices.get(t) ?? 0;
|
|
2224
2372
|
return {
|
|
2225
2373
|
mediaIndex: n,
|
|
@@ -2244,16 +2392,16 @@ function Ut(e, t) {
|
|
|
2244
2392
|
}
|
|
2245
2393
|
//#endregion
|
|
2246
2394
|
//#region src/core/reelEscapeStack.ts
|
|
2247
|
-
var
|
|
2248
|
-
function
|
|
2249
|
-
return
|
|
2250
|
-
let t =
|
|
2251
|
-
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);
|
|
2252
2400
|
};
|
|
2253
2401
|
}
|
|
2254
|
-
function
|
|
2402
|
+
function sn(e) {
|
|
2255
2403
|
if (!e.isActive()) return !1;
|
|
2256
|
-
let t =
|
|
2404
|
+
let t = an.filter((e) => e.isActive()), n = e.element();
|
|
2257
2405
|
return n !== null && t.some((t) => {
|
|
2258
2406
|
if (t === e) return !1;
|
|
2259
2407
|
let r = t.element();
|
|
@@ -2269,14 +2417,14 @@ function Kt(e) {
|
|
|
2269
2417
|
}
|
|
2270
2418
|
//#endregion
|
|
2271
2419
|
//#region src/components/useReelKeyboard.ts
|
|
2272
|
-
function
|
|
2420
|
+
function cn(e) {
|
|
2273
2421
|
let t = {
|
|
2274
2422
|
element: e.element,
|
|
2275
2423
|
isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
|
|
2276
2424
|
}, n = null;
|
|
2277
2425
|
function r(n) {
|
|
2278
2426
|
let r = t.isActive();
|
|
2279
|
-
if (n.key === "Escape" && r && !
|
|
2427
|
+
if (n.key === "Escape" && r && !sn(t)) return;
|
|
2280
2428
|
if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
|
|
2281
2429
|
n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
|
|
2282
2430
|
return;
|
|
@@ -2296,14 +2444,14 @@ function qt(e) {
|
|
|
2296
2444
|
a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
|
|
2297
2445
|
}
|
|
2298
2446
|
y(() => {
|
|
2299
|
-
n =
|
|
2447
|
+
n = on(t), window.addEventListener("keydown", r);
|
|
2300
2448
|
}), v(() => {
|
|
2301
2449
|
window.removeEventListener("keydown", r), n?.(), n = null;
|
|
2302
2450
|
});
|
|
2303
2451
|
}
|
|
2304
2452
|
//#endregion
|
|
2305
2453
|
//#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
|
|
2306
|
-
var
|
|
2454
|
+
var ln = 35, un = 420, dn = /* @__PURE__ */ d({
|
|
2307
2455
|
__name: "VibeSurface",
|
|
2308
2456
|
props: {
|
|
2309
2457
|
canRetryEnd: { type: Boolean },
|
|
@@ -2331,7 +2479,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2331
2479
|
"retryForward"
|
|
2332
2480
|
],
|
|
2333
2481
|
setup(t, { expose: i, emit: c }) {
|
|
2334
|
-
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, {
|
|
2335
2483
|
ready: (e) => d("mediaReady", e),
|
|
2336
2484
|
reelChange: (e) => d("reelMediaChange", e),
|
|
2337
2485
|
visible: (e) => d("mediaVisible", e)
|
|
@@ -2382,10 +2530,10 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2382
2530
|
if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || ee()) return 0;
|
|
2383
2531
|
let n = [...new Set(e)], r = n.filter(se);
|
|
2384
2532
|
if (r.length === 0) return 0;
|
|
2385
|
-
let i = new Map(C.value), a = t?.staggerMs ??
|
|
2533
|
+
let i = new Map(C.value), a = t?.staggerMs ?? ln;
|
|
2386
2534
|
return r.forEach((e, t) => {
|
|
2387
2535
|
i.set(e, t * a);
|
|
2388
|
-
}), 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;
|
|
2389
2537
|
}
|
|
2390
2538
|
function ce(e, t) {
|
|
2391
2539
|
let n = se(e), r = n?.querySelector(".media-card-activator") ?? n;
|
|
@@ -2402,7 +2550,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2402
2550
|
e !== null && ce(e, t);
|
|
2403
2551
|
});
|
|
2404
2552
|
}
|
|
2405
|
-
return
|
|
2553
|
+
return cn({
|
|
2406
2554
|
closeMasonryReel: le,
|
|
2407
2555
|
element: () => g.value,
|
|
2408
2556
|
isReelLeaving: () => _.value,
|
|
@@ -2417,7 +2565,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2417
2565
|
let t = x.value.get(e);
|
|
2418
2566
|
t !== void 0 && r.set(e, t);
|
|
2419
2567
|
}), t.forEach((e, t) => {
|
|
2420
|
-
r.set(e, t *
|
|
2568
|
+
r.set(e, t * ln);
|
|
2421
2569
|
}), x.value = r, y.value = new Set([...y.value, ...t]), te();
|
|
2422
2570
|
}, { flush: "sync" }), v(() => {
|
|
2423
2571
|
H !== null && cancelAnimationFrame(H);
|
|
@@ -2434,7 +2582,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2434
2582
|
ref_key: "surfaceElement",
|
|
2435
2583
|
ref: g,
|
|
2436
2584
|
class: "vibe-surface"
|
|
2437
|
-
}, [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, {
|
|
2438
2586
|
key: 0,
|
|
2439
2587
|
ref_key: "reelRenderer",
|
|
2440
2588
|
ref: p,
|
|
@@ -2487,7 +2635,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2487
2635
|
"can-retry-end",
|
|
2488
2636
|
"feed-footer",
|
|
2489
2637
|
"state"
|
|
2490
|
-
])) : (b(), s(e, { key: 2 }, [u(
|
|
2638
|
+
])) : (b(), s(e, { key: 2 }, [u(zt, {
|
|
2491
2639
|
ref_key: "masonryRenderer",
|
|
2492
2640
|
ref: f,
|
|
2493
2641
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2558,7 +2706,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2558
2706
|
"aria-label": "Media viewer",
|
|
2559
2707
|
"aria-modal": "true",
|
|
2560
2708
|
tabindex: "-1"
|
|
2561
|
-
}, [u(
|
|
2709
|
+
}, [u(en, {
|
|
2562
2710
|
ref_key: "reelRenderer",
|
|
2563
2711
|
ref: p,
|
|
2564
2712
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2604,7 +2752,7 @@ var Jt = 35, Yt = 420, Xt = /* @__PURE__ */ d({
|
|
|
2604
2752
|
});
|
|
2605
2753
|
//#endregion
|
|
2606
2754
|
//#region src/core/page.ts
|
|
2607
|
-
function
|
|
2755
|
+
function fn(e) {
|
|
2608
2756
|
if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
|
|
2609
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.");
|
|
2610
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.");
|
|
@@ -2615,22 +2763,22 @@ function Z(e, t) {
|
|
|
2615
2763
|
let n = new Set(e.map((e) => e.postId));
|
|
2616
2764
|
return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
|
|
2617
2765
|
}
|
|
2618
|
-
function
|
|
2766
|
+
function pn(e) {
|
|
2619
2767
|
return `${typeof e}:${String(e)}`;
|
|
2620
2768
|
}
|
|
2621
|
-
function
|
|
2622
|
-
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)}`;
|
|
2623
2771
|
}
|
|
2624
|
-
function
|
|
2625
|
-
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]));
|
|
2626
2774
|
return t.forEach((e) => {
|
|
2627
|
-
let t =
|
|
2775
|
+
let t = pn(e.postId), i = r.get(t);
|
|
2628
2776
|
if (i === void 0) {
|
|
2629
2777
|
r.set(t, n.length), n.push(e);
|
|
2630
2778
|
return;
|
|
2631
2779
|
}
|
|
2632
|
-
let a = n[i], o = new Set([a, ...a.items].map(
|
|
2633
|
-
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);
|
|
2634
2782
|
return o.has(t) ? !1 : (o.add(t), !0);
|
|
2635
2783
|
});
|
|
2636
2784
|
s.length > 0 && (n[i] = {
|
|
@@ -2639,14 +2787,14 @@ function en(e, t) {
|
|
|
2639
2787
|
});
|
|
2640
2788
|
}), n;
|
|
2641
2789
|
}
|
|
2642
|
-
function
|
|
2790
|
+
function gn(e) {
|
|
2643
2791
|
return Object.prototype.hasOwnProperty.call(e, "current") ? e.current ?? null : e.next;
|
|
2644
2792
|
}
|
|
2645
2793
|
//#endregion
|
|
2646
2794
|
//#region src/core/appendPage.ts
|
|
2647
|
-
function
|
|
2648
|
-
let i =
|
|
2649
|
-
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([{
|
|
2650
2798
|
contributionIds: a.map(({ postId: e }) => e),
|
|
2651
2799
|
cursor: o,
|
|
2652
2800
|
next: i.next,
|
|
@@ -2655,32 +2803,32 @@ function nn(e, t, n, r) {
|
|
|
2655
2803
|
}
|
|
2656
2804
|
//#endregion
|
|
2657
2805
|
//#region src/core/requestDelay.ts
|
|
2658
|
-
var
|
|
2806
|
+
var vn = 2e3, yn = 1e4, bn = 250, xn = {
|
|
2659
2807
|
delayRemainingMs: null,
|
|
2660
2808
|
nextRequestAt: null
|
|
2661
2809
|
};
|
|
2662
|
-
function
|
|
2810
|
+
function Sn(e, t) {
|
|
2663
2811
|
return e === void 0 ? t : Math.floor(e);
|
|
2664
2812
|
}
|
|
2665
|
-
function
|
|
2813
|
+
function Cn(e, t) {
|
|
2666
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.`);
|
|
2667
2815
|
}
|
|
2668
|
-
function
|
|
2669
|
-
let n =
|
|
2816
|
+
function wn(e, t = {}) {
|
|
2817
|
+
let n = Sn(t.delayStepMs, vn), r = Sn(t.delayMaxMs, yn);
|
|
2670
2818
|
return Math.min(Math.max(0, e) * n, r);
|
|
2671
2819
|
}
|
|
2672
2820
|
function Q(e) {
|
|
2673
|
-
if (e == null || !Number.isFinite(e)) return { ...
|
|
2821
|
+
if (e == null || !Number.isFinite(e)) return { ...xn };
|
|
2674
2822
|
let t = Math.max(0, Math.floor(e - Date.now()));
|
|
2675
2823
|
return t > 0 ? {
|
|
2676
2824
|
delayRemainingMs: t,
|
|
2677
2825
|
nextRequestAt: e
|
|
2678
|
-
} : { ...
|
|
2826
|
+
} : { ...xn };
|
|
2679
2827
|
}
|
|
2680
|
-
async function
|
|
2828
|
+
async function Tn({ delayMs: e, onChange: t, signal: n }) {
|
|
2681
2829
|
if (n.aborted) throw new DOMException("Aborted", "AbortError");
|
|
2682
2830
|
if (e <= 0) {
|
|
2683
|
-
t({ ...
|
|
2831
|
+
t({ ...xn });
|
|
2684
2832
|
return;
|
|
2685
2833
|
}
|
|
2686
2834
|
let r = Date.now() + e;
|
|
@@ -2688,9 +2836,9 @@ async function dn({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2688
2836
|
delayRemainingMs: e,
|
|
2689
2837
|
nextRequestAt: r
|
|
2690
2838
|
}), await new Promise((i, a) => {
|
|
2691
|
-
let o = !1, s = setInterval(f,
|
|
2839
|
+
let o = !1, s = setInterval(f, bn), c = setTimeout(() => u(), e);
|
|
2692
2840
|
function l() {
|
|
2693
|
-
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...
|
|
2841
|
+
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...xn });
|
|
2694
2842
|
}
|
|
2695
2843
|
function u(e) {
|
|
2696
2844
|
o || (o = !0, l(), e ? a(e) : i());
|
|
@@ -2705,13 +2853,13 @@ async function dn({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2705
2853
|
n.addEventListener("abort", d, { once: !0 });
|
|
2706
2854
|
});
|
|
2707
2855
|
}
|
|
2708
|
-
var
|
|
2856
|
+
var En = class {
|
|
2709
2857
|
interval = null;
|
|
2710
2858
|
constructor(e) {
|
|
2711
2859
|
this.onChange = e;
|
|
2712
2860
|
}
|
|
2713
2861
|
clear() {
|
|
2714
|
-
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...
|
|
2862
|
+
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...xn });
|
|
2715
2863
|
}
|
|
2716
2864
|
sync(e) {
|
|
2717
2865
|
this.clear();
|
|
@@ -2719,22 +2867,22 @@ var fn = class {
|
|
|
2719
2867
|
this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
|
|
2720
2868
|
let t = Q(e);
|
|
2721
2869
|
this.onChange(t), t.delayRemainingMs === null && this.clear();
|
|
2722
|
-
},
|
|
2870
|
+
}, bn));
|
|
2723
2871
|
}
|
|
2724
2872
|
};
|
|
2725
|
-
function
|
|
2873
|
+
function Dn(e, t = !0) {
|
|
2726
2874
|
return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
|
|
2727
2875
|
}
|
|
2728
|
-
function
|
|
2876
|
+
function On(e) {
|
|
2729
2877
|
return `${typeof e}:${String(e)}`;
|
|
2730
2878
|
}
|
|
2731
|
-
function
|
|
2879
|
+
function kn(e, t) {
|
|
2732
2880
|
if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
|
|
2733
2881
|
}
|
|
2734
|
-
function
|
|
2882
|
+
function An(e) {
|
|
2735
2883
|
if (!e) return;
|
|
2736
|
-
if (
|
|
2737
|
-
|
|
2884
|
+
if (kn(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
|
|
2885
|
+
Cn(e, "frontend autofill");
|
|
2738
2886
|
let t = e.maxAdditionalPages;
|
|
2739
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\".");
|
|
2740
2888
|
return;
|
|
@@ -2746,7 +2894,7 @@ function gn(e) {
|
|
|
2746
2894
|
if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
|
|
2747
2895
|
}
|
|
2748
2896
|
}
|
|
2749
|
-
function
|
|
2897
|
+
function jn(e, t, n = !0) {
|
|
2750
2898
|
if (!e) return {
|
|
2751
2899
|
cycleId: null,
|
|
2752
2900
|
delayRemainingMs: null,
|
|
@@ -2780,7 +2928,7 @@ function _n(e, t, n = !0) {
|
|
|
2780
2928
|
strategy: e.strategy
|
|
2781
2929
|
};
|
|
2782
2930
|
}
|
|
2783
|
-
function
|
|
2931
|
+
function Mn(e) {
|
|
2784
2932
|
return [
|
|
2785
2933
|
"cancelling",
|
|
2786
2934
|
"filling",
|
|
@@ -2788,9 +2936,9 @@ function vn(e) {
|
|
|
2788
2936
|
"waiting"
|
|
2789
2937
|
].includes(e.status);
|
|
2790
2938
|
}
|
|
2791
|
-
async function
|
|
2939
|
+
async function Nn(e, t, n) {
|
|
2792
2940
|
let r = t.autofill;
|
|
2793
|
-
if (!
|
|
2941
|
+
if (!Mn(r) || !r.cycleId) return;
|
|
2794
2942
|
let i = {
|
|
2795
2943
|
cycleId: r.cycleId,
|
|
2796
2944
|
feedKey: r.feedKey ?? "",
|
|
@@ -2803,16 +2951,16 @@ async function yn(e, t, n) {
|
|
|
2803
2951
|
throw r.error = e, r.status = "error", e;
|
|
2804
2952
|
}
|
|
2805
2953
|
}
|
|
2806
|
-
function
|
|
2954
|
+
function Pn(e, t, n) {
|
|
2807
2955
|
return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
|
|
2808
2956
|
}
|
|
2809
|
-
async function
|
|
2810
|
-
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;
|
|
2811
2959
|
for (; y < h;) {
|
|
2812
|
-
let e =
|
|
2960
|
+
let e = On(g);
|
|
2813
2961
|
if (m.has(e)) throw Error("Vibe autofill received a repeated cursor.");
|
|
2814
|
-
if (m.add(e), await
|
|
2815
|
-
delayMs:
|
|
2962
|
+
if (m.add(e), await Tn({
|
|
2963
|
+
delayMs: wn(l + y, s),
|
|
2816
2964
|
onChange: a,
|
|
2817
2965
|
signal: d
|
|
2818
2966
|
}), y > 0 && u()) return {
|
|
@@ -2826,7 +2974,7 @@ async function xn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2826
2974
|
status: "paused",
|
|
2827
2975
|
total: x
|
|
2828
2976
|
};
|
|
2829
|
-
let t =
|
|
2977
|
+
let t = fn(await n({
|
|
2830
2978
|
cursor: g,
|
|
2831
2979
|
signal: d
|
|
2832
2980
|
}));
|
|
@@ -2883,12 +3031,12 @@ async function xn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2883
3031
|
}
|
|
2884
3032
|
//#endregion
|
|
2885
3033
|
//#region src/core/autofillController.ts
|
|
2886
|
-
var
|
|
3034
|
+
var In = class {
|
|
2887
3035
|
collection = null;
|
|
2888
3036
|
cycle = 0;
|
|
2889
3037
|
delayCountdown;
|
|
2890
3038
|
constructor(e) {
|
|
2891
|
-
this.context = e, this.delayCountdown = new
|
|
3039
|
+
this.context = e, this.delayCountdown = new En((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
|
|
2892
3040
|
}
|
|
2893
3041
|
beginCycle() {
|
|
2894
3042
|
let { options: e, state: t } = this.context;
|
|
@@ -2896,14 +3044,14 @@ var Sn = class {
|
|
|
2896
3044
|
this.clear();
|
|
2897
3045
|
let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
2898
3046
|
return t.autofill = {
|
|
2899
|
-
...
|
|
3047
|
+
...jn(e, void 0, !1),
|
|
2900
3048
|
cycleId: n,
|
|
2901
3049
|
status: "filling"
|
|
2902
3050
|
}, n;
|
|
2903
3051
|
}
|
|
2904
3052
|
async cancel() {
|
|
2905
3053
|
let { cancelRequest: e, options: t, state: n } = this.context;
|
|
2906
|
-
await
|
|
3054
|
+
await Nn(t, n, e), this.commitCollection();
|
|
2907
3055
|
}
|
|
2908
3056
|
captureCollection(e, t) {
|
|
2909
3057
|
t && (this.collection = e);
|
|
@@ -2931,30 +3079,30 @@ var Sn = class {
|
|
|
2931
3079
|
requests: r.requests
|
|
2932
3080
|
}), !0) : !1;
|
|
2933
3081
|
}
|
|
2934
|
-
},
|
|
2935
|
-
function
|
|
3082
|
+
}, Ln = 100;
|
|
3083
|
+
function Rn(e, t) {
|
|
2936
3084
|
if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
|
|
2937
3085
|
}
|
|
2938
|
-
function
|
|
3086
|
+
function zn(e, t, n) {
|
|
2939
3087
|
return Math.min(n, Math.max(t, e));
|
|
2940
3088
|
}
|
|
2941
|
-
function
|
|
3089
|
+
function Bn(e) {
|
|
2942
3090
|
if (!e) return;
|
|
2943
3091
|
let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
|
|
2944
|
-
if (
|
|
2945
|
-
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);
|
|
2946
3094
|
}
|
|
2947
|
-
function
|
|
3095
|
+
function Vn(e) {
|
|
2948
3096
|
let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
|
|
2949
3097
|
return {
|
|
2950
3098
|
enabled: e?.enabled ?? !1,
|
|
2951
3099
|
maxSpeedPxPerSecond: n,
|
|
2952
3100
|
minSpeedPxPerSecond: t,
|
|
2953
3101
|
paused: !1,
|
|
2954
|
-
speedPxPerSecond:
|
|
3102
|
+
speedPxPerSecond: zn(e?.speedPxPerSecond ?? 80, t, n)
|
|
2955
3103
|
};
|
|
2956
3104
|
}
|
|
2957
|
-
var
|
|
3105
|
+
var Hn = class {
|
|
2958
3106
|
frame = null;
|
|
2959
3107
|
lastTimestamp = null;
|
|
2960
3108
|
mounted = !1;
|
|
@@ -2974,9 +3122,9 @@ var On = class {
|
|
|
2974
3122
|
this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
|
|
2975
3123
|
}
|
|
2976
3124
|
setSpeed(e) {
|
|
2977
|
-
|
|
3125
|
+
Rn("auto-scroll speed", e);
|
|
2978
3126
|
let t = this.options.state;
|
|
2979
|
-
t.speedPxPerSecond =
|
|
3127
|
+
t.speedPxPerSecond = zn(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
|
|
2980
3128
|
}
|
|
2981
3129
|
tick = (e) => {
|
|
2982
3130
|
this.frame = null;
|
|
@@ -2988,7 +3136,7 @@ var On = class {
|
|
|
2988
3136
|
return;
|
|
2989
3137
|
}
|
|
2990
3138
|
if (this.lastTimestamp !== null) {
|
|
2991
|
-
let r = Math.min(
|
|
3139
|
+
let r = Math.min(Ln, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
|
|
2992
3140
|
n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
|
|
2993
3141
|
}
|
|
2994
3142
|
this.lastTimestamp = e, this.schedule();
|
|
@@ -3002,7 +3150,7 @@ var On = class {
|
|
|
3002
3150
|
};
|
|
3003
3151
|
//#endregion
|
|
3004
3152
|
//#region src/core/backendAutofill.ts
|
|
3005
|
-
async function
|
|
3153
|
+
async function Un(e, t, n, r) {
|
|
3006
3154
|
let i = await e.onUnderfilled(n);
|
|
3007
3155
|
if (!r()) return;
|
|
3008
3156
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
|
|
@@ -3016,19 +3164,19 @@ async function kn(e, t, n, r) {
|
|
|
3016
3164
|
status: "waiting"
|
|
3017
3165
|
});
|
|
3018
3166
|
}
|
|
3019
|
-
function
|
|
3167
|
+
function Wn(e, t) {
|
|
3020
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);
|
|
3021
3169
|
}
|
|
3022
|
-
function
|
|
3170
|
+
function Gn(e, t, n) {
|
|
3023
3171
|
let r = t.autofill;
|
|
3024
|
-
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);
|
|
3025
3173
|
}
|
|
3026
|
-
function
|
|
3027
|
-
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);
|
|
3028
3176
|
}
|
|
3029
3177
|
//#endregion
|
|
3030
3178
|
//#region src/core/backlogRestore.ts
|
|
3031
|
-
async function
|
|
3179
|
+
async function qn(e, t, n) {
|
|
3032
3180
|
if (!e) return;
|
|
3033
3181
|
let r = new AbortController();
|
|
3034
3182
|
n(r);
|
|
@@ -3043,7 +3191,7 @@ async function Nn(e, t, n) {
|
|
|
3043
3191
|
}
|
|
3044
3192
|
//#endregion
|
|
3045
3193
|
//#region src/core/initialAutofill.ts
|
|
3046
|
-
async function
|
|
3194
|
+
async function Jn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
|
|
3047
3195
|
let c = a.autofill;
|
|
3048
3196
|
if (!c) return;
|
|
3049
3197
|
let l = s.items.length;
|
|
@@ -3056,7 +3204,7 @@ async function Pn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3056
3204
|
return;
|
|
3057
3205
|
}
|
|
3058
3206
|
if (c.strategy === "backend") {
|
|
3059
|
-
await
|
|
3207
|
+
await Un(c, s, {
|
|
3060
3208
|
cycleId: e,
|
|
3061
3209
|
feedKey: c.feedKey,
|
|
3062
3210
|
items: [...s.items],
|
|
@@ -3073,11 +3221,11 @@ async function Pn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3073
3221
|
s.autofill.status = "exhausted";
|
|
3074
3222
|
return;
|
|
3075
3223
|
}
|
|
3076
|
-
let u = await
|
|
3224
|
+
let u = await Fn({
|
|
3077
3225
|
existingItems: s.items,
|
|
3078
3226
|
initialCursor: s.next,
|
|
3079
3227
|
loadPage: a.loadPage,
|
|
3080
|
-
maximumRequests:
|
|
3228
|
+
maximumRequests: Dn(c, !1),
|
|
3081
3229
|
onCollection: n,
|
|
3082
3230
|
onDelayChange: (e) => {
|
|
3083
3231
|
t() && Object.assign(s.autofill, e);
|
|
@@ -3100,13 +3248,13 @@ async function Pn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
3100
3248
|
}
|
|
3101
3249
|
//#endregion
|
|
3102
3250
|
//#region src/core/fill.ts
|
|
3103
|
-
function
|
|
3251
|
+
function Yn(e) {
|
|
3104
3252
|
return "items" in e ? { items: e.items } : "pages" in e ? { pages: e.pages } : { until: "end" };
|
|
3105
3253
|
}
|
|
3106
|
-
function
|
|
3254
|
+
function Xn(e) {
|
|
3107
3255
|
return `${typeof e}:${String(e)}`;
|
|
3108
3256
|
}
|
|
3109
|
-
function
|
|
3257
|
+
function Zn(e) {
|
|
3110
3258
|
if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
|
|
3111
3259
|
if ("pages" in e) {
|
|
3112
3260
|
if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
|
|
@@ -3119,20 +3267,20 @@ function Ln(e) {
|
|
|
3119
3267
|
if ("until" in e && e.until === "end") return { until: "end" };
|
|
3120
3268
|
throw TypeError("Vibe fill target must be { items }, { pages }, or { until: 'end' }.");
|
|
3121
3269
|
}
|
|
3122
|
-
function
|
|
3270
|
+
function Qn(e) {
|
|
3123
3271
|
if (!e) return;
|
|
3124
3272
|
if (e.strategy === "frontend") {
|
|
3125
|
-
|
|
3273
|
+
Cn(e, "frontend fill");
|
|
3126
3274
|
return;
|
|
3127
3275
|
}
|
|
3128
3276
|
if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
|
|
3129
3277
|
let t = e.initialSession;
|
|
3130
3278
|
if (t) {
|
|
3131
3279
|
if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
|
|
3132
|
-
|
|
3280
|
+
Zn(t.target);
|
|
3133
3281
|
}
|
|
3134
3282
|
}
|
|
3135
|
-
function
|
|
3283
|
+
function $n(e, t, n = !0) {
|
|
3136
3284
|
let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
|
|
3137
3285
|
return {
|
|
3138
3286
|
completedPages: i?.completedPages ?? 0,
|
|
@@ -3146,10 +3294,10 @@ function zn(e, t, n = !0) {
|
|
|
3146
3294
|
sessionId: i?.sessionId ?? null,
|
|
3147
3295
|
status: i?.status ?? "idle",
|
|
3148
3296
|
strategy: e?.strategy ?? null,
|
|
3149
|
-
target: i ?
|
|
3297
|
+
target: i ? Yn(i.target) : null
|
|
3150
3298
|
};
|
|
3151
3299
|
}
|
|
3152
|
-
function
|
|
3300
|
+
function er(e) {
|
|
3153
3301
|
return [
|
|
3154
3302
|
"cancelling",
|
|
3155
3303
|
"filling",
|
|
@@ -3157,7 +3305,7 @@ function Bn(e) {
|
|
|
3157
3305
|
"waiting"
|
|
3158
3306
|
].includes(e.status);
|
|
3159
3307
|
}
|
|
3160
|
-
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 }) {
|
|
3161
3309
|
let u = [], d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = 0, h = t, g = t, _ = t, v = 0, y;
|
|
3162
3310
|
if ("items" in l && f.length >= l.items) return {
|
|
3163
3311
|
completedPages: m,
|
|
@@ -3169,10 +3317,10 @@ async function Vn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3169
3317
|
status: "complete"
|
|
3170
3318
|
};
|
|
3171
3319
|
for (; _ !== null;) {
|
|
3172
|
-
let e =
|
|
3320
|
+
let e = Xn(h);
|
|
3173
3321
|
if (p.has(e)) throw Error("Vibe fill received a repeated cursor.");
|
|
3174
|
-
if (p.add(e), await
|
|
3175
|
-
delayMs:
|
|
3322
|
+
if (p.add(e), await Tn({
|
|
3323
|
+
delayMs: wn(m, o),
|
|
3176
3324
|
onChange: i,
|
|
3177
3325
|
signal: c
|
|
3178
3326
|
}), m > 0 && s()) return {
|
|
@@ -3185,7 +3333,7 @@ async function Vn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3185
3333
|
status: "paused",
|
|
3186
3334
|
total: y
|
|
3187
3335
|
};
|
|
3188
|
-
let t =
|
|
3336
|
+
let t = fn(await n({
|
|
3189
3337
|
cursor: h,
|
|
3190
3338
|
signal: c
|
|
3191
3339
|
}));
|
|
@@ -3253,7 +3401,7 @@ async function Vn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
3253
3401
|
}
|
|
3254
3402
|
//#endregion
|
|
3255
3403
|
//#region src/core/backendFill.ts
|
|
3256
|
-
async function
|
|
3404
|
+
async function nr(e, t, n, r) {
|
|
3257
3405
|
let i = await e.onStart(n);
|
|
3258
3406
|
if (r()) {
|
|
3259
3407
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
|
|
@@ -3267,22 +3415,22 @@ async function Hn(e, t, n, r) {
|
|
|
3267
3415
|
});
|
|
3268
3416
|
}
|
|
3269
3417
|
}
|
|
3270
|
-
function
|
|
3418
|
+
function rr(e, t, n) {
|
|
3271
3419
|
return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
|
|
3272
3420
|
}
|
|
3273
|
-
function
|
|
3421
|
+
function ir(e) {
|
|
3274
3422
|
return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
|
|
3275
3423
|
}
|
|
3276
|
-
function
|
|
3424
|
+
function ar(e, t) {
|
|
3277
3425
|
if (!["complete", "exhausted"].includes(t.status)) return !0;
|
|
3278
3426
|
let n = e.fill.target;
|
|
3279
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;
|
|
3280
3428
|
}
|
|
3281
|
-
function
|
|
3429
|
+
function or(e, t, n) {
|
|
3282
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));
|
|
3283
3431
|
}
|
|
3284
|
-
function
|
|
3285
|
-
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, {
|
|
3286
3434
|
...Q(n.status === "waiting" ? n.nextRequestAt : null),
|
|
3287
3435
|
completedPages: n.completedPages,
|
|
3288
3436
|
error: n.error ?? null,
|
|
@@ -3291,45 +3439,45 @@ function qn(e, t, n, r) {
|
|
|
3291
3439
|
status: n.status
|
|
3292
3440
|
}), !0);
|
|
3293
3441
|
}
|
|
3294
|
-
function
|
|
3442
|
+
function cr(e, t, n, r) {
|
|
3295
3443
|
if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
|
|
3296
3444
|
let i = t.fill;
|
|
3297
|
-
return t.fill =
|
|
3445
|
+
return t.fill = $n(e, n), !ir(n) || !ar(t, n) ? (t.fill = i, !1) : (or(t, n, r), !0);
|
|
3298
3446
|
}
|
|
3299
3447
|
//#endregion
|
|
3300
3448
|
//#region src/core/fillController.ts
|
|
3301
|
-
var
|
|
3449
|
+
var lr = class {
|
|
3302
3450
|
abortController = null;
|
|
3303
3451
|
cycle = 0;
|
|
3304
3452
|
delayCountdown;
|
|
3305
3453
|
requestVersion = 0;
|
|
3306
3454
|
collection = null;
|
|
3307
3455
|
constructor(e) {
|
|
3308
|
-
this.options = e, this.delayCountdown = new
|
|
3456
|
+
this.options = e, this.delayCountdown = new En((e) => {
|
|
3309
3457
|
Object.assign(this.options.state.fill, e);
|
|
3310
3458
|
}), this.syncBackendCountdown();
|
|
3311
3459
|
}
|
|
3312
3460
|
isActive() {
|
|
3313
|
-
return
|
|
3461
|
+
return er(this.options.state.fill);
|
|
3314
3462
|
}
|
|
3315
3463
|
applyUpdate(e) {
|
|
3316
|
-
let t =
|
|
3464
|
+
let t = sr(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
3317
3465
|
return t && this.syncBackendCountdown(), t;
|
|
3318
3466
|
}
|
|
3319
3467
|
restoreSession(e) {
|
|
3320
|
-
let t =
|
|
3468
|
+
let t = cr(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
3321
3469
|
return t && this.syncBackendCountdown(), t;
|
|
3322
3470
|
}
|
|
3323
3471
|
async start(e, t = {}) {
|
|
3324
3472
|
let n = this.options.fill;
|
|
3325
3473
|
if (!n) throw Error("Vibe fill is not configured.");
|
|
3326
3474
|
if (this.isActive()) throw Error("Vibe fill is already active.");
|
|
3327
|
-
let r =
|
|
3475
|
+
let r = Zn(e), i = Zn(t.target ?? r), a = t.progressOffset ?? {
|
|
3328
3476
|
completedPages: 0,
|
|
3329
3477
|
received: 0
|
|
3330
3478
|
}, o = t.cycleId ?? `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
3331
3479
|
if (this.options.state.fill = {
|
|
3332
|
-
|
|
3480
|
+
...$n(n, void 0, !1),
|
|
3333
3481
|
completedPages: a.completedPages,
|
|
3334
3482
|
cycleId: o,
|
|
3335
3483
|
received: a.received,
|
|
@@ -3342,7 +3490,7 @@ var Yn = class {
|
|
|
3342
3490
|
let s = ++this.requestVersion, c = new AbortController();
|
|
3343
3491
|
this.abortController = c;
|
|
3344
3492
|
try {
|
|
3345
|
-
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, {
|
|
3346
3494
|
cycleId: o,
|
|
3347
3495
|
feedKey: n.feedKey,
|
|
3348
3496
|
items: [...this.options.state.items],
|
|
@@ -3360,7 +3508,7 @@ var Yn = class {
|
|
|
3360
3508
|
}
|
|
3361
3509
|
async cancel() {
|
|
3362
3510
|
let { fill: e, state: t } = this.options;
|
|
3363
|
-
if (!
|
|
3511
|
+
if (!er(t.fill) || !t.fill.cycleId) return;
|
|
3364
3512
|
let n = {
|
|
3365
3513
|
cycleId: t.fill.cycleId,
|
|
3366
3514
|
feedKey: t.fill.feedKey ?? "",
|
|
@@ -3404,7 +3552,7 @@ var Yn = class {
|
|
|
3404
3552
|
});
|
|
3405
3553
|
}
|
|
3406
3554
|
reset() {
|
|
3407
|
-
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;
|
|
3408
3556
|
}
|
|
3409
3557
|
destroy() {
|
|
3410
3558
|
this.abortLocalRequest(), this.delayCountdown.clear();
|
|
@@ -3439,7 +3587,7 @@ var Yn = class {
|
|
|
3439
3587
|
s.fill.status = "until" in t ? "complete" : "exhausted";
|
|
3440
3588
|
return;
|
|
3441
3589
|
}
|
|
3442
|
-
let c = await
|
|
3590
|
+
let c = await tr({
|
|
3443
3591
|
existingItems: s.items,
|
|
3444
3592
|
initialCursor: s.next,
|
|
3445
3593
|
loadPage: o,
|
|
@@ -3487,7 +3635,7 @@ var Yn = class {
|
|
|
3487
3635
|
};
|
|
3488
3636
|
//#endregion
|
|
3489
3637
|
//#region src/core/fillReconciliation.ts
|
|
3490
|
-
async function
|
|
3638
|
+
async function ur({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, setLastCursor: i, signal: a, state: o }) {
|
|
3491
3639
|
if (!e.needsReconciliation(o.items)) return "skipped";
|
|
3492
3640
|
let s = await e.reconcile({
|
|
3493
3641
|
existingItems: o.items,
|
|
@@ -3500,7 +3648,7 @@ async function Xn({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r,
|
|
|
3500
3648
|
}
|
|
3501
3649
|
//#endregion
|
|
3502
3650
|
//#region src/core/feedFooter.ts
|
|
3503
|
-
function
|
|
3651
|
+
function dr(e) {
|
|
3504
3652
|
return {
|
|
3505
3653
|
cancelAutofill: () => e.cancelAutofill(),
|
|
3506
3654
|
loadMore: () => e.loadNext(),
|
|
@@ -3512,46 +3660,46 @@ function Zn(e) {
|
|
|
3512
3660
|
retryFill: () => e.retryFill()
|
|
3513
3661
|
};
|
|
3514
3662
|
}
|
|
3515
|
-
function
|
|
3663
|
+
function fr(e) {
|
|
3516
3664
|
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
3517
3665
|
}
|
|
3518
|
-
function
|
|
3519
|
-
e?.intervalMs !== void 0 &&
|
|
3666
|
+
function pr(e) {
|
|
3667
|
+
e?.intervalMs !== void 0 && fr(e.intervalMs);
|
|
3520
3668
|
}
|
|
3521
|
-
function
|
|
3669
|
+
function mr(e) {
|
|
3522
3670
|
return {
|
|
3523
3671
|
enabled: e?.enabled ?? !1,
|
|
3524
3672
|
includePostItems: e?.includePostItems ?? !1,
|
|
3525
3673
|
intervalMs: e?.intervalMs ?? 5e3
|
|
3526
3674
|
};
|
|
3527
3675
|
}
|
|
3528
|
-
function
|
|
3676
|
+
function hr(e, t) {
|
|
3529
3677
|
if (typeof t == "boolean") {
|
|
3530
3678
|
e.enabled = t;
|
|
3531
3679
|
return;
|
|
3532
3680
|
}
|
|
3533
|
-
|
|
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);
|
|
3534
3682
|
}
|
|
3535
3683
|
//#endregion
|
|
3536
3684
|
//#region src/core/reelInfoSheet.ts
|
|
3537
|
-
function
|
|
3685
|
+
function gr(e) {
|
|
3538
3686
|
return { enabled: e?.enabled ?? !1 };
|
|
3539
3687
|
}
|
|
3540
|
-
function
|
|
3688
|
+
function _r(e, t, n) {
|
|
3541
3689
|
if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
|
|
3542
3690
|
e.enabled = n;
|
|
3543
3691
|
}
|
|
3544
3692
|
//#endregion
|
|
3545
3693
|
//#region src/core/initialRuntimeState.ts
|
|
3546
|
-
function
|
|
3694
|
+
function vr(e, t) {
|
|
3547
3695
|
let n = e.initialPage;
|
|
3548
3696
|
return {
|
|
3549
3697
|
activeReelPostId: null,
|
|
3550
|
-
autoScroll:
|
|
3551
|
-
autofill:
|
|
3698
|
+
autoScroll: Vn(e.autoScroll),
|
|
3699
|
+
autofill: jn(e.autofill),
|
|
3552
3700
|
current: n?.current ?? null,
|
|
3553
3701
|
error: null,
|
|
3554
|
-
fill:
|
|
3702
|
+
fill: $n(e.fill),
|
|
3555
3703
|
infiniteScroll: e.infiniteScroll ?? !0,
|
|
3556
3704
|
isLoading: !n,
|
|
3557
3705
|
isLoadingMore: !1,
|
|
@@ -3562,14 +3710,14 @@ function ir(e, t) {
|
|
|
3562
3710
|
next: n?.next ?? null,
|
|
3563
3711
|
nextPageError: null,
|
|
3564
3712
|
phoneMode: !1,
|
|
3565
|
-
reelAutoAdvance:
|
|
3713
|
+
reelAutoAdvance: mr(e.reelAutoAdvance),
|
|
3566
3714
|
reelForward: {
|
|
3567
3715
|
error: null,
|
|
3568
3716
|
status: "idle"
|
|
3569
3717
|
},
|
|
3570
3718
|
reelForwardIndex: null,
|
|
3571
3719
|
reelForwardItem: null,
|
|
3572
|
-
reelInfoSheet:
|
|
3720
|
+
reelInfoSheet: gr(e.reelInfoSheet),
|
|
3573
3721
|
reelInfoSheetOverlay: !1,
|
|
3574
3722
|
reelMediaSource: "original",
|
|
3575
3723
|
reelOrigin: null,
|
|
@@ -3578,20 +3726,21 @@ function ir(e, t) {
|
|
|
3578
3726
|
}
|
|
3579
3727
|
//#endregion
|
|
3580
3728
|
//#region src/core/options.ts
|
|
3581
|
-
function
|
|
3729
|
+
function yr(e, t) {
|
|
3582
3730
|
if (t) {
|
|
3583
3731
|
if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
|
|
3584
3732
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
|
|
3585
3733
|
}
|
|
3586
3734
|
}
|
|
3587
|
-
function
|
|
3735
|
+
function br(e, t) {
|
|
3588
3736
|
if (t) {
|
|
3589
3737
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
|
|
3590
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.`);
|
|
3591
3739
|
}
|
|
3592
3740
|
}
|
|
3593
|
-
function
|
|
3594
|
-
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) {
|
|
3595
3744
|
if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
|
|
3596
3745
|
let t = e.removalReconciliation.maxReplayPages ?? 5;
|
|
3597
3746
|
if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
|
|
@@ -3606,7 +3755,7 @@ function sr(e) {
|
|
|
3606
3755
|
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
3607
3756
|
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
3608
3757
|
}
|
|
3609
|
-
function
|
|
3758
|
+
function Sr(e) {
|
|
3610
3759
|
if (typeof e != "string") return e;
|
|
3611
3760
|
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
3612
3761
|
let t = document.querySelector(e);
|
|
@@ -3615,7 +3764,7 @@ function cr(e) {
|
|
|
3615
3764
|
}
|
|
3616
3765
|
//#endregion
|
|
3617
3766
|
//#region src/core/pageRequest.ts
|
|
3618
|
-
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 }) {
|
|
3619
3768
|
let u = s.autofill, d = e && u?.strategy === "frontend" && (l.autofill.status === "paused" || l.autofill.status === "error"), f = d ? {
|
|
3620
3769
|
received: l.autofill.received,
|
|
3621
3770
|
requests: l.autofill.requests
|
|
@@ -3627,11 +3776,11 @@ async function lr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3627
3776
|
let m = !1;
|
|
3628
3777
|
try {
|
|
3629
3778
|
if (u?.strategy === "frontend") {
|
|
3630
|
-
let s = await
|
|
3779
|
+
let s = await Fn({
|
|
3631
3780
|
existingItems: e ? l.items : [],
|
|
3632
3781
|
initialCursor: n,
|
|
3633
3782
|
loadPage: i,
|
|
3634
|
-
maximumRequests: f ? Math.max(0,
|
|
3783
|
+
maximumRequests: f ? Math.max(0, Dn(u) - f.requests) : void 0,
|
|
3635
3784
|
onCollection: (e) => t.captureCollection(e, r()),
|
|
3636
3785
|
onDelayChange: (e) => {
|
|
3637
3786
|
r() && Object.assign(l.autofill, e);
|
|
@@ -3654,7 +3803,7 @@ async function lr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3654
3803
|
}), o(s.pages), t.clearCollection();
|
|
3655
3804
|
return;
|
|
3656
3805
|
}
|
|
3657
|
-
let s =
|
|
3806
|
+
let s = fn(await i({
|
|
3658
3807
|
cursor: n,
|
|
3659
3808
|
signal: c
|
|
3660
3809
|
}));
|
|
@@ -3674,7 +3823,7 @@ async function lr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3674
3823
|
l.autofill.status = "complete";
|
|
3675
3824
|
return;
|
|
3676
3825
|
}
|
|
3677
|
-
await
|
|
3826
|
+
await Un(u, l, {
|
|
3678
3827
|
cycleId: p,
|
|
3679
3828
|
feedKey: u.feedKey,
|
|
3680
3829
|
items: h.slice(d.length),
|
|
@@ -3699,13 +3848,13 @@ async function lr({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3699
3848
|
function $(e) {
|
|
3700
3849
|
return `${typeof e}:${String(e)}`;
|
|
3701
3850
|
}
|
|
3702
|
-
function
|
|
3851
|
+
function wr(e) {
|
|
3703
3852
|
return `${typeof e}:${String(e)}`;
|
|
3704
3853
|
}
|
|
3705
|
-
function
|
|
3854
|
+
function Tr(e) {
|
|
3706
3855
|
return e.map(({ postId: e }) => e);
|
|
3707
3856
|
}
|
|
3708
|
-
var
|
|
3857
|
+
var Er = class {
|
|
3709
3858
|
delay;
|
|
3710
3859
|
enabled;
|
|
3711
3860
|
maxReplayPages;
|
|
@@ -3737,10 +3886,10 @@ var fr = class {
|
|
|
3737
3886
|
}
|
|
3738
3887
|
recordInitialPage(e) {
|
|
3739
3888
|
e && this.recordPages([{
|
|
3740
|
-
contributionIds:
|
|
3741
|
-
cursor:
|
|
3889
|
+
contributionIds: Tr(e.items),
|
|
3890
|
+
cursor: gn(e),
|
|
3742
3891
|
next: e.next,
|
|
3743
|
-
returnedIds:
|
|
3892
|
+
returnedIds: Tr(e.items)
|
|
3744
3893
|
}]);
|
|
3745
3894
|
}
|
|
3746
3895
|
remove(e) {
|
|
@@ -3755,14 +3904,14 @@ var fr = class {
|
|
|
3755
3904
|
async reconcile({ existingItems: e, loadPage: t, onDelayChange: n = () => void 0, shouldPause: r = () => !1, signal: i }) {
|
|
3756
3905
|
let a = this.pending ?? this.createSession(e);
|
|
3757
3906
|
for (this.pending = a; a.remainingRequests > 0;) {
|
|
3758
|
-
let e =
|
|
3907
|
+
let e = wr(a.cursor);
|
|
3759
3908
|
if (a.seenCursors.has(e)) throw Error("Vibe removal reconciliation received a repeated cursor.");
|
|
3760
|
-
if (await
|
|
3761
|
-
delayMs:
|
|
3909
|
+
if (await Tn({
|
|
3910
|
+
delayMs: wn(a.pages.length, this.delay),
|
|
3762
3911
|
onChange: n,
|
|
3763
3912
|
signal: i
|
|
3764
3913
|
}), a.pages.length > 0 && r()) return this.result(a, "paused");
|
|
3765
|
-
let o =
|
|
3914
|
+
let o = fn(await t({
|
|
3766
3915
|
cursor: a.cursor,
|
|
3767
3916
|
signal: i
|
|
3768
3917
|
}));
|
|
@@ -3775,7 +3924,7 @@ var fr = class {
|
|
|
3775
3924
|
contributionIds: c,
|
|
3776
3925
|
cursor: a.cursor,
|
|
3777
3926
|
next: o.next,
|
|
3778
|
-
returnedIds:
|
|
3927
|
+
returnedIds: Tr(s)
|
|
3779
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");
|
|
3780
3929
|
}
|
|
3781
3930
|
return this.result(a, "complete");
|
|
@@ -3814,7 +3963,7 @@ var fr = class {
|
|
|
3814
3963
|
return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
|
|
3815
3964
|
}
|
|
3816
3965
|
recordPage(e) {
|
|
3817
|
-
let t =
|
|
3966
|
+
let t = wr(e.cursor), n = this.pages.findIndex(({ cursor: e }) => wr(e) === t);
|
|
3818
3967
|
n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
|
|
3819
3968
|
...e,
|
|
3820
3969
|
contributionIds: [...e.contributionIds],
|
|
@@ -3824,7 +3973,7 @@ var fr = class {
|
|
|
3824
3973
|
};
|
|
3825
3974
|
//#endregion
|
|
3826
3975
|
//#region src/core/activeItemRemoval.ts
|
|
3827
|
-
function
|
|
3976
|
+
function Dr(e, t, n, r, i) {
|
|
3828
3977
|
let a = new Set(t.map(({ item: e }) => e.postId));
|
|
3829
3978
|
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
3830
3979
|
let o = e.items[Math.max(n, 0)];
|
|
@@ -3837,7 +3986,7 @@ function pr(e, t, n, r, i) {
|
|
|
3837
3986
|
}
|
|
3838
3987
|
//#endregion
|
|
3839
3988
|
//#region src/core/exactMediaRemovalController.ts
|
|
3840
|
-
function
|
|
3989
|
+
function Or(e, t) {
|
|
3841
3990
|
let [n, ...r] = t;
|
|
3842
3991
|
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
3843
3992
|
return {
|
|
@@ -3846,10 +3995,10 @@ function mr(e, t) {
|
|
|
3846
3995
|
items: r
|
|
3847
3996
|
};
|
|
3848
3997
|
}
|
|
3849
|
-
function
|
|
3998
|
+
function kr(e) {
|
|
3850
3999
|
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
3851
4000
|
}
|
|
3852
|
-
var
|
|
4001
|
+
var Ar = class {
|
|
3853
4002
|
generation = 0;
|
|
3854
4003
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
3855
4004
|
state;
|
|
@@ -3857,7 +4006,7 @@ var gr = class {
|
|
|
3857
4006
|
this.options = e, this.state = e.state;
|
|
3858
4007
|
}
|
|
3859
4008
|
remove(e) {
|
|
3860
|
-
|
|
4009
|
+
kr(e);
|
|
3861
4010
|
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
3862
4011
|
if (!n) return null;
|
|
3863
4012
|
let r = [...P(n)], i = r[e.mediaIndex];
|
|
@@ -3874,7 +4023,7 @@ var gr = class {
|
|
|
3874
4023
|
restored: !1
|
|
3875
4024
|
});
|
|
3876
4025
|
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
3877
|
-
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);
|
|
3878
4027
|
}
|
|
3879
4028
|
reset() {
|
|
3880
4029
|
this.generation += 1;
|
|
@@ -3900,7 +4049,7 @@ var gr = class {
|
|
|
3900
4049
|
}
|
|
3901
4050
|
restoreIntoPost(e, t) {
|
|
3902
4051
|
let n = this.state.items[e], r = [...P(n)], i = Math.min(t.mediaIndex, r.length);
|
|
3903
|
-
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;
|
|
3904
4053
|
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
3905
4054
|
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
3906
4055
|
}
|
|
@@ -3913,18 +4062,18 @@ var gr = class {
|
|
|
3913
4062
|
};
|
|
3914
4063
|
//#endregion
|
|
3915
4064
|
//#region src/core/itemPlacement.ts
|
|
3916
|
-
function
|
|
4065
|
+
function jr(e, t) {
|
|
3917
4066
|
let n = new Set(t);
|
|
3918
4067
|
return e.flatMap((e, t) => n.has(e.postId) ? [{
|
|
3919
4068
|
index: t,
|
|
3920
4069
|
item: e
|
|
3921
4070
|
}] : []);
|
|
3922
4071
|
}
|
|
3923
|
-
function
|
|
4072
|
+
function Mr(e, t) {
|
|
3924
4073
|
let n = new Set(t.map(({ item: e }) => e.postId));
|
|
3925
4074
|
return e.filter((e) => !n.has(e.postId));
|
|
3926
4075
|
}
|
|
3927
|
-
function
|
|
4076
|
+
function Nr(e, t) {
|
|
3928
4077
|
t.forEach(({ index: e }) => {
|
|
3929
4078
|
if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
|
|
3930
4079
|
});
|
|
@@ -3935,7 +4084,7 @@ function yr(e, t) {
|
|
|
3935
4084
|
}
|
|
3936
4085
|
//#endregion
|
|
3937
4086
|
//#region src/core/itemRemovalController.ts
|
|
3938
|
-
var
|
|
4087
|
+
var Pr = 20, Fr = class {
|
|
3939
4088
|
generation = 0;
|
|
3940
4089
|
historyLimit;
|
|
3941
4090
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -3944,7 +4093,7 @@ var br = 20, xr = class {
|
|
|
3944
4093
|
itemOrder;
|
|
3945
4094
|
stopItemsWatcher;
|
|
3946
4095
|
constructor(e) {
|
|
3947
|
-
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" });
|
|
3948
4097
|
}
|
|
3949
4098
|
destroy() {
|
|
3950
4099
|
this.reset(), this.stopItemsWatcher();
|
|
@@ -3958,7 +4107,7 @@ var br = 20, xr = class {
|
|
|
3958
4107
|
let a = this.options.startRemoval(i, t);
|
|
3959
4108
|
if (a > 0 && await new Promise((e) => setTimeout(e, a)), this.metadata.get(r)?.generation !== this.generation) return r;
|
|
3960
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);
|
|
3961
|
-
return this.state.items =
|
|
4110
|
+
return this.state.items = Mr(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
|
|
3962
4111
|
}
|
|
3963
4112
|
reset() {
|
|
3964
4113
|
this.generation += 1, this.history = [], this.itemOrder = [];
|
|
@@ -3969,7 +4118,7 @@ var br = 20, xr = class {
|
|
|
3969
4118
|
this.restoreRemoval(t);
|
|
3970
4119
|
return;
|
|
3971
4120
|
}
|
|
3972
|
-
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);
|
|
3973
4122
|
this.registerExternalPlacements(r), this.state.items = i, r.length > 0 && this.options.onRemovalRestored(r);
|
|
3974
4123
|
}
|
|
3975
4124
|
restoreRemoval(e) {
|
|
@@ -3995,7 +4144,7 @@ var br = 20, xr = class {
|
|
|
3995
4144
|
}
|
|
3996
4145
|
collectOrderedPlacements(e) {
|
|
3997
4146
|
let t = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
3998
|
-
return
|
|
4147
|
+
return jr(this.state.items, e).map((e) => ({
|
|
3999
4148
|
index: t.get(e.item.postId) ?? e.index,
|
|
4000
4149
|
item: e.item
|
|
4001
4150
|
}));
|
|
@@ -4026,7 +4175,7 @@ var br = 20, xr = class {
|
|
|
4026
4175
|
let r = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
4027
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;
|
|
4028
4177
|
}
|
|
4029
|
-
},
|
|
4178
|
+
}, Ir = class {
|
|
4030
4179
|
forward = null;
|
|
4031
4180
|
forwardPromise = null;
|
|
4032
4181
|
forwardVersion = 0;
|
|
@@ -4113,7 +4262,7 @@ var br = 20, xr = class {
|
|
|
4113
4262
|
}
|
|
4114
4263
|
}
|
|
4115
4264
|
}
|
|
4116
|
-
},
|
|
4265
|
+
}, Lr = class {
|
|
4117
4266
|
generation = 0;
|
|
4118
4267
|
pending = Promise.resolve();
|
|
4119
4268
|
constructor(e) {
|
|
@@ -4163,24 +4312,24 @@ var br = 20, xr = class {
|
|
|
4163
4312
|
};
|
|
4164
4313
|
//#endregion
|
|
4165
4314
|
//#region src/core/removalControllers.ts
|
|
4166
|
-
function
|
|
4167
|
-
let t = new
|
|
4315
|
+
function Rr(e) {
|
|
4316
|
+
let t = new Ir(e), n = new Lr({
|
|
4168
4317
|
state: e.state,
|
|
4169
4318
|
transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
|
|
4170
4319
|
transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
|
|
4171
4320
|
});
|
|
4172
4321
|
return {
|
|
4173
|
-
exactMediaRemoval: new
|
|
4322
|
+
exactMediaRemoval: new Ar({
|
|
4174
4323
|
onActivate: e.onActivate,
|
|
4175
4324
|
onPostRemoved: (t) => e.onItemsRemoved([t]),
|
|
4176
4325
|
onPostRestored: (t) => e.onItemsRestored([t]),
|
|
4177
4326
|
reelForward: t,
|
|
4178
4327
|
state: e.state
|
|
4179
4328
|
}),
|
|
4180
|
-
itemRemoval: new
|
|
4329
|
+
itemRemoval: new Fr({
|
|
4181
4330
|
historyLimit: e.historyLimit,
|
|
4182
4331
|
onItemsRemoved: (n, r, i) => {
|
|
4183
|
-
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));
|
|
4184
4333
|
},
|
|
4185
4334
|
onRemovalRestored: (n) => {
|
|
4186
4335
|
e.onItemsRestored(n.map(({ item: e }) => e.postId));
|
|
@@ -4195,17 +4344,17 @@ function wr(e) {
|
|
|
4195
4344
|
reelRemoval: n
|
|
4196
4345
|
};
|
|
4197
4346
|
}
|
|
4198
|
-
var
|
|
4199
|
-
function
|
|
4347
|
+
var zr = 1.5;
|
|
4348
|
+
function Br(e) {
|
|
4200
4349
|
let t = Math.min(e.screenWidth, e.screenHeight);
|
|
4201
4350
|
if (t > 0 && t < 600) return !0;
|
|
4202
|
-
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n *
|
|
4351
|
+
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * zr;
|
|
4203
4352
|
return !e.hasHover && n > 0 && n < 600 && r;
|
|
4204
4353
|
}
|
|
4205
|
-
function
|
|
4206
|
-
return
|
|
4354
|
+
function Vr(e) {
|
|
4355
|
+
return Br(e) ? "reel" : "masonry";
|
|
4207
4356
|
}
|
|
4208
|
-
function
|
|
4357
|
+
function Hr(e) {
|
|
4209
4358
|
let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
|
|
4210
4359
|
return {
|
|
4211
4360
|
hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
|
|
@@ -4215,15 +4364,15 @@ function Or(e) {
|
|
|
4215
4364
|
viewportWidth: n.clientWidth
|
|
4216
4365
|
};
|
|
4217
4366
|
}
|
|
4218
|
-
function
|
|
4219
|
-
return
|
|
4367
|
+
function Ur(e) {
|
|
4368
|
+
return Br(Hr(e));
|
|
4220
4369
|
}
|
|
4221
|
-
function
|
|
4222
|
-
return
|
|
4370
|
+
function Wr(e) {
|
|
4371
|
+
return Vr(Hr(e));
|
|
4223
4372
|
}
|
|
4224
4373
|
//#endregion
|
|
4225
4374
|
//#region src/core/responsiveLayoutController.ts
|
|
4226
|
-
var
|
|
4375
|
+
var Gr = class {
|
|
4227
4376
|
layoutMode;
|
|
4228
4377
|
resizeObserver = null;
|
|
4229
4378
|
target = null;
|
|
@@ -4248,13 +4397,13 @@ var jr = class {
|
|
|
4248
4397
|
}
|
|
4249
4398
|
handleResponsiveLayout = () => {
|
|
4250
4399
|
if (!this.target) return;
|
|
4251
|
-
let e =
|
|
4252
|
-
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);
|
|
4253
4402
|
};
|
|
4254
|
-
},
|
|
4403
|
+
}, Kr = class {
|
|
4255
4404
|
state;
|
|
4256
4405
|
constructor(e) {
|
|
4257
|
-
this.options = e, this.state = x(
|
|
4406
|
+
this.options = e, this.state = x($e({
|
|
4258
4407
|
...e.initialReelAudioState,
|
|
4259
4408
|
muted: e.initialReelAudioState?.muted ?? e.mediaCard?.videoMuted ?? !1
|
|
4260
4409
|
}));
|
|
@@ -4263,9 +4412,9 @@ var jr = class {
|
|
|
4263
4412
|
return { ...this.state };
|
|
4264
4413
|
}
|
|
4265
4414
|
set(e, t = !1) {
|
|
4266
|
-
Object.assign(this.state,
|
|
4415
|
+
Object.assign(this.state, $e(e, this.state)), t && this.options.onReelAudioStateChange?.(this.get());
|
|
4267
4416
|
}
|
|
4268
|
-
},
|
|
4417
|
+
}, qr = class {
|
|
4269
4418
|
routedReelPostId = null;
|
|
4270
4419
|
reelRouteIsActive = !1;
|
|
4271
4420
|
constructor(e, t) {
|
|
@@ -4292,7 +4441,7 @@ var jr = class {
|
|
|
4292
4441
|
let i = this.reelRouteIsActive ? "replace" : "push";
|
|
4293
4442
|
this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
|
|
4294
4443
|
}
|
|
4295
|
-
},
|
|
4444
|
+
}, Jr = class {
|
|
4296
4445
|
app = null;
|
|
4297
4446
|
autoScroll;
|
|
4298
4447
|
autofillController;
|
|
@@ -4315,24 +4464,24 @@ var jr = class {
|
|
|
4315
4464
|
reelAudio;
|
|
4316
4465
|
state;
|
|
4317
4466
|
constructor(e) {
|
|
4318
|
-
this.options = e,
|
|
4467
|
+
this.options = e, xr(e);
|
|
4319
4468
|
let t = e.layout ?? "masonry";
|
|
4320
|
-
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({
|
|
4321
4470
|
getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
|
|
4322
4471
|
state: this.state.autoScroll
|
|
4323
|
-
}), this.autofillController = new
|
|
4472
|
+
}), this.autofillController = new In({
|
|
4324
4473
|
cancelRequest: () => this.cancelRequest(),
|
|
4325
4474
|
onLastCursor: (e) => this.setCurrentCursor(e),
|
|
4326
4475
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
4327
4476
|
options: e.autofill,
|
|
4328
4477
|
state: this.state
|
|
4329
|
-
}), this.removalReconciliation = new
|
|
4478
|
+
}), this.removalReconciliation = new Er(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new lr({
|
|
4330
4479
|
fill: e.fill,
|
|
4331
4480
|
loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
|
|
4332
4481
|
needsFrontendPreparation: () => this.removalReconciliation.needsReconciliation(this.state.items),
|
|
4333
4482
|
onLastCursor: (e) => this.setCurrentCursor(e),
|
|
4334
4483
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
4335
|
-
prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) =>
|
|
4484
|
+
prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => ur({
|
|
4336
4485
|
controller: this.removalReconciliation,
|
|
4337
4486
|
isCurrent: t,
|
|
4338
4487
|
loadPage: e.loadPage,
|
|
@@ -4342,8 +4491,8 @@ var jr = class {
|
|
|
4342
4491
|
state: this.state
|
|
4343
4492
|
}),
|
|
4344
4493
|
state: this.state
|
|
4345
|
-
}), this.routing = new
|
|
4346
|
-
let n =
|
|
4494
|
+
}), this.routing = new qr(e.routing, this.state);
|
|
4495
|
+
let n = Rr({
|
|
4347
4496
|
historyLimit: e.removalHistoryLimit,
|
|
4348
4497
|
onActivate: (e) => this.setActiveReelPost(e),
|
|
4349
4498
|
onItemsRemoved: (e) => this.removalReconciliation.remove(e),
|
|
@@ -4352,20 +4501,20 @@ var jr = class {
|
|
|
4352
4501
|
state: this.state,
|
|
4353
4502
|
surface: () => this.surface
|
|
4354
4503
|
});
|
|
4355
|
-
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, () => {
|
|
4356
4505
|
this.routing.syncFeed();
|
|
4357
4506
|
}), this.startStateNotifications();
|
|
4358
4507
|
}
|
|
4359
4508
|
async mount() {
|
|
4360
4509
|
if (this.app) throw Error("Vibe is already mounted.");
|
|
4361
4510
|
this.startStateNotifications();
|
|
4362
|
-
let e =
|
|
4363
|
-
this.responsiveLayout.mount(e), this.app = i(
|
|
4511
|
+
let e = Sr(this.options.target);
|
|
4512
|
+
this.responsiveLayout.mount(e), this.app = i(dn, {
|
|
4364
4513
|
canRetryEnd: !!this.options.loadPage,
|
|
4365
4514
|
cardFooter: this.options.cardFooter,
|
|
4366
4515
|
cardHeader: this.options.cardHeader,
|
|
4367
4516
|
feedFooter: this.options.feedFooter,
|
|
4368
|
-
feedFooterActions:
|
|
4517
|
+
feedFooterActions: dr(this),
|
|
4369
4518
|
mediaCard: this.options.mediaCard,
|
|
4370
4519
|
masonry: this.options.masonry,
|
|
4371
4520
|
onMediaReady: this.options.onMediaReady,
|
|
@@ -4390,7 +4539,7 @@ var jr = class {
|
|
|
4390
4539
|
onRetryForward: () => {
|
|
4391
4540
|
this.retryReelForward();
|
|
4392
4541
|
}
|
|
4393
|
-
}), 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) => {
|
|
4394
4543
|
this.restoreController = e;
|
|
4395
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();
|
|
4396
4545
|
}
|
|
@@ -4461,7 +4610,7 @@ var jr = class {
|
|
|
4461
4610
|
this.autoScroll.setSpeed(e);
|
|
4462
4611
|
}
|
|
4463
4612
|
applyAutofillUpdate(e) {
|
|
4464
|
-
let t =
|
|
4613
|
+
let t = Gn(this.options.autofill, this.state, e);
|
|
4465
4614
|
return t && this.autofillController.syncCountdown(), t;
|
|
4466
4615
|
}
|
|
4467
4616
|
cancelAutofill() {
|
|
@@ -4472,7 +4621,7 @@ var jr = class {
|
|
|
4472
4621
|
await this.cancelFill();
|
|
4473
4622
|
return;
|
|
4474
4623
|
}
|
|
4475
|
-
if (
|
|
4624
|
+
if (Mn(this.state.autofill)) {
|
|
4476
4625
|
await this.cancelAutofill();
|
|
4477
4626
|
return;
|
|
4478
4627
|
}
|
|
@@ -4486,12 +4635,12 @@ var jr = class {
|
|
|
4486
4635
|
}
|
|
4487
4636
|
async fill(e) {
|
|
4488
4637
|
if (!this.state.loadMoreLocked) {
|
|
4489
|
-
if (this.pendingRequest ||
|
|
4638
|
+
if (this.pendingRequest || Mn(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
|
|
4490
4639
|
await this.fillController.start(e);
|
|
4491
4640
|
}
|
|
4492
4641
|
}
|
|
4493
4642
|
restoreAutofillSession(e) {
|
|
4494
|
-
let t =
|
|
4643
|
+
let t = Kn(this.options.autofill, this.state, e);
|
|
4495
4644
|
return t && this.autofillController.syncCountdown(), t;
|
|
4496
4645
|
}
|
|
4497
4646
|
restoreFillSession(e) {
|
|
@@ -4501,14 +4650,14 @@ var jr = class {
|
|
|
4501
4650
|
return this.startLoadMore(() => this.loadNextSequence());
|
|
4502
4651
|
}
|
|
4503
4652
|
appendPage(e) {
|
|
4504
|
-
|
|
4653
|
+
_n(e, this.state, this.removalReconciliation, (e) => this.setCurrentCursor(e));
|
|
4505
4654
|
}
|
|
4506
4655
|
replenishAfterRemoval() {
|
|
4507
4656
|
return this.startLoadMore(() => this.replenishAfterRemovalSequence());
|
|
4508
4657
|
}
|
|
4509
4658
|
async startLoadMore(e) {
|
|
4510
4659
|
if (this.pendingRequest) return this.pendingRequest;
|
|
4511
|
-
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;
|
|
4512
4661
|
this.state.isLoadingMore = !0, this.state.nextPageError = null;
|
|
4513
4662
|
let t = e();
|
|
4514
4663
|
return this.pendingRequest = t, t.finally(() => {
|
|
@@ -4523,12 +4672,12 @@ var jr = class {
|
|
|
4523
4672
|
}
|
|
4524
4673
|
async replaceFeed(e, t) {
|
|
4525
4674
|
if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
|
|
4526
|
-
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);
|
|
4527
4676
|
}
|
|
4528
4677
|
async loadFilteredPage(e) {
|
|
4529
4678
|
let t = this.options.loadPage;
|
|
4530
4679
|
if (!t) throw Error("Vibe cannot load a page without loadPage.");
|
|
4531
|
-
let n =
|
|
4680
|
+
let n = fn(await t(e));
|
|
4532
4681
|
return {
|
|
4533
4682
|
...n,
|
|
4534
4683
|
items: this.removalReconciliation.filterItems(n.items)
|
|
@@ -4547,7 +4696,7 @@ var jr = class {
|
|
|
4547
4696
|
let t = ++this.requestVersion, n = new AbortController();
|
|
4548
4697
|
this.abortController = n;
|
|
4549
4698
|
try {
|
|
4550
|
-
let r = await
|
|
4699
|
+
let r = await ur({
|
|
4551
4700
|
controller: this.removalReconciliation,
|
|
4552
4701
|
isCurrent: () => t === this.requestVersion,
|
|
4553
4702
|
loadPage: e,
|
|
@@ -4565,7 +4714,7 @@ var jr = class {
|
|
|
4565
4714
|
}
|
|
4566
4715
|
async retryEnd() {
|
|
4567
4716
|
if (this.pendingRequest) return this.pendingRequest;
|
|
4568
|
-
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);
|
|
4569
4718
|
}
|
|
4570
4719
|
setInfiniteScroll(e) {
|
|
4571
4720
|
this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
|
|
@@ -4589,10 +4738,10 @@ var jr = class {
|
|
|
4589
4738
|
this.state.total = e;
|
|
4590
4739
|
}
|
|
4591
4740
|
setReelAutoAdvance(e) {
|
|
4592
|
-
|
|
4741
|
+
hr(this.state.reelAutoAdvance, e);
|
|
4593
4742
|
}
|
|
4594
4743
|
setReelInfoSheet(e) {
|
|
4595
|
-
|
|
4744
|
+
_r(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
|
|
4596
4745
|
}
|
|
4597
4746
|
setLayout(e) {
|
|
4598
4747
|
this.responsiveLayout.setLayout(e);
|
|
@@ -4612,7 +4761,7 @@ var jr = class {
|
|
|
4612
4761
|
async fetchPage(e, t) {
|
|
4613
4762
|
if (!this.options.loadPage) return;
|
|
4614
4763
|
let n = ++this.requestVersion, r = new AbortController();
|
|
4615
|
-
this.abortController = r, await
|
|
4764
|
+
this.abortController = r, await Cr({
|
|
4616
4765
|
append: t,
|
|
4617
4766
|
autofillController: this.autofillController,
|
|
4618
4767
|
cursor: e,
|
|
@@ -4634,7 +4783,7 @@ var jr = class {
|
|
|
4634
4783
|
startInitialAutofill() {
|
|
4635
4784
|
let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
|
|
4636
4785
|
this.abortController = t, this.state.isLoadingMore = !0;
|
|
4637
|
-
let r =
|
|
4786
|
+
let r = Jn({
|
|
4638
4787
|
cycleId: n,
|
|
4639
4788
|
isCurrent: () => e === this.requestVersion,
|
|
4640
4789
|
onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
|
|
@@ -4661,8 +4810,8 @@ var jr = class {
|
|
|
4661
4810
|
this.lastLoadedCursor = e, this.state.current = e;
|
|
4662
4811
|
}
|
|
4663
4812
|
};
|
|
4664
|
-
function
|
|
4665
|
-
return new
|
|
4813
|
+
function Yr(e) {
|
|
4814
|
+
return new Jr(e);
|
|
4666
4815
|
}
|
|
4667
4816
|
//#endregion
|
|
4668
|
-
export {
|
|
4817
|
+
export { Yr as createVibe };
|