@xpert-ai/chatkit-ui5 0.16.1 → 0.17.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/dist/chatkit.cjs CHANGED
@@ -433,6 +433,20 @@ class FrameSafeIntegrationError {
433
433
  this.stack = new Error(message).stack;
434
434
  }
435
435
  }
436
+ function serializeFrameError(error) {
437
+ try {
438
+ return structuredClone(error);
439
+ } catch {
440
+ const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
441
+ if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
442
+ return new FrameSafeHttpError(message, {
443
+ status: error.status,
444
+ statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
445
+ });
446
+ }
447
+ return new Error(message);
448
+ }
449
+ }
436
450
  class BaseMessenger {
437
451
  constructor({
438
452
  handlers,
@@ -630,7 +644,8 @@ class BaseMessenger {
630
644
  const message = {
631
645
  __xpaiChatKit: true,
632
646
  ...this.channelId ? { channelId: this.channelId } : {},
633
- ...data
647
+ ...data,
648
+ ...data.type === "response" && data.error !== void 0 ? { error: serializeFrameError(data.error) } : {}
634
649
  };
635
650
  (_a2 = this.target()) == null ? void 0 : _a2.postMessage(message, this.targetOrigin, transfer);
636
651
  }