@dxos/react-client 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5

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 (129) hide show
  1. package/.storybook/main.mts +9 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  4. package/dist/lib/browser/chunk-BVDNYEYI.mjs +179 -0
  5. package/dist/lib/browser/chunk-BVDNYEYI.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-BXOLJYAY.mjs → chunk-LO3TU5CK.mjs} +4 -4
  7. package/dist/lib/browser/chunk-LO3TU5CK.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-PFF63FPR.mjs +16 -0
  9. package/dist/lib/browser/chunk-PFF63FPR.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-TSF6Y5VB.mjs +8 -0
  11. package/dist/lib/browser/chunk-TSF6Y5VB.mjs.map +7 -0
  12. package/dist/lib/browser/devtools/index.mjs +2 -1
  13. package/dist/lib/browser/devtools/index.mjs.map +1 -1
  14. package/dist/lib/browser/echo/index.mjs +58 -121
  15. package/dist/lib/browser/echo/index.mjs.map +4 -4
  16. package/dist/lib/browser/halo/index.mjs +4 -4
  17. package/dist/lib/browser/halo/index.mjs.map +2 -2
  18. package/dist/lib/browser/index.mjs +114 -12
  19. package/dist/lib/browser/index.mjs.map +4 -4
  20. package/dist/lib/browser/invitations/index.mjs +1 -1
  21. package/dist/lib/browser/mesh/index.mjs +2 -1
  22. package/dist/lib/browser/mesh/index.mjs.map +1 -1
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/testing/index.mjs +121 -149
  25. package/dist/lib/browser/testing/index.mjs.map +3 -3
  26. package/dist/lib/node-esm/chunk-373DPHEQ.mjs +10 -0
  27. package/dist/lib/node-esm/chunk-373DPHEQ.mjs.map +7 -0
  28. package/dist/lib/node-esm/{chunk-256IHY6F.mjs → chunk-AQJH2UNZ.mjs} +4 -4
  29. package/dist/lib/node-esm/chunk-AQJH2UNZ.mjs.map +7 -0
  30. package/dist/lib/node-esm/chunk-NETTSER2.mjs +17 -0
  31. package/dist/lib/node-esm/chunk-NETTSER2.mjs.map +7 -0
  32. package/dist/lib/node-esm/chunk-VSA674XR.mjs +180 -0
  33. package/dist/lib/node-esm/chunk-VSA674XR.mjs.map +7 -0
  34. package/dist/lib/node-esm/devtools/index.mjs +2 -1
  35. package/dist/lib/node-esm/devtools/index.mjs.map +1 -1
  36. package/dist/lib/node-esm/echo/index.mjs +58 -121
  37. package/dist/lib/node-esm/echo/index.mjs.map +4 -4
  38. package/dist/lib/node-esm/halo/index.mjs +4 -4
  39. package/dist/lib/node-esm/halo/index.mjs.map +2 -2
  40. package/dist/lib/node-esm/index.mjs +114 -12
  41. package/dist/lib/node-esm/index.mjs.map +4 -4
  42. package/dist/lib/node-esm/invitations/index.mjs +1 -1
  43. package/dist/lib/node-esm/mesh/index.mjs +2 -1
  44. package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
  45. package/dist/lib/node-esm/meta.json +1 -1
  46. package/dist/lib/node-esm/testing/index.mjs +121 -149
  47. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  48. package/dist/types/src/client/ClientProvider.d.ts +0 -10
  49. package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
  50. package/dist/types/src/echo/index.d.ts +2 -2
  51. package/dist/types/src/echo/index.d.ts.map +1 -1
  52. package/dist/types/src/echo/useMembers.d.ts +2 -2
  53. package/dist/types/src/echo/useMembers.d.ts.map +1 -1
  54. package/dist/types/src/echo/useQueue.d.ts +3 -2
  55. package/dist/types/src/echo/useQueue.d.ts.map +1 -1
  56. package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
  57. package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
  58. package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
  59. package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
  60. package/dist/types/src/echo/useSpaces.d.ts +18 -9
  61. package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
  62. package/dist/types/src/echo/useSubscription.d.ts +1 -1
  63. package/dist/types/src/echo/useSubscription.d.ts.map +1 -1
  64. package/dist/types/src/echo/useSyncState.d.ts.map +1 -1
  65. package/dist/types/src/halo/Passkey.stories.d.ts +5 -5
  66. package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
  67. package/dist/types/src/invitations/useInvitationStatus.d.ts +1 -1
  68. package/dist/types/src/invitations/useInvitationStatus.d.ts.map +1 -1
  69. package/dist/types/src/testing/ClientRepeater.d.ts +6 -5
  70. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  71. package/dist/types/src/testing/ClientRepeater.stories.d.ts +6 -10
  72. package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
  73. package/dist/types/src/testing/context.d.ts +4 -2
  74. package/dist/types/src/testing/context.d.ts.map +1 -1
  75. package/dist/types/src/testing/util.d.ts.map +1 -1
  76. package/dist/types/src/testing/withClientProvider.d.ts +5 -9
  77. package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
  78. package/dist/types/src/testing/withClientProvider.stories.d.ts +8 -9
  79. package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
  80. package/dist/types/tsconfig.tsbuildinfo +1 -1
  81. package/docs/README.md +38 -38
  82. package/moon.yml +3 -2
  83. package/package.json +35 -33
  84. package/src/client/ClientProvider.test.tsx +0 -1
  85. package/src/client/ClientProvider.tsx +29 -48
  86. package/src/client/useConfig.test.tsx +0 -1
  87. package/src/echo/index.ts +2 -2
  88. package/src/echo/useMembers.ts +5 -3
  89. package/src/echo/useQueue.ts +3 -4
  90. package/src/echo/useSpaceInvitations.ts +9 -5
  91. package/src/echo/useSpaceProperties.ts +28 -0
  92. package/src/echo/useSpaces.test.tsx +7 -14
  93. package/src/echo/useSpaces.ts +31 -30
  94. package/src/echo/useSubscription.ts +1 -1
  95. package/src/echo/useSyncState.ts +4 -3
  96. package/src/halo/Passkey.stories.tsx +15 -14
  97. package/src/halo/useDevices.test.tsx +0 -1
  98. package/src/invitations/useInvitationStatus.ts +9 -8
  99. package/src/testing/ClientRepeater.stories.tsx +19 -12
  100. package/src/testing/ClientRepeater.tsx +31 -40
  101. package/src/testing/context.tsx +4 -3
  102. package/src/testing/util.tsx +0 -1
  103. package/src/testing/withClientProvider.stories.tsx +30 -17
  104. package/src/testing/withClientProvider.tsx +74 -92
  105. package/tsconfig.json +3 -6
  106. package/typedoc.json +1 -1
  107. package/vitest.config.ts +10 -16
  108. package/.swc/plugins/v7_linux_x86_64_13.0.0/c614d7475354583212fbd7669acbae95b9832c305bf51bdaabe2e6de05abb6bf +0 -0
  109. package/dist/lib/browser/chunk-BXOLJYAY.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-FQAPI3I4.mjs +0 -312
  111. package/dist/lib/browser/chunk-FQAPI3I4.mjs.map +0 -7
  112. package/dist/lib/node-esm/chunk-256IHY6F.mjs.map +0 -7
  113. package/dist/lib/node-esm/chunk-MNTJNI2M.mjs +0 -314
  114. package/dist/lib/node-esm/chunk-MNTJNI2M.mjs.map +0 -7
  115. package/dist/types/src/echo/useQuery.d.ts +0 -11
  116. package/dist/types/src/echo/useQuery.d.ts.map +0 -1
  117. package/dist/types/src/echo/useQuery.test.d.ts +0 -2
  118. package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
  119. package/dist/types/src/echo/useSchema.d.ts +0 -8
  120. package/dist/types/src/echo/useSchema.d.ts.map +0 -1
  121. package/dist/types/src/playwright/playwright.config.d.ts +0 -3
  122. package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
  123. package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
  124. package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
  125. package/src/echo/useQuery.test.tsx +0 -129
  126. package/src/echo/useQuery.ts +0 -56
  127. package/src/echo/useSchema.ts +0 -54
  128. package/src/playwright/playwright.config.ts +0 -17
  129. package/src/playwright/smoke.spec.ts +0 -24
