@dxos/react-client 2.31.2-dev.ab9a89e2 → 2.31.2-dev.b400b683

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/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "2.31.2-dev.ab9a89e2",
3
+ "version": "2.31.2-dev.b400b683",
4
4
  "description": "React client API",
5
5
  "license": "MIT",
6
6
  "author": "DXOS.org",
7
7
  "main": "dist/src/index.js",
8
8
  "types": "dist/src/index.d.ts",
9
9
  "dependencies": {
10
- "@dxos/async": "2.31.2-dev.ab9a89e2",
11
- "@dxos/bot-factory-client": "2.31.2-dev.ab9a89e2",
12
- "@dxos/client": "2.31.2-dev.ab9a89e2",
13
- "@dxos/config": "2.31.2-dev.ab9a89e2",
14
- "@dxos/credentials": "2.31.2-dev.ab9a89e2",
15
- "@dxos/crypto": "2.31.2-dev.ab9a89e2",
16
- "@dxos/debug": "2.31.2-dev.ab9a89e2",
17
- "@dxos/echo-db": "2.31.2-dev.ab9a89e2",
18
- "@dxos/network-manager": "2.31.2-dev.ab9a89e2",
19
- "@dxos/util": "2.31.2-dev.ab9a89e2",
10
+ "@dxos/async": "2.31.2-dev.b400b683",
11
+ "@dxos/bot-factory-client": "2.31.2-dev.b400b683",
12
+ "@dxos/client": "2.31.2-dev.b400b683",
13
+ "@dxos/config": "2.31.2-dev.b400b683",
14
+ "@dxos/credentials": "2.31.2-dev.b400b683",
15
+ "@dxos/crypto": "2.31.2-dev.b400b683",
16
+ "@dxos/debug": "2.31.2-dev.b400b683",
17
+ "@dxos/echo-db": "2.31.2-dev.b400b683",
18
+ "@dxos/network-manager": "2.31.2-dev.b400b683",
19
+ "@dxos/util": "2.31.2-dev.b400b683",
20
20
  "assert": "^2.0.0",
21
21
  "debug": "^4.3.3",
22
22
  "use-subscription": "^1.4.1"
@@ -33,23 +33,19 @@
33
33
  "@types/mocha": "~8.2.2",
34
34
  "@types/node": "^14.0.9",
35
35
  "@types/react": "^17.0.24",
36
- "@types/react-dom": "^17.0.9",
37
36
  "@types/testing-library__jest-dom": "~5.9.5",
38
37
  "@types/use-subscription": "^1.0.0",
39
38
  "eslint": "^7.12.1",
40
39
  "expect": "~27.0.2",
41
40
  "fork-ts-checker-webpack-plugin": "~6.2.5",
42
41
  "level-js": "^5.0.2",
43
- "raf": "^3.4.1",
44
42
  "react": "^17.0.2",
45
43
  "react-dom": "^17.0.2",
46
44
  "react-test-renderer": "^17.0.2",
47
- "typescript": "^4.5.2",
48
- "wait-for-expect": "^3.0.2"
45
+ "typescript": "^4.5.2"
49
46
  },
50
47
  "peerDependencies": {
51
- "react": "*",
52
- "react-dom": "*"
48
+ "react": "*"
53
49
  },
