@assistant-ui/react-native 0.1.45 → 0.1.46

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.
Files changed (33) hide show
  1. package/dist/index.d.ts +4 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/primitives/message.d.ts +1 -0
  5. package/dist/primitives/message.d.ts.map +1 -1
  6. package/dist/primitives/message.js +3 -2
  7. package/dist/primitives/message.js.map +1 -1
  8. package/dist/primitives/thread/ThreadMessages.d.ts +7 -5
  9. package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
  10. package/dist/primitives/thread/ThreadMessages.js +109 -376
  11. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  12. package/dist/primitives/thread/ThreadRowsFlatList.d.ts +29 -0
  13. package/dist/primitives/thread/ThreadRowsFlatList.d.ts.map +1 -0
  14. package/dist/primitives/thread/ThreadRowsFlatList.js +226 -0
  15. package/dist/primitives/thread/ThreadRowsFlatList.js.map +1 -0
  16. package/dist/primitives/thread/flatListScroll.d.ts +52 -0
  17. package/dist/primitives/thread/flatListScroll.d.ts.map +1 -0
  18. package/dist/primitives/thread/flatListScroll.js +380 -0
  19. package/dist/primitives/thread/flatListScroll.js.map +1 -0
  20. package/dist/primitives/thread.d.ts +2 -0
  21. package/dist/primitives/thread.d.ts.map +1 -1
  22. package/dist/primitives/thread.js +5 -2
  23. package/dist/primitives/thread.js.map +1 -1
  24. package/package.json +4 -3
  25. package/src/index.ts +18 -1
  26. package/src/primitives/message.test.tsx +74 -0
  27. package/src/primitives/message.ts +1 -0
  28. package/src/primitives/thread/ThreadMessages.test.tsx +28 -1
  29. package/src/primitives/thread/ThreadMessages.tsx +49 -343
  30. package/src/primitives/thread/ThreadRowsFlatList.test.tsx +253 -0
  31. package/src/primitives/thread/ThreadRowsFlatList.tsx +159 -0
  32. package/src/primitives/thread/flatListScroll.ts +467 -0
  33. package/src/primitives/thread.ts +5 -0
@@ -1,35 +1,12 @@
1
+ import { getFlatListPagingProps, useComposedFlatListRef, useFlatListAutoScroll, useFlatListScrollProps, useHistoryLoad, useThreadHistory } from "./flatListScroll.js";
1
2
  import { MessageByIndexProvider } from "@assistant-ui/core/react";
2
- import { RenderChildrenWithAccessor, useAuiEvent, useAuiState } from "@assistant-ui/store";
3
+ import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
3
4
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { FlatList } from "react-native";
5
6
  import { jsx } from "react/jsx-runtime";
6
- import { forwardRef, memo, useCallback, useEffect, useRef } from "@assistant-ui/tap/react-shim";
7
+ import { forwardRef, memo } from "@assistant-ui/tap/react-shim";
7
8
  //#region src/primitives/thread/ThreadMessages.tsx
8
9
  const DEFAULT_SYSTEM_MESSAGE = () => null;
9
- const AT_BOTTOM_THRESHOLD = 4;
10
- const useHistoryLoad = (history, onStartReached) => {
11
- const loadRequestedRef = useRef(false);
12
- const hasMore = history?.hasMore ?? false;
13
- const isLoadingMore = history?.isLoadingMore ?? false;
14
- useEffect(() => {
15
- loadRequestedRef.current = isLoadingMore;
16
- });
17
- const handleStartReached = useCallback((info) => {
18
- onStartReached?.(info);
19
- if (loadRequestedRef.current) return;
20
- loadRequestedRef.current = true;
21
- try {
22
- history?.loadMore();
23
- } catch (error) {
24
- loadRequestedRef.current = false;
25
- throw error;
26
- }
27
- }, [history, onStartReached]);
28
- return {
29
- canLoadMore: hasMore && !isLoadingMore,
30
- handleStartReached
31
- };
32
- };
33
10
  const getComponent = (components, role, isEditing) => {
34
11
  switch (role) {
35
12
  case "user": if (isEditing) return components.UserEditComposer ?? components.EditComposer ?? components.UserMessage ?? components.Message;
@@ -97,239 +74,16 @@ const ThreadMessageByChildren = memo(({ index, children }) => {
97
74
  });
98
75
  }, (prev, next) => prev.index === next.index && prev.children === next.children);
