@dxos/react-client 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/.storybook/main.mts +2 -4
- package/.storybook/preview.mts +2 -2
- package/dist/lib/browser/chunk-5UKA2BMA.mjs +179 -0
- package/dist/lib/browser/chunk-5UKA2BMA.mjs.map +7 -0
- package/dist/lib/browser/chunk-PFF63FPR.mjs +16 -0
- package/dist/lib/browser/chunk-PFF63FPR.mjs.map +7 -0
- package/dist/lib/browser/chunk-TSF6Y5VB.mjs +8 -0
- package/dist/lib/browser/chunk-TSF6Y5VB.mjs.map +7 -0
- package/dist/lib/browser/devtools/index.mjs +2 -1
- package/dist/lib/browser/devtools/index.mjs.map +1 -1
- package/dist/lib/browser/echo/index.mjs +44 -94
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/halo/index.mjs +7 -20
- package/dist/lib/browser/halo/index.mjs.map +2 -2
- package/dist/lib/browser/index.mjs +114 -12
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/mesh/index.mjs +2 -1
- package/dist/lib/browser/mesh/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +83 -110
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-373DPHEQ.mjs +10 -0
- package/dist/lib/node-esm/chunk-373DPHEQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NETTSER2.mjs +17 -0
- package/dist/lib/node-esm/chunk-NETTSER2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-T3QTQHBD.mjs +180 -0
- package/dist/lib/node-esm/chunk-T3QTQHBD.mjs.map +7 -0
- package/dist/lib/node-esm/devtools/index.mjs +2 -1
- package/dist/lib/node-esm/devtools/index.mjs.map +1 -1
- package/dist/lib/node-esm/echo/index.mjs +44 -94
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/halo/index.mjs +7 -20
- package/dist/lib/node-esm/halo/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +114 -12
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/mesh/index.mjs +2 -1
- package/dist/lib/node-esm/mesh/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +83 -110
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/client/ClientProvider.d.ts +0 -10
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +2 -2
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useMembers.d.ts +2 -2
- package/dist/types/src/echo/useMembers.d.ts.map +1 -1
- package/dist/types/src/echo/useQueue.d.ts +2 -2
- package/dist/types/src/echo/useQueue.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceInvitations.d.ts +3 -2
- package/dist/types/src/echo/useSpaceInvitations.d.ts.map +1 -1
- package/dist/types/src/echo/useSpaceProperties.d.ts +13 -0
- package/dist/types/src/echo/useSpaceProperties.d.ts.map +1 -0
- package/dist/types/src/echo/useSpaces.d.ts +17 -8
- package/dist/types/src/echo/useSpaces.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.d.ts +5 -4
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/context.d.ts +4 -2
- package/dist/types/src/testing/context.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts +0 -3
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +1 -0
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/docs/README.md +38 -38
- package/moon.yml +2 -5
- package/package.json +35 -32
- package/src/client/ClientProvider.tsx +12 -26
- package/src/echo/index.ts +2 -2
- package/src/echo/useMembers.ts +5 -3
- package/src/echo/useQueue.ts +2 -2
- package/src/echo/useSpaceInvitations.ts +9 -4
- package/src/echo/useSpaceProperties.ts +28 -0
- package/src/echo/useSpaces.test.tsx +1 -1
- package/src/echo/useSpaces.ts +33 -12
- package/src/echo/useSyncState.ts +2 -2
- package/src/halo/Passkey.stories.tsx +3 -3
- package/src/testing/ClientRepeater.stories.tsx +9 -4
- package/src/testing/ClientRepeater.tsx +9 -12
- package/src/testing/context.tsx +4 -3
- package/src/testing/withClientProvider.stories.tsx +14 -9
- package/src/testing/withClientProvider.tsx +62 -79
- package/tsconfig.json +3 -3
- package/typedoc.json +1 -1
- package/vitest.config.ts +1 -1
- package/dist/lib/browser/chunk-TA2HGRAF.mjs +0 -309
- package/dist/lib/browser/chunk-TA2HGRAF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZJMNF7GC.mjs +0 -311
- package/dist/lib/node-esm/chunk-ZJMNF7GC.mjs.map +0 -7
- package/dist/types/src/echo/useQuery.d.ts +0 -11
- package/dist/types/src/echo/useQuery.d.ts.map +0 -1
- package/dist/types/src/echo/useQuery.test.d.ts +0 -2
- package/dist/types/src/echo/useQuery.test.d.ts.map +0 -1
- package/dist/types/src/echo/useSchema.d.ts +0 -8
- package/dist/types/src/echo/useSchema.d.ts.map +0 -1
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- package/dist/types/src/playwright/smoke.spec.d.ts +0 -2
- package/dist/types/src/playwright/smoke.spec.d.ts.map +0 -1
- package/src/echo/useQuery.test.tsx +0 -129
- package/src/echo/useQuery.ts +0 -72
- package/src/echo/useSchema.ts +0 -54
- package/src/playwright/playwright.config.ts +0 -17
- package/src/playwright/smoke.spec.ts +0 -24
package/src/echo/useQuery.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useMemo, useSyncExternalStore } from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type Echo,
|
|
9
|
-
Filter,
|
|
10
|
-
type Live,
|
|
11
|
-
Query,
|
|
12
|
-
type Queryable,
|
|
13
|
-
type Queue,
|
|
14
|
-
type Space,
|
|
15
|
-
isSpace,
|
|
16
|
-
} from '@dxos/client/echo';
|
|
17
|
-
|
|
18
|
-
const EMPTY_ARRAY: never[] = [];
|
|
19
|
-
|
|
20
|
-
const noop = () => {};
|
|
21
|
-
|
|
22
|
-
// TODO(dmaretskyi): Queries are fully serializable, so we can remove `deps` argument.
|
|
23
|
-
interface UseQueryFn {
|
|
24
|
-
<Q extends Query.Any>(
|
|
25
|
-
spaceOrEcho: Space | Echo | Queue<any> | undefined,
|
|
26
|
-
query: Q,
|
|
27
|
-
deps?: any[],
|
|
28
|
-
): Live<Query.Type<Q>>[];
|
|
29
|
-
|
|
30
|
-
<F extends Filter.Any>(
|
|
31
|
-
spaceOrEcho: Space | Echo | Queue<any> | undefined,
|
|
32
|
-
filter: F,
|
|
33
|
-
deps?: any[],
|
|
34
|
-
): Live<Filter.Type<F>>[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create subscription.
|
|
39
|
-
*/
|
|
40
|
-
export const useQuery: UseQueryFn = (
|
|
41
|
-
// TODO(burdon): Remove Space and just requre Queryable?
|
|
42
|
-
resource: Space | Queryable | undefined,
|
|
43
|
-
queryOrFilter: Query.Any | Filter.Any,
|
|
44
|
-
deps?: any[],
|
|
45
|
-
): Live<unknown>[] => {
|
|
46
|
-
const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;
|
|
47
|
-
|
|
48
|
-
const { getObjects, subscribe } = useMemo(() => {
|
|
49
|
-
let queryResult = undefined;
|
|
50
|
-
if (resource) {
|
|
51
|
-
queryResult = isSpace(resource) ? resource.db.query(query) : resource.query(query);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let subscribed = false;
|
|
55
|
-
return {
|
|
56
|
-
getObjects: () => (subscribed && queryResult ? queryResult.objects : EMPTY_ARRAY),
|
|
57
|
-
subscribe: (cb: () => void) => {
|
|
58
|
-
subscribed = true;
|
|
59
|
-
const unsubscribe = queryResult?.subscribe(cb) ?? noop;
|
|
60
|
-
return () => {
|
|
61
|
-
unsubscribe?.();
|
|
62
|
-
subscribed = false;
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}, [resource, JSON.stringify(query.ast), ...(deps ?? [])]);
|
|
67
|
-
|
|
68
|
-
// https://beta.reactjs.org/reference/react/useSyncExternalStore
|
|
69
|
-
// NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.
|
|
70
|
-
const objects = useSyncExternalStore<Live<unknown>[] | undefined>(subscribe, getObjects);
|
|
71
|
-
return objects ?? [];
|
|
72
|
-
};
|
package/src/echo/useSchema.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type * as Schema from 'effect/Schema';
|
|
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/internal';
|
|
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
|
-
});
|