@dxos/react-client 0.10.0 → 0.11.0
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/.storybook/main.mts +1 -1
- package/.storybook/preview.mts +2 -2
- package/CHANGELOG.md +57 -0
- package/dist/lib/chunk-ClientProvider.mjs +152 -0
- package/dist/lib/chunk-ClientProvider.mjs.map +1 -0
- package/dist/lib/chunk-context.mjs +14 -0
- package/dist/lib/chunk-context.mjs.map +1 -0
- package/dist/lib/chunk-useClient.mjs +16 -0
- package/dist/lib/chunk-useClient.mjs.map +1 -0
- package/dist/lib/devtools.mjs +37 -0
- package/dist/lib/devtools.mjs.map +1 -0
- package/dist/lib/echo.mjs +230 -0
- package/dist/lib/echo.mjs.map +1 -0
- package/dist/lib/halo.mjs +85 -0
- package/dist/lib/halo.mjs.map +1 -0
- package/dist/lib/index.mjs +108 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/invitations.mjs +130 -0
- package/dist/lib/invitations.mjs.map +1 -0
- package/dist/lib/mesh.mjs +14 -0
- package/dist/lib/mesh.mjs.map +1 -0
- package/dist/lib/testing.mjs +206 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/client/AgentHostingProvider.d.ts +0 -3
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
- package/dist/types/src/client/context.d.ts +4 -1
- package/dist/types/src/client/context.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +1 -0
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useFeedSyncState.d.ts +1 -1
- package/dist/types/src/echo/useFlush.d.ts +10 -0
- package/dist/types/src/echo/useFlush.d.ts.map +1 -0
- package/dist/types/src/echo/useSpaces.d.ts +0 -10
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +1 -12
- package/package.json +32 -45
- package/src/client/AgentHostingProvider.tsx +5 -8
- package/src/client/context.ts +11 -2
- package/src/echo/index.ts +1 -0
- package/src/echo/useFeedSyncState.ts +4 -4
- package/src/echo/useFlush.ts +39 -0
- package/src/echo/useSpaces.ts +0 -14
- package/src/echo/useSyncState.ts +2 -2
- package/src/halo/Passkey.stories.tsx +1 -1
- package/src/testing/withClientProvider.stories.tsx +1 -1
- package/vite.config.ts +19 -0
- package/dist/lib/browser/chunk-3LVU7RNK.mjs +0 -16
- package/dist/lib/browser/chunk-3LVU7RNK.mjs.map +0 -7
- package/dist/lib/browser/chunk-CZMIVAGI.mjs +0 -8
- package/dist/lib/browser/chunk-CZMIVAGI.mjs.map +0 -7
- package/dist/lib/browser/chunk-SSDQ6NXU.mjs +0 -153
- package/dist/lib/browser/chunk-SSDQ6NXU.mjs.map +0 -7
- package/dist/lib/browser/chunk-XT352YI6.mjs +0 -134
- package/dist/lib/browser/chunk-XT352YI6.mjs.map +0 -7
- package/dist/lib/browser/devtools/index.mjs +0 -39
- package/dist/lib/browser/devtools/index.mjs.map +0 -7
- package/dist/lib/browser/echo/index.mjs +0 -239
- package/dist/lib/browser/echo/index.mjs.map +0 -7
- package/dist/lib/browser/halo/index.mjs +0 -109
- package/dist/lib/browser/halo/index.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -119
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/invitations/index.mjs +0 -17
- package/dist/lib/browser/invitations/index.mjs.map +0 -7
- package/dist/lib/browser/mesh/index.mjs +0 -18
- package/dist/lib/browser/mesh/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs +0 -204
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -3
- package/dist/lib/browser/worker.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CUDKNAMV.mjs +0 -17
- package/dist/lib/node-esm/chunk-CUDKNAMV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JZNSBWIR.mjs +0 -155
- package/dist/lib/node-esm/chunk-JZNSBWIR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs +0 -135
- package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUTK2IJF.mjs +0 -10
- package/dist/lib/node-esm/chunk-WUTK2IJF.mjs.map +0 -7
- package/dist/lib/node-esm/devtools/index.mjs +0 -40
- package/dist/lib/node-esm/devtools/index.mjs.map +0 -7
- package/dist/lib/node-esm/echo/index.mjs +0 -240
- package/dist/lib/node-esm/echo/index.mjs.map +0 -7
- package/dist/lib/node-esm/halo/index.mjs +0 -110
- package/dist/lib/node-esm/halo/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -120
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/invitations/index.mjs +0 -18
- package/dist/lib/node-esm/invitations/index.mjs.map +0 -7
- package/dist/lib/node-esm/mesh/index.mjs +0 -19
- package/dist/lib/node-esm/mesh/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -205
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -5
- package/dist/lib/node-esm/worker.mjs.map +0 -7
- package/dist/types/src/worker.d.ts +0 -2
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/worker.ts +0 -5
- package/vitest.config.ts +0 -16
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as useClient } from "./chunk-useClient.mjs";
|
|
2
|
+
import { useInvitationStatus } from "./invitations.mjs";
|
|
3
|
+
import { useMemo, useReducer } from "react";
|
|
4
|
+
import { useMulticastObservable } from "@dxos/react-hooks";
|
|
5
|
+
import { Device, DeviceKind, DeviceType } from "@dxos/client/halo";
|
|
6
|
+
//#region src/halo/useContacts.ts
|
|
7
|
+
/**
|
|
8
|
+
* Returns all known Contacts across all Spaces.
|
|
9
|
+
* Contacts are known members of a common Space.
|
|
10
|
+
* Requires ClientContext to be set via ClientProvider.
|
|
11
|
+
*/
|
|
12
|
+
var useContacts = () => {
|
|
13
|
+
return useMulticastObservable(useClient().halo.contacts);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/halo/useCredentials.ts
|
|
17
|
+
var useCredentials = () => {
|
|
18
|
+
return useMulticastObservable(useClient().halo.credentials);
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/halo/useDevices.ts
|
|
22
|
+
var useDevices = () => {
|
|
23
|
+
return useMulticastObservable(useClient().halo.devices);
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/halo/useHaloInvitations.ts
|
|
27
|
+
var useHaloInvitations = () => {
|
|
28
|
+
return useMulticastObservable(useClient().halo.invitations);
|
|
29
|
+
};
|
|
30
|
+
var useHaloInvitation = (invitationId) => {
|
|
31
|
+
const invitations = useHaloInvitations();
|
|
32
|
+
return useInvitationStatus(useMemo(() => invitations.find((invitation) => invitation.get().invitationId === invitationId), [invitations]));
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/halo/useIdentity.ts
|
|
36
|
+
/**
|
|
37
|
+
* Hook returning DXOS identity object.
|
|
38
|
+
* Requires ClientContext to be set via ClientProvider.
|
|
39
|
+
*/
|
|
40
|
+
var useIdentity = () => {
|
|
41
|
+
return useMulticastObservable(useClient().halo.identity);
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/halo/useKeyStore.ts
|
|
45
|
+
var KeyStore = class {
|
|
46
|
+
_defaultKeys;
|
|
47
|
+
_keyMap = /* @__PURE__ */ new Map();
|
|
48
|
+
constructor(_defaultKeys = []) {
|
|
49
|
+
this._defaultKeys = _defaultKeys;
|
|
50
|
+
}
|
|
51
|
+
get map() {
|
|
52
|
+
return this._keyMap;
|
|
53
|
+
}
|
|
54
|
+
initialize() {
|
|
55
|
+
this._defaultKeys.forEach((key) => {
|
|
56
|
+
const value = localStorage.getItem(key);
|
|
57
|
+
this.setKey(key, value ?? "");
|
|
58
|
+
});
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
getKey(key) {
|
|
62
|
+
localStorage.getItem(key);
|
|
63
|
+
}
|
|
64
|
+
setKey(key, value) {
|
|
65
|
+
localStorage.setItem(key, "");
|
|
66
|
+
this._keyMap.set(key, value);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Settings store.
|
|
71
|
+
* @deprecated Replace with HALO key store when available.
|
|
72
|
+
*/
|
|
73
|
+
var useKeyStore = (defaultKeys = []) => {
|
|
74
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
75
|
+
const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);
|
|
76
|
+
const setKey = (key, value) => {
|
|
77
|
+
store.setKey(key, value);
|
|
78
|
+
forceUpdate();
|
|
79
|
+
};
|
|
80
|
+
return [store.map, setKey];
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { Device, DeviceKind, DeviceType, KeyStore, useContacts, useCredentials, useDevices, useHaloInvitation, useHaloInvitations, useIdentity, useKeyStore };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=halo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halo.mjs","names":[],"sources":["../../src/halo/useContacts.ts","../../src/halo/useCredentials.ts","../../src/halo/useDevices.ts","../../src/halo/useHaloInvitations.ts","../../src/halo/useIdentity.ts","../../src/halo/useKeyStore.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Credential } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useCredentials = (): Credential[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.credentials);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n","//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize(): this {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string): void {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string): void {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,oBAA+B;CAE1C,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,QAAQ;AACpD;;;ACRA,IAAa,uBAAqC;CAEhD,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,WAAW;AACvD;;;ACHA,IAAa,mBAA6B;CAExC,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,OAAO;AACnD;;;ACDA,IAAa,2BAA8D;CAEzE,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,WAAW;AACvD;AAEA,IAAa,qBAAqB,iBAA0B;CAC1D,MAAM,cAAc,mBAAmB;CAKvC,OAAO,oBAJY,cACX,YAAY,MAAM,eAAe,WAAW,IAAI,CAAC,CAAC,iBAAiB,YAAY,GACrF,CAAC,WAAW,CAEa,CAAU;AACvC;;;;;;;ACVA,IAAa,oBAAqC;CAEhD,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,QAAQ;AACpD;;;ACTA,IAAa,WAAb,MAAsB;CAGS;CAF7B,0BAAkB,IAAI,IAAoB;CAE1C,YAAY,eAA0C,CAAC,GAAG;EAA7B,KAAA,eAAA;CAA8B;CAE3D,IAAI,MAAM;EACR,OAAO,KAAK;CACd;CAGA,aAAmB;EACjB,KAAK,aAAa,SAAS,QAAQ;GACjC,MAAM,QAAQ,aAAa,QAAQ,GAAG;GACtC,KAAK,OAAO,KAAK,SAAS,EAAE;EAC9B,CAAC;EAED,OAAO;CACT;CAEA,OAAO,KAAmB;EACxB,aAAa,QAAQ,GAAG;CAC1B;CAEA,OAAO,KAAa,OAAqB;EACvC,aAAa,QAAQ,KAAK,EAAE;EAC5B,KAAK,QAAQ,IAAI,KAAK,KAAK;CAC7B;AACF;;;;;AAMA,IAAa,eACX,cAAwB,CAAC,MACuC;CAChE,MAAM,GAAG,eAAe,YAAY,MAAM,IAAI,GAAG,CAAC;CAClD,MAAM,QAAQ,cAAc,IAAI,SAAS,WAAW,CAAC,CAAC,WAAW,GAAG,CAAC,WAAW,CAAC;CACjF,MAAM,UAAU,KAAa,UAAkB;EAC7C,MAAM,OAAO,KAAK,KAAK;EACvB,YAAY;CACd;CAEA,OAAO,CAAC,MAAM,KAAK,MAAM;AAC3B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { n as ClientContext, r as useAgentHostingClient, t as AgentHostingContext } from "./chunk-context.mjs";
|
|
2
|
+
import { t as useClient } from "./chunk-useClient.mjs";
|
|
3
|
+
import { t as ClientProvider } from "./chunk-ClientProvider.mjs";
|
|
4
|
+
import { raise } from "@dxos/debug";
|
|
5
|
+
import { useContext, useEffect, useState } from "react";
|
|
6
|
+
import { AgentManagerClient, FakeAgentHostingProvider } from "@dxos/client";
|
|
7
|
+
import { log } from "@dxos/log";
|
|
8
|
+
import { jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useMulticastObservable } from "@dxos/react-hooks";
|
|
10
|
+
export * from "@dxos/client";
|
|
11
|
+
//#region src/client/AgentHostingProvider.tsx
|
|
12
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/client/AgentHostingProvider.tsx";
|
|
13
|
+
/**
|
|
14
|
+
* Experimental agent hosting provider.
|
|
15
|
+
* @param props
|
|
16
|
+
* @constructor
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
var AgentHostingProvider = (props) => {
|
|
20
|
+
const [agentHostingProviderClient] = useState(makeClient(useClient()));
|
|
21
|
+
return /* @__PURE__ */ jsxs(AgentHostingContext.Provider, {
|
|
22
|
+
value: agentHostingProviderClient,
|
|
23
|
+
children: [" ", props.children]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var makeClient = ({ config, halo }) => {
|
|
27
|
+
const agentHostingConfig = config.get("runtime.services.agentHosting");
|
|
28
|
+
if (!agentHostingConfig) {
|
|
29
|
+
log("no agent hosting configured", void 0, {
|
|
30
|
+
"~LogMeta": "~LogMeta",
|
|
31
|
+
F: __dxlog_file,
|
|
32
|
+
L: 36,
|
|
33
|
+
S: void 0
|
|
34
|
+
});
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
let agentHostingProviderClient = null;
|
|
38
|
+
switch (agentHostingConfig.type) {
|
|
39
|
+
case "LOCAL_TESTING":
|
|
40
|
+
log("using FakeAgentHostingProvider", void 0, {
|
|
41
|
+
"~LogMeta": "~LogMeta",
|
|
42
|
+
F: __dxlog_file,
|
|
43
|
+
L: 44,
|
|
44
|
+
S: void 0
|
|
45
|
+
});
|
|
46
|
+
return new FakeAgentHostingProvider();
|
|
47
|
+
case "AGENTHOSTING_API":
|
|
48
|
+
agentHostingProviderClient = new AgentManagerClient(config, halo);
|
|
49
|
+
if (agentHostingProviderClient.init()) return agentHostingProviderClient;
|
|
50
|
+
else return null;
|
|
51
|
+
default:
|
|
52
|
+
log.error("Unknown agent hosting provider type: " + agentHostingConfig.type, void 0, {
|
|
53
|
+
"~LogMeta": "~LogMeta",
|
|
54
|
+
F: __dxlog_file,
|
|
55
|
+
L: 59,
|
|
56
|
+
S: void 0
|
|
57
|
+
});
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/client/useClientStatus.ts
|
|
63
|
+
var useClientStatus = (client) => {
|
|
64
|
+
const [status, setStatus] = useState();
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!client) return;
|
|
67
|
+
const subscription = client.status.subscribe((status) => setStatus(status));
|
|
68
|
+
return () => subscription.unsubscribe();
|
|
69
|
+
}, [client, setStatus]);
|
|
70
|
+
return status;
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/client/useConfig.ts
|
|
74
|
+
/**
|
|
75
|
+
* Hook returning config object used to initialize the DXOS client instance.
|
|
76
|
+
* Requires ClientContext to be set via ClientProvider.
|
|
77
|
+
*/
|
|
78
|
+
var useConfig = () => {
|
|
79
|
+
const { client } = useContext(ClientContext) ?? raise(/* @__PURE__ */ new Error("Missing ClientContext."));
|
|
80
|
+
return client.config;
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/client/useShell.ts
|
|
84
|
+
/**
|
|
85
|
+
* Helper hook to access the shell.
|
|
86
|
+
*/
|
|
87
|
+
var useShell = () => {
|
|
88
|
+
return useClient().shell;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Hook to access the shell’s display state.
|
|
92
|
+
*/
|
|
93
|
+
var useShellDisplay = () => {
|
|
94
|
+
const client = useClient();
|
|
95
|
+
const [display, setDisplay] = useState(client.shell.display);
|
|
96
|
+
useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);
|
|
97
|
+
return display;
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/client/useStatus.ts
|
|
101
|
+
var useStatus = () => {
|
|
102
|
+
const { status } = useContext(ClientContext) ?? raise(/* @__PURE__ */ new Error("Missing ClientContext."));
|
|
103
|
+
return status;
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
export { AgentHostingContext, AgentHostingProvider, ClientContext, ClientProvider, useAgentHostingClient, useClient, useClientStatus, useConfig, useMulticastObservable, useShell, useShellDisplay, useStatus };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/AgentHostingProvider.tsx","../../src/client/useClientStatus.ts","../../src/client/useConfig.ts","../../src/client/useShell.ts","../../src/client/useStatus.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type PropsWithChildren, 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\n// Imported from the defining module, not the directory barrel: `'../client'` is this file's own\n// barrel, and that cycle made every downstream edit a full page reload.\nimport { AgentHostingContext } from './context';\nimport { useClient } from './useClient';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\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\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 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('Missing ClientContext.'));\n return status;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,IAAa,wBAAwB,UAA6B;CAEhE,MAAM,CAAC,8BAA8B,SAAS,WAD/B,UAC0C,CAAM,CAAC;CAChE,OACE,qBAAC,oBAAoB,UAArB;EAA8B,OAAO;YAArC,CAAiE,KAAE,MAAM,QAAuC;;AAEpH;AAEA,IAAM,cAAc,EAAE,QAAQ,WAAsC;CAClE,MAAM,qBAAqB,OAAO,IAAI,+BAA+B;CACrE,IAAI,CAAC,oBAAoB;EACvB,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AK,sBAAM,IAAI,MAAM,wBAAwB,CAAC;CACzF,OAAO;AACT"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useReducer } from "react";
|
|
2
|
+
import { log } from "@dxos/log";
|
|
3
|
+
import { AuthenticatingInvitationObservable, CancellableInvitationObservable, Invitation, Invitation as Invitation$1, InvitationEncoder, InvitationEncoder as InvitationEncoder$1, InvitationsProxy } from "@dxos/client/invitations";
|
|
4
|
+
//#region src/invitations/useInvitationStatus.ts
|
|
5
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/invitations/useInvitationStatus.ts";
|
|
6
|
+
var isShareableInvitation = (invitation) => invitation.authMethod !== Invitation$1.AuthMethod.KNOWN_PUBLIC_KEY || !!invitation.guestKeypair?.privateKey;
|
|
7
|
+
var useInvitationStatus = (observable) => {
|
|
8
|
+
const [state, dispatch] = useReducer((prev, action) => {
|
|
9
|
+
log("useInvitationStatus", { action }, {
|
|
10
|
+
"~LogMeta": "~LogMeta",
|
|
11
|
+
F: __dxlog_file,
|
|
12
|
+
L: 91,
|
|
13
|
+
S: void 0
|
|
14
|
+
});
|
|
15
|
+
const invitationProps = "invitation" in action ? {
|
|
16
|
+
id: action.invitation.invitationId,
|
|
17
|
+
multiUse: action.invitation.multiUse,
|
|
18
|
+
invitationCode: InvitationEncoder$1.encode(action.invitation),
|
|
19
|
+
authCode: action.invitation.authCode,
|
|
20
|
+
authMethod: action.invitation.authMethod,
|
|
21
|
+
shareable: isShareableInvitation(action.invitation),
|
|
22
|
+
type: action.invitation.type
|
|
23
|
+
} : {};
|
|
24
|
+
return {
|
|
25
|
+
...prev,
|
|
26
|
+
...invitationProps,
|
|
27
|
+
status: action.status,
|
|
28
|
+
result: action.status === Invitation$1.State.SUCCESS ? action.result : prev.result,
|
|
29
|
+
...action.status === Invitation$1.State.ERROR && { error: action.error },
|
|
30
|
+
...(action.status === Invitation$1.State.ERROR || action.status === Invitation$1.State.CANCELLED || action.status === Invitation$1.State.TIMEOUT) && { haltedAt: typeof prev.haltedAt === "undefined" ? action.haltedAt : prev.haltedAt }
|
|
31
|
+
};
|
|
32
|
+
}, null, (_arg) => {
|
|
33
|
+
const invitation = observable?.get();
|
|
34
|
+
return {
|
|
35
|
+
status: Invitation$1.State.INIT,
|
|
36
|
+
result: {
|
|
37
|
+
spaceKey: null,
|
|
38
|
+
identityKey: null,
|
|
39
|
+
swarmKey: null,
|
|
40
|
+
target: null
|
|
41
|
+
},
|
|
42
|
+
id: invitation?.invitationId,
|
|
43
|
+
multiUse: invitation?.multiUse,
|
|
44
|
+
invitationCode: invitation ? InvitationEncoder$1.encode(invitation) : void 0,
|
|
45
|
+
authCode: invitation?.authCode,
|
|
46
|
+
authMethod: invitation?.authMethod,
|
|
47
|
+
shareable: invitation ? isShareableInvitation(invitation) : false,
|
|
48
|
+
type: invitation?.type
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const update = (invitation) => {
|
|
53
|
+
switch (invitation.state) {
|
|
54
|
+
case Invitation$1.State.INIT:
|
|
55
|
+
case Invitation$1.State.CONNECTED:
|
|
56
|
+
case Invitation$1.State.READY_FOR_AUTHENTICATION:
|
|
57
|
+
case Invitation$1.State.AUTHENTICATING:
|
|
58
|
+
dispatch({
|
|
59
|
+
invitation,
|
|
60
|
+
status: invitation.state
|
|
61
|
+
});
|
|
62
|
+
break;
|
|
63
|
+
case Invitation$1.State.SUCCESS:
|
|
64
|
+
dispatch({
|
|
65
|
+
invitation,
|
|
66
|
+
status: invitation.state,
|
|
67
|
+
result: {
|
|
68
|
+
spaceKey: invitation.spaceKey || null,
|
|
69
|
+
identityKey: invitation.identityKey || null,
|
|
70
|
+
swarmKey: invitation.swarmKey || null,
|
|
71
|
+
target: invitation.target || null
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case Invitation$1.State.CANCELLED:
|
|
76
|
+
case Invitation$1.State.TIMEOUT:
|
|
77
|
+
dispatch({
|
|
78
|
+
invitation,
|
|
79
|
+
status: invitation.state,
|
|
80
|
+
haltedAt: state.status
|
|
81
|
+
});
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const subscription = observable?.subscribe(update, (err) => {
|
|
86
|
+
dispatch({
|
|
87
|
+
status: Invitation$1.State.ERROR,
|
|
88
|
+
error: err,
|
|
89
|
+
haltedAt: state.status
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
const currentState = observable?.get();
|
|
93
|
+
if (currentState) update(currentState);
|
|
94
|
+
return () => subscription?.unsubscribe();
|
|
95
|
+
}, [observable, state.status]);
|
|
96
|
+
const connect = useCallback((observable) => {
|
|
97
|
+
dispatch({
|
|
98
|
+
invitation: observable.get(),
|
|
99
|
+
status: Invitation$1.State.CONNECTING,
|
|
100
|
+
observable
|
|
101
|
+
});
|
|
102
|
+
}, []);
|
|
103
|
+
const authenticate = useCallback((authCode) => {
|
|
104
|
+
log("authenticating...", { authCode }, {
|
|
105
|
+
"~LogMeta": "~LogMeta",
|
|
106
|
+
F: __dxlog_file,
|
|
107
|
+
L: 196,
|
|
108
|
+
S: void 0
|
|
109
|
+
});
|
|
110
|
+
return observable.authenticate(authCode);
|
|
111
|
+
}, [observable]);
|
|
112
|
+
const cancel = useCallback(async () => observable?.cancel(), [observable]);
|
|
113
|
+
return useMemo(() => {
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
cancel,
|
|
117
|
+
connect,
|
|
118
|
+
authenticate
|
|
119
|
+
};
|
|
120
|
+
}, [
|
|
121
|
+
state,
|
|
122
|
+
cancel,
|
|
123
|
+
connect,
|
|
124
|
+
authenticate
|
|
125
|
+
]);
|
|
126
|
+
};
|
|
127
|
+
//#endregion
|
|
128
|
+
export { AuthenticatingInvitationObservable, CancellableInvitationObservable, Invitation, InvitationEncoder, InvitationsProxy, useInvitationStatus };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=invitations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitations.mjs","names":[],"sources":["../../src/invitations/useInvitationStatus.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { useCallback, useEffect, useMemo, useReducer } from 'react';\n\nimport { type PublicKey } from '@dxos/client';\nimport {\n type AuthenticatingInvitationObservable,\n type CancellableInvitationObservable,\n Invitation,\n InvitationEncoder,\n} from '@dxos/client/invitations';\nimport { log } from '@dxos/log';\n\nexport type InvitationResult = {\n spaceKey: PublicKey | null;\n identityKey: PublicKey | null;\n swarmKey: PublicKey | null;\n target: string | null;\n};\n\ninterface InvitationReducerState {\n status: Invitation.State; // TODO(burdon): Rename state.\n haltedAt?: Invitation.State;\n result: InvitationResult;\n error?: Error;\n id?: string;\n multiUse?: boolean;\n shareable?: boolean;\n invitationCode?: string;\n authCode?: string;\n authMethod?: Invitation.AuthMethod;\n type?: Invitation.Type;\n}\n\ntype InvitationPayload = { invitation: Invitation };\n\nexport type InvitationAction =\n | ({\n status:\n | Invitation.State.INIT\n | Invitation.State.CONNECTED\n | Invitation.State.READY_FOR_AUTHENTICATION\n | Invitation.State.AUTHENTICATING;\n } & InvitationPayload)\n | ({\n status: Invitation.State.CONNECTING;\n observable: CancellableInvitationObservable;\n } & InvitationPayload)\n | ({\n status: Invitation.State.SUCCESS;\n result: InvitationResult;\n } & InvitationPayload)\n | ({\n status: Invitation.State.CANCELLED | Invitation.State.TIMEOUT;\n haltedAt: Invitation.State;\n } & InvitationPayload)\n | {\n status: Invitation.State.ERROR;\n error?: Error;\n haltedAt: Invitation.State;\n };\n\nexport type InvitationStatus = {\n id?: string;\n invitationCode?: string;\n authCode?: string;\n authMethod?: Invitation.AuthMethod;\n type?: Invitation.Type;\n status: Invitation.State;\n haltedAt?: Invitation.State;\n multiUse?: boolean;\n shareable?: boolean;\n result: InvitationResult;\n error?: Error;\n cancel(): void;\n // TODO(wittjosiah): Remove?\n connect(observable: CancellableInvitationObservable): void;\n authenticate(authCode: string): Promise<void>;\n};\n\n// Without private key, the invitation code cannot be created.\n// These invitations are only available to be accepted but not shared.\nconst isShareableInvitation = (invitation: Invitation) =>\n invitation.authMethod !== Invitation.AuthMethod.KNOWN_PUBLIC_KEY || !!invitation.guestKeypair?.privateKey;\n\nexport const useInvitationStatus = (observable?: CancellableInvitationObservable): InvitationStatus => {\n const [state, dispatch] = useReducer(\n (prev: InvitationReducerState, action: InvitationAction): InvitationReducerState => {\n log('useInvitationStatus', { action });\n const invitationProps =\n 'invitation' in action\n ? {\n id: action.invitation.invitationId,\n multiUse: action.invitation.multiUse,\n invitationCode: InvitationEncoder.encode(action.invitation),\n authCode: action.invitation.authCode,\n authMethod: action.invitation.authMethod,\n shareable: isShareableInvitation(action.invitation),\n type: action.invitation.type,\n }\n : {};\n return {\n ...prev,\n ...invitationProps,\n // TODO(burdon): State.\n status: action.status,\n // `invitationObservable`, `secret`, and `result` is persisted between the status-actions that set them.\n result: action.status === Invitation.State.SUCCESS ? action.result : prev.result,\n // `error` gets set each time we enter the error state\n ...(action.status === Invitation.State.ERROR && { error: action.error }),\n // `haltedAt` gets set on only the first error/cancelled/timeout action and reset on any others.\n ...((action.status === Invitation.State.ERROR ||\n action.status === Invitation.State.CANCELLED ||\n action.status === Invitation.State.TIMEOUT) && {\n haltedAt: typeof prev.haltedAt === 'undefined' ? action.haltedAt : prev.haltedAt,\n }),\n };\n },\n null,\n (_arg: null): InvitationReducerState => {\n const invitation = observable?.get();\n return {\n status: Invitation.State.INIT,\n result: { spaceKey: null, identityKey: null, swarmKey: null, target: null },\n id: invitation?.invitationId,\n multiUse: invitation?.multiUse,\n invitationCode: invitation ? InvitationEncoder.encode(invitation) : undefined,\n authCode: invitation?.authCode,\n authMethod: invitation?.authMethod,\n shareable: invitation ? isShareableInvitation(invitation) : false,\n type: invitation?.type,\n };\n },\n );\n\n // Handle unmount.\n\n useEffect(() => {\n const update = (invitation: Invitation) => {\n switch (invitation.state) {\n case Invitation.State.INIT:\n case Invitation.State.CONNECTED:\n case Invitation.State.READY_FOR_AUTHENTICATION:\n case Invitation.State.AUTHENTICATING: {\n dispatch({\n invitation,\n status: invitation.state,\n });\n break;\n }\n\n case Invitation.State.SUCCESS: {\n dispatch({\n invitation,\n status: invitation.state,\n result: {\n spaceKey: invitation.spaceKey || null,\n identityKey: invitation.identityKey || null,\n swarmKey: invitation.swarmKey || null,\n target: invitation.target || null,\n },\n });\n break;\n }\n\n case Invitation.State.CANCELLED:\n case Invitation.State.TIMEOUT: {\n dispatch({ invitation, status: invitation.state, haltedAt: state.status });\n break;\n }\n }\n };\n\n const subscription = observable?.subscribe(update, (err: Error) => {\n dispatch({ status: Invitation.State.ERROR, error: err, haltedAt: state.status });\n });\n\n const currentState = observable?.get();\n if (currentState) {\n update(currentState);\n }\n\n return () => subscription?.unsubscribe();\n }, [observable, state.status]);\n\n // Return memoized callbacks & values.\n\n const connect = useCallback((observable: CancellableInvitationObservable) => {\n dispatch({ invitation: observable.get(), status: Invitation.State.CONNECTING, observable });\n }, []);\n\n const authenticate = useCallback(\n (authCode: string) => {\n log('authenticating...', { authCode });\n return (observable as AuthenticatingInvitationObservable).authenticate(authCode);\n },\n [observable],\n );\n\n const cancel = useCallback(async () => observable?.cancel(), [observable]);\n\n return useMemo(() => {\n return {\n ...state,\n cancel,\n connect,\n authenticate,\n };\n }, [state, cancel, connect, authenticate]);\n};\n"],"mappings":";;;;;AAoFA,IAAM,yBAAyB,eAC7B,WAAW,eAAe,aAAW,WAAW,oBAAoB,CAAC,CAAC,WAAW,cAAc;AAEjG,IAAa,uBAAuB,eAAmE;CACrG,MAAM,CAAC,OAAO,YAAY,YACvB,MAA8B,WAAqD;EAClF,IAAI,uBAAuB,EAAE,OAAO,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;EACrC,MAAM,kBACJ,gBAAgB,SACZ;GACE,IAAI,OAAO,WAAW;GACtB,UAAU,OAA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,YAAY;OACjC,QAAQ,WAAW,UAAU;MAC/B;KACF,CAAC;KACD;IAGF,KAAK,aAAW,MAAM;IACtB,KAAK,aAAW,MAAM;KACpB,SAAS;MAAE;MAAY,QAAQ,WAAW;MAAO,UAAU,MAAM;KAAO,CAAC;KACzE;GAEJ;EACF;EAEA,MAAM,eAAe,YAAY,UAAU,SAAS,QAAe;GACjE,SAAS;IAAE,QAAQ,aAAW,MAAM;IAAO,OAAO;IAAK,UAAU,MAAM;GAAO,CAAC;EACjF,CAAC;EAED,MAAM,eAAe,YAAY,IAAI;EACrC,IAAI,cACF,OAAO,YAAY;EAGrB,aAAa,cAAc,YAAY;CACzC,GAAG,CAAC,YAAY,MAAM,MAAM,CAAC;CAI7B,MAAM,UAAU,aAAa,eAAgD;EAC3E,SAAS;GAAE,YAAY,WAAW,IAAI;GAAG,QAAQ,aAAW,MAAM;GAAY;EAAW,CAAC;CAC5F,GAAG,CAAC,CAAC;CAEL,MAAM,eAAe,aAClB,aAAqB;EACpB,IAAI,qBAAqB,EAAE,SAAS,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;EACrC,OAAQ,WAAkD,aAAa,QAAQ;CACjF,GACA,CAAC,UAAU,CACb;CAEA,MAAM,SAAS,YAAY,YAAY,YAAY,OAAO,GAAG,CAAC,UAAU,CAAC;CAEzE,OAAO,cAAc;EACnB,OAAO;GACL,GAAG;GACH;GACA;GACA;EACF;CACF,GAAG;EAAC;EAAO;EAAQ;EAAS;CAAY,CAAC;AAC3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as useClient } from "./chunk-useClient.mjs";
|
|
2
|
+
import { useMulticastObservable } from "@dxos/react-hooks";
|
|
3
|
+
export * from "@dxos/client/mesh";
|
|
4
|
+
//#region src/mesh/useNetworkStatus.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a network status subscription.
|
|
7
|
+
*/
|
|
8
|
+
var useNetworkStatus = () => {
|
|
9
|
+
return useMulticastObservable(useClient().mesh.networkStatus);
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { useNetworkStatus };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=mesh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.mjs","names":[],"sources":["../../src/mesh/useNetworkStatus.ts"],"sourcesContent":["//\n// Copyright 2020 DXOS.org\n//\n\nimport { type NetworkStatus } from '@dxos/client/mesh';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Creates a network status subscription.\n */\nexport const useNetworkStatus = (): NetworkStatus => {\n const client = useClient();\n return useMulticastObservable(client.mesh.networkStatus);\n};\n"],"mappings":";;;;;;;AAYA,IAAa,yBAAwC;CAEnD,OAAO,uBADQ,UACe,CAAA,CAAO,KAAK,aAAa;AACzD"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { t as ClientProvider } from "./chunk-ClientProvider.mjs";
|
|
2
|
+
import { raise } from "@dxos/debug";
|
|
3
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Client } from "@dxos/client";
|
|
5
|
+
import { log } from "@dxos/log";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useAsyncEffect } from "@dxos/react-hooks";
|
|
8
|
+
import { Trigger } from "@dxos/async";
|
|
9
|
+
import { TestBuilder, performInvitation } from "@dxos/client/testing";
|
|
10
|
+
import { random } from "@dxos/random";
|
|
11
|
+
import { ErrorBoundary } from "@dxos/react-ui";
|
|
12
|
+
export * from "@dxos/client/testing";
|
|
13
|
+
//#region src/testing/context.tsx
|
|
14
|
+
var ClientStory = createContext(void 0);
|
|
15
|
+
var useClientStory = () => {
|
|
16
|
+
return useContext(ClientStory) ?? raise(/* @__PURE__ */ new Error("Missing ClientStory"));
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/testing/ClientRepeater.tsx
|
|
20
|
+
/**
|
|
21
|
+
* Utility component for Storybook stories which sets up clients for n peers.
|
|
22
|
+
* The `Component` property is rendered n times, once for each peer.
|
|
23
|
+
* @deprecated use `withClientProvider`.
|
|
24
|
+
*/
|
|
25
|
+
var ClientRepeater = (props) => {
|
|
26
|
+
const { component: Component, controls: Controls, count = 1, types, createIdentity, createSpace, onCreateSpace } = props;
|
|
27
|
+
const [clients, setClients] = useState(props.clients ?? []);
|
|
28
|
+
const [spaceId, setSpaceId] = useState();
|
|
29
|
+
const testBuilder = useRef(new TestBuilder());
|
|
30
|
+
useAsyncEffect(async () => {
|
|
31
|
+
const clients = [...Array(count)].map((_) => new Client({
|
|
32
|
+
services: testBuilder.current.createLocalClientServices(),
|
|
33
|
+
types
|
|
34
|
+
}));
|
|
35
|
+
await Promise.all(clients.map((client) => client.initialize()));
|
|
36
|
+
if (createIdentity || createSpace) await Promise.all(clients.map((client) => client.halo.createIdentity()));
|
|
37
|
+
if (createSpace) {
|
|
38
|
+
const client = clients[0];
|
|
39
|
+
const space = await client.spaces.create({ name: random.commerce.productName() });
|
|
40
|
+
setSpaceId(space.id);
|
|
41
|
+
await onCreateSpace?.({
|
|
42
|
+
client,
|
|
43
|
+
space
|
|
44
|
+
}, {});
|
|
45
|
+
await Promise.all(clients.slice(1).flatMap((client) => performInvitation({
|
|
46
|
+
host: space,
|
|
47
|
+
guest: client.spaces
|
|
48
|
+
})));
|
|
49
|
+
}
|
|
50
|
+
setClients(clients);
|
|
51
|
+
}, []);
|
|
52
|
+
if (clients.length === 0) return null;
|
|
53
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [Controls && /* @__PURE__ */ jsx(Controls, { clients }), clients.map((client, index) => /* @__PURE__ */ jsx(ClientProvider, {
|
|
54
|
+
client,
|
|
55
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
56
|
+
id: index,
|
|
57
|
+
count: clients.length,
|
|
58
|
+
spaceId,
|
|
59
|
+
...props.args
|
|
60
|
+
})
|
|
61
|
+
}, index))] });
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/testing/withClientProvider.tsx
|
|
65
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/react-client/src/testing/withClientProvider.tsx";
|
|
66
|
+
/**
|
|
67
|
+
* Initialize client, identity and first space.
|
|
68
|
+
*/
|
|
69
|
+
var initializeClient = async (client, { createIdentity, createSpace, onCreateIdentity, onCreateSpace, onInitialized }, context) => {
|
|
70
|
+
await onInitialized?.(client);
|
|
71
|
+
if (createIdentity || createSpace) {
|
|
72
|
+
if (!client.halo.identity.get()) {
|
|
73
|
+
await client.halo.createIdentity();
|
|
74
|
+
await onCreateIdentity?.({ client }, context);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
let space;
|
|
78
|
+
if (createSpace) {
|
|
79
|
+
space = await client.spaces.create({ name: "Test Space" });
|
|
80
|
+
await space.waitUntilReady();
|
|
81
|
+
await onCreateSpace?.({
|
|
82
|
+
client,
|
|
83
|
+
space
|
|
84
|
+
}, context);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
space,
|
|
88
|
+
spaceId: space?.id
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Decorator that provides the client context.
|
|
93
|
+
*/
|
|
94
|
+
var withClientProvider = ({ createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, ...props } = {}) => {
|
|
95
|
+
return (Story, context) => {
|
|
96
|
+
const [data, setData] = useState({});
|
|
97
|
+
const handleInitialized = async (client) => {
|
|
98
|
+
const data = await initializeClient(client, {
|
|
99
|
+
createIdentity,
|
|
100
|
+
createSpace,
|
|
101
|
+
onCreateSpace,
|
|
102
|
+
onCreateIdentity,
|
|
103
|
+
onInitialized
|
|
104
|
+
}, context);
|
|
105
|
+
setData(data);
|
|
106
|
+
};
|
|
107
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
108
|
+
name: "client-provider",
|
|
109
|
+
children: /* @__PURE__ */ jsx(ClientProvider, {
|
|
110
|
+
onInitialized: handleInitialized,
|
|
111
|
+
...props,
|
|
112
|
+
children: /* @__PURE__ */ jsx(ClientStory.Provider, {
|
|
113
|
+
value: data,
|
|
114
|
+
children: /* @__PURE__ */ jsx(Story, {})
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Decorator that creates a scaffold for multiple clients.
|
|
122
|
+
* Orchestrates invitations between a randomly selected host and the remaining clients.
|
|
123
|
+
*/
|
|
124
|
+
var withMultiClientProvider = ({ numClients = 2, createIdentity, createSpace, onCreateSpace, onCreateIdentity, onInitialized, ...props }) => {
|
|
125
|
+
return (Story, context) => {
|
|
126
|
+
const spaceReady = useRef(new Trigger());
|
|
127
|
+
const [spaceId, setSpaceId] = useState();
|
|
128
|
+
const clients = useMemo(() => {
|
|
129
|
+
const buidler = new TestBuilder();
|
|
130
|
+
return Array.from({ length: numClients }).map(() => {
|
|
131
|
+
return { services: buidler.createLocalClientServices() };
|
|
132
|
+
});
|
|
133
|
+
}, [numClients]);
|
|
134
|
+
const handleInitialized = useCallback(async (client, index) => {
|
|
135
|
+
if (index === 0) {
|
|
136
|
+
const { space } = await initializeClient(client, {
|
|
137
|
+
createIdentity,
|
|
138
|
+
createSpace,
|
|
139
|
+
onCreateSpace,
|
|
140
|
+
onCreateIdentity,
|
|
141
|
+
onInitialized
|
|
142
|
+
}, context);
|
|
143
|
+
log.info("inviting", {
|
|
144
|
+
index,
|
|
145
|
+
spaceId: space?.id
|
|
146
|
+
}, {
|
|
147
|
+
"~LogMeta": "~LogMeta",
|
|
148
|
+
F: __dxlog_file,
|
|
149
|
+
L: 148,
|
|
150
|
+
S: void 0
|
|
151
|
+
});
|
|
152
|
+
setSpaceId(space?.id);
|
|
153
|
+
spaceReady.current.wake(space);
|
|
154
|
+
} else {
|
|
155
|
+
await initializeClient(client, {
|
|
156
|
+
createIdentity,
|
|
157
|
+
onInitialized
|
|
158
|
+
}, context);
|
|
159
|
+
log.info("waiting", { index }, {
|
|
160
|
+
"~LogMeta": "~LogMeta",
|
|
161
|
+
F: __dxlog_file,
|
|
162
|
+
L: 155,
|
|
163
|
+
S: void 0
|
|
164
|
+
});
|
|
165
|
+
const space = await spaceReady.current.wait();
|
|
166
|
+
if (space) {
|
|
167
|
+
log.info("joining", {
|
|
168
|
+
index,
|
|
169
|
+
spaceId: space.id
|
|
170
|
+
}, {
|
|
171
|
+
"~LogMeta": "~LogMeta",
|
|
172
|
+
F: __dxlog_file,
|
|
173
|
+
L: 158,
|
|
174
|
+
S: void 0
|
|
175
|
+
});
|
|
176
|
+
await Promise.all(performInvitation({
|
|
177
|
+
host: space,
|
|
178
|
+
guest: client.spaces
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, []);
|
|
183
|
+
return /* @__PURE__ */ jsx("div", {
|
|
184
|
+
className: "absolute inset-0 grid grid-flow-col auto-cols-fr gap-4 overflow-hidden",
|
|
185
|
+
children: clients.map((client, index) => /* @__PURE__ */ jsx(ClientProvider, {
|
|
186
|
+
services: client.services,
|
|
187
|
+
onInitialized: (client) => handleInitialized(client, index),
|
|
188
|
+
...props,
|
|
189
|
+
children: /* @__PURE__ */ jsx(ClientStory.Provider, {
|
|
190
|
+
value: {
|
|
191
|
+
index,
|
|
192
|
+
spaceId
|
|
193
|
+
},
|
|
194
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
195
|
+
name: "client-provider",
|
|
196
|
+
children: /* @__PURE__ */ jsx(Story, {})
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
}, index))
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
//#endregion
|
|
204
|
+
export { ClientRepeater, ClientStory, useClientStory, withClientProvider, withMultiClientProvider };
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing/context.tsx","../../src/testing/ClientRepeater.tsx","../../src/testing/withClientProvider.tsx"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { type Space } from '@dxos/client/echo';\nimport { raise } from '@dxos/debug';\nimport { type SpaceId } from '@dxos/keys';\n\nexport type ClientStory = {\n index?: number;\n spaceId?: SpaceId;\n space?: Space;\n};\n\nexport const ClientStory = createContext<ClientStory | undefined>(undefined);\n\nexport const useClientStory = (): ClientStory => {\n return useContext(ClientStory) ?? raise(new Error('Missing ClientStory'));\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { type FC, useRef, useState } from 'react';\n\nimport { Client } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type Type } from '@dxos/echo';\nimport { type SpaceId } from '@dxos/keys';\nimport { random } from '@dxos/random';\nimport { useAsyncEffect } from '@dxos/react-hooks';\n\nimport { ClientProvider } from '../client';\nimport { type WithClientProviderProps } from './withClientProvider';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceId?: SpaceId };\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?: Type.AnyObj[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onCreateSpace'>;\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 onCreateSpace,\n } = props;\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceId, setSpaceId] = useState<SpaceId>();\n\n const testBuilder = useRef(new TestBuilder());\n useAsyncEffect(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: random.commerce.productName() });\n setSpaceId(space.id);\n await onCreateSpace?.({ client, space }, {});\n await Promise.all(clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })));\n }\n\n setClients(clients);\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} spaceId={spaceId} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator, type StoryContext } from '@storybook/react';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ErrorBoundary } from '@dxos/react-ui';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\nimport { ClientStory } from './context';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<void>;\n onCreateIdentity?: (props: { client: Client }, context: StoryContext | any) => MaybePromise<void>;\n // NOTE: context must be untyped until ClientRepeater is removed.\n onCreateSpace?: (props: { client: Client; space: Space }, context: StoryContext | any) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onCreateIdentity, onCreateSpace, onInitialized }: InitializeProps,\n context: StoryContext,\n): Promise<ClientStory> => {\n await onInitialized?.(client);\n\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n await onCreateIdentity?.({ client }, context);\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await space.waitUntilReady(); // Is this required?\n await onCreateSpace?.({ client, space }, context);\n }\n\n return { space, spaceId: space?.id };\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story, context) => {\n const [data, setData] = useState<ClientStory>({});\n const handleInitialized = async (client: Client) => {\n const data = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n },\n context,\n );\n\n setData(data);\n };\n\n return (\n <ErrorBoundary name='client-provider'>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <ClientStory.Provider value={data}>\n <Story />\n </ClientStory.Provider>\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 &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story, context) => {\n const spaceReady = useRef(new Trigger<Space | undefined>());\n const [spaceId, setSpaceId] = useState<SpaceId>();\n\n const clients = useMemo(() => {\n const buidler = new TestBuilder();\n return Array.from({ length: numClients }).map(() => {\n return {\n services: buidler.createLocalClientServices(),\n };\n });\n }, [numClients]);\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = useCallback(async (client: Client, index: number) => {\n if (index === 0) {\n // Initialize host.\n const { space } = await initializeClient(\n client,\n {\n createIdentity,\n createSpace,\n onCreateSpace,\n onCreateIdentity,\n onInitialized,\n },\n context,\n );\n\n log.info('inviting', { index, spaceId: space?.id });\n setSpaceId(space?.id);\n spaceReady.current.wake(space);\n } else {\n // Initialize guest.\n await initializeClient(client, { createIdentity, onInitialized }, context);\n\n log.info('waiting', { index });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index, spaceId: space.id });\n await Promise.all(\n performInvitation({\n host: space,\n guest: client.spaces,\n }),\n );\n }\n }\n }, []);\n\n return (\n <div className='absolute inset-0 grid grid-flow-col auto-cols-fr gap-4 overflow-hidden'>\n {clients.map((client, index) => (\n <ClientProvider\n key={index}\n services={client.services}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <ClientStory.Provider value={{ index, spaceId }}>\n <ErrorBoundary name='client-provider'>\n <Story />\n </ErrorBoundary>\n </ClientStory.Provider>\n </ClientProvider>\n ))}\n </div>\n );\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAa,cAAc,cAAuC,KAAA,CAAS;AAE3E,IAAa,uBAAoC;CAC/C,OAAO,WAAW,WAA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AAb;KAAsB,OAAO;MAAE;MAAO;KAAQ;eAC5C,oBAAC,eAAD;MAAe,MAAK;gBAClB,oBAAC,OAAD,CAAQ,CAAA;KACK,CAAA;IACK,CAAA;GACR,GAVT,KAUS,CACjB;EACE,CAAA;CAET;AACF"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React, { type PropsWithChildren } from 'react';
|
|
2
|
-
import { type AgentHostingProviderClient } from '@dxos/client';
|
|
3
2
|
import { type Halo } from '@dxos/client/halo';
|
|
4
3
|
import { type Config } from '@dxos/config';
|
|
5
4
|
export type AgentHostingProviderProps = {
|
|
6
5
|
config: Config;
|
|
7
6
|
halo: Halo;
|
|
8
7
|
};
|
|
9
|
-
export declare const AgentHostingContext: React.Context<AgentHostingProviderClient | null>;
|
|
10
8
|
/**
|
|
11
9
|
* Experimental agent hosting provider.
|
|
12
10
|
* @param props
|
|
@@ -14,5 +12,4 @@ export declare const AgentHostingContext: React.Context<AgentHostingProviderClie
|
|
|
14
12
|
* @deprecated
|
|
15
13
|
*/
|
|
16
14
|
export declare const AgentHostingProvider: (props: PropsWithChildren) => React.JSX.Element;
|
|
17
|
-
export declare const useAgentHostingClient: () => AgentHostingProviderClient | null;
|
|
18
15
|
//# 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,EAAE,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/AgentHostingProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAQ3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,sBAM5D,CAAC"}
|