@dxos/react-client 0.8.4-main.422d1c7879 → 0.8.4-main.43cb759274
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/{chunk-PFF63FPR.mjs → chunk-3LVU7RNK.mjs} +2 -2
- package/dist/lib/browser/{chunk-TSF6Y5VB.mjs → chunk-CZMIVAGI.mjs} +1 -1
- package/dist/lib/browser/{chunk-TSF6Y5VB.mjs.map → chunk-CZMIVAGI.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-BVDNYEYI.mjs → chunk-XT352YI6.mjs} +11 -56
- package/dist/lib/browser/{chunk-BVDNYEYI.mjs.map → chunk-XT352YI6.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-LO3TU5CK.mjs → chunk-YHE6WD44.mjs} +3 -13
- package/dist/lib/browser/{chunk-LO3TU5CK.mjs.map → chunk-YHE6WD44.mjs.map} +2 -2
- package/dist/lib/browser/devtools/index.mjs +3 -8
- package/dist/lib/browser/devtools/index.mjs.map +2 -2
- package/dist/lib/browser/echo/index.mjs +85 -73
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/halo/index.mjs +3 -3
- package/dist/lib/browser/halo/index.mjs.map +2 -2
- package/dist/lib/browser/index.mjs +6 -21
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/invitations/index.mjs +1 -1
- package/dist/lib/browser/mesh/index.mjs +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +5 -20
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-NETTSER2.mjs → chunk-CUDKNAMV.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AQJH2UNZ.mjs → chunk-RQJPEHDY.mjs} +3 -13
- package/dist/lib/node-esm/{chunk-AQJH2UNZ.mjs.map → chunk-RQJPEHDY.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-VSA674XR.mjs → chunk-WL3Z5HOH.mjs} +11 -56
- package/dist/lib/node-esm/{chunk-VSA674XR.mjs.map → chunk-WL3Z5HOH.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-373DPHEQ.mjs → chunk-WUTK2IJF.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-373DPHEQ.mjs.map → chunk-WUTK2IJF.mjs.map} +2 -2
- package/dist/lib/node-esm/devtools/index.mjs +3 -8
- package/dist/lib/node-esm/devtools/index.mjs.map +2 -2
- package/dist/lib/node-esm/echo/index.mjs +85 -73
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/halo/index.mjs +3 -3
- package/dist/lib/node-esm/halo/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +6 -21
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/invitations/index.mjs +1 -1
- package/dist/lib/node-esm/mesh/index.mjs +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +5 -20
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/banner.d.ts.map +1 -1
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
- package/dist/types/src/client/ClientProvider.d.ts +1 -1
- package/dist/types/src/client/useClientStatus.d.ts.map +1 -1
- package/dist/types/src/devtools/useStream.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +2 -1
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useFeedSyncState.d.ts +13 -0
- package/dist/types/src/echo/useFeedSyncState.d.ts.map +1 -0
- package/dist/types/src/echo/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useRegistry.d.ts +6 -0
- package/dist/types/src/echo/useRegistry.d.ts.map +1 -0
- package/dist/types/src/echo/useSpaceInvitations.d.ts +1 -1
- package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaces.d.ts +4 -2
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
- package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
- package/dist/types/src/halo/useKeyStore.d.ts.map +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/context.d.ts +2 -1
- package/dist/types/src/testing/context.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -25
- package/src/echo/index.ts +2 -1
- package/src/echo/useFeedSyncState.ts +78 -0
- package/src/echo/useRegistry.ts +15 -0
- package/src/echo/useSpaceInvitations.ts +1 -1
- package/src/echo/useSpaces.ts +3 -1
- package/src/echo/useSyncState.ts +1 -6
- package/src/testing/ClientRepeater.stories.tsx +1 -1
- package/src/testing/ClientRepeater.tsx +1 -1
- package/src/testing/context.tsx +2 -1
- package/src/testing/withClientProvider.tsx +2 -1
- package/tsconfig.json +5 -2
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/types/src/echo/useQueue.d.ts +0 -12
- package/dist/types/src/echo/useQueue.d.ts.map +0 -1
- package/src/echo/useQueue.ts +0 -73
- /package/dist/lib/browser/{chunk-PFF63FPR.mjs.map → chunk-3LVU7RNK.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-NETTSER2.mjs.map → chunk-CUDKNAMV.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.43cb759274",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"type": "module",
|
|
@@ -64,20 +64,21 @@
|
|
|
64
64
|
},
|
|
65
65
|
"types": "dist/types/src/index.d.ts",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@dxos/async": "0.8.4-main.
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/echo-
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/node-std": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
67
|
+
"@dxos/async": "0.8.4-main.43cb759274",
|
|
68
|
+
"@dxos/client": "0.8.4-main.43cb759274",
|
|
69
|
+
"@dxos/config": "0.8.4-main.43cb759274",
|
|
70
|
+
"@dxos/codec-protobuf": "0.8.4-main.43cb759274",
|
|
71
|
+
"@dxos/context": "0.8.4-main.43cb759274",
|
|
72
|
+
"@dxos/debug": "0.8.4-main.43cb759274",
|
|
73
|
+
"@dxos/echo-protocol": "0.8.4-main.43cb759274",
|
|
74
|
+
"@dxos/echo": "0.8.4-main.43cb759274",
|
|
75
|
+
"@dxos/echo-react": "0.8.4-main.43cb759274",
|
|
76
|
+
"@dxos/invariant": "0.8.4-main.43cb759274",
|
|
77
|
+
"@dxos/keys": "0.8.4-main.43cb759274",
|
|
78
|
+
"@dxos/log": "0.8.4-main.43cb759274",
|
|
79
|
+
"@dxos/node-std": "0.8.4-main.43cb759274",
|
|
80
|
+
"@dxos/util": "0.8.4-main.43cb759274",
|
|
81
|
+
"@dxos/react-hooks": "0.8.4-main.43cb759274"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@types/react": "~19.2.7",
|
|
@@ -85,21 +86,21 @@
|
|
|
85
86
|
"react": "~19.2.3",
|
|
86
87
|
"react-dom": "~19.2.3",
|
|
87
88
|
"typedoc": "0.28.1",
|
|
88
|
-
"@dxos/react-ui
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.43cb759274",
|
|
90
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.43cb759274",
|
|
91
|
+
"@dxos/storybook-utils": "0.8.4-main.43cb759274",
|
|
92
|
+
"@dxos/random": "0.8.4-main.43cb759274",
|
|
93
|
+
"@dxos/test-utils": "0.8.4-main.43cb759274",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.43cb759274"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"react": "~19.2.3",
|
|
97
98
|
"react-dom": "~19.2.3"
|
|
98
99
|
},
|
|
99
100
|
"optionalDependencies": {
|
|
100
|
-
"@dxos/ui
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/
|
|
101
|
+
"@dxos/react-ui": "0.8.4-main.43cb759274",
|
|
102
|
+
"@dxos/ui-theme": "0.8.4-main.43cb759274",
|
|
103
|
+
"@dxos/random": "0.8.4-main.43cb759274"
|
|
103
104
|
},
|
|
104
105
|
"publishConfig": {
|
|
105
106
|
"access": "public"
|
package/src/echo/index.ts
CHANGED
|
@@ -6,9 +6,10 @@ export * from '@dxos/client/echo';
|
|
|
6
6
|
export * from '@dxos/echo-react';
|
|
7
7
|
|
|
8
8
|
export * from './useMembers';
|
|
9
|
-
export * from './useQueue';
|
|
10
9
|
export * from './useSpaces';
|
|
11
10
|
export * from './useSpaceInvitations';
|
|
12
11
|
export * from './useSpaceProperties';
|
|
13
12
|
export * from './useSubscription';
|
|
14
13
|
export * from './useSyncState';
|
|
14
|
+
export * from './useFeedSyncState';
|
|
15
|
+
export * from './useRegistry';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SpaceId } from '@dxos/keys';
|
|
8
|
+
|
|
9
|
+
import { useClient } from '../client';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
12
|
+
|
|
13
|
+
export type FeedSyncState = {
|
|
14
|
+
/** Combined blocks to pull + push across namespaces. */
|
|
15
|
+
pending: number;
|
|
16
|
+
/** Total blocks stored locally across namespaces. */
|
|
17
|
+
total: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type FeedSyncStateMap = Record<SpaceId, FeedSyncState>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Polls queue replication state per space.
|
|
24
|
+
*/
|
|
25
|
+
export const useFeedSyncState = (pollIntervalMs = DEFAULT_POLL_INTERVAL_MS): FeedSyncStateMap => {
|
|
26
|
+
const client = useClient();
|
|
27
|
+
const [feedSyncState, setFeedSyncState] = useState<FeedSyncStateMap>({});
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const queueService = client.services.services.QueueService;
|
|
31
|
+
if (!queueService) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let cancelled = false;
|
|
36
|
+
|
|
37
|
+
const poll = async () => {
|
|
38
|
+
const spaces = client.spaces.get();
|
|
39
|
+
const entries = await Promise.all(
|
|
40
|
+
spaces.map(async (space) => {
|
|
41
|
+
try {
|
|
42
|
+
const response = await queueService.getSyncState({ spaceId: space.id });
|
|
43
|
+
const state = (response.namespaces ?? []).reduce<FeedSyncState>(
|
|
44
|
+
(acc, entry) => {
|
|
45
|
+
acc.pending += Number(entry.blocksToPull ?? 0) + Number(entry.blocksToPush ?? 0);
|
|
46
|
+
acc.total += Number(entry.totalBlocks ?? 0);
|
|
47
|
+
return acc;
|
|
48
|
+
},
|
|
49
|
+
{ pending: 0, total: 0 },
|
|
50
|
+
);
|
|
51
|
+
return [space.id, state] as const;
|
|
52
|
+
} catch {
|
|
53
|
+
return [space.id, { pending: 0, total: 0 }] as const;
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (!cancelled) {
|
|
59
|
+
setFeedSyncState(Object.fromEntries(entries));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
void poll();
|
|
64
|
+
const interval = setInterval(() => void poll(), pollIntervalMs);
|
|
65
|
+
|
|
66
|
+
const spacesSubscription = client.spaces.subscribe(() => {
|
|
67
|
+
void poll();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
cancelled = true;
|
|
72
|
+
clearInterval(interval);
|
|
73
|
+
spacesSubscription.unsubscribe();
|
|
74
|
+
};
|
|
75
|
+
}, [client, pollIntervalMs]);
|
|
76
|
+
|
|
77
|
+
return feedSyncState;
|
|
78
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Registry } from '@dxos/echo';
|
|
6
|
+
|
|
7
|
+
import { useClient } from '../client';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns the hypergraph registry attached to the current client.
|
|
11
|
+
*/
|
|
12
|
+
export const useRegistry = (): Registry.Registry => {
|
|
13
|
+
const client = useClient();
|
|
14
|
+
return client.graph.registry;
|
|
15
|
+
};
|
|
@@ -6,7 +6,7 @@ import { useMemo } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { MulticastObservable } from '@dxos/async';
|
|
8
8
|
import { type PublicKey } from '@dxos/client';
|
|
9
|
-
import { type SpaceId } from '@dxos/
|
|
9
|
+
import { type SpaceId } from '@dxos/keys';
|
|
10
10
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
11
11
|
|
|
12
12
|
import { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';
|
package/src/echo/useSpaces.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { PublicKey } from '@dxos/client';
|
|
6
|
-
import { type Space,
|
|
6
|
+
import { type Space, SpaceState } from '@dxos/client/echo';
|
|
7
|
+
import { type SpaceId } from '@dxos/keys';
|
|
7
8
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
8
9
|
|
|
9
10
|
import { useClient } from '../client';
|
|
@@ -41,6 +42,7 @@ export const useSpace = (spaceId?: SpaceId | PublicKey): Space | undefined => {
|
|
|
41
42
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
42
43
|
*
|
|
43
44
|
* @param spaceId the id of the space to look for.
|
|
45
|
+
* @deprecated Use useSpace.
|
|
44
46
|
*/
|
|
45
47
|
export const useDatabase = (spaceId?: SpaceId): Space['db'] | undefined => {
|
|
46
48
|
const space = useSpace(spaceId);
|
package/src/echo/useSyncState.ts
CHANGED
|
@@ -6,15 +6,10 @@ import { useEffect, useState } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type PeerSyncState, type Space, type SpaceSyncStateMap } from '@dxos/client/echo';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
|
-
import {
|
|
10
|
-
import { EdgeService } from '@dxos/protocols';
|
|
11
|
-
import { compositeKey } from '@dxos/util';
|
|
9
|
+
import { isEdgePeerId } from '@dxos/echo-protocol';
|
|
12
10
|
|
|
13
11
|
import { useClient } from '../client';
|
|
14
12
|
|
|
15
|
-
const isEdgePeerId = (peerId: string, spaceId: SpaceId) =>
|
|
16
|
-
peerId.startsWith(compositeKey(EdgeService.AUTOMERGE_REPLICATOR, spaceId));
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* Hook Subscribes to sync state for each space.
|
|
20
15
|
*/
|
|
@@ -44,7 +44,7 @@ const ClientSpace = ({ spaceId }: ClientRepeatedComponentProps) => {
|
|
|
44
44
|
placeholder='Name'
|
|
45
45
|
value={space.properties.name}
|
|
46
46
|
onChange={(event) =>
|
|
47
|
-
Obj.
|
|
47
|
+
Obj.update(space.properties, (obj) => {
|
|
48
48
|
obj.name = event.target.value;
|
|
49
49
|
})
|
|
50
50
|
}
|
|
@@ -7,11 +7,11 @@ import React, { type FC, useRef, useState } from 'react';
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
8
|
import { TestBuilder, performInvitation } from '@dxos/client/testing';
|
|
9
9
|
import { type Type } from '@dxos/echo';
|
|
10
|
+
import { type SpaceId } from '@dxos/keys';
|
|
10
11
|
import { random } from '@dxos/random';
|
|
11
12
|
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
12
13
|
|
|
13
14
|
import { ClientProvider } from '../client';
|
|
14
|
-
import { type SpaceId } from '../echo';
|
|
15
15
|
import { type WithClientProviderProps } from './withClientProvider';
|
|
16
16
|
|
|
17
17
|
export type ClientRepeatedComponentProps = { id: number; count: number; spaceId?: SpaceId };
|
package/src/testing/context.tsx
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type Space
|
|
7
|
+
import { type Space } from '@dxos/client/echo';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
|
+
import { type SpaceId } from '@dxos/keys';
|
|
9
10
|
|
|
10
11
|
export type ClientStory = {
|
|
11
12
|
index?: number;
|
|
@@ -7,8 +7,9 @@ import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Trigger } from '@dxos/async';
|
|
9
9
|
import { type Client } from '@dxos/client';
|
|
10
|
-
import { type Space
|
|
10
|
+
import { type Space } from '@dxos/client/echo';
|
|
11
11
|
import { TestBuilder, performInvitation } from '@dxos/client/testing';
|
|
12
|
+
import { type SpaceId } from '@dxos/keys';
|
|
12
13
|
import { log } from '@dxos/log';
|
|
13
14
|
import { ErrorBoundary } from '@dxos/react-ui';
|
|
14
15
|
import { type MaybePromise } from '@dxos/util';
|
package/tsconfig.json
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
{
|
|
24
24
|
"path": "../../common/invariant"
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../../common/keys"
|
|
28
|
+
},
|
|
26
29
|
{
|
|
27
30
|
"path": "../../common/log"
|
|
28
31
|
},
|
|
@@ -45,10 +48,10 @@
|
|
|
45
48
|
"path": "../../core/echo/echo"
|
|
46
49
|
},
|
|
47
50
|
{
|
|
48
|
-
"path": "../../core/echo/echo-
|
|
51
|
+
"path": "../../core/echo/echo-protocol"
|
|
49
52
|
},
|
|
50
53
|
{
|
|
51
|
-
"path": "../../core/
|
|
54
|
+
"path": "../../core/echo/echo-react"
|
|
52
55
|
},
|
|
53
56
|
{
|
|
54
57
|
"path": "../../ui/react-primitives/react-hooks"
|
|
Binary file
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Queue } from '@dxos/client/echo';
|
|
2
|
-
import { type Entity } from '@dxos/echo';
|
|
3
|
-
import { type DXN } from '@dxos/keys';
|
|
4
|
-
export type UseQueueOptions = {
|
|
5
|
-
pollInterval?: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Polls the given Edge queue.
|
|
9
|
-
* @deprecated Use `useQuery` instead.
|
|
10
|
-
*/
|
|
11
|
-
export declare const useQueue: <T extends Entity.Unknown>(queueDxn?: DXN, options?: UseQueueOptions) => Queue<T> | undefined;
|
|
12
|
-
//# sourceMappingURL=useQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQueue.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQueue.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAMtC,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;GAGG;AAGH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,OAAO,EAC/C,WAAW,GAAG,EACd,UAAS,eAAoB,KAC5B,KAAK,CAAC,CAAC,CAAC,GAAG,SA4Cb,CAAC"}
|
package/src/echo/useQueue.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type Queue } from '@dxos/client/echo';
|
|
8
|
-
import { raise } from '@dxos/debug';
|
|
9
|
-
import { type Entity } from '@dxos/echo';
|
|
10
|
-
import { type DXN } from '@dxos/keys';
|
|
11
|
-
|
|
12
|
-
import { useClient } from '../client';
|
|
13
|
-
|
|
14
|
-
const MIN_POLL_INTERVAL = 1_000;
|
|
15
|
-
|
|
16
|
-
export type UseQueueOptions = {
|
|
17
|
-
pollInterval?: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Polls the given Edge queue.
|
|
22
|
-
* @deprecated Use `useQuery` instead.
|
|
23
|
-
*/
|
|
24
|
-
// TODO(dmaretskyi): Move into client package.
|
|
25
|
-
// TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.
|
|
26
|
-
export const useQueue = <T extends Entity.Unknown>(
|
|
27
|
-
queueDxn?: DXN,
|
|
28
|
-
options: UseQueueOptions = {},
|
|
29
|
-
): Queue<T> | undefined => {
|
|
30
|
-
const client = useClient();
|
|
31
|
-
const mountedRef = useRef(true);
|
|
32
|
-
|
|
33
|
-
const queue = useMemo<Queue<T> | undefined>(() => {
|
|
34
|
-
if (!queueDxn) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError('Invalid queue DXN'));
|
|
39
|
-
return client.spaces.get(spaceId)?.queues.get<T>(queueDxn);
|
|
40
|
-
}, [client, queueDxn?.toString()]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
void queue?.refresh();
|
|
44
|
-
}, [queue]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
let timeout: NodeJS.Timeout;
|
|
48
|
-
mountedRef.current = true;
|
|
49
|
-
|
|
50
|
-
const poll = () => {
|
|
51
|
-
if (!mountedRef.current) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
void queue?.refresh().finally(() => {
|
|
56
|
-
if (mountedRef.current && options.pollInterval) {
|
|
57
|
-
timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
if (options.pollInterval) {
|
|
63
|
-
poll();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return () => {
|
|
67
|
-
mountedRef.current = false;
|
|
68
|
-
clearTimeout(timeout);
|
|
69
|
-
};
|
|
70
|
-
}, [queue, options.pollInterval]);
|
|
71
|
-
|
|
72
|
-
return queue;
|
|
73
|
-
};
|
|
File without changes
|
|
File without changes
|