@wyxos/vibe 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +1 -1
- package/lib/index.js +393 -386
- package/lib/style.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1009,7 +1009,10 @@ var Be = [
|
|
|
1009
1009
|
])) : o("", !0)
|
|
1010
1010
|
])], 46, Be));
|
|
1011
1011
|
}
|
|
1012
|
-
}), nt = { class: "masonry-feed-shell" }, rt = ["aria-hidden", "inert"], it =
|
|
1012
|
+
}), nt = { class: "masonry-feed-shell" }, rt = ["aria-hidden", "inert"], it = {
|
|
1013
|
+
key: 0,
|
|
1014
|
+
class: "masonry-feed-status-overlay"
|
|
1015
|
+
}, at = 240, ot = 6, st = 12, ct = 800, lt = 1.5, ut = /* @__PURE__ */ d({
|
|
1013
1016
|
__name: "MasonryFeed",
|
|
1014
1017
|
props: {
|
|
1015
1018
|
enteringPostIds: {},
|
|
@@ -1044,60 +1047,60 @@ var Be = [
|
|
|
1044
1047
|
"visible"
|
|
1045
1048
|
],
|
|
1046
1049
|
setup(t, { expose: n, emit: i }) {
|
|
1047
|
-
let
|
|
1048
|
-
additionalHeight: (
|
|
1049
|
-
gap:
|
|
1050
|
-
minColumnWidth:
|
|
1051
|
-
})),
|
|
1052
|
-
let e =
|
|
1053
|
-
if (
|
|
1054
|
-
let t =
|
|
1055
|
-
additionalHeight: (
|
|
1056
|
-
gap:
|
|
1057
|
-
minColumnWidth:
|
|
1050
|
+
let l = t, d = i, f = w(null), p = `vibe-masonry-${D()}`, m = w(null), g = w(0), y = w(ot), x = w(0), C = w(0), T = w(0), k = null, A = null, j = null, M = r(() => ie(l.items, g.value, {
|
|
1051
|
+
additionalHeight: (l.cardHeader?.height ?? 0) + (l.cardFooter?.height ?? 0),
|
|
1052
|
+
gap: y.value,
|
|
1053
|
+
minColumnWidth: at
|
|
1054
|
+
})), N = r(() => {
|
|
1055
|
+
let e = M.value;
|
|
1056
|
+
if (l.leavingPostIds.size === 0) return e;
|
|
1057
|
+
let t = l.items.filter((e) => !l.leavingPostIds.has(e.postId)), n = ie(t, g.value, {
|
|
1058
|
+
additionalHeight: (l.cardHeader?.height ?? 0) + (l.cardFooter?.height ?? 0),
|
|
1059
|
+
gap: y.value,
|
|
1060
|
+
minColumnWidth: at
|
|
1058
1061
|
}), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
|
|
1059
1062
|
return {
|
|
1060
1063
|
...n,
|
|
1061
|
-
items:
|
|
1064
|
+
items: l.items.map((t, n) => l.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
|
|
1062
1065
|
};
|
|
1063
|
-
}),
|
|
1064
|
-
if (
|
|
1066
|
+
}), P = r(() => ({ height: `${l.leavingPostIds.size === 0 ? N.value.height : M.value.height}px` })), I = r(() => !l.infiniteScroll || C.value > 0 && T.value + N.value.height <= C.value + 1), L = r(() => {
|
|
1067
|
+
if (l.suspended) return /* @__PURE__ */ new Set();
|
|
1065
1068
|
let e = {
|
|
1066
|
-
scrollTop:
|
|
1067
|
-
viewportHeight:
|
|
1068
|
-
}, t = re(
|
|
1069
|
+
scrollTop: x.value - T.value,
|
|
1070
|
+
viewportHeight: C.value
|
|
1071
|
+
}, t = re(N.value.items, {
|
|
1069
1072
|
...e,
|
|
1070
1073
|
overscan: 0
|
|
1071
|
-
}), n =
|
|
1074
|
+
}), n = l.leavingPostIds.size === 0 ? [] : re(M.value.items, {
|
|
1072
1075
|
...e,
|
|
1073
1076
|
overscan: 0
|
|
1074
1077
|
});
|
|
1075
1078
|
return new Set([...t, ...n]);
|
|
1076
|
-
}),
|
|
1077
|
-
let e = Math.max(
|
|
1078
|
-
scrollTop:
|
|
1079
|
-
viewportHeight:
|
|
1080
|
-
}, n = re(
|
|
1079
|
+
}), R = r(() => {
|
|
1080
|
+
let e = Math.max(ct, C.value * lt), t = {
|
|
1081
|
+
scrollTop: x.value - T.value,
|
|
1082
|
+
viewportHeight: C.value
|
|
1083
|
+
}, n = re(N.value.items, {
|
|
1081
1084
|
...t,
|
|
1082
1085
|
overscan: e
|
|
1083
|
-
}), r =
|
|
1086
|
+
}), r = l.leavingPostIds.size === 0 ? [] : re(M.value.items, {
|
|
1084
1087
|
...t,
|
|
1085
1088
|
overscan: e
|
|
1086
1089
|
});
|
|
1087
1090
|
return [...new Set([...n, ...r])].sort((e, t) => e - t).flatMap((e) => {
|
|
1088
|
-
let t =
|
|
1091
|
+
let t = l.items[e];
|
|
1089
1092
|
return t ? [{
|
|
1090
|
-
fetchPriority:
|
|
1093
|
+
fetchPriority: L.value.has(e) ? "high" : "low",
|
|
1091
1094
|
index: e,
|
|
1092
1095
|
item: t
|
|
1093
1096
|
}] : [];
|
|
1094
1097
|
});
|
|
1095
|
-
}),
|
|
1096
|
-
O(() => [...
|
|
1097
|
-
let t =
|
|
1098
|
+
}), z = /* @__PURE__ */ new Set();
|
|
1099
|
+
O(() => [...L.value].flatMap((e) => {
|
|
1100
|
+
let t = l.items[e];
|
|
1098
1101
|
if (!t) return [];
|
|
1099
|
-
let n =
|
|
1100
|
-
return
|
|
1102
|
+
let n = l.mediaIndices.get(t.postId) ?? 0, r = F(t.postId, n);
|
|
1103
|
+
return l.previewStates.get(r) === "ready" ? [{
|
|
1101
1104
|
key: r,
|
|
1102
1105
|
mediaIndex: n,
|
|
1103
1106
|
postId: t.postId
|
|
@@ -1105,152 +1108,156 @@ var Be = [
|
|
|
1105
1108
|
}), (e) => {
|
|
1106
1109
|
let t = new Set(e.map(({ key: e }) => e));
|
|
1107
1110
|
e.forEach(({ key: e, mediaIndex: t, postId: n }) => {
|
|
1108
|
-
|
|
1109
|
-
}),
|
|
1111
|
+
z.has(e) || d("visible", n, t);
|
|
1112
|
+
}), z = t;
|
|
1110
1113
|
}, {
|
|
1111
1114
|
immediate: !0,
|
|
1112
1115
|
flush: "post"
|
|
1113
1116
|
});
|
|
1114
|
-
function
|
|
1115
|
-
let t =
|
|
1117
|
+
function B(e) {
|
|
1118
|
+
let t = N.value.items[e], n = l.items[e]?.postId;
|
|
1116
1119
|
if (!t) return {};
|
|
1117
|
-
let r = n !== void 0 &&
|
|
1118
|
-
containerHeight:
|
|
1119
|
-
gap:
|
|
1120
|
-
}) : 0,
|
|
1120
|
+
let r = n !== void 0 && l.enteringPostIds.has(n), i = n !== void 0 && l.leavingPostIds.has(n), a = r || i ? ne({
|
|
1121
|
+
containerHeight: M.value.height,
|
|
1122
|
+
gap: y.value
|
|
1123
|
+
}) : 0, o = n === void 0 ? 0 : i ? l.removalDelays.get(n) ?? 0 : r ? l.entryDelays.get(n) ?? 0 : 0;
|
|
1121
1124
|
return {
|
|
1122
|
-
"--masonry-entry-delay": `${
|
|
1125
|
+
"--masonry-entry-delay": `${o}ms`,
|
|
1123
1126
|
width: `${t.width}px`,
|
|
1124
1127
|
height: `${t.height}px`,
|
|
1125
1128
|
transform: `translate3d(${t.x}px, ${t.y + a}px, 0)`
|
|
1126
1129
|
};
|
|
1127
1130
|
}
|
|
1128
|
-
function
|
|
1129
|
-
let e =
|
|
1131
|
+
function V() {
|
|
1132
|
+
let e = f.value;
|
|
1130
1133
|
if (!e) return;
|
|
1131
|
-
|
|
1132
|
-
let t =
|
|
1133
|
-
t && (
|
|
1134
|
+
x.value = e.scrollTop, C.value = e.clientHeight;
|
|
1135
|
+
let t = m.value;
|
|
1136
|
+
t && (T.value = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop);
|
|
1134
1137
|
}
|
|
1135
|
-
function
|
|
1138
|
+
function H(e) {
|
|
1136
1139
|
let t = e.ownerDocument.documentElement.clientWidth;
|
|
1137
|
-
|
|
1140
|
+
g.value = e.clientWidth, y.value = Math.min(st, Math.max(ot, t * .0075)), V();
|
|
1138
1141
|
}
|
|
1139
|
-
function
|
|
1142
|
+
function W(e) {
|
|
1140
1143
|
let t = e.currentTarget;
|
|
1141
|
-
t && (
|
|
1142
|
-
}
|
|
1143
|
-
function W() {
|
|
1144
|
-
let e = d.value;
|
|
1145
|
-
!o.loadMoreLocked && e && K(e) && l("loadMore");
|
|
1144
|
+
t && (x.value = t.scrollTop, !l.loadMoreLocked && l.infiniteScroll && K(t) && d("loadMore"));
|
|
1146
1145
|
}
|
|
1147
1146
|
function G() {
|
|
1148
|
-
|
|
1147
|
+
let e = f.value;
|
|
1148
|
+
!l.loadMoreLocked && e && K(e) && d("loadMore");
|
|
1149
|
+
}
|
|
1150
|
+
function ee() {
|
|
1151
|
+
return f.value;
|
|
1149
1152
|
}
|
|
1150
|
-
return O(
|
|
1151
|
-
|
|
1153
|
+
return O(m, (e) => {
|
|
1154
|
+
k?.disconnect(), k = null, j !== null && cancelAnimationFrame(j), e && (H(e), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(([t]) => {
|
|
1152
1155
|
let n = t?.contentRect.width ?? e.clientWidth;
|
|
1153
|
-
Math.abs(n -
|
|
1154
|
-
|
|
1156
|
+
Math.abs(n - g.value) < .5 || (j = requestAnimationFrame(() => {
|
|
1157
|
+
j = null, H(e);
|
|
1155
1158
|
}));
|
|
1156
|
-
}),
|
|
1157
|
-
}), O(
|
|
1158
|
-
|
|
1159
|
+
}), k.observe(e)));
|
|
1160
|
+
}), O(f, (e) => {
|
|
1161
|
+
A?.disconnect(), A = null, e && (V(), !(typeof ResizeObserver > "u") && (A = new ResizeObserver(V), A.observe(e)));
|
|
1159
1162
|
}), v(() => {
|
|
1160
|
-
|
|
1163
|
+
k?.disconnect(), A?.disconnect(), j !== null && cancelAnimationFrame(j);
|
|
1161
1164
|
}), n({
|
|
1162
|
-
getScrollElement:
|
|
1163
|
-
loadIfNearBottom:
|
|
1164
|
-
}), (n, r) => (b(), s("div", nt, [
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
"
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1165
|
+
getScrollElement: ee,
|
|
1166
|
+
loadIfNearBottom: G
|
|
1167
|
+
}), (n, r) => (b(), s("div", nt, [
|
|
1168
|
+
c("main", {
|
|
1169
|
+
id: p,
|
|
1170
|
+
ref_key: "galleryElement",
|
|
1171
|
+
ref: f,
|
|
1172
|
+
class: h(["gallery-shell masonry-feed", { "masonry-feed--suspended": t.suspended }]),
|
|
1173
|
+
"data-layout-mode": "masonry",
|
|
1174
|
+
"aria-hidden": t.suspended || void 0,
|
|
1175
|
+
inert: t.suspended || void 0,
|
|
1176
|
+
onScrollPassive: W
|
|
1177
|
+
}, [c("section", {
|
|
1178
|
+
ref_key: "masonryElement",
|
|
1179
|
+
ref: m,
|
|
1180
|
+
class: h(["masonry", { "masonry--ready": g.value > 0 }]),
|
|
1181
|
+
style: _(P.value),
|
|
1182
|
+
"aria-label": "Media gallery"
|
|
1183
|
+
}, [(b(!0), s(e, null, S(R.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(tt, {
|
|
1184
|
+
key: n.postId,
|
|
1185
|
+
class: "masonry-item",
|
|
1186
|
+
entering: t.enteringPostIds.has(n.postId),
|
|
1187
|
+
leaving: t.leavingPostIds.has(n.postId),
|
|
1188
|
+
"fetch-priority": e,
|
|
1189
|
+
"card-footer": t.cardFooter,
|
|
1190
|
+
"card-header": t.cardHeader,
|
|
1191
|
+
"media-card": t.mediaCard,
|
|
1192
|
+
index: r,
|
|
1193
|
+
item: n,
|
|
1194
|
+
"item-style": B(r),
|
|
1195
|
+
interactive: "",
|
|
1196
|
+
layout: "masonry",
|
|
1197
|
+
"loaded-count": t.items.length,
|
|
1198
|
+
"media-index": t.mediaIndices.get(n.postId) ?? 0,
|
|
1199
|
+
"preview-state": t.previewStates.get(E(F)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
|
|
1200
|
+
total: t.total,
|
|
1201
|
+
onActivate: (e) => d("activate", n.postId, e),
|
|
1202
|
+
onMediaChange: (e) => d("mediaChange", n.postId, e),
|
|
1203
|
+
onReady: (e) => d("ready", n.postId, e),
|
|
1204
|
+
onError: (e) => d("error", n.postId, e)
|
|
1205
|
+
}, null, 8, [
|
|
1206
|
+
"entering",
|
|
1207
|
+
"leaving",
|
|
1208
|
+
"fetch-priority",
|
|
1209
|
+
"card-footer",
|
|
1210
|
+
"card-header",
|
|
1211
|
+
"media-card",
|
|
1212
|
+
"index",
|
|
1213
|
+
"item",
|
|
1214
|
+
"item-style",
|
|
1215
|
+
"loaded-count",
|
|
1216
|
+
"media-index",
|
|
1217
|
+
"preview-state",
|
|
1218
|
+
"total",
|
|
1219
|
+
"onActivate",
|
|
1220
|
+
"onMediaChange",
|
|
1221
|
+
"onReady",
|
|
1222
|
+
"onError"
|
|
1223
|
+
]))), 128))], 6)], 42, rt),
|
|
1224
|
+
t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && I.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", it, [u(U, {
|
|
1225
|
+
actions: t.feedFooterActions,
|
|
1226
|
+
"can-retry-end": t.canRetryEnd,
|
|
1227
|
+
"feed-footer": t.feedFooter,
|
|
1228
|
+
"has-error": t.nextPageError,
|
|
1229
|
+
"has-next": t.hasNext,
|
|
1230
|
+
"is-loading": t.isLoadingMore,
|
|
1231
|
+
"load-more-locked": t.loadMoreLocked,
|
|
1232
|
+
"show-load-more": I.value,
|
|
1233
|
+
state: t.state,
|
|
1234
|
+
onLoadMore: r[0] ||= (e) => d("loadMore"),
|
|
1235
|
+
onRetryEnd: r[1] ||= (e) => d("retryEnd")
|
|
1236
|
+
}, null, 8, [
|
|
1237
|
+
"actions",
|
|
1238
|
+
"can-retry-end",
|
|
1239
|
+
"feed-footer",
|
|
1240
|
+
"has-error",
|
|
1241
|
+
"has-next",
|
|
1242
|
+
"is-loading",
|
|
1243
|
+
"load-more-locked",
|
|
1244
|
+
"show-load-more",
|
|
1245
|
+
"state"
|
|
1246
|
+
])])) : o("", !0),
|
|
1247
|
+
u(ue, {
|
|
1248
|
+
"content-size": N.value.height,
|
|
1249
|
+
"controls-id": p,
|
|
1250
|
+
"scroll-element": f.value,
|
|
1251
|
+
suspended: t.suspended
|
|
1252
|
+
}, null, 8, [
|
|
1253
|
+
"content-size",
|
|
1254
|
+
"scroll-element",
|
|
1255
|
+
"suspended"
|
|
1256
|
+
])
|
|
1257
|
+
]));
|
|
1251
1258
|
}
|
|
1252
|
-
}),
|
|
1253
|
-
function
|
|
1259
|
+
}), dt = 300;
|
|
1260
|
+
function ft(e, t, n) {
|
|
1254
1261
|
let r = e.scrollTop;
|
|
1255
1262
|
if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
|
|
1256
1263
|
e.setAttribute("data-transitioning", "");
|
|
@@ -1258,7 +1265,7 @@ function dt(e, t, n) {
|
|
|
1258
1265
|
return new Promise((n) => {
|
|
1259
1266
|
let o = (s) => {
|
|
1260
1267
|
a += 1;
|
|
1261
|
-
let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c /
|
|
1268
|
+
let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / dt), u = 1 - (1 - l) ** 3;
|
|
1262
1269
|
if (e.scrollTop = r + (t - r) * u, l < 1) {
|
|
1263
1270
|
requestAnimationFrame(o);
|
|
1264
1271
|
return;
|
|
@@ -1270,7 +1277,7 @@ function dt(e, t, n) {
|
|
|
1270
1277
|
}
|
|
1271
1278
|
//#endregion
|
|
1272
1279
|
//#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
|
|
1273
|
-
var
|
|
1280
|
+
var pt = ["aria-label"], mt = /* @__PURE__ */ d({
|
|
1274
1281
|
__name: "ReelAutoAdvanceProgress",
|
|
1275
1282
|
props: {
|
|
1276
1283
|
durationMs: {},
|
|
@@ -1288,9 +1295,9 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1288
1295
|
class: "reel-auto-advance-progress",
|
|
1289
1296
|
style: _(a.value),
|
|
1290
1297
|
onAnimationend: n[0] ||= (e) => i("complete")
|
|
1291
|
-
}, null, 36)], 8,
|
|
1298
|
+
}, null, 36)], 8, pt));
|
|
1292
1299
|
}
|
|
1293
|
-
}),
|
|
1300
|
+
}), ht = { class: "reel-viewport" }, gt = ["data-active-post-id", "data-active-media-index"], _t = ["role", "data-status"], vt = 2, yt = 300, bt = /* @__PURE__ */ d({
|
|
1294
1301
|
__name: "ReelFeed",
|
|
1295
1302
|
props: {
|
|
1296
1303
|
initialPostId: {},
|
|
@@ -1328,7 +1335,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1328
1335
|
],
|
|
1329
1336
|
setup(t, { expose: n, emit: i }) {
|
|
1330
1337
|
let l = t, u = i, d = w(null), f = w(null), p = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), g = w(Math.max(0, p)), x = w(!1), C = w(!1), D = 0, k = null, A = null, j = null, N = r(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), I = r(() => {
|
|
1331
|
-
let e = Math.max(0, g.value -
|
|
1338
|
+
let e = Math.max(0, g.value - vt), t = Math.min(l.items.length - 1, g.value + vt);
|
|
1332
1339
|
return l.items.slice(e, t + 1).map((t, n) => ({
|
|
1333
1340
|
fetchPriority: e + n === g.value ? "high" : "low",
|
|
1334
1341
|
index: e + n,
|
|
@@ -1418,7 +1425,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1418
1425
|
let t = d.value;
|
|
1419
1426
|
if (!t) return Promise.resolve();
|
|
1420
1427
|
let n = e * (D || t.clientHeight);
|
|
1421
|
-
return g.value = e,
|
|
1428
|
+
return g.value = e, ft(t, n, de());
|
|
1422
1429
|
}
|
|
1423
1430
|
function pe(e) {
|
|
1424
1431
|
fe(e);
|
|
@@ -1428,7 +1435,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1428
1435
|
return t < 0 || t === g.value ? !1 : (await fe(t), !0);
|
|
1429
1436
|
}
|
|
1430
1437
|
async function me(e) {
|
|
1431
|
-
return Y(e) ? (de() || await new Promise((e) => setTimeout(e,
|
|
1438
|
+
return Y(e) ? (de() || await new Promise((e) => setTimeout(e, yt)), !0) : !1;
|
|
1432
1439
|
}
|
|
1433
1440
|
function he() {
|
|
1434
1441
|
if (!l.reelAutoAdvance.enabled) return;
|
|
@@ -1497,7 +1504,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1497
1504
|
"style",
|
|
1498
1505
|
"total"
|
|
1499
1506
|
])) : o("", !0),
|
|
1500
|
-
c("div",
|
|
1507
|
+
c("div", ht, [c("div", {
|
|
1501
1508
|
ref_key: "galleryElement",
|
|
1502
1509
|
ref: d,
|
|
1503
1510
|
class: "gallery-shell reel-feed",
|
|
@@ -1560,7 +1567,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1560
1567
|
class: "reel-forward-retry",
|
|
1561
1568
|
type: "button",
|
|
1562
1569
|
onClick: r[0] ||= (e) => u("retryForward")
|
|
1563
|
-
}, " Retry ")) : o("", !0)], 8,
|
|
1570
|
+
}, " Retry ")) : o("", !0)], 8, _t)), t.reelForward.status === "idle" ? (b(), a(U, {
|
|
1564
1571
|
key: 2,
|
|
1565
1572
|
actions: t.feedFooterActions,
|
|
1566
1573
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -1583,7 +1590,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1583
1590
|
"load-more-locked",
|
|
1584
1591
|
"show-load-more",
|
|
1585
1592
|
"state"
|
|
1586
|
-
])) : o("", !0)], 40,
|
|
1593
|
+
])) : o("", !0)], 40, gt), c("div", {
|
|
1587
1594
|
ref_key: "reelControlsElement",
|
|
1588
1595
|
ref: f,
|
|
1589
1596
|
class: "reel-media-controls-host",
|
|
@@ -1611,7 +1618,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1611
1618
|
"style",
|
|
1612
1619
|
"total"
|
|
1613
1620
|
])) : o("", !0),
|
|
1614
|
-
ee.value ? (b(), a(
|
|
1621
|
+
ee.value ? (b(), a(mt, {
|
|
1615
1622
|
key: W.value,
|
|
1616
1623
|
"duration-ms": t.reelAutoAdvance.intervalMs,
|
|
1617
1624
|
label: G.value,
|
|
@@ -1619,16 +1626,16 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1619
1626
|
}, null, 8, ["duration-ms", "label"])) : o("", !0)
|
|
1620
1627
|
], 2));
|
|
1621
1628
|
}
|
|
1622
|
-
}),
|
|
1629
|
+
}), xt = ["data-info-sheet-open", "data-info-sheet-mode"], St = ["aria-hidden", "inert"], Ct = {
|
|
1623
1630
|
key: 0,
|
|
1624
1631
|
class: "reel-info-sheet-layer",
|
|
1625
1632
|
"data-test": "reel-info-sheet"
|
|
1626
|
-
},
|
|
1633
|
+
}, wt = [
|
|
1627
1634
|
"role",
|
|
1628
1635
|
"aria-modal",
|
|
1629
1636
|
"tabindex",
|
|
1630
1637
|
"data-active-post-id"
|
|
1631
|
-
],
|
|
1638
|
+
], Tt = /* @__PURE__ */ d({
|
|
1632
1639
|
__name: "ReelLayout",
|
|
1633
1640
|
props: {
|
|
1634
1641
|
forwardIndex: { default: null },
|
|
@@ -1753,7 +1760,7 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1753
1760
|
class: "reel-layout-main",
|
|
1754
1761
|
"aria-hidden": e.infoSheetOverlay && A.value || void 0,
|
|
1755
1762
|
inert: e.infoSheetOverlay && A.value || void 0
|
|
1756
|
-
}, [u(
|
|
1763
|
+
}, [u(bt, {
|
|
1757
1764
|
ref_key: "reelFeed",
|
|
1758
1765
|
ref: p,
|
|
1759
1766
|
"can-retry-end": e.canRetryEnd,
|
|
@@ -1804,8 +1811,8 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1804
1811
|
"reel-forward",
|
|
1805
1812
|
"state",
|
|
1806
1813
|
"total"
|
|
1807
|
-
])], 8,
|
|
1808
|
-
default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div",
|
|
1814
|
+
])], 8, St), u(n, { name: "vibe-info-sheet" }, {
|
|
1815
|
+
default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", Ct, [c("aside", {
|
|
1809
1816
|
ref_key: "sheetElement",
|
|
1810
1817
|
ref: _,
|
|
1811
1818
|
class: "reel-info-sheet",
|
|
@@ -1814,14 +1821,14 @@ var ft = ["aria-label"], pt = /* @__PURE__ */ d({
|
|
|
1814
1821
|
"aria-modal": e.infoSheetOverlay ? "true" : void 0,
|
|
1815
1822
|
tabindex: e.infoSheetOverlay ? -1 : void 0,
|
|
1816
1823
|
"data-active-post-id": T.value?.postId
|
|
1817
|
-
}, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8,
|
|
1824
|
+
}, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, wt)])) : o("", !0)]),
|
|
1818
1825
|
_: 1
|
|
1819
|
-
})], 10,
|
|
1826
|
+
})], 10, xt));
|
|
1820
1827
|
}
|
|
1821
1828
|
});
|
|
1822
1829
|
//#endregion
|
|
1823
1830
|
//#region src/core/mediaLifecycle.ts
|
|
1824
|
-
function
|
|
1831
|
+
function Et(e, t, n, r, i) {
|
|
1825
1832
|
let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
|
|
1826
1833
|
if (!o) return null;
|
|
1827
1834
|
let s = N(o, n), c = P(o, s);
|
|
@@ -1837,7 +1844,7 @@ function Tt(e, t, n, r, i) {
|
|
|
1837
1844
|
postIndex: a
|
|
1838
1845
|
};
|
|
1839
1846
|
}
|
|
1840
|
-
function
|
|
1847
|
+
function Dt(e, t) {
|
|
1841
1848
|
O(() => {
|
|
1842
1849
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
|
|
1843
1850
|
return {
|
|
@@ -1847,20 +1854,20 @@ function Et(e, t) {
|
|
|
1847
1854
|
};
|
|
1848
1855
|
}, (n, r) => {
|
|
1849
1856
|
if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
|
|
1850
|
-
let i =
|
|
1857
|
+
let i = Et(e, n.postId, n.mediaIndex, "reel", n.origin);
|
|
1851
1858
|
i && t(i);
|
|
1852
1859
|
}, { flush: "sync" });
|
|
1853
1860
|
}
|
|
1854
1861
|
//#endregion
|
|
1855
1862
|
//#region src/components/useMediaLifecycle.ts
|
|
1856
|
-
function
|
|
1863
|
+
function Ot(e, t) {
|
|
1857
1864
|
let n = w(/* @__PURE__ */ new Map()), i = w(/* @__PURE__ */ new Map()), a = r(() => e.reelMediaSource === "original" ? i.value : n.value);
|
|
1858
1865
|
function o(e, t, n, r) {
|
|
1859
1866
|
let i = F(t, n);
|
|
1860
1867
|
e.value.get(i) !== r && (e.value = new Map(e.value).set(i, r));
|
|
1861
1868
|
}
|
|
1862
1869
|
function s(t, n, r, i) {
|
|
1863
|
-
return
|
|
1870
|
+
return Et(e, t, n, r, i);
|
|
1864
1871
|
}
|
|
1865
1872
|
function c(e, n, r, i) {
|
|
1866
1873
|
let a = s(e, n, r, i);
|
|
@@ -1882,7 +1889,7 @@ function Dt(e, t) {
|
|
|
1882
1889
|
let r = s(e, n, "masonry", null);
|
|
1883
1890
|
r && t.visible(r);
|
|
1884
1891
|
}
|
|
1885
|
-
return
|
|
1892
|
+
return Dt(e, t.reelChange), O(() => {
|
|
1886
1893
|
let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null, n = t === null ? 0 : e.mediaIndices.get(t) ?? 0;
|
|
1887
1894
|
return {
|
|
1888
1895
|
mediaIndex: n,
|
|
@@ -1907,16 +1914,16 @@ function Dt(e, t) {
|
|
|
1907
1914
|
}
|
|
1908
1915
|
//#endregion
|
|
1909
1916
|
//#region src/core/reelEscapeStack.ts
|
|
1910
|
-
var
|
|
1911
|
-
function
|
|
1912
|
-
return
|
|
1913
|
-
let t =
|
|
1914
|
-
t >= 0 &&
|
|
1917
|
+
var kt = [];
|
|
1918
|
+
function At(e) {
|
|
1919
|
+
return kt.push(e), () => {
|
|
1920
|
+
let t = kt.indexOf(e);
|
|
1921
|
+
t >= 0 && kt.splice(t, 1);
|
|
1915
1922
|
};
|
|
1916
1923
|
}
|
|
1917
|
-
function
|
|
1924
|
+
function jt(e) {
|
|
1918
1925
|
if (!e.isActive()) return !1;
|
|
1919
|
-
let t =
|
|
1926
|
+
let t = kt.filter((e) => e.isActive()), n = e.element();
|
|
1920
1927
|
return n !== null && t.some((t) => {
|
|
1921
1928
|
if (t === e) return !1;
|
|
1922
1929
|
let r = t.element();
|
|
@@ -1932,14 +1939,14 @@ function At(e) {
|
|
|
1932
1939
|
}
|
|
1933
1940
|
//#endregion
|
|
1934
1941
|
//#region src/components/useReelKeyboard.ts
|
|
1935
|
-
function
|
|
1942
|
+
function Mt(e) {
|
|
1936
1943
|
let t = {
|
|
1937
1944
|
element: e.element,
|
|
1938
1945
|
isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
|
|
1939
1946
|
}, n = null;
|
|
1940
1947
|
function r(n) {
|
|
1941
1948
|
let r = t.isActive();
|
|
1942
|
-
if (n.key === "Escape" && r && !
|
|
1949
|
+
if (n.key === "Escape" && r && !jt(t)) return;
|
|
1943
1950
|
if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
|
|
1944
1951
|
n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
|
|
1945
1952
|
return;
|
|
@@ -1959,14 +1966,14 @@ function jt(e) {
|
|
|
1959
1966
|
a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
|
|
1960
1967
|
}
|
|
1961
1968
|
y(() => {
|
|
1962
|
-
n =
|
|
1969
|
+
n = At(t), window.addEventListener("keydown", r);
|
|
1963
1970
|
}), v(() => {
|
|
1964
1971
|
window.removeEventListener("keydown", r), n?.(), n = null;
|
|
1965
1972
|
});
|
|
1966
1973
|
}
|
|
1967
1974
|
//#endregion
|
|
1968
1975
|
//#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
|
|
1969
|
-
var
|
|
1976
|
+
var Nt = 35, Pt = 420, Ft = /* @__PURE__ */ d({
|
|
1970
1977
|
__name: "VibeSurface",
|
|
1971
1978
|
props: {
|
|
1972
1979
|
canRetryEnd: { type: Boolean },
|
|
@@ -1991,7 +1998,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
1991
1998
|
"retryForward"
|
|
1992
1999
|
],
|
|
1993
2000
|
setup(t, { expose: i, emit: c }) {
|
|
1994
|
-
let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), y = w({}), x = w(!1), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = w(/* @__PURE__ */ new Set()), D = w(/* @__PURE__ */ new Map()), A = r(() => I(l.state)), { markMasonryVisible: j, markPreviewError: P, markPreviewReady: F, markReelError: L, markReelReady: R, originalStates: z, previewStates: B, reelStates: V } =
|
|
2001
|
+
let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), y = w({}), x = w(!1), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = w(/* @__PURE__ */ new Set()), D = w(/* @__PURE__ */ new Map()), A = r(() => I(l.state)), { markMasonryVisible: j, markPreviewError: P, markPreviewReady: F, markReelError: L, markReelReady: R, originalStates: z, previewStates: B, reelStates: V } = Ot(l.state, {
|
|
1995
2002
|
ready: (e) => d("mediaReady", e),
|
|
1996
2003
|
reelChange: (e) => d("reelMediaChange", e),
|
|
1997
2004
|
visible: (e) => d("mediaVisible", e)
|
|
@@ -2044,8 +2051,8 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2044
2051
|
if (n.length === 0) return 0;
|
|
2045
2052
|
let r = new Map(D.value);
|
|
2046
2053
|
return n.forEach((e, t) => {
|
|
2047
|
-
r.set(e, t *
|
|
2048
|
-
}), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), D.value = r,
|
|
2054
|
+
r.set(e, t * Nt);
|
|
2055
|
+
}), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), D.value = r, Pt + (n.length - 1) * Nt;
|
|
2049
2056
|
}
|
|
2050
2057
|
function Y(e, t) {
|
|
2051
2058
|
let n = J(e), r = n?.querySelector(".media-card-activator") ?? n;
|
|
@@ -2073,7 +2080,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2073
2080
|
e !== null && Y(e, t);
|
|
2074
2081
|
});
|
|
2075
2082
|
}
|
|
2076
|
-
return
|
|
2083
|
+
return Mt({
|
|
2077
2084
|
closeMasonryReel: ue,
|
|
2078
2085
|
element: () => g.value,
|
|
2079
2086
|
isReelLeaving: () => x.value,
|
|
@@ -2088,7 +2095,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2088
2095
|
let t = C.value.get(e);
|
|
2089
2096
|
t !== void 0 && r.set(e, t);
|
|
2090
2097
|
}), t.forEach((e, t) => {
|
|
2091
|
-
r.set(e, t *
|
|
2098
|
+
r.set(e, t * Nt);
|
|
2092
2099
|
}), C.value = r, S.value = new Set([...S.value, ...t]), q();
|
|
2093
2100
|
}, { flush: "sync" }), v(() => {
|
|
2094
2101
|
U !== null && cancelAnimationFrame(U);
|
|
@@ -2105,7 +2112,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2105
2112
|
ref_key: "surfaceElement",
|
|
2106
2113
|
ref: g,
|
|
2107
2114
|
class: "vibe-surface"
|
|
2108
|
-
}, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(
|
|
2115
|
+
}, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Tt, {
|
|
2109
2116
|
key: 0,
|
|
2110
2117
|
ref_key: "reelRenderer",
|
|
2111
2118
|
ref: p,
|
|
@@ -2156,7 +2163,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2156
2163
|
"can-retry-end",
|
|
2157
2164
|
"feed-footer",
|
|
2158
2165
|
"state"
|
|
2159
|
-
])) : (b(), s(e, { key: 2 }, [u(
|
|
2166
|
+
])) : (b(), s(e, { key: 2 }, [u(ut, {
|
|
2160
2167
|
ref_key: "masonryRenderer",
|
|
2161
2168
|
ref: f,
|
|
2162
2169
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2226,7 +2233,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2226
2233
|
"aria-modal": "true",
|
|
2227
2234
|
tabindex: "-1",
|
|
2228
2235
|
style: _(y.value)
|
|
2229
|
-
}, [u(
|
|
2236
|
+
}, [u(Tt, {
|
|
2230
2237
|
ref_key: "reelRenderer",
|
|
2231
2238
|
ref: p,
|
|
2232
2239
|
"can-retry-end": t.canRetryEnd,
|
|
@@ -2270,7 +2277,7 @@ var Mt = 35, Nt = 420, Pt = /* @__PURE__ */ d({
|
|
|
2270
2277
|
});
|
|
2271
2278
|
//#endregion
|
|
2272
2279
|
//#region src/core/page.ts
|
|
2273
|
-
function
|
|
2280
|
+
function It(e) {
|
|
2274
2281
|
if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
|
|
2275
2282
|
if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
|
|
2276
2283
|
if (e.total !== void 0 && (!Number.isFinite(e.total) || e.total < 0)) throw TypeError("Vibe page total must be a non-negative number when provided.");
|
|
@@ -2282,32 +2289,32 @@ function Z(e, t) {
|
|
|
2282
2289
|
}
|
|
2283
2290
|
//#endregion
|
|
2284
2291
|
//#region src/core/requestDelay.ts
|
|
2285
|
-
var
|
|
2292
|
+
var Lt = 2e3, Rt = 1e4, zt = 250, Bt = {
|
|
2286
2293
|
delayRemainingMs: null,
|
|
2287
2294
|
nextRequestAt: null
|
|
2288
2295
|
};
|
|
2289
|
-
function
|
|
2296
|
+
function Vt(e, t) {
|
|
2290
2297
|
return e === void 0 ? t : Math.floor(e);
|
|
2291
2298
|
}
|
|
2292
|
-
function
|
|
2299
|
+
function Ht(e, t) {
|
|
2293
2300
|
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.`);
|
|
2294
2301
|
}
|
|
2295
|
-
function
|
|
2296
|
-
let n =
|
|
2302
|
+
function Ut(e, t = {}) {
|
|
2303
|
+
let n = Vt(t.delayStepMs, Lt), r = Vt(t.delayMaxMs, Rt);
|
|
2297
2304
|
return Math.min(Math.max(0, e) * n, r);
|
|
2298
2305
|
}
|
|
2299
2306
|
function Q(e) {
|
|
2300
|
-
if (e == null || !Number.isFinite(e)) return { ...
|
|
2307
|
+
if (e == null || !Number.isFinite(e)) return { ...Bt };
|
|
2301
2308
|
let t = Math.max(0, Math.floor(e - Date.now()));
|
|
2302
2309
|
return t > 0 ? {
|
|
2303
2310
|
delayRemainingMs: t,
|
|
2304
2311
|
nextRequestAt: e
|
|
2305
|
-
} : { ...
|
|
2312
|
+
} : { ...Bt };
|
|
2306
2313
|
}
|
|
2307
|
-
async function
|
|
2314
|
+
async function Wt({ delayMs: e, onChange: t, signal: n }) {
|
|
2308
2315
|
if (n.aborted) throw new DOMException("Aborted", "AbortError");
|
|
2309
2316
|
if (e <= 0) {
|
|
2310
|
-
t({ ...
|
|
2317
|
+
t({ ...Bt });
|
|
2311
2318
|
return;
|
|
2312
2319
|
}
|
|
2313
2320
|
let r = Date.now() + e;
|
|
@@ -2315,9 +2322,9 @@ async function Ut({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2315
2322
|
delayRemainingMs: e,
|
|
2316
2323
|
nextRequestAt: r
|
|
2317
2324
|
}), await new Promise((i, a) => {
|
|
2318
|
-
let o = !1, s = setInterval(f,
|
|
2325
|
+
let o = !1, s = setInterval(f, zt), c = setTimeout(() => u(), e);
|
|
2319
2326
|
function l() {
|
|
2320
|
-
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...
|
|
2327
|
+
clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Bt });
|
|
2321
2328
|
}
|
|
2322
2329
|
function u(e) {
|
|
2323
2330
|
o || (o = !0, l(), e ? a(e) : i());
|
|
@@ -2332,13 +2339,13 @@ async function Ut({ delayMs: e, onChange: t, signal: n }) {
|
|
|
2332
2339
|
n.addEventListener("abort", d, { once: !0 });
|
|
2333
2340
|
});
|
|
2334
2341
|
}
|
|
2335
|
-
var
|
|
2342
|
+
var Gt = class {
|
|
2336
2343
|
interval = null;
|
|
2337
2344
|
constructor(e) {
|
|
2338
2345
|
this.onChange = e;
|
|
2339
2346
|
}
|
|
2340
2347
|
clear() {
|
|
2341
|
-
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...
|
|
2348
|
+
this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Bt });
|
|
2342
2349
|
}
|
|
2343
2350
|
sync(e) {
|
|
2344
2351
|
this.clear();
|
|
@@ -2346,22 +2353,22 @@ var Wt = class {
|
|
|
2346
2353
|
this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
|
|
2347
2354
|
let t = Q(e);
|
|
2348
2355
|
this.onChange(t), t.delayRemainingMs === null && this.clear();
|
|
2349
|
-
},
|
|
2356
|
+
}, zt));
|
|
2350
2357
|
}
|
|
2351
2358
|
};
|
|
2352
|
-
function
|
|
2359
|
+
function Kt(e, t = !0) {
|
|
2353
2360
|
return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
|
|
2354
2361
|
}
|
|
2355
|
-
function
|
|
2362
|
+
function qt(e) {
|
|
2356
2363
|
return `${typeof e}:${String(e)}`;
|
|
2357
2364
|
}
|
|
2358
|
-
function
|
|
2365
|
+
function Jt(e, t) {
|
|
2359
2366
|
if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
|
|
2360
2367
|
}
|
|
2361
|
-
function
|
|
2368
|
+
function Yt(e) {
|
|
2362
2369
|
if (!e) return;
|
|
2363
|
-
if (
|
|
2364
|
-
|
|
2370
|
+
if (Jt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
|
|
2371
|
+
Ht(e, "frontend autofill");
|
|
2365
2372
|
let t = e.maxAdditionalPages;
|
|
2366
2373
|
if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
|
|
2367
2374
|
return;
|
|
@@ -2373,7 +2380,7 @@ function Jt(e) {
|
|
|
2373
2380
|
if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
|
|
2374
2381
|
}
|
|
2375
2382
|
}
|
|
2376
|
-
function
|
|
2383
|
+
function Xt(e, t, n = !0) {
|
|
2377
2384
|
if (!e) return {
|
|
2378
2385
|
cycleId: null,
|
|
2379
2386
|
delayRemainingMs: null,
|
|
@@ -2407,7 +2414,7 @@ function Yt(e, t, n = !0) {
|
|
|
2407
2414
|
strategy: e.strategy
|
|
2408
2415
|
};
|
|
2409
2416
|
}
|
|
2410
|
-
function
|
|
2417
|
+
function Zt(e) {
|
|
2411
2418
|
return [
|
|
2412
2419
|
"cancelling",
|
|
2413
2420
|
"filling",
|
|
@@ -2415,9 +2422,9 @@ function Xt(e) {
|
|
|
2415
2422
|
"waiting"
|
|
2416
2423
|
].includes(e.status);
|
|
2417
2424
|
}
|
|
2418
|
-
async function
|
|
2425
|
+
async function Qt(e, t, n) {
|
|
2419
2426
|
let r = t.autofill;
|
|
2420
|
-
if (!
|
|
2427
|
+
if (!Zt(r) || !r.cycleId) return;
|
|
2421
2428
|
let i = {
|
|
2422
2429
|
cycleId: r.cycleId,
|
|
2423
2430
|
feedKey: r.feedKey ?? "",
|
|
@@ -2430,16 +2437,16 @@ async function Zt(e, t, n) {
|
|
|
2430
2437
|
throw r.error = e, r.status = "error", e;
|
|
2431
2438
|
}
|
|
2432
2439
|
}
|
|
2433
|
-
function
|
|
2440
|
+
function $t(e, t, n) {
|
|
2434
2441
|
return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
|
|
2435
2442
|
}
|
|
2436
|
-
async function
|
|
2437
|
-
let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ??
|
|
2443
|
+
async function en({ 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 }) {
|
|
2444
|
+
let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? Kt(s), g = t, _ = t, v = t, y = 0, b = [], x;
|
|
2438
2445
|
for (; y < h;) {
|
|
2439
|
-
let e =
|
|
2446
|
+
let e = qt(g);
|
|
2440
2447
|
if (m.has(e)) throw Error("Vibe autofill received a repeated cursor.");
|
|
2441
|
-
if (m.add(e), await
|
|
2442
|
-
delayMs:
|
|
2448
|
+
if (m.add(e), await Wt({
|
|
2449
|
+
delayMs: Ut(l + y, s),
|
|
2443
2450
|
onChange: a,
|
|
2444
2451
|
signal: d
|
|
2445
2452
|
}), y > 0 && u()) return {
|
|
@@ -2453,7 +2460,7 @@ async function $t({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2453
2460
|
status: "paused",
|
|
2454
2461
|
total: x
|
|
2455
2462
|
};
|
|
2456
|
-
let t =
|
|
2463
|
+
let t = It(await n({
|
|
2457
2464
|
cursor: g,
|
|
2458
2465
|
signal: d
|
|
2459
2466
|
}));
|
|
@@ -2510,12 +2517,12 @@ async function $t({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
|
|
|
2510
2517
|
}
|
|
2511
2518
|
//#endregion
|
|
2512
2519
|
//#region src/core/autofillController.ts
|
|
2513
|
-
var
|
|
2520
|
+
var tn = class {
|
|
2514
2521
|
collection = null;
|
|
2515
2522
|
cycle = 0;
|
|
2516
2523
|
delayCountdown;
|
|
2517
2524
|
constructor(e) {
|
|
2518
|
-
this.context = e, this.delayCountdown = new
|
|
2525
|
+
this.context = e, this.delayCountdown = new Gt((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
|
|
2519
2526
|
}
|
|
2520
2527
|
beginCycle() {
|
|
2521
2528
|
let { options: e, state: t } = this.context;
|
|
@@ -2523,14 +2530,14 @@ var en = class {
|
|
|
2523
2530
|
this.clear();
|
|
2524
2531
|
let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
2525
2532
|
return t.autofill = {
|
|
2526
|
-
...
|
|
2533
|
+
...Xt(e, void 0, !1),
|
|
2527
2534
|
cycleId: n,
|
|
2528
2535
|
status: "filling"
|
|
2529
2536
|
}, n;
|
|
2530
2537
|
}
|
|
2531
2538
|
async cancel() {
|
|
2532
2539
|
let { cancelRequest: e, options: t, state: n } = this.context;
|
|
2533
|
-
await
|
|
2540
|
+
await Qt(t, n, e), this.commitCollection();
|
|
2534
2541
|
}
|
|
2535
2542
|
captureCollection(e, t) {
|
|
2536
2543
|
t && (this.collection = e);
|
|
@@ -2558,30 +2565,30 @@ var en = class {
|
|
|
2558
2565
|
requests: r.requests
|
|
2559
2566
|
}));
|
|
2560
2567
|
}
|
|
2561
|
-
},
|
|
2562
|
-
function
|
|
2568
|
+
}, nn = 100;
|
|
2569
|
+
function rn(e, t) {
|
|
2563
2570
|
if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
|
|
2564
2571
|
}
|
|
2565
|
-
function
|
|
2572
|
+
function an(e, t, n) {
|
|
2566
2573
|
return Math.min(n, Math.max(t, e));
|
|
2567
2574
|
}
|
|
2568
|
-
function
|
|
2575
|
+
function on(e) {
|
|
2569
2576
|
if (!e) return;
|
|
2570
2577
|
let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
|
|
2571
|
-
if (
|
|
2572
|
-
e.speedPxPerSecond !== void 0 &&
|
|
2578
|
+
if (rn("autoScroll.minSpeedPxPerSecond", t), rn("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
|
|
2579
|
+
e.speedPxPerSecond !== void 0 && rn("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
|
|
2573
2580
|
}
|
|
2574
|
-
function
|
|
2581
|
+
function sn(e) {
|
|
2575
2582
|
let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
|
|
2576
2583
|
return {
|
|
2577
2584
|
enabled: e?.enabled ?? !1,
|
|
2578
2585
|
maxSpeedPxPerSecond: n,
|
|
2579
2586
|
minSpeedPxPerSecond: t,
|
|
2580
2587
|
paused: !1,
|
|
2581
|
-
speedPxPerSecond:
|
|
2588
|
+
speedPxPerSecond: an(e?.speedPxPerSecond ?? 80, t, n)
|
|
2582
2589
|
};
|
|
2583
2590
|
}
|
|
2584
|
-
var
|
|
2591
|
+
var cn = class {
|
|
2585
2592
|
frame = null;
|
|
2586
2593
|
lastTimestamp = null;
|
|
2587
2594
|
mounted = !1;
|
|
@@ -2601,9 +2608,9 @@ var sn = class {
|
|
|
2601
2608
|
this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
|
|
2602
2609
|
}
|
|
2603
2610
|
setSpeed(e) {
|
|
2604
|
-
|
|
2611
|
+
rn("auto-scroll speed", e);
|
|
2605
2612
|
let t = this.options.state;
|
|
2606
|
-
t.speedPxPerSecond =
|
|
2613
|
+
t.speedPxPerSecond = an(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
|
|
2607
2614
|
}
|
|
2608
2615
|
tick = (e) => {
|
|
2609
2616
|
this.frame = null;
|
|
@@ -2615,7 +2622,7 @@ var sn = class {
|
|
|
2615
2622
|
return;
|
|
2616
2623
|
}
|
|
2617
2624
|
if (this.lastTimestamp !== null) {
|
|
2618
|
-
let r = Math.min(
|
|
2625
|
+
let r = Math.min(nn, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
|
|
2619
2626
|
n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
|
|
2620
2627
|
}
|
|
2621
2628
|
this.lastTimestamp = e, this.schedule();
|
|
@@ -2629,7 +2636,7 @@ var sn = class {
|
|
|
2629
2636
|
};
|
|
2630
2637
|
//#endregion
|
|
2631
2638
|
//#region src/core/backendAutofill.ts
|
|
2632
|
-
async function
|
|
2639
|
+
async function ln(e, t, n, r) {
|
|
2633
2640
|
let i = await e.onUnderfilled(n);
|
|
2634
2641
|
if (!r()) return;
|
|
2635
2642
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
|
|
@@ -2643,19 +2650,19 @@ async function cn(e, t, n, r) {
|
|
|
2643
2650
|
status: "waiting"
|
|
2644
2651
|
});
|
|
2645
2652
|
}
|
|
2646
|
-
function
|
|
2653
|
+
function un(e, t) {
|
|
2647
2654
|
["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);
|
|
2648
2655
|
}
|
|
2649
|
-
function
|
|
2656
|
+
function dn(e, t, n) {
|
|
2650
2657
|
let r = t.autofill;
|
|
2651
|
-
return
|
|
2658
|
+
return !$t(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (un(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);
|
|
2652
2659
|
}
|
|
2653
|
-
function
|
|
2654
|
-
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill =
|
|
2660
|
+
function fn(e, t, n) {
|
|
2661
|
+
return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Xt(e, n), un(t, n), !0);
|
|
2655
2662
|
}
|
|
2656
2663
|
//#endregion
|
|
2657
2664
|
//#region src/core/initialAutofill.ts
|
|
2658
|
-
async function
|
|
2665
|
+
async function pn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
|
|
2659
2666
|
let c = a.autofill;
|
|
2660
2667
|
if (!c) return;
|
|
2661
2668
|
let l = s.items.length;
|
|
@@ -2668,7 +2675,7 @@ async function fn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
2668
2675
|
return;
|
|
2669
2676
|
}
|
|
2670
2677
|
if (c.strategy === "backend") {
|
|
2671
|
-
await
|
|
2678
|
+
await ln(c, s, {
|
|
2672
2679
|
cycleId: e,
|
|
2673
2680
|
feedKey: c.feedKey,
|
|
2674
2681
|
items: [...s.items],
|
|
@@ -2685,11 +2692,11 @@ async function fn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
2685
2692
|
s.autofill.status = "exhausted";
|
|
2686
2693
|
return;
|
|
2687
2694
|
}
|
|
2688
|
-
let u = await
|
|
2695
|
+
let u = await en({
|
|
2689
2696
|
existingItems: s.items,
|
|
2690
2697
|
initialCursor: s.next,
|
|
2691
2698
|
loadPage: a.loadPage,
|
|
2692
|
-
maximumRequests:
|
|
2699
|
+
maximumRequests: Kt(c, !1),
|
|
2693
2700
|
onCollection: n,
|
|
2694
2701
|
onDelayChange: (e) => {
|
|
2695
2702
|
t() && Object.assign(s.autofill, e);
|
|
@@ -2712,13 +2719,13 @@ async function fn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
|
|
|
2712
2719
|
}
|
|
2713
2720
|
//#endregion
|
|
2714
2721
|
//#region src/core/fill.ts
|
|
2715
|
-
function
|
|
2722
|
+
function mn(e) {
|
|
2716
2723
|
return "pages" in e ? { pages: e.pages } : { until: "end" };
|
|
2717
2724
|
}
|
|
2718
|
-
function
|
|
2725
|
+
function hn(e) {
|
|
2719
2726
|
return `${typeof e}:${String(e)}`;
|
|
2720
2727
|
}
|
|
2721
|
-
function
|
|
2728
|
+
function gn(e) {
|
|
2722
2729
|
if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
|
|
2723
2730
|
if ("pages" in e) {
|
|
2724
2731
|
if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
|
|
@@ -2727,20 +2734,20 @@ function hn(e) {
|
|
|
2727
2734
|
if ("until" in e && e.until === "end") return { until: "end" };
|
|
2728
2735
|
throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
|
|
2729
2736
|
}
|
|
2730
|
-
function
|
|
2737
|
+
function _n(e) {
|
|
2731
2738
|
if (!e) return;
|
|
2732
2739
|
if (e.strategy === "frontend") {
|
|
2733
|
-
|
|
2740
|
+
Ht(e, "frontend fill");
|
|
2734
2741
|
return;
|
|
2735
2742
|
}
|
|
2736
2743
|
if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
|
|
2737
2744
|
let t = e.initialSession;
|
|
2738
2745
|
if (t) {
|
|
2739
2746
|
if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
|
|
2740
|
-
|
|
2747
|
+
gn(t.target);
|
|
2741
2748
|
}
|
|
2742
2749
|
}
|
|
2743
|
-
function
|
|
2750
|
+
function vn(e, t, n = !0) {
|
|
2744
2751
|
let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
|
|
2745
2752
|
return {
|
|
2746
2753
|
completedPages: i?.completedPages ?? 0,
|
|
@@ -2754,10 +2761,10 @@ function _n(e, t, n = !0) {
|
|
|
2754
2761
|
sessionId: i?.sessionId ?? null,
|
|
2755
2762
|
status: i?.status ?? "idle",
|
|
2756
2763
|
strategy: e?.strategy ?? null,
|
|
2757
|
-
target: i ?
|
|
2764
|
+
target: i ? mn(i.target) : null
|
|
2758
2765
|
};
|
|
2759
2766
|
}
|
|
2760
|
-
function
|
|
2767
|
+
function yn(e) {
|
|
2761
2768
|
return [
|
|
2762
2769
|
"cancelling",
|
|
2763
2770
|
"filling",
|
|
@@ -2765,13 +2772,13 @@ function vn(e) {
|
|
|
2765
2772
|
"waiting"
|
|
2766
2773
|
].includes(e.status);
|
|
2767
2774
|
}
|
|
2768
|
-
async function
|
|
2775
|
+
async function bn({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
|
|
2769
2776
|
let u = [], d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = 0, h = t, g = t, _ = t, v = 0, y;
|
|
2770
2777
|
for (; _ !== null;) {
|
|
2771
|
-
let e =
|
|
2778
|
+
let e = hn(h);
|
|
2772
2779
|
if (p.has(e)) throw Error("Vibe fill received a repeated cursor.");
|
|
2773
|
-
if (p.add(e), await
|
|
2774
|
-
delayMs:
|
|
2780
|
+
if (p.add(e), await Wt({
|
|
2781
|
+
delayMs: Ut(m, o),
|
|
2775
2782
|
onChange: i,
|
|
2776
2783
|
signal: c
|
|
2777
2784
|
}), m > 0 && s()) return {
|
|
@@ -2784,7 +2791,7 @@ async function yn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
2784
2791
|
status: "paused",
|
|
2785
2792
|
total: y
|
|
2786
2793
|
};
|
|
2787
|
-
let t =
|
|
2794
|
+
let t = It(await n({
|
|
2788
2795
|
cursor: h,
|
|
2789
2796
|
signal: c
|
|
2790
2797
|
}));
|
|
@@ -2852,7 +2859,7 @@ async function yn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
|
|
|
2852
2859
|
}
|
|
2853
2860
|
//#endregion
|
|
2854
2861
|
//#region src/core/backendFill.ts
|
|
2855
|
-
async function
|
|
2862
|
+
async function xn(e, t, n, r) {
|
|
2856
2863
|
let i = await e.onStart(n);
|
|
2857
2864
|
if (r()) {
|
|
2858
2865
|
if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
|
|
@@ -2866,22 +2873,22 @@ async function bn(e, t, n, r) {
|
|
|
2866
2873
|
});
|
|
2867
2874
|
}
|
|
2868
2875
|
}
|
|
2869
|
-
function
|
|
2876
|
+
function Sn(e, t, n) {
|
|
2870
2877
|
return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
|
|
2871
2878
|
}
|
|
2872
|
-
function
|
|
2879
|
+
function Cn(e) {
|
|
2873
2880
|
return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
|
|
2874
2881
|
}
|
|
2875
|
-
function
|
|
2882
|
+
function wn(e, t) {
|
|
2876
2883
|
if (!["complete", "exhausted"].includes(t.status)) return !0;
|
|
2877
2884
|
let n = e.fill.target;
|
|
2878
2885
|
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;
|
|
2879
2886
|
}
|
|
2880
|
-
function
|
|
2887
|
+
function Tn(e, t, n) {
|
|
2881
2888
|
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));
|
|
2882
2889
|
}
|
|
2883
|
-
function
|
|
2884
|
-
return !
|
|
2890
|
+
function En(e, t, n, r) {
|
|
2891
|
+
return !Sn(e, t, n) || !Cn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !wn(t, n) ? !1 : (Tn(t, n, r), Object.assign(t.fill, {
|
|
2885
2892
|
...Q(n.status === "waiting" ? n.nextRequestAt : null),
|
|
2886
2893
|
completedPages: n.completedPages,
|
|
2887
2894
|
error: n.error ?? null,
|
|
@@ -2890,42 +2897,42 @@ function Tn(e, t, n, r) {
|
|
|
2890
2897
|
status: n.status
|
|
2891
2898
|
}), !0);
|
|
2892
2899
|
}
|
|
2893
|
-
function
|
|
2900
|
+
function Dn(e, t, n, r) {
|
|
2894
2901
|
if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
|
|
2895
2902
|
let i = t.fill;
|
|
2896
|
-
return t.fill =
|
|
2903
|
+
return t.fill = vn(e, n), !Cn(n) || !wn(t, n) ? (t.fill = i, !1) : (Tn(t, n, r), !0);
|
|
2897
2904
|
}
|
|
2898
2905
|
//#endregion
|
|
2899
2906
|
//#region src/core/fillController.ts
|
|
2900
|
-
var
|
|
2907
|
+
var On = class {
|
|
2901
2908
|
abortController = null;
|
|
2902
2909
|
cycle = 0;
|
|
2903
2910
|
delayCountdown;
|
|
2904
2911
|
requestVersion = 0;
|
|
2905
2912
|
collection = null;
|
|
2906
2913
|
constructor(e) {
|
|
2907
|
-
this.options = e, this.delayCountdown = new
|
|
2914
|
+
this.options = e, this.delayCountdown = new Gt((e) => {
|
|
2908
2915
|
Object.assign(this.options.state.fill, e);
|
|
2909
2916
|
}), this.syncBackendCountdown();
|
|
2910
2917
|
}
|
|
2911
2918
|
isActive() {
|
|
2912
|
-
return
|
|
2919
|
+
return yn(this.options.state.fill);
|
|
2913
2920
|
}
|
|
2914
2921
|
applyUpdate(e) {
|
|
2915
|
-
let t =
|
|
2922
|
+
let t = En(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2916
2923
|
return t && this.syncBackendCountdown(), t;
|
|
2917
2924
|
}
|
|
2918
2925
|
restoreSession(e) {
|
|
2919
|
-
let t =
|
|
2926
|
+
let t = Dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
|
|
2920
2927
|
return t && this.syncBackendCountdown(), t;
|
|
2921
2928
|
}
|
|
2922
2929
|
async start(e) {
|
|
2923
2930
|
let t = this.options.fill;
|
|
2924
2931
|
if (!t) throw Error("Vibe fill is not configured.");
|
|
2925
2932
|
if (this.isActive()) throw Error("Vibe fill is already active.");
|
|
2926
|
-
let n =
|
|
2933
|
+
let n = gn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
|
|
2927
2934
|
if (this.options.state.fill = {
|
|
2928
|
-
...
|
|
2935
|
+
...vn(t, void 0, !1),
|
|
2929
2936
|
cycleId: r,
|
|
2930
2937
|
status: "filling",
|
|
2931
2938
|
target: n
|
|
@@ -2936,7 +2943,7 @@ var Dn = class {
|
|
|
2936
2943
|
let i = ++this.requestVersion, a = new AbortController();
|
|
2937
2944
|
this.abortController = a;
|
|
2938
2945
|
try {
|
|
2939
|
-
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await
|
|
2946
|
+
t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await xn(t, this.options.state, {
|
|
2940
2947
|
cycleId: r,
|
|
2941
2948
|
feedKey: t.feedKey,
|
|
2942
2949
|
items: [...this.options.state.items],
|
|
@@ -2954,7 +2961,7 @@ var Dn = class {
|
|
|
2954
2961
|
}
|
|
2955
2962
|
async cancel() {
|
|
2956
2963
|
let { fill: e, state: t } = this.options;
|
|
2957
|
-
if (!
|
|
2964
|
+
if (!yn(t.fill) || !t.fill.cycleId) return;
|
|
2958
2965
|
let n = {
|
|
2959
2966
|
cycleId: t.fill.cycleId,
|
|
2960
2967
|
feedKey: t.fill.feedKey ?? "",
|
|
@@ -2968,7 +2975,7 @@ var Dn = class {
|
|
|
2968
2975
|
}
|
|
2969
2976
|
}
|
|
2970
2977
|
reset() {
|
|
2971
|
-
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill =
|
|
2978
|
+
this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = vn(this.options.fill, void 0, !1), this.collection = null;
|
|
2972
2979
|
}
|
|
2973
2980
|
destroy() {
|
|
2974
2981
|
this.abortLocalRequest(), this.delayCountdown.clear();
|
|
@@ -2984,7 +2991,7 @@ var Dn = class {
|
|
|
2984
2991
|
if (!i) throw Error("Vibe frontend fill requires loadPage.");
|
|
2985
2992
|
let a = this.options.state;
|
|
2986
2993
|
a.isLoadingMore = !0;
|
|
2987
|
-
let o = await
|
|
2994
|
+
let o = await bn({
|
|
2988
2995
|
existingItems: a.items,
|
|
2989
2996
|
initialCursor: a.next,
|
|
2990
2997
|
loadPage: i,
|
|
@@ -3024,7 +3031,7 @@ var Dn = class {
|
|
|
3024
3031
|
};
|
|
3025
3032
|
//#endregion
|
|
3026
3033
|
//#region src/core/feedFooter.ts
|
|
3027
|
-
function
|
|
3034
|
+
function kn(e) {
|
|
3028
3035
|
return {
|
|
3029
3036
|
cancelAutofill: () => e.cancelAutofill(),
|
|
3030
3037
|
loadMore: () => e.loadNext(),
|
|
@@ -3032,45 +3039,45 @@ function On(e) {
|
|
|
3032
3039
|
retryEnd: () => e.retryEnd()
|
|
3033
3040
|
};
|
|
3034
3041
|
}
|
|
3035
|
-
function kn(e) {
|
|
3036
|
-
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
3037
|
-
}
|
|
3038
3042
|
function An(e) {
|
|
3039
|
-
e
|
|
3043
|
+
if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
|
|
3040
3044
|
}
|
|
3041
3045
|
function jn(e) {
|
|
3046
|
+
e?.intervalMs !== void 0 && An(e.intervalMs);
|
|
3047
|
+
}
|
|
3048
|
+
function Mn(e) {
|
|
3042
3049
|
return {
|
|
3043
3050
|
enabled: e?.enabled ?? !1,
|
|
3044
3051
|
includePostItems: e?.includePostItems ?? !1,
|
|
3045
3052
|
intervalMs: e?.intervalMs ?? 5e3
|
|
3046
3053
|
};
|
|
3047
3054
|
}
|
|
3048
|
-
function
|
|
3055
|
+
function Nn(e, t) {
|
|
3049
3056
|
if (typeof t == "boolean") {
|
|
3050
3057
|
e.enabled = t;
|
|
3051
3058
|
return;
|
|
3052
3059
|
}
|
|
3053
|
-
|
|
3060
|
+
jn(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);
|
|
3054
3061
|
}
|
|
3055
3062
|
//#endregion
|
|
3056
3063
|
//#region src/core/reelInfoSheet.ts
|
|
3057
|
-
function
|
|
3064
|
+
function Pn(e) {
|
|
3058
3065
|
return { enabled: e?.enabled ?? !1 };
|
|
3059
3066
|
}
|
|
3060
|
-
function
|
|
3067
|
+
function Fn(e, t, n) {
|
|
3061
3068
|
if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
|
|
3062
3069
|
e.enabled = n;
|
|
3063
3070
|
}
|
|
3064
3071
|
//#endregion
|
|
3065
3072
|
//#region src/core/initialRuntimeState.ts
|
|
3066
|
-
function
|
|
3073
|
+
function In(e, t) {
|
|
3067
3074
|
let n = e.initialPage;
|
|
3068
3075
|
return {
|
|
3069
3076
|
activeReelPostId: null,
|
|
3070
|
-
autoScroll:
|
|
3071
|
-
autofill:
|
|
3077
|
+
autoScroll: sn(e.autoScroll),
|
|
3078
|
+
autofill: Xt(e.autofill),
|
|
3072
3079
|
error: null,
|
|
3073
|
-
fill:
|
|
3080
|
+
fill: vn(e.fill),
|
|
3074
3081
|
infiniteScroll: e.infiniteScroll ?? !0,
|
|
3075
3082
|
isLoading: !n,
|
|
3076
3083
|
isLoadingMore: !1,
|
|
@@ -3081,14 +3088,14 @@ function Fn(e, t) {
|
|
|
3081
3088
|
next: n?.next ?? null,
|
|
3082
3089
|
nextPageError: null,
|
|
3083
3090
|
phoneMode: !1,
|
|
3084
|
-
reelAutoAdvance:
|
|
3091
|
+
reelAutoAdvance: Mn(e.reelAutoAdvance),
|
|
3085
3092
|
reelForward: {
|
|
3086
3093
|
error: null,
|
|
3087
3094
|
status: "idle"
|
|
3088
3095
|
},
|
|
3089
3096
|
reelForwardIndex: null,
|
|
3090
3097
|
reelForwardItem: null,
|
|
3091
|
-
reelInfoSheet:
|
|
3098
|
+
reelInfoSheet: Pn(e.reelInfoSheet),
|
|
3092
3099
|
reelInfoSheetOverlay: !1,
|
|
3093
3100
|
reelMediaSource: "original",
|
|
3094
3101
|
reelOrigin: null,
|
|
@@ -3097,20 +3104,20 @@ function Fn(e, t) {
|
|
|
3097
3104
|
}
|
|
3098
3105
|
//#endregion
|
|
3099
3106
|
//#region src/core/options.ts
|
|
3100
|
-
function
|
|
3107
|
+
function Ln(e, t) {
|
|
3101
3108
|
if (t) {
|
|
3102
3109
|
if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
|
|
3103
3110
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
|
|
3104
3111
|
}
|
|
3105
3112
|
}
|
|
3106
|
-
function
|
|
3113
|
+
function Rn(e, t) {
|
|
3107
3114
|
if (t) {
|
|
3108
3115
|
if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
|
|
3109
3116
|
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.`);
|
|
3110
3117
|
}
|
|
3111
3118
|
}
|
|
3112
|
-
function
|
|
3113
|
-
if (
|
|
3119
|
+
function zn(e) {
|
|
3120
|
+
if (on(e.autoScroll), Ln("cardHeader", e.cardHeader), Ln("cardFooter", e.cardFooter), Rn("header", e.mediaCard?.header), Rn("footer", e.mediaCard?.footer), Yt(e.autofill), _n(e.fill), jn(e.reelAutoAdvance), e.removalReconciliation) {
|
|
3114
3121
|
if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
|
|
3115
3122
|
let t = e.removalReconciliation.maxReplayPages ?? 5;
|
|
3116
3123
|
if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
|
|
@@ -3124,7 +3131,7 @@ function Rn(e) {
|
|
|
3124
3131
|
if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
|
|
3125
3132
|
if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
|
|
3126
3133
|
}
|
|
3127
|
-
function
|
|
3134
|
+
function Bn(e) {
|
|
3128
3135
|
if (typeof e != "string") return e;
|
|
3129
3136
|
if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
|
|
3130
3137
|
let t = document.querySelector(e);
|
|
@@ -3133,7 +3140,7 @@ function zn(e) {
|
|
|
3133
3140
|
}
|
|
3134
3141
|
//#endregion
|
|
3135
3142
|
//#region src/core/pageRequest.ts
|
|
3136
|
-
async function
|
|
3143
|
+
async function Vn({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
|
|
3137
3144
|
let u = s.autofill, d = e && u?.strategy === "frontend" && l.autofill.status === "paused", f = d ? {
|
|
3138
3145
|
received: l.autofill.received,
|
|
3139
3146
|
requests: l.autofill.requests
|
|
@@ -3145,11 +3152,11 @@ async function Bn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3145
3152
|
let m = !1;
|
|
3146
3153
|
try {
|
|
3147
3154
|
if (u?.strategy === "frontend") {
|
|
3148
|
-
let s = await
|
|
3155
|
+
let s = await en({
|
|
3149
3156
|
existingItems: e ? l.items : [],
|
|
3150
3157
|
initialCursor: n,
|
|
3151
3158
|
loadPage: i,
|
|
3152
|
-
maximumRequests: f ? Math.max(0,
|
|
3159
|
+
maximumRequests: f ? Math.max(0, Kt(u) - f.requests) : void 0,
|
|
3153
3160
|
onCollection: (e) => t.captureCollection(e, r()),
|
|
3154
3161
|
onDelayChange: (e) => {
|
|
3155
3162
|
r() && Object.assign(l.autofill, e);
|
|
@@ -3172,7 +3179,7 @@ async function Bn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3172
3179
|
}), o(s.pages), t.clearCollection();
|
|
3173
3180
|
return;
|
|
3174
3181
|
}
|
|
3175
|
-
let s =
|
|
3182
|
+
let s = It(await i({
|
|
3176
3183
|
cursor: n,
|
|
3177
3184
|
signal: c
|
|
3178
3185
|
}));
|
|
@@ -3192,7 +3199,7 @@ async function Bn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3192
3199
|
l.autofill.status = "complete";
|
|
3193
3200
|
return;
|
|
3194
3201
|
}
|
|
3195
|
-
await
|
|
3202
|
+
await ln(u, l, {
|
|
3196
3203
|
cycleId: p,
|
|
3197
3204
|
feedKey: u.feedKey,
|
|
3198
3205
|
items: h.slice(d.length),
|
|
@@ -3216,13 +3223,13 @@ async function Bn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
|
|
|
3216
3223
|
function $(e) {
|
|
3217
3224
|
return `${typeof e}:${String(e)}`;
|
|
3218
3225
|
}
|
|
3219
|
-
function
|
|
3226
|
+
function Hn(e) {
|
|
3220
3227
|
return `${typeof e}:${String(e)}`;
|
|
3221
3228
|
}
|
|
3222
|
-
function
|
|
3229
|
+
function Un(e) {
|
|
3223
3230
|
return e.map(({ postId: e }) => e);
|
|
3224
3231
|
}
|
|
3225
|
-
var
|
|
3232
|
+
var Wn = class {
|
|
3226
3233
|
delay;
|
|
3227
3234
|
enabled;
|
|
3228
3235
|
maxReplayPages;
|
|
@@ -3264,14 +3271,14 @@ var Un = class {
|
|
|
3264
3271
|
async reconcile({ existingItems: e, loadPage: t, shouldPause: n = () => !1, signal: r }) {
|
|
3265
3272
|
let i = this.pending ?? this.createSession(e);
|
|
3266
3273
|
for (this.pending = i; i.remainingRequests > 0;) {
|
|
3267
|
-
let e =
|
|
3274
|
+
let e = Hn(i.cursor);
|
|
3268
3275
|
if (i.seenCursors.has(e)) throw Error("Vibe removal reconciliation received a repeated cursor.");
|
|
3269
|
-
if (await
|
|
3270
|
-
delayMs:
|
|
3276
|
+
if (await Wt({
|
|
3277
|
+
delayMs: Ut(i.pages.length, this.delay),
|
|
3271
3278
|
onChange: () => void 0,
|
|
3272
3279
|
signal: r
|
|
3273
3280
|
}), i.pages.length > 0 && n()) return this.result(i, "paused");
|
|
3274
|
-
let a =
|
|
3281
|
+
let a = It(await t({
|
|
3275
3282
|
cursor: i.cursor,
|
|
3276
3283
|
signal: r
|
|
3277
3284
|
}));
|
|
@@ -3284,7 +3291,7 @@ var Un = class {
|
|
|
3284
3291
|
contributionIds: s,
|
|
3285
3292
|
cursor: i.cursor,
|
|
3286
3293
|
next: a.next,
|
|
3287
|
-
returnedIds:
|
|
3294
|
+
returnedIds: Un(o)
|
|
3288
3295
|
}), i.lastCursor = i.cursor, i.next = a.next, --i.remainingRequests, a.total !== void 0 && (i.total = a.total), i.next === null ? i.remainingRequests = 0 : i.cursor = i.next, i.remainingRequests > 0 && n()) return this.result(i, "paused");
|
|
3289
3296
|
}
|
|
3290
3297
|
return this.result(i, "complete");
|
|
@@ -3323,7 +3330,7 @@ var Un = class {
|
|
|
3323
3330
|
return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
|
|
3324
3331
|
}
|
|
3325
3332
|
recordPage(e) {
|
|
3326
|
-
let t =
|
|
3333
|
+
let t = Hn(e.cursor), n = this.pages.findIndex(({ cursor: e }) => Hn(e) === t);
|
|
3327
3334
|
n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
|
|
3328
3335
|
...e,
|
|
3329
3336
|
contributionIds: [...e.contributionIds],
|
|
@@ -3333,7 +3340,7 @@ var Un = class {
|
|
|
3333
3340
|
};
|
|
3334
3341
|
//#endregion
|
|
3335
3342
|
//#region src/core/activeItemRemoval.ts
|
|
3336
|
-
function
|
|
3343
|
+
function Gn(e, t, n, r, i) {
|
|
3337
3344
|
let a = new Set(t.map(({ item: e }) => e.postId));
|
|
3338
3345
|
if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
|
|
3339
3346
|
let o = e.items[Math.max(n, 0)];
|
|
@@ -3346,7 +3353,7 @@ function Wn(e, t, n, r, i) {
|
|
|
3346
3353
|
}
|
|
3347
3354
|
//#endregion
|
|
3348
3355
|
//#region src/core/exactMediaRemovalController.ts
|
|
3349
|
-
function
|
|
3356
|
+
function Kn(e, t) {
|
|
3350
3357
|
let [n, ...r] = t;
|
|
3351
3358
|
if (!n) throw Error("Vibe items must contain at least one media asset.");
|
|
3352
3359
|
return {
|
|
@@ -3355,10 +3362,10 @@ function Gn(e, t) {
|
|
|
3355
3362
|
items: r
|
|
3356
3363
|
};
|
|
3357
3364
|
}
|
|
3358
|
-
function
|
|
3365
|
+
function qn(e) {
|
|
3359
3366
|
if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
|
|
3360
3367
|
}
|
|
3361
|
-
var
|
|
3368
|
+
var Jn = class {
|
|
3362
3369
|
generation = 0;
|
|
3363
3370
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
3364
3371
|
state;
|
|
@@ -3366,7 +3373,7 @@ var qn = class {
|
|
|
3366
3373
|
this.options = e, this.state = e.state;
|
|
3367
3374
|
}
|
|
3368
3375
|
remove(e) {
|
|
3369
|
-
|
|
3376
|
+
qn(e);
|
|
3370
3377
|
let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
|
|
3371
3378
|
if (!n) return null;
|
|
3372
3379
|
let r = [...M(n)], i = r[e.mediaIndex];
|
|
@@ -3383,7 +3390,7 @@ var qn = class {
|
|
|
3383
3390
|
restored: !1
|
|
3384
3391
|
});
|
|
3385
3392
|
let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
|
|
3386
|
-
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] =
|
|
3393
|
+
return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Kn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
|
|
3387
3394
|
}
|
|
3388
3395
|
reset() {
|
|
3389
3396
|
this.generation += 1;
|
|
@@ -3409,7 +3416,7 @@ var qn = class {
|
|
|
3409
3416
|
}
|
|
3410
3417
|
restoreIntoPost(e, t) {
|
|
3411
3418
|
let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
|
|
3412
|
-
if (r.splice(i, 0, t.media), this.state.items[e] =
|
|
3419
|
+
if (r.splice(i, 0, t.media), this.state.items[e] = Kn(n, r), this.state.activeReelPostId !== t.postId) return;
|
|
3413
3420
|
let a = this.state.mediaIndices.get(t.postId) ?? 0;
|
|
3414
3421
|
a >= i && this.state.mediaIndices.set(t.postId, a + 1);
|
|
3415
3422
|
}
|
|
@@ -3422,18 +3429,18 @@ var qn = class {
|
|
|
3422
3429
|
};
|
|
3423
3430
|
//#endregion
|
|
3424
3431
|
//#region src/core/itemPlacement.ts
|
|
3425
|
-
function
|
|
3432
|
+
function Yn(e, t) {
|
|
3426
3433
|
let n = new Set(t);
|
|
3427
3434
|
return e.flatMap((e, t) => n.has(e.postId) ? [{
|
|
3428
3435
|
index: t,
|
|
3429
3436
|
item: e
|
|
3430
3437
|
}] : []);
|
|
3431
3438
|
}
|
|
3432
|
-
function
|
|
3439
|
+
function Xn(e, t) {
|
|
3433
3440
|
let n = new Set(t.map(({ item: e }) => e.postId));
|
|
3434
3441
|
return e.filter((e) => !n.has(e.postId));
|
|
3435
3442
|
}
|
|
3436
|
-
function
|
|
3443
|
+
function Zn(e, t) {
|
|
3437
3444
|
t.forEach(({ index: e }) => {
|
|
3438
3445
|
if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
|
|
3439
3446
|
});
|
|
@@ -3444,7 +3451,7 @@ function Xn(e, t) {
|
|
|
3444
3451
|
}
|
|
3445
3452
|
//#endregion
|
|
3446
3453
|
//#region src/core/itemRemovalController.ts
|
|
3447
|
-
var
|
|
3454
|
+
var Qn = 20, $n = class {
|
|
3448
3455
|
generation = 0;
|
|
3449
3456
|
historyLimit;
|
|
3450
3457
|
metadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -3453,7 +3460,7 @@ var Zn = 20, Qn = class {
|
|
|
3453
3460
|
itemOrder;
|
|
3454
3461
|
stopItemsWatcher;
|
|
3455
3462
|
constructor(e) {
|
|
3456
|
-
this.options = e, this.historyLimit = e.historyLimit ??
|
|
3463
|
+
this.options = e, this.historyLimit = e.historyLimit ?? Qn, 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" });
|
|
3457
3464
|
}
|
|
3458
3465
|
destroy() {
|
|
3459
3466
|
this.reset(), this.stopItemsWatcher();
|
|
@@ -3466,7 +3473,7 @@ var Zn = 20, Qn = class {
|
|
|
3466
3473
|
let i = this.options.startRemoval(r);
|
|
3467
3474
|
if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
|
|
3468
3475
|
let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
|
|
3469
|
-
return this.state.items =
|
|
3476
|
+
return this.state.items = Xn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
|
|
3470
3477
|
}
|
|
3471
3478
|
reset() {
|
|
3472
3479
|
this.generation += 1, this.history = [], this.itemOrder = [];
|
|
@@ -3477,7 +3484,7 @@ var Zn = 20, Qn = class {
|
|
|
3477
3484
|
this.restoreRemoval(t);
|
|
3478
3485
|
return;
|
|
3479
3486
|
}
|
|
3480
|
-
let n =
|
|
3487
|
+
let n = Zn(this.state.items, e);
|
|
3481
3488
|
this.registerExternalPlacements(e), this.state.items = n;
|
|
3482
3489
|
}
|
|
3483
3490
|
restoreRemoval(e) {
|
|
@@ -3503,7 +3510,7 @@ var Zn = 20, Qn = class {
|
|
|
3503
3510
|
}
|
|
3504
3511
|
collectOrderedPlacements(e) {
|
|
3505
3512
|
let t = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
3506
|
-
return
|
|
3513
|
+
return Yn(this.state.items, e).map((e) => ({
|
|
3507
3514
|
index: t.get(e.item.postId) ?? e.index,
|
|
3508
3515
|
item: e.item
|
|
3509
3516
|
}));
|
|
@@ -3534,7 +3541,7 @@ var Zn = 20, Qn = class {
|
|
|
3534
3541
|
let r = new Map(this.itemOrder.map((e, t) => [e, t]));
|
|
3535
3542
|
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;
|
|
3536
3543
|
}
|
|
3537
|
-
},
|
|
3544
|
+
}, er = class {
|
|
3538
3545
|
forward = null;
|
|
3539
3546
|
forwardPromise = null;
|
|
3540
3547
|
forwardVersion = 0;
|
|
@@ -3612,7 +3619,7 @@ var Zn = 20, Qn = class {
|
|
|
3612
3619
|
}
|
|
3613
3620
|
}
|
|
3614
3621
|
}
|
|
3615
|
-
},
|
|
3622
|
+
}, tr = class {
|
|
3616
3623
|
generation = 0;
|
|
3617
3624
|
pending = Promise.resolve();
|
|
3618
3625
|
constructor(e) {
|
|
@@ -3662,24 +3669,24 @@ var Zn = 20, Qn = class {
|
|
|
3662
3669
|
};
|
|
3663
3670
|
//#endregion
|
|
3664
3671
|
//#region src/core/removalControllers.ts
|
|
3665
|
-
function
|
|
3666
|
-
let t = new
|
|
3672
|
+
function nr(e) {
|
|
3673
|
+
let t = new er(e), n = new tr({
|
|
3667
3674
|
state: e.state,
|
|
3668
3675
|
transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
|
|
3669
3676
|
transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
|
|
3670
3677
|
});
|
|
3671
3678
|
return {
|
|
3672
|
-
exactMediaRemoval: new
|
|
3679
|
+
exactMediaRemoval: new Jn({
|
|
3673
3680
|
onActivate: e.onActivate,
|
|
3674
3681
|
onPostRemoved: (t) => e.onItemsRemoved([t]),
|
|
3675
3682
|
onPostRestored: (t) => e.onItemsRestored([t]),
|
|
3676
3683
|
reelForward: t,
|
|
3677
3684
|
state: e.state
|
|
3678
3685
|
}),
|
|
3679
|
-
itemRemoval: new
|
|
3686
|
+
itemRemoval: new $n({
|
|
3680
3687
|
historyLimit: e.historyLimit,
|
|
3681
3688
|
onItemsRemoved: (n, r, i) => {
|
|
3682
|
-
e.onItemsRemoved(r.map(({ item: e }) => e.postId)),
|
|
3689
|
+
e.onItemsRemoved(r.map(({ item: e }) => e.postId)), Gn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
|
|
3683
3690
|
},
|
|
3684
3691
|
onRemovalRestored: (n) => {
|
|
3685
3692
|
e.onItemsRestored(n.map(({ item: e }) => e.postId));
|
|
@@ -3694,17 +3701,17 @@ function tr(e) {
|
|
|
3694
3701
|
reelRemoval: n
|
|
3695
3702
|
};
|
|
3696
3703
|
}
|
|
3697
|
-
var
|
|
3698
|
-
function
|
|
3704
|
+
var rr = 1.5;
|
|
3705
|
+
function ir(e) {
|
|
3699
3706
|
let t = Math.min(e.screenWidth, e.screenHeight);
|
|
3700
3707
|
if (t > 0 && t < 600) return !0;
|
|
3701
|
-
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n *
|
|
3708
|
+
let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * rr;
|
|
3702
3709
|
return !e.hasHover && n > 0 && n < 600 && r;
|
|
3703
3710
|
}
|
|
3704
|
-
function ir(e) {
|
|
3705
|
-
return rr(e) ? "reel" : "masonry";
|
|
3706
|
-
}
|
|
3707
3711
|
function ar(e) {
|
|
3712
|
+
return ir(e) ? "reel" : "masonry";
|
|
3713
|
+
}
|
|
3714
|
+
function or(e) {
|
|
3708
3715
|
let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
|
|
3709
3716
|
return {
|
|
3710
3717
|
hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
|
|
@@ -3714,15 +3721,15 @@ function ar(e) {
|
|
|
3714
3721
|
viewportWidth: n.clientWidth
|
|
3715
3722
|
};
|
|
3716
3723
|
}
|
|
3717
|
-
function or(e) {
|
|
3718
|
-
return rr(ar(e));
|
|
3719
|
-
}
|
|
3720
3724
|
function sr(e) {
|
|
3721
|
-
return ir(
|
|
3725
|
+
return ir(or(e));
|
|
3726
|
+
}
|
|
3727
|
+
function cr(e) {
|
|
3728
|
+
return ar(or(e));
|
|
3722
3729
|
}
|
|
3723
3730
|
//#endregion
|
|
3724
3731
|
//#region src/core/responsiveLayoutController.ts
|
|
3725
|
-
var
|
|
3732
|
+
var lr = class {
|
|
3726
3733
|
layoutMode;
|
|
3727
3734
|
resizeObserver = null;
|
|
3728
3735
|
target = null;
|
|
@@ -3747,10 +3754,10 @@ var cr = class {
|
|
|
3747
3754
|
}
|
|
3748
3755
|
handleResponsiveLayout = () => {
|
|
3749
3756
|
if (!this.target) return;
|
|
3750
|
-
let e =
|
|
3751
|
-
this.state.phoneMode =
|
|
3757
|
+
let e = cr(this.target);
|
|
3758
|
+
this.state.phoneMode = sr(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
|
|
3752
3759
|
};
|
|
3753
|
-
},
|
|
3760
|
+
}, ur = class {
|
|
3754
3761
|
routedReelPostId = null;
|
|
3755
3762
|
reelRouteIsActive = !1;
|
|
3756
3763
|
constructor(e, t) {
|
|
@@ -3777,7 +3784,7 @@ var cr = class {
|
|
|
3777
3784
|
let i = this.reelRouteIsActive ? "replace" : "push";
|
|
3778
3785
|
this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
|
|
3779
3786
|
}
|
|
3780
|
-
},
|
|
3787
|
+
}, dr = class {
|
|
3781
3788
|
app = null;
|
|
3782
3789
|
autoScroll;
|
|
3783
3790
|
autofillController;
|
|
@@ -3797,12 +3804,12 @@ var cr = class {
|
|
|
3797
3804
|
lastLoadedCursor = null;
|
|
3798
3805
|
state;
|
|
3799
3806
|
constructor(e) {
|
|
3800
|
-
this.options = e,
|
|
3807
|
+
this.options = e, zn(e);
|
|
3801
3808
|
let t = e.layout ?? "masonry";
|
|
3802
|
-
this.state = x(
|
|
3809
|
+
this.state = x(In(e, t)), this.autoScroll = new cn({
|
|
3803
3810
|
getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
|
|
3804
3811
|
state: this.state.autoScroll
|
|
3805
|
-
}), this.autofillController = new
|
|
3812
|
+
}), this.autofillController = new tn({
|
|
3806
3813
|
cancelRequest: () => this.cancelRequest(),
|
|
3807
3814
|
onLastCursor: (e) => {
|
|
3808
3815
|
this.lastLoadedCursor = e;
|
|
@@ -3810,7 +3817,7 @@ var cr = class {
|
|
|
3810
3817
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
3811
3818
|
options: e.autofill,
|
|
3812
3819
|
state: this.state
|
|
3813
|
-
}), this.removalReconciliation = new
|
|
3820
|
+
}), this.removalReconciliation = new Wn(e), this.fillController = new On({
|
|
3814
3821
|
fill: e.fill,
|
|
3815
3822
|
loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
|
|
3816
3823
|
onLastCursor: (e) => {
|
|
@@ -3818,8 +3825,8 @@ var cr = class {
|
|
|
3818
3825
|
},
|
|
3819
3826
|
onPages: (e) => this.removalReconciliation.recordPages(e),
|
|
3820
3827
|
state: this.state
|
|
3821
|
-
}), this.routing = new
|
|
3822
|
-
let n =
|
|
3828
|
+
}), this.routing = new ur(e.routing, this.state);
|
|
3829
|
+
let n = nr({
|
|
3823
3830
|
historyLimit: e.removalHistoryLimit,
|
|
3824
3831
|
loadNext: () => this.loadNext(),
|
|
3825
3832
|
onActivate: (e) => this.setActiveReelPost(e),
|
|
@@ -3829,20 +3836,20 @@ var cr = class {
|
|
|
3829
3836
|
state: this.state,
|
|
3830
3837
|
surface: () => this.surface
|
|
3831
3838
|
});
|
|
3832
|
-
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new
|
|
3839
|
+
this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new lr(t, this.state, () => {
|
|
3833
3840
|
this.routing.syncFeed();
|
|
3834
3841
|
}), this.startStateNotifications();
|
|
3835
3842
|
}
|
|
3836
3843
|
async mount() {
|
|
3837
3844
|
if (this.app) throw Error("Vibe is already mounted.");
|
|
3838
3845
|
this.startStateNotifications();
|
|
3839
|
-
let e =
|
|
3840
|
-
this.responsiveLayout.mount(e), this.app = i(
|
|
3846
|
+
let e = Bn(this.options.target);
|
|
3847
|
+
this.responsiveLayout.mount(e), this.app = i(Ft, {
|
|
3841
3848
|
canRetryEnd: !!this.options.loadPage,
|
|
3842
3849
|
cardFooter: this.options.cardFooter,
|
|
3843
3850
|
cardHeader: this.options.cardHeader,
|
|
3844
3851
|
feedFooter: this.options.feedFooter,
|
|
3845
|
-
feedFooterActions:
|
|
3852
|
+
feedFooterActions: kn(this),
|
|
3846
3853
|
mediaCard: this.options.mediaCard,
|
|
3847
3854
|
onMediaReady: this.options.onMediaReady,
|
|
3848
3855
|
onMediaVisible: this.options.onMediaVisible,
|
|
@@ -3924,7 +3931,7 @@ var cr = class {
|
|
|
3924
3931
|
this.autoScroll.setSpeed(e);
|
|
3925
3932
|
}
|
|
3926
3933
|
applyAutofillUpdate(e) {
|
|
3927
|
-
let t =
|
|
3934
|
+
let t = dn(this.options.autofill, this.state, e);
|
|
3928
3935
|
return t && this.autofillController.syncCountdown(), t;
|
|
3929
3936
|
}
|
|
3930
3937
|
cancelAutofill() {
|
|
@@ -3935,7 +3942,7 @@ var cr = class {
|
|
|
3935
3942
|
await this.cancelFill();
|
|
3936
3943
|
return;
|
|
3937
3944
|
}
|
|
3938
|
-
if (
|
|
3945
|
+
if (Zt(this.state.autofill)) {
|
|
3939
3946
|
await this.cancelAutofill();
|
|
3940
3947
|
return;
|
|
3941
3948
|
}
|
|
@@ -3949,12 +3956,12 @@ var cr = class {
|
|
|
3949
3956
|
}
|
|
3950
3957
|
async fill(e) {
|
|
3951
3958
|
if (!this.state.loadMoreLocked) {
|
|
3952
|
-
if (this.pendingRequest ||
|
|
3959
|
+
if (this.pendingRequest || Zt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
|
|
3953
3960
|
await this.fillController.start(e);
|
|
3954
3961
|
}
|
|
3955
3962
|
}
|
|
3956
3963
|
restoreAutofillSession(e) {
|
|
3957
|
-
let t =
|
|
3964
|
+
let t = fn(this.options.autofill, this.state, e);
|
|
3958
3965
|
return t && this.autofillController.syncCountdown(), t;
|
|
3959
3966
|
}
|
|
3960
3967
|
restoreFillSession(e) {
|
|
@@ -3962,7 +3969,7 @@ var cr = class {
|
|
|
3962
3969
|
}
|
|
3963
3970
|
async loadNext() {
|
|
3964
3971
|
if (this.pendingRequest) return this.pendingRequest;
|
|
3965
|
-
if (this.state.loadMoreLocked ||
|
|
3972
|
+
if (this.state.loadMoreLocked || Zt(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
|
|
3966
3973
|
this.state.isLoadingMore = !0, this.state.nextPageError = null;
|
|
3967
3974
|
let e = this.loadNextSequence();
|
|
3968
3975
|
return this.pendingRequest = e, e.finally(() => {
|
|
@@ -3977,12 +3984,12 @@ var cr = class {
|
|
|
3977
3984
|
}
|
|
3978
3985
|
async replaceFeed(e, t) {
|
|
3979
3986
|
if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
|
|
3980
|
-
return
|
|
3987
|
+
return Zt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Xt(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.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
|
|
3981
3988
|
}
|
|
3982
3989
|
async loadFilteredPage(e) {
|
|
3983
3990
|
let t = this.options.loadPage;
|
|
3984
3991
|
if (!t) throw Error("Vibe cannot load a page without loadPage.");
|
|
3985
|
-
let n =
|
|
3992
|
+
let n = It(await t(e));
|
|
3986
3993
|
return {
|
|
3987
3994
|
...n,
|
|
3988
3995
|
items: this.removalReconciliation.filterItems(n.items)
|
|
@@ -4012,7 +4019,7 @@ var cr = class {
|
|
|
4012
4019
|
}
|
|
4013
4020
|
async retryEnd() {
|
|
4014
4021
|
if (this.pendingRequest) return this.pendingRequest;
|
|
4015
|
-
if (!this.state.loadMoreLocked && !(
|
|
4022
|
+
if (!this.state.loadMoreLocked && !(Zt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
|
|
4016
4023
|
}
|
|
4017
4024
|
setInfiniteScroll(e) {
|
|
4018
4025
|
this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
|
|
@@ -4040,10 +4047,10 @@ var cr = class {
|
|
|
4040
4047
|
this.state.total = e;
|
|
4041
4048
|
}
|
|
4042
4049
|
setReelAutoAdvance(e) {
|
|
4043
|
-
|
|
4050
|
+
Nn(this.state.reelAutoAdvance, e);
|
|
4044
4051
|
}
|
|
4045
4052
|
setReelInfoSheet(e) {
|
|
4046
|
-
|
|
4053
|
+
Fn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
|
|
4047
4054
|
}
|
|
4048
4055
|
setLayout(e) {
|
|
4049
4056
|
this.responsiveLayout.setLayout(e);
|
|
@@ -4063,7 +4070,7 @@ var cr = class {
|
|
|
4063
4070
|
async fetchPage(e, t) {
|
|
4064
4071
|
if (!this.options.loadPage) return;
|
|
4065
4072
|
let n = ++this.requestVersion, r = new AbortController();
|
|
4066
|
-
this.abortController = r, await
|
|
4073
|
+
this.abortController = r, await Vn({
|
|
4067
4074
|
append: t,
|
|
4068
4075
|
autofillController: this.autofillController,
|
|
4069
4076
|
cursor: e,
|
|
@@ -4087,7 +4094,7 @@ var cr = class {
|
|
|
4087
4094
|
startInitialAutofill() {
|
|
4088
4095
|
let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
|
|
4089
4096
|
this.abortController = t, this.state.isLoadingMore = !0;
|
|
4090
|
-
let r =
|
|
4097
|
+
let r = pn({
|
|
4091
4098
|
cycleId: n,
|
|
4092
4099
|
isCurrent: () => e === this.requestVersion,
|
|
4093
4100
|
onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
|
|
@@ -4113,8 +4120,8 @@ var cr = class {
|
|
|
4113
4120
|
}));
|
|
4114
4121
|
}
|
|
4115
4122
|
};
|
|
4116
|
-
function
|
|
4117
|
-
return new
|
|
4123
|
+
function fr(e) {
|
|
4124
|
+
return new dr(e);
|
|
4118
4125
|
}
|
|
4119
4126
|
//#endregion
|
|
4120
|
-
export {
|
|
4127
|
+
export { fr as createVibe };
|