Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@af-utils/virtual-core

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@af-utils/virtual-core - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

lib/index.server.js.map

8

lib/bundlesize.index.d.ts

@@ -1,4 +0,4 @@

export declare const raw = 7482;
export declare const min = 4803;
export declare const minGz = 2105;
export declare const minBrotli = 1928;
export declare const raw = 7548;
export declare const min = 4765;
export declare const minGz = 2089;
export declare const minBrotli = 1907;

@@ -1,4 +0,4 @@

export const raw = 7482;
export const min = 4803;
export const minGz = 2105;
export const minBrotli = 1928;
export const raw = 7548;
export const min = 4765;
export const minGz = 2089;
export const minBrotli = 1907;

@@ -35,3 +35,3 @@ const t = {

box: "border-box"
}, d = 2147483647, S = new i(0), v = [ "offsetHeight", "offsetWidth", "innerHeight", "innerWidth" ], E = [ "scrollTop", "scrollLeft", "scrollY", "scrollX" ], z = [ "blockSize", "inlineSize" ], T = [ "top", "left" ], b = (t, s) => Math.round(t[0][s]);
}, d = 2147483647, S = new i(0), v = [ "offsetHeight", "offsetWidth", "innerHeight", "innerWidth" ], E = [ "scrollTop", "scrollLeft", "scrollY", "scrollX" ], z = [ "blockSize", "inlineSize" ], T = [ "top", "left" ], b = (t, s) => Math.round(t.borderBoxSize[0][s]);

