@myop/sdk 0.3.36 → 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.
- package/dist/bundled-declarations.d.ts +406 -166
- package/dist/cjs/{_IframeSDK.3283252f.js → _IframeSDK.096d8320.js} +1325 -915
- package/dist/cjs/_IframeSDK.096d8320.js.map +7 -0
- package/dist/cjs/_IframeSDK.8e791f92.min.js +1 -0
- package/dist/cjs/_MyopHelpers.91004b19.min.js +1 -0
- package/dist/cjs/{_MyopHelpers.08d1cf5d.js → _MyopHelpers.efed13e4.js} +362 -2
- package/dist/cjs/_MyopHelpers.efed13e4.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.4a87f826.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.e84be6ea.js → _WebComponentSDK.e9e877db.js} +893 -486
- package/dist/cjs/_WebComponentSDK.e9e877db.js.map +7 -0
- package/dist/cjs/{_hostSDK.fa5b3ccf.js → _hostSDK.0c271647.js} +1348 -941
- package/dist/cjs/_hostSDK.0c271647.js.map +7 -0
- package/dist/cjs/_hostSDK.7d759290.min.js +1 -0
- package/dist/cjs/myop_sdk.js +35 -24
- package/dist/cjs/myop_sdk.js.map +2 -2
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +1820 -1379
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +4 -4
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +1501 -1079
- package/dist/module/Iframe/index.js.map +4 -4
- package/dist/module/SDK.d.ts +5 -1
- package/dist/module/SDK.js +1974 -1523
- package/dist/module/SDK.js.map +4 -4
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/helpers/CloudRepository.d.ts +96 -0
- package/dist/module/helpers/cloudRepositoryHelpers.d.ts +99 -0
- package/dist/module/helpers/deliveryStore.d.ts +51 -0
- package/dist/module/helpers/index.js +370 -3
- package/dist/module/helpers/index.js.map +4 -4
- package/dist/module/host/components/myopIframeComponent.d.ts +6 -0
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/hostSDK.d.ts +2 -0
- package/dist/module/host/index.js +1516 -1097
- package/dist/module/host/index.js.map +4 -4
- package/dist/module/webcomponent/index.js +1202 -783
- package/dist/module/webcomponent/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.3283252f.js.map +0 -7
- package/dist/cjs/_IframeSDK.652f4774.min.js +0 -1
- package/dist/cjs/_MyopHelpers.08d1cf5d.js.map +0 -7
- package/dist/cjs/_MyopHelpers.59521d8f.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.8fe7c9bf.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.e84be6ea.js.map +0 -7
- package/dist/cjs/_hostSDK.de2d767e.min.js +0 -1
- package/dist/cjs/_hostSDK.fa5b3ccf.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 {
|
|
@@ -1776,174 +2175,9 @@ declare module "@myop/sdk/helpers/configBuilder" {
|
|
|
1776
2175
|
build: () => any;
|
|
1777
2176
|
}
|
|
1778
2177
|
}
|
|
1779
|
-
declare module "@myop/sdk/helpers/CloudRepository" {
|
|
1780
|
-
import { IComponentConfig, IUserFlow } from "@myop/sdk/common";
|
|
1781
|
-
export class CloudRepository {
|
|
1782
|
-
private _baseUrl;
|
|
1783
|
-
private static _main;
|
|
1784
|
-
static get Main(): CloudRepository;
|
|
1785
|
-
private variants;
|
|
1786
|
-
private preloadedComponents;
|
|
1787
|
-
private userFlows;
|
|
1788
|
-
private _defaultEnv;
|
|
1789
|
-
private _envExplicitlySet;
|
|
1790
|
-
private _staticMode;
|
|
1791
|
-
private _queryParams;
|
|
1792
|
-
constructor(_baseUrl?: string);
|
|
1793
|
-
/**
|
|
1794
|
-
* Enable static mode for self-hosted component registries.
|
|
1795
|
-
* In static mode, URLs are constructed as file paths instead of query params:
|
|
1796
|
-
* ${baseUrl}/components/${componentId}/${env}.json
|
|
1797
|
-
*/
|
|
1798
|
-
enableStaticMode(): void;
|
|
1799
|
-
/**
|
|
1800
|
-
* Set query parameters to append to all fetch URLs (e.g. for CDN cache busting).
|
|
1801
|
-
* Example: `setQueryParams({ lastupdate: '11112026' })`
|
|
1802
|
-
*/
|
|
1803
|
-
setQueryParams(params: Record<string, string>): void;
|
|
1804
|
-
/**
|
|
1805
|
-
* Set the default environment for this CloudRepository instance
|
|
1806
|
-
*/
|
|
1807
|
-
setEnvironment(env: string): void;
|
|
1808
|
-
/**
|
|
1809
|
-
* Get the current default environment
|
|
1810
|
-
*/
|
|
1811
|
-
getDefaultEnvironment(): string;
|
|
1812
|
-
/**
|
|
1813
|
-
* Check if a component is already cached/preloaded (v2)
|
|
1814
|
-
* If env and preview are not provided, checks if ANY version is preloaded
|
|
1815
|
-
*/
|
|
1816
|
-
isPreloaded(componentId: string, env?: string, preview?: boolean): boolean;
|
|
1817
|
-
/**
|
|
1818
|
-
* Get the preloaded params for a component (if preloaded)
|
|
1819
|
-
* Returns undefined if not preloaded
|
|
1820
|
-
*/
|
|
1821
|
-
getPreloadedParams(componentId: string): {
|
|
1822
|
-
env: string;
|
|
1823
|
-
preview: boolean;
|
|
1824
|
-
} | undefined;
|
|
1825
|
-
/**
|
|
1826
|
-
* Resolve a component config: fetch it once, then serve it from this
|
|
1827
|
-
* repository's cache.
|
|
1828
|
-
*
|
|
1829
|
-
* This is the name to use. `fetchComponentV2` is the same method under its
|
|
1830
|
-
* versioned name and stays for backward compatibility — note that the
|
|
1831
|
-
* unversioned `fetchComponent` is a *deprecated v1* API and is NOT this.
|
|
1832
|
-
*
|
|
1833
|
-
* Completes the trio with {@link getResolvedConfig} (synchronous read of an
|
|
1834
|
-
* already-resolved config) and {@link hydrateComponent} (seed one you
|
|
1835
|
-
* already hold).
|
|
1836
|
-
*
|
|
1837
|
-
* Prefer the module-level `preloadComponents([id])` in app code; reach for
|
|
1838
|
-
* this when you need an isolated repository instance whose cache lifetime
|
|
1839
|
-
* you control — a server with its own TTL, for example.
|
|
1840
|
-
*/
|
|
1841
|
-
resolveComponent(componentId: string, env?: string, preview?: boolean): Promise<IComponentConfig>;
|
|
1842
|
-
/**
|
|
1843
|
-
* Fetch a v2 component config
|
|
1844
|
-
* If env/preview not specified and component was preloaded, uses preloaded params
|
|
1845
|
-
*
|
|
1846
|
-
* @see resolveComponent — the unversioned name for this method
|
|
1847
|
-
*/
|
|
1848
|
-
fetchComponentV2(componentId: string, environmentIdentifier?: string, preview?: boolean): Promise<IComponentConfig>;
|
|
1849
|
-
/**
|
|
1850
|
-
* Synchronous version of fetchComponentV2 — returns the config only if
|
|
1851
|
-
* the fetch already completed, null otherwise.
|
|
1852
|
-
*
|
|
1853
|
-
* Uses the same `this.variants` cache that fetchComponentV2/preloadComponents
|
|
1854
|
-
* populate. Each cached Promise is tagged with a `.resolved` property when
|
|
1855
|
-
* it settles — this method just reads that property. No separate cache.
|
|
1856
|
-
*
|
|
1857
|
-
* Why this exists: React Native needs the config at render time to embed it
|
|
1858
|
-
* in the WebView HTML (can't await in useState). If preloadComponents ran
|
|
1859
|
-
* earlier and the fetch completed, this returns the result synchronously,
|
|
1860
|
-
* skipping the WEBVIEW_READY → fetch → inject round trip entirely.
|
|
1861
|
-
*/
|
|
1862
|
-
getResolvedConfig(componentId: string, env?: string, preview?: boolean): IComponentConfig | null;
|
|
1863
|
-
/**
|
|
1864
|
-
* Resolve which (env, preview) pair — and therefore which cache key — a call
|
|
1865
|
-
* for `componentId` refers to.
|
|
1866
|
-
*
|
|
1867
|
-
* Single source of truth for fetchComponentV2, getResolvedConfig and
|
|
1868
|
-
* hydrateComponent, so a hydrated config always lands on the key a later
|
|
1869
|
-
* fetch will look under.
|
|
1870
|
-
*/
|
|
1871
|
-
private resolveParams;
|
|
1872
|
-
/**
|
|
1873
|
-
* Seed an already-resolved component config into the cache, without any
|
|
1874
|
-
* network request.
|
|
1875
|
-
*
|
|
1876
|
-
* The counterpart to {@link fetchComponentV2}: use it when the config was
|
|
1877
|
-
* resolved somewhere else — most often on a server, then embedded in the
|
|
1878
|
-
* page — so the browser can render the component with no round trip.
|
|
1879
|
-
*
|
|
1880
|
-
* After hydrating, `fetchComponentV2`, `getResolvedConfig` and `isPreloaded`
|
|
1881
|
-
* all answer for this component from memory.
|
|
1882
|
-
*
|
|
1883
|
-
* Pass the same `env` / `preview` the config was resolved with; the defaults
|
|
1884
|
-
* match what a plain `fetchComponentV2(componentId)` would have used.
|
|
1885
|
-
*/
|
|
1886
|
-
hydrateComponent(componentId: string, config: IComponentConfig, env?: string, preview?: boolean): void;
|
|
1887
|
-
/**
|
|
1888
|
-
* Fetch a v1 component from a flow
|
|
1889
|
-
*/
|
|
1890
|
-
fetchComponentV1(componentId: string, flowId?: string): Promise<IComponentConfig>;
|
|
1891
|
-
fetchAutoFlow(componentId: string): Promise<IUserFlow>;
|
|
1892
|
-
fetchFlow(flowId: string): Promise<IUserFlow>;
|
|
1893
|
-
/**
|
|
1894
|
-
* @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly
|
|
1895
|
-
* Defaults to v1 behavior for backward compatibility with existing code
|
|
1896
|
-
*/
|
|
1897
|
-
fetchComponent(componentId: string, flowId?: string): Promise<IComponentConfig>;
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
* @deprecated Use CloudRepository instead
|
|
1901
|
-
*/
|
|
1902
|
-
export const v2_CloudRepository: typeof CloudRepository;
|
|
1903
|
-
}
|
|
1904
2178
|
declare module "@myop/sdk/helpers/exec" {
|
|
1905
2179
|
export const exec: (getter: any) => Promise<any>;
|
|
1906
2180
|
}
|
|
1907
|
-
declare module "@myop/sdk/helpers/cloudRepositoryHelpers" {
|
|
1908
|
-
import { CloudRepository } from "@myop/sdk/helpers/CloudRepository";
|
|
1909
|
-
import { IComponentConfig } from "@myop/sdk/common";
|
|
1910
|
-
export const getCloudRepository: () => CloudRepository;
|
|
1911
|
-
export const isPreloaded: (componentId: string, env?: string, preview?: boolean) => boolean;
|
|
1912
|
-
export const getPreloadedParams: (componentId: string) => {
|
|
1913
|
-
env: string;
|
|
1914
|
-
preview: boolean;
|
|
1915
|
-
};
|
|
1916
|
-
export const enableLocalDev: () => void;
|
|
1917
|
-
export const setCloudRepositoryUrl: (url: string) => void;
|
|
1918
|
-
/**
|
|
1919
|
-
* Configure the SDK to fetch components from a self-hosted static registry (S3, CDN, etc.)
|
|
1920
|
-
* instead of the Myop cloud. Components are served as static JSON files:
|
|
1921
|
-
* `${cdnUrl}/components/${componentId}/${environment}.json`
|
|
1922
|
-
*/
|
|
1923
|
-
export const enableSelfHosted: (cdnUrl: string, queryParams?: Record<string, string>) => void;
|
|
1924
|
-
export const setCloudRepository: (repository: CloudRepository) => void;
|
|
1925
|
-
export const setEnvironment: (env: string) => void;
|
|
1926
|
-
export const getResolvedConfig: (componentId: string, env?: string, preview?: boolean) => IComponentConfig;
|
|
1927
|
-
export const preloadComponents: (ids: string[], env?: string, preview?: boolean) => Promise<PromiseSettledResult<IComponentConfig>[]>;
|
|
1928
|
-
/**
|
|
1929
|
-
* Seed already-resolved component configs into the SDK cache, with no network
|
|
1930
|
-
* request. The counterpart to {@link preloadComponents}.
|
|
1931
|
-
*
|
|
1932
|
-
* Use it when the configs were resolved somewhere else — typically on a server
|
|
1933
|
-
* and embedded in the page — so the component renders with zero round trips:
|
|
1934
|
-
*
|
|
1935
|
-
* ```ts
|
|
1936
|
-
* // server: const configs = { [id]: await new CloudRepository().fetchComponentV2(id) }
|
|
1937
|
-
* // client:
|
|
1938
|
-
* hydrateComponents(configs);
|
|
1939
|
-
* // <MyopComponent componentId={id} /> now renders without fetching
|
|
1940
|
-
* ```
|
|
1941
|
-
*
|
|
1942
|
-
* Pass the same `env` / `preview` the configs were resolved with; the defaults
|
|
1943
|
-
* match what a plain `preloadComponents([id])` would have used.
|
|
1944
|
-
*/
|
|
1945
|
-
export const hydrateComponents: (configs: Record<string, IComponentConfig>, env?: string, preview?: boolean) => void;
|
|
1946
|
-
}
|
|
1947
2181
|
declare module "@myop/sdk/helpers" {
|
|
1948
2182
|
export * from "@myop/sdk/helpers/applyStylesheet";
|
|
1949
2183
|
export * from "@myop/sdk/helpers/iframeSkinUrlTokenizer";
|
|
@@ -1986,9 +2220,11 @@ declare module "@myop/sdk/host/hostSDK" {
|
|
|
1986
2220
|
assignId: (componentDefinition: IComponentDefinitionConfig) => string;
|
|
1987
2221
|
private inspected;
|
|
1988
2222
|
inspect: () => void;
|
|
2223
|
+
private isTrustedSource;
|
|
1989
2224
|
private incomingMessageHandler;
|
|
1990
2225
|
send: (message: BaseMyopMessage) => void;
|
|
1991
2226
|
init: (customComponentLoaderCreators?: componentLoaderCreator[]) => void;
|
|
2227
|
+
private _registerLoaders;
|
|
1992
2228
|
private _getSkinIdBySkinSelector;
|
|
1993
2229
|
private runSkinSelector;
|
|
1994
2230
|
loaderHooks?: loaderHooks;
|
|
@@ -2075,11 +2311,15 @@ declare module "@myop/sdk/SDK" {
|
|
|
2075
2311
|
const getHostModule: () => Promise<typeof import("@myop/sdk/host/hostSDK")>;
|
|
2076
2312
|
const getIframeModule: () => Promise<typeof import("@myop/sdk/Iframe/IframeSDK")>;
|
|
2077
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")>;
|
|
2078
2316
|
const sdkModule: {
|
|
2079
2317
|
getHostModule: () => Promise<typeof import("@myop/sdk/host/hostSDK")>;
|
|
2080
2318
|
getIframeModule: () => Promise<typeof import("@myop/sdk/Iframe/IframeSDK")>;
|
|
2081
2319
|
getWebcomponentModule: () => Promise<typeof import("@myop/sdk/webcomponent/WebComponentSDK")>;
|
|
2320
|
+
getMyopMessages: () => Promise<typeof import("messages/MyopMessages")>;
|
|
2321
|
+
getMyopHelpers: () => Promise<typeof import("helpers/MyopHelpers")>;
|
|
2082
2322
|
};
|
|
2083
2323
|
export type rootSDKType = typeof sdkModule;
|
|
2084
|
-
export { getHostModule, getIframeModule, getWebcomponentModule };
|
|
2324
|
+
export { getHostModule, getIframeModule, getWebcomponentModule, getMyopMessages, getMyopHelpers };
|
|
2085
2325
|
}
|