@dxos/react-client 0.8.3-main.7f5a14c → 0.8.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.
Files changed (86) hide show
  1. package/dist/lib/browser/echo/index.mjs.map +1 -1
  2. package/dist/lib/browser/meta.json +1 -1
  3. package/dist/lib/node/echo/index.cjs.map +1 -1
  4. package/dist/lib/node/meta.json +1 -1
  5. package/dist/lib/node-esm/echo/index.mjs.map +1 -1
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/echo/useQuery.test.d.ts +2 -0
  8. package/dist/types/src/echo/useQuery.test.d.ts.map +1 -0
  9. package/dist/types/src/echo/useQueue.d.ts +2 -2
  10. package/dist/types/src/echo/useQueue.d.ts.map +1 -1
  11. package/package.json +25 -24
  12. package/src/echo/useQuery.test.tsx +128 -0
  13. package/src/echo/useQueue.ts +2 -2
  14. package/tsconfig.json +3 -0
  15. package/typedoc/assets/hierarchy.js +1 -1
  16. package/typedoc/classes/echo.PropertiesType.html +3 -3
  17. package/typedoc/classes/halo.KeyStore.html +2 -2
  18. package/typedoc/classes/index.Client.html +1 -1
  19. package/typedoc/classes/invitations.AuthenticatingInvitationObservable.html +1 -1
  20. package/typedoc/classes/invitations.CancellableInvitationObservable.html +1 -1
  21. package/typedoc/functions/devtools.useDevtools.html +1 -1
  22. package/typedoc/functions/devtools.useStream.html +1 -1
  23. package/typedoc/functions/echo.useMembers.html +1 -1
  24. package/typedoc/functions/echo.useQueue.html +2 -2
  25. package/typedoc/functions/echo.useSchema.html +1 -1
  26. package/typedoc/functions/echo.useSpace.html +1 -1
  27. package/typedoc/functions/echo.useSpaceInvitation.html +1 -1
  28. package/typedoc/functions/echo.useSpaceInvitations.html +1 -1
  29. package/typedoc/functions/echo.useSpaceSyncState.html +1 -1
  30. package/typedoc/functions/echo.useSpaces.html +1 -1
  31. package/typedoc/functions/echo.useSubscription.html +1 -1
  32. package/typedoc/functions/echo.useSyncState.html +1 -1
  33. package/typedoc/functions/halo.useContacts.html +1 -1
  34. package/typedoc/functions/halo.useCredentials.html +1 -1
  35. package/typedoc/functions/halo.useDevices.html +1 -1
  36. package/typedoc/functions/halo.useHaloInvitation.html +1 -1
  37. package/typedoc/functions/halo.useHaloInvitations.html +1 -1
  38. package/typedoc/functions/halo.useIdentity.html +1 -1
  39. package/typedoc/functions/halo.useKeyStore.html +1 -1
  40. package/typedoc/functions/index.AgentHostingProvider.html +1 -1
  41. package/typedoc/functions/index.useAgentHostingClient.html +1 -1
  42. package/typedoc/functions/index.useClient.html +1 -1
  43. package/typedoc/functions/index.useClientStatus.html +1 -1
  44. package/typedoc/functions/index.useConfig.html +1 -1
  45. package/typedoc/functions/index.useShell.html +1 -1
  46. package/typedoc/functions/index.useShellDisplay.html +1 -1
  47. package/typedoc/functions/index.useStatus.html +1 -1
  48. package/typedoc/functions/invitations.useInvitationStatus.html +1 -1
  49. package/typedoc/functions/mesh.useNetworkStatus.html +1 -1
  50. package/typedoc/hierarchy.html +1 -1
  51. package/typedoc/interfaces/echo.EchoDatabase.html +5 -5
  52. package/typedoc/interfaces/echo.Expando.html +1 -1
  53. package/typedoc/interfaces/echo.Filter.html +2 -2
  54. package/typedoc/interfaces/echo.Query.html +13 -13
  55. package/typedoc/interfaces/echo.Queue.html +4 -4
  56. package/typedoc/interfaces/echo.TypedObject.html +1 -1
  57. package/typedoc/types/echo.Filter.And.html +1 -1
  58. package/typedoc/types/echo.Filter.Any.html +1 -1
  59. package/typedoc/types/echo.Filter.Or.html +1 -1
  60. package/typedoc/types/echo.Filter.Props.html +1 -1
  61. package/typedoc/types/echo.Filter.Type.html +1 -1
  62. package/typedoc/types/echo.ObjectMigration.html +2 -2
  63. package/typedoc/types/echo.PropertiesTypeProps.html +1 -1
  64. package/typedoc/types/echo.Query.Any.html +1 -1
  65. package/typedoc/types/echo.Query.TextSearchOptions.html +2 -2
  66. package/typedoc/types/echo.Query.Type.html +1 -1
  67. package/typedoc/types/echo.UseQueueOptions.html +2 -2
  68. package/typedoc/types/echo.UseSpacesParams.html +2 -2
  69. package/typedoc/types/index.AgentHostingProviderProps.html +2 -2
  70. package/typedoc/types/index.ClientContextProps.html +2 -2
  71. package/typedoc/types/index.ClientProviderProps.html +1 -1
  72. package/typedoc/types/invitations.InvitationAction.html +1 -1
  73. package/typedoc/types/invitations.InvitationResult.html +2 -2
  74. package/typedoc/types/invitations.InvitationStatus.html +2 -2
  75. package/typedoc/variables/echo.Filter.html +1 -1
  76. package/typedoc/variables/echo.Query.html +1 -1
  77. package/typedoc/variables/echo.Queue.html +1 -1
  78. package/typedoc/variables/echo.defineObjectMigration.html +1 -1
  79. package/typedoc/variables/echo.live.html +2 -2
  80. package/typedoc/variables/echo.makeRef.html +1 -1
  81. package/typedoc/variables/echo.refFromDXN.html +1 -1
  82. package/typedoc/variables/echo.useQuery.html +1 -1
  83. package/typedoc/variables/index.AgentHostingContext.html +1 -1
  84. package/typedoc/variables/index.ClientProvider.html +1 -1
  85. package/typedoc/variables/index.DXOS_VERSION.html +1 -1
  86. package/typedoc/variables/index.resolveRef.html +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "0.8.3-main.7f5a14c",