@@ -1,56 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import { useMemo, useSyncExternalStore } from 'react';
6
-
7
- import { type Echo, Filter, type Live, Query, type Space, isSpace } from '@dxos/client/echo';
8
-
9
- const EMPTY_ARRAY: never[] = [];
10
-
11
- const noop = () => {};
12
-
13
- // TODO(dmaretskyi): Queries are fully serializable, so we can remove `deps` argument.
14
- interface UseQueryFn {
15
- <Q extends Query.Any>(spaceOrEcho: Space | Echo | undefined, query: Q, deps?: any[]): Live<Query.Type<Q>>[];
16
-
17
- <F extends Filter.Any>(spaceOrEcho: Space | Echo | undefined, filter: F, deps?: any[]): Live<Filter.Type<F>>[];
18
- }
19
-
20
- /**
21
- * Create subscription.
22
- */
23
- export const useQuery: UseQueryFn = (
24
- spaceOrEcho: Space | Echo | undefined,
25
- queryOrFilter: Query.Any | Filter.Any,
26
- deps?: any[],
27
- ): Live<unknown>[] => {
28
- const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;
29
-
30
- const { getObjects, subscribe } = useMemo(() => {
31
- let subscribed = false;
32
- const queryResult =
33
- spaceOrEcho === undefined
34
- ? undefined
35
- : isSpace(spaceOrEcho)
36
- ? spaceOrEcho.db.query(query)
37
- : spaceOrEcho.query(query);
38
-
39
- return {
40
- getObjects: () => (subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY),
41
- subscribe: (cb: () => void) => {
42
- subscribed = true;
43
- const unsubscribe = queryResult?.subscribe(cb) ?? noop;
44
- return () => {
45
- unsubscribe?.();
46
- subscribed = false;
47
- };
48
- },
49
- };
50
- }, [spaceOrEcho, JSON.stringify(query.ast), ...(deps ?? [])]);
51
-
52
- // https://beta.reactjs.org/reference/react/useSyncExternalStore
53
- // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.
54
- const objects = useSyncExternalStore<Live<unknown>[] | undefined>(subscribe, getObjects);
55
- return objects ?? [];
56
- };
@@ -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
- });