@dxos/react-client 0.8.4-main.5ea62a8 → 0.8.4-main.60689f5b1c

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 (136) hide show
  1. package/.storybook/main.mts +9 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/LICENSE +102 -5
  4. package/README.md +1 -1
  5. package/dist/lib/browser/chunk-3LVU7RNK.mjs +16 -0
  6. package/dist/lib/browser/chunk-3LVU7RNK.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-CZMIVAGI.mjs +8 -0
  8. package/dist/lib/browser/chunk-CZMIVAGI.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-XT352YI6.mjs +134 -0
  10. package/dist/lib/browser/chunk-XT352YI6.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-BXOLJYAY.mjs → chunk-YHE6WD44.mjs} +4 -14
  12. package/dist/lib/browser/chunk-YHE6WD44.mjs.map +7 -0
  13. package/dist/lib/browser/devtools/index.mjs +3 -7
  14. package/dist/lib/browser/devtools/index.mjs.map +2 -2
  15. package/dist/lib/browser/echo/index.mjs +55 -173
  16. package/dist/lib/browser/echo/index.mjs.map +4 -4
  17. package/dist/lib/browser/halo/index.mjs +8 -21
  18. package/dist/lib/browser/halo/index.mjs.map +2 -2
  19. package/dist/lib/browser/index.mjs +99 -12
  20. package/dist/lib/browser/index.mjs.map +4 -4
  21. package/dist/lib/browser/invitations/index.mjs +1 -1
  22. package/dist/lib/browser/mesh/index.mjs +2 -1
  23. package/dist/lib/browser/mesh/index.mjs.map +1 -1
  24. package/dist/lib/browser/meta.json +1 -1
  25. package/dist/lib/browser/testing/index.mjs +86 -127
  26. package/dist/lib/browser/testing/index.mjs.map +3 -3
  27. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs +17 -0
  28. package/dist/lib/node-esm/chunk-CUDKNAMV.mjs.map +7 -0
  29. package/dist/lib/node-esm/{chunk-256IHY6F.mjs → chunk-RQJPEHDY.mjs} +4 -14
  30. package/dist/lib/node-esm/chunk-RQJPEHDY.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs +135 -0
  32. package/dist/lib/node-esm/chunk-WL3Z5HOH.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs +10 -0
  34. package/dist/lib/node-esm/chunk-WUTK2IJF.mjs.map +7 -0
  35. package/dist/lib/node-esm/devtools/index.mjs +3 -7
  36. package/dist/lib/node-esm/devtools/index.mjs.map +2 -2
  37. package/dist/lib/node-esm/echo/index.mjs +55 -173
  38. package/dist/lib/node-esm/echo/index.mjs.map +4 -4
  39. package/dist/lib/node-esm/halo/index.mjs +8 -21
  40. package/dist/lib/node-esm/halo/index.mjs.map +2 -2
  41. package/dist/lib/node-esm/index.mjs +99 -12
  42. package/dist/lib/node-esm/index.mjs.map +4 -4
  43. package/dist/lib/node-esm/invitations/index.mjs +1 -1
  44. package/dist/lib/node-esm/mesh/index.mjs +2 -1
  45. package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
  46. package/dist/lib/node-esm/meta.json +1 -1
  47. package/dist/lib/node-esm/testing/index.mjs +86 -127
  48. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  49. package/dist/types/src/banner.d.ts.map +1 -1
  50. package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
  51. package/dist/types/src/client/ClientProvider.d.ts +1 -11
  52. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  53. package/dist/types/src/client/useClientStatus.d.ts.map +1 -1
  54. package/dist/types/src/devtools/useStream.d.ts.map +1 -1
  55. package/dist/types/src/echo/index.d.ts +2 -3
  56. package/dist/types/src/echo/index.d.ts.map +1 -1
  57. package/dist/types/src/echo/useMembers.d.ts +2 -2
  58. package/dist/types/src/echo/useMembers.d.ts.map +1 -1
  59. package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
  60. package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
  61. package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
  62. package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
  63. package/dist/types/src/echo/useSpaces.d.ts +19 -8
  64. package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
  65. package/dist/types/src/echo/useSubscription.d.ts +1 -1
  66. package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
  67. package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
  68. package/dist/types/src/halo/Passkey.stories.d.ts +1 -1
  69. package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
  70. package/dist/types/src/halo/useHaloInvitations.d.ts.map +1 -1
  71. package/dist/types/src/halo/useKeyStore.d.ts.map +1 -1
  72. package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
  73. package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
  74. package/dist/types/src/testing/ClientRepeater.d.ts +6 -5
  75. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  76. package/dist/types/src/testing/ClientRepeater.stories.d.ts +0 -1
  77. package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
  78. package/dist/types/src/testing/context.d.ts +4 -1
  79. package/dist/types/src/testing/context.d.ts.map +1 -1
  80. package/dist/types/src/testing/util.d.ts.map +1 -1
  81. package/dist/types/src/testing/withClientProvider.d.ts +5 -9
  82. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  83. package/dist/types/src/testing/withClientProvider.stories.d.ts +3 -2
  84. package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
  85. package/dist/types/tsconfig.tsbuildinfo +1 -1
  86. package/docs/README.md +38 -38
  87. package/moon.yml +3 -2
  88. package/package.json +38 -59
  89. package/src/client/ClientProvider.test.tsx +0 -1
  90. package/src/client/ClientProvider.tsx +12 -27
  91. package/src/client/useConfig.test.tsx +0 -1
  92. package/src/echo/index.ts +2 -3
  93. package/src/echo/useMembers.ts +5 -3
  94. package/src/echo/useSpaceInvitations.ts +9 -5
  95. package/src/echo/useSpaceProperties.ts +28 -0
  96. package/src/echo/useSpaces.test.tsx +7 -14
  97. package/src/echo/useSpaces.ts +33 -26
  98. package/src/echo/useSubscription.ts +1 -1
  99. package/src/echo/useSyncState.ts +3 -7
  100. package/src/halo/Passkey.stories.tsx +16 -22
  101. package/src/halo/useDevices.test.tsx +0 -1
  102. package/src/invitations/useInvitationStatus.ts +9 -8
  103. package/src/testing/ClientRepeater.stories.tsx +12 -12
  104. package/src/testing/ClientRepeater.tsx +14 -18
  105. package/src/testing/context.tsx +4 -2
  106. package/src/testing/util.tsx +0 -1
  107. package/src/testing/withClientProvider.stories.tsx +23 -15
  108. package/src/testing/withClientProvider.tsx +74 -91
  109. package/tsconfig.json +7 -4
  110. package/typedoc.json +1 -1
  111. package/vitest.config.ts +10 -16
  112. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  113. package/dist/lib/browser/chunk-BXOLJYAY.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-TA2HGRAF.mjs +0 -309
  115. package/dist/lib/browser/chunk-TA2HGRAF.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-256IHY6F.mjs.map +0 -7
  117. package/dist/lib/node-esm/chunk-ZJMNF7GC.mjs +0 -311
  118. package/dist/lib/node-esm/chunk-ZJMNF7GC.mjs.map +0 -7
  119. package/dist/types/src/echo/useQuery.d.ts +0 -11
  120. package/dist/types/src/echo/useQuery.d.ts.map +0 -1
  121. package/dist/types/src/echo/useQuery.test.d.ts +0 -2
  122. package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
  123. package/dist/types/src/echo/useQueue.d.ts +0 -11
  124. package/dist/types/src/echo/useQueue.d.ts.map +0 -1
  125. package/dist/types/src/echo/useSchema.d.ts +0 -8
  126. package/dist/types/src/echo/useSchema.d.ts.map +0 -1
  127. package/dist/types/src/playwright/playwright.config.d.ts +0 -3
  128. package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
  129. package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
  130. package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
  131. package/src/echo/useQuery.test.tsx +0 -129
  132. package/src/echo/useQuery.ts +0 -56
  133. package/src/echo/useQueue.ts +0 -74
  134. package/src/echo/useSchema.ts +0 -54
  135. package/src/playwright/playwright.config.ts +0 -17
  136. package/src/playwright/smoke.spec.ts +0 -24
