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.19 to 0.2.20-stillness.0

dist/utils/BatchinateLast.d.ts

1

dist/common.d.ts

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

export declare const ON_END_REACHED_HANDLER_TIMEOUT_THRESHOLD = 1000;
export declare const DISPATCH_METRICS_THRESHOLD = 50;
export declare const ON_END_REACHED_THRESHOLD = 2;

@@ -12,0 +13,0 @@ export declare const WINDOW_SIZE = 5;

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

private _offsetTriggerCachedState;
private _stillnessHelper;
private memoizedResolveSpaceState;

@@ -133,4 +134,6 @@ private memoizedResolveRecycleState;

dispatchScrollMetricsEnabled(): boolean;
stillnessHandler(): void;
isStill(): void;
updateScrollMetrics(scrollMetrics?: ScrollMetrics, useCache?: boolean): void;
}
export default ListDimensions;

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

recycleEnabled?: boolean;
stillnessThreshold?: number;
dispatchMetricsThreshold?: number;
} & BaseDimensionsProps & OnEndReachedHelperProps;

@@ -179,2 +181,3 @@ export declare type ItemsDimensionsProps = BaseDimensionsProps;

targetKey: string;
targetIndex: number;
offset: number;

@@ -181,0 +184,0 @@ } & SpaceStateToken<ItemT>;

2

