@dxos/react-client 2.22.1-dev.d95e6684 → 2.23.1-dev.16a90c25

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.
Files changed (31) hide show
  1. package/.rush/temp/package-deps_build.json +8 -8
  2. package/.rush/temp/package-deps_build:test.json +8 -8
  3. package/dist/src/containers/ClientProvider.d.ts +2 -2
  4. package/dist/src/containers/ClientProvider.d.ts.map +1 -1
  5. package/dist/src/hooks/bot-factory/useBotFactoryClient.js +1 -1
  6. package/dist/src/hooks/bot-factory/useBotFactoryClient.js.map +1 -1
  7. package/dist/src/hooks/client/client.test.js +6 -3
  8. package/dist/src/hooks/client/client.test.js.map +1 -1
  9. package/dist/src/hooks/client/config.test.js +8 -5
  10. package/dist/src/hooks/client/config.test.js.map +1 -1
  11. package/dist/src/hooks/client/useConfig.d.ts +1 -1
  12. package/dist/src/hooks/client/useConfig.d.ts.map +1 -1
  13. package/dist/src/hooks/echo-queries/useParties.d.ts.map +1 -1
  14. package/dist/src/hooks/echo-queries/useParties.js +2 -4
  15. package/dist/src/hooks/echo-queries/useParties.js.map +1 -1
  16. package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
  17. package/dist/stories/halo-invitations.stories.js +4 -4
  18. package/dist/stories/halo-invitations.stories.js.map +1 -1
  19. package/dist/stories/party-invitations.stories.d.ts.map +1 -1
  20. package/dist/stories/party-invitations.stories.js +3 -3
  21. package/dist/stories/party-invitations.stories.js.map +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +12 -12
  24. package/react-client.build.log +7 -7
  25. package/src/containers/ClientProvider.tsx +2 -2
  26. package/src/hooks/bot-factory/useBotFactoryClient.ts +1 -1
  27. package/src/hooks/client/client.test.tsx +8 -5
  28. package/src/hooks/client/config.test.tsx +9 -6
  29. package/src/hooks/echo-queries/useParties.ts +3 -4
  30. package/stories/halo-invitations.stories.tsx +5 -4
  31. package/stories/party-invitations.stories.tsx +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "2.22.1-dev.d95e6684",
3
+ "version": "2.23.1-dev.16a90c25",
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.22.1-dev.d95e6684",
12
- "@dxos/bot-factory-client": "2.22.1-dev.d95e6684",
13
- "@dxos/client": "2.22.1-dev.d95e6684",
14
- "@dxos/config": "2.22.1-dev.d95e6684",
15
- "@dxos/credentials": "2.22.1-dev.d95e6684",
16
- "@dxos/crypto": "2.22.1-dev.d95e6684",
17
- "@dxos/debug": "2.22.1-dev.d95e6684",
18
- "@dxos/echo-db": "2.22.1-dev.d95e6684",
19
- "@dxos/util": "2.22.1-dev.d95e6684",
11
+ "@dxos/async": "2.23.1-dev.16a90c25",
12
+ "@dxos/bot-factory-client": "2.23.1-dev.16a90c25",
13
+ "@dxos/client": "2.23.1-dev.16a90c25",
14
+ "@dxos/config": "2.23.1-dev.16a90c25",
15
+ "@dxos/credentials": "2.23.1-dev.16a90c25",
16
+ "@dxos/crypto": "2.23.1-dev.16a90c25",
17
+ "@dxos/debug": "2.23.1-dev.16a90c25",
18
+ "@dxos/echo-db": "2.23.1-dev.16a90c25",
19
+ "@dxos/util": "2.23.1-dev.16a90c25",
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.22.1-dev.d95e6684",
26
+ "@dxos/esbuild-plugins": "2.23.1-dev.16a90c25",
27
27
  "@dxos/esbuild-server": "~1.7.4",
28
- "@dxos/toolchain-node-library": "2.22.0",
28
+ "@dxos/toolchain-node-library": "2.23.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",
@@ -2,10 +2,10 @@ Invoking: toolchain build:test
2
2
 
3
3
 
4
4
  typescript
5
- OK in 8243 ms
5
+ OK in 10263 ms
6
6
 
7
7
  eslint
8
- OK in 7364 ms
8
+ OK in 14006 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
@@ -13,11 +13,11 @@ This browser doesn't support cancelAnimationFrame. Make sure that you load a pol
13
13
 
14
14
 
15
15
  ClientProvider
16
- ✓ Renders with children
16
+ ✓ Renders with children (90ms)
17
17
  ✓ Provides the client
18
18
 
19
19
  Client hook
