open-chat-studio-widget 0.6.0 → 0.8.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 +28 -25
- package/dist/cjs/{index-CcvroTR_.js → index-Cf6K60f1.js} +3 -3
- package/dist/cjs/{index-CcvroTR_.js.map → index-Cf6K60f1.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js +480 -178
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/open-chat-studio-widget.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.entry.cjs.js.map +1 -1
- package/dist/collection/components/ocs-chat/icons.js +2 -2
- package/dist/collection/components/ocs-chat/icons.js.map +1 -1
- package/dist/collection/components/ocs-chat/ocs-chat.css +29 -34
- package/dist/collection/components/ocs-chat/ocs-chat.js +374 -102
- package/dist/collection/components/ocs-chat/ocs-chat.js.map +1 -1
- package/dist/collection/services/chat-session-service.js +39 -1
- package/dist/collection/services/chat-session-service.js.map +1 -1
- package/dist/collection/services/file-attachment-manager.js +4 -7
- package/dist/collection/services/file-attachment-manager.js.map +1 -1
- package/dist/collection/utils/cookies.js.map +1 -1
- package/dist/collection/utils/markdown.js +43 -17
- package/dist/collection/utils/markdown.js.map +1 -1
- package/dist/collection/utils/translations.js +1 -3
- package/dist/collection/utils/translations.js.map +1 -1
- package/dist/collection/utils/utils.js +2 -2
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/open-chat-studio-widget.js +487 -178
- package/dist/components/open-chat-studio-widget.js.map +1 -1
- package/dist/esm/{index-BKVXO_5E.js → index-DXf2dIht.js} +3 -3
- package/dist/esm/{index-BKVXO_5E.js.map → index-DXf2dIht.js.map} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/open-chat-studio-widget.entry.js +480 -178
- package/dist/esm/open-chat-studio-widget.entry.js.map +1 -1
- package/dist/esm/open-chat-studio-widget.js +3 -3
- package/dist/open-chat-studio-widget/open-chat-studio-widget.entry.esm.js.map +1 -1
- package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js +1 -1
- package/dist/open-chat-studio-widget/{p-BKVXO_5E.js → p-DXf2dIht.js} +2 -2
- package/dist/open-chat-studio-widget/{p-BKVXO_5E.js.map → p-DXf2dIht.js.map} +1 -1
- package/dist/open-chat-studio-widget/p-ff47dabf.entry.js +4 -0
- package/dist/open-chat-studio-widget/p-ff47dabf.entry.js.map +1 -0
- package/dist/types/components/ocs-chat/ocs-chat.d.ts +44 -2
- package/dist/types/components.d.ts +33 -4
- package/dist/types/services/chat-session-service.d.ts +7 -0
- package/dist/types/utils/markdown.d.ts +8 -0
- package/package.json +7 -2
- package/dist/open-chat-studio-widget/p-a0d04423.entry.js +0 -4
- package/dist/open-chat-studio-widget/p-a0d04423.entry.js.map +0 -1
|
@@ -37,6 +37,18 @@ export declare class OcsChat {
|
|
|
37
37
|
* The shape of the chat button. 'round' makes it circular, 'square' keeps it rectangular.
|
|
38
38
|
*/
|
|
39
39
|
buttonShape: 'round' | 'square';
|
|
40
|
+
/**
|
|
41
|
+
* Whether to show the launcher button. Set to false to hide the button
|
|
42
|
+
* and open the chat window programmatically via the `visible` property.
|
|
43
|
+
*/
|
|
44
|
+
showButton: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The operating mode of the widget.
|
|
47
|
+
* - 'standard': Default floating window with launcher button.
|
|
48
|
+
* - 'kiosk': Fills parent container, always visible, no header or launcher button.
|
|
49
|
+
* The parent element must establish a containing block (e.g. `position: relative`).
|
|
50
|
+
*/
|
|
51
|
+
mode: 'standard' | 'kiosk';
|
|
40
52
|
/**
|
|
41
53
|
* The text to place in the header.
|
|
42
54
|
*/
|
|
@@ -62,7 +74,7 @@ export declare class OcsChat {
|
|
|
62
74
|
*/
|
|
63
75
|
starterQuestions?: string;
|
|
64
76
|
/**
|
|
65
|
-
|
|
77
|
+
* Used to associate chat sessions with a specific user across multiple visits/sessions
|
|
66
78
|
*/
|
|
67
79
|
userId?: string;
|
|
68
80
|
/**
|
|
@@ -71,6 +83,7 @@ export declare class OcsChat {
|
|
|
71
83
|
userName?: string;
|
|
72
84
|
/**
|
|
73
85
|
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
86
|
+
* Ignored when `sessionId` is provided.
|
|
74
87
|
*/
|
|
75
88
|
persistentSession: boolean;
|
|
76
89
|
/**
|
|
@@ -99,11 +112,25 @@ export declare class OcsChat {
|
|
|
99
112
|
* Optional context object to send with each message. This provides page-specific context to the bot.
|
|
100
113
|
*/
|
|
101
114
|
pageContext?: Record<string, any>;
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
* Optional version number of the chatbot to use. Requires authentication.
|
|
118
|
+
* This is for internal use only and is not intended for public-facing widgets.
|
|
119
|
+
*/
|
|
120
|
+
versionNumber?: number;
|
|
121
|
+
/**
|
|
122
|
+
* The ID of an existing chat session to connect to. When provided, the widget
|
|
123
|
+
* is bound to that session: local session persistence is disabled and the
|
|
124
|
+
* message history is loaded from the server. Intended for host pages that
|
|
125
|
+
* create the session server-side (e.g. the OCS web chat page).
|
|
126
|
+
*/
|
|
127
|
+
sessionId?: string;
|
|
102
128
|
error: string;
|
|
103
129
|
messages: ChatMessage[];
|
|
104
|
-
|
|
130
|
+
activeSessionId?: string;
|
|
105
131
|
isLoading: boolean;
|
|
106
132
|
isTyping: boolean;
|
|
133
|
+
typingProgressMessage: string;
|
|
107
134
|
messageInput: string;
|
|
108
135
|
currentPollTaskId: string;
|
|
109
136
|
isDragging: boolean;
|
|
@@ -148,6 +175,7 @@ export declare class OcsChat {
|
|
|
148
175
|
private chatWindowFullscreenWidth;
|
|
149
176
|
private positionInitialized;
|
|
150
177
|
private internalPageContext?;
|
|
178
|
+
private sessionEpoch;
|
|
151
179
|
host: HTMLElement;
|
|
152
180
|
componentWillLoad(): Promise<void>;
|
|
153
181
|
componentDidLoad(): void;
|
|
@@ -163,6 +191,11 @@ export declare class OcsChat {
|
|
|
163
191
|
private loadTranslationsFromUrl;
|
|
164
192
|
private cleanup;
|
|
165
193
|
private startSession;
|
|
194
|
+
/**
|
|
195
|
+
* Load the full message history for a session provided via the `session-id`
|
|
196
|
+
* prop, then begin regular polling.
|
|
197
|
+
*/
|
|
198
|
+
private loadBoundSessionHistory;
|
|
166
199
|
private uploadFiles;
|
|
167
200
|
private sendMessage;
|
|
168
201
|
private handleStarterQuestionClick;
|
|
@@ -186,6 +219,7 @@ export declare class OcsChat {
|
|
|
186
219
|
* @param pageContext - The new value for the field.
|
|
187
220
|
*/
|
|
188
221
|
pageContextHandler(): void;
|
|
222
|
+
chatbotConfigHandler(): Promise<void>;
|
|
189
223
|
/**
|
|
190
224
|
* Watch for changes to the `visible` attribute and update accordingly.
|
|
191
225
|
*
|
|
@@ -199,6 +233,10 @@ export declare class OcsChat {
|
|
|
199
233
|
getPositionClasses(): string;
|
|
200
234
|
private getFullscreenBounds;
|
|
201
235
|
getPositionStyles(): {
|
|
236
|
+
left?: undefined;
|
|
237
|
+
top?: undefined;
|
|
238
|
+
transform?: undefined;
|
|
239
|
+
} | {
|
|
202
240
|
left: string;
|
|
203
241
|
top: string;
|
|
204
242
|
transform: string;
|
|
@@ -245,7 +283,11 @@ export declare class OcsChat {
|
|
|
245
283
|
private saveSessionToStorage;
|
|
246
284
|
private loadSessionFromStorage;
|
|
247
285
|
private getOrGenerateUserId;
|
|
286
|
+
private saveVisibleState;
|
|
287
|
+
private restoreVisibleState;
|
|
248
288
|
private clearSessionStorage;
|
|
289
|
+
private isKioskMode;
|
|
290
|
+
private isSessionBound;
|
|
249
291
|
private isLocalStorageAvailable;
|
|
250
292
|
private showConfirmationDialog;
|
|
251
293
|
private hideConfirmationDialog;
|
|
@@ -19,7 +19,7 @@ export namespace Components {
|
|
|
19
19
|
"allowFullScreen": boolean;
|
|
20
20
|
/**
|
|
21
21
|
* The base URL for the API.
|
|
22
|
-
* @default
|
|
22
|
+
* @default 'https://www.openchatstudio.com'
|
|
23
23
|
*/
|
|
24
24
|
"apiBaseUrl"?: string;
|
|
25
25
|
/**
|
|
@@ -51,6 +51,11 @@ export namespace Components {
|
|
|
51
51
|
* The language code for the widget UI (e.g., 'en', 'es', 'fr'). Defaults to en
|
|
52
52
|
*/
|
|
53
53
|
"language"?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The operating mode of the widget. - 'standard': Default floating window with launcher button. - 'kiosk': Fills parent container, always visible, no header or launcher button. The parent element must establish a containing block (e.g. `position: relative`).
|
|
56
|
+
* @default 'standard'
|
|
57
|
+
*/
|
|
58
|
+
"mode": 'standard' | 'kiosk';
|
|
54
59
|
/**
|
|
55
60
|
* The message to display in the new chat confirmation dialog.
|
|
56
61
|
*/
|
|
@@ -60,7 +65,7 @@ export namespace Components {
|
|
|
60
65
|
*/
|
|
61
66
|
"pageContext"?: Record<string, any>;
|
|
62
67
|
/**
|
|
63
|
-
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
68
|
+
* Whether to persist session data to local storage to allow resuming previous conversations after page reload. Ignored when `sessionId` is provided.
|
|
64
69
|
* @default true
|
|
65
70
|
*/
|
|
66
71
|
"persistentSession": boolean;
|
|
@@ -74,6 +79,15 @@ export namespace Components {
|
|
|
74
79
|
* @default 'right'
|
|
75
80
|
*/
|
|
76
81
|
"position": 'left' | 'center' | 'right';
|
|
82
|
+
/**
|
|
83
|
+
* The ID of an existing chat session to connect to. When provided, the widget is bound to that session: local session persistence is disabled and the message history is loaded from the server. Intended for host pages that create the session server-side (e.g. the OCS web chat page).
|
|
84
|
+
*/
|
|
85
|
+
"sessionId"?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Whether to show the launcher button. Set to false to hide the button and open the chat window programmatically via the `visible` property.
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
"showButton": boolean;
|
|
77
91
|
/**
|
|
78
92
|
* Array of starter questions that users can click to send (JSON array of strings)
|
|
79
93
|
*/
|
|
@@ -91,6 +105,7 @@ export namespace Components {
|
|
|
91
105
|
* Display name for the user.
|
|
92
106
|
*/
|
|
93
107
|
"userName"?: string;
|
|
108
|
+
"versionNumber"?: number;
|
|
94
109
|
/**
|
|
95
110
|
* Whether the chat widget is visible on load.
|
|
96
111
|
* @default false
|
|
@@ -127,7 +142,7 @@ declare namespace LocalJSX {
|
|
|
127
142
|
"allowFullScreen"?: boolean;
|
|
128
143
|
/**
|
|
129
144
|
* The base URL for the API.
|
|
130
|
-
* @default
|
|
145
|
+
* @default 'https://www.openchatstudio.com'
|
|
131
146
|
*/
|
|
132
147
|
"apiBaseUrl"?: string;
|
|
133
148
|
/**
|
|
@@ -159,6 +174,11 @@ declare namespace LocalJSX {
|
|
|
159
174
|
* The language code for the widget UI (e.g., 'en', 'es', 'fr'). Defaults to en
|
|
160
175
|
*/
|
|
161
176
|
"language"?: string;
|
|
177
|
+
/**
|
|
178
|
+
* The operating mode of the widget. - 'standard': Default floating window with launcher button. - 'kiosk': Fills parent container, always visible, no header or launcher button. The parent element must establish a containing block (e.g. `position: relative`).
|
|
179
|
+
* @default 'standard'
|
|
180
|
+
*/
|
|
181
|
+
"mode"?: 'standard' | 'kiosk';
|
|
162
182
|
/**
|
|
163
183
|
* The message to display in the new chat confirmation dialog.
|
|
164
184
|
*/
|
|
@@ -168,7 +188,7 @@ declare namespace LocalJSX {
|
|
|
168
188
|
*/
|
|
169
189
|
"pageContext"?: Record<string, any>;
|
|
170
190
|
/**
|
|
171
|
-
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
191
|
+
* Whether to persist session data to local storage to allow resuming previous conversations after page reload. Ignored when `sessionId` is provided.
|
|
172
192
|
* @default true
|
|
173
193
|
*/
|
|
174
194
|
"persistentSession"?: boolean;
|
|
@@ -182,6 +202,15 @@ declare namespace LocalJSX {
|
|
|
182
202
|
* @default 'right'
|
|
183
203
|
*/
|
|
184
204
|
"position"?: 'left' | 'center' | 'right';
|
|
205
|
+
/**
|
|
206
|
+
* The ID of an existing chat session to connect to. When provided, the widget is bound to that session: local session persistence is disabled and the message history is loaded from the server. Intended for host pages that create the session server-side (e.g. the OCS web chat page).
|
|
207
|
+
*/
|
|
208
|
+
"sessionId"?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Whether to show the launcher button. Set to false to hide the button and open the chat window programmatically via the `visible` property.
|
|
211
|
+
* @default true
|
|
212
|
+
*/
|
|
213
|
+
"showButton"?: boolean;
|
|
185
214
|
/**
|
|
186
215
|
* Array of starter questions that users can click to send (JSON array of strings)
|
|
187
216
|
*/
|
|
@@ -42,6 +42,7 @@ export interface ChatSessionServiceOptions {
|
|
|
42
42
|
}
|
|
43
43
|
export interface TaskPollingCallbacks {
|
|
44
44
|
onMessage: (message: ChatMessage) => void;
|
|
45
|
+
onProgress?: (message: string) => void;
|
|
45
46
|
onTimeout?: () => void;
|
|
46
47
|
onError?: (error: Error) => void;
|
|
47
48
|
}
|
|
@@ -65,12 +66,18 @@ export declare class ChatSessionService {
|
|
|
65
66
|
private readonly taskPollingMaxAttempts;
|
|
66
67
|
private readonly messagePollingIntervalMs;
|
|
67
68
|
private messagePollingTimer?;
|
|
69
|
+
private static readonly MAX_HISTORY_PAGES;
|
|
68
70
|
constructor(options: ChatSessionServiceOptions);
|
|
69
71
|
startSession(requestBody: Record<string, unknown>): Promise<ChatStartSessionResponse>;
|
|
70
72
|
sendMessage(sessionId: string, payload: Record<string, unknown>): Promise<ChatSendMessageResponse>;
|
|
71
73
|
pollTaskOnce(sessionId: string, taskId: string): Promise<ChatTaskPollResponse>;
|
|
72
74
|
pollTask(sessionId: string, taskId: string, callbacks: TaskPollingCallbacks): TaskPollingHandle;
|
|
73
75
|
fetchMessages(sessionId: string, since?: string): Promise<ChatPollResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Fetch the complete message history for a session by paging through the
|
|
78
|
+
* poll endpoint until no more messages remain.
|
|
79
|
+
*/
|
|
80
|
+
fetchAllMessages(sessionId: string): Promise<ChatMessage[]>;
|
|
74
81
|
startMessagePolling(sessionId: string, callbacks: MessagePollingCallbacks): MessagePollingHandle;
|
|
75
82
|
stopMessagePolling(): void;
|
|
76
83
|
private getJsonHeaders;
|
|
@@ -3,4 +3,12 @@
|
|
|
3
3
|
* This is called after DOMPurify to ensure external links open in new tabs
|
|
4
4
|
*/
|
|
5
5
|
export declare function postProcessMarkdownHTML(html: string): string;
|
|
6
|
+
export declare const SANITIZE_CONFIG: {
|
|
7
|
+
ALLOWED_TAGS: string[];
|
|
8
|
+
ALLOWED_ATTR: string[];
|
|
9
|
+
ALLOWED_URI_REGEXP: RegExp;
|
|
10
|
+
ADD_ATTR: string[];
|
|
11
|
+
FORBID_TAGS: string[];
|
|
12
|
+
FORBID_ATTR: string[];
|
|
13
|
+
};
|
|
6
14
|
export declare function renderMarkdownSync(content: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-chat-studio-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Chat component for Open Chat Studio",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"exports": "./dist/esm/open-chat-studio-widget.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "stencil test --spec -- --forceExit",
|
|
24
|
+
"test:security": "node --test src/utils/markdown-security.test.mjs",
|
|
24
25
|
"build": "stencil build --docs",
|
|
25
26
|
"start": "stencil build --dev --watch --serve",
|
|
26
27
|
"generate": "stencil generate",
|
|
@@ -29,7 +30,9 @@
|
|
|
29
30
|
"prepublishOnly": "run-s build use:npmReadme",
|
|
30
31
|
"postpublish": "npm run use:gitReadme",
|
|
31
32
|
"type-check": "tsc --noEmit",
|
|
32
|
-
"lint": "eslint --fix src"
|
|
33
|
+
"lint": "eslint --fix src",
|
|
34
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
|
|
35
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,css}\""
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
35
38
|
"@stencil/core": "^4.27.0",
|
|
@@ -45,10 +48,12 @@
|
|
|
45
48
|
"@types/jest": "^29.5.14",
|
|
46
49
|
"@types/node": "^22.13.4",
|
|
47
50
|
"autoprefixer": "^10.4.20",
|
|
51
|
+
"happy-dom": "^20.8.4",
|
|
48
52
|
"jest": "^29.7.0",
|
|
49
53
|
"jest-cli": "^29.7.0",
|
|
50
54
|
"npm-run-all": "^4.1.5",
|
|
51
55
|
"postcss-import": "^16.1.0",
|
|
56
|
+
"prettier": "^3.8.3",
|
|
52
57
|
"puppeteer": "^24.2.0",
|
|
53
58
|
"stencil-tailwind-plugin": "^2.0.5",
|
|
54
59
|
"tailwindcss": "^4.1.12",
|