@dxos/react-client 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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/echo/index.mjs +16 -29
- package/dist/lib/browser/echo/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -45
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/echo/index.mjs +16 -29
- package/dist/lib/node-esm/echo/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +11 -45
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- 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/useSpaces.d.ts +5 -5
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/src/echo/useSyncState.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/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 +2 -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 +2 -5
- package/package.json +24 -25
- package/src/echo/useQueue.ts +1 -0
- package/src/echo/useSpaces.test.tsx +6 -12
- package/src/echo/useSpaces.ts +15 -30
- package/src/echo/useSyncState.ts +2 -1
- package/src/halo/Passkey.stories.tsx +3 -3
- package/src/testing/ClientRepeater.stories.tsx +3 -3
- package/src/testing/ClientRepeater.tsx +1 -1
- package/src/testing/util.tsx +0 -1
- package/src/testing/withClientProvider.stories.tsx +12 -6
- package/src/testing/withClientProvider.tsx +4 -37
- package/typedoc.json +1 -1
- package/vitest.config.ts +0 -2
- 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/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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
layer: library
|
|
2
2
|
language: typescript
|
|
3
3
|
tags:
|
|
4
|
-
- e2e
|
|
5
4
|
- ts-build
|
|
6
5
|
- ts-test
|
|
6
|
+
- ts-test-storybook
|
|
7
7
|
- typedoc
|
|
8
8
|
- pack
|
|
9
9
|
- storybook
|
|
@@ -18,6 +18,3 @@ tasks:
|
|
|
18
18
|
- '--entryPoint=src/mesh/index.ts'
|
|
19
19
|
- '--entryPoint=src/testing/index.ts'
|
|
20
20
|
- '--entryPoint=src/worker.ts'
|
|
21
|
-
test:
|
|
22
|
-
inputs:
|
|
23
|
-
- .storybook/*
|
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.bcb3aa67d6",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -89,21 +89,20 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/debug": "0.8.4-main.
|
|
99
|
-
"@dxos/echo": "0.8.4-main.
|
|
100
|
-
"@dxos/
|
|
101
|
-
"@dxos/log": "0.8.4-main.
|
|
102
|
-
"@dxos/protocols": "0.8.4-main.
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/
|
|
105
|
-
"@dxos/node-std": "0.8.4-main.
|
|
106
|
-
"@dxos/util": "0.8.4-main.bc674ce"
|
|
92
|
+
"@dxos/async": "0.8.4-main.bcb3aa67d6",
|
|
93
|
+
"@dxos/client": "0.8.4-main.bcb3aa67d6",
|
|
94
|
+
"@dxos/codec-protobuf": "0.8.4-main.bcb3aa67d6",
|
|
95
|
+
"@dxos/context": "0.8.4-main.bcb3aa67d6",
|
|
96
|
+
"@dxos/config": "0.8.4-main.bcb3aa67d6",
|
|
97
|
+
"@dxos/echo": "0.8.4-main.bcb3aa67d6",
|
|
98
|
+
"@dxos/debug": "0.8.4-main.bcb3aa67d6",
|
|
99
|
+
"@dxos/echo-react": "0.8.4-main.bcb3aa67d6",
|
|
100
|
+
"@dxos/invariant": "0.8.4-main.bcb3aa67d6",
|
|
101
|
+
"@dxos/log": "0.8.4-main.bcb3aa67d6",
|
|
102
|
+
"@dxos/protocols": "0.8.4-main.bcb3aa67d6",
|
|
103
|
+
"@dxos/react-hooks": "0.8.4-main.bcb3aa67d6",
|
|
104
|
+
"@dxos/util": "0.8.4-main.bcb3aa67d6",
|
|
105
|
+
"@dxos/node-std": "0.8.4-main.bcb3aa67d6"
|
|
107
106
|
},
|
|
108
107
|
"devDependencies": {
|
|
109
108
|
"@types/react": "~19.2.7",
|
|
@@ -111,21 +110,21 @@
|
|
|
111
110
|
"react": "~19.2.3",
|
|
112
111
|
"react-dom": "~19.2.3",
|
|
113
112
|
"typedoc": "0.28.1",
|
|
114
|
-
"@dxos/
|
|
115
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
116
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
117
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
118
|
-
"@dxos/
|
|
119
|
-
"@dxos/
|
|
113
|
+
"@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
|
|
114
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.bcb3aa67d6",
|
|
115
|
+
"@dxos/storybook-utils": "0.8.4-main.bcb3aa67d6",
|
|
116
|
+
"@dxos/test-utils": "0.8.4-main.bcb3aa67d6",
|
|
117
|
+
"@dxos/random": "0.8.4-main.bcb3aa67d6",
|
|
118
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
|
|
120
119
|
},
|
|
121
120
|
"peerDependencies": {
|
|
122
121
|
"react": "~19.2.3",
|
|
123
122
|
"react-dom": "~19.2.3"
|
|
124
123
|
},
|
|
125
124
|
"optionalDependencies": {
|
|
126
|
-
"@dxos/random": "0.8.4-main.
|
|
127
|
-
"@dxos/ui
|
|
128
|
-
"@dxos/
|
|
125
|
+
"@dxos/random": "0.8.4-main.bcb3aa67d6",
|
|
126
|
+
"@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
|
|
127
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
|
|
129
128
|
},
|
|
130
129
|
"publishConfig": {
|
|
131
130
|
"access": "public"
|
package/src/echo/useQueue.ts
CHANGED
|
@@ -11,14 +11,14 @@ import { useSpace, useSpaces } from './useSpaces';
|
|
|
11
11
|
|
|
12
12
|
describe('useSpaces', () => {
|
|
13
13
|
test('lists existing spaces', async () => {
|
|
14
|
-
const { client } = await createClient({ createIdentity: true });
|
|
14
|
+
const { client } = await createClient({ createIdentity: true, createSpace: true });
|
|
15
15
|
const wrapper = await createClientContextProvider(client);
|
|
16
16
|
const { result } = renderHook(() => useSpaces(), { wrapper });
|
|
17
17
|
expect(result.current.length).to.eq(1);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
test('updates when new spaces are created', async () => {
|
|
21
|
-
const { client } = await createClient({ createIdentity: true });
|
|
21
|
+
const { client } = await createClient({ createIdentity: true, createSpace: true });
|
|
22
22
|
const wrapper = await createClientContextProvider(client);
|
|
23
23
|
const { result, rerender } = renderHook(() => useSpaces(), { wrapper });
|
|
24
24
|
expect(result.current.length).to.eq(1);
|
|
@@ -31,20 +31,14 @@ describe('useSpaces', () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe('useSpace', () => {
|
|
34
|
-
test('
|
|
35
|
-
const { client } = await createClient();
|
|
34
|
+
test('returns undefined when no id provided', async () => {
|
|
35
|
+
const { client } = await createClient({ createIdentity: true });
|
|
36
36
|
const wrapper = await createClientContextProvider(client);
|
|
37
|
-
const { result
|
|
37
|
+
const { result } = renderHook(() => useSpace(), { wrapper });
|
|
38
38
|
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
39
|
});
|
|
46
40
|
|
|
47
|
-
test('gets space by
|
|
41
|
+
test('gets space by id', async () => {
|
|
48
42
|
const { client, space } = await createClient({ createIdentity: true, createSpace: true });
|
|
49
43
|
const wrapper = await createClientContextProvider(client);
|
|
50
44
|
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
|
-
const [ready, setReady] = useState(false);
|
|
27
|
-
|
|
28
|
-
useAsyncEffect(async () => {
|
|
29
|
-
// Only wait for ready if looking for the default space.
|
|
30
|
-
if (spaceId) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await client.spaces.waitUntilReady();
|
|
35
|
-
setReady(true);
|
|
36
|
-
}, [client, spaceId]);
|
|
37
24
|
|
|
38
|
-
if (spaceId) {
|
|
39
|
-
return
|
|
40
|
-
if (spaceId instanceof PublicKey) {
|
|
41
|
-
return space.key.equals(spaceId);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return space.id === spaceId;
|
|
45
|
-
});
|
|
25
|
+
if (!spaceId) {
|
|
26
|
+
return undefined;
|
|
46
27
|
}
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
return spaces.find((space) => {
|
|
30
|
+
if (spaceId instanceof PublicKey) {
|
|
31
|
+
return space.key.equals(spaceId);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return space.id === spaceId;
|
|
35
|
+
});
|
|
51
36
|
};
|
|
52
37
|
|
|
53
38
|
/**
|
|
54
39
|
* Get a Space database by the id of the space.
|
|
55
40
|
* The space is not guaranteed to be in the ready state.
|
|
56
|
-
* Returns
|
|
41
|
+
* Returns undefined if no id is provided.
|
|
57
42
|
* Requires a ClientProvider somewhere in the parent tree.
|
|
58
43
|
*
|
|
59
|
-
* @param spaceId the id of the space to look for
|
|
44
|
+
* @param spaceId the id of the space to look for.
|
|
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.
|
|
@@ -105,7 +105,7 @@ const Test = () => {
|
|
|
105
105
|
|
|
106
106
|
return (
|
|
107
107
|
<>
|
|
108
|
-
<div className='
|
|
108
|
+
<div className='mb-4 flex gap-2'>
|
|
109
109
|
<Button disabled={!!identity} onClick={handleCreateIdentity}>
|
|
110
110
|
Create Identity
|
|
111
111
|
</Button>
|
|
@@ -116,7 +116,7 @@ const Test = () => {
|
|
|
116
116
|
Authenticate with Passkey
|
|
117
117
|
</Button>
|
|
118
118
|
</div>
|
|
119
|
-
<div className='flex flex-col min-w-[28rem] divide-y divide-separator border border-separator rounded'>
|
|
119
|
+
<div className='flex flex-col min-w-[28rem] divide-y divide-separator border border-separator rounded-sm'>
|
|
120
120
|
<SyntaxHighlighter language='json'>
|
|
121
121
|
{JSON.stringify({ identity, credentials: credentials.length }, null, 2)}
|
|
122
122
|
</SyntaxHighlighter>
|
|
@@ -148,7 +148,7 @@ const config = new Config({
|
|
|
148
148
|
const meta = {
|
|
149
149
|
title: 'sdk/react-client/Passkeys',
|
|
150
150
|
render: Test,
|
|
151
|
-
decorators: [withClientProvider({ config }), withTheme],
|
|
151
|
+
decorators: [withClientProvider({ config }), withTheme()],
|
|
152
152
|
} satisfies Meta;
|
|
153
153
|
|
|
154
154
|
export default meta;
|
|
@@ -17,7 +17,7 @@ import { type ClientRepeatedComponentProps, ClientRepeater } from './ClientRepea
|
|
|
17
17
|
|
|
18
18
|
const meta = {
|
|
19
19
|
title: 'sdk/react-client/ClientRepeater',
|
|
20
|
-
decorators: [withTheme],
|
|
20
|
+
decorators: [withTheme()],
|
|
21
21
|
} satisfies Meta<typeof Input>;
|
|
22
22
|
|
|
23
23
|
export default meta;
|
|
@@ -47,8 +47,8 @@ const ClientSpace = ({ spaceId }: ClientRepeatedComponentProps) => {
|
|
|
47
47
|
placeholder='Name'
|
|
48
48
|
value={space.properties.name}
|
|
49
49
|
onChange={(event) =>
|
|
50
|
-
Obj.change(space.properties, (
|
|
51
|
-
|
|
50
|
+
Obj.change(space.properties, (obj) => {
|
|
51
|
+
obj.name = event.target.value;
|
|
52
52
|
})
|
|
53
53
|
}
|
|
54
54
|
/>
|
|
@@ -26,7 +26,7 @@ export type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {
|
|
|
26
26
|
controls?: FC<ClientRepeaterControlsProps>;
|
|
27
27
|
count?: number;
|
|
28
28
|
clients?: Client[];
|
|
29
|
-
types?: Type.
|
|
29
|
+
types?: Type.AnyObj[];
|
|
30
30
|
args?: Omit<P, 'id' | 'count'>;
|
|
31
31
|
} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onCreateSpace'>;
|
|
32
32
|
|
package/src/testing/util.tsx
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import { expect, within } from 'storybook/test';
|
|
7
8
|
|
|
8
9
|
import { log } from '@dxos/log';
|
|
9
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
import { withLayout, withTheme, Loading } from '@dxos/react-ui/testing';
|
|
10
11
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
11
|
-
import { render } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { useClient } from '../client';
|
|
14
14
|
import { type Space, useSpaces } from '../echo';
|
|
@@ -24,7 +24,7 @@ const DefaultStory = () => {
|
|
|
24
24
|
const client = useClient();
|
|
25
25
|
const spaces = useSpaces();
|
|
26
26
|
if (!client) {
|
|
27
|
-
return
|
|
27
|
+
return <Loading data={{ client: !!client }} />;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return (
|
|
@@ -39,8 +39,9 @@ const DefaultStory = () => {
|
|
|
39
39
|
|
|
40
40
|
const meta = {
|
|
41
41
|
title: 'sdk/react-client/withClientProvider',
|
|
42
|
-
render:
|
|
43
|
-
decorators: [withTheme],
|
|
42
|
+
render: DefaultStory,
|
|
43
|
+
decorators: [withTheme()],
|
|
44
|
+
tags: ['test'],
|
|
44
45
|
} satisfies Meta<typeof DefaultStory>;
|
|
45
46
|
|
|
46
47
|
export default meta;
|
|
@@ -63,11 +64,16 @@ export const Default: Story = {
|
|
|
63
64
|
parameters: {
|
|
64
65
|
layout: 'centered',
|
|
65
66
|
},
|
|
67
|
+
play: async ({ canvasElement }) => {
|
|
68
|
+
const canvas = within(canvasElement);
|
|
69
|
+
const initializedText = await canvas.findByText(/"initialized": true/i, {}, { timeout: 30_000 });
|
|
70
|
+
await expect(initializedText).toBeVisible();
|
|
71
|
+
},
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
export const Multiple: Story = {
|
|
69
75
|
decorators: [
|
|
70
|
-
withTheme,
|
|
76
|
+
withTheme(),
|
|
71
77
|
withLayout({ classNames: 'grid grid-cols-3' }),
|
|
72
78
|
withMultiClientProvider({ ...clientProps, numClients: 3 }),
|
|
73
79
|
],
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Decorator, type StoryContext } from '@storybook/react';
|
|
6
|
-
import React, {
|
|
7
|
-
import { type FallbackProps, ErrorBoundary as NaturalErrorBoundary } from 'react-error-boundary';
|
|
6
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { Trigger } from '@dxos/async';
|
|
10
9
|
import { type Client } from '@dxos/client';
|
|
11
10
|
import { type Space, type SpaceId } from '@dxos/client/echo';
|
|
12
11
|
import { TestBuilder, performInvitation } from '@dxos/client/testing';
|
|
13
12
|
import { log } from '@dxos/log';
|
|
13
|
+
import { ErrorBoundary } from '@dxos/react-ui';
|
|
14
14
|
import { type MaybePromise } from '@dxos/util';
|
|
15
15
|
|
|
16
16
|
import { ClientProvider, type ClientProviderProps } from '../client';
|
|
@@ -39,8 +39,6 @@ const initializeClient = async (
|
|
|
39
39
|
if (createIdentity || createSpace) {
|
|
40
40
|
if (!client.halo.identity.get()) {
|
|
41
41
|
await client.halo.createIdentity();
|
|
42
|
-
await client.spaces.waitUntilReady();
|
|
43
|
-
await client.spaces.default.waitUntilReady();
|
|
44
42
|
await onCreateIdentity?.({ client }, context);
|
|
45
43
|
}
|
|
46
44
|
}
|
|
@@ -87,7 +85,7 @@ export const withClientProvider = ({
|
|
|
87
85
|
};
|
|
88
86
|
|
|
89
87
|
return (
|
|
90
|
-
<ErrorBoundary>
|
|
88
|
+
<ErrorBoundary name='client-provider'>
|
|
91
89
|
<ClientProvider onInitialized={handleInitialized} {...props}>
|
|
92
90
|
<ClientStory.Provider value={data}>
|
|
93
91
|
<Story />
|
|
@@ -178,7 +176,7 @@ export const withMultiClientProvider = ({
|
|
|
178
176
|
{...props}
|
|
179
177
|
>
|
|
180
178
|
<ClientStory.Provider value={{ index, spaceId }}>
|
|
181
|
-
<ErrorBoundary>
|
|
179
|
+
<ErrorBoundary name='client-provider'>
|
|
182
180
|
<Story />
|
|
183
181
|
</ErrorBoundary>
|
|
184
182
|
</ClientStory.Provider>
|
|
@@ -188,34 +186,3 @@ export const withMultiClientProvider = ({
|
|
|
188
186
|
);
|
|
189
187
|
};
|
|
190
188
|
};
|
|
191
|
-
|
|
192
|
-
const ErrorBoundary = ({ children }: PropsWithChildren) => {
|
|
193
|
-
const [error, setError] = useState<Error>();
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
const handleError = (event: PromiseRejectionEvent) => {
|
|
196
|
-
setError(event.reason);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
window.addEventListener('unhandledrejection', handleError);
|
|
200
|
-
return () => window.removeEventListener('unhandledrejection', handleError);
|
|
201
|
-
}, []);
|
|
202
|
-
|
|
203
|
-
if (error) {
|
|
204
|
-
return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return <NaturalErrorBoundary FallbackComponent={ErrorFallback}>{children}</NaturalErrorBoundary>;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const ErrorFallback = ({ error }: FallbackProps) => {
|
|
211
|
-
const { name, message, stack } =
|
|
212
|
-
error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>
|
|
216
|
-
<h1 className='text-xl text-red-500'>{name}</h1>
|
|
217
|
-
<div className='text-lg'>{message}</div>
|
|
218
|
-
{stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}
|
|
219
|
-
</div>
|
|
220
|
-
);
|
|
221
|
-
};
|
package/typedoc.json
CHANGED
package/vitest.config.ts
CHANGED
|
@@ -11,8 +11,6 @@ export default createConfig({
|
|
|
11
11
|
dirname: typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)),
|
|
12
12
|
node: {
|
|
13
13
|
environment: 'happy-dom',
|
|
14
|
-
// TODO(dmaretskyi): Enabled because client tests were flaky. Remove when that's not the case.
|
|
15
|
-
retry: 2,
|
|
16
14
|
},
|
|
17
15
|
storybook: true,
|
|
18
16
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":";AAQA,wBAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smoke.spec.d.ts","sourceRoot":"","sources":["../../../../src/playwright/smoke.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { defineConfig } from '@playwright/test';
|
|
6
|
-
|
|
7
|
-
import { e2ePreset } from '@dxos/test-utils/playwright';
|
|
8
|
-
|
|
9
|
-
export default defineConfig({
|
|
10
|
-
...e2ePreset(import.meta.dirname),
|
|
11
|
-
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
|
-
webServer: {
|
|
13
|
-
command: 'moon run storybook-react:serve-e2e -- --port=9000',
|
|
14
|
-
port: 9000,
|
|
15
|
-
reuseExistingServer: false,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2021 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Page, expect, test } from '@playwright/test';
|
|
6
|
-
|
|
7
|
-
import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
|
|
8
|
-
|
|
9
|
-
test.describe('Smoke test', () => {
|
|
10
|
-
let page: Page;
|
|
11
|
-
|
|
12
|
-
test.beforeAll(async ({ browser }) => {
|
|
13
|
-
const result = await setupPage(browser, {
|
|
14
|
-
url: storybookUrl('sdk-react-client-withclientprovider--default', 9000),
|
|
15
|
-
});
|
|
16
|
-
page = result.page;
|
|
17
|
-
await page.locator(':text("initialized")').waitFor({ state: 'visible' });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// NOTE: This test depends on connecting to the default production deployed HALO vault.
|
|
21
|
-
test('Renders remote client info', async () => {
|
|
22
|
-
await expect(page.locator(':text("initialized")')).toBeVisible();
|
|
23
|
-
});
|
|
24
|
-
});
|