@calimero-network/mero-react 8.0.0 → 9.1.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.d.cts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import * as _calimero_network_mero_js from '@calimero-network/mero-js';
5
- import { MeroJs, TokenStore, SetMetadataRequest, SseEventData, GroupMembershipEventData, GroupMigrationEventData, Codec, AddGroupMembersRequest, CreateContextRequest, CreateGroupInNamespaceRequest, CreateNamespaceRequest, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, DeleteGroupRequest, DeleteNamespaceRequest, DetachContextFromGroupRequest, GroupUpgradeStatusResponseData, GroupContextEntry, GroupInfo, CreateGroupInvitationRequest, MetadataRecord, JoinGroupRequest, JoinNamespaceRequest, MigrationStatus, MigrationStatusRollup, MemberMigrationStatusEntry, MigrateMyEntriesSummary, Namespace, SubgroupEntry, NamespaceIdentity, NodeIdentity, RemoveGroupMembersRequest, ReparentGroupRequest, ResyncContextRequest, RetryGroupUpgradeRequest, SetDefaultCapabilitiesRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, SyncGroupRequest, UpdateMemberRoleRequest, UpgradeGroupRequest, TokenData } from '@calimero-network/mero-js';
5
+ import { MeroJs, TokenStore, SetMetadataRequest, SseEventData, GroupMembershipEventData, GroupMigrationEventData, Codec, AddGroupMembersRequest, GetBlobInfoResponseData, CreateContextRequest, CreateGroupInNamespaceRequest, CreateNamespaceRequest, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, GroupUpgradeStatusResponseData, GroupContextEntry, GroupInfo, CreateGroupInvitationRequest, MetadataRecord, JoinGroupRequest, JoinNamespaceRequest, MigrationStatus, MigrationStatusRollup, MemberMigrationStatusEntry, MigrateMyEntriesSummary, Namespace, SubgroupEntry, NamespaceIdentity, NodeIdentity, RemoveGroupMembersRequest, ReparentGroupRequest, ResyncContextRequest, SetDefaultCapabilitiesRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, UpdateMemberRoleRequest, UpgradeGroupRequest, UploadBlobRequest, TokenData } from '@calimero-network/mero-js';
6
6
  export * from '@calimero-network/mero-js';
7
7
  export { CAPABILITIES, Codec, DEFAULT_LOCAL_NODE_PORTS, DiscoverLocalNodesOptions, EphemeralClient, EphemeralEntry, MetadataRecord, discoverLocalNodes, hasCap, localNodeUrl, nodeEndpoint, probeNodeHealth, withCap, withoutCap } from '@calimero-network/mero-js';
8
8
 
@@ -493,12 +493,12 @@ declare function useGroupInfo(groupId?: string | null): {
493
493
  refetch: () => Promise<void>;
494
494
  };
495
495
  declare function useDeleteGroup(): {
496
- deleteGroup: (groupId: string, request?: DeleteGroupRequest) => Promise<_calimero_network_mero_js.DeleteGroupResponseData | null>;
496
+ deleteGroup: (groupId: string) => Promise<_calimero_network_mero_js.DeleteGroupResponseData | null>;
497
497
  loading: boolean;
498
498
  error: Error | null;
499
499
  };
500
500
  declare function useSyncGroup(): {
501
- syncGroup: (groupId: string, request?: SyncGroupRequest) => Promise<_calimero_network_mero_js.SyncGroupResponseData | null>;
501
+ syncGroup: (groupId: string) => Promise<_calimero_network_mero_js.SyncGroupResponseData | null>;
502
502
  loading: boolean;
503
503
  error: Error | null;
504
504
  };
@@ -571,7 +571,7 @@ declare function useCreateNamespace(): {
571
571
  error: Error | null;
572
572
  };
573
573
  declare function useDeleteNamespace(): {
574
- deleteNamespace: (namespaceId: string, request?: DeleteNamespaceRequest) => Promise<_calimero_network_mero_js.DeleteNamespaceResponseData | null>;
574
+ deleteNamespace: (namespaceId: string) => Promise<_calimero_network_mero_js.DeleteNamespaceResponseData | null>;
575
575
  loading: boolean;
576
576
  error: Error | null;
577
577
  };
