@dxos/react-client 0.6.13 → 0.6.14-main.69511f5
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
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ClientProvider
|
|
4
|
+
} from "../chunk-E5UAY5Z4.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/sdk/react-client/src/testing/index.ts
|
|
7
|
+
export * from "@dxos/client/testing";
|
|
8
|
+
|
|
9
|
+
// packages/sdk/react-client/src/testing/ClientRepeater.tsx
|
|
10
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
11
|
+
import { Client } from "@dxos/client";
|
|
12
|
+
import { TestBuilder, performInvitation } from "@dxos/client/testing";
|
|
13
|
+
import { registerSignalsRuntime } from "@dxos/echo-signals/react";
|
|
14
|
+
import { faker } from "@dxos/random";
|
|
15
|
+
var ClientRepeater = (props) => {
|
|
16
|
+
const { component: Component, controls: Controls, count = 1, types, createIdentity, createSpace, onSpaceCreated } = props;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
registerSignalsRuntime();
|
|
19
|
+
}, []);
|
|
20
|
+
const [clients, setClients] = useState(props.clients ?? []);
|
|
21
|
+
const [spaceKey, setSpaceKey] = useState();
|
|
22
|
+
const testBuilder = useRef(new TestBuilder());
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const timeout = setTimeout(async () => {
|
|
25
|
+
const clients2 = [
|
|
26
|
+
...Array(count)
|
|
27
|
+
].map((_) => new Client({
|
|
28
|
+
services: testBuilder.current.createLocalClientServices(),
|
|
29
|
+
types
|
|
30
|
+
}));
|
|
31
|
+
await Promise.all(clients2.map((client) => client.initialize()));
|
|
32
|
+
if (createIdentity || createSpace) {
|
|
33
|
+
await Promise.all(clients2.map((client) => client.halo.createIdentity()));
|
|
34
|
+
}
|
|
35
|
+
if (createSpace) {
|
|
36
|
+
const client = clients2[0];
|
|
37
|
+
const space = await client.spaces.create({
|
|
38
|
+
name: faker.commerce.productName()
|
|
39
|
+
});
|
|
40
|
+
setSpaceKey(space.key);
|
|
41
|
+
await onSpaceCreated?.({
|
|
42
|
+
client,
|
|
43
|
+
space
|
|
44
|
+
});
|
|
45
|
+
await Promise.all(clients2.slice(1).flatMap((client2) => performInvitation({
|
|
46
|
+
host: space,
|
|
47
|
+
guest: client2.spaces
|
|
48
|
+
})));
|
|
49
|
+
}
|
|
50
|
+
setClients(clients2);
|
|
51
|
+
});
|
|
52
|
+
return () => clearTimeout(timeout);
|
|
53
|
+
}, []);
|
|
54
|
+
if (clients.length === 0) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, Controls && /* @__PURE__ */ React.createElement(Controls, {
|
|
58
|
+
clients
|
|
59
|
+
}), clients.map((client, index) => /* @__PURE__ */ React.createElement(ClientProvider, {
|
|
60
|
+
key: index,
|
|
61
|
+
client
|
|
62
|
+
}, /* @__PURE__ */ React.createElement(Component, {
|
|
63
|
+
id: index,
|
|
64
|
+
count: clients.length,
|
|
65
|
+
spaceKey,
|
|
66
|
+
...props.args
|
|
67
|
+
}))));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// packages/sdk/react-client/src/testing/withClientProvider.tsx
|
|
71
|
+
import React2, { createContext, useContext, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
72
|
+
import { ErrorBoundary as NativeErrorBoundary } from "react-error-boundary";
|
|
73
|
+
import { Trigger } from "@dxos/async";
|
|
74
|
+
import { performInvitation as performInvitation2, TestBuilder as TestBuilder2 } from "@dxos/client/testing";
|
|
75
|
+
import { log } from "@dxos/log";
|
|
76
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/react-client/src/testing/withClientProvider.tsx";
|
|
77
|
+
var initializeClient = async (client, { createIdentity, createSpace, onSpaceCreated, onInitialized }) => {
|
|
78
|
+
if (createIdentity || createSpace) {
|
|
79
|
+
if (!client.halo.identity.get()) {
|
|
80
|
+
await client.halo.createIdentity();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let space;
|
|
84
|
+
if (createSpace) {
|
|
85
|
+
space = await client.spaces.create({
|
|
86
|
+
name: "Test Space"
|
|
87
|
+
});
|
|
88
|
+
await onSpaceCreated?.({
|
|
89
|
+
client,
|
|
90
|
+
space
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
await onInitialized?.(client);
|
|
94
|
+
return space;
|
|
95
|
+
};
|
|
96
|
+
var withClientProvider = ({ createIdentity, createSpace, onSpaceCreated, onInitialized, ...props } = {}) => {
|
|
97
|
+
return (Story) => {
|
|
98
|
+
const handleInitialized = async (client) => {
|
|
99
|
+
await initializeClient(client, {
|
|
100
|
+
createIdentity,
|
|
101
|
+
createSpace,
|
|
102
|
+
onSpaceCreated,
|
|
103
|
+
onInitialized
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return /* @__PURE__ */ React2.createElement(ErrorBoundary, null, /* @__PURE__ */ React2.createElement(ClientProvider, {
|
|
107
|
+
onInitialized: handleInitialized,
|
|
108
|
+
...props
|
|
109
|
+
}, /* @__PURE__ */ React2.createElement(Story, null)));
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
var MultiClientContext = /* @__PURE__ */ createContext({
|
|
113
|
+
id: 0
|
|
114
|
+
});
|
|
115
|
+
var useMultiClient = () => useContext(MultiClientContext);
|
|
116
|
+
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onSpaceCreated, onInitialized, ...props }) => {
|
|
117
|
+
return (Story) => {
|
|
118
|
+
const builder = useRef2(new TestBuilder2());
|
|
119
|
+
const hostRef = useRef2();
|
|
120
|
+
const spaceReady = useRef2(new Trigger());
|
|
121
|
+
const handleInitialized = async (client, index) => {
|
|
122
|
+
log.info("initialized", {
|
|
123
|
+
index
|
|
124
|
+
}, {
|
|
125
|
+
F: __dxlog_file,
|
|
126
|
+
L: 109,
|
|
127
|
+
S: void 0,
|
|
128
|
+
C: (f, a) => f(...a)
|
|
129
|
+
});
|
|
130
|
+
if (createSpace) {
|
|
131
|
+
if (!hostRef.current) {
|
|
132
|
+
hostRef.current = client;
|
|
133
|
+
const space = await initializeClient(client, {
|
|
134
|
+
createIdentity,
|
|
135
|
+
createSpace,
|
|
136
|
+
onSpaceCreated,
|
|
137
|
+
onInitialized
|
|
138
|
+
});
|
|
139
|
+
spaceReady.current.wake(space);
|
|
140
|
+
log.info("inviting", {
|
|
141
|
+
index
|
|
142
|
+
}, {
|
|
143
|
+
F: __dxlog_file,
|
|
144
|
+
L: 115,
|
|
145
|
+
S: void 0,
|
|
146
|
+
C: (f, a) => f(...a)
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
await initializeClient(client, {
|
|
150
|
+
createIdentity,
|
|
151
|
+
onInitialized
|
|
152
|
+
});
|
|
153
|
+
const space = await spaceReady.current.wait();
|
|
154
|
+
if (space) {
|
|
155
|
+
log.info("joining", {
|
|
156
|
+
index
|
|
157
|
+
}, {
|
|
158
|
+
F: __dxlog_file,
|
|
159
|
+
L: 120,
|
|
160
|
+
S: void 0,
|
|
161
|
+
C: (f, a) => f(...a)
|
|
162
|
+
});
|
|
163
|
+
await Promise.all(performInvitation2({
|
|
164
|
+
host: space,
|
|
165
|
+
guest: client.spaces
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return /* @__PURE__ */ React2.createElement(ErrorBoundary, null, Array.from({
|
|
172
|
+
length: numClients
|
|
173
|
+
}).map((_, index) => /* @__PURE__ */ React2.createElement(MultiClientContext.Provider, {
|
|
174
|
+
key: index,
|
|
175
|
+
value: {
|
|
176
|
+
id: index
|
|
177
|
+
}
|
|
178
|
+
}, /* @__PURE__ */ React2.createElement(ClientProvider, {
|
|
179
|
+
services: builder.current.createLocalClientServices(),
|
|
180
|
+
onInitialized: (client) => handleInitialized(client, index),
|
|
181
|
+
...props
|
|
182
|
+
}, /* @__PURE__ */ React2.createElement(Story, null)))));
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
var ErrorBoundary = ({ children }) => {
|
|
186
|
+
const [error, setError] = useState2();
|
|
187
|
+
useEffect2(() => {
|
|
188
|
+
const handleError = (event) => {
|
|
189
|
+
setError(event.reason);
|
|
190
|
+
};
|
|
191
|
+
window.addEventListener("unhandledrejection", handleError);
|
|
192
|
+
return () => window.removeEventListener("unhandledrejection", handleError);
|
|
193
|
+
}, []);
|
|
194
|
+
if (error) {
|
|
195
|
+
return /* @__PURE__ */ React2.createElement(ErrorFallback, {
|
|
196
|
+
error,
|
|
197
|
+
resetErrorBoundary: () => setError(void 0)
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return /* @__PURE__ */ React2.createElement(NativeErrorBoundary, {
|
|
201
|
+
FallbackComponent: ErrorFallback
|
|
202
|
+
}, children);
|
|
203
|
+
};
|
|
204
|
+
var ErrorFallback = ({ error }) => {
|
|
205
|
+
const { name, message, stack } = error instanceof Error ? error : {
|
|
206
|
+
name: "Error",
|
|
207
|
+
message: String(error),
|
|
208
|
+
stack: void 0
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
211
|
+
role: "alert",
|
|
212
|
+
className: "flex flex-col p-4 gap-4 overflow-auto"
|
|
213
|
+
}, /* @__PURE__ */ React2.createElement("h1", {
|
|
214
|
+
className: "text-xl text-red-500"
|
|
215
|
+
}, name), /* @__PURE__ */ React2.createElement("div", {
|
|
216
|
+
className: "text-lg"
|
|
217
|
+
}, message), stack && /* @__PURE__ */ React2.createElement("pre", {
|
|
218
|
+
className: "whitespace-pre-wrap text-sm text-subdued"
|
|
219
|
+
}, stack));
|
|
220
|
+
};
|
|
221
|
+
export {
|
|
222
|
+
ClientRepeater,
|
|
223
|
+
useMultiClient,
|
|
224
|
+
withClientProvider,
|
|
225
|
+
withMultiClientProvider
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/testing/index.ts", "../../../../src/testing/ClientRepeater.tsx", "../../../../src/testing/withClientProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\nimport React, { useState, type FC, useEffect, useRef } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: S.Schema<any>[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space });\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onSpaceCreated?: (props: { client: Client; space: Space }) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n }: InitializeProps & Pick<WithClientProviderProps, 'onInitialized'>,\n): Promise<Space | undefined> => {\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.({ client, space });\n }\n\n await onInitialized?.(client);\n return space;\n};\n\nexport type WithClientProviderProps = InitializeProps & ClientProviderProps;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story) => {\n const handleInitialized = async (client: Client) => {\n await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <Story />\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps & ClientProviderProps & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const space = await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,cAAc;;;ACCd,OAAOA,SAASC,UAAmBC,WAAWC,cAAc;AAE5D,SAASC,cAA8B;AACvC,SAASC,aAAaC,yBAAyB;AAC/C,SAASC,8BAA8B;AACvC,SAASC,aAAa;AA8Bf,IAAMC,iBAAiB,CAAyCC,UAAAA;AACrE,QAAM,EACJC,WAAWC,WACXC,UAAUC,UACVC,QAAQ,GACRC,OACAC,gBACAC,aACAC,eAAc,IACZT;AACJU,YAAU,MAAA;AACRC,2BAAAA;EACF,GAAG,CAAA,CAAE;AAEL,QAAM,CAACC,SAASC,UAAAA,IAAcC,SAASd,MAAMY,WAAW,CAAA,CAAE;AAC1D,QAAM,CAACG,UAAUC,WAAAA,IAAeF,SAAAA;AAEhC,QAAMG,cAAcC,OAAO,IAAIC,YAAAA,CAAAA;AAC/BT,YAAU,MAAA;AACR,UAAMU,UAAUC,WAAW,YAAA;AACzB,YAAMT,WAAU;WAAIU,MAAMjB,KAAAA;QAAQkB,IAChC,CAACC,MAAM,IAAIC,OAAO;QAAEC,UAAUT,YAAYU,QAAQC,0BAAyB;QAAItB;MAAM,CAAA,CAAA;AAGvF,YAAMuB,QAAQC,IAAIlB,SAAQW,IAAI,CAACQ,WAAWA,OAAOC,WAAU,CAAA,CAAA;AAC3D,UAAIzB,kBAAkBC,aAAa;AAC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,OAAO;AACT,WAAO,gBAAAtC,OAAA,cAACgD,eAAAA;MAAcV;MAAcW,oBAAoB,MAAMV,SAASW,MAAAA;;EACzE;AAEA,SAAO,gBAAAlD,OAAA,cAACmD,qBAAAA;IAAoBC,mBAAmBJ;KAAgBX,QAAAA;AACjE;AAEA,IAAMW,gBAAgB,CAAC,EAAEV,MAAK,MAAiB;AAC7C,QAAM,EAAE3C,MAAM0D,SAASC,MAAK,IAC1BhB,iBAAiBiB,QAAQjB,QAAQ;IAAE3C,MAAM;IAAS0D,SAASG,OAAOlB,KAAAA;IAAQgB,OAAOJ;EAAU;AAC7F,SACE,gBAAAlD,OAAA,cAACyD,OAAAA;IAAIC,MAAK;IAAQC,WAAU;KAC1B,gBAAA3D,OAAA,cAAC4D,MAAAA;IAAGD,WAAU;KAAwBhE,IAAAA,GACtC,gBAAAK,OAAA,cAACyD,OAAAA;IAAIE,WAAU;KAAWN,OAAAA,GACzBC,SAAS,gBAAAtD,OAAA,cAAC6D,OAAAA;IAAIF,WAAU;KAA4CL,KAAAA,CAAAA;AAG3E;",
|
|
6
|
+
"names": ["React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onInitialized", "halo", "identity", "get", "space", "spaces", "create", "name", "withClientProvider", "props", "Story", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "MultiClientContext", "createContext", "id", "useMultiClient", "useContext", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "Provider", "key", "value", "services", "createLocalClientServices", "children", "error", "setError", "useState", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "undefined", "NativeErrorBoundary", "FallbackComponent", "message", "stack", "Error", "String", "div", "role", "className", "h1", "pre"]
|
|
7
|
+
}
|
|
@@ -13,6 +13,6 @@ export declare const AgentHostingContext: React.Context<AgentHostingProviderClie
|
|
|
13
13
|
* @constructor
|
|
14
14
|
* @deprecated
|
|
15
15
|
*/
|
|
16
|
-
export declare const AgentHostingProvider: (props: PropsWithChildren
|
|
16
|
+
export declare const AgentHostingProvider: (props: PropsWithChildren) => React.JSX.Element;
|
|
17
17
|
export declare const useAgentHostingClient: () => AgentHostingProviderClient | null;
|
|
18
18
|
//# sourceMappingURL=AgentHostingProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/AgentHostingProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAiB,KAAK,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAE3F,OAAO,EAAE,KAAK,0BAA0B,EAAgD,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,mBAAmB,kDAAyD,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/AgentHostingProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAiB,KAAK,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAE3F,OAAO,EAAE,KAAK,0BAA0B,EAAgD,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,mBAAmB,kDAAyD,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,sBAM5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,yCAEjC,CAAC"}
|
|
@@ -1,52 +1,89 @@
|
|
|
1
|
-
import React, { type FunctionComponent, type
|
|
1
|
+
import React, { type FunctionComponent, type PropsWithChildren } from 'react';
|
|
2
2
|
import { Client, type ClientOptions, type ClientServicesProvider } from '@dxos/client';
|
|
3
3
|
import { type Config } from '@dxos/config';
|
|
4
|
-
import { type S } from '@dxos/echo-schema';
|
|
5
4
|
import { type MaybePromise, type Provider } from '@dxos/util';
|
|
6
5
|
import { type ClientContextProps } from './context';
|
|
7
6
|
/**
|
|
8
7
|
* Properties for the ClientProvider.
|
|
9
8
|
*/
|
|
10
|
-
export type ClientProviderProps =
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Config object or async provider.
|
|
14
|
-
*/
|
|
15
|
-
config?: Config | Provider<Promise<Config>>;
|
|
9
|
+
export type ClientProviderProps = Omit<ClientOptions, 'config' | 'services'> & Pick<ClientContextProps, 'status'> & PropsWithChildren<{
|
|
16
10
|
/**
|
|
17
11
|
* Client object or async provider to enable to caller to do custom initialization.
|
|
18
12
|
*
|
|
19
|
-
*
|
|
13
|
+
* NOTE: For advanced use cases only.
|
|
20
14
|
*/
|
|
21
15
|
client?: Client | Provider<Promise<Client>>;
|
|
22
16
|
/**
|
|
23
|
-
*
|
|
17
|
+
* Config object or async provider.
|
|
24
18
|
*
|
|
25
|
-
*
|
|
19
|
+
* NOTE: If a `client` is provided then `config` is ignored.
|
|
26
20
|
*/
|
|
27
|
-
|
|
21
|
+
config?: Config | Provider<Promise<Config>>;
|
|
28
22
|
/**
|
|
29
|
-
*
|
|
23
|
+
* Callback to enable the caller to create a custom ClientServicesProvider.
|
|
24
|
+
*
|
|
25
|
+
* NOTE: If a `client` is provided then `services` is ignored.
|
|
30
26
|
*/
|
|
31
|
-
|
|
27
|
+
services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);
|
|
32
28
|
/**
|
|
33
29
|
* ReactNode to display until the client is available.
|
|
34
30
|
*/
|
|
35
31
|
fallback?: FunctionComponent<Partial<ClientContextProps>>;
|
|
36
32
|
/**
|
|
37
|
-
*
|
|
33
|
+
* Enable (by default) registration of Preact signals runtime for reactive ECHO objects.
|
|
34
|
+
* @see https://www.npmjs.com/package/@preact/signals-react
|
|
38
35
|
*/
|
|
39
|
-
|
|
36
|
+
signalsRuntime?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Skip the DXOS banner.
|
|
39
|
+
*/
|
|
40
|
+
noBanner?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* Post initialization hook to enable to caller to do custom initialization.
|
|
42
|
-
*
|
|
43
|
-
* @param Client
|
|
44
43
|
*/
|
|
45
44
|
onInitialized?: (client: Client) => MaybePromise<void>;
|
|
46
|
-
}
|
|
45
|
+
}>;
|
|
47
46
|
/**
|
|
48
47
|
* Root component that provides the DXOS client instance to child components.
|
|
49
48
|
* To be used with the `useClient` hook.
|
|
50
49
|
*/
|
|
51
|
-
export declare const ClientProvider:
|
|
50
|
+
export declare const ClientProvider: React.ForwardRefExoticComponent<Omit<ClientOptions, "services" | "config"> & Pick<ClientContextProps, "status"> & {
|
|
51
|
+
/**
|
|
52
|
+
* Client object or async provider to enable to caller to do custom initialization.
|
|
53
|
+
*
|
|
54
|
+
* NOTE: For advanced use cases only.
|
|
55
|
+
*/
|
|
56
|
+
client?: Client | Provider<Promise<Client>>;
|
|
57
|
+
/**
|
|
58
|
+
* Config object or async provider.
|
|
59
|
+
*
|
|
60
|
+
* NOTE: If a `client` is provided then `config` is ignored.
|
|
61
|
+
*/
|
|
62
|
+
config?: Config | Provider<Promise<Config>>;
|
|
63
|
+
/**
|
|
64
|
+
* Callback to enable the caller to create a custom ClientServicesProvider.
|
|
65
|
+
*
|
|
66
|
+
* NOTE: If a `client` is provided then `services` is ignored.
|
|
67
|
+
*/
|
|
68
|
+
services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);
|
|
69
|
+
/**
|
|
70
|
+
* ReactNode to display until the client is available.
|
|
71
|
+
*/
|
|
72
|
+
fallback?: FunctionComponent<Partial<ClientContextProps>>;
|
|
73
|
+
/**
|
|
74
|
+
* Enable (by default) registration of Preact signals runtime for reactive ECHO objects.
|
|
75
|
+
* @see https://www.npmjs.com/package/@preact/signals-react
|
|
76
|
+
*/
|
|
77
|
+
signalsRuntime?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Skip the DXOS banner.
|
|
80
|
+
*/
|
|
81
|
+
noBanner?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Post initialization hook to enable to caller to do custom initialization.
|
|
84
|
+
*/
|
|
85
|
+
onInitialized?: (client: Client) => MaybePromise<void>;
|
|
86
|
+
} & {
|
|
87
|
+
children?: React.ReactNode | undefined;
|
|
88
|
+
} & React.RefAttributes<Client | undefined>>;
|
|
52
89
|
//# sourceMappingURL=ClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAEZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAIvB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,sBAAsB,EAAgB,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAyB,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGnE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,UAAU,CAAC,GAC1E,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GAClC,iBAAiB,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5C;;;;OAIG;IAEH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5C;;;;OAIG;IAEH,QAAQ,CAAC,EAAE,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAEhG;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE1D;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,cAAc;IAjDvB;;;;OAIG;aACM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;aAEM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C;;;;OAIG;eAEQ,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAE/F;;OAEG;eACQ,iBAAiB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzD;;;OAGG;qBACc,OAAO;IAExB;;OAEG;eACQ,OAAO;IAElB;;OAEG;oBACa,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC;;;4CA4GzD,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type Client, type ClientServices, type SystemStatus } from '@dxos/client';
|
|
1
|
+
import { type Client, type SystemStatus } from '@dxos/client';
|
|
3
2
|
export type ClientContextProps = {
|
|
4
3
|
client: Client;
|
|
5
|
-
services?: ClientServices;
|
|
6
4
|
status?: SystemStatus | null;
|
|
7
5
|
};
|
|
8
|
-
export declare const ClientContext: Context<ClientContextProps | undefined>;
|
|
9
6
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/client/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/client/context.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC9B,CAAC"}
|
|
@@ -2,7 +2,6 @@ export * from './AgentHostingProvider';
|
|
|
2
2
|
export * from './ClientProvider';
|
|
3
3
|
export * from './context';
|
|
4
4
|
export * from './useClient';
|
|
5
|
-
export * from './useClientServices';
|
|
6
5
|
export * from './useClientStatus';
|
|
7
6
|
export * from './useConfig';
|
|
8
7
|
export * from './useShell';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAE1B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AAEH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,gBAC1C,KAAK,GAAG,IAAI,WACjB,YAAY,CAAC,CAAC,CAAC,YACd,YAAY,SACf,GAAG,EAAE,KACX,CAAC,EAuBH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
declare const _default: import("@playwright/test").PlaywrightTestConfig<{}, {}>;
|
|
2
|
+
export default _default;
|
|
3
3
|
//# sourceMappingURL=playwright.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":";AASA,wBAQG"}
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
+
import { type Schema as S } from '@effect/schema';
|
|
1
2
|
import React, { type FC } from 'react';
|
|
2
3
|
import { Client, type PublicKey } from '@dxos/client';
|
|
3
|
-
import { type
|
|
4
|
-
import { type S } from '@dxos/echo-schema';
|
|
5
|
-
import { type MaybePromise } from '@dxos/util';
|
|
4
|
+
import { type WithClientProviderProps } from './withClientProvider';
|
|
6
5
|
export type ClientRepeatedComponentProps = {
|
|
7
6
|
id: number;
|
|
8
7
|
count: number;
|
|
9
8
|
spaceKey?: PublicKey;
|
|
10
9
|
};
|
|
10
|
+
export type ClientRepeaterControlsProps = {
|
|
11
|
+
clients: Client[];
|
|
12
|
+
};
|
|
11
13
|
export type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {
|
|
12
14
|
className?: string;
|
|
13
15
|
component: FC<ClientRepeatedComponentProps>;
|
|
14
|
-
controls?: FC<
|
|
15
|
-
clients: Client[];
|
|
16
|
-
}>;
|
|
17
|
-
clients?: Client[];
|
|
16
|
+
controls?: FC<ClientRepeaterControlsProps>;
|
|
18
17
|
count?: number;
|
|
19
|
-
|
|
18
|
+
clients?: Client[];
|
|
20
19
|
types?: S.Schema<any>[];
|
|
21
|
-
createIdentity?: boolean;
|
|
22
|
-
createSpace?: boolean;
|
|
23
|
-
onCreateSpace?: (space: Space) => MaybePromise<void>;
|
|
24
20
|
args?: Omit<P, 'id' | 'count'>;
|
|
25
|
-
}
|
|
21
|
+
} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;
|
|
26
22
|
/**
|
|
27
23
|
* Utility component for Storybook stories which sets up clients for n peers.
|
|
28
24
|
* The `Component` property is rendered n times, once for each peer.
|
|
25
|
+
* @deprecated use `withClientProvider`.
|
|
29
26
|
*/
|
|
30
27
|
export declare const ClientRepeater: <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => React.JSX.Element | null;
|
|
31
28
|
//# sourceMappingURL=ClientRepeater.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientRepeater.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"ClientRepeater.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,EAAY,KAAK,EAAE,EAAqB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,MAAM,4BAA4B,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/F,MAAM,MAAM,2BAA2B,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAGhE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,4BAA4B,IAAI;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,EAAE,CAAC,4BAA4B,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,EAAE,CAAC,2BAA2B,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;CAChC,GAAG,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,GAAG,aAAa,GAAG,gBAAgB,CAAC,CAAC;AAEvF;;;;GAIG;AAMH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,4BAA4B,SAAS,mBAAmB,CAAC,CAAC,CAAC,6BA2DnG,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Client } from '@dxos/client';
|
|
2
|
+
import { Client, type Config } from '@dxos/client';
|
|
3
3
|
import { type Space } from '@dxos/client/echo';
|
|
4
|
-
export declare const createClient: ({ createIdentity, createSpace, }?: {
|
|
4
|
+
export declare const createClient: ({ config, createIdentity, createSpace, }?: {
|
|
5
|
+
config?: Config;
|
|
5
6
|
createIdentity?: boolean;
|
|
6
7
|
createSpace?: boolean;
|
|
7
8
|
}) => Promise<{
|
|
8
9
|
client: Client;
|
|
9
10
|
space: Space | undefined;
|
|
10
11
|
}>;
|
|
11
|
-
export declare const
|
|
12
|
+
export declare const createClientContextProvider: (client: Client) => Promise<({ children }: any) => React.JSX.Element>;
|
|
13
|
+
export declare const createClientProvider: (client: Client) => Promise<({ children }: any) => React.JSX.Element>;
|
|
12
14
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAY,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,YAAY,8CAItB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE;;;EActE,CAAC;AAEF,eAAO,MAAM,2BAA2B,WAAkB,MAAM,4BACxC,GAAG,uBAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAkB,MAAM,4BACjC,GAAG,uBAC1B,CAAC"}
|
|
@@ -6,7 +6,10 @@ import { type ClientProviderProps } from '../client';
|
|
|
6
6
|
type InitializeProps = {
|
|
7
7
|
createIdentity?: boolean;
|
|
8
8
|
createSpace?: boolean;
|
|
9
|
-
onSpaceCreated?: (
|
|
9
|
+
onSpaceCreated?: (props: {
|
|
10
|
+
client: Client;
|
|
11
|
+
space: Space;
|
|
12
|
+
}) => MaybePromise<void>;
|
|
10
13
|
};
|
|
11
14
|
export type WithClientProviderProps = InitializeProps & ClientProviderProps;
|
|
12
15
|
/**
|
|
@@ -16,6 +19,9 @@ export declare const withClientProvider: ({ createIdentity, createSpace, onSpace
|
|
|
16
19
|
export type WithMultiClientProviderProps = InitializeProps & ClientProviderProps & {
|
|
17
20
|
numClients?: number;
|
|
18
21
|
};
|
|
22
|
+
export declare const useMultiClient: () => {
|
|
23
|
+
id: number;
|
|
24
|
+
};
|
|
19
25
|
/**
|
|
20
26
|
* Decorator that creates a scaffold for multiple clients.
|
|
21
27
|
* Orchestrates invitations between a randomly selected host and the remaining clients.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"withClientProvider.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErE,KAAK,eAAe,GAAG;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAClF,CAAC;AA8BF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,mBAAmB,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,kBAAkB,8EAM5B,uBAAuB,KAAQ,SAcjC,CAAC;AAKF,MAAM,MAAM,4BAA4B,GAAG,eAAe,GAAG,mBAAmB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI3G,eAAO,MAAM,cAAc;QAFoB,MAAM;CAEa,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,yFAOjC,4BAA4B,KAAG,SA2CjC,CAAC"}
|
|
@@ -2,11 +2,12 @@ import '@dxos-theme';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
|
|
6
|
-
decorators: import("@storybook/react/*").Decorator[];
|
|
5
|
+
render: () => React.JSX.Element | null;
|
|
7
6
|
};
|
|
8
7
|
export default _default;
|
|
9
|
-
export declare const Default: {
|
|
8
|
+
export declare const Default: {
|
|
9
|
+
decorators: import("@storybook/react/*").Decorator[];
|
|
10
|
+
};
|
|
10
11
|
export declare const Multiple: {
|
|
11
12
|
decorators: import("@storybook/react/*").Decorator[];
|
|
12
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withClientProvider.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"withClientProvider.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;;;;;AAgC1B,wBAGE;AAaF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAMpB,CAAC"}
|