@arbidocs/react 0.5.28 → 0.5.30
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 +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -6274,6 +6274,8 @@ function ArbiWebSocketProvider({
|
|
|
6274
6274
|
children
|
|
6275
6275
|
}) {
|
|
6276
6276
|
const arbi = chunkYIUUTRMQ_cjs.useArbi();
|
|
6277
|
+
const arbiRef = React.useRef(arbi);
|
|
6278
|
+
arbiRef.current = arbi;
|
|
6277
6279
|
const queryClient = reactQuery.useQueryClient();
|
|
6278
6280
|
const subscribersRef = React.useRef(/* @__PURE__ */ new Set());
|
|
6279
6281
|
const setStatus = useArbiWsStore((s) => s.setStatus);
|
|
@@ -6312,10 +6314,10 @@ function ArbiWebSocketProvider({
|
|
|
6312
6314
|
else {
|
|
6313
6315
|
const type = msg.type;
|
|
6314
6316
|
if (type.startsWith("chat.") || type === "agent_dm_status")
|
|
6315
|
-
void chunk3ZLRZTKP_cjs.applyChatEvent(
|
|
6317
|
+
void chunk3ZLRZTKP_cjs.applyChatEvent(arbiRef.current, queryClient, msg);
|
|
6316
6318
|
else if (type.startsWith("call."))
|
|
6317
6319
|
chunk3ZLRZTKP_cjs.applyCallEvent(queryClient, msg, {
|
|
6318
|
-
me:
|
|
6320
|
+
me: arbiRef.current.isLoggedIn ? arbiRef.current.user.identity()?.externalId ?? null : null,
|
|
6319
6321
|
acceptRings: acceptRingsRef.current
|
|
6320
6322
|
});
|
|
6321
6323
|
else void applyLiveUpdate(queryClient, msg);
|
|
@@ -6341,8 +6343,11 @@ function ArbiWebSocketProvider({
|
|
|
6341
6343
|
};
|
|
6342
6344
|
const start = async () => {
|
|
6343
6345
|
if (cancelled) return;
|
|
6344
|
-
const info =
|
|
6345
|
-
if (!info)
|
|
6346
|
+
const info = arbiRef.current.getConnectionInfo();
|
|
6347
|
+
if (!info) {
|
|
6348
|
+
scheduleRestart();
|
|
6349
|
+
return;
|
|
6350
|
+
}
|
|
6346
6351
|
conn?.close();
|
|
6347
6352
|
conn = null;
|
|
6348
6353
|
setStatus("connecting");
|
|
@@ -6354,9 +6359,9 @@ function ArbiWebSocketProvider({
|
|
|
6354
6359
|
),
|
|
6355
6360
|
accessToken: info.accessToken,
|
|
6356
6361
|
// Resolve the freshest token on every (re)connect so rotation is picked up.
|
|
6357
|
-
getAccessToken: () =>
|
|
6362
|
+
getAccessToken: () => arbiRef.current.getConnectionInfo()?.accessToken ?? null,
|
|
6358
6363
|
// A reconnect refused for its token re-logs in silently first.
|
|
6359
|
-
refreshAuth: () =>
|
|
6364
|
+
refreshAuth: () => arbiRef.current.refreshAccess(),
|
|
6360
6365
|
onAuthenticated: (message) => onAuthenticatedRef.current?.(message),
|
|
6361
6366
|
// The session's: a sign-out closes the socket before the server revokes the token.
|
|
6362
6367
|
signal: info.signal,
|
|
@@ -6397,7 +6402,7 @@ function ArbiWebSocketProvider({
|
|
|
6397
6402
|
conn?.close();
|
|
6398
6403
|
reset();
|
|
6399
6404
|
};
|
|
6400
|
-
}, [enabled,
|
|
6405
|
+
}, [enabled, queryClient, setStatus, setEvicted, applyTaskUpdate, applyPresence, reset]);
|
|
6401
6406
|
return /* @__PURE__ */ jsxRuntime.jsx(ArbiWsContext.Provider, { value: context, children });
|
|
6402
6407
|
}
|
|
6403
6408
|
function useArbiWebSocket(onMessage) {
|