@myop/sdk 0.3.20 → 0.3.22

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.
Files changed (30) hide show
  1. package/dist/cjs/{_IframeSDK.63faba1b.js → _IframeSDK.4a7ea89d.js} +44 -10
  2. package/dist/cjs/_IframeSDK.4a7ea89d.js.map +7 -0
  3. package/dist/cjs/_IframeSDK.fe8716bb.min.js +1 -0
  4. package/dist/cjs/{_WebComponentSDK.8f19258f.js → _WebComponentSDK.0579265f.js} +44 -10
  5. package/dist/cjs/{_WebComponentSDK.8f19258f.js.map → _WebComponentSDK.0579265f.js.map} +2 -2
  6. package/dist/cjs/_WebComponentSDK.11b0056f.min.js +1 -0
  7. package/dist/cjs/{_hostSDK.a5f727f5.js → _hostSDK.279d5ccb.js} +44 -10
  8. package/dist/cjs/{_hostSDK.a5f727f5.js.map → _hostSDK.279d5ccb.js.map} +2 -2
  9. package/dist/cjs/_hostSDK.eb048156.min.js +1 -0
  10. package/dist/cjs/myop_sdk.js +16 -16
  11. package/dist/cjs/myop_sdk.js.map +1 -1
  12. package/dist/cjs/myop_sdk.min.js +1 -1
  13. package/dist/cjs-bundled/myop_sdk.bundled.js +45 -11
  14. package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
  15. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  16. package/dist/module/Iframe/index.js +45 -11
  17. package/dist/module/Iframe/index.js.map +2 -2
  18. package/dist/module/SDK.js +45 -11
  19. package/dist/module/SDK.js.map +2 -2
  20. package/dist/module/embeddedSDK.js +1 -1
  21. package/dist/module/host/embeddedSDK.js +1 -1
  22. package/dist/module/host/index.js +45 -11
  23. package/dist/module/host/index.js.map +2 -2
  24. package/dist/module/webcomponent/index.js +45 -11
  25. package/dist/module/webcomponent/index.js.map +2 -2
  26. package/package.json +6 -54
  27. package/dist/cjs/_IframeSDK.63faba1b.js.map +0 -7
  28. package/dist/cjs/_IframeSDK.a00fcd4b.min.js +0 -1
  29. package/dist/cjs/_WebComponentSDK.03cdf3cf.min.js +0 -1
  30. package/dist/cjs/_hostSDK.1c0fe5db.min.js +0 -1
@@ -1685,14 +1685,33 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1685
1685
  }
1686
1686
  return;
1687
1687
  }
1688
- if (shouldAutoHeight) {
1689
- iframe.style.height = "0px";
1690
- }
1691
- if (shouldAutoWidth) {
1692
- iframe.style.width = "0px";
1688
+ const prevTransition = iframe.style.transition;
1689
+ const container = this.container;
1690
+ const prevContainerTransition = container.style.transition;
1691
+ iframe.style.transition = "none";
1692
+ container.style.transition = "none";
1693
+ const currentIframeHeight = iframe.getBoundingClientRect().height;
1694
+ const currentIframeWidth = iframe.getBoundingClientRect().width;
1695
+ const preScrollHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight));
1696
+ const preScrollWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth));
1697
+ let contentWidth = preScrollWidth;
1698
+ let contentHeight = preScrollHeight;
1699
+ const heightGrew = shouldAutoHeight && preScrollHeight > currentIframeHeight + 1;
1700
+ const widthGrew = shouldAutoWidth && preScrollWidth > currentIframeWidth + 1;
1701
+ const needsHeightCollapse = shouldAutoHeight && !heightGrew;
1702
+ const needsWidthCollapse = shouldAutoWidth && !widthGrew;
1703
+ if (needsHeightCollapse || needsWidthCollapse) {
1704
+ const prevMinHeight = container.style.minHeight;
1705
+ const prevMinWidth = container.style.minWidth;
1706
+ if (needsHeightCollapse) container.style.minHeight = "".concat(currentIframeHeight, "px");
1707
+ if (needsWidthCollapse) container.style.minWidth = "".concat(currentIframeWidth, "px");
1708
+ if (needsHeightCollapse) iframe.style.height = "0px";
1709
+ if (needsWidthCollapse) iframe.style.width = "0px";
1710
+ contentWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth));
1711
+ contentHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight));
1712
+ container.style.minHeight = prevMinHeight;
1713
+ container.style.minWidth = prevMinWidth;
1693
1714
  }
1694
- const contentWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth));
1695
- const contentHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight));
1696
1715
  const width = clamp(contentWidth, minWidth, maxWidth);
1697
1716
  const height = clamp(contentHeight, minHeight, maxHeight);
1698
1717
  if (shouldAutoWidth) {
@@ -1705,6 +1724,9 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1705
1724
  } else {
1706
1725
  iframe.style.height = typeof resolvedExplicitHeight === "number" ? "".concat(resolvedExplicitHeight, "px") : "100%";
1707
1726
  }
1727
+ iframe.offsetHeight;
1728
+ iframe.style.transition = prevTransition;
1729
+ container.style.transition = prevContainerTransition;
1708
1730
  const isWidthConstrained = shouldAutoWidth && maxWidth !== void 0 && contentWidth > maxWidth;
1709
1731
  const isHeightConstrained = shouldAutoHeight && maxHeight !== void 0 && contentHeight > maxHeight;
1710
1732
  contentDoc.documentElement.style.overflowX = isWidthConstrained ? "auto" : "";
@@ -1718,14 +1740,26 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1718
1740
  };
1719
1741
  updateSize();
1720
1742
  this._autoSizeUpdate = updateSize;
1721
- const resizeObserver = new ResizeObserver(updateSize);
1743
+ let rafId;
1744
+ const scheduleUpdate = () => {
1745
+ if (rafId !== void 0) return;
1746
+ rafId = requestAnimationFrame(() => {
1747
+ rafId = void 0;
1748
+ updateSize();
1749
+ });
1750
+ };
1751
+ const resizeObserver = new ResizeObserver(() => scheduleUpdate());
1722
1752
  resizeObserver.observe(doc.body);
1723
1753
  resizeObserver.observe(doc.documentElement);
1724
- const mutationObserver = new MutationObserver(updateSize);
1754
+ const mutationObserver = new MutationObserver(() => scheduleUpdate());
1725
1755
  mutationObserver.observe(doc.body, { childList: true, subtree: true, characterData: true, attributes: true });
1726
1756
  const cleanup = () => {
1727
1757
  resizeObserver.disconnect();
1728
1758
  mutationObserver.disconnect();
1759
+ if (rafId !== void 0) {
1760
+ cancelAnimationFrame(rafId);
1761
+ rafId = void 0;
1762
+ }
1729
1763
  this._autoSizeUpdate = void 0;
1730
1764
  this._autoSizeCleanup = void 0;
1731
1765
  };
@@ -1995,7 +2029,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1995
2029
  };
1996
2030
 
1997
2031
  // version:myop-sdk-version
1998
- var myop_sdk_version_default = "0.3.19";
2032
+ var myop_sdk_version_default = "0.3.22";
1999
2033
 
2000
2034
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
2001
2035
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {