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