@clivly/chat-widget 0.14.1 → 0.16.0
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 +61 -1
- package/dist/browser-mount.cjs +470 -58
- package/dist/browser-mount.d.cts +73 -1
- package/dist/browser-mount.d.mts +73 -1
- package/dist/browser-mount.mjs +471 -59
- package/dist/browser.cjs +470 -58
- package/dist/browser.d.cts +73 -1
- package/dist/browser.d.mts +73 -1
- package/dist/browser.mjs +471 -59
- package/dist/index.cjs +470 -58
- package/dist/index.d.cts +76 -4
- package/dist/index.d.mts +76 -4
- package/dist/index.mjs +471 -59
- package/dist/widget.global.js +151 -299
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { Root } from "react-dom/client";
|
|
2
2
|
import { CSSProperties, ReactElement } from "react";
|
|
3
|
+
//#region src/layout.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Where the widget sits on the host page, and what its launcher looks like.
|
|
6
|
+
*
|
|
7
|
+
* Until 0.16 the widget rendered in normal flow wherever it was mounted — the
|
|
8
|
+
* script tag inserted it directly after itself, so most embeds showed a
|
|
9
|
+
* full-width-label pill at the end of the page rather than a floating button.
|
|
10
|
+
* Floating in a corner is now the default; `"inline"` keeps the old behaviour
|
|
11
|
+
* for a host that positions the widget itself.
|
|
12
|
+
*/
|
|
13
|
+
type ChatWidgetPlacement = "bottom-left" | "bottom-right" | "inline";
|
|
14
|
+
/**
|
|
15
|
+
* - `"auto"` (default): the labelled pill on wide screens, a 48px icon-only
|
|
16
|
+
* button below 48rem, where a pill covers the host's own controls.
|
|
17
|
+
* - `"pill"`: always the labelled pill.
|
|
18
|
+
* - `"icon"`: always the icon-only button.
|
|
19
|
+
*
|
|
20
|
+
* The label stays the button's accessible name in every variant.
|
|
21
|
+
*/
|
|
22
|
+
type ChatWidgetLauncher = "auto" | "icon" | "pill";
|
|
23
|
+
//#endregion
|
|
3
24
|
//#region src/theme.d.ts
|
|
4
25
|
/**
|
|
5
26
|
* Theme resolution for the widget.
|
|
@@ -48,11 +69,30 @@ interface WidgetSummary {
|
|
|
48
69
|
}
|
|
49
70
|
interface WidgetMessage {
|
|
50
71
|
author: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Set on messages the support assistant wrote (`greeting`, `topic`,
|
|
74
|
+
* `handoff`, `ai`, `ai_clarify`) and on a visitor's topic click
|
|
75
|
+
* (`topic_choice`). Absent or null on everything a person typed, and on
|
|
76
|
+
* every message from a server that predates the assistant.
|
|
77
|
+
*/
|
|
78
|
+
automation?: string | null;
|
|
51
79
|
body: string;
|
|
52
80
|
createdAt: string;
|
|
53
81
|
id: string;
|
|
54
82
|
senderType: WidgetSenderType;
|
|
55
83
|
}
|
|
84
|
+
type WidgetSupportState = "automated" | "handoff" | "human";
|
|
85
|
+
interface WidgetSupportTopic {
|
|
86
|
+
action: "answer" | "ask" | "link" | "human";
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
}
|
|
90
|
+
/** Guided support for one conversation. Answers stay on the server. */
|
|
91
|
+
interface WidgetSupport {
|
|
92
|
+
mode: "human" | "guided" | "ai";
|
|
93
|
+
state: WidgetSupportState | null;
|
|
94
|
+
topics: WidgetSupportTopic[];
|
|
95
|
+
}
|
|
56
96
|
interface WidgetSessionPayload {
|
|
57
97
|
contact: WidgetContact | null;
|
|
58
98
|
conversation: WidgetConversation;
|
|
@@ -60,6 +100,8 @@ interface WidgetSessionPayload {
|
|
|
60
100
|
messages: WidgetMessage[];
|
|
61
101
|
/** Absolute socket URL returned by Clivly's bootstrap. */
|
|
62
102
|
socketUrl?: string;
|
|
103
|
+
/** Absent or null when the widget has no guided support configured. */
|
|
104
|
+
support?: WidgetSupport | null;
|
|
63
105
|
token: string;
|
|
64
106
|
visitorToken: string;
|
|
65
107
|
widget: WidgetSummary;
|
|
@@ -83,7 +125,13 @@ interface WidgetClientCreateMessageEvent {
|
|
|
83
125
|
interface WidgetClientReadEvent {
|
|
84
126
|
type: "conversation.read";
|
|
85
127
|
}
|
|
86
|
-
|
|
128
|
+
/** The visitor picked a guided topic (see `ChatTransportConnection.selectTopic`). */
|
|
129
|
+
interface WidgetClientTopicEvent {
|
|
130
|
+
id: string;
|
|
131
|
+
topicId: string;
|
|
132
|
+
type: "topic.select";
|
|
133
|
+
}
|
|
134
|
+
type WidgetClientEvent = WidgetClientCreateMessageEvent | WidgetClientReadEvent | WidgetClientTopicEvent;
|
|
87
135
|
interface WidgetSessionReadyEvent {
|
|
88
136
|
conversationId: string;
|
|
89
137
|
type: "session.ready";
|
|
@@ -102,11 +150,20 @@ interface WidgetMessageAckEvent {
|
|
|
102
150
|
message: WidgetMessage;
|
|
103
151
|
type: "message.ack";
|
|
104
152
|
}
|
|
153
|
+
interface WidgetSupportStateEvent {
|
|
154
|
+
state: WidgetSupportState;
|
|
155
|
+
type: "support.state";
|
|
156
|
+
}
|
|
157
|
+
/** The assistant is preparing an answer (`thinking`) or has finished (`idle`). */
|
|
158
|
+
interface WidgetAssistantStatusEvent {
|
|
159
|
+
status: "thinking" | "idle";
|
|
160
|
+
type: "assistant.status";
|
|
161
|
+
}
|
|
105
162
|
interface WidgetErrorEvent {
|
|
106
163
|
message: string;
|
|
107
164
|
type: "error";
|
|
108
165
|
}
|
|
109
|
-
type WidgetServerEvent = WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent;
|
|
166
|
+
type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
|
|
110
167
|
//#endregion
|
|
111
168
|
//#region src/transport.d.ts
|
|
112
169
|
interface ChatTransportHandlers {
|
|
@@ -123,6 +180,11 @@ interface ChatTransportConnection {
|
|
|
123
180
|
* without it still works, its visitors are just emailed replies they saw.
|
|
124
181
|
*/
|
|
125
182
|
markRead?: () => void;
|
|
183
|
+
/**
|
|
184
|
+
* Send a guided-topic click. Optional: without it the widget sends the
|
|
185
|
+
* topic's label as an ordinary message, so a custom transport still works.
|
|
186
|
+
*/
|
|
187
|
+
selectTopic?: (event: WidgetClientTopicEvent) => void;
|
|
126
188
|
sendMessage: (event: WidgetClientCreateMessageEvent) => void;
|
|
127
189
|
}
|
|
128
190
|
interface CreateChatTransportOptions {
|
|
@@ -167,7 +229,17 @@ interface ChatWidgetProps {
|
|
|
167
229
|
defaultVisitor?: Partial<ChatWidgetVisitor>;
|
|
168
230
|
getSession: GetSession;
|
|
169
231
|
initiallyOpen?: boolean;
|
|
232
|
+
/** Launcher shape; see {@link ChatWidgetLauncher}. Defaults to `"auto"`. */
|
|
233
|
+
launcher?: ChatWidgetLauncher;
|
|
234
|
+
/** The launcher's visible text, and always its accessible name. */
|
|
170
235
|
launcherLabel?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Where the widget sits; see {@link ChatWidgetPlacement}. Defaults to
|
|
238
|
+
* `"bottom-right"`, floating clear of the device's safe-area insets. Stacks
|
|
239
|
+
* at `--clivly-chat-z-index` (default 2147483000) — lower it through
|
|
240
|
+
* `style` to sit beneath the host's own dialogs.
|
|
241
|
+
*/
|
|
242
|
+
placement?: ChatWidgetPlacement;
|
|
171
243
|
storage?: Pick<Storage, "getItem" | "setItem">;
|
|
172
244
|
/**
|
|
173
245
|
* Inline styles on the widget root. The intended use is overriding palette
|
|
@@ -183,7 +255,7 @@ interface ChatWidgetProps {
|
|
|
183
255
|
theme?: ChatWidgetTheme;
|
|
184
256
|
widgetId: string;
|
|
185
257
|
}
|
|
186
|
-
export declare function ChatWidget({ className, createTransport, defaultVisitor, getSession, initiallyOpen, launcherLabel, storage, style, theme, widgetId }: ChatWidgetProps): ReactElement;
|
|
258
|
+
export declare function ChatWidget({ className, createTransport, defaultVisitor, getSession, initiallyOpen, launcher, launcherLabel, placement, storage, style, theme, widgetId }: ChatWidgetProps): ReactElement;
|
|
187
259
|
export declare function ChatLauncher(): null;
|
|
188
260
|
export declare function ChatPanel(): null;
|
|
189
261
|
export declare function MessageComposer(): null;
|
|
@@ -246,4 +318,4 @@ export declare const createClivlyTransport: typeof createClivlyTransport$1;
|
|
|
246
318
|
export declare const mountChatWidget: typeof mountChatWidget$1;
|
|
247
319
|
export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
|
|
248
320
|
//#endregion
|
|
249
|
-
export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary };
|
|
321
|
+
export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetLauncher, ChatWidgetPlacement, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetAssistantStatusEvent, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetClientTopicEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary, WidgetSupport, WidgetSupportState, WidgetSupportStateEvent, WidgetSupportTopic };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { Root } from "react-dom/client";
|
|
2
2
|
import { CSSProperties, ReactElement } from "react";
|
|
3
|
+
//#region src/layout.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Where the widget sits on the host page, and what its launcher looks like.
|
|
6
|
+
*
|
|
7
|
+
* Until 0.16 the widget rendered in normal flow wherever it was mounted — the
|
|
8
|
+
* script tag inserted it directly after itself, so most embeds showed a
|
|
9
|
+
* full-width-label pill at the end of the page rather than a floating button.
|
|
10
|
+
* Floating in a corner is now the default; `"inline"` keeps the old behaviour
|
|
11
|
+
* for a host that positions the widget itself.
|
|
12
|
+
*/
|
|
13
|
+
type ChatWidgetPlacement = "bottom-left" | "bottom-right" | "inline";
|
|
14
|
+
/**
|
|
15
|
+
* - `"auto"` (default): the labelled pill on wide screens, a 48px icon-only
|
|
16
|
+
* button below 48rem, where a pill covers the host's own controls.
|
|
17
|
+
* - `"pill"`: always the labelled pill.
|
|
18
|
+
* - `"icon"`: always the icon-only button.
|
|
19
|
+
*
|
|
20
|
+
* The label stays the button's accessible name in every variant.
|
|
21
|
+
*/
|
|
22
|
+
type ChatWidgetLauncher = "auto" | "icon" | "pill";
|
|
23
|
+
//#endregion
|
|
3
24
|
//#region src/theme.d.ts
|
|
4
25
|
/**
|
|
5
26
|
* Theme resolution for the widget.
|
|
@@ -48,11 +69,30 @@ interface WidgetSummary {
|
|
|
48
69
|
}
|
|
49
70
|
interface WidgetMessage {
|
|
50
71
|
author: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Set on messages the support assistant wrote (`greeting`, `topic`,
|
|
74
|
+
* `handoff`, `ai`, `ai_clarify`) and on a visitor's topic click
|
|
75
|
+
* (`topic_choice`). Absent or null on everything a person typed, and on
|
|
76
|
+
* every message from a server that predates the assistant.
|
|
77
|
+
*/
|
|
78
|
+
automation?: string | null;
|
|
51
79
|
body: string;
|
|
52
80
|
createdAt: string;
|
|
53
81
|
id: string;
|
|
54
82
|
senderType: WidgetSenderType;
|
|
55
83
|
}
|
|
84
|
+
type WidgetSupportState = "automated" | "handoff" | "human";
|
|
85
|
+
interface WidgetSupportTopic {
|
|
86
|
+
action: "answer" | "ask" | "link" | "human";
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
}
|
|
90
|
+
/** Guided support for one conversation. Answers stay on the server. */
|
|
91
|
+
interface WidgetSupport {
|
|
92
|
+
mode: "human" | "guided" | "ai";
|
|
93
|
+
state: WidgetSupportState | null;
|
|
94
|
+
topics: WidgetSupportTopic[];
|
|
95
|
+
}
|
|
56
96
|
interface WidgetSessionPayload {
|
|
57
97
|
contact: WidgetContact | null;
|
|
58
98
|
conversation: WidgetConversation;
|
|
@@ -60,6 +100,8 @@ interface WidgetSessionPayload {
|
|
|
60
100
|
messages: WidgetMessage[];
|
|
61
101
|
/** Absolute socket URL returned by Clivly's bootstrap. */
|
|
62
102
|
socketUrl?: string;
|
|
103
|
+
/** Absent or null when the widget has no guided support configured. */
|
|
104
|
+
support?: WidgetSupport | null;
|
|
63
105
|
token: string;
|
|
64
106
|
visitorToken: string;
|
|
65
107
|
widget: WidgetSummary;
|
|
@@ -83,7 +125,13 @@ interface WidgetClientCreateMessageEvent {
|
|
|
83
125
|
interface WidgetClientReadEvent {
|
|
84
126
|
type: "conversation.read";
|
|
85
127
|
}
|
|
86
|
-
|
|
128
|
+
/** The visitor picked a guided topic (see `ChatTransportConnection.selectTopic`). */
|
|
129
|
+
interface WidgetClientTopicEvent {
|
|
130
|
+
id: string;
|
|
131
|
+
topicId: string;
|
|
132
|
+
type: "topic.select";
|
|
133
|
+
}
|
|
134
|
+
type WidgetClientEvent = WidgetClientCreateMessageEvent | WidgetClientReadEvent | WidgetClientTopicEvent;
|
|
87
135
|
interface WidgetSessionReadyEvent {
|
|
88
136
|
conversationId: string;
|
|
89
137
|
type: "session.ready";
|
|
@@ -102,11 +150,20 @@ interface WidgetMessageAckEvent {
|
|
|
102
150
|
message: WidgetMessage;
|
|
103
151
|
type: "message.ack";
|
|
104
152
|
}
|
|
153
|
+
interface WidgetSupportStateEvent {
|
|
154
|
+
state: WidgetSupportState;
|
|
155
|
+
type: "support.state";
|
|
156
|
+
}
|
|
157
|
+
/** The assistant is preparing an answer (`thinking`) or has finished (`idle`). */
|
|
158
|
+
interface WidgetAssistantStatusEvent {
|
|
159
|
+
status: "thinking" | "idle";
|
|
160
|
+
type: "assistant.status";
|
|
161
|
+
}
|
|
105
162
|
interface WidgetErrorEvent {
|
|
106
163
|
message: string;
|
|
107
164
|
type: "error";
|
|
108
165
|
}
|
|
109
|
-
type WidgetServerEvent = WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent;
|
|
166
|
+
type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
|
|
110
167
|
//#endregion
|
|
111
168
|
//#region src/transport.d.ts
|
|
112
169
|
interface ChatTransportHandlers {
|
|
@@ -123,6 +180,11 @@ interface ChatTransportConnection {
|
|
|
123
180
|
* without it still works, its visitors are just emailed replies they saw.
|
|
124
181
|
*/
|
|
125
182
|
markRead?: () => void;
|
|
183
|
+
/**
|
|
184
|
+
* Send a guided-topic click. Optional: without it the widget sends the
|
|
185
|
+
* topic's label as an ordinary message, so a custom transport still works.
|
|
186
|
+
*/
|
|
187
|
+
selectTopic?: (event: WidgetClientTopicEvent) => void;
|
|
126
188
|
sendMessage: (event: WidgetClientCreateMessageEvent) => void;
|
|
127
189
|
}
|
|
128
190
|
interface CreateChatTransportOptions {
|
|
@@ -167,7 +229,17 @@ interface ChatWidgetProps {
|
|
|
167
229
|
defaultVisitor?: Partial<ChatWidgetVisitor>;
|
|
168
230
|
getSession: GetSession;
|
|
169
231
|
initiallyOpen?: boolean;
|
|
232
|
+
/** Launcher shape; see {@link ChatWidgetLauncher}. Defaults to `"auto"`. */
|
|
233
|
+
launcher?: ChatWidgetLauncher;
|
|
234
|
+
/** The launcher's visible text, and always its accessible name. */
|
|
170
235
|
launcherLabel?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Where the widget sits; see {@link ChatWidgetPlacement}. Defaults to
|
|
238
|
+
* `"bottom-right"`, floating clear of the device's safe-area insets. Stacks
|
|
239
|
+
* at `--clivly-chat-z-index` (default 2147483000) — lower it through
|
|
240
|
+
* `style` to sit beneath the host's own dialogs.
|
|
241
|
+
*/
|
|
242
|
+
placement?: ChatWidgetPlacement;
|
|
171
243
|
storage?: Pick<Storage, "getItem" | "setItem">;
|
|
172
244
|
/**
|
|
173
245
|
* Inline styles on the widget root. The intended use is overriding palette
|
|
@@ -183,7 +255,7 @@ interface ChatWidgetProps {
|
|
|
183
255
|
theme?: ChatWidgetTheme;
|
|
184
256
|
widgetId: string;
|
|
185
257
|
}
|
|
186
|
-
export declare function ChatWidget({ className, createTransport, defaultVisitor, getSession, initiallyOpen, launcherLabel, storage, style, theme, widgetId }: ChatWidgetProps): ReactElement;
|
|
258
|
+
export declare function ChatWidget({ className, createTransport, defaultVisitor, getSession, initiallyOpen, launcher, launcherLabel, placement, storage, style, theme, widgetId }: ChatWidgetProps): ReactElement;
|
|
187
259
|
export declare function ChatLauncher(): null;
|
|
188
260
|
export declare function ChatPanel(): null;
|
|
189
261
|
export declare function MessageComposer(): null;
|
|
@@ -246,4 +318,4 @@ export declare const createClivlyTransport: typeof createClivlyTransport$1;
|
|
|
246
318
|
export declare const mountChatWidget: typeof mountChatWidget$1;
|
|
247
319
|
export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
|
|
248
320
|
//#endregion
|
|
249
|
-
export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary };
|
|
321
|
+
export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetLauncher, ChatWidgetPlacement, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetAssistantStatusEvent, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetClientTopicEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary, WidgetSupport, WidgetSupportState, WidgetSupportStateEvent, WidgetSupportTopic };
|