@dxos/react-client 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731
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/lib/browser/echo/index.mjs +70 -0
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/echo/index.mjs +70 -0
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/echo/index.d.ts +2 -0
- 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/useRegistry.d.ts +6 -0
- package/dist/types/src/echo/useRegistry.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -26
- package/src/echo/index.ts +2 -0
- package/src/echo/useFeedSyncState.ts +78 -0
- package/src/echo/useRegistry.ts +15 -0
- package/tsconfig.json +0 -3
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.d9fc60f731",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -64,22 +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/client": "0.8.4-main.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/echo
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/keys": "0.8.4-main.
|
|
78
|
-
"@dxos/log": "0.8.4-main.
|
|
79
|
-
"@dxos/node-std": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/util": "0.8.4-main.d05539e30a"
|
|
67
|
+
"@dxos/async": "0.8.4-main.d9fc60f731",
|
|
68
|
+
"@dxos/client": "0.8.4-main.d9fc60f731",
|
|
69
|
+
"@dxos/codec-protobuf": "0.8.4-main.d9fc60f731",
|
|
70
|
+
"@dxos/config": "0.8.4-main.d9fc60f731",
|
|
71
|
+
"@dxos/debug": "0.8.4-main.d9fc60f731",
|
|
72
|
+
"@dxos/context": "0.8.4-main.d9fc60f731",
|
|
73
|
+
"@dxos/echo-protocol": "0.8.4-main.d9fc60f731",
|
|
74
|
+
"@dxos/echo": "0.8.4-main.d9fc60f731",
|
|
75
|
+
"@dxos/invariant": "0.8.4-main.d9fc60f731",
|
|
76
|
+
"@dxos/echo-react": "0.8.4-main.d9fc60f731",
|
|
77
|
+
"@dxos/keys": "0.8.4-main.d9fc60f731",
|
|
78
|
+
"@dxos/log": "0.8.4-main.d9fc60f731",
|
|
79
|
+
"@dxos/node-std": "0.8.4-main.d9fc60f731",
|
|
80
|
+
"@dxos/react-hooks": "0.8.4-main.d9fc60f731",
|
|
81
|
+
"@dxos/util": "0.8.4-main.d9fc60f731"
|
|
83
82
|
},
|
|
84
83
|
"devDependencies": {
|
|
85
84
|
"@types/react": "~19.2.7",
|
|
@@ -87,21 +86,21 @@
|
|
|
87
86
|
"react": "~19.2.3",
|
|
88
87
|
"react-dom": "~19.2.3",
|
|
89
88
|
"typedoc": "0.28.1",
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
89
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
90
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
91
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.d9fc60f731",
|
|
92
|
+
"@dxos/storybook-utils": "0.8.4-main.d9fc60f731",
|
|
93
|
+
"@dxos/test-utils": "0.8.4-main.d9fc60f731",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731"
|
|
96
95
|
},
|
|
97
96
|
"peerDependencies": {
|
|
98
97
|
"react": "~19.2.3",
|
|
99
98
|
"react-dom": "~19.2.3"
|
|
100
99
|
},
|
|
101
100
|
"optionalDependencies": {
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
101
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
102
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
103
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731"
|
|
105
104
|
},
|
|
106
105
|
"publishConfig": {
|
|
107
106
|
"access": "public"
|
package/src/echo/index.ts
CHANGED
|
@@ -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
|
+
};
|