@aparte/core 0.29.2 → 0.29.4

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/index.js CHANGED
@@ -3491,10 +3491,12 @@ class AparteChatViewport extends HTMLElement {
3491
3491
  _onDisclosureToggle = () => {
3492
3492
  this._scheduleSpacerUpdate();
3493
3493
  };
3494
- /** The `[overlay-composer]` shell this viewport floats in, if any. Read at observer setup, like `framework-managed`. */
3494
+ /** The `[overlay-composer]` shell this viewport floats in, if any. Followed, not read once: see `_wireOverlay`. */
3495
3495
  _overlayRoot = null;
3496
3496
  /** Watches the overlay shell's childList, so a stack child that mounts later (elicitation) gets observed too. */
3497
3497
  _overlayObserver = null;
3498
+ /** Watches the parent's `overlay-composer` attribute, so the mode follows a binding that lands after connect. */
3499
+ _overlayAttrObserver = null;
3498
3500
  /** Last `--aparte-bottom-inset` written, in px — style writes only when it changes. */
3499
3501
  _overlayInset = -1;
3500
3502
  /** Last `--aparte-transcript-inset` written on the host, in px — same write-on-change rule. */
@@ -4558,15 +4560,10 @@ class AparteChatViewport extends HTMLElement {
4558
4560
  this._resizeObserver.observe(this._container);
4559
4561
  }
4560
4562
  }
4561
- this._overlayRoot = this.closest("[overlay-composer]");
4562
- if (this._overlayRoot && this._resizeObserver) {
4563
- for (const child of this._overlayStack()) this._resizeObserver.observe(child);
4564
- this._overlayObserver = new MutationObserver(() => {
4565
- for (const child of this._overlayStack()) this._resizeObserver?.observe(child);
4566
- this._updateOverlayInset();
4567
- });
4568
- this._overlayObserver.observe(this._overlayRoot, { childList: true });
4569
- this._updateOverlayInset();
4563
+ this._wireOverlay();
4564
+ if (this.parentElement) {
4565
+ this._overlayAttrObserver = new MutationObserver(() => this._wireOverlay());
4566
+ this._overlayAttrObserver.observe(this.parentElement, { attributes: true, attributeFilter: ["overlay-composer"] });
4570
4567
  }
4571
4568
  this._mutationObserver = new MutationObserver((mutations) => {
4572
4569
  this._lastMutationAt = performance.now();
@@ -4607,6 +4604,29 @@ class AparteChatViewport extends HTMLElement {
4607
4604
  });
4608
4605
  }
4609
4606
  }
4607
+ /**
4608
+ * Follow the `[overlay-composer]` shell: observe its stack when the attribute is
4609
+ * there, unobserve it and drop the var when it is gone. A no-op while the shell
4610
+ * has not changed — it runs at setup and on every write of the attribute.
4611
+ */
4612
+ _wireOverlay() {
4613
+ const root = this.closest("[overlay-composer]");
4614
+ if (root === this._overlayRoot) return;
4615
+ for (const child of this._overlayStack()) this._resizeObserver?.unobserve(child);
4616
+ this._overlayObserver?.disconnect();
4617
+ this._overlayObserver = null;
4618
+ this._overlayRoot = root;
4619
+ this._overlayInset = -1;
4620
+ this.style.removeProperty("--aparte-bottom-inset");
4621
+ if (!root || !this._resizeObserver) return;
4622
+ for (const child of this._overlayStack()) this._resizeObserver.observe(child);
4623
+ this._overlayObserver = new MutationObserver(() => {
4624
+ for (const child of this._overlayStack()) this._resizeObserver?.observe(child);
4625
+ this._updateOverlayInset();
4626
+ });
4627
+ this._overlayObserver.observe(root, { childList: true });
4628
+ this._updateOverlayInset();
4629
+ }
4610
4630
  /**
4611
4631
  * The overlay shell's element children that are the floating bottom stack: not this
4612
4632
  * viewport, and not the scroll rail, which floats over the transcript by design —
@@ -4958,6 +4978,8 @@ class AparteChatViewport extends HTMLElement {
4958
4978
  this.removeEventListener("toggle", this._onDisclosureToggle, true);
4959
4979
  this._overlayObserver?.disconnect();
4960
4980
  this._overlayObserver = null;
4981
+ this._overlayAttrObserver?.disconnect();
4982
+ this._overlayAttrObserver = null;
4961
4983
  this._overlayRoot = null;
4962
4984
  this._overlayInset = -1;
4963
4985
  this._transcriptInset = -1;