@@ -1,74 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { useEffect, useMemo, useRef } from 'react';
6
-
7
- import { type Queue } from '@dxos/client/echo';
8
- import { raise } from '@dxos/debug';
9
- import { type Obj, type Relation } from '@dxos/echo';
10
- import { type DXN } from '@dxos/keys';
11
-
12
- import { useClient } from '../client';
13
-
14
- const MIN_POLL_INTERVAL = 1_000;
15
-
16
- export type UseQueueOptions = {
17
- pollInterval?: number;
18
- };
19
-
20
- /**
21
- * Polls the given Edge queue.
22
- */
23
- // TODO(burdon): Replace polling with socket?
24
- // TODO(dmaretskyi): Move into client package.
25
- // TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.
26
- // TODO(ZaymonFC): If queue is unchanged returned object should be refferentially stable on poll.
27
- export const useQueue = <T extends Obj.Any | Relation.Any>(
28
- queueDxn?: DXN,
29
- options: UseQueueOptions = {},
30
- ): Queue<T> | undefined => {
31
- const client = useClient();
32
- const mountedRef = useRef(true);
33
-
34
- const queue = useMemo<Queue<T> | undefined>(() => {
35
- if (!queueDxn) {
36
- return undefined;
37
- }
38
-
39
- const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError('Invalid queue DXN'));
40
- return client.spaces.get(spaceId)?.queues.get<T>(queueDxn);
41
- }, [client, queueDxn?.toString()]);
42
-
43
- useEffect(() => {
44
- void queue?.refresh();
45
- }, [queue]);
46
-
47
- useEffect(() => {
48
- let timeout: NodeJS.Timeout;
49
- mountedRef.current = true;
50
-
51
- const poll = () => {
52
- if (!mountedRef.current) {
53
- return;
54
- }
55
-
56
- void queue?.refresh().finally(() => {
57
- if (mountedRef.current && options.pollInterval) {
58
- timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));
59
- }
60
- });
61
- };
62
-
63
- if (options.pollInterval) {
64
- poll();
65
- }
66
-
67
- return () => {
68
- mountedRef.current = false;
69
- clearTimeout(timeout);
70
- };
71
- }, [queue, options.pollInterval]);
72
-
73
- return queue;
74
- };
@@ -1,54 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
- import { useMemo, useSyncExternalStore } from 'react';
7
-
8
- import { type Client } from '@dxos/client';
9
- import { type Space } from '@dxos/client/echo';
10
- import { type BaseSchema } from '@dxos/echo-schema';
11
-
12
- /**
13
- * Subscribe to and retrieve schema changes from a space's schema registry.
14
- */
15
- export const useSchema = (
16
- client: Client,
17
- space: Space | undefined,
18
- typename: string | undefined,
19
- ): Schema.Schema.AnyNoContext | undefined => {
20
- const { subscribe, getSchema } = useMemo(() => {
21
- if (!typename || !space) {
22
- return {
23
- subscribe: () => () => {},
24
- getSchema: () => undefined,
25
- };
26
- }
27
-
28
- const staticSchema = client.graph.schemaRegistry.getSchema(typename);
29
- if (staticSchema) {
30
- return {
31
- subscribe: () => () => {},
32
- getSchema: () => staticSchema,
33
- };
34
- }
35
-
36
- const query = space.db.schemaRegistry.query({ typename });
37
- const initialResult: BaseSchema = query.runSync()[0];
38
- let currentSchema = initialResult;
39
-
40
- return {
41
- subscribe: (onStoreChange: () => void) => {
42
- const unsubscribe = query.subscribe(() => {
43
- currentSchema = query.results[0];
44
- onStoreChange();
45
- });
46
-
47
- return unsubscribe;
48
- },
49
- getSchema: () => currentSchema,
50
- };
51
- }, [typename, space]);
52
-
53
- return useSyncExternalStore(subscribe, getSchema);
54
- };
@@ -1,17 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { defineConfig } from '@playwright/test';
6
-
7
- import { e2ePreset } from '@dxos/test-utils/playwright';
8
-
9
- export default defineConfig({
10
- ...e2ePreset(import.meta.dirname),
11
- // TODO(wittjosiah): Avoid hard-coding ports.
12
- webServer: {
13
- command: 'moon run storybook:serve-e2e -- --port=9000',
14
- port: 9000,
15
- reuseExistingServer: false,
16
- },
17
- });
@@ -1,24 +0,0 @@
1
- //
2
- // Copyright 2021 DXOS.org
3
- //
4
-
5
- import { type Page, expect, test } from '@playwright/test';
6
-
7
- import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
8
-
9
- test.describe('Smoke test', () => {
10
- let page: Page;
11
-
12
- test.beforeAll(async ({ browser }) => {
13
- const result = await setupPage(browser, {
14
- url: storybookUrl('sdk-react-client-withclientprovider--default', 9000),
15
- });
16
- page = result.page;
17
- await page.locator(':text("initialized")').waitFor({ state: 'visible' });
18
- });
19
-
20
- // NOTE: This test depends on connecting to the default production deployed HALO vault.
21
- test('Renders remote client info', async () => {
22
- await expect(page.locator(':text("initialized")')).toBeVisible();
23
- });
24
- });