embeddedaichatux 1.7.1 → 1.7.2

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.
Files changed (2) hide show
  1. package/EmbeddedChat.js +19 -1
  2. package/package.json +1 -1
package/EmbeddedChat.js CHANGED
@@ -142,6 +142,9 @@
142
142
  } else if (e.data.message === "show" || e.data.message === "maximize") {
143
143
  const animate = e.data.animate === true;
144
144
  this.showMaximized(animate);
145
+ } else if (e.data.message === "navigate" && e.data.url) {
146
+ // Handle the navigate message
147
+ window.location.href = e.data.url;
145
148
  }
146
149
  }
147
150
 
@@ -241,6 +244,21 @@
241
244
 
242
245
 
243
246
  showMaximized(animate = false) {
247
+ const schedulePostMessage = () => {
248
+ if (this.iframe.contentWindow) {
249
+ this.iframe.contentWindow.postMessage({ message: "show" }, "*");
250
+ } else {
251
+ // Schedule a single retry with a delay
252
+ setTimeout(() => {
253
+ if (this.iframe.contentWindow) {
254
+ this.iframe.contentWindow.postMessage({ message: "show" }, "*");
255
+ } else {
256
+ console.warn("iframe contentWindow is not available.");
257
+ }
258
+ }, 500);
259
+ }
260
+ };
261
+
244
262
  if (animate) {
245
263
  this.animateMaximize();
246
264
  }
@@ -261,7 +279,7 @@
261
279
  this.iframe.style.height = `${this.height}px`;
262
280
  this.iframe.style.opacity = '1';
263
281
 
264
- this.iframe.contentWindow.postMessage({ message: "show" }, "*");
282
+ schedulePostMessage();
265
283
  }
266
284
  }
267
285
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embeddedaichatux",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
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": {