@dxos/react-client 0.5.9-main.bdf733d → 0.5.9-main.bf3bb8f

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "0.5.9-main.bdf733d",
3
+ "version": "0.5.9-main.bf3bb8f",
4
4
  "description": "React client API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -91,18 +91,18 @@
91
91
  }
92
92
  },
93
93
  "dependencies": {
94
- "@dxos/async": "0.5.9-main.bdf733d",
95
- "@dxos/codec-protobuf": "0.5.9-main.bdf733d",
96
- "@dxos/client": "0.5.9-main.bdf733d",
97
- "@dxos/config": "0.5.9-main.bdf733d",
98
- "@dxos/debug": "0.5.9-main.bdf733d",
99
- "@dxos/echo-schema": "0.5.9-main.bdf733d",
100
- "@dxos/echo-signals": "0.5.9-main.bdf733d",
101
- "@dxos/invariant": "0.5.9-main.bdf733d",
102
- "@dxos/log": "0.5.9-main.bdf733d",
103
- "@dxos/react-async": "0.5.9-main.bdf733d",
104
- "@dxos/util": "0.5.9-main.bdf733d",
105
- "@dxos/node-std": "0.5.9-main.bdf733d"
94
+ "@dxos/async": "0.5.9-main.bf3bb8f",
95
+ "@dxos/client": "0.5.9-main.bf3bb8f",
96
+ "@dxos/config": "0.5.9-main.bf3bb8f",
97
+ "@dxos/codec-protobuf": "0.5.9-main.bf3bb8f",
98
+ "@dxos/echo-schema": "0.5.9-main.bf3bb8f",
99
+ "@dxos/debug": "0.5.9-main.bf3bb8f",
100
+ "@dxos/echo-signals": "0.5.9-main.bf3bb8f",
101
+ "@dxos/invariant": "0.5.9-main.bf3bb8f",
102
+ "@dxos/log": "0.5.9-main.bf3bb8f",
103
+ "@dxos/node-std": "0.5.9-main.bf3bb8f",
104
+ "@dxos/react-async": "0.5.9-main.bf3bb8f",
105
+ "@dxos/util": "0.5.9-main.bf3bb8f"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@testing-library/dom": "^8.17.1",
@@ -112,17 +112,17 @@
112
112
  "@types/react-dom": "^18.0.6",
113
113
  "react": "^18.2.0",
114
114
  "react-dom": "^18.2.0",
115
- "@dxos/random": "0.5.9-main.bdf733d",
116
- "@dxos/react-ui": "0.5.9-main.bdf733d",
117
- "@dxos/react-ui-theme": "0.5.9-main.bdf733d",
118
- "@dxos/storybook-utils": "0.5.9-main.bdf733d"
115
+ "@dxos/random": "0.5.9-main.bf3bb8f",
116
+ "@dxos/react-ui": "0.5.9-main.bf3bb8f",
117
+ "@dxos/react-ui-theme": "0.5.9-main.bf3bb8f",
118
+ "@dxos/storybook-utils": "0.5.9-main.bf3bb8f"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "react": "*",
122
122
  "react-dom": "*"
123
123
  },
124
124
  "optionalDependencies": {
125
- "@dxos/random": "0.5.9-main.bdf733d"
125
+ "@dxos/random": "0.5.9-main.bf3bb8f"
126
126
  },
127
127
  "publishConfig": {
128
128
  "access": "public"
@@ -2,7 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Shell } from '@dxos/client/services';
5
+ import { useEffect, useState } from 'react';
6
+
7
+ import { type Shell, type ShellDisplay } from '@dxos/client/services';
6
8
 
7
9
  import { useClient } from './ClientContext';
8
10
 
@@ -13,3 +15,13 @@ export const useShell = (): Shell => {
13
15
  const client = useClient();
14
16
  return client.shell;
15
17
  };
18
+
19
+ /**
20
+ * Hook to access the shell’s display state.
21
+ */
22
+ export const useShellDisplay = (): ShellDisplay => {
23
+ const client = useClient();
24
+ const [display, setDisplay] = useState(client.shell.display);
25
+ useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);
26
+ return display;
27
+ };
@@ -16,16 +16,16 @@ import { useClient } from '../client';
16
16
  * Returns the default space if no key is provided.
17
17
  * Requires a ClientProvider somewhere in the parent tree.
18
18
  *
19
- * @param spaceKey the key of the space to look for
19
+ * @param spaceKeyLike the key of the space to look for
20
20
  */
21
- export const useSpace = (spaceKey?: PublicKeyLike): Space | undefined => {
21
+ export const useSpace = (spaceKeyLike?: PublicKeyLike): Space | undefined => {
22
22
  const client = useClient();
23
23
  const spaces = useMulticastObservable<Space[]>(client.spaces);
24
24
  const [ready, setReady] = useState(false);
25
25
 
26
26
  useEffect(() => {
27
27
  // Only wait for ready if looking for the default space.
28
- if (spaceKey) {
28
+ if (spaceKeyLike) {
29
29
  return;
30
30
  }
31
31
 
@@ -35,10 +35,10 @@ export const useSpace = (spaceKey?: PublicKeyLike): Space | undefined => {
35
35
  });
36
36
 
37
37
  return () => clearTimeout(timeout);
38
- }, [client, spaceKey]);
38
+ }, [client, spaceKeyLike]);
39
39
 
40
- if (spaceKey) {
41
- return spaces.find((space) => space.key.equals(spaceKey));
40
+ if (spaceKeyLike) {
41
+ return spaces.find((space) => space.key.equals(spaceKeyLike) || space.id === spaceKeyLike);
42
42
  }
43
43
 
44
44
  if (ready && client.halo.identity.get()) {