3
+ "version": "0.8.3",
4
4
  "description": "React client API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -78,20 +78,21 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "react-error-boundary": "^4.0.13",
81
- "@dxos/async": "0.8.3-main.7f5a14c",
82
- "@dxos/client": "0.8.3-main.7f5a14c",
83
- "@dxos/codec-protobuf": "0.8.3-main.7f5a14c",
84
- "@dxos/config": "0.8.3-main.7f5a14c",
85
- "@dxos/context": "0.8.3-main.7f5a14c",
86
- "@dxos/echo-schema": "0.8.3-main.7f5a14c",
87
- "@dxos/echo-signals": "0.8.3-main.7f5a14c",
88
- "@dxos/log": "0.8.3-main.7f5a14c",
89
- "@dxos/invariant": "0.8.3-main.7f5a14c",
90
- "@dxos/protocols": "0.8.3-main.7f5a14c",
91
- "@dxos/node-std": "0.8.3-main.7f5a14c",
92
- "@dxos/debug": "0.8.3-main.7f5a14c",
93
- "@dxos/util": "0.8.3-main.7f5a14c",
94
- "@dxos/react-hooks": "0.8.3-main.7f5a14c"
81
+ "@dxos/async": "0.8.3",
82
+ "@dxos/client": "0.8.3",
83
+ "@dxos/codec-protobuf": "0.8.3",
84
+ "@dxos/config": "0.8.3",
85
+ "@dxos/context": "0.8.3",
86
+ "@dxos/debug": "0.8.3",
87
+ "@dxos/echo": "0.8.3",
88
+ "@dxos/echo-schema": "0.8.3",
89
+ "@dxos/echo-signals": "0.8.3",
90
+ "@dxos/invariant": "0.8.3",
91
+ "@dxos/log": "0.8.3",
92
+ "@dxos/node-std": "0.8.3",
93
+ "@dxos/protocols": "0.8.3",
94
+ "@dxos/react-hooks": "0.8.3",
95
+ "@dxos/util": "0.8.3"
95
96
  },
