@myop/sdk 0.3.24 → 0.3.26

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 (41) hide show
  1. package/dist/bundled-declarations.d.ts +23 -0
  2. package/dist/cjs/_IframeSDK.8724e6a9.min.js +1 -0
  3. package/dist/cjs/{_IframeSDK.398c9caf.js → _IframeSDK.f8e27dc0.js} +63 -14
  4. package/dist/cjs/_IframeSDK.f8e27dc0.js.map +7 -0
  5. package/dist/cjs/_MyopHelpers.6fb8c382.min.js +1 -0
  6. package/dist/cjs/{_MyopHelpers.71a8a09b.js → _MyopHelpers.859b9bc8.js} +37 -0
  7. package/dist/cjs/{_MyopHelpers.71a8a09b.js.map → _MyopHelpers.859b9bc8.js.map} +2 -2
  8. package/dist/cjs/_WebComponentSDK.9222ca02.min.js +1 -0
  9. package/dist/cjs/{_WebComponentSDK.c8c6ebc0.js → _WebComponentSDK.f8bc2f3a.js} +63 -14
  10. package/dist/cjs/{_WebComponentSDK.c8c6ebc0.js.map → _WebComponentSDK.f8bc2f3a.js.map} +2 -2
  11. package/dist/cjs/{_hostSDK.6d5f8f31.js → _hostSDK.9c5e7767.js} +63 -14
  12. package/dist/cjs/_hostSDK.9c5e7767.js.map +7 -0
  13. package/dist/cjs/_hostSDK.e2851f6a.min.js +1 -0
  14. package/dist/cjs/myop_sdk.js +14 -14
  15. package/dist/cjs/myop_sdk.js.map +1 -1
  16. package/dist/cjs/myop_sdk.min.js +1 -1
  17. package/dist/cjs-bundled/myop_sdk.bundled.js +70 -16
  18. package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
  19. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  20. package/dist/module/Iframe/index.js +64 -15
  21. package/dist/module/Iframe/index.js.map +2 -2
  22. package/dist/module/SDK.js +70 -16
  23. package/dist/module/SDK.js.map +3 -3
  24. package/dist/module/embeddedSDK.js +1 -1
  25. package/dist/module/helpers/CloudRepository.d.ts +14 -0
  26. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +1 -0
  27. package/dist/module/helpers/index.js +37 -1
  28. package/dist/module/helpers/index.js.map +2 -2
  29. package/dist/module/host/embeddedSDK.js +1 -1
  30. package/dist/module/host/hostSDK.d.ts +8 -0
  31. package/dist/module/host/index.js +64 -15
  32. package/dist/module/host/index.js.map +2 -2
  33. package/dist/module/webcomponent/index.js +64 -15
  34. package/dist/module/webcomponent/index.js.map +2 -2
  35. package/package.json +1 -1
  36. package/dist/cjs/_IframeSDK.398c9caf.js.map +0 -7
  37. package/dist/cjs/_IframeSDK.b1090eff.min.js +0 -1
  38. package/dist/cjs/_MyopHelpers.19dc0df3.min.js +0 -1
  39. package/dist/cjs/_WebComponentSDK.fc58ea5a.min.js +0 -1
  40. package/dist/cjs/_hostSDK.2c80162b.min.js +0 -1
  41. package/dist/cjs/_hostSDK.6d5f8f31.js.map +0 -7
@@ -1675,16 +1675,12 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1675
1675
  if (!shouldAutoWidth && !shouldAutoHeight) {
1676
1676
  iframe.style.width = typeof resolvedExplicitWidth === "number" ? "".concat(resolvedExplicitWidth, "px") : "100%";
1677
1677
  iframe.style.height = typeof resolvedExplicitHeight === "number" ? "".concat(resolvedExplicitHeight, "px") : "100%";
1678
- const explicitWidthPx = typeof resolvedExplicitWidth === "number" ? resolvedExplicitWidth : void 0;
1679
- const explicitHeightPx = typeof resolvedExplicitHeight === "number" ? resolvedExplicitHeight : void 0;
1680
- if (explicitWidthPx !== void 0 || explicitHeightPx !== void 0) {
1681
- (_g = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _g.call(opts, {
1682
- width: explicitWidthPx,
1683
- height: explicitHeightPx,
1684
- autoSizingWidth: false,
1685
- autoSizingHeight: false
1686
- });
1687
- }
1678
+ (_g = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _g.call(opts, {
1679
+ width: typeof resolvedExplicitWidth === "number" ? resolvedExplicitWidth : void 0,
1680
+ height: typeof resolvedExplicitHeight === "number" ? resolvedExplicitHeight : void 0,
1681
+ autoSizingWidth: false,
1682
+ autoSizingHeight: false
1683
+ });
1688
1684
  return;
1689
1685
  }
1690
1686
  const prevTransition = iframe.style.transition;
@@ -1707,10 +1703,22 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1707
1703
  const prevMinWidth = container.style.minWidth;
1708
1704
  if (needsHeightCollapse) container.style.minHeight = "".concat(currentIframeHeight, "px");
1709
1705
  if (needsWidthCollapse) container.style.minWidth = "".concat(currentIframeWidth, "px");
1706
+ const measureStyle = contentDoc.createElement("style");
1707
+ measureStyle.id = "__myop_measure";
1708
+ const rules = [];
1709
+ if (needsHeightCollapse) {
1710
+ rules.push("height: auto !important", "min-height: 0 !important", "max-height: none !important");
1711
+ }
1712
+ if (needsWidthCollapse) {
1713
+ rules.push("width: auto !important", "min-width: 0 !important", "max-width: none !important");
1714
+ }
1715
+ measureStyle.textContent = "*, *::before, *::after { ".concat(rules.join("; "), "; flex-basis: auto !important; flex-grow: 0 !important; }");
1716
+ contentDoc.head.appendChild(measureStyle);
1710
1717
  if (needsHeightCollapse) iframe.style.height = "0px";
1711
1718
  if (needsWidthCollapse) iframe.style.width = "0px";
1712
1719
  contentWidth = Math.ceil(Math.max(contentDoc.documentElement.scrollWidth, contentDoc.body.scrollWidth, contentDoc.body.getBoundingClientRect().width));
1713
1720
  contentHeight = Math.ceil(Math.max(contentDoc.documentElement.scrollHeight, contentDoc.body.scrollHeight, contentDoc.body.getBoundingClientRect().height));
1721
+ measureStyle.remove();
1714
1722
  container.style.minHeight = prevMinHeight;
1715
1723
  container.style.minWidth = prevMinWidth;
1716
1724
  }
@@ -2026,7 +2034,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
2026
2034
  };