@@ -72,3 +72,3 @@ class p {

if (-1 !== t) {
const e = b(i.borderBoxSize, this.u) - this.Z[t];
const e = b(i, this.u) - this.Z[t];
this.Z[t] += e, s += e;

@@ -81,7 +81,7 @@ }

let s = 0, i = !1;
const e = c(this.K, this.from + 1, this.to);
const e = /*#__NOINLINE__*/ c(this.K, this.from + 1, this.to);
for (const h of t) {
const t = this.W.get(h.target);
if (e > t) {
const r = b(h.borderBoxSize, this.u) - this.F[t];
const r = b(h, this.u) - this.F[t];
r && (i = !0, this.F[t] += r, s += r, l(this.K, t + 1, r, e));

@@ -99,4 +99,3 @@ }

B=() => {
const t = (s = this.C, i = this.l, e = this.O, s[i] - e);
var s, i, e;
const t = this.C[this.l] - this.O;
t !== this.R && (this.R = t, this.updateScrollerOffset(), this.Y());

@@ -149,3 +148,3 @@ };

t !== this.C && (clearInterval(this.v), clearTimeout(this.T), this.D(), this.C?.removeEventListener("scroll", this.st),
this.C = t, t && (this.j(), this.D = r(t, this.B), t.addEventListener("scroll", this.st, {
this.C = t, t && (this.j(), this.D = /*#__NOINLINE__*/ r(t, this.B), t.addEventListener("scroll", this.st, {
passive: !0

@@ -160,3 +159,4 @@ }), this.updateScrollerOffset(), this.V()));

if (this.C) {
const t = f(this.C, this.H, this._, this.m), s = t - this.M;
const t =
/*#__NOINLINE__*/ f(this.C, this.H, this._, this.m), s = t - this.M;
s && (this.M = t, this.p -= s, this.V());

@@ -218,3 +218,4 @@ }

const s = Math.min(t + 32, d);
this.F = o(this.F, s, this.L || 40), this.K = new i(s + 1), n(this.K, this.F);
this.F = /*#__NOINLINE__*/ o(this.F, s, this.L || 40), this.K = new i(s + 1),
/*#__NOINLINE__*/ n(this.K, this.F);
}

@@ -221,0 +222,0 @@ this.scrollSize = this.getOffset(t), this.X(1), this.to > t && (this.to = -1), this.Y(),

@@ -1,230 +0,4 @@

const t = {
RANGE: 0,
SCROLL_SIZE: 1,
SIZES: 2
}, s = [ 0, 1, 2 ], i = Uint32Array, e = t => t(), h = (t, s) => {
if (!t) throw Error(s);
}, r = (t, s) => {
if (t instanceof HTMLElement) {
const i = new ResizeObserver(s);
return i.observe(t), () => i.disconnect();
}
return s(), addEventListener("resize", s), () => removeEventListener("resize", s);
}, o = (t, s, e) => {
const h = new i(s);
return h.set(t), h.fill(e, t.length), h;
}, n = (t, s) => {
t.set(s, 1);
for (let s, i = 1, e = t.length; e > i; i++) s = i + (i & -i), e > s && (t[s] += t[i]);
}, l = (t, s, i, e) => {
for (;e > s; s += s & -s) t[s] += i;
}, c = (t, s, i) => {
for (;i > s; s += s & -s) ;
return Math.min(s, t.length);
}, a = (t, s) => t.getBoundingClientRect()[s], f = (t, s, i, e) => s && t && t !== s ? t[i] + Math.round(a(s, e) - (t instanceof HTMLElement ? a(t, e) : 0)) : 0, _ = new Set, u = {
t: 0,
i() {
this.t++;
},
h() {
0 == --this.t && (_.forEach(e), _.clear());
},
o: t => _.add(t)
}, m = {
box: "border-box"
}, d = 2147483647, v = new i(0), S = [ "offsetHeight", "offsetWidth", "innerHeight", "innerWidth" ], E = [ "scrollTop", "scrollLeft", "scrollY", "scrollX" ], z = [ "blockSize", "inlineSize" ], b = [ "top", "left" ], T = (t, s) => Math.round(t[0][s]);
import "./resize-observer-node.js";
class p {
l=S[0];
_=E[0];
u=z[0];
m=b[0];
v=0;
S=0;
T=0;
p=0;
M=0;
O=0;
I=0;
R=0;
k=6;
L=40;
C=null;
H=null;
F=v;
K=v;
P=0;
horizontal=!1;
scrollSize=0;
from=0;
to=0;
sizesHash=0;
W=new Map;
A=new Map;
G=[ null, null ];
Z=[ 0, 0 ];
q=new ResizeObserver((t => {
let s = 0;
for (const i of t) {
const t = this.G.indexOf(i.target);
if (-1 !== t) {
const e = T(i.borderBoxSize, this.u) - this.Z[t];
this.Z[t] += e, s += e;
}
}
this.N(s);
}));
U=new ResizeObserver((t => {
let s = 0, i = !1;
const e = c(this.K, this.from + 1, this.to);
for (const h of t) {
const t = this.W.get(h.target);
if (e > t) {
const r = T(h.borderBoxSize, this.u) - this.F[t];
r && (i = !0, this.F[t] += r, s += r, l(this.K, t + 1, r, e));
}
}
i && (u.i(), 0 !== s && (l(this.K, e, s, this.K.length), this.scrollSize += s, this.X(1),
0 > s && this.Y()), this.sizesHash = this.sizesHash + 1 & d, this.X(2), u.h());
}));
$=s.map((() => []));
j() {
const t = this.horizontal ? 1 : 0, s = t + 2 * (this.C instanceof HTMLElement ? 0 : 1);
this.l = S[s], this._ = E[s], this.u = z[t], this.m = b[t];
}
B=() => {
const t = (s = this.C, i = this.l, e = this.O, s[i] - e);
var s, i, e;
t !== this.R && (this.R = t, this.updateScrollerOffset(), this.Y());
};
N(t) {
t && (this.O += t, this.R -= t, this.Y());
}
D=() => {};
constructor(t) {
t && (this.horizontal = !!t.horizontal, this.M = t.estimatedScrollElementOffset || 0,
this.R = t.estimatedWidgetSize ?? 200, this.set(t));
}
on(t, s) {
return s.forEach((s => this.$[s].push(t))), () => s.forEach((s => this.$[s].splice(this.$[s].indexOf(t) >>> 0, 1)));
}
X(t) {
this.$[t].forEach(0 === u.t ? e : u.o);
}
getIndex(t) {
if (0 >= t) return 0;
if (t >= this.scrollSize) return this.I - 1;
let s = 0;
for (let i = this.P, e = 0; i > 0; i >>= 1) e = s + i, e <= this.I && t > this.K[e] && (s = e,
t -= this.K[e]);
return s;
}
getOffset(t) {
"production" !== process.env.NODE_ENV && h(t <= this.I, "index must not be > itemCount");
let s = 0;
for (;t > 0; t -= t & -t) s += this.K[t];
return s;
}
getSize(t) {
return "production" !== process.env.NODE_ENV && h(t < this.F.length, "itemIndex must be < itemCount in getSize"),
this.F[t];
}
get visibleFrom() {
const t = this.J;
return t + (this.p - this.getOffset(t)) / this.F[t];
}
V() {
const t = this.p, s = Math.round(this.C[this._]) - this.M;
s !== t && (this.p = s, s > t ? this.Y() : this.tt());
}
st=t => {
this.v = t.timeStamp, this.V();
};
setScroller(t) {
t !== this.C && (clearInterval(this.S), clearTimeout(this.T), this.D(), this.C?.removeEventListener("scroll", this.st),
this.C = t, t && (this.j(), this.D = r(t, this.B), t.addEventListener("scroll", this.st, {
passive: !0
}), this.updateScrollerOffset(), this.V()));
}
setContainer(t) {
t !== this.H && (this.H = t, this.updateScrollerOffset());
}
updateScrollerOffset() {
clearTimeout(this.T), this.T = setTimeout((() => {
if (this.C) {
const t = f(this.C, this.H, this._, this.m), s = t - this.M;
s && (this.M = t, this.p -= s, this.V());
}
}), 256);
}
el(t, s) {
const i = this.A.get(t);
i && (this.A.delete(t), this.W.delete(i), this.U.unobserve(i)), s && (this.W.set(s, t),
this.A.set(t, s), this.U.observe(s, m));
}
it(t, s) {
const i = this.G[t];
i && (this.q.unobserve(i), this.N(-this.Z[t]), this.G[t] = null, this.Z[t] = 0),
s && (this.G[t] = s, this.q.observe(s, m));
}
setStickyHeader(t) {
this.it(0, t);
}
setStickyFooter(t) {
this.it(1, t);
}
get J() {
return this.getIndex(this.p);
}
get et() {
return this.I && 1 + this.getIndex(this.p + this.R);
}
Y() {
const {et: t} = this;
t > this.to && (this.to = Math.min(this.I, t + this.k), this.from = this.J, this.X(0));
}
tt() {
const {J: t} = this;
t < this.from && (this.from = Math.max(0, t - this.k), this.to = this.et, this.X(0));
}
scrollToOffset(t, s) {
this.C?.scroll({
[this.m]: this.M + t,
behavior: s ? "smooth" : "instant"
});
}
scrollToIndex(t, s) {
clearInterval(this.S);
let i = 5;
this.S = setInterval((() => {
if (!s || performance.now() - this.v > 128) {
--i || clearInterval(this.S);
const e = Math.trunc(t), h = Math.min(this.scrollSize - this.R, this.getOffset(e) + Math.round(this.F[e] * (t - e)));
this.scrollToOffset(h, s);
}
}), s ? 50 : 16);
}
setItemCount(t) {
if (this.I !== t) {
if (u.i(), h(d >= t, `itemCount must be <= 2147483647. Got: ${t}.`), this.I = t,
this.P = t && 1 << 31 - Math.clz32(t), t > this.F.length) {
const s = Math.min(t + 32, d);
this.F = o(this.F, s, this.L || 40), this.K = new i(s + 1), n(this.K, this.F);
}
this.scrollSize = this.getOffset(t), this.X(1), this.to > t && (this.to = -1), this.Y(),
u.h();
}
}
set(t) {
t.estimatedItemSize && (this.L = t.estimatedItemSize), void 0 !== t.overscanCount && (this.k = t.overscanCount),
void 0 !== t.itemCount && this.setItemCount(t.itemCount);
}
}
global.ResizeObserver ||= class {
observe() {}
unobserve() {}
disconnect() {}
};
export { p as VirtualScroller, t as VirtualScrollerEvent };
export { VirtualScroller, VirtualScrollerEvent } from "./index.js";
//# sourceMappingURL=index.server.js.map
{
"name": "@af-utils/virtual-core",
"private": false,
"version": "0.0.16",
"version": "0.0.17",
"description": "Model for rendering large scrollable data",

@@ -35,3 +35,2 @@ "repository": "https://github.com/nowaalex/af-utils.git",

"devDependencies": {
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",

@@ -38,0 +37,0 @@ "@rollup/plugin-typescript": "^11.1.5",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc