@dxos/react-client 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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/.storybook/main.mts +1 -3
- 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-5UKA2BMA.mjs → chunk-XT352YI6.mjs} +11 -56
- package/dist/lib/browser/chunk-XT352YI6.mjs.map +7 -0
- 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 +19 -38
- package/dist/lib/browser/echo/index.mjs.map +3 -3
- 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 +15 -64
- 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-T3QTQHBD.mjs → chunk-WL3Z5HOH.mjs} +11 -56
- package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +7 -0
- 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 +19 -38
- package/dist/lib/node-esm/echo/index.mjs.map +3 -3
- 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 +15 -64
- 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/ClientProvider.d.ts.map +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/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useQueue.d.ts +1 -0
- package/dist/types/src/echo/useQueue.d.ts.map +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 +7 -6
- 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/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 +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/docs/README.md +38 -38
- package/moon.yml +1 -4
- package/package.json +24 -50
- package/src/client/ClientProvider.test.tsx +0 -1
- package/src/client/ClientProvider.tsx +0 -1
- package/src/client/useConfig.test.tsx +0 -1
- package/src/echo/useQueue.ts +1 -2
- package/src/echo/useSpaceInvitations.ts +0 -1
- package/src/echo/useSpaces.test.tsx +6 -13
- package/src/echo/useSpaces.ts +15 -30
- package/src/echo/useSyncState.ts +2 -1
- package/src/halo/Passkey.stories.tsx +4 -7
- package/src/halo/useDevices.test.tsx +0 -1
- package/src/testing/ClientRepeater.stories.tsx +4 -7
- package/src/testing/ClientRepeater.tsx +3 -4
- package/src/testing/util.tsx +0 -1
- package/src/testing/withClientProvider.stories.tsx +6 -8
- package/src/testing/withClientProvider.tsx +4 -38
- package/typedoc.json +1 -1
- package/vitest.config.ts +0 -2
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/chunk-5UKA2BMA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T3QTQHBD.mjs.map +0 -7
- /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/docs/README.md
CHANGED
|
@@ -168,41 +168,41 @@ dxos/react-client --> dxos/react-async
|
|
|
168
168
|
|
|
169
169
|
## Dependencies
|
|
170
170
|
|
|
171
|
-
| Module
|
|
172
|
-
|
|
173
|
-
| [`@dxos/async`](../../../common/async/docs/README.md)
|
|
174
|
-
| [`@dxos/broadcast`](../../../core/mesh/broadcast/docs/README.md)
|
|
175
|
-
| [`@dxos/client`](../../client/docs/README.md)
|
|
176
|
-
| [`@dxos/client-services`](../../client-services/docs/README.md)
|
|
177
|
-
| [`@dxos/codec-protobuf`](../../../common/codec-protobuf/docs/README.md)
|
|
178
|
-
| [`@dxos/config`](../../config/docs/README.md)
|
|
179
|
-
| [`@dxos/context`](../../../common/context/docs/README.md)
|
|
180
|
-
| [`@dxos/credentials`](../../../core/halo/credentials/docs/README.md)
|
|
181
|
-
| [`@dxos/crypto`](../../../common/crypto/docs/README.md)
|
|
182
|
-
| [`@dxos/debug`](../../../common/debug/docs/README.md)
|
|
183
|
-
| [`@dxos/echo-db`](../../../core/echo/echo-db/docs/README.md)
|
|
184
|
-
| [`@dxos/errors`](../../errors/docs/README.md)
|
|
185
|
-
| [`@dxos/feed-store`](../../../common/feed-store/docs/README.md)
|
|
186
|
-
| [`@dxos/hypercore`](../../../common/hypercore/docs/README.md)
|
|
187
|
-
| [`@dxos/keyring`](../../../core/halo/keyring/docs/README.md)
|
|
188
|
-
| [`@dxos/keys`](../../../common/keys/docs/README.md)
|
|
189
|
-
| [`@dxos/log`](../../../common/log/docs/README.md)
|
|
190
|
-
| [`@dxos/mesh-protocol`](../../../core/mesh/mesh-protocol/docs/README.md)
|
|
191
|
-
| [`@dxos/messaging`](../../../core/mesh/messaging/docs/README.md)
|
|
192
|
-
| [`@dxos/model-factory`](../../../core/echo/model-factory/docs/README.md)
|
|
193
|
-
| [`@dxos/network-generator`](../../../core/mesh/network-generator/docs/README.md)
|
|
194
|
-
| [`@dxos/network-manager`](../../../core/mesh/network-manager/docs/README.md)
|
|
195
|
-
| [`@dxos/document-model`](../../../core/echo/document-model/docs/README.md)
|
|
196
|
-
| [`@dxos/protocol-plugin-presence`](../../../core/mesh/protocol-plugin-presence/docs/README.md)
|
|
197
|
-
| [`@dxos/protocol-plugin-replicator`](../../../core/mesh/protocol-plugin-replicator/docs/README.md) |
|
|
198
|
-
| [`@dxos/protocol-plugin-rpc`](../../../core/mesh/protocol-plugin-rpc/docs/README.md)
|
|
199
|
-
| [`@dxos/protocols`](../../../core/protocols/docs/README.md)
|
|
200
|
-
| [`@dxos/random-access-storage`](../../../common/random-access-storage/docs/README.md)
|
|
201
|
-
| [`@dxos/react-async`](../../../common/react-async/docs/README.md)
|
|
202
|
-
| [`@dxos/rpc`](../../../core/mesh/rpc/docs/README.md)
|
|
203
|
-
| [`@dxos/rpc-tunnel`](../../../core/mesh/rpc-tunnel/docs/README.md)
|
|
204
|
-
| [`@dxos/teleport`](../../../core/mesh/teleport/docs/README.md)
|
|
205
|
-
| [`@dxos/teleport-plugin-replicator`](../../../core/mesh/teleport-plugin-replicator/docs/README.md) |
|
|
206
|
-
| [`@dxos/text-model`](../../../core/echo/text-model/docs/README.md)
|
|
207
|
-
| [`@dxos/timeframe`](../../../common/timeframe/docs/README.md)
|
|
208
|
-
| [`@dxos/util`](../../../common/util/docs/README.md)
|
|
171
|
+
| Module | Direct |
|
|
172
|
+
| -------------------------------------------------------------------------------------------------- | ------- |
|
|
173
|
+
| [`@dxos/async`](../../../common/async/docs/README.md) | ✓ |
|
|
174
|
+
| [`@dxos/broadcast`](../../../core/mesh/broadcast/docs/README.md) | |
|
|
175
|
+
| [`@dxos/client`](../../client/docs/README.md) | ✓ |
|
|
176
|
+
| [`@dxos/client-services`](../../client-services/docs/README.md) | ✓ |
|
|
177
|
+
| [`@dxos/codec-protobuf`](../../../common/codec-protobuf/docs/README.md) | ✓ |
|
|
178
|
+
| [`@dxos/config`](../../config/docs/README.md) | ✓ |
|
|
179
|
+
| [`@dxos/context`](../../../common/context/docs/README.md) | |
|
|
180
|
+
| [`@dxos/credentials`](../../../core/halo/credentials/docs/README.md) | |
|
|
181
|
+
| [`@dxos/crypto`](../../../common/crypto/docs/README.md) | |
|
|
182
|
+
| [`@dxos/debug`](../../../common/debug/docs/README.md) | ✓ |
|
|
183
|
+
| [`@dxos/echo-db`](../../../core/echo/echo-db/docs/README.md) | |
|
|
184
|
+
| [`@dxos/errors`](../../errors/docs/README.md) | |
|
|
185
|
+
| [`@dxos/feed-store`](../../../common/feed-store/docs/README.md) | |
|
|
186
|
+
| [`@dxos/hypercore`](../../../common/hypercore/docs/README.md) | |
|
|
187
|
+
| [`@dxos/keyring`](../../../core/halo/keyring/docs/README.md) | |
|
|
188
|
+
| [`@dxos/keys`](../../../common/keys/docs/README.md) | ✓ |
|
|
189
|
+
| [`@dxos/log`](../../../common/log/docs/README.md) | ✓ |
|
|
190
|
+
| [`@dxos/mesh-protocol`](../../../core/mesh/mesh-protocol/docs/README.md) | |
|
|
191
|
+
| [`@dxos/messaging`](../../../core/mesh/messaging/docs/README.md) | ✓ |
|
|
192
|
+
| [`@dxos/model-factory`](../../../core/echo/model-factory/docs/README.md) | |
|
|
193
|
+
| [`@dxos/network-generator`](../../../core/mesh/network-generator/docs/README.md) | |
|
|
194
|
+
| [`@dxos/network-manager`](../../../core/mesh/network-manager/docs/README.md) | |
|
|
195
|
+
| [`@dxos/document-model`](../../../core/echo/document-model/docs/README.md) | |
|
|
196
|
+
| [`@dxos/protocol-plugin-presence`](../../../core/mesh/protocol-plugin-presence/docs/README.md) | |
|
|
197
|
+
| [`@dxos/protocol-plugin-replicator`](../../../core/mesh/protocol-plugin-replicator/docs/README.md) | |
|
|
198
|
+
| [`@dxos/protocol-plugin-rpc`](../../../core/mesh/protocol-plugin-rpc/docs/README.md) | |
|
|
199
|
+
| [`@dxos/protocols`](../../../core/protocols/docs/README.md) | ✓ |
|
|
200
|
+
| [`@dxos/random-access-storage`](../../../common/random-access-storage/docs/README.md) | |
|
|
201
|
+
| [`@dxos/react-async`](../../../common/react-async/docs/README.md) | ✓ |
|
|
202
|
+
| [`@dxos/rpc`](../../../core/mesh/rpc/docs/README.md) | ✓ |
|
|
203
|
+
| [`@dxos/rpc-tunnel`](../../../core/mesh/rpc-tunnel/docs/README.md) | ✓ |
|
|
204
|
+
| [`@dxos/teleport`](../../../core/mesh/teleport/docs/README.md) | |
|
|
205
|
+
| [`@dxos/teleport-plugin-replicator`](../../../core/mesh/teleport-plugin-replicator/docs/README.md) | |
|
|
206
|
+
| [`@dxos/text-model`](../../../core/echo/text-model/docs/README.md) | |
|
|
207
|
+
| [`@dxos/timeframe`](../../../common/timeframe/docs/README.md) | |
|
|
208
|
+
| [`@dxos/util`](../../../common/util/docs/README.md) | ✓ |
|
package/moon.yml
CHANGED
|
@@ -3,6 +3,7 @@ language: typescript
|
|
|
3
3
|
tags:
|
|
4
4
|
- ts-build
|
|
5
5
|
- ts-test
|
|
6
|
+
- ts-test-storybook
|
|
6
7
|
- typedoc
|
|
7
8
|
- pack
|
|
8
9
|
- storybook
|
|
@@ -17,7 +18,3 @@ tasks:
|
|
|
17
18
|
- '--entryPoint=src/mesh/index.ts'
|
|
18
19
|
- '--entryPoint=src/testing/index.ts'
|
|
19
20
|
- '--entryPoint=src/worker.ts'
|
|
20
|
-
test:
|
|
21
|
-
inputs:
|
|
22
|
-
- .storybook/*
|
|
23
|
-
- /tools/storybook-react/.storybook/main.ts
|
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.3fbcb4aa9b",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -63,47 +63,21 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"types": "dist/types/src/index.d.ts",
|
|
66
|
-
"typesVersions": {
|
|
67
|
-
"*": {
|
|
68
|
-
"devtools": [
|
|
69
|
-
"dist/types/src/devtools/index.d.ts"
|
|
70
|
-
],
|
|
71
|
-
"echo": [
|
|
72
|
-
"dist/types/src/echo/index.d.ts"
|
|
73
|
-
],
|
|
74
|
-
"halo": [
|
|
75
|
-
"dist/types/src/halo/index.d.ts"
|
|
76
|
-
],
|
|
77
|
-
"invitations": [
|
|
78
|
-
"dist/types/src/invitations/index.d.ts"
|
|
79
|
-
],
|
|
80
|
-
"mesh": [
|
|
81
|
-
"dist/types/src/mesh/index.d.ts"
|
|
82
|
-
],
|
|
83
|
-
"testing": [
|
|
84
|
-
"dist/types/src/testing/index.d.ts"
|
|
85
|
-
],
|
|
86
|
-
"worker": [
|
|
87
|
-
"dist/types/src/worker.d.ts"
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
66
|
"dependencies": {
|
|
92
|
-
"
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/echo": "0.8.4-main.
|
|
99
|
-
"@dxos/
|
|
100
|
-
"@dxos/
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/protocols": "0.8.4-main.
|
|
104
|
-
"@dxos/react-hooks": "0.8.4-main.
|
|
105
|
-
"@dxos/util": "0.8.4-main.
|
|
106
|
-
"@dxos/codec-protobuf": "0.8.4-main.3eb6e50203"
|
|
67
|
+
"@dxos/async": "0.8.4-main.3fbcb4aa9b",
|
|
68
|
+
"@dxos/client": "0.8.4-main.3fbcb4aa9b",
|
|
69
|
+
"@dxos/codec-protobuf": "0.8.4-main.3fbcb4aa9b",
|
|
70
|
+
"@dxos/config": "0.8.4-main.3fbcb4aa9b",
|
|
71
|
+
"@dxos/debug": "0.8.4-main.3fbcb4aa9b",
|
|
72
|
+
"@dxos/echo": "0.8.4-main.3fbcb4aa9b",
|
|
73
|
+
"@dxos/echo-react": "0.8.4-main.3fbcb4aa9b",
|
|
74
|
+
"@dxos/context": "0.8.4-main.3fbcb4aa9b",
|
|
75
|
+
"@dxos/invariant": "0.8.4-main.3fbcb4aa9b",
|
|
76
|
+
"@dxos/log": "0.8.4-main.3fbcb4aa9b",
|
|
77
|
+
"@dxos/node-std": "0.8.4-main.3fbcb4aa9b",
|
|
78
|
+
"@dxos/protocols": "0.8.4-main.3fbcb4aa9b",
|
|
79
|
+
"@dxos/react-hooks": "0.8.4-main.3fbcb4aa9b",
|
|
80
|
+
"@dxos/util": "0.8.4-main.3fbcb4aa9b"
|
|
107
81
|
},
|
|
108
82
|
"devDependencies": {
|
|
109
83
|
"@types/react": "~19.2.7",
|
|
@@ -111,21 +85,21 @@
|
|
|
111
85
|
"react": "~19.2.3",
|
|
112
86
|
"react-dom": "~19.2.3",
|
|
113
87
|
"typedoc": "0.28.1",
|
|
114
|
-
"@dxos/random": "0.8.4-main.
|
|
115
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
116
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.
|
|
117
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
118
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
119
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
88
|
+
"@dxos/random": "0.8.4-main.3fbcb4aa9b",
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
90
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.3fbcb4aa9b",
|
|
91
|
+
"@dxos/storybook-utils": "0.8.4-main.3fbcb4aa9b",
|
|
92
|
+
"@dxos/test-utils": "0.8.4-main.3fbcb4aa9b",
|
|
93
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
|
|
120
94
|
},
|
|
121
95
|
"peerDependencies": {
|
|
122
96
|
"react": "~19.2.3",
|
|
123
97
|
"react-dom": "~19.2.3"
|
|
124
98
|
},
|
|
125
99
|
"optionalDependencies": {
|
|
126
|
-
"@dxos/
|
|
127
|
-
"@dxos/
|
|
128
|
-
"@dxos/
|
|
100
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
101
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b",
|
|
102
|
+
"@dxos/random": "0.8.4-main.3fbcb4aa9b"
|
|
129
103
|
},
|
|
130
104
|
"publishConfig": {
|
|
131
105
|
"access": "public"
|
|
@@ -18,7 +18,6 @@ import { useAsyncEffect, useControlledState } from '@dxos/react-hooks';
|
|
|
18
18
|
import { type MaybePromise, type Provider, getAsyncProviderValue } from '@dxos/util';
|
|
19
19
|
|
|
20
20
|
import { printBanner } from '../banner';
|
|
21
|
-
|
|
22
21
|
import { ClientContext, type ClientContextProps } from './context';
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -9,7 +9,6 @@ import { waitForCondition } from '@dxos/async';
|
|
|
9
9
|
import { Config, SystemStatus } from '@dxos/client';
|
|
10
10
|
|
|
11
11
|
import { createClient, createClientContextProvider } from '../testing/util';
|
|
12
|
-
|
|
13
12
|
import { useConfig } from './useConfig';
|
|
14
13
|
|
|
15
14
|
// TODO(burdon): Disabled in CI since flaky.
|
package/src/echo/useQueue.ts
CHANGED
|
@@ -19,11 +19,10 @@ export type UseQueueOptions = {
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Polls the given Edge queue.
|
|
22
|
+
* @deprecated Use `useQuery` instead.
|
|
22
23
|
*/
|
|
23
|
-
// TODO(burdon): Replace polling with socket?
|
|
24
24
|
// TODO(dmaretskyi): Move into client package.
|
|
25
25
|
// TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.
|
|
26
|
-
// TODO(ZaymonFC): If queue is unchanged returned object should be refferentially stable on poll.
|
|
27
26
|
export const useQueue = <T extends Entity.Unknown>(
|
|
28
27
|
queueDxn?: DXN,
|
|
29
28
|
options: UseQueueOptions = {},
|
|
@@ -10,7 +10,6 @@ import { type SpaceId } from '@dxos/client/echo';
|
|
|
10
10
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
11
11
|
|
|
12
12
|
import { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';
|
|
13
|
-
|
|
14
13
|
import { useSpace } from './useSpaces';
|
|
15
14
|
|
|
16
15
|
// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.
|
|
@@ -6,19 +6,18 @@ import { act, renderHook } from '@testing-library/react';
|
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { createClient, createClientContextProvider } from '../testing/util';
|
|
9
|
-
|
|
10
9
|
import { useSpace, useSpaces } from './useSpaces';
|
|
11
10
|
|
|
12
11
|
describe('useSpaces', () => {
|
|
13
12
|
test('lists existing spaces', async () => {
|
|
14
|
-
const { client } = await createClient({ createIdentity: true });
|
|
13
|
+
const { client } = await createClient({ createIdentity: true, createSpace: true });
|
|
15
14
|
const wrapper = await createClientContextProvider(client);
|
|
16
15
|
const { result } = renderHook(() => useSpaces(), { wrapper });
|
|
17
16
|
expect(result.current.length).to.eq(1);
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
test('updates when new spaces are created', async () => {
|
|
21
|
-
const { client } = await createClient({ createIdentity: true });
|
|
20
|
+
const { client } = await createClient({ createIdentity: true, createSpace: true });
|
|
22
21
|
const wrapper = await createClientContextProvider(client);
|
|
23
22
|
const { result, rerender } = renderHook(() => useSpaces(), { wrapper });
|
|
24
23
|
expect(result.current.length).to.eq(1);
|
|
@@ -31,20 +30,14 @@ describe('useSpaces', () => {
|
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
describe('useSpace', () => {
|
|
34
|
-
test('
|
|
35
|
-
const { client } = await createClient();
|
|
33
|
+
test('returns undefined when no id provided', async () => {
|
|
34
|
+
const { client } = await createClient({ createIdentity: true });
|
|
36
35
|
const wrapper = await createClientContextProvider(client);
|
|
37
|
-
const { result
|
|
36
|
+
const { result } = renderHook(() => useSpace(undefined), { wrapper });
|
|
38
37
|
expect(result.current).to.be.undefined;
|
|
39
|
-
await act(async () => {
|
|
40
|
-
await client.halo.createIdentity();
|
|
41
|
-
await client.spaces.waitUntilReady();
|
|
42
|
-
});
|
|
43
|
-
rerender();
|
|
44
|
-
expect(result.current).to.not.be.undefined;
|
|
45
38
|
});
|
|
46
39
|
|
|
47
|
-
test('gets space by
|
|
40
|
+
test('gets space by id', async () => {
|
|
48
41
|
const { client, space } = await createClient({ createIdentity: true, createSpace: true });
|
|
49
42
|
const wrapper = await createClientContextProvider(client);
|
|
50
43
|
const { result } = renderHook(() => useSpace(space!.id), { wrapper });
|
package/src/echo/useSpaces.ts
CHANGED
|
@@ -2,61 +2,46 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useState } from 'react';
|
|
6
|
-
|
|
7
5
|
import { PublicKey } from '@dxos/client';
|
|
8
6
|
import { type Space, type SpaceId, SpaceState } from '@dxos/client/echo';
|
|
9
|
-
import {
|
|
7
|
+
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
10
8
|
|
|
11
9
|
import { useClient } from '../client';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Get a specific Space using its id.
|
|
15
13
|
* The space is not guaranteed to be in the ready state.
|
|
16
|
-
* Returns
|
|
14
|
+
* Returns undefined if no id is provided.
|
|
17
15
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
18
16
|
*
|
|
19
|
-
* @param spaceId the id of the space to look for
|
|
17
|
+
* @param spaceId the id of the space to look for.
|
|
20
18
|
*/
|
|
21
19
|
// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.
|
|
22
20
|
// When initially joining a space that is all that is returned.
|
|
23
21
|
export const useSpace = (spaceId?: SpaceId | PublicKey): Space | undefined => {
|
|
24
22
|
const client = useClient();
|
|
25
23
|
const spaces = useMulticastObservable<Space[]>(client.spaces);
|
|
26
|
-
|
|
24
|
+
if (!spaceId) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return;
|
|
28
|
+
return spaces.find((space) => {
|
|
29
|
+
if (spaceId instanceof PublicKey) {
|
|
30
|
+
return space.key.equals(spaceId);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [client, spaceId]);
|
|
37
|
-
|
|
38
|
-
if (spaceId) {
|
|
39
|
-
return spaces.find((space) => {
|
|
40
|
-
if (spaceId instanceof PublicKey) {
|
|
41
|
-
return space.key.equals(spaceId);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return space.id === spaceId;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (ready && client.halo.identity.get()) {
|
|
49
|
-
return client.spaces.default;
|
|
50
|
-
}
|
|
33
|
+
return space.id === spaceId;
|
|
34
|
+
});
|
|
51
35
|
};
|
|
52
36
|
|
|
53
37
|
/**
|
|
54
38
|
* Get a Space database by the id of the space.
|
|
55
39
|
* The space is not guaranteed to be in the ready state.
|
|
56
|
-
* Returns
|
|
40
|
+
* Returns undefined if no id is provided.
|
|
57
41
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
58
42
|
*
|
|
59
|
-
* @param spaceId the id of the space to look for
|
|
43
|
+
* @param spaceId the id of the space to look for.
|
|
44
|
+
* @deprecated Use useSpace.
|
|
60
45
|
*/
|
|
61
46
|
export const useDatabase = (spaceId?: SpaceId): Space['db'] | undefined => {
|
|
62
47
|
const space = useSpace(spaceId);
|
|
@@ -74,7 +59,7 @@ export type UseSpacesProps = {
|
|
|
74
59
|
* Get all Spaces available to current user.
|
|
75
60
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
76
61
|
* By default, only ready spaces are returned.
|
|
77
|
-
* @returns an array of Spaces
|
|
62
|
+
* @returns an array of Spaces.
|
|
78
63
|
*/
|
|
79
64
|
export const useSpaces = ({ all = false }: UseSpacesProps = {}): Space[] => {
|
|
80
65
|
const client = useClient();
|
package/src/echo/useSyncState.ts
CHANGED
|
@@ -8,11 +8,12 @@ import { type PeerSyncState, type Space, type SpaceSyncStateMap } from '@dxos/cl
|
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { type SpaceId } from '@dxos/keys';
|
|
10
10
|
import { EdgeService } from '@dxos/protocols';
|
|
11
|
+
import { compositeKey } from '@dxos/util';
|
|
11
12
|
|
|
12
13
|
import { useClient } from '../client';
|
|
13
14
|
|
|
14
15
|
const isEdgePeerId = (peerId: string, spaceId: SpaceId) =>
|
|
15
|
-
peerId.startsWith(
|
|
16
|
+
peerId.startsWith(compositeKey(EdgeService.AUTOMERGE_REPLICATOR, spaceId));
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Hook Subscribes to sync state for each space.
|
|
@@ -9,12 +9,11 @@ import { Config, PublicKey } from '@dxos/client';
|
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { Button } from '@dxos/react-ui';
|
|
12
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
12
13
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
13
|
-
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
14
14
|
|
|
15
15
|
import { useClient } from '../client';
|
|
16
16
|
import { withClientProvider } from '../testing';
|
|
17
|
-
|
|
18
17
|
import { useCredentials } from './useCredentials';
|
|
19
18
|
import { useIdentity } from './useIdentity';
|
|
20
19
|
|
|
@@ -105,7 +104,7 @@ const Test = () => {
|
|
|
105
104
|
|
|
106
105
|
return (
|
|
107
106
|
<>
|
|
108
|
-
<div className='
|
|
107
|
+
<div className='mb-4 flex gap-2'>
|
|
109
108
|
<Button disabled={!!identity} onClick={handleCreateIdentity}>
|
|
110
109
|
Create Identity
|
|
111
110
|
</Button>
|
|
@@ -116,10 +115,8 @@ const Test = () => {
|
|
|
116
115
|
Authenticate with Passkey
|
|
117
116
|
</Button>
|
|
118
117
|
</div>
|
|
119
|
-
<div className='flex flex-col min-w-[28rem] divide-y divide-separator border border-separator rounded'>
|
|
120
|
-
<
|
|
121
|
-
{JSON.stringify({ identity, credentials: credentials.length }, null, 2)}
|
|
122
|
-
</SyntaxHighlighter>
|
|
118
|
+
<div className='flex flex-col min-w-[28rem] divide-y divide-separator border border-separator rounded-sm'>
|
|
119
|
+
<JsonHighlighter data={{ identity, credentials: credentials.length }} />
|
|
123
120
|
</div>
|
|
124
121
|
</>
|
|
125
122
|
);
|
|
@@ -6,7 +6,6 @@ import { renderHook } from '@testing-library/react';
|
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { createClient, createClientContextProvider } from '../testing/util';
|
|
9
|
-
|
|
10
9
|
import { useDevices } from './useDevices';
|
|
11
10
|
|
|
12
11
|
describe('useDevices', () => {
|
|
@@ -7,12 +7,11 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import { Input } from '@dxos/react-ui';
|
|
10
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
11
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
|
-
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
12
12
|
|
|
13
13
|
import { useClient } from '../client';
|
|
14
14
|
import { useSpace } from '../echo';
|
|
15
|
-
|
|
16
15
|
import { type ClientRepeatedComponentProps, ClientRepeater } from './ClientRepeater';
|
|
17
16
|
|
|
18
17
|
const meta = {
|
|
@@ -24,9 +23,7 @@ export default meta;
|
|
|
24
23
|
|
|
25
24
|
type Story = StoryObj<typeof meta>;
|
|
26
25
|
|
|
27
|
-
const JsonPanel = ({ value }: { value: any }) =>
|
|
28
|
-
<SyntaxHighlighter language='json'>{JSON.stringify(value, undefined, 2)}</SyntaxHighlighter>
|
|
29
|
-
);
|
|
26
|
+
const JsonPanel = ({ value }: { value: any }) => <JsonHighlighter data={value} />;
|
|
30
27
|
|
|
31
28
|
const ClientStory = () => {
|
|
32
29
|
const client = useClient();
|
|
@@ -47,8 +44,8 @@ const ClientSpace = ({ spaceId }: ClientRepeatedComponentProps) => {
|
|
|
47
44
|
placeholder='Name'
|
|
48
45
|
value={space.properties.name}
|
|
49
46
|
onChange={(event) =>
|
|
50
|
-
Obj.
|
|
51
|
-
|
|
47
|
+
Obj.update(space.properties, (obj) => {
|
|
48
|
+
obj.name = event.target.value;
|
|
52
49
|
})
|
|
53
50
|
}
|
|
54
51
|
/>
|
|
@@ -7,12 +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 {
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
11
|
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
12
12
|
|
|
13
13
|
import { ClientProvider } from '../client';
|
|
14
14
|
import { type SpaceId } from '../echo';
|
|
15
|
-
|
|
16
15
|
import { type WithClientProviderProps } from './withClientProvider';
|
|
17
16
|
|
|
18
17
|
export type ClientRepeatedComponentProps = { id: number; count: number; spaceId?: SpaceId };
|
|
@@ -26,7 +25,7 @@ export type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {
|
|
|
26
25
|
controls?: FC<ClientRepeaterControlsProps>;
|
|
27
26
|
count?: number;
|
|
28
27
|
clients?: Client[];
|
|
29
|
-
types?: Type.
|
|
28
|
+
types?: Type.AnyObj[];
|
|
30
29
|
args?: Omit<P, 'id' | 'count'>;
|
|
31
30
|
} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onCreateSpace'>;
|
|
32
31
|
|
|
@@ -67,7 +66,7 @@ export const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: Cl
|
|
|
67
66
|
|
|
68
67
|
if (createSpace) {
|
|
69
68
|
const client = clients[0];
|
|
70
|
-
const space = await client.spaces.create({ name:
|
|
69
|
+
const space = await client.spaces.create({ name: random.commerce.productName() });
|
|
71
70
|
setSpaceId(space.id);
|
|
72
71
|
await onCreateSpace?.({ client, space }, {});
|
|
73
72
|
await Promise.all(clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })));
|
package/src/testing/util.tsx
CHANGED
|
@@ -7,30 +7,28 @@ import React from 'react';
|
|
|
7
7
|
import { expect, within } from 'storybook/test';
|
|
8
8
|
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { render } from '@dxos/storybook-utils';
|
|
10
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
11
|
+
import { withLayout, withTheme, Loading } from '@dxos/react-ui/testing';
|
|
13
12
|
|
|
14
13
|
import { useClient } from '../client';
|
|
15
14
|
import { type Space, useSpaces } from '../echo';
|
|
16
|
-
|
|
17
15
|
import { type WithClientProviderProps, withClientProvider, withMultiClientProvider } from './withClientProvider';
|
|
18
16
|
|
|
19
17
|
const SpaceInfo = ({ space }: { space: Space }) => {
|
|
20
18
|
const name = space.isOpen ? space.properties.name : '';
|
|
21
|
-
return <
|
|
19
|
+
return <JsonHighlighter data={{ id: space.id, name }} />;
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
const DefaultStory = () => {
|
|
25
23
|
const client = useClient();
|
|
26
24
|
const spaces = useSpaces();
|
|
27
25
|
if (!client) {
|
|
28
|
-
return
|
|
26
|
+
return <Loading data={{ client: !!client }} />;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
return (
|
|
32
30
|
<div className='flex flex-col divide-y divide-separator border border-separator'>
|
|
33
|
-
<
|
|
31
|
+
<JsonHighlighter data={client.toJSON()} />
|
|
34
32
|
{spaces.map((space) => (
|
|
35
33
|
<SpaceInfo key={space.id} space={space} />
|
|
36
34
|
))}
|
|
@@ -40,7 +38,7 @@ const DefaultStory = () => {
|
|
|
40
38
|
|
|
41
39
|
const meta = {
|
|
42
40
|
title: 'sdk/react-client/withClientProvider',
|
|
43
|
-
render:
|
|
41
|
+
render: DefaultStory,
|
|
44
42
|
decorators: [withTheme()],
|
|
45
43
|
tags: ['test'],
|
|
46
44
|
} satisfies Meta<typeof DefaultStory>;
|