open-chat-studio-widget 0.5.3 → 0.7.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 +27 -24
- package/dist/cjs/{index-D8A4RBzq.js → index-CvB341El.js} +3 -3
- package/dist/cjs/{index-D8A4RBzq.js.map → index-CvB341El.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js +387 -139
- 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 +329 -76
- package/dist/collection/components/ocs-chat/ocs-chat.js.map +1 -1
- package/dist/collection/services/chat-session-service.js +4 -0
- package/dist/collection/services/chat-session-service.js.map +1 -1
- package/dist/collection/services/file-attachment-manager.js +4 -6
- 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 +394 -138
- package/dist/components/open-chat-studio-widget.js.map +1 -1
- package/dist/esm/{index-C53whb-B.js → index-C2QZK0Ui.js} +3 -3
- package/dist/esm/{index-C53whb-B.js.map → index-C2QZK0Ui.js.map} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/open-chat-studio-widget.entry.js +387 -139
- 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-C53whb-B.js → p-C2QZK0Ui.js} +2 -2
- package/dist/open-chat-studio-widget/{p-C53whb-B.js.map → p-C2QZK0Ui.js.map} +1 -1
- package/dist/open-chat-studio-widget/p-e87d4e31.entry.js +4 -0
- package/dist/open-chat-studio-widget/p-e87d4e31.entry.js.map +1 -0
- package/dist/types/components/ocs-chat/ocs-chat.d.ts +41 -1
- package/dist/types/components.d.ts +31 -2
- package/dist/types/services/chat-session-service.d.ts +1 -0
- package/dist/types/utils/markdown.d.ts +8 -0
- package/package.json +7 -2
- package/dist/open-chat-studio-widget/p-b9556259.entry.js +0 -4
- package/dist/open-chat-studio-widget/p-b9556259.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
|
/**
|
|
@@ -95,11 +107,22 @@ export declare class OcsChat {
|
|
|
95
107
|
*/
|
|
96
108
|
language?: string;
|
|
97
109
|
translationsUrl?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Optional context object to send with each message. This provides page-specific context to the bot.
|
|
112
|
+
*/
|
|
113
|
+
pageContext?: Record<string, any>;
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
* Optional version number of the chatbot to use. Requires authentication.
|
|
117
|
+
* This is for internal use only and is not intended for public-facing widgets.
|
|
118
|
+
*/
|
|
119
|
+
versionNumber?: number;
|
|
98
120
|
error: string;
|
|
99
121
|
messages: ChatMessage[];
|
|
100
122
|
sessionId?: string;
|
|
101
123
|
isLoading: boolean;
|
|
102
124
|
isTyping: boolean;
|
|
125
|
+
typingProgressMessage: string;
|
|
103
126
|
messageInput: string;
|
|
104
127
|
currentPollTaskId: string;
|
|
105
128
|
isDragging: boolean;
|
|
@@ -143,6 +166,8 @@ export declare class OcsChat {
|
|
|
143
166
|
private chatWindowWidth;
|
|
144
167
|
private chatWindowFullscreenWidth;
|
|
145
168
|
private positionInitialized;
|
|
169
|
+
private internalPageContext?;
|
|
170
|
+
private sessionEpoch;
|
|
146
171
|
host: HTMLElement;
|
|
147
172
|
componentWillLoad(): Promise<void>;
|
|
148
173
|
componentDidLoad(): void;
|
|
@@ -154,6 +179,7 @@ export declare class OcsChat {
|
|
|
154
179
|
private parseWelcomeMessages;
|
|
155
180
|
private parseStarterQuestions;
|
|
156
181
|
private initializeTranslations;
|
|
182
|
+
private loadInternalPageContext;
|
|
157
183
|
private loadTranslationsFromUrl;
|
|
158
184
|
private cleanup;
|
|
159
185
|
private startSession;
|
|
@@ -174,6 +200,13 @@ export declare class OcsChat {
|
|
|
174
200
|
private formatFileSize;
|
|
175
201
|
private formatTime;
|
|
176
202
|
private toggleWindowVisibility;
|
|
203
|
+
/**
|
|
204
|
+
* Watch for changes to the `pageContext` prop and sync to internal variable.
|
|
205
|
+
*
|
|
206
|
+
* @param pageContext - The new value for the field.
|
|
207
|
+
*/
|
|
208
|
+
pageContextHandler(): void;
|
|
209
|
+
chatbotConfigHandler(): Promise<void>;
|
|
177
210
|
/**
|
|
178
211
|
* Watch for changes to the `visible` attribute and update accordingly.
|
|
179
212
|
*
|
|
@@ -187,6 +220,10 @@ export declare class OcsChat {
|
|
|
187
220
|
getPositionClasses(): string;
|
|
188
221
|
private getFullscreenBounds;
|
|
189
222
|
getPositionStyles(): {
|
|
223
|
+
left?: undefined;
|
|
224
|
+
top?: undefined;
|
|
225
|
+
transform?: undefined;
|
|
226
|
+
} | {
|
|
190
227
|
left: string;
|
|
191
228
|
top: string;
|
|
192
229
|
transform: string;
|
|
@@ -233,7 +270,10 @@ export declare class OcsChat {
|
|
|
233
270
|
private saveSessionToStorage;
|
|
234
271
|
private loadSessionFromStorage;
|
|
235
272
|
private getOrGenerateUserId;
|
|
273
|
+
private saveVisibleState;
|
|
274
|
+
private restoreVisibleState;
|
|
236
275
|
private clearSessionStorage;
|
|
276
|
+
private isKioskMode;
|
|
237
277
|
private isLocalStorageAvailable;
|
|
238
278
|
private showConfirmationDialog;
|
|
239
279
|
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,10 +51,19 @@ 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
|
*/
|
|
57
62
|
"newChatConfirmationMessage"?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Optional context object to send with each message. This provides page-specific context to the bot.
|
|
65
|
+
*/
|
|
66
|
+
"pageContext"?: Record<string, any>;
|
|
58
67
|
/**
|
|
59
68
|
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
60
69
|
* @default true
|
|
@@ -70,6 +79,11 @@ export namespace Components {
|
|
|
70
79
|
* @default 'right'
|
|
71
80
|
*/
|
|
72
81
|
"position": 'left' | 'center' | 'right';
|
|
82
|
+
/**
|
|
83
|
+
* Whether to show the launcher button. Set to false to hide the button and open the chat window programmatically via the `visible` property.
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
"showButton": boolean;
|
|
73
87
|
/**
|
|
74
88
|
* Array of starter questions that users can click to send (JSON array of strings)
|
|
75
89
|
*/
|
|
@@ -87,6 +101,7 @@ export namespace Components {
|
|
|
87
101
|
* Display name for the user.
|
|
88
102
|
*/
|
|
89
103
|
"userName"?: string;
|
|
104
|
+
"versionNumber"?: number;
|
|
90
105
|
/**
|
|
91
106
|
* Whether the chat widget is visible on load.
|
|
92
107
|
* @default false
|
|
@@ -123,7 +138,7 @@ declare namespace LocalJSX {
|
|
|
123
138
|
"allowFullScreen"?: boolean;
|
|
124
139
|
/**
|
|
125
140
|
* The base URL for the API.
|
|
126
|
-
* @default
|
|
141
|
+
* @default 'https://www.openchatstudio.com'
|
|
127
142
|
*/
|
|
128
143
|
"apiBaseUrl"?: string;
|
|
129
144
|
/**
|
|
@@ -155,10 +170,19 @@ declare namespace LocalJSX {
|
|
|
155
170
|
* The language code for the widget UI (e.g., 'en', 'es', 'fr'). Defaults to en
|
|
156
171
|
*/
|
|
157
172
|
"language"?: string;
|
|
173
|
+
/**
|
|
174
|
+
* 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`).
|
|
175
|
+
* @default 'standard'
|
|
176
|
+
*/
|
|
177
|
+
"mode"?: 'standard' | 'kiosk';
|
|
158
178
|
/**
|
|
159
179
|
* The message to display in the new chat confirmation dialog.
|
|
160
180
|
*/
|
|
161
181
|
"newChatConfirmationMessage"?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Optional context object to send with each message. This provides page-specific context to the bot.
|
|
184
|
+
*/
|
|
185
|
+
"pageContext"?: Record<string, any>;
|
|
162
186
|
/**
|
|
163
187
|
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
164
188
|
* @default true
|
|
@@ -174,6 +198,11 @@ declare namespace LocalJSX {
|
|
|
174
198
|
* @default 'right'
|
|
175
199
|
*/
|
|
176
200
|
"position"?: 'left' | 'center' | 'right';
|
|
201
|
+
/**
|
|
202
|
+
* Whether to show the launcher button. Set to false to hide the button and open the chat window programmatically via the `visible` property.
|
|
203
|
+
* @default true
|
|
204
|
+
*/
|
|
205
|
+
"showButton"?: boolean;
|
|
177
206
|
/**
|
|
178
207
|
* Array of starter questions that users can click to send (JSON array of strings)
|
|
179
208
|
*/
|
|
@@ -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.7.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",
|