99
76
  ThreadMessageByChildren.displayName = "ThreadPrimitive.MessageByChildren";
100
- const setForwardedRef = (ref, value) => {
101
- if (typeof ref === "function") ref(value);
102
- else if (ref) ref.current = value;
103
- };
104
- const useComposedFlatListRef = (forwardedRef) => {
105
- const $ = c(4);
106
- const flatListRef = useRef(null);
107
- let t0;
108
- if ($[0] !== forwardedRef) {
109
- t0 = (node) => {
110
- flatListRef.current = node;
111
- setForwardedRef(forwardedRef, node);
112
- };
113
- $[0] = forwardedRef;
114
- $[1] = t0;
115
- } else t0 = $[1];
116
- const setFlatListRef = t0;
117
- let t1;
118
- if ($[2] !== setFlatListRef) {
119
- t1 = [flatListRef, setFlatListRef];
120
- $[2] = setFlatListRef;
121
- $[3] = t1;
122
- } else t1 = $[3];
123
- return t1;
124
- };
125
- const useThreadMessagesFlatListAutoScroll = (t0) => {
126
- const $ = c(29);
127
- const { flatListRef, hasMessages, horizontal: t1, autoScroll: t2, scrollToBottomOnRunStart: t3, scrollToBottomOnInitialize: t4, scrollToBottomOnThreadSwitch: t5 } = t0;
128
- const horizontal = t1 === void 0 ? false : t1;
129
- const autoScroll = t2 === void 0 ? true : t2;
130
- const scrollToBottomOnRunStart = t3 === void 0 ? true : t3;
131
- const scrollToBottomOnInitialize = t4 === void 0 ? true : t4;
132
- const scrollToBottomOnThreadSwitch = t5 === void 0 ? true : t5;
133
- let t6;
134
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
135
- t6 = {
136
- contentHeight: 0,
137
- viewportHeight: 0,
138
- scrollY: 0
139
- };
140
- $[0] = t6;
141
- } else t6 = $[0];
142
- const metricsRef = useRef(t6);
143
- const isAtBottomRef = useRef(true);
144
- const lastScrollEventOffsetRef = useRef(0);
145
- const initializeScrollRequestedRef = useRef(false);
146
- const contentSizeVersionRef = useRef(0);
147
- const pendingScrollToBottomRef = useRef(false);
148
- let t7;
149
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
150
- t7 = () => {
151
- const { contentHeight, scrollY, viewportHeight } = metricsRef.current;
152
- isAtBottomRef.current = contentHeight <= viewportHeight || contentHeight - scrollY - viewportHeight <= AT_BOTTOM_THRESHOLD;
153
- };
154
- $[1] = t7;
155
- } else t7 = $[1];
156
- const updateIsAtBottom = t7;
157
- let t8;
158
- if ($[2] !== flatListRef) {
159
- t8 = (animated) => {
160
- const { contentHeight: contentHeight_0, viewportHeight: viewportHeight_0 } = metricsRef.current;
161
- const offset = Math.max(0, contentHeight_0 - viewportHeight_0);
162
- metricsRef.current.scrollY = offset;
163
- isAtBottomRef.current = true;
164
- flatListRef.current?.scrollToOffset({
165
- offset,
166
- animated
167
- });
168
- };
169
- $[2] = flatListRef;
170
- $[3] = t8;
171
- } else t8 = $[3];
172
- const scrollToBottom = t8;
173
- let t9;
174
- if ($[4] !== autoScroll || $[5] !== horizontal || $[6] !== scrollToBottom) {
175
- t9 = (event) => {
176
- const wasAtBottom = isAtBottomRef.current;
177
- const previousViewportHeight = metricsRef.current.viewportHeight;
178
- const viewportHeight_1 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
179
- metricsRef.current.viewportHeight = viewportHeight_1;
180
- updateIsAtBottom();
181
- const pending = pendingScrollToBottomRef.current;
182
- if (pending && contentSizeVersionRef.current >= pending.minimumContentSizeVersion && viewportHeight_1 > 0) {
183
- pendingScrollToBottomRef.current = false;
184
- scrollToBottom(pending.animated);
185
- return;
186
- }
187
- if (!wasAtBottom) return;
188
- if (autoScroll && previousViewportHeight !== 0 && viewportHeight_1 !== previousViewportHeight) scrollToBottom(pending ? pending.animated : false);
189
- else isAtBottomRef.current = true;
190
- };
191
- $[4] = autoScroll;
192
- $[5] = horizontal;
193
- $[6] = scrollToBottom;
194
- $[7] = t9;
195
- } else t9 = $[7];
196
- const handleLayout = t9;
197
- let t10;
198
- if ($[8] !== horizontal) {
199
- t10 = (event_0) => {
200
- const { contentOffset, contentSize, layoutMeasurement } = event_0.nativeEvent;
201
- const scrollOffset = horizontal ? contentOffset.x : contentOffset.y;
202
- const previousEventOffset = lastScrollEventOffsetRef.current;
203
- const wasPinnedToBottom = isAtBottomRef.current;
204
- lastScrollEventOffsetRef.current = scrollOffset;
205
- metricsRef.current = {
206
- contentHeight: horizontal ? contentSize.width : contentSize.height,
207
- viewportHeight: horizontal ? layoutMeasurement.width : layoutMeasurement.height,
208
- scrollY: scrollOffset
209
- };
210
- updateIsAtBottom();
211
- const upwardMove = scrollOffset < previousEventOffset;
212
- if (wasPinnedToBottom && !upwardMove) isAtBottomRef.current = true;
213
- if (!isAtBottomRef.current && upwardMove) pendingScrollToBottomRef.current = false;
214
- };
215
- $[8] = horizontal;
216
- $[9] = t10;
217
- } else t10 = $[9];
218
- const handleScroll = t10;
219
- let t11;
220
- if ($[10] !== autoScroll || $[11] !== horizontal || $[12] !== scrollToBottom) {
221
- t11 = (width, height) => {
222
- const metrics = metricsRef.current;
223
- const contentHeight_1 = horizontal ? width : height;
224
- const previousContentHeight = metrics.contentHeight;
225
- const wasAtBottom_0 = isAtBottomRef.current;
226
- if (contentHeight_1 > 0) contentSizeVersionRef.current = contentSizeVersionRef.current + 1;
227
- metrics.contentHeight = contentHeight_1;
228
- updateIsAtBottom();
229
- const pendingScroll = pendingScrollToBottomRef.current;
230
- if (pendingScroll && contentSizeVersionRef.current >= pendingScroll.minimumContentSizeVersion && metrics.viewportHeight > 0) {
231
- pendingScrollToBottomRef.current = false;
232
- scrollToBottom(pendingScroll.animated);
233
- return;
234
- }
235
- if (!autoScroll) return;
236
- if (!wasAtBottom_0) return;
237
- if (previousContentHeight === 0) return;
238
- if (contentHeight_1 <= previousContentHeight) return;
239
- scrollToBottom(false);
240
- };
241
- $[10] = autoScroll;
242
- $[11] = horizontal;
243
- $[12] = scrollToBottom;
244
- $[13] = t11;
245
- } else t11 = $[13];
246
- const handleContentSizeChange = t11;
247
- let t12;
248
- let t13;
249
- if ($[14] !== hasMessages || $[15] !== scrollToBottom || $[16] !== scrollToBottomOnInitialize) {
250
- t12 = () => {
251
- if (!scrollToBottomOnInitialize) return;
252
- if (!hasMessages) {
253
- initializeScrollRequestedRef.current = false;
254
- return;
255
- }
256
- if (initializeScrollRequestedRef.current) return;
257
- initializeScrollRequestedRef.current = true;
258
- pendingScrollToBottomRef.current = {
259
- animated: false,
260
- minimumContentSizeVersion: Math.max(1, contentSizeVersionRef.current)
261
- };
262
- scrollToBottom(false);
263
- };
264
- t13 = [
265
- hasMessages,
266
- scrollToBottom,
267
- scrollToBottomOnInitialize
268
- ];
269
- $[14] = hasMessages;
270
- $[15] = scrollToBottom;
271
- $[16] = scrollToBottomOnInitialize;
272
- $[17] = t12;
273
- $[18] = t13;
274
- } else {
275
- t12 = $[17];
276
- t13 = $[18];
277
- }
278
- useEffect(t12, t13);
279
- let t14;
280
- if ($[19] !== scrollToBottom || $[20] !== scrollToBottomOnRunStart) {
281
- t14 = () => {
282
- if (!scrollToBottomOnRunStart) return;
283
- pendingScrollToBottomRef.current = {
284
- animated: true,
285
- minimumContentSizeVersion: contentSizeVersionRef.current + 1
286
- };
287
- scrollToBottom(true);
288
- };
289
- $[19] = scrollToBottom;
290
- $[20] = scrollToBottomOnRunStart;
291
- $[21] = t14;
292
- } else t14 = $[21];
293
- useAuiEvent("thread.runStart", t14);
294
- let t15;
295
- if ($[22] !== scrollToBottom || $[23] !== scrollToBottomOnThreadSwitch) {
296
- t15 = () => {
297
- if (!scrollToBottomOnThreadSwitch) return;
298
- initializeScrollRequestedRef.current = false;
299
- lastScrollEventOffsetRef.current = 0;
300
- pendingScrollToBottomRef.current = {
301
- animated: false,
302
- minimumContentSizeVersion: contentSizeVersionRef.current + 1
303
- };
304
- scrollToBottom(false);
305
- };
306
- $[22] = scrollToBottom;
307
- $[23] = scrollToBottomOnThreadSwitch;
308
- $[24] = t15;
309
- } else t15 = $[24];
310
- useAuiEvent("threads.selectionChanged", t15);
311
- let t16;
312
- if ($[25] !== handleContentSizeChange || $[26] !== handleLayout || $[27] !== handleScroll) {
313
- t16 = {
314
- handleLayout,
315
- handleScroll,
316
- handleContentSizeChange
317
- };
318
- $[25] = handleContentSizeChange;
319
- $[26] = handleLayout;
320
- $[27] = handleScroll;
321
- $[28] = t16;
322
- } else t16 = $[28];
323
- return t16;
324
- };
325
77
  const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
