@myop/sdk 0.3.34 → 0.4.0-beta.0

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 (47) hide show
  1. package/dist/bundled-declarations.d.ts +408 -167
  2. package/dist/cjs/{_IframeSDK.c7926c56.js → _IframeSDK.096d8320.js} +1328 -917
  3. package/dist/cjs/_IframeSDK.096d8320.js.map +7 -0
  4. package/dist/cjs/_IframeSDK.8e791f92.min.js +1 -0
  5. package/dist/cjs/_MyopHelpers.91004b19.min.js +1 -0
  6. package/dist/cjs/{_MyopHelpers.08d1cf5d.js → _MyopHelpers.efed13e4.js} +362 -2
  7. package/dist/cjs/_MyopHelpers.efed13e4.js.map +7 -0
  8. package/dist/cjs/_WebComponentSDK.4a87f826.min.js +1 -0
  9. package/dist/cjs/{_WebComponentSDK.501a71f9.js → _WebComponentSDK.e9e877db.js} +886 -478
  10. package/dist/cjs/_WebComponentSDK.e9e877db.js.map +7 -0
  11. package/dist/cjs/{_hostSDK.cdbc1f60.js → _hostSDK.0c271647.js} +1349 -941
  12. package/dist/cjs/_hostSDK.0c271647.js.map +7 -0
  13. package/dist/cjs/_hostSDK.7d759290.min.js +1 -0
  14. package/dist/cjs/myop_sdk.js +35 -24
  15. package/dist/cjs/myop_sdk.js.map +2 -2
  16. package/dist/cjs/myop_sdk.min.js +1 -1
  17. package/dist/cjs-bundled/myop_sdk.bundled.js +1822 -1380
  18. package/dist/cjs-bundled/myop_sdk.bundled.js.map +4 -4
  19. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  20. package/dist/module/Iframe/index.js +1095 -672
  21. package/dist/module/Iframe/index.js.map +4 -4
  22. package/dist/module/SDK.d.ts +5 -1
  23. package/dist/module/SDK.js +1980 -1528
  24. package/dist/module/SDK.js.map +4 -4
  25. package/dist/module/embeddedSDK.js +1 -1
  26. package/dist/module/helpers/CloudRepository.d.ts +96 -0
  27. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +99 -0
  28. package/dist/module/helpers/deliveryStore.d.ts +51 -0
  29. package/dist/module/helpers/index.js +370 -3
  30. package/dist/module/helpers/index.js.map +4 -4
  31. package/dist/module/host/components/myopIframeComponent.d.ts +6 -0
  32. package/dist/module/host/embeddedSDK.js +1 -1
  33. package/dist/module/host/hostSDK.d.ts +2 -0
  34. package/dist/module/host/index.js +1065 -645
  35. package/dist/module/host/index.js.map +4 -4
  36. package/dist/module/host/loaders/HTMLComponentLoader.d.ts +2 -1
  37. package/dist/module/webcomponent/index.js +1136 -716
  38. package/dist/module/webcomponent/index.js.map +4 -4
  39. package/package.json +1 -1
  40. package/dist/cjs/_IframeSDK.c2225e19.min.js +0 -1
  41. package/dist/cjs/_IframeSDK.c7926c56.js.map +0 -7
  42. package/dist/cjs/_MyopHelpers.08d1cf5d.js.map +0 -7
  43. package/dist/cjs/_MyopHelpers.59521d8f.min.js +0 -1
  44. package/dist/cjs/_WebComponentSDK.0caec562.min.js +0 -1
  45. package/dist/cjs/_WebComponentSDK.501a71f9.js.map +0 -7
  46. package/dist/cjs/_hostSDK.02edf3e2.min.js +0 -1
  47. package/dist/cjs/_hostSDK.cdbc1f60.js.map +0 -7
