@dxos/react-client 2.23.1-dev.f5b1145e → 2.24.1-dev.4c2329ab
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/.rush/temp/package-deps_build.json +14 -13
- package/.rush/temp/package-deps_build:test.json +14 -13
- package/dist/src/containers/ClientProvider.d.ts +2 -2
- package/dist/src/containers/ClientProvider.d.ts.map +1 -1
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js +1 -1
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js.map +1 -1
- package/dist/src/hooks/client/client.test.js +6 -3
- package/dist/src/hooks/client/client.test.js.map +1 -1
- package/dist/src/hooks/client/config.test.js +8 -5
- package/dist/src/hooks/client/config.test.js.map +1 -1
- package/dist/src/hooks/client/useConfig.d.ts +1 -1
- package/dist/src/hooks/client/useConfig.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useContacts.d.ts +1 -1
- package/dist/src/hooks/echo-queries/useContacts.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.d.ts +2 -3
- package/dist/src/hooks/echo-queries/useMembers.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.js.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.d.ts +3 -3
- package/dist/src/hooks/echo-queries/useParties.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.js.map +1 -1
- package/dist/src/hooks/echo-selections/useSelection.d.ts +1 -1
- package/dist/src/hooks/echo-selections/useSelection.d.ts.map +1 -1
- package/dist/src/hooks/util/useResultSet.d.ts +1 -1
- package/dist/src/hooks/util/useResultSet.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.js +3 -3
- package/dist/stories/halo-invitations.stories.js.map +1 -1
- package/dist/stories/halo-recovery.stories.d.ts +7 -0
- package/dist/stories/halo-recovery.stories.d.ts.map +1 -0
- package/dist/stories/halo-recovery.stories.js +90 -0
- package/dist/stories/halo-recovery.stories.js.map +1 -0
- package/dist/stories/helpers/ClientPanel.d.ts +2 -2
- package/dist/stories/helpers/ClientPanel.d.ts.map +1 -1
- package/dist/stories/party-invitations.stories.d.ts.map +1 -1
- package/dist/stories/party-invitations.stories.js +2 -2
- package/dist/stories/party-invitations.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/react-client.build.log +5 -5
- package/src/containers/ClientProvider.tsx +2 -2
- package/src/hooks/bot-factory/useBotFactoryClient.ts +1 -1
- package/src/hooks/client/client.test.tsx +8 -5
- package/src/hooks/client/config.test.tsx +9 -6
- package/src/hooks/echo-queries/useContacts.ts +1 -1
- package/src/hooks/echo-queries/useMembers.tsx +2 -3
- package/src/hooks/echo-queries/useParties.ts +3 -3
- package/src/hooks/echo-selections/useSelection.ts +1 -1
- package/src/hooks/util/useResultSet.ts +1 -1
- package/stories/halo-invitations.stories.tsx +2 -3
- package/stories/halo-recovery.stories.tsx +126 -0
- package/stories/helpers/ClientPanel.tsx +2 -2
- package/stories/party-invitations.stories.tsx +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.1-dev.4c2329ab",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
"main": "dist/src/index.js",
|
|
9
9
|
"types": "dist/src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@dxos/async": "2.
|
|
12
|
-
"@dxos/bot-factory-client": "2.
|
|
13
|
-
"@dxos/client": "2.
|
|
14
|
-
"@dxos/config": "2.
|
|
15
|
-
"@dxos/credentials": "2.
|
|
16
|
-
"@dxos/crypto": "2.
|
|
17
|
-
"@dxos/debug": "2.
|
|
18
|
-
"@dxos/echo-db": "2.
|
|
19
|
-
"@dxos/util": "2.
|
|
11
|
+
"@dxos/async": "2.24.1-dev.4c2329ab",
|
|
12
|
+
"@dxos/bot-factory-client": "2.24.1-dev.4c2329ab",
|
|
13
|
+
"@dxos/client": "2.24.1-dev.4c2329ab",
|
|
14
|
+
"@dxos/config": "2.24.1-dev.4c2329ab",
|
|
15
|
+
"@dxos/credentials": "2.24.1-dev.4c2329ab",
|
|
16
|
+
"@dxos/crypto": "2.24.1-dev.4c2329ab",
|
|
17
|
+
"@dxos/debug": "2.24.1-dev.4c2329ab",
|
|
18
|
+
"@dxos/echo-db": "2.24.1-dev.4c2329ab",
|
|
19
|
+
"@dxos/util": "2.24.1-dev.4c2329ab",
|
|
20
20
|
"assert": "^2.0.0",
|
|
21
21
|
"debug": "^4.3.3",
|
|
22
22
|
"react-display-name": "^0.2.5",
|
|
23
23
|
"use-subscription": "^1.4.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@dxos/esbuild-plugins": "2.
|
|
26
|
+
"@dxos/esbuild-plugins": "2.24.1-dev.4c2329ab",
|
|
27
27
|
"@dxos/esbuild-server": "~1.7.4",
|
|
28
|
-
"@dxos/toolchain-node-library": "2.
|
|
28
|
+
"@dxos/toolchain-node-library": "2.24.0",
|
|
29
29
|
"@mui/material": "^5.0.1",
|
|
30
30
|
"@testing-library/react": "^11.0.4",
|
|
31
31
|
"@testing-library/react-hooks": "5.1.2",
|
package/react-client.build.log
CHANGED
|
@@ -2,10 +2,10 @@ Invoking: toolchain build:test
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
typescript
|
|
5
|
-
OK in
|
|
5
|
+
OK in 5931 ms
|
|
6
6
|
|
|
7
7
|
eslint
|
|
8
|
-
OK in
|
|
8
|
+
OK in 6755 ms
|
|
9
9
|
|
|
10
10
|
mocha
|
|
11
11
|
This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
|
|
@@ -26,8 +26,8 @@ This browser doesn't support cancelAnimationFrame. Make sure that you load a pol
|
|
|
26
26
|
✓ should return custom client config when used properly in a context
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
7 passing (
|
|
29
|
+
7 passing (244ms)
|
|
30
30
|
|
|
31
|
-
OK in
|
|
31
|
+
OK in 2114 ms
|
|
32
32
|
|
|
33
|
-
CHECK COMPLETE in
|
|
33
|
+
CHECK COMPLETE in 14813 ms
|
|
@@ -6,7 +6,7 @@ import debug from 'debug';
|
|
|
6
6
|
import React, { MutableRefObject, ReactNode, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Client, ClientOptions } from '@dxos/client';
|
|
9
|
-
import { Config, ConfigObject } from '@dxos/config';
|
|
9
|
+
import { Config, ConfigObject, ConfigV1Object } from '@dxos/config';
|
|
10
10
|
import { MaybeFunction, MaybePromise, getAsyncValue } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { printBanner } from '../banner';
|
|
@@ -17,7 +17,7 @@ const log = debug('dxos:react-client');
|
|
|
17
17
|
export type ClientProvider = MaybeFunction<MaybePromise<Client>>
|
|
18
18
|
|
|
19
19
|
// TODO(burdon): Why defs?
|
|
20
|
-
export type ConfigProvider = MaybeFunction<MaybePromise<Config | ConfigObject>>
|
|
20
|
+
export type ConfigProvider = MaybeFunction<MaybePromise<Config | ConfigObject | ConfigV1Object>>
|
|
21
21
|
|
|
22
22
|
export interface ClientProviderProps {
|
|
23
23
|
children?: ReactNode
|
|
@@ -18,7 +18,7 @@ export const useBotFactoryClient = (): BotFactoryClient | undefined => {
|
|
|
18
18
|
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
const botFactoryClient = new BotFactoryClient(client.echo.networkManager);
|
|
21
|
-
const topic = config.get('services.bot.topic') ??
|
|
21
|
+
const topic = config.get('runtime.services.bot.topic') ??
|
|
22
22
|
raise(new Error('Bot factory topic is not provided'));
|
|
23
23
|
setImmediate(async () => {
|
|
24
24
|
await botFactoryClient.start(PublicKey.from(topic));
|
|
@@ -7,7 +7,7 @@ import expect from 'expect';
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
9
|
import { Client } from '@dxos/client';
|
|
10
|
-
import {
|
|
10
|
+
import { ConfigV1Object } from '@dxos/config';
|
|
11
11
|
|
|
12
12
|
import { ClientProvider } from '../../containers';
|
|
13
13
|
import { useClient } from './useClient';
|
|
@@ -21,10 +21,13 @@ describe('Client hook', () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('should return client when used properly in a context', () => {
|
|
24
|
-
const config:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const config: ConfigV1Object = {
|
|
25
|
+
version: 1,
|
|
26
|
+
runtime: {
|
|
27
|
+
client: {
|
|
28
|
+
storage: {
|
|
29
|
+
persistent: false
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
};
|
|
@@ -7,7 +7,7 @@ import expect from 'expect';
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
9
|
import { Client } from '@dxos/client';
|
|
10
|
-
import {
|
|
10
|
+
import { ConfigV1Object } from '@dxos/config';
|
|
11
11
|
|
|
12
12
|
import { ClientProvider } from '../../containers';
|
|
13
13
|
import { useConfig } from './useConfig';
|
|
@@ -29,10 +29,13 @@ describe('Config hook', () => {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('should return custom client config when used properly in a context', () => {
|
|
32
|
-
const config:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const config: ConfigV1Object = {
|
|
33
|
+
version: 1,
|
|
34
|
+
runtime: {
|
|
35
|
+
client: {
|
|
36
|
+
storage: {
|
|
37
|
+
persistent: false
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
};
|
|
@@ -40,6 +43,6 @@ describe('Config hook', () => {
|
|
|
40
43
|
const wrapper = ({ children }: any) => <ClientProvider client={client}>{children}</ClientProvider>;
|
|
41
44
|
const { result } = renderHook(render, { wrapper });
|
|
42
45
|
expect(result.error?.message).not.toBeDefined();
|
|
43
|
-
expect(result.current.get('
|
|
46
|
+
expect(result.current.get('runtime.client.storage')).toEqual(config.runtime?.client?.storage);
|
|
44
47
|
});
|
|
45
48
|
});
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { PartyMember } from '@dxos/echo-db';
|
|
7
|
+
import { Party, PartyMember } from '@dxos/client';
|
|
9
8
|
|
|
10
|
-
export const useMembers = (party:
|
|
9
|
+
export const useMembers = (party: Party | undefined) => {
|
|
11
10
|
const [members, setMembers] = useState<PartyMember[]>([]);
|
|
12
11
|
|
|
13
12
|
useEffect(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Party } from '@dxos/client';
|
|
8
8
|
import { PublicKeyLike } from '@dxos/crypto';
|
|
9
9
|
|
|
10
10
|
import { useClient } from '../client';
|
|
@@ -13,7 +13,7 @@ import { useClient } from '../client';
|
|
|
13
13
|
* Get a specific Party.
|
|
14
14
|
* Requires ClientContext to be set via ClientProvider.
|
|
15
15
|
*/
|
|
16
|
-
export const useParty = (partyKey?: PublicKeyLike):
|
|
16
|
+
export const useParty = (partyKey?: PublicKeyLike): Party | undefined => {
|
|
17
17
|
const parties = useParties();
|
|
18
18
|
return parties.find(party => partyKey && party.key.equals(partyKey));
|
|
19
19
|
};
|
|
@@ -24,7 +24,7 @@ export const useParty = (partyKey?: PublicKeyLike): PartyProxy | undefined => {
|
|
|
24
24
|
*/
|
|
25
25
|
export const useParties = () => {
|
|
26
26
|
const client = useClient();
|
|
27
|
-
const [parties, setParties] = useState<
|
|
27
|
+
const [parties, setParties] = useState<Party[]>([]);
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
const result = client.echo.queryParties();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { useSubscription } from 'use-subscription';
|
|
7
7
|
|
|
8
|
-
import { ResultSet } from '@dxos/
|
|
8
|
+
import { ResultSet } from '@dxos/client';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A convenience hook used for subscribing to changing values of a result set.
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
|
|
11
|
-
import { Invitation } from '@dxos/client';
|
|
12
|
-
import { InvitationDescriptor } from '@dxos/echo-db';
|
|
11
|
+
import { Invitation, InvitationDescriptor } from '@dxos/client';
|
|
13
12
|
|
|
14
13
|
import {
|
|
15
14
|
ClientProvider,
|
|
@@ -53,7 +52,7 @@ const HaloInvitationContainer = () => {
|
|
|
53
52
|
setInvitationCode(invitation.descriptor.encode());
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
if (!client.halo.
|
|
55
|
+
if (!client.halo.profile) {
|
|
57
56
|
return null;
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2021 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Box, Button, Divider, Input, Paper, Toolbar
|
|
9
|
+
} from '@mui/material';
|
|
10
|
+
|
|
11
|
+
import { generateSeedPhrase, keyPairFromSeedPhrase } from '@dxos/crypto';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ClientProvider, useClient,
|
|
15
|
+
useParties,
|
|
16
|
+
useProfile
|
|
17
|
+
} from '../src';
|
|
18
|
+
import {
|
|
19
|
+
ClientPanel, Container
|
|
20
|
+
} from './helpers';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'react-client/HALO Recovery'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const HaloCreationContainer = () => {
|
|
27
|
+
const client = useClient();
|
|
28
|
+
const profile = useProfile();
|
|
29
|
+
const [seed, setSeed] = useState('');
|
|
30
|
+
|
|
31
|
+
const handleCreateHalo = async () => {
|
|
32
|
+
const seedPhrase = generateSeedPhrase();
|
|
33
|
+
const keyPair = keyPairFromSeedPhrase(seedPhrase);
|
|
34
|
+
|
|
35
|
+
await client.halo.createProfile({ ...keyPair });
|
|
36
|
+
setSeed(seedPhrase);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Box sx={{ padding: 1 }}>
|
|
41
|
+
{profile && (
|
|
42
|
+
<p>Generated with seedphrase: {seed}</p>
|
|
43
|
+
)}
|
|
44
|
+
{!profile && (
|
|
45
|
+
<Toolbar>
|
|
46
|
+
<Button
|
|
47
|
+
onClick={handleCreateHalo}
|
|
48
|
+
>
|
|
49
|
+
Create Halo
|
|
50
|
+
</Button>
|
|
51
|
+
</Toolbar>
|
|
52
|
+
)}
|
|
53
|
+
|
|
54
|
+
</Box>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const HaloRecoveryContainer = () => {
|
|
59
|
+
const client = useClient();
|
|
60
|
+
const [seed, setSeed] = useState('');
|
|
61
|
+
|
|
62
|
+
const handleRecover = async () => {
|
|
63
|
+
await client.halo.recoverProfile(seed);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Box sx={{ padding: 1 }}>
|
|
68
|
+
<Input
|
|
69
|
+
value={seed}
|
|
70
|
+
onChange={(e) => setSeed(e.target.value)}
|
|
71
|
+
/>
|
|
72
|
+
<Button
|
|
73
|
+
disabled={!seed}
|
|
74
|
+
onClick={handleRecover}
|
|
75
|
+
>
|
|
76
|
+
Recover
|
|
77
|
+
</Button>
|
|
78
|
+
</Box>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const TestApp = () => {
|
|
83
|
+
const client = useClient();
|
|
84
|
+
const parties = useParties();
|
|
85
|
+
const profile = useProfile();
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Box sx={{
|
|
89
|
+
display: 'flex',
|
|
90
|
+
flexDirection: 'column',
|
|
91
|
+
flex: 1,
|
|
92
|
+
flexShrink: 0,
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
margin: 1
|
|
95
|
+
}}>
|
|
96
|
+
<Paper>
|
|
97
|
+
<ClientPanel client={client} profile={profile} parties={parties} />
|
|
98
|
+
<Divider />
|
|
99
|
+
<HaloCreationContainer />
|
|
100
|
+
{!profile && (
|
|
101
|
+
<>
|
|
102
|
+
<Divider />
|
|
103
|
+
<HaloRecoveryContainer />
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
</Paper>
|
|
107
|
+
</Box>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const HaloRecovery = () => {
|
|
112
|
+
return (
|
|
113
|
+
<Container>
|
|
114
|
+
<Box sx={{ display: 'flex', flex: 1, padding: 1, justifyContent: 'space-around' }}>
|
|
115
|
+
{/* Instantiated Client. */}
|
|
116
|
+
<ClientProvider>
|
|
117
|
+
<TestApp />
|
|
118
|
+
</ClientProvider>
|
|
119
|
+
|
|
120
|
+
<ClientProvider>
|
|
121
|
+
<TestApp />
|
|
122
|
+
</ClientProvider>
|
|
123
|
+
</Box>
|
|
124
|
+
</Container>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
@@ -6,7 +6,7 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Box } from '@mui/material';
|
|
8
8
|
|
|
9
|
-
import { Client,
|
|
9
|
+
import { Client, Party } from '@dxos/client';
|
|
10
10
|
|
|
11
11
|
import { useProfile } from '../../src';
|
|
12
12
|
import { JsonPanel } from './JsonPanel';
|
|
@@ -18,7 +18,7 @@ export const ClientPanel = ({
|
|
|
18
18
|
}: {
|
|
19
19
|
client: Client,
|
|
20
20
|
profile?: Partial<ReturnType<typeof useProfile>>,
|
|
21
|
-
parties?:
|
|
21
|
+
parties?: Party[]
|
|
22
22
|
}) => {
|
|
23
23
|
const data = (parties.length !== 0) ? { parties: parties.map(({ key }) => key.toHex()) } : undefined;
|
|
24
24
|
|
|
@@ -8,9 +8,8 @@ import {
|
|
|
8
8
|
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
|
|
11
|
-
import { PartyInvitation } from '@dxos/client';
|
|
11
|
+
import { PartyInvitation, InvitationDescriptor } from '@dxos/client';
|
|
12
12
|
import { PublicKey } from '@dxos/crypto';
|
|
13
|
-
import { InvitationDescriptor } from '@dxos/echo-db';
|
|
14
13
|
|
|
15
14
|
import {
|
|
16
15
|
ClientProvider,
|