96
97
  "devDependencies": {
97
98
  "@types/react": "~18.2.0",
@@ -99,21 +100,21 @@
99
100
  "react": "~18.2.0",
100
101
  "react-dom": "~18.2.0",
101
102
  "typedoc": "0.28.1",
102
- "@dxos/random": "0.8.3-main.7f5a14c",
103
- "@dxos/react-ui-syntax-highlighter": "0.8.3-main.7f5a14c",
104
- "@dxos/react-ui-theme": "0.8.3-main.7f5a14c",
105
- "@dxos/react-ui": "0.8.3-main.7f5a14c",
106
- "@dxos/test-utils": "0.8.3-main.7f5a14c",
107
- "@dxos/storybook-utils": "0.8.3-main.7f5a14c"
103
+ "@dxos/random": "0.8.3",
104
+ "@dxos/react-ui": "0.8.3",
105
+ "@dxos/react-ui-syntax-highlighter": "0.8.3",
106
+ "@dxos/react-ui-theme": "0.8.3",
107
+ "@dxos/storybook-utils": "0.8.3",
108
+ "@dxos/test-utils": "0.8.3"
108
109
  },
109
110
  "peerDependencies": {
110
111
  "react": "~18.2.0",
111
112
  "react-dom": "~18.2.0"
112
113
  },
113
114
  "optionalDependencies": {
114
- "@dxos/react-ui": "0.8.3-main.7f5a14c",
115
- "@dxos/random": "0.8.3-main.7f5a14c",
116
- "@dxos/react-ui-theme": "0.8.3-main.7f5a14c"
115
+ "@dxos/random": "0.8.3",
116
+ "@dxos/react-ui": "0.8.3",
117
+ "@dxos/react-ui-theme": "0.8.3"
117
118
  },