326
- const $ = c(58);
78
+ const $ = c(56);
327
79
  let autoScroll;
328
80
  let children;
329
81
  let components;
330
82
  let flatListProps;
331
83
  let history;
332
84
  let onContentSizeChange;
85
+ let onEndReached;
86
+ let onEndReachedThreshold;
333
87
  let onLayout;
334
88
  let onScroll;
335
89
  let onStartReached;
@@ -339,7 +93,7 @@ const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
339
93
  let scrollToBottomOnRunStart;
340
94
  let scrollToBottomOnThreadSwitch;
341
95
  if ($[0] !== t0) {
342
- ({autoScroll, components, children, onContentSizeChange, onLayout, onScroll, onStartReached, onStartReachedThreshold, scrollEventThrottle, scrollToBottomOnInitialize, scrollToBottomOnRunStart, scrollToBottomOnThreadSwitch, history, ...flatListProps} = t0);
96
+ ({autoScroll, components, children, onContentSizeChange, onLayout, onScroll, onStartReached, onStartReachedThreshold, onEndReached, onEndReachedThreshold, scrollEventThrottle, scrollToBottomOnInitialize, scrollToBottomOnRunStart, scrollToBottomOnThreadSwitch, history, ...flatListProps} = t0);
343
97
  $[0] = t0;
344
98
  $[1] = autoScroll;
345
99
  $[2] = children;
@@ -347,14 +101,16 @@ const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
347
101
  $[4] = flatListProps;
348
102
  $[5] = history;
349
103
  $[6] = onContentSizeChange;
350
- $[7] = onLayout;
351
- $[8] = onScroll;
352
- $[9] = onStartReached;
353
- $[10] = onStartReachedThreshold;
354
- $[11] = scrollEventThrottle;
355
- $[12] = scrollToBottomOnInitialize;
356
- $[13] = scrollToBottomOnRunStart;
357
- $[14] = scrollToBottomOnThreadSwitch;
104
+ $[7] = onEndReached;
105
+ $[8] = onEndReachedThreshold;
106
+ $[9] = onLayout;
107
+ $[10] = onScroll;
108
+ $[11] = onStartReached;
109
+ $[12] = onStartReachedThreshold;
110
+ $[13] = scrollEventThrottle;
111
+ $[14] = scrollToBottomOnInitialize;
112
+ $[15] = scrollToBottomOnRunStart;
113
+ $[16] = scrollToBottomOnThreadSwitch;
358
114
  } else {
359
115
  autoScroll = $[1];
360
116
  children = $[2];
@@ -362,20 +118,23 @@ const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
362
118
  flatListProps = $[4];
363
119
  history = $[5];
364
120
  onContentSizeChange = $[6];
365
- onLayout = $[7];
366
- onScroll = $[8];
367
- onStartReached = $[9];
368
- onStartReachedThreshold = $[10];
369
- scrollEventThrottle = $[11];
370
- scrollToBottomOnInitialize = $[12];
371
- scrollToBottomOnRunStart = $[13];
372
- scrollToBottomOnThreadSwitch = $[14];
121
+ onEndReached = $[7];
122
+ onEndReachedThreshold = $[8];
123
+ onLayout = $[9];
124
+ onScroll = $[10];
125
+ onStartReached = $[11];
126
+ onStartReachedThreshold = $[12];
127
+ scrollEventThrottle = $[13];
128
+ scrollToBottomOnInitialize = $[14];
129
+ scrollToBottomOnRunStart = $[15];
130
+ scrollToBottomOnThreadSwitch = $[16];
373
131
  }
