@calimero-network/mero-react 10.1.2 → 10.2.1

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.d.cts CHANGED
@@ -459,13 +459,13 @@ interface LoginModalProps {
459
459
  * the modal is open. Nothing to wire; the modal must be inside a
460
460
  * `MeroProvider`.
461
461
  * - **`false`**: no Cloud tab and no tabs at all — the node dialog as it was.
462
- * - **omitted inside a Calimero Desktop window**: as `false` — the window is
463
- * already bound to the desktop's node. Pass a `cloud` object to override.
464
- * The modal reads no enrolment callback, leaving it to whichever component
465
- * does.
466
462
  * - **An object**: the caller's own enrolment, used verbatim; the modal reads
467
463
  * none itself. The values are `useAccountEnrolment`'s, as `ConnectButton`
468
464
  * passes them.
465
+ *
466
+ * Inside a Calimero Desktop window every form is as `false` — the window is
467
+ * already bound to the desktop's node, so there is no relay and no passkey to
468
+ * go through. `cloudOnDesktop` turns that off.
469
469
  */
470
470
  cloud?: false | {
471
471
  /** Start enrolment — normally `useAccountEnrolment().goToWallet`. */
@@ -477,6 +477,12 @@ interface LoginModalProps {
477
477
  /** Whether `walletUrl` is an override rather than the hosted wallet. */
478
478
  customWallet?: boolean;
479
479
  };
480
+ /**
481
+ * Show the Cloud tab inside a Calimero Desktop window too. Default false:
482
+ * the desktop logs in to its own node, so `cloud` — omitted or an object —
483
+ * is ignored there (see `isDesktopWindow`).
484
+ */
485
+ cloudOnDesktop?: boolean;
480
486
  /**
481
487
  * The tab selected when the modal opens. Ignored with `cloud={false}`.
482
488
  *
@@ -492,7 +498,7 @@ type LoginModalTab = 'node' | 'cloud';
492
498
  /**
493
499
  * LoginModal - Connection modal component
494
500
  */
495
- declare function LoginModal({ onConnect, onClose, isOpen, theme, localNodePorts, cloud, initialTab: initialTabProp, }: LoginModalProps): React.ReactPortal | null;
501
+ declare function LoginModal({ onConnect, onClose, isOpen, theme, localNodePorts, cloud, cloudOnDesktop, initialTab: initialTabProp, }: LoginModalProps): React.ReactPortal | null;
496
502
 
497
503
  interface AccountSignInPanelProps {
498
504
  /** Start enrolment — normally `useAccountEnrolment().goToWallet`. */
@@ -1062,7 +1068,9 @@ interface UseAccountEnrolmentOptions {
1062
1068
  /**
1063
1069
  * When false, the hook reads no callback and completes nothing, so a
1064
1070
  * component that has the account path switched off leaves the fragment for
1065
- * whichever component does handle it. Default true.
1071
+ * whichever component does handle it. Default true, except inside a
1072
+ * Calimero Desktop window (see `isDesktopWindow`), whose app is already
1073
+ * bound to the desktop's node and has no wallet callback to complete.
1066
1074
  */
1067
1075
  enabled?: boolean;
1068
1076
  }
package/dist/index.d.ts CHANGED
@@ -459,13 +459,13 @@ interface LoginModalProps {
459
459
  * the modal is open. Nothing to wire; the modal must be inside a
460
460
  * `MeroProvider`.
461
461
  * - **`false`**: no Cloud tab and no tabs at all — the node dialog as it was.
462
- * - **omitted inside a Calimero Desktop window**: as `false` — the window is
463
- * already bound to the desktop's node. Pass a `cloud` object to override.
464
- * The modal reads no enrolment callback, leaving it to whichever component
465
- * does.
466
462
  * - **An object**: the caller's own enrolment, used verbatim; the modal reads
467
463
  * none itself. The values are `useAccountEnrolment`'s, as `ConnectButton`
468
464
  * passes them.
465
+ *
466
+ * Inside a Calimero Desktop window every form is as `false` — the window is
467
+ * already bound to the desktop's node, so there is no relay and no passkey to
468
+ * go through. `cloudOnDesktop` turns that off.
469
469
  */
470
470
  cloud?: false | {
471
471
  /** Start enrolment — normally `useAccountEnrolment().goToWallet`. */
@@ -477,6 +477,12 @@ interface LoginModalProps {
477
477
  /** Whether `walletUrl` is an override rather than the hosted wallet. */
478
478
  customWallet?: boolean;
479
479
  };
480
+ /**
481
+ * Show the Cloud tab inside a Calimero Desktop window too. Default false:
482
+ * the desktop logs in to its own node, so `cloud` — omitted or an object —
483
+ * is ignored there (see `isDesktopWindow`).
484
+ */
485
+ cloudOnDesktop?: boolean;
480
486
  /**
481
487
  * The tab selected when the modal opens. Ignored with `cloud={false}`.
482
488
  *
@@ -492,7 +498,7 @@ type LoginModalTab = 'node' | 'cloud';
492
498
  /**
493
499
  * LoginModal - Connection modal component
494
500
  */
495
- declare function LoginModal({ onConnect, onClose, isOpen, theme, localNodePorts, cloud, initialTab: initialTabProp, }: LoginModalProps): React.ReactPortal | null;
501
+ declare function LoginModal({ onConnect, onClose, isOpen, theme, localNodePorts, cloud, cloudOnDesktop, initialTab: initialTabProp, }: LoginModalProps): React.ReactPortal | null;
496
502
 
497
503
  interface AccountSignInPanelProps {
498
504
  /** Start enrolment — normally `useAccountEnrolment().goToWallet`. */
@@ -1062,7 +1068,9 @@ interface UseAccountEnrolmentOptions {
1062
1068
  /**
1063
1069
  * When false, the hook reads no callback and completes nothing, so a
1064
1070
  * component that has the account path switched off leaves the fragment for
1065
- * whichever component does handle it. Default true.
1071
+ * whichever component does handle it. Default true, except inside a
1072
+ * Calimero Desktop window (see `isDesktopWindow`), whose app is already
1073
+ * bound to the desktop's node and has no wallet callback to complete.
1066
1074
  */
1067
1075
  enabled?: boolean;
1068
1076
  }
package/dist/index.js CHANGED
@@ -462,8 +462,9 @@ function MeroProvider({
462
462
  let active = true;
463
463
  const stop = new AbortController();
464
464
  (async () => {
465
- if (!client || !relayUrl) return;
466
- if (awaitingKey) {
465
+ const hasRelay = Boolean(client && relayUrl);
466
+ if (!hasRelay && !packageName) return;
467
+ if (awaitingKey && relayUrl) {
467
468
  const nodeKey = await learnRelayNodeKey(relayUrl, { signal: stop.signal });
468
469
  if (!active) return;
469
470
  setMero(nodeKey ? buildDelegatedClient(routed, contextId) ?? client : client);
@@ -484,6 +485,7 @@ function MeroProvider({
484
485
  if (!active) return;
485
486
  }
486
487
  }
488
+ if (!hasRelay) return;
487
489
  try {
488
490
  const contexts = await listDelegatedContexts(delegated);
489
491
  if (!active) return;
@@ -949,7 +951,7 @@ function isReturningFromWallet(location = typeof window === "undefined" ? void 0
949
951
  }
950
952
  function useAccountEnrolment({
951
953
  walletUrl: walletOverride,
952
- enabled = true
954
+ enabled = !isDesktopWindow()
953
955
  } = {}) {
954
956
  const { connectWithAccount, cloudBaseUrl } = useMero();
955
957
  const [note, setNote] = useState(null);
@@ -1327,9 +1329,11 @@ function LoginModal({
1327
1329
  theme,
1328
1330
  localNodePorts = DEFAULT_LOCAL_NODE_PORTS,
1329
1331
  cloud,
1332
+ cloudOnDesktop = false,
1330
1333
  initialTab: initialTabProp
1331
1334
  }) {
1332
- const ownCloud = cloud === void 0 && !isDesktopWindow();
1335
+ const cloudAllowed = cloudOnDesktop || !isDesktopWindow();
1336
+ const ownCloud = cloud === void 0 && cloudAllowed;
1333
1337
  const own = useAccountEnrolment({ enabled: ownCloud });
1334
1338
  const cloudTab = useMemo(
1335
1339
  () => ownCloud ? {
@@ -1339,8 +1343,8 @@ function LoginModal({
1339
1343
  note: own.note,
1340
1344
  walletUrl: own.walletUrl,
1341
1345
  customWallet: own.customWallet
1342
- } : cloud || null,
1343
- [cloud, ownCloud, own.goToWallet, own.note, own.walletUrl, own.customWallet]
1346
+ } : cloudAllowed && cloud || null,
1347
+ [cloud, cloudAllowed, ownCloud, own.goToWallet, own.note, own.walletUrl, own.customWallet]
1344
1348
  );
1345
1349
  const initialTab = initialTabProp ?? (ownCloud && own.returning ? "cloud" : "node");
1346
1350
  const [tab, setTab] = useState(initialTab);
@@ -1874,6 +1878,7 @@ function ConnectButton({
1874
1878
  walletUrl: enrolment.walletUrl,
1875
1879
  customWallet: enrolment.customWallet
1876
1880
  } : false,
1881
+ cloudOnDesktop: cloud,
1877
1882
  initialTab: cloud && enrolment.returning ? "cloud" : "node"
1878
1883
  }
1879
1884
  )