@botpress/webchat 5.3.2 → 5.5.3

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.
@@ -1,19 +1,18 @@
1
1
 
2
- > @botpress/webchat@5.3.2 build /home/runner/work/genisys/genisys/packages/webchat-components
2
+ > @botpress/webchat@5.5.3 build /home/runner/work/genisys/genisys/packages/webchat/components
3
3
  > vite build
4
4
 
5
5
  vite v5.4.8 building for production...
6
6
  transforming...
7
- ✓ 2812 modules transformed.
7
+ ✓ 2816 modules transformed.
8
8
  rendering chunks...
9
9
 
10
10
  [vite:dts] Start generate declaration files...
11
11
  computing gzip size...
12
- dist/index.js 1,887.30 kB │ gzip: 421.05 kB
12
+ dist/index.js 1,902.64 kB │ gzip: 424.88 kB
13
13
  [vite:dts] Start rollup declaration files...
14
- Analysis will use the bundled TypeScript version 5.8.2
15
- *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
16
- [vite:dts] Declaration files built in 27349ms.
14
+ Analysis will use the bundled TypeScript version 5.9.3
15
+ [vite:dts] Declaration files built in 27022ms.
17
16
 
18
- dist/index.umd.cjs 1,202.73 kB │ gzip: 346.52 kB
19
- ✓ built in 34.20s
17
+ dist/index.umd.cjs 1,213.78 kB │ gzip: 350.17 kB
18
+ ✓ built in 34.69s
package/dist/index.d.ts CHANGED
@@ -24,6 +24,10 @@ import { ListConversationsResponse } from '@botpress/webchat-client';
24
24
  import { LucideIcon } from 'lucide-react';
25
25
  import { MemoExoticComponent } from '../../../node_modules/@types/react';
26
26
  import { Message as Message_2 } from '@botpress/webchat-client';
27
+ import { MessageStreamAbort } from '@botpress/webchat-client';
28
+ import { MessageStreamComplete } from '@botpress/webchat-client';
29
+ import { MessageStreamDelta } from '@botpress/webchat-client';
30
+ import { MessageStreamSnapshot } from '@botpress/webchat-client';
27
31
  import { NamedExoticComponent } from '../../../node_modules/@types/react';
28
32
  import { PersistOptions } from 'zustand/middleware';
29
33
  import { ReactNode } from '../../node_modules/@types/react';