374
132
  const messages = useAuiState(_temp3);
133
+ const effectiveHistory = useThreadHistory(history);
375
134
  const [flatListRef, setFlatListRef] = useComposedFlatListRef(forwardedRef);
376
135
  const t1 = messages.length > 0;
377
136
  let t2;
378
- if ($[15] !== autoScroll || $[16] !== flatListProps.horizontal || $[17] !== flatListRef || $[18] !== scrollToBottomOnInitialize || $[19] !== scrollToBottomOnRunStart || $[20] !== scrollToBottomOnThreadSwitch || $[21] !== t1) {
137
+ if ($[17] !== autoScroll || $[18] !== flatListProps.horizontal || $[19] !== flatListRef || $[20] !== scrollToBottomOnInitialize || $[21] !== scrollToBottomOnRunStart || $[22] !== scrollToBottomOnThreadSwitch || $[23] !== t1) {
379
138
  t2 = {
380
139
  flatListRef,
381
140
  hasMessages: t1,
@@ -385,18 +144,18 @@ const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
385
144
  scrollToBottomOnRunStart,
386
145
  scrollToBottomOnThreadSwitch
387
146
  };
388
- $[15] = autoScroll;
389
- $[16] = flatListProps.horizontal;
390
- $[17] = flatListRef;
391
- $[18] = scrollToBottomOnInitialize;
392
- $[19] = scrollToBottomOnRunStart;
393
- $[20] = scrollToBottomOnThreadSwitch;
394
- $[21] = t1;
395
- $[22] = t2;
396
- } else t2 = $[22];
397
- const { handleContentSizeChange: handleAutoScrollContentSizeChange, handleLayout: handleAutoScrollLayout, handleScroll: handleAutoScrollScroll } = useThreadMessagesFlatListAutoScroll(t2);
147
+ $[17] = autoScroll;
148
+ $[18] = flatListProps.horizontal;
149
+ $[19] = flatListRef;
150
+ $[20] = scrollToBottomOnInitialize;
151
+ $[21] = scrollToBottomOnRunStart;
152
+ $[22] = scrollToBottomOnThreadSwitch;
153
+ $[23] = t1;
154
+ $[24] = t2;
155
+ } else t2 = $[24];
156
+ const { handleContentSizeChange: handleAutoScrollContentSizeChange, handleLayout: handleAutoScrollLayout, handleScroll: handleAutoScrollScroll } = useFlatListAutoScroll(t2);
398
157
  let t3;
