@syntrologie/adapt-chatbot 2.8.0-canary.280 → 2.8.0-canary.282

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.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AdaptiveChatBar
3
3
  } from "./chunk-QELVKBQV.js";
4
- import "./chunk-LX2VCWH5.js";
5
- import "./chunk-BDFKAVVA.js";
4
+ import "./chunk-XP2UFKPG.js";
5
+ import "./chunk-K2IG34L7.js";
6
6
  import "./chunk-UVKRO5ER.js";
7
7
  export {
8
8
  AdaptiveChatBar
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AdaptiveChatTrail
3
- } from "./chunk-LX2VCWH5.js";
4
- import "./chunk-BDFKAVVA.js";
3
+ } from "./chunk-XP2UFKPG.js";
4
+ import "./chunk-K2IG34L7.js";
5
5
  import "./chunk-UVKRO5ER.js";
6
6
  export {
7
7
  AdaptiveChatTrail
@@ -2,7 +2,7 @@ import {
2
2
  ChatAssistantLitMountable,
3
3
  renderFallbackHtml
4
4
  } from "./chunk-FQ7QUZZ3.js";
5
- import "./chunk-BDFKAVVA.js";
5
+ import "./chunk-K2IG34L7.js";
6
6
  import "./chunk-435KJD27.js";
7
7
  import "./chunk-UVKRO5ER.js";
8
8
  export {
@@ -2917,8 +2917,11 @@ function injectChatStyles(root = typeof document === "undefined" ? void 0 : docu
2917
2917
  const style = document.createElement("style");
2918
2918
  style.id = STYLE_ID;
2919
2919
  style.textContent = STYLE_RULES;
2920
- const target = root instanceof Document ? root.head : root;
2921
- target.appendChild(style);
2920
+ if (root instanceof Document) {
2921
+ root.head.appendChild(style);
2922
+ return;
2923
+ }
2924
+ root.insertBefore(style, root.firstChild ?? null);
2922
2925
  }
2923
2926
  var SyntroChat = class extends LitElement {
2924
2927
  constructor() {
@@ -3093,8 +3096,7 @@ var SyntroChat = class extends LitElement {
3093
3096
  }
3094
3097
  connectedCallback() {
3095
3098
  super.connectedCallback();
3096
- const root = this.getRootNode();
3097
- injectChatStyles(root instanceof ShadowRoot || root instanceof Document ? root : document);
3099
+ this._ensureStylesInRoot();
3098
3100
  if (this.transport) {
3099
3101
  this._unsubscribe = this.transport.subscribe(this._handleEvent);
3100
3102
  this.transport.connect();
@@ -3107,9 +3109,42 @@ var SyntroChat = class extends LitElement {
3107
3109
  this.transport?.disconnect();
3108
3110
  }
3109
3111
  firstUpdated() {
3112
+ this._ensureStylesInRoot();
3110
3113
  this._scrollContainer = this.querySelector("[data-sc-scroll-area]");
3111
3114
  this._scrollContainer?.addEventListener("scroll", this._handleScroll);
3112
3115
  }
3116
+ /**
3117
+ * Resolve the *effective* rendering root for this chat instance.
3118
+ *
3119
+ * `this.getRootNode()` will follow shadow boundaries, but in the editor
3120
+ * surface the chat is created via `document.createElement('syntro-chat')`
3121
+ * and then committed into the smart-canvas shadow tree by Lit several
3122
+ * frames after `connectedCallback`. During that window
3123
+ * `getRootNode()` returns Document even though the element ultimately
3124
+ * lives in a shadow root (BUG-1779636600).
3125
+ *
3126
+ * Walk the parent chain manually, hopping across shadow boundaries via
3127
+ * `.host`, and return the deepest enclosing `ShadowRoot` we can reach.
3128
+ * Fall back to `getRootNode()` (Document or self) when no shadow root
3129
+ * is in the chain — that's the host-page chatbot case.
3130
+ */
3131
+ _resolveStyleRoot() {
3132
+ let node = this;
3133
+ while (node) {
3134
+ const parent = node.parentNode;
3135
+ if (parent) {
3136
+ node = parent;
3137
+ continue;
3138
+ }
3139
+ if (node instanceof ShadowRoot) return node;
3140
+ break;
3141
+ }
3142
+ const r = this.getRootNode();
3143
+ return r instanceof ShadowRoot || r instanceof Document ? r : document;
3144
+ }
3145
+ _ensureStylesInRoot() {
3146
+ injectChatStyles(this._resolveStyleRoot());
3147
+ }
3113
3148
  updated() {
3114
3149
  this._injectCodeCopyButtons();
3115
3150
  }
@@ -3235,4 +3270,4 @@ export {
3235
3270
  dompurify/dist/purify.es.mjs:
3236
3271
  (*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE *)
3237
3272
  */
3238
- //# sourceMappingURL=chunk-BDFKAVVA.js.map
3273
+ //# sourceMappingURL=chunk-K2IG34L7.js.map