@dxos/react-client 2.28.5 → 2.28.6-dev.50c5d54b
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 +8 -7
- package/.rush/temp/package-deps_build:test.json +8 -7
- package/.rush/temp/package-deps_prerelease.json +8 -7
- package/dist/src/banner.d.ts.map +1 -1
- package/dist/src/banner.js +0 -1
- package/dist/src/banner.js.map +1 -1
- package/dist/src/containers/BotFactoryClientProvider.d.ts +9 -0
- package/dist/src/containers/BotFactoryClientProvider.d.ts.map +1 -0
- package/dist/src/containers/BotFactoryClientProvider.js +55 -0
- package/dist/src/containers/BotFactoryClientProvider.js.map +1 -0
- package/dist/src/containers/ClientProvider.d.ts +1 -2
- package/dist/src/containers/ClientProvider.d.ts.map +1 -1
- package/dist/src/containers/ClientProvider.js +2 -1
- package/dist/src/containers/ClientProvider.js.map +1 -1
- package/dist/src/containers/index.d.ts +1 -0
- package/dist/src/containers/index.d.ts.map +1 -1
- package/dist/src/containers/index.js +1 -0
- package/dist/src/containers/index.js.map +1 -1
- package/dist/src/hooks/bot-factory/useBotFactoryClient.d.ts +4 -1
- package/dist/src/hooks/bot-factory/useBotFactoryClient.d.ts.map +1 -1
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js +18 -23
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js.map +1 -1
- package/dist/src/hooks/client/context.d.ts +0 -3
- package/dist/src/hooks/client/context.d.ts.map +1 -1
- package/dist/src/hooks/client/context.js +0 -3
- package/dist/src/hooks/client/context.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -2
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +2 -2
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/banner.ts +0 -2
- package/src/containers/BotFactoryClientProvider.tsx +50 -0
- package/src/containers/ClientProvider.tsx +3 -5
- package/src/containers/index.ts +1 -0
- package/src/hooks/bot-factory/useBotFactoryClient.ts +19 -23
- package/src/hooks/client/context.ts +0 -3
- package/src/hooks/index.ts +2 -2
- package/stories/halo-invitations.stories.tsx +1 -3
- package/out/book/index.html +0 -13
- package/out/book/index.js +0 -209110
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.28.
|
|
3
|
+
"version": "2.28.6-dev.50c5d54b",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "DXOS.org",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"types": "dist/src/index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@dxos/async": "2.28.
|
|
11
|
-
"@dxos/bot-factory-client": "2.28.
|
|
12
|
-
"@dxos/client": "2.28.
|
|
13
|
-
"@dxos/config": "2.28.
|
|
14
|
-
"@dxos/credentials": "2.28.
|
|
15
|
-
"@dxos/crypto": "2.28.
|
|
16
|
-
"@dxos/debug": "2.28.
|
|
17
|
-
"@dxos/echo-db": "2.28.
|
|
18
|
-
"@dxos/network-manager": "2.28.
|
|
19
|
-
"@dxos/util": "2.28.
|
|
10
|
+
"@dxos/async": "2.28.6-dev.50c5d54b",
|
|
11
|
+
"@dxos/bot-factory-client": "2.28.6-dev.50c5d54b",
|
|
12
|
+
"@dxos/client": "2.28.6-dev.50c5d54b",
|
|
13
|
+
"@dxos/config": "2.28.6-dev.50c5d54b",
|
|
14
|
+
"@dxos/credentials": "2.28.6-dev.50c5d54b",
|
|
15
|
+
"@dxos/crypto": "2.28.6-dev.50c5d54b",
|
|
16
|
+
"@dxos/debug": "2.28.6-dev.50c5d54b",
|
|
17
|
+
"@dxos/echo-db": "2.28.6-dev.50c5d54b",
|
|
18
|
+
"@dxos/network-manager": "2.28.6-dev.50c5d54b",
|
|
19
|
+
"@dxos/util": "2.28.6-dev.50c5d54b",
|
|
20
20
|
"assert": "^2.0.0",
|
|
21
21
|
"debug": "^4.3.3",
|
|
22
22
|
"use-subscription": "^1.4.1"
|
package/src/banner.ts
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Client } from '@dxos/client';
|
|
6
6
|
|
|
7
|
-
// TODO(burdon): Print version.
|
|
8
7
|
// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS
|
|
9
|
-
|
|
10
8
|
const BANNER = (client: Client) => '\n' +
|
|
11
9
|
'_/\\/\\/\\/\\/\\____/\\/\\____/\\/\\____/\\/\\/\\/\\______/\\/\\/\\/\\/\\_\n' +
|
|
12
10
|
'_/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\____/\\/\\__/\\/\\_________\n' +
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { ReactNode, 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 { BotFactoryClientContext, createBotFactoryClient, useConfig } from '../hooks';
|
|
12
|
+
|
|
13
|
+
export interface BotFactoryClientProviderProps {
|
|
14
|
+
children?: ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* BotFactoryClientProvider
|
|
19
|
+
*/
|
|
20
|
+
export const BotFactoryClientProvider = ({
|
|
21
|
+
children
|
|
22
|
+
}: BotFactoryClientProviderProps) => {
|
|
23
|
+
const config = useConfig();
|
|
24
|
+
const [botFactoryClient, setBotFactoryClient] = useState<BotFactoryClient>();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setImmediate(async () => {
|
|
28
|
+
const botFactoryClient = await createBotFactoryClient(config);
|
|
29
|
+
setBotFactoryClient(botFactoryClient);
|
|
30
|
+
|
|
31
|
+
// TODO(burdon): Rename property: 'runtime.services.bot-factory.topic'
|
|
32
|
+
const topic = config.get('runtime.services.bot.topic') ?? raise(new Error('Missing Bot factory topic.'));
|
|
33
|
+
await botFactoryClient.start(PublicKey.from(topic));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
void botFactoryClient?.stop();
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
if (!botFactoryClient) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<BotFactoryClientContext.Provider value={botFactoryClient}>
|
|
47
|
+
{children}
|
|
48
|
+
</BotFactoryClientContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -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 {
|
|
9
|
+
import { ConfigProvider } from '@dxos/config';
|
|
10
10
|
import { MaybeFunction, MaybePromise, getAsyncValue } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { printBanner } from '../banner';
|
|
@@ -16,9 +16,6 @@ const log = debug('dxos:react-client');
|
|
|
16
16
|
|
|
17
17
|
export type ClientProvider = MaybeFunction<MaybePromise<Client>>
|
|
18
18
|
|
|
19
|
-
// TODO(burdon): Why defs?
|
|
20
|
-
export type ConfigProvider = MaybeFunction<MaybePromise<Config | ConfigObject>>
|
|
21
|
-
|
|
22
19
|
export interface ClientProviderProps {
|
|
23
20
|
children?: ReactNode
|
|
24
21
|
|
|
@@ -76,7 +73,6 @@ export const ClientProvider = ({
|
|
|
76
73
|
printBanner(client);
|
|
77
74
|
};
|
|
78
75
|
|
|
79
|
-
// TODO(burdon): Error handling.
|
|
80
76
|
setImmediate(async () => {
|
|
81
77
|
if (clientProvider) {
|
|
82
78
|
// Asynchornously request client.
|
|
@@ -93,6 +89,8 @@ export const ClientProvider = ({
|
|
|
93
89
|
}
|
|
94
90
|
}, []);
|
|
95
91
|
|
|
92
|
+
// Console debug access.
|
|
93
|
+
// TODO(burdon): Debug only.
|
|
96
94
|
useEffect(() => {
|
|
97
95
|
if (client) {
|
|
98
96
|
(window as any).__DXOS__ = client.getDevtoolsContext();
|
package/src/containers/index.ts
CHANGED
|
@@ -2,34 +2,30 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
7
|
import { BotFactoryClient } from '@dxos/bot-factory-client';
|
|
8
8
|
import { Config } from '@dxos/config';
|
|
9
|
-
import { PublicKey } from '@dxos/crypto';
|
|
10
|
-
import { raise } from '@dxos/debug';
|
|
11
9
|
import { NetworkManager } from '@dxos/network-manager';
|
|
12
10
|
|
|
13
|
-
export const
|
|
14
|
-
const [botFactoryClient, setBotFactoryClient] = useState<BotFactoryClient>();
|
|
11
|
+
export const BotFactoryClientContext = createContext<BotFactoryClient | undefined>(undefined);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
const botFactoryClient = new BotFactoryClient(networkManager);
|
|
23
|
-
const topic = config.get('runtime.services.bot.topic') ??
|
|
24
|
-
raise(new Error('Bot factory topic is not provided'));
|
|
25
|
-
setImmediate(async () => {
|
|
26
|
-
await botFactoryClient.start(PublicKey.from(topic));
|
|
27
|
-
setBotFactoryClient(botFactoryClient);
|
|
28
|
-
});
|
|
29
|
-
return () => {
|
|
30
|
-
void botFactoryClient.stop();
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
13
|
+
export const useBotFactoryClient = (required = true): BotFactoryClient | undefined => {
|
|
14
|
+
const client = useContext(BotFactoryClientContext);
|
|
15
|
+
if (required && !client) {
|
|
16
|
+
throw new Error('Missing BotFactoryClientContext.');
|
|
17
|
+
}
|
|
33
18
|
|
|
34
|
-
return
|
|
19
|
+
return client;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const createBotFactoryClient = async (config: Config): Promise<BotFactoryClient> => {
|
|
23
|
+
const signal = config.get('runtime.services.signal.server');
|
|
24
|
+
const networkManager = new NetworkManager({
|
|
25
|
+
signal: signal ? [signal] : undefined,
|
|
26
|
+
ice: config.get('runtime.services.ice'),
|
|
27
|
+
log: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return new BotFactoryClient(networkManager);
|
|
35
31
|
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export * from './bot-factory';
|
|
5
6
|
export * from './client';
|
|
6
7
|
export * from './echo-queries';
|
|
7
8
|
export * from './echo-selections';
|
|
8
9
|
export * from './invitations';
|
|
9
|
-
export * from './wns';
|
|
10
10
|
export * from './util';
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './wns';
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
|
-
} from '@mui/material';
|
|
7
|
+
import { Box, Button, Divider, Paper, TextField, Toolbar } from '@mui/material';
|
|
10
8
|
|
|
11
9
|
import { Invitation, InvitationDescriptor } from '@dxos/client';
|
|
12
10
|
|
package/out/book/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>ESBuild-Server Book</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id='root'></div>
|
|
11
|
-
<script src='index.js'></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|