@dxos/react-client 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5
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 +9 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/chunk-BVDNYEYI.mjs +179 -0
- package/dist/lib/browser/chunk-BVDNYEYI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BXOLJYAY.mjs → chunk-LO3TU5CK.mjs} +4 -4
- package/dist/lib/browser/chunk-LO3TU5CK.mjs.map +7 -0
- package/dist/lib/browser/chunk-PFF63FPR.mjs +16 -0
- package/dist/lib/browser/chunk-PFF63FPR.mjs.map +7 -0
- package/dist/lib/browser/chunk-TSF6Y5VB.mjs +8 -0
- package/dist/lib/browser/chunk-TSF6Y5VB.mjs.map +7 -0
- package/dist/lib/browser/devtools/index.mjs +2 -1
- package/dist/lib/browser/devtools/index.mjs.map +1 -1
- package/dist/lib/browser/echo/index.mjs +58 -121
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/halo/index.mjs +4 -4
- package/dist/lib/browser/halo/index.mjs.map +2 -2
- package/dist/lib/browser/index.mjs +114 -12
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invitations/index.mjs +1 -1
- package/dist/lib/browser/mesh/index.mjs +2 -1
- package/dist/lib/browser/mesh/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +121 -149
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-373DPHEQ.mjs +10 -0
- package/dist/lib/node-esm/chunk-373DPHEQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-256IHY6F.mjs → chunk-AQJH2UNZ.mjs} +4 -4
- package/dist/lib/node-esm/chunk-AQJH2UNZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NETTSER2.mjs +17 -0
- package/dist/lib/node-esm/chunk-NETTSER2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VSA674XR.mjs +180 -0
- package/dist/lib/node-esm/chunk-VSA674XR.mjs.map +7 -0
- package/dist/lib/node-esm/devtools/index.mjs +2 -1
- package/dist/lib/node-esm/devtools/index.mjs.map +1 -1
- package/dist/lib/node-esm/echo/index.mjs +58 -121
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/halo/index.mjs +4 -4
- package/dist/lib/node-esm/halo/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +114 -12
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invitations/index.mjs +1 -1
- package/dist/lib/node-esm/mesh/index.mjs +2 -1
- package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +121 -149
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/client/ClientProvider.d.ts +0 -10
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +2 -2
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useMembers.d.ts +2 -2
- package/dist/types/src/echo/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useQueue.d.ts +3 -2
- package/dist/types/src/echo/useQueue.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
- package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
- package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
- package/dist/types/src/echo/useSpaces.d.ts +18 -9
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/src/echo/useSubscription.d.ts +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 +5 -5
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
- package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +6 -5
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts +6 -10
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/context.d.ts +4 -2
- 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 +5 -9
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +8 -9
- 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 +3 -2
- package/package.json +35 -33
- package/src/client/ClientProvider.test.tsx +0 -1
- package/src/client/ClientProvider.tsx +29 -48
- package/src/client/useConfig.test.tsx +0 -1
- package/src/echo/index.ts +2 -2
- package/src/echo/useMembers.ts +5 -3
- package/src/echo/useQueue.ts +3 -4
- package/src/echo/useSpaceInvitations.ts +9 -5
- package/src/echo/useSpaceProperties.ts +28 -0
- package/src/echo/useSpaces.test.tsx +7 -14
- package/src/echo/useSpaces.ts +31 -30
- package/src/echo/useSubscription.ts +1 -1
- package/src/echo/useSyncState.ts +4 -3
- package/src/halo/Passkey.stories.tsx +15 -14
- package/src/halo/useDevices.test.tsx +0 -1
- package/src/invitations/useInvitationStatus.ts +9 -8
- package/src/testing/ClientRepeater.stories.tsx +19 -12
- package/src/testing/ClientRepeater.tsx +31 -40
- package/src/testing/context.tsx +4 -3
- package/src/testing/util.tsx +0 -1
- package/src/testing/withClientProvider.stories.tsx +30 -17
- package/src/testing/withClientProvider.tsx +74 -92
- package/tsconfig.json +3 -6
- package/typedoc.json +1 -1
- package/vitest.config.ts +10 -16
- package/.swc/plugins/v7_linux_x86_64_13.0.0/c614d7475354583212fbd7669acbae95b9832c305bf51bdaabe2e6de05abb6bf +0 -0
- package/dist/lib/browser/chunk-BXOLJYAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-FQAPI3I4.mjs +0 -312
- package/dist/lib/browser/chunk-FQAPI3I4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-256IHY6F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MNTJNI2M.mjs +0 -314
- package/dist/lib/node-esm/chunk-MNTJNI2M.mjs.map +0 -7
- package/dist/types/src/echo/useQuery.d.ts +0 -11
- package/dist/types/src/echo/useQuery.d.ts.map +0 -1
- package/dist/types/src/echo/useQuery.test.d.ts +0 -2
- package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
- package/dist/types/src/echo/useSchema.d.ts +0 -8
- package/dist/types/src/echo/useSchema.d.ts.map +0 -1
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
- package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
- package/src/echo/useQuery.test.tsx +0 -129
- package/src/echo/useQuery.ts +0 -56
- package/src/echo/useSchema.ts +0 -54
- package/src/playwright/playwright.config.ts +0 -17
- package/src/playwright/smoke.spec.ts +0 -24
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
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcfe5033a5",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
"./devtools": {
|
|
@@ -85,44 +89,42 @@
|
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
91
|
"dependencies": {
|
|
88
|
-
"
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/echo-
|
|
96
|
-
"@dxos/
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/log": "0.8.4-main.
|
|
100
|
-
"@dxos/
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/react-hooks": "0.8.4-main.f5c0578",
|
|
103
|
-
"@dxos/util": "0.8.4-main.f5c0578"
|
|
92
|
+
"@dxos/client": "0.8.4-main.fcfe5033a5",
|
|
93
|
+
"@dxos/codec-protobuf": "0.8.4-main.fcfe5033a5",
|
|
94
|
+
"@dxos/async": "0.8.4-main.fcfe5033a5",
|
|
95
|
+
"@dxos/context": "0.8.4-main.fcfe5033a5",
|
|
96
|
+
"@dxos/config": "0.8.4-main.fcfe5033a5",
|
|
97
|
+
"@dxos/debug": "0.8.4-main.fcfe5033a5",
|
|
98
|
+
"@dxos/echo": "0.8.4-main.fcfe5033a5",
|
|
99
|
+
"@dxos/echo-react": "0.8.4-main.fcfe5033a5",
|
|
100
|
+
"@dxos/invariant": "0.8.4-main.fcfe5033a5",
|
|
101
|
+
"@dxos/node-std": "0.8.4-main.fcfe5033a5",
|
|
102
|
+
"@dxos/protocols": "0.8.4-main.fcfe5033a5",
|
|
103
|
+
"@dxos/log": "0.8.4-main.fcfe5033a5",
|
|
104
|
+
"@dxos/react-hooks": "0.8.4-main.fcfe5033a5",
|
|
105
|
+
"@dxos/util": "0.8.4-main.fcfe5033a5"
|
|
104
106
|
},
|
|
105
107
|
"devDependencies": {
|
|
106
|
-
"@types/react": "~
|
|
107
|
-
"@types/react-dom": "~
|
|
108
|
-
"react": "~
|
|
109
|
-
"react-dom": "~
|
|
108
|
+
"@types/react": "~19.2.7",
|
|
109
|
+
"@types/react-dom": "~19.2.3",
|
|
110
|
+
"react": "~19.2.3",
|
|
111
|
+
"react-dom": "~19.2.3",
|
|
110
112
|
"typedoc": "0.28.1",
|
|
111
|
-
"@dxos/
|
|
112
|
-
"@dxos/
|
|
113
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
114
|
-
"@dxos/
|
|
115
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
116
|
-
"@dxos/
|
|
113
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
114
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
115
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
|
|
116
|
+
"@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
|
|
117
|
+
"@dxos/test-utils": "0.8.4-main.fcfe5033a5",
|
|
118
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
117
119
|
},
|
|
118
120
|
"peerDependencies": {
|
|
119
|
-
"react": "~
|
|
120
|
-
"react-dom": "~
|
|
121
|
+
"react": "~19.2.3",
|
|
122
|
+
"react-dom": "~19.2.3"
|
|
121
123
|
},
|
|
122
124
|
"optionalDependencies": {
|
|
123
|
-
"@dxos/random": "0.8.4-main.
|
|
124
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
125
|
-
"@dxos/
|
|
125
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
126
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
127
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
126
128
|
},
|
|
127
129
|
"publishConfig": {
|
|
128
130
|
"access": "public"
|
|
@@ -13,13 +13,11 @@ import React, {
|
|
|
13
13
|
|
|
14
14
|
import { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';
|
|
15
15
|
import { type Config } from '@dxos/config';
|
|
16
|
-
import { registerSignalsRuntime } from '@dxos/echo-signals/react';
|
|
17
16
|
import { log } from '@dxos/log';
|
|
18
|
-
import { useControlledState } from '@dxos/react-hooks';
|
|
17
|
+
import { useAsyncEffect, useControlledState } from '@dxos/react-hooks';
|
|
19
18
|
import { type MaybePromise, type Provider, getAsyncProviderValue } from '@dxos/util';
|
|
20
19
|
|
|
21
20
|
import { printBanner } from '../banner';
|
|
22
|
-
|
|
23
21
|
import { ClientContext, type ClientContextProps } from './context';
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -56,12 +54,6 @@ export type ClientProviderProps = Omit<ClientOptions, 'config' | 'services'> &
|
|
|
56
54
|
*/
|
|
57
55
|
fallback?: FunctionComponent<Partial<ClientContextProps>>;
|
|
58
56
|
|
|
59
|
-
/**
|
|
60
|
-
* Enable (by default) registration of Preact signals runtime for reactive ECHO objects.
|
|
61
|
-
* @see https://www.npmjs.com/package/@preact/signals-react
|
|
62
|
-
*/
|
|
63
|
-
signalsRuntime?: boolean;
|
|
64
|
-
|
|
65
57
|
/**
|
|
66
58
|
* Skip the DXOS banner.
|
|
67
59
|
*/
|
|
@@ -81,24 +73,17 @@ export const ClientProvider = forwardRef<Client | undefined, ClientProviderProps
|
|
|
81
73
|
(
|
|
82
74
|
{
|
|
83
75
|
children,
|
|
84
|
-
config:
|
|
85
|
-
client:
|
|
86
|
-
services:
|
|
87
|
-
status:
|
|
76
|
+
config: configProp,
|
|
77
|
+
client: clientProp,
|
|
78
|
+
services: servicesProp,
|
|
79
|
+
status: statusProp,
|
|
88
80
|
fallback: Fallback = () => null,
|
|
89
|
-
signalsRuntime = true,
|
|
90
81
|
noBanner,
|
|
91
82
|
onInitialized,
|
|
92
83
|
...options
|
|
93
84
|
},
|
|
94
85
|
forwardedRef,
|
|
95
86
|
) => {
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
// TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.
|
|
98
|
-
// Unfortunately, async import seemed to break signals React instrumentation.
|
|
99
|
-
signalsRuntime && registerSignalsRuntime();
|
|
100
|
-
}, []);
|
|
101
|
-
|
|
102
87
|
// The client is initialized asynchronously.
|
|
103
88
|
// If an error occurs during initialization, it is caught and the state is set.
|
|
104
89
|
// This allows the error to be thrown in the render method.
|
|
@@ -109,13 +94,13 @@ export const ClientProvider = forwardRef<Client | undefined, ClientProviderProps
|
|
|
109
94
|
throw error;
|
|
110
95
|
}
|
|
111
96
|
|
|
112
|
-
const [client, setClient] = useState(
|
|
97
|
+
const [client, setClient] = useState(clientProp instanceof Client ? clientProp : undefined);
|
|
113
98
|
|
|
114
99
|
// Provide external access.
|
|
115
100
|
useImperativeHandle(forwardedRef, () => client, [client]);
|
|
116
101
|
|
|
117
102
|
// Client status subscription.
|
|
118
|
-
const [status, setStatus] = useControlledState(
|
|
103
|
+
const [status, setStatus] = useControlledState(statusProp);
|
|
119
104
|
useEffect(() => {
|
|
120
105
|
if (!client) {
|
|
121
106
|
return;
|
|
@@ -126,7 +111,7 @@ export const ClientProvider = forwardRef<Client | undefined, ClientProviderProps
|
|
|
126
111
|
}, [client]);
|
|
127
112
|
|
|
128
113
|
// Create and/or initialize client.
|
|
129
|
-
|
|
114
|
+
useAsyncEffect(async () => {
|
|
130
115
|
let disposed = false;
|
|
131
116
|
const initialize = async (client: Client) => {
|
|
132
117
|
if (!client.initialized) {
|
|
@@ -141,42 +126,38 @@ export const ClientProvider = forwardRef<Client | undefined, ClientProviderProps
|
|
|
141
126
|
}
|
|
142
127
|
|
|
143
128
|
setClient(client);
|
|
144
|
-
|
|
145
129
|
if (!noBanner) {
|
|
146
130
|
printBanner(client);
|
|
147
131
|
}
|
|
148
132
|
};
|
|
149
133
|
|
|
150
134
|
let client: Client;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await initialize(client);
|
|
166
|
-
}
|
|
167
|
-
} catch (err) {
|
|
168
|
-
if (!disposed) {
|
|
169
|
-
log.catch(err);
|
|
170
|
-
}
|
|
135
|
+
try {
|
|
136
|
+
if (clientProp) {
|
|
137
|
+
// Asynchronously request client.
|
|
138
|
+
client = await getAsyncProviderValue(clientProp);
|
|
139
|
+
await initialize(client);
|
|
140
|
+
} else {
|
|
141
|
+
// Asynchronously construct client (config may be undefined).
|
|
142
|
+
const config = await getAsyncProviderValue(configProp);
|
|
143
|
+
log('resolved config', { config });
|
|
144
|
+
const services = await getAsyncProviderValue(servicesProp, config);
|
|
145
|
+
log('created services', { services });
|
|
146
|
+
client = new Client({ config, services, ...options });
|
|
147
|
+
log('created client');
|
|
148
|
+
await initialize(client);
|
|
171
149
|
}
|
|
172
|
-
})
|
|
150
|
+
} catch (err) {
|
|
151
|
+
if (!disposed) {
|
|
152
|
+
log.catch(err);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
173
155
|
|
|
174
156
|
return () => {
|
|
175
157
|
log('clean up');
|
|
176
158
|
disposed = true;
|
|
177
|
-
clearTimeout(t);
|
|
178
159
|
// Only destroy if the client is not provided by the parent.
|
|
179
|
-
if (!
|
|
160
|
+
if (!clientProp) {
|
|
180
161
|
void client
|
|
181
162
|
?.destroy()
|
|
182
163
|
.then(() => {
|
|
@@ -185,7 +166,7 @@ export const ClientProvider = forwardRef<Client | undefined, ClientProviderProps
|
|
|
185
166
|
.catch((err) => log.catch(err));
|
|
186
167
|
}
|
|
187
168
|
};
|
|
188
|
-
}, [
|
|
169
|
+
}, [configProp, clientProp, servicesProp, noBanner]);
|
|
189
170
|
|
|
190
171
|
if (!client?.initialized || status !== SystemStatus.ACTIVE) {
|
|
191
172
|
return <Fallback client={client} status={status} />;
|
|
@@ -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/index.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from '@dxos/client/echo';
|
|
6
|
+
export * from '@dxos/echo-react';
|
|
6
7
|
|
|
7
8
|
export * from './useMembers';
|
|
8
|
-
export * from './useQuery';
|
|
9
9
|
export * from './useQueue';
|
|
10
|
-
export * from './useSchema';
|
|
11
10
|
export * from './useSpaces';
|
|
12
11
|
export * from './useSpaceInvitations';
|
|
12
|
+
export * from './useSpaceProperties';
|
|
13
13
|
export * from './useSubscription';
|
|
14
14
|
export * from './useSyncState';
|
package/src/echo/useMembers.ts
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { MulticastObservable } from '@dxos/async';
|
|
6
|
-
import { type
|
|
6
|
+
import { PublicKey, type PublicKeyLike } from '@dxos/client';
|
|
7
7
|
import { HaloSpaceMember, type SpaceMember } from '@dxos/client/echo';
|
|
8
8
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
9
9
|
|
|
10
10
|
import { useSpaces } from './useSpaces';
|
|
11
11
|
|
|
12
|
-
export const useMembers = (spaceKey:
|
|
12
|
+
export const useMembers = (spaceKey: PublicKeyLike | undefined): SpaceMember[] => {
|
|
13
13
|
// TODO(dmaretskyi): useSpace hook for spaces that are not ready.
|
|
14
14
|
const spaces = useSpaces({ all: true });
|
|
15
|
-
const space = spaceKey
|
|
15
|
+
const space = spaceKey
|
|
16
|
+
? spaces.find((space) => (spaceKey instanceof PublicKey ? space.key.equals(spaceKey) : space.id === spaceKey))
|
|
17
|
+
: undefined;
|
|
16
18
|
|
|
17
19
|
// EMPTY_OBSERVABLE needs to be a stable reference to avoid re-subscribing on every render.
|
|
18
20
|
const members = useMulticastObservable(space?.members ?? MulticastObservable.empty()) ?? [];
|
package/src/echo/useQueue.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useRef } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Queue } from '@dxos/client/echo';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
|
-
import { type
|
|
9
|
+
import { type Entity } from '@dxos/echo';
|
|
10
10
|
import { type DXN } from '@dxos/keys';
|
|
11
11
|
|
|
12
12
|
import { useClient } from '../client';
|
|
@@ -19,12 +19,11 @@ 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
|
-
|
|
27
|
-
export const useQueue = <T extends Obj.Any | Relation.Any>(
|
|
26
|
+
export const useQueue = <T extends Entity.Unknown>(
|
|
28
27
|
queueDxn?: DXN,
|
|
29
28
|
options: UseQueueOptions = {},
|
|
30
29
|
): Queue<T> | undefined => {
|
|
@@ -6,19 +6,23 @@ 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/client/echo';
|
|
9
10
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
10
11
|
|
|
11
12
|
import { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';
|
|
12
|
-
|
|
13
13
|
import { useSpace } from './useSpaces';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.
|
|
16
|
+
// When initially joining a space that is all that is returned.
|
|
17
|
+
export const useSpaceInvitations = (spaceId?: SpaceId | PublicKey): CancellableInvitationObservable[] => {
|
|
18
|
+
const space = useSpace(spaceId);
|
|
17
19
|
return useMulticastObservable(space?.invitations ?? MulticastObservable.empty()) ?? [];
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
// TODO(wittjosiah): Currently unable to remove `PublicKey` from this api.
|
|
23
|
+
// When initially joining a space that is all that is returned.
|
|
24
|
+
export const useSpaceInvitation = (spaceId?: SpaceId | PublicKey, invitationId?: string) => {
|
|
25
|
+
const invitations = useSpaceInvitations(spaceId);
|
|
22
26
|
const invitation = useMemo(
|
|
23
27
|
() => invitations.find((invitation) => invitation.get().invitationId === invitationId),
|
|
24
28
|
[invitations],
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { MulticastObservable } from '@dxos/async';
|
|
6
|
+
import { type SpaceProperties, SpaceState } from '@dxos/client/echo';
|
|
7
|
+
import { type Key, type Obj } from '@dxos/echo';
|
|
8
|
+
import { type ObjectUpdateCallback, useObject } from '@dxos/echo-react';
|
|
9
|
+
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
10
|
+
|
|
11
|
+
import { useSpace } from './useSpaces';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Subscribe to a space's properties with reactive updates.
|
|
15
|
+
* Returns undefined if the space is undefined or not ready yet.
|
|
16
|
+
* Automatically waits for the space to be ready before returning properties.
|
|
17
|
+
*
|
|
18
|
+
* @param spaceId - The space ID to get properties from (can be undefined).
|
|
19
|
+
* @returns A tuple of [snapshot, updateCallback] or [undefined, no-op] if not ready.
|
|
20
|
+
*/
|
|
21
|
+
export const useSpaceProperties = (
|
|
22
|
+
spaceId: Key.SpaceId | undefined,
|
|
23
|
+
): [Obj.Snapshot<SpaceProperties> | undefined, ObjectUpdateCallback<SpaceProperties>] => {
|
|
24
|
+
const space = useSpace(spaceId);
|
|
25
|
+
const spaceState = useMulticastObservable(space?.state ?? MulticastObservable.empty());
|
|
26
|
+
const properties = spaceState === SpaceState.SPACE_READY ? space?.properties : undefined;
|
|
27
|
+
return useObject(properties);
|
|
28
|
+
};
|
|
@@ -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,23 +30,17 @@ 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
|
-
const { result } = renderHook(() => useSpace(space!.
|
|
43
|
+
const { result } = renderHook(() => useSpace(space!.id), { wrapper });
|
|
51
44
|
expect(result.current).to.not.be.undefined;
|
|
52
45
|
});
|
|
53
46
|
});
|
package/src/echo/useSpaces.ts
CHANGED
|
@@ -2,51 +2,52 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { type PublicKeyLike } from '@dxos/client';
|
|
8
|
-
import { type Space, SpaceState } from '@dxos/client/echo';
|
|
5
|
+
import { PublicKey } from '@dxos/client';
|
|
6
|
+
import { type Space, type SpaceId, SpaceState } from '@dxos/client/echo';
|
|
9
7
|
import { useMulticastObservable } from '@dxos/react-hooks';
|
|
10
8
|
|
|
11
9
|
import { useClient } from '../client';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
|
-
* Get a specific Space using its
|
|
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
|
|
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.
|
|
20
|
+
// When initially joining a space that is all that is returned.
|
|
21
|
+
export const useSpace = (spaceId?: SpaceId | PublicKey): Space | undefined => {
|
|
22
22
|
const client = useClient();
|
|
23
23
|
const spaces = useMulticastObservable<Space[]>(client.spaces);
|
|
24
|
-
|
|
24
|
+
if (!spaceId) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
28
|
+
return spaces.find((space) => {
|
|
29
|
+
if (spaceId instanceof PublicKey) {
|
|
30
|
+
return space.key.equals(spaceId);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => clearTimeout(timeout);
|
|
38
|
-
}, [client, spaceKeyLike]);
|
|
39
|
-
|
|
40
|
-
if (spaceKeyLike) {
|
|
41
|
-
return spaces.find((space) => space.key.equals(spaceKeyLike) || space.id === spaceKeyLike);
|
|
42
|
-
}
|
|
33
|
+
return space.id === spaceId;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Get a Space database by the id of the space.
|
|
39
|
+
* The space is not guaranteed to be in the ready state.
|
|
40
|
+
* Returns undefined if no id is provided.
|
|
41
|
+
* Requires a ClientProvider somewhere in the parent tree.
|
|
42
|
+
*
|
|
43
|
+
* @param spaceId the id of the space to look for.
|
|
44
|
+
*/
|
|
45
|
+
export const useDatabase = (spaceId?: SpaceId): Space['db'] | undefined => {
|
|
46
|
+
const space = useSpace(spaceId);
|
|
47
|
+
return space?.db;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
export type
|
|
50
|
+
export type UseSpacesProps = {
|
|
50
51
|
/**
|
|
51
52
|
* Return uninitialized spaces as well.
|
|
52
53
|
*/
|
|
@@ -57,9 +58,9 @@ export type UseSpacesParams = {
|
|
|
57
58
|
* Get all Spaces available to current user.
|
|
58
59
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
59
60
|
* By default, only ready spaces are returned.
|
|
60
|
-
* @returns an array of Spaces
|
|
61
|
+
* @returns an array of Spaces.
|
|
61
62
|
*/
|
|
62
|
-
export const useSpaces = ({ all = false }:
|
|
63
|
+
export const useSpaces = ({ all = false }: UseSpacesProps = {}): Space[] => {
|
|
63
64
|
const client = useClient();
|
|
64
65
|
const spaces = useMulticastObservable<Space[]>(client.spaces);
|
|
65
66
|
|