54
50
  "publishConfig": {
55
51
  "access": "public"
@@ -1,2 +0,0 @@
1
- import 'raf/polyfill';
2
- //# sourceMappingURL=useSelection.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSelection.test.d.ts","sourceRoot":"","sources":["../../../../src/hooks/echo-selections/useSelection.test.tsx"],"names":[],"mappings":"AAKA,OAAO,cAAc,CAAC"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- //
3
- // Copyright 2022 DXOS.org
4
- //
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const expect_1 = __importDefault(require("expect"));
10
- require("raf/polyfill");
11
- const react_1 = __importDefault(require("react"));
12
- const react_dom_1 = __importDefault(require("react-dom"));
13
- const test_utils_1 = require("react-dom/test-utils");
14
- const wait_for_expect_1 = __importDefault(require("wait-for-expect"));
15
- const client_1 = require("@dxos/client");
16
- const useSelection_1 = require("./useSelection");
17
- const count = 10;
18
- const TYPE_EXAMPLE = 'example:type/org';
19
- const useTestComponents = async () => {
20
- const config = {};
21
- const client = new client_1.Client(config);
22
- await client.initialize();
23
- await client.halo.createProfile();
24
- const party = await client.echo.createParty();
25
- const items = await Promise.all(Array.from({ length: count }).map(async () => {
26
- return await party.database.createItem({ type: TYPE_EXAMPLE });
27
- }));
28
- (0, expect_1.default)(items.length).toBe(count);
29
- return { client, party };
30
- };
31
- const UseSelectionTestComponent = ({ party }) => {
32
- const items = (0, useSelection_1.useSelection)(party === null || party === void 0 ? void 0 : party.select().filter({ type: TYPE_EXAMPLE }), []);
33
- const addItem = async () => await party.database.createItem({ type: TYPE_EXAMPLE });
34
- return (react_1.default.createElement("ul", { onClick: addItem }, items === null || items === void 0 ? void 0 : items.map(item => react_1.default.createElement("li", { key: item.id }, item.id))));
35
- };
36
- let rootContainer;
37
- beforeEach(() => {
38
- rootContainer = document.createElement('div');
39
- document.body.appendChild(rootContainer);
40
- });
41
- afterEach(() => {
42
- document.body.removeChild(rootContainer);
43
- rootContainer = null;
44
- });
45
- describe.only('useSelection', () => {
46
- it('gets updated items selection', async () => {
47
- const { party } = await useTestComponents();
48
- (0, test_utils_1.act)(() => {
49
- react_dom_1.default.render(react_1.default.createElement(UseSelectionTestComponent, { party: party }), rootContainer);
50
- });
51
- const ul = rootContainer.querySelector('ul');
52
- await (0, wait_for_expect_1.default)(() => {
53
- (0, expect_1.default)(ul.childNodes.length).toEqual(count);
54
- });
55
- ul.click();
56
- await (0, wait_for_expect_1.default)(() => {
57
- (0, expect_1.default)(ul.childNodes.length).toEqual(count + 1);
58
- });
59
- });
60
- });
61
- //# sourceMappingURL=useSelection.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSelection.test.js","sourceRoot":"","sources":["../../../../src/hooks/echo-selections/useSelection.test.tsx"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;AAEF,oDAA4B;AAC5B,wBAAsB;AACtB,kDAA0B;AAC1B,0DAAiC;AACjC,qDAA2C;AAC3C,sEAA4C;AAE5C,yCAA6C;AAE7C,iDAA8C;AAE9C,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,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CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,74 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import expect from 'expect';
6
- import 'raf/polyfill';
7
- import React from 'react';
8
- import ReactDOM from 'react-dom';
9
- import { act } from 'react-dom/test-utils';
10
- import waitForExpect from 'wait-for-expect';
11
-
12
- import { Client, Party } from '@dxos/client';
13
-
14
- import { useSelection } from './useSelection';
15
-
16
- const count = 10;
17
- const TYPE_EXAMPLE = 'example:type/org';
18
-
19
- const useTestComponents = async () => {
20
- const config = {};
21
- const client = new Client(config);
22
- await client.initialize();
23
- await client.halo.createProfile();
24
-
25
- const party = await client.echo.createParty();
26
- const items = await Promise.all(Array.from({ length: count }).map(async () => {
27
- return await party.database.createItem({ type: TYPE_EXAMPLE });
28
- }));
29
- expect(items.length).toBe(count);
30
-
31
- return { client, party };
32
- };
33
-
34
- const UseSelectionTestComponent = ({ party }: { party: Party}) => {
35
- const items = useSelection(party?.select().filter({ type: TYPE_EXAMPLE }), []);
36
-
37
- const addItem = async () => await party.database.createItem({ type: TYPE_EXAMPLE });
38
-
39
- return (
40
- <ul onClick={addItem}>
41
- {items?.map(item => <li key={item.id}>{item.id}</li>)}
42
- </ul>
43
- );
44
- };
45
-
46
- let rootContainer: any;
47
-
48
- beforeEach(() => {
49
- rootContainer = document.createElement('div');
50
- document.body.appendChild(rootContainer);
51
- });
52
-
53
- afterEach(() => {
54
- document.body.removeChild(rootContainer);
55
- rootContainer = null;
56
- });
57
-
58
- describe.only('useSelection', () => {
59
- it('gets updated items selection', async () => {
60
- const { party } = await useTestComponents();
61
- act(() => {
62
- ReactDOM.render(<UseSelectionTestComponent party={party} />, rootContainer);
63
- });
64
-
65
- const ul = rootContainer.querySelector('ul');
66
- await waitForExpect(() => {
67
- expect(ul.childNodes.length).toEqual(count);
68
- });
69
- ul.click();
70
- await waitForExpect(() => {
71
- expect(ul.childNodes.length).toEqual(count + 1);
72
- });
73
- });
74
- });