arky-sdk 0.4.21 → 0.4.22

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 CHANGED
@@ -1421,6 +1421,13 @@ var createPlatformApi = (apiConfig) => {
1421
1421
  };
1422
1422
 
1423
1423
  // src/utils/currency.ts
1424
+ var cachedCurrencies = null;
1425
+ function setCurrenciesCache(currencies) {
1426
+ cachedCurrencies = currencies;
1427
+ }
1428
+ function getCurrenciesCache() {
1429
+ return cachedCurrencies;
1430
+ }
1424
1431
  function formatCurrency(amount, currencyCode, locale = "en") {
1425
1432
  return new Intl.NumberFormat(locale, {
1426
1433
  style: "currency",
@@ -1428,6 +1435,8 @@ function formatCurrency(amount, currencyCode, locale = "en") {
1428
1435
  }).format(amount);
1429
1436
  }
1430
1437
  function getCurrencySymbol(currencyCode) {
1438
+ const cached = cachedCurrencies?.find((c) => c.code === currencyCode.toLowerCase());
1439
+ if (cached) return cached.symbol;
1431
1440
  const parts = new Intl.NumberFormat("en", {
1432
1441
  style: "currency",
1433
1442
  currency: currencyCode.toUpperCase(),
@@ -1436,6 +1445,8 @@ function getCurrencySymbol(currencyCode) {
1436
1445
  return parts.find((p) => p.type === "currency")?.value || "";
1437
1446
  }
1438
1447
  function getCurrencyName(currencyCode) {
1448
+ const cached = cachedCurrencies?.find((c) => c.code === currencyCode.toLowerCase());
1449
+ if (cached) return cached.name;
1439
1450
  const displayNames = new Intl.DisplayNames(["en"], { type: "currency" });
1440
1451
  return displayNames.of(currencyCode.toUpperCase()) || "";
1441
1452
  }
@@ -1652,7 +1663,7 @@ function track(eventName, params) {
1652
1663
  }
1653
1664
 
1654
1665
  // src/index.ts
1655
- var SDK_VERSION = "0.4.21";
1666
+ var SDK_VERSION = "0.4.22";
1656
1667
  var SUPPORTED_FRAMEWORKS = [
1657
1668
  "astro",
1658
1669
  "react",
@@ -1683,6 +1694,14 @@ async function createArkySDK(config) {
1683
1694
  }
1684
1695
  }).catch(() => {
1685
1696
  });
1697
+ if (config.fetchFullConfig) {
1698
+ platformApi.getConfig({ params: { currencies: true } }).then((platformConfig) => {
1699
+ if (platformConfig.currencies) {
1700
+ setCurrenciesCache(platformConfig.currencies);
1701
+ }
1702
+ }).catch(() => {
1703
+ });
1704
+ }
1686
1705
  }
1687
1706
  const sdk = {
1688
1707
  auth: authApi,
@@ -1737,6 +1756,7 @@ async function createArkySDK(config) {
1737
1756
  formatCurrency,
1738
1757
  getCurrencySymbol,
1739
1758
  getCurrencyName,
1759
+ getCurrenciesCache,
1740
1760
  validatePhoneNumber,
1741
1761
  tzGroups,
1742
1762
  findTimeZone,
@@ -1766,6 +1786,7 @@ exports.SDK_VERSION = SDK_VERSION;
1766
1786
  exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
1767
1787
  exports.createArkySDK = createArkySDK;
1768
1788
  exports.formatCurrency = formatCurrency;
1789
+ exports.getCurrenciesCache = getCurrenciesCache;
1769
1790
  exports.getCurrencyName = getCurrencyName;
1770
1791
  exports.getCurrencySymbol = getCurrencySymbol;
1771
1792
  //# sourceMappingURL=index.cjs.map