embeddedaichatux 1.6.0 → 1.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/EmbeddedChat.js +71 -16
- package/package.json +5 -2
- package/AIChat.npm.csproj +0 -29
- package/AIChat.npm.csproj.user +0 -6
- package/AIChat.npm.sln +0 -25
- package/Properties/launchSettings.json +0 -37
package/EmbeddedChat.js
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
this.positionStyle = this.containerDiv.dataset.position === 'in-place' ?
|
|
25
25
|
`width:100%; height:${this.height}px; ${transitionStyle}` :
|
|
26
|
-
`position: fixed; right:
|
|
27
|
-
this.mode = options.mode || 'Chat'; // default to 'chat'
|
|
26
|
+
`position: fixed; right: 1em; bottom: 0; width: ${this.width}px; height: ${this.height}px; z-index: 100000; max-width:80%; ${transitionStyle}`;
|
|
27
|
+
this.mode = options.mode || 'Chat'; // default to 'chat'
|
|
28
28
|
this.minimizeOnScroll = false; // Default to false
|
|
29
29
|
if (this.mode === 'ContactForm') {
|
|
30
30
|
// Adjust position style for contact form if mode is 'ContactForm'
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
this.conversationId = this.getStoredConversationId();
|
|
36
|
-
|
|
37
36
|
this.sessionInfo = options.sessionInfo || null;
|
|
38
37
|
this.init();
|
|
39
38
|
}
|
|
@@ -65,7 +64,6 @@
|
|
|
65
64
|
const previousId = this.conversationId || 'null';
|
|
66
65
|
|
|
67
66
|
if (newConversationId !== previousId) {
|
|
68
|
-
// Separate block for changes to allow breakpoint placement
|
|
69
67
|
this.conversationId = newConversationId;
|
|
70
68
|
this.setStoredConversationId(newConversationId);
|
|
71
69
|
}
|
|
@@ -92,7 +90,6 @@
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
addEventListeners() {
|
|
95
|
-
// Add event listeners to track mouse position
|
|
96
93
|
this.iframe.addEventListener("mouseenter", () => { this.mouseInsideChat = true; });
|
|
97
94
|
this.iframe.addEventListener("mouseleave", () => { this.mouseInsideChat = false; });
|
|
98
95
|
this.minimizedIframe.addEventListener("mouseenter", () => { this.mouseInsideChat = true; });
|
|
@@ -111,9 +108,30 @@
|
|
|
111
108
|
|
|
112
109
|
handleMessage(e) {
|
|
113
110
|
if (typeof e.data === "object" && (!e.data.chatId || e.data.chatId === this.chatId)) {
|
|
111
|
+
const updates = {};
|
|
112
|
+
|
|
113
|
+
// Preserve minimize on scroll functionality
|
|
114
114
|
if (e.data.type === "setMinimizeOnScroll") {
|
|
115
115
|
this.minimizeOnScroll = e.data.value === "true";
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
// Collect updates for locale, width, and scale
|
|
119
|
+
if (e.data.locale) {
|
|
120
|
+
updates.locale = e.data.locale;
|
|
121
|
+
}
|
|
122
|
+
if (e.data.width) {
|
|
123
|
+
updates.width = e.data.width;
|
|
124
|
+
}
|
|
125
|
+
if (e.data.scale) {
|
|
126
|
+
updates.scale = e.data.scale;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Apply iframe updates (locale, width, scale) in one go
|
|
130
|
+
if (Object.keys(updates).length > 0) {
|
|
131
|
+
this.applyIframeUpdates(updates);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Handle maximize/minimize
|
|
117
135
|
if (e.data.message) {
|
|
118
136
|
if (e.data.message === "minimize") {
|
|
119
137
|
if (this.mode !== 'ContactForm') {
|
|
@@ -122,19 +140,14 @@
|
|
|
122
140
|
} else if (e.data.message === "show" || e.data.message === "maximize") {
|
|
123
141
|
this.showMaximized();
|
|
124
142
|
}
|
|
125
|
-
if (e.data.scale) {
|
|
126
|
-
this.applyScale(e.data.scale);
|
|
127
|
-
}
|
|
128
|
-
if (this.sessionInfo !== null) {
|
|
129
|
-
this.setSessionInfo(this.sessionInfo);
|
|
130
|
-
}
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
//
|
|
145
|
+
// Handle conversationId update
|
|
134
146
|
if (e.data.conversationId) {
|
|
135
147
|
this.setConversationId(e.data.conversationId);
|
|
136
148
|
}
|
|
137
149
|
} else if (typeof e.data === "string") {
|
|
150
|
+
// Preserve original handling for string messages
|
|
138
151
|
if (e.data === "minimize") {
|
|
139
152
|
this.animateMinimize();
|
|
140
153
|
} else if (e.data === "show" || e.data === "maximize") {
|
|
@@ -146,17 +159,59 @@
|
|
|
146
159
|
animateMinimize() {
|
|
147
160
|
if (this.mode !== 'ContactForm') {
|
|
148
161
|
this.iframe.style.height = this.minimizedHeight;
|
|
149
|
-
this.iframe.style.opacity = '0';
|
|
162
|
+
this.iframe.style.opacity = '0';
|
|
150
163
|
setTimeout(() => {
|
|
151
164
|
this.iframe.style.display = "none";
|
|
152
|
-
this.iframe.style.opacity = '1';
|
|
165
|
+
this.iframe.style.opacity = '1';
|
|
153
166
|
this.minimizedIframe.style.display = "block";
|
|
154
167
|
this.minimizedIframe.style.height = this.minimizedHeight;
|
|
155
|
-
this.minimizedIframe.style.opacity = '1';
|
|
156
|
-
}, this.enableAnimation ? 300 : 0);
|
|
168
|
+
this.minimizedIframe.style.opacity = '1';
|
|
169
|
+
}, this.enableAnimation ? 300 : 0);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
applyIframeUpdates({ locale, width, scale } = {}) {
|
|
174
|
+
// Update locale if provided and different (but do not update the iframe URL)
|
|
175
|
+
if (locale && typeof locale === 'string' && locale !== this.locale) {
|
|
176
|
+
this.locale = locale;
|
|
177
|
+
console.log(`Locale stored locally: ${this.locale}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Update width if provided and different
|
|
181
|
+
const parsedWidth = parseInt(width, 10);
|
|
182
|
+
if (!isNaN(parsedWidth) && parsedWidth > 0 && parsedWidth !== this.width) {
|
|
183
|
+
this.width = Math.max(parsedWidth, 320);
|
|
184
|
+
console.log(`Width updated to: ${this.width}px`);
|
|
185
|
+
|
|
186
|
+
// Apply width to container
|
|
187
|
+
this.containerDiv.style.width = `${this.width}px`;
|
|
188
|
+
|
|
189
|
+
// Apply width to the main iframe
|
|
190
|
+
if (this.iframe) {
|
|
191
|
+
this.iframe.style.width = `${this.width}px`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Apply width to the minimized iframe
|
|
195
|
+
if (this.minimizedIframe) {
|
|
196
|
+
this.minimizedIframe.style.width = `${this.width}px`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Apply scale if provided
|
|
201
|
+
if (typeof scale === 'number' && scale > 0) {
|
|
202
|
+
if (this.iframe) {
|
|
203
|
+
this.iframe.style.transform = `scale(${scale})`;
|
|
204
|
+
this.iframe.style.transformOrigin = "bottom right";
|
|
205
|
+
}
|
|
206
|
+
if (this.minimizedIframe) {
|
|
207
|
+
this.minimizedIframe.style.transform = `scale(${scale})`;
|
|
208
|
+
this.minimizedIframe.style.transformOrigin = "bottom right";
|
|
209
|
+
}
|
|
210
|
+
console.log(`Scale applied: ${scale}`);
|
|
157
211
|
}
|
|
158
212
|
}
|
|
159
213
|
|
|
214
|
+
|
|
160
215
|
showMaximized() {
|
|
161
216
|
this.minimizedIframe.style.display = "none";
|
|
162
217
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embeddedaichatux",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A lightweight and customizable embedded AI chat UI component that seamlessly integrates into web applications, offering minimized and expanded views, with iframe-based content rendering.",
|
|
5
5
|
"main": "EmbeddedChat.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"author": "EmbedGPT.chat, LLC",
|
|
10
|
-
"license": "MIT"
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"files": [
|
|
12
|
+
"EmbeddedChat.js"
|
|
13
|
+
]
|
|
11
14
|
}
|
package/AIChat.npm.csproj
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
|
-
|
|
3
|
-
<PropertyGroup>
|
|
4
|
-
<TargetFramework>net7.0</TargetFramework>
|
|
5
|
-
<Nullable>enable</Nullable>
|
|
6
|
-
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
-
</PropertyGroup>
|
|
8
|
-
|
|
9
|
-
<Target Name="CopyCommonWebFiles" BeforeTargets="Build">
|
|
10
|
-
<ItemGroup>
|
|
11
|
-
<_CommonWebJsFiles Include="..\AIChat.Web\wwwroot\js\EmbeddedChat.js" />
|
|
12
|
-
</ItemGroup>
|
|
13
|
-
|
|
14
|
-
<Copy SourceFiles="@(_CommonWebJsFiles)" DestinationFolder="$(MSBuildProjectDirectory)" SkipUnchangedFiles="true" />
|
|
15
|
-
</Target>
|
|
16
|
-
|
|
17
|
-
<ItemGroup>
|
|
18
|
-
<None Remove="EmbeddedChat.js" />
|
|
19
|
-
</ItemGroup>
|
|
20
|
-
|
|
21
|
-
<ItemGroup>
|
|
22
|
-
<Content Include="EmbeddedChat.js">
|
|
23
|
-
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
|
24
|
-
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
|
25
|
-
</Content>
|
|
26
|
-
</ItemGroup>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</Project>
|
package/AIChat.npm.csproj.user
DELETED
package/AIChat.npm.sln
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
3
|
-
# Visual Studio Version 17
|
|
4
|
-
VisualStudioVersion = 17.7.34024.191
|
|
5
|
-
MinimumVisualStudioVersion = 10.0.40219.1
|
|
6
|
-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIChat.npm", "AIChat.npm.csproj", "{37DB7D9F-39C4-428D-A205-7E78FAB8BB25}"
|
|
7
|
-
EndProject
|
|
8
|
-
Global
|
|
9
|
-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
10
|
-
Debug|Any CPU = Debug|Any CPU
|
|
11
|
-
Release|Any CPU = Release|Any CPU
|
|
12
|
-
EndGlobalSection
|
|
13
|
-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
14
|
-
{37DB7D9F-39C4-428D-A205-7E78FAB8BB25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
15
|
-
{37DB7D9F-39C4-428D-A205-7E78FAB8BB25}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
16
|
-
{37DB7D9F-39C4-428D-A205-7E78FAB8BB25}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
17
|
-
{37DB7D9F-39C4-428D-A205-7E78FAB8BB25}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
18
|
-
EndGlobalSection
|
|
19
|
-
GlobalSection(SolutionProperties) = preSolution
|
|
20
|
-
HideSolutionNode = FALSE
|
|
21
|
-
EndGlobalSection
|
|
22
|
-
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
23
|
-
SolutionGuid = {33D9F6CE-532F-4C22-AAAD-2D8B3BB56596}
|
|
24
|
-
EndGlobalSection
|
|
25
|
-
EndGlobal
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"iisSettings": {
|
|
3
|
-
"windowsAuthentication": false,
|
|
4
|
-
"anonymousAuthentication": true,
|
|
5
|
-
"iisExpress": {
|
|
6
|
-
"applicationUrl": "http://localhost:27434",
|
|
7
|
-
"sslPort": 44389
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"profiles": {
|
|
11
|
-
"http": {
|
|
12
|
-
"commandName": "Project",
|
|
13
|
-
"dotnetRunMessages": true,
|
|
14
|
-
"launchBrowser": true,
|
|
15
|
-
"applicationUrl": "http://localhost:5103",
|
|
16
|
-
"environmentVariables": {
|
|
17
|
-
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"https": {
|
|
21
|
-
"commandName": "Project",
|
|
22
|
-
"dotnetRunMessages": true,
|
|
23
|
-
"launchBrowser": true,
|
|
24
|
-
"applicationUrl": "https://localhost:7299;http://localhost:5103",
|
|
25
|
-
"environmentVariables": {
|
|
26
|
-
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"IIS Express": {
|
|
30
|
-
"commandName": "IISExpress",
|
|
31
|
-
"launchBrowser": true,
|
|
32
|
-
"environmentVariables": {
|
|
33
|
-
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|