@myop/sdk 0.3.19 → 0.3.20
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/bundled-declarations.d.ts +8 -0
- package/dist/cjs/{_IframeSDK.b158be2e.js → _IframeSDK.63faba1b.js} +91 -69
- package/dist/cjs/_IframeSDK.63faba1b.js.map +7 -0
- package/dist/cjs/_IframeSDK.a00fcd4b.min.js +1 -0
- package/dist/cjs/_WebComponentSDK.03cdf3cf.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.fedea102.js → _WebComponentSDK.8f19258f.js} +91 -69
- package/dist/cjs/{_WebComponentSDK.fedea102.js.map → _WebComponentSDK.8f19258f.js.map} +3 -3
- package/dist/cjs/_hostSDK.1c0fe5db.min.js +1 -0
- package/dist/cjs/{_hostSDK.898f6183.js → _hostSDK.a5f727f5.js} +91 -69
- package/dist/cjs/_hostSDK.a5f727f5.js.map +7 -0
- package/dist/cjs/myop_sdk.js +15 -15
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +92 -70
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +92 -70
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +92 -70
- package/dist/module/SDK.js.map +2 -2
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/host/components/myopIframeComponent.d.ts +8 -0
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/index.js +92 -70
- package/dist/module/host/index.js.map +3 -3
- package/dist/module/webcomponent/index.js +92 -70
- package/dist/module/webcomponent/index.js.map +3 -3
- package/package.json +54 -6
- package/dist/cjs/_IframeSDK.736cc080.min.js +0 -1
- package/dist/cjs/_IframeSDK.b158be2e.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.d0ae9e45.min.js +0 -1
- package/dist/cjs/_hostSDK.1f707218.min.js +0 -1
- package/dist/cjs/_hostSDK.898f6183.js.map +0 -7
|
@@ -1191,6 +1191,9 @@ declare module "@myop/sdk/host/components/myopIframeComponent" {
|
|
|
1191
1191
|
componentConfig: IComponentDefinitionConfig;
|
|
1192
1192
|
container: HTMLElement;
|
|
1193
1193
|
private IframeElement;
|
|
1194
|
+
private _autoSizeCleanup?;
|
|
1195
|
+
private _autoSizeOptions?;
|
|
1196
|
+
private _autoSizeUpdate?;
|
|
1194
1197
|
constructor(componentConfig: IComponentDefinitionConfig, skin: ISkinConfig, container: HTMLElement, IframeElement: HTMLIFrameElement, options?: loaderOptions);
|
|
1195
1198
|
sizeMeta?: {
|
|
1196
1199
|
width?: string | number;
|
|
@@ -1209,6 +1212,11 @@ declare module "@myop/sdk/host/components/myopIframeComponent" {
|
|
|
1209
1212
|
/**
|
|
1210
1213
|
* Observes the iframe content size and automatically syncs it to the iframe element.
|
|
1211
1214
|
* Uses direct contentDocument access (same-origin only) for accurate measurements.
|
|
1215
|
+
*
|
|
1216
|
+
* Reentrant: when called again while observers already exist, updates options and
|
|
1217
|
+
* re-evaluates sizing without recreating observers. Cleanup + re-call (e.g. React
|
|
1218
|
+
* re-render) creates fresh observers since cleanup clears the existing ones.
|
|
1219
|
+
*
|
|
1212
1220
|
* @param options - Configuration options including size change callback and min/max constraints
|
|
1213
1221
|
* @returns Cleanup function to stop observing
|
|
1214
1222
|
*/
|
|
@@ -1585,6 +1585,9 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1585
1585
|
this.componentConfig = componentConfig;
|
|
1586
1586
|
this.container = container;
|
|
1587
1587
|
this.IframeElement = IframeElement;
|
|
1588
|
+
__publicField(this, "_autoSizeCleanup");
|
|
1589
|
+
__publicField(this, "_autoSizeOptions");
|
|
1590
|
+
__publicField(this, "_autoSizeUpdate");
|
|
1588
1591
|
__publicField(this, "sizeMeta");
|
|
1589
1592
|
__publicField(this, "cleanupInspect");
|
|
1590
1593
|
__publicField(this, "setHeightBasedOnDocumentElement", () => {
|
|
@@ -1614,11 +1617,20 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1614
1617
|
/**
|
|
1615
1618
|
* Observes the iframe content size and automatically syncs it to the iframe element.
|
|
1616
1619
|
* Uses direct contentDocument access (same-origin only) for accurate measurements.
|
|
1620
|
+
*
|
|
1621
|
+
* Reentrant: when called again while observers already exist, updates options and
|
|
1622
|
+
* re-evaluates sizing without recreating observers. Cleanup + re-call (e.g. React
|
|
1623
|
+
* re-render) creates fresh observers since cleanup clears the existing ones.
|
|
1624
|
+
*
|
|
1617
1625
|
* @param options - Configuration options including size change callback and min/max constraints
|
|
1618
1626
|
* @returns Cleanup function to stop observing
|
|
1619
1627
|
*/
|
|
1620
1628
|
__publicField(this, "observeAutoSize", (options) => {
|
|
1621
|
-
|
|
1629
|
+
this._autoSizeOptions = options;
|
|
1630
|
+
if (this._autoSizeCleanup && this._autoSizeUpdate) {
|
|
1631
|
+
this._autoSizeUpdate();
|
|
1632
|
+
return this._autoSizeCleanup;
|
|
1633
|
+
}
|
|
1622
1634
|
const iframe = this.IframeElement;
|
|
1623
1635
|
const doc = iframe.contentDocument;
|
|
1624
1636
|
if (!doc) {
|
|
@@ -1637,78 +1649,88 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1637
1649
|
const parsed = parseFloat(value);
|
|
1638
1650
|
return isNaN(parsed) ? void 0 : parsed;
|
|
1639
1651
|
};
|
|
1640
|
-
const minWidth = parseSize(options == null ? void 0 : options.minWidth);
|
|
1641
|
-
const maxWidth = parseSize(options == null ? void 0 : options.maxWidth);
|
|
1642
|
-
const minHeight = parseSize(options == null ? void 0 : options.minHeight);
|
|
1643
|
-
const maxHeight = parseSize(options == null ? void 0 : options.maxHeight);
|
|
1644
|
-
const loaderMinHeight = (_a = options == null ? void 0 : options.loaderMinHeight) != null ? _a : 50;
|
|
1645
|
-
const sizeMetaFillWidth = ((_b = this.sizeMeta) == null ? void 0 : _b.width) === "100%" ? "100%" : void 0;
|
|
1646
|
-
const sizeMetaFillHeight = ((_c = this.sizeMeta) == null ? void 0 : _c.height) === "100%" ? "100%" : void 0;
|
|
1647
|
-
const resolvedExplicitWidth = (_e = (_d = options == null ? void 0 : options.explicitWidth) != null ? _d : sizeMetaFillWidth) != null ? _e : "100%";
|
|
1648
|
-
const resolvedExplicitHeight = (_f = options == null ? void 0 : options.explicitHeight) != null ? _f : sizeMetaFillHeight;
|
|
1649
|
-
const hasExplicitWidth = resolvedExplicitWidth !== void 0;
|
|
1650
|
-
const hasExplicitHeight = resolvedExplicitHeight !== void 0;
|
|
1651
|
-
const containerRect = this.container.getBoundingClientRect();
|
|
1652
|
-
const collapsedWidth = containerRect.width === 0;
|
|
1653
|
-
const collapsedHeight = containerRect.height === 0 || containerRect.height === loaderMinHeight;
|
|
1654
|
-
const shouldAutoWidth = (options == null ? void 0 : options.forceAutoSize) ? !hasExplicitWidth : collapsedWidth && !hasExplicitWidth;
|
|
1655
|
-
const shouldAutoHeight = (options == null ? void 0 : options.forceAutoSize) ? !hasExplicitHeight : collapsedHeight && !hasExplicitHeight;
|
|
1656
|
-
if (!shouldAutoWidth && !shouldAutoHeight) {
|
|
1657
|
-
const explicitWidthPx = typeof resolvedExplicitWidth === "number" ? resolvedExplicitWidth : void 0;
|
|
1658
|
-
const explicitHeightPx = typeof resolvedExplicitHeight === "number" ? resolvedExplicitHeight : void 0;
|
|
1659
|
-
if (explicitWidthPx !== void 0 || explicitHeightPx !== void 0) {
|
|
1660
|
-
(_g = options == null ? void 0 : options.onSizeChange) == null ? void 0 : _g.call(options, {
|
|
1661
|
-
width: explicitWidthPx,
|
|
1662
|
-
height: explicitHeightPx,
|
|
1663
|
-
autoSizingWidth: false,
|
|
1664
|
-
autoSizingHeight: false
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
return () => {
|
|
1668
|
-
};
|
|
1669
|
-
}
|
|
1670
1652
|
const updateSize = () => {
|
|
1671
|
-
var
|
|
1653
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1672
1654
|
const contentDoc = iframe.contentDocument;
|
|
1673
|
-
if (contentDoc)
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1655
|
+
if (!contentDoc) return;
|
|
1656
|
+
const opts = this._autoSizeOptions;
|
|
1657
|
+
const minWidth = parseSize(opts == null ? void 0 : opts.minWidth);
|
|
1658
|
+
const maxWidth = parseSize(opts == null ? void 0 : opts.maxWidth);
|
|
1659
|
+
const minHeight = parseSize(opts == null ? void 0 : opts.minHeight);
|
|
1660
|
+
const maxHeight = parseSize(opts == null ? void 0 : opts.maxHeight);
|
|
1661
|
+
const loaderMinHeight = (_a = opts == null ? void 0 : opts.loaderMinHeight) != null ? _a : 50;
|
|
1662
|
+
const sizeMetaFillWidth = ((_b = this.sizeMeta) == null ? void 0 : _b.width) === "100%" ? "100%" : void 0;
|
|
1663
|
+
const sizeMetaFillHeight = ((_c = this.sizeMeta) == null ? void 0 : _c.height) === "100%" ? "100%" : void 0;
|
|
1664
|
+
const resolvedExplicitWidth = (_e = (_d = opts == null ? void 0 : opts.explicitWidth) != null ? _d : sizeMetaFillWidth) != null ? _e : "100%";
|
|
1665
|
+
const resolvedExplicitHeight = (_f = opts == null ? void 0 : opts.explicitHeight) != null ? _f : sizeMetaFillHeight;
|
|
1666
|
+
const hasExplicitWidth = resolvedExplicitWidth !== void 0;
|
|
1667
|
+
const hasExplicitHeight = resolvedExplicitHeight !== void 0;
|
|
1668
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
1669
|
+
const collapsedWidth = containerRect.width === 0;
|
|
1670
|
+
const collapsedHeight = containerRect.height === 0 || containerRect.height === loaderMinHeight;
|
|
1671
|
+
const shouldAutoWidth = (opts == null ? void 0 : opts.forceAutoSize) ? !hasExplicitWidth : collapsedWidth && !hasExplicitWidth;
|
|
1672
|
+
const shouldAutoHeight = (opts == null ? void 0 : opts.forceAutoSize) ? !hasExplicitHeight : collapsedHeight && !hasExplicitHeight;
|
|
1673
|
+
if (!shouldAutoWidth && !shouldAutoHeight) {
|
|
1674
|
+
iframe.style.width = typeof resolvedExplicitWidth === "number" ? "".concat(resolvedExplicitWidth, "px") : "100%";
|
|
1675
|
+
iframe.style.height = typeof resolvedExplicitHeight === "number" ? "".concat(resolvedExplicitHeight, "px") : "100%";
|
|
1676
|
+
const explicitWidthPx = typeof resolvedExplicitWidth === "number" ? resolvedExplicitWidth : void 0;
|
|
1677
|
+
const explicitHeightPx = typeof resolvedExplicitHeight === "number" ? resolvedExplicitHeight : void 0;
|
|
1678
|
+
if (explicitWidthPx !== void 0 || explicitHeightPx !== void 0) {
|
|
1679
|
+
(_g = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _g.call(opts, {
|
|
1680
|
+
width: explicitWidthPx,
|
|
1681
|
+
height: explicitHeightPx,
|
|
1682
|
+
autoSizingWidth: false,
|
|
1683
|
+
autoSizingHeight: false
|
|
1684
|
+
});
|
|
1689
1685
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
autoSizingWidth: shouldAutoWidth,
|
|
1698
|
-
autoSizingHeight: shouldAutoHeight
|
|
1699
|
-
});
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (shouldAutoHeight) {
|
|
1689
|
+
iframe.style.height = "0px";
|
|
1690
|
+
}
|
|
1691
|
+
if (shouldAutoWidth) {
|
|
1692
|
+
iframe.style.width = "0px";
|
|
1700
1693
|
}
|
|
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
|
+
const width = clamp(contentWidth, minWidth, maxWidth);
|
|
1697
|
+
const height = clamp(contentHeight, minHeight, maxHeight);
|
|
1698
|
+
if (shouldAutoWidth) {
|
|
1699
|
+
iframe.style.width = "".concat(width, "px");
|
|
1700
|
+
} else {
|
|
1701
|
+
iframe.style.width = typeof resolvedExplicitWidth === "number" ? "".concat(resolvedExplicitWidth, "px") : "100%";
|
|
1702
|
+
}
|
|
1703
|
+
if (shouldAutoHeight) {
|
|
1704
|
+
iframe.style.height = "".concat(height, "px");
|
|
1705
|
+
} else {
|
|
1706
|
+
iframe.style.height = typeof resolvedExplicitHeight === "number" ? "".concat(resolvedExplicitHeight, "px") : "100%";
|
|
1707
|
+
}
|
|
1708
|
+
const isWidthConstrained = shouldAutoWidth && maxWidth !== void 0 && contentWidth > maxWidth;
|
|
1709
|
+
const isHeightConstrained = shouldAutoHeight && maxHeight !== void 0 && contentHeight > maxHeight;
|
|
1710
|
+
contentDoc.documentElement.style.overflowX = isWidthConstrained ? "auto" : "";
|
|
1711
|
+
contentDoc.documentElement.style.overflowY = isHeightConstrained ? "auto" : "";
|
|
1712
|
+
(_h = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _h.call(opts, {
|
|
1713
|
+
width,
|
|
1714
|
+
height,
|
|
1715
|
+
autoSizingWidth: shouldAutoWidth,
|
|
1716
|
+
autoSizingHeight: shouldAutoHeight
|
|
1717
|
+
});
|
|
1701
1718
|
};
|
|
1702
1719
|
updateSize();
|
|
1720
|
+
this._autoSizeUpdate = updateSize;
|
|
1703
1721
|
const resizeObserver = new ResizeObserver(updateSize);
|
|
1704
1722
|
resizeObserver.observe(doc.body);
|
|
1705
1723
|
resizeObserver.observe(doc.documentElement);
|
|
1706
1724
|
const mutationObserver = new MutationObserver(updateSize);
|
|
1707
1725
|
mutationObserver.observe(doc.body, { childList: true, subtree: true, characterData: true, attributes: true });
|
|
1708
|
-
|
|
1726
|
+
const cleanup = () => {
|
|
1709
1727
|
resizeObserver.disconnect();
|
|
1710
1728
|
mutationObserver.disconnect();
|
|
1729
|
+
this._autoSizeUpdate = void 0;
|
|
1730
|
+
this._autoSizeCleanup = void 0;
|
|
1711
1731
|
};
|
|
1732
|
+
this._autoSizeCleanup = cleanup;
|
|
1733
|
+
return cleanup;
|
|
1712
1734
|
});
|
|
1713
1735
|
__publicField(this, "setSizeBasedOnDocumentElement", () => {
|
|
1714
1736
|
const cleanupHandler = this.send(new ExecuteScriptMessage(() => {
|
|
@@ -1755,16 +1777,15 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1755
1777
|
return cleanupHandler;
|
|
1756
1778
|
});
|
|
1757
1779
|
__publicField(this, "dispose", () => {
|
|
1780
|
+
if (this._autoSizeCleanup) {
|
|
1781
|
+
this._autoSizeCleanup();
|
|
1782
|
+
this._autoSizeCleanup = void 0;
|
|
1783
|
+
}
|
|
1758
1784
|
if (this.cleanupInspect)
|
|
1759
1785
|
this.cleanupInspect();
|
|
1760
1786
|
super.dispose();
|
|
1761
1787
|
this.IframeElement.parentNode.removeChild(this.IframeElement);
|
|
1762
1788
|
});
|
|
1763
|
-
if (skin.loader.autoHeight) {
|
|
1764
|
-
this.initiated().then(() => {
|
|
1765
|
-
this.setHeightBasedOnScrollHeight();
|
|
1766
|
-
});
|
|
1767
|
-
}
|
|
1768
1789
|
this.element = this.IframeElement;
|
|
1769
1790
|
}
|
|
1770
1791
|
inspect() {
|
|
@@ -2408,11 +2429,12 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
2408
2429
|
doc.close();
|
|
2409
2430
|
const comp = new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
|
|
2410
2431
|
comp.sizeMeta = parsedSizeMeta;
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2432
|
+
comp.initiated().then(() => {
|
|
2433
|
+
comp.observeAutoSize({ forceAutoSize: true });
|
|
2434
|
+
if (!(options == null ? void 0 : options.hidden)) {
|
|
2435
|
+
comp.show();
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2416
2438
|
return comp;
|
|
2417
2439
|
}
|
|
2418
2440
|
if (loaderConfig.shadowRootMode === ShadowRootModeType.none) {
|