@wyxos/vibe 1.3.1 → 1.4.0

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.js ADDED
@@ -0,0 +1,685 @@
1
+ import { nextTick as X, defineComponent as dt, computed as et, ref as B, onMounted as gt, onUnmounted as pt, createElementBlock as Y, openBlock as J, createElementVNode as C, normalizeStyle as mt, createVNode as ht, createCommentVNode as yt, TransitionGroup as vt, unref as V, withCtx as bt, Fragment as xt, renderList as wt, mergeProps as nt, renderSlot as Tt, normalizeClass as Mt, toDisplayString as at } from "vue";
2
+ function It() {
3
+ const t = document.createElement("div");
4
+ t.style.visibility = "hidden", t.style.overflow = "scroll", t.style.msOverflowStyle = "scrollbar", t.style.width = "100px", t.style.height = "100px", document.body.appendChild(t);
5
+ const a = document.createElement("div");
6
+ a.style.width = "100%", t.appendChild(a);
7
+ const o = t.offsetWidth - a.offsetWidth;
8
+ return document.body.removeChild(t), o;
9
+ }
10
+ function St(t, a, o, s = {}) {
11
+ const {
12
+ gutterX: b = 0,
13
+ gutterY: r = 0,
14
+ header: d = 0,
15
+ footer: i = 0,
16
+ paddingLeft: w = 0,
17
+ paddingRight: h = 0,
18
+ sizes: m = {
19
+ base: 1,
20
+ sm: 2,
21
+ md: 3,
22
+ lg: 4,
23
+ xl: 5,
24
+ "2xl": 6
25
+ },
26
+ placement: p = "masonry"
27
+ } = s;
28
+ let T = 0, E = 0;
29
+ try {
30
+ if (a && a.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
31
+ const f = window.getComputedStyle(a);
32
+ T = parseFloat(f.paddingLeft) || 0, E = parseFloat(f.paddingRight) || 0;
33
+ }
34
+ } catch {
35
+ }
36
+ const $ = (w || 0) + T, A = (h || 0) + E, W = a.offsetWidth - a.clientWidth, M = W > 0 ? W + 2 : It() + 2, H = a.offsetWidth - M - $ - A, N = b * (o - 1), I = Math.floor((H - N) / o), y = t.map((f) => {
37
+ const v = f.width, S = f.height;
38
+ return Math.round(I * S / v) + i + d;
39
+ });
40
+ if (p === "sequential-balanced") {
41
+ const f = y.length;
42
+ if (f === 0) return [];
43
+ const v = (e, n, l) => e + (n > 0 ? r : 0) + l;
44
+ let S = Math.max(...y), L = y.reduce((e, n) => e + n, 0) + r * Math.max(0, f - 1);
45
+ const R = (e) => {
46
+ let n = 1, l = 0, g = 0;
47
+ for (let x = 0; x < f; x++) {
48
+ const P = y[x], k = v(l, g, P);
49
+ if (k <= e)
50
+ l = k, g++;
51
+ else if (n++, l = P, g = 1, P > e || n > o) return !1;
52
+ }
53
+ return n <= o;
54
+ };
55
+ for (; S < L; ) {
56
+ const e = Math.floor((S + L) / 2);
57
+ R(e) ? L = e : S = e + 1;
58
+ }
59
+ const _ = L, O = new Array(o).fill(0);
60
+ let z = o - 1, D = 0, j = 0;
61
+ for (let e = f - 1; e >= 0; e--) {
62
+ const n = y[e], l = e < z;
63
+ !(v(D, j, n) <= _) || l ? (O[z] = e + 1, z--, D = n, j = 1) : (D = v(D, j, n), j++);
64
+ }
65
+ O[0] = 0;
66
+ const q = [], U = new Array(o).fill(0);
67
+ for (let e = 0; e < o; e++) {
68
+ const n = O[e], l = e + 1 < o ? O[e + 1] : f, g = e * (I + b);
69
+ for (let x = n; x < l; x++) {
70
+ const k = { ...t[x], columnWidth: I, imageHeight: 0, columnHeight: 0, left: 0, top: 0 }, F = y[x] - (i + d);
71
+ k.imageHeight = F, k.columnHeight = y[x], k.left = g, k.top = U[e], U[e] += k.columnHeight + (x + 1 < l ? r : 0), q.push(k);
72
+ }
73
+ }
74
+ return q;
75
+ }
76
+ const c = new Array(o).fill(0), u = [];
77
+ for (let f = 0; f < t.length; f++) {
78
+ const v = t[f], S = { ...v, columnWidth: 0, imageHeight: 0, columnHeight: 0, left: 0, top: 0 }, L = c.indexOf(Math.min(...c)), R = v.width, _ = v.height;
79
+ S.columnWidth = I, S.left = L * (I + b), S.imageHeight = Math.round(I * _ / R), S.columnHeight = S.imageHeight + i + d, S.top = c[L], c[L] += S.columnHeight + r, u.push(S);
80
+ }
81
+ return u;
82
+ }
83
+ var kt = typeof global == "object" && global && global.Object === Object && global, Ht = typeof self == "object" && self && self.Object === Object && self, ut = kt || Ht || Function("return this")(), K = ut.Symbol, ft = Object.prototype, Et = ft.hasOwnProperty, Pt = ft.toString, G = K ? K.toStringTag : void 0;
84
+ function Lt(t) {
85
+ var a = Et.call(t, G), o = t[G];
86
+ try {
87
+ t[G] = void 0;
88
+ var s = !0;
89
+ } catch {
90
+ }
91
+ var b = Pt.call(t);
92
+ return s && (a ? t[G] = o : delete t[G]), b;
93
+ }
94
+ var $t = Object.prototype, Nt = $t.toString;
95
+ function Wt(t) {
96
+ return Nt.call(t);
97
+ }
98
+ var At = "[object Null]", Ot = "[object Undefined]", rt = K ? K.toStringTag : void 0;
99
+ function jt(t) {
100
+ return t == null ? t === void 0 ? Ot : At : rt && rt in Object(t) ? Lt(t) : Wt(t);
101
+ }
102
+ function Bt(t) {
103
+ return t != null && typeof t == "object";
104
+ }
105
+ var Ct = "[object Symbol]";
106
+ function zt(t) {
107
+ return typeof t == "symbol" || Bt(t) && jt(t) == Ct;
108
+ }
109
+ var Dt = /\s/;
110
+ function Ft(t) {
111
+ for (var a = t.length; a-- && Dt.test(t.charAt(a)); )
112
+ ;
113
+ return a;
114
+ }
115
+ var Rt = /^\s+/;
116
+ function _t(t) {
117
+ return t && t.slice(0, Ft(t) + 1).replace(Rt, "");
118
+ }
119
+ function Z(t) {
120
+ var a = typeof t;
121
+ return t != null && (a == "object" || a == "function");
122
+ }
123
+ var ot = NaN, qt = /^[-+]0x[0-9a-f]+$/i, Vt = /^0b[01]+$/i, Gt = /^0o[0-7]+$/i, Xt = parseInt;
124
+ function it(t) {
125
+ if (typeof t == "number")
126
+ return t;
127
+ if (zt(t))
128
+ return ot;
129
+ if (Z(t)) {
130
+ var a = typeof t.valueOf == "function" ? t.valueOf() : t;
131
+ t = Z(a) ? a + "" : a;
132
+ }
133
+ if (typeof t != "string")
134
+ return t === 0 ? t : +t;
135
+ t = _t(t);
136
+ var o = Vt.test(t);
137
+ return o || Gt.test(t) ? Xt(t.slice(2), o ? 2 : 8) : qt.test(t) ? ot : +t;
138
+ }
139
+ var Q = function() {
140
+ return ut.Date.now();
141
+ }, Ut = "Expected a function", Yt = Math.max, Jt = Math.min;
142
+ function st(t, a, o) {
143
+ var s, b, r, d, i, w, h = 0, m = !1, p = !1, T = !0;
144
+ if (typeof t != "function")
145
+ throw new TypeError(Ut);
146
+ a = it(a) || 0, Z(o) && (m = !!o.leading, p = "maxWait" in o, r = p ? Yt(it(o.maxWait) || 0, a) : r, T = "trailing" in o ? !!o.trailing : T);
147
+ function E(c) {
148
+ var u = s, f = b;
149
+ return s = b = void 0, h = c, d = t.apply(f, u), d;
150
+ }
151
+ function $(c) {
152
+ return h = c, i = setTimeout(M, a), m ? E(c) : d;
153
+ }
154
+ function A(c) {
155
+ var u = c - w, f = c - h, v = a - u;
156
+ return p ? Jt(v, r - f) : v;
157
+ }
158
+ function W(c) {
159
+ var u = c - w, f = c - h;
160
+ return w === void 0 || u >= a || u < 0 || p && f >= r;
161
+ }
162
+ function M() {
163
+ var c = Q();
164
+ if (W(c))
165
+ return H(c);
166
+ i = setTimeout(M, A(c));
167
+ }
168
+ function H(c) {
169
+ return i = void 0, T && s ? E(c) : (s = b = void 0, d);
170
+ }
171
+ function N() {
172
+ i !== void 0 && clearTimeout(i), h = 0, s = w = b = i = void 0;
173
+ }
174
+ function I() {
175
+ return i === void 0 ? d : H(Q());
176
+ }
177
+ function y() {
178
+ var c = Q(), u = W(c);
179
+ if (s = arguments, b = this, w = c, u) {
180
+ if (i === void 0)
181
+ return $(w);
182
+ if (p)
183
+ return clearTimeout(i), i = setTimeout(M, a), E(w);
184
+ }
185
+ return i === void 0 && (i = setTimeout(M, a)), d;
186
+ }
187
+ return y.cancel = N, y.flush = I, y;
188
+ }
189
+ function lt(t) {
190
+ const a = window.innerWidth, o = t.sizes;
191
+ return a >= 1536 && o["2xl"] ? o["2xl"] : a >= 1280 && o.xl ? o.xl : a >= 1024 && o.lg ? o.lg : a >= 768 && o.md ? o.md : a >= 640 && o.sm ? o.sm : o.base;
192
+ }
193
+ function Kt(t) {
194
+ return t.reduce((o, s) => Math.max(o, s.top + s.columnHeight), 0) + 500;
195
+ }
196
+ function Qt(t) {
197
+ return {
198
+ transform: `translate3d(${t.left}px, ${t.top}px, 0)`,
199
+ top: "0px",
200
+ left: "0px",
201
+ width: `${t.columnWidth}px`,
202
+ height: `${t.columnHeight}px`
203
+ };
204
+ }
205
+ function Zt(t, a = 0) {
206
+ return {
207
+ style: Qt(t),
208
+ "data-top": t.top,
209
+ "data-left": t.left,
210
+ "data-id": `${t.page}-${t.id}`,
211
+ "data-index": a
212
+ };
213
+ }
214
+ function tt(t, a) {
215
+ const o = new Array(a).fill(0);
216
+ for (let s = 0; s < t.length; s++) {
217
+ const b = t[s], r = s % a;
218
+ o[r] = Math.max(o[r], b.top + b.columnHeight);
219
+ }
220
+ return o;
221
+ }
222
+ function te(t) {
223
+ function a(r, d) {
224
+ const i = parseInt(r.dataset.left || "0", 10), w = parseInt(r.dataset.top || "0", 10), h = parseInt(r.dataset.index || "0", 10), m = Math.min(h * 20, 160), p = r.style.getPropertyValue("--masonry-opacity-delay");
225
+ r.style.setProperty("--masonry-opacity-delay", `${m}ms`), requestAnimationFrame(() => {
226
+ r.style.opacity = "1", r.style.transform = `translate3d(${i}px, ${w}px, 0) scale(1)`;
227
+ const T = () => {
228
+ p ? r.style.setProperty("--masonry-opacity-delay", p) : r.style.removeProperty("--masonry-opacity-delay"), r.removeEventListener("transitionend", T), d();
229
+ };
230
+ r.addEventListener("transitionend", T);
231
+ });
232
+ }
233
+ function o(r) {
234
+ const d = parseInt(r.dataset.left || "0", 10), i = parseInt(r.dataset.top || "0", 10);
235
+ r.style.opacity = "0", r.style.transform = `translate3d(${d}px, ${i + 10}px, 0) scale(0.985)`;
236
+ }
237
+ function s(r) {
238
+ const d = parseInt(r.dataset.left || "0", 10), i = parseInt(r.dataset.top || "0", 10);
239
+ r.style.transition = "none", r.style.opacity = "1", r.style.transform = `translate3d(${d}px, ${i}px, 0) scale(1)`, r.style.removeProperty("--masonry-opacity-delay"), r.offsetWidth, r.style.transition = "";
240
+ }
241
+ function b(r, d) {
242
+ const i = parseInt(r.dataset.left || "0", 10), w = parseInt(r.dataset.top || "0", 10), m = getComputedStyle(r).getPropertyValue("--masonry-leave-duration") || "", p = parseFloat(m), T = Number.isFinite(p) && p > 0 ? p : 200, E = r.style.transitionDuration, $ = () => {
243
+ r.removeEventListener("transitionend", A), clearTimeout(W), r.style.transitionDuration = E || "";
244
+ }, A = (M) => {
245
+ (!M || M.target === r) && ($(), d());
246
+ }, W = setTimeout(() => {
247
+ $(), d();
248
+ }, T + 100);
249
+ requestAnimationFrame(() => {
250
+ r.style.transitionDuration = `${T}ms`, r.style.opacity = "0", r.style.transform = `translate3d(${i}px, ${w + 10}px, 0) scale(0.985)`, r.addEventListener("transitionend", A);
251
+ });
252
+ }
253
+ return {
254
+ onEnter: a,
255
+ onBeforeEnter: o,
256
+ onBeforeLeave: s,
257
+ onLeave: b
258
+ };
259
+ }
260
+ function ee({
261
+ container: t,
262
+ masonry: a,
263
+ columns: o,
264
+ containerHeight: s,
265
+ isLoading: b,
266
+ maxItems: r,
267
+ pageSize: d,
268
+ refreshLayout: i,
269
+ setItemsRaw: w,
270
+ loadNext: h,
271
+ leaveEstimateMs: m
272
+ }) {
273
+ let p = !1;
274
+ async function T() {
275
+ if (!t.value) return;
276
+ const { scrollTop: M, clientHeight: H } = t.value, N = M + H, I = tt(a.value, o.value), c = Math.max(...I) + 300 < N - 1, u = M + H >= s.value - 1;
277
+ if ((c || u) && !b.value && !p)
278
+ try {
279
+ a.value.length > r && await E(I), await h(), await X();
280
+ } catch (f) {
281
+ console.error("Error in scroll handler:", f);
282
+ }
283
+ }
284
+ async function E(M) {
285
+ if (!a.value.length || a.value.length <= d) return;
286
+ const H = a.value.reduce((u, f) => {
287
+ const v = f.page;
288
+ return u[v] || (u[v] = []), u[v].push(f), u;
289
+ }, {}), N = Object.keys(H).sort((u, f) => parseInt(u) - parseInt(f));
290
+ if (N.length === 0) return;
291
+ let I = 0;
292
+ const y = [];
293
+ for (const u of N)
294
+ if (y.push(u), I += H[u].length, I >= d) break;
295
+ const c = a.value.filter((u) => !y.includes(String(u.page)));
296
+ c.length !== a.value.length && (p = !0, w(c), await X(), await A($()), i(c), await X(), await W(), p = !1);
297
+ }
298
+ function $() {
299
+ return (typeof m == "number" && m > 0 ? m : 250) + 50;
300
+ }
301
+ function A(M) {
302
+ return new Promise((H) => setTimeout(H, M));
303
+ }
304
+ async function W() {
305
+ if (!t.value) return;
306
+ const { scrollTop: M, clientHeight: H } = t.value, N = M + H * 0.4, I = tt(a.value, o.value), y = I.indexOf(Math.max(...I)), c = a.value.filter((v, S) => S % o.value === y);
307
+ if (c.length === 0) return;
308
+ let u = c[0];
309
+ for (const v of c)
310
+ v.top <= N && v.top >= u.top && (u = v);
311
+ const f = Math.max(0, u.top - H * 0.4);
312
+ Math.abs(f - M) > 4 && t.value.scrollTo({ top: f, behavior: "auto" });
313
+ }
314
+ return {
315
+ handleScroll: T
316
+ };
317
+ }
318
+ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ dt({
319
+ __name: "Masonry",
320
+ props: {
321
+ getNextPage: {
322
+ type: Function,
323
+ default: () => {
324
+ }
325
+ },
326
+ loadAtPage: {
327
+ type: [Number, String],
328
+ default: null
329
+ },
330
+ items: {
331
+ type: Array,
332
+ default: () => []
333
+ },
334
+ layout: {
335
+ type: Object
336
+ },
337
+ paginationType: {
338
+ type: String,
339
+ default: "page",
340
+ // or 'cursor'
341
+ validator: (t) => ["page", "cursor"].includes(t)
342
+ },
343
+ skipInitialLoad: {
344
+ type: Boolean,
345
+ default: !1
346
+ },
347
+ maxItems: {
348
+ type: Number,
349
+ default: 100
350
+ },
351
+ pageSize: {
352
+ type: Number,
353
+ default: 40
354
+ },
355
+ // Backfill configuration
356
+ backfillEnabled: {
357
+ type: Boolean,
358
+ default: !0
359
+ },
360
+ backfillDelayMs: {
361
+ type: Number,
362
+ default: 2e3
363
+ },
364
+ backfillMaxCalls: {
365
+ type: Number,
366
+ default: 10
367
+ },
368
+ // Retry configuration
369
+ retryMaxAttempts: {
370
+ type: Number,
371
+ default: 3
372
+ },
373
+ retryInitialDelayMs: {
374
+ type: Number,
375
+ default: 2e3
376
+ },
377
+ retryBackoffStepMs: {
378
+ type: Number,
379
+ default: 2e3
380
+ },
381
+ transitionDurationMs: {
382
+ type: Number,
383
+ default: 450
384
+ },
385
+ // Shorter, snappier duration specifically for item removal (leave)
386
+ leaveDurationMs: {
387
+ type: Number,
388
+ default: 160
389
+ },
390
+ transitionEasing: {
391
+ type: String,
392
+ default: "cubic-bezier(.22,.61,.36,1)"
393
+ }
394
+ },
395
+ emits: [
396
+ "update:items",
397
+ "backfill:start",
398
+ "backfill:tick",
399
+ "backfill:stop",
400
+ "retry:start",
401
+ "retry:tick",
402
+ "retry:stop"
403
+ ],
404
+ setup(t, { expose: a, emit: o }) {
405
+ const s = t, b = {
406
+ sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
407
+ gutterX: 10,
408
+ gutterY: 10,
409
+ header: 0,
410
+ footer: 0,
411
+ paddingLeft: 0,
412
+ paddingRight: 0,
413
+ placement: "masonry"
414
+ }, r = et(() => {
415
+ var e;
416
+ return {
417
+ ...b,
418
+ ...s.layout,
419
+ sizes: {
420
+ ...b.sizes,
421
+ ...((e = s.layout) == null ? void 0 : e.sizes) || {}
422
+ }
423
+ };
424
+ }), d = o, i = et({
425
+ get: () => s.items,
426
+ set: (e) => d("update:items", e)
427
+ }), w = B(7), h = B(null), m = B([]);
428
+ B(null);
429
+ const p = B(!1), T = B(0), E = B({
430
+ distanceToTrigger: 0,
431
+ isNearTrigger: !1
432
+ }), $ = () => {
433
+ if (!h.value) return;
434
+ const { scrollTop: e, clientHeight: n } = h.value, l = e + n, g = tt(i.value, w.value), P = Math.max(...g) + 300, k = Math.max(0, P - l), F = k <= 100;
435
+ E.value = {
436
+ distanceToTrigger: Math.round(k),
437
+ isNearTrigger: F
438
+ };
439
+ }, { onEnter: A, onBeforeEnter: W, onBeforeLeave: M, onLeave: H } = te(), { handleScroll: N } = ee({
440
+ container: h,
441
+ masonry: i,
442
+ columns: w,
443
+ containerHeight: T,
444
+ isLoading: p,
445
+ maxItems: s.maxItems,
446
+ pageSize: s.pageSize,
447
+ refreshLayout: y,
448
+ setItemsRaw: (e) => {
449
+ i.value = e;
450
+ },
451
+ loadNext: S,
452
+ leaveEstimateMs: s.leaveDurationMs
453
+ });
454
+ a({
455
+ isLoading: p,
456
+ refreshLayout: y,
457
+ containerHeight: T,
458
+ remove: L,
459
+ removeMany: R,
460
+ loadNext: S,
461
+ loadPage: v,
462
+ reset: D,
463
+ init: U,
464
+ paginationHistory: m
465
+ });
466
+ function I(e) {
467
+ const n = Kt(e);
468
+ let l = 0;
469
+ if (h.value) {
470
+ const { scrollTop: g, clientHeight: x } = h.value;
471
+ l = g + x + 100;
472
+ }
473
+ T.value = Math.max(n, l);
474
+ }
475
+ function y(e) {
476
+ if (!h.value) return;
477
+ const n = St(e, h.value, w.value, r.value);
478
+ I(n), i.value = n;
479
+ }
480
+ function c(e, n) {
481
+ return new Promise((l) => {
482
+ const g = Math.max(0, e | 0), x = Date.now();
483
+ n(g, g);
484
+ const P = setInterval(() => {
485
+ const k = Date.now() - x, F = Math.max(0, g - k);
486
+ n(F, g), F <= 0 && (clearInterval(P), l());
487
+ }, 100);
488
+ });
489
+ }
490
+ async function u(e) {
491
+ try {
492
+ const n = await f(() => s.getNextPage(e));
493
+ return y([...i.value, ...n.items]), n;
494
+ } catch (n) {
495
+ throw console.error("Error in getContent:", n), n;
496
+ }
497
+ }
498
+ async function f(e) {
499
+ let n = 0;
500
+ const l = s.retryMaxAttempts;
501
+ let g = s.retryInitialDelayMs;
502
+ for (; ; )
503
+ try {
504
+ const x = await e();
505
+ return n > 0 && d("retry:stop", { attempt: n, success: !0 }), x;
506
+ } catch (x) {
507
+ if (n++, n > l)
508
+ throw d("retry:stop", { attempt: n - 1, success: !1 }), x;
509
+ d("retry:start", { attempt: n, max: l, totalMs: g }), await c(g, (P, k) => {
510
+ d("retry:tick", { attempt: n, remainingMs: P, totalMs: k });
511
+ }), g += s.retryBackoffStepMs;
512
+ }
513
+ }
514
+ async function v(e) {
515
+ if (!p.value) {
516
+ p.value = !0;
517
+ try {
518
+ const n = i.value.length, l = await u(e);
519
+ return m.value.push(l.nextPage), await z(n), l;
520
+ } catch (n) {
521
+ throw console.error("Error loading page:", n), n;
522
+ } finally {
523
+ p.value = !1;
524
+ }
525
+ }
526
+ }
527
+ async function S() {
528
+ if (!p.value) {
529
+ p.value = !0;
530
+ try {
531
+ const e = i.value.length, n = m.value[m.value.length - 1], l = await u(n);
532
+ return m.value.push(l.nextPage), await z(e), l;
533
+ } catch (e) {
534
+ throw console.error("Error loading next page:", e), e;
535
+ } finally {
536
+ p.value = !1;
537
+ }
538
+ }
539
+ }
540
+ async function L(e) {
541
+ const n = i.value.filter((l) => l.id !== e.id);
542
+ i.value = n, await X(), requestAnimationFrame(() => {
543
+ requestAnimationFrame(() => {
544
+ y(n);
545
+ });
546
+ });
547
+ }
548
+ async function R(e) {
549
+ if (!e || e.length === 0) return;
550
+ const n = new Set(e.map((g) => g.id)), l = i.value.filter((g) => !n.has(g.id));
551
+ i.value = l, await X(), requestAnimationFrame(() => {
552
+ requestAnimationFrame(() => {
553
+ y(l);
554
+ });
555
+ });
556
+ }
557
+ function _() {
558
+ w.value = lt(r.value), y(i.value);
559
+ }
560
+ let O = !1;
561
+ async function z(e) {
562
+ if (!s.backfillEnabled || O) return;
563
+ const n = (e || 0) + (s.pageSize || 0);
564
+ if (!(!s.pageSize || s.pageSize <= 0 || m.value[m.value.length - 1] == null) && !(i.value.length >= n)) {
565
+ O = !0;
566
+ try {
567
+ let g = 0;
568
+ for (d("backfill:start", { target: n, fetched: i.value.length, calls: g }); i.value.length < n && g < s.backfillMaxCalls && m.value[m.value.length - 1] != null; ) {
569
+ await c(s.backfillDelayMs, (P, k) => {
570
+ d("backfill:tick", {
571
+ fetched: i.value.length,
572
+ target: n,
573
+ calls: g,
574
+ remainingMs: P,
575
+ totalMs: k
576
+ });
577
+ });
578
+ const x = m.value[m.value.length - 1];
579
+ try {
580
+ p.value = !0;
581
+ const P = await u(x);
582
+ m.value.push(P.nextPage);
583
+ } finally {
584
+ p.value = !1;
585
+ }
586
+ g++;
587
+ }
588
+ d("backfill:stop", { fetched: i.value.length, calls: g });
589
+ } finally {
590
+ O = !1;
591
+ }
592
+ }
593
+ }
594
+ function D() {
595
+ h.value && h.value.scrollTo({
596
+ top: 0,
597
+ behavior: "smooth"
598
+ }), i.value = [], T.value = 0, m.value = [s.loadAtPage], E.value = {
599
+ distanceToTrigger: 0,
600
+ isNearTrigger: !1
601
+ };
602
+ }
603
+ const j = st(() => {
604
+ N(), $();
605
+ }, 200), q = st(_, 200);
606
+ function U(e, n, l) {
607
+ m.value = [n], m.value.push(l), y([...i.value, ...e]), $();
608
+ }
609
+ return gt(async () => {
610
+ var e;
611
+ try {
612
+ w.value = lt(r.value);
613
+ const n = s.loadAtPage;
614
+ m.value = [n], s.skipInitialLoad || await v(m.value[0]), $();
615
+ } catch (n) {
616
+ console.error("Error during component initialization:", n), p.value = !1;
617
+ }
618
+ (e = h.value) == null || e.addEventListener("scroll", j), window.addEventListener("resize", q);
619
+ }), pt(() => {
620
+ var e;
621
+ (e = h.value) == null || e.removeEventListener("scroll", j), window.removeEventListener("resize", q);
622
+ }), (e, n) => (J(), Y("div", {
623
+ class: "overflow-auto w-full flex-1 masonry-container",
624
+ ref_key: "container",
625
+ ref: h
626
+ }, [
627
+ C("div", {
628
+ class: "relative",
629
+ style: mt({ height: `${T.value}px`, "--masonry-duration": `${t.transitionDurationMs}ms`, "--masonry-leave-duration": `${t.leaveDurationMs}ms`, "--masonry-ease": t.transitionEasing })
630
+ }, [
631
+ ht(vt, {
632
+ name: "masonry",
633
+ css: !1,
634
+ onEnter: V(A),
635
+ onBeforeEnter: V(W),
636
+ onLeave: V(H),
637
+ onBeforeLeave: V(M)
638
+ }, {
639
+ default: bt(() => [
640
+ (J(!0), Y(xt, null, wt(i.value, (l, g) => (J(), Y("div", nt({
641
+ key: `${l.page}-${l.id}`,
642
+ class: "absolute masonry-item",
643
+ ref_for: !0
644
+ }, V(Zt)(l, g)), [
645
+ Tt(e.$slots, "item", nt({ ref_for: !0 }, { item: l, remove: L }), () => [
646
+ C("img", {
647
+ src: l.src,
648
+ class: "w-full"
649
+ }, null, 8, ne),
650
+ C("button", {
651
+ class: "absolute bottom-0 right-0 bg-red-500 text-white p-2 rounded cursor-pointer",
652
+ onClick: (x) => L(l)
653
+ }, n[0] || (n[0] = [
654
+ C("i", { class: "fas fa-trash" }, null, -1)
655
+ ]), 8, ae)
656
+ ], !0)
657
+ ], 16))), 128))
658
+ ]),
659
+ _: 3
660
+ }, 8, ["onEnter", "onBeforeEnter", "onLeave", "onBeforeLeave"]),
661
+ T.value > 0 ? (J(), Y("div", {
662
+ key: 0,
663
+ class: Mt(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !E.value.isNearTrigger, "opacity-100": E.value.isNearTrigger }])
664
+ }, [
665
+ C("span", null, at(i.value.length) + " items", 1),
666
+ n[1] || (n[1] = C("span", { class: "mx-2" }, "|", -1)),
667
+ C("span", null, at(E.value.distanceToTrigger) + "px to load", 1)
668
+ ], 2)) : yt("", !0)
669
+ ], 4)
670
+ ], 512));
671
+ }
672
+ }), oe = (t, a) => {
673
+ const o = t.__vccOpts || t;
674
+ for (const [s, b] of a)
675
+ o[s] = b;
676
+ return o;
677
+ }, ct = /* @__PURE__ */ oe(re, [["__scopeId", "data-v-dc6ab8b8"]]), se = {
678
+ install(t) {
679
+ t.component("WyxosMasonry", ct), t.component("WMasonry", ct);
680
+ }
681
+ };
682
+ export {
683
+ ct as Masonry,
684
+ se as default
685
+ };
package/lib/vibe.css ADDED
@@ -0,0 +1 @@
1
+ .masonry-container[data-v-dc6ab8b8]{overflow-anchor:none}.masonry-item[data-v-dc6ab8b8]{will-change:transform,opacity;contain:layout paint;transition:transform var(--masonry-duration, .45s) var(--masonry-ease, cubic-bezier(.22, .61, .36, 1)),opacity var(--masonry-leave-duration, .16s) ease-out var(--masonry-opacity-delay, 0ms);backface-visibility:hidden}.masonry-move[data-v-dc6ab8b8]{transition:transform var(--masonry-duration, .45s) var(--masonry-ease, cubic-bezier(.22, .61, .36, 1))}@media (prefers-reduced-motion: reduce){.masonry-item[data-v-dc6ab8b8],.masonry-move[data-v-dc6ab8b8]{transition-duration:1ms!important}}
package/lib/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>