@dxos/react-client 2.28.3-dev.cb8eaf22 → 2.28.3

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": "2.28.3-dev.cb8eaf22",
3
+ "version": "2.28.3",
4
4
  "description": "React client API",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -8,24 +8,25 @@
8
8
  "main": "dist/src/index.js",
9
9
  "types": "dist/src/index.d.ts",
10
10
  "dependencies": {
11
- "@dxos/async": "2.28.3-dev.cb8eaf22",
12
- "@dxos/bot-factory-client": "2.28.3-dev.cb8eaf22",
13
- "@dxos/client": "2.28.3-dev.cb8eaf22",
14
- "@dxos/config": "2.28.3-dev.cb8eaf22",
15
- "@dxos/credentials": "2.28.3-dev.cb8eaf22",
16
- "@dxos/crypto": "2.28.3-dev.cb8eaf22",
17
- "@dxos/debug": "2.28.3-dev.cb8eaf22",
18
- "@dxos/echo-db": "2.28.3-dev.cb8eaf22",
19
- "@dxos/network-manager": "2.28.3-dev.cb8eaf22",
20
- "@dxos/util": "2.28.3-dev.cb8eaf22",
11
+ "@dxos/async": "2.28.3",
12
+ "@dxos/bot-factory-client": "2.28.3",
13
+ "@dxos/client": "2.28.3",
14
+ "@dxos/config": "2.28.3",
15
+ "@dxos/credentials": "2.28.3",
16
+ "@dxos/crypto": "2.28.3",
17
+ "@dxos/debug": "2.28.3",
18
+ "@dxos/echo-db": "2.28.3",
19
+ "@dxos/network-manager": "2.28.3",
20
+ "@dxos/util": "2.28.3",
21
21
  "assert": "^2.0.0",
22
22
  "debug": "^4.3.3",
23
23
  "react-display-name": "^0.2.5",
24
24
  "use-subscription": "^1.4.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@dxos/esbuild-plugins": "2.28.3-dev.cb8eaf22",
28
- "@dxos/toolchain-node-library": "2.28.2",
27
+ "@dxos/esbuild-plugins": "~2.28.2",
28
+ "@dxos/eslint-plugin": "~1.0.26",
29
+ "@dxos/protocols-toolchain": "2.28.3",
29
30
  "@mui/material": "^5.4.2",
30
31
  "@testing-library/react": "^11.0.4",
31
32
  "@testing-library/react-hooks": "5.1.2",
@@ -36,6 +37,7 @@
36
37
  "@types/react": "^17.0.24",
37
38
  "@types/testing-library__jest-dom": "~5.9.5",
38
39
  "@types/use-subscription": "^1.0.0",
40
+ "eslint": "^7.12.1",
39
41
  "expect": "~27.0.2",
40
42
  "fork-ts-checker-webpack-plugin": "~6.2.5",
41
43
  "level-js": "^5.0.2",
@@ -23,20 +23,20 @@ export const useSelection = <T extends Entity<any>> (
23
23
  deps: readonly any[] = []
24
24
  ): T[] | undefined => {
25
25
  const [result, setResult] = useState(() => coerceSelection(selection));
26
- const [data, setData] = useState<T[] | undefined>(() => result ? result.result : undefined);
26
+ const [data, setData] = useState<T[] | undefined>(() => result ? result.entities : undefined);
27
27
 
28
28
  // Update selection when the query or customs deps change.
29
29
  useEffect(() => {
30
30
  const newResult = coerceSelection(selection);
31
31
  setResult(newResult);
32
- setData(newResult?.result);
32
+ setData(newResult?.entities);
33
33
  }, [!!selection, !!selection && selection.root, ...deps]);
34
34
 
35
35
  // Update data when database updates.
36
36
  useEffect(() => {
37
37
  if (result) {
38
- return result.update.on((entities: T[]) => {
39
- setData(entities);
38
+ return result.update.on(result => {
39
+ setData(result.entities);
40
40
  });
41
41
  }
42
42
  }, [result]);
@@ -45,11 +45,12 @@ export const useSelection = <T extends Entity<any>> (
45
45
  };
46
46
 
47
47
  /**
48
+ * Hook to process selection reducer.
49
+ *
48
50
  * @param selection
49
51
  * @param value
50
52
  * @param deps
51
53
  */
52
- // TODO(burdon): Factor out common code with useSelection.
53
54
  export const useReducer = <T extends Entity<any>, R> (
54
55
  selection: Selection<T> | SelectionResult<T> | Falsy,
55
56
  value: R,
@@ -68,7 +69,7 @@ export const useReducer = <T extends Entity<any>, R> (
68
69
  // Update data when database updates.
69
70
  useEffect(() => {
70
71
  if (result) {
71
- return result.update.on(() => {
72
+ return result.update.on(result => {
72
73
  setData(result.value);
73
74
  });
74
75
  }
@@ -78,9 +79,10 @@ export const useReducer = <T extends Entity<any>, R> (
78
79
  };
79
80
 
80
81
  /**
81
- * @param arg
82
+ * @param value Selection or SelectionResult from hook.
82
83
  */
83
- // TODO(burdon): ???
84
84
  const coerceSelection = <T extends Entity>(
85
- arg: Selection<T> | SelectionResult<T> | Falsy
86
- ): SelectionResult<T> | undefined => !arg ? undefined : arg instanceof Selection ? arg.query() : arg;
85
+ value: Selection<T> | SelectionResult<T> | Falsy
86
+ ): SelectionResult<T> | undefined => {
87
+ return !value ? undefined : value instanceof Selection ? value.query() : value;
88
+ };