@calimero-network/mero-react 9.14.0 → 9.14.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.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useMemo, useState, useRef, useCallback, useEffect, useContext, useId, useSyncExternalStore } from 'react';
|
|
1
|
+
import { createContext, useMemo, useState, useRef, useCallback, useEffect, useContext, useReducer, useId, useSyncExternalStore } from 'react';
|
|
2
2
|
import { LocalStorageTokenStore, readDelegatedSession, parseAuthCallback, MeroJs, buildAuthLoginUrl, saveDelegatedSession, saveDelegatedCredential, clearDelegatedSession, clearDelegatedCredential, relayForContext, buildDelegatedClient, readPinnedRelayNodeKey, learnRelayNodeKey, resolveApplicationIdFromRegistry, listDelegatedContexts, createAccountAdmin, createNodeAdmin, readEnrolmentCallback, completeDeviceEnrolment, CloudClient, deviceEnrolmentUrl, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, nodeEndpoint, createDelegatedContext, createDelegatedPrivateContext, governRoot, memberJoinedOpenOp, signerFromSecret, compareSemver, readDelegatedCredential, bootstrapFromInvitation, rememberRelay, carryExecutorAccount, shouldRetain, redeemInvitation, listDelegatedNamespaces, AuthRevokedError, HTTPError, foundDelegatedNamespace, joinAsAccount, classifyError } from '@calimero-network/mero-js';
|
|
3
3
|
export * from '@calimero-network/mero-js';
|
|
4
4
|
export { CAPABILITIES, DEFAULT_LOCAL_NODE_PORTS, HA_ACCOUNT_NOT_LINKED_MESSAGE, HA_REFUSAL_MESSAGES, InvitationNotClaimableError, NoRelayError, NotForAccountError, applicationIdForBundle, bootstrapFromInvitation, clearDelegatedCredential, createAccountAdmin, createDelegatedContext, createNodeAdmin, discoverLocalNodes, hasCap, joinWithNode, listDelegatedContexts, localNodeUrl, nodeEndpoint, normaliseAccount, pinRelayNodeKey, probeNodeHealth, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveApplicationIdFromRegistry, resolveRelayFromInvitation, saveDelegatedCredential, selectLatestBundle, withCap, withoutCap } from '@calimero-network/mero-js';
|
|
@@ -4364,23 +4364,25 @@ function useJoinSync({
|
|
|
4364
4364
|
settled,
|
|
4365
4365
|
active
|
|
4366
4366
|
}) {
|
|
4367
|
-
const [
|
|
4367
|
+
const [, storeChanged] = useReducer((n) => n + 1, 0);
|
|
4368
|
+
useEffect(() => {
|
|
4369
|
+
const unsubscribe = subscribeJustJoined(storeChanged);
|
|
4370
|
+
storeChanged();
|
|
4371
|
+
return unsubscribe;
|
|
4372
|
+
}, []);
|
|
4373
|
+
const flagged = isNamespaceJustJoined(namespaceId);
|
|
4368
4374
|
const firstSeen = useRef(/* @__PURE__ */ new Map());
|
|
4375
|
+
if (namespaceId && flagged && !firstSeen.current.has(namespaceId)) {
|
|
4376
|
+
firstSeen.current.set(namespaceId, Date.now());
|
|
4377
|
+
} else if (namespaceId && !flagged) {
|
|
4378
|
+
firstSeen.current.delete(namespaceId);
|
|
4379
|
+
}
|
|
4369
4380
|
const activeRef = useRef(active);
|
|
4370
4381
|
activeRef.current = active;
|
|
4371
|
-
const flagged = useMemo(() => {
|
|
4372
|
-
if (!namespaceId) return false;
|
|
4373
|
-
if (!isNamespaceJustJoined(namespaceId)) return false;
|
|
4374
|
-
if (!firstSeen.current.has(namespaceId)) {
|
|
4375
|
-
firstSeen.current.set(namespaceId, Date.now());
|
|
4376
|
-
}
|
|
4377
|
-
return true;
|
|
4378
|
-
}, [namespaceId, tick]);
|
|
4379
4382
|
useEffect(() => {
|
|
4380
|
-
if (!namespaceId || !
|
|
4383
|
+
if (!namespaceId || !settled || !isNamespaceJustJoined(namespaceId)) return;
|
|
4381
4384
|
clearNamespaceJustJoined(namespaceId);
|
|
4382
|
-
|
|
4383
|
-
}, [namespaceId, flagged, settled]);
|
|
4385
|
+
});
|
|
4384
4386
|
useEffect(() => {
|
|
4385
4387
|
if (!namespaceId || !flagged || settled) return;
|
|
4386
4388
|
const since = firstSeen.current.get(namespaceId) ?? Date.now();
|
|
@@ -4390,7 +4392,6 @@ function useJoinSync({
|
|
|
4390
4392
|
const giveUp = elapsed >= JOIN_SYNC_MAX_MS || elapsed >= JOIN_SYNC_WATCHDOG_MS && !activeRef.current;
|
|
4391
4393
|
if (giveUp) {
|
|
4392
4394
|
clearNamespaceJustJoined(namespaceId);
|
|
4393
|
-
setTick((t) => t + 1);
|
|
4394
4395
|
return;
|
|
4395
4396
|
}
|
|
4396
4397
|
timer = setTimeout(check, JOIN_SYNC_POLL_MS);
|
|
@@ -4403,7 +4404,6 @@ function useJoinSync({
|
|
|
4403
4404
|
dismiss: () => {
|
|
4404
4405
|
if (!namespaceId) return;
|
|
4405
4406
|
clearNamespaceJustJoined(namespaceId);
|
|
4406
|
-
setTick((t) => t + 1);
|
|
4407
4407
|
}
|
|
4408
4408
|
};
|
|
4409
4409
|
}
|