@myop/sdk 0.3.23 → 0.3.25
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 +23 -0
- package/dist/cjs/_IframeSDK.1f1af47b.min.js +1 -0
- package/dist/cjs/{_IframeSDK.3d4aa749.js → _IframeSDK.4fb657bf.js} +61 -8
- package/dist/cjs/_IframeSDK.4fb657bf.js.map +7 -0
- package/dist/cjs/_MyopHelpers.6fb8c382.min.js +1 -0
- package/dist/cjs/{_MyopHelpers.71a8a09b.js → _MyopHelpers.859b9bc8.js} +37 -0
- package/dist/cjs/{_MyopHelpers.71a8a09b.js.map → _MyopHelpers.859b9bc8.js.map} +2 -2
- package/dist/cjs/_WebComponentSDK.05217c76.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.53f31f1e.js → _WebComponentSDK.949eae52.js} +61 -8
- package/dist/cjs/{_WebComponentSDK.53f31f1e.js.map → _WebComponentSDK.949eae52.js.map} +2 -2
- package/dist/cjs/{_hostSDK.28ed3ff2.js → _hostSDK.664e938c.js} +61 -8
- package/dist/cjs/{_hostSDK.28ed3ff2.js.map → _hostSDK.664e938c.js.map} +2 -2
- package/dist/cjs/_hostSDK.d90560a4.min.js +1 -0
- package/dist/cjs/myop_sdk.js +14 -14
- 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 +68 -10
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +62 -9
- package/dist/module/Iframe/index.js.map +2 -2
- package/dist/module/SDK.js +68 -10
- package/dist/module/SDK.js.map +3 -3
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/helpers/CloudRepository.d.ts +14 -0
- package/dist/module/helpers/cloudRepositoryHelpers.d.ts +1 -0
- package/dist/module/helpers/index.js +37 -1
- package/dist/module/helpers/index.js.map +2 -2
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/hostSDK.d.ts +8 -0
- package/dist/module/host/index.js +62 -9
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/webcomponent/index.js +62 -9
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.3d4aa749.js.map +0 -7
- package/dist/cjs/_IframeSDK.a1a4e2dc.min.js +0 -1
- package/dist/cjs/_MyopHelpers.19dc0df3.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.87c9fc31.min.js +0 -1
- package/dist/cjs/_hostSDK.126a70b4.min.js +0 -1
|
@@ -1694,8 +1694,8 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1694
1694
|
container.style.transition = "none";
|
|
1695
1695
|
const currentIframeHeight = iframe.getBoundingClientRect().height;
|
|
1696
1696
|
const currentIframeWidth = iframe.getBoundingClientRect().width;
|
|
1697
|
-
const preScrollHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight));
|
|
1698
|
-
const preScrollWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth));
|
|
1697
|
+
const preScrollHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight, contentDoc.body.getBoundingClientRect().height));
|
|
1698
|
+
const preScrollWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth, contentDoc.body.getBoundingClientRect().width));
|
|
1699
1699
|
let contentWidth = preScrollWidth;
|
|
1700
1700
|
let contentHeight = preScrollHeight;
|
|
1701
1701
|
const heightGrew = shouldAutoHeight && preScrollHeight > currentIframeHeight + 1;
|
|
@@ -1707,10 +1707,22 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1707
1707
|
const prevMinWidth = container.style.minWidth;
|
|
1708
1708
|
if (needsHeightCollapse) container.style.minHeight = "".concat(currentIframeHeight, "px");
|
|
1709
1709
|
if (needsWidthCollapse) container.style.minWidth = "".concat(currentIframeWidth, "px");
|
|
1710
|
+
const measureStyle = contentDoc.createElement("style");
|
|
1711
|
+
measureStyle.id = "__myop_measure";
|
|
1712
|
+
const rules = [];
|
|
1713
|
+
if (needsHeightCollapse) {
|
|
1714
|
+
rules.push("height: auto !important", "min-height: 0 !important", "max-height: none !important");
|
|
1715
|
+
}
|
|
1716
|
+
if (needsWidthCollapse) {
|
|
1717
|
+
rules.push("width: auto !important", "min-width: 0 !important", "max-width: none !important");
|
|
1718
|
+
}
|
|
1719
|
+
measureStyle.textContent = "*, *::before, *::after { ".concat(rules.join("; "), "; flex-basis: auto !important; flex-grow: 0 !important; }");
|
|
1720
|
+
contentDoc.head.appendChild(measureStyle);
|
|
1710
1721
|
if (needsHeightCollapse) iframe.style.height = "0px";
|
|
1711
1722
|
if (needsWidthCollapse) iframe.style.width = "0px";
|
|
1712
|
-
contentWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth));
|
|
1713
|
-
contentHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight));
|
|
1723
|
+
contentWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth, contentDoc.body.getBoundingClientRect().width));
|
|
1724
|
+
contentHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight, contentDoc.body.getBoundingClientRect().height));
|
|
1725
|
+
measureStyle.remove();
|
|
1714
1726
|
container.style.minHeight = prevMinHeight;
|
|
1715
1727
|
container.style.minWidth = prevMinWidth;
|
|
1716
1728
|
}
|
|
@@ -2026,7 +2038,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
2026
2038
|
};
|
|
2027
2039
|
|
|
2028
2040
|
// version:myop-sdk-version
|
|
2029
|
-
var myop_sdk_version_default = "0.3.
|
|
2041
|
+
var myop_sdk_version_default = "0.3.25";
|
|
2030
2042
|
|
|
2031
2043
|
// src/host/embeddedSDK.ts
|
|
2032
2044
|
var EMBEDDED_SDK_CONTENT = "";
|
|
@@ -2138,10 +2150,19 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
2138
2150
|
const comp = new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
|
|
2139
2151
|
comp.sizeMeta = parsedSizeMeta;
|
|
2140
2152
|
comp.initiated().then(() => {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
comp.show();
|
|
2153
|
+
if ((options == null ? void 0 : options.autoSize) === false) {
|
|
2154
|
+
return;
|
|
2144
2155
|
}
|
|
2156
|
+
let shown = false;
|
|
2157
|
+
comp.observeAutoSize({
|
|
2158
|
+
forceAutoSize: true,
|
|
2159
|
+
onSizeChange: () => {
|
|
2160
|
+
if (!shown && !(options == null ? void 0 : options.hidden)) {
|
|
2161
|
+
shown = true;
|
|
2162
|
+
comp.show();
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2145
2166
|
});
|
|
2146
2167
|
return comp;
|
|
2147
2168
|
}
|
|
@@ -2328,6 +2349,7 @@ var _CloudRepository = class _CloudRepository {
|
|
|
2328
2349
|
constructor(_baseUrl = "https://cloud.myop.dev") {
|
|
2329
2350
|
this._baseUrl = _baseUrl;
|
|
2330
2351
|
// v2 cache - keyed by componentId:env:preview|live
|
|
2352
|
+
// Each Promise is tagged with a `resolved` property after settling (see fetchComponentV2).
|
|
2331
2353
|
__publicField(this, "variants", {});
|
|
2332
2354
|
// Track which components were preloaded and with what params
|
|
2333
2355
|
// Key: componentId, Value: { env, preview }
|
|
@@ -2428,6 +2450,7 @@ var _CloudRepository = class _CloudRepository {
|
|
|
2428
2450
|
return;
|
|
2429
2451
|
}
|
|
2430
2452
|
const componentConfig = convertV2VariantToComponentConfig(variant);
|
|
2453
|
+
this.variants[cacheKey].resolved = componentConfig;
|
|
2431
2454
|
resolve(componentConfig);
|
|
2432
2455
|
} catch (e) {
|
|
2433
2456
|
reject(e);
|
|
@@ -2437,6 +2460,36 @@ var _CloudRepository = class _CloudRepository {
|
|
|
2437
2460
|
}
|
|
2438
2461
|
return await this.variants[cacheKey];
|
|
2439
2462
|
}
|
|
2463
|
+
/**
|
|
2464
|
+
* Synchronous version of fetchComponentV2 — returns the config only if
|
|
2465
|
+
* the fetch already completed, null otherwise.
|
|
2466
|
+
*
|
|
2467
|
+
* Uses the same `this.variants` cache that fetchComponentV2/preloadComponents
|
|
2468
|
+
* populate. Each cached Promise is tagged with a `.resolved` property when
|
|
2469
|
+
* it settles — this method just reads that property. No separate cache.
|
|
2470
|
+
*
|
|
2471
|
+
* Why this exists: React Native needs the config at render time to embed it
|
|
2472
|
+
* in the WebView HTML (can't await in useState). If preloadComponents ran
|
|
2473
|
+
* earlier and the fetch completed, this returns the result synchronously,
|
|
2474
|
+
* skipping the WEBVIEW_READY → fetch → inject round trip entirely.
|
|
2475
|
+
*/
|
|
2476
|
+
getResolvedConfig(componentId, env, preview) {
|
|
2477
|
+
var _a;
|
|
2478
|
+
const preloaded = this.preloadedComponents[componentId];
|
|
2479
|
+
const hasExplicitParams = env !== void 0 || preview !== void 0;
|
|
2480
|
+
let resolvedEnv;
|
|
2481
|
+
let usePreview;
|
|
2482
|
+
if (!hasExplicitParams && preloaded) {
|
|
2483
|
+
resolvedEnv = preloaded.env;
|
|
2484
|
+
usePreview = preloaded.preview;
|
|
2485
|
+
} else {
|
|
2486
|
+
resolvedEnv = env || this._defaultEnv;
|
|
2487
|
+
const hasEffectiveEnv = env || this._envExplicitlySet;
|
|
2488
|
+
usePreview = preview === true ? true : preview === false ? false : !hasEffectiveEnv;
|
|
2489
|
+
}
|
|
2490
|
+
const cacheKey = "".concat(componentId, ":").concat(resolvedEnv, ":").concat(usePreview ? "preview" : "live");
|
|
2491
|
+
return ((_a = this.variants[cacheKey]) == null ? void 0 : _a.resolved) || null;
|
|
2492
|
+
}
|
|
2440
2493
|
// ============ V1 Methods (Legacy) ============
|
|
2441
2494
|
/**
|
|
2442
2495
|
* Fetch a v1 component from a flow
|