open-chat-studio-widget 0.3.1 → 0.4.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 +14 -7
- package/dist/cjs/{index-d39b7c53.js → index-b700441a.js} +83 -4
- package/dist/cjs/index-b700441a.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js +4846 -50
- 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/collection/components/ocs-chat/heroicons.js +6 -12
- package/dist/collection/components/ocs-chat/heroicons.js.map +1 -1
- package/dist/collection/components/ocs-chat/ocs-chat.css +1094 -73
- package/dist/collection/components/ocs-chat/ocs-chat.js +752 -40
- package/dist/collection/components/ocs-chat/ocs-chat.js.map +1 -1
- package/dist/collection/utils/markdown.js +64 -0
- package/dist/collection/utils/markdown.js.map +1 -0
- package/dist/components/open-chat-studio-widget.js +4869 -52
- package/dist/components/open-chat-studio-widget.js.map +1 -1
- package/dist/esm/{index-b73ebc69.js → index-b188b488.js} +83 -4
- package/dist/esm/index-b188b488.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/open-chat-studio-widget.entry.js +4846 -50
- 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.esm.js +1 -1
- package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js.map +1 -1
- package/dist/open-chat-studio-widget/p-a0fbe1b4.js +3 -0
- package/dist/open-chat-studio-widget/p-a0fbe1b4.js.map +1 -0
- package/dist/open-chat-studio-widget/p-d2d76b54.entry.js +3 -0
- package/dist/open-chat-studio-widget/p-d2d76b54.entry.js.map +1 -0
- package/dist/types/components/ocs-chat/heroicons.d.ts +2 -4
- package/dist/types/components/ocs-chat/ocs-chat.d.ts +129 -4
- package/dist/types/components.d.ts +61 -5
- package/dist/types/utils/markdown.d.ts +6 -0
- package/package.json +4 -3
- package/dist/cjs/index-d39b7c53.js.map +0 -1
- package/dist/esm/index-b73ebc69.js.map +0 -1
- package/dist/open-chat-studio-widget/p-4cdc34c1.js +0 -3
- package/dist/open-chat-studio-widget/p-4cdc34c1.js.map +0 -1
- package/dist/open-chat-studio-widget/p-c4c7c404.entry.js +0 -2
- package/dist/open-chat-studio-widget/p-c4c7c404.entry.js.map +0 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export declare const ArrowLeftEndOnRectangleIcon: () => any;
|
|
2
|
-
export declare const ArrowRightEndOnRectangleIcon: () => any;
|
|
3
|
-
export declare const ArrowDownOnSquareIcon: () => any;
|
|
4
|
-
export declare const ViewfinderCircleIcon: () => any;
|
|
5
1
|
export declare const XMarkIcon: () => any;
|
|
6
2
|
export declare const ChevronUpIcon: () => any;
|
|
7
3
|
export declare const ChevronDownIcon: () => any;
|
|
4
|
+
export declare const GripDotsVerticalIcon: () => any;
|
|
5
|
+
export declare const PencilSquare: () => any;
|
|
@@ -1,12 +1,48 @@
|
|
|
1
|
+
interface ChatMessage {
|
|
2
|
+
created_at: string;
|
|
3
|
+
role: 'system' | 'user' | 'assistant';
|
|
4
|
+
content: string;
|
|
5
|
+
metadata?: any;
|
|
6
|
+
attachments?: ChatAttachment[];
|
|
7
|
+
}
|
|
8
|
+
interface ChatAttachment {
|
|
9
|
+
name: string;
|
|
10
|
+
content_type: string;
|
|
11
|
+
size: number;
|
|
12
|
+
content_url: string;
|
|
13
|
+
}
|
|
1
14
|
export declare class OcsChat {
|
|
15
|
+
private static readonly TASK_POLLING_MAX_ATTEMPTS;
|
|
16
|
+
private static readonly TASK_POLLING_INTERVAL_MS;
|
|
17
|
+
private static readonly MESSAGE_POLLING_INTERVAL_MS;
|
|
18
|
+
private static readonly SCROLL_DELAY_MS;
|
|
19
|
+
private static readonly FOCUS_DELAY_MS;
|
|
20
|
+
private static readonly CHAT_WIDTH_DESKTOP;
|
|
21
|
+
private static readonly CHAT_HEIGHT_EXPANDED_RATIO;
|
|
22
|
+
private static readonly CHAT_HEIGHT_COLLAPSED_RATIO;
|
|
23
|
+
private static readonly MOBILE_BREAKPOINT;
|
|
24
|
+
private static readonly WINDOW_MARGIN;
|
|
25
|
+
private static readonly LOCALSTORAGE_TEST_KEY;
|
|
26
|
+
/**
|
|
27
|
+
* The ID of the chatbot to connect to.
|
|
28
|
+
*/
|
|
29
|
+
chatbotId: string;
|
|
2
30
|
/**
|
|
3
|
-
* The URL
|
|
31
|
+
* The base URL for the API (defaults to current origin).
|
|
4
32
|
*/
|
|
5
|
-
|
|
33
|
+
apiBaseUrl?: string;
|
|
6
34
|
/**
|
|
7
35
|
* The text to display on the button.
|
|
8
36
|
*/
|
|
9
|
-
buttonText
|
|
37
|
+
buttonText?: string;
|
|
38
|
+
/**
|
|
39
|
+
* URL of the icon to display on the button. If not provided, uses the default OCS logo.
|
|
40
|
+
*/
|
|
41
|
+
iconUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The shape of the chat button. 'round' makes it circular, 'square' keeps it rectangular.
|
|
44
|
+
*/
|
|
45
|
+
buttonShape: 'round' | 'square';
|
|
10
46
|
/**
|
|
11
47
|
* Whether the chat widget is visible on load.
|
|
12
48
|
*/
|
|
@@ -19,12 +55,101 @@ export declare class OcsChat {
|
|
|
19
55
|
* Whether the chat widget is initially expanded.
|
|
20
56
|
*/
|
|
21
57
|
expanded: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Welcome messages to display above starter questions (JSON array of strings)
|
|
60
|
+
*/
|
|
61
|
+
welcomeMessages?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Array of starter questions that users can click to send (JSON array of strings)
|
|
64
|
+
*/
|
|
65
|
+
starterQuestions?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
68
|
+
*/
|
|
69
|
+
persistentSession: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Minutes since the most recent message after which the session data in local storage will expire. Set this to
|
|
72
|
+
* `0` to never expire.
|
|
73
|
+
*/
|
|
74
|
+
persistentSessionExpire: number;
|
|
22
75
|
loaded: boolean;
|
|
23
76
|
error: string;
|
|
77
|
+
messages: ChatMessage[];
|
|
78
|
+
sessionId?: string;
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
isTyping: boolean;
|
|
81
|
+
messageInput: string;
|
|
82
|
+
pollingInterval?: any;
|
|
83
|
+
lastPollTime?: Date;
|
|
84
|
+
isTaskPolling: boolean;
|
|
85
|
+
isDragging: boolean;
|
|
86
|
+
dragOffset: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
};
|
|
90
|
+
windowPosition: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
};
|
|
94
|
+
showStarterQuestions: boolean;
|
|
95
|
+
parsedWelcomeMessages: string[];
|
|
96
|
+
parsedStarterQuestions: string[];
|
|
97
|
+
private messageListRef?;
|
|
98
|
+
private textareaRef?;
|
|
99
|
+
private chatWindowRef?;
|
|
24
100
|
componentWillLoad(): void;
|
|
25
|
-
|
|
101
|
+
componentDidLoad(): void;
|
|
102
|
+
disconnectedCallback(): void;
|
|
103
|
+
private parseJSONProp;
|
|
104
|
+
private parseWelcomeMessages;
|
|
105
|
+
private parseStarterQuestions;
|
|
106
|
+
private cleanup;
|
|
107
|
+
private getApiBaseUrl;
|
|
108
|
+
private startSession;
|
|
109
|
+
private sendMessage;
|
|
110
|
+
private handleStarterQuestionClick;
|
|
111
|
+
private pollTaskResponse;
|
|
112
|
+
private startPolling;
|
|
113
|
+
private pauseMessagePolling;
|
|
114
|
+
private resumeMessagePolling;
|
|
115
|
+
private pollForMessages;
|
|
116
|
+
private clearError;
|
|
117
|
+
private scrollToBottom;
|
|
118
|
+
private focusInput;
|
|
119
|
+
private handleKeyPress;
|
|
120
|
+
private handleInputChange;
|
|
121
|
+
private formatTime;
|
|
122
|
+
load(): Promise<void>;
|
|
26
123
|
setPosition(position: 'left' | 'center' | 'right'): void;
|
|
27
124
|
toggleSize(): void;
|
|
28
125
|
getPositionClasses(): string;
|
|
126
|
+
getPositionStyles(): {
|
|
127
|
+
left: string;
|
|
128
|
+
top: string;
|
|
129
|
+
};
|
|
130
|
+
private initializePosition;
|
|
131
|
+
private getPointerCoordinates;
|
|
132
|
+
private startDrag;
|
|
133
|
+
private updateDragPosition;
|
|
134
|
+
private endDrag;
|
|
135
|
+
private addEventListeners;
|
|
136
|
+
private removeEventListeners;
|
|
137
|
+
private handleMouseDown;
|
|
138
|
+
private handleMouseMove;
|
|
139
|
+
private handleMouseUp;
|
|
140
|
+
private handleTouchStart;
|
|
141
|
+
private handleTouchMove;
|
|
142
|
+
private handleTouchEnd;
|
|
143
|
+
private handleWindowResize;
|
|
144
|
+
private getDefaultIconUrl;
|
|
145
|
+
private getButtonClasses;
|
|
146
|
+
private renderButton;
|
|
147
|
+
private getStorageKeys;
|
|
148
|
+
private saveSessionToStorage;
|
|
149
|
+
private loadSessionFromStorage;
|
|
150
|
+
private clearSessionStorage;
|
|
151
|
+
private isLocalStorageAvailable;
|
|
152
|
+
private startNewChat;
|
|
29
153
|
render(): any;
|
|
30
154
|
}
|
|
155
|
+
export {};
|
|
@@ -8,25 +8,53 @@ import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
|
8
8
|
export namespace Components {
|
|
9
9
|
interface OpenChatStudioWidget {
|
|
10
10
|
/**
|
|
11
|
-
* The URL
|
|
11
|
+
* The base URL for the API (defaults to current origin).
|
|
12
12
|
*/
|
|
13
|
-
"
|
|
13
|
+
"apiBaseUrl"?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The shape of the chat button. 'round' makes it circular, 'square' keeps it rectangular.
|
|
16
|
+
*/
|
|
17
|
+
"buttonShape": 'round' | 'square';
|
|
14
18
|
/**
|
|
15
19
|
* The text to display on the button.
|
|
16
20
|
*/
|
|
17
|
-
"buttonText"
|
|
21
|
+
"buttonText"?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The ID of the chatbot to connect to.
|
|
24
|
+
*/
|
|
25
|
+
"chatbotId": string;
|
|
18
26
|
/**
|
|
19
27
|
* Whether the chat widget is initially expanded.
|
|
20
28
|
*/
|
|
21
29
|
"expanded": boolean;
|
|
30
|
+
/**
|
|
31
|
+
* URL of the icon to display on the button. If not provided, uses the default OCS logo.
|
|
32
|
+
*/
|
|
33
|
+
"iconUrl"?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
36
|
+
*/
|
|
37
|
+
"persistentSession": boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Minutes since the most recent message after which the session data in local storage will expire. Set this to `0` to never expire.
|
|
40
|
+
*/
|
|
41
|
+
"persistentSessionExpire": number;
|
|
22
42
|
/**
|
|
23
43
|
* The initial position of the chat widget on the screen.
|
|
24
44
|
*/
|
|
25
45
|
"position": 'left' | 'center' | 'right';
|
|
46
|
+
/**
|
|
47
|
+
* Array of starter questions that users can click to send (JSON array of strings)
|
|
48
|
+
*/
|
|
49
|
+
"starterQuestions"?: string;
|
|
26
50
|
/**
|
|
27
51
|
* Whether the chat widget is visible on load.
|
|
28
52
|
*/
|
|
29
53
|
"visible": boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Welcome messages to display above starter questions (JSON array of strings)
|
|
56
|
+
*/
|
|
57
|
+
"welcomeMessages"?: string;
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
declare global {
|
|
@@ -43,25 +71,53 @@ declare global {
|
|
|
43
71
|
declare namespace LocalJSX {
|
|
44
72
|
interface OpenChatStudioWidget {
|
|
45
73
|
/**
|
|
46
|
-
* The URL
|
|
74
|
+
* The base URL for the API (defaults to current origin).
|
|
47
75
|
*/
|
|
48
|
-
"
|
|
76
|
+
"apiBaseUrl"?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The shape of the chat button. 'round' makes it circular, 'square' keeps it rectangular.
|
|
79
|
+
*/
|
|
80
|
+
"buttonShape"?: 'round' | 'square';
|
|
49
81
|
/**
|
|
50
82
|
* The text to display on the button.
|
|
51
83
|
*/
|
|
52
84
|
"buttonText"?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The ID of the chatbot to connect to.
|
|
87
|
+
*/
|
|
88
|
+
"chatbotId": string;
|
|
53
89
|
/**
|
|
54
90
|
* Whether the chat widget is initially expanded.
|
|
55
91
|
*/
|
|
56
92
|
"expanded"?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* URL of the icon to display on the button. If not provided, uses the default OCS logo.
|
|
95
|
+
*/
|
|
96
|
+
"iconUrl"?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Whether to persist session data to local storage to allow resuming previous conversations after page reload.
|
|
99
|
+
*/
|
|
100
|
+
"persistentSession"?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Minutes since the most recent message after which the session data in local storage will expire. Set this to `0` to never expire.
|
|
103
|
+
*/
|
|
104
|
+
"persistentSessionExpire"?: number;
|
|
57
105
|
/**
|
|
58
106
|
* The initial position of the chat widget on the screen.
|
|
59
107
|
*/
|
|
60
108
|
"position"?: 'left' | 'center' | 'right';
|
|
109
|
+
/**
|
|
110
|
+
* Array of starter questions that users can click to send (JSON array of strings)
|
|
111
|
+
*/
|
|
112
|
+
"starterQuestions"?: string;
|
|
61
113
|
/**
|
|
62
114
|
* Whether the chat widget is visible on load.
|
|
63
115
|
*/
|
|
64
116
|
"visible"?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Welcome messages to display above starter questions (JSON array of strings)
|
|
119
|
+
*/
|
|
120
|
+
"welcomeMessages"?: string;
|
|
65
121
|
}
|
|
66
122
|
interface IntrinsicElements {
|
|
67
123
|
"open-chat-studio-widget": OpenChatStudioWidget;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-processes rendered HTML to add additional attributes
|
|
3
|
+
* This is called after DOMPurify to ensure external links open in new tabs
|
|
4
|
+
*/
|
|
5
|
+
export declare function postProcessMarkdownHTML(html: string): string;
|
|
6
|
+
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.4.0",
|
|
4
4
|
"description": "Chat component for Open Chat Studio",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "stencil build --docs",
|
|
23
23
|
"start": "stencil build --dev --watch --serve",
|
|
24
|
-
"test": "stencil test --spec --e2e",
|
|
25
|
-
"test.watch": "stencil test --spec --e2e --watchAll",
|
|
26
24
|
"generate": "stencil generate",
|
|
27
25
|
"use:npmReadme": "mv 'README.md' 'git.README.md' && cp 'src/components/ocs-chat/readme.md' 'README.md'",
|
|
28
26
|
"use:gitReadme": "mv 'git.README.md' 'README.md'",
|
|
@@ -31,10 +29,13 @@
|
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
31
|
"@stencil/core": "^4.26.0",
|
|
32
|
+
"dompurify": "^3.0.5",
|
|
33
|
+
"marked": "^4.3.0",
|
|
34
34
|
"npmrc": "^1.1.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@stencil-community/postcss": "^2.2.0",
|
|
38
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
38
39
|
"@types/jest": "^29.5.14",
|
|
39
40
|
"@types/node": "^22.13.4",
|
|
40
41
|
"autoprefixer": "^10.4.20",
|