@dxos/react-client 0.6.13 → 0.6.14-main.1366248
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/dist/lib/browser/{chunk-CL7JDETM.mjs → chunk-U6WOCCWH.mjs} +62 -60
- package/dist/lib/browser/chunk-U6WOCCWH.mjs.map +7 -0
- package/dist/lib/browser/devtools/index.mjs +1 -1
- package/dist/lib/browser/echo/index.mjs +7 -5
- package/dist/lib/browser/echo/index.mjs.map +3 -3
- package/dist/lib/browser/halo/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/mesh/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +98 -37
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-C4EWAKPZ.cjs → chunk-BYDG3FH4.cjs} +63 -60
- package/dist/lib/node/chunk-BYDG3FH4.cjs.map +7 -0
- package/dist/lib/node/devtools/index.cjs +2 -2
- package/dist/lib/node/echo/index.cjs +8 -6
- package/dist/lib/node/echo/index.cjs.map +3 -3
- package/dist/lib/node/halo/index.cjs +5 -5
- package/dist/lib/node/index.cjs +12 -14
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/mesh/index.cjs +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +98 -36
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/chunk-E5UAY5Z4.mjs +295 -0
- package/dist/lib/node-esm/chunk-E5UAY5Z4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UYJUBYMU.mjs +165 -0
- package/dist/lib/node-esm/chunk-UYJUBYMU.mjs.map +7 -0
- package/dist/lib/node-esm/devtools/index.mjs +44 -0
- package/dist/lib/node-esm/devtools/index.mjs.map +7 -0
- package/dist/lib/node-esm/echo/index.mjs +134 -0
- package/dist/lib/node-esm/echo/index.mjs.map +7 -0
- package/dist/lib/node-esm/halo/index.mjs +100 -0
- package/dist/lib/node-esm/halo/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +33 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/invitations/index.mjs +18 -0
- package/dist/lib/node-esm/invitations/index.mjs.map +7 -0
- package/dist/lib/node-esm/mesh/index.mjs +18 -0
- package/dist/lib/node-esm/mesh/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/testing/index.mjs +227 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/worker.mjs +5 -0
- package/dist/lib/node-esm/worker.mjs.map +7 -0
- package/dist/types/src/client/AgentHostingProvider.d.ts +1 -1
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
- package/dist/types/src/client/ClientProvider.d.ts +57 -20
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/client/context.d.ts +1 -4
- package/dist/types/src/client/context.d.ts.map +1 -1
- package/dist/types/src/client/index.d.ts +0 -1
- package/dist/types/src/client/index.d.ts.map +1 -1
- package/dist/types/src/echo/useQuery.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +2 -2
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +9 -12
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts +7 -1
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +4 -3
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/package.json +45 -62
- package/project.json +3 -22
- package/src/client/AgentHostingProvider.tsx +1 -1
- package/src/client/ClientProvider.test.tsx +7 -4
- package/src/client/ClientProvider.tsx +126 -102
- package/src/client/context.ts +4 -5
- package/src/client/index.ts +0 -3
- package/src/client/useConfig.test.tsx +10 -12
- package/src/echo/useQuery.ts +3 -6
- package/src/echo/useSpaces.test.tsx +7 -9
- package/src/echo/useSpaces.ts +1 -1
- package/src/halo/useDevices.test.tsx +3 -5
- package/src/playwright/playwright.config.ts +13 -2
- package/src/playwright/smoke.spec.ts +5 -10
- package/src/testing/ClientRepeater.stories.tsx +1 -1
- package/src/testing/ClientRepeater.tsx +19 -20
- package/src/testing/util.tsx +12 -7
- package/src/testing/withClientProvider.stories.tsx +20 -11
- package/src/testing/withClientProvider.tsx +55 -24
- package/tsconfig.json +3 -59
- package/vitest.config.ts +22 -0
- package/dist/lib/browser/chunk-CL7JDETM.mjs.map +0 -7
- package/dist/lib/node/chunk-C4EWAKPZ.cjs.map +0 -7
- package/dist/types/src/client/useClientServices.d.ts +0 -3
- package/dist/types/src/client/useClientServices.d.ts.map +0 -1
- package/src/client/useClientServices.ts +0 -15
|
@@ -3,24 +3,22 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { act, renderHook } from '@testing-library/react';
|
|
6
|
-
import { expect } from '
|
|
7
|
-
|
|
8
|
-
import { describe, test } from '@dxos/test';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
9
7
|
|
|
10
8
|
import { useSpace, useSpaces } from './useSpaces';
|
|
11
|
-
import { createClient,
|
|
9
|
+
import { createClient, createClientContextProvider } from '../testing/util';
|
|
12
10
|
|
|
13
11
|
describe('useSpaces', () => {
|
|
14
12
|
test('lists existing spaces', async () => {
|
|
15
13
|
const { client } = await createClient({ createIdentity: true });
|
|
16
|
-
const wrapper = await
|
|
14
|
+
const wrapper = await createClientContextProvider(client);
|
|
17
15
|
const { result } = renderHook(() => useSpaces(), { wrapper });
|
|
18
16
|
expect(result.current.length).to.eq(1);
|
|
19
17
|
});
|
|
20
18
|
|
|
21
19
|
test('updates when new spaces are created', async () => {
|
|
22
20
|
const { client } = await createClient({ createIdentity: true });
|
|
23
|
-
const wrapper = await
|
|
21
|
+
const wrapper = await createClientContextProvider(client);
|
|
24
22
|
const { result, rerender } = renderHook(() => useSpaces(), { wrapper });
|
|
25
23
|
expect(result.current.length).to.eq(1);
|
|
26
24
|
await act(async () => {
|
|
@@ -34,12 +32,12 @@ describe('useSpaces', () => {
|
|
|
34
32
|
describe('useSpace', () => {
|
|
35
33
|
test('gets default space', async () => {
|
|
36
34
|
const { client } = await createClient();
|
|
37
|
-
const wrapper = await
|
|
35
|
+
const wrapper = await createClientContextProvider(client);
|
|
38
36
|
const { result, rerender } = renderHook(() => useSpace(), { wrapper });
|
|
39
37
|
expect(result.current).to.be.undefined;
|
|
40
38
|
await act(async () => {
|
|
41
39
|
await client.halo.createIdentity();
|
|
42
|
-
await client.spaces.
|
|
40
|
+
await client.spaces.waitUntilReady();
|
|
43
41
|
});
|
|
44
42
|
rerender();
|
|
45
43
|
expect(result.current).to.not.be.undefined;
|
|
@@ -47,7 +45,7 @@ describe('useSpace', () => {
|
|
|
47
45
|
|
|
48
46
|
test('gets space by key', async () => {
|
|
49
47
|
const { client, space } = await createClient({ createIdentity: true, createSpace: true });
|
|
50
|
-
const wrapper = await
|
|
48
|
+
const wrapper = await createClientContextProvider(client);
|
|
51
49
|
const { result } = renderHook(() => useSpace(space!.key), { wrapper });
|
|
52
50
|
expect(result.current).to.not.be.undefined;
|
|
53
51
|
});
|
package/src/echo/useSpaces.ts
CHANGED
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { renderHook } from '@testing-library/react';
|
|
6
|
-
import { expect } from '
|
|
7
|
-
|
|
8
|
-
import { describe, test } from '@dxos/test';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
9
7
|
|
|
10
8
|
import { useDevices } from './useDevices';
|
|
11
|
-
import { createClient,
|
|
9
|
+
import { createClient, createClientContextProvider } from '../testing/util';
|
|
12
10
|
|
|
13
11
|
describe('useDevices', () => {
|
|
14
12
|
test('lists existing devices', async () => {
|
|
15
13
|
const { client } = await createClient({ createIdentity: true });
|
|
16
|
-
const wrapper = await
|
|
14
|
+
const wrapper = await createClientContextProvider(client);
|
|
17
15
|
const { result } = renderHook(() => useDevices(), { wrapper });
|
|
18
16
|
expect(result.current?.length).to.eq(1);
|
|
19
17
|
});
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { nxE2EPreset } from '@nx/playwright/preset';
|
|
6
|
+
import { defineConfig } from '@playwright/test';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
import { e2ePreset } from '@dxos/test-utils/playwright';
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
...nxE2EPreset(__filename, { testDir: __dirname }),
|
|
12
|
+
...e2ePreset(__dirname),
|
|
13
|
+
webServer: {
|
|
14
|
+
command: 'pnpm -w nx storybook-e2e stories',
|
|
15
|
+
port: 9009,
|
|
16
|
+
reuseExistingServer: !process.env.CI,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Page, test } from '@playwright/test';
|
|
6
|
-
import { expect } from 'chai';
|
|
5
|
+
import { type Page, expect, test } from '@playwright/test';
|
|
7
6
|
|
|
8
|
-
import { setupPage } from '@dxos/test/playwright';
|
|
7
|
+
import { setupPage } from '@dxos/test-utils/playwright';
|
|
9
8
|
|
|
10
9
|
// TODO(wittjosiah): Factor out.
|
|
11
10
|
// TODO(burdon): No hard-coding of ports; reconcile all DXOS tools ports.
|
|
@@ -15,17 +14,13 @@ test.describe('Smoke test', () => {
|
|
|
15
14
|
let page: Page;
|
|
16
15
|
|
|
17
16
|
test.beforeAll(async ({ browser }) => {
|
|
18
|
-
const result = await setupPage(browser, {
|
|
19
|
-
url: storybookUrl('react-client-withclientprovider--default'),
|
|
20
|
-
waitFor: (page) => page.isVisible(':has-text("initialized")'),
|
|
21
|
-
});
|
|
22
|
-
|
|
17
|
+
const result = await setupPage(browser, { url: storybookUrl('sdk-react-client-withclientprovider--default') });
|
|
23
18
|
page = result.page;
|
|
19
|
+
await page.locator(':text("initialized")').waitFor({ state: 'visible' });
|
|
24
20
|
});
|
|
25
21
|
|
|
26
22
|
// NOTE: This test depends on connecting to the default production deployed HALO vault.
|
|
27
23
|
test('Renders remote client info', async () => {
|
|
28
|
-
|
|
29
|
-
expect(isVisible).to.be.true;
|
|
24
|
+
await expect(page.locator(':text("initialized")')).toBeVisible();
|
|
30
25
|
});
|
|
31
26
|
});
|
|
@@ -2,37 +2,36 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Schema as S } from '@effect/schema';
|
|
5
6
|
import React, { useState, type FC, useEffect, useRef } from 'react';
|
|
6
7
|
|
|
7
8
|
import { Client, type PublicKey } from '@dxos/client';
|
|
8
|
-
import { type Space } from '@dxos/client/echo';
|
|
9
9
|
import { TestBuilder, performInvitation } from '@dxos/client/testing';
|
|
10
|
-
import {
|
|
11
|
-
import { registerSignalFactory } from '@dxos/echo-signals/react';
|
|
10
|
+
import { registerSignalsRuntime } from '@dxos/echo-signals/react';
|
|
12
11
|
import { faker } from '@dxos/random';
|
|
13
|
-
import { type MaybePromise } from '@dxos/util';
|
|
14
12
|
|
|
13
|
+
import { type WithClientProviderProps } from './withClientProvider';
|
|
15
14
|
import { ClientProvider } from '../client';
|
|
16
15
|
|
|
17
16
|
export type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };
|
|
18
17
|
|
|
18
|
+
export type ClientRepeaterControlsProps = { clients: Client[] };
|
|
19
|
+
|
|
20
|
+
// TODO(burdon): Reconcile with ClientProviderProps.
|
|
19
21
|
export type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {
|
|
20
22
|
className?: string;
|
|
21
23
|
component: FC<ClientRepeatedComponentProps>;
|
|
22
|
-
controls?: FC<
|
|
23
|
-
clients?: Client[];
|
|
24
|
+
controls?: FC<ClientRepeaterControlsProps>;
|
|
24
25
|
count?: number;
|
|
25
|
-
|
|
26
|
+
clients?: Client[];
|
|
26
27
|
types?: S.Schema<any>[];
|
|
27
|
-
createIdentity?: boolean;
|
|
28
|
-
createSpace?: boolean;
|
|
29
|
-
onCreateSpace?: (space: Space) => MaybePromise<void>;
|
|
30
28
|
args?: Omit<P, 'id' | 'count'>;
|
|
31
|
-
}
|
|
29
|
+
} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* Utility component for Storybook stories which sets up clients for n peers.
|
|
35
33
|
* The `Component` property is rendered n times, once for each peer.
|
|
34
|
+
* @deprecated use `withClientProvider`.
|
|
36
35
|
*/
|
|
37
36
|
// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.
|
|
38
37
|
// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.
|
|
@@ -47,11 +46,11 @@ export const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: Cl
|
|
|
47
46
|
types,
|
|
48
47
|
createIdentity,
|
|
49
48
|
createSpace,
|
|
50
|
-
|
|
49
|
+
onSpaceCreated,
|
|
51
50
|
} = props;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
registerSignalsRuntime();
|
|
53
|
+
}, []);
|
|
55
54
|
|
|
56
55
|
const [clients, setClients] = useState(props.clients ?? []);
|
|
57
56
|
const [spaceKey, setSpaceKey] = useState<PublicKey>();
|
|
@@ -60,19 +59,19 @@ export const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: Cl
|
|
|
60
59
|
useEffect(() => {
|
|
61
60
|
const timeout = setTimeout(async () => {
|
|
62
61
|
const clients = [...Array(count)].map(
|
|
63
|
-
(_) => new Client({ services: testBuilder.current.createLocalClientServices() }),
|
|
62
|
+
(_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),
|
|
64
63
|
);
|
|
65
|
-
await Promise.all(clients.map((client) => client.initialize()));
|
|
66
|
-
types && clients.map((client) => client.addTypes(types));
|
|
67
64
|
|
|
65
|
+
await Promise.all(clients.map((client) => client.initialize()));
|
|
68
66
|
if (createIdentity || createSpace) {
|
|
69
67
|
await Promise.all(clients.map((client) => client.halo.createIdentity()));
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
if (createSpace) {
|
|
73
|
-
const
|
|
71
|
+
const client = clients[0];
|
|
72
|
+
const space = await client.spaces.create({ name: faker.commerce.productName() });
|
|
74
73
|
setSpaceKey(space.key);
|
|
75
|
-
await
|
|
74
|
+
await onSpaceCreated?.({ client, space });
|
|
76
75
|
await Promise.all(
|
|
77
76
|
clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),
|
|
78
77
|
);
|
package/src/testing/util.tsx
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Client, fromHost } from '@dxos/client';
|
|
7
|
+
import { Client, type Config, fromHost } from '@dxos/client';
|
|
8
8
|
import { type Space } from '@dxos/client/echo';
|
|
9
9
|
|
|
10
|
-
import { ClientContext } from '../client';
|
|
10
|
+
import { ClientContext, ClientProvider } from '../client';
|
|
11
11
|
|
|
12
|
+
// TODO(burdon): Reconcile with initializeClient.
|
|
12
13
|
export const createClient = async ({
|
|
14
|
+
config,
|
|
13
15
|
createIdentity,
|
|
14
16
|
createSpace,
|
|
15
|
-
}: { createIdentity?: boolean; createSpace?: boolean } = {}) => {
|
|
16
|
-
const client = new Client({ services: fromHost() });
|
|
17
|
+
}: { config?: Config; createIdentity?: boolean; createSpace?: boolean } = {}) => {
|
|
18
|
+
const client = new Client({ config, services: fromHost(config) });
|
|
17
19
|
await client.initialize();
|
|
18
20
|
if (createIdentity) {
|
|
19
21
|
await client.halo.createIdentity();
|
|
@@ -22,13 +24,16 @@ export const createClient = async ({
|
|
|
22
24
|
let space: Space | undefined;
|
|
23
25
|
if (createSpace) {
|
|
24
26
|
space = await client.spaces.create();
|
|
25
|
-
await client.spaces.
|
|
27
|
+
await client.spaces.waitUntilReady();
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
return { client, space };
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
export const createContextProvider = async (client: Client) => {
|
|
33
|
+
export const createClientContextProvider = async (client: Client) => {
|
|
33
34
|
return ({ children }: any) => <ClientContext.Provider value={{ client }}>{children}</ClientContext.Provider>;
|
|
34
35
|
};
|
|
36
|
+
|
|
37
|
+
export const createClientProvider = async (client: Client) => {
|
|
38
|
+
return ({ children }: any) => <ClientProvider client={client}>{children}</ClientProvider>;
|
|
39
|
+
};
|
|
@@ -6,10 +6,11 @@ import '@dxos-theme';
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
|
+
import { log } from '@dxos/log';
|
|
9
10
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
11
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
12
|
|
|
12
|
-
import { withClientProvider, withMultiClientProvider } from './withClientProvider';
|
|
13
|
+
import { withClientProvider, type WithClientProviderProps, withMultiClientProvider } from './withClientProvider';
|
|
13
14
|
import { useClient } from '../client';
|
|
14
15
|
import { type Space, useSpaces } from '../echo';
|
|
15
16
|
|
|
@@ -36,21 +37,29 @@ const Test = () => {
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
export default {
|
|
39
|
-
title: 'react-client/withClientProvider',
|
|
40
|
-
|
|
41
|
-
decorators: [withTheme, withClientProvider({ createIdentity: true })],
|
|
40
|
+
title: 'sdk/react-client/withClientProvider',
|
|
41
|
+
render: Test,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const clientProps: WithClientProviderProps = {
|
|
45
|
+
createIdentity: true,
|
|
46
|
+
createSpace: true,
|
|
47
|
+
onInitialized: async (client) => {
|
|
48
|
+
log.info('onInitialized', { client });
|
|
49
|
+
},
|
|
50
|
+
onSpaceCreated: async ({ client, space }) => {
|
|
51
|
+
log.info('onSpaceCreated', { client, space });
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Default = {
|
|
56
|
+
decorators: [withClientProvider(clientProps), withTheme, withLayout({ classNames: ['flex gap-2'] })],
|
|
57
|
+
};
|
|
45
58
|
|
|
46
59
|
export const Multiple = {
|
|
47
60
|
decorators: [
|
|
48
|
-
withMultiClientProvider({
|
|
49
|
-
numClients: 3,
|
|
50
|
-
createIdentity: true,
|
|
51
|
-
createSpace: true,
|
|
52
|
-
}),
|
|
53
|
-
withLayout({ classNames: ['flex gap-2'] }),
|
|
61
|
+
withMultiClientProvider({ ...clientProps, numClients: 3 }),
|
|
54
62
|
withTheme,
|
|
63
|
+
withLayout({ classNames: ['flex gap-2'] }),
|
|
55
64
|
],
|
|
56
65
|
};
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
|
-
import React, { useRef } from 'react';
|
|
7
|
-
import { type FallbackProps, ErrorBoundary } from 'react-error-boundary';
|
|
6
|
+
import React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';
|
|
8
8
|
|
|
9
9
|
import { Trigger } from '@dxos/async';
|
|
10
10
|
import { type Client } from '@dxos/client';
|
|
11
11
|
import { type Space } from '@dxos/client/echo';
|
|
12
12
|
import { performInvitation, TestBuilder } from '@dxos/client/testing';
|
|
13
|
+
import { log } from '@dxos/log';
|
|
13
14
|
import { type MaybePromise } from '@dxos/util';
|
|
14
15
|
|
|
15
16
|
import { ClientProvider, type ClientProviderProps } from '../client';
|
|
@@ -17,7 +18,7 @@ import { ClientProvider, type ClientProviderProps } from '../client';
|
|
|
17
18
|
type InitializeProps = {
|
|
18
19
|
createIdentity?: boolean;
|
|
19
20
|
createSpace?: boolean;
|
|
20
|
-
onSpaceCreated?: (client: Client
|
|
21
|
+
onSpaceCreated?: (props: { client: Client; space: Space }) => MaybePromise<void>;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -32,14 +33,16 @@ const initializeClient = async (
|
|
|
32
33
|
onInitialized,
|
|
33
34
|
}: InitializeProps & Pick<WithClientProviderProps, 'onInitialized'>,
|
|
34
35
|
): Promise<Space | undefined> => {
|
|
35
|
-
if (createIdentity) {
|
|
36
|
-
|
|
36
|
+
if (createIdentity || createSpace) {
|
|
37
|
+
if (!client.halo.identity.get()) {
|
|
38
|
+
await client.halo.createIdentity();
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
let space: Space | undefined;
|
|
40
43
|
if (createSpace) {
|
|
41
44
|
space = await client.spaces.create({ name: 'Test Space' });
|
|
42
|
-
await onSpaceCreated?.(client, space);
|
|
45
|
+
await onSpaceCreated?.({ client, space });
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
await onInitialized?.(client);
|
|
@@ -58,17 +61,19 @@ export const withClientProvider = ({
|
|
|
58
61
|
onInitialized,
|
|
59
62
|
...props
|
|
60
63
|
}: WithClientProviderProps = {}): Decorator => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
return (Story) => {
|
|
65
|
+
const handleInitialized = async (client: Client) => {
|
|
66
|
+
await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });
|
|
67
|
+
};
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
return (
|
|
70
|
+
<ErrorBoundary>
|
|
71
|
+
<ClientProvider onInitialized={handleInitialized} {...props}>
|
|
72
|
+
<Story />
|
|
73
|
+
</ClientProvider>
|
|
74
|
+
</ErrorBoundary>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
72
77
|
};
|
|
73
78
|
|
|
74
79
|
// TODO(burdon): Implement context per client for context.
|
|
@@ -76,6 +81,10 @@ export const withClientProvider = ({
|
|
|
76
81
|
// TODO(burdon): Delay/jitter for creation of other clients.
|
|
77
82
|
export type WithMultiClientProviderProps = InitializeProps & ClientProviderProps & { numClients?: number };
|
|
78
83
|
|
|
84
|
+
const MultiClientContext = createContext<{ id: number }>({ id: 0 });
|
|
85
|
+
|
|
86
|
+
export const useMultiClient = () => useContext(MultiClientContext);
|
|
87
|
+
|
|
79
88
|
/**
|
|
80
89
|
* Decorator that creates a scaffold for multiple clients.
|
|
81
90
|
* Orchestrates invitations between a randomly selected host and the remaining clients.
|
|
@@ -95,16 +104,20 @@ export const withMultiClientProvider = ({
|
|
|
95
104
|
const spaceReady = useRef(new Trigger<Space | undefined>());
|
|
96
105
|
|
|
97
106
|
// Handle invitations.
|
|
98
|
-
|
|
107
|
+
// NOTE: The zeroth client isn't necessarily the first to be initialized.
|
|
108
|
+
const handleInitialized = async (client: Client, index: number) => {
|
|
109
|
+
log.info('initialized', { index });
|
|
99
110
|
if (createSpace) {
|
|
100
111
|
if (!hostRef.current) {
|
|
101
112
|
hostRef.current = client;
|
|
102
113
|
const space = await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });
|
|
103
114
|
spaceReady.current.wake(space);
|
|
115
|
+
log.info('inviting', { index });
|
|
104
116
|
} else {
|
|
105
117
|
await initializeClient(client, { createIdentity, onInitialized });
|
|
106
118
|
const space = await spaceReady.current.wait();
|
|
107
119
|
if (space) {
|
|
120
|
+
log.info('joining', { index });
|
|
108
121
|
await Promise.all(performInvitation({ host: space, guest: client.spaces }));
|
|
109
122
|
}
|
|
110
123
|
}
|
|
@@ -112,31 +125,49 @@ export const withMultiClientProvider = ({
|
|
|
112
125
|
};
|
|
113
126
|
|
|
114
127
|
return (
|
|
115
|
-
|
|
128
|
+
<ErrorBoundary>
|
|
116
129
|
{Array.from({ length: numClients }).map((_, index) => (
|
|
117
|
-
<
|
|
130
|
+
<MultiClientContext.Provider key={index} value={{ id: index }}>
|
|
118
131
|
<ClientProvider
|
|
119
132
|
services={builder.current.createLocalClientServices()}
|
|
120
|
-
onInitialized={
|
|
133
|
+
onInitialized={(client) => handleInitialized(client, index)}
|
|
121
134
|
{...props}
|
|
122
135
|
>
|
|
123
136
|
<Story />
|
|
124
137
|
</ClientProvider>
|
|
125
|
-
</
|
|
138
|
+
</MultiClientContext.Provider>
|
|
126
139
|
))}
|
|
127
|
-
|
|
140
|
+
</ErrorBoundary>
|
|
128
141
|
);
|
|
129
142
|
};
|
|
130
143
|
};
|
|
131
144
|
|
|
145
|
+
const ErrorBoundary = ({ children }: PropsWithChildren) => {
|
|
146
|
+
const [error, setError] = useState<Error>();
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
const handleError = (event: PromiseRejectionEvent) => {
|
|
149
|
+
setError(event.reason);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
window.addEventListener('unhandledrejection', handleError);
|
|
153
|
+
return () => window.removeEventListener('unhandledrejection', handleError);
|
|
154
|
+
}, []);
|
|
155
|
+
|
|
156
|
+
if (error) {
|
|
157
|
+
return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;
|
|
161
|
+
};
|
|
162
|
+
|
|
132
163
|
const ErrorFallback = ({ error }: FallbackProps) => {
|
|
133
164
|
const { name, message, stack } =
|
|
134
165
|
error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };
|
|
135
166
|
return (
|
|
136
|
-
<div role='alert' className='flex flex-col gap-4'>
|
|
167
|
+
<div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>
|
|
137
168
|
<h1 className='text-xl text-red-500'>{name}</h1>
|
|
138
169
|
<div className='text-lg'>{message}</div>
|
|
139
|
-
{stack && <pre className='text-sm text-subdued'>{stack}</pre>}
|
|
170
|
+
{stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}
|
|
140
171
|
</div>
|
|
141
172
|
);
|
|
142
173
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,72 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../../tsconfig.json",
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"jsx": "react",
|
|
5
5
|
"lib": [
|
|
6
6
|
"DOM",
|
|
7
7
|
"ESNext"
|
|
8
8
|
],
|
|
9
|
-
"module": "ESNext"
|
|
10
|
-
"outDir": "dist/types"
|
|
9
|
+
"module": "ESNext"
|
|
11
10
|
},
|
|
12
11
|
"include": [
|
|
13
12
|
"playwright",
|
|
14
13
|
"src"
|
|
15
14
|
],
|
|
16
|
-
"references": [
|
|
17
|
-
{
|
|
18
|
-
"path": "../../common/async"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"path": "../../common/codec-protobuf"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "../../common/debug"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"path": "../../common/invariant"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"path": "../../common/log"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../../common/node-std"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../common/random"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../common/util"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../core/echo/echo-schema"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"path": "../../core/echo/echo-signals"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"path": "../../core/protocols"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"path": "../../ui/primitives/react-hooks"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"path": "../../ui/react-ui"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"path": "../../ui/react-ui-syntax-highlighter"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"path": "../../ui/react-ui-theme"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"path": "../../ui/storybook-utils"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"path": "../client"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"path": "../config"
|
|
70
|
-
}
|
|
71
|
-
]
|
|
15
|
+
"references": []
|
|
72
16
|
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
6
|
+
|
|
7
|
+
import { baseConfig } from '../../../vitest.shared';
|
|
8
|
+
|
|
9
|
+
// TODO(wittjosiah): Factor out to shared config as an option.
|
|
10
|
+
const specifiedEnv = (process.env.VITEST_ENV ?? 'node').toLowerCase();
|
|
11
|
+
const environment = specifiedEnv === 'node' ? 'jsdom' : undefined;
|
|
12
|
+
|
|
13
|
+
export default mergeConfig(
|
|
14
|
+
baseConfig({ cwd: __dirname }),
|
|
15
|
+
defineConfig({
|
|
16
|
+
test: {
|
|
17
|
+
environment,
|
|
18
|
+
// TODO(dmaretskyi): Enabled because client tests were flaky. Remove when that's not the case.
|
|
19
|
+
retry: 2,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/client/AgentHostingProvider.tsx", "../../../src/client/ClientProvider.tsx", "../../../src/client/context.ts", "../../../src/banner.ts", "../../../src/client/useClient.ts", "../../../src/client/useClientServices.ts", "../../../src/client/useClientStatus.ts", "../../../src/client/useConfig.ts", "../../../src/client/useShell.ts", "../../../src/client/useStatus.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { createContext, type PropsWithChildren, useContext, useState } from 'react';\n\nimport { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client';\nimport { type Halo } from '@dxos/client/halo';\nimport { type Config } from '@dxos/config';\nimport { log } from '@dxos/log';\n\nimport { useClient } from '../client';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\n\nexport const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);\n\n/**\n * Experimental agent hosting provider.\n * @param props\n * @constructor\n * @deprecated\n */\nexport const AgentHostingProvider = (props: PropsWithChildren<{}>) => {\n const client = useClient();\n const [agentHostingProviderClient] = useState(makeClient(client));\n return (\n <AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>\n );\n};\n\nexport const useAgentHostingClient = () => {\n return useContext(AgentHostingContext);\n};\n\nconst makeClient = ({ config, halo }: AgentHostingProviderProps) => {\n const agentHostingConfig = config.get('runtime.services.agentHosting');\n if (!agentHostingConfig) {\n log('no agent hosting configured');\n return null;\n }\n\n // TODO(nf): Dynamically discover based on runtime config.\n let agentHostingProviderClient: AgentHostingProviderClient | null = null;\n switch (agentHostingConfig.type) {\n case 'LOCAL_TESTING': {\n log('using FakeAgentHostingProvider');\n return new FakeAgentHostingProvider();\n }\n\n case 'AGENTHOSTING_API': {\n agentHostingProviderClient = new AgentManagerClient(config, halo);\n if (agentHostingProviderClient.init()) {\n return agentHostingProviderClient;\n } else {\n // Not authorized or error initializing.\n return null;\n }\n }\n\n default: {\n log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);\n return null;\n }\n }\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport React, { type FunctionComponent, type ReactNode, useEffect, useMemo, useState } from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalFactory } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { useControlledValue } from '@dxos/react-hooks';\nimport { getAsyncProviderValue, type MaybePromise, type Provider } from '@dxos/util';\n\nimport { ClientContext, type ClientContextProps } from './context';\nimport { printBanner } from '../banner';\n\n/**\n * Properties for the ClientProvider.\n */\nexport type ClientProviderProps = Pick<ClientContextProps, 'status'> &\n Omit<ClientOptions, 'config' | 'services'> & {\n children?: ReactNode;\n\n /**\n * Config object or async provider.\n */\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * Most apps won't need this.\n */\n // TODO(wittjosiah): Remove async and just use to keep reference to client?\n // (Preferring `onInitialized` for custom initialization.)\n // TODO(burdon): Use useImperativeHandle to expose client.\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * Most apps won't need this.\n */\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * List of schema to register.\n */\n types?: S.Schema<any>[];\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Set to false to stop default signal factory from being registered.\n */\n // TODO(burdon): Move to options.\n registerSignalFactory?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n *\n * @param Client\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n };\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = ({\n children,\n config: configProvider,\n client: clientProvider,\n services: servicesProvider,\n types,\n status: controlledStatus,\n fallback: Fallback = () => null,\n registerSignalFactory: _registerSignalFactory = true,\n onInitialized,\n ...options\n}: ClientProviderProps) => {\n useMemo(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n _registerSignalFactory && registerSignalFactory();\n }, []);\n\n const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : undefined);\n\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n // Status subscription.\n const [status, setStatus] = useControlledValue(controlledStatus);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n // Initialize client.\n useEffect(() => {\n const done = async (client: Client) => {\n await client.initialize().catch(setError);\n log('client ready');\n await onInitialized?.(client);\n log('initialization complete');\n if (types) {\n client.addTypes(types);\n }\n\n setClient(client);\n setStatus(client.status.get() ?? SystemStatus.ACTIVE);\n printBanner(client);\n };\n\n const t = setTimeout(async () => {\n if (clientProvider) {\n // Asynchronously request client.\n const client = await getAsyncProviderValue(clientProvider);\n await done(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, config);\n log('created services', { services });\n const client = new Client({ config, services, ...options });\n log('created client');\n await done(client);\n }\n });\n\n return () => {\n log('clean up');\n clearTimeout(t);\n void client?.destroy().catch((err) => log.catch(err));\n };\n }, [clientProvider, configProvider, servicesProvider]);\n\n if (!client || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type ClientServices, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n\n // Optionally expose services (e.g., for devtools).\n services?: ClientServices;\n\n status?: SystemStatus | null;\n};\n\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted) {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type ClientServices } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useClientServices = (): ClientServices | undefined => {\n const { services } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return services;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error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BiB,KAAI,GAAI;AACrC,eAAOjB;MACT,OAAO;AAEL,eAAO;MACT;IACF;IAEA,SAAS;AACPa,MAAAA,KAAIK,MAAM,0CAA0CP,mBAAmBG,MAAI,QAAA;;;;;;AAC3E,aAAO;IACT;EACF;AACF;",
|
|
6
|
-
"names": ["React", "createContext", "useContext", "useState", "AgentManagerClient", "FakeAgentHostingProvider", "log", "React", "useEffect", "useMemo", "useState", "Client", "SystemStatus", "registerSignalFactory", "log", "useControlledValue", "getAsyncProviderValue", "createContext", "ClientContext", "createContext", "undefined", "BANNER", "client", "commitHash", "config", "get", "hash", "version", "bannerPrinted", "printBanner", "console", "log", "ClientProvider", "children", "config", "configProvider", "client", "clientProvider", "services", "servicesProvider", "types", "status", "controlledStatus", "fallback", "Fallback", "registerSignalFactory", "_registerSignalFactory", "onInitialized", "options", "useMemo", "setClient", "useState", "Client", "undefined", "error", "setError", "setStatus", "useControlledValue", "useEffect", "subscription", "subscribe", "unsubscribe", "done", "initialize", "catch", "log", "addTypes", "get", "SystemStatus", "ACTIVE", "printBanner", "t", "setTimeout", "getAsyncProviderValue", "clearTimeout", "destroy", "err", "ClientContext", "Provider", "value", "useContext", "raise", "useClient", "client", "useContext", "ClientContext", "raise", "Error", "useContext", "raise", "useClientServices", "services", "useContext", "ClientContext", "raise", "Error", "useEffect", "useState", "useClientStatus", "client", "status", "setStatus", "useState", "useEffect", "subscription", "subscribe", "unsubscribe", "useContext", "raise", "useConfig", "client", "useContext", "ClientContext", "raise", "Error", "config", "useEffect", "useState", "useShell", "client", "useClient", "shell", "useShellDisplay", "display", "setDisplay", "useState", "useEffect", "onDisplayChange", "useContext", "raise", "useStatus", "status", "useContext", "ClientContext", "raise", "Error", "AgentHostingContext", "createContext", "AgentHostingProvider", "props", "client", "useClient", "agentHostingProviderClient", "useState", "makeClient", "React", "Provider", "value", "children", "useAgentHostingClient", "useContext", "config", "halo", "agentHostingConfig", "get", "log", "type", "FakeAgentHostingProvider", "AgentManagerClient", "init", "error"]
|
|
7
|
-
}
|