embeddedaichatux 1.0.1 → 1.0.5
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/AIChat.npm.csproj +8 -7
- package/EmbeddedChat.js +51 -20
- package/README.md +8 -1
- package/bin/Debug/net7.0/package.json +1 -1
- package/obj/Debug/net7.0/AIChat.npm.csproj.FileListAbsolute.txt +0 -1
- package/obj/Debug/net7.0/staticwebassets.build.json +2 -10
- package/package.json +1 -1
- package/bin/Debug/net7.0/AIChat.npm.staticwebassets.runtime.json +0 -1
- package/obj/Debug/net7.0/staticwebassets.development.json +0 -1
package/AIChat.npm.csproj
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
2
|
|
|
3
3
|
<PropertyGroup>
|
|
4
4
|
<TargetFramework>net7.0</TargetFramework>
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
7
|
</PropertyGroup>
|
|
8
8
|
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
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>
|
|
12
16
|
|
|
13
|
-
<ItemGroup>
|
|
14
|
-
<Content Include="EmbeddedChat.js" />
|
|
15
|
-
</ItemGroup>
|
|
16
17
|
|
|
17
18
|
</Project>
|
package/EmbeddedChat.js
CHANGED
|
@@ -1,44 +1,75 @@
|
|
|
1
|
+
// embeddedChat.js
|
|
1
2
|
class EmbeddedChat {
|
|
2
3
|
constructor(containerDiv, chatId, options) {
|
|
4
|
+
if (!containerDiv) {
|
|
5
|
+
containerDiv = this.createChatContainer();
|
|
6
|
+
}
|
|
3
7
|
this.containerDiv = containerDiv;
|
|
4
8
|
this.chatId = chatId;
|
|
5
9
|
this.options = options || {};
|
|
6
|
-
this.avatarImage = this.options.avatarImage || '/img/avatar.jpg';
|
|
7
10
|
this.isPreview = this.options.isPreview || false;
|
|
8
11
|
this.previewParam = this.isPreview ? "?isPreview=true" : "";
|
|
12
|
+
this.serverUrl = this.options.serverUrl || 'https://embedgpt.chat/';
|
|
9
13
|
this.positionStyle = this.containerDiv.dataset.position === 'in-place' ? 'width:100%; height:600px' : 'position: fixed; right: 0; bottom: 0; width: 300px; height: 600px';
|
|
10
14
|
this.init();
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
init() {
|
|
18
|
+
const cleanedServerUrl = this.serverUrl.endsWith('/') ? this.serverUrl.slice(0, -1) : this.serverUrl;
|
|
19
|
+
const baseIframeUrl = `${cleanedServerUrl}/ChatUX/${this.chatId}`;
|
|
20
|
+
const previewQueryString = this.isPreview ? "?isPreview=true" : "";
|
|
21
|
+
const minimizedQueryString = this.isPreview ? "&isMinimized=true" : "?isMinimized=true";
|
|
22
|
+
|
|
23
|
+
const minimizedPositionStyle = 'position: fixed; right: 0; bottom: 0; width: 300px; height: 70px;';
|
|
24
|
+
|
|
14
25
|
const iframeHtml = `
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</div>
|
|
19
|
-
<iframe id="embedded-chat" style="${this.positionStyle}; display: none; border:none; overflow:hidden;" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="https://embedgpt.chat/ChatUX/${this.chatId}${this.previewParam}"></iframe>
|
|
20
|
-
`;
|
|
26
|
+
<iframe id="embedded-chat" style="${this.positionStyle}; display: none; border:none; overflow:hidden;" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="${baseIframeUrl}${previewQueryString}"></iframe>
|
|
27
|
+
<iframe id="embedded-chat-minimized" style="${minimizedPositionStyle}; display: none; border:none; overflow:hidden;" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="${baseIframeUrl}${previewQueryString}${minimizedQueryString}"></iframe>
|
|
28
|
+
`;
|
|
21
29
|
|
|
22
30
|
this.containerDiv.innerHTML = iframeHtml;
|
|
23
31
|
this.iframe = this.containerDiv.querySelector("#embedded-chat");
|
|
24
|
-
this.
|
|
25
|
-
this.chatNowButton = this.containerDiv.querySelector("#embedded-chat-now");
|
|
26
|
-
|
|
27
|
-
this.chatNowButton.addEventListener("click", () => {
|
|
28
|
-
this.iframe.style.display = "block";
|
|
29
|
-
this.minimizedDiv.style.display = "none";
|
|
30
|
-
});
|
|
32
|
+
this.minimizedIframe = this.containerDiv.querySelector("#embedded-chat-minimized");
|
|
31
33
|
|
|
32
34
|
window.addEventListener("message", (e) => {
|
|
33
|
-
if
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// Check if the data is an object and has a message property
|
|
36
|
+
if (typeof e.data === "object" && e.data.message) {
|
|
37
|
+
if (e.data.message === "minimize") {
|
|
38
|
+
this.iframe.style.display = "none";
|
|
39
|
+
this.minimizedIframe.style.display = "block";
|
|
40
|
+
} else if (e.data.message === "show" || e.data.message === "maximize") {
|
|
41
|
+
this.iframe.style.display = "block";
|
|
42
|
+
this.minimizedIframe.style.display = "none";
|
|
43
|
+
// Check if the data has a scale property
|
|
44
|
+
if (e.data.scale) {
|
|
45
|
+
// Resize the iframe according to the scale factor
|
|
46
|
+
this.iframe.style.transform = `scale(${e.data.scale})`;
|
|
47
|
+
this.iframe.style.transformOrigin = "bottom right";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// For backward compatibility, handle the case when the data is a string
|
|
52
|
+
else if (typeof e.data === "string") {
|
|
53
|
+
if (e.data === "minimize") {
|
|
54
|
+
this.iframe.style.display = "none";
|
|
55
|
+
this.minimizedIframe.style.display = "block";
|
|
56
|
+
} else if (e.data === "show" || e.data === "maximize") {
|
|
57
|
+
this.iframe.style.display = "block";
|
|
58
|
+
this.minimizedIframe.style.display = "none";
|
|
59
|
+
}
|
|
39
60
|
}
|
|
40
61
|
});
|
|
41
62
|
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
createChatContainer() {
|
|
67
|
+
const chatContainer = document.createElement('div');
|
|
68
|
+
chatContainer.className = 'embedded-chat-container';
|
|
69
|
+
chatContainer.style.position = 'relative';
|
|
70
|
+
document.body.appendChild(chatContainer);
|
|
71
|
+
return chatContainer;
|
|
72
|
+
}
|
|
42
73
|
}
|
|
43
74
|
|
|
44
75
|
export function initEmbeddedChat(containerDiv, chatId, options) {
|
package/README.md
CHANGED
|
@@ -4,4 +4,11 @@ A lightweight and customizable embedded chat UI component that seamlessly integr
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
To update
|
|
8
|
+
1. Modify the version in package.json
|
|
9
|
+
1. NPM login
|
|
10
|
+
1. npm publish
|
|
11
|
+
|
|
12
|
+
NPM: https://www.npmjs.com/settings/aichatepicenter/packages
|
|
13
|
+
|
|
14
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embeddedaichatux",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\appsettings.Development.json
|
|
2
2
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\appsettings.json
|
|
3
3
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\package.json
|
|
4
|
-
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\AIChat.npm.staticwebassets.runtime.json
|
|
5
4
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\AIChat.npm.exe
|
|
6
5
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\AIChat.npm.deps.json
|
|
7
6
|
C:\Git\AIChat\AIChat.npm\bin\Debug\net7.0\AIChat.npm.runtimeconfig.json
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Version": 1,
|
|
3
|
-
"Hash": "
|
|
3
|
+
"Hash": "XERhvELNAMUvgNoh15s4mBH/fub4TdCl8jFj3CODgig=",
|
|
4
4
|
"Source": "AIChat.npm",
|
|
5
5
|
"BasePath": "_content/AIChat.npm",
|
|
6
6
|
"Mode": "Default",
|
|
7
7
|
"ManifestType": "Build",
|
|
8
8
|
"ReferencedProjectsConfiguration": [],
|
|
9
|
-
"DiscoveryPatterns": [
|
|
10
|
-
{
|
|
11
|
-
"Name": "AIChat.npm\\wwwroot",
|
|
12
|
-
"Source": "AIChat.npm",
|
|
13
|
-
"ContentRoot": "C:\\Git\\AIChat\\AIChat.npm\\wwwroot\\",
|
|
14
|
-
"BasePath": "_content/AIChat.npm",
|
|
15
|
-
"Pattern": "**"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
9
|
+
"DiscoveryPatterns": [],
|
|
18
10
|
"Assets": []
|
|
19
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embeddedaichatux",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"ContentRoots":["C:\\Git\\AIChat\\AIChat.npm\\wwwroot\\"],"Root":{"Children":null,"Asset":null,"Patterns":[{"ContentRootIndex":0,"Pattern":"**","Depth":0}]}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"ContentRoots":["C:\\Git\\AIChat\\AIChat.npm\\wwwroot\\"],"Root":{"Children":null,"Asset":null,"Patterns":[{"ContentRootIndex":0,"Pattern":"**","Depth":0}]}}
|