@@ -677,7 +677,7 @@ declare function useUpgradeGroup(): {
677
677
  * itself change what any group runs; pair it with a subsequent upgrade.
678
678
  */
679
679
  declare function useInstallFromRegistry(): {
680
- installFromRegistry: (registryUrl: string, packageName: string, version: string) => Promise<_calimero_network_mero_js.InstallApplicationResponseData | null>;
680
+ installFromRegistry: (packageName: string, version: string) => Promise<_calimero_network_mero_js.InstallApplicationResponseData | null>;
681
681
  loading: boolean;
682
682
  error: Error | null;
683
683
  };
@@ -698,7 +698,7 @@ declare function useGroupUpgradeStatus(groupId?: string | null): {
698
698
  refetch: () => Promise<void>;
699
699
  };
700
700
  declare function useRetryGroupUpgrade(): {
701
- retryGroupUpgrade: (groupId: string, request?: RetryGroupUpgradeRequest) => Promise<_calimero_network_mero_js.UpgradeGroupResponseData | null>;
701
+ retryGroupUpgrade: (groupId: string) => Promise<_calimero_network_mero_js.UpgradeGroupResponseData | null>;
702
702
  loading: boolean;
703
703
  error: Error | null;
704
704
  };
@@ -715,7 +715,7 @@ declare function useSubgroups(groupId?: string | null): {
715
715
  refetch: () => Promise<void>;
716
716
  };
717
717
  declare function useDetachContextFromGroup(): {
718
- detachContextFromGroup: (groupId: string, contextId: string, request?: DetachContextFromGroupRequest) => Promise<void | null>;
718
+ detachContextFromGroup: (groupId: string, contextId: string) => Promise<void | null>;
719
719
  loading: boolean;
720
720
  error: Error | null;
721
721
  };
@@ -841,6 +841,106 @@ declare function useMyAuthoredMigration(contextId?: string | null): {
841
841
  error: Error | null;
842
842
  refresh: () => Promise<void>;
843
843
  };
844
+ /**
845
+ * Options for the blob READ hooks.
846
+ *
847
+ * `contextId` is what picks the mode, and the two modes have wildly different
848
+ * costs:
849
+ *
850
+ * - **omitted** — local-only read. The node answers from its own blob store
851
+ * and returns immediately, or 404s.
852
+ * - **supplied** — network discovery. The node probes that context's peers
853
+ * (availability nodes first) for a holder. Core bounds the search by a ~30s
854
+ * deadline, and for {@link useBlobUrl} the byte transfer is on top of that.
855
+ *
856
+ * So `loading` is load-bearing UI state on these hooks, not decoration: a
857
+ * discovery read can plausibly spin for half a minute before it resolves
858
+ * either way. Render a spinner (or a cancel affordance) accordingly.
859
+ */
860
+ interface BlobHookOptions {
861
+ /** Context whose peers to probe. Omit for a local-only read. */
862
+ contextId?: string;
863
+ }
864
+ /** Options for {@link useBlobUrl}. */
865
+ interface UseBlobUrlOptions extends BlobHookOptions {
866
+ /**
867
+ * MIME type stamped on the `Blob` the object URL points at. The blob read
868
+ * itself carries no type, and a peer-sourced answer has no `mimeType` at
869
+ * all, so pass it when the consumer needs one (`<img>` sniffs; a download
870
+ * `<a>` and an `<iframe>` do not).
871
+ */
872
+ type?: string;
873
+ }
874
+ /**
875
+ * A blob's presence and size, WITHOUT downloading it — the cheap half of the
876
+ * blob surface, and the one to ask before pulling something large.
877
+ *
878
+ * `blobId` follows the same `string | null` convention as the other read
879
+ * hooks: null/undefined means "no read", not "read nothing" — nothing is
880
+ * fetched and `info` stays null.
881
+ *
882
+ * `hash` and `mimeType` on the result are genuinely optional: a peer probe
883
+ * answers with presence and size only, so a discovery-sourced hit carries
884
+ * neither. `info.source` (`'local' | 'peer'`, undefined on nodes that predate
885
+ * the header) tells the two apart — do not treat a missing `mimeType` as a
886
+ * malformed response.
887
+ *
888
+ * `notFound` distinguishes the legitimate "no holder" outcome (the node
889
+ * answered 404) from a transport failure. `error` is set in BOTH cases — this
890
+ * hook does not swallow the 404, it only labels it.
891
+ *
892
+ * Latency: immediate without `contextId`, up to core's ~30s discovery deadline
893
+ * with one. See {@link BlobHookOptions}.
894
+ */
895
+ declare function useBlobInfo(blobId?: string | null, options?: BlobHookOptions): {
896
+ info: GetBlobInfoResponseData | null;
897
+ notFound: boolean;
898
+ loading: boolean;
899
+ error: Error | null;
900
+ refetch: () => Promise<void>;
901
+ };
902
+ /**
903
+ * A blob's bytes as an object URL, ready for `<img src>`, an `<a href>`
904
+ * download, or an `<iframe>`.
905
+ *
906
+ * Lifecycle is handled here so the consumer never has to revoke: the URL is
907
+ * revoked on unmount, and whenever `blobId`/`contextId`/`type` change. `url`
908
+ * goes back to null synchronously on such a change, so a revoked URL is never
909
+ * handed out as the current one — render off `url` and it is always live.
910
+ *
911
+ * A response for a superseded `blobId` is dropped before an object URL is even
912
+ * created, so an out-of-order arrival can neither overwrite the newer result
913
+ * nor leak.
914
+ *
915
+ * Latency: this is the expensive hook. Without `contextId` it is a local read;
916
+ * with one it is discovery (core's ~30s deadline) PLUS the transfer of the
917
+ * bytes. Prefer {@link useBlobInfo} to decide whether the download is worth
918
+ * starting, and always render `loading`.
919
+ *
920
+ * `notFound` marks the node's 404 ("no peer holds this") apart from a
921
+ * transport failure; `error` is set for both.
922
+ */
923
+ declare function useBlobUrl(blobId?: string | null, options?: UseBlobUrlOptions): {
924
+ url: string | null;
925
+ notFound: boolean;
926
+ loading: boolean;
927
+ error: Error | null;
928
+ refetch: () => Promise<void>;
929
+ };
930
+ /**
931
+ * Upload bytes to the node's blob store. Mutation-shaped, like the other
932
+ * write hooks: `uploadBlob` resolves to `{ blobId, size }`, or null when the
933
+ * client is absent or the call failed (read `error` for which).
934
+ *
935
+ * Pass `contextId` to announce the blob to that context, which is what lets
936
+ * the context's other members later discover it with {@link useBlobUrl} /
937
+ * {@link useBlobInfo}. Without it the blob is only readable on this node.
938
+ */
939
+ declare function useUploadBlob(): {
940
+ uploadBlob: (request: UploadBlobRequest) => Promise<_calimero_network_mero_js.BlobInfo | null>;
941
+ loading: boolean;
942
+ error: Error | null;
943
+ };
844
944
 
845
945
  /**
846
946
  * Storage utilities for mero-react
@@ -918,4 +1018,4 @@ declare function clearContextIdentity(): void;
918
1018
  */
919
1019
  declare function clearAllStorage(): void;
920
1020
 
921
- export { type AppContext, AppMode, type ApplicationContextRecord, CalimeroLogo, type CalimeroLogoProps, ConnectButton, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type ExecutionResult, LoginModal, type LoginModalProps, MERO_CSS_VARS, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseEphemeralOptions, type UseEphemeralResult, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup };
1021
+ export { type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, CalimeroLogo, type CalimeroLogoProps, ConnectButton, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type ExecutionResult, LoginModal, type LoginModalProps, MERO_CSS_VARS, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseBlobUrlOptions, type UseEphemeralOptions, type UseEphemeralResult, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import * as _calimero_network_mero_js from '@calimero-network/mero-js';
5
- import { MeroJs, TokenStore, SetMetadataRequest, SseEventData, GroupMembershipEventData, GroupMigrationEventData, Codec, AddGroupMembersRequest, CreateContextRequest, CreateGroupInNamespaceRequest, CreateNamespaceRequest, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, DeleteGroupRequest, DeleteNamespaceRequest, DetachContextFromGroupRequest, GroupUpgradeStatusResponseData, GroupContextEntry, GroupInfo, CreateGroupInvitationRequest, MetadataRecord, JoinGroupRequest, JoinNamespaceRequest, MigrationStatus, MigrationStatusRollup, MemberMigrationStatusEntry, MigrateMyEntriesSummary, Namespace, SubgroupEntry, NamespaceIdentity, NodeIdentity, RemoveGroupMembersRequest, ReparentGroupRequest, ResyncContextRequest, RetryGroupUpgradeRequest, SetDefaultCapabilitiesRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, SyncGroupRequest, UpdateMemberRoleRequest, UpgradeGroupRequest, TokenData } from '@calimero-network/mero-js';
5
+ import { MeroJs, TokenStore, SetMetadataRequest, SseEventData, GroupMembershipEventData, GroupMigrationEventData, Codec, AddGroupMembersRequest, GetBlobInfoResponseData, CreateContextRequest, CreateGroupInNamespaceRequest, CreateNamespaceRequest, CreateNamespaceInvitationRequest, CreateNamespaceInvitationResponseData, CreateRecursiveInvitationResponseData, GroupUpgradeStatusResponseData, GroupContextEntry, GroupInfo, CreateGroupInvitationRequest, MetadataRecord, JoinGroupRequest, JoinNamespaceRequest, MigrationStatus, MigrationStatusRollup, MemberMigrationStatusEntry, MigrateMyEntriesSummary, Namespace, SubgroupEntry, NamespaceIdentity, NodeIdentity, RemoveGroupMembersRequest, ReparentGroupRequest, ResyncContextRequest, SetDefaultCapabilitiesRequest, SetSubgroupVisibilityRequest, SetTeeAdmissionPolicyRequest, UpdateMemberRoleRequest, UpgradeGroupRequest, UploadBlobRequest, TokenData } from '@calimero-network/mero-js';
6
6
  export * from '@calimero-network/mero-js';
7
7
  export { CAPABILITIES, Codec, DEFAULT_LOCAL_NODE_PORTS, DiscoverLocalNodesOptions, EphemeralClient, EphemeralEntry, MetadataRecord, discoverLocalNodes, hasCap, localNodeUrl, nodeEndpoint, probeNodeHealth, withCap, withoutCap } from '@calimero-network/mero-js';
8
8
 
@@ -493,12 +493,12 @@ declare function useGroupInfo(groupId?: string | null): {
493
493
  refetch: () => Promise<void>;
494
494
  };
495
495
  declare function useDeleteGroup(): {
496
- deleteGroup: (groupId: string, request?: DeleteGroupRequest) => Promise<_calimero_network_mero_js.DeleteGroupResponseData | null>;
496
+ deleteGroup: (groupId: string) => Promise<_calimero_network_mero_js.DeleteGroupResponseData | null>;
497
497
  loading: boolean;
498
498
  error: Error | null;
499
499
  };
500
500
  declare function useSyncGroup(): {
501
- syncGroup: (groupId: string, request?: SyncGroupRequest) => Promise<_calimero_network_mero_js.SyncGroupResponseData | null>;
501
+ syncGroup: (groupId: string) => Promise<_calimero_network_mero_js.SyncGroupResponseData | null>;
502
502
  loading: boolean;
503
503
  error: Error | null;
504
504
  };
@@ -571,7 +571,7 @@ declare function useCreateNamespace(): {
571
571
  error: Error | null;
572
572
  };
573
573
  declare function useDeleteNamespace(): {
574
- deleteNamespace: (namespaceId: string, request?: DeleteNamespaceRequest) => Promise<_calimero_network_mero_js.DeleteNamespaceResponseData | null>;
574
+ deleteNamespace: (namespaceId: string) => Promise<_calimero_network_mero_js.DeleteNamespaceResponseData | null>;
575
575
  loading: boolean;
576
576
  error: Error | null;
577
577
  };
@@ -677,7 +677,7 @@ declare function useUpgradeGroup(): {
677
677
  * itself change what any group runs; pair it with a subsequent upgrade.
678
678
  */
679
679
  declare function useInstallFromRegistry(): {
680
- installFromRegistry: (registryUrl: string, packageName: string, version: string) => Promise<_calimero_network_mero_js.InstallApplicationResponseData | null>;
680
+ installFromRegistry: (packageName: string, version: string) => Promise<_calimero_network_mero_js.InstallApplicationResponseData | null>;
681
681
  loading: boolean;
682
682
  error: Error | null;
683
683
  };
@@ -698,7 +698,7 @@ declare function useGroupUpgradeStatus(groupId?: string | null): {
698
698
  refetch: () => Promise<void>;
699
699
  };
700
700
  declare function useRetryGroupUpgrade(): {
701
- retryGroupUpgrade: (groupId: string, request?: RetryGroupUpgradeRequest) => Promise<_calimero_network_mero_js.UpgradeGroupResponseData | null>;
701
+ retryGroupUpgrade: (groupId: string) => Promise<_calimero_network_mero_js.UpgradeGroupResponseData | null>;
702
702
  loading: boolean;
703
703
  error: Error | null;
704
704
  };
@@ -715,7 +715,7 @@ declare function useSubgroups(groupId?: string | null): {
715
715
  refetch: () => Promise<void>;
716
716
  };
717
717
  declare function useDetachContextFromGroup(): {
718
- detachContextFromGroup: (groupId: string, contextId: string, request?: DetachContextFromGroupRequest) => Promise<void | null>;
718
+ detachContextFromGroup: (groupId: string, contextId: string) => Promise<void | null>;
719
719
  loading: boolean;
720
720
  error: Error | null;
721
721
  };
@@ -841,6 +841,106 @@ declare function useMyAuthoredMigration(contextId?: string | null): {
841
841
  error: Error | null;
842
842
  refresh: () => Promise<void>;
843
843
  };
844
+ /**
845
+ * Options for the blob READ hooks.
846
+ *
847
+ * `contextId` is what picks the mode, and the two modes have wildly different
848
+ * costs:
849
+ *
850
+ * - **omitted** — local-only read. The node answers from its own blob store
851
+ * and returns immediately, or 404s.
852
+ * - **supplied** — network discovery. The node probes that context's peers
853
+ * (availability nodes first) for a holder. Core bounds the search by a ~30s
854
+ * deadline, and for {@link useBlobUrl} the byte transfer is on top of that.
855
+ *
856
+ * So `loading` is load-bearing UI state on these hooks, not decoration: a
857
+ * discovery read can plausibly spin for half a minute before it resolves
858
+ * either way. Render a spinner (or a cancel affordance) accordingly.
859
+ */
860
+ interface BlobHookOptions {
861
+ /** Context whose peers to probe. Omit for a local-only read. */
862
+ contextId?: string;
863
+ }
864
+ /** Options for {@link useBlobUrl}. */
865
+ interface UseBlobUrlOptions extends BlobHookOptions {
866
+ /**
867
+ * MIME type stamped on the `Blob` the object URL points at. The blob read
868
+ * itself carries no type, and a peer-sourced answer has no `mimeType` at
869
+ * all, so pass it when the consumer needs one (`<img>` sniffs; a download
870
+ * `<a>` and an `<iframe>` do not).
871
+ */
872
+ type?: string;
873
+ }
874
+ /**
875
+ * A blob's presence and size, WITHOUT downloading it — the cheap half of the
876
+ * blob surface, and the one to ask before pulling something large.
877
+ *
878
+ * `blobId` follows the same `string | null` convention as the other read
879
+ * hooks: null/undefined means "no read", not "read nothing" — nothing is
880
+ * fetched and `info` stays null.
881
+ *
882
+ * `hash` and `mimeType` on the result are genuinely optional: a peer probe
883
+ * answers with presence and size only, so a discovery-sourced hit carries
884
+ * neither. `info.source` (`'local' | 'peer'`, undefined on nodes that predate
885
+ * the header) tells the two apart — do not treat a missing `mimeType` as a
886
+ * malformed response.
887
+ *
888
+ * `notFound` distinguishes the legitimate "no holder" outcome (the node
889
+ * answered 404) from a transport failure. `error` is set in BOTH cases — this
890
+ * hook does not swallow the 404, it only labels it.
891
+ *
892
+ * Latency: immediate without `contextId`, up to core's ~30s discovery deadline
893
+ * with one. See {@link BlobHookOptions}.
894
+ */
895
+ declare function useBlobInfo(blobId?: string | null, options?: BlobHookOptions): {
896
+ info: GetBlobInfoResponseData | null;
897
+ notFound: boolean;
898
+ loading: boolean;
899
+ error: Error | null;
900
+ refetch: () => Promise<void>;
901
+ };
902
+ /**
903
+ * A blob's bytes as an object URL, ready for `<img src>`, an `<a href>`
904
+ * download, or an `<iframe>`.
905
+ *
906
+ * Lifecycle is handled here so the consumer never has to revoke: the URL is
907
+ * revoked on unmount, and whenever `blobId`/`contextId`/`type` change. `url`
908
+ * goes back to null synchronously on such a change, so a revoked URL is never
909
+ * handed out as the current one — render off `url` and it is always live.
910
+ *
911
+ * A response for a superseded `blobId` is dropped before an object URL is even
912
+ * created, so an out-of-order arrival can neither overwrite the newer result
913
+ * nor leak.
914
+ *
915
+ * Latency: this is the expensive hook. Without `contextId` it is a local read;
916
+ * with one it is discovery (core's ~30s deadline) PLUS the transfer of the
917
+ * bytes. Prefer {@link useBlobInfo} to decide whether the download is worth
918
+ * starting, and always render `loading`.
919
+ *
920
+ * `notFound` marks the node's 404 ("no peer holds this") apart from a
921
+ * transport failure; `error` is set for both.
922
+ */
923
+ declare function useBlobUrl(blobId?: string | null, options?: UseBlobUrlOptions): {
924
+ url: string | null;
925
+ notFound: boolean;
926
+ loading: boolean;
927
+ error: Error | null;
928
+ refetch: () => Promise<void>;
929
+ };
930
+ /**
931
+ * Upload bytes to the node's blob store. Mutation-shaped, like the other
932
+ * write hooks: `uploadBlob` resolves to `{ blobId, size }`, or null when the
933
+ * client is absent or the call failed (read `error` for which).
934
+ *
935
+ * Pass `contextId` to announce the blob to that context, which is what lets
936
+ * the context's other members later discover it with {@link useBlobUrl} /
937
+ * {@link useBlobInfo}. Without it the blob is only readable on this node.
938
+ */
939
+ declare function useUploadBlob(): {
940
+ uploadBlob: (request: UploadBlobRequest) => Promise<_calimero_network_mero_js.BlobInfo | null>;
941
+ loading: boolean;
942
+ error: Error | null;
943
+ };
844
944
 
845
945
  /**
846
946
  * Storage utilities for mero-react
@@ -918,4 +1018,4 @@ declare function clearContextIdentity(): void;
918
1018
  */
919
1019
  declare function clearAllStorage(): void;
920
1020
 
921
- export { type AppContext, AppMode, type ApplicationContextRecord, CalimeroLogo, type CalimeroLogoProps, ConnectButton, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type ExecutionResult, LoginModal, type LoginModalProps, MERO_CSS_VARS, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseEphemeralOptions, type UseEphemeralResult, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup };
1021
+ export { type AppContext, AppMode, type ApplicationContextRecord, type BlobHookOptions, CalimeroLogo, type CalimeroLogoProps, ConnectButton, type ConnectButtonProps, ConnectionType, type ContextDiscoveryOptions, type ContextDiscoveryState, type CustomConnectionConfig, DEFAULT_MIGRATION_POLL_INTERVAL_MS, type ExecutionResult, LoginModal, type LoginModalProps, MERO_CSS_VARS, MeroContext, type MeroContextValue, MeroProvider, type MeroProviderConfig, type MeroProviderProps, type MeroTheme, MigrationAdminPanel, type MigrationAdminPanelProps, MigrationPendingBanner, type MigrationPendingBannerProps, type ResolvedMeroTheme, type SetMetadataInput, type SubscriptionEventData, type SubscriptionInput, type UseBlobUrlOptions, type UseEphemeralOptions, type UseEphemeralResult, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
package/dist/index.js CHANGED
@@ -1949,9 +1949,9 @@ function useDeleteGroup() {
1949
1949
  const { mero } = useMero();
1950
1950
  const { loading, error, run } = useAsyncMutation();
1951
1951
  const deleteGroup = useCallback(
1952
- async (groupId, request) => {
1952
+ async (groupId) => {
1953
1953
  if (!mero) return null;
1954
- return run(() => mero.admin.deleteGroup(groupId, request));
1954
+ return run(() => mero.admin.deleteGroup(groupId));
1955
1955
  },
1956
1956
  [mero, run]
1957
1957
  );
@@ -1961,9 +1961,9 @@ function useSyncGroup() {
1961
1961
  const { mero } = useMero();
1962
1962
  const { loading, error, run } = useAsyncMutation();
1963
1963
  const syncGroup = useCallback(
1964
- async (groupId, request) => {
1964
+ async (groupId) => {
1965
1965
  if (!mero) return null;
1966
- return run(() => mero.admin.syncGroup(groupId, request));
1966
+ return run(() => mero.admin.syncGroup(groupId));
1967
1967
  },
1968
1968
  [mero, run]
1969
1969
  );
@@ -2054,9 +2054,9 @@ function useDeleteNamespace() {
2054
2054
  const { mero } = useMero();
2055
2055
  const { loading, error, run } = useAsyncMutation();
2056
2056
  const deleteNamespace = useCallback(
2057
- async (namespaceId, request) => {
2057
+ async (namespaceId) => {
2058
2058
  if (!mero) return null;
2059
- return run(() => mero.admin.deleteNamespace(namespaceId, request));
2059
+ return run(() => mero.admin.deleteNamespace(namespaceId));
2060
2060
  },
2061
2061
  [mero, run]
2062
2062
  );
@@ -2277,9 +2277,9 @@ function useInstallFromRegistry() {
2277
2277
  const { mero } = useMero();
2278
2278
  const { loading, error, run } = useAsyncMutation();
2279
2279
  const installFromRegistry = useCallback(
2280
- async (registryUrl, packageName, version) => {
2280
+ async (packageName, version) => {
2281
2281
  if (!mero) return null;
2282
- return run(() => mero.admin.installFromRegistry(registryUrl, packageName, version));
2282
+ return run(() => mero.admin.installApplication({ package: packageName, version }));
2283
2283
  },
2284
2284
  [mero, run]
2285
2285
  );
@@ -2348,9 +2348,9 @@ function useRetryGroupUpgrade() {
2348
2348
  const { mero } = useMero();
2349
2349
  const { loading, error, run } = useAsyncMutation();
2350
2350
  const retryGroupUpgrade = useCallback(
2351
- async (groupId, request) => {
2351
+ async (groupId) => {
2352
2352
  if (!mero) return null;
2353
- return run(() => mero.admin.retryGroupUpgrade(groupId, request));
2353
+ return run(() => mero.admin.retryGroupUpgrade(groupId));
2354
2354
  },
2355
2355
  [mero, run]
2356
2356
  );
@@ -2381,9 +2381,9 @@ function useDetachContextFromGroup() {
2381
2381
  const { mero } = useMero();
2382
2382
  const { loading, error, run } = useAsyncMutation();
2383
2383
  const detachContextFromGroup = useCallback(
2384
- async (groupId, contextId, request) => {
2384
+ async (groupId, contextId) => {
2385
2385
  if (!mero) return null;
2386
- return run(() => mero.admin.detachContextFromGroup(groupId, contextId, request));
2386
+ return run(() => mero.admin.detachContextFromGroup(groupId, contextId));
2387
2387
  },
2388
2388
  [mero, run]
2389
2389
  );
@@ -2730,6 +2730,80 @@ function useMyAuthoredMigration(contextId) {
2730
2730
  refresh
2731
2731
  };
2732
2732
  }
2733
+ function isBlobNotFound(error) {
2734
+ return !!error && error.status === 404;
2735
+ }
2736
+ function useBlobInfo(blobId, options) {
2737
+ const { mero } = useMero();
2738
+ const contextId = options?.contextId;
2739
+ const { data, loading, error, refetch } = useAsyncResource(
2740
+ mero && blobId ? () => mero.admin.getBlobInfo(blobId, contextId ? { contextId } : void 0) : null,
2741
+ null,
2742
+ [mero, blobId, contextId]
2743
+ );
2744
+ return { info: data, notFound: isBlobNotFound(error), loading, error, refetch };
2745
+ }
2746
+ function useBlobUrl(blobId, options) {
2747
+ const { mero } = useMero();
2748
+ const contextId = options?.contextId;
2749
+ const type = options?.type;
2750
+ const mountedRef = useMountedRef();
2751
+ const [url, setUrl] = useState(null);
2752
+ const [loading, setLoading] = useState(false);
2753
+ const [error, setError] = useState(null);
2754
+ const reqRef = useRef(0);
2755
+ const urlRef = useRef(null);
2756
+ const revoke = useCallback(() => {
2757
+ if (urlRef.current) {
2758
+ URL.revokeObjectURL(urlRef.current);
2759
+ urlRef.current = null;
2760
+ }
2761
+ }, []);
2762
+ const refetch = useCallback(async () => {
2763
+ const seq = ++reqRef.current;
2764
+ if (!mero || !blobId) return;
2765
+ if (mountedRef.current) {
2766
+ setLoading(true);
2767
+ setError(null);
2768
+ }
2769
+ try {
2770
+ const bytes = await mero.admin.getBlob(blobId, contextId ? { contextId } : void 0);
2771
+ if (!mountedRef.current || seq !== reqRef.current) return;
2772
+ revoke();
2773
+ const objectUrl = URL.createObjectURL(new Blob([bytes], type ? { type } : void 0));
2774
+ urlRef.current = objectUrl;
2775
+ setUrl(objectUrl);
2776
+ } catch (err) {
2777
+ if (mountedRef.current && seq === reqRef.current) setError(toError(err));
2778
+ } finally {
2779
+ if (mountedRef.current && seq === reqRef.current) setLoading(false);
2780
+ }
2781
+ }, [mero, blobId, contextId, type, revoke, mountedRef]);
2782
+ useEffect(() => {
2783
+ reqRef.current += 1;
2784
+ revoke();
2785
+ setUrl(null);
2786
+ setError(null);
2787
+ setLoading(false);
2788
+ }, [mero, blobId, contextId, type, revoke]);
2789
+ useEffect(() => {
2790
+ void refetch();
2791
+ }, [refetch]);
2792
+ useEffect(() => revoke, [revoke]);
2793
+ return { url, notFound: isBlobNotFound(error), loading, error, refetch };
2794
+ }
2795
+ function useUploadBlob() {
2796
+ const { mero } = useMero();
2797
+ const { loading, error, run } = useAsyncMutation();
2798
+ const uploadBlob = useCallback(
2799
+ async (request) => {
2800
+ if (!mero) return null;
2801
+ return run(() => mero.admin.uploadBlob(request));
2802
+ },
2803
+ [mero, run]
2804
+ );
2805
+ return { uploadBlob, loading, error };
2806
+ }
2733
2807
  function MigrationPendingBanner({
2734
2808
  contextId,
2735
2809
  className,
@@ -2824,6 +2898,6 @@ function MigrationAdminPanel({ namespaceId, pollIntervalMs, className }) {
2824
2898
  ] });
2825
2899
  }
2826
2900
 
2827
- export { AppMode, CalimeroLogo, ConnectButton, ConnectionType, DEFAULT_MIGRATION_POLL_INTERVAL_MS, LoginModal, MERO_CSS_VARS, MeroContext, MeroProvider, MigrationAdminPanel, MigrationPendingBanner, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup };
2901
+ export { AppMode, CalimeroLogo, ConnectButton, ConnectionType, DEFAULT_MIGRATION_POLL_INTERVAL_MS, LoginModal, MERO_CSS_VARS, MeroContext, MeroProvider, MigrationAdminPanel, MigrationPendingBanner, clearAllStorage, clearApplicationId, clearContextId, clearContextIdentity, clearNodeUrl, clearTokenNodeUrl, cssVar, defaultMeroTheme, getApplicationId, getContextId, getContextIdentity, getNodeUrl, getTokenNodeUrl, localStorageTokenStorage, resolveMeroTheme, setApplicationId, setContextId, setContextIdentity, setNodeUrl, setTokenNodeUrl, themeToCssVars, useAddGroupMembers, useAppVersion, useApplicationContexts, useBlobInfo, useBlobUrl, useContextDiscovery, useContextGroup, useContexts, useCreateContext, useCreateGroupInNamespace, useCreateNamespace, useCreateNamespaceInvitation, useDefaultCapabilities, useDeleteContext, useDeleteGroup, useDeleteNamespace, useDetachContextFromGroup, useEphemeral, useExecute, useGroupAppVersion, useGroupCapabilities, useGroupContexts, useGroupInfo, useGroupInvitations, useGroupMembers, useGroupMetadata, useGroupUpgradeStatus, useInstallFromRegistry, useJoinContext, useJoinGroup, useJoinNamespace, useJoinSubgroupInheritance, useLatestVersion, useMemberMetadata, useMero, useMigrationEvents, useMigrationStatus, useMyAuthoredMigration, useNamespace, useNamespaceGroups, useNamespaceIdentity, useNamespaces, useNamespacesForApplication, useNodeIdentity, useRemoveGroupMembers, useReparentGroup, useResyncContext, useRetryGroupUpgrade, useSetContextMetadata, useSetDefaultCapabilities, useSetGroupMetadata, useSetMemberMetadata, useSetSubgroupVisibility, useSetTeeAdmissionPolicy, useSubgroupVisibility, useSubgroups, useSubscription, useSyncGroup, useUpdateMemberRole, useUpgradeGroup, useUploadBlob };
2828
2902
  //# sourceMappingURL=index.js.map
2829
2903
  //# sourceMappingURL=index.js.map