@vinaverse/react-native 0.1.0-alpha.8 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/dist/chat.cjs +63 -59
- package/dist/chat.d.cts +20 -6
- package/dist/chat.d.ts +20 -6
- package/dist/chat.js +1 -1
- package/dist/{chunk-NXGLI4Y7.js → chunk-GIQYOTNH.js} +89 -55
- package/dist/chunk-GIQYOTNH.js.map +1 -0
- package/dist/{chunk-EXN5TNLU.cjs → chunk-V7XYOLLT.cjs} +91 -53
- package/dist/chunk-V7XYOLLT.cjs.map +1 -0
- package/dist/index.cjs +63 -59
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/launcher.cjs +4 -0
- package/dist/launcher.d.cts +1 -1
- package/dist/launcher.d.ts +1 -1
- package/dist/launcher.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-EXN5TNLU.cjs.map +0 -1
- package/dist/chunk-NXGLI4Y7.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTheme, useReducedMotion, announce, useNativeLifecycle, themeProblems, ThemeProvider, useAgentSweep } from './chunk-EFEXTVIT.js';
|
|
2
2
|
import { useAgentRuntime, useAgentConversation, useAgentName } from '@vinaverse/react/agent';
|
|
3
|
-
export { AgentRuntimeProvider, forgetGreeting, greetedKey, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus } from '@vinaverse/react/agent';
|
|
3
|
+
export { AgentRuntimeProvider, forgetGreeting, greetedKey, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus, useAgentStatusState } from '@vinaverse/react/agent';
|
|
4
4
|
import { FlashList } from '@shopify/flash-list';
|
|
5
|
-
import { useCopy, formatMoney, formatTimeRange, useConversationSelector, formatDate, useStreamingText, bannedWordsIn, CopyProvider } from '@vinaverse/react';
|
|
5
|
+
import { useCopy, formatMoney, formatTimeRange, formatDayTime, useConversationSelector, formatDate, useStreamingText, bannedWordsIn, CopyProvider } from '@vinaverse/react';
|
|
6
6
|
import { Pressable, ActivityIndicator, Text, View, Image, Linking, TextInput, useWindowDimensions, Platform, KeyboardAvoidingView } from 'react-native';
|
|
7
7
|
import { readCard } from '@vinaverse/client/agent';
|
|
8
8
|
import { useContext, memo, useState, useMemo, useCallback, useRef, useEffect, createContext } from 'react';
|
|
@@ -170,7 +170,7 @@ function safeImage(url) {
|
|
|
170
170
|
function InfoCard(props) {
|
|
171
171
|
const card = cardOf(props.card);
|
|
172
172
|
const { locale, t } = useCopy();
|
|
173
|
-
const { slots, timeZone } = useChat();
|
|
173
|
+
const { slots, timeZone, handlers } = useChat();
|
|
174
174
|
const { colors, radius, space, font } = useTheme();
|
|
175
175
|
const image = safeImage(card.image_url);
|
|
176
176
|
const Img = slots.Image ?? Image;
|
|
@@ -179,13 +179,42 @@ function InfoCard(props) {
|
|
|
179
179
|
const amount = money ? formatMoney(money.amount, money.currency, locale) : null;
|
|
180
180
|
const price = amount && !card.price ? t("priceFrom", { price: amount }) : amount;
|
|
181
181
|
const when = card.starts_at ? formatTimeRange(card.starts_at, void 0, locale, timeZone) : null;
|
|
182
|
+
const status = typeof card.status === "string" && card.status ? card.status : null;
|
|
183
|
+
const ref = card.ref;
|
|
184
|
+
const onOpenTarget = handlers.current?.onOpenTarget;
|
|
185
|
+
const open = ref && onOpenTarget && !props.restored ? () => onOpenTarget({ type: ref.type, id: ref.id }, props.card) : null;
|
|
182
186
|
const label = [
|
|
183
187
|
card.title,
|
|
184
188
|
card.subtitle,
|
|
189
|
+
status,
|
|
185
190
|
rating && `\u2605 ${rating}`,
|
|
186
191
|
price,
|
|
187
192
|
when
|
|
188
193
|
].filter(Boolean).join(", ");
|
|
194
|
+
const top = /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: space.md }, children: [
|
|
195
|
+
image ? /* @__PURE__ */ jsx(
|
|
196
|
+
Img,
|
|
197
|
+
{
|
|
198
|
+
source: { uri: image },
|
|
199
|
+
style: {
|
|
200
|
+
width: 64,
|
|
201
|
+
height: 64,
|
|
202
|
+
borderRadius: radius.md,
|
|
203
|
+
backgroundColor: colors.surface
|
|
204
|
+
},
|
|
205
|
+
accessible: false
|
|
206
|
+
}
|
|
207
|
+
) : null,
|
|
208
|
+
/* @__PURE__ */ jsxs(View, { style: { flex: 1, gap: space.xxs }, children: [
|
|
209
|
+
/* @__PURE__ */ jsx(Title, { numberOfLines: 2, children: card.title }),
|
|
210
|
+
card.subtitle ? /* @__PURE__ */ jsx(Body, { muted: true, children: card.subtitle }) : null,
|
|
211
|
+
/* @__PURE__ */ jsx(Text, { style: { color: colors.textMuted, fontSize: font.size.sm }, children: [
|
|
212
|
+
rating && `\u2605 ${rating}${card.rating ? ` (${card.rating.count})` : ""}`,
|
|
213
|
+
price,
|
|
214
|
+
when
|
|
215
|
+
].filter(Boolean).join(" \xB7 ") })
|
|
216
|
+
] })
|
|
217
|
+
] });
|
|
189
218
|
return /* @__PURE__ */ jsxs(
|
|
190
219
|
CardFrame,
|
|
191
220
|
{
|
|
@@ -193,32 +222,23 @@ function InfoCard(props) {
|
|
|
193
222
|
restored: props.restored,
|
|
194
223
|
testID: `vinaverse-card-${card.id}`,
|
|
195
224
|
children: [
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
},
|
|
207
|
-
accessible: false
|
|
208
|
-
}
|
|
209
|
-
) : null,
|
|
210
|
-
/* @__PURE__ */ jsxs(View, { style: { flex: 1, gap: space.xxs }, children: [
|
|
211
|
-
/* @__PURE__ */ jsx(Title, { numberOfLines: 2, children: card.title }),
|
|
212
|
-
card.subtitle ? /* @__PURE__ */ jsx(Body, { muted: true, children: card.subtitle }) : null,
|
|
213
|
-
/* @__PURE__ */ jsx(Text, { style: { color: colors.textMuted, fontSize: font.size.sm }, children: [
|
|
214
|
-
rating && `\u2605 ${rating}${card.rating ? ` (${card.rating.count})` : ""}`,
|
|
215
|
-
price,
|
|
216
|
-
when
|
|
217
|
-
].filter(Boolean).join(" \xB7 ") })
|
|
218
|
-
] })
|
|
219
|
-
] }),
|
|
225
|
+
open ? /* @__PURE__ */ jsx(
|
|
226
|
+
Pressable,
|
|
227
|
+
{
|
|
228
|
+
accessibilityRole: "link",
|
|
229
|
+
accessibilityLabel: card.title,
|
|
230
|
+
onPress: open,
|
|
231
|
+
testID: `vinaverse-open-${card.id}`,
|
|
232
|
+
children: top
|
|
233
|
+
}
|
|
234
|
+
) : top,
|
|
220
235
|
card.body ? /* @__PURE__ */ jsx(Body, { children: card.body }) : null,
|
|
221
|
-
/* @__PURE__ */ jsx(
|
|
236
|
+
/* @__PURE__ */ jsx(
|
|
237
|
+
Badges,
|
|
238
|
+
{
|
|
239
|
+
badges: status ? [status, ...card.badges ?? []] : card.badges
|
|
240
|
+
}
|
|
241
|
+
),
|
|
222
242
|
props.restored ? null : /* @__PURE__ */ jsx(CardActions, { ...props })
|
|
223
243
|
]
|
|
224
244
|
}
|
|
@@ -329,14 +349,24 @@ function ListingCard(props) {
|
|
|
329
349
|
)
|
|
330
350
|
}) : null;
|
|
331
351
|
const next = card.next_available ? t("nextAvailable", {
|
|
332
|
-
|
|
352
|
+
// "today, 10:00 AM", "tomorrow, 10:00 AM", else the date (the copy's `today` and `tomorrow`).
|
|
353
|
+
time: formatDayTime(
|
|
354
|
+
card.next_available,
|
|
355
|
+
{ today: t("today"), tomorrow: t("tomorrow") },
|
|
356
|
+
locale,
|
|
357
|
+
timeZone
|
|
358
|
+
)
|
|
333
359
|
}) : null;
|
|
334
360
|
const ref = card.ref;
|
|
335
361
|
const onOpenTarget = handlers.current?.onOpenTarget;
|
|
336
362
|
const open = ref && onOpenTarget && !props.restored ? () => onOpenTarget({ type: ref.type, id: ref.id }, props.card) : null;
|
|
363
|
+
const asked = imagePolicy?.aspectRatio;
|
|
364
|
+
const size2 = card.images?.[0];
|
|
365
|
+
const range = imagePolicy?.naturalAspect ?? { min: 1, max: 2 };
|
|
366
|
+
const own = asked === "natural" && !props.grouped && size2?.width && size2.height ? Math.min(range.max, Math.max(range.min, size2.width / size2.height)) : null;
|
|
337
367
|
const photo = {
|
|
338
368
|
width: "100%",
|
|
339
|
-
aspectRatio:
|
|
369
|
+
aspectRatio: own ?? (typeof asked === "number" ? asked : 1.6),
|
|
340
370
|
borderRadius: radius.md
|
|
341
371
|
};
|
|
342
372
|
const top = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1295,7 +1325,13 @@ var CardView = /* @__PURE__ */ memo(function CardView2(props) {
|
|
|
1295
1325
|
const Default = defaultCard(card.kind);
|
|
1296
1326
|
const Custom = slots.cards?.[card.kind];
|
|
1297
1327
|
const read = useMemo(() => readCard(card.card), [card]);
|
|
1298
|
-
const own = {
|
|
1328
|
+
const own = {
|
|
1329
|
+
card,
|
|
1330
|
+
read,
|
|
1331
|
+
busy,
|
|
1332
|
+
restored: props.item.restored === true,
|
|
1333
|
+
grouped: props.grouped === true
|
|
1334
|
+
};
|
|
1299
1335
|
return Custom ? /* @__PURE__ */ jsx(Custom, { ...own, Default }) : /* @__PURE__ */ jsx(Default, { ...own });
|
|
1300
1336
|
});
|
|
1301
1337
|
var keyOf = (item) => item.key;
|
|
@@ -1318,7 +1354,7 @@ function CardCarousel(props) {
|
|
|
1318
1354
|
data: props.items,
|
|
1319
1355
|
keyExtractor: keyOf,
|
|
1320
1356
|
getItemType: kindOf,
|
|
1321
|
-
renderItem: ({ item }) => /* @__PURE__ */ jsx(View, { style: { width: size2 }, children: /* @__PURE__ */ jsx(CardView, { item }) }),
|
|
1357
|
+
renderItem: ({ item }) => /* @__PURE__ */ jsx(View, { style: { width: size2 }, children: /* @__PURE__ */ jsx(CardView, { item, grouped: true }) }),
|
|
1322
1358
|
snapToInterval: size2,
|
|
1323
1359
|
decelerationRate: "fast",
|
|
1324
1360
|
showsHorizontalScrollIndicator: false
|
|
@@ -1904,29 +1940,27 @@ function authorOf(item) {
|
|
|
1904
1940
|
return item?.type === "message" ? item.role : null;
|
|
1905
1941
|
}
|
|
1906
1942
|
function carousels(items, previous) {
|
|
1943
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1944
|
+
for (const item of items) {
|
|
1945
|
+
if (item.type !== "card") continue;
|
|
1946
|
+
const group = item.card.card.group;
|
|
1947
|
+
if (group?.layout !== "carousel" || typeof group.id !== "string") continue;
|
|
1948
|
+
const id = `${item.card.turnId ?? ""}\0${group.id}`;
|
|
1949
|
+
const members = groups.get(id);
|
|
1950
|
+
if (members) members.push(item);
|
|
1951
|
+
else groups.set(id, [item]);
|
|
1952
|
+
}
|
|
1907
1953
|
const runs = /* @__PURE__ */ new Map();
|
|
1908
1954
|
const inside = /* @__PURE__ */ new Set();
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
while (end < items.length && groupOf(items[end]) === id) end++;
|
|
1919
|
-
if (end - i > 1) {
|
|
1920
|
-
const run = items.slice(i, end);
|
|
1921
|
-
const key = run[0]?.key;
|
|
1922
|
-
const before = previous.get(key);
|
|
1923
|
-
runs.set(
|
|
1924
|
-
key,
|
|
1925
|
-
before && before.length === run.length && before.every((c, n) => c === run[n]) ? before : run
|
|
1926
|
-
);
|
|
1927
|
-
for (const card of run.slice(1)) inside.add(card.key);
|
|
1928
|
-
}
|
|
1929
|
-
i = end - 1;
|
|
1955
|
+
for (const run of groups.values()) {
|
|
1956
|
+
if (run.length < 2) continue;
|
|
1957
|
+
const key = run[0]?.key;
|
|
1958
|
+
const before = previous.get(key);
|
|
1959
|
+
runs.set(
|
|
1960
|
+
key,
|
|
1961
|
+
before && before.length === run.length && before.every((c, n) => c === run[n]) ? before : run
|
|
1962
|
+
);
|
|
1963
|
+
for (const card of run.slice(1)) inside.add(card.key);
|
|
1930
1964
|
}
|
|
1931
1965
|
return { runs, inside };
|
|
1932
1966
|
}
|
|
@@ -2564,5 +2598,5 @@ function AgentFooter(props) {
|
|
|
2564
2598
|
}
|
|
2565
2599
|
|
|
2566
2600
|
export { ActivityLine, AgentChat, AgentFooter, Avatar, Button, CardActions, CardCarousel, CardFrame, CardView, ChatHeader, ChatSkeleton, Composer, DefaultBubble, DefaultComposer, DefaultEnded, DefaultHeader, DefaultTurnFailed, DefaultUnavailable, DefaultUnavailableScreen, DefaultUnreachable, DisclosureBar, FailureActionButton, InfoCard, LinksCard, ListingCard, MessageBubble, MessageList, NextStepCard, ProposalCard, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, TimeSlotsCard, VinaverseChat, VinaverseChatProvider, Welcome, allowedImage, answerText, carousels, defaultCard, fieldText, itemType, monogram, newestWholeReply, ratingText, useChat };
|
|
2567
|
-
//# sourceMappingURL=chunk-
|
|
2568
|
-
//# sourceMappingURL=chunk-
|
|
2601
|
+
//# sourceMappingURL=chunk-GIQYOTNH.js.map
|
|
2602
|
+
//# sourceMappingURL=chunk-GIQYOTNH.js.map
|