@vinaverse/react-native 0.1.0-alpha.10 → 0.1.0-alpha.11
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 +25 -1
- package/dist/chat.cjs +118 -117
- package/dist/chat.d.cts +7 -205
- package/dist/chat.d.ts +7 -205
- package/dist/chat.js +2 -1
- package/dist/chunk-2J2LIJLW.js +624 -0
- package/dist/chunk-2J2LIJLW.js.map +1 -0
- package/dist/chunk-4PXQ7DEY.cjs +680 -0
- package/dist/chunk-4PXQ7DEY.cjs.map +1 -0
- package/dist/{chunk-43I4ZAEK.js → chunk-KSHDF3MG.js} +13 -624
- package/dist/chunk-KSHDF3MG.js.map +1 -0
- package/dist/{chunk-NRYNK7E4.cjs → chunk-XAG2P447.cjs} +11 -675
- package/dist/chunk-XAG2P447.cjs.map +1 -0
- package/dist/context-gHCLFsJh.d.cts +212 -0
- package/dist/context-gHCLFsJh.d.ts +212 -0
- package/dist/history.cjs +673 -0
- package/dist/history.cjs.map +1 -0
- package/dist/history.d.cts +177 -0
- package/dist/history.d.ts +177 -0
- package/dist/history.js +618 -0
- package/dist/history.js.map +1 -0
- package/dist/index.cjs +133 -132
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +79 -10
- package/dist/chunk-43I4ZAEK.js.map +0 -1
- package/dist/chunk-NRYNK7E4.cjs.map +0 -1
package/dist/chat.d.ts
CHANGED
|
@@ -1,92 +1,17 @@
|
|
|
1
1
|
export { AgentRuntimeProvider, GreetingStorage, UseAgentConversation, UseAgentLauncher, forgetGreeting, greetedKey, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus, useAgentStatusState } from '@vinaverse/react/agent';
|
|
2
|
+
import { b as CardProps, c as ChatHandlers, d as ChatSlots, g as Chip, I as ImagePolicy, H as HeaderProps, h as ComposerProps, j as FailureState, M as MessageBubbleProps } from './context-gHCLFsJh.js';
|
|
3
|
+
export { C as CardCarousel, a as CardGroupProps, e as ChatStore, f as ChatWarning, E as EmptyStateProps, F as FailureAction, i as FailureProps, L as ListProps, P as ProposalDecision, u as useChat } from './context-gHCLFsJh.js';
|
|
2
4
|
import * as react from 'react';
|
|
3
|
-
import {
|
|
5
|
+
import { ReactNode, ComponentType } from 'react';
|
|
4
6
|
import * as _vinaverse_client_conversation from '@vinaverse/client/conversation';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ImageProps, StyleProp, ViewStyle } from 'react-native';
|
|
7
|
+
import { CardItem, Question, ConversationStore, MessageItem, TimelineItem, SystemItem, Welcome as Welcome$1 } from '@vinaverse/client/conversation';
|
|
8
|
+
import { AgentKey, AgentPlace, AgentEntryPoint, AgentFailureReason, AgentRating } from '@vinaverse/client/agent';
|
|
8
9
|
import { CopyOverrides } from '@vinaverse/react';
|
|
10
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
9
11
|
import { a as ThemeOverrides, C as ColorSchemeSetting } from './theme-BhiEGv64.js';
|
|
10
12
|
export { T as Theme, b as ThemeProvider, c as createTheme, t as themeProblems, u as useTheme } from './theme-BhiEGv64.js';
|
|
11
13
|
import '@vinaverse/tokens';
|
|
12
14
|
|
|
13
|
-
interface HeaderProps {
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly avatarUrl: string | null;
|
|
16
|
-
/** While a person from the business replies: their role. */
|
|
17
|
-
readonly takeoverBy: string | null;
|
|
18
|
-
readonly Default: ComponentType<Omit<HeaderProps, 'Default'>>;
|
|
19
|
-
}
|
|
20
|
-
interface MessageBubbleProps {
|
|
21
|
-
readonly item: MessageItem;
|
|
22
|
-
/** The text to draw: the message's, or the streamed text so far. */
|
|
23
|
-
readonly text: string;
|
|
24
|
-
readonly Default: ComponentType<Omit<MessageBubbleProps, 'Default'>>;
|
|
25
|
-
}
|
|
26
|
-
interface ComposerProps {
|
|
27
|
-
readonly placeholder: string;
|
|
28
|
-
readonly responding: boolean;
|
|
29
|
-
readonly onSend: (text: string) => void;
|
|
30
|
-
readonly onStop: () => void;
|
|
31
|
-
readonly Default: ComponentType<Omit<ComposerProps, 'Default'>>;
|
|
32
|
-
}
|
|
33
|
-
interface EmptyStateProps {
|
|
34
|
-
readonly agentName: string;
|
|
35
|
-
/** The tenant's greeting and chips for the session's mode (`Session.welcome`), or null. */
|
|
36
|
-
readonly welcome: Welcome$1 | null;
|
|
37
|
-
/** Sends a chip's `message` as the person's own text. */
|
|
38
|
-
readonly onChip: (message: string) => void;
|
|
39
|
-
}
|
|
40
|
-
/** `components.CardGroup`: the cards one turn drew together with `group.layout: carousel`, in order. */
|
|
41
|
-
interface CardGroupProps {
|
|
42
|
-
readonly items: readonly CardItem[];
|
|
43
|
-
}
|
|
44
|
-
/** The props the kit gives its list: FlashList's, so FlashList or LegendList take them as they are. */
|
|
45
|
-
interface ListProps {
|
|
46
|
-
readonly data: readonly TimelineItem[];
|
|
47
|
-
readonly renderItem: (info: {
|
|
48
|
-
item: TimelineItem;
|
|
49
|
-
index: number;
|
|
50
|
-
}) => ReactElement | null;
|
|
51
|
-
readonly keyExtractor: (item: TimelineItem) => string;
|
|
52
|
-
readonly getItemType: (item: TimelineItem) => string;
|
|
53
|
-
readonly maintainVisibleContentPosition: {
|
|
54
|
-
readonly startRenderingFromBottom: boolean;
|
|
55
|
-
readonly autoscrollToBottomThreshold: number;
|
|
56
|
-
readonly animateAutoScrollToBottom: boolean;
|
|
57
|
-
};
|
|
58
|
-
readonly ListFooterComponent: ReactElement | null;
|
|
59
|
-
readonly ListEmptyComponent: ReactElement | null;
|
|
60
|
-
readonly keyboardShouldPersistTaps: 'handled';
|
|
61
|
-
readonly contentContainerStyle: object;
|
|
62
|
-
}
|
|
63
|
-
/** A failure the person needs a way out of: a turn that failed before any reply, or no session to talk to. */
|
|
64
|
-
interface FailureState {
|
|
65
|
-
/** `turn_failed`: a turn failed before any of its reply; `unavailable`: the backend gave no session, or none it could use. */
|
|
66
|
-
readonly kind: 'turn_failed' | 'unavailable';
|
|
67
|
-
/** Why: the turn's error `code` (`internal`, `timeout`, …), or the conversation's status (`unavailable`, `unauthorized`). */
|
|
68
|
-
readonly reason: string | null;
|
|
69
|
-
/** Try again, when it can be: the person's text again for a turn the server allows to retry, a new session otherwise. */
|
|
70
|
-
readonly retry: (() => void) | undefined;
|
|
71
|
-
/** The conversation, once a session named it: for your support records. */
|
|
72
|
-
readonly conversationId: string | null;
|
|
73
|
-
}
|
|
74
|
-
/** A slot for a failure (`components.Error`, `components.Unavailable`): the state, and the kit's own part to wrap. */
|
|
75
|
-
interface FailureProps {
|
|
76
|
-
readonly state: FailureState;
|
|
77
|
-
readonly Default: ComponentType<{
|
|
78
|
-
readonly state: FailureState;
|
|
79
|
-
}>;
|
|
80
|
-
}
|
|
81
|
-
/** One action on every failure, drawn as a button by the kit's own parts: a person is always the way out. */
|
|
82
|
-
interface FailureAction {
|
|
83
|
-
/** Default: the copy's `talkToPerson` ("Talk to a person"), in the person's language. */
|
|
84
|
-
readonly label?: string;
|
|
85
|
-
readonly onPress: (state: FailureState) => void;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
declare function CardCarousel(props: CardGroupProps): react.JSX.Element;
|
|
89
|
-
|
|
90
15
|
declare function CardFrame(props: {
|
|
91
16
|
readonly label: string;
|
|
92
17
|
readonly restored?: boolean;
|
|
@@ -98,20 +23,6 @@ declare function ratingText(valuePpm: number, locale: string | undefined): strin
|
|
|
98
23
|
/** A photo the image policy allows: https, and from one of its hosts when it names them. */
|
|
99
24
|
declare function allowedImage(url: string | undefined, hosts: readonly string[] | undefined): string | null;
|
|
100
25
|
|
|
101
|
-
interface CardProps {
|
|
102
|
-
readonly card: HeldCard;
|
|
103
|
-
/** The card read once for drawing, every field checked (`readCard`): kind, target, photo, rating, price, group, links. */
|
|
104
|
-
readonly read: ReadCard | null;
|
|
105
|
-
/** A proposal being decided: draw its buttons busy. */
|
|
106
|
-
readonly busy: boolean;
|
|
107
|
-
/** Restored after a restart: draw it as it was, taking no answer or action. */
|
|
108
|
-
readonly restored: boolean;
|
|
109
|
-
/** Drawn inside a carousel with its group: a photo keeps the policy's fixed frame, so the row stays even. */
|
|
110
|
-
readonly grouped?: boolean;
|
|
111
|
-
/** The kit's own renderer for this kind, to wrap rather than rewrite. */
|
|
112
|
-
readonly Default: ComponentType<Omit<CardProps, 'Default'>>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
26
|
/** The kit's own renderer for a kind. */
|
|
116
27
|
declare function defaultCard(kind: string): ComponentType<Omit<CardProps, 'Default'>>;
|
|
117
28
|
declare const CardView: react.NamedExoticComponent<{
|
|
@@ -144,115 +55,6 @@ declare function TimeSlotsCard(props: Omit<CardProps, 'Default'>): react.JSX.Ele
|
|
|
144
55
|
|
|
145
56
|
declare const ActivityLine: react.NamedExoticComponent<object>;
|
|
146
57
|
|
|
147
|
-
type ProposalDecision = 'confirm' | 'decline';
|
|
148
|
-
/** What the kit asks of the tenant's app. Only `onProposal` and `onOpenLink` are needed for the cards that use them. */
|
|
149
|
-
/** What a chat warning is about. */
|
|
150
|
-
interface ChatWarning {
|
|
151
|
-
readonly code: 'theme' | 'copy' | 'send_failed' | 'answer_failed' | 'proposal_failed' | 'photo_failed';
|
|
152
|
-
}
|
|
153
|
-
interface ChatHandlers {
|
|
154
|
-
/**
|
|
155
|
-
* The person confirmed or declined a proposal: call your backend with the person's own token, then say what
|
|
156
|
-
* happened (`confirmed`, `declined`, `failed`, or `expired` when it had expired). The kit reports it to the session.
|
|
157
|
-
*/
|
|
158
|
-
readonly onProposal?: (card: HeldCard, decision: ProposalDecision) => Promise<ProposalOutcome>;
|
|
159
|
-
/**
|
|
160
|
-
* Open a card's link in your app: a deep link that already passed the deep-link rule (route by the page it names),
|
|
161
|
-
* or a `links` card's https page (your in-app browser; without this handler the system opens it).
|
|
162
|
-
*/
|
|
163
|
-
readonly onOpenLink?: (link: string, card: HeldCard) => void;
|
|
164
|
-
/** A card action without a link (`show_times`, …): sent to the session; this tells your app too. */
|
|
165
|
-
readonly onCardAction?: (card: HeldCard, action: string) => void;
|
|
166
|
-
/** A photo question: let the person pick one, upload it to your backend, and give back its `upload_ref`. */
|
|
167
|
-
readonly onPickPhoto?: (question: Question, card: HeldCard) => Promise<{
|
|
168
|
-
readonly upload_ref: string;
|
|
169
|
-
} | null>;
|
|
170
|
-
/**
|
|
171
|
-
* A way out on a failed turn and on "couldn't connect": a button with your label (default "Talk to a person"),
|
|
172
|
-
* drawn by the kit's own parts when no `components.Error` or `components.Unavailable` replaces them.
|
|
173
|
-
*/
|
|
174
|
-
readonly failureAction?: FailureAction;
|
|
175
|
-
/**
|
|
176
|
-
* Warnings for the app's logger: a theme that is hard to read, copy that says "assistant", a send, an answer, a
|
|
177
|
-
* proposal or a photo pick that failed. `warning.code` says which, so a logger counts them without the text.
|
|
178
|
-
*/
|
|
179
|
-
readonly onWarning?: (message: string, warning: ChatWarning) => void;
|
|
180
|
-
/**
|
|
181
|
-
* The person tapped a card about something of yours (its `ref`: a professional, a space, a booking): open its page
|
|
182
|
-
* with your router. Without it, only the card's own actions open anything.
|
|
183
|
-
*/
|
|
184
|
-
readonly onOpenTarget?: (target: AgentCardTarget, card: HeldCard) => void;
|
|
185
|
-
/** Card photos arrive: fetch them ahead with your image library (`Image.prefetch`), so the cards draw at once. */
|
|
186
|
-
readonly prefetchImage?: (url: string) => void;
|
|
187
|
-
/** Reads a line to a screen reader (a finished reply, the launcher's greeting). Default: the platform's. */
|
|
188
|
-
readonly announce?: (text: string) => void;
|
|
189
|
-
/** A chip was tapped (a welcome chip, a starter, the suggestion); its message is sent as the person's own. */
|
|
190
|
-
readonly onChip?: (chip: Chip) => void;
|
|
191
|
-
}
|
|
192
|
-
/** Which card photos are drawn, in what frame, and what stands in for one that is not. */
|
|
193
|
-
interface ImagePolicy {
|
|
194
|
-
/** Hosts a photo may come from (exact names); default any https host. */
|
|
195
|
-
readonly hosts?: readonly string[];
|
|
196
|
-
/**
|
|
197
|
-
* Width / height of a listing's photo frame. Default 1.6 (16:10). `natural`: a card on its own takes its photo's
|
|
198
|
-
* own shape (its `width` and `height`), held within `naturalAspect`; a card in a carousel keeps 1.6, so the row
|
|
199
|
-
* stays even, and a photo without its size too.
|
|
200
|
-
*/
|
|
201
|
-
readonly aspectRatio?: number | 'natural';
|
|
202
|
-
/** The shapes a `natural` photo is held within. Default square to 2:1 (`{ min: 1, max: 2 }`). */
|
|
203
|
-
readonly naturalAspect?: {
|
|
204
|
-
readonly min: number;
|
|
205
|
-
readonly max: number;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* What stands in for a missing, refused or failed photo, by the card's `kind` (a person's tile, a space's tile).
|
|
209
|
-
* Default the name's monogram.
|
|
210
|
-
*/
|
|
211
|
-
readonly Placeholder?: ComponentType<{
|
|
212
|
-
readonly title: string;
|
|
213
|
-
readonly kind: string;
|
|
214
|
-
}>;
|
|
215
|
-
}
|
|
216
|
-
/** Parts a tenant can replace. Each gets the default's props and the default itself (`Default`), to wrap it. */
|
|
217
|
-
interface ChatSlots {
|
|
218
|
-
readonly Header?: ComponentType<HeaderProps>;
|
|
219
|
-
readonly MessageBubble?: ComponentType<MessageBubbleProps>;
|
|
220
|
-
readonly Composer?: ComponentType<ComposerProps>;
|
|
221
|
-
readonly EmptyState?: ComponentType<EmptyStateProps>;
|
|
222
|
-
readonly Image?: ComponentType<ImageProps>;
|
|
223
|
-
/** A list with FlashList's props (LegendList works). Default: FlashList. */
|
|
224
|
-
readonly ListComponent?: ComponentType<ListProps>;
|
|
225
|
-
/** A turn that failed before any reply: replaces the "Something went wrong." row. */
|
|
226
|
-
readonly Error?: ComponentType<FailureProps>;
|
|
227
|
-
/** No session to talk to: replaces the "Couldn't connect." banner. */
|
|
228
|
-
readonly Unavailable?: ComponentType<FailureProps>;
|
|
229
|
-
/**
|
|
230
|
-
* Draws a turn's cards that ask for a carousel (`group.layout: carousel`) in one row: the kit's `CardCarousel`, or
|
|
231
|
-
* yours. Without it they draw one under another. Opt-in, so an app that never draws a carousel does not ship one.
|
|
232
|
-
*/
|
|
233
|
-
readonly CardGroup?: ComponentType<CardGroupProps>;
|
|
234
|
-
/** Card renderers by kind (`professional`, `proposal`, …). */
|
|
235
|
-
readonly cards?: Readonly<Partial<Record<string, ComponentType<CardProps>>>>;
|
|
236
|
-
}
|
|
237
|
-
interface ChatContextValue {
|
|
238
|
-
readonly store: ConversationStore;
|
|
239
|
-
readonly handlers: RefObject<ChatHandlers>;
|
|
240
|
-
readonly slots: ChatSlots;
|
|
241
|
-
readonly agentAvatar: string | undefined;
|
|
242
|
-
readonly timeZone: string | undefined;
|
|
243
|
-
/** The failure action's label when there is one (`label` undefined: the copy's); `onPress` is read from `handlers`. */
|
|
244
|
-
readonly failureAction: {
|
|
245
|
-
readonly label: string | undefined;
|
|
246
|
-
} | null;
|
|
247
|
-
/** Chips for an empty conversation when the session brings no welcome. */
|
|
248
|
-
readonly starters: readonly Chip[] | undefined;
|
|
249
|
-
readonly imagePolicy: ImagePolicy | undefined;
|
|
250
|
-
}
|
|
251
|
-
/** A tap target that sends `message` as the person's own text (a welcome chip, a starter, a suggestion). */
|
|
252
|
-
type Chip = Welcome$1['chips'][number];
|
|
253
|
-
/** The conversation, handlers and slots; only inside `VinaverseChat` (or `VinaverseChatProvider`). */
|
|
254
|
-
declare function useChat(): ChatContextValue;
|
|
255
|
-
|
|
256
58
|
interface VinaverseChatProps extends ChatHandlers {
|
|
257
59
|
/** The conversation (`createConversation`), created where it can outlive the screen. */
|
|
258
60
|
readonly conversation: ConversationStore;
|
|
@@ -487,4 +289,4 @@ declare function useReducedMotion(): boolean;
|
|
|
487
289
|
/** Reads a line to a screen reader, without moving focus. */
|
|
488
290
|
declare function announce(text: string): void;
|
|
489
291
|
|
|
490
|
-
export { ActivityLine, AgentChat, type AgentChatProps, type AgentChatSlots, type AgentEndedProps, AgentFooter, type AgentFooterProps, type AgentUnavailableScreenProps, type AgentUnreachableProps, Avatar, Button, type ButtonProps, CardActions,
|
|
292
|
+
export { ActivityLine, AgentChat, type AgentChatProps, type AgentChatSlots, type AgentEndedProps, AgentFooter, type AgentFooterProps, type AgentUnavailableScreenProps, type AgentUnreachableProps, Avatar, Button, type ButtonProps, CardActions, CardFrame, CardProps, CardView, ChatHandlers, ChatHeader, ChatSkeleton, ChatSlots, Chip, ColorSchemeSetting, Composer, ComposerProps, DefaultBubble, DefaultComposer, DefaultEnded, DefaultHeader, DefaultTurnFailed, DefaultUnavailable, DefaultUnavailableScreen, DefaultUnreachable, DisclosureBar, FailureActionButton, FailureState, HeaderProps, ImagePolicy, InfoCard, type LifecycleTarget, LinksCard, ListingCard, MessageBubble, MessageBubbleProps, MessageList, NextStepCard, ProposalCard, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, ThemeOverrides, TimeSlotsCard, VinaverseChat, type VinaverseChatProps, VinaverseChatProvider, Welcome, allowedImage, announce, answerText, carousels, defaultCard, fieldText, itemType, monogram, newestWholeReply, ratingText, useNativeLifecycle, useReducedMotion };
|
package/dist/chat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AgentChat, AgentFooter, AgentRuntimeProvider, Composer, DefaultComposer, DefaultEnded, DefaultUnavailable, DefaultUnavailableScreen, DefaultUnreachable, StatusBanner, VinaverseChat, VinaverseChatProvider, forgetGreeting, greetedKey, newestWholeReply, useAgentConversation, useAgentFeatures, useAgentLauncher, useAgentName, useAgentProfile, useAgentRuntime, useAgentStatus, useAgentStatusState } from './chunk-2J2LIJLW.js';
|
|
2
|
+
export { ActivityLine, Avatar, Button, CardActions, CardCarousel, CardFrame, CardView, ChatHeader, ChatSkeleton, DefaultBubble, DefaultHeader, DefaultTurnFailed, DisclosureBar, FailureActionButton, InfoCard, LinksCard, ListingCard, MessageBubble, MessageList, NextStepCard, ProposalCard, QuestionCard, Row, StreamingBubble, SystemRow, TimeSlotsCard, Welcome, allowedImage, answerText, carousels, defaultCard, fieldText, itemType, monogram, ratingText, useChat } from './chunk-KSHDF3MG.js';
|
|
2
3
|
export { ThemeProvider, announce, createTheme, themeProblems, useNativeLifecycle, useReducedMotion, useTheme } from './chunk-EFEXTVIT.js';
|
|
3
4
|
//# sourceMappingURL=chat.js.map
|
|
4
5
|
//# sourceMappingURL=chat.js.map
|