@monterosa/sdk-launcher-kit 0.18.2 → 0.18.3

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/index.cjs.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var sdkCore = require('@monterosa/sdk-core');
6
6
  var sdkUtil = require('@monterosa/sdk-util');
7
7
  var uuid = require('uuid');
8
- var sdkInteractKit = require('@monterosa/sdk-interact-kit');
8
+ var sdkInteractInterop = require('@monterosa/sdk-interact-interop');
9
9
 
10
10
  /*! *****************************************************************************
11
11
  Copyright (c) Microsoft Corporation.
@@ -127,7 +127,7 @@ var DEFAULT_HEIGHT = 250;
127
127
  *
128
128
  * More details on the license can be found at https://www.monterosa.co/sdk/license
129
129
  */
130
- var logger = new sdkCore.Logger('@monterosa/sdk-interact-kit');
130
+ var logger = new sdkCore.Logger('@monterosa/sdk-launcher-kit');
131
131
 
132
132
  /**
133
133
  * @license
@@ -363,9 +363,7 @@ function handleWindowMessage(_a) {
363
363
  receiveMessage(message);
364
364
  }
365
365
  catch (err) {
366
- if (err instanceof Error) {
367
- console.error(err.message);
368
- }
366
+ console.error(sdkUtil.getErrorMessage(err));
369
367
  }
370
368
  }
371
369
  /**
@@ -824,7 +822,7 @@ var ExperienceImpl = /** @class */ (function () {
824
822
  return [2 /*return*/, Promise.resolve(this.embedUrl)];
825
823
  }
826
824
  _a = this.sdk.options, host = _a.host, projectId = _a.projectId;
827
- return [4 /*yield*/, sdkInteractKit.fetchListings(host, projectId)];
825
+ return [4 /*yield*/, sdkInteractInterop.fetchListings(host, projectId)];
828
826
  case 1:
829
827
  listings = _b.sent();
830
828
  this.embedUrl = listings.project.embed;
@@ -1051,7 +1049,7 @@ function unstashStyles(element) {
1051
1049
  element.removeAttribute('data-stash');
1052
1050
  }
1053
1051
 
1054
- var version = "0.18.2";
1052
+ var version = "0.18.3";
1055
1053
 
1056
1054
  /**
1057
1055
  * @license
@@ -1350,6 +1348,9 @@ registerEmbedHook(onResize);
1350
1348
  *
1351
1349
  * More details on the license can be found at https://www.monterosa.co/sdk/license
1352
1350
  */
1351
+ /**
1352
+ * @internal
1353
+ */
1353
1354
  var ParentApplicationImpl = /** @class */ (function () {
1354
1355
  function ParentApplicationImpl(bridge) {
1355
1356
  this.bridge = bridge;
@@ -1552,293 +1553,10 @@ function reportExperienceSizeChanges(element) {
1552
1553
  return function () { return observer.unobserve(element); };
1553
1554
  }
1554
1555
 
1555
- /**
1556
- * @license
1557
- * storage_impl.ts
1558
- * launcher-kit
1559
- *
1560
- * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-15
1561
- * Copyright © 2023 Monterosa. All rights reserved.
1562
- *
1563
- * More details on the license can be found at https://www.monterosa.co/sdk/license
1564
- */
1565
- var StorageImpl = /** @class */ (function () {
1566
- function StorageImpl() {
1567
- this.memoryStore = {};
1568
- this.accessible = sdkUtil.checkAvailability();
1569
- this._persistent = false;
1570
- }
1571
- Object.defineProperty(StorageImpl.prototype, "persistent", {
1572
- get: function () {
1573
- return this._persistent;
1574
- },
1575
- set: function (newValue) {
1576
- var oldValue = this._persistent;
1577
- if (oldValue === newValue) {
1578
- return;
1579
- }
1580
- var swapToStorage = newValue === true && this.accessible;
1581
- var swapToMemory = newValue === false && this.accessible;
1582
- if (swapToStorage) {
1583
- for (var _i = 0, _a = Object.entries(this.memoryStore); _i < _a.length; _i++) {
1584
- var _b = _a[_i], key = _b[0], value = _b[1];
1585
- sdkUtil.setItem(key, value);
1586
- }
1587
- }
1588
- if (swapToMemory) {
1589
- sdkUtil.clear();
1590
- }
1591
- this._persistent = newValue;
1592
- },
1593
- enumerable: false,
1594
- configurable: true
1595
- });
1596
- StorageImpl.prototype.getItem = function (key) {
1597
- if (this.persistent && this.accessible) {
1598
- return sdkUtil.getItem(key);
1599
- }
1600
- if (Object.prototype.hasOwnProperty.call(this.memoryStore, key)) {
1601
- return this.memoryStore[key];
1602
- }
1603
- return null;
1604
- };
1605
- StorageImpl.prototype.setItem = function (key, value) {
1606
- if (this.persistent && this.accessible) {
1607
- sdkUtil.setItem(key, value);
1608
- }
1609
- this.memoryStore[key] = value;
1610
- };
1611
- StorageImpl.prototype.removeItem = function (key) {
1612
- if (this.persistent && this.accessible) {
1613
- sdkUtil.removeItem(key);
1614
- }
1615
- delete this.memoryStore[key];
1616
- };
1617
- StorageImpl.prototype.clear = function () {
1618
- if (this.persistent && this.accessible) {
1619
- sdkUtil.clear();
1620
- }
1621
- this.memoryStore = {};
1622
- };
1623
- return StorageImpl;
1624
- }());
1625
-
1626
- /**
1627
- * @license
1628
- * storage.ts
1629
- * launcher-kit
1630
- *
1631
- * Created by Rygor Kharytanovich <rygor@monterosa.co.uk> on 2023-02-15
1632
- * Copyright © 2023 Monterosa. All rights reserved.
1633
- *
1634
- * More details on the license can be found at https://www.monterosa.co/sdk/license
1635
- */
1636
- /**
1637
- * @internal
1638
- */
1639
- exports.StorageAction = void 0;
1640
- (function (StorageAction) {
1641
- StorageAction["Read"] = "storageRead";
1642
- StorageAction["Write"] = "storageWrite";
1643
- StorageAction["Remove"] = "storageRemove";
1644
- StorageAction["Clear"] = "storageClear";
1645
- })(exports.StorageAction || (exports.StorageAction = {}));
1646
- /**
1647
- * @internal
1648
- */
1649
- var storage = new StorageImpl();
1650
- /**
1651
- * @internal
1652
- */
1653
- function listenStorageMessages(experience) {
1654
- return onSdkMessage(experience, function (message) {
1655
- var payload = {};
1656
- if (!Object.values(exports.StorageAction).includes(message.action)) {
1657
- return;
1658
- }
1659
- switch (message.action) {
1660
- case exports.StorageAction.Read:
1661
- payload = {
1662
- value: storage.getItem(message.payload.key),
1663
- };
1664
- break;
1665
- case exports.StorageAction.Write:
1666
- storage.setItem(message.payload.key, message.payload.value);
1667
- break;
1668
- case exports.StorageAction.Remove:
1669
- storage.removeItem(message.payload.key);
1670
- break;
1671
- case exports.StorageAction.Clear:
1672
- storage.clear();
1673
- break;
1674
- }
1675
- respondToSdkMessage(experience, message, payload);
1676
- });
1677
- }
1678
- /**
1679
- * The `setStoragePersistent` function is a simple function that allows to
1680
- * control the persistence of the SDK storage. If the argument `persistent` is
1681
- * set to `true`, then the storage will be persistent across browser sessions
1682
- * and if it is set to `false`, then the storage will save to memory.
1683
- * It is important to note that the use of persistent storage may be subject
1684
- * to laws and regulations, such as those related to data privacy and protection.
1685
- *
1686
- * @remarks
1687
- * - We transition from persistent to memory and memory to persistent in
1688
- * a seamless manner for you
1689
- *
1690
- * - By default we store in memory
1691
- *
1692
- * - The value of storage persistent persists across session (aka put it to true,
1693
- * it will remain so, put it back to false, it will remain so)
1694
- *
1695
- * - You have the responsibility to comply with any laws and regulations, and
1696
- * store only the data if you know it's valid to do so
1697
- *
1698
- * @param persistent - Determines whether or not SDK storage should persist
1699
- * across browser sessions.
1700
- */
1701
- function setStoragePersistent(persistent) {
1702
- storage.persistent = persistent;
1703
- }
1704
- /**
1705
- * The function allows to read data from the SDK storage.
1706
- *
1707
- * @param key - The name of the item to be read from storage.
1708
- *
1709
- * @throws
1710
- * The function throws an error if there is a timeout reading the data
1711
- * from the parent application storage.
1712
- *
1713
- * @returns A promise that resolves to the value
1714
- * of the item in storage or `null` if the item doesn't exist.
1715
- */
1716
- function storageRead(key) {
1717
- return __awaiter(this, void 0, void 0, function () {
1718
- var parentApp, value, result;
1719
- return __generator(this, function (_a) {
1720
- switch (_a.label) {
1721
- case 0:
1722
- parentApp = getParentApplication();
1723
- value = null;
1724
- if (!(parentApp !== null)) return [3 /*break*/, 2];
1725
- return [4 /*yield*/, sendSdkRequest(parentApp, exports.StorageAction.Read, {
1726
- key: key,
1727
- })];
1728
- case 1:
1729
- result = _a.sent();
1730
- value = result.payload.value;
1731
- return [3 /*break*/, 3];
1732
- case 2:
1733
- value = storage.getItem(key);
1734
- _a.label = 3;
1735
- case 3: return [2 /*return*/, Promise.resolve(value)];
1736
- }
1737
- });
1738
- });
1739
- }
1740
- /**
1741
- * The function allows to write data to the SDK storage.
1742
- *
1743
- * @param key - A name of the item to be stored.
1744
- * @param value - A value to be stored.
1745
- *
1746
- * @throws
1747
- * The function throws an error if there is a timeout writing the data
1748
- * to the parent's application storage.
1749
- *
1750
- * @returns A promise that resolves to `void` once the data has
1751
- * been successfully stored.
1752
- */
1753
- function storageWrite(key, value) {
1754
- return __awaiter(this, void 0, void 0, function () {
1755
- var parentApp;
1756
- return __generator(this, function (_a) {
1757
- switch (_a.label) {
1758
- case 0:
1759
- parentApp = getParentApplication();
1760
- if (!(parentApp !== null)) return [3 /*break*/, 2];
1761
- return [4 /*yield*/, sendSdkRequest(parentApp, exports.StorageAction.Write, {
1762
- key: key,
1763
- value: value,
1764
- })];
1765
- case 1:
1766
- _a.sent();
1767
- return [3 /*break*/, 3];
1768
- case 2:
1769
- storage.setItem(key, value);
1770
- _a.label = 3;
1771
- case 3: return [2 /*return*/, Promise.resolve()];
1772
- }
1773
- });
1774
- });
1775
- }
1776
- /**
1777
- * The function allows to remove an item from the SDK storage.
1778
- *
1779
- * @param key - A name of the item to be removed.
1780
- *
1781
- * @throws
1782
- * The function throws an error if there is a timeout removing the data
1783
- * from the parent's application storage.
1784
- *
1785
- * @returns A promise that resolves to `void` once the data has
1786
- * been successfully removed.
1787
- */
1788
- function storageRemove(key) {
1789
- return __awaiter(this, void 0, void 0, function () {
1790
- var parentApp;
1791
- return __generator(this, function (_a) {
1792
- switch (_a.label) {
1793
- case 0:
1794
- parentApp = getParentApplication();
1795
- if (!(parentApp !== null)) return [3 /*break*/, 2];
1796
- return [4 /*yield*/, sendSdkRequest(parentApp, exports.StorageAction.Remove, { key: key })];
1797
- case 1:
1798
- _a.sent();
1799
- return [3 /*break*/, 3];
1800
- case 2:
1801
- storage.removeItem(key);
1802
- _a.label = 3;
1803
- case 3: return [2 /*return*/, Promise.resolve()];
1804
- }
1805
- });
1806
- });
1807
- }
1808
- /**
1809
- * The function allows to clear all data from the SDK storage.
1810
- *
1811
- * @throws
1812
- * The function throws an error if there is a timeout clearing the parent's
1813
- * application storage.
1814
- *
1815
- * @returns A promise that resolves to `void` once the data has been
1816
- * successfully cleared.
1817
- */
1818
- function storageClear() {
1819
- return __awaiter(this, void 0, void 0, function () {
1820
- var parentApp;
1821
- return __generator(this, function (_a) {
1822
- switch (_a.label) {
1823
- case 0:
1824
- parentApp = getParentApplication();
1825
- if (!(parentApp !== null)) return [3 /*break*/, 2];
1826
- return [4 /*yield*/, sendSdkRequest(parentApp, exports.StorageAction.Clear)];
1827
- case 1:
1828
- _a.sent();
1829
- return [3 /*break*/, 3];
1830
- case 2:
1831
- storage.clear();
1832
- _a.label = 3;
1833
- case 3: return [2 /*return*/, Promise.resolve()];
1834
- }
1835
- });
1836
- });
1837
- }
1838
- registerEmbedHook(listenStorageMessages);
1839
-
1840
1556
  exports.BRIDGE_VERSION = VERSION$1;
1841
1557
  exports.BridgeImpl = BridgeImpl;
1558
+ exports.ExperienceImpl = ExperienceImpl;
1559
+ exports.ParentApplicationImpl = ParentApplicationImpl;
1842
1560
  exports.VERSION = VERSION;
1843
1561
  exports.embed = embed;
1844
1562
  exports.enableLogging = enableLogging;
@@ -1847,7 +1565,6 @@ exports.getExperience = getExperience;
1847
1565
  exports.getParentApplication = getParentApplication;
1848
1566
  exports.getParentBridge = getParentBridge;
1849
1567
  exports.isAutoresizesHeight = isAutoresizesHeight;
1850
- exports.listenStorageMessages = listenStorageMessages;
1851
1568
  exports.onMessage = onMessage;
1852
1569
  exports.onMoreDataRequested = onMoreDataRequested;
1853
1570
  exports.onReady = onReady;
@@ -1866,12 +1583,6 @@ exports.sendRequest = sendRequest;
1866
1583
  exports.sendSdkMessage = sendSdkMessage;
1867
1584
  exports.sendSdkRequest = sendSdkRequest;
1868
1585
  exports.setRequestTimeout = setRequestTimeout;
1869
- exports.setStoragePersistent = setStoragePersistent;
1870
1586
  exports.shouldHideHeaderAndFooter = shouldHideHeaderAndFooter;
1871
- exports.storage = storage;
1872
- exports.storageClear = storageClear;
1873
- exports.storageRead = storageRead;
1874
- exports.storageRemove = storageRemove;
1875
- exports.storageWrite = storageWrite;
1876
1587
  exports.unmount = unmount;
1877
1588
  //# sourceMappingURL=index.cjs.js.map