@dxos/react-client 0.4.10-main.4c7b3fa → 0.4.10-main.4d26ea7

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.
Files changed (30) hide show
  1. package/dist/lib/browser/{chunk-6SW7V4VI.mjs → chunk-HJDLXXEZ.mjs} +3 -3
  2. package/dist/lib/browser/{chunk-6SW7V4VI.mjs.map → chunk-HJDLXXEZ.mjs.map} +3 -3
  3. package/dist/lib/browser/devtools/index.mjs +1 -1
  4. package/dist/lib/browser/echo/index.mjs +15 -6
  5. package/dist/lib/browser/echo/index.mjs.map +3 -3
  6. package/dist/lib/browser/halo/index.mjs +1 -1
  7. package/dist/lib/browser/halo/index.mjs.map +1 -1
  8. package/dist/lib/browser/index.mjs +1 -1
  9. package/dist/lib/browser/mesh/index.mjs +1 -1
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/testing/index.mjs +1 -1
  12. package/dist/lib/node/{chunk-IRRRZ2KE.cjs → chunk-3GRHATJ3.cjs} +5 -5
  13. package/dist/lib/node/{chunk-IRRRZ2KE.cjs.map → chunk-3GRHATJ3.cjs.map} +3 -3
  14. package/dist/lib/node/devtools/index.cjs +2 -2
  15. package/dist/lib/node/echo/index.cjs +19 -10
  16. package/dist/lib/node/echo/index.cjs.map +3 -3
  17. package/dist/lib/node/halo/index.cjs +5 -5
  18. package/dist/lib/node/halo/index.cjs.map +1 -1
  19. package/dist/lib/node/index.cjs +9 -9
  20. package/dist/lib/node/mesh/index.cjs +2 -2
  21. package/dist/lib/node/meta.json +1 -1
  22. package/dist/lib/node/testing/index.cjs +2 -2
  23. package/dist/types/src/echo/useQuery.d.ts +2 -2
  24. package/dist/types/src/echo/useQuery.d.ts.map +1 -1
  25. package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
  26. package/package.json +33 -25
  27. package/project.json +3 -0
  28. package/src/client/useAgentHostingProvider.ts +2 -2
  29. package/src/echo/useQuery.ts +25 -7
  30. package/src/halo/useHaloInvitations.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "0.4.10-main.4c7b3fa",
3
+ "version": "0.4.10-main.4d26ea7",
4
4
  "description": "React client API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -11,49 +11,57 @@
11
11
  "browser": "./dist/lib/browser/index.mjs",
12
12
  "import": "./dist/lib/browser/index.mjs",
13
13
  "require": "./dist/lib/node/index.cjs",
14
- "node": "./dist/lib/node/index.cjs"
14
+ "node": "./dist/lib/node/index.cjs",
15
+ "types": "./dist/types/src/index.d.ts"
15
16
  },
16
17
  "./devtools": {
17
18
  "browser": "./dist/lib/browser/devtools/index.mjs",
18
19
  "import": "./dist/lib/browser/devtools/index.mjs",
19
20
  "require": "./dist/lib/node/devtools/index.cjs",
20
- "node": "./dist/lib/node/devtools/index.cjs"
21
+ "node": "./dist/lib/node/devtools/index.cjs",
22
+ "types": "./dist/types/src/devtools/index.d.ts"
21
23
  },
22
24
  "./echo": {
23
25
  "browser": "./dist/lib/browser/echo/index.mjs",
24
26
  "import": "./dist/lib/browser/echo/index.mjs",
25
27
  "require": "./dist/lib/node/echo/index.cjs",
26
- "node": "./dist/lib/node/echo/index.cjs"
28
+ "node": "./dist/lib/node/echo/index.cjs",
29
+ "types": "./dist/types/src/echo/index.d.ts"
27
30
  },
28
31
  "./halo": {
29
32
  "browser": "./dist/lib/browser/halo/index.mjs",
30
33
  "import": "./dist/lib/browser/halo/index.mjs",
31
34
  "require": "./dist/lib/node/halo/index.cjs",
32
- "node": "./dist/lib/node/halo/index.cjs"
35
+ "node": "./dist/lib/node/halo/index.cjs",
36
+ "types": "./dist/types/src/halo/index.d.ts"
33
37
  },
34
38
  "./invitations": {
35
39
  "browser": "./dist/lib/browser/invitations/index.mjs",
36
40
  "import": "./dist/lib/browser/invitations/index.mjs",
37
41
  "require": "./dist/lib/node/invitations/index.cjs",
38
- "node": "./dist/lib/node/invitations/index.cjs"
42
+ "node": "./dist/lib/node/invitations/index.cjs",
43
+ "types": "./dist/types/src/invitations/index.d.ts"
39
44
  },