399
- if ($[23] !== children || $[24] !== components) {
158
+ if ($[25] !== children || $[26] !== components) {
400
159
  t3 = (t4) => {
401
160
  const { index } = t4;
402
161
  if (children) return /* @__PURE__ */ jsx(ThreadMessageByChildren, {
@@ -408,113 +167,87 @@ const ThreadMessagesFlatList = forwardRef((t0, forwardedRef) => {
408
167
  components
409
168
  });
410
169
  };
411
- $[23] = children;
412
- $[24] = components;
413
- $[25] = t3;
414
- } else t3 = $[25];
170
+ $[25] = children;
171
+ $[26] = components;
172
+ $[27] = t3;
173
+ } else t3 = $[27];
415
174
  const renderItem = t3;
416
175
  const keyExtractor = _temp4;
417
- const scrollTracking = (autoScroll ?? true) || (scrollToBottomOnInitialize ?? true) || (scrollToBottomOnRunStart ?? true) || (scrollToBottomOnThreadSwitch ?? true);
418
176
  let t4;
419
- if ($[26] !== handleAutoScrollLayout || $[27] !== onLayout) {
420
- t4 = (event) => {
421
- handleAutoScrollLayout(event);
422
- onLayout?.(event);
177
+ if ($[28] !== autoScroll || $[29] !== handleAutoScrollContentSizeChange || $[30] !== handleAutoScrollLayout || $[31] !== handleAutoScrollScroll || $[32] !== onContentSizeChange || $[33] !== onLayout || $[34] !== onScroll || $[35] !== scrollEventThrottle || $[36] !== scrollToBottomOnInitialize || $[37] !== scrollToBottomOnRunStart || $[38] !== scrollToBottomOnThreadSwitch) {
178
+ t4 = {
179
+ autoScroll,
180
+ scrollToBottomOnInitialize,
181
+ scrollToBottomOnRunStart,
182
+ scrollToBottomOnThreadSwitch,
183
+ onContentSizeChange,
184
+ onLayout,
185
+ onScroll,
186
+ scrollEventThrottle,
187
+ handleAutoScrollContentSizeChange,
188
+ handleAutoScrollLayout,
189
+ handleAutoScrollScroll
423
190
  };
424
- $[26] = handleAutoScrollLayout;
425
- $[27] = onLayout;
426
- $[28] = t4;
427
- } else t4 = $[28];
428
- const handleLayout = t4;
191
+ $[28] = autoScroll;
192
+ $[29] = handleAutoScrollContentSizeChange;
193
+ $[30] = handleAutoScrollLayout;
194
+ $[31] = handleAutoScrollScroll;
195
+ $[32] = onContentSizeChange;
196
+ $[33] = onLayout;
197
+ $[34] = onScroll;
198
+ $[35] = scrollEventThrottle;
199
+ $[36] = scrollToBottomOnInitialize;
200
+ $[37] = scrollToBottomOnRunStart;
201
+ $[38] = scrollToBottomOnThreadSwitch;
202
+ $[39] = t4;
203
+ } else t4 = $[39];
204
+ const scrollProps = useFlatListScrollProps(t4);
205
+ const { canLoadMore, handleReached } = useHistoryLoad(effectiveHistory, onStartReached);
429
206
  let t5;
430
- if ($[29] !== handleAutoScrollScroll || $[30] !== onScroll) {
431
- t5 = (event_0) => {
432
- handleAutoScrollScroll(event_0);
433
- onScroll?.(event_0);
434
- };
435
- $[29] = handleAutoScrollScroll;
436
- $[30] = onScroll;
437
- $[31] = t5;
438
- } else t5 = $[31];
439
- const handleScroll = t5;
440
- let t6;
441
- if ($[32] !== handleAutoScrollContentSizeChange || $[33] !== onContentSizeChange) {
442
- t6 = (width, height) => {
443
- handleAutoScrollContentSizeChange(width, height);
444
- onContentSizeChange?.(width, height);
445
- };
446
- $[32] = handleAutoScrollContentSizeChange;
447
- $[33] = onContentSizeChange;
448
- $[34] = t6;
449
- } else t6 = $[34];
450
- const handleContentSizeChange = t6;
451
- const { canLoadMore, handleStartReached } = useHistoryLoad(history, onStartReached);
452
- const t7 = messages;
207
+ if ($[40] !== canLoadMore || $[41] !== effectiveHistory || $[42] !== handleReached || $[43] !== onEndReached || $[44] !== onEndReachedThreshold || $[45] !== onStartReached || $[46] !== onStartReachedThreshold) {
208
+ t5 = getFlatListPagingProps("start", effectiveHistory, canLoadMore, handleReached, {
209
+ onStartReached,
210
+ onStartReachedThreshold,
211
+ onEndReached,
212
+ onEndReachedThreshold
213
+ });
214
+ $[40] = canLoadMore;
215
+ $[41] = effectiveHistory;
216
+ $[42] = handleReached;
217
+ $[43] = onEndReached;
218
+ $[44] = onEndReachedThreshold;
219
+ $[45] = onStartReached;
220
+ $[46] = onStartReachedThreshold;
221
+ $[47] = t5;
222
+ } else t5 = $[47];
223
+ const pagingProps = t5;
224
+ const t6 = messages;
225
+ let t7;
226
+ if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
227
+ t7 = { minIndexForVisible: 0 };
228
+ $[48] = t7;
229
+ } else t7 = $[48];
453
230
  let t8;
454
- if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
455
- t8 = { minIndexForVisible: 0 };
456
- $[35] = t8;
457
- } else t8 = $[35];
458
- let t9;
459
- if ($[36] !== handleContentSizeChange || $[37] !== handleLayout || $[38] !== handleScroll || $[39] !== onContentSizeChange || $[40] !== onLayout || $[41] !== onScroll || $[42] !== scrollEventThrottle || $[43] !== scrollTracking) {
460
- t9 = scrollTracking ? {
461
- onContentSizeChange: handleContentSizeChange,
462
- onLayout: handleLayout,
463
- onScroll: handleScroll,
464
- scrollEventThrottle: scrollEventThrottle ?? 16
465
- } : {
466
- ...onContentSizeChange && { onContentSizeChange },
467
- ...onLayout && { onLayout },
468
- ...onScroll && { onScroll },
469
- ...scrollEventThrottle !== void 0 && { scrollEventThrottle }
470
- };
471
- $[36] = handleContentSizeChange;
472
- $[37] = handleLayout;
473
- $[38] = handleScroll;
474
- $[39] = onContentSizeChange;
475
- $[40] = onLayout;
476
- $[41] = onScroll;
477
- $[42] = scrollEventThrottle;
478
- $[43] = scrollTracking;
479
- $[44] = t9;
480
- } else t9 = $[44];
481
- let t10;
482
- if ($[45] !== canLoadMore || $[46] !== handleStartReached || $[47] !== history || $[48] !== onStartReached || $[49] !== onStartReachedThreshold) {
483
- t10 = history ? {
484
- ...canLoadMore ? { onStartReached: handleStartReached } : onStartReached ? { onStartReached } : {},
485
- onStartReachedThreshold: onStartReachedThreshold ?? 1
486
- } : {
487
- ...onStartReached && { onStartReached },
488
- ...onStartReachedThreshold !== void 0 && { onStartReachedThreshold }
489
- };
490
- $[45] = canLoadMore;
491
- $[46] = handleStartReached;
492
- $[47] = history;
493
- $[48] = onStartReached;
494
- $[49] = onStartReachedThreshold;
495
- $[50] = t10;
496
- } else t10 = $[50];
497
- let t11;
498
- if ($[51] !== flatListProps || $[52] !== renderItem || $[53] !== setFlatListRef || $[54] !== t10 || $[55] !== t7 || $[56] !== t9) {
499
- t11 = /* @__PURE__ */ jsx(FlatList, {
231
+ if ($[49] !== flatListProps || $[50] !== pagingProps || $[51] !== renderItem || $[52] !== scrollProps || $[53] !== setFlatListRef || $[54] !== t6) {
232
+ t8 = /* @__PURE__ */ jsx(FlatList, {
500
233
  ref: setFlatListRef,
501
- data: t7,
234
+ data: t6,
502
235
  renderItem,
503
236
  keyExtractor,
504
- maintainVisibleContentPosition: t8,
505
- ...t9,
506
- ...t10,
237
+ maintainVisibleContentPosition: t7,
238
+ ...scrollProps,
239
+ ...pagingProps,
507
240
  ...flatListProps
508
241
  });
509
- $[51] = flatListProps;
510
- $[52] = renderItem;
242
+ $[49] = flatListProps;
243
+ $[50] = pagingProps;
244
+ $[51] = renderItem;
245
+ $[52] = scrollProps;
511
246
  $[53] = setFlatListRef;
512
- $[54] = t10;
513
- $[55] = t7;
514
- $[56] = t9;
515
- $[57] = t11;
516
- } else t11 = $[57];
517
- return t11;
247
+ $[54] = t6;
248
+ $[55] = t8;
249
+ } else t8 = $[55];
250
+ return t8;
518
251
  });
519
252
  ThreadMessagesFlatList.displayName = "ThreadPrimitive.MessagesFlatList";
520
253
  /** @deprecated Use ThreadPrimitive.MessagesFlatList instead. */