@xpert-ai/chatkit-web-component 0.16.2 → 0.18.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.
@@ -381,7 +381,13 @@ function createSecureChannelId() {
381
381
  return null;
382
382
  }
383
383
  function safeRandomUUID() {
384
- return createSecureChannelId() ?? `ck_${Date.now()}_${Math.random().toString(16).slice(2)}`;
384
+ const id = createSecureChannelId();
385
+ if (id === null) {
386
+ throw new Error(
387
+ "ChatKit requires crypto.randomUUID or crypto.getRandomValues to generate secure UUIDs."
388
+ );
389
+ }
390
+ return id;
385
391
  }
386
392
  function isTrustedChatKitMessageEvent(event, { channelId, expectedOrigin, expectedSource }) {
387
393
  const payload = event.data;
@@ -430,6 +436,20 @@ class FrameSafeIntegrationError {
430
436
  this.stack = new Error(message).stack;
431
437
  }
432
438
  }
439
+ function serializeFrameError(error) {
440
+ try {
441
+ return structuredClone(error);
442
+ } catch {
443
+ const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
444
+ if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
445
+ return new FrameSafeHttpError(message, {
446
+ status: error.status,
447
+ statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
448
+ });
449
+ }
450
+ return new Error(message);
451
+ }
452
+ }
433
453
  class BaseMessenger {
434
454
  constructor({
435
455
  handlers,
@@ -627,7 +647,8 @@ class BaseMessenger {
627
647
  const message = {
628
648
  __xpaiChatKit: true,
629
649
  ...this.channelId ? { channelId: this.channelId } : {},
630
- ...data
650
+ ...data,
651
+ ...data.type === "response" && data.error !== void 0 ? { error: serializeFrameError(data.error) } : {}
631
652
  };
632
653
  (_a2 = this.target()) == null ? void 0 : _a2.postMessage(message, this.targetOrigin, transfer);
633
654
  }
@@ -2846,6 +2867,10 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
2846
2867
  }
2847
2868
  return connect(request);
2848
2869
  },
2870
+ onWorkbenchNavigationChange: async (navigation) => {
2871
+ var _a2, _b2, _c2;
2872
+ await ((_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.workbench) == null ? void 0 : _b2.onNavigationChange) == null ? void 0 : _c2.call(_b2, navigation));
2873
+ },
2849
2874
  onWorkbenchClientCommand: async ({
2850
2875
  commandKey,
2851
2876
  payload,