40
45
  "./mesh": {
41
46
  "browser": "./dist/lib/browser/mesh/index.mjs",
42
47
  "import": "./dist/lib/browser/mesh/index.mjs",
43
48
  "require": "./dist/lib/node/mesh/index.cjs",
44
- "node": "./dist/lib/node/mesh/index.cjs"
49
+ "node": "./dist/lib/node/mesh/index.cjs",
50
+ "types": "./dist/types/src/mesh/index.d.ts"
45
51
  },
46
52
  "./testing": {
47
53
  "browser": "./dist/lib/browser/testing/index.mjs",
48
54
  "import": "./dist/lib/browser/testing/index.mjs",
49
55
  "require": "./dist/lib/node/testing/index.cjs",
50
- "node": "./dist/lib/node/testing/index.cjs"
56
+ "node": "./dist/lib/node/testing/index.cjs",
57
+ "types": "./dist/types/src/testing/index.d.ts"
51
58
  },
52
59
  "./worker": {
53
60
  "browser": "./dist/lib/browser/worker.mjs",
54
61
  "import": "./dist/lib/browser/worker.mjs",
55
62
  "require": "./dist/lib/node/worker.cjs",
56
- "node": "./dist/lib/node/worker.cjs"
63
+ "node": "./dist/lib/node/worker.cjs",
64
+ "types": "./dist/types/src/worker.d.ts"
57
65
  }
58
66
  },
59
67
  "types": "dist/types/src/index.d.ts",
@@ -83,17 +91,17 @@
83
91
  }
84
92
  },
85
93
  "dependencies": {
86
- "@dxos/async": "0.4.10-main.4c7b3fa",
87
- "@dxos/client": "0.4.10-main.4c7b3fa",
88
- "@dxos/config": "0.4.10-main.4c7b3fa",
89
- "@dxos/codec-protobuf": "0.4.10-main.4c7b3fa",
90
- "@dxos/debug": "0.4.10-main.4c7b3fa",
91
- "@dxos/echo-signals": "0.4.10-main.4c7b3fa",
92
- "@dxos/invariant": "0.4.10-main.4c7b3fa",
93
- "@dxos/log": "0.4.10-main.4c7b3fa",
94
- "@dxos/node-std": "0.4.10-main.4c7b3fa",
95
- "@dxos/react-async": "0.4.10-main.4c7b3fa",
96
- "@dxos/util": "0.4.10-main.4c7b3fa"
94
+ "@dxos/async": "0.4.10-main.4d26ea7",
95
+ "@dxos/client": "0.4.10-main.4d26ea7",
96
+ "@dxos/codec-protobuf": "0.4.10-main.4d26ea7",
97
+ "@dxos/echo-signals": "0.4.10-main.4d26ea7",
98
+ "@dxos/debug": "0.4.10-main.4d26ea7",
99
+ "@dxos/config": "0.4.10-main.4d26ea7",
100
+ "@dxos/invariant": "0.4.10-main.4d26ea7",
101
+ "@dxos/log": "0.4.10-main.4d26ea7",
102
+ "@dxos/react-async": "0.4.10-main.4d26ea7",
103
+ "@dxos/node-std": "0.4.10-main.4d26ea7",
104
+ "@dxos/util": "0.4.10-main.4d26ea7"
97
105
  },
98
106
  "devDependencies": {
99
107
  "@testing-library/dom": "^8.17.1",
@@ -104,10 +112,10 @@
104
112
  "react": "^18.2.0",
105
113
  "react-dom": "^18.2.0",
106
114
  "yjs": "^13.6.10",
107
- "@dxos/random": "0.4.10-main.4c7b3fa",
108
- "@dxos/react-ui": "0.4.10-main.4c7b3fa",
109
- "@dxos/storybook-utils": "0.4.10-main.4c7b3fa",
110
- "@dxos/react-ui-theme": "0.4.10-main.4c7b3fa"
115
+ "@dxos/random": "0.4.10-main.4d26ea7",
116
+ "@dxos/react-ui": "0.4.10-main.4d26ea7",
117
+ "@dxos/react-ui-theme": "0.4.10-main.4d26ea7",
118
+ "@dxos/storybook-utils": "0.4.10-main.4d26ea7"
111
119
  },
112
120
  "peerDependencies": {
113
121
  "react": "*",
@@ -115,7 +123,7 @@
115
123
  },
