@onekeyfe/react-native-native-list 6.7.0-7 → 6.7.0-9

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.
@@ -11,7 +11,7 @@ import { measureRailWidth } from "./templates/RailRowRenderer.js";
11
11
  import { rowRenderer, rowRendererKey, recycleRowBody } from "./templates/RowRendererRegistry.js";
12
12
  import { checkboxStateForKeys, checkboxStateForSection, isRowPressEnabled, isSelectableRow, reduceSelection, selectionStateFromSnapshot } from "../selection.js";
13
13
  import { calculateAlignedScrollOffset, resolveLocationIndex, scrollFailure, validateOffset } from "../scrolling.js";
14
- import { applyRowPatches, validateSnapshot } from "../validation.js";
14
+ import { applyRowPatches, containNativeListInput, emptyNativeListSnapshot, validatePatches, validateSnapshot } from "../validation.js";
15
15
  import { avatarPrefetchWindow } from "../avatarPrefetch.js";
16
16
  import { acquireNativeListAvatar, canonicalNativeListAvatarUri } from "./NativeListWebAvatarCache.js";
17
17
  const SECTION_INDEX_CONTENT_INSET = 16;
@@ -1327,7 +1327,7 @@ export class NativeListWebEngine {
1327
1327
  this.contentBounds = scrollOptions.contentBounds;
1328
1328
  this.externalStickyInset = this.validateStickyInset(scrollOptions.stickyInset);
1329
1329
  this.document = host.ownerDocument;
1330
- this.snapshot = validateSnapshot(snapshot);
1330
+ this.snapshot = containNativeListInput(() => validateSnapshot(snapshot)) ?? emptyNativeListSnapshot();
1331
1331
  this.callbacks = callbacks;
1332
1332
  this.virtualizationEnabled = virtualizationEnabled;
1333
1333
  this.sectionIndexContainer = sectionIndexContainer ?? undefined;
@@ -1516,8 +1516,12 @@ export class NativeListWebEngine {
1516
1516
  this.renderWindow();
1517
1517
  }
1518
1518
  applySnapshot(snapshot) {
1519
- const validated = validateSnapshot(snapshot);
1520
- if (this.externalScrollHost && validated.layout.orientation === 'horizontal') throw new Error('External scrolling supports vertical lists only');
1519
+ const validated = containNativeListInput(() => {
1520
+ const next = validateSnapshot(snapshot);
1521
+ if (this.externalScrollHost && next.layout.orientation === 'horizontal') throw new Error('External scrolling supports vertical lists only');
1522
+ return next;
1523
+ });
1524
+ if (!validated) return;
1521
1525
  this.invalidateActionAnchor('snapshot');
1522
1526
  this.setSnapshot(validated);
1523
1527
  }
@@ -1528,8 +1532,16 @@ export class NativeListWebEngine {
1528
1532
  return this.snapshot;
1529
1533
  }
1530
1534
  applyPatches(patches) {
1531
- if (patches.length === 0) return;
1532
- const next = applyRowPatches(this.snapshot, patches);
1535
+ const accepted = containNativeListInput(() => {
1536
+ const normalized = validatePatches(patches);
1537
+ return {
1538
+ patches: normalized,
1539
+ snapshot: applyRowPatches(this.snapshot, normalized)
1540
+ };
1541
+ });
1542
+ if (!accepted || accepted.patches.length === 0) return;
1543
+ patches = accepted.patches;
1544
+ const next = accepted.snapshot;
1533
1545
  const selection = new Set(this.selectedKeys);
1534
1546
  patches.forEach(patch => {
1535
1547
  const selected = 'selected' in patch.changes ? patch.changes.selected : undefined;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import type { ImageSource } from './models';
2
+ import type { ImageSource, NativeListSnapshot } from './models';
3
3
  import type { NativeListProps } from './NativeList.types';
4
4
  export type { NativeListProps, NativeListRef } from './NativeList.types';
5
5
  export type { ActionAnchorState, NativeListKeyboardDismissMode, NativeListKeyboardShouldPersistTaps, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, } from './NativeList.types';
6
6
  export declare function preloadNativeListAvatarImages(sources: readonly ImageSource[]): Promise<boolean>;
7
7
  export declare const NativeList: React.ForwardRefExoticComponent<NativeListProps & React.RefAttributes<Readonly<{
8
- applySnapshot(snapshot: import("./models").NativeListSnapshot): void;
8
+ applySnapshot(snapshot: NativeListSnapshot): void;
9
9
  applyPatches(patches: readonly import("./models").RowPatch[]): void;
10
10
  reconcileSelection(selectedKeys: readonly string[]): void;
11
11
  scrollToKey: (paramsOrKey: import("./NativeList.types").ScrollToKeyParams | string, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
@@ -1,4 +1,7 @@
1
1
  import type { NativeListSnapshot, RowPatch } from './models';
2
+ /** Component boundaries report locations, never caller-controlled payload values. */
3
+ export declare function containNativeListInput<T>(operation: () => T): T | undefined;
4
+ export declare function emptyNativeListSnapshot(): NativeListSnapshot;
2
5
  export declare function validateSnapshot(snapshot: NativeListSnapshot): NativeListSnapshot;
3
6
  export declare function validatePatches(patches: readonly RowPatch[]): readonly RowPatch[];
4
7
  export declare function applyRowPatches(snapshot: NativeListSnapshot, patches: readonly RowPatch[]): NativeListSnapshot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.7.0-7",
3
+ "version": "6.7.0-9",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -86,8 +86,8 @@
86
86
  "typescript": "^5.9.2"
87
87
  },
88
88
  "peerDependencies": {
89
- "@onekeyfe/react-native-image": "6.7.0-7",
90
- "@onekeyfe/react-native-native-logger": "6.7.0-7",
89
+ "@onekeyfe/react-native-image": "6.7.0-9",
90
+ "@onekeyfe/react-native-native-logger": "6.7.0-9",
91
91
  "react": "*",
92
92
  "react-native": "*",
93
93
  "react-native-nitro-modules": "0.37.0"
@@ -1,6 +1,7 @@
1
1
  import { useNativeListFontFamiliesJson } from './fonts';
2
2
  import React, {
3
3
  forwardRef,
4
+ useCallback,
4
5
  useEffect,
5
6
  useImperativeHandle,
6
7
  useMemo,
@@ -24,6 +25,7 @@ import type {
24
25
  import type {
25
26
  ActionAnchorInvalidatedEvent,
26
27
  ImageSource,
28
+ NativeListSnapshot,
27
29
  RowActionEvent,
28
30
  SelectionDeltaEvent,
29
31
  ReorderEvent,
@@ -43,8 +45,11 @@ import {
43
45
  } from './scrolling';
44
46
  import {
45
47
  applyRowPatches,
48
+ containNativeListInput,
49
+ emptyNativeListSnapshot,
46
50
  serializePatches,
47
- serializeSnapshot,
51
+ validatePatches,
52
+ validateSnapshot,
48
53
  } from './validation';
49
54
 
50
55
  export type { NativeListProps, NativeListRef } from './NativeList.types';
@@ -98,7 +103,7 @@ function parsePayload<T>(payloadJson: string): T {
98
103
  export const NativeList = forwardRef<NativeListRef, NativeListProps>(
99
104
  function NativeList(
100
105
  {
101
- snapshot,
106
+ snapshot: inputSnapshot,
102
107
  listHeader,
103
108
  listFooter,
104
109
  listEmpty,
@@ -128,6 +133,26 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
128
133
  },
129
134
  forwardedRef
130
135
  ) {
136
+ const snapshotRef = useRef<NativeListSnapshot>(emptyNativeListSnapshot());
137
+ const initializedSnapshot = useRef(false);
138
+ const hasContainerSlots = Boolean(listHeader || listEmpty || listFooter);
139
+ const prepareSnapshot = useCallback(
140
+ (next: NativeListSnapshot) => {
141
+ const accepted = validateSnapshot(next);
142
+ if (hasContainerSlots && accepted.layout.orientation === 'horizontal')
143
+ throw new Error(
144
+ 'NativeList container slots require vertical orientation'
145
+ );
146
+ return accepted;
147
+ },
148
+ [hasContainerSlots]
149
+ );
150
+ const snapshot = useMemo(
151
+ () =>
152
+ containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
153
+ snapshotRef.current,
154
+ [inputSnapshot, prepareSnapshot]
155
+ );
131
156
  const fontFamiliesJson = useNativeListFontFamiliesJson();
132
157
  const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
133
158
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
@@ -141,14 +166,6 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
141
166
  snapshot.layout.contentPaddingHorizontal ??
142
167
  snapshot.layout.contentPadding ??
143
168
  0;
144
- if (
145
- snapshot.layout.orientation === 'horizontal' &&
146
- (listHeader || listEmpty || listFooter)
147
- ) {
148
- throw new Error(
149
- 'NativeList container slots require vertical orientation'
150
- );
151
- }
152
169
  const slotContents = [listHeader, listEmpty, listFooter];
153
170
  const normalizedKeyboardShouldPersistTaps =
154
171
  keyboardShouldPersistTaps === true
@@ -179,33 +196,40 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
179
196
  onRefresh,
180
197
  onScrollToIndexFailed,
181
198
  };
182
- const scrollPositionThresholdsJson = useMemo(() => {
183
- if (
184
- !scrollPositionThresholds ||
185
- scrollPositionThresholds.enabled === false
186
- )
187
- return '';
188
- const { start, end } = scrollPositionThresholds;
189
- if (
190
- !Number.isFinite(start) ||
191
- !Number.isFinite(end) ||
192
- start < 0 ||
193
- end <= start
194
- ) {
195
- throw new Error(
196
- 'scrollPositionThresholds requires 0 <= start < end and finite values'
197
- );
198
- }
199
- return JSON.stringify({ start, end });
200
- }, [scrollPositionThresholds]);
201
- const snapshotJson = useMemo(() => serializeSnapshot(snapshot), [snapshot]);
202
- const snapshotRef = useRef(snapshot);
199
+ const scrollPositionThresholdsJson = useMemo(
200
+ () =>
201
+ containNativeListInput(() => {
202
+ if (
203
+ !scrollPositionThresholds ||
204
+ scrollPositionThresholds.enabled === false
205
+ )
206
+ return '';
207
+ const { start, end } = scrollPositionThresholds;
208
+ if (
209
+ !Number.isFinite(start) ||
210
+ !Number.isFinite(end) ||
211
+ start < 0 ||
212
+ end <= start
213
+ ) {
214
+ throw new Error(
215
+ 'scrollPositionThresholds requires 0 <= start < end and finite values'
216
+ );
217
+ }
218
+ return JSON.stringify({ start, end });
219
+ }) ?? '',
220
+ [scrollPositionThresholds]
221
+ );
222
+ const snapshotJson = useMemo(() => JSON.stringify(snapshot), [snapshot]);
203
223
  const previousSnapshotJsonRef = useRef(snapshotJson);
204
224
  const snapshotChanged = previousSnapshotJsonRef.current !== snapshotJson;
205
225
  if (snapshotChanged) {
206
226
  snapshotRef.current = snapshot;
207
227
  previousSnapshotJsonRef.current = snapshotJson;
208
228
  }
229
+ if (!initializedSnapshot.current) {
230
+ snapshotRef.current = snapshot;
231
+ initializedSnapshot.current = true;
232
+ }
209
233
  // OneKey patch: range events already cross the bridge only when row indices
210
234
  // change. Prefetch is optional work; scrolling and visible loads stay native.
211
235
  const avatarQueueRef = useRef<NativeAvatarPrefetchQueue | null>(null);
@@ -260,26 +284,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
260
284
  }>
261
285
  | undefined
262
286
  >(
263
- initialScrollIndex === undefined && initialScrollKey === undefined
264
- ? undefined
265
- : initialScrollIndex !== undefined
266
- ? normalizeIndexScroll({
267
- index: initialScrollIndex,
268
- animated: false,
269
- viewPosition: initialScrollViewPosition,
270
- viewOffset: initialScrollViewOffset,
271
- })
272
- : {
273
- key: initialScrollKey,
274
- scroll: normalizePositionScroll(
275
- {
276
- animated: false,
277
- viewPosition: initialScrollViewPosition,
278
- viewOffset: initialScrollViewOffset,
279
- },
280
- 'start'
281
- ),
282
- }
287
+ containNativeListInput(() =>
288
+ initialScrollIndex === undefined && initialScrollKey === undefined
289
+ ? undefined
290
+ : initialScrollIndex !== undefined
291
+ ? normalizeIndexScroll({
292
+ index: initialScrollIndex,
293
+ animated: false,
294
+ viewPosition: initialScrollViewPosition,
295
+ viewOffset: initialScrollViewOffset,
296
+ })
297
+ : {
298
+ key: initialScrollKey,
299
+ scroll: normalizePositionScroll(
300
+ {
301
+ animated: false,
302
+ viewPosition: initialScrollViewPosition,
303
+ viewOffset: initialScrollViewOffset,
304
+ },
305
+ 'start'
306
+ ),
307
+ }
308
+ )
283
309
  );
284
310
  const didApplyInitialScroll = useRef(false);
285
311
 
@@ -337,21 +363,33 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
337
363
 
338
364
  useImperativeHandle(forwardedRef, () => ({
339
365
  applySnapshot(nextSnapshot) {
340
- const nextSnapshotJson = serializeSnapshot(nextSnapshot);
366
+ const accepted = containNativeListInput(() =>
367
+ prepareSnapshot(nextSnapshot)
368
+ );
369
+ if (!accepted) return;
370
+ const nextSnapshotJson = JSON.stringify(accepted);
341
371
  nativeRef.current?.applySnapshot(nextSnapshotJson);
342
- snapshotRef.current = nextSnapshot;
372
+ snapshotRef.current = accepted;
343
373
  if (nativeRef.current && avatarLifecycle.current !== 'unmounted') {
344
- avatarModelRef.current?.replaceSnapshot(nextSnapshot.rows);
374
+ avatarModelRef.current?.replaceSnapshot(accepted.rows);
345
375
  updateAvatarPrefetchRef.current();
346
376
  }
347
377
  },
348
378
  applyPatches(patches) {
349
- if (patches.length === 0) return;
350
- const nextSnapshot = applyRowPatches(snapshotRef.current, patches);
379
+ const accepted = containNativeListInput(() => {
380
+ const normalized = validatePatches(patches);
381
+ return {
382
+ patches: normalized,
383
+ snapshot: applyRowPatches(snapshotRef.current, normalized),
384
+ json: serializePatches(normalized),
385
+ };
386
+ });
387
+ if (!accepted || accepted.patches.length === 0) return;
388
+ const nextSnapshot = accepted.snapshot;
351
389
  const native = nativeRef.current;
352
390
  const dispatch = native
353
391
  ? () => {
354
- native.applyPatches(serializePatches(patches));
392
+ native.applyPatches(accepted.json);
355
393
  snapshotRef.current = nextSnapshot;
356
394
  }
357
395
  : undefined;
@@ -359,7 +397,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
359
397
  dispatch?.();
360
398
  return;
361
399
  }
362
- if (avatarModelRef.current?.applyPatches(patches, dispatch))
400
+ if (avatarModelRef.current?.applyPatches(accepted.patches, dispatch))
363
401
  updateAvatarPrefetchRef.current();
364
402
  },
365
403
  reconcileSelection(selectedKeys) {
@@ -21,7 +21,13 @@ import {
21
21
  validateOffset,
22
22
  type NormalizedPositionScroll,
23
23
  } from './scrolling';
24
- import { applyRowPatches, validateSnapshot } from './validation';
24
+ import {
25
+ applyRowPatches,
26
+ containNativeListInput,
27
+ emptyNativeListSnapshot,
28
+ validatePatches,
29
+ validateSnapshot,
30
+ } from './validation';
25
31
  import {
26
32
  NativeListWebEngine,
27
33
  type NativeListWebCallbacks,
@@ -83,14 +89,14 @@ export function preloadNativeListAvatarImages(
83
89
  export const NativeList = forwardRef<NativeListRef, NativeListProps>(
84
90
  function NativeList(
85
91
  {
86
- snapshot,
92
+ snapshot: inputSnapshot,
87
93
  listHeader,
88
94
  listEmpty,
89
95
  listFooter,
90
96
  topOverlay: _topOverlay,
91
97
  topScrollEdgeEffect: _topScrollEdgeEffect,
92
98
  webScrollHost,
93
- webStickyInset = 0,
99
+ webStickyInset: inputStickyInset = 0,
94
100
  scrollPositionThresholds: _scrollPositionThresholds,
95
101
  onScrollPositionThresholdChange: _onScrollPositionThresholdChange,
96
102
  webVirtualizationEnabled = true,
@@ -113,6 +119,24 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
113
119
  },
114
120
  forwardedRef
115
121
  ) {
122
+ const acceptedSnapshotRef = useRef<NativeListSnapshot>(
123
+ emptyNativeListSnapshot()
124
+ );
125
+ const initializedSnapshot = useRef(false);
126
+ const webStickyInset = useMemo(
127
+ () =>
128
+ containNativeListInput(() => {
129
+ if (!Number.isFinite(inputStickyInset) || inputStickyInset < 0)
130
+ throw new Error('webStickyInset must be finite and non-negative');
131
+ return inputStickyInset;
132
+ }) ?? 0,
133
+ [inputStickyInset]
134
+ );
135
+ const preparedSnapshot = useMemo(
136
+ () => containNativeListInput(() => validateSnapshot(inputSnapshot)),
137
+ [inputSnapshot]
138
+ );
139
+ const snapshot = preparedSnapshot ?? acceptedSnapshotRef.current;
116
140
  const fontFamiliesJson = useNativeListFontFamiliesJson();
117
141
  const fontFamiliesJsonRef = useRef(fontFamiliesJson);
118
142
  fontFamiliesJsonRef.current = fontFamiliesJson;
@@ -188,13 +212,14 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
188
212
  ? ownedScrollHost
189
213
  : undefined
190
214
  : webScrollHost;
191
- if (!Number.isFinite(webStickyInset) || webStickyInset < 0)
192
- throw new Error('webStickyInset must be finite and non-negative');
193
215
  const engineRef = useRef<NativeListWebEngine | undefined>(undefined);
194
216
  const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
195
217
  webVirtualizationEnabledRef.current = webVirtualizationEnabled;
196
218
  const validatedSnapshot = useMemo(
197
- () => normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout),
219
+ () =>
220
+ containNativeListInput(() =>
221
+ normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout)
222
+ ) ?? acceptedSnapshotRef.current,
198
223
  [snapshot, hasEmptySlot, useSlotLayout]
199
224
  );
200
225
  const snapshotRef = useRef(validatedSnapshot);
@@ -203,8 +228,13 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
203
228
  if (snapshotPropRef.current !== validatedSnapshot) {
204
229
  snapshotPropRef.current = validatedSnapshot;
205
230
  snapshotRef.current = validatedSnapshot;
231
+ acceptedSnapshotRef.current = validatedSnapshot;
206
232
  synchronizeSlots(snapshot);
207
233
  }
234
+ if (!initializedSnapshot.current) {
235
+ acceptedSnapshotRef.current = validatedSnapshot;
236
+ initializedSnapshot.current = true;
237
+ }
208
238
  const appliedSnapshotRef = useRef<NativeListSnapshot | undefined>(
209
239
  undefined
210
240
  );
@@ -227,26 +257,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
227
257
  }>
228
258
  | undefined
229
259
  >(
230
- initialScrollIndex === undefined && initialScrollKey === undefined
231
- ? undefined
232
- : initialScrollIndex !== undefined
233
- ? normalizeIndexScroll({
234
- index: initialScrollIndex,
235
- animated: false,
236
- viewPosition: initialScrollViewPosition,
237
- viewOffset: initialScrollViewOffset,
238
- })
239
- : {
240
- key: initialScrollKey,
241
- scroll: normalizePositionScroll(
242
- {
243
- animated: false,
244
- viewPosition: initialScrollViewPosition,
245
- viewOffset: initialScrollViewOffset,
246
- },
247
- 'start'
248
- ),
249
- }
260
+ containNativeListInput(() =>
261
+ initialScrollIndex === undefined && initialScrollKey === undefined
262
+ ? undefined
263
+ : initialScrollIndex !== undefined
264
+ ? normalizeIndexScroll({
265
+ index: initialScrollIndex,
266
+ animated: false,
267
+ viewPosition: initialScrollViewPosition,
268
+ viewOffset: initialScrollViewOffset,
269
+ })
270
+ : {
271
+ key: initialScrollKey,
272
+ scroll: normalizePositionScroll(
273
+ {
274
+ animated: false,
275
+ viewPosition: initialScrollViewPosition,
276
+ viewOffset: initialScrollViewOffset,
277
+ },
278
+ 'start'
279
+ ),
280
+ }
281
+ )
250
282
  );
251
283
  const didApplyInitialScroll = useRef(false);
252
284
  const scrollOptionsRef = useRef({
@@ -265,19 +297,23 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
265
297
  (useSlotLayout && !contentBounds)
266
298
  )
267
299
  return;
268
- const engine = new NativeListWebEngine(
269
- host,
270
- snapshotRef.current,
271
- callbacksRef.current,
272
- webVirtualizationEnabledRef.current,
273
- webSectionIndexContainerRef?.current as unknown as HTMLElement | null,
274
- fontFamiliesJsonRef.current,
275
- {
276
- scrollHost: resolvedScrollHost as HTMLElement | undefined,
277
- contentBounds: contentBounds ?? undefined,
278
- ...scrollOptionsRef.current,
279
- }
300
+ const engine = containNativeListInput(
301
+ () =>
302
+ new NativeListWebEngine(
303
+ host,
304
+ snapshotRef.current,
305
+ callbacksRef.current,
306
+ webVirtualizationEnabledRef.current,
307
+ webSectionIndexContainerRef?.current as unknown as HTMLElement | null,
308
+ fontFamiliesJsonRef.current,
309
+ {
310
+ scrollHost: resolvedScrollHost as HTMLElement | undefined,
311
+ contentBounds: contentBounds ?? undefined,
312
+ ...scrollOptionsRef.current,
313
+ }
314
+ )
280
315
  );
316
+ if (!engine) return;
281
317
  host.style.height = '';
282
318
  engineRef.current = engine;
283
319
  appliedSnapshotRef.current = snapshotRef.current;
@@ -337,20 +373,30 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
337
373
 
338
374
  useImperativeHandle(forwardedRef, () => ({
339
375
  applySnapshot(nextSnapshot) {
340
- const next = normalizeWebSnapshot(nextSnapshot);
376
+ const next = containNativeListInput(() =>
377
+ normalizeWebSnapshot(nextSnapshot)
378
+ );
379
+ if (!next) return;
341
380
  engineRef.current?.applySnapshot(next);
342
381
  snapshotRef.current = next;
382
+ acceptedSnapshotRef.current = next;
343
383
  appliedSnapshotRef.current = next;
344
- synchronizeSlots(nextSnapshot);
384
+ synchronizeSlots(next);
345
385
  },
346
386
  applyPatches(patches) {
347
- if (patches.length > 0) {
387
+ const accepted = containNativeListInput(() => validatePatches(patches));
388
+ if (accepted && accepted.length > 0) {
348
389
  const engine = engineRef.current;
349
390
  if (engine) {
350
- engine.applyPatches(patches);
391
+ engine.applyPatches(accepted);
351
392
  snapshotRef.current = engine.currentSnapshot();
352
- } else
353
- snapshotRef.current = applyRowPatches(snapshotRef.current, patches);
393
+ } else {
394
+ const next = containNativeListInput(() =>
395
+ applyRowPatches(snapshotRef.current, accepted)
396
+ );
397
+ if (next) snapshotRef.current = next;
398
+ }
399
+ acceptedSnapshotRef.current = snapshotRef.current;
354
400
  }
355
401
  },
356
402
  reconcileSelection(selectedKeys) {