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

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/src/validation.ts CHANGED
@@ -31,8 +31,42 @@ const MAX_SPACER_HEIGHT = 512;
31
31
  const MAX_SECTION_INDEX_TITLE_LENGTH = 8;
32
32
  const MAX_MARKET_BADGES = 3;
33
33
 
34
+ function isDevelopment(): boolean {
35
+ return typeof __DEV__ !== 'undefined' && __DEV__;
36
+ }
37
+
38
+ class NativeListInputError extends Error {
39
+ constructor(readonly path: string, readonly reason: string) {
40
+ super(`NativeList ${path}: ${reason}`);
41
+ }
42
+ }
43
+
34
44
  function fail(path: string, message: string): never {
35
- throw new Error(`NativeList ${path}: ${message}`);
45
+ throw new NativeListInputError(path, message);
46
+ }
47
+
48
+ /** Component boundaries report locations, never caller-controlled payload values. */
49
+ export function containNativeListInput<T>(operation: () => T): T | undefined {
50
+ try {
51
+ return operation();
52
+ } catch (error) {
53
+ const path = error instanceof NativeListInputError ? error.path : 'input';
54
+ const reason =
55
+ isDevelopment() && error instanceof NativeListInputError
56
+ ? `: ${error.reason.split('"')[0].trim()}`
57
+ : '';
58
+ console.warn(`NativeList rejected invalid input at ${path}${reason}`);
59
+ return undefined;
60
+ }
61
+ }
62
+
63
+ export function emptyNativeListSnapshot(): NativeListSnapshot {
64
+ return {
65
+ schemaVersion: 1,
66
+ generation: 0,
67
+ layout: { kind: 'linear' },
68
+ rows: [],
69
+ };
36
70
  }
37
71
 
