@dxos/react-client 2.31.8-dev.65575f28 → 2.31.8-dev.9afc174f
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 -11
- package/.rush/temp/package-deps_build:test.json +8 -11
- package/.rush/temp/package-deps_prerelease.json +8 -11
- package/.rush/temp/shrinkwrap-deps.json +3 -3
- package/dist/src/containers/BotFactoryClientProvider.d.ts.map +1 -1
- package/dist/src/containers/BotFactoryClientProvider.js +8 -9
- package/dist/src/containers/BotFactoryClientProvider.js.map +1 -1
- package/dist/src/containers/ClientProvider.d.ts.map +1 -1
- package/dist/src/containers/ClientProvider.js +14 -16
- package/dist/src/containers/ClientProvider.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.js +10 -2
- package/dist/stories/halo-invitations.stories.js.map +1 -1
- package/dist/stories/party-invitations.stories.d.ts.map +1 -1
- package/dist/stories/party-invitations.stories.js +10 -2
- package/dist/stories/party-invitations.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/containers/BotFactoryClientProvider.tsx +8 -9
- package/src/containers/ClientProvider.tsx +13 -15
- package/src/index.ts +0 -1
- package/stories/halo-invitations.stories.tsx +12 -4
- package/stories/party-invitations.stories.tsx +12 -4
- package/tsconfig.json +12 -9
- package/dist/src/testing/ProfileInitializer.d.ts +0 -9
- package/dist/src/testing/ProfileInitializer.d.ts.map +0 -1
- package/dist/src/testing/ProfileInitializer.js +0 -49
- package/dist/src/testing/ProfileInitializer.js.map +0 -1
- package/dist/src/testing/index.d.ts +0 -3
- package/dist/src/testing/index.d.ts.map +0 -1
- package/dist/src/testing/index.js +0 -18
- package/dist/src/testing/index.js.map +0 -1
- package/dist/src/testing/useTestPartyBootstrap.d.ts +0 -11
- package/dist/src/testing/useTestPartyBootstrap.d.ts.map +0 -1
- package/dist/src/testing/useTestPartyBootstrap.js +0 -38
- package/dist/src/testing/useTestPartyBootstrap.js.map +0 -1
- package/out/book/esbuild-server-book.js +0 -190637
- package/out/book/index.html +0 -14
- package/src/testing/ProfileInitializer.tsx +0 -31
- package/src/testing/index.ts +0 -6
- package/src/testing/useTestPartyBootstrap.ts +0 -40
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.31.8-dev.
|
|
3
|
+
"version": "2.31.8-dev.9afc174f",
|
|
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.31.8-dev.
|
|
11
|
-
"@dxos/bot-factory-client": "2.31.8-dev.
|
|
12
|
-
"@dxos/client": "2.31.8-dev.
|
|
13
|
-
"@dxos/config": "2.31.8-dev.
|
|
14
|
-
"@dxos/credentials": "2.31.8-dev.
|
|
15
|
-
"@dxos/crypto": "2.31.8-dev.
|
|
16
|
-
"@dxos/debug": "2.31.8-dev.
|
|
17
|
-
"@dxos/echo-db": "2.31.8-dev.
|
|
18
|
-
"@dxos/network-manager": "2.31.8-dev.
|
|
19
|
-
"@dxos/
|
|
10
|
+
"@dxos/async": "2.31.8-dev.9afc174f",
|
|
11
|
+
"@dxos/bot-factory-client": "2.31.8-dev.9afc174f",
|
|
12
|
+
"@dxos/client": "2.31.8-dev.9afc174f",
|
|
13
|
+
"@dxos/config": "2.31.8-dev.9afc174f",
|
|
14
|
+
"@dxos/credentials": "2.31.8-dev.9afc174f",
|
|
15
|
+
"@dxos/crypto": "2.31.8-dev.9afc174f",
|
|
16
|
+
"@dxos/debug": "2.31.8-dev.9afc174f",
|
|
17
|
+
"@dxos/echo-db": "2.31.8-dev.9afc174f",
|
|
18
|
+
"@dxos/network-manager": "2.31.8-dev.9afc174f",
|
|
19
|
+
"@dxos/react-async": "2.31.8-dev.9afc174f",
|
|
20
|
+
"@dxos/util": "2.31.8-dev.9afc174f",
|
|
20
21
|
"assert": "^2.0.0",
|
|
21
22
|
"debug": "^4.3.3",
|
|
22
23
|
"use-subscription": "^1.4.1"
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { ReactNode,
|
|
5
|
+
import React, { ReactNode, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { BotFactoryClient } from '@dxos/bot-factory-client';
|
|
8
8
|
import { PublicKey } from '@dxos/crypto';
|
|
9
9
|
import { raise } from '@dxos/debug';
|
|
10
|
+
import { useAsyncEffect } from '@dxos/react-async';
|
|
10
11
|
|
|
11
12
|
import { BotFactoryClientContext, createBotFactoryClient, useConfig } from '../hooks';
|
|
12
13
|
|
|
@@ -23,15 +24,13 @@ export const BotFactoryClientProvider = ({
|
|
|
23
24
|
const config = useConfig();
|
|
24
25
|
const [botFactoryClient, setBotFactoryClient] = useState<BotFactoryClient>();
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setBotFactoryClient(botFactoryClient);
|
|
27
|
+
useAsyncEffect(async () => {
|
|
28
|
+
const botFactoryClient = await createBotFactoryClient(config);
|
|
29
|
+
setBotFactoryClient(botFactoryClient);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
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));
|
|
35
34
|
|
|
36
35
|
return () => {
|
|
37
36
|
void botFactoryClient?.stop();
|
|
@@ -7,6 +7,7 @@ import React, { MutableRefObject, ReactNode, useEffect, useState } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Client, ClientOptions } from '@dxos/client';
|
|
9
9
|
import { ConfigProvider } from '@dxos/config';
|
|
10
|
+
import { useAsyncEffect } from '@dxos/react-async';
|
|
10
11
|
import { MaybeFunction, MaybePromise, getAsyncValue } from '@dxos/util';
|
|
11
12
|
|
|
12
13
|
import { printBanner } from '../banner';
|
|
@@ -63,8 +64,7 @@ export const ClientProvider = ({
|
|
|
63
64
|
}: ClientProviderProps) => {
|
|
64
65
|
const [client, setClient] = useState<Client | undefined>(clientProvider instanceof Client ? clientProvider : undefined);
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
67
|
+
useAsyncEffect(async () => {
|
|
68
68
|
if (!client) {
|
|
69
69
|
const done = async (client: Client) => {
|
|
70
70
|
log(`Created client: ${client}`);
|
|
@@ -76,19 +76,17 @@ export const ClientProvider = ({
|
|
|
76
76
|
printBanner(client);
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
});
|
|
79
|
+
if (clientProvider) {
|
|
80
|
+
// Asynchornously request client.
|
|
81
|
+
const client = await getAsyncValue(clientProvider);
|
|
82
|
+
await done(client);
|
|
83
|
+
} else {
|
|
84
|
+
// Asynchronously construct client (config may be undefined).
|
|
85
|
+
const config = await getAsyncValue(configProvider);
|
|
86
|
+
const client = new Client(config, options);
|
|
87
|
+
await client.initialize();
|
|
88
|
+
await done(client);
|
|
89
|
+
}
|
|
92
90
|
}
|
|
93
91
|
}, []);
|
|
94
92
|
|
package/src/index.ts
CHANGED
|
@@ -7,10 +7,10 @@ import React, { useState } from 'react';
|
|
|
7
7
|
import { Box, Button, Divider, Paper, TextField, Toolbar } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
import { Invitation, InvitationDescriptor } from '@dxos/client';
|
|
10
|
+
import { useAsyncEffect } from '@dxos/react-async';
|
|
10
11
|
|
|
11
12
|
import {
|
|
12
13
|
ClientProvider,
|
|
13
|
-
ProfileInitializer,
|
|
14
14
|
useClient,
|
|
15
15
|
useParties,
|
|
16
16
|
useProfile
|
|
@@ -131,6 +131,16 @@ const TestApp = () => {
|
|
|
131
131
|
const parties = useParties();
|
|
132
132
|
const profile = useProfile();
|
|
133
133
|
|
|
134
|
+
useAsyncEffect(async () => {
|
|
135
|
+
if (!profile) {
|
|
136
|
+
await client.halo.createProfile();
|
|
137
|
+
}
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
if (!profile) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
return (
|
|
135
145
|
<Box sx={{
|
|
136
146
|
display: 'flex',
|
|
@@ -163,9 +173,7 @@ export const Primary = () => {
|
|
|
163
173
|
<Box sx={{ display: 'flex', flex: 1, padding: 1, justifyContent: 'space-around' }}>
|
|
164
174
|
{/* Instantiated Client. */}
|
|
165
175
|
<ClientProvider>
|
|
166
|
-
<
|
|
167
|
-
<TestApp />
|
|
168
|
-
</ProfileInitializer>
|
|
176
|
+
<TestApp />
|
|
169
177
|
</ClientProvider>
|
|
170
178
|
|
|
171
179
|
{/* Joiners. */}
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { PartyInvitation, InvitationDescriptor } from '@dxos/client';
|
|
12
12
|
import { PublicKey } from '@dxos/crypto';
|
|
13
|
+
import { useAsyncEffect } from '@dxos/react-async';
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
ClientProvider,
|
|
16
|
-
ProfileInitializer,
|
|
17
17
|
useClient,
|
|
18
18
|
useContacts,
|
|
19
19
|
useParties,
|
|
@@ -172,6 +172,16 @@ const TestApp = () => {
|
|
|
172
172
|
const parties = useParties();
|
|
173
173
|
const profile = useProfile();
|
|
174
174
|
|
|
175
|
+
useAsyncEffect(async () => {
|
|
176
|
+
if (!profile) {
|
|
177
|
+
await client.halo.createProfile();
|
|
178
|
+
}
|
|
179
|
+
}, []);
|
|
180
|
+
|
|
181
|
+
if (!profile) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
175
185
|
return (
|
|
176
186
|
<Box sx={{
|
|
177
187
|
display: 'flex',
|
|
@@ -200,9 +210,7 @@ export const Primary = () => {
|
|
|
200
210
|
<Box sx={{ display: 'flex', flex: 1, padding: 1, justifyContent: 'space-around' }}>
|
|
201
211
|
{[...new Array(peers)].map((_, i) => (
|
|
202
212
|
<ClientProvider key={i}>
|
|
203
|
-
<
|
|
204
|
-
<TestApp />
|
|
205
|
-
</ProfileInitializer>
|
|
213
|
+
<TestApp />
|
|
206
214
|
</ClientProvider>
|
|
207
215
|
))}
|
|
208
216
|
</Box>
|
package/tsconfig.json
CHANGED
|
@@ -14,35 +14,38 @@
|
|
|
14
14
|
"tests"
|
|
15
15
|
],
|
|
16
16
|
"references": [
|
|
17
|
-
{
|
|
18
|
-
"path": "../../common/async"
|
|
19
|
-
},
|
|
20
17
|
{
|
|
21
18
|
"path": "../../bot/bot-factory-client"
|
|
22
19
|
},
|
|
23
20
|
{
|
|
24
|
-
"path": "
|
|
21
|
+
"path": "../../common/async"
|
|
25
22
|
},
|
|
26
23
|
{
|
|
27
|
-
"path": "
|
|
24
|
+
"path": "../../common/crypto"
|
|
28
25
|
},
|
|
29
26
|
{
|
|
30
|
-
"path": "../../
|
|
27
|
+
"path": "../../common/debug"
|
|
31
28
|
},
|
|
32
29
|
{
|
|
33
|
-
"path": "../../common/
|
|
30
|
+
"path": "../../common/react-async"
|
|
34
31
|
},
|
|
35
32
|
{
|
|
36
|
-
"path": "../../common/
|
|
33
|
+
"path": "../../common/util"
|
|
37
34
|
},
|
|
38
35
|
{
|
|
39
36
|
"path": "../../echo/echo-db"
|
|
40
37
|
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../../halo/credentials"
|
|
40
|
+
},
|
|
41
41
|
{
|
|
42
42
|
"path": "../../mesh/network-manager"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
"path": "
|
|
45
|
+
"path": "../client"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../config"
|
|
46
49
|
}
|
|
47
50
|
]
|
|
48
51
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Automatically creates a random DXOS profile.
|
|
4
|
-
* @deprecated
|
|
5
|
-
*/
|
|
6
|
-
export declare const ProfileInitializer: ({ children }: {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}) => JSX.Element | null;
|
|
9
|
-
//# sourceMappingURL=ProfileInitializer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileInitializer.d.ts","sourceRoot":"","sources":["../../../src/testing/ProfileInitializer.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAIpD;;;GAGG;AAEH,eAAO,MAAM,kBAAkB;cAA8B,SAAS;wBAiBrE,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
-
}) : function(o, v) {
|
|
15
|
-
o["default"] = v;
|
|
16
|
-
});
|
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.ProfileInitializer = void 0;
|
|
26
|
-
const react_1 = __importStar(require("react"));
|
|
27
|
-
const hooks_1 = require("../hooks");
|
|
28
|
-
/**
|
|
29
|
-
* Automatically creates a random DXOS profile.
|
|
30
|
-
* @deprecated
|
|
31
|
-
*/
|
|
32
|
-
// TODO(burdon): Testing-only; replace with useTestProfile();
|
|
33
|
-
const ProfileInitializer = ({ children }) => {
|
|
34
|
-
const client = (0, hooks_1.useClient)();
|
|
35
|
-
const profile = (0, hooks_1.useProfile)();
|
|
36
|
-
(0, react_1.useEffect)(() => {
|
|
37
|
-
if (!profile) {
|
|
38
|
-
setImmediate(async () => {
|
|
39
|
-
await client.halo.createProfile();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, []);
|
|
43
|
-
if (!profile) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
47
|
-
};
|
|
48
|
-
exports.ProfileInitializer = ProfileInitializer;
|
|
49
|
-
//# sourceMappingURL=ProfileInitializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileInitializer.js","sourceRoot":"","sources":["../../../src/testing/ProfileInitializer.tsx"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAEF,+CAAoD;AAEpD,oCAAiD;AAEjD;;;GAGG;AACH,6DAA6D;AACtD,MAAM,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IAC1E,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAA,kBAAU,GAAE,CAAC;IAE7B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,YAAY,CAAC,KAAK,IAAI,EAAE;gBACtB,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACpC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,OAAO,8DAAG,QAAQ,CAAI,CAAC;AACzB,CAAC,CAAC;AAjBW,QAAA,kBAAkB,sBAiB7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
__exportStar(require("./ProfileInitializer"), exports);
|
|
17
|
-
__exportStar(require("./useTestPartyBootstrap"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;AAEF,uDAAqC;AACrC,0DAAwC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Client, Party } from '@dxos/client';
|
|
2
|
-
/**
|
|
3
|
-
* Hook which returns a set of peers joined in a shared party.
|
|
4
|
-
*
|
|
5
|
-
* Useful for setting up examples or tests which display multiple peers in a single view.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useTestPartyBootstrap: (peerCount?: number) => {
|
|
8
|
-
client: Client;
|
|
9
|
-
party: Party;
|
|
10
|
-
}[];
|
|
11
|
-
//# sourceMappingURL=useTestPartyBootstrap.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTestPartyBootstrap.d.ts","sourceRoot":"","sources":["../../../src/testing/useTestPartyBootstrap.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;YACa,MAAM;WAAS,KAAK;GAyBlE,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2022 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useTestPartyBootstrap = void 0;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const client_1 = require("@dxos/client");
|
|
9
|
-
/**
|
|
10
|
-
* Hook which returns a set of peers joined in a shared party.
|
|
11
|
-
*
|
|
12
|
-
* Useful for setting up examples or tests which display multiple peers in a single view.
|
|
13
|
-
*/
|
|
14
|
-
const useTestPartyBootstrap = (peerCount = 2) => {
|
|
15
|
-
const [peers, setPeers] = (0, react_1.useState)([]);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
setImmediate(async () => {
|
|
18
|
-
const peers = [];
|
|
19
|
-
const inviter = new client_1.Client();
|
|
20
|
-
await inviter.initialize();
|
|
21
|
-
await inviter.halo.createProfile({ username: 'peer-0' });
|
|
22
|
-
const inviterParty = await inviter.echo.createParty();
|
|
23
|
-
peers.push({ client: inviter, party: inviterParty });
|
|
24
|
-
for (let i = 1; i < peerCount; i++) {
|
|
25
|
-
const joiner = new client_1.Client();
|
|
26
|
-
await joiner.initialize();
|
|
27
|
-
await joiner.halo.createProfile({ username: `peer-${i}` });
|
|
28
|
-
const invitation = await inviterParty.createInvitation();
|
|
29
|
-
const joinerParty = await joiner.echo.acceptInvitation(invitation.descriptor).getParty();
|
|
30
|
-
peers.push({ client: joiner, party: joinerParty });
|
|
31
|
-
}
|
|
32
|
-
setPeers(peers);
|
|
33
|
-
});
|
|
34
|
-
}, []);
|
|
35
|
-
return peers;
|
|
36
|
-
};
|
|
37
|
-
exports.useTestPartyBootstrap = useTestPartyBootstrap;
|
|
38
|
-
//# sourceMappingURL=useTestPartyBootstrap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTestPartyBootstrap.js","sourceRoot":"","sources":["../../../src/testing/useTestPartyBootstrap.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,iCAA4C;AAE5C,yCAA6C;AAE7C;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,EAAE;IACrD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqC,EAAE,CAAC,CAAC;IAE3E,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,YAAY,CAAC,KAAK,IAAI,EAAE;YACtB,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,IAAI,eAAM,EAAE,CAAC;YAC7B,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACzD,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;YAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;gBAClC,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;gBAC5B,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC1B,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3D,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC;gBACzD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACzF,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;aACpD;YAED,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AA1BW,QAAA,qBAAqB,yBA0BhC"}
|