@@ -93,6 +97,7 @@ export declare type BlocIntegrationMessageItems = Extract<IntegrationMessage['pa
93
97
  export declare type BlockContext = {
94
98
  direction: 'incoming' | 'outgoing' | 'system';
95
99
  messageId: string;
100
+ isStreaming?: boolean;
96
101
  isReadOnly?: boolean;
97
102
  sendMessage?: ScopedClient['sendMessage'];
98
103
  /** All citation entries on the message (`metadata.citations`); renderers pick
@@ -166,7 +171,7 @@ export declare type CarouselBlock = {
166
171
  cards: CardBlock[];
167
172
  };
168
173
 
169
- export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, isReadOnly, disableComposer, error, participants, closeWindow, sendMessage, addMessageFeedback, uploadFile, listConversations, restartConversation, clientId, storageKey, soundOn, toggleSound, disableSendButton, conversationId, expanded, onToggleExpand, locale, ...props }: ChatProps) => JSX.Element;
174
+ export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, isReadOnly, disableComposer, error, participants, closeWindow, sendMessage, addMessageFeedback, uploadFile, listConversations, restartConversation, clientId, storageKey, soundOn, toggleSound, disableSendButton, conversationId, expanded, onToggleExpand, locale, onComposerTextChange, ...props }: ChatProps) => JSX.Element;
170
175
 
171
176
  export declare type ChatProps = {
172
177
  className?: string;
@@ -195,6 +200,8 @@ export declare type ChatProps = {
195
200
  expanded?: boolean;
196
201
  onToggleExpand?: () => void;
197
202
  locale?: Partial<WebchatTranslations>;
203
+ /** Fired on every composer keystroke; used to report the end user's typing upstream. */
204
+ onComposerTextChange?: (text: string) => void;
198
205
  };
199
206
 
200
207
  declare type ChatSoundStore = {
@@ -458,6 +465,11 @@ export declare const defaultTranslations: {
458
465
  readonly 'csat.thanks': "Thanks — sent to the team";
459
466
  };
460
467
 
468
+ export declare function deriveHitlStatus(messages: {
469
+ metadata?: Record<string, any>;
470
+ timestamp: Date;
471
+ }[]): HitlStatus;
472
+
461
473
  export declare function detectLocale(language?: string): WebchatTranslations;
462
474
 
463
475
  export declare type Dimensions = {
@@ -554,7 +566,7 @@ declare type HeaderProps = {
554
566
  * Drives the header (amber "finding an agent" pulse / agent identity) and the
555
567
  * in-stream waiting block.
556
568
  */
557
- declare type HitlStatus = {
569
+ export declare type HitlStatus = {
558
570
  mode: 'bot';
559
571
  } | {
560
572
  mode: 'waiting';
@@ -728,6 +740,14 @@ export declare type MessageRenderers = {
728
740
  custom?: React.FC<CustomRendererProps>;
729
741
  };
730
742
 
743
+ export { MessageStreamAbort }
744
+
745
+ export { MessageStreamComplete }
746
+
747
+ export { MessageStreamDelta }
748
+
749
+ export { MessageStreamSnapshot }
750
+
731
751
  export declare const MISSING_API_URL = "The API url is required to initialize the webchat.";
732
752
 
733
753
  export declare const MISSING_BOT_ID = "The Bot ID is required to initialize the webchat.";
@@ -889,6 +909,12 @@ declare type Props_5 = {
889
909
  user?: UserCredentials;
890
910
  conversationId?: string;
891
911
  configuration?: Configuration;
912
+ /**
913
+ * Fires once per user send, with the outgoing payload and the conversation
914
+ * it belongs to (absent until a fresh conversation resolves). Same moment as
915
+ * the `messageSent` event, for hosts mounting <Webchat> outside the provider.
916
+ */
917
+ onMessageSent?: (payload: unknown, conversationId?: string) => void;
892
918
  } & ComponentProps_2<'div'>;
893
919
 
894
920
  declare type Props_6 = {
@@ -935,6 +961,14 @@ export declare function renderBlock(block: MessageBlock, ctx: BlockContext): JSX
935
961
 
936
962
  export declare const resolveStarterIcon: (icon?: string) => LucideIcon;
937
963
 
964
+ /**
965
+ * Resolves the translation map for the webchat: pick the base bundle for `language`
966
+ * (or auto-detect from navigator.language when omitted), then merge any custom string
967
+ * `overrides` on top. Overrides win per-key, so a site can localize into an unsupported
968
+ * language or tweak individual strings on top of a built-in bundle.
969
+ */
970
+ export declare function resolveTranslations(language?: string, overrides?: Partial<WebchatTranslations>): WebchatTranslations;
971
+
938
972
  export declare const retryWithBackoff: <T>(fn: () => Promise<T>, maxAttempts?: number, delayMs?: number) => Promise<T>;
939
973
 
940
974
  export declare type RichBlockMessage = BlockMessage & {
@@ -993,7 +1027,7 @@ export declare type StyleOptions = {
993
1027
  /**
994
1028
  * StylesheetProvider component that manages theme styles and font loading
995
1029
  */
996
- export declare const StylesheetProvider: ({ color, fontFamily, themeMode }: Props_20) => JSX.Element;
1030
+ export declare const StylesheetProvider: ({ color, fontFamily, themeMode, headerVariant }: Props_20) => JSX.Element;
997
1031
 
998
1032
  declare const Text_2: ({ text, ctx, bare, citationPath, citationOffsetShift }: Props_6) => JSX.Element;
999
1033
  export { Text_2 as Text }
@@ -1032,6 +1066,9 @@ declare type UseActiveConversationReturn = {
1032
1066
  error?: WebchatError;
1033
1067
  isTyping: boolean;
1034
1068
  isAwaitingResponse: boolean;
1069
+ upsertMessageStream: (input: MessageStreamDelta) => void;
1070
+ completeMessageStream: (input: MessageStreamComplete) => void;
1071
+ abortMessageStream: (input: MessageStreamAbort) => void;
1035
1072
  };
1036
1073
 
1037
1074
  export declare function useConversationList({ userCredentials, listConversations, clientId, }: UseConversationListParams): UseConversationListReturn;
@@ -1065,6 +1102,23 @@ export declare function useMessageContext(): MessageContextVaue;
1065
1102
 
1066
1103
  export declare function useModalContext(): ModalContextValue;
1067
1104
 
1105
+ /**
1106
+ * Reports the end user's presence to the conversation as a `userPresence` custom event so a
1107
+ * human agent (e.g. in Desk) can tell whether the visitor is around:
1108
+ * - `online` — stream connected, tab present, active within the last AWAY_MS
1109
+ * - `away` — connected but the tab has been blurred or idle for AWAY_MS
1110
+ * - `offline` — stream disconnected, or the tab is being closed
1111
+ * Only the transitions are emitted (deduped against the last reported state).
1112
+ */
1113
+ export declare function usePresenceEmitter({ enabled, connected }: UsePresenceEmitterProps): void;
1114
+
1115
+ declare type UsePresenceEmitterProps = {
1116
+ /** Gate — only emit when the bot reports presence upstream (agentPresenceEnabled). */
1117
+ enabled?: boolean;
1118
+ /** Whether the webchat client's event stream is connected (drives online vs offline). */
1119
+ connected?: boolean;
1120
+ };
1121
+
1068
1122
  export { User }
1069
1123
 
1070
1124
  export declare function useReadIndicator(): {
@@ -1088,6 +1142,20 @@ declare type UseSoundReturn = {
1088
1142
  playNotificationSound: () => void;
1089
1143
  };
1090
1144
 
1145
+ /**
1146
+ * Reports the end user's typing to the conversation as a `userTyping` custom event so a human
1147
+ * agent (e.g. in Desk) can see when the visitor is composing. Returns an `onTextChange` handler
1148
+ * to wire to the composer; it is `undefined` when disabled so nothing is emitted.
1149
+ */
1150
+ export declare function useTypingEmitter({ enabled }: UseTypingEmitterProps): {
1151
+ onTextChange: ((text: string) => void) | undefined;
1152
+ };
1153
+
1154
+ declare type UseTypingEmitterProps = {
1155
+ /** Gate — only emit when the bot reports presence upstream (agentPresenceEnabled). */
1156
+ enabled?: boolean;
1157
+ };
1158
+
1091
1159
  export declare const useUser: () => UseUserReturn;
1092
1160
 
1093
1161
  declare type UseUserReturn = {
@@ -1190,6 +1258,9 @@ export declare type WebchatContextValue = {
1190
1258
  isTyping: boolean;
1191
1259
  isAwaitingResponse: boolean;
1192
1260
  setAwaitingResponse: (state: boolean, timeout?: number) => void;
1261
+ upsertMessageStream: (input: MessageStreamDelta) => void;
1262
+ completeMessageStream: (input: MessageStreamComplete) => void;
1263
+ abortMessageStream: (input: MessageStreamAbort) => void;
1193
1264
  emitter: ReturnType<typeof createEventEmitter<Events>>;
1194
1265
  };
1195
1266