20
- ✓ should throw when used outside a context
20
+ ✓ should throw when used outside a context (59ms)
21
21
  ✓ should return client when used properly in a context
22
22
 
23
23
  Config hook
@@ -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 (275ms)
29
+ 7 passing (1s)
30
30
 
31
- OK in 2953 ms
31
+ OK in 6054 ms
32
32
 
33
- CHECK COMPLETE in 18583 ms
33
+ CHECK COMPLETE in 30340 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 { defs } from '@dxos/config';
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: defs.Config = {
25
- system: {
26
- storage: {
27
- persistent: false
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 { ConfigObject } from '@dxos/config';
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: ConfigObject = {
33
- system: {
34
- storage: {
35
- persistent: false
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('system.storage')).toEqual(config.system?.storage);
46
+ expect(result.current.get('runtime.client.storage')).toEqual(config.runtime?.client?.storage);
44
47
  });
45
48
  });
@@ -5,7 +5,7 @@
5
5
  import { useEffect, useState } from 'react';
6
6
 
7
7
  import { PartyProxy } from '@dxos/client';
8
- import { PublicKey, PublicKeyLike } from '@dxos/crypto';
8
+ import { PublicKeyLike } from '@dxos/crypto';
9
9
 
10
10
  import { useClient } from '../client';
11
11
 
@@ -14,9 +14,8 @@ import { useClient } from '../client';
14
14
  * Requires ClientContext to be set via ClientProvider.
15
15
  */
16
16
  export const useParty = (partyKey?: PublicKeyLike): PartyProxy | undefined => {
17
- const client = useClient();
18
- // TODO(wittjosiah): Not responsive to party updates?
19
- return partyKey ? client.echo.getParty(PublicKey.from(partyKey)) : undefined;
17
+ const parties = useParties();
18
+ return parties.find(party => partyKey && party.key.equals(partyKey));
20
19
  };
21
20
 
22
21
  /**
@@ -8,7 +8,8 @@ import {
8
8
  Box, Button, Divider, Paper, TextField, Toolbar
9
9
  } from '@mui/material';
10
10
 
11
- import { decodeInvitation, encodeInvitation, Invitation } from '@dxos/client';
11
+ import { Invitation } from '@dxos/client';
12
+ import { InvitationDescriptor } from '@dxos/echo-db';
12
13
 
13
14
  import {
14
15
  ClientProvider,
@@ -49,10 +50,10 @@ const HaloInvitationContainer = () => {
49
50
  setPin(invitation.secret.toString());
50
51
  });
51
52
 
52
- setInvitationCode(encodeInvitation(invitation.descriptor));
53
+ setInvitationCode(invitation.descriptor.encode());
53
54
  };
54
55
 
55
- if (!client.halo.hasProfile()) {
56
+ if (!client.halo.profile) {
56
57
  return null;
57
58
  }
58
59
 
@@ -106,7 +107,7 @@ const HaloAuthenticationContainer = () => {
106
107
 
107
108
  const handleSubmit = async (invitationCode: string) => {
108
109
  try {
109
- const invitationDescriptor = decodeInvitation(invitationCode);
110
+ const invitationDescriptor = InvitationDescriptor.decode(invitationCode);
110
111
  const invitation = await client.halo.acceptInvitation(invitationDescriptor);
111
112
  setStatus({ identity: invitationDescriptor.identityKey?.toString(), invitation });
112
113
  } catch (err: any) {
@@ -8,8 +8,9 @@ import {
8
8
  Box, Button, Divider, Paper, TextField, Toolbar
9
9
  } from '@mui/material';
10
10
 
11
- import { decodeInvitation, encodeInvitation, PartyInvitation } from '@dxos/client';
11
+ import { PartyInvitation } from '@dxos/client';
12
12
  import { PublicKey } from '@dxos/crypto';
13
+ import { InvitationDescriptor } from '@dxos/echo-db';
13
14
 
14
15
  import {
15
16
  ClientProvider,
@@ -69,7 +70,7 @@ const PartyInvitationContainer = () => {
69
70
  invitation.connected.on(() => setPin(invitation.secret.toString()));
70
71
  }
71
72
 
72
- setInvitationCode(encodeInvitation(invitation.descriptor));
73
+ setInvitationCode(invitation.descriptor.encode());
73
74
  });
74
75
  };
75
76
 
@@ -144,7 +145,7 @@ const PartyJoinContainer = () => {
144
145
  setStatus({});
145
146
 
146
147
  try {
147
- const invitation = await client.echo.acceptInvitation(decodeInvitation(invitationCode));
148
+ const invitation = await client.echo.acceptInvitation(InvitationDescriptor.decode(invitationCode));
148
149
  setStatus({ invitation });
149
150
 
150
151
  const party = await invitation.getParty();