@dxos/react-client 0.5.0 → 0.5.1-main.0ba1ecb
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-HJDLXXEZ.mjs → chunk-KR6MTIAK.mjs} +50 -14
- package/dist/lib/browser/{chunk-HJDLXXEZ.mjs.map → chunk-KR6MTIAK.mjs.map} +4 -4
- package/dist/lib/browser/devtools/index.mjs +1 -1
- package/dist/lib/browser/echo/index.mjs +1 -1
- package/dist/lib/browser/echo/index.mjs.map +2 -2
- package/dist/lib/browser/halo/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +7 -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 +1 -1
- package/dist/lib/node/{chunk-3GRHATJ3.cjs → chunk-HVU2FX77.cjs} +54 -16
- package/dist/lib/node/{chunk-3GRHATJ3.cjs.map → chunk-HVU2FX77.cjs.map} +4 -4
- package/dist/lib/node/devtools/index.cjs +2 -2
- package/dist/lib/node/echo/index.cjs +3 -3
- package/dist/lib/node/echo/index.cjs.map +1 -1
- package/dist/lib/node/halo/index.cjs +5 -5
- package/dist/lib/node/index.cjs +14 -10
- 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 +2 -2
- package/dist/types/src/client/AgentHostingProvider.d.ts +12 -0
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -0
- package/dist/types/src/client/index.d.ts +1 -1
- package/dist/types/src/client/index.d.ts.map +1 -1
- package/dist/types/src/echo/useQuery.d.ts +1 -1
- package/dist/types/src/echo/useQuery.d.ts.map +1 -1
- package/package.json +17 -17
- package/project.json +3 -0
- package/src/client/AgentHostingProvider.tsx +65 -0
- package/src/client/index.ts +1 -1
- package/src/echo/useQuery.ts +5 -5
- package/dist/types/src/client/useAgentHostingProvider.d.ts +0 -4
- package/dist/types/src/client/useAgentHostingProvider.d.ts.map +0 -1
- package/src/client/useAgentHostingProvider.ts +0 -37
|
@@ -33,7 +33,7 @@ __export(testing_exports, {
|
|
|
33
33
|
FullscreenDecorator: () => FullscreenDecorator
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(testing_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_chunk_HVU2FX77 = require("../chunk-HVU2FX77.cjs");
|
|
37
37
|
__reExport(testing_exports, require("@dxos/client/testing"), module.exports);
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
39
39
|
var import_client = require("@dxos/client");
|
|
@@ -83,7 +83,7 @@ var ClientRepeater = (props) => {
|
|
|
83
83
|
clients
|
|
84
84
|
}), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
85
85
|
className
|
|
86
|
-
}, clients.map((client, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
86
|
+
}, clients.map((client, index) => /* @__PURE__ */ import_react.default.createElement(import_chunk_HVU2FX77.ClientContext.Provider, {
|
|
87
87
|
key: index,
|
|
88
88
|
value: {
|
|
89
89
|
client
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type Halo } from '@dxos/client/halo';
|
|
3
|
+
import { type AgentHostingProviderClient } from '@dxos/client/services';
|
|
4
|
+
import { type Config } from '@dxos/config';
|
|
5
|
+
export type AgentHostingProviderProps = {
|
|
6
|
+
config: Config;
|
|
7
|
+
halo: Halo;
|
|
8
|
+
};
|
|
9
|
+
export declare const AgentHostingContext: React.Context<AgentHostingProviderClient | null>;
|
|
10
|
+
export declare const AgentHostingProvider: (props: PropsWithChildren<{}>) => JSX.Element;
|
|
11
|
+
export declare const useAgentHostingClient: () => AgentHostingProviderClient | null;
|
|
12
|
+
//# sourceMappingURL=AgentHostingProvider.d.ts.map
|
|
@@ -0,0 +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,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,0BAA0B,EAAgD,MAAM,uBAAuB,CAAC;AACtH,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAU3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,mBAAmB,kDAAyD,CAAC;AAE1F,eAAO,MAAM,oBAAoB,UAAW,kBAAkB,EAAE,CAAC,gBAMhE,CAAC;AAEF,eAAO,MAAM,qBAAqB,yCAEjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Echo, type EchoReactiveObject, type FilterSource, type QueryOptions, type Space } from '@dxos/client/echo';
|
|
2
2
|
type UseQuery = {
|
|
3
3
|
<T extends EchoReactiveObject<any>>(spaceOrEcho?: Space | Echo, filter?: FilterSource<T>, options?: QueryOptions, deps?: any[]): T[];
|
|
4
4
|
};
|
|
@@ -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,EAEL,KAAK,IAAI,EACT,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAC;AAE3B,KAAK,QAAQ,GAAG;IACd,CAAC,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,EAChC,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,EAC1B,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,OAAO,CAAC,EAAE,YAAY,EACtB,IAAI,CAAC,EAAE,GAAG,EAAE,GACX,CAAC,EAAE,CAAC;CACR,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,QAAQ,EAAE,QA4BtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-main.0ba1ecb",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -91,17 +91,17 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/
|
|
97
|
-
"@dxos/debug": "0.5.
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/
|
|
100
|
-
"@dxos/
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/
|
|
94
|
+
"@dxos/client": "0.5.1-main.0ba1ecb",
|
|
95
|
+
"@dxos/codec-protobuf": "0.5.1-main.0ba1ecb",
|
|
96
|
+
"@dxos/config": "0.5.1-main.0ba1ecb",
|
|
97
|
+
"@dxos/debug": "0.5.1-main.0ba1ecb",
|
|
98
|
+
"@dxos/echo-signals": "0.5.1-main.0ba1ecb",
|
|
99
|
+
"@dxos/async": "0.5.1-main.0ba1ecb",
|
|
100
|
+
"@dxos/invariant": "0.5.1-main.0ba1ecb",
|
|
101
|
+
"@dxos/log": "0.5.1-main.0ba1ecb",
|
|
102
|
+
"@dxos/react-async": "0.5.1-main.0ba1ecb",
|
|
103
|
+
"@dxos/node-std": "0.5.1-main.0ba1ecb",
|
|
104
|
+
"@dxos/util": "0.5.1-main.0ba1ecb"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@testing-library/dom": "^8.17.1",
|
|
@@ -112,10 +112,10 @@
|
|
|
112
112
|
"react": "^18.2.0",
|
|
113
113
|
"react-dom": "^18.2.0",
|
|
114
114
|
"yjs": "^13.6.10",
|
|
115
|
-
"@dxos/
|
|
116
|
-
"@dxos/react-ui
|
|
117
|
-
"@dxos/storybook-utils": "0.5.
|
|
118
|
-
"@dxos/
|
|
115
|
+
"@dxos/random": "0.5.1-main.0ba1ecb",
|
|
116
|
+
"@dxos/react-ui": "0.5.1-main.0ba1ecb",
|
|
117
|
+
"@dxos/storybook-utils": "0.5.1-main.0ba1ecb",
|
|
118
|
+
"@dxos/react-ui-theme": "0.5.1-main.0ba1ecb"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"react": "*",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
},
|
|
124
124
|
"optionalDependencies": {
|
|
125
125
|
"yjs": "^13.6.10",
|
|
126
|
-
"@dxos/random": "0.5.
|
|
126
|
+
"@dxos/random": "0.5.1-main.0ba1ecb"
|
|
127
127
|
},
|
|
128
128
|
"publishConfig": {
|
|
129
129
|
"access": "public"
|
package/project.json
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { createContext, type PropsWithChildren, useContext, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Halo } from '@dxos/client/halo';
|
|
8
|
+
import { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client/services';
|
|
9
|
+
import { type Config } from '@dxos/config';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
import { useClient } from './ClientContext';
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Interface for invoking the agent hosting provider client.
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type AgentHostingProviderProps = { config: Config; halo: Halo };
|
|
20
|
+
|
|
21
|
+
export const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);
|
|
22
|
+
|
|
23
|
+
export const AgentHostingProvider = (props: PropsWithChildren<{}>) => {
|
|
24
|
+
const client = useClient();
|
|
25
|
+
const [agentHostingProviderClient] = useState(makeClient(client));
|
|
26
|
+
return (
|
|
27
|
+
<AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const useAgentHostingClient = () => {
|
|
32
|
+
return useContext(AgentHostingContext);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const makeClient = ({ config, halo }: AgentHostingProviderProps) => {
|
|
36
|
+
const agentHostingConfig = config.get('runtime.services.agentHosting');
|
|
37
|
+
if (!agentHostingConfig) {
|
|
38
|
+
log('no agent hosting configured');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// TODO(nf): Dynamically discover based on runtime config.
|
|
43
|
+
let agentHostingProviderClient: AgentHostingProviderClient | null = null;
|
|
44
|
+
switch (agentHostingConfig.type) {
|
|
45
|
+
case 'LOCAL_TESTING': {
|
|
46
|
+
log('using FakeAgentHostingProvider');
|
|
47
|
+
return new FakeAgentHostingProvider(config, halo);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
case 'AGENTHOSTING_API': {
|
|
51
|
+
agentHostingProviderClient = new AgentManagerClient(config, halo);
|
|
52
|
+
if (agentHostingProviderClient.init()) {
|
|
53
|
+
return agentHostingProviderClient;
|
|
54
|
+
} else {
|
|
55
|
+
// Not authorized or error initializing
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
default: {
|
|
61
|
+
log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
package/src/client/index.ts
CHANGED
package/src/echo/useQuery.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import { useMemo, useSyncExternalStore } from 'react';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
type
|
|
8
|
+
isSpace,
|
|
9
|
+
type Echo,
|
|
10
|
+
type EchoReactiveObject,
|
|
10
11
|
type FilterSource,
|
|
12
|
+
type Query,
|
|
13
|
+
type QueryOptions,
|
|
11
14
|
type Space,
|
|
12
|
-
type EchoReactiveObject,
|
|
13
|
-
type Echo,
|
|
14
|
-
isSpace,
|
|
15
15
|
} from '@dxos/client/echo';
|
|
16
16
|
|
|
17
17
|
type UseQuery = {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type AgentHostingProviderClient } from '@dxos/client/services';
|
|
2
|
-
import { type Config } from '@dxos/config';
|
|
3
|
-
export declare const useAgentHostingProviderClient: (config: Config) => AgentHostingProviderClient | null;
|
|
4
|
-
//# sourceMappingURL=useAgentHostingProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/useAgentHostingProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,0BAA0B,EAGhC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAO3C,eAAO,MAAM,6BAA6B,WAAY,MAAM,KAAG,0BAA0B,GAAG,IAoB3F,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
type AgentHostingProviderClient,
|
|
7
|
-
DXOSAgentHostingProviderClient,
|
|
8
|
-
FakeAgentHostingProvider,
|
|
9
|
-
} from '@dxos/client/services';
|
|
10
|
-
import { type Config } from '@dxos/config';
|
|
11
|
-
import { log } from '@dxos/log';
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* Interface for invoking the agent hosting provider client.
|
|
15
|
-
* @experimental
|
|
16
|
-
*/
|
|
17
|
-
export const useAgentHostingProviderClient = (config: Config): AgentHostingProviderClient | null => {
|
|
18
|
-
// TODO: Dynamically discover based on runtime config
|
|
19
|
-
if (
|
|
20
|
-
config.get('runtime.app.env.DX_ENVIRONMENT') !== 'development' &&
|
|
21
|
-
localStorage.getItem('dxos.org/shell/features/agentHosting') !== 'true'
|
|
22
|
-
) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const agentHostingConfig = config.get('runtime.services.agentHosting');
|
|
27
|
-
if (!agentHostingConfig) {
|
|
28
|
-
log.info('no agent hosting configured');
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (agentHostingConfig.type === 'LOCAL_TESTING') {
|
|
33
|
-
return new FakeAgentHostingProvider(config);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return new DXOSAgentHostingProviderClient(config);
|
|
37
|
-
};
|