New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@infinite-list/data-model

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infinite-list/data-model - npm Package Compare versions

Comparing version 0.2.34 to 0.2.35

9

dist/BaseLayout.d.ts

@@ -18,2 +18,3 @@ import SelectValue from '@x-oasis/select-value';

readonly _fillingMode: FillingMode;
readonly _lengthPrecision: number;
private _recycleBufferedCount;

@@ -35,2 +36,3 @@ private _canIUseRIC;

canIUseRIC?: boolean;
lengthPrecision?: number;
});

@@ -65,3 +67,10 @@ get initialNumToRender(): number;

getSelectValue(): SelectValue;
normalizeLengthNumber(length: number): number;
normalizeLengthInfo(info: ItemLayout): {
x: number;
y: number;
width: number;
height: number;
};
}
export default BaseLayout;

1

dist/common.d.ts

@@ -12,2 +12,3 @@ export declare const DEFAULT_LAYOUT: {

export declare const RECYCLE_BUFFERED_COUNT = 4;
export declare const LENGTH_PRECISION = 4;
export declare const ON_END_REACHED_THRESHOLD = 2;

@@ -14,0 +15,0 @@ export declare const WINDOW_SIZE = 5;

@@ -21,2 +21,3 @@ import BaseDimensions from '../BaseDimensions';

canIUseRIC?: boolean;
lengthPrecision?: number;
onUpdateItemLayout?: Function;

@@ -23,0 +24,0 @@ onUpdateIntervalTree?: Function;

6

package.json
{
"name": "@infinite-list/data-model",
"version": "0.2.34",
"version": "0.2.35",
"files": [

@@ -23,5 +23,5 @@ "dist",

"@x-oasis/default-boolean-value": "^0.1.10",
"@x-oasis/integer-buffer-set": "0.1.10",
"@x-oasis/integer-buffer-set": "0.1.13",
"@x-oasis/is-clamped": "0.1.10",
"@x-oasis/layout-equal": "0.1.10",
"@x-oasis/layout-equal": "0.1.13",
"@x-oasis/noop": "0.1.10",

@@ -28,0 +28,0 @@ "@x-oasis/omit": "0.1.10",

@@ -8,2 +8,3 @@ import {

RECYCLE_BUFFERED_COUNT,
LENGTH_PRECISION,
} from './common';

@@ -32,2 +33,3 @@ import SelectValue, {

readonly _fillingMode: FillingMode;
readonly _lengthPrecision: number;
private _recycleBufferedCount: number;

@@ -52,2 +54,4 @@ private _canIUseRIC: boolean;

canIUseRIC?: boolean;
lengthPrecision?: number;
}) {

@@ -64,2 +68,3 @@ const {

windowSize = WINDOW_SIZE,
lengthPrecision = LENGTH_PRECISION,
recycleBufferedCount = RECYCLE_BUFFERED_COUNT,

@@ -84,3 +89,5 @@ maxToRenderPerBatch = MAX_TO_RENDER_PER_BATCH,

: 0;
this._recycleBufferedCount = recycleBufferedCount;
// recycleBufferedCount should greater than 0.
this._recycleBufferedCount = Math.max(recycleBufferedCount, 1);
this._stickyHeaderIndices = stickyHeaderIndices;

@@ -90,6 +97,6 @@ this._maxToRenderPerBatch = maxToRenderPerBatch;

this._onEndReachedThreshold = onEndReachedThreshold;
this._recycleBufferedCount = recycleBufferedCount;
this.persistanceIndices = persistanceIndices;
this.stickyHeaderIndices = stickyHeaderIndices;
this._canIUseRIC = canIUseRIC;
this._lengthPrecision = lengthPrecision;
}

@@ -237,4 +244,17 @@

}
normalizeLengthNumber(length: number) {
return +length.toPrecision(this._lengthPrecision);
}
normalizeLengthInfo(info: ItemLayout) {
const { width, height, ...rest } = info;
return {
width: this.normalizeLengthNumber(width),
height: this.normalizeLengthNumber(height),
...rest,
};
}
}
export default BaseLayout;

@@ -13,2 +13,3 @@ export const DEFAULT_LAYOUT = {

export const RECYCLE_BUFFERED_COUNT = 4;
export const LENGTH_PRECISION = 4;

@@ -15,0 +16,0 @@ // 建议 ON_END_REACHED_THRESHOLD * VisibleLength > MAX_TO_RENDER_PER_BATCH * itemLength

@@ -40,3 +40,3 @@ import Batchinator from '@x-oasis/batchinator';

if (typeof info === 'number') {
const length = info;
const length = this.normalizeLengthNumber(info);
if (this._selectValue.selectLength(meta.getLayout()) !== length) {

@@ -47,6 +47,9 @@ this._selectValue.setLength(meta.getLayout(), length);

}
return false;
}
if (!layoutEqual(meta.getLayout(), info as ItemLayout)) {
meta.setLayout(info as ItemLayout);
const _info = this.normalizeLengthInfo(info);
if (!layoutEqual(meta.getLayout(), _info as ItemLayout)) {
meta.setLayout(_info as ItemLayout);
this._sortedItems.add(meta);

@@ -53,0 +56,0 @@ return true;

@@ -859,3 +859,3 @@ import noop from '@x-oasis/noop';

if (typeof info === 'number') {
let length = info;
let length = this.normalizeLengthNumber(info);
if (this._selectValue.selectLength(meta.getLayout() || {}) !== length) {

@@ -872,10 +872,27 @@ this._selectValue.setLength(meta.ensureLayout(), length);

}
return false;
}
const _info = this.normalizeLengthInfo(info);
if (!layoutEqual(meta.getLayout(), info as ItemLayout)) {
if (
!layoutEqual(
meta.getLayout(),
_info as ItemLayout,
this.horizontal ? ['width'] : ['height']
)
) {
// if (meta.getLayout()) {
// console.warn(
// '[infinite-list/data-model] override existing key item ',
// `${key} from value ${JSON.stringify(
// meta.getLayout()
// )}to ${JSON.stringify(_info)}`
// );
// }
const currentLength = this._selectValue.selectLength(
meta.getLayout() || {}
);
let length = this._selectValue.selectLength((info as ItemLayout) || {});
meta.setLayout(info as ItemLayout);
let length = this._selectValue.selectLength((_info as ItemLayout) || {});
meta.setLayout(_info as ItemLayout);
// 只有关心的值发生变化时,才会再次触发setIntervalTreeValue

@@ -1070,3 +1087,9 @@ if (currentLength !== length && _update) {

endIndex,
rowIndex
rowIndex,
(options) => {
const { bufferSetRange, currentIndex } = options;
const { maxValue } = bufferSetRange;
if (currentIndex > maxValue) return true;
return false;
}
);

@@ -1145,4 +1168,9 @@ }

resolveRecycleRecycleState(state: ListState<ItemT>) {
const { visibleEndIndex, visibleStartIndex: _visibleStartIndex } = state;
const {
visibleEndIndex,
visibleStartIndex: _visibleStartIndex,
isEndReached,
} = state;
const targetIndices = this._bufferSet.indices.map((i) => parseInt(i));
const targetIndicesCopy = targetIndices.slice();
const recycleStateResult = [];

@@ -1173,27 +1201,31 @@ const velocity = this._scrollMetrics?.velocity || 0;

const remainingPosition = Math.max(
this.recycleThreshold - (safeRange.endIndex - safeRange.startIndex + 1),
0
);
const remainingCount = Math.min(
this.recycleBufferedCount * 2,
remainingPosition
);
// const remainingPosition = Math.max(
// this.recycleThreshold - (safeRange.endIndex - safeRange.startIndex + 1),
// 0
// );
// const remainingCount = Math.min(
// this.recycleBufferedCount * 2,
// remainingPosition
// );
if (velocity > 0) {
this.updateIndices(targetIndices, {
safeRange,
startIndex: visibleEndIndex + 1,
maxCount: remainingCount,
step: 1,
});
if (isEndReached || Math.abs(velocity) < 0.5) {
this.updateIndices(targetIndices, {
safeRange,
startIndex: visibleEndIndex + 1,
maxCount: this.recycleBufferedCount,
step: 1,
});
}
} else if (velocity < 0) {
this.updateIndices(targetIndices, {
safeRange,
startIndex: visibleStartIndex - 1,
maxCount: remainingCount,
step: -1,
});
if (Math.abs(velocity) < 0.5) {
this.updateIndices(targetIndices, {
safeRange,
startIndex: visibleStartIndex - 1,
maxCount: this.recycleBufferedCount,
step: -1,
});
}
} else {
const part = Math.floor(remainingCount / 2);
const part = Math.floor(this.recycleBufferedCount / 2);
this.updateIndices(targetIndices, {

@@ -1208,3 +1240,3 @@ safeRange,

startIndex: visibleEndIndex + 1,
maxCount: remainingCount - part,
maxCount: this.recycleBufferedCount - part,
step: 1,

@@ -1214,2 +1246,22 @@ });

// let changed = '';
// for (let index = 0; index < targetIndices.length; index++) {
// const next = targetIndices[index];
// const current = targetIndicesCopy[index];
// if (current && next !== current) {
// changed += `${index} occurs update, ${current} -> ${next}\n`;
// }
// }
// if (changed)
// console.warn(
// '[infinite-list] replace info ',
// `visibleStartIndex : ${visibleStartIndex}, visibleEndIndex: ${visibleEndIndex} \n`,
// changed,
// `velocity: ${velocity}\n`,
// `prev: ${JSON.stringify(targetIndicesCopy)}\n`,
// `next: ${JSON.stringify(targetIndices)}\n`
// );
const minValue = this._bufferSet.getMinValue();

@@ -1216,0 +1268,0 @@ const maxValue = this._bufferSet.getMaxValue();

@@ -143,3 +143,3 @@ import BaseDimensions from './BaseDimensions';

if (typeof info === 'number') {
const length = info;
const length = this.normalizeLengthNumber(info);
if (meta && this._selectValue.selectLength(meta.getLayout()) !== length) {

@@ -152,10 +152,15 @@ this._selectValue.setLength(meta.getLayout(), length);

}
return false;
}
if (!layoutEqual(meta.getLayout(), info as ItemLayout)) {
const _info = this.normalizeLengthInfo(info);
if (!layoutEqual(meta.getLayout(), _info as ItemLayout)) {
const currentLength = this._selectValue.selectLength(
meta.getLayout() || {}
);
const length = this._selectValue.selectLength((info as ItemLayout) || {});
meta.setLayout(info as ItemLayout);
const length = this._selectValue.selectLength(
(_info as ItemLayout) || {}
);
meta.setLayout(_info as ItemLayout);

@@ -162,0 +167,0 @@ if (currentLength !== length && _update) {

@@ -30,2 +30,4 @@ import BaseDimensions from '../BaseDimensions';

lengthPrecision?: number;
onUpdateItemLayout?: Function;

@@ -32,0 +34,0 @@ onUpdateIntervalTree?: Function;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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