38
72
  function assertPlainSerializable(
@@ -72,16 +106,14 @@ function assertPlainSerializable(
72
106
  function assertKey(key: string, path: string): void {
73
107
  if (
74
108
  typeof key !== 'string' ||
75
- key.length === 0 ||
109
+ key.trim().length === 0 ||
76
110
  key.length > MAX_KEY_LENGTH
77
111
  ) {
78
112
  fail(
79
113
  path,
80
- `must be a non-empty string no longer than ${MAX_KEY_LENGTH} characters`
114
+ `must be a non-blank string no longer than ${MAX_KEY_LENGTH} characters`
81
115
  );
82
116
  }
83
- if (key.trim() !== key)
84
- fail(path, 'must not have leading or trailing whitespace');
85
117
  }
86
118
 
87
119
  function assertText(text: string | undefined, path: string): void {
@@ -1677,7 +1709,7 @@ function assertMediaPreview(value: unknown, path: string) {
1677
1709
  }
1678
1710
  }
1679
1711
 
1680
- export function validateSnapshot(
1712
+ function assertSnapshotContract(
1681
1713
  snapshot: NativeListSnapshot
1682
1714
  ): NativeListSnapshot {
1683
1715
  if (
@@ -1826,7 +1858,384 @@ export function validateSnapshot(
1826
1858
  'supports at most one key in single mode'
1827
1859
  );
1828
1860
  }
1829
- return normalizeSnapshotStyles(snapshot);
1861
+ return snapshot;
1862
+ }
1863
+
1864
+ function protocolObject(value: unknown, path: string): Record<string, unknown> {
1865
+ if (!value || typeof value !== 'object' || Array.isArray(value))
1866
+ fail(path, 'must be an object');
1867
+ return value as Record<string, unknown>;
1868
+ }
1869
+
1870
+ function protocolKey(value: unknown, path: string): void {
1871
+ if (typeof value !== 'string' || value.trim().length === 0)
1872
+ fail(path, 'must be a non-blank string');
1873
+ }
1874
+
1875
+ const PROTOCOL_ARRAY_FIELDS = new Set([
1876
+ 'columns',
1877
+ 'cells',
1878
+ 'points',
1879
+ 'images',
1880
+ 'overlays',
1881
+ 'badges',
1882
+ 'trailing',
1883
+ 'footerActions',
1884
+ 'amounts',
1885
+ 'metrics',
1886
+ 'children',
1887
+ 'subtitleSegments',
1888
+ 'titleMatch',
1889
+ 'selectedKeys',
1890
+ 'segments',
1891
+ 'hoverSecondary',
1892
+ 'hoverImages',
1893
+ 'secondaryBadges',
1894
+ 'fallbackUris',
1895
+ 'probeOrder',
1896
+ 'priceSegments',
1897
+ 'textSegments',
1898
+ 'secondaryTextSegments',
1899
+ 'primaryTextSegments',
1900
+ ]);
1901
+ const PROTOCOL_NUMBER_FIELDS = new Set([
1902
+ 'height',
1903
+ 'width',
1904
+ 'fontSize',
1905
+ 'lineHeight',
1906
+ 'opacity',
1907
+ 'offsetY',
1908
+ 'offsetX',
1909
+ 'cornerRadius',
1910
+ 'borderWidth',
1911
+ 'horizontalPadding',
1912
+ 'verticalPadding',
1913
+ 'leadingGap',
1914
+ 'lineGap',
1915
+ 'titleBadgeGap',
1916
+ 'trailingGap',
1917
+ 'start',
1918
+ 'end',
1919
+ 'padding',
1920
+ 'offset',
1921
+ 'overscan',
1922
+ 'minWidth',
1923
+ 'flex',
1924
+ 'paddingStart',
1925
+ 'paddingEnd',
1926
+ 'changeWidth',
1927
+ 'changeHeight',
1928
+ 'changeCornerRadius',
1929
+ 'contentTrailingGap',
1930
+ 'subtitleTrailingPadding',
1931
+ 'partGap',
1932
+ 'contentPadding',
1933
+ 'contentPaddingHorizontal',
1934
+ 'contentPaddingTop',
1935
+ 'contentPaddingBottom',
1936
+ 'itemSpacing',
1937
+ 'gridColumns',
1938
+ ]);
1939
+
1940
+ /** Validate only shapes that renderers dereference, not display budgets. */
1941
+ function assertProtocolFields(
1942
+ value: unknown,
1943
+ path: string,
1944
+ parentField = ''
1945
+ ): void {
1946
+ if (value === undefined || value === null || typeof value !== 'object')
1947
+ return;
1948
+ if (Array.isArray(value)) {
1949
+ for (const [index, item] of value.entries()) {
1950
+ const itemPath = `${path}[${index}]`;
1951
+ if (
1952
+ ['selectedKeys', 'fallbackUris', 'probeOrder'].includes(parentField)
1953
+ ) {
1954
+ if (typeof item !== 'string') fail(itemPath, 'must be a string');
1955
+ } else if (parentField === 'points') {
1956
+ if (typeof item !== 'number') fail(itemPath, 'must be a finite number');
1957
+ } else if (parentField === 'hoverImages' && item === null) continue;
1958
+ else protocolObject(item, itemPath);
1959
+ assertProtocolFields(item, itemPath, parentField);
1960
+ }
1961
+ return;
1962
+ }
1963
+ const object = value as Record<string, unknown>;
1964
+ if (
1965
+ !path.includes('.style.') &&
1966
+ ['image', 'networkImage', 'thumbnail', 'images', 'hoverImages'].includes(
1967
+ parentField
1968
+ ) &&
1969
+ typeof object.uri !== 'string'
1970
+ )
1971
+ fail(`${path}.uri`, 'must be a string');
1972
+ Object.entries(value).forEach(([field, item]) => {
1973
+ if (item === undefined) return;
1974
+ const fieldPath = `${path}.${field}`;
1975
+ if (
1976
+ !path.endsWith('.style') &&
1977
+ PROTOCOL_ARRAY_FIELDS.has(field) &&
1978
+ !Array.isArray(item)
1979
+ )
1980
+ fail(fieldPath, 'must be an array');
1981
+ if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item !== 'number')
1982
+ fail(fieldPath, 'must be a finite number');
1983
+ if (
1984
+ PROTOCOL_NUMBER_FIELDS.has(field) &&
1985
+ typeof item === 'number' &&
1986
+ item < 0 &&
1987
+ !['offsetX', 'offsetY'].includes(field)
1988
+ )
1989
+ fail(fieldPath, 'must be non-negative');
1990
+ if (
1991
+ field === 'key' ||
1992
+ field === 'sectionKey' ||
1993
+ field === 'actionKey' ||
1994
+ field.endsWith('ActionKey')
1995
+ )
1996
+ protocolKey(item, fieldPath);
1997
+ if (
1998
+ (field === 'uri' || field === 'fallbackUri') &&
1999
+ typeof item !== 'string'
2000
+ )
2001
+ fail(fieldPath, 'must be a string');
2002
+ if (
2003
+ (field === 'style' &&
2004
+ !(item === 'subscript' && /[Ss]egments\[/.test(path))) ||
2005
+ field === 'container'
2006
+ )
2007
+ protocolObject(item, fieldPath);
2008
+ if (
2009
+ path.endsWith('.style') &&
2010
+ [
2011
+ 'title',
2012
+ 'subtitle',
2013
+ 'tertiary',
2014
+ 'body',
2015
+ 'time',
2016
+ 'price',
2017
+ 'change',
2018
+ 'columns',
2019
+ 'columnSecondary',
2020
+ 'value',
2021
+ 'valueSecondary',
2022
+ 'badge',
2023
+ 'description',
2024
+ 'status',
2025
+ 'primaryAmount',
2026
+ 'secondaryAmount',
2027
+ 'trend',
2028
+ 'message',
2029
+ 'actionText',
2030
+ ].includes(field)
2031
+ )
2032
+ protocolObject(item, fieldPath);
2033
+ assertProtocolFields(item, fieldPath, field);
2034
+ });
2035
+ }
2036
+
2037
+ function assertRowProtocol(row: RowModel, path: string): void {
2038
+ protocolObject(row, path);
2039
+ assertRowType(row.type, path);
2040
+ protocolKey(row.key, `${path}.key`);
2041
+ assertProtocolFields(row, path);
2042
+ for (const field of ['leading', 'visual', 'secondaryLeading'] as const) {
2043
+ const visual = (row as unknown as Record<string, unknown>)[field];
2044
+ if (
2045
+ visual !== undefined ||
2046
+ (field === 'leading' &&
2047
+ (row.type === 'identity' || row.type === 'market'))
2048
+ ) {
2049
+ const object = protocolObject(visual, `${path}.${field}`);
2050
+ if (object.kind === 'stackedImages' && !Array.isArray(object.images))
2051
+ fail(`${path}.${field}.images`, 'must be an array');
2052
+ }
2053
+ }
2054
+ for (const field of [
2055
+ 'title',
2056
+ 'subtitle',
2057
+ 'tertiary',
2058
+ 'body',
2059
+ 'time',
2060
+ 'price',
2061
+ 'indexTitle',
2062
+ ] as const) {
2063
+ const value = (row as unknown as Record<string, unknown>)[field];
2064
+ if (value !== undefined && typeof value !== 'string')
2065
+ fail(`${path}.${field}`, 'must be a string');
2066
+ }
2067
+ if (row.height !== undefined && row.height < 0)
2068
+ fail(`${path}.height`, 'must be non-negative');
2069
+ if (row.type === 'identity') {
2070
+ let end = 0;
2071
+ row.titleMatch?.forEach((match) => {
2072
+ if (
2073
+ !Number.isInteger(match.start) ||
2074
+ !Number.isInteger(match.end) ||
2075
+ match.start < end ||
2076
+ match.end <= match.start ||
2077
+ match.end > row.title.length
2078
+ )
2079
+ fail(`${path}.titleMatch`, 'invalid text range');
2080
+ end = match.end;
2081
+ });
2082
+ }
2083
+ if (row.type === 'mediaTile' && row.media) {
2084
+ protocolObject(row.media.source, `${path}.media.source`);
2085
+ if (!Array.isArray(row.media.probeOrder))
2086
+ fail(`${path}.media.probeOrder`, 'must be an array');
2087
+ }
2088
+ if (row.type === 'walletGroup') {
2089
+ protocolObject(row.parent, `${path}.parent`);
2090
+ if (!Array.isArray(row.children))
2091
+ fail(`${path}.children`, 'must be an array');
2092
+ const members = [row.parent, ...row.children];
2093
+ const keys = new Set<string>();
2094
+ if (row.parent.key !== row.key)
2095
+ fail(`${path}.parent.key`, 'must match its group');
2096
+ members.forEach((member, index) => {
2097
+ assertRowProtocol(member, `${path}.members[${index}]`);
2098
+ if (member.type !== 'identity' || keys.has(member.key))
2099
+ fail(path, 'invalid wallet member identity');
2100
+ keys.add(member.key);
2101
+ });
2102
+ }
2103
+ if (row.type === 'dataRow' && !Array.isArray(row.columns))
2104
+ fail(`${path}.columns`, 'must be an array');
2105
+ if (row.type === 'market') {
2106
+ protocolObject(row.change, `${path}.change`);
2107
+ if (row.webTable) {
2108
+ const { columns, cells } = row.webTable;
2109
+ if (
2110
+ !Array.isArray(columns) ||
2111
+ !Array.isArray(cells) ||
2112
+ columns.length !== cells.length
2113
+ )
2114
+ fail(`${path}.webTable`, 'columns and cells must match');
2115
+ const keys = new Set<string>();
2116
+ columns.forEach((column, index) => {
2117
+ protocolKey(column.key, `${path}.webTable.columns[${index}].key`);
2118
+ if (keys.has(column.key) || cells[index]?.key !== column.key)
2119
+ fail(`${path}.webTable`, 'invalid column identity');
2120
+ keys.add(column.key);
2121
+ const cell = cells[index];
2122
+ if (!['favorite', 'asset', 'text', 'sparkline'].includes(cell.kind))
2123
+ fail(`${path}.webTable.cells[${index}]`, 'unsupported cell kind');
2124
+ if (cell.kind === 'asset')
2125
+ protocolObject(cell.title, `${path}.webTable.cells[${index}].title`);
2126
+ if (
2127
+ (cell.kind === 'asset' || cell.kind === 'text') &&
2128
+ cell.secondary !== undefined &&
2129
+ !Array.isArray(cell.secondary)
2130
+ )
2131
+ fail(
2132
+ `${path}.webTable.cells[${index}].secondary`,
2133
+ 'must be an array'
2134
+ );
2135
+ if (cell.kind === 'text' && !Array.isArray(cell.primary))
2136
+ fail(`${path}.webTable.cells[${index}].primary`, 'must be an array');
2137
+ // The Web renderer spreads samples into Math.min/Math.max.
2138
+ if (
2139
+ cell.kind === 'sparkline' &&
2140
+ (!Array.isArray(cell.points) || cell.points.length > 256)
2141
+ )
2142
+ fail(
2143
+ `${path}.webTable.cells[${index}].points`,
2144
+ 'must be an array of at most 256 samples'
2145
+ );
2146
+ });
2147
+ }
2148
+ }
2149
+ }
2150
+
2151
+ function assertSnapshotProtocol(snapshot: NativeListSnapshot): void {
2152
+ protocolObject(snapshot, 'snapshot');
2153
+ if (snapshot.schemaVersion !== 1) fail('snapshot.schemaVersion', 'must be 1');
2154
+ if (!Number.isSafeInteger(snapshot.generation) || snapshot.generation < 0)
2155
+ fail('snapshot.generation', 'must be a non-negative safe integer');
2156
+ protocolObject(snapshot.layout, 'snapshot.layout');
2157
+ assertProtocolFields(snapshot.layout, 'snapshot.layout');
2158
+ if (
2159
+ snapshot.layout.orientation !== undefined &&
2160
+ !['vertical', 'horizontal'].includes(snapshot.layout.orientation)
2161
+ )
2162
+ fail('snapshot.layout.orientation', 'is not supported');
2163
+ if (!['linear', 'sectioned', 'grid', 'table'].includes(snapshot.layout.kind))
2164
+ fail('snapshot.layout.kind', 'is not supported');
2165
+ if (!Array.isArray(snapshot.rows)) fail('snapshot.rows', 'must be an array');
2166
+ if (
2167
+ snapshot.layout.kind === 'grid' &&
2168
+ (!Number.isInteger(snapshot.layout.gridColumns) ||
2169
+ (snapshot.layout.gridColumns ?? 0) < 1 ||
2170
+ (snapshot.layout.gridColumns ?? 0) > 7)
2171
+ )
2172
+ fail('snapshot.layout.gridColumns', 'must be an integer from 1 to 7');
2173
+ const keys = new Set<string>();
2174
+ for (const [index, row] of snapshot.rows.entries()) {
2175
+ assertRowProtocol(row, `rows[${index}]`);
2176
+ if (keys.has(row.key)) fail(`rows[${index}].key`, 'duplicate row identity');
2177
+ keys.add(row.key);
2178
+ }
2179
+ if (snapshot.emptyState) assertRowProtocol(snapshot.emptyState, 'emptyState');
2180
+ if (snapshot.fixedFooter)
2181
+ assertRowProtocol(snapshot.fixedFooter, 'fixedFooter');
2182
+ if (snapshot.selection) {
2183
+ if (!Array.isArray(snapshot.selection.selectedKeys))
2184
+ fail('snapshot.selection.selectedKeys', 'must be an array');
2185
+ snapshot.selection.selectedKeys.forEach((key) => {
2186
+ if (!keys.has(key))
2187
+ fail('snapshot.selection.selectedKeys', 'unknown row identity');
2188
+ });
2189
+ }
2190
+ }
2191
+
2192
+ /** Empty optional image descriptors must take the same path as absent images. */
2193
+ function normalizeEmptyImages(value: unknown, field = ''): unknown {
2194
+ if (!value || typeof value !== 'object') return value;
2195
+ if (Array.isArray(value)) {
2196
+ const next = value.map((item) => normalizeEmptyImages(item));
2197
+ const filtered =
2198
+ field === 'images'
2199
+ ? next.filter((item) => item !== undefined)
2200
+ : next.map((item) => (item === undefined ? null : item));
2201
+ return filtered.length === value.length &&
2202
+ filtered.every((item, index) => item === value[index])
2203
+ ? value
2204
+ : filtered;
2205
+ }
2206
+ const object = value as Record<string, unknown>;
2207
+ if (
2208
+ typeof object.uri === 'string' &&
2209
+ !object.uri.trim() &&
2210
+ 'width' in object &&
2211
+ 'height' in object
2212
+ )
2213
+ return undefined;
2214
+ let changed = false;
2215
+ const next = { ...object };
2216
+ Object.entries(object).forEach(([key, item]) => {
2217
+ const normalized = normalizeEmptyImages(item, key);
2218
+ if (normalized !== item) {
2219
+ // Omitted JSON patch fields must also be absent from the JS merge.
2220
+ if (field === 'changes' && normalized === undefined) delete next[key];
2221
+ else next[key] = normalized;
2222
+ changed = true;
2223
+ }
2224
+ });
2225
+ if (field === 'media' && next.source === undefined) return undefined;
2226
+ return changed ? next : value;
2227
+ }
2228
+
2229
+ export function validateSnapshot(
2230
+ snapshot: NativeListSnapshot
2231
+ ): NativeListSnapshot {
2232
+ assertPlainSerializable(snapshot, 'snapshot', new Set<object>());
2233
+ if (isDevelopment()) assertSnapshotContract(snapshot);
2234
+ const normalized = isDevelopment()
2235
+ ? snapshot
2236
+ : (normalizeEmptyImages(snapshot) as NativeListSnapshot);
2237
+ assertSnapshotProtocol(normalized);
2238
+ return normalizeSnapshotStyles(normalized);
1830
2239
  }
1831
2240
 
1832
2241
  /**
@@ -2075,18 +2484,30 @@ export function validatePatches(
2075
2484
  patches: readonly RowPatch[]
2076
2485
  ): readonly RowPatch[] {
2077
2486
  assertPlainSerializable(patches, 'patches', new Set<object>());
2487
+ if (!Array.isArray(patches)) fail('patches', 'must be an array');
2078
2488
  const keys = new Set<string>();
2079
- patches.forEach((patch, index) => {
2080
- assertKey(patch.key, `patches[${index}].key`);
2489
+ for (const [index, patch] of patches.entries()) {
2490
+ protocolObject(patch, `patches[${index}]`);
2491
+ protocolKey(patch.key, `patches[${index}].key`);
2081
2492
  if (keys.has(patch.key))
2082
2493
  fail(`patches[${index}].key`, `duplicate key "${patch.key}"`);
2083
2494
  keys.add(patch.key);
2495
+ protocolObject(patch.changes, `patches[${index}].changes`);
2496
+ assertRowType(patch.type, `patches[${index}]`);
2497
+ assertProtocolFields(patch.changes, `patches[${index}].changes`);
2498
+ if (!isDevelopment()) continue;
2499
+ assertKey(patch.key, `patches[${index}].key`);
2084
2500
  if (Object.keys(patch.changes).length === 0) {
2085
2501
  fail(`patches[${index}].changes`, 'must contain at least one field');
2086
2502
  }
2087
2503
  assertPatchChanges(patch, index);
2088
- });
2089
- return normalizePatchStyles(patches);
2504
+ }
2505
+ const normalized = isDevelopment()
2506
+ ? patches
2507
+ : (normalizeEmptyImages(patches) as readonly RowPatch[]);
2508
+ return normalizePatchStyles(
2509
+ normalized.filter((patch) => Object.keys(patch.changes).length > 0)
2510
+ );
2090
2511
  }
2091
2512
 
2092
2513
  /** Patches reach the native side without passing through a snapshot. */
@@ -2112,10 +2533,12 @@ export function applyRowPatches(
2112
2533
  snapshot: NativeListSnapshot,
2113
2534
  patches: readonly RowPatch[]
2114
2535
  ): NativeListSnapshot {
2115
- validatePatches(patches);
2116
- const patchByKey = new Map(patches.map((patch) => [patch.key, patch]));
2536
+ const normalizedPatches = validatePatches(patches);
2537
+ const patchByKey = new Map(
2538
+ normalizedPatches.map((patch) => [patch.key, patch])
2539
+ );
2117
2540
  const knownKeys = new Set(snapshot.rows.map((row) => row.key));
2118
- patches.forEach((patch) => {
2541
+ normalizedPatches.forEach((patch) => {
2119
2542
  if (!knownKeys.has(patch.key))
2120
2543
  fail('patches', `unknown row key "${patch.key}"`);
2121
2544
  });
@@ -60,7 +60,13 @@ import {
60
60
  validateOffset,
61
61
  type NormalizedPositionScroll,
62
62
  } from '../scrolling';
63
- import { applyRowPatches, validateSnapshot } from '../validation';
63
+ import {
64
+ applyRowPatches,
65
+ containNativeListInput,
66
+ emptyNativeListSnapshot,
67
+ validatePatches,
68
+ validateSnapshot,
69
+ } from '../validation';
64
70
  import { avatarPrefetchWindow } from '../avatarPrefetch';
65
71
  import {
66
72
  acquireNativeListAvatar,
@@ -2160,7 +2166,9 @@ export class NativeListWebEngine {
2160
2166
  scrollOptions.stickyInset
2161
2167
  );
2162
2168
  this.document = host.ownerDocument;
2163
- this.snapshot = validateSnapshot(snapshot);
2169
+ this.snapshot =
2170
+ containNativeListInput(() => validateSnapshot(snapshot)) ??
2171
+ emptyNativeListSnapshot();
2164
2172
  this.callbacks = callbacks;
2165
2173
  this.virtualizationEnabled = virtualizationEnabled;
2166
2174
  this.sectionIndexContainer = sectionIndexContainer ?? undefined;
@@ -2442,12 +2450,13 @@ export class NativeListWebEngine {
2442
2450
  }
2443
2451
 
2444
2452
  applySnapshot(snapshot: NativeListSnapshot) {
2445
- const validated = validateSnapshot(snapshot);
2446
- if (
2447
- this.externalScrollHost &&
2448
- validated.layout.orientation === 'horizontal'
2449
- )
2450
- throw new Error('External scrolling supports vertical lists only');
2453
+ const validated = containNativeListInput(() => {
2454
+ const next = validateSnapshot(snapshot);
2455
+ if (this.externalScrollHost && next.layout.orientation === 'horizontal')
2456
+ throw new Error('External scrolling supports vertical lists only');
2457
+ return next;
2458
+ });
2459
+ if (!validated) return;
2451
2460
  this.invalidateActionAnchor('snapshot');
2452
2461
  this.setSnapshot(validated);
2453
2462
  }
@@ -2461,8 +2470,16 @@ export class NativeListWebEngine {
2461
2470
  }
2462
2471
 
2463
2472
  applyPatches(patches: readonly RowPatch[]) {
2464
- if (patches.length === 0) return;
2465
- const next = applyRowPatches(this.snapshot, patches);
2473
+ const accepted = containNativeListInput(() => {
2474
+ const normalized = validatePatches(patches);
2475
+ return {
2476
+ patches: normalized,
2477
+ snapshot: applyRowPatches(this.snapshot, normalized),
2478
+ };
2479
+ });
2480
+ if (!accepted || accepted.patches.length === 0) return;
2481
+ patches = accepted.patches;
2482
+ const next = accepted.snapshot;
2466
2483
  const selection = new Set(this.selectedKeys);
2467
2484
  patches.forEach((patch) => {
2468
2485
  const selected =