@calimero-network/mero-react 9.11.5 → 9.13.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/index.cjs CHANGED
@@ -1024,6 +1024,13 @@ function useAccountEnrolment({
1024
1024
  customWallet: walletOverride !== void 0
1025
1025
  };
1026
1026
  }
1027
+
1028
+ // src/utils/desktop.ts
1029
+ function isDesktopWindow() {
1030
+ if (typeof window === "undefined") return false;
1031
+ const w = window;
1032
+ return "__TAURI_INTERNALS__" in w || w.__TAURI_FETCH_PROXY_INJECTED__ === true;
1033
+ }
1027
1034
  var CUSTOM_SELECTION = "__custom__";
1028
1035
  var TABS = [
1029
1036
  { id: "node", label: "Node" },
@@ -1309,9 +1316,10 @@ function LoginModal({
1309
1316
  cloud,
1310
1317
  initialTab: initialTabProp
1311
1318
  }) {
1312
- const own = useAccountEnrolment({ enabled: cloud === void 0 });
1319
+ const ownCloud = cloud === void 0 && !isDesktopWindow();
1320
+ const own = useAccountEnrolment({ enabled: ownCloud });
1313
1321
  const cloudTab = react.useMemo(
1314
- () => cloud === void 0 ? {
1322
+ () => ownCloud ? {
1315
1323
  onEnrol: () => {
1316
1324
  void own.goToWallet();
1317
1325
  },
@@ -1319,9 +1327,9 @@ function LoginModal({
1319
1327
  walletUrl: own.walletUrl,
1320
1328
  customWallet: own.customWallet
1321
1329
  } : cloud || null,
1322
- [cloud, own.goToWallet, own.note, own.walletUrl, own.customWallet]
1330
+ [cloud, ownCloud, own.goToWallet, own.note, own.walletUrl, own.customWallet]
1323
1331
  );
1324
- const initialTab = initialTabProp ?? (cloud === void 0 && own.returning ? "cloud" : "node");
1332
+ const initialTab = initialTabProp ?? (ownCloud && own.returning ? "cloud" : "node");
1325
1333
  const [tab, setTab] = react.useState(initialTab);
1326
1334
  react.useEffect(() => {
1327
1335
  if (isOpen) setTab(initialTab);
@@ -1625,9 +1633,10 @@ function ConnectButton({
1625
1633
  theme,
1626
1634
  logoOnly = false,
1627
1635
  label,
1628
- cloud = true,
1636
+ cloud: cloudProp,
1629
1637
  accountDefaults
1630
1638
  }) {
1639
+ const cloud = cloudProp ?? !isDesktopWindow();
1631
1640
  const { isAuthenticated, connectToNode, logout, nodeUrl, isOnline, isDelegated } = useMero();
1632
1641
  const enrolment = useAccountEnrolment({
1633
1642
  walletUrl: accountDefaults?.walletUrl,
@@ -1805,8 +1814,10 @@ function ConnectButtonAccount({
1805
1814
  className,
1806
1815
  style,
1807
1816
  theme,
1808
- defaults = {}
1817
+ defaults = {},
1818
+ cloud: cloudProp
1809
1819
  }) {
1820
+ const cloud = cloudProp ?? !isDesktopWindow();
1810
1821
  const { isAuthenticated, isOnline, nodeUrl, isDelegated, connectToNode, logout } = useMero();
1811
1822
  const [isDropdownOpen, setIsDropdownOpen] = react.useState(false);
1812
1823
  const [isNodeModalOpen, setIsNodeModalOpen] = react.useState(false);
@@ -1826,7 +1837,10 @@ function ConnectButtonAccount({
1826
1837
  document.addEventListener("mousedown", onOutside);
1827
1838
  return () => document.removeEventListener("mousedown", onOutside);
1828
1839
  }, []);
1829
- const { goToWallet, note, walletUrl } = useAccountEnrolment({ walletUrl: defaults.walletUrl });
1840
+ const { goToWallet, note, walletUrl } = useAccountEnrolment({
1841
+ walletUrl: defaults.walletUrl,
1842
+ enabled: cloud
1843
+ });
1830
1844
  if (isAuthenticated && !isOnline) {
1831
1845
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-connect-container", style: { ...themeVars, display: "inline-block" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
1832
1846
  "button",
@@ -1905,7 +1919,7 @@ function ConnectButtonAccount({
1905
1919
  ]
1906
1920
  }
1907
1921
  ),
1908
- /* @__PURE__ */ jsxRuntime.jsx(
1922
+ cloud && /* @__PURE__ */ jsxRuntime.jsx(
1909
1923
  "button",
1910
1924
  {
1911
1925
  className: ["mero-connect-button", className].filter(Boolean).join(" "),
@@ -1915,7 +1929,7 @@ function ConnectButtonAccount({
1915
1929
  }
1916
1930
  )
1917
1931
  ] }),
1918
- isAccountOpen && /* @__PURE__ */ jsxRuntime.jsxs(
1932
+ cloud && isAccountOpen && /* @__PURE__ */ jsxRuntime.jsxs(
1919
1933
  "div",
1920
1934
  {
1921
1935
  style: {
@@ -4022,7 +4036,9 @@ exports.getApplicationId = getApplicationId;
4022
4036
  exports.getContextId = getContextId;
4023
4037
  exports.getContextIdentity = getContextIdentity;
4024
4038
  exports.getNodeUrl = getNodeUrl;
4039
+ exports.getPermissionsForMode = getPermissionsForMode;
4025
4040
  exports.getTokenNodeUrl = getTokenNodeUrl;
4041
+ exports.isDesktopWindow = isDesktopWindow;
4026
4042
  exports.isFinalInvitationError = isFinalInvitationError;
4027
4043
  exports.isReturningFromWallet = isReturningFromWallet;
4028
4044
  exports.localStorageTokenStorage = localStorageTokenStorage;