@dxos/react-client 2.19.3-dev.f4e71246 → 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/.rush/temp/package-deps_build.json +13 -10
- package/.rush/temp/package-deps_build:test.json +13 -10
- package/.rush/temp/shrinkwrap-deps.json +825 -570
- package/dist/src/banner.d.ts +3 -0
- package/dist/src/banner.d.ts.map +1 -0
- package/dist/src/banner.js +25 -0
- package/dist/src/banner.js.map +1 -0
- package/dist/src/containers/ClientProvider.d.ts.map +1 -1
- package/dist/src/containers/ClientProvider.js +2 -0
- package/dist/src/containers/ClientProvider.js.map +1 -1
- package/dist/src/hooks/bot-factory/index.d.ts +2 -0
- package/dist/src/hooks/bot-factory/index.d.ts.map +1 -0
- package/dist/src/hooks/bot-factory/index.js +17 -0
- package/dist/src/hooks/bot-factory/index.js.map +1 -0
- package/dist/src/hooks/bot-factory/useBotFactoryClient.d.ts +3 -0
- package/dist/src/hooks/bot-factory/useBotFactoryClient.d.ts.map +1 -0
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js +31 -0
- package/dist/src/hooks/bot-factory/useBotFactoryClient.js.map +1 -0
- package/dist/src/hooks/echo-queries/useMembers.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.js +0 -2
- package/dist/src/hooks/echo-queries/useMembers.js.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.d.ts +0 -4
- package/dist/src/hooks/echo-queries/useParties.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.js +2 -9
- package/dist/src/hooks/echo-queries/useParties.js.map +1 -1
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +1 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/testing/ProfileInitializer.d.ts +2 -2
- package/dist/src/testing/ProfileInitializer.d.ts.map +1 -1
- package/dist/src/testing/ProfileInitializer.js.map +1 -1
- package/dist/stories/helpers/Container.d.ts +2 -2
- package/dist/stories/helpers/Container.d.ts.map +1 -1
- package/dist/stories/helpers/Container.js.map +1 -1
- package/dist/stories/helpers/ThemeProvider.d.ts +2 -2
- package/dist/stories/helpers/ThemeProvider.d.ts.map +1 -1
- package/dist/stories/helpers/ThemeProvider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +67 -66
- package/react-client.build.log +6 -6
- package/src/banner.ts +27 -0
- package/src/containers/ClientProvider.tsx +2 -0
- package/src/hooks/bot-factory/index.ts +5 -0
- package/src/hooks/bot-factory/useBotFactoryClient.ts +33 -0
- package/src/hooks/echo-queries/useMembers.tsx +0 -2
- package/src/hooks/echo-queries/useParties.ts +2 -9
- package/src/hooks/index.ts +1 -0
- package/src/testing/ProfileInitializer.tsx +2 -2
- package/stories/helpers/Container.tsx +2 -2
- package/stories/helpers/ThemeProvider.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
2
|
+
"name": "@dxos/react-client",
|
|
3
|
+
"version": "2.19.4-dev.7d022b84",
|
|
4
|
+
"description": "React client API",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "AGPL-3.0",
|
|
7
|
+
"author": "DXOS.org",
|
|
8
|
+
"main": "dist/src/index.js",
|
|
9
|
+
"types": "dist/src/index.d.ts",
|
|
10
|
+
"dependencies": {
|
|
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
|
+
"assert": "^2.0.0",
|
|
20
|
+
"debug": "^4.3.3",
|
|
21
|
+
"react-display-name": "^0.2.5",
|
|
22
|
+
"use-subscription": "^1.4.1",
|
|
23
|
+
"@dxos/bot-factory-client": "2.19.4-dev.7d022b84"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@dxos/esbuild-plugins": "2.19.4-dev.7d022b84",
|
|
27
|
+
"@dxos/esbuild-server": "~1.7.1",
|
|
28
|
+
"@dxos/toolchain-node-library": "2.19.3",
|
|
29
|
+
"@mui/material": "^5.0.1",
|
|
30
|
+
"@testing-library/react": "^11.0.4",
|
|
31
|
+
"@testing-library/react-hooks": "5.1.2",
|
|
32
|
+
"@types/debug": "^4.1.7",
|
|
33
|
+
"@types/level-js": "~4.0.1",
|
|
34
|
+
"@types/mocha": "~8.2.2",
|
|
35
|
+
"@types/node": "^14.0.9",
|
|
36
|
+
"@types/react": "^17.0.24",
|
|
37
|
+
"@types/testing-library__jest-dom": "~5.9.5",
|
|
38
|
+
"@types/use-subscription": "^1.0.0",
|
|
39
|
+
"expect": "~27.0.2",
|
|
40
|
+
"fork-ts-checker-webpack-plugin": "~6.2.5",
|
|
41
|
+
"level-js": "^5.0.2",
|
|
42
|
+
"react": "^17.0.2",
|
|
43
|
+
"react-docgen-typescript-loader": "^3.7.2",
|
|
44
|
+
"react-dom": "^17.0.2",
|
|
45
|
+
"react-test-renderer": "^17.0.2",
|
|
46
|
+
"typescript": "^4.5.2",
|
|
47
|
+
"webpack": "4.44.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"react": "*"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"toolchain": {
|
|
56
|
+
"testingFramework": "mocha",
|
|
57
|
+
"jsdom": true,
|
|
58
|
+
"forceCloseTests": true
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"book": "esbuild-server book",
|
|
62
|
+
"build": "toolchain build",
|
|
63
|
+
"build:test": "toolchain build:test",
|
|
64
|
+
"lint": "toolchain lint",
|
|
65
|
+
"test": "toolchain test"
|
|
66
|
+
},
|
|
67
|
+
"readme": "# @dxos/react-client\n\nA react implementation of the DXOS Client APIs.\n\n## Install\n\n```bash\ngit clone git@github.com:dxos/protocols.git\ncd protocols\nrush update\nrush build\n\ncd packages/sdk/demos\nrushx book\n```\n\n## Usage\n\nThe snippet below illustrates a self-contained DXOS application that uses providers to create the client and instantiate a user profile.\n\n```javascript\nimport { useClient, ClientProvider, ProfileInitializer } from '@dxos/react-client';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\nconst App = () => {\n const client = useClient();\n\n return (\n <pre>{JSON.stringify(client.info())}</pre>\n );\n};\n\nconst Root = () => (\n <ClientProvider>\n <ProfileInitializer>\n <App />\n </ProfileInitializer>\n </ClientProvider>\n);\n\nReactDOM.render(<Root/>, document.getElementById('root'));\n```\n\n## Storybooks\n\nThe [HALO Invitation Story](./stories/halo-invitations.stories.tsx) demonstrates multiple clients (devices) joining the same HALO.\n\nhttps://user-images.githubusercontent.com/3523355/137532718-a21f1f27-9854-4c0b-831a-e9ff92feac49.mov\n\nThe [Party Invitation Story](./stories/party-invitations.stories.tsx) demonstrates multiple clients creating and sharing parties.\n\nhttps://user-images.githubusercontent.com/3523355/137532717-e77395dc-96f9-4e4b-8f67-e6bd026a3abe.mov\n\n\n## Contributing\n\nPRs accepted.\n\n## License\n\nAGPL-3.0 © DXOS\n"
|
|
68
|
+
}
|
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 2801 ms
|
|
6
6
|
|
|
7
7
|
eslint
|
|
8
|
-
OK in
|
|
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
|
|
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 (
|
|
29
|
+
7 passing (309ms)
|
|
30
30
|
|
|
31
|
-
OK in
|
|
31
|
+
OK in 2440 ms
|
|
32
32
|
|
|
33
|
-
CHECK COMPLETE in
|
|
33
|
+
CHECK COMPLETE in 11456 ms
|
package/src/banner.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2021 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Client } from '@dxos/client';
|
|
6
|
+
|
|
7
|
+
// TODO(burdon): Print version.
|
|
8
|
+
// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS
|
|
9
|
+
|
|
10
|
+
const BANNER = (client: Client) => '\n' +
|
|
11
|
+
'_/\\/\\/\\/\\/\\____/\\/\\____/\\/\\____/\\/\\/\\/\\______/\\/\\/\\/\\/\\_\n' +
|
|
12
|
+
'_/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\____/\\/\\__/\\/\\_________\n' +
|
|
13
|
+
'_/\\/\\____/\\/\\______/\\/\\______/\\/\\____/\\/\\____/\\/\\/\\/\\___\n' +
|
|
14
|
+
'_/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\____/\\/\\__________/\\/\\_\n' +
|
|
15
|
+
'_/\\/\\/\\/\\/\\____/\\/\\____/\\/\\____/\\/\\/\\/\\____/\\/\\/\\/\\/\\___\n' +
|
|
16
|
+
`\n DXOS Client ${client.version} \n\n`;
|
|
17
|
+
|
|
18
|
+
let bannerPrinted = false;
|
|
19
|
+
|
|
20
|
+
export function printBanner (client: Client) {
|
|
21
|
+
if (bannerPrinted) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
bannerPrinted = true;
|
|
26
|
+
console.log(BANNER(client));
|
|
27
|
+
}
|
|
@@ -9,6 +9,7 @@ import { Client, ClientOptions } from '@dxos/client';
|
|
|
9
9
|
import { Config, ConfigObject } from '@dxos/config';
|
|
10
10
|
import { MaybeFunction, MaybePromise, getAsyncValue } from '@dxos/util';
|
|
11
11
|
|
|
12
|
+
import { printBanner } from '../banner';
|
|
12
13
|
import { ClientContext } from '../hooks';
|
|
13
14
|
|
|
14
15
|
const log = debug('dxos:react-client');
|
|
@@ -72,6 +73,7 @@ export const ClientProvider = ({
|
|
|
72
73
|
}
|
|
73
74
|
await onInitialize?.(client);
|
|
74
75
|
setClient(client);
|
|
76
|
+
printBanner(client);
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
// TODO(burdon): Error handling.
|
|
@@ -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
|
+
};
|
|
@@ -18,8 +18,6 @@ export const useMembers = (party: PartyProxy | undefined) => {
|
|
|
18
18
|
setMembers(result.value);
|
|
19
19
|
|
|
20
20
|
return result.subscribe(() => {
|
|
21
|
-
// TODO(wittjosiah): Result not triggering update when name loads.
|
|
22
|
-
// https://github.com/dxos/protocols/issues/372
|
|
23
21
|
const update = setInterval(() => {
|
|
24
22
|
const newMembers = party.queryMembers().value;
|
|
25
23
|
const isNameFilled = newMembers.every(m => m.displayName);
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useEffect,
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { PartyProxy } from '@dxos/client';
|
|
8
8
|
import { PublicKey, PublicKeyLike } from '@dxos/crypto';
|
|
9
9
|
|
|
10
10
|
import { useClient } from '../client';
|
|
11
|
-
import { useResultSet } from '../util';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Get a specific Party.
|
|
@@ -16,6 +15,7 @@ import { useResultSet } from '../util';
|
|
|
16
15
|
*/
|
|
17
16
|
export const useParty = (partyKey?: PublicKeyLike): PartyProxy | undefined => {
|
|
18
17
|
const client = useClient();
|
|
18
|
+
// TODO(wittjosiah): Not responsive to party updates?
|
|
19
19
|
return partyKey ? client.echo.getParty(PublicKey.from(partyKey)) : undefined;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -44,10 +44,3 @@ export const useParties = () => {
|
|
|
44
44
|
|
|
45
45
|
return parties;
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get all known members of a Party.
|
|
50
|
-
*/
|
|
51
|
-
export const usePartyMembers = (party: PartyProxy) => {
|
|
52
|
-
return useResultSet(useMemo(() => party.queryMembers(), [party.key.toHex()]));
|
|
53
|
-
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useEffect } from 'react';
|
|
5
|
+
import React, { ReactNode, useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { useClient, useProfile } from '../hooks';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import { useClient, useProfile } from '../hooks';
|
|
|
11
11
|
* @deprecated
|
|
12
12
|
*/
|
|
13
13
|
// TODO(burdon): Testing-only; replace with useTestProfile();
|
|
14
|
-
export const ProfileInitializer = ({ children }: { children:
|
|
14
|
+
export const ProfileInitializer = ({ children }: { children: ReactNode }) => {
|
|
15
15
|
const client = useClient();
|
|
16
16
|
const profile = useProfile();
|
|
17
17
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { ReactNode } from 'react';
|
|
6
6
|
|
|
7
7
|
import { styled } from '@mui/material';
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ const FullScreen = styled('div')({
|
|
|
19
19
|
backgroundColor: '#EEE'
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
export const Container = ({ children }: { children:
|
|
22
|
+
export const Container = ({ children }: { children: ReactNode }) => (
|
|
23
23
|
<FullScreen>
|
|
24
24
|
<ThemeProvider>
|
|
25
25
|
{children}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { ReactNode } from 'react';
|
|
6
6
|
|
|
7
7
|
import { createTheme, ThemeProvider as MuiThemeProvider } from '@mui/material';
|
|
8
8
|
|
|
@@ -33,7 +33,7 @@ const theme = createTheme({
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
// TODO(burdon): Add theme as decorator.
|
|
36
|
-
export const ThemeProvider = ({ children }: { children:
|
|
36
|
+
export const ThemeProvider = ({ children }: { children: ReactNode }) => (
|
|
37
37
|
<MuiThemeProvider theme={theme}>
|
|
38
38
|
{children}
|
|
39
39
|
</MuiThemeProvider>
|