@dxos/react-client 2.19.4-dev.54bbea97 → 2.19.4-dev.7d022b84

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "2.19.4-dev.54bbea97",
3
+ "version": "2.19.4-dev.7d022b84",
4
4
  "description": "React client API",
5
5
  "keywords": [],
6
6
  "license": "AGPL-3.0",
@@ -8,21 +8,22 @@
8
8
  "main": "dist/src/index.js",
9
9
  "types": "dist/src/index.d.ts",
10
10
  "dependencies": {
11
- "@dxos/async": "2.19.4-dev.54bbea97",
12
- "@dxos/client": "2.19.4-dev.54bbea97",
13
- "@dxos/config": "2.19.4-dev.54bbea97",
14
- "@dxos/credentials": "2.19.4-dev.54bbea97",
15
- "@dxos/crypto": "2.19.4-dev.54bbea97",
16
- "@dxos/debug": "2.19.4-dev.54bbea97",
17
- "@dxos/echo-db": "2.19.4-dev.54bbea97",
18
- "@dxos/util": "2.19.4-dev.54bbea97",
11
+ "@dxos/async": "2.19.4-dev.7d022b84",
12
+ "@dxos/client": "2.19.4-dev.7d022b84",
13
+ "@dxos/config": "2.19.4-dev.7d022b84",
14
+ "@dxos/credentials": "2.19.4-dev.7d022b84",
15
+ "@dxos/crypto": "2.19.4-dev.7d022b84",
16
+ "@dxos/debug": "2.19.4-dev.7d022b84",
17
+ "@dxos/echo-db": "2.19.4-dev.7d022b84",
18
+ "@dxos/util": "2.19.4-dev.7d022b84",
19
19
  "assert": "^2.0.0",
20
20
  "debug": "^4.3.3",
21
21
  "react-display-name": "^0.2.5",
22
- "use-subscription": "^1.4.1"
22
+ "use-subscription": "^1.4.1",
23
+ "@dxos/bot-factory-client": "2.19.4-dev.7d022b84"
23
24
  },
24
25
  "devDependencies": {
25
- "@dxos/esbuild-plugins": "2.19.4-dev.54bbea97",
26
+ "@dxos/esbuild-plugins": "2.19.4-dev.7d022b84",
26
27
  "@dxos/esbuild-server": "~1.7.1",
27
28
  "@dxos/toolchain-node-library": "2.19.3",
28
29
  "@mui/material": "^5.0.1",
@@ -2,10 +2,10 @@ Invoking: toolchain build:test
2
2
 
3
3
 
4
4
  typescript
5
- OK in 3976 ms
5
+ OK in 2801 ms
6
6
 
7
7
  eslint
8
- OK in 8381 ms
8
+ OK in 6209 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,7 +13,7 @@ This browser doesn't support cancelAnimationFrame. Make sure that you load a pol
13
13
 
14
14
 
15
15
  ClientProvider
16
- ✓ Renders with children (42ms)
16
+ ✓ Renders with children
17
17
  ✓ Provides the client
18
18
 
19
19
  Client 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 (403ms)
29
+ 7 passing (309ms)
30
30
 
31
- OK in 3627 ms
31
+ OK in 2440 ms
32
32
 
33
- CHECK COMPLETE in 15992 ms
33
+ CHECK COMPLETE in 11456 ms
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2021 DXOS.org
3
+ //
4
+
5
+ export * from './useBotFactoryClient';
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2021 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useState } from 'react';
6
+
7
+ import { BotFactoryClient } from '@dxos/bot-factory-client';
8
+ import { PublicKey } from '@dxos/crypto';
9
+ import { raise } from '@dxos/debug';
10
+
11
+ import { useClient, useConfig } from '../client';
12
+
13
+ export const useBotFactoryClient = (): BotFactoryClient | undefined => {
14
+ const [botFactoryClient, setBotFactoryClient] = useState<BotFactoryClient>();
15
+
16
+ const client = useClient();
17
+ const config = useConfig();
18
+
19
+ useEffect(() => {
20
+ const botFactoryClient = new BotFactoryClient(client.echo.networkManager);
21
+ const topic = config.get('services.bot.topic') ??
22
+ raise(new Error('Bot factory topic is not provided'));
23
+ setImmediate(async () => {
24
+ await botFactoryClient.start(PublicKey.from(topic));
25
+ setBotFactoryClient(botFactoryClient);
26
+ });
27
+ return () => {
28
+ void botFactoryClient.stop();
29
+ };
30
+ }, []);
31
+
32
+ return botFactoryClient;
33
+ };
@@ -8,3 +8,4 @@ export * from './echo-selections';
8
8
  export * from './invitations';
9
9
  export * from './wns';
10
10
  export * from './util';
11
+ export * from './bot-factory';