118
119
  "publishConfig": {
119
120
  "access": "public"
@@ -0,0 +1,128 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { renderHook } from '@testing-library/react';
6
+ import { describe, expect, test } from 'vitest';
7
+
8
+ import { Expando, Filter, live } from '@dxos/client/echo';
9
+
10
+ import { useQuery } from './useQuery';
11
+ import { createClient, createClientContextProvider } from '../testing/util';
12
+
13
+ describe('useQuery', () => {
14
+ // TODO(dmaretskyi): Fix this test.
15
+ test.skip('deleting an element should result in correct render sequence', async () => {
16
+ // Setup: Create client and space.
17
+ const { client, space } = await createClient({ createIdentity: true, createSpace: true });
18
+ const wrapper = await createClientContextProvider(client);
19
+
20
+ // Create 3 test objects: Alice, Bob, Charlie.
21
+ const alice = live(Expando, { name: 'Alice' });
22
+ const bob = live(Expando, { name: 'Bob' });
23
+ const charlie = live(Expando, { name: 'Charlie' });
24
+
25
+ space!.db.add(alice);
26
+ space!.db.add(bob);
27
+ space!.db.add(charlie);
28
+ await space!.db.flush();
29
+
30
+ // Track all renders to observe the bug.
31
+ const allRenders: string[][] = [];
32
+
33
+ // Setup useQuery hook that captures every render.
34
+ renderHook(
35
+ () => {
36
+ const objects = useQuery(space, Filter.type(Expando));
37
+
38
+ // Capture the names in this render.
39
+ const namesInThisRender = objects.map((obj) => obj.name);
40
+ allRenders.push([...namesInThisRender]);
41
+
42
+ return objects;
43
+ },
44
+ { wrapper },
45
+ );
46
+
47
+ // Wait for initial renders to complete.
48
+ await new Promise((resolve) => setTimeout(resolve, 100));
49
+
50
+ // THE BUG REPRODUCTION: Delete Bob.
51
+ space!.db.remove(bob);
52
+
53
+ // Wait for all reactive updates to complete.
54
+ await new Promise((resolve) => setTimeout(resolve, 500));
55
+
56
+ // TODO(ZaymonFC): Remove this comment once the flash bug is resolved.
57
+ /*
58
+ * NOTE(ZaymonFC):
59
+ * Expected: 3 renders
60
+ * 1. [] (empty)
61
+ * 2. ['Alice', 'Bob', 'Charlie'] (all loaded)
62
+ * 3. ['Alice', 'Charlie'] (Bob removed, no flash)
63
+ *
64
+ * Actual: 4 renders
65
+ * 1. [] (empty)
66
+ * 2. ['Alice', 'Bob', 'Charlie'] (all loaded)
67
+ * 3. ['Alice', 'Charlie', 'Bob'] (FLASH BUG - Bob moves to end!)
68
+ * 4. ['Alice', 'Charlie'] (Bob finally removed)
69
+ */
70
+
71
+ expect(allRenders).toEqual([
72
+ [], // Initial loading state.
73
+ ['Alice', 'Bob', 'Charlie'], // All objects loaded.
74
+ ['Alice', 'Charlie'], // Bob removed (no flash).
75
+ ]);
76
+ });
77
+
78
+ test('bulk deleting multiple items should remove them from query results', async () => {
79
+ // Setup: Create client and space.
80
+ const { client, space } = await createClient({ createIdentity: true, createSpace: true });
81
+ const wrapper = await createClientContextProvider(client);
82
+
83
+ // Create 10 test objects: 1, 2, 3, ..., 10.
84
+ const objects = Array.from({ length: 10 }, (_, i) => live(Expando, { value: i + 1 }));
85
+
86
+ objects.forEach((obj) => space!.db.add(obj));
87
+ await space!.db.flush();
88
+
89
+ // Track all renders to observe the bug.
90
+ const allRenders: number[][] = [];
91
+
92
+ // Setup useQuery hook that captures every render.
93
+ renderHook(
94
+ () => {
95
+ const queryObjects = useQuery(space, Filter.type(Expando));
96
+
97
+ // Capture the values in this render.
98
+ const valuesInThisRender = queryObjects.map((obj) => obj.value);
99
+ allRenders.push([...valuesInThisRender]);
100
+
101
+ return queryObjects;
102
+ },
103
+ { wrapper },
104
+ );
105
+
106
+ // Wait for initial renders to complete.
107
+ await new Promise((resolve) => setTimeout(resolve, 100));
108
+
109
+ // THE BUG REPRODUCTION: Delete all items in a loop.
110
+ for (const item of objects) {
111
+ space!.db.remove(item);
112
+ }
113
+
114
+ // Wait for all reactive updates to complete.
115
+ await new Promise((resolve) => setTimeout(resolve, 500));
116
+
117
+ // Convert to sets for order-independent comparison.
118
+ const renderSets = allRenders.map((render) => new Set(render));
119
+
120
+ expect(renderSets).toEqual([
121
+ new Set([]), // Initial loading state.
122
+ new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), // All objects loaded.
123
+ // TODO(dmaretskyi): Fix this with query ordering.
124
+ new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), // Getting another render for some reason.
125
+ new Set([]), // All items deleted.
126
+ ]);
127
+ });
128
+ });
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useRef } from 'react';
6
6
 
7
7
  import { type Queue } from '@dxos/client/echo';
8
8
  import { raise } from '@dxos/debug';
9
- import { type BaseEchoObject } from '@dxos/echo-schema';
9
+ import { type Obj, type Relation } from '@dxos/echo';
10
10
  import { type DXN } from '@dxos/keys';
11
11
 
12
12
  import { useClient } from '../client';
@@ -24,7 +24,7 @@ export type UseQueueOptions = {
24
24
  // TODO(dmaretskyi): Move into client package.
25
25
  // TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.
26
26
  // TODO(ZaymonFC): If queue is unchanged returned object should be refferentially stable on poll.
27
- export const useQueue = <T extends BaseEchoObject>(
27
+ export const useQueue = <T extends Obj.Any | Relation.Any>(
28
28
  queueDxn?: DXN,
29
29
  options: UseQueueOptions = {},
30
30
  ): Queue<T> | undefined => {
package/tsconfig.json CHANGED
@@ -41,6 +41,9 @@
41
41
  {
42
42
  "path": "../../common/util"
43
43
  },
44
+ {
45
+ "path": "../../core/echo/echo"
46
+ },
44
47
  {
45
48
  "path": "../../core/echo/echo-schema"
46
49
  },
@@ -1 +1 @@
1
- window.hierarchyData = "eJylV8tS2zAU/RetBbVsyY/sOilM0ynQgT4WDAthi6CJImUkJSVl+PeOSUJk7MTX7SqTWOeecx/RPX5G1hjv0OiWkDTHN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