package.json
{
"name": "@infinite-list/data-model",
"version": "0.2.19",
"version": "0.2.20-stillness.0",
"files": [

@@ -5,0 +5,0 @@ "dist",

@@ -12,2 +12,4 @@ export const DEFAULT_LAYOUT = {

export const DISPATCH_METRICS_THRESHOLD = 50;
// 建议 ON_END_REACHED_THRESHOLD * VisibleLength > MAX_TO_RENDER_PER_BATCH * itemLength

@@ -14,0 +16,0 @@ // 这样可以在滚动停止的时候,自动获取一屏幕

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

buildStateTokenIndexKey,
DISPATCH_METRICS_THRESHOLD,
} from './common';

@@ -50,2 +51,3 @@ import resolveChanged from '@x-oasis/resolve-changed';

import shallowArrayEqual from '@x-oasis/shallow-array-equal';
import StillnessHelper from './utils/StillnessHelper';

@@ -104,2 +106,4 @@ class ListDimensions<ItemT extends {} = {}> extends BaseDimensions {

private _stillnessHelper: StillnessHelper;
private memoizedResolveSpaceState: (

@@ -131,4 +135,6 @@ state: ListState<ItemT>

persistanceIndices,
stillnessThreshold,
onEndReachedTimeoutThreshold,
onEndReachedHandlerTimeoutThreshold,
dispatchMetricsThreshold = DISPATCH_METRICS_THRESHOLD,
} = props;

@@ -143,3 +149,3 @@ this._keyExtractor = keyExtractor;

this.dispatchMetrics.bind(this),
50
dispatchMetricsThreshold
);

@@ -154,2 +160,8 @@ this.onEndReachedHelper = new OnEndReachedHelper({

this.stillnessHandler = this.stillnessHandler.bind(this);
this._stillnessHelper = new StillnessHelper({
stillnessThreshold,
handler: this.stillnessHandler,
});
this._deps = deps;

@@ -977,3 +989,4 @@ this._isActive = this.resolveInitialActiveValue(active);

const targetIndices = this._bufferSet.indices.map((i) => parseInt(i));
const _targetIndices = this._bufferSet.indices.map((i) => parseInt(i));
const targetIndices = new Array(_targetIndices.length).fill(null);

@@ -993,4 +1006,4 @@ // const scrolling = actionType === 'scrollDown' || actionType === 'scrollUp';

index,
visibleStartIndex,
visibleEndIndex
visibleStartIndex - 2,
visibleEndIndex + 2
);

@@ -1005,2 +1018,4 @@ if (position !== null) targetIndices[position] = index;

let _beforeCount = 0;
for (

@@ -1011,11 +1026,24 @@ let index = visibleStartIndex, size = beforeSize;

) {
const position = this.getPosition(
index,
bufferedStartIndex,
visibleStartIndex
);
const item = data[index];
if (!item) continue;
const itemMeta = this.getItemMeta(item, index);
const itemLayout = itemMeta?.getLayout();
if (position !== null) targetIndices[position] = index;
if (_beforeCount < 2 || !itemLayout) {
const position = this.getPosition(
index,
visibleStartIndex - 2,
visibleEndIndex + 2
);
if (position !== null) targetIndices[position] = index;
}
if (index >= this.initialNumToRender) {
_beforeCount++;
}
}
let _afterCount = 0;
for (

@@ -1026,8 +1054,19 @@ let index = visibleEndIndex + 1, size = afterSize;

) {
const position = this.getPosition(
index,
visibleEndIndex + 1,
bufferedEndIndex
);
if (position !== null) targetIndices[position] = index;
const item = data[index];
if (!item) continue;
const itemMeta = this.getItemMeta(item, index);
const itemLayout = itemMeta?.getLayout();
if (_afterCount < 2 || !itemLayout) {
const position = this.getPosition(
index,
visibleStartIndex - 2,
visibleEndIndex + 2
);
if (position !== null) targetIndices[position] = index;
}
if (index >= this.initialNumToRender) {
_afterCount++;
}
}

@@ -1043,3 +1082,36 @@

let negativeStartIndex = visibleStartIndex - 3;
let positiveStartIndex = visibleEndIndex + 3;
targetIndices.forEach((targetIndex, index) => {
const prevStateResult = this._stateResult as RecycleStateResult<ItemT>;
// targetIndex is null or undefined
if (targetIndex == null) {
if (prevStateResult?.recycleState) {
const _result = prevStateResult.recycleState[index];
if (_result) {
const { item, targetKey } = _result;
// maybe item has been deleted
if (item === this._data[this.getKeyIndex(targetKey)]) {
const { targetIndex, offset: _offset } = _result;
if (targetIndex < visibleStartIndex) {
const offset = indexToOffsetMap[negativeStartIndex--];
if (typeof offset === 'number')
recycleStateResult.push({
..._result,
offset: offset || _offset,
});
} else if (targetIndex > visibleStartIndex) {
const offset = indexToOffsetMap[positiveStartIndex++];
if (typeof offset === 'number')
recycleStateResult.push({
..._result,
offset: offset || _offset,
});
}
}
}
}
return;
}
const item = data[targetIndex];

@@ -1072,2 +1144,3 @@ if (!item) return;

targetKey: itemKey,
targetIndex,
length: itemLength,

@@ -1088,4 +1161,4 @@ isSpace: false,

const stateResult = {
recycleState: recycleStateResult,
spaceState: spaceStateResult,
recycleState: recycleStateResult.filter((v) => v),
spaceState: spaceStateResult.filter((v) => v),
};

@@ -1358,2 +1431,10 @@

stillnessHandler() {
this.dispatchMetrics(this._scrollMetrics);
}
isStill() {
this._stillnessHelper.isStill;
}
/**

@@ -1382,2 +1463,6 @@ * When to trigger updateScrollMetrics..

if (this._scrollMetrics?.offset !== scrollMetrics?.offset) {
// this._stillnessHelper.startClockBatchinateLast.schedule();
}
if (

@@ -1384,0 +1469,0 @@ !this._scrollMetrics ||

@@ -81,2 +81,6 @@ import BaseDimensions from '../BaseDimensions';

recycleEnabled?: boolean;
stillnessThreshold?: number;
dispatchMetricsThreshold?: number;
} & BaseDimensionsProps &

@@ -230,2 +234,3 @@ OnEndReachedHelperProps;

targetKey: string;
targetIndex: number;
offset: number;

@@ -232,0 +237,0 @@ } & SpaceStateToken<ItemT>;

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

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