@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.
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/primitives/message.d.ts +1 -0
- package/dist/primitives/message.d.ts.map +1 -1
- package/dist/primitives/message.js +3 -2
- package/dist/primitives/message.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts +7 -5
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +109 -376
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadRowsFlatList.d.ts +29 -0
- package/dist/primitives/thread/ThreadRowsFlatList.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadRowsFlatList.js +226 -0
- package/dist/primitives/thread/ThreadRowsFlatList.js.map +1 -0
- package/dist/primitives/thread/flatListScroll.d.ts +52 -0
- package/dist/primitives/thread/flatListScroll.d.ts.map +1 -0
- package/dist/primitives/thread/flatListScroll.js +380 -0
- package/dist/primitives/thread/flatListScroll.js.map +1 -0
- package/dist/primitives/thread.d.ts +2 -0
- package/dist/primitives/thread.d.ts.map +1 -1
- package/dist/primitives/thread.js +5 -2
- package/dist/primitives/thread.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +18 -1
- package/src/primitives/message.test.tsx +74 -0
- package/src/primitives/message.ts +1 -0
- package/src/primitives/thread/ThreadMessages.test.tsx +28 -1
- package/src/primitives/thread/ThreadMessages.tsx +49 -343
- package/src/primitives/thread/ThreadRowsFlatList.test.tsx +253 -0
- package/src/primitives/thread/ThreadRowsFlatList.tsx +159 -0
- package/src/primitives/thread/flatListScroll.ts +467 -0
- package/src/primitives/thread.ts +5 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
+
import "react-native";
|
|
4
|
+
import { useCallback, useEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
5
|
+
//#region src/primitives/thread/flatListScroll.ts
|
|
6
|
+
const AT_BOTTOM_THRESHOLD = 4;
|
|
7
|
+
/** `history` when given, else the runtime's earlier-message paging. */
|
|
8
|
+
const useThreadHistory = (history) => {
|
|
9
|
+
const $ = c(4);
|
|
10
|
+
const aui = useAui();
|
|
11
|
+
const hasEarlier = useAuiState(_temp);
|
|
12
|
+
const isLoadingEarlier = useAuiState(_temp2);
|
|
13
|
+
let t0;
|
|
14
|
+
if ($[0] !== aui || $[1] !== hasEarlier || $[2] !== isLoadingEarlier) {
|
|
15
|
+
t0 = hasEarlier || isLoadingEarlier ? {
|
|
16
|
+
hasMore: hasEarlier,
|
|
17
|
+
isLoadingMore: isLoadingEarlier,
|
|
18
|
+
loadMore: () => {
|
|
19
|
+
aui.thread.loadEarlier();
|
|
20
|
+
}
|
|
21
|
+
} : void 0;
|
|
22
|
+
$[0] = aui;
|
|
23
|
+
$[1] = hasEarlier;
|
|
24
|
+
$[2] = isLoadingEarlier;
|
|
25
|
+
$[3] = t0;
|
|
26
|
+
} else t0 = $[3];
|
|
27
|
+
return history ?? t0;
|
|
28
|
+
};
|
|
29
|
+
const useHistoryLoad = (history, onReached) => {
|
|
30
|
+
const loadRequestedRef = useRef(false);
|
|
31
|
+
const hasMore = history?.hasMore ?? false;
|
|
32
|
+
const isLoadingMore = history?.isLoadingMore ?? false;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
loadRequestedRef.current = isLoadingMore;
|
|
35
|
+
});
|
|
36
|
+
const handleReached = useCallback((info) => {
|
|
37
|
+
onReached?.(info);
|
|
38
|
+
if (loadRequestedRef.current) return;
|
|
39
|
+
loadRequestedRef.current = true;
|
|
40
|
+
try {
|
|
41
|
+
history?.loadMore();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
loadRequestedRef.current = false;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}, [history, onReached]);
|
|
47
|
+
return {
|
|
48
|
+
canLoadMore: hasMore && !isLoadingMore,
|
|
49
|
+
handleReached
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const useFlatListScrollProps = (t0) => {
|
|
53
|
+
const $ = c(18);
|
|
54
|
+
const { autoScroll, scrollToBottomOnInitialize, scrollToBottomOnRunStart, scrollToBottomOnThreadSwitch, onLayout, onScroll, onContentSizeChange, scrollEventThrottle, handleAutoScrollLayout, handleAutoScrollScroll, handleAutoScrollContentSizeChange } = t0;
|
|
55
|
+
let t1;
|
|
56
|
+
if ($[0] !== handleAutoScrollLayout || $[1] !== onLayout) {
|
|
57
|
+
t1 = (event) => {
|
|
58
|
+
handleAutoScrollLayout(event);
|
|
59
|
+
onLayout?.(event);
|
|
60
|
+
};
|
|
61
|
+
$[0] = handleAutoScrollLayout;
|
|
62
|
+
$[1] = onLayout;
|
|
63
|
+
$[2] = t1;
|
|
64
|
+
} else t1 = $[2];
|
|
65
|
+
const handleLayout = t1;
|
|
66
|
+
let t2;
|
|
67
|
+
if ($[3] !== handleAutoScrollScroll || $[4] !== onScroll) {
|
|
68
|
+
t2 = (event_0) => {
|
|
69
|
+
handleAutoScrollScroll(event_0);
|
|
70
|
+
onScroll?.(event_0);
|
|
71
|
+
};
|
|
72
|
+
$[3] = handleAutoScrollScroll;
|
|
73
|
+
$[4] = onScroll;
|
|
74
|
+
$[5] = t2;
|
|
75
|
+
} else t2 = $[5];
|
|
76
|
+
const handleScroll = t2;
|
|
77
|
+
let t3;
|
|
78
|
+
if ($[6] !== handleAutoScrollContentSizeChange || $[7] !== onContentSizeChange) {
|
|
79
|
+
t3 = (width, height) => {
|
|
80
|
+
handleAutoScrollContentSizeChange(width, height);
|
|
81
|
+
onContentSizeChange?.(width, height);
|
|
82
|
+
};
|
|
83
|
+
$[6] = handleAutoScrollContentSizeChange;
|
|
84
|
+
$[7] = onContentSizeChange;
|
|
85
|
+
$[8] = t3;
|
|
86
|
+
} else t3 = $[8];
|
|
87
|
+
const handleContentSizeChange = t3;
|
|
88
|
+
const scrollTracking = (autoScroll ?? true) || (scrollToBottomOnInitialize ?? true) || (scrollToBottomOnRunStart ?? true) || (scrollToBottomOnThreadSwitch ?? true);
|
|
89
|
+
let t4;
|
|
90
|
+
if ($[9] !== handleContentSizeChange || $[10] !== handleLayout || $[11] !== handleScroll || $[12] !== onContentSizeChange || $[13] !== onLayout || $[14] !== onScroll || $[15] !== scrollEventThrottle || $[16] !== scrollTracking) {
|
|
91
|
+
t4 = scrollTracking ? {
|
|
92
|
+
onContentSizeChange: handleContentSizeChange,
|
|
93
|
+
onLayout: handleLayout,
|
|
94
|
+
onScroll: handleScroll,
|
|
95
|
+
scrollEventThrottle: scrollEventThrottle ?? 16
|
|
96
|
+
} : {
|
|
97
|
+
...onContentSizeChange && { onContentSizeChange },
|
|
98
|
+
...onLayout && { onLayout },
|
|
99
|
+
...onScroll && { onScroll },
|
|
100
|
+
...scrollEventThrottle !== void 0 && { scrollEventThrottle }
|
|
101
|
+
};
|
|
102
|
+
$[9] = handleContentSizeChange;
|
|
103
|
+
$[10] = handleLayout;
|
|
104
|
+
$[11] = handleScroll;
|
|
105
|
+
$[12] = onContentSizeChange;
|
|
106
|
+
$[13] = onLayout;
|
|
107
|
+
$[14] = onScroll;
|
|
108
|
+
$[15] = scrollEventThrottle;
|
|
109
|
+
$[16] = scrollTracking;
|
|
110
|
+
$[17] = t4;
|
|
111
|
+
} else t4 = $[17];
|
|
112
|
+
return t4;
|
|
113
|
+
};
|
|
114
|
+
function getFlatListPagingProps(edge, history, canLoadMore, handleReached, { onStartReached, onStartReachedThreshold, onEndReached, onEndReachedThreshold }) {
|
|
115
|
+
const startProps = history ? {
|
|
116
|
+
...canLoadMore ? { onStartReached: handleReached } : onStartReached ? { onStartReached } : {},
|
|
117
|
+
onStartReachedThreshold: onStartReachedThreshold ?? 1
|
|
118
|
+
} : {
|
|
119
|
+
...onStartReached && { onStartReached },
|
|
120
|
+
...onStartReachedThreshold !== void 0 && { onStartReachedThreshold }
|
|
121
|
+
};
|
|
122
|
+
const endProps = history ? {
|
|
123
|
+
...canLoadMore ? { onEndReached: handleReached } : onEndReached ? { onEndReached } : {},
|
|
124
|
+
onEndReachedThreshold: onEndReachedThreshold ?? 1
|
|
125
|
+
} : {
|
|
126
|
+
...onEndReached && { onEndReached },
|
|
127
|
+
...onEndReachedThreshold !== void 0 && { onEndReachedThreshold }
|
|
128
|
+
};
|
|
129
|
+
return edge === "start" ? {
|
|
130
|
+
...startProps,
|
|
131
|
+
...onEndReached && { onEndReached },
|
|
132
|
+
...onEndReachedThreshold !== void 0 && { onEndReachedThreshold }
|
|
133
|
+
} : {
|
|
134
|
+
...onStartReached && { onStartReached },
|
|
135
|
+
...onStartReachedThreshold !== void 0 && { onStartReachedThreshold },
|
|
136
|
+
...endProps
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const setForwardedRef = (ref, value) => {
|
|
140
|
+
if (typeof ref === "function") ref(value);
|
|
141
|
+
else if (ref) ref.current = value;
|
|
142
|
+
};
|
|
143
|
+
const useComposedFlatListRef = (forwardedRef) => {
|
|
144
|
+
const $ = c(4);
|
|
145
|
+
const flatListRef = useRef(null);
|
|
146
|
+
let t0;
|
|
147
|
+
if ($[0] !== forwardedRef) {
|
|
148
|
+
t0 = (node) => {
|
|
149
|
+
flatListRef.current = node;
|
|
150
|
+
setForwardedRef(forwardedRef, node);
|
|
151
|
+
};
|
|
152
|
+
$[0] = forwardedRef;
|
|
153
|
+
$[1] = t0;
|
|
154
|
+
} else t0 = $[1];
|
|
155
|
+
const setFlatListRef = t0;
|
|
156
|
+
let t1;
|
|
157
|
+
if ($[2] !== setFlatListRef) {
|
|
158
|
+
t1 = [flatListRef, setFlatListRef];
|
|
159
|
+
$[2] = setFlatListRef;
|
|
160
|
+
$[3] = t1;
|
|
161
|
+
} else t1 = $[3];
|
|
162
|
+
return t1;
|
|
163
|
+
};
|
|
164
|
+
const useFlatListAutoScroll = (t0) => {
|
|
165
|
+
const $ = c(35);
|
|
166
|
+
const { flatListRef, hasMessages, inverted: t1, horizontal: t2, autoScroll: t3, scrollToBottomOnRunStart: t4, scrollToBottomOnInitialize: t5, scrollToBottomOnThreadSwitch: t6 } = t0;
|
|
167
|
+
const inverted = t1 === void 0 ? false : t1;
|
|
168
|
+
const horizontal = t2 === void 0 ? false : t2;
|
|
169
|
+
const autoScroll = t3 === void 0 ? true : t3;
|
|
170
|
+
const scrollToBottomOnRunStart = t4 === void 0 ? true : t4;
|
|
171
|
+
const scrollToBottomOnInitialize = t5 === void 0 ? true : t5;
|
|
172
|
+
const scrollToBottomOnThreadSwitch = t6 === void 0 ? true : t6;
|
|
173
|
+
let t7;
|
|
174
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
175
|
+
t7 = {
|
|
176
|
+
contentHeight: 0,
|
|
177
|
+
viewportHeight: 0,
|
|
178
|
+
scrollY: 0
|
|
179
|
+
};
|
|
180
|
+
$[0] = t7;
|
|
181
|
+
} else t7 = $[0];
|
|
182
|
+
const metricsRef = useRef(t7);
|
|
183
|
+
const isAtBottomRef = useRef(true);
|
|
184
|
+
const lastScrollEventOffsetRef = useRef(0);
|
|
185
|
+
const initializeScrollRequestedRef = useRef(false);
|
|
186
|
+
const contentSizeVersionRef = useRef(0);
|
|
187
|
+
const pendingScrollToBottomRef = useRef(false);
|
|
188
|
+
let t8;
|
|
189
|
+
if ($[1] !== inverted) {
|
|
190
|
+
t8 = () => {
|
|
191
|
+
const { contentHeight, scrollY, viewportHeight } = metricsRef.current;
|
|
192
|
+
isAtBottomRef.current = inverted ? scrollY <= AT_BOTTOM_THRESHOLD : contentHeight <= viewportHeight || contentHeight - scrollY - viewportHeight <= AT_BOTTOM_THRESHOLD;
|
|
193
|
+
};
|
|
194
|
+
$[1] = inverted;
|
|
195
|
+
$[2] = t8;
|
|
196
|
+
} else t8 = $[2];
|
|
197
|
+
const updateIsAtBottom = t8;
|
|
198
|
+
let t9;
|
|
199
|
+
if ($[3] !== flatListRef || $[4] !== inverted) {
|
|
200
|
+
t9 = (animated) => {
|
|
201
|
+
const { contentHeight: contentHeight_0, viewportHeight: viewportHeight_0 } = metricsRef.current;
|
|
202
|
+
const offset = inverted ? 0 : Math.max(0, contentHeight_0 - viewportHeight_0);
|
|
203
|
+
metricsRef.current.scrollY = offset;
|
|
204
|
+
isAtBottomRef.current = true;
|
|
205
|
+
flatListRef.current?.scrollToOffset({
|
|
206
|
+
offset,
|
|
207
|
+
animated
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
$[3] = flatListRef;
|
|
211
|
+
$[4] = inverted;
|
|
212
|
+
$[5] = t9;
|
|
213
|
+
} else t9 = $[5];
|
|
214
|
+
const scrollToBottom = t9;
|
|
215
|
+
let t10;
|
|
216
|
+
if ($[6] !== autoScroll || $[7] !== horizontal || $[8] !== scrollToBottom || $[9] !== updateIsAtBottom) {
|
|
217
|
+
t10 = (event) => {
|
|
218
|
+
const wasAtBottom = isAtBottomRef.current;
|
|
219
|
+
const previousViewportHeight = metricsRef.current.viewportHeight;
|
|
220
|
+
const viewportHeight_1 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
|
|
221
|
+
metricsRef.current.viewportHeight = viewportHeight_1;
|
|
222
|
+
updateIsAtBottom();
|
|
223
|
+
const pending = pendingScrollToBottomRef.current;
|
|
224
|
+
if (pending && contentSizeVersionRef.current >= pending.minimumContentSizeVersion && viewportHeight_1 > 0) {
|
|
225
|
+
pendingScrollToBottomRef.current = false;
|
|
226
|
+
scrollToBottom(pending.animated);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!wasAtBottom) return;
|
|
230
|
+
if (autoScroll && previousViewportHeight !== 0 && viewportHeight_1 !== previousViewportHeight) scrollToBottom(pending ? pending.animated : false);
|
|
231
|
+
else isAtBottomRef.current = true;
|
|
232
|
+
};
|
|
233
|
+
$[6] = autoScroll;
|
|
234
|
+
$[7] = horizontal;
|
|
235
|
+
$[8] = scrollToBottom;
|
|
236
|
+
$[9] = updateIsAtBottom;
|
|
237
|
+
$[10] = t10;
|
|
238
|
+
} else t10 = $[10];
|
|
239
|
+
const handleLayout = t10;
|
|
240
|
+
let t11;
|
|
241
|
+
if ($[11] !== horizontal || $[12] !== inverted || $[13] !== updateIsAtBottom) {
|
|
242
|
+
t11 = (event_0) => {
|
|
243
|
+
const { contentOffset, contentSize, layoutMeasurement } = event_0.nativeEvent;
|
|
244
|
+
const scrollOffset = horizontal ? contentOffset.x : contentOffset.y;
|
|
245
|
+
const previousEventOffset = lastScrollEventOffsetRef.current;
|
|
246
|
+
const wasPinnedToBottom = isAtBottomRef.current;
|
|
247
|
+
lastScrollEventOffsetRef.current = scrollOffset;
|
|
248
|
+
metricsRef.current = {
|
|
249
|
+
contentHeight: horizontal ? contentSize.width : contentSize.height,
|
|
250
|
+
viewportHeight: horizontal ? layoutMeasurement.width : layoutMeasurement.height,
|
|
251
|
+
scrollY: scrollOffset
|
|
252
|
+
};
|
|
253
|
+
updateIsAtBottom();
|
|
254
|
+
const upwardMove = inverted ? scrollOffset > previousEventOffset : scrollOffset < previousEventOffset;
|
|
255
|
+
if (wasPinnedToBottom && !upwardMove) isAtBottomRef.current = true;
|
|
256
|
+
if (!isAtBottomRef.current && upwardMove) pendingScrollToBottomRef.current = false;
|
|
257
|
+
};
|
|
258
|
+
$[11] = horizontal;
|
|
259
|
+
$[12] = inverted;
|
|
260
|
+
$[13] = updateIsAtBottom;
|
|
261
|
+
$[14] = t11;
|
|
262
|
+
} else t11 = $[14];
|
|
263
|
+
const handleScroll = t11;
|
|
264
|
+
let t12;
|
|
265
|
+
if ($[15] !== autoScroll || $[16] !== horizontal || $[17] !== scrollToBottom || $[18] !== updateIsAtBottom) {
|
|
266
|
+
t12 = (width, height) => {
|
|
267
|
+
const metrics = metricsRef.current;
|
|
268
|
+
const contentHeight_1 = horizontal ? width : height;
|
|
269
|
+
const previousContentHeight = metrics.contentHeight;
|
|
270
|
+
const wasAtBottom_0 = isAtBottomRef.current;
|
|
271
|
+
if (contentHeight_1 > 0) contentSizeVersionRef.current = contentSizeVersionRef.current + 1;
|
|
272
|
+
metrics.contentHeight = contentHeight_1;
|
|
273
|
+
updateIsAtBottom();
|
|
274
|
+
const pendingScroll = pendingScrollToBottomRef.current;
|
|
275
|
+
if (pendingScroll && contentSizeVersionRef.current >= pendingScroll.minimumContentSizeVersion && metrics.viewportHeight > 0) {
|
|
276
|
+
pendingScrollToBottomRef.current = false;
|
|
277
|
+
scrollToBottom(pendingScroll.animated);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!autoScroll) return;
|
|
281
|
+
if (!wasAtBottom_0) return;
|
|
282
|
+
if (previousContentHeight === 0) return;
|
|
283
|
+
if (contentHeight_1 <= previousContentHeight) return;
|
|
284
|
+
scrollToBottom(false);
|
|
285
|
+
};
|
|
286
|
+
$[15] = autoScroll;
|
|
287
|
+
$[16] = horizontal;
|
|
288
|
+
$[17] = scrollToBottom;
|
|
289
|
+
$[18] = updateIsAtBottom;
|
|
290
|
+
$[19] = t12;
|
|
291
|
+
} else t12 = $[19];
|
|
292
|
+
const handleContentSizeChange = t12;
|
|
293
|
+
let t13;
|
|
294
|
+
let t14;
|
|
295
|
+
if ($[20] !== hasMessages || $[21] !== scrollToBottom || $[22] !== scrollToBottomOnInitialize) {
|
|
296
|
+
t13 = () => {
|
|
297
|
+
if (!scrollToBottomOnInitialize) return;
|
|
298
|
+
if (!hasMessages) {
|
|
299
|
+
initializeScrollRequestedRef.current = false;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (initializeScrollRequestedRef.current) return;
|
|
303
|
+
initializeScrollRequestedRef.current = true;
|
|
304
|
+
pendingScrollToBottomRef.current = {
|
|
305
|
+
animated: false,
|
|
306
|
+
minimumContentSizeVersion: Math.max(1, contentSizeVersionRef.current)
|
|
307
|
+
};
|
|
308
|
+
scrollToBottom(false);
|
|
309
|
+
};
|
|
310
|
+
t14 = [
|
|
311
|
+
hasMessages,
|
|
312
|
+
scrollToBottom,
|
|
313
|
+
scrollToBottomOnInitialize
|
|
314
|
+
];
|
|
315
|
+
$[20] = hasMessages;
|
|
316
|
+
$[21] = scrollToBottom;
|
|
317
|
+
$[22] = scrollToBottomOnInitialize;
|
|
318
|
+
$[23] = t13;
|
|
319
|
+
$[24] = t14;
|
|
320
|
+
} else {
|
|
321
|
+
t13 = $[23];
|
|
322
|
+
t14 = $[24];
|
|
323
|
+
}
|
|
324
|
+
useEffect(t13, t14);
|
|
325
|
+
let t15;
|
|
326
|
+
if ($[25] !== scrollToBottom || $[26] !== scrollToBottomOnRunStart) {
|
|
327
|
+
t15 = () => {
|
|
328
|
+
if (!scrollToBottomOnRunStart) return;
|
|
329
|
+
pendingScrollToBottomRef.current = {
|
|
330
|
+
animated: true,
|
|
331
|
+
minimumContentSizeVersion: contentSizeVersionRef.current + 1
|
|
332
|
+
};
|
|
333
|
+
scrollToBottom(true);
|
|
334
|
+
};
|
|
335
|
+
$[25] = scrollToBottom;
|
|
336
|
+
$[26] = scrollToBottomOnRunStart;
|
|
337
|
+
$[27] = t15;
|
|
338
|
+
} else t15 = $[27];
|
|
339
|
+
useAuiEvent("thread.runStart", t15);
|
|
340
|
+
let t16;
|
|
341
|
+
if ($[28] !== scrollToBottom || $[29] !== scrollToBottomOnThreadSwitch) {
|
|
342
|
+
t16 = () => {
|
|
343
|
+
if (!scrollToBottomOnThreadSwitch) return;
|
|
344
|
+
initializeScrollRequestedRef.current = false;
|
|
345
|
+
lastScrollEventOffsetRef.current = 0;
|
|
346
|
+
pendingScrollToBottomRef.current = {
|
|
347
|
+
animated: false,
|
|
348
|
+
minimumContentSizeVersion: contentSizeVersionRef.current + 1
|
|
349
|
+
};
|
|
350
|
+
scrollToBottom(false);
|
|
351
|
+
};
|
|
352
|
+
$[28] = scrollToBottom;
|
|
353
|
+
$[29] = scrollToBottomOnThreadSwitch;
|
|
354
|
+
$[30] = t16;
|
|
355
|
+
} else t16 = $[30];
|
|
356
|
+
useAuiEvent("threads.selectionChanged", t16);
|
|
357
|
+
let t17;
|
|
358
|
+
if ($[31] !== handleContentSizeChange || $[32] !== handleLayout || $[33] !== handleScroll) {
|
|
359
|
+
t17 = {
|
|
360
|
+
handleLayout,
|
|
361
|
+
handleScroll,
|
|
362
|
+
handleContentSizeChange
|
|
363
|
+
};
|
|
364
|
+
$[31] = handleContentSizeChange;
|
|
365
|
+
$[32] = handleLayout;
|
|
366
|
+
$[33] = handleScroll;
|
|
367
|
+
$[34] = t17;
|
|
368
|
+
} else t17 = $[34];
|
|
369
|
+
return t17;
|
|
370
|
+
};
|
|
371
|
+
function _temp(s) {
|
|
372
|
+
return s.thread.hasEarlier;
|
|
373
|
+
}
|
|
374
|
+
function _temp2(s_0) {
|
|
375
|
+
return s_0.thread.isLoadingEarlier;
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
export { getFlatListPagingProps, setForwardedRef, useComposedFlatListRef, useFlatListAutoScroll, useFlatListScrollProps, useHistoryLoad, useThreadHistory };
|
|
379
|
+
|
|
380
|
+
//# sourceMappingURL=flatListScroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatListScroll.js","names":["ForwardedRef","RefObject","useCallback","useEffect","useMemo","useRef","FlatList","FlatListProps","LayoutChangeEvent","NativeScrollEvent","NativeSyntheticEvent","useAui","useAuiEvent","useAuiState","FlatListHistory","hasMore","isLoadingMore","loadMore","AT_BOTTOM_THRESHOLD","useThreadHistory","history","$","_c","aui","hasEarlier","_temp","isLoadingEarlier","_temp2","t0","thread","loadEarlier","undefined","runtimeHistory","useHistoryLoad","onReached","info","TInfo","loadRequestedRef","current","handleReached","error","canLoadMore","ScrollProps","Pick","useFlatListScrollProps","autoScroll","scrollToBottomOnInitialize","scrollToBottomOnRunStart","scrollToBottomOnThreadSwitch","onLayout","onScroll","onContentSizeChange","scrollEventThrottle","handleAutoScrollLayout","handleAutoScrollScroll","handleAutoScrollContentSizeChange","t1","event","handleLayout","t2","event_0","handleScroll","t3","width","height","handleContentSizeChange","scrollTracking","t4","PagingProps","T","StartReached","NonNullable","EndReached","getFlatListPagingProps","edge","userProps","onStartReached","onStartReachedThreshold","onEndReached","onEndReachedThreshold","startProps","endProps","setForwardedRef","ref","value","useComposedFlatListRef","forwardedRef","flatListRef","node","setFlatListRef","const","useFlatListAutoScroll","hasMessages","inverted","horizontal","t5","t6","t7","Symbol","for","contentHeight","viewportHeight","scrollY","metricsRef","isAtBottomRef","lastScrollEventOffsetRef","initializeScrollRequestedRef","contentSizeVersionRef","pendingScrollToBottomRef","t8","updateIsAtBottom","t9","animated","contentHeight_0","viewportHeight_0","offset","Math","max","scrollToOffset","scrollToBottom","t10","wasAtBottom","previousViewportHeight","viewportHeight_1","nativeEvent","layout","pending","minimumContentSizeVersion","t11","contentOffset","contentSize","layoutMeasurement","scrollOffset","x","y","previousEventOffset","wasPinnedToBottom","upwardMove","t12","metrics","contentHeight_1","previousContentHeight","wasAtBottom_0","pendingScroll","t13","t14","t15","t16","t17","s","s_0","_c","runtimeHistory"],"sources":["../../../src/primitives/thread/flatListScroll.ts"],"sourcesContent":["import {\n type ForwardedRef,\n type RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n type FlatList,\n type FlatListProps,\n type LayoutChangeEvent,\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n} from \"react-native\";\nimport { useAui, useAuiEvent, useAuiState } from \"@assistant-ui/store\";\n\nexport type FlatListHistory = {\n hasMore: boolean;\n isLoadingMore: boolean;\n loadMore: () => void;\n};\n\nconst AT_BOTTOM_THRESHOLD = 4;\n\n/** `history` when given, else the runtime's earlier-message paging. */\nexport const useThreadHistory = (history: FlatListHistory | undefined) => {\n const aui = useAui();\n const hasEarlier = useAuiState((s) => s.thread.hasEarlier);\n const isLoadingEarlier = useAuiState((s) => s.thread.isLoadingEarlier);\n const runtimeHistory = useMemo<FlatListHistory | undefined>(\n () =>\n hasEarlier || isLoadingEarlier\n ? {\n hasMore: hasEarlier,\n isLoadingMore: isLoadingEarlier,\n loadMore: () => {\n void aui.thread.loadEarlier();\n },\n }\n : undefined,\n [aui, hasEarlier, isLoadingEarlier],\n );\n return history ?? runtimeHistory;\n};\n\nexport const useHistoryLoad = <TInfo>(\n history: FlatListHistory | undefined,\n onReached: ((info: TInfo) => void) | undefined,\n) => {\n const loadRequestedRef = useRef(false);\n const hasMore = history?.hasMore ?? false;\n const isLoadingMore = history?.isLoadingMore ?? false;\n\n // The latch is scoped to one commit so a no-op load cannot disable paging.\n useEffect(() => {\n loadRequestedRef.current = isLoadingMore;\n });\n\n const handleReached = useCallback(\n (info: TInfo) => {\n onReached?.(info);\n if (loadRequestedRef.current) return;\n loadRequestedRef.current = true;\n try {\n history?.loadMore();\n } catch (error) {\n loadRequestedRef.current = false;\n throw error;\n }\n },\n [history, onReached],\n );\n\n return {\n canLoadMore: hasMore && !isLoadingMore,\n handleReached,\n };\n};\n\ntype ScrollProps = Pick<\n FlatListProps<unknown>,\n \"onLayout\" | \"onScroll\" | \"onContentSizeChange\" | \"scrollEventThrottle\"\n>;\n\nexport const useFlatListScrollProps = ({\n autoScroll,\n scrollToBottomOnInitialize,\n scrollToBottomOnRunStart,\n scrollToBottomOnThreadSwitch,\n onLayout,\n onScroll,\n onContentSizeChange,\n scrollEventThrottle,\n handleAutoScrollLayout,\n handleAutoScrollScroll,\n handleAutoScrollContentSizeChange,\n}: ScrollProps & {\n autoScroll: boolean | undefined;\n scrollToBottomOnInitialize: boolean | undefined;\n scrollToBottomOnRunStart: boolean | undefined;\n scrollToBottomOnThreadSwitch: boolean | undefined;\n handleAutoScrollLayout: NonNullable<ScrollProps[\"onLayout\"]>;\n handleAutoScrollScroll: NonNullable<ScrollProps[\"onScroll\"]>;\n handleAutoScrollContentSizeChange: NonNullable<\n ScrollProps[\"onContentSizeChange\"]\n >;\n}) => {\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n handleAutoScrollLayout(event);\n onLayout?.(event);\n },\n [handleAutoScrollLayout, onLayout],\n );\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n handleAutoScrollScroll(event);\n onScroll?.(event);\n },\n [handleAutoScrollScroll, onScroll],\n );\n const handleContentSizeChange = useCallback(\n (width: number, height: number) => {\n handleAutoScrollContentSizeChange(width, height);\n onContentSizeChange?.(width, height);\n },\n [handleAutoScrollContentSizeChange, onContentSizeChange],\n );\n\n const scrollTracking =\n (autoScroll ?? true) ||\n (scrollToBottomOnInitialize ?? true) ||\n (scrollToBottomOnRunStart ?? true) ||\n (scrollToBottomOnThreadSwitch ?? true);\n\n return scrollTracking\n ? {\n onContentSizeChange: handleContentSizeChange,\n onLayout: handleLayout,\n onScroll: handleScroll,\n scrollEventThrottle: scrollEventThrottle ?? 16,\n }\n : {\n ...(onContentSizeChange && { onContentSizeChange }),\n ...(onLayout && { onLayout }),\n ...(onScroll && { onScroll }),\n ...(scrollEventThrottle !== undefined && { scrollEventThrottle }),\n };\n};\n\ntype PagingProps<T> = Pick<\n FlatListProps<T>,\n | \"onStartReached\"\n | \"onStartReachedThreshold\"\n | \"onEndReached\"\n | \"onEndReachedThreshold\"\n>;\n\ntype StartReached = NonNullable<FlatListProps<unknown>[\"onStartReached\"]>;\ntype EndReached = NonNullable<FlatListProps<unknown>[\"onEndReached\"]>;\n\nexport function getFlatListPagingProps<T>(\n edge: \"start\",\n history: FlatListHistory | undefined,\n canLoadMore: boolean,\n handleReached: StartReached,\n userProps: PagingProps<T>,\n): PagingProps<T>;\nexport function getFlatListPagingProps<T>(\n edge: \"end\",\n history: FlatListHistory | undefined,\n canLoadMore: boolean,\n handleReached: EndReached,\n userProps: PagingProps<T>,\n): PagingProps<T>;\nexport function getFlatListPagingProps<T>(\n edge: \"start\" | \"end\",\n history: FlatListHistory | undefined,\n canLoadMore: boolean,\n handleReached: StartReached & EndReached,\n userProps: PagingProps<T>,\n): PagingProps<T>;\nexport function getFlatListPagingProps<T>(\n edge: \"start\" | \"end\",\n history: FlatListHistory | undefined,\n canLoadMore: boolean,\n handleReached: StartReached | EndReached,\n {\n onStartReached,\n onStartReachedThreshold,\n onEndReached,\n onEndReachedThreshold,\n }: PagingProps<T>,\n): PagingProps<T> {\n const startProps = history\n ? {\n ...(canLoadMore\n ? { onStartReached: handleReached as StartReached }\n : onStartReached\n ? { onStartReached }\n : {}),\n onStartReachedThreshold: onStartReachedThreshold ?? 1,\n }\n : {\n ...(onStartReached && { onStartReached }),\n ...(onStartReachedThreshold !== undefined && {\n onStartReachedThreshold,\n }),\n };\n const endProps = history\n ? {\n ...(canLoadMore\n ? { onEndReached: handleReached as EndReached }\n : onEndReached\n ? { onEndReached }\n : {}),\n onEndReachedThreshold: onEndReachedThreshold ?? 1,\n }\n : {\n ...(onEndReached && { onEndReached }),\n ...(onEndReachedThreshold !== undefined && { onEndReachedThreshold }),\n };\n\n return edge === \"start\"\n ? {\n ...startProps,\n ...(onEndReached && { onEndReached }),\n ...(onEndReachedThreshold !== undefined && { onEndReachedThreshold }),\n }\n : {\n ...(onStartReached && { onStartReached }),\n ...(onStartReachedThreshold !== undefined && {\n onStartReachedThreshold,\n }),\n ...endProps,\n };\n}\n\nexport const setForwardedRef = <T>(ref: ForwardedRef<T>, value: T | null) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const useComposedFlatListRef = <T>(\n forwardedRef: ForwardedRef<FlatList<T>>,\n) => {\n const flatListRef = useRef<FlatList<T> | null>(null);\n\n const setFlatListRef = useCallback(\n (node: FlatList<T> | null) => {\n flatListRef.current = node;\n setForwardedRef(forwardedRef, node);\n },\n [forwardedRef],\n );\n\n return [flatListRef, setFlatListRef] as const;\n};\n\nexport const useFlatListAutoScroll = <T>({\n flatListRef,\n hasMessages,\n inverted = false,\n horizontal = false,\n autoScroll = true,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: {\n flatListRef: RefObject<FlatList<T> | null>;\n hasMessages: boolean;\n inverted?: boolean | undefined;\n horizontal?: boolean | null | undefined;\n autoScroll?: boolean | undefined;\n scrollToBottomOnRunStart?: boolean | undefined;\n scrollToBottomOnInitialize?: boolean | undefined;\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n}) => {\n const metricsRef = useRef({\n contentHeight: 0,\n viewportHeight: 0,\n scrollY: 0,\n });\n const isAtBottomRef = useRef(true);\n const lastScrollEventOffsetRef = useRef(0);\n const initializeScrollRequestedRef = useRef(false);\n const contentSizeVersionRef = useRef(0);\n const pendingScrollToBottomRef = useRef<\n | false\n | {\n animated: boolean;\n minimumContentSizeVersion: number;\n }\n >(false);\n\n const updateIsAtBottom = useCallback(() => {\n const { contentHeight, scrollY, viewportHeight } = metricsRef.current;\n isAtBottomRef.current = inverted\n ? scrollY <= AT_BOTTOM_THRESHOLD\n : contentHeight <= viewportHeight ||\n contentHeight - scrollY - viewportHeight <= AT_BOTTOM_THRESHOLD;\n }, [inverted]);\n\n // Commanding a scroll records the intended position immediately; the\n // native scroll echo is bridged and throttled, so waiting for it lets a\n // fast stream observe stale metrics and drop out of following.\n const scrollToBottom = useCallback(\n (animated: boolean) => {\n const { contentHeight, viewportHeight } = metricsRef.current;\n const offset = inverted ? 0 : Math.max(0, contentHeight - viewportHeight);\n metricsRef.current.scrollY = offset;\n isAtBottomRef.current = true;\n flatListRef.current?.scrollToOffset({ offset, animated });\n },\n [flatListRef, inverted],\n );\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n const wasAtBottom = isAtBottomRef.current;\n const previousViewportHeight = metricsRef.current.viewportHeight;\n const viewportHeight = horizontal\n ? event.nativeEvent.layout.width\n : event.nativeEvent.layout.height;\n metricsRef.current.viewportHeight = viewportHeight;\n updateIsAtBottom();\n const pending = pendingScrollToBottomRef.current;\n if (\n pending &&\n contentSizeVersionRef.current >= pending.minimumContentSizeVersion &&\n viewportHeight > 0\n ) {\n pendingScrollToBottomRef.current = false;\n scrollToBottom(pending.animated);\n return;\n }\n if (!wasAtBottom) return;\n // Layout changes are never user gestures, so they must not unpin. Past\n // the first measurement, a viewport change while pinned re-commands the\n // bottom position, since no content-size event follows a bare keyboard\n // open or close.\n if (\n autoScroll &&\n previousViewportHeight !== 0 &&\n viewportHeight !== previousViewportHeight\n ) {\n scrollToBottom(pending ? pending.animated : false);\n } else {\n isAtBottomRef.current = true;\n }\n },\n [autoScroll, horizontal, scrollToBottom, updateIsAtBottom],\n );\n\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n const { contentOffset, contentSize, layoutMeasurement } =\n event.nativeEvent;\n const scrollOffset = horizontal ? contentOffset.x : contentOffset.y;\n const previousEventOffset = lastScrollEventOffsetRef.current;\n const wasPinnedToBottom = isAtBottomRef.current;\n lastScrollEventOffsetRef.current = scrollOffset;\n metricsRef.current = {\n contentHeight: horizontal ? contentSize.width : contentSize.height,\n viewportHeight: horizontal\n ? layoutMeasurement.width\n : layoutMeasurement.height,\n scrollY: scrollOffset,\n };\n updateIsAtBottom();\n const upwardMove = inverted\n ? scrollOffset > previousEventOffset\n : scrollOffset < previousEventOffset;\n // Only a deliberate move away from the bottom unpins or cancels a pending scroll.\n // Gestures are detected echo-to-echo because a commanded scroll\n // optimistically moves the tracked position ahead of its ascending\n // animation echoes, and those echoes must not unpin mid-flight.\n if (wasPinnedToBottom && !upwardMove) {\n isAtBottomRef.current = true;\n }\n if (!isAtBottomRef.current && upwardMove) {\n pendingScrollToBottomRef.current = false;\n }\n },\n [horizontal, inverted, updateIsAtBottom],\n );\n\n const handleContentSizeChange = useCallback(\n (width: number, height: number) => {\n const metrics = metricsRef.current;\n const contentHeight = horizontal ? width : height;\n const previousContentHeight = metrics.contentHeight;\n const wasAtBottom = isAtBottomRef.current;\n if (contentHeight > 0) contentSizeVersionRef.current += 1;\n metrics.contentHeight = contentHeight;\n updateIsAtBottom();\n\n // Initialize and thread-switch requests are repeated after the list has\n // measured so the explicit bottom offset uses real content metrics.\n const pendingScroll = pendingScrollToBottomRef.current;\n if (\n pendingScroll &&\n contentSizeVersionRef.current >=\n pendingScroll.minimumContentSizeVersion &&\n metrics.viewportHeight > 0\n ) {\n pendingScrollToBottomRef.current = false;\n scrollToBottom(pendingScroll.animated);\n return;\n }\n\n if (!autoScroll) return;\n if (!wasAtBottom) return;\n if (previousContentHeight === 0) return;\n if (contentHeight <= previousContentHeight) return;\n\n scrollToBottom(false);\n },\n [autoScroll, horizontal, scrollToBottom, updateIsAtBottom],\n );\n\n useEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n pendingScrollToBottomRef.current = {\n animated: false,\n minimumContentSizeVersion: Math.max(1, contentSizeVersionRef.current),\n };\n scrollToBottom(false);\n }, [hasMessages, scrollToBottom, scrollToBottomOnInitialize]);\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n pendingScrollToBottomRef.current = {\n animated: true,\n minimumContentSizeVersion: contentSizeVersionRef.current + 1,\n };\n scrollToBottom(true);\n });\n\n useAuiEvent(\"threads.selectionChanged\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n initializeScrollRequestedRef.current = false;\n lastScrollEventOffsetRef.current = 0;\n pendingScrollToBottomRef.current = {\n animated: false,\n minimumContentSizeVersion: contentSizeVersionRef.current + 1,\n };\n scrollToBottom(false);\n });\n\n return {\n handleLayout,\n handleScroll,\n handleContentSizeChange,\n };\n};\n"],"mappings":";;;;;AAuBA,MAAMkB,sBAAsB;;AAG5B,MAAaC,oBAAmBC,YAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAC9B,MAAAC,MAAYZ,OAAO;CACnB,MAAAa,aAAmBX,YAAYY,KAA0B;CACzD,M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;EAAC5C,EAAA,MAAA4C;EAAA5C,EAAA,MAAAqC;EAAArC,EAAA,MAAAwC;EAAAxC,EAAA,MAAA+H;CAAA,OAAAA,MAAA/H,EAAA;CAAA,OAJM+H;AAIN;AAvb6B,SAAA3H,MAAA4H,GAAA;CAAA,OAEQA,EAACxH,OAAOL;AAAW;AAF3B,SAAAG,OAAA2H,KAAA;CAAA,OAGcD,IAACxH,OAAOH;AAAiB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { ThreadRoot as Root, type ThreadRootProps as RootProps, } from "./thread/ThreadRoot.js";
|
|
2
2
|
export { ThreadMessagesFlatList as MessagesFlatList, type ThreadMessagesFlatListProps as MessagesFlatListProps, ThreadMessages as Messages, type ThreadMessagesProps as MessagesProps, } from "./thread/ThreadMessages.js";
|
|
3
3
|
export { ThreadPrimitiveMessageByIndex as MessageByIndex } from "@assistant-ui/core/react";
|
|
4
|
+
export { ThreadPrimitiveRow as Row } from "@assistant-ui/core/react";
|
|
5
|
+
export { ThreadRowsFlatList as RowsFlatList, type ThreadRowsFlatListProps as RowsFlatListProps, } from "./thread/ThreadRowsFlatList.js";
|
|
4
6
|
export { ThreadPrimitiveUnstable_MessageById as Unstable_MessageById } from "@assistant-ui/core/react";
|
|
5
7
|
export { ThreadEmpty as Empty, type ThreadEmptyProps as EmptyProps, } from "./thread/ThreadEmpty.js";
|
|
6
8
|
export { ThreadIf as If, type ThreadIfProps as IfProps, } from "./thread/ThreadIf.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/primitives/thread.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,IAAI,EAClB,KAAK,eAAe,IAAI,SAAS,GAClC,+BAA4B;AAC7B,OAAO,EACL,sBAAsB,IAAI,gBAAgB,EAC1C,KAAK,2BAA2B,IAAI,qBAAqB,EACzD,cAAc,IAAI,QAAQ,EAC1B,KAAK,mBAAmB,IAAI,aAAa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AI,OAAO,GAC9B,6BAA0B;AAC3B,OAAO,EACL,gBAAgB,IAAI,UAAU,EAC9B,KAAK,qBAAqB,IAAI,eAAe,GAC9C,qCAAkC;AACnC,OAAO,EACL,0BAA0B,IAAI,WAAW,EACzC,gCAAgC,IAAI,iBAAiB,GACtD,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { ThreadRoot } from "./thread/ThreadRoot.js";
|
|
3
3
|
import { ThreadMessages, ThreadMessagesFlatList } from "./thread/ThreadMessages.js";
|
|
4
|
+
import { ThreadRowsFlatList } from "./thread/ThreadRowsFlatList.js";
|
|
4
5
|
import { ThreadEmpty } from "./thread/ThreadEmpty.js";
|
|
5
6
|
import { ThreadIf } from "./thread/ThreadIf.js";
|
|
6
7
|
import { ThreadSuggestion } from "./thread/ThreadSuggestion.js";
|
|
7
|
-
import { ThreadPrimitiveMessageByIndex as MessageByIndex, ThreadPrimitiveSuggestionByIndex as SuggestionByIndex, ThreadPrimitiveSuggestions as Suggestions, ThreadPrimitiveUnstable_MessageById as Unstable_MessageById } from "@assistant-ui/core/react";
|
|
8
|
+
import { ThreadPrimitiveMessageByIndex as MessageByIndex, ThreadPrimitiveRow as Row, ThreadPrimitiveSuggestionByIndex as SuggestionByIndex, ThreadPrimitiveSuggestions as Suggestions, ThreadPrimitiveUnstable_MessageById as Unstable_MessageById } from "@assistant-ui/core/react";
|
|
8
9
|
//#region src/primitives/thread.ts
|
|
9
10
|
var thread_exports = /* @__PURE__ */ __exportAll({
|
|
10
11
|
Empty: () => ThreadEmpty,
|
|
@@ -13,12 +14,14 @@ var thread_exports = /* @__PURE__ */ __exportAll({
|
|
|
13
14
|
Messages: () => ThreadMessages,
|
|
14
15
|
MessagesFlatList: () => ThreadMessagesFlatList,
|
|
15
16
|
Root: () => ThreadRoot,
|
|
17
|
+
Row: () => Row,
|
|
18
|
+
RowsFlatList: () => ThreadRowsFlatList,
|
|
16
19
|
Suggestion: () => ThreadSuggestion,
|
|
17
20
|
SuggestionByIndex: () => SuggestionByIndex,
|
|
18
21
|
Suggestions: () => Suggestions,
|
|
19
22
|
Unstable_MessageById: () => Unstable_MessageById
|
|
20
23
|
});
|
|
21
24
|
//#endregion
|
|
22
|
-
export { ThreadEmpty as Empty, ThreadIf as If, MessageByIndex, ThreadMessages as Messages, ThreadMessagesFlatList as MessagesFlatList, ThreadRoot as Root, ThreadSuggestion as Suggestion, SuggestionByIndex, Suggestions, Unstable_MessageById, thread_exports };
|
|
25
|
+
export { ThreadEmpty as Empty, ThreadIf as If, MessageByIndex, ThreadMessages as Messages, ThreadMessagesFlatList as MessagesFlatList, ThreadRoot as Root, Row, ThreadRowsFlatList as RowsFlatList, ThreadSuggestion as Suggestion, SuggestionByIndex, Suggestions, Unstable_MessageById, thread_exports };
|
|
23
26
|
|
|
24
27
|
//# sourceMappingURL=thread.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.js","names":["ThreadRoot","Root","ThreadRootProps","RootProps","ThreadMessagesFlatList","MessagesFlatList","ThreadMessagesFlatListProps","MessagesFlatListProps","ThreadMessages","Messages","ThreadMessagesProps","MessagesProps","ThreadPrimitiveMessageByIndex","MessageByIndex","ThreadPrimitiveUnstable_MessageById","Unstable_MessageById","ThreadEmpty","Empty","ThreadEmptyProps","EmptyProps","ThreadIf","If","ThreadIfProps","IfProps","ThreadSuggestion","Suggestion","ThreadSuggestionProps","SuggestionProps","ThreadPrimitiveSuggestions","Suggestions","ThreadPrimitiveSuggestionByIndex","SuggestionByIndex"],"sources":["../../src/primitives/thread.ts"],"sourcesContent":["export {\n ThreadRoot as Root,\n type ThreadRootProps as RootProps,\n} from \"./thread/ThreadRoot\";\nexport {\n ThreadMessagesFlatList as MessagesFlatList,\n type ThreadMessagesFlatListProps as MessagesFlatListProps,\n ThreadMessages as Messages,\n type ThreadMessagesProps as MessagesProps,\n} from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveMessageByIndex as MessageByIndex } from \"@assistant-ui/core/react\";\nexport { ThreadPrimitiveUnstable_MessageById as Unstable_MessageById } from \"@assistant-ui/core/react\";\nexport {\n ThreadEmpty as Empty,\n type ThreadEmptyProps as EmptyProps,\n} from \"./thread/ThreadEmpty\";\nexport {\n ThreadIf as If,\n type ThreadIfProps as IfProps,\n} from \"./thread/ThreadIf\";\nexport {\n ThreadSuggestion as Suggestion,\n type ThreadSuggestionProps as SuggestionProps,\n} from \"./thread/ThreadSuggestion\";\nexport {\n ThreadPrimitiveSuggestions as Suggestions,\n ThreadPrimitiveSuggestionByIndex as SuggestionByIndex,\n} from \"@assistant-ui/core/react\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"thread.js","names":["ThreadRoot","Root","ThreadRootProps","RootProps","ThreadMessagesFlatList","MessagesFlatList","ThreadMessagesFlatListProps","MessagesFlatListProps","ThreadMessages","Messages","ThreadMessagesProps","MessagesProps","ThreadPrimitiveMessageByIndex","MessageByIndex","ThreadPrimitiveRow","Row","ThreadRowsFlatList","RowsFlatList","ThreadRowsFlatListProps","RowsFlatListProps","ThreadPrimitiveUnstable_MessageById","Unstable_MessageById","ThreadEmpty","Empty","ThreadEmptyProps","EmptyProps","ThreadIf","If","ThreadIfProps","IfProps","ThreadSuggestion","Suggestion","ThreadSuggestionProps","SuggestionProps","ThreadPrimitiveSuggestions","Suggestions","ThreadPrimitiveSuggestionByIndex","SuggestionByIndex"],"sources":["../../src/primitives/thread.ts"],"sourcesContent":["export {\n ThreadRoot as Root,\n type ThreadRootProps as RootProps,\n} from \"./thread/ThreadRoot\";\nexport {\n ThreadMessagesFlatList as MessagesFlatList,\n type ThreadMessagesFlatListProps as MessagesFlatListProps,\n ThreadMessages as Messages,\n type ThreadMessagesProps as MessagesProps,\n} from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveMessageByIndex as MessageByIndex } from \"@assistant-ui/core/react\";\nexport { ThreadPrimitiveRow as Row } from \"@assistant-ui/core/react\";\nexport {\n ThreadRowsFlatList as RowsFlatList,\n type ThreadRowsFlatListProps as RowsFlatListProps,\n} from \"./thread/ThreadRowsFlatList\";\nexport { ThreadPrimitiveUnstable_MessageById as Unstable_MessageById } from \"@assistant-ui/core/react\";\nexport {\n ThreadEmpty as Empty,\n type ThreadEmptyProps as EmptyProps,\n} from \"./thread/ThreadEmpty\";\nexport {\n ThreadIf as If,\n type ThreadIfProps as IfProps,\n} from \"./thread/ThreadIf\";\nexport {\n ThreadSuggestion as Suggestion,\n type ThreadSuggestionProps as SuggestionProps,\n} from \"./thread/ThreadSuggestion\";\nexport {\n ThreadPrimitiveSuggestions as Suggestions,\n ThreadPrimitiveSuggestionByIndex as SuggestionByIndex,\n} from \"@assistant-ui/core/react\";\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"description": "React Native bindings for assistant-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"assistant",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
],
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@assistant-ui/core": "^0.3.
|
|
34
|
+
"@assistant-ui/core": "^0.3.24",
|
|
35
35
|
"@assistant-ui/store": "^0.3.17",
|
|
36
36
|
"@assistant-ui/tap": "^0.9.21",
|
|
37
37
|
"assistant-cloud": "^0.2.5",
|
|
38
|
-
"assistant-stream": "^0.3.
|
|
38
|
+
"assistant-stream": "^0.3.48"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@types/react": "*",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "aui-build",
|
|
78
78
|
"test": "vitest run",
|
|
79
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text --coverage.reporter=html --coverage.reporter=json-summary",
|
|
79
80
|
"typecheck": "tsc --noEmit",
|
|
80
81
|
"test:peer-react18": "vitest run --config vitest.peer-react18.config.ts",
|
|
81
82
|
"test:types:peer-react18": "aui-react18-types",
|
package/src/index.ts
CHANGED
|
@@ -20,9 +20,13 @@ export type {
|
|
|
20
20
|
ToolApprovalDisplay,
|
|
21
21
|
ToolApprovalOption,
|
|
22
22
|
ToolApprovalOptionKind,
|
|
23
|
+
ToolApprovalAnswer,
|
|
24
|
+
ToolApprovalQuestion,
|
|
25
|
+
ToolApprovalQuestionOption,
|
|
23
26
|
ToolApprovalResponse,
|
|
24
27
|
ToolCallMessagePart,
|
|
25
28
|
ToolCallMessagePartStatus,
|
|
29
|
+
MessagePartTiming,
|
|
26
30
|
ToolCallTiming,
|
|
27
31
|
ToolModelContentPart,
|
|
28
32
|
ImageMessagePart,
|
|
@@ -179,6 +183,11 @@ export * as SuggestionPrimitive from "./primitives/suggestion";
|
|
|
179
183
|
export * as ErrorPrimitive from "./primitives/error";
|
|
180
184
|
|
|
181
185
|
export { groupPartByType, type GroupByContext } from "@assistant-ui/core/react";
|
|
186
|
+
export {
|
|
187
|
+
createThreadRowsSelector,
|
|
188
|
+
type ThreadRow,
|
|
189
|
+
type ThreadRowsOptions,
|
|
190
|
+
} from "@assistant-ui/core/react";
|
|
182
191
|
export { unstable_useThreadMessageIds } from "@assistant-ui/core/react";
|
|
183
192
|
|
|
184
193
|
// Re-export shared providers from core/react
|
|
@@ -404,9 +413,17 @@ export type {
|
|
|
404
413
|
ThreadSuggestion,
|
|
405
414
|
ToolCallMessagePartMcpMetadata,
|
|
406
415
|
ToolExecutionStatus,
|
|
416
|
+
DirectiveFormatter,
|
|
417
|
+
DirectiveSegment,
|
|
418
|
+
TriggerAdapter,
|
|
419
|
+
TriggerCategory,
|
|
420
|
+
TriggerItem,
|
|
407
421
|
Unstable_DirectiveFormatter,
|
|
408
422
|
Unstable_DirectiveSegment,
|
|
409
423
|
Unstable_TriggerItem,
|
|
410
424
|
VoiceSessionState,
|
|
411
425
|
} from "@assistant-ui/core";
|
|
412
|
-
export {
|
|
426
|
+
export {
|
|
427
|
+
defaultDirectiveFormatter,
|
|
428
|
+
unstable_defaultDirectiveFormatter,
|
|
429
|
+
} from "@assistant-ui/core";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { act, type ReactElement } from "react";
|
|
2
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { Text } from "react-native";
|
|
5
|
+
import * as MessagePrimitive from "./message";
|
|
6
|
+
|
|
7
|
+
const h = vi.hoisted(() => ({
|
|
8
|
+
message: { metadata: { custom: {} } as { custom: Record<string, unknown> } },
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
vi.mock("@assistant-ui/store", async (importOriginal) => {
|
|
12
|
+
const actual = await importOriginal<typeof import("@assistant-ui/store")>();
|
|
13
|
+
return {
|
|
14
|
+
...actual,
|
|
15
|
+
useAuiState: <T,>(selector: (state: typeof h) => T) => selector(h),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
(globalThis as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;
|
|
20
|
+
|
|
21
|
+
describe("MessagePrimitive.Quote", () => {
|
|
22
|
+
let container: HTMLDivElement;
|
|
23
|
+
let root: Root;
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
h.message = { metadata: { custom: {} } };
|
|
27
|
+
container = document.createElement("div");
|
|
28
|
+
document.body.appendChild(container);
|
|
29
|
+
root = createRoot(container);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(async () => {
|
|
33
|
+
await act(async () => {
|
|
34
|
+
root.unmount();
|
|
35
|
+
});
|
|
36
|
+
container.remove();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const render = async (element: ReactElement) => {
|
|
40
|
+
await act(async () => {
|
|
41
|
+
root.render(element);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
it("renders nothing for a message without a quote", async () => {
|
|
46
|
+
await render(
|
|
47
|
+
<MessagePrimitive.Quote>
|
|
48
|
+
{({ text }) => <Text testID="quote">{text}</Text>}
|
|
49
|
+
</MessagePrimitive.Quote>,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(container.querySelector('[data-testid="quote"]')).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("passes the quote text and source message id to its child", async () => {
|
|
56
|
+
h.message = {
|
|
57
|
+
metadata: { custom: { quote: { text: "quoted text", messageId: "m1" } } },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
await render(
|
|
61
|
+
<MessagePrimitive.Quote>
|
|
62
|
+
{({ text, messageId }) => (
|
|
63
|
+
<Text testID="quote">
|
|
64
|
+
{messageId}: {text}
|
|
65
|
+
</Text>
|
|
66
|
+
)}
|
|
67
|
+
</MessagePrimitive.Quote>,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(container.querySelector('[data-testid="quote"]')?.textContent).toBe(
|
|
71
|
+
"m1: quoted text",
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
MessagePrimitivePartByIndex as PartByIndex,
|
|
12
12
|
} from "./message/MessageParts";
|
|
13
13
|
export { MessagePrimitiveGroupedParts as GroupedParts } from "@assistant-ui/core/react";
|
|
14
|
+
export { MessagePrimitiveQuote as Quote } from "@assistant-ui/core/react";
|
|
14
15
|
export {
|
|
15
16
|
MessageIf as If,
|
|
16
17
|
type MessageIfProps as IfProps,
|