116
124
  "optionalDependencies": {
117
125
  "yjs": "^13.6.10",
118
- "@dxos/random": "0.4.10-main.4c7b3fa"
126
+ "@dxos/random": "0.4.10-main.4d26ea7"
119
127
  },
120
128
  "publishConfig": {
121
129
  "access": "public"
package/project.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "$schema": "../../../node_modules/nx/schemas/project-schema.json",
3
3
  "name": "react-client",
4
+ "tags": [
5
+ "scope:sdk"
6
+ ],
4
7
  "sourceRoot": "packages/sdk/react-client/src",
5
8
  "projectType": "library",
6
9
  "targets": {
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {
6
6
  type AgentHostingProviderClient,
7
- EldonAgentHostingProviderClient,
7
+ DXOSAgentHostingProviderClient,
8
8
  FakeAgentHostingProvider,
9
9
  } from '@dxos/client/services';
10
10
  import { type Config } from '@dxos/config';
@@ -33,5 +33,5 @@ export const useAgentHostingProviderClient = (config: Config): AgentHostingProvi
33
33
  return new FakeAgentHostingProvider(config);
34
34
  }
35
35
 
36
- return new EldonAgentHostingProviderClient(config);
36
+ return new DXOSAgentHostingProviderClient(config);
37
37
  };
@@ -4,11 +4,19 @@
4
4
 
5
5
  import { useMemo, useSyncExternalStore } from 'react';
6
6
 
7
- import type { QueryOptions, Query, FilterSource, Space, EchoReactiveObject } from '@dxos/client/echo';
7
+ import {
8
+ type QueryOptions,
9
+ type Query,
10
+ type FilterSource,
11
+ type Space,
12
+ type EchoReactiveObject,
13
+ type Echo,
14
+ isSpace,
15
+ } from '@dxos/client/echo';
8
16
 
9
17
  type UseQuery = {
10
18
  <T extends EchoReactiveObject<any>>(
11
- space?: Space,
19
+ spaceOrEcho?: Space | Echo,
12
20
  filter?: FilterSource<T>,
13
21
  options?: QueryOptions,
14
22
  deps?: any[],
@@ -20,19 +28,29 @@ type UseQuery = {
20
28
  */
21
29
  // TODO(burdon): Support typed operator filters (e.g., Note.filter(note => ...)).
22
30
  export const useQuery: UseQuery = <T extends EchoReactiveObject<any>>(
23
- space?: Space,
31
+ spaceOrEcho?: Space | Echo,
24
32
  filter?: FilterSource<T>,
25
33
  options?: QueryOptions,
26
34
  deps?: any[],
27
35
  ) => {
28
36
  const { subscribe, getObjects } = useMemo(() => {
29
- const query = space?.db.query(filter, options) as Query<T> | undefined;
37
+ const query = isSpace(spaceOrEcho)
38
+ ? spaceOrEcho.db.query(filter, options)
39
+ : (spaceOrEcho?.query(filter, options) as Query<T> | undefined);
40
+ let subscribed = false;
30
41
 
31
42
  return {
32
- subscribe: (cb: () => void) => query?.subscribe(cb) ?? noop,
33
- getObjects: () => query?.objects ?? EMPTY_ARRAY,
43
+ subscribe: (cb: () => void) => {
44
+ subscribed = true;
45
+ const unsubscribe = query?.subscribe(cb) ?? noop;
46
+ return () => {
47
+ unsubscribe?.();
48
+ subscribed = false;
49
+ };
50
+ },
51
+ getObjects: () => (subscribed && query ? query.objects : EMPTY_ARRAY),
34
52
  };
35
- }, [space?.db, ...(typeof filter === 'function' ? [] : filterToDepsArray(filter)), ...(deps ?? [])]);
53
+ }, [spaceOrEcho, ...(typeof filter === 'function' ? [] : filterToDepsArray(filter)), ...(deps ?? [])]);
36
54
 
37
55
  // https://beta.reactjs.org/reference/react/useSyncExternalStore
38
56
  // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes -- make sure it is stable.
@@ -7,7 +7,7 @@ import { useMemo } from 'react';
7
7
  import { useMulticastObservable } from '@dxos/react-async';
8
8
 
9
9
  import { useClient } from '../client';
10
- import { type CancellableInvitationObservable, useInvitationStatus } from '../invitations';
10
+ import { useInvitationStatus, type CancellableInvitationObservable } from '../invitations';
11
11
 
12
12
  export const useHaloInvitations = (): CancellableInvitationObservable[] => {
13
13
  const client = useClient();