2027
2035
 
2028
2036
  // version:myop-sdk-version
2029
- var myop_sdk_version_default = "0.3.24";
2037
+ var myop_sdk_version_default = "0.3.26";
2030
2038
 
2031
2039
  // src/host/embeddedSDK.ts
2032
2040
  var EMBEDDED_SDK_CONTENT = "";
@@ -2138,10 +2146,19 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
2138
2146
  const comp = new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
2139
2147
  comp.sizeMeta = parsedSizeMeta;
2140
2148
  comp.initiated().then(() => {
2141
- comp.observeAutoSize({ forceAutoSize: true });
2142
- if (!(options == null ? void 0 : options.hidden)) {
2143
- comp.show();
2149
+ if ((options == null ? void 0 : options.autoSize) === false) {
2150
+ return;
2144
2151
  }
2152
+ let shown = false;
2153
+ comp.observeAutoSize({
2154
+ forceAutoSize: true,
2155
+ onSizeChange: () => {
2156
+ if (!shown && !(options == null ? void 0 : options.hidden)) {
2157
+ shown = true;
2158
+ comp.show();
2159
+ }
2160
+ }
2161
+ });
2145
2162
  });
2146
2163
  return comp;
2147
2164
  }
@@ -2328,6 +2345,7 @@ var _CloudRepository = class _CloudRepository {
2328
2345
  constructor(_baseUrl = "https://cloud.myop.dev") {
2329
2346
  this._baseUrl = _baseUrl;
2330
2347
  // v2 cache - keyed by componentId:env:preview|live
2348
+ // Each Promise is tagged with a `resolved` property after settling (see fetchComponentV2).
2331
2349
  __publicField(this, "variants", {});
2332
2350
  // Track which components were preloaded and with what params
2333
2351
  // Key: componentId, Value: { env, preview }
@@ -2428,6 +2446,7 @@ var _CloudRepository = class _CloudRepository {
2428
2446
  return;
2429
2447
  }
2430
2448
  const componentConfig = convertV2VariantToComponentConfig(variant);
2449
+ this.variants[cacheKey].resolved = componentConfig;
2431
2450
  resolve(componentConfig);
2432
2451
  } catch (e) {
2433
2452
  reject(e);
@@ -2437,6 +2456,36 @@ var _CloudRepository = class _CloudRepository {
2437
2456
  }
2438
2457
  return await this.variants[cacheKey];
2439
2458
  }
2459
+ /**
2460
+ * Synchronous version of fetchComponentV2 — returns the config only if
2461
+ * the fetch already completed, null otherwise.
2462
+ *
2463
+ * Uses the same `this.variants` cache that fetchComponentV2/preloadComponents
2464
+ * populate. Each cached Promise is tagged with a `.resolved` property when
2465
+ * it settles — this method just reads that property. No separate cache.
2466
+ *
2467
+ * Why this exists: React Native needs the config at render time to embed it
2468
+ * in the WebView HTML (can't await in useState). If preloadComponents ran
2469
+ * earlier and the fetch completed, this returns the result synchronously,
2470
+ * skipping the WEBVIEW_READY → fetch → inject round trip entirely.
2471
+ */
2472
+ getResolvedConfig(componentId, env, preview) {
2473
+ var _a;
2474
+ const preloaded = this.preloadedComponents[componentId];
2475
+ const hasExplicitParams = env !== void 0 || preview !== void 0;
2476
+ let resolvedEnv;
2477
+ let usePreview;
2478
+ if (!hasExplicitParams && preloaded) {
2479
+ resolvedEnv = preloaded.env;
2480
+ usePreview = preloaded.preview;
2481
+ } else {
2482
+ resolvedEnv = env || this._defaultEnv;
2483
+ const hasEffectiveEnv = env || this._envExplicitlySet;
2484
+ usePreview = preview === true ? true : preview === false ? false : !hasEffectiveEnv;
2485
+ }
2486
+ const cacheKey = "".concat(componentId, ":").concat(resolvedEnv, ":").concat(usePreview ? "preview" : "live");
2487
+ return ((_a = this.variants[cacheKey]) == null ? void 0 : _a.resolved) || null;
2488
+ }
2440
2489
  // ============ V1 Methods (Legacy) ============
2441
2490
  /**
2442
2491
  * Fetch a v1 component from a flow