@@ -645,6 +645,12 @@ declare module "@myop/sdk/host/components/myopIframeComponent" {
645
645
  * @returns Cleanup function to stop observing
646
646
  */
647
647
  observeAutoSize: (options?: AutoSizeOptions) => CleanupHandler;
648
+ private _bridgeSizeCleanup?;
649
+ /**
650
+ * Auto-height for a frame the host can't read (cross-origin). Runs after the IframeSDK
651
+ * handshake: the frame reports body resizes and the host re-reads the scroll height.
652
+ */
653
+ observeHeightViaBridge: () => CleanupHandler;
648
654
  setSizeBasedOnDocumentElement: () => void;
649
655
  setHeightBasedOnScrollHeight: () => void;
650
656
  send: (message: BaseMyopMessage) => CleanupHandler;
@@ -1482,6 +1488,399 @@ declare module "@myop/sdk/Iframe/IframeSDK" {
1482
1488
  declare module "@myop/sdk/Iframe" {
1483
1489
  export * from "@myop/sdk/Iframe/IframeSDK";
1484
1490
  }
1491
+ declare module "@myop/sdk/helpers/deliveryStore" {
1492
+ export interface StoredEntry {
1493
+ key: string;
1494
+ /** the resolved component config, exactly as the network path produces it */
1495
+ config: any;
1496
+ /** the server's version token for these bytes: `<rev>~<opt>` */
1497
+ tag: string | null;
1498
+ /** when this browser stored it */
1499
+ storedAt: number;
1500
+ /** how long it may be used without asking, in ms (already Age-adjusted) */
1501
+ windowMs: number;
1502
+ /** which host produced it — a key from another host is never reused */
1503
+ host: string;
1504
+ /** wire size of the response it came from, so stats can say what the window saved */
1505
+ bytes?: number;
1506
+ }
1507
+ export const deliveryStore: {
1508
+ key(host: string, componentId: string, env: string, preview: boolean, opt: string): string;
1509
+ get(key: string): Promise<StoredEntry | null>;
1510
+ put(entry: StoredEntry): Promise<void>;
1511
+ drop(key: string): Promise<void>;
1512
+ /** Still usable without asking the server? */
1513
+ fresh(e: StoredEntry | null): boolean;
1514
+ /**
1515
+ * The window this response licenses: the server's freshness minus what a CDN already
1516
+ * spent. Returns 0 when the server said nothing about caching, which means "do not
1517
+ * hold this" — the safe reading, and what production sends today.
1518
+ */
1519
+ windowFrom(headers: Headers): number;
1520
+ /** For tests and for `refresh()`: forget everything this browser holds. */
1521
+ clear(): Promise<void>;
1522
+ };
1523
+ }
1524
+ declare module "@myop/sdk/helpers/CloudRepository" {
1525
+ import { IComponentConfig, IUserFlow } from "@myop/sdk/common";
1526
+ export class CloudRepository {
1527
+ private _baseUrl;
1528
+ private static _main;
1529
+ static get Main(): CloudRepository;
1530
+ private variants;
1531
+ private preloadedComponents;
1532
+ private userFlows;
1533
+ private _defaultEnv;
1534
+ private _envExplicitlySet;
1535
+ private _staticMode;
1536
+ private _queryParams;
1537
+ constructor(_baseUrl?: string);
1538
+ /**
1539
+ * How big the component we are NOT re-downloading is. Deliberately measured from what
1540
+ * we hold rather than from Content-Length: once a response is compressed the header is
1541
+ * not readable cross-origin, so reading it there reported 0 every single time.
1542
+ */
1543
+ private static sizeOfHeld;
1544
+ /** The host every request goes to unless delivery() moved it. Never changes. */
1545
+ private static readonly DEFAULT_HOST;
1546
+ /**
1547
+ * Opt-in delivery settings, set by myop.delivery(). Off means: this file behaves
1548
+ * EXACTLY as it did before — same host, same URL, same everything.
1549
+ */
1550
+ private _delivery;
1551
+ /**
1552
+ * What actually happened, for myop.delivery.stats(). `fellBack` is the number that
1553
+ * matters: it is how you find out the lane is unhealthy without waiting for a
1554
+ * bug report, because a fallback is INVISIBLE to the page (it still renders).
1555
+ */
1556
+ private _deliveryStats;
1557
+ /**
1558
+ * Turn on the opt-in delivery path.
1559
+ *
1560
+ * Opting in IS choosing the delivery stack: this points /consume at `host` (a second,
1561
+ * complete stack reading the same data) and asks for the minified artifact. Leave this
1562
+ * uncalled and nothing about the SDK changes.
1563
+ *
1564
+ * Deliberately mutates THIS instance rather than constructing a new repository:
1565
+ * CloudRepository.Main is a global singleton shared across bundles (see getGlobalMain),
1566
+ * so a second instance would be ignored by every component already using the first.
1567
+ */
1568
+ setDelivery(opts?: {
1569
+ minify?: boolean;
1570
+ host?: string | null;
1571
+ cache?: boolean;
1572
+ }): void;
1573
+ deliveryStats(): {
1574
+ host: string;
1575
+ minify: boolean;
1576
+ cache: boolean;
1577
+ requests: number;
1578
+ viaDelivery: number;
1579
+ fellBack: number;
1580
+ lastError: string | null;
1581
+ /** where the last loads were answered from — the number the client window exists to move */
1582
+ fromMemory: number;
1583
+ fromStorage: number;
1584
+ fromNetwork: number;
1585
+ /** re-checks after the window ended, and how many were answered "nothing changed" */
1586
+ revalidations: number;
1587
+ unchanged: number;
1588
+ bytesSaved: number;
1589
+ };
1590
+ /**
1591
+ * Forget what this browser holds, so the next load asks the server.
1592
+ * `refresh()` with no ids drops everything; the counterpart to the window for the case
1593
+ * where a change has to be visible on THIS load — right after someone publishes.
1594
+ */
1595
+ refreshDelivery(): Promise<void>;
1596
+ /**
1597
+ * Local serves waiting to be reported: componentId -> {env, count}.
1598
+ *
1599
+ * THE MEASUREMENT PROBLEM THIS SOLVES. The better this cache works, the more usage
1600
+ * vanishes: a visitor inside their freshness window renders the page with no request,
1601
+ * so neither the server nor the CDN can see them. Left alone, a successful rollout
1602
+ * looks in the ledger exactly like customers leaving.
1603
+ *
1604
+ * So local serves are counted here and reported afterwards, batched, on a path that
1605
+ * never blocks rendering: flushed when the page is hidden (keepalive, so it survives
1606
+ * the tab closing) and opportunistically whenever the SDK is talking to the server
1607
+ * anyway. Nothing is sent while the page is loading, which is the point of the window.
1608
+ */
1609
+ private _localServes;
1610
+ private _flushBound;
1611
+ private noteLocalServe;
1612
+ /** Report on page-hide, which is the only event that reliably fires on mobile. */
1613
+ private bindFlush;
1614
+ /**
1615
+ * Send what we have. `keepalive` is what makes this work at page-hide: the request
1616
+ * outlives the document. Failure is ignored — a lost usage report must never be
1617
+ * visible to a visitor, and the next page load will report its own.
1618
+ */
1619
+ flushLocalServes(): void;
1620
+ /** Where /consume should be fetched from right now. */
1621
+ private deliveryHost;
1622
+ /**
1623
+ * Fetch a delivery URL with ONE fallback to the default host.
1624
+ *
1625
+ * The fallback is the kill switch: break or disable the lane and every client drifts
1626
+ * back to cloud.myop.dev on its own, with no customer deploy. It must therefore be
1627
+ * genuinely silent to the page and genuinely LOUD in stats() — a fallback that nobody
1628
+ * counts is an outage nobody notices.
1629
+ *
1630
+ * Only transport failures and 5xx fall back. A 404 is an answer: the component really
1631
+ * is missing, and retrying elsewhere would only hide it.
1632
+ */
1633
+ private deliveryFetch;
1634
+ /**
1635
+ * Enable static mode for self-hosted component registries.
1636
+ * In static mode, URLs are constructed as file paths instead of query params:
1637
+ * ${baseUrl}/components/${componentId}/${env}.json
1638
+ */
1639
+ enableStaticMode(): void;
1640
+ /**
1641
+ * Set query parameters to append to all fetch URLs (e.g. for CDN cache busting).
1642
+ * Example: `setQueryParams({ lastupdate: '11112026' })`
1643
+ */
1644
+ setQueryParams(params: Record<string, string>): void;
1645
+ /**
1646
+ * Set the default environment for this CloudRepository instance
1647
+ */
1648
+ setEnvironment(env: string): void;
1649
+ /**
1650
+ * Get the current default environment
1651
+ */
1652
+ getDefaultEnvironment(): string;
1653
+ /**
1654
+ * Check if a component is already cached/preloaded (v2)
1655
+ * If env and preview are not provided, checks if ANY version is preloaded
1656
+ */
1657
+ isPreloaded(componentId: string, env?: string, preview?: boolean): boolean;
1658
+ /**
1659
+ * Get the preloaded params for a component (if preloaded)
1660
+ * Returns undefined if not preloaded
1661
+ */
1662
+ getPreloadedParams(componentId: string): {
1663
+ env: string;
1664
+ preview: boolean;
1665
+ } | undefined;
1666
+ /**
1667
+ * Resolve a component config: fetch it once, then serve it from this
1668
+ * repository's cache.
1669
+ *
1670
+ * This is the name to use. `fetchComponentV2` is the same method under its
1671
+ * versioned name and stays for backward compatibility — note that the
1672
+ * unversioned `fetchComponent` is a *deprecated v1* API and is NOT this.
1673
+ *
1674
+ * Completes the trio with {@link getResolvedConfig} (synchronous read of an
1675
+ * already-resolved config) and {@link hydrateComponent} (seed one you
1676
+ * already hold).
1677
+ *
1678
+ * Prefer the module-level `preloadComponents([id])` in app code; reach for
1679
+ * this when you need an isolated repository instance whose cache lifetime
1680
+ * you control — a server with its own TTL, for example.
1681
+ */
1682
+ resolveComponent(componentId: string, env?: string, preview?: boolean): Promise<IComponentConfig>;
1683
+ /**
1684
+ * Fetch a v2 component config
1685
+ * If env/preview not specified and component was preloaded, uses preloaded params
1686
+ *
1687
+ * @see resolveComponent — the unversioned name for this method
1688
+ */
1689
+ fetchComponentV2(componentId: string, environmentIdentifier?: string, preview?: boolean): Promise<IComponentConfig>;
1690
+ /**
1691
+ * Synchronous version of fetchComponentV2 — returns the config only if
1692
+ * the fetch already completed, null otherwise.
1693
+ *
1694
+ * Uses the same `this.variants` cache that fetchComponentV2/preloadComponents
1695
+ * populate. Each cached Promise is tagged with a `.resolved` property when
1696
+ * it settles — this method just reads that property. No separate cache.
1697
+ *
1698
+ * Why this exists: React Native needs the config at render time to embed it
1699
+ * in the WebView HTML (can't await in useState). If preloadComponents ran
1700
+ * earlier and the fetch completed, this returns the result synchronously,
1701
+ * skipping the WEBVIEW_READY → fetch → inject round trip entirely.
1702
+ */
1703
+ getResolvedConfig(componentId: string, env?: string, preview?: boolean): IComponentConfig | null;
1704
+ /**
1705
+ * Resolve which (env, preview) pair — and therefore which cache key — a call
1706
+ * for `componentId` refers to.
1707
+ *
1708
+ * Single source of truth for fetchComponentV2, getResolvedConfig and
1709
+ * hydrateComponent, so a hydrated config always lands on the key a later
1710
+ * fetch will look under.
1711
+ */
1712
+ private resolveParams;
1713
+ /**
1714
+ * Seed an already-resolved component config into the cache, without any
1715
+ * network request.
1716
+ *
1717
+ * The counterpart to {@link fetchComponentV2}: use it when the config was
1718
+ * resolved somewhere else — most often on a server, then embedded in the
1719
+ * page — so the browser can render the component with no round trip.
1720
+ *
1721
+ * After hydrating, `fetchComponentV2`, `getResolvedConfig` and `isPreloaded`
1722
+ * all answer for this component from memory.
1723
+ *
1724
+ * Pass the same `env` / `preview` the config was resolved with; the defaults
1725
+ * match what a plain `fetchComponentV2(componentId)` would have used.
1726
+ */
1727
+ hydrateComponent(componentId: string, config: IComponentConfig, env?: string, preview?: boolean): void;
1728
+ /**
1729
+ * Fetch a v1 component from a flow
1730
+ */
1731
+ fetchComponentV1(componentId: string, flowId?: string): Promise<IComponentConfig>;
1732
+ fetchAutoFlow(componentId: string): Promise<IUserFlow>;
1733
+ fetchFlow(flowId: string): Promise<IUserFlow>;
1734
+ /**
1735
+ * @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly
1736
+ * Defaults to v1 behavior for backward compatibility with existing code
1737
+ */
1738
+ fetchComponent(componentId: string, flowId?: string): Promise<IComponentConfig>;
1739
+ }
1740
+ /**
1741
+ * @deprecated Use CloudRepository instead
1742
+ */
1743
+ export const v2_CloudRepository: typeof CloudRepository;
1744
+ }
1745
+ declare module "@myop/sdk/helpers/cloudRepositoryHelpers" {
1746
+ import { CloudRepository } from "@myop/sdk/helpers/CloudRepository";
1747
+ import { IComponentConfig } from "@myop/sdk/common";
1748
+ export const getCloudRepository: () => CloudRepository;
1749
+ export const isPreloaded: (componentId: string, env?: string, preview?: boolean) => boolean;
1750
+ export const getPreloadedParams: (componentId: string) => {
1751
+ env: string;
1752
+ preview: boolean;
1753
+ };
1754
+ export const enableLocalDev: () => void;
1755
+ export const setCloudRepositoryUrl: (url: string) => void;
1756
+ /**
1757
+ * Configure the SDK to fetch components from a self-hosted static registry (S3, CDN, etc.)
1758
+ * instead of the Myop cloud. Components are served as static JSON files:
1759
+ * `${cdnUrl}/components/${componentId}/${environment}.json`
1760
+ */
1761
+ export const enableSelfHosted: (cdnUrl: string, queryParams?: Record<string, string>) => void;
1762
+ /**
1763
+ * THE OPT-IN. One call, and nothing changes for anyone who does not make it.
1764
+ *
1765
+ * myop.delivery({ minify: true });
1766
+ *
1767
+ * Opting in IS choosing the delivery lane: a second, complete Myop stack (its own server
1768
+ * and CDN) reading the same component data. So this call does two things at once — it
1769
+ * points `/consume` at that stack and asks it for the minified artifact — which is why
1770
+ * turning the feature off is a config value on our side or one line on yours, and never
1771
+ * a DNS change.
1772
+ *
1773
+ * Safety properties, all deliberate:
1774
+ * - If the lane fails (transport error or 5xx), the SDK retries ONCE against
1775
+ * cloud.myop.dev and the page renders anyway. `delivery.stats().fellBack` counts it.
1776
+ * - `cache: true` adds the client window: a component this browser already holds, still
1777
+ * inside the freshness the server promised, is rendered with NO request. Once the
1778
+ * window ends the browser sends back the version it holds instead of re-downloading.
1779
+ * - A preview is never minified and never cached.
1780
+ * - Only /consume moves. Everything else keeps the host it has today.
1781
+ * - Asking for `minify` does not force it: the server decides per component, and a
1782
+ * component that is not enabled is served raw, which is not an error.
1783
+ *
1784
+ * `host` is for us (a staging lane, a local server); leave it out.
1785
+ */
1786
+ export const DELIVERY_HOST = "https://delivery.myop.dev";
1787
+ export const delivery: (opts?: {
1788
+ minify?: boolean;
1789
+ cache?: boolean;
1790
+ host?: string | null;
1791
+ }) => {
1792
+ host: string;
1793
+ minify: boolean;
1794
+ cache: boolean;
1795
+ requests: number;
1796
+ viaDelivery: number;
1797
+ fellBack: number;
1798
+ lastError: string | null;
1799
+ fromMemory: number;
1800
+ fromStorage: number;
1801
+ fromNetwork: number;
1802
+ revalidations: number;
1803
+ unchanged: number;
1804
+ bytesSaved: number;
1805
+ };
1806
+ /**
1807
+ * Forget what this browser holds, so the next load asks the server. Use it when a change
1808
+ * has to be visible on THIS load — right after someone publishes — rather than within the
1809
+ * freshness window.
1810
+ */
1811
+ export const deliveryRefresh: () => Promise<{
1812
+ host: string;
1813
+ minify: boolean;
1814
+ cache: boolean;
1815
+ requests: number;
1816
+ viaDelivery: number;
1817
+ fellBack: number;
1818
+ lastError: string | null;
1819
+ fromMemory: number;
1820
+ fromStorage: number;
1821
+ fromNetwork: number;
1822
+ revalidations: number;
1823
+ unchanged: number;
1824
+ bytesSaved: number;
1825
+ }>;
1826
+ /**
1827
+ * What answered the last requests, and — the number worth watching — how many times the
1828
+ * SDK had to fall back to the default host because the lane did not answer.
1829
+ */
1830
+ export const deliveryStats: () => {
1831
+ host: string;
1832
+ minify: boolean;
1833
+ cache: boolean;
1834
+ requests: number;
1835
+ viaDelivery: number;
1836
+ fellBack: number;
1837
+ lastError: string | null;
1838
+ fromMemory: number;
1839
+ fromStorage: number;
1840
+ fromNetwork: number;
1841
+ revalidations: number;
1842
+ unchanged: number;
1843
+ bytesSaved: number;
1844
+ };
1845
+ /** Undo delivery(): back to the default host and raw bytes, with no reload. */
1846
+ export const deliveryOff: () => {
1847
+ host: string;
1848
+ minify: boolean;
1849
+ cache: boolean;
1850
+ requests: number;
1851
+ viaDelivery: number;
1852
+ fellBack: number;
1853
+ lastError: string | null;
1854
+ fromMemory: number;
1855
+ fromStorage: number;
1856
+ fromNetwork: number;
1857
+ revalidations: number;
1858
+ unchanged: number;
1859
+ bytesSaved: number;
1860
+ };
1861
+ export const setCloudRepository: (repository: CloudRepository) => void;
1862
+ export const setEnvironment: (env: string) => void;
1863
+ export const getResolvedConfig: (componentId: string, env?: string, preview?: boolean) => IComponentConfig;
1864
+ export const preloadComponents: (ids: string[], env?: string, preview?: boolean) => Promise<PromiseSettledResult<IComponentConfig>[]>;
1865
+ /**
1866
+ * Seed already-resolved component configs into the SDK cache, with no network
1867
+ * request. The counterpart to {@link preloadComponents}.
1868
+ *
1869
+ * Use it when the configs were resolved somewhere else — typically on a server
1870
+ * and embedded in the page — so the component renders with zero round trips:
1871
+ *
1872
+ * ```ts
1873
+ * // server: const configs = { [id]: await new CloudRepository().fetchComponentV2(id) }
1874
+ * // client:
1875
+ * hydrateComponents(configs);
1876
+ * // <MyopComponent componentId={id} /> now renders without fetching
1877
+ * ```
1878
+ *
1879
+ * Pass the same `env` / `preview` the configs were resolved with; the defaults
1880
+ * match what a plain `preloadComponents([id])` would have used.
1881
+ */
1882
+ export const hydrateComponents: (configs: Record<string, IComponentConfig>, env?: string, preview?: boolean) => void;
1883
+ }
1485
1884
  declare module "@myop/sdk/webcomponent/shadowRootRef" {
1486
1885
  import { RootRef } from "@myop/sdk/common";
1487
1886
  export class ShadowRootRef extends RootRef {
@@ -1710,7 +2109,8 @@ declare module "@myop/sdk/host/loaders/HTMLComponentLoader" {
1710
2109
  */
1711
2110
  private extractWebComponentScript;
1712
2111
  /**
1713
- * Execute the web component script on the host document
2112
+ * Execute the web component script on the host document.
2113
+ * Returns the custom element tag name this script registered.
1714
2114
  */
1715
2115
  private executeWebComponentScript;
1716
2116
  /**
@@ -1775,174 +2175,9 @@ declare module "@myop/sdk/helpers/configBuilder" {
1775
2175
  build: () => any;
1776
2176
  }
1777
2177
  }
1778
- declare module "@myop/sdk/helpers/CloudRepository" {
1779
- import { IComponentConfig, IUserFlow } from "@myop/sdk/common";
1780
- export class CloudRepository {
1781
- private _baseUrl;
1782
- private static _main;
1783
- static get Main(): CloudRepository;
1784
- private variants;
1785
- private preloadedComponents;
1786
- private userFlows;
1787
- private _defaultEnv;
1788
- private _envExplicitlySet;
1789
- private _staticMode;
1790
- private _queryParams;
1791
- constructor(_baseUrl?: string);
1792
- /**
1793
- * Enable static mode for self-hosted component registries.
1794
- * In static mode, URLs are constructed as file paths instead of query params:
1795
- * ${baseUrl}/components/${componentId}/${env}.json
1796
- */
1797
- enableStaticMode(): void;
1798
- /**
1799
- * Set query parameters to append to all fetch URLs (e.g. for CDN cache busting).
1800
- * Example: `setQueryParams({ lastupdate: '11112026' })`
1801
- */
1802
- setQueryParams(params: Record<string, string>): void;
1803
- /**
1804
- * Set the default environment for this CloudRepository instance
1805
- */
1806
- setEnvironment(env: string): void;
1807
- /**
1808
- * Get the current default environment
1809
- */
1810
- getDefaultEnvironment(): string;
1811
- /**
1812
- * Check if a component is already cached/preloaded (v2)
1813
- * If env and preview are not provided, checks if ANY version is preloaded
1814
- */
1815
- isPreloaded(componentId: string, env?: string, preview?: boolean): boolean;
1816
- /**
1817
- * Get the preloaded params for a component (if preloaded)
1818
- * Returns undefined if not preloaded
1819
- */
1820
- getPreloadedParams(componentId: string): {
1821
- env: string;
1822
- preview: boolean;
1823
- } | undefined;
1824
- /**
1825
- * Resolve a component config: fetch it once, then serve it from this
1826
- * repository's cache.
1827
- *
1828
- * This is the name to use. `fetchComponentV2` is the same method under its
1829
- * versioned name and stays for backward compatibility — note that the
1830
- * unversioned `fetchComponent` is a *deprecated v1* API and is NOT this.
1831
- *
1832
- * Completes the trio with {@link getResolvedConfig} (synchronous read of an
1833
- * already-resolved config) and {@link hydrateComponent} (seed one you
1834
- * already hold).
1835
- *
1836
- * Prefer the module-level `preloadComponents([id])` in app code; reach for
1837
- * this when you need an isolated repository instance whose cache lifetime
1838
- * you control — a server with its own TTL, for example.
1839
- */
1840
- resolveComponent(componentId: string, env?: string, preview?: boolean): Promise<IComponentConfig>;
1841
- /**
1842
- * Fetch a v2 component config
1843
- * If env/preview not specified and component was preloaded, uses preloaded params
1844
- *
1845
- * @see resolveComponent — the unversioned name for this method
1846
- */
1847
- fetchComponentV2(componentId: string, environmentIdentifier?: string, preview?: boolean): Promise<IComponentConfig>;
1848
- /**
1849
- * Synchronous version of fetchComponentV2 — returns the config only if
1850
- * the fetch already completed, null otherwise.
1851
- *
1852
- * Uses the same `this.variants` cache that fetchComponentV2/preloadComponents
1853
- * populate. Each cached Promise is tagged with a `.resolved` property when
1854
- * it settles — this method just reads that property. No separate cache.
1855
- *
1856
- * Why this exists: React Native needs the config at render time to embed it
1857
- * in the WebView HTML (can't await in useState). If preloadComponents ran
1858
- * earlier and the fetch completed, this returns the result synchronously,
1859
- * skipping the WEBVIEW_READY → fetch → inject round trip entirely.
1860
- */
1861
- getResolvedConfig(componentId: string, env?: string, preview?: boolean): IComponentConfig | null;
1862
- /**
1863
- * Resolve which (env, preview) pair — and therefore which cache key — a call
1864
- * for `componentId` refers to.
1865
- *
1866
- * Single source of truth for fetchComponentV2, getResolvedConfig and
1867
- * hydrateComponent, so a hydrated config always lands on the key a later
1868
- * fetch will look under.
1869
- */
1870
- private resolveParams;
1871
- /**
1872
- * Seed an already-resolved component config into the cache, without any
1873
- * network request.
1874
- *
1875
- * The counterpart to {@link fetchComponentV2}: use it when the config was
1876
- * resolved somewhere else — most often on a server, then embedded in the
1877
- * page — so the browser can render the component with no round trip.
1878
- *
1879
- * After hydrating, `fetchComponentV2`, `getResolvedConfig` and `isPreloaded`
1880
- * all answer for this component from memory.
1881
- *
1882
- * Pass the same `env` / `preview` the config was resolved with; the defaults
1883
- * match what a plain `fetchComponentV2(componentId)` would have used.
1884
- */
1885
- hydrateComponent(componentId: string, config: IComponentConfig, env?: string, preview?: boolean): void;
1886
- /**
1887
- * Fetch a v1 component from a flow
1888
- */
1889
- fetchComponentV1(componentId: string, flowId?: string): Promise<IComponentConfig>;
1890
- fetchAutoFlow(componentId: string): Promise<IUserFlow>;
1891
- fetchFlow(flowId: string): Promise<IUserFlow>;
1892
- /**
1893
- * @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly
1894
- * Defaults to v1 behavior for backward compatibility with existing code
1895
- */
1896
- fetchComponent(componentId: string, flowId?: string): Promise<IComponentConfig>;
1897
- }
1898
- /**
1899
- * @deprecated Use CloudRepository instead
1900
- */
1901
- export const v2_CloudRepository: typeof CloudRepository;
1902
- }
1903
2178
  declare module "@myop/sdk/helpers/exec" {
1904
2179
  export const exec: (getter: any) => Promise<any>;
1905
2180
  }
1906
- declare module "@myop/sdk/helpers/cloudRepositoryHelpers" {
1907
- import { CloudRepository } from "@myop/sdk/helpers/CloudRepository";
1908
- import { IComponentConfig } from "@myop/sdk/common";
1909
- export const getCloudRepository: () => CloudRepository;
1910
- export const isPreloaded: (componentId: string, env?: string, preview?: boolean) => boolean;
1911
- export const getPreloadedParams: (componentId: string) => {
1912
- env: string;
1913
- preview: boolean;
1914
- };
1915
- export const enableLocalDev: () => void;
1916
- export const setCloudRepositoryUrl: (url: string) => void;
1917
- /**
1918
- * Configure the SDK to fetch components from a self-hosted static registry (S3, CDN, etc.)
1919
- * instead of the Myop cloud. Components are served as static JSON files:
1920
- * `${cdnUrl}/components/${componentId}/${environment}.json`
1921
- */
1922
- export const enableSelfHosted: (cdnUrl: string, queryParams?: Record<string, string>) => void;
1923
- export const setCloudRepository: (repository: CloudRepository) => void;
1924
- export const setEnvironment: (env: string) => void;
1925
- export const getResolvedConfig: (componentId: string, env?: string, preview?: boolean) => IComponentConfig;
1926
- export const preloadComponents: (ids: string[], env?: string, preview?: boolean) => Promise<PromiseSettledResult<IComponentConfig>[]>;
1927
- /**
1928
- * Seed already-resolved component configs into the SDK cache, with no network
1929
- * request. The counterpart to {@link preloadComponents}.
1930
- *
1931
- * Use it when the configs were resolved somewhere else — typically on a server
1932
- * and embedded in the page — so the component renders with zero round trips:
1933
- *
1934
- * ```ts
1935
- * // server: const configs = { [id]: await new CloudRepository().fetchComponentV2(id) }
1936
- * // client:
1937
- * hydrateComponents(configs);
1938
- * // <MyopComponent componentId={id} /> now renders without fetching
1939
- * ```
1940
- *
1941
- * Pass the same `env` / `preview` the configs were resolved with; the defaults
1942
- * match what a plain `preloadComponents([id])` would have used.
1943
- */
1944
- export const hydrateComponents: (configs: Record<string, IComponentConfig>, env?: string, preview?: boolean) => void;
1945
- }
1946
2181
  declare module "@myop/sdk/helpers" {
1947
2182
  export * from "@myop/sdk/helpers/applyStylesheet";
1948
2183
  export * from "@myop/sdk/helpers/iframeSkinUrlTokenizer";
@@ -1985,9 +2220,11 @@ declare module "@myop/sdk/host/hostSDK" {
1985
2220
  assignId: (componentDefinition: IComponentDefinitionConfig) => string;
1986
2221
  private inspected;
1987
2222
  inspect: () => void;
2223
+ private isTrustedSource;
1988
2224
  private incomingMessageHandler;
1989
2225
  send: (message: BaseMyopMessage) => void;
1990
2226
  init: (customComponentLoaderCreators?: componentLoaderCreator[]) => void;
2227
+ private _registerLoaders;
1991
2228
  private _getSkinIdBySkinSelector;
1992
2229
  private runSkinSelector;
1993
2230
  loaderHooks?: loaderHooks;
@@ -2074,11 +2311,15 @@ declare module "@myop/sdk/SDK" {
2074
2311
  const getHostModule: () => Promise<typeof import("@myop/sdk/host/hostSDK")>;
2075
2312
  const getIframeModule: () => Promise<typeof import("@myop/sdk/Iframe/IframeSDK")>;
2076
2313
  const getWebcomponentModule: () => Promise<typeof import("@myop/sdk/webcomponent/WebComponentSDK")>;
2314
+ const getMyopMessages: () => Promise<typeof import("messages/MyopMessages")>;
2315
+ const getMyopHelpers: () => Promise<typeof import("helpers/MyopHelpers")>;
2077
2316
  const sdkModule: {
2078
2317
  getHostModule: () => Promise<typeof import("@myop/sdk/host/hostSDK")>;
2079
2318
  getIframeModule: () => Promise<typeof import("@myop/sdk/Iframe/IframeSDK")>;
2080
2319
  getWebcomponentModule: () => Promise<typeof import("@myop/sdk/webcomponent/WebComponentSDK")>;
2320
+ getMyopMessages: () => Promise<typeof import("messages/MyopMessages")>;
2321
+ getMyopHelpers: () => Promise<typeof import("helpers/MyopHelpers")>;
2081
2322
  };
2082
2323
  export type rootSDKType = typeof sdkModule;
2083
- export { getHostModule, getIframeModule, getWebcomponentModule };
2324
+ export { getHostModule, getIframeModule, getWebcomponentModule, getMyopMessages, getMyopHelpers };
2084
2325
  }