@dxos/react-client 0.7.5-staging.b81e783 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/echo/index.mjs +7 -6
- package/dist/lib/browser/echo/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/echo/index.cjs +6 -5
- package/dist/lib/node/echo/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/echo/index.mjs +7 -6
- package/dist/lib/node-esm/echo/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/client/useClient.d.ts +1 -1
- package/dist/types/src/client/useClient.d.ts.map +1 -1
- package/dist/types/src/client/useConfig.d.ts +1 -1
- package/dist/types/src/client/useConfig.d.ts.map +1 -1
- package/dist/types/src/echo/useQuery.d.ts +1 -1
- package/dist/types/src/echo/useQuery.d.ts.map +1 -1
- package/dist/types/src/halo/Passkey.stories.d.ts +1 -1
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +2 -2
- package/package.json +23 -23
- package/src/echo/useQuery.ts +8 -7
- package/src/halo/Passkey.stories.tsx +11 -7
- package/tsconfig.json +1 -6
|
@@ -5,9 +5,9 @@ declare const _default: {
|
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: {
|
|
8
|
-
decorators: import("@storybook/react
|
|
8
|
+
decorators: import("@storybook/react").Decorator[];
|
|
9
9
|
};
|
|
10
10
|
export declare const Multiple: {
|
|
11
|
-
decorators: import("@storybook/react
|
|
11
|
+
decorators: import("@storybook/react").Decorator[];
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=withClientProvider.stories.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -78,40 +78,40 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"react-error-boundary": "^4.0.13",
|
|
81
|
-
"@dxos/async": "0.
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/config": "0.
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/echo-
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/log": "0.
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
81
|
+
"@dxos/async": "0.8.0",
|
|
82
|
+
"@dxos/codec-protobuf": "0.8.0",
|
|
83
|
+
"@dxos/config": "0.8.0",
|
|
84
|
+
"@dxos/client": "0.8.0",
|
|
85
|
+
"@dxos/debug": "0.8.0",
|
|
86
|
+
"@dxos/echo-schema": "0.8.0",
|
|
87
|
+
"@dxos/echo-signals": "0.8.0",
|
|
88
|
+
"@dxos/invariant": "0.8.0",
|
|
89
|
+
"@dxos/log": "0.8.0",
|
|
90
|
+
"@dxos/node-std": "0.8.0",
|
|
91
|
+
"@dxos/react-hooks": "0.8.0",
|
|
92
|
+
"@dxos/util": "0.8.0",
|
|
93
|
+
"@dxos/protocols": "0.8.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/react": "~18.2.0",
|
|
97
97
|
"@types/react-dom": "~18.2.0",
|
|
98
98
|
"react": "~18.2.0",
|
|
99
99
|
"react-dom": "~18.2.0",
|
|
100
|
-
"@dxos/
|
|
101
|
-
"@dxos/react-ui": "0.
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/react-ui-theme": "0.
|
|
104
|
-
"@dxos/storybook-utils": "0.
|
|
105
|
-
"@dxos/test-utils": "0.
|
|
100
|
+
"@dxos/react-ui": "0.8.0",
|
|
101
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.0",
|
|
102
|
+
"@dxos/random": "0.8.0",
|
|
103
|
+
"@dxos/react-ui-theme": "0.8.0",
|
|
104
|
+
"@dxos/storybook-utils": "0.8.0",
|
|
105
|
+
"@dxos/test-utils": "0.8.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"react": "~18.2.0",
|
|
109
109
|
"react-dom": "~18.2.0"
|
|
110
110
|
},
|
|
111
111
|
"optionalDependencies": {
|
|
112
|
-
"@dxos/random": "0.
|
|
113
|
-
"@dxos/react-ui": "0.
|
|
114
|
-
"@dxos/react-ui-theme": "0.
|
|
112
|
+
"@dxos/random": "0.8.0",
|
|
113
|
+
"@dxos/react-ui": "0.8.0",
|
|
114
|
+
"@dxos/react-ui-theme": "0.8.0"
|
|
115
115
|
},
|
|
116
116
|
"publishConfig": {
|
|
117
117
|
"access": "public"
|
package/src/echo/useQuery.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { useMemo, useSyncExternalStore } from 'react';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
Filter,
|
|
9
8
|
isSpace,
|
|
10
9
|
type Echo,
|
|
11
|
-
type ReactiveEchoObject,
|
|
12
10
|
type FilterSource,
|
|
11
|
+
Filter,
|
|
12
|
+
type ReactiveEchoObject,
|
|
13
13
|
type Query,
|
|
14
14
|
type QueryOptions,
|
|
15
15
|
type Space,
|
|
@@ -25,13 +25,14 @@ export const useQuery = <T extends ReactiveEchoObject<any>>(
|
|
|
25
25
|
options?: QueryOptions,
|
|
26
26
|
deps?: any[],
|
|
27
27
|
): T[] => {
|
|
28
|
-
const {
|
|
28
|
+
const { getObjects, subscribe } = useMemo(() => {
|
|
29
|
+
let subscribed = false;
|
|
29
30
|
const query = isSpace(spaceOrEcho)
|
|
30
31
|
? spaceOrEcho.db.query(filter, options)
|
|
31
32
|
: (spaceOrEcho?.query(filter, options) as Query<T> | undefined);
|
|
32
|
-
let subscribed = false;
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
|
+
getObjects: () => (subscribed && query ? query.objects : EMPTY_ARRAY),
|
|
35
36
|
subscribe: (cb: () => void) => {
|
|
36
37
|
subscribed = true;
|
|
37
38
|
const unsubscribe = query?.subscribe(cb) ?? noop;
|
|
@@ -40,13 +41,13 @@ export const useQuery = <T extends ReactiveEchoObject<any>>(
|
|
|
40
41
|
subscribed = false;
|
|
41
42
|
};
|
|
42
43
|
},
|
|
43
|
-
getObjects: () => (subscribed && query ? query.objects : EMPTY_ARRAY),
|
|
44
44
|
};
|
|
45
45
|
}, [spaceOrEcho, ...filterToDepsArray(filter), ...(deps ?? [])]);
|
|
46
46
|
|
|
47
47
|
// https://beta.reactjs.org/reference/react/useSyncExternalStore
|
|
48
|
-
// NOTE: This hook will resubscribe whenever the callback passed to the first argument changes
|
|
49
|
-
|
|
48
|
+
// NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.
|
|
49
|
+
const objects = useSyncExternalStore<T[] | undefined>(subscribe, getObjects);
|
|
50
|
+
return objects ?? [];
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const filterToDepsArray = (filter?: FilterSource<any>) => [JSON.stringify(Filter.from(filter).toProto())];
|
|
@@ -35,6 +35,7 @@ const Test = () => {
|
|
|
35
35
|
const handleCreatePassKey = useCallback(async () => {
|
|
36
36
|
invariant(identity, 'Identity not available');
|
|
37
37
|
const challenge = getNewChallenge();
|
|
38
|
+
const lookupKey = PublicKey.random();
|
|
38
39
|
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions
|
|
39
40
|
const credential = await navigator.credentials
|
|
40
41
|
.create({
|
|
@@ -42,7 +43,7 @@ const Test = () => {
|
|
|
42
43
|
challenge: new TextEncoder().encode(challenge),
|
|
43
44
|
rp: { id: location.hostname, name: 'Test' },
|
|
44
45
|
user: {
|
|
45
|
-
id:
|
|
46
|
+
id: lookupKey.asUint8Array(),
|
|
46
47
|
name: identity.did,
|
|
47
48
|
displayName: identity.profile?.displayName ?? '',
|
|
48
49
|
},
|
|
@@ -66,8 +67,11 @@ const Test = () => {
|
|
|
66
67
|
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
67
68
|
// TODO(wittjosiah): This needs a proper api.
|
|
68
69
|
await client.services.services.IdentityService.createRecoveryCredential({
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
data: {
|
|
71
|
+
recoveryKey,
|
|
72
|
+
algorithm,
|
|
73
|
+
lookupKey,
|
|
74
|
+
},
|
|
71
75
|
});
|
|
72
76
|
}, [client, identity]);
|
|
73
77
|
|
|
@@ -86,10 +90,10 @@ const Test = () => {
|
|
|
86
90
|
},
|
|
87
91
|
})
|
|
88
92
|
.catch(log.error);
|
|
89
|
-
const
|
|
93
|
+
const lookupKey = PublicKey.from(new Uint8Array((credential as any).response.userHandle));
|
|
90
94
|
await client.services.services.IdentityService.recoverIdentity({
|
|
91
95
|
external: {
|
|
92
|
-
|
|
96
|
+
lookupKey,
|
|
93
97
|
deviceKey,
|
|
94
98
|
controlFeedKey,
|
|
95
99
|
signature: Buffer.from((credential as any).response.signature),
|
|
@@ -138,8 +142,8 @@ const config = new Config({
|
|
|
138
142
|
},
|
|
139
143
|
services: {
|
|
140
144
|
edge: {
|
|
141
|
-
|
|
142
|
-
url: 'ws://localhost:8787',
|
|
145
|
+
url: 'wss://edge-main.dxos.workers.dev/',
|
|
146
|
+
// url: 'ws://localhost:8787',
|
|
143
147
|
},
|
|
144
148
|
iceProviders: [{ urls: 'https://edge-production.dxos.workers.dev/ice' }],
|
|
145
149
|
},
|