@dxos/client 2.25.0 → 2.25.1-dev.0ff9b5c9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client",
3
- "version": "2.25.0",
3
+ "version": "2.25.1-dev.0ff9b5c9",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "DXOS.org",
6
6
  "main": "dist/src/index.js",
@@ -10,21 +10,21 @@
10
10
  "src"
11
11
  ],
12
12
  "dependencies": {
13
- "@dxos/async": "2.25.0",
14
- "@dxos/codec-protobuf": "2.25.0",
15
- "@dxos/config": "2.25.0",
16
- "@dxos/credentials": "2.25.0",
17
- "@dxos/crypto": "2.25.0",
18
- "@dxos/debug": "2.25.0",
19
- "@dxos/echo-db": "2.25.0",
20
- "@dxos/echo-protocol": "2.25.0",
21
- "@dxos/feed-store": "2.25.0",
22
- "@dxos/model-factory": "2.25.0",
23
- "@dxos/network-manager": "2.25.0",
24
- "@dxos/object-model": "2.25.0",
25
- "@dxos/proto": "2.25.0",
26
- "@dxos/rpc": "2.25.0",
27
- "@dxos/util": "2.25.0",
13
+ "@dxos/async": "2.25.1-dev.0ff9b5c9",
14
+ "@dxos/codec-protobuf": "2.25.1-dev.0ff9b5c9",
15
+ "@dxos/config": "2.25.1-dev.0ff9b5c9",
16
+ "@dxos/credentials": "2.25.1-dev.0ff9b5c9",
17
+ "@dxos/crypto": "2.25.1-dev.0ff9b5c9",
18
+ "@dxos/debug": "2.25.1-dev.0ff9b5c9",
19
+ "@dxos/echo-db": "2.25.1-dev.0ff9b5c9",
20
+ "@dxos/echo-protocol": "2.25.1-dev.0ff9b5c9",
21
+ "@dxos/feed-store": "2.25.1-dev.0ff9b5c9",
22
+ "@dxos/model-factory": "2.25.1-dev.0ff9b5c9",
23
+ "@dxos/network-manager": "2.25.1-dev.0ff9b5c9",
24
+ "@dxos/object-model": "2.25.1-dev.0ff9b5c9",
25
+ "@dxos/proto": "2.25.1-dev.0ff9b5c9",
26
+ "@dxos/rpc": "2.25.1-dev.0ff9b5c9",
27
+ "@dxos/util": "2.25.1-dev.0ff9b5c9",
28
28
  "@polkadot/keyring": "6.11.1",
29
29
  "@polkadot/util": "6.11.1",
30
30
  "@polkadot/util-crypto": "6.11.1",
@@ -41,7 +41,7 @@
41
41
  "uuid": "^8.3.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@dxos/random-access-multi-storage": "2.25.0",
44
+ "@dxos/random-access-multi-storage": "2.25.1-dev.0ff9b5c9",
45
45
  "@dxos/testutils": "2.25.0",
46
46
  "@dxos/toolchain-node-library": "2.25.0",
47
47
  "@types/debug": "^4.1.7",
@@ -63,7 +63,9 @@ export class EchoProxy {
63
63
  /**
64
64
  * @internal
65
65
  */
66
- _open () {
66
+ async _open () {
67
+ const gotParties = this._partiesChanged.waitForCount(1);
68
+
67
69
  const partiesStream = this._serviceProvider.services.PartyService.SubscribeParties();
68
70
  partiesStream.subscribe(async data => {
69
71
  for (const party of data.parties ?? []) {
@@ -94,6 +96,8 @@ export class EchoProxy {
94
96
  this._partiesChanged.emit();
95
97
  }, () => {});
96
98
  this._subscriptions.push(() => partiesStream.close());
99
+
100
+ await gotParties;
97
101
  }
98
102
 
99
103
  /**
@@ -133,7 +133,10 @@ export class HaloProxy extends InvitationProxy {
133
133
  *
134
134
  * @internal
135
135
  */
136
- _open () {
136
+ async _open () {
137
+ const gotProfile = this._profileChanged.waitForCount(1);
138
+ const gotContacts = this._contactsChanged.waitForCount(1);
139
+
137
140
  const profileStream = this._serviceProvider.services.ProfileService.SubscribeProfile();
138
141
  profileStream.subscribe(data => {
139
142
  this._profile = data.profile;
@@ -147,6 +150,8 @@ export class HaloProxy extends InvitationProxy {
147
150
  this._contactsChanged.emit();
148
151
  }, () => {});
149
152
  this._subscriptions.push(() => contactsStream.close());
153
+
154
+ await Promise.all([gotProfile, gotContacts]);
150
155
  }
151
156
 
152
157
  /**
@@ -5,7 +5,7 @@
5
5
  import { PublicKey } from '@dxos/crypto';
6
6
  import { failUndefined } from '@dxos/debug';
7
7
  import {
8
- ActivationOptions, Database, PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, RemoteDatabaseBackend
8
+ ActivationOptions, Database, PARTY_ITEM_TYPE, PARTY_TITLE_PROPERTY, RemoteDatabaseBackend, RootSelector
9
9
  } from '@dxos/echo-db';
10
10
  import { PartyKey } from '@dxos/echo-protocol';
11
11
  import { ModelFactory } from '@dxos/model-factory';
@@ -125,6 +125,13 @@ export class Party extends InvitationProxy {
125
125
  });
126
126
  }
127
127
 
128
+ /**
129
+ * Returns a selection context, which can be used to traverse the object graph.
130
+ */
131
+ get select (): RootSelector {
132
+ return this.database.select.bind(this.database);
133
+ }
134
+
128
135
  /**
129
136
  * Creates an invitation to a given party.
130
137
  * The Invitation flow requires the inviter and invitee to be online at the same time.
@@ -164,7 +171,7 @@ export class Party extends InvitationProxy {
164
171
  }
165
172
 
166
173
  private getPropertiesItem () {
167
- const items = this.database.select(s => s.filter({ type: PARTY_ITEM_TYPE }).items).getValue();
174
+ const items = this.database.select({ type: PARTY_ITEM_TYPE }).query().result;
168
175
  return items[0];
169
176
  }
170
177
 
@@ -309,8 +309,8 @@ describe('Client', () => {
309
309
  client.registerModel(TestModel);
310
310
 
311
311
  const party = client.echo.queryParties().first;
312
- const selection = party.database.select(s => s.filter({ type: 'test' }).items);
313
- await selection.update.waitForCondition(() => selection.getValue().length > 0);
312
+ const selection = party.database.select({ type: 'test' }).query();
313
+ await selection.update.waitForCondition(() => selection.result.length > 0);
314
314
 
315
315
  const item = selection.expectOne();
316
316
 
@@ -169,8 +169,8 @@ export class Client {
169
169
  this._halo = new HaloProxy(this._serviceProvider);
170
170
  this._echo = new EchoProxy(this._serviceProvider);
171
171
 
172
- this._halo._open();
173
- this._echo._open();
172
+ await this._halo._open();
173
+ await this._echo._open();
174
174
 
175
175
  this._initialized = true; // TODO(burdon): Initialized === halo.initialized?
176
176
  clearInterval(timeout);
@@ -24,6 +24,11 @@ export class HaloService implements IHaloService {
24
24
  return resultSetToStream(this.echo.halo.queryContacts(), (contacts): Contacts => ({ contacts }));
25
25
  } else {
26
26
  return new Stream(({ next }) => {
27
+ // If profile does not exist, send an empty array.
28
+ if (!this.echo.halo.isInitialized) {
29
+ next({ contacts: [] });
30
+ }
31
+
27
32
  const subGroup = new SubscriptionGroup();
28
33
 
29
34
  setImmediate(async () => {
@@ -19,7 +19,7 @@ const getData = (echo: DevtoolsServiceDependencies['echo']): SubscribeToItemsRes
19
19
  items: []
20
20
  };
21
21
 
22
- const items = party.database.select(selection => selection.items).getValue();
22
+ const { result: items } = party.database.select().query();
23
23
  for (const item of items) {
24
24
  partyInfo.items.push({
25
25
  id: item.id,
@@ -48,7 +48,7 @@ export const subscribeToItems = ({ echo }: DevtoolsServiceDependencies) => {
48
48
  const unsubscribe = echo.queryParties().subscribe((parties) => {
49
49
  parties.forEach(party => {
50
50
  if (!partySubscriptions[party.key.toHex()]) {
51
- const sub = party.database.select(selection => selection.items).update.on(() => {
51
+ const sub = party.database.select().query().update.on(() => {
52
52
  // Send updates on items changes.
53
53
  update();
54
54
  });