@dxos/react-client 2.24.1-dev.79448ad7 → 2.25.1-dev.3e7251f9
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/.rush/temp/package-deps_build.json +3 -3
- package/.rush/temp/package-deps_build:test.json +11 -12
- package/.rush/temp/package-deps_prerelease.json +58 -0
- package/dist/src/hooks/client/useProfile.d.ts +1 -1
- package/dist/src/hooks/client/useProfile.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/index.d.ts +0 -1
- package/dist/src/hooks/echo-queries/index.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/index.js +0 -1
- package/dist/src/hooks/echo-queries/index.js.map +1 -1
- package/dist/src/hooks/echo-queries/useContacts.d.ts +1 -1
- package/dist/src/hooks/echo-queries/useContacts.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.d.ts +2 -3
- package/dist/src/hooks/echo-queries/useMembers.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.js.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.d.ts +3 -3
- package/dist/src/hooks/echo-queries/useParties.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.js.map +1 -1
- package/dist/src/hooks/echo-selections/search.d.ts +2 -1
- package/dist/src/hooks/echo-selections/search.d.ts.map +1 -1
- package/dist/src/hooks/echo-selections/search.js +9 -7
- package/dist/src/hooks/echo-selections/search.js.map +1 -1
- package/dist/src/hooks/echo-selections/useSelection.d.ts +3 -3
- package/dist/src/hooks/echo-selections/useSelection.d.ts.map +1 -1
- package/dist/src/hooks/echo-selections/useSelection.js +16 -13
- package/dist/src/hooks/echo-selections/useSelection.js.map +1 -1
- package/dist/src/hooks/util/useResultSet.d.ts +1 -1
- package/dist/src/hooks/util/useResultSet.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.js +2 -2
- package/dist/stories/halo-invitations.stories.js.map +1 -1
- package/dist/stories/helpers/ClientPanel.d.ts +2 -2
- package/dist/stories/helpers/ClientPanel.d.ts.map +1 -1
- package/dist/stories/party-invitations.stories.d.ts.map +1 -1
- package/dist/stories/party-invitations.stories.js +2 -2
- package/dist/stories/party-invitations.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/react-client.build.log +0 -33
- package/src/hooks/echo-queries/index.ts +0 -1
- package/src/hooks/echo-queries/useContacts.ts +1 -1
- package/src/hooks/echo-queries/useMembers.tsx +2 -3
- package/src/hooks/echo-queries/useParties.ts +3 -3
- package/src/hooks/echo-selections/search.ts +9 -5
- package/src/hooks/echo-selections/useSelection.ts +20 -15
- package/src/hooks/util/useResultSet.ts +1 -1
- package/stories/halo-invitations.stories.tsx +1 -2
- package/stories/helpers/ClientPanel.tsx +2 -2
- package/stories/party-invitations.stories.tsx +1 -2
- package/dist/src/hooks/echo-queries/useRemoteParties.d.ts +0 -7
- package/dist/src/hooks/echo-queries/useRemoteParties.d.ts.map +0 -1
- package/dist/src/hooks/echo-queries/useRemoteParties.js +0 -24
- package/dist/src/hooks/echo-queries/useRemoteParties.js.map +0 -1
- package/src/hooks/echo-queries/useRemoteParties.ts +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.1-dev.3e7251f9",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
"main": "dist/src/index.js",
|
|
9
9
|
"types": "dist/src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@dxos/async": "2.
|
|
12
|
-
"@dxos/bot-factory-client": "2.
|
|
13
|
-
"@dxos/client": "2.
|
|
14
|
-
"@dxos/config": "2.
|
|
15
|
-
"@dxos/credentials": "2.
|
|
16
|
-
"@dxos/crypto": "2.
|
|
17
|
-
"@dxos/debug": "2.
|
|
18
|
-
"@dxos/echo-db": "2.
|
|
19
|
-
"@dxos/util": "2.
|
|
11
|
+
"@dxos/async": "2.25.1-dev.3e7251f9",
|
|
12
|
+
"@dxos/bot-factory-client": "2.25.1-dev.3e7251f9",
|
|
13
|
+
"@dxos/client": "2.25.1-dev.3e7251f9",
|
|
14
|
+
"@dxos/config": "2.25.1-dev.3e7251f9",
|
|
15
|
+
"@dxos/credentials": "2.25.1-dev.3e7251f9",
|
|
16
|
+
"@dxos/crypto": "2.25.1-dev.3e7251f9",
|
|
17
|
+
"@dxos/debug": "2.25.1-dev.3e7251f9",
|
|
18
|
+
"@dxos/echo-db": "2.25.1-dev.3e7251f9",
|
|
19
|
+
"@dxos/util": "2.25.1-dev.3e7251f9",
|
|
20
20
|
"assert": "^2.0.0",
|
|
21
21
|
"debug": "^4.3.3",
|
|
22
22
|
"react-display-name": "^0.2.5",
|
|
23
23
|
"use-subscription": "^1.4.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@dxos/esbuild-plugins": "2.
|
|
26
|
+
"@dxos/esbuild-plugins": "2.25.1-dev.3e7251f9",
|
|
27
27
|
"@dxos/esbuild-server": "~1.7.4",
|
|
28
|
-
"@dxos/toolchain-node-library": "2.
|
|
28
|
+
"@dxos/toolchain-node-library": "2.25.0",
|
|
29
29
|
"@mui/material": "^5.0.1",
|
|
30
30
|
"@testing-library/react": "^11.0.4",
|
|
31
31
|
"@testing-library/react-hooks": "5.1.2",
|
package/react-client.build.log
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Invoking: toolchain build:test
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
typescript
|
|
5
|
-
OK in 7607 ms
|
|
6
|
-
|
|
7
|
-
eslint
|
|
8
|
-
OK in 7853 ms
|
|
9
|
-
|
|
10
|
-
mocha
|
|
11
|
-
This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
|
|
12
|
-
This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ClientProvider
|
|
16
|
-
✓ Renders with children
|
|
17
|
-
✓ Provides the client
|
|
18
|
-
|
|
19
|
-
Client hook
|
|
20
|
-
✓ should throw when used outside a context
|
|
21
|
-
✓ should return client when used properly in a context
|
|
22
|
-
|
|
23
|
-
Config hook
|
|
24
|
-
✓ should throw when used outside a context
|
|
25
|
-
✓ should return default client config when no config is passed in a context
|
|
26
|
-
✓ should return custom client config when used properly in a context
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
7 passing (362ms)
|
|
30
|
-
|
|
31
|
-
OK in 2825 ms
|
|
32
|
-
|
|
33
|
-
CHECK COMPLETE in 18304 ms
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { PartyMember } from '@dxos/echo-db';
|
|
7
|
+
import { Party, PartyMember } from '@dxos/client';
|
|
9
8
|
|
|
10
|
-
export const useMembers = (party:
|
|
9
|
+
export const useMembers = (party: Party | undefined) => {
|
|
11
10
|
const [members, setMembers] = useState<PartyMember[]>([]);
|
|
12
11
|
|
|
13
12
|
useEffect(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Party } from '@dxos/client';
|
|
8
8
|
import { PublicKeyLike } from '@dxos/crypto';
|
|
9
9
|
|
|
10
10
|
import { useClient } from '../client';
|
|
@@ -13,7 +13,7 @@ import { useClient } from '../client';
|
|
|
13
13
|
* Get a specific Party.
|
|
14
14
|
* Requires ClientContext to be set via ClientProvider.
|
|
15
15
|
*/
|
|
16
|
-
export const useParty = (partyKey?: PublicKeyLike):
|
|
16
|
+
export const useParty = (partyKey?: PublicKeyLike): Party | undefined => {
|
|
17
17
|
const parties = useParties();
|
|
18
18
|
return parties.find(party => partyKey && party.key.equals(partyKey));
|
|
19
19
|
};
|
|
@@ -24,7 +24,7 @@ export const useParty = (partyKey?: PublicKeyLike): PartyProxy | undefined => {
|
|
|
24
24
|
*/
|
|
25
25
|
export const useParties = () => {
|
|
26
26
|
const client = useClient();
|
|
27
|
-
const [parties, setParties] = useState<
|
|
27
|
+
const [parties, setParties] = useState<Party[]>([]);
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
const result = client.echo.queryParties();
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Party } from '@dxos/client';
|
|
6
|
+
|
|
7
|
+
import { useSelection } from '.';
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* A Selector used for finding items based on a search pattern.
|
|
7
11
|
* @param search Searched value.
|
|
8
12
|
*/
|
|
9
13
|
// TODO(burdon): Create index.
|
|
10
|
-
|
|
14
|
+
// TODO(dmaretskyi): Why is this in react-client?
|
|
15
|
+
export const useSearchSelection = (party: Party, search: any) => {
|
|
11
16
|
const match = (pattern: any, text: any) => {
|
|
12
17
|
if (!pattern) {
|
|
13
18
|
return true;
|
|
@@ -21,15 +26,14 @@ export const searchSelector = (search: any) => (selection: any) => {
|
|
|
21
26
|
return text.toLowerCase().indexOf(pattern) !== -1;
|
|
22
27
|
};
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
return selection.items.filter((item: any) => {
|
|
29
|
+
return useSelection(party.select().filter(item => {
|
|
26
30
|
// TODO(burdon): Filter types.
|
|
27
|
-
if (item.type
|
|
31
|
+
if (item.type?.indexOf('example') === -1) {
|
|
28
32
|
return false;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// TODO(burdon): Generalize.
|
|
32
36
|
const text = item.model.getProperty('name');
|
|
33
37
|
return match(search, text);
|
|
34
|
-
});
|
|
38
|
+
}), [search]);
|
|
35
39
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Entity, Selection } from '@dxos/client';
|
|
8
8
|
import { Falsy } from '@dxos/util';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -15,27 +15,32 @@ import { Falsy } from '@dxos/util';
|
|
|
15
15
|
* apart from changes in ECHO database itself, must be passed to deps array
|
|
16
16
|
* for updates to work correctly.
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param selection Selection from which to query data. Can be falsy - in that case the hook will return undefined.
|
|
19
19
|
* @param deps Array of values that trigger the selector when changed.
|
|
20
20
|
*/
|
|
21
|
-
export function useSelection<T
|
|
22
|
-
|
|
21
|
+
export function useSelection<T extends Entity<any>> (
|
|
22
|
+
selection: Selection<T> | Falsy,
|
|
23
23
|
deps: readonly any[] = []
|
|
24
|
-
): T | undefined {
|
|
25
|
-
const [
|
|
24
|
+
): T[] | undefined {
|
|
25
|
+
const [result, setResult] = useState(() => selection ? selection.query() : undefined);
|
|
26
|
+
const [data, setData] = useState(() => result ? result.result : undefined);
|
|
26
27
|
|
|
27
|
-
// Update
|
|
28
|
+
// Update selection when the query or customs deps change.
|
|
28
29
|
useEffect(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const newResult = selection ? selection.query() : undefined;
|
|
31
|
+
const newData = newResult ? newResult.result : undefined;
|
|
32
|
+
setResult(newResult);
|
|
33
|
+
setData(newData);
|
|
34
|
+
}, [!!selection, !!selection && selection.root, ...deps]);
|
|
35
|
+
|
|
36
|
+
// Update data when database updates.
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (result) {
|
|
39
|
+
return result.update.on(newData => {
|
|
40
|
+
setData(newData);
|
|
32
41
|
});
|
|
33
|
-
setData(selectionResult.getValue());
|
|
34
|
-
return unsub;
|
|
35
|
-
} else {
|
|
36
|
-
setData(undefined);
|
|
37
42
|
}
|
|
38
|
-
},
|
|
43
|
+
}, [result]);
|
|
39
44
|
|
|
40
45
|
return data;
|
|
41
46
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { useSubscription } from 'use-subscription';
|
|
7
7
|
|
|
8
|
-
import { ResultSet } from '@dxos/
|
|
8
|
+
import { ResultSet } from '@dxos/client';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A convenience hook used for subscribing to changing values of a result set.
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
|
|
11
|
-
import { Invitation } from '@dxos/client';
|
|
12
|
-
import { InvitationDescriptor } from '@dxos/echo-db';
|
|
11
|
+
import { Invitation, InvitationDescriptor } from '@dxos/client';
|
|
13
12
|
|
|
14
13
|
import {
|
|
15
14
|
ClientProvider,
|
|
@@ -6,7 +6,7 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Box } from '@mui/material';
|
|
8
8
|
|
|
9
|
-
import { Client,
|
|
9
|
+
import { Client, Party } from '@dxos/client';
|
|
10
10
|
|
|
11
11
|
import { useProfile } from '../../src';
|
|
12
12
|
import { JsonPanel } from './JsonPanel';
|
|
@@ -18,7 +18,7 @@ export const ClientPanel = ({
|
|
|
18
18
|
}: {
|
|
19
19
|
client: Client,
|
|
20
20
|
profile?: Partial<ReturnType<typeof useProfile>>,
|
|
21
|
-
parties?:
|
|
21
|
+
parties?: Party[]
|
|
22
22
|
}) => {
|
|
23
23
|
const data = (parties.length !== 0) ? { parties: parties.map(({ key }) => key.toHex()) } : undefined;
|
|
24
24
|
|
|
@@ -8,9 +8,8 @@ import {
|
|
|
8
8
|
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
|
|
11
|
-
import { PartyInvitation } from '@dxos/client';
|
|
11
|
+
import { PartyInvitation, InvitationDescriptor } from '@dxos/client';
|
|
12
12
|
import { PublicKey } from '@dxos/crypto';
|
|
13
|
-
import { InvitationDescriptor } from '@dxos/echo-db';
|
|
14
13
|
|
|
15
14
|
import {
|
|
16
15
|
ClientProvider,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Party } from '@dxos/client/src/proto/gen/dxos/client';
|
|
2
|
-
/**
|
|
3
|
-
* Get all Parties available to current user.
|
|
4
|
-
* Requires ClientContext to be set via ClientProvider.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useRemoteParties: () => Party[];
|
|
7
|
-
//# sourceMappingURL=useRemoteParties.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoteParties.d.ts","sourceRoot":"","sources":["../../../../src/hooks/echo-queries/useRemoteParties.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAI/D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,eAY5B,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020 DXOS.org
|
|
4
|
-
//
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useRemoteParties = void 0;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const client_1 = require("../client");
|
|
9
|
-
/**
|
|
10
|
-
* Get all Parties available to current user.
|
|
11
|
-
* Requires ClientContext to be set via ClientProvider.
|
|
12
|
-
*/
|
|
13
|
-
const useRemoteParties = () => {
|
|
14
|
-
const client = (0, client_1.useClient)();
|
|
15
|
-
const [parties, setParties] = (0, react_1.useState)([]);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
const stream = client.services.PartyService.SubscribeParties();
|
|
18
|
-
stream.subscribe(result => { var _a; return setParties((_a = result.parties) !== null && _a !== void 0 ? _a : []); }, console.error);
|
|
19
|
-
return () => stream.close();
|
|
20
|
-
}, []);
|
|
21
|
-
return parties;
|
|
22
|
-
};
|
|
23
|
-
exports.useRemoteParties = useRemoteParties;
|
|
24
|
-
//# sourceMappingURL=useRemoteParties.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoteParties.js","sourceRoot":"","sources":["../../../../src/hooks/echo-queries/useRemoteParties.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,iCAA4C;AAI5C,sCAAsC;AAEtC;;;GAGG;AACI,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC3B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAU,EAAE,CAAC,CAAC;IAEpD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC/D,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,WAAC,OAAA,UAAU,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAA,EAAA,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAE5E,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2020 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Party } from '@dxos/client/src/proto/gen/dxos/client';
|
|
8
|
-
|
|
9
|
-
import { useClient } from '../client';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get all Parties available to current user.
|
|
13
|
-
* Requires ClientContext to be set via ClientProvider.
|
|
14
|
-
*/
|
|
15
|
-
export const useRemoteParties = () => {
|
|
16
|
-
const client = useClient();
|
|
17
|
-
const [parties, setParties] = useState<Party[]>([]);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const stream = client.services.PartyService.SubscribeParties();
|
|
21
|
-
stream.subscribe(result => setParties(result.parties ?? []), console.error);
|
|
22
|
-
|
|
23
|
-
return () => stream.close();
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
|
-
return parties